Search in sources :

Example 1 with IEntityLivingData

use of net.minecraft.entity.IEntityLivingData in project MorePlanets by SteveKunG.

the class EntityInfectedZombie method onInitialSpawn.

@Override
public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData data) {
    this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).applyModifier(new AttributeModifier("Random spawn bonus", this.rand.nextGaussian() * 0.05D, 1));
    float f = difficulty.getClampedAdditionalDifficulty();
    this.setCanPickUpLoot(this.rand.nextFloat() < 0.55F * f);
    if (data == null) {
        data = new GroupData(this.world.rand.nextFloat() < net.minecraftforge.common.ForgeModContainer.zombieBabyChance);
    }
    if (data instanceof GroupData) {
        GroupData entityzombie$groupdata = (GroupData) data;
        if (entityzombie$groupdata.isChild) {
            this.setChild(true);
            if (this.world.rand.nextFloat() < 0.05D) {
                List<EntityInfectedChicken> list = this.world.getEntitiesWithinAABB(EntityInfectedChicken.class, this.getEntityBoundingBox().grow(5.0D, 3.0D, 5.0D), EntitySelectors.IS_STANDALONE);
                if (!list.isEmpty()) {
                    EntityInfectedChicken entitychicken = list.get(0);
                    entitychicken.setChickenJockey(true);
                    this.startRiding(entitychicken);
                }
            } else if (this.world.rand.nextFloat() < 0.05D) {
                EntityInfectedChicken entitychicken1 = new EntityInfectedChicken(this.world);
                entitychicken1.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
                entitychicken1.onInitialSpawn(difficulty, (IEntityLivingData) null);
                entitychicken1.setChickenJockey(true);
                this.world.spawnEntity(entitychicken1);
                this.startRiding(entitychicken1);
            }
        }
    }
    this.setBreakDoorsAItask(this.rand.nextFloat() < f * 0.1F);
    this.setEquipmentBasedOnDifficulty(difficulty);
    this.setEnchantmentBasedOnDifficulty(difficulty);
    if (this.getItemStackFromSlot(EntityEquipmentSlot.HEAD) == null) {
        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;
        }
    }
    this.getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).applyModifier(new AttributeModifier("Random spawn bonus", this.rand.nextDouble() * 0.05000000074505806D, 0));
    double d0 = this.rand.nextDouble() * 1.5D * f;
    if (d0 > 1.0D) {
        this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).applyModifier(new AttributeModifier("Random zombie-spawn bonus", d0, 2));
    }
    if (this.rand.nextFloat() < f * 0.05F) {
        this.getEntityAttribute(SPAWN_REINFORCEMENTS_CHANCE).applyModifier(new AttributeModifier("Leader zombie bonus", this.rand.nextDouble() * 0.25D + 0.5D, 0));
        this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).applyModifier(new AttributeModifier("Leader zombie bonus", this.rand.nextDouble() * 3.0D + 1.0D, 2));
        this.setBreakDoorsAItask(true);
    }
    return data;
}
Also used : Calendar(java.util.Calendar) IEntityLivingData(net.minecraft.entity.IEntityLivingData) AttributeModifier(net.minecraft.entity.ai.attributes.AttributeModifier) ItemStack(net.minecraft.item.ItemStack)

Aggregations

Calendar (java.util.Calendar)1 IEntityLivingData (net.minecraft.entity.IEntityLivingData)1 AttributeModifier (net.minecraft.entity.ai.attributes.AttributeModifier)1 ItemStack (net.minecraft.item.ItemStack)1