Java Code Examples for net.minecraft.entity.EntityLivingBase

The following are top voted examples for showing how to use net.minecraft.entity.EntityLivingBase. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: BaseClient   File: BlockFarmland.java   View source code 6 votes vote down vote up
/**
 * Block's chance to react to a living entity falling on it.
 */
public void onFallenUpon(World worldIn, BlockPos pos, Entity entityIn, float fallDistance)
{
    if (entityIn instanceof EntityLivingBase)
    {
        if (!worldIn.isRemote && worldIn.rand.nextFloat() < fallDistance - 0.5F)
        {
            if (!(entityIn instanceof EntityPlayer) && !worldIn.getGameRules().getBoolean("mobGriefing"))
            {
                return;
            }

            worldIn.setBlockState(pos, Blocks.dirt.getDefaultState());
        }

        super.onFallenUpon(worldIn, pos, entityIn, fallDistance);
    }
}
 
Example 2
Project: DecompiledMinecraft   File: Village.java   View source code 6 votes vote down vote up
public EntityPlayer getNearestTargetPlayer(EntityLivingBase villageDefender)
{
    double d0 = Double.MAX_VALUE;
    EntityPlayer entityplayer = null;

    for (String s : this.playerReputation.keySet())
    {
        if (this.isPlayerReputationTooLow(s))
        {
            EntityPlayer entityplayer1 = this.worldObj.getPlayerEntityByName(s);

            if (entityplayer1 != null)
            {
                double d1 = entityplayer1.getDistanceSqToEntity(villageDefender);

                if (d1 <= d0)
                {
                    entityplayer = entityplayer1;
                    d0 = d1;
                }
            }
        }
    }

    return entityplayer;
}
 
Example 3
Project: BaseClient   File: EntityAIAttackOnCollide.java   View source code 6 votes vote down vote up
/**
 * Returns whether the EntityAIBase should begin execution.
 */
public boolean shouldExecute()
{
    EntityLivingBase entitylivingbase = this.attacker.getAttackTarget();

    if (entitylivingbase == null)
    {
        return false;
    }
    else if (!entitylivingbase.isEntityAlive())
    {
        return false;
    }
    else if (this.classTarget != null && !this.classTarget.isAssignableFrom(entitylivingbase.getClass()))
    {
        return false;
    }
    else
    {
        this.entityPathEntity = this.attacker.getNavigator().getPathToEntityLiving(entitylivingbase);
        return this.entityPathEntity != null;
    }
}
 
Example 4
Project: Backmemed   File: WorldServer.java   View source code 6 votes vote down vote up
protected BlockPos adjustPosToNearbyEntity(BlockPos pos)
{
    BlockPos blockpos = this.getPrecipitationHeight(pos);
    AxisAlignedBB axisalignedbb = (new AxisAlignedBB(blockpos, new BlockPos(blockpos.getX(), this.getHeight(), blockpos.getZ()))).expandXyz(3.0D);
    List<EntityLivingBase> list = this.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb, new Predicate<EntityLivingBase>()
    {
        public boolean apply(@Nullable EntityLivingBase p_apply_1_)
        {
            return p_apply_1_ != null && p_apply_1_.isEntityAlive() && WorldServer.this.canSeeSky(p_apply_1_.getPosition());
        }
    });

    if (!list.isEmpty())
    {
        return ((EntityLivingBase)list.get(this.rand.nextInt(list.size()))).getPosition();
    }
    else
    {
        if (blockpos.getY() == -1)
        {
            blockpos = blockpos.up(2);
        }

        return blockpos;
    }
}
 
Example 5
Project: BaseClient   File: NetHandlerPlayClient.java   View source code 6 votes vote down vote up
public void handleCombatEvent(S42PacketCombatEvent packetIn) {
	PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
	Entity entity = this.clientWorldController.getEntityByID(packetIn.field_179775_c);
	EntityLivingBase entitylivingbase = entity instanceof EntityLivingBase ? (EntityLivingBase) entity : null;

	if (packetIn.eventType == S42PacketCombatEvent.Event.END_COMBAT) {
		long i = (long) (1000 * packetIn.field_179772_d / 20);
		MetadataCombat metadatacombat = new MetadataCombat(this.gameController.thePlayer, entitylivingbase);
		this.gameController.getTwitchStream().func_176026_a(metadatacombat, 0L - i, 0L);
	} else if (packetIn.eventType == S42PacketCombatEvent.Event.ENTITY_DIED) {
		Entity entity1 = this.clientWorldController.getEntityByID(packetIn.field_179774_b);

		if (entity1 instanceof EntityPlayer) {
			MetadataPlayerDeath metadataplayerdeath = new MetadataPlayerDeath((EntityPlayer) entity1,
					entitylivingbase);
			metadataplayerdeath.func_152807_a(packetIn.deathMessage);
			this.gameController.getTwitchStream().func_152911_a(metadataplayerdeath, 0L);
		}
	}
}
 
Example 6
Project: Backmemed   File: EntityAISit.java   View source code 6 votes vote down vote up
/**
 * Returns whether the EntityAIBase should begin execution.
 */
public boolean shouldExecute()
{
    if (!this.theEntity.isTamed())
    {
        return false;
    }
    else if (this.theEntity.isInWater())
    {
        return false;
    }
    else if (!this.theEntity.onGround)
    {
        return false;
    }
    else
    {
        EntityLivingBase entitylivingbase = this.theEntity.getOwner();
        return entitylivingbase == null ? true : (this.theEntity.getDistanceSqToEntity(entitylivingbase) < 144.0D && entitylivingbase.getAITarget() != null ? false : this.isSitting);
    }
}
 
Example 7
Project: DecompiledMinecraft   File: EntityAITarget.java   View source code 6 votes vote down vote up
/**
 * Checks to see if this entity can find a short path to the given target.
 */
private boolean canEasilyReach(EntityLivingBase p_75295_1_)
{
    this.targetSearchDelay = 10 + this.taskOwner.getRNG().nextInt(5);
    PathEntity pathentity = this.taskOwner.getNavigator().getPathToEntityLiving(p_75295_1_);

    if (pathentity == null)
    {
        return false;
    }
    else
    {
        PathPoint pathpoint = pathentity.getFinalPathPoint();

        if (pathpoint == null)
        {
            return false;
        }
        else
        {
            int i = pathpoint.xCoord - MathHelper.floor_double(p_75295_1_.posX);
            int j = pathpoint.zCoord - MathHelper.floor_double(p_75295_1_.posZ);
            return (double)(i * i + j * j) <= 2.25D;
        }
    }
}
 
Example 8
Project: Melodium   File: SongHunt.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void handleBounty(LootingLevelEvent event) {
	EntityLivingBase target = event.getEntityLiving();
	EntityLivingBase attacker = target.getAttackingEntity();
	if (attacker instanceof EntityPlayer) {
		EntityPlayer player = (EntityPlayer) attacker;
		Collection<PotionEffect> potions = player.getActivePotionEffects();
		for (PotionEffect potion : potions) {
			if (potion.getPotion() instanceof PotionHunt) {
				PotionHunt huntPotion = (PotionHunt) potion.getPotion();
				if (huntPotion.appliesTo(target)) {
					event.setLootingLevel(event.getLootingLevel() + 2);

					return;
				}
			}
		}
	}
}
 
Example 9
Project: BaseClient   File: EntityGuardian.java   View source code 6 votes vote down vote up
public EntityGuardian(World worldIn)
{
    super(worldIn);
    this.experienceValue = 10;
    this.setSize(0.85F, 0.85F);
    this.tasks.addTask(4, new EntityGuardian.AIGuardianAttack(this));
    EntityAIMoveTowardsRestriction entityaimovetowardsrestriction;
    this.tasks.addTask(5, entityaimovetowardsrestriction = new EntityAIMoveTowardsRestriction(this, 1.0D));
    this.tasks.addTask(7, this.wander = new EntityAIWander(this, 1.0D, 80));
    this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
    this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityGuardian.class, 12.0F, 0.01F));
    this.tasks.addTask(9, new EntityAILookIdle(this));
    this.wander.setMutexBits(3);
    entityaimovetowardsrestriction.setMutexBits(3);
    this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityLivingBase.class, 10, true, false, new EntityGuardian.GuardianTargetSelector(this)));
    this.moveHelper = new EntityGuardian.GuardianMoveHelper(this);
    this.field_175484_c = this.field_175482_b = this.rand.nextFloat();
}
 
Example 10
Project: BaseClient   File: ItemDye.java   View source code 6 votes vote down vote up
/**
 * Returns true if the item can be used on the given entity, e.g. shears on sheep.
 */
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer playerIn, EntityLivingBase target)
{
    if (target instanceof EntitySheep)
    {
        EntitySheep entitysheep = (EntitySheep)target;
        EnumDyeColor enumdyecolor = EnumDyeColor.byDyeDamage(stack.getMetadata());

        if (!entitysheep.getSheared() && entitysheep.getFleeceColor() != enumdyecolor)
        {
            entitysheep.setFleeceColor(enumdyecolor);
            --stack.stackSize;
        }

        return true;
    }
    else
    {
        return false;
    }
}
 
Example 11
Project: BaseClient   File: BlockLever.java   View source code 6 votes vote down vote up
/**
 * Called by ItemBlocks just before a block is actually set in the world, to
 * allow for adjustments to the IBlockstate
 */
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ,
		int meta, EntityLivingBase placer) {
	IBlockState iblockstate = this.getDefaultState().withProperty(POWERED, Boolean.valueOf(false));

	if (func_181090_a(worldIn, pos, facing.getOpposite())) {
		return iblockstate.withProperty(FACING,
				BlockLever.EnumOrientation.forFacings(facing, placer.getHorizontalFacing()));
	} else {
		for (Object enumfacing0 : EnumFacing.Plane.HORIZONTAL) {
			EnumFacing enumfacing = (EnumFacing) enumfacing0;
			if (enumfacing != facing && func_181090_a(worldIn, pos, enumfacing.getOpposite())) {
				return iblockstate.withProperty(FACING,
						BlockLever.EnumOrientation.forFacings(enumfacing, placer.getHorizontalFacing()));
			}
		}

		if (World.doesBlockHaveSolidTopSurface(worldIn, pos.down())) {
			return iblockstate.withProperty(FACING,
					BlockLever.EnumOrientation.forFacings(EnumFacing.UP, placer.getHorizontalFacing()));
		} else {
			return iblockstate;
		}
	}
}
 
Example 12
Project: Backmemed   File: EntityPolarBear.java   View source code 6 votes vote down vote up
public boolean shouldExecute()
{
    if (EntityPolarBear.this.isChild())
    {
        return false;
    }
    else
    {
        if (super.shouldExecute())
        {
            for (EntityPolarBear entitypolarbear : EntityPolarBear.this.world.getEntitiesWithinAABB(EntityPolarBear.class, EntityPolarBear.this.getEntityBoundingBox().expand(8.0D, 4.0D, 8.0D)))
            {
                if (entitypolarbear.isChild())
                {
                    return true;
                }
            }
        }

        EntityPolarBear.this.setAttackTarget((EntityLivingBase)null);
        return false;
    }
}
 
Example 13
Project: CustomWorldGen   File: LayerHeldItem.java   View source code 6 votes vote down vote up
public void doRenderLayer(EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale)
{
    boolean flag = entitylivingbaseIn.getPrimaryHand() == EnumHandSide.RIGHT;
    ItemStack itemstack = flag ? entitylivingbaseIn.getHeldItemOffhand() : entitylivingbaseIn.getHeldItemMainhand();
    ItemStack itemstack1 = flag ? entitylivingbaseIn.getHeldItemMainhand() : entitylivingbaseIn.getHeldItemOffhand();

    if (itemstack != null || itemstack1 != null)
    {
        GlStateManager.pushMatrix();

        if (this.livingEntityRenderer.getMainModel().isChild)
        {
            float f = 0.5F;
            GlStateManager.translate(0.0F, 0.625F, 0.0F);
            GlStateManager.rotate(-20.0F, -1.0F, 0.0F, 0.0F);
            GlStateManager.scale(0.5F, 0.5F, 0.5F);
        }

        this.renderHeldItem(entitylivingbaseIn, itemstack1, ItemCameraTransforms.TransformType.THIRD_PERSON_RIGHT_HAND, EnumHandSide.RIGHT);
        this.renderHeldItem(entitylivingbaseIn, itemstack, ItemCameraTransforms.TransformType.THIRD_PERSON_LEFT_HAND, EnumHandSide.LEFT);
        GlStateManager.popMatrix();
    }
}
 
Example 14
Project: MakeClayValuableAgain   File: ClayProgressionImprovements.java   View source code 5 votes vote down vote up
@SubscribeEvent
public void onSkeletonDeath(LivingDeathEvent event) {
    EntityLivingBase entity = event.getEntityLiving();
    Entity sourceOfDamage = event.getSource().getSourceOfDamage();
    if (entity instanceof EntitySkeleton && sourceOfDamage instanceof EntityPlayer &&
      entity.isServerWorld()) {
        spawnWitherSkeleton(entity.getEntityWorld(), entity.getPosition());
        destroyHeldTool((EntityPlayer) sourceOfDamage);
    }
}
 
Example 15
Project: Backmemed   File: EnchantmentFrostWalker.java   View source code 5 votes vote down vote up
public static void freezeNearby(EntityLivingBase living, World worldIn, BlockPos pos, int level)
{
    if (living.onGround)
    {
        float f = (float)Math.min(16, 2 + level);
        BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(0, 0, 0);

        for (BlockPos.MutableBlockPos blockpos$mutableblockpos1 : BlockPos.getAllInBoxMutable(pos.add((double)(-f), -1.0D, (double)(-f)), pos.add((double)f, -1.0D, (double)f)))
        {
            if (blockpos$mutableblockpos1.distanceSqToCenter(living.posX, living.posY, living.posZ) <= (double)(f * f))
            {
                blockpos$mutableblockpos.setPos(blockpos$mutableblockpos1.getX(), blockpos$mutableblockpos1.getY() + 1, blockpos$mutableblockpos1.getZ());
                IBlockState iblockstate = worldIn.getBlockState(blockpos$mutableblockpos);

                if (iblockstate.getMaterial() == Material.AIR)
                {
                    IBlockState iblockstate1 = worldIn.getBlockState(blockpos$mutableblockpos1);

                    if (iblockstate1.getMaterial() == Material.WATER && ((Integer)iblockstate1.getValue(BlockLiquid.LEVEL)).intValue() == 0 && worldIn.func_190527_a(Blocks.FROSTED_ICE, blockpos$mutableblockpos1, false, EnumFacing.DOWN, (Entity)null))
                    {
                        worldIn.setBlockState(blockpos$mutableblockpos1, Blocks.FROSTED_ICE.getDefaultState());
                        worldIn.scheduleUpdate(blockpos$mutableblockpos1.toImmutable(), Blocks.FROSTED_ICE, MathHelper.getInt(living.getRNG(), 60, 120));
                    }
                }
            }
        }
    }
}
 
Example 16
Project: Backmemed   File: EntityGuardian.java   View source code 5 votes vote down vote up
@Nullable
public EntityLivingBase getTargetedEntity()
{
    if (!this.hasTargetedEntity())
    {
        return null;
    }
    else if (this.world.isRemote)
    {
        if (this.targetedEntity != null)
        {
            return this.targetedEntity;
        }
        else
        {
            Entity entity = this.world.getEntityByID(((Integer)this.dataManager.get(TARGET_ENTITY)).intValue());

            if (entity instanceof EntityLivingBase)
            {
                this.targetedEntity = (EntityLivingBase)entity;
                return this.targetedEntity;
            }
            else
            {
                return null;
            }
        }
    }
    else
    {
        return this.getAttackTarget();
    }
}
 
Example 17
Project: ToughExpansion   File: ItemTempRegulator.java   View source code 5 votes vote down vote up
@Override
@Method(modid = MODID_BAUBLES)
public void onWornTick(ItemStack stack, EntityLivingBase player) {
	if (!player.getEntityWorld().isRemote) {
		doTick(player, stack);
	}
}
 
Example 18
Project: DecompiledMinecraft   File: RenderManager.java   View source code 5 votes vote down vote up
public void cacheActiveRenderInfo(World worldIn, FontRenderer textRendererIn, Entity livingPlayerIn, Entity pointedEntityIn, GameSettings optionsIn, float partialTicks)
{
    this.worldObj = worldIn;
    this.options = optionsIn;
    this.livingPlayer = livingPlayerIn;
    this.pointedEntity = pointedEntityIn;
    this.textRenderer = textRendererIn;

    if (livingPlayerIn instanceof EntityLivingBase && ((EntityLivingBase)livingPlayerIn).isPlayerSleeping())
    {
        IBlockState iblockstate = worldIn.getBlockState(new BlockPos(livingPlayerIn));
        Block block = iblockstate.getBlock();

        if (block == Blocks.bed)
        {
            int i = ((EnumFacing)iblockstate.getValue(BlockBed.FACING)).getHorizontalIndex();
            this.playerViewY = (float)(i * 90 + 180);
            this.playerViewX = 0.0F;
        }
    }
    else
    {
        this.playerViewY = livingPlayerIn.prevRotationYaw + (livingPlayerIn.rotationYaw - livingPlayerIn.prevRotationYaw) * partialTicks;
        this.playerViewX = livingPlayerIn.prevRotationPitch + (livingPlayerIn.rotationPitch - livingPlayerIn.prevRotationPitch) * partialTicks;
    }

    if (optionsIn.thirdPersonView == 2)
    {
        this.playerViewY += 180.0F;
    }

    this.viewerPosX = livingPlayerIn.lastTickPosX + (livingPlayerIn.posX - livingPlayerIn.lastTickPosX) * (double)partialTicks;
    this.viewerPosY = livingPlayerIn.lastTickPosY + (livingPlayerIn.posY - livingPlayerIn.lastTickPosY) * (double)partialTicks;
    this.viewerPosZ = livingPlayerIn.lastTickPosZ + (livingPlayerIn.posZ - livingPlayerIn.lastTickPosZ) * (double)partialTicks;
}
 
Example 19
Project: CustomWorldGen   File: ItemElytra.java   View source code 5 votes vote down vote up
public ItemElytra()
{
    this.maxStackSize = 1;
    this.setMaxDamage(432);
    this.setCreativeTab(CreativeTabs.TRANSPORTATION);
    this.addPropertyOverride(new ResourceLocation("broken"), new IItemPropertyGetter()
    {
        @SideOnly(Side.CLIENT)
        public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn)
        {
            return ItemElytra.isBroken(stack) ? 0.0F : 1.0F;
        }
    });
    BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(this, ItemArmor.DISPENSER_BEHAVIOR);
}
 
Example 20
Project: DecompiledMinecraft   File: RenderGuardian.java   View source code 5 votes vote down vote up
private Vec3 func_177110_a(EntityLivingBase entityLivingBaseIn, double p_177110_2_, float p_177110_4_)
{
    double d0 = entityLivingBaseIn.lastTickPosX + (entityLivingBaseIn.posX - entityLivingBaseIn.lastTickPosX) * (double)p_177110_4_;
    double d1 = p_177110_2_ + entityLivingBaseIn.lastTickPosY + (entityLivingBaseIn.posY - entityLivingBaseIn.lastTickPosY) * (double)p_177110_4_;
    double d2 = entityLivingBaseIn.lastTickPosZ + (entityLivingBaseIn.posZ - entityLivingBaseIn.lastTickPosZ) * (double)p_177110_4_;
    return new Vec3(d0, d1, d2);
}
 
Example 21
Project: Mods   File: TF2Util.java   View source code 5 votes vote down vote up
public static void attractMobs(EntityLivingBase living, World world) {
	if (!world.isRemote && TF2ConfigVars.shootAttract && world.getDifficulty().getDifficultyId()>1) {
		
		int range=world.getDifficulty()==EnumDifficulty.HARD?60:38;
		for (EntityCreature mob : world.getEntitiesWithinAABB(EntityCreature.class,
				living.getEntityBoundingBox().grow(range, range, range), new Predicate<EntityCreature>() {

					@Override
					public boolean apply(EntityCreature input) {
						// TODO Auto-generated method stub
						return input.getAttackTarget() == null && (input instanceof IMob) && input.isNonBoss();
					}

				})) {
			mob.getLookHelper().setLookPositionWithEntity(mob, 60, 30);
			if (!TF2Util.isOnSameTeam(living, mob)) {
				if (mob.getEntitySenses().canSee(living) || mob.getDistanceSqToEntity(living)<150){
					mob.setAttackTarget(living);
					if(mob.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).getModifier(FOLLOW_MODIFIER)==null)
						mob.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE)
					.applyModifier(new AttributeModifier(FOLLOW_MODIFIER, "Follow Check", 65-mob.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).getAttributeValue(), 0));
					//mob.getNavigator().tryMoveToEntityLiving(living, 1.1f);
					
					mob.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).removeModifier(FOLLOW_MODIFIER);
				}
				
				// CoroUtilPath.tryMoveToEntityLivingLongDist((EntityCreature)mob,
				// living, 1.1D);
				;
			}

		}
	}
}
 
Example 22
Project: Loot-Slash-Conquer   File: EventEntityJoinWorld.java   View source code 5 votes vote down vote up
public static void setAttributeModifiers(EntityLivingBase entity, int level)
{
	AttributeModifier attackDamage = new AttributeModifier(ATTACK_DAMAGE, "attackDamage", level * 0.1, 1);
	AttributeModifier maxHealth = new AttributeModifier(MAX_HEALTH, "maxHealth", level * 0.2, 1);
	
	if (!entity.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).hasModifier(attackDamage))
		entity.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).applyModifier(attackDamage);
	
	if (!entity.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).hasModifier(maxHealth))
	{
		entity.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).applyModifier(maxHealth);
		entity.setHealth(entity.getMaxHealth());
	}
}
 
Example 23
Project: Industrial-Foregoing   File: MobRenderInPrisonHandler.java   View source code 5 votes vote down vote up
@SubscribeEvent
public void onTooltip(RenderTooltipEvent.PostText event) {
    if (event.getStack() == null || event.getStack().isEmpty()) return;
    if (event.getStack().getItem() instanceof MobImprisonmentToolItem && ((MobImprisonmentToolItem) event.getStack().getItem()).containsEntity(event.getStack())) {
        try {
            Entity entity = EntityList.createEntityByID(event.getStack().getTagCompound().getInteger("id"), Minecraft.getMinecraft().world);
            entity.readFromNBT(event.getStack().getTagCompound());
            ItemStackUtils.renderEntity((int) (event.getX() + 15 + entity.width), (int) (event.getY() + 58 + entity.height), 15, 0, 0, (EntityLivingBase) entity);
        } catch (NullPointerException e) {
            e.printStackTrace();
        }
    }

}
 
Example 24
Project: BaseClient   File: Aura.java   View source code 5 votes vote down vote up
private void fakeAttack(final EntityLivingBase ent) {
    this.fakeSwingItem();
    final float sharpLevel = EnchantmentHelper.func_152377_a(this.mc.thePlayer.getHeldItem(), ent.getCreatureAttribute());
    final boolean vanillaCrit = this.mc.thePlayer.fallDistance > 0.0f && !this.mc.thePlayer.onGround && !this.mc.thePlayer.isOnLadder() && !this.mc.thePlayer.isInWater() && !this.mc.thePlayer.isPotionActive(Potion.blindness) && this.mc.thePlayer.ridingEntity == null;
    if (this.criticals || vanillaCrit) {
        this.mc.thePlayer.onCriticalHit(ent);
    }
    if (sharpLevel > 0.0f) {
        this.mc.thePlayer.onEnchantmentCritical(ent);
    }
    this.pseudoTimer.reset();
}
 
Example 25
Project: Backmemed   File: BlockMagma.java   View source code 5 votes vote down vote up
/**
 * Triggered whenever an entity collides with this block (enters into the block)
 */
public void onEntityWalk(World worldIn, BlockPos pos, Entity entityIn)
{
    if (!entityIn.isImmuneToFire() && entityIn instanceof EntityLivingBase && !EnchantmentHelper.hasFrostWalkerEnchantment((EntityLivingBase)entityIn))
    {
        entityIn.attackEntityFrom(DamageSource.hotFloor, 1.0F);
    }

    super.onEntityWalk(worldIn, pos, entityIn);
}
 
Example 26
Project: TechReborn3   File: BlockRubberLog.java   View source code 5 votes vote down vote up
@Override
public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
	if (!FMLForgePlugin.RUNTIME_DEOBF && placer instanceof EntityPlayer && ((EntityPlayer) placer).isCreative() && placer.isSneaking()) {
		return getDefaultState().withProperty(SAP_SIDE, getSideFromFacing(placer.getHorizontalFacing().getOpposite()));
	}
	return super.getStateForPlacement(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer);
}
 
Example 27
Project: EMC   File: IEntity.java   View source code 5 votes vote down vote up
public boolean instanceOf(EntityType e) {
	// Generic types and players
	if (e.equals(EntityType.ENTITY_PLAYER_SP)) {
		return entity instanceof EntityPlayerSP;
	} else if (e.equals(EntityType.ENTITY_PLAYER)) {
		return entity instanceof EntityPlayer;
	} else if (e.equals(EntityType.ENTITY_LIVING_BASE)) {
		return entity instanceof EntityLivingBase;
	} else if (e.equals(EntityType.ENTITY_LIVING)) {
		return entity instanceof EntityLiving;
	}
	// Mobs
	if (e.equals(EntityType.ENTITY_WOLF)) {
		return entity instanceof EntityWolf;
	} else if (e.equals(EntityType.Entity_Ageable)) {
		return entity instanceof EntityAgeable;
	} else if (e.equals(EntityType.EntityAmbientCreature)) {
		return entity instanceof EntityAmbientCreature;
	} else if (e.equals(EntityType.EntityWaterMob)) {
		return entity instanceof EntityWaterMob;
	} else if (e.equals(EntityType.EntityMob)) {
		return entity instanceof EntityMob;
	} else if (e.equals(EntityType.EntitySlime)) {
		return entity instanceof EntitySlime;
	} else if (e.equals(EntityType.EntityFlying)) {
		return entity instanceof EntityFlying;
	} else if (e.equals(EntityType.EntityGolem)) {
		return entity instanceof EntityGolem;
	} else if (e.equals(EntityType.ENTITY_SPIDER)) {
		return entity instanceof EntitySpider;
	} else if (e.equals(EntityType.ENTITY_SPIDER)) {
		return entity instanceof EntitySpider;
	} else if (e.equals(EntityType.ENTITY_ZOMBIE_PIGMAN)) {
		return entity instanceof EntityZombie;
	} else if (e.equals(EntityType.ENTITY_ENDERMAN)) {
		return entity instanceof EntityEnderman;
	}
	return false;
}
 
Example 28
Project: DecompiledMinecraft   File: EntityMob.java   View source code 5 votes vote down vote up
public boolean attackEntityAsMob(Entity entityIn)
{
    float f = (float)this.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue();
    int i = 0;

    if (entityIn instanceof EntityLivingBase)
    {
        f += EnchantmentHelper.func_152377_a(this.getHeldItem(), ((EntityLivingBase)entityIn).getCreatureAttribute());
        i += EnchantmentHelper.getKnockbackModifier(this);
    }

    boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), f);

    if (flag)
    {
        if (i > 0)
        {
            entityIn.addVelocity((double)(-MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F) * (float)i * 0.5F), 0.1D, (double)(MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F) * (float)i * 0.5F));
            this.motionX *= 0.6D;
            this.motionZ *= 0.6D;
        }

        int j = EnchantmentHelper.getFireAspectModifier(this);

        if (j > 0)
        {
            entityIn.setFire(j * 4);
        }

        this.applyEnchantments(this, entityIn);
    }

    return flag;
}
 
Example 29
Project: Bewitchment   File: ItemBoline.java   View source code 5 votes vote down vote up
@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase target, @Nonnull EntityLivingBase attacker) {
	if (!target.world.isRemote) {
		if (attacker instanceof EntityPlayer)
			target.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) attacker), 5);
		stack.damageItem(1, attacker);
	}
	return true;
}
 
Example 30
Project: BaseClient   File: BlockTNT.java   View source code 5 votes vote down vote up
/**
 * Called When an Entity Collided with the Block
 */
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
{
    if (!worldIn.isRemote && entityIn instanceof EntityArrow)
    {
        EntityArrow entityarrow = (EntityArrow)entityIn;

        if (entityarrow.isBurning())
        {
            this.explode(worldIn, pos, worldIn.getBlockState(pos).withProperty(EXPLODE, Boolean.valueOf(true)), entityarrow.shootingEntity instanceof EntityLivingBase ? (EntityLivingBase)entityarrow.shootingEntity : null);
            worldIn.setBlockToAir(pos);
        }
    }
}
 
Example 31
Project: CustomWorldGen   File: BlockHopper.java   View source code 5 votes vote down vote up
/**
 * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
 * IBlockstate
 */
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
    EnumFacing enumfacing = facing.getOpposite();

    if (enumfacing == EnumFacing.UP)
    {
        enumfacing = EnumFacing.DOWN;
    }

    return this.getDefaultState().withProperty(FACING, enumfacing).withProperty(ENABLED, Boolean.valueOf(true));
}
 
Example 32
Project: Thermionics   File: LayerScarf.java   View source code 5 votes vote down vote up
@Override
public void doRenderLayer(EntityLivingBase entity, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
	//TextureAtlasSprite sprite = Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite();
	//TextureAtlasSprite stone = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("stone");
	//Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
	//GlStateManager.color(1f, 0.0f, 0f);
	//legacyCube(-4,-1,-2.5f, 8, 2, 5f, sprite, true, true, true);
	
	//GlStateManager.pushMatrix();
	//GlStateManager.rotate(TAU/8, 1, 0, 0);
	//legacyCube(0,0,0, 16, 16, 16, sprite, true, true, true);
	
	//GlStateManager.popMatrix();
}
 
Example 33
Project: CustomWorldGen   File: EntityAIAttackMelee.java   View source code 5 votes vote down vote up
/**
 * Returns whether the EntityAIBase should begin execution.
 */
public boolean shouldExecute()
{
    EntityLivingBase entitylivingbase = this.attacker.getAttackTarget();

    if (entitylivingbase == null)
    {
        return false;
    }
    else if (!entitylivingbase.isEntityAlive())
    {
        return false;
    }
    else
    {
        if (canPenalize)
        {
            if (--this.delayCounter <= 0)
            {
                this.entityPathEntity = this.attacker.getNavigator().getPathToEntityLiving(entitylivingbase);
                this.delayCounter = 4 + this.attacker.getRNG().nextInt(7);
                return this.entityPathEntity != null;
            }
            else
            {
                return true;
            }
        }
        this.entityPathEntity = this.attacker.getNavigator().getPathToEntityLiving(entitylivingbase);
        return this.entityPathEntity != null;
    }
}
 
Example 34
Project: WirelessRedstone   File: EntityWirelessTracker.java   View source code 5 votes vote down vote up
@Override
public EntityLivingBase getAttachedEntity()
{
    if(attachedEntity instanceof EntityLivingBase)
        return (EntityLivingBase) attachedEntity;
    return null;
}
 
Example 35
Project: ClientAPI   File: EntityTravelEvent.java   View source code 5 votes vote down vote up
public EntityTravelEvent(EventState state, EntityLivingBase entity, float strafe, float vertical, float forward) {
    this.entity = entity;
    this.state = state;
    this.strafe = strafe;
    this.vertical = vertical;
    this.forward = forward;
}
 
Example 36
Project: DecompiledMinecraft   File: NetHandlerPlayClient.java   View source code 5 votes vote down vote up
/**
 * Updates en entity's attributes and their respective modifiers, which are used for speed bonusses (player
 * sprinting, animals fleeing, baby speed), weapon/tool attackDamage, hostiles followRange randomization, zombie
 * maxHealth and knockback resistance as well as reinforcement spawning chance.
 */
public void handleEntityProperties(S20PacketEntityProperties packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());

    if (entity != null)
    {
        if (!(entity instanceof EntityLivingBase))
        {
            throw new IllegalStateException("Server tried to update attributes of a non-living entity (actually: " + entity + ")");
        }
        else
        {
            BaseAttributeMap baseattributemap = ((EntityLivingBase)entity).getAttributeMap();

            for (S20PacketEntityProperties.Snapshot s20packetentityproperties$snapshot : packetIn.func_149441_d())
            {
                IAttributeInstance iattributeinstance = baseattributemap.getAttributeInstanceByName(s20packetentityproperties$snapshot.func_151409_a());

                if (iattributeinstance == null)
                {
                    iattributeinstance = baseattributemap.registerAttribute(new RangedAttribute((IAttribute)null, s20packetentityproperties$snapshot.func_151409_a(), 0.0D, 2.2250738585072014E-308D, Double.MAX_VALUE));
                }

                iattributeinstance.setBaseValue(s20packetentityproperties$snapshot.func_151410_b());
                iattributeinstance.removeAllModifiers();

                for (AttributeModifier attributemodifier : s20packetentityproperties$snapshot.func_151408_c())
                {
                    iattributeinstance.applyModifier(attributemodifier);
                }
            }
        }
    }
}
 
Example 37
Project: BaseClient   File: EntityPigZombie.java   View source code 5 votes vote down vote up
protected void setEntityAttackTarget(EntityCreature creatureIn, EntityLivingBase entityLivingBaseIn)
{
    super.setEntityAttackTarget(creatureIn, entityLivingBaseIn);

    if (creatureIn instanceof EntityPigZombie)
    {
        ((EntityPigZombie)creatureIn).becomeAngryAt(entityLivingBaseIn);
    }
}
 
Example 38
Project: BaseClient   File: EntityDragon.java   View source code 5 votes vote down vote up
/**
 * Attacks all entities inside this list, dealing 5 hearts of damage.
 */
private void attackEntitiesInList(List<Entity> p_70971_1_)
{
    for (int i = 0; i < p_70971_1_.size(); ++i)
    {
        Entity entity = (Entity)p_70971_1_.get(i);

        if (entity instanceof EntityLivingBase)
        {
            entity.attackEntityFrom(DamageSource.causeMobDamage(this), 10.0F);
            this.applyEnchantments(this, entity);
        }
    }
}
 
Example 39
Project: DecompiledMinecraft   File: EntityAIOwnerHurtTarget.java   View source code 5 votes vote down vote up
/**
 * Execute a one shot task or start executing a continuous task
 */
public void startExecuting()
{
    this.taskOwner.setAttackTarget(this.theTarget);
    EntityLivingBase entitylivingbase = this.theEntityTameable.getOwner();

    if (entitylivingbase != null)
    {
        this.field_142050_e = entitylivingbase.getLastAttackerTime();
    }

    super.startExecuting();
}
 
Example 40
Project: Randores2   File: AbilitySeries.java   View source code 5 votes vote down vote up
public void onArmorHit(EntityLivingBase entity, final EntityLivingBase source) {
    if (!this.armorActive.isEmpty()) {
        AbilityContext context = new AbilityContext(source, entity, AbilityType.ARMOR_ACTIVE);
        RunNextAbility nextAbility = new RunNextAbility(this.armorActive, 0, entity, context, source::getPositionVector);
        nextAbility.run();
    }
}