aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/creative/GT_MetaTileEntity_InfiniteItemHolder.java31
3 files changed, 45 insertions, 18 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);
}
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/creative/GT_MetaTileEntity_InfiniteItemHolder.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/creative/GT_MetaTileEntity_InfiniteItemHolder.java
index 5aa004637c..529a0b79f6 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/creative/GT_MetaTileEntity_InfiniteItemHolder.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/creative/GT_MetaTileEntity_InfiniteItemHolder.java
@@ -6,6 +6,7 @@ import net.minecraft.item.ItemStack;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.metatileentity.MetaTileEntity;
import gtPlusPlus.core.util.minecraft.PlayerUtils;
import gtPlusPlus.core.util.sys.KeyboardUtils;
@@ -23,8 +24,7 @@ public class GT_MetaTileEntity_InfiniteItemHolder extends GT_MetaTileEntity_Tier
@Override
public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {
-
- if (aPlayer.worldObj.isRemote) {
+ if (aBaseMetaTileEntity.getWorld().isRemote) {
return false;
}
@@ -33,19 +33,25 @@ public class GT_MetaTileEntity_InfiniteItemHolder extends GT_MetaTileEntity_Tier
if (aPlayer.getHeldItem() != null) {
this.mItemStack = aPlayer.getHeldItem().copy();
this.mItemCount = Short.MAX_VALUE;
+ aPlayer.setCurrentItemOrArmor(0, null);
+ PlayerUtils.messagePlayer(aPlayer, "Now holding "+this.mItemStack.getDisplayName()+" x"+Short.MAX_VALUE+".");
+ return true;
}
}
else {
if (aPlayer.getHeldItem() == null) {
+ aPlayer.entityDropItem(mItemStack, 1);
this.mItemStack = null;
this.mItemCount = 0;
+ PlayerUtils.messagePlayer(aPlayer, "Emptying.");
+ return true;
}
}
}
- else {
- PlayerUtils.messagePlayer(aPlayer, "Currently holding: "+(this.mItemStack != null ? this.mItemStack.getDisplayName() : "Nothing")+" x"+this.mItemCount);
- }
- return super.onRightclick(aBaseMetaTileEntity, aPlayer);
+
+ PlayerUtils.messagePlayer(aPlayer, "Currently holding: "+(this.mItemStack != null ? this.mItemStack.getDisplayName() : "Nothing")+" x"+this.mItemCount);
+ return true;
+ //return super.onRightclick(aBaseMetaTileEntity, aPlayer);
}
@Override
@@ -60,6 +66,9 @@ public class GT_MetaTileEntity_InfiniteItemHolder extends GT_MetaTileEntity_Tier
@Override
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) {
+ if (mItemStack != null) {
+ setItemCount(0);
+ }
super.onPostTick(aBaseMetaTileEntity, aTimer);
}
@@ -70,14 +79,16 @@ public class GT_MetaTileEntity_InfiniteItemHolder extends GT_MetaTileEntity_Tier
@Override
public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
- // TODO Auto-generated method stub
- return super.allowPullStack(aBaseMetaTileEntity, aIndex, aSide, aStack);
+ return true;
}
@Override
public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
- // TODO Auto-generated method stub
- return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack);
+ return false;
+ }
+
+ public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new GT_MetaTileEntity_InfiniteItemHolder(this.mName, this.mTier, this.mDescription, this.mTextures);
}