Search in sources :

Example 96 with EntityLivingBase

use of net.minecraft.entity.EntityLivingBase in project BetterWithAddons by DaedalusGame.

the class ButcherHandler method playerTick.

@SubscribeEvent
public void playerTick(AttackEntityEvent attackEvent) {
    Entity target = attackEvent.getTarget();
    EntityLivingBase attacker = attackEvent.getEntityLiving();
    if (attacker == null || target == null)
        return;
    World world = attacker.getEntityWorld();
    BlockPos pos = EntityUtil.getEntityFloor(target, 2);
    if (!world.isRemote) {
        IBlockState state = world.getBlockState(pos);
        if (isChopBlock(state) && isSuitableWeapon(attacker.getHeldItemMainhand())) {
            attacker.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, 200));
            attacker.addPotionEffect(new PotionEffect(MobEffects.HUNGER, 200));
            splatter(world, pos, 1);
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) IBlockState(net.minecraft.block.state.IBlockState) PotionEffect(net.minecraft.potion.PotionEffect) EntityLivingBase(net.minecraft.entity.EntityLivingBase) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 97 with EntityLivingBase

use of net.minecraft.entity.EntityLivingBase in project BetterWithAddons by DaedalusGame.

the class TerratorialHandler method spawnLiving.

@SubscribeEvent
public void spawnLiving(LivingSpawnEvent.CheckSpawn spawnEvent) {
    World world = spawnEvent.getWorld();
    EntityLivingBase entity = spawnEvent.getEntityLiving();
    Chunk chunk = world.getChunkFromBlockCoords(new BlockPos(spawnEvent.getX(), spawnEvent.getY(), spawnEvent.getZ()));
    if (!chunk.isLoaded())
        return;
    if (entity instanceof EntityZombie || entity instanceof EntitySkeleton || entity instanceof EntityCreeper)
        spawnEvent.setResult(Event.Result.DENY);
}
Also used : EntityCreeper(net.minecraft.entity.monster.EntityCreeper) EntityZombie(net.minecraft.entity.monster.EntityZombie) EntitySkeleton(net.minecraft.entity.monster.EntitySkeleton) EntityLivingBase(net.minecraft.entity.EntityLivingBase) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) Chunk(net.minecraft.world.chunk.Chunk) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 98 with EntityLivingBase

use of net.minecraft.entity.EntityLivingBase in project BetterWithAddons by DaedalusGame.

the class AssortedHandler method livingTick.

@SubscribeEvent
public void livingTick(LivingEvent.LivingUpdateEvent updateEvent) {
    final EntityLivingBase entity = updateEvent.getEntityLiving();
    World world = entity.getEntityWorld();
    UUID uuid = entity.getUniqueID();
    BlockPos pos = entity.getPosition();
    if (!world.isRemote) {
        if (entity.isPotionActive(ModPotions.boss)) {
            if (!BossList.containsKey(uuid)) {
                BossInfoServer displayData = (BossInfoServer) new BossInfoServer(entity.getDisplayName(), Color.PURPLE, Overlay.PROGRESS).setDarkenSky(false);
                BossList.put(uuid, displayData);
                List<EntityPlayerMP> entities = world.getEntitiesWithinAABB(EntityPlayerMP.class, new AxisAlignedBB(pos).expand(24, 24, 24));
                if (entities != null)
                    for (EntityPlayerMP ply : entities) {
                        displayData.addPlayer(ply);
                    }
            } else {
                BossInfoServer bossInfo = BossList.get(uuid);
                bossInfo.setPercent(entity.getHealth() / entity.getMaxHealth());
            }
        } else if (world.getMinecraftServer().getTickCounter() % BossCleanupThreshold == 0 && BossList.containsKey(uuid)) {
            BossInfoServer bossInfo = BossList.get(uuid);
            for (EntityPlayerMP ply : bossInfo.getPlayers()) {
                bossInfo.removePlayer(ply);
            }
            BossList.remove(uuid);
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EntityLivingBase(net.minecraft.entity.EntityLivingBase) BlockPos(net.minecraft.util.math.BlockPos) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) World(net.minecraft.world.World) BossInfoServer(net.minecraft.world.BossInfoServer) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 99 with EntityLivingBase

use of net.minecraft.entity.EntityLivingBase in project Bookshelf by Darkhax-Minecraft.

the class ModelArmorExtended method syncModel.

/**
     * Updates the pose/state of the model to reflect that of the entity it's attatched to.
     *
     * @param entity The entity to sync the model with.
     * @param partialTicks The partial ticks.
     */
private void syncModel(Entity entity, float partialTicks) {
    final EntityLivingBase living = (EntityLivingBase) entity;
    this.isSneak = living != null ? living.isSneaking() : false;
    this.isChild = living != null ? living.isChild() : false;
    if (living != null && living instanceof EntityPlayer) {
        final EntityPlayer player = (EntityPlayer) living;
        final ArmPose poseMainhand = this.getArmPose(player.getHeldItemMainhand(), player);
        final ArmPose poseOffhand = this.getArmPose(player.getHeldItemOffhand(), player);
        final boolean isRightHanded = player.getPrimaryHand() == EnumHandSide.RIGHT;
        this.rightArmPose = isRightHanded ? poseMainhand : poseOffhand;
        this.leftArmPose = isRightHanded ? poseOffhand : poseMainhand;
        this.swingProgress = player.getSwingProgress(partialTicks);
    }
}
Also used : EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 100 with EntityLivingBase

use of net.minecraft.entity.EntityLivingBase in project SecurityCraft by Geforce132.

the class TileEntityClaymore method updateEntity.

public void updateEntity() {
    if (getWorldObj().isRemote) {
        return;
    } else {
        if (getWorldObj().getBlock(xCoord, yCoord, zCoord) == mod_SecurityCraft.claymoreDefused) {
            return;
        }
        if (cooldown > 0) {
            cooldown--;
            return;
        }
        if (cooldown == 0) {
            BlockUtils.destroyBlock(getWorldObj(), xCoord, yCoord, zCoord, false);
            getWorldObj().createExplosion((Entity) null, entityX, entityY + 0.5F, entityZ, 3.5F, true);
            return;
        }
        int meta = getWorldObj().getBlockMetadata(xCoord, yCoord, zCoord);
        AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1);
        if (meta == 3) {
            axisalignedbb = axisalignedbb.addCoord(0, 0, -mod_SecurityCraft.configHandler.claymoreRange);
        } else if (meta == 1) {
            axisalignedbb = axisalignedbb.addCoord(0, 0, mod_SecurityCraft.configHandler.claymoreRange);
        } else if (meta == 2) {
            axisalignedbb = axisalignedbb.addCoord(mod_SecurityCraft.configHandler.claymoreRange, 0, 0);
        } else if (meta == 4) {
            axisalignedbb = axisalignedbb.addCoord(-mod_SecurityCraft.configHandler.claymoreRange, 0, 0);
        }
        List<?> list = getWorldObj().getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb);
        Iterator<?> iterator = list.iterator();
        EntityLivingBase entityliving;
        while (iterator.hasNext()) {
            entityliving = (EntityLivingBase) iterator.next();
            entityX = entityliving.posX;
            entityY = entityliving.posY;
            entityZ = entityliving.posZ;
            cooldown = 20;
            getWorldObj().playSoundEffect(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "random.click", 0.3F, 0.6F);
            break;
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) EntityLivingBase(net.minecraft.entity.EntityLivingBase)

Aggregations

EntityLivingBase (net.minecraft.entity.EntityLivingBase)221 EntityPlayer (net.minecraft.entity.player.EntityPlayer)91 Entity (net.minecraft.entity.Entity)60 ItemStack (net.minecraft.item.ItemStack)33 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)29 PotionEffect (net.minecraft.potion.PotionEffect)21 TileEntity (net.minecraft.tileentity.TileEntity)21 BlockPos (net.minecraft.util.math.BlockPos)21 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)19 Vec3d (net.minecraft.util.math.Vec3d)18 World (net.minecraft.world.World)16 AMVector3 (am2.api.math.AMVector3)15 IArsMagicaBoss (am2.bosses.IArsMagicaBoss)15 IBlockState (net.minecraft.block.state.IBlockState)15 ArrayList (java.util.ArrayList)12 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)12 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)10 EntityDragonPart (net.minecraft.entity.boss.EntityDragonPart)10 Block (net.minecraft.block.Block)9 ExtendedProperties (am2.playerextensions.ExtendedProperties)8