diff options
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api')
2 files changed, 14 insertions, 13 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_ThreadedBuffer.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_ThreadedBuffer.java index 8dc0a8c2cf..855b856f49 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_ThreadedBuffer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_ThreadedBuffer.java @@ -21,6 +21,7 @@ public abstract class GT_MetaTileEntity_ThreadedBuffer extends GT_MetaTileEntity protected GregtechBufferThread mLogicThread; protected BlockPos mPos; public final ItemStack[] mInventorySynchro; + public int mThreadTimeLeft = 0; public GT_MetaTileEntity_ThreadedBuffer(final int aID, final String aName, final String aNameRegional, final int aTier, final int aInvSlotCount, final String aDescription) { @@ -308,6 +309,7 @@ public abstract class GT_MetaTileEntity_ThreadedBuffer extends GT_MetaTileEntity } if (mLogicThread!= null) { getLogicThread().onPostTick(aBaseMetaTileEntity, aTimer, this); + this.mThreadTimeLeft = this.mLogicThread.getTimeLeft(); } } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/objects/GregtechBufferThread.java b/src/Java/gtPlusPlus/xmod/gregtech/api/objects/GregtechBufferThread.java index 47c53d18f1..cf477b0889 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/objects/GregtechBufferThread.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/objects/GregtechBufferThread.java @@ -1,8 +1,8 @@ package gtPlusPlus.xmod.gregtech.api.objects; -import java.util.HashMap; import java.util.List; -import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import net.minecraft.init.Items; import net.minecraft.inventory.IInventory; @@ -18,9 +18,10 @@ import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity public class GregtechBufferThread extends Thread { - public static final Map<String, GregtechBufferThread> mBufferThreadAllocation = new HashMap<String, GregtechBufferThread>(); + public static final ConcurrentMap<String, GregtechBufferThread> mBufferThreadAllocation = new ConcurrentHashMap<String, GregtechBufferThread>(); private final BlockPos mBlockPos; - private int mLifeCycleTime = 300; + private final int mMaxLife = 300; + private int mLifeCycleTime = mMaxLife; private final String mID; public static synchronized final GregtechBufferThread getBufferThread(BlockPos pos) { @@ -51,11 +52,12 @@ public class GregtechBufferThread extends Thread { Logger.INFO("[SB] Created a SuperBuffer Thread for dimension "+mID+"."); } } + + public synchronized int getTimeLeft() { + return this.mLifeCycleTime; + } public synchronized void fillStacksIntoFirstSlots(GT_MetaTileEntity_ThreadedChestBuffer mBuffer) { - if (mLifeCycleTime < (Short.MAX_VALUE-10)){ - mLifeCycleTime += 10; - } for (int i = 0; i < mBuffer.mInventorySynchro.length - 1; ++i) { for (int j = i + 1; j < mBuffer.mInventorySynchro.length - 1; ++j) { if (mBuffer.mInventorySynchro[j] != null && (mBuffer.mInventorySynchro[i] == null @@ -68,9 +70,6 @@ public class GregtechBufferThread extends Thread { } public synchronized boolean moveItems(final IGregTechTileEntity aBaseMetaTileEntity, final long aTimer, GT_MetaTileEntity_ThreadedBuffer mBuffer) { - if (mLifeCycleTime < (Short.MAX_VALUE-10)){ - mLifeCycleTime += 10; - } final byte mTargetStackSize = (byte) mBuffer.mTargetStackSize; final int tCost = GT_Utility.moveOneItemStack((Object) aBaseMetaTileEntity, (Object) aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()), @@ -91,7 +90,7 @@ public class GregtechBufferThread extends Thread { && (aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified() || aTimer % 200L == 0L || mBuffer.mSuccess > 0)) { --mBuffer.mSuccess; - if (mLifeCycleTime < (Short.MAX_VALUE-1)){ + if (mLifeCycleTime < (mMaxLife-1)){ mLifeCycleTime += 1; } //Logger.INFO("Ticking SB @ "+mBuffer.getLogicThread().mBlockPos.getUniqueIdentifier() + " | Time Left: "+mLifeCycleTime); @@ -192,8 +191,8 @@ public class GregtechBufferThread extends Thread { mLifeCycleTime = 0; } //Prevent Overflows - if (mLifeCycleTime > Short.MAX_VALUE) { - mLifeCycleTime = Short.MAX_VALUE; + if (mLifeCycleTime > mMaxLife) { + mLifeCycleTime = mMaxLife; } try { sleep(1000); |