use of net.minecraft.entity.monster.EntityMob in project SimplyJetpacks by Tonius.
the class LivingTickHandler method mobUseJetpack.
@SubscribeEvent
public void mobUseJetpack(LivingUpdateEvent evt) {
if (!evt.entityLiving.worldObj.isRemote && evt.entityLiving instanceof EntityMob) {
ItemStack armor = evt.entityLiving.getEquipmentInSlot(3);
if (armor != null && armor.getItem() instanceof ItemJetpack) {
ItemJetpack jetpackItem = (ItemJetpack) armor.getItem();
Jetpack jetpack = jetpackItem.getPack(armor);
if (jetpack != null) {
if (jetpack instanceof JetpackPotato || MathHelper.RANDOM.nextInt(3) == 0) {
jetpack.setMobMode(armor);
jetpack.flyUser(evt.entityLiving, armor, jetpackItem, false);
}
}
if (evt.entityLiving.posY > evt.entityLiving.worldObj.getActualHeight() + 10) {
evt.entityLiving.attackEntityFrom(DamageSource.generic, 80);
}
}
}
}
use of net.minecraft.entity.monster.EntityMob in project MineFactoryReloaded by powercrystals.
the class TileEntityVet method activateMachine.
@Override
public boolean activateMachine() {
List<?> entities = worldObj.getEntitiesWithinAABB(EntityLiving.class, _areaManager.getHarvestArea().toAxisAlignedBB());
for (Object o : entities) {
if (!(o instanceof EntityLiving) || o instanceof EntityPlayer || o instanceof EntityMob) {
continue;
}
EntityLiving e = (EntityLiving) o;
for (int i = 0; i < getSizeInventory(); i++) {
ItemStack s = getStackInSlot(i);
if (s != null && s.getItem() instanceof ISyringe) {
if (((ISyringe) s.getItem()).canInject(worldObj, e, s)) {
if (((ISyringe) s.getItem()).inject(worldObj, e, s)) {
s.itemID = MineFactoryReloadedCore.syringeEmptyItem.itemID;
return true;
}
}
}
}
}
setIdleTicks(getIdleTicksMax());
return false;
}
use of net.minecraft.entity.monster.EntityMob in project MineFactoryReloaded by powercrystals.
the class BlockFactoryFluid method onEntityCollidedWithBlock.
@Override
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
if (world.isRemote) {
return;
}
if (entity instanceof EntityPlayer || entity instanceof EntityMob && !((EntityLiving) entity).isEntityUndead()) {
EntityLiving ent = (EntityLiving) entity;
if (blockID == MineFactoryReloadedCore.sludgeLiquid.blockID) {
ent.addPotionEffect(new PotionEffect(Potion.poison.id, 12 * 20, 0));
ent.addPotionEffect(new PotionEffect(Potion.weakness.id, 12 * 20, 0));
ent.addPotionEffect(new PotionEffect(Potion.confusion.id, 12 * 20, 0));
} else if (blockID == MineFactoryReloadedCore.sewageLiquid.blockID) {
ent.addPotionEffect(new PotionEffect(Potion.hunger.id, 12 * 20, 0));
ent.addPotionEffect(new PotionEffect(Potion.poison.id, 12 * 20, 0));
ent.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 12 * 20, 0));
} else if (blockID == MineFactoryReloadedCore.essenceLiquid.blockID) {
ent.addPotionEffect(new PotionEffect(Potion.nightVision.id, 60 * 20, 0));
} else if (blockID == MineFactoryReloadedCore.milkLiquid.blockID) {
ent.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 6 * 20, 0));
} else if (blockID == MineFactoryReloadedCore.biofuelLiquid.blockID) {
ent.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 12 * 20, 0));
}
}
super.onEntityCollidedWithBlock(world, x, y, z, entity);
}
use of net.minecraft.entity.monster.EntityMob in project minecolonies by Minecolonies.
the class ColonyPermissionEventHandler method on.
/**
* AttackEntityEvent handler.
* <p>
* Check, if a player tries to attack an entity..
* Deny if:
* - If the attacking happens in the colony
* - Player is less than officer to the colony.
*
* @param event EntityItemPickupEvent
*/
@SubscribeEvent
public void on(final AttackEntityEvent event) {
if (event.getTarget() instanceof EntityMob) {
return;
}
@NotNull final EntityPlayer player = EntityUtils.getPlayerOfFakePlayer(event.getEntityPlayer(), event.getEntityPlayer().getEntityWorld());
if (Configurations.enableColonyProtection && colony.isCoordInColony(player.getEntityWorld(), player.getPosition())) {
final Permissions perms = colony.getPermissions();
if (event.getTarget() instanceof EntityCitizen) {
final EntityCitizen citizen = (EntityCitizen) event.getTarget();
if (citizen.getColonyJob() instanceof JobGuard && perms.hasPermission(event.getEntityPlayer(), Action.GUARDS_ATTACK)) {
return;
}
if (perms.hasPermission(event.getEntityPlayer(), Action.ATTACK_CITIZEN)) {
return;
}
cancelEvent(event, player);
return;
}
if (!perms.hasPermission(event.getEntityPlayer(), Action.ATTACK_ENTITY)) {
cancelEvent(event, player);
}
}
}
use of net.minecraft.entity.monster.EntityMob in project minecolonies by Minecolonies.
the class EntityAIStructureBuilder method requestEntityToBuildingIfRequired.
/**
* Adds entities to the builder building if he needs it.
*/
private void requestEntityToBuildingIfRequired(final Template.EntityInfo entityInfo) {
if (entityInfo != null) {
final Entity entity = getEntityFromEntityInfoOrNull(entityInfo);
if (entity != null) {
final List<ItemStack> request = new ArrayList<>();
if (entity instanceof EntityItemFrame) {
final ItemStack stack = ((EntityItemFrame) entity).getDisplayedItem();
if (!InventoryUtils.isItemStackEmpty(stack)) {
stack.setCount(1);
request.add(stack);
}
request.add(new ItemStack(Items.ITEM_FRAME, 1));
} else if (entity instanceof EntityArmorStand) {
request.add(entity.getPickedResult(new RayTraceResult(worker)));
entity.getArmorInventoryList().forEach(request::add);
} else if (entity instanceof EntityMob) {
//Don't try to request the monster.
} else {
request.add(entity.getPickedResult(new RayTraceResult(worker)));
}
for (final ItemStack stack : request) {
final BuildingBuilder building = (BuildingBuilder) getOwnBuilding();
if (stack != null && stack.getItem() != null) {
building.addNeededResource(stack, 1);
}
}
}
}
}
Aggregations