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: Backmemed   File: EntityPolarBear.java   Source Code and License 7 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 2
Project: BaseClient   File: BlockFarmland.java   Source Code and License 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 3
Project: BaseClient   File: EntityAIAttackOnCollide.java   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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: Melodium   File: SongHunt.java   Source Code and License 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 8
Project: BaseClient   File: EntityGuardian.java   Source Code and License 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 9
Project: BaseClient   File: ItemDye.java   Source Code and License 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 10
Project: BaseClient   File: BlockLever.java   Source Code and License 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 11
Project: CustomWorldGen   File: LayerHeldItem.java   Source Code and License 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 12
Project: MakeClayValuableAgain   File: ClayProgressionImprovements.java   Source Code and License 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 13
Project: Backmemed   File: EnchantmentFrostWalker.java   Source Code and License 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 14
Project: Backmemed   File: EntityGuardian.java   Source Code and License 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 15
Project: ToughExpansion   File: ItemTempRegulator.java   Source Code and License 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 16
Project: CustomWorldGen   File: ItemElytra.java   Source Code and License 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 17
Project: Mods   File: TF2Util.java   Source Code and License 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 18
Project: Loot-Slash-Conquer   File: EventEntityJoinWorld.java   Source Code and License 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 19
Project: Industrial-Foregoing   File: MobRenderInPrisonHandler.java   Source Code and License 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 20
Project: BaseClient   File: Aura.java   Source Code and License 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 21
Project: Backmemed   File: BlockMagma.java   Source Code and License 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 22
Project: TechReborn3   File: BlockRubberLog.java   Source Code and License 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 23
Project: EMC   File: IEntity.java   Source Code and License 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 24
Project: Bewitchment   File: ItemBoline.java   Source Code and License 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 25
Project: BaseClient   File: BlockTNT.java   Source Code and License 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 26
Project: CustomWorldGen   File: BlockHopper.java   Source Code and License 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 27
Project: Thermionics   File: LayerScarf.java   Source Code and License 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 28
Project: CustomWorldGen   File: EntityAIAttackMelee.java   Source Code and License 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 29
Project: WirelessRedstone   File: EntityWirelessTracker.java   Source Code and License 5 votes vote down vote up
@Override
public EntityLivingBase getAttachedEntity()
{
    if(attachedEntity instanceof EntityLivingBase)
        return (EntityLivingBase) attachedEntity;
    return null;
}
 
Example 30
Project: ClientAPI   File: EntityTravelEvent.java   Source Code and License 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 31
Project: BaseClient   File: EntityPigZombie.java   Source Code and License 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 32
Project: BaseClient   File: EntityDragon.java   Source Code and License 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 33
Project: Randores2   File: AbilitySeries.java   Source Code and License 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();
    }
}
 
Example 34
Project: CustomWorldGen   File: EntitySpider.java   Source Code and License 5 votes vote down vote up
/**
 * Returns whether an in-progress EntityAIBase should continue executing
 */
public boolean continueExecuting()
{
    float f = this.attacker.getBrightness(1.0F);

    if (f >= 0.5F && this.attacker.getRNG().nextInt(100) == 0)
    {
        this.attacker.setAttackTarget((EntityLivingBase)null);
        return false;
    }
    else
    {
        return super.continueExecuting();
    }
}
 
Example 35
Project: CustomWorldGen   File: BlockRedstoneDiode.java   Source Code and License 5 votes vote down vote up
/**
 * Called by ItemBlocks after a block is set in the world, to allow post-place logic
 */
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
    if (this.shouldBePowered(worldIn, pos, state))
    {
        worldIn.scheduleUpdate(pos, this, 1);
    }
}
 
Example 36
Project: BaseClient   File: LayerArmorBase.java   Source Code and License 5 votes vote down vote up
private void renderLayer(EntityLivingBase entitylivingbaseIn, float p_177182_2_, float p_177182_3_, float p_177182_4_, float p_177182_5_, float p_177182_6_, float p_177182_7_, float p_177182_8_, int armorSlot)
{
    ItemStack itemstack = this.getCurrentArmor(entitylivingbaseIn, armorSlot);

    if (itemstack != null && itemstack.getItem() instanceof ItemArmor)
    {
        ItemArmor itemarmor = (ItemArmor)itemstack.getItem();
        T t = this.func_177175_a(armorSlot);
        t.setModelAttributes(this.renderer.getMainModel());
        t.setLivingAnimations(entitylivingbaseIn, p_177182_2_, p_177182_3_, p_177182_4_);
        this.func_177179_a(t, armorSlot);
        boolean flag = this.isSlotForLeggings(armorSlot);
        this.renderer.bindTexture(this.getArmorResource(itemarmor, flag));

        switch (itemarmor.getArmorMaterial())
        {
            case LEATHER:
                int i = itemarmor.getColor(itemstack);
                float f = (float)(i >> 16 & 255) / 255.0F;
                float f1 = (float)(i >> 8 & 255) / 255.0F;
                float f2 = (float)(i & 255) / 255.0F;
                GlStateManager.color(this.colorR * f, this.colorG * f1, this.colorB * f2, this.alpha);
                t.render(entitylivingbaseIn, p_177182_2_, p_177182_3_, p_177182_5_, p_177182_6_, p_177182_7_, p_177182_8_);
                this.renderer.bindTexture(this.getArmorResource(itemarmor, flag, "overlay"));

            case CHAIN:
            case IRON:
            case GOLD:
            case DIAMOND:
                GlStateManager.color(this.colorR, this.colorG, this.colorB, this.alpha);
                t.render(entitylivingbaseIn, p_177182_2_, p_177182_3_, p_177182_5_, p_177182_6_, p_177182_7_, p_177182_8_);

            default:
                if (!this.field_177193_i && itemstack.isItemEnchanted())
                {
                    this.func_177183_a(entitylivingbaseIn, t, p_177182_2_, p_177182_3_, p_177182_4_, p_177182_5_, p_177182_6_, p_177182_7_, p_177182_8_);
                }
        }
    }
}
 
Example 37
Project: ForgeHax   File: ChamsMod.java   Source Code and License 5 votes vote down vote up
public boolean shouldDraw(EntityLivingBase entity) {
    return !entity.equals(MC.player) &&
            !entity.isDead && (
                    (mobs_hostile.get() && EntityUtils.isHostileMob(entity)) || // check this first
                    (players.get() && EntityUtils.isPlayer(entity)) ||
                    (mobs_friendly.get() && EntityUtils.isFriendlyMob(entity))
    );
}
 
Example 38
Project: harshencastle   File: HarshenJaguarArmor.java   Source Code and License 5 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot,
		ModelBiped _default) {
	if (itemStack != null) {
		if (itemStack.getItem() instanceof ItemArmor) {

			EntityEquipmentSlot type = ((ItemArmor) itemStack.getItem()).armorType;
			ModelArmour armorModel = null;
			switch (type) {
			case HEAD:
			case LEGS:
				armorModel = HarshenCastle.proxy.getArmorModel(0);
				break;
			case FEET:
			case CHEST:
				armorModel =  HarshenCastle.proxy.getArmorModel(1);
				break;
			default:
				break;
			}
			
			armorModel.slotActive = armorSlot;
			armorModel.isSneak = _default.isSneak;
			armorModel.isRiding = _default.isRiding;
			armorModel.isChild = _default.isChild;
			armorModel.rightArmPose = _default.rightArmPose;
			armorModel.leftArmPose = _default.leftArmPose;
			return armorModel;
		}
	}
	return null;
}
 
Example 39
Project: BaseClient   File: RenderManager.java   Source Code and License 5 votes vote down vote up
/**
 * Renders the bounding box around an entity when F3+B is pressed
 */
private void renderDebugBoundingBox(Entity entityIn, double p_85094_2_, double p_85094_4_, double p_85094_6_, float p_85094_8_, float p_85094_9_)
{
    GlStateManager.depthMask(false);
    GlStateManager.disableTexture2D();
    GlStateManager.disableLighting();
    GlStateManager.disableCull();
    GlStateManager.disableBlend();
    float f = entityIn.width / 2.0F;
    AxisAlignedBB axisalignedbb = entityIn.getEntityBoundingBox();
    AxisAlignedBB axisalignedbb1 = new AxisAlignedBB(axisalignedbb.minX - entityIn.posX + p_85094_2_, axisalignedbb.minY - entityIn.posY + p_85094_4_, axisalignedbb.minZ - entityIn.posZ + p_85094_6_, axisalignedbb.maxX - entityIn.posX + p_85094_2_, axisalignedbb.maxY - entityIn.posY + p_85094_4_, axisalignedbb.maxZ - entityIn.posZ + p_85094_6_);
    RenderGlobal.func_181563_a(axisalignedbb1, 255, 255, 255, 255);

    if (entityIn instanceof EntityLivingBase)
    {
        float f1 = 0.01F;
        RenderGlobal.func_181563_a(new AxisAlignedBB(p_85094_2_ - (double)f, p_85094_4_ + (double)entityIn.getEyeHeight() - 0.009999999776482582D, p_85094_6_ - (double)f, p_85094_2_ + (double)f, p_85094_4_ + (double)entityIn.getEyeHeight() + 0.009999999776482582D, p_85094_6_ + (double)f), 255, 0, 0, 255);
    }

    Tessellator tessellator = Tessellator.getInstance();
    WorldRenderer worldrenderer = tessellator.getWorldRenderer();
    Vec3 vec3 = entityIn.getLook(p_85094_9_);
    worldrenderer.begin(3, DefaultVertexFormats.POSITION_COLOR);
    worldrenderer.pos(p_85094_2_, p_85094_4_ + (double)entityIn.getEyeHeight(), p_85094_6_).color(0, 0, 255, 255).endVertex();
    worldrenderer.pos(p_85094_2_ + vec3.xCoord * 2.0D, p_85094_4_ + (double)entityIn.getEyeHeight() + vec3.yCoord * 2.0D, p_85094_6_ + vec3.zCoord * 2.0D).color(0, 0, 255, 255).endVertex();
    tessellator.draw();
    GlStateManager.enableTexture2D();
    GlStateManager.enableLighting();
    GlStateManager.enableCull();
    GlStateManager.disableBlend();
    GlStateManager.depthMask(true);
}
 
Example 40
Project: UniversalRemote   File: EntityPlayerMPProxy.java   Source Code and License 5 votes vote down vote up
@Override
public void setRevengeTarget(EntityLivingBase livingBase) {
	if (m_realPlayer == null) {
		super.setRevengeTarget(livingBase);
	} else {
		syncToRealPlayer();
		m_realPlayer.setRevengeTarget(livingBase);
		syncPublicFieldsFromReal();
	}
}
 
Example 41
Project: BaseClient   File: ESP.java   Source Code and License 5 votes vote down vote up
public static void renderFive(final Entity ent) {
    if (!checkValidity((EntityLivingBase)ent)) {
        return;
    }
    GL11.glPolygonOffset(1.0f, 2000000.0f);
    GL11.glDisable(10754);
    GL11.glDisable(2960);
    GL11.glDisable(2848);
    GL11.glHint(3154, 4352);
    GL11.glDisable(3042);
    GL11.glEnable(2896);
    GL11.glEnable(3553);
    GL11.glEnable(3008);
    GL11.glPopAttrib();
}
 
Example 42
Project: Mods   File: ItemAmmo.java   Source Code and License 5 votes vote down vote up
public static void consumeAmmoGlobal(EntityLivingBase living, ItemStack stack, int amount) {
	if (EntityDispenser.isNearDispenser(living.world, living))
		return;
	if (living instanceof EntityTF2Character)
		((EntityTF2Character)living).useAmmo(((ItemWeapon) stack.getItem()).getActualAmmoUse(stack, living, amount));
	if (!(living instanceof EntityPlayer))
		return;
	if (TF2Attribute.getModifier("Metal Ammo", stack, 0, living) != 0) {
		living.getCapability(TF2weapons.WEAPONS_CAP, null).setMetal(living.getCapability(TF2weapons.WEAPONS_CAP, null).getMetal()-amount);
	}
	if (amount > 0) {
		amount = ((ItemWeapon) stack.getItem()).getActualAmmoUse(stack, living, amount);
		// int
		// type=ItemFromData.getData(stack).getInt(PropertyType.AMMO_TYPE);

		// stack.getCount()-=amount;
		ItemStack stackAmmo;
		while (amount > 0 && !(stackAmmo = searchForAmmo(living, stack)).isEmpty()) {
			int inStack;
			if(stackAmmo.getMaxDamage()!=0)
				inStack = stackAmmo.getMaxDamage()-stackAmmo.getItemDamage();
			else
				inStack = stackAmmo.getCount();
			((ItemAmmo) stackAmmo.getItem()).consumeAmmo(living, stackAmmo, amount);
			amount -= inStack;
		}
	}
}
 
Example 43
Project: BaseClient   File: EntityAICreeperSwell.java   Source Code and License 4 votes vote down vote up
/**
 * Returns whether the EntityAIBase should begin execution.
 */
public boolean shouldExecute()
{
    EntityLivingBase entitylivingbase = this.swellingCreeper.getAttackTarget();
    return this.swellingCreeper.getCreeperState() > 0 || entitylivingbase != null && this.swellingCreeper.getDistanceSqToEntity(entitylivingbase) < 9.0D;
}
 
Example 44
Project: Mods   File: TF2EventsClient.java   Source Code and License 4 votes vote down vote up
@SubscribeEvent
public void clientTickEnd(TickEvent.ClientTickEvent event) {

	Minecraft minecraft = Minecraft.getMinecraft();

	if (event.phase == TickEvent.Phase.END) {
		if(Minecraft.getMinecraft().player != null && ClientProxy.reload.isKeyDown() && Minecraft.getMinecraft().currentScreen == null) {
			if(ticksPressedReload++ > 20) {
				Minecraft.getMinecraft().displayGuiScreen(new GuiContracts());
			}
		}
		else {
			ticksPressedReload=0;
		}
		/*
		 * Iterator<Entry<EntityLivingBase,EntityLivingBase>>
		 * iterator=fakeEntities.entrySet().iterator();
		 * while(iterator.hasNext()){
		 * Entry<EntityLivingBase,EntityLivingBase> entry=iterator.next();
		 * EntityLivingBase real=entry.getKey(); EntityLivingBase
		 * fake=entry.getValue(); fake.posX=real.posX; fake.posY=real.posY;
		 * fake.posZ=real.posZ; fake.prevPosX=real.prevPosX;
		 * fake.prevPosY=real.prevPosY; fake.prevPosZ=real.prevPosZ;
		 * fake.rotationPitch=real.rotationPitch;
		 * fake.rotationYaw=real.rotationYaw;
		 * fake.rotationYawHead=real.rotationYawHead;
		 * fake.motionX=real.motionX; fake.motionY=real.motionY;
		 * fake.motionZ=real.motionZ;
		 * //System.out.println("pos: "+fake.posX+" "+fake.posY+" "+fake.
		 * posZ); }
		 */

		Iterator<EntityLivingBase> soundIterator = ClientProxy.soundsToStart.keySet().iterator();
		while (soundIterator.hasNext()) {
			EntityLivingBase living = soundIterator.next();
			
			soundIterator.remove();
		}
		if(TF2ConfigVars.dynamicLights){
			removeSource();
		}
		// ItemUsable.tick(true);
	}
}
 
Example 45
Project: Never-Enough-Currency   File: BlockShelf.java   Source Code and License 4 votes vote down vote up
@Override
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) {
	return getDefaultState().withProperty(FACING, placer.getHorizontalFacing());
}
 
Example 46
Project: EndermanEvolution   File: EntityFrienderman.java   Source Code and License 4 votes vote down vote up
public boolean isOwner(EntityLivingBase entityIn) {
	return entityIn == getOwner();
}
 
Example 47
Project: bit-client   File: CombatManager.java   Source Code and License 4 votes vote down vote up
public EntityLivingBase getCurrentTarget() {
    return currentTarget;
}
 
Example 48
Project: Backmemed   File: BlockVine.java   Source Code and License 4 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(UP, Boolean.valueOf(false)).withProperty(NORTH, Boolean.valueOf(false)).withProperty(EAST, Boolean.valueOf(false)).withProperty(SOUTH, Boolean.valueOf(false)).withProperty(WEST, Boolean.valueOf(false));
    return facing.getAxis().isHorizontal() ? iblockstate.withProperty(getPropertyFor(facing.getOpposite()), Boolean.valueOf(true)) : iblockstate;
}
 
Example 49
Project: Backmemed   File: DamageSource.java   Source Code and License 4 votes vote down vote up
public static DamageSource causeMobDamage(EntityLivingBase mob)
{
    return new EntityDamageSource("mob", mob);
}
 
Example 50
Project: Bewitchment   File: SetehsWastesBrew.java   Source Code and License 4 votes vote down vote up
@Override
public void apply(World world, BlockPos pos, EntityLivingBase entity, int amplifier, int tick) {
	//NO-OP
}
 
Example 51
Project: CustomWorldGen   File: BlockSlab.java   Source Code and License 4 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 = super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer).withProperty(HALF, BlockSlab.EnumBlockHalf.BOTTOM);
    return this.isDouble() ? iblockstate : (facing != EnumFacing.DOWN && (facing == EnumFacing.UP || (double)hitY <= 0.5D) ? iblockstate : iblockstate.withProperty(HALF, BlockSlab.EnumBlockHalf.TOP));
}
 
Example 52
Project: CustomWorldGen   File: ForgeEventFactory.java   Source Code and License 4 votes vote down vote up
public static boolean onUseItemStop(EntityLivingBase entity, ItemStack item, int duration)
{
    return MinecraftForge.EVENT_BUS.post(new LivingEntityUseItemEvent.Stop(entity, item, duration));
}
 
Example 53
Project: connor41-etfuturum2   File: EntityTippedArrow.java   Source Code and License 4 votes vote down vote up
public EntityTippedArrow(World world, EntityLivingBase entity, EntityLivingBase target, float f0, float f1) {
	super(world, entity, target, f0, f1);
}
 
Example 54
Project: rezolve   File: DatabaseServerBlock.java   Source Code and License 4 votes vote down vote up
@Override
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ,
		int meta, EntityLivingBase placer) {
	return getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
}
 
Example 55
Project: BaseClient   File: BlockFurnace.java   Source Code and License 4 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)
{
    return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
}
 
Example 56
Project: Halloween   File: EntityAIHaunter.java   Source Code and License 4 votes vote down vote up
@Override
public boolean shouldExecute()
{
	EntityLivingBase attackTarget = this.taskOwner.getAttackTarget();
	return (attackTarget != null && attackTarget.isEntityAlive() && attackTarget instanceof EntityPlayer);
}
 
Example 57
Project: Randores2   File: AbilitySeries.java   Source Code and License 4 votes vote down vote up
public void onArmorUpdate(EntityLivingBase entity) {
    for (Ability ability : this.armorPassive) {
        ability.apply(entity.getPositionVector(), entity, new AbilityContext(AbilityType.ARMOR_PASSIVE));
    }
}
 
Example 58
Project: CustomWorldGen   File: EntityAITarget.java   Source Code and License 4 votes vote down vote up
/**
 * Resets the task
 */
public void resetTask()
{
    this.taskOwner.setAttackTarget((EntityLivingBase)null);
    this.target = null;
}
 
Example 59
Project: Mods   File: ItemSniperRifle.java   Source Code and License 4 votes vote down vote up
@Override
public boolean canAltFire(World worldObj, EntityLivingBase player, ItemStack item) {
	return super.canAltFire(worldObj, player, item)
			&& player.getCapability(TF2weapons.WEAPONS_CAP, null).fire1Cool <= 0;
}
 
Example 60
Project: Pangu   File: BlockAddLandingEffectsCallback.java   Source Code and License 4 votes vote down vote up
boolean apply(IBlockState arg0, WorldServer arg1, BlockPos arg2, IBlockState arg3,
EntityLivingBase arg4, int arg5);