Search in sources :

Example 26 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 27 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 28 with EntityLivingBase

use of net.minecraft.entity.EntityLivingBase in project NewHorizonsCoreMod by GTNewHorizons.

the class CustomDropsHandler method onMobDrops.

@SubscribeEvent
public void onMobDrops(LivingDropsEvent pEvent) {
    try {
        EntityLivingBase tEntity = pEvent.entityLiving;
        UUID tUUID = null;
        EntityPlayer tEP = null;
        if (pEvent.source.getEntity() != null) {
            if (pEvent.source.getEntity() instanceof EntityPlayer) {
                tEP = (EntityPlayer) pEvent.source.getEntity();
                tUUID = tEP.getUniqueID();
                if (_mDeathDebugPlayers.contains(tUUID))
                    PlayerChatHelper.SendInfo(tEP, String.format("Killed entity: [%s]", tEntity.getClass().getName()));
            }
        }
        if (// Not doing anything, only players are valid
        tEP == null)
            return;
        if (// Nope,
        tEP instanceof net.minecraftforge.common.util.FakePlayer)
            // fakeplayers
            return;
        CustomDrop tCustomDrop = _mCustomDrops.FindDropEntry(tEntity);
        // no custom drop defined for this
        if (tCustomDrop == null)
            return;
        // mob, skipping
        HandleCustomDrops(tCustomDrop, tEntity, tEP, pEvent.drops);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : CustomDrop(com.dreammaster.modcustomdrops.CustomDrops.CustomDrop) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) UUID(java.util.UUID) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 29 with EntityLivingBase

use of net.minecraft.entity.EntityLivingBase in project VanillaTeleporter by dyeo.

the class BlockTeleporter method onEntityWalk.

@Override
public void onEntityWalk(World world, BlockPos pos, Entity entity) {
    TeleporterNode destinationNode = null;
    IBlockState state = world.getBlockState(pos);
    EnumType type = EnumType.byMetadata(getMetaFromState(state));
    if (entity instanceof EntityLivingBase && entity.hasCapability(CapabilityTeleportHandler.TELEPORT_CAPABILITY, null)) {
        ITeleportHandler teleportHandler = entity.getCapability(CapabilityTeleportHandler.TELEPORT_CAPABILITY, null);
        if (!world.isRemote) {
            if (teleportHandler.getTeleportStatus() == EnumTeleportStatus.INACTIVE) {
                teleportHandler.setOnTeleporter(entity.getPosition().distanceSq(pos) <= 1);
                teleportHandler.setDimension(entity.dimension);
                if (teleportHandler.getOnTeleporter()) {
                    boolean isHostile = (entity instanceof EntityMob) || (entity instanceof EntityWolf && ((EntityWolf) entity).isAngry());
                    boolean isPassive = (entity instanceof EntityAnimal);
                    if ((isHostile == false || isHostile == ModConfiguration.teleportHostileMobs) && (isPassive == false || isPassive == ModConfiguration.teleportPassiveMobs)) {
                        destinationNode = TeleporterUtility.teleport((EntityLivingBase) entity, pos);
                    }
                }
            }
        }
        if (teleportHandler.getTeleportStatus() == EnumTeleportStatus.INACTIVE) {
            TileEntityTeleporter tEnt = (TileEntityTeleporter) world.getTileEntity(pos);
            if (tEnt != null) {
                tEnt.spawnParticles();
            }
        }
        if (type.isRecall() && entity instanceof EntityPlayerMP && destinationNode != null) {
            WorldServer nextWorld = world.getMinecraftServer().worldServerForDimension(destinationNode.dimension);
            breakBlockRecall(world, nextWorld, pos, destinationNode.pos, state, (EntityPlayerMP) entity);
        }
    }
}
Also used : EntityMob(net.minecraft.entity.monster.EntityMob) IBlockState(net.minecraft.block.state.IBlockState) TeleporterNode(net.dyeo.teleporter.teleport.TeleporterNode) ITeleportHandler(net.dyeo.teleporter.capabilities.ITeleportHandler) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) WorldServer(net.minecraft.world.WorldServer) EntityWolf(net.minecraft.entity.passive.EntityWolf) EntityAnimal(net.minecraft.entity.passive.EntityAnimal) TileEntityTeleporter(net.dyeo.teleporter.tileentity.TileEntityTeleporter)

Example 30 with EntityLivingBase

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

the class EntityKarateZombie method attackEntityFrom.

@Override
public boolean attackEntityFrom(DamageSource source, float amount) {
    EntityLivingBase entity = this.getAttackTarget();
    boolean success = super.attackEntityFrom(source, amount);
    if (success && getCurrentMove() == MartialArts.Disarm && !this.isDead) {
        if (entity == source.getImmediateSource() && entity != null) {
            disarm(entity);
        }
        randomizeMove();
    }
    return success;
}
Also used : EntityLivingBase(net.minecraft.entity.EntityLivingBase)

Aggregations

EntityLivingBase (net.minecraft.entity.EntityLivingBase)594 EntityPlayer (net.minecraft.entity.player.EntityPlayer)201 Entity (net.minecraft.entity.Entity)177 PotionEffect (net.minecraft.potion.PotionEffect)106 ItemStack (net.minecraft.item.ItemStack)88 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)86 BlockPos (net.minecraft.util.math.BlockPos)77 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)77 Vec3d (net.minecraft.util.math.Vec3d)65 World (net.minecraft.world.World)57 IBlockState (net.minecraft.block.state.IBlockState)45 List (java.util.List)38 ArrayList (java.util.ArrayList)37 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)37 TileEntity (net.minecraft.tileentity.TileEntity)37 EntityItem (net.minecraft.entity.item.EntityItem)32 DamageSource (net.minecraft.util.DamageSource)25 Block (net.minecraft.block.Block)24 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)23 WorldServer (net.minecraft.world.WorldServer)23