diff options
author | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2018-05-27 14:01:51 +1000 |
---|---|---|
committer | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2018-05-27 14:01:51 +1000 |
commit | a6e9f62a360ecb43eb771e4d0952a0e728cd748d (patch) | |
tree | 185a923a40c30207a74cedb6ab7c533187c1d537 /src/Java/gtPlusPlus/core/entity/item | |
parent | 9285a2ffdc9729f7b3c6917e44fdc68fc2d253c9 (diff) | |
download | GT5-Unofficial-a6e9f62a360ecb43eb771e4d0952a0e728cd748d.tar.gz GT5-Unofficial-a6e9f62a360ecb43eb771e4d0952a0e728cd748d.tar.bz2 GT5-Unofficial-a6e9f62a360ecb43eb771e4d0952a0e728cd748d.zip |
$ Fixed Locale issue.
% Made Large Eggs turn into Spawn eggs for large chickens.
Diffstat (limited to 'src/Java/gtPlusPlus/core/entity/item')
-rw-r--r-- | src/Java/gtPlusPlus/core/entity/item/ItemEntityGiantEgg.java | 82 |
1 files changed, 44 insertions, 38 deletions
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(); + } + } + } + } + } |