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:00:21 +1000
committerAlkalus <3060479+draknyte1@users.noreply.github.com>2018-05-29 14:00:21 +1000
commita2377acf4dc0dedc087fe83ca5665d142ab26ba1 (patch)
tree91664db8d5a3cdd781b6f87ab4d4296d5f68f40f /src/Java/gtPlusPlus/xmod/gregtech/api
parent524a1242befd9b1ddb3dc591ac7a16148b272ea8 (diff)
downloadGT5-Unofficial-a2377acf4dc0dedc087fe83ca5665d142ab26ba1.tar.gz
GT5-Unofficial-a2377acf4dc0dedc087fe83ca5665d142ab26ba1.tar.bz2
GT5-Unofficial-a2377acf4dc0dedc087fe83ca5665d142ab26ba1.zip
+ Attempted to make some server friendly threaded Super Buffers.
+ Initial work on an infinite item holder, for test setups. % Renamed GregtechSuperTanks.java to GregtechSuperChests.java.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api')
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java8
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_ThreadedBuffer.java366
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/objects/GregtechBufferThread.java175
3 files changed, 548 insertions, 1 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java
index 81b40cc301..76ebac2cae 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java
@@ -340,7 +340,13 @@ public enum GregtechItemList implements GregtechItemContainer {
//Crate Box
CrateStorage,
- Thaumcraft_Researcher,
+ Thaumcraft_Researcher,
+
+ Automation_Threaded_SuperBuffer_ULV, Automation_Threaded_SuperBuffer_LV, Automation_Threaded_SuperBuffer_MV, Automation_Threaded_SuperBuffer_HV, Automation_Threaded_SuperBuffer_EV,
+ Automation_Threaded_SuperBuffer_IV, Automation_Threaded_SuperBuffer_LuV, Automation_Threaded_SuperBuffer_ZPM, Automation_Threaded_SuperBuffer_UV, Automation_Threaded_SuperBuffer_MAX,
+
+ Infinite_Item_Chest,
+
;
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
new file mode 100644
index 0000000000..20e1d726d3
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_ThreadedBuffer.java
@@ -0,0 +1,366 @@
+package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations;
+
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.entity.player.EntityPlayer;
+import gregtech.api.enums.GT_Values;
+import gregtech.api.util.GT_Utility;
+
+import gtPlusPlus.xmod.gregtech.api.objects.GregtechBufferThread;
+
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Buffer;
+import gregtech.api.interfaces.IIconContainer;
+import gregtech.api.objects.GT_RenderedTexture;
+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;
+
+ public GT_MetaTileEntity_ThreadedBuffer(final int aID, final String aName, final String aNameRegional, final int aTier,
+ final int aInvSlotCount, final String aDescription) {
+ super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription);
+ this.bOutput = false;
+ this.bRedstoneIfFull = false;
+ this.bInvert = false;
+ this.mSuccess = 0;
+ this.mTargetStackSize = 0;
+ this.mInventorySynchro = new ItemStack[aInvSlotCount];
+ }
+
+ public GT_MetaTileEntity_ThreadedBuffer(final int aID, final String aName, final String aNameRegional, final int aTier,
+ final int aInvSlotCount, final String[] aDescription) {
+ super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription);
+ this.bOutput = false;
+ this.bRedstoneIfFull = false;
+ this.bInvert = false;
+ this.mSuccess = 0;
+ this.mTargetStackSize = 0;
+ this.mInventorySynchro = new ItemStack[aInvSlotCount];
+ }
+
+ public GT_MetaTileEntity_ThreadedBuffer(final String aName, final int aTier, final int aInvSlotCount,
+ final String aDescription, final ITexture[][][] aTextures) {
+ super(aName, aTier, aInvSlotCount, aDescription, aTextures);
+ this.bOutput = false;
+ this.bRedstoneIfFull = false;
+ this.bInvert = false;
+ this.mSuccess = 0;
+ this.mTargetStackSize = 0;
+ this.mInventorySynchro = new ItemStack[aInvSlotCount];
+ }
+
+ public GT_MetaTileEntity_ThreadedBuffer(final String aName, final int aTier, final int aInvSlotCount,
+ final String[] aDescription, final ITexture[][][] aTextures) {
+ super(aName, aTier, aInvSlotCount, aDescription, aTextures);
+ this.bOutput = false;
+ this.bRedstoneIfFull = false;
+ this.bInvert = false;
+ this.mSuccess = 0;
+ this.mTargetStackSize = 0;
+ this.mInventorySynchro = new ItemStack[aInvSlotCount];
+ }
+
+ public synchronized final GregtechBufferThread getLogicThread() {
+ if (mLogicThread != null) {
+ return mLogicThread;
+ }
+ else {
+ return this.mLogicThread = GregtechBufferThread.getBufferThread(this.getBaseMetaTileEntity().getWorld());
+ }
+ }
+
+ public ITexture[][][] getTextureSet(final ITexture[] aTextures) {
+ final ITexture[][][] rTextures = new ITexture[6][17][];
+ final ITexture tIcon = this.getOverlayIcon();
+ final ITexture tOut = (ITexture) new GT_RenderedTexture((IIconContainer) Textures.BlockIcons.OVERLAY_PIPE_OUT);
+ final ITexture tUp = (ITexture) new GT_RenderedTexture((IIconContainer) Textures.BlockIcons.ARROW_UP);
+ final ITexture tDown = (ITexture) new GT_RenderedTexture((IIconContainer) Textures.BlockIcons.ARROW_DOWN);
+ final ITexture tLeft = (ITexture) new GT_RenderedTexture((IIconContainer) Textures.BlockIcons.ARROW_LEFT);
+ final ITexture tRight = (ITexture) new GT_RenderedTexture((IIconContainer) Textures.BlockIcons.ARROW_RIGHT);
+ for (byte i = -1; i < 16; ++i) {
+ rTextures[0][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tOut};
+ rTextures[1][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tRight, tIcon};
+ rTextures[2][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tDown, tIcon};
+ rTextures[3][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tLeft, tIcon};
+ rTextures[4][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tUp, tIcon};
+ rTextures[5][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tIcon};
+ }
+ return rTextures;
+ }
+
+ public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing,
+ final byte aColorIndex, final boolean aActive, final boolean aRedstone) {
+ if (aSide == aFacing) {
+ return this.mTextures[5][aColorIndex + 1];
+ }
+ if (GT_Utility.getOppositeSide((int) aSide) == aFacing) {
+ return this.mTextures[0][aColorIndex + 1];
+ }
+ Label_0356 : {
+ switch (aFacing) {
+ case 0 : {
+ return this.mTextures[4][aColorIndex + 1];
+ }
+ case 1 : {
+ return this.mTextures[2][aColorIndex + 1];
+ }
+ case 2 : {
+ switch (aSide) {
+ case 0 : {
+ return this.mTextures[2][aColorIndex + 1];
+ }
+ case 1 : {
+ return this.mTextures[2][aColorIndex + 1];
+ }
+ case 4 : {
+ return this.mTextures[1][aColorIndex + 1];
+ }
+ case 5 : {
+ return this.mTextures[3][aColorIndex + 1];
+ }
+ default : {
+ break Label_0356;
+ }
+ }
+ }
+ case 3 : {
+ switch (aSide) {
+ case 0 : {
+ return this.mTextures[4][aColorIndex + 1];
+ }
+ case 1 : {
+ return this.mTextures[4][aColorIndex + 1];
+ }
+ case 4 : {
+ return this.mTextures[3][aColorIndex + 1];
+ }
+ case 5 : {
+ return this.mTextures[1][aColorIndex + 1];
+ }
+ default : {
+ break Label_0356;
+ }
+ }
+ }
+ case 4 : {
+ switch (aSide) {
+ case 0 : {
+ return this.mTextures[3][aColorIndex + 1];
+ }
+ case 1 : {
+ return this.mTextures[1][aColorIndex + 1];
+ }
+ case 2 : {
+ return this.mTextures[3][aColorIndex + 1];
+ }
+ case 3 : {
+ return this.mTextures[1][aColorIndex + 1];
+ }
+ default : {
+ break Label_0356;
+ }
+ }
+ }
+ case 5 : {
+ switch (aSide) {
+ case 0 : {
+ return this.mTextures[1][aColorIndex + 1];
+ }
+ case 1 : {
+ return this.mTextures[3][aColorIndex + 1];
+ }
+ case 2 : {
+ return this.mTextures[1][aColorIndex + 1];
+ }
+ case 3 : {
+ return this.mTextures[3][aColorIndex + 1];
+ }
+ default : {
+ break Label_0356;
+ }
+ }
+ }
+ }
+ }
+ return this.mTextures[5][aColorIndex + 1];
+ }
+
+ public boolean isSimpleMachine() {
+ return false;
+ }
+
+ public boolean isValidSlot(final int aIndex) {
+ return aIndex < this.mInventorySynchro.length - 1;
+ }
+
+ public boolean isFacingValid(final byte aFacing) {
+ return true;
+ }
+
+ public boolean isEnetInput() {
+ return true;
+ }
+
+ public boolean isEnetOutput() {
+ return true;
+ }
+
+ public boolean isInputFacing(final byte aSide) {
+ return !this.isOutputFacing(aSide);
+ }
+
+ public boolean isOutputFacing(final byte aSide) {
+ return this.getBaseMetaTileEntity().getBackFacing() == aSide;
+ }
+
+ public boolean isTeleporterCompatible() {
+ return false;
+ }
+
+ public long getMinimumStoredEU() {
+ return 512L;
+ }
+
+ public long maxEUStore() {
+ return 512L + GT_Values.V[this.mTier] * 50L;
+ }
+
+ public long maxEUInput() {
+ return GT_Values.V[this.mTier];
+ }
+
+ public long maxEUOutput() {
+ return this.bOutput ? GT_Values.V[this.mTier] : 0L;
+ }
+
+ public long maxAmperesIn() {
+ return 2L;
+ }
+
+ public long maxAmperesOut() {
+ return 2L;
+ }
+
+ public boolean isAccessAllowed(final EntityPlayer aPlayer) {
+ return true;
+ }
+
+ public abstract ITexture getOverlayIcon();
+
+ public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) {
+ if (aBaseMetaTileEntity.isClientSide()) {
+ return true;
+ }
+ aBaseMetaTileEntity.openGUI(aPlayer);
+ return true;
+ }
+
+ public void saveNBTData(final NBTTagCompound aNBT) {
+ aNBT.setBoolean("bInvert", this.bInvert);
+ aNBT.setBoolean("bOutput", this.bOutput);
+ aNBT.setBoolean("bRedstoneIfFull", this.bRedstoneIfFull);
+ aNBT.setInteger("mTargetStackSize", this.mTargetStackSize);
+ }
+
+ public void loadNBTData(final NBTTagCompound aNBT) {
+ this.bInvert = aNBT.getBoolean("bInvert");
+ this.bOutput = aNBT.getBoolean("bOutput");
+ this.bRedstoneIfFull = aNBT.getBoolean("bRedstoneIfFull");
+ this.mTargetStackSize = aNBT.getInteger("mTargetStackSize");
+ }
+
+ public void setItemNBT(final NBTTagCompound aNBT) {
+ super.setItemNBT(aNBT);
+ if (this.mTargetStackSize > 0) {
+ aNBT.setInteger("mTargetStackSize", this.mTargetStackSize);
+ }
+ }
+
+ public void onScrewdriverRightClick(final byte aSide, final EntityPlayer aPlayer, final float aX, final float aY,
+ final float aZ) {
+ if (aSide == this.getBaseMetaTileEntity().getBackFacing()) {
+ this.mTargetStackSize = (byte) ((this.mTargetStackSize + (aPlayer.isSneaking() ? -1 : 1)) % 65);
+ if (this.mTargetStackSize < 0) {
+ this.mTargetStackSize = 64;
+ }
+ if (this.mTargetStackSize == 0) {
+ GT_Utility.sendChatToPlayer(aPlayer, this.trans("098", "Do not regulate Item Stack Size"));
+ } else {
+ GT_Utility.sendChatToPlayer(aPlayer,
+ this.trans("099", "Regulate Item Stack Size to: ") + this.mTargetStackSize);
+ }
+ }
+ }
+
+ public synchronized void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTimer) {
+ getLogicThread().onPostTick(aBaseMetaTileEntity, aTimer, this);
+ }
+
+ public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) {
+ for (byte b = 0; b < 6; ++b) {
+ aBaseMetaTileEntity.setInternalOutputRedstoneSignal(b, (byte) 0);
+ }
+ }
+
+ protected synchronized void moveItems(final IGregTechTileEntity aBaseMetaTileEntity, final long aTimer) {
+ getLogicThread().moveItems(aBaseMetaTileEntity, aTimer, this);
+ }
+
+ public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide,
+ final ItemStack aStack) {
+ return true;
+ }
+
+ public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide,
+ final ItemStack aStack) {
+ return aSide != aBaseMetaTileEntity.getBackFacing();
+ }
+
+ public boolean allowGeneralRedstoneOutput() {
+ return true;
+ }
+
+ //Custom inventory handler
+
+ @Override
+ public synchronized ItemStack[] getRealInventory() {
+ return this.mInventorySynchro;
+ }
+
+ @Override
+ public synchronized boolean canInsertItem(final int aIndex, final ItemStack aStack, final int aSide) {
+ return this.isValidSlot(aIndex) && aStack != null && aIndex < getSizeInventory()
+ && (this.mInventorySynchro[aIndex] == null || GT_Utility.areStacksEqual(aStack, this.mInventorySynchro[aIndex]))
+ && this.allowPutStack(this.getBaseMetaTileEntity(), aIndex, (byte) aSide, aStack);
+ }
+
+ @Override
+ public synchronized boolean canExtractItem(final int aIndex, final ItemStack aStack, final int aSide) {
+ return this.isValidSlot(aIndex) && aStack != null && aIndex < getSizeInventory()
+ && this.allowPullStack(this.getBaseMetaTileEntity(), aIndex, (byte) aSide, aStack);
+ }
+
+ @Override
+ public synchronized int getSizeInventory() {
+ return this.mInventorySynchro.length;
+ }
+
+ @Override
+ public synchronized ItemStack getStackInSlot(final int aIndex) {
+ if (aIndex >= 0 && aIndex < getSizeInventory()) {
+ return this.mInventorySynchro[aIndex];
+ }
+ return null;
+ }
+
+ @Override
+ public synchronized void setInventorySlotContents(final int aIndex, final ItemStack aStack) {
+ if (aIndex >= 0 && aIndex < getSizeInventory()) {
+ this.mInventorySynchro[aIndex] = aStack;
+ }
+ }
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/objects/GregtechBufferThread.java b/src/Java/gtPlusPlus/xmod/gregtech/api/objects/GregtechBufferThread.java
new file mode 100644
index 0000000000..1f92aa45a7
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/objects/GregtechBufferThread.java
@@ -0,0 +1,175 @@
+package gtPlusPlus.xmod.gregtech.api.objects;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.minecraft.init.Items;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.world.World;
+
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.util.GT_Utility;
+
+import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_ThreadedBuffer;
+import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_ThreadedChestBuffer;
+
+public class GregtechBufferThread extends Thread {
+
+ public static final Map<String, GregtechBufferThread> mBufferThreadAllocation = new HashMap<String, GregtechBufferThread>();
+ private final World mWorldRef;
+ private short mLifeCycleTime = 12000;
+
+ public static synchronized final GregtechBufferThread getBufferThread(World world) {
+ if (world != null && mBufferThreadAllocation.containsKey(""+world.provider.dimensionId)){
+ return mBufferThreadAllocation.get(""+world.provider.dimensionId);
+ }
+ else {
+ return new GregtechBufferThread(world);
+ }
+ }
+
+ public GregtechBufferThread(World world) {
+
+ int mID = world != null ? world.provider.dimensionId : Short.MIN_VALUE;
+ if (world != null && !mBufferThreadAllocation.containsKey(""+mID)){
+ mWorldRef = world;
+ mBufferThreadAllocation.put(""+mID, this);
+ }
+ else {
+ this.mLifeCycleTime = 1;
+ mWorldRef = null;
+ }
+ }
+
+ public synchronized void fillStacksIntoFirstSlots(GT_MetaTileEntity_ThreadedChestBuffer mBuffer) {
+ 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
+ || areStacksEqual(mBuffer.mInventorySynchro[i], mBuffer.mInventorySynchro[j]))) {
+ moveStackFromSlotAToSlotB((IInventory) mBuffer.getBaseMetaTileEntity(),
+ (IInventory) mBuffer.getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1);
+ }
+ }
+ }
+ }
+
+ public synchronized boolean moveItems(final IGregTechTileEntity aBaseMetaTileEntity, final long aTimer, GT_MetaTileEntity_ThreadedBuffer mBuffer) {
+ final byte mTargetStackSize = (byte) mBuffer.mTargetStackSize;
+ final int tCost = GT_Utility.moveOneItemStack((Object) aBaseMetaTileEntity,
+ (Object) aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()),
+ aBaseMetaTileEntity.getBackFacing(), aBaseMetaTileEntity.getFrontFacing(), (List<ItemStack>) null, false,
+ (byte) ((mTargetStackSize == 0) ? 64 : ((byte) mTargetStackSize)),
+ (byte) ((mTargetStackSize == 0) ? 1 : ((byte) mTargetStackSize)), (byte) 64, (byte) 1);
+ if (tCost > 0 || aBaseMetaTileEntity.hasInventoryBeenModified()) {
+ mBuffer.mSuccess = 50;
+ aBaseMetaTileEntity.decreaseStoredEnergyUnits((long) Math.abs(tCost), true);
+ return true;
+ }
+ return false;
+ }
+
+ public synchronized void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTimer, GT_MetaTileEntity_ThreadedBuffer mBuffer) {
+ if (aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.isServerSide()
+ && aBaseMetaTileEntity.isUniversalEnergyStored(mBuffer.getMinimumStoredEU())
+ && (aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified()
+ || aTimer % 200L == 0L || mBuffer.mSuccess > 0)) {
+ --mBuffer.mSuccess;
+ moveItems(aBaseMetaTileEntity, aTimer, mBuffer);
+ for (byte b = 0; b < 6; ++b) {
+ aBaseMetaTileEntity.setInternalOutputRedstoneSignal(b, (byte) (mBuffer.bInvert ? 15 : 0));
+ }
+ if (mBuffer.bRedstoneIfFull) {
+ for (byte b = 0; b < 6; ++b) {
+ aBaseMetaTileEntity.setInternalOutputRedstoneSignal(b, (byte) (mBuffer.bInvert ? 0 : 15));
+ }
+ for (int i = 0; i < mBuffer.mInventorySynchro.length; ++i) {
+ if (mBuffer.isValidSlot(i) && mBuffer.mInventorySynchro[i] == null) {
+ for (byte b2 = 0; b2 < 6; ++b2) {
+ aBaseMetaTileEntity.setInternalOutputRedstoneSignal(b2, (byte) (mBuffer.bInvert ? 15 : 0));
+ }
+ aBaseMetaTileEntity.decreaseStoredEnergyUnits(1L, true);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Some GT logic we'd like to move off thread
+ */
+
+ public synchronized static boolean areStacksEqual(final ItemStack aStack1, final ItemStack aStack2) {
+ return areStacksEqual(aStack1, aStack2, false);
+ }
+
+ public synchronized static boolean areStacksEqual(final ItemStack aStack1, final ItemStack aStack2, final boolean aIgnoreNBT) {
+ return aStack1 != null && aStack2 != null && aStack1.getItem() == aStack2.getItem()
+ && (aIgnoreNBT || (aStack1.getTagCompound() == null == (aStack2.getTagCompound() == null)
+ && (aStack1.getTagCompound() == null
+ || aStack1.getTagCompound().equals((Object) aStack2.getTagCompound()))))
+ && (Items.feather.getDamage(aStack1) == Items.feather.getDamage(aStack2)
+ || Items.feather.getDamage(aStack1) == 32767 || Items.feather.getDamage(aStack2) == 32767);
+ }
+
+ public synchronized static byte moveStackFromSlotAToSlotB(final IInventory aTileEntity1, final IInventory aTileEntity2,
+ final int aGrabFrom, final int aPutTo, byte aMaxTargetStackSize, final byte aMinTargetStackSize,
+ final byte aMaxMoveAtOnce, final byte aMinMoveAtOnce) {
+ if (aTileEntity1 == null || aTileEntity2 == null || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0
+ || aMinTargetStackSize > aMaxTargetStackSize || aMaxMoveAtOnce <= 0
+ || aMinMoveAtOnce > aMaxMoveAtOnce) {
+ return 0;
+ }
+ final ItemStack tStack1 = aTileEntity1.getStackInSlot(aGrabFrom);
+ final ItemStack tStack2 = aTileEntity2.getStackInSlot(aPutTo);
+ ItemStack tStack3 = null;
+ if (tStack1 != null) {
+ if (tStack2 != null && !areStacksEqual(tStack1, tStack2)) {
+ return 0;
+ }
+ tStack3 = GT_Utility.copy(tStack1);
+ aMaxTargetStackSize = (byte) Math.min(aMaxTargetStackSize,
+ Math.min(tStack3.getMaxStackSize(),
+ Math.min((tStack2 == null) ? Integer.MAX_VALUE : tStack2.getMaxStackSize(),
+ aTileEntity2.getInventoryStackLimit())));
+ tStack3.stackSize = Math.min(tStack3.stackSize,
+ aMaxTargetStackSize - ((tStack2 == null) ? 0 : tStack2.stackSize));
+ if (tStack3.stackSize > aMaxMoveAtOnce) {
+ tStack3.stackSize = aMaxMoveAtOnce;
+ }
+ if (tStack3.stackSize + ((tStack2 == null) ? 0 : tStack2.stackSize) >= Math.min(tStack3.getMaxStackSize(),
+ aMinTargetStackSize) && tStack3.stackSize >= aMinMoveAtOnce) {
+ tStack3 = aTileEntity1.decrStackSize(aGrabFrom, tStack3.stackSize);
+ aTileEntity1.markDirty();
+ if (tStack3 != null) {
+ if (tStack2 == null) {
+ aTileEntity2.setInventorySlotContents(aPutTo, GT_Utility.copy(tStack3));
+ aTileEntity2.markDirty();
+ } else {
+ final ItemStack itemStack = tStack2;
+ itemStack.stackSize += tStack3.stackSize;
+ aTileEntity2.markDirty();
+ }
+ return (byte) tStack3.stackSize;
+ }
+ }
+ }
+ return 0;
+ }
+
+ @Override
+ public void run() {
+ while (mLifeCycleTime > 0) {
+ mLifeCycleTime--;
+ }
+ if (mLifeCycleTime <= 0) {
+ GregtechBufferThread.mBufferThreadAllocation.remove(""+(mWorldRef != null ? mWorldRef.provider.dimensionId : Short.MIN_VALUE), this);
+ }
+ }
+
+
+
+
+}