From a6e9f62a360ecb43eb771e4d0952a0e728cd748d Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Sun, 27 May 2018 14:01:51 +1000 Subject: $ Fixed Locale issue. % Made Large Eggs turn into Spawn eggs for large chickens. --- .../core/entity/item/ItemEntityGiantEgg.java | 82 ++++++++++++---------- 1 file changed, 44 insertions(+), 38 deletions(-) (limited to 'src/Java/gtPlusPlus/core/entity/item') diff --git a/src/Java/gtPlusPlus/core/entity/item/ItemEntityGiantEgg.java b/src/Java/gtPlusPlus/core/entity/item/ItemEntityGiantEgg.java index c6ba9ff224..e6129317c6 100644 --- a/src/Java/gtPlusPlus/core/entity/item/ItemEntityGiantEgg.java +++ b/src/Java/gtPlusPlus/core/entity/item/ItemEntityGiantEgg.java @@ -32,48 +32,16 @@ public class ItemEntityGiantEgg extends EntityItem { super(aWorld, aX, aY, aZ, aStack); } - - //Large eggs don't despawn, because they will try hatch first. - @Override - public void onUpdate() { - if (this.lifespan != Integer.MAX_VALUE) { - this.lifespan = Integer.MAX_VALUE; - } - - if (this.getEntityItem() != null) { - ItemStack g = this.getEntityItem(); - NBTUtils.setInteger(g, "mTicksExisted", this.age); - this.setEntityItemStack(g); - Logger.INFO("Writing age to NBT of stored stack item."); - } - else { - ItemStack g = ItemUtils.getSimpleStack(ModItems.itemBigEgg); - NBTUtils.setInteger(g, "mTicksExisted", this.age); - this.setEntityItemStack(g); - Logger.INFO("Writing age to NBT of new stack item."); - - } - - if (this.age >= 1000) { - //Cache the value for efficiency - if (mEggSize == -1) - mEggSize = (this.getEntityItem() != null ? (this.getEntityItem().hasTagCompound() ? (this.getEntityItem().getTagCompound().hasKey("size") ? this.getEntityItem().getTagCompound().getInteger("size") : 1) : 1) : 1); - if (MathUtils.randInt(100*mEggSize, 1000) >= MathUtils.randInt(950, 1000)) { - //Spawn Chicken - spawnGiantChicken(); - } - } - super.onUpdate(); - } - - private void spawnGiantChicken() { + private boolean spawnGiantChicken() { try { EntityGiantChickenBase entitychicken = new EntityGiantChickenBase(this.worldObj); - entitychicken.setGrowingAge(-24000); + entitychicken.setGrowingAge(-MathUtils.randInt(20000, 40000)); entitychicken.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F); - this.worldObj.spawnEntityInWorld(entitychicken); + return this.worldObj.spawnEntityInWorld(entitychicken); + } + catch (Throwable t) { + return false; } - catch (Throwable t) {} } //These eggs also do not combine. @@ -105,5 +73,43 @@ public class ItemEntityGiantEgg extends EntityItem { return false; } + @Override + public void onEntityUpdate() { + super.onEntityUpdate(); + Logger.INFO("1"); + //Large eggs don't despawn, because they will try hatch first. + if (this.lifespan != Integer.MAX_VALUE-1) { + this.lifespan = Integer.MAX_VALUE-1; + } + + if (this.getEntityItem() != null) { + ItemStack g = this.getEntityItem(); + NBTUtils.setInteger(g, "mTicksExisted", this.age); + NBTUtils.setInteger(g, "lifespan", this.lifespan); + this.setEntityItemStack(g); + Logger.INFO("Writing age to NBT of stored stack item."); + } + else { + ItemStack g = ItemUtils.getSimpleStack(ModItems.itemBigEgg); + NBTUtils.setInteger(g, "mTicksExisted", this.age); + NBTUtils.setInteger(g, "lifespan", this.lifespan); + this.setEntityItemStack(g); + Logger.INFO("Writing age to NBT of new stack item."); + + } + + if (this.age >= 1000) { + //Cache the value for efficiency + if (mEggSize == -1) + mEggSize = (this.getEntityItem() != null ? (this.getEntityItem().hasTagCompound() ? (this.getEntityItem().getTagCompound().hasKey("size") ? this.getEntityItem().getTagCompound().getInteger("size") : 1) : 1) : 1); + if (MathUtils.randInt(100*mEggSize, 1000) >= MathUtils.randInt(950, 1000)) { + //Spawn Chicken + if (spawnGiantChicken()) { + this.kill(); + } + } + } + } + } -- cgit