Search in sources :

Example 1 with EntityMob

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);
            }
        }
    }
}
Also used : EntityMob(net.minecraft.entity.monster.EntityMob) JetpackPotato(tonius.simplyjetpacks.item.meta.JetpackPotato) ItemJetpack(tonius.simplyjetpacks.item.ItemPack.ItemJetpack) ItemStack(net.minecraft.item.ItemStack) Jetpack(tonius.simplyjetpacks.item.meta.Jetpack) ItemJetpack(tonius.simplyjetpacks.item.ItemPack.ItemJetpack) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 2 with EntityMob

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;
}
Also used : EntityMob(net.minecraft.entity.monster.EntityMob) EntityLiving(net.minecraft.entity.EntityLiving) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ISyringe(powercrystals.minefactoryreloaded.api.ISyringe) ItemStack(net.minecraft.item.ItemStack)

Example 3 with EntityMob

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);
}
Also used : EntityMob(net.minecraft.entity.monster.EntityMob) EntityLiving(net.minecraft.entity.EntityLiving) PotionEffect(net.minecraft.potion.PotionEffect) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 4 with EntityMob

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);
        }
    }
}
Also used : EntityMob(net.minecraft.entity.monster.EntityMob) Permissions(com.minecolonies.coremod.colony.permissions.Permissions) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityCitizen(com.minecolonies.coremod.entity.EntityCitizen) JobGuard(com.minecolonies.coremod.colony.jobs.JobGuard) NotNull(org.jetbrains.annotations.NotNull) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 5 with EntityMob

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);
                }
            }
        }
    }
}
Also used : EntityMob(net.minecraft.entity.monster.EntityMob) Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) EntityItemFrame(net.minecraft.entity.item.EntityItemFrame) BuildingBuilder(com.minecolonies.coremod.colony.buildings.BuildingBuilder) ArrayList(java.util.ArrayList) RayTraceResult(net.minecraft.util.math.RayTraceResult) EntityArmorStand(net.minecraft.entity.item.EntityArmorStand) ItemStack(net.minecraft.item.ItemStack)

Aggregations

EntityMob (net.minecraft.entity.monster.EntityMob)10 EntityPlayer (net.minecraft.entity.player.EntityPlayer)5 ItemStack (net.minecraft.item.ItemStack)5 ArrayList (java.util.ArrayList)3 Entity (net.minecraft.entity.Entity)2 EntityLiving (net.minecraft.entity.EntityLiving)2 EntityDarkMage (am2.entities.EntityDarkMage)1 EntityLightMage (am2.entities.EntityLightMage)1 BuildingBuilder (com.minecolonies.coremod.colony.buildings.BuildingBuilder)1 JobGuard (com.minecolonies.coremod.colony.jobs.JobGuard)1 Permissions (com.minecolonies.coremod.colony.permissions.Permissions)1 EntityCitizen (com.minecolonies.coremod.entity.EntityCitizen)1 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 SideOnly (cpw.mods.fml.relauncher.SideOnly)1 Iterator (java.util.Iterator)1 Entry (java.util.Map.Entry)1 ITeleportHandler (net.dyeo.teleporter.capabilities.ITeleportHandler)1 TeleporterNode (net.dyeo.teleporter.teleport.TeleporterNode)1 TileEntityTeleporter (net.dyeo.teleporter.tileentity.TileEntityTeleporter)1 IBlockState (net.minecraft.block.state.IBlockState)1