aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/metatileentity/implementations
diff options
context:
space:
mode:
authorPrometheus0000 <prometheus0000000@gmail.com>2021-04-26 19:32:52 -0400
committerGitHub <noreply@github.com>2021-04-26 19:32:52 -0400
commit4959a2d1a0c86fd75ca8e38cfbfa8b87adb8cd45 (patch)
treefab581fe42bb3e14e0e8cbff5c00711ab7ebe9de /src/main/java/gregtech/api/metatileentity/implementations
parentd7467b6d1a47190bf36eaa01758f9136a417cc1a (diff)
parent037fce95062f900e4e816ad103d3f70b1ae6da2a (diff)
downloadGT5-Unofficial-4959a2d1a0c86fd75ca8e38cfbfa8b87adb8cd45.tar.gz
GT5-Unofficial-4959a2d1a0c86fd75ca8e38cfbfa8b87adb8cd45.tar.bz2
GT5-Unofficial-4959a2d1a0c86fd75ca8e38cfbfa8b87adb8cd45.zip
Merge pull request #28 from GTNewHorizons/experimental
update
Diffstat (limited to 'src/main/java/gregtech/api/metatileentity/implementations')
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java3
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java3
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java6
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java3
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java13
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java5
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java38
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java35
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java38
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java45
10 files changed, 140 insertions, 49 deletions
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java
index 02d6752bdd..19b6d26237 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java
@@ -294,6 +294,7 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile
@Override
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
+ super.onPostTick(aBaseMetaTileEntity, aTick);
if (aBaseMetaTileEntity.isServerSide()) {
{ //amp handler
@@ -358,7 +359,7 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile
mTransferredAmperageLast20 = 0;
if (!GT_Mod.gregtechproxy.gt6Cable || mCheckConnections) checkConnections();
}
- } else if(aBaseMetaTileEntity.isClientSide() && GT_Client.changeDetected==4) aBaseMetaTileEntity.issueTextureUpdate();
+ }
}
@Override
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java
index e6c24ec4b1..708bbf2ca8 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java
@@ -232,6 +232,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity {
@Override
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
+ super.onPostTick(aBaseMetaTileEntity, aTick);
if (aBaseMetaTileEntity.isServerSide() && aTick % 5 == 0) {
mLastReceivedFrom &= 63;
if (mLastReceivedFrom == 63) {
@@ -256,7 +257,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity {
oLastReceivedFrom = mLastReceivedFrom;
- } else if(aBaseMetaTileEntity.isClientSide() && GT_Client.changeDetected==4) aBaseMetaTileEntity.issueTextureUpdate();
+ }
}
private boolean checkEnvironment(int index, IGregTechTileEntity aBaseMetaTileEntity) {
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java
index 7074d63422..455d327209 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java
@@ -6,6 +6,7 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.MetaPipeEntity;
import gregtech.api.objects.GT_RenderedTexture;
+import gregtech.api.util.GT_LanguageManager;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_ModHandler.RecipeBits;
import gregtech.api.util.GT_OreDictUnificator;
@@ -15,6 +16,9 @@ import net.minecraft.nbt.NBTTagCompound;
import static gregtech.api.enums.GT_Values.RA;
public class GT_MetaPipeEntity_Frame extends MetaPipeEntity {
+ private static final String localizedDescFormat = GT_LanguageManager.addStringLocalization(
+ "gt.blockmachines.gt_frame.desc.format",
+ "Just something you can put covers on.");
public final Materials mMaterial;
public GT_MetaPipeEntity_Frame(int aID, String aName, String aNameRegional, Materials aMaterial) {
@@ -48,7 +52,7 @@ public class GT_MetaPipeEntity_Frame extends MetaPipeEntity {
@Override
public String[] getDescription() {
- return new String[]{"Just something you can put a Cover or CFoam on."};
+ return localizedDescFormat.split("\\R");
}
@Override
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java
index 6ed5a9edd0..1bbae2821b 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java
@@ -156,6 +156,7 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE
@Override
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
+ super.onPostTick(aBaseMetaTileEntity, aTick);
if (aBaseMetaTileEntity.isServerSide() && aTick % 10 == 0) {
if (aTick % mTickTime == 0) mTransferredItems = 0;
@@ -181,7 +182,7 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE
if (isInventoryEmpty()) mLastReceivedFrom = 6;
oLastReceivedFrom = mLastReceivedFrom;
- }else if(aBaseMetaTileEntity.isClientSide() && GT_Client.changeDetected==4) aBaseMetaTileEntity.issueTextureUpdate();
+ }
}
@Override
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java
index 4775158319..d940ff6602 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java
@@ -576,7 +576,11 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
mHasBeenUpdated = true;
getBaseMetaTileEntity().setFrontFacing(getBaseMetaTileEntity().getBackFacing());
}
+ }
+ @Override
+ protected void updateFluidDisplayItem() {
+ super.updateFluidDisplayItem();
if (displaysInputFluid()) {
int tDisplayStackSlot = OTHER_SLOT_COUNT + mInputSlotCount + mOutputItems.length;
if (getFillableStack() == null) {
@@ -824,14 +828,17 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
if (aSide == mMainFacing || aIndex < getInputSlot() || aIndex >= getInputSlot() + mInputSlotCount || (!mAllowInputFromOutputSide && aSide == aBaseMetaTileEntity.getFrontFacing()))
return false;
- if (mDisableFilter) return true;
for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++)
if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get(aStack), mInventory[i])) return i == aIndex;
- return true;
+ return mDisableFilter || allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack);
}
+ /**
+ * Test if given stack can be inserted into specified slot.
+ * Before execution of this method it is ensured there is no such kind of item inside any input slots already.
+ */
protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
- return true;
+ return mInventory[aIndex] == null;
}
/**
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java
index 84b9fd9d5f..00ce4051ec 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java
@@ -738,9 +738,8 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_
}
@Override
- public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
- if (!super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) return false;
- if (this.mInventory[aIndex] != null || mDisableFilter) return true;
+ protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ if (!super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack)) return false;
switch (this.mInputSlotCount) {
case 0:
return false;
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java
index 9222029854..219df59723 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java
@@ -21,6 +21,7 @@ import net.minecraftforge.fluids.FluidTankInfo;
public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_TieredMachineBlock {
public FluidStack mFluid;
+ protected int mOpenerCount;
/**
* @param aInvSlotCount should be 3
@@ -133,19 +134,27 @@ public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_Tier
}
@Override
+ public void onOpenGUI() {
+ super.onOpenGUI();
+ mOpenerCount++;
+ if (mOpenerCount == 1)
+ updateFluidDisplayItem();
+ }
+
+ @Override
+ public void onCloseGUI() {
+ super.onCloseGUI();
+ mOpenerCount--;
+ }
+
+ @Override
public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
if (aBaseMetaTileEntity.isServerSide()) {
if (isFluidChangingAllowed() && getFillableStack() != null && getFillableStack().amount <= 0)
setFillableStack(null);
- if (displaysItemStack() && getStackDisplaySlot() >= 0 && getStackDisplaySlot() < mInventory.length) {
- if (getDisplayedFluid() == null) {
- if (ItemList.Display_Fluid.isStackEqual(mInventory[getStackDisplaySlot()], true, true))
- mInventory[getStackDisplaySlot()] = null;
- } else {
- mInventory[getStackDisplaySlot()] = GT_Utility.getFluidDisplayStack(getDisplayedFluid(), displaysStackSize());
- }
- }
+ if (mOpenerCount > 0)
+ updateFluidDisplayItem();
if (doesEmptyContainers()) {
FluidStack tFluid = GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true);
@@ -159,7 +168,7 @@ public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_Tier
}
}
} else {
- if (tFluid.isFluidEqual(getFillableStack()) && tFluid.amount + getFillableStack().amount <= getCapacity()) {
+ if (tFluid.isFluidEqual(getFillableStack()) && ((long)tFluid.amount + getFillableStack().amount) <= (long)getCapacity()) {
if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerItem(mInventory[getInputSlot()], true), 1)) {
getFillableStack().amount += tFluid.amount;
aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1);
@@ -181,6 +190,17 @@ public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_Tier
}
}
+ protected void updateFluidDisplayItem() {
+ if (displaysItemStack() && getStackDisplaySlot() >= 0 && getStackDisplaySlot() < mInventory.length) {
+ if (getDisplayedFluid() == null) {
+ if (ItemList.Display_Fluid.isStackEqual(mInventory[getStackDisplaySlot()], true, true))
+ mInventory[getStackDisplaySlot()] = null;
+ } else {
+ mInventory[getStackDisplaySlot()] = GT_Utility.getFluidDisplayStack(getDisplayedFluid(), displaysStackSize());
+ }
+ }
+ }
+
@Override
public FluidStack getFluid() {
return getDrainableStack();
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java
index 7c57076ae9..d462e8adb9 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java
@@ -20,7 +20,7 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM
private static final int ARROW_UP_INDEX = 4;
private static final int FRONT_INDEX = 5;
- public boolean bOutput = false, bRedstoneIfFull = false, bInvert = false, bStockingMode = false;
+ public boolean bOutput = false, bRedstoneIfFull = false, bInvert = false, bStockingMode = false, bSortStacks = false;
public int mSuccess = 0, mTargetStackSize = 0;
public GT_MetaTileEntity_Buffer(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription) {
@@ -213,6 +213,7 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM
aNBT.setBoolean("bRedstoneIfFull", bRedstoneIfFull);
aNBT.setBoolean("bStockingMode", bStockingMode);
aNBT.setInteger("mTargetStackSize", mTargetStackSize);
+ aNBT.setBoolean("bSortStacks", bSortStacks);
}
@Override
@@ -220,9 +221,13 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM
bInvert = aNBT.getBoolean("bInvert");
bOutput = aNBT.getBoolean("bOutput");
bRedstoneIfFull = aNBT.getBoolean("bRedstoneIfFull");
+ bSortStacks = aNBT.getBoolean("bSortStacks");
if (aNBT.hasKey("bStockingMode")) { // Adding new key to existing NBT, need to protect if it is not there.
bStockingMode = aNBT.getBoolean("bStockingMode");
}
+ if (aNBT.hasKey("bSortStacks")) {
+ bSortStacks = aNBT.getBoolean("bSortStacks");
+ }
mTargetStackSize = aNBT.getInteger("mTargetStackSize");
}
@@ -250,6 +255,7 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) {
if (aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.isServerSide() && (aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified() || aTimer % 200 == 0 || mSuccess > 0)) {
mSuccess--;
+ updateSlots();
moveItems(aBaseMetaTileEntity, aTimer);
for(byte b = 0;b<6;b++)
aBaseMetaTileEntity.setInternalOutputRedstoneSignal(b,bInvert ? (byte)15 : (byte)0);
@@ -300,4 +306,31 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM
public boolean allowGeneralRedstoneOutput(){
return true;
}
+
+ public void updateSlots() {
+ for (int i = 0; i < mInventory.length; i++)
+ if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null;
+ fillStacksIntoFirstSlots();
+ }
+
+ protected void fillStacksIntoFirstSlots() {
+ if (bSortStacks) {
+ for (int i = 0; i < mInventory.length; i++)
+ for (int j = i + 1; j < mInventory.length; j++)
+ if (mInventory[j] != null && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j])))
+ GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1);
+ }
+ }
+
+ @Override
+ public boolean onSolderingToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ if (aPlayer.isSneaking()) {
+ // I was so proud of all this but I literally just copied code from OutputBus
+ bSortStacks = !bSortStacks;
+ GT_Utility.sendChatToPlayer(aPlayer, trans("200", "Sort mode: " + (bSortStacks ? "Disabled" : "Enabled")));
+ return true;
+ }
+ return super.onSolderingToolRightClick(aSide,aWrenchingSide,aPlayer,aX,aY,aZ);
+ }
+
}
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java
index 9c227b8da7..57cfc44ff6 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java
@@ -12,7 +12,7 @@ import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
-import static gregtech.api.util.GT_Utility.*;
+import static gregtech.api.util.GT_Utility.moveMultipleItemStacks;
public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch {
public GT_MetaTileEntity_Hatch_OutputBus(int aID, String aName, String aNameRegional, int aTier) {
@@ -110,6 +110,42 @@ public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch {
}
}
+ /**
+ * Attempt to store as many items as possible into the internal inventory of this output bus.
+ * If you need atomicity you should use {@link gregtech.api.interfaces.tileentity.IHasInventory#addStackToSlot(int, ItemStack)}
+ * @param aStack Assume valid.
+ * Will be mutated.
+ * Take over the ownership. Caller should not retain a reference to this stack if the call returns true.
+ * @return true if stack is fully accepted. false is stack is partially accepted or nothing is accepted
+ */
+ public boolean storeAll(ItemStack aStack) {
+ for (int i = 0, mInventoryLength = mInventory.length; i < mInventoryLength; i++) {
+ ItemStack tSlot = mInventory[i];
+ if (GT_Utility.isStackInvalid(tSlot)) {
+ if (aStack.stackSize <= getInventoryStackLimit()) {
+ mInventory[i] = aStack;
+ return true;
+ }
+ mInventory[i] = aStack.splitStack(getInventoryStackLimit());
+ } else {
+ int tRealStackLimit = Math.min(getInventoryStackLimit(), tSlot.getMaxStackSize());
+ if (tSlot.stackSize < tRealStackLimit &&
+ tSlot.isItemEqual(aStack) &&
+ ItemStack.areItemStackTagsEqual(tSlot, aStack)) {
+ if (aStack.stackSize + tSlot.stackSize <= tRealStackLimit) {
+ mInventory[i].stackSize += aStack.stackSize;
+ return true;
+ } else {
+ // more to serve
+ aStack.stackSize -= tRealStackLimit - tSlot.stackSize;
+ mInventory[i].stackSize = tRealStackLimit;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
@Override
public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
return aSide == aBaseMetaTileEntity.getFrontFacing();
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java
index 3adff2fc3f..193b9d482c 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java
@@ -16,8 +16,6 @@ import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
import gregtech.api.util.GT_Utility;
import gregtech.common.GT_Pollution;
import gregtech.common.items.GT_MetaGenerated_Tool_01;
-import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_OutputBus_ME;
-
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
@@ -310,8 +308,12 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
aBaseMetaTileEntity.setErrorDisplayID((aBaseMetaTileEntity.getErrorDisplayID() & ~127) | (mWrench ? 0 : 1) | (mScrewdriver ? 0 : 2) | (mSoftHammer ? 0 : 4) | (mHardHammer ? 0 : 8) | (mSolderingTool ? 0 : 16) | (mCrowbar ? 0 : 32) | (mMachine ? 0 : 64));
aBaseMetaTileEntity.setActive(mMaxProgresstime > 0);
boolean active=aBaseMetaTileEntity.isActive() && mPollution>0;
- for(GT_MetaTileEntity_Hatch_Muffler aMuffler:mMufflerHatches)
- aMuffler.getBaseMetaTileEntity().setActive(active);
+ for (GT_MetaTileEntity_Hatch_Muffler aMuffler : mMufflerHatches) {
+ IGregTechTileEntity iGTTileEntity = aMuffler.getBaseMetaTileEntity();
+ if (iGTTileEntity != null && !iGTTileEntity.isDead()) {
+ iGTTileEntity.setActive(active);
+ }
+ }
}
}
@@ -341,7 +343,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
}
if (mEUt < 0) {
if (!drainEnergyInput(((long) -mEUt * 10000) / Math.max(1000, mEfficiency))) {
- stopMachine();
+ criticalStopMachine();
return false;
}
}
@@ -393,6 +395,11 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
getBaseMetaTileEntity().disableWorking();
}
+ public void criticalStopMachine() {
+ stopMachine();
+ getBaseMetaTileEntity().setShutdownStatus(true);
+ }
+
public int getRepairStatus() {
return (mWrench ? 1 : 0) + (mScrewdriver ? 1 : 0) + (mSoftHammer ? 1 : 0) + (mHardHammer ? 1 : 0) + (mSolderingTool ? 1 : 0) + (mCrowbar ? 1 : 0);
}
@@ -735,33 +742,15 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
public boolean addOutput(ItemStack aStack) {
if (GT_Utility.isStackInvalid(aStack)) return false;
aStack = GT_Utility.copy(aStack);
+ for (GT_MetaTileEntity_Hatch_OutputBus tHatch : mOutputBusses) {
+ if (isValidMetaTileEntity(tHatch) && tHatch.storeAll(aStack)) {
+ return true;
+ }
+ }
boolean outputSuccess = true;
while (outputSuccess && aStack.stackSize > 0) {
outputSuccess = false;
-
- if (GregTech_API.mAE2) {
- // this separate cycle may be refactored out, after this function will hopefully be totally refactored
- // for now it is here to avoid splitting stack when we have ME output bus
- for (GT_MetaTileEntity_Hatch_OutputBus tHatch : mOutputBusses) {
- // TODO: If ever there will be another hatch storing in some external storage, here should be an interface check
- if (tHatch instanceof GT_MetaTileEntity_Hatch_OutputBus_ME && isValidMetaTileEntity(tHatch)) {
- int rest = ((GT_MetaTileEntity_Hatch_OutputBus_ME) tHatch).store(aStack);
- if (rest != aStack.stackSize)
- outputSuccess = true;
- aStack.stackSize = rest;
- if (rest == 0)
- return true;
- }
- }
- }
ItemStack single = aStack.splitStack(1);
- for (GT_MetaTileEntity_Hatch_OutputBus tHatch : mOutputBusses) {
- if (!outputSuccess && isValidMetaTileEntity(tHatch)) {
- for (int i = tHatch.getSizeInventory() - 1; i >= 0 && !outputSuccess; i--) {
- if (tHatch.getBaseMetaTileEntity().addStackToSlot(i, single)) outputSuccess = true;
- }
- }
- }
for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) {
if (!outputSuccess && isValidMetaTileEntity(tHatch) && tHatch.outputsItems()) {
if (tHatch.getBaseMetaTileEntity().addStackToSlot(1, single)) outputSuccess = true;