diff options
author | Jakub <53441451+kuba6000@users.noreply.github.com> | 2022-08-06 16:20:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-06 21:20:49 +0700 |
commit | 5ea0f1d6ebc897701da3f95ffd17161d9e43fa1b (patch) | |
tree | 1e39c113c1a95ffb588bbae7678cbf0db13e652a /src | |
parent | d248501196ac127599804ee5962757ed35bf8bcc (diff) | |
download | GT5-Unofficial-5ea0f1d6ebc897701da3f95ffd17161d9e43fa1b.tar.gz GT5-Unofficial-5ea0f1d6ebc897701da3f95ffd17161d9e43fa1b.tar.bz2 GT5-Unofficial-5ea0f1d6ebc897701da3f95ffd17161d9e43fa1b.zip |
Industrial Apiary bug fixes (#1202)
* Add delay to pollination
* nbt
* Don't pollinate when breeding
* Retrieve all individual drones from queen death
* use mOutputItems.length
* Bug fix
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_IndustrialApiary.java | 75 |
1 files changed, 46 insertions, 29 deletions
diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_IndustrialApiary.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_IndustrialApiary.java index 0ec52f2ee2..de41e5bc17 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_IndustrialApiary.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_IndustrialApiary.java @@ -120,6 +120,8 @@ public class GT_MetaTileEntity_IndustrialApiary extends GT_MetaTileEntity_BasicM aNBT.setBoolean("mLockedSpeed", mLockedSpeed); if(usedQueen != null) aNBT.setTag("usedQueen", usedQueen.writeToNBT(new NBTTagCompound())); + aNBT.setBoolean("retrievingPollenInThisOperation", retrievingPollenInThisOperation); + aNBT.setInteger("pollinationDelay", pollinationDelay); } @Override @@ -129,10 +131,13 @@ public class GT_MetaTileEntity_IndustrialApiary extends GT_MetaTileEntity_BasicM mLockedSpeed = aNBT.getBoolean("mLockedSpeed"); if(aNBT.hasKey("usedQueen")) usedQueen = ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag("usedQueen")); + retrievingPollenInThisOperation = aNBT.getBoolean("retrievingPollenInThisOperation"); + pollinationDelay = aNBT.getInteger("pollinationDelay"); } boolean retrievingPollenInThisOperation = false; IIndividual retrievedpollen = null; + int pollinationDelay = 100; @Override public int checkRecipe() { @@ -207,21 +212,7 @@ public class GT_MetaTileEntity_IndustrialApiary extends GT_MetaTileEntity_BasicM } int i = 0; - for(Map.Entry<GT_Utility.ItemId, Float> entry : drops.entrySet()) - { - ItemStack s = dropstacks.get(entry.getKey()).copy(); - s.stackSize = entry.getValue().intValue() + (getWorld().rand.nextFloat() < (entry.getValue() - (float) entry.getValue().intValue()) ? 1 : 0); - if(s.stackSize > 0 && i < 7) - while(true) { - if (s.stackSize <= s.getMaxStackSize()) { - this.mOutputItems[i++] = s; - break; - } else - this.mOutputItems[i++] = s.splitStack(s.getMaxStackSize()); - if(i >= 7) - break; - } - } + int imax = mOutputItems.length; IApiaristTracker breedingTracker = beeRoot.getBreedingTracker(getWorld(), getOwner()); @@ -230,36 +221,57 @@ public class GT_MetaTileEntity_IndustrialApiary extends GT_MetaTileEntity_BasicM NBTTagCompound nbttagcompound = new NBTTagCompound(); queen.writeToNBT(nbttagcompound); convert.setTagCompound(nbttagcompound); - this.mOutputItems[7] = convert; + this.mOutputItems[i++] = convert; } else { IBee b = bee.spawnPrincess(this); if(b != null){ ItemStack princess = beeRoot.getMemberStack(b, EnumBeeType.PRINCESS.ordinal()); breedingTracker.registerPrincess(b); - this.mOutputItems[7] = princess; + this.mOutputItems[i++] = princess; } IBee[] d = bee.spawnDrones(this); if(d != null && d.length > 0) { - ItemStack drone = beeRoot.getMemberStack(d[0], EnumBeeType.DRONE.ordinal()); - drone.stackSize = d.length; - breedingTracker.registerDrone(d[0]); - this.mOutputItems[8] = drone; + HashMap<GT_Utility.ItemId, ItemStack> drones = new HashMap<>(d.length); + for(IBee dr : d) { + ItemStack drone = beeRoot.getMemberStack(dr, EnumBeeType.DRONE.ordinal()); + breedingTracker.registerDrone(dr); + GT_Utility.ItemId drid = GT_Utility.ItemId.createNoCopy(drone); + if(drones.containsKey(drid)) drones.get(drid).stackSize += drone.stackSize; + else { + this.mOutputItems[i++] = drone; + drones.put(drid, drone); + } + } } } + int imin = i; + setQueen(null); + for(Map.Entry<GT_Utility.ItemId, Float> entry : drops.entrySet()) + { + ItemStack s = dropstacks.get(entry.getKey()).copy(); + s.stackSize = entry.getValue().intValue() + (getWorld().rand.nextFloat() < (entry.getValue() - (float) entry.getValue().intValue()) ? 1 : 0); + if(s.stackSize > 0 && i < imax) + while(true) { + if (s.stackSize <= s.getMaxStackSize()) { + this.mOutputItems[i++] = s; + break; + } else + this.mOutputItems[i++] = s.splitStack(s.getMaxStackSize()); + if(i >= imax) + break; + } + } + for(ItemStack s : pollen.values()) - if(i < 7) + if(i < imax) this.mOutputItems[i++] = s; else break; - - - - // Overclock @@ -269,9 +281,11 @@ public class GT_MetaTileEntity_IndustrialApiary extends GT_MetaTileEntity_BasicM int actualdivider = useddivider; this.mMaxProgresstime /= Math.min(actualdivider, timemaxdivider); actualdivider /= Math.min(actualdivider, timemaxdivider); - for(i--; i >= 0; i--) + for(i--; i >= imin; i--) this.mOutputItems[i].stackSize *= actualdivider; + pollinationDelay = Math.max((int)(this.mMaxProgresstime / cycles), 20); // don't run too often + this.mProgresstime = 0; this.mEUt = (int)((float)baseEUtUsage * this.energyMod * useddivider); if(useddivider == 2) @@ -281,6 +295,9 @@ public class GT_MetaTileEntity_IndustrialApiary extends GT_MetaTileEntity_BasicM } else { // Breeding time + + retrievingPollenInThisOperation = true; // Don't pollinate when breeding + this.mMaxProgresstime = 100; this.mProgresstime = 0; int useddivider = Math.min(100, 1 << this.mSpeed); @@ -398,11 +415,11 @@ public class GT_MetaTileEntity_IndustrialApiary extends GT_MetaTileEntity_BasicM if(usedQueenBee == null) usedQueenBee = beeRoot.getMember(usedQueen); effectData = usedQueenBee.doEffect(effectData, this); - if(!retrievingPollenInThisOperation && floweringMod > 0f) + if(!retrievingPollenInThisOperation && floweringMod > 0f && this.mProgresstime % pollinationDelay == 0) { if(retrievedpollen == null) retrievedpollen = usedQueenBee.retrievePollen(this); - if(usedQueenBee.pollinateRandom(this, retrievedpollen) || this.mProgresstime % 100 == 0) + if(retrievedpollen != null && (usedQueenBee.pollinateRandom(this, retrievedpollen) || this.mProgresstime % (pollinationDelay * 5) == 0)) retrievedpollen = null; } } |