aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/xmod/gregtech/api
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
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')
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_ThreadedBuffer.java14
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/objects/GregtechBufferThread.java18
2 files changed, 24 insertions, 8 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 20e1d726d3..c7914331b7 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
@@ -16,7 +16,7 @@ import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
public abstract class GT_MetaTileEntity_ThreadedBuffer extends GT_MetaTileEntity_Buffer {
-
+
protected GregtechBufferThread mLogicThread;
public final ItemStack[] mInventorySynchro;
@@ -63,7 +63,7 @@ public abstract class GT_MetaTileEntity_ThreadedBuffer extends GT_MetaTileEntity
this.mTargetStackSize = 0;
this.mInventorySynchro = new ItemStack[aInvSlotCount];
}
-
+
public synchronized final GregtechBufferThread getLogicThread() {
if (mLogicThread != null) {
return mLogicThread;
@@ -297,7 +297,8 @@ public abstract class GT_MetaTileEntity_ThreadedBuffer extends GT_MetaTileEntity
}
public synchronized void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTimer) {
- getLogicThread().onPostTick(aBaseMetaTileEntity, aTimer, this);
+ if (aBaseMetaTileEntity.isServerSide())
+ getLogicThread().onPostTick(aBaseMetaTileEntity, aTimer, this);
}
public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) {
@@ -307,7 +308,8 @@ public abstract class GT_MetaTileEntity_ThreadedBuffer extends GT_MetaTileEntity
}
protected synchronized void moveItems(final IGregTechTileEntity aBaseMetaTileEntity, final long aTimer) {
- getLogicThread().moveItems(aBaseMetaTileEntity, aTimer, this);
+ if (aBaseMetaTileEntity.isServerSide())
+ getLogicThread().moveItems(aBaseMetaTileEntity, aTimer, this);
}
public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide,
@@ -323,9 +325,9 @@ public abstract class GT_MetaTileEntity_ThreadedBuffer extends GT_MetaTileEntity
public boolean allowGeneralRedstoneOutput() {
return true;
}
-
+
//Custom inventory handler
-
+
@Override
public synchronized ItemStack[] getRealInventory() {
return this.mInventorySynchro;
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);
}
}