本文整理匯總了Java中net.minecraft.entity.passive.EntityChicken.onInitialSpawn方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityChicken.onInitialSpawn方法的具體用法?Java EntityChicken.onInitialSpawn怎麽用?Java EntityChicken.onInitialSpawn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.entity.passive.EntityChicken
的用法示例。
在下文中一共展示了EntityChicken.onInitialSpawn方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onInitialSpawn
import net.minecraft.entity.passive.EntityChicken; //導入方法依賴的package包/類
@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);
float f = difficulty.getClampedAdditionalDifficulty();
this.setCanPickUpLoot(this.rand.nextFloat() < 0.55F * f);
if (livingdata == null)
{
livingdata = new EntityZombie.GroupData(this.world.rand.nextFloat() < 0.05F);
}
if (livingdata instanceof EntityZombie.GroupData)
{
EntityZombie.GroupData entityzombie$groupdata = (EntityZombie.GroupData)livingdata;
if (entityzombie$groupdata.isChild)
{
this.setChild(true);
if ((double)this.world.rand.nextFloat() < 0.05D)
{
List<EntityChicken> list = this.world.<EntityChicken>getEntitiesWithinAABB(EntityChicken.class, this.getEntityBoundingBox().expand(5.0D, 3.0D, 5.0D), EntitySelectors.IS_STANDALONE);
if (!list.isEmpty())
{
EntityChicken entitychicken = (EntityChicken)list.get(0);
entitychicken.setChickenJockey(true);
this.startRiding(entitychicken);
}
}
else if ((double)this.world.rand.nextFloat() < 0.05D)
{
EntityChicken entitychicken1 = new EntityChicken(this.world);
entitychicken1.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
entitychicken1.onInitialSpawn(difficulty, (IEntityLivingData)null);
entitychicken1.setChickenJockey(true);
this.world.spawnEntityInWorld(entitychicken1);
this.startRiding(entitychicken1);
}
}
}
this.setBreakDoorsAItask(this.rand.nextFloat() < f * 0.1F);
this.setEquipmentBasedOnDifficulty(difficulty);
this.setEnchantmentBasedOnDifficulty(difficulty);
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;
}
}
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));
}
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 livingdata;
}