@Nullable public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata) { livingdata = super.onInitialSpawn(difficulty, livingdata); float f = difficulty.getClampedAdditionalDifficulty(); this.setCanPickUpLoot(false); this.setEquipmentBasedOnDifficulty(difficulty); this.setEnchantmentBasedOnDifficulty(difficulty); this.setCombatTask(); this.getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).applyModifier( new AttributeModifier("Random spawn bonus", this.rand.nextDouble() * 0.05000000074505806D, 0)); double d0 = this.rand.nextDouble() * 1.5D * (double) f; if (d0 > 1.0D) { this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE) .applyModifier(new AttributeModifier("Random zombie-spawn bonus", d0, 2)); } return livingdata; }
/** * Enchants Entity's current equipments based on given DifficultyInstance */ protected void setEnchantmentBasedOnDifficulty(DifficultyInstance difficulty) { float f = difficulty.getClampedAdditionalDifficulty(); if (this.getHeldItem() != null && this.rand.nextFloat() < 0.25F * f) { EnchantmentHelper.addRandomEnchantment(this.rand, this.getHeldItem(), (int)(5.0F + f * (float)this.rand.nextInt(18))); } for (int i = 0; i < 4; ++i) { ItemStack itemstack = this.getCurrentArmor(i); if (itemstack != null && this.rand.nextFloat() < 0.5F * f) { EnchantmentHelper.addRandomEnchantment(this.rand, itemstack, (int)(5.0F + f * (float)this.rand.nextInt(18))); } } }
/** * Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called * when entity is reloaded from nbt. Mainly used for initializing attributes and inventory */ public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData livingdata) { livingdata = super.onInitialSpawn(difficulty, livingdata); int i = this.rand.nextInt(6); boolean flag = false; if (livingdata instanceof EntityRabbit.RabbitTypeData) { i = ((EntityRabbit.RabbitTypeData)livingdata).typeData; flag = true; } else { livingdata = new EntityRabbit.RabbitTypeData(i); } this.setRabbitType(i); if (flag) { this.setGrowingAge(-24000); } return livingdata; }
/** * Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called * when entity is reloaded from nbt. Mainly used for initializing attributes and inventory */ @Nullable public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata) { this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).applyModifier(new AttributeModifier("Random spawn bonus", this.rand.nextGaussian() * 0.05D, 1)); if (this.rand.nextFloat() < 0.05F) { this.setLeftHanded(true); } else { this.setLeftHanded(false); } return livingdata; }
/** * Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called * when entity is reloaded from nbt. Mainly used for initializing attributes and inventory */ public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData livingdata) { if (livingdata instanceof EntityPolarBear.GroupData) { if (((EntityPolarBear.GroupData)livingdata).madeParent) { this.setGrowingAge(-24000); } } else { EntityPolarBear.GroupData entitypolarbear$groupdata = new EntityPolarBear.GroupData(); entitypolarbear$groupdata.madeParent = true; livingdata = entitypolarbear$groupdata; } return (IEntityLivingData)livingdata; }
/** * Gives armor or weapon for entity based on given DifficultyInstance */ protected void setEquipmentBasedOnDifficulty(DifficultyInstance difficulty) { super.setEquipmentBasedOnDifficulty(difficulty); if (this.rand.nextFloat() < (this.worldObj.getDifficulty() == EnumDifficulty.HARD ? 0.05F : 0.01F)) { int i = this.rand.nextInt(3); if (i == 0) { this.setCurrentItemOrArmor(0, new ItemStack(Items.iron_sword)); } else { this.setCurrentItemOrArmor(0, new ItemStack(Items.iron_shovel)); } } }
/** * Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called * when entity is reloaded from nbt. Mainly used for initializing attributes and inventory */ public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData livingdata) { livingdata = super.onInitialSpawn(difficulty, livingdata); if (this.worldObj.rand.nextInt(7) == 0) { for (int i = 0; i < 2; ++i) { EntityOcelot entityocelot = new EntityOcelot(this.worldObj); entityocelot.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F); entityocelot.setGrowingAge(-24000); this.worldObj.spawnEntityInWorld(entityocelot); } } return livingdata; }
private EntitySkeleton createSkeleton(DifficultyInstance p_188514_1_, EntityHorse p_188514_2_) { EntitySkeleton entityskeleton = new EntitySkeleton(p_188514_2_.worldObj); entityskeleton.onInitialSpawn(p_188514_1_, (IEntityLivingData)null); entityskeleton.setPosition(p_188514_2_.posX, p_188514_2_.posY, p_188514_2_.posZ); entityskeleton.hurtResistantTime = 60; entityskeleton.enablePersistence(); if (entityskeleton.getItemStackFromSlot(EntityEquipmentSlot.HEAD) == null) { entityskeleton.setItemStackToSlot(EntityEquipmentSlot.HEAD, new ItemStack(Items.IRON_HELMET)); } EnchantmentHelper.addRandomEnchantment(entityskeleton.getRNG(), entityskeleton.getHeldItemMainhand(), (int)(5.0F + p_188514_1_.getClampedAdditionalDifficulty() * (float)entityskeleton.getRNG().nextInt(18)), false); EnchantmentHelper.addRandomEnchantment(entityskeleton.getRNG(), entityskeleton.getItemStackFromSlot(EntityEquipmentSlot.HEAD), (int)(5.0F + p_188514_1_.getClampedAdditionalDifficulty() * (float)entityskeleton.getRNG().nextInt(18)), false); entityskeleton.worldObj.spawnEntityInWorld(entityskeleton); return entityskeleton; }
/** * Updates the task */ public void updateTask() { DifficultyInstance difficultyinstance = this.horse.worldObj.getDifficultyForLocation(new BlockPos(this.horse)); this.horse.setSkeletonTrap(false); this.horse.setType(HorseType.SKELETON); this.horse.setHorseTamed(true); this.horse.setGrowingAge(0); this.horse.worldObj.addWeatherEffect(new EntityLightningBolt(this.horse.worldObj, this.horse.posX, this.horse.posY, this.horse.posZ, true)); EntitySkeleton entityskeleton = this.createSkeleton(difficultyinstance, this.horse); entityskeleton.startRiding(this.horse); for (int i = 0; i < 3; ++i) { EntityHorse entityhorse = this.createHorse(difficultyinstance); EntitySkeleton entityskeleton1 = this.createSkeleton(difficultyinstance, entityhorse); entityskeleton1.startRiding(entityhorse); entityhorse.addVelocity(this.horse.getRNG().nextGaussian() * 0.5D, 0.0D, this.horse.getRNG().nextGaussian() * 0.5D); } }
/** * Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called * when entity is reloaded from nbt. Mainly used for initializing attributes and inventory */ @Nullable public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata) { livingdata = super.onInitialSpawn(difficulty, livingdata); if (this.getTameSkin() == 0 && this.worldObj.rand.nextInt(7) == 0) { for (int i = 0; i < 2; ++i) { EntityOcelot entityocelot = new EntityOcelot(this.worldObj); entityocelot.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F); entityocelot.setGrowingAge(-24000); this.worldObj.spawnEntityInWorld(entityocelot); } } return livingdata; }
/** * Overridden to fire "fake" arrows instead of real ones. * see {@link net.minecraft.entity.monster.EntitySkeleton#attackEntityWithRangedAttack(net.minecraft.entity.EntityLivingBase, float)}. */ @Override public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor) { EntityFakeArrow entityarrow = new EntityFakeArrow(this.world, this); double x = target.posX - this.posX; double y = target.getEntityBoundingBox().minY + (double)(target.height / 3.0F) - entityarrow.posY; double z = target.posZ - this.posZ; double d3 = (double)MathHelper.sqrt(x * x + z * z); entityarrow.setThrowableHeading(x, y + d3 * 0.2D, z, 1.6F, (float)(14 - this.world.getDifficulty().getDifficultyId() * 4)); DifficultyInstance difficultyinstance = this.world.getDifficultyForLocation(new BlockPos(this)); entityarrow.setDamage((double)(distanceFactor * 2.0F) + this.rand.nextGaussian() * 0.25D + (double)((float)this.world.getDifficulty().getDifficultyId() * 0.11F)); this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); this.world.spawnEntity(entityarrow); }
/** * Overridden to call {@link EntityZombie#setChild(boolean)} to force all ZombieHands to be adults, and to create HuskHands in desert biomes */ @Override public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata) { super.onInitialSpawn(difficulty, livingdata); this.setChild(false); // *** logic copied from 1.10 implementation of EntityZombie Biome biome = this.world.getBiome(new BlockPos(this)); if (biome instanceof BiomeDesert && this.world.canSeeSky(new BlockPos(this)) && this.rand.nextInt(5) != 0) { this.setZombieType(ZombieType.HUSK); } // *** logic copied from 1.10 implementation of EntityZombie return livingdata; }
/** * Updates the task */ public void updateTask() { DifficultyInstance difficultyinstance = this.horse.world.getDifficultyForLocation(new BlockPos(this.horse)); this.horse.func_190691_p(false); this.horse.setHorseTamed(true); this.horse.setGrowingAge(0); this.horse.world.addWeatherEffect(new EntityLightningBolt(this.horse.world, this.horse.posX, this.horse.posY, this.horse.posZ, true)); EntitySkeleton entityskeleton = this.createSkeleton(difficultyinstance, this.horse); entityskeleton.startRiding(this.horse); for (int i = 0; i < 3; ++i) { AbstractHorse abstracthorse = this.createHorse(difficultyinstance); EntitySkeleton entityskeleton1 = this.createSkeleton(difficultyinstance, abstracthorse); entityskeleton1.startRiding(abstracthorse); abstracthorse.addVelocity(this.horse.getRNG().nextGaussian() * 0.5D, 0.0D, this.horse.getRNG().nextGaussian() * 0.5D); } }
private EntitySkeleton createSkeleton(DifficultyInstance p_188514_1_, AbstractHorse p_188514_2_) { EntitySkeleton entityskeleton = new EntitySkeleton(p_188514_2_.world); entityskeleton.onInitialSpawn(p_188514_1_, (IEntityLivingData)null); entityskeleton.setPosition(p_188514_2_.posX, p_188514_2_.posY, p_188514_2_.posZ); entityskeleton.hurtResistantTime = 60; entityskeleton.enablePersistence(); if (entityskeleton.getItemStackFromSlot(EntityEquipmentSlot.HEAD).func_190926_b()) { entityskeleton.setItemStackToSlot(EntityEquipmentSlot.HEAD, new ItemStack(Items.IRON_HELMET)); } entityskeleton.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, EnchantmentHelper.addRandomEnchantment(entityskeleton.getRNG(), entityskeleton.getHeldItemMainhand(), (int)(5.0F + p_188514_1_.getClampedAdditionalDifficulty() * (float)entityskeleton.getRNG().nextInt(18)), false)); entityskeleton.setItemStackToSlot(EntityEquipmentSlot.HEAD, EnchantmentHelper.addRandomEnchantment(entityskeleton.getRNG(), entityskeleton.getItemStackFromSlot(EntityEquipmentSlot.HEAD), (int)(5.0F + p_188514_1_.getClampedAdditionalDifficulty() * (float)entityskeleton.getRNG().nextInt(18)), false)); entityskeleton.world.spawnEntityInWorld(entityskeleton); return entityskeleton; }
/** * Enchants Entity's current equipments based on given DifficultyInstance */ protected void setEnchantmentBasedOnDifficulty(DifficultyInstance difficulty) { float f = difficulty.getClampedAdditionalDifficulty(); if (!this.getHeldItemMainhand().func_190926_b() && this.rand.nextFloat() < 0.25F * f) { this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, EnchantmentHelper.addRandomEnchantment(this.rand, this.getHeldItemMainhand(), (int)(5.0F + f * (float)this.rand.nextInt(18)), false)); } for (EntityEquipmentSlot entityequipmentslot : EntityEquipmentSlot.values()) { if (entityequipmentslot.getSlotType() == EntityEquipmentSlot.Type.ARMOR) { ItemStack itemstack = this.getItemStackFromSlot(entityequipmentslot); if (!itemstack.func_190926_b() && this.rand.nextFloat() < 0.5F * f) { this.setItemStackToSlot(entityequipmentslot, EnchantmentHelper.addRandomEnchantment(this.rand, itemstack, (int)(5.0F + f * (float)this.rand.nextInt(18)), false)); } } } }
@Nullable /** * Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called * when entity is reloaded from nbt. Mainly used for initializing attributes and inventory */ public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata) { this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).applyModifier(new AttributeModifier("Random spawn bonus", this.rand.nextGaussian() * 0.05D, 1)); if (this.rand.nextFloat() < 0.05F) { this.setLeftHanded(true); } else { this.setLeftHanded(false); } return livingdata; }
@Nullable /** * Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called * when entity is reloaded from nbt. Mainly used for initializing attributes and inventory */ public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata) { livingdata = super.onInitialSpawn(difficulty, livingdata); this.func_190705_dT(); int i; if (livingdata instanceof EntityLlama.GroupData) { i = ((EntityLlama.GroupData)livingdata).field_190886_a; } else { i = this.rand.nextInt(4); livingdata = new EntityLlama.GroupData(i); } this.func_190710_o(i); return livingdata; }
@Nullable /** * Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called * when entity is reloaded from nbt. Mainly used for initializing attributes and inventory */ public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata) { livingdata = super.onInitialSpawn(difficulty, livingdata); if (this.rand.nextInt(5) == 0) { this.setGrowingAge(-24000); } return livingdata; }
@Nullable /** * Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called * when entity is reloaded from nbt. Mainly used for initializing attributes and inventory */ public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata) { livingdata = super.onInitialSpawn(difficulty, livingdata); if (this.getTameSkin() == 0 && this.world.rand.nextInt(7) == 0) { for (int i = 0; i < 2; ++i) { EntityOcelot entityocelot = new EntityOcelot(this.world); entityocelot.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F); entityocelot.setGrowingAge(-24000); this.world.spawnEntityInWorld(entityocelot); } } return livingdata; }
/** * Enchants Entity's current equipments based on given DifficultyInstance */ protected void setEnchantmentBasedOnDifficulty(DifficultyInstance difficulty) { float f = difficulty.getClampedAdditionalDifficulty(); if (this.getHeldItemMainhand() != null && this.rand.nextFloat() < 0.25F * f) { EnchantmentHelper.addRandomEnchantment(this.rand, this.getHeldItemMainhand(), (int)(5.0F + f * (float)this.rand.nextInt(18)), false); } for (EntityEquipmentSlot entityequipmentslot : EntityEquipmentSlot.values()) { if (entityequipmentslot.getSlotType() == EntityEquipmentSlot.Type.ARMOR) { ItemStack itemstack = this.getItemStackFromSlot(entityequipmentslot); if (itemstack != null && this.rand.nextFloat() < 0.5F * f) { EnchantmentHelper.addRandomEnchantment(this.rand, itemstack, (int)(5.0F + f * (float)this.rand.nextInt(18)), false); } } } }
/** * Gives armor or weapon for entity based on given DifficultyInstance */ protected void setEquipmentBasedOnDifficulty(DifficultyInstance difficulty) { super.setEquipmentBasedOnDifficulty(difficulty); if (this.rand.nextFloat() < (this.world.getDifficulty() == EnumDifficulty.HARD ? 0.05F : 0.01F)) { int i = this.rand.nextInt(3); if (i == 0) { this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.IRON_SWORD)); } else { this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.IRON_SHOVEL)); } } }
@Nullable /** * Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called * when entity is reloaded from nbt. Mainly used for initializing attributes and inventory */ public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata) { this.renderYawOffset = 180.0F; this.prevRenderYawOffset = 180.0F; this.rotationYaw = 180.0F; this.prevRotationYaw = 180.0F; this.rotationYawHead = 180.0F; this.prevRotationYawHead = 180.0F; return super.onInitialSpawn(difficulty, livingdata); }
@Override public IEntityLivingData onInitialSpawn(DifficultyInstance p_180482_1_, IEntityLivingData data) { data=super.onInitialSpawn(p_180482_1_, data); if(!this.loadout.getStackInSlot(1).isEmpty() && this.loadout.getStackInSlot(1).getItem() instanceof ItemChargingTarge){ this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).applyModifier(new AttributeModifier("ShieldHP", 3, 0)); this.heal(3); this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).applyModifier(new AttributeModifier("ShieldMove", 0.02, 2)); } return data; }
/** * Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called * when entity is reloaded from nbt. Mainly used for initializing attributes and inventory */ @Nullable public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata) { livingdata = super.onInitialSpawn(difficulty, livingdata); this.setFleeceColor(getRandomSheepColor(this.worldObj.rand)); return livingdata; }
/** * Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called * when entity is reloaded from nbt. Mainly used for initializing attributes and inventory */ public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData livingdata) { livingdata = super.onInitialSpawn(difficulty, livingdata); this.setFleeceColor(getRandomSheepColor(this.worldObj.rand)); return livingdata; }
/** * Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called * when entity is reloaded from nbt. Mainly used for initializing attributes and inventory */ public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData livingdata) { super.onInitialSpawn(difficulty, livingdata); this.setVillager(false); return livingdata; }
@Nullable /** * Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called * when entity is reloaded from nbt. Mainly used for initializing attributes and inventory */ public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata) { livingdata = super.onInitialSpawn(difficulty, livingdata); this.setEquipmentBasedOnDifficulty(difficulty); this.setEnchantmentBasedOnDifficulty(difficulty); this.setCombatTask(); this.setCanPickUpLoot(this.rand.nextFloat() < 0.55F * difficulty.getClampedAdditionalDifficulty()); if (this.getItemStackFromSlot(EntityEquipmentSlot.HEAD).func_190926_b()) { Calendar calendar = this.world.getCurrentDate(); if (calendar.get(2) + 1 == 10 && calendar.get(5) == 31 && this.rand.nextFloat() < 0.25F) { this.setItemStackToSlot(EntityEquipmentSlot.HEAD, new ItemStack(this.rand.nextFloat() < 0.1F ? Blocks.LIT_PUMPKIN : Blocks.PUMPKIN)); this.inventoryArmorDropChances[EntityEquipmentSlot.HEAD.getIndex()] = 0.0F; } } return livingdata; }
/** * Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called * when entity is reloaded from nbt. Mainly used for initializing attributes and inventory */ public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData livingdata) { livingdata = super.onInitialSpawn(difficulty, livingdata); this.setProfession(this.worldObj.rand.nextInt(5)); this.setAdditionalAItasks(); return livingdata; }
/** * Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called * when entity is reloaded from nbt. Mainly used for initializing attributes and inventory */ public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData livingdata) { livingdata = super.onInitialSpawn(difficulty, livingdata); if (this.worldObj.provider instanceof WorldProviderHell && this.getRNG().nextInt(5) > 0) { this.tasks.addTask(4, this.aiAttackOnCollide); this.setSkeletonType(1); this.setCurrentItemOrArmor(0, new ItemStack(Items.stone_sword)); this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(4.0D); } else { this.tasks.addTask(4, this.aiArrowAttack); this.setEquipmentBasedOnDifficulty(difficulty); this.setEnchantmentBasedOnDifficulty(difficulty); } this.setCanPickUpLoot(this.rand.nextFloat() < 0.55F * difficulty.getClampedAdditionalDifficulty()); if (this.getEquipmentInSlot(4) == null) { Calendar calendar = this.worldObj.getCurrentDate(); if (calendar.get(2) + 1 == 10 && calendar.get(5) == 31 && this.rand.nextFloat() < 0.25F) { this.setCurrentItemOrArmor(4, new ItemStack(this.rand.nextFloat() < 0.1F ? Blocks.lit_pumpkin : Blocks.pumpkin)); this.equipmentDropChances[4] = 0.0F; } } return livingdata; }
/** * Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called * when entity is reloaded from nbt. Mainly used for initializing attributes and inventory */ public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData livingdata) { int i = this.rand.nextInt(3); if (i < 2 && this.rand.nextFloat() < 0.5F * difficulty.getClampedAdditionalDifficulty()) { ++i; } int j = 1 << i; this.setSlimeSize(j); return super.onInitialSpawn(difficulty, livingdata); }