aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/xmod/gregtech/api/objects/GregtechBufferThread.java
diff options
context:
space:
mode:
authorAlkalus <3060479+draknyte1@users.noreply.github.com>2018-05-29 14:58:07 +1000
committerAlkalus <3060479+draknyte1@users.noreply.github.com>2018-05-29 14:58:07 +1000
commitf887c642796d77adb7a5baf559092807d8274f81 (patch)
treeabb6f4b20aeeaabf924df119fed0c28b75b3c7c8 /src/Java/gtPlusPlus/xmod/gregtech/api/objects/GregtechBufferThread.java
parenta2377acf4dc0dedc087fe83ca5665d142ab26ba1 (diff)
downloadGT5-Unofficial-f887c642796d77adb7a5baf559092807d8274f81.tar.gz
GT5-Unofficial-f887c642796d77adb7a5baf559092807d8274f81.tar.bz2
GT5-Unofficial-f887c642796d77adb7a5baf559092807d8274f81.zip
$ More work on threaded super buffers.
$ Fixed the infinite item holder.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api/objects/GregtechBufferThread.java')
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/objects/GregtechBufferThread.java18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/objects/GregtechBufferThread.java b/src/Java/gtPlusPlus/xmod/gregtech/api/objects/GregtechBufferThread.java
index 1f92aa45a7..2d55e8d5ee 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/objects/GregtechBufferThread.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/objects/GregtechBufferThread.java
@@ -12,6 +12,7 @@ import net.minecraft.world.World;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.util.GT_Utility;
+import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_ThreadedBuffer;
import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_ThreadedChestBuffer;
@@ -23,6 +24,7 @@ public class GregtechBufferThread extends Thread {
public static synchronized final GregtechBufferThread getBufferThread(World world) {
if (world != null && mBufferThreadAllocation.containsKey(""+world.provider.dimensionId)){
+ Logger.INFO("[SB] Found an existing thread for this dimension.");
return mBufferThreadAllocation.get(""+world.provider.dimensionId);
}
else {
@@ -31,7 +33,6 @@ public class GregtechBufferThread extends Thread {
}
public GregtechBufferThread(World world) {
-
int mID = world != null ? world.provider.dimensionId : Short.MIN_VALUE;
if (world != null && !mBufferThreadAllocation.containsKey(""+mID)){
mWorldRef = world;
@@ -41,9 +42,12 @@ public class GregtechBufferThread extends Thread {
this.mLifeCycleTime = 1;
mWorldRef = null;
}
+ this.setName("GTPP_SuperBuffer-Dim("+mID+"");
+ Logger.INFO("[SB] Created a SuperBuffer Thread for dimension "+mID+".");
}
public synchronized void fillStacksIntoFirstSlots(GT_MetaTileEntity_ThreadedChestBuffer mBuffer) {
+ mLifeCycleTime += 100;
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
@@ -56,6 +60,7 @@ public class GregtechBufferThread extends Thread {
}
public synchronized boolean moveItems(final IGregTechTileEntity aBaseMetaTileEntity, final long aTimer, GT_MetaTileEntity_ThreadedBuffer mBuffer) {
+ mLifeCycleTime += 100;
final byte mTargetStackSize = (byte) mBuffer.mTargetStackSize;
final int tCost = GT_Utility.moveOneItemStack((Object) aBaseMetaTileEntity,
(Object) aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()),
@@ -163,9 +168,18 @@ public class GregtechBufferThread extends Thread {
public void run() {
while (mLifeCycleTime > 0) {
mLifeCycleTime--;
+ Logger.INFO("[SB] Ticking Thread for dimension. "+mLifeCycleTime);
+ try {
+ this.sleep(1000);
+ }
+ catch (InterruptedException e) {
+
+ }
}
if (mLifeCycleTime <= 0) {
- GregtechBufferThread.mBufferThreadAllocation.remove(""+(mWorldRef != null ? mWorldRef.provider.dimensionId : Short.MIN_VALUE), this);
+ int mID = (mWorldRef != null ? mWorldRef.provider.dimensionId : Short.MIN_VALUE);
+ GregtechBufferThread.mBufferThreadAllocation.remove(""+mID, this);
+ Logger.INFO("[SB] Removing Thread for dimension "+mID);
}
}