aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common/tileentities
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/common/tileentities')
-rw-r--r--src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java24
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java113
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java8
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java4
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java2
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java2
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java2
-rw-r--r--src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java5
8 files changed, 131 insertions, 29 deletions
diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java
index 7b0723f37d..c71126b146 100644
--- a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java
+++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java
@@ -23,11 +23,19 @@ import static gregtech.api.enums.Textures.BlockIcons.MACHINE_STEELBRICKS_TOP;
import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPE;
public class GT_MetaTileEntity_Boiler_Lava extends GT_MetaTileEntity_Boiler {
+
+ public static final int COOLDOWN_INTERVAL = 20;
+ public static final int ENERGY_PER_LAVA = 1;
+ public static final int CONSUMPTION_PER_HEATUP = 3;
+ public static final int PRODUCTION_PER_SECOND = 600;
+ public static final int POLLUTION_PER_SECOND = 20;
+
public GT_MetaTileEntity_Boiler_Lava(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional, new String[]{
"A Boiler running off Lava",
- "Produces 600L of Steam per second",
- "Causes 20 Pollution per second"});
+ "Produces " + PRODUCTION_PER_SECOND + "L of Steam per second",
+ "Causes " + POLLUTION_PER_SECOND + " Pollution per second",
+ "Consumes " + ((double) CONSUMPTION_PER_HEATUP / ENERGY_PER_LAVA) + "L of Lava every " + COOLDOWN_INTERVAL + " ticks when fully heat up"});
}
public GT_MetaTileEntity_Boiler_Lava(String aName, int aTier, String aDescription, ITexture[][][] aTextures) {
@@ -85,12 +93,12 @@ public class GT_MetaTileEntity_Boiler_Lava extends GT_MetaTileEntity_Boiler {
@Override
protected int getPollution() {
- return 20;
+ return POLLUTION_PER_SECOND;
}
@Override
protected int getProductionPerSecond() {
- return 600;
+ return PRODUCTION_PER_SECOND;
}
@Override
@@ -100,18 +108,18 @@ public class GT_MetaTileEntity_Boiler_Lava extends GT_MetaTileEntity_Boiler {
@Override
protected int getEnergyConsumption() {
- return 3;
+ return CONSUMPTION_PER_HEATUP;
}
@Override
protected int getCooldownInterval() {
- return 20;
+ return COOLDOWN_INTERVAL;
}
@Override
protected void updateFuel(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.bucket.get(Materials.Lava))) {
- this.mProcessingEnergy += 1000;
+ this.mProcessingEnergy += 1000 * ENERGY_PER_LAVA;
aBaseMetaTileEntity.decrStackSize(2, 1);
aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.bucket, Materials.Empty, 1L));
}
@@ -122,7 +130,7 @@ public class GT_MetaTileEntity_Boiler_Lava extends GT_MetaTileEntity_Boiler {
if ((GT_ModHandler.isLava(aFluid)) && (this.mProcessingEnergy < 50)) {
int tFilledAmount = Math.min(50, aFluid.amount);
if (doFill) {
- this.mProcessingEnergy += tFilledAmount;
+ this.mProcessingEnergy += tFilledAmount * ENERGY_PER_LAVA;
}
return tFilledAmount;
}
diff --git a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java
index 12d839d221..ef3689f64c 100644
--- a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java
+++ b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java
@@ -21,8 +21,12 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus;
import gregtech.api.render.TextureFactory;
+import gregtech.api.util.GT_Utility;
+
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTBase;
+import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ME_HATCH;
@@ -30,6 +34,10 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ME_HATCH;
public class GT_MetaTileEntity_Hatch_OutputBus_ME extends GT_MetaTileEntity_Hatch_OutputBus {
private BaseActionSource requestSource = null;
private AENetworkProxy gridProxy = null;
+ ItemStack cachedStack = null;
+ long lastOutputTick = 0;
+ long tickCounter = 0;
+ boolean lastOutputFailed = false;
public GT_MetaTileEntity_Hatch_OutputBus_ME(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional, 1, new String[]{
@@ -65,12 +73,16 @@ public class GT_MetaTileEntity_Hatch_OutputBus_ME extends GT_MetaTileEntity_Hatc
public boolean storeAll(ItemStack aStack) {
if (!GregTech_API.mAE2)
return false;
- int tTotal = aStack.stackSize;
- int tStored = store(aStack);
- aStack.stackSize -= tStored;
- return tTotal == tStored;
+ aStack.stackSize = store(aStack);
+ return aStack.stackSize == 0;
}
+ /**
+ * Attempt to store items in connected ME network. Returns how many items did not fit (if the network was down e.g.)
+ *
+ * @param stack input stack
+ * @return amount of items left over
+ */
@Optional.Method(modid = "appliedenergistics2")
public int store(final ItemStack stack) {
if (stack == null)
@@ -78,17 +90,67 @@ public class GT_MetaTileEntity_Hatch_OutputBus_ME extends GT_MetaTileEntity_Hatc
try {
AENetworkProxy proxy = getProxy();
if (proxy == null)
- return stack.stackSize;
- IMEMonitor<IAEItemStack> sg = proxy.getStorage().getItemInventory();
- final IEnergySource src = proxy.getEnergy();
- IAEItemStack toStore = AEApi.instance().storage().createItemStack(stack);
- IAEItemStack rest = Platform.poweredInsert( src, sg, toStore, getRequest());
- if (rest != null)
- return (int)rest.getStackSize();
+ {
+ lastOutputFailed = true;
+ int cacheSize = cachedStack == null ? 0 : cachedStack.stackSize;
+ cachedStack = null;
+ return stack.stackSize + cacheSize;
+ }
+ if (lastOutputFailed) // if last output failed, don't buffer
+ {
+ IMEMonitor<IAEItemStack> sg = proxy.getStorage().getItemInventory();
+ IAEItemStack toStore = AEApi.instance().storage().createItemStack(stack);
+ IAEItemStack rest = Platform.poweredInsert(proxy.getEnergy(), sg, toStore, getRequest());
+ if (rest != null && rest.getStackSize() > 0)
+ return (int) rest.getStackSize();
+ else
+ lastOutputFailed = false;
+ }
+ else if (cachedStack != null && ((tickCounter > (lastOutputTick+20)) || !cachedStack.isItemEqual(stack)))
+ {
+ lastOutputTick = tickCounter;
+ boolean sameStack = cachedStack.isItemEqual(stack);
+ if (sameStack)
+ cachedStack.stackSize += stack.stackSize;
+ IMEMonitor<IAEItemStack> sg = proxy.getStorage().getItemInventory();
+ IAEItemStack toStore = AEApi.instance().storage().createItemStack(cachedStack);
+ IAEItemStack rest = Platform.poweredInsert(proxy.getEnergy(), sg, toStore, getRequest());
+ if (rest != null && rest.getStackSize() > 0)
+ {
+ lastOutputFailed = true;
+ cachedStack.stackSize = (int)rest.getStackSize();
+ if (sameStack) // return all that was cached to sender
+ {
+ cachedStack = null;
+ return (int) rest.getStackSize();
+ }
+ else // leave the cache, and return input to sender
+ {
+ cachedStack.stackSize = (int)rest.getStackSize();
+ return stack.stackSize;
+ }
+ }
+ else
+ {
+ if (!sameStack)
+ cachedStack = stack.copy();
+ else
+ cachedStack = null;
+ return 0;
+ }
+ }
+ else
+ {
+ if (cachedStack == null)
+ cachedStack = stack.copy();
+ else
+ cachedStack.stackSize += stack.stackSize;
+ }
return 0;
}
catch( final GridAccessException ignored )
{
+ lastOutputFailed = true;
}
return stack.stackSize;
}
@@ -128,4 +190,33 @@ public class GT_MetaTileEntity_Hatch_OutputBus_ME extends GT_MetaTileEntity_Hatc
@Optional.Method(modid = "appliedenergistics2")
public void gridChanged() {
}
+
+ @Override
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
+ tickCounter = aTick;
+ super.onPostTick(aBaseMetaTileEntity, aTick);
+ }
+
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT)
+ {
+ super.saveNBTData(aNBT);
+ if (cachedStack != null) {
+ NBTTagCompound tTag = new NBTTagCompound();
+ cachedStack.writeToNBT(tTag);
+ aNBT.setTag("cachedStack", tTag);
+ }
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ super.loadNBTData(aNBT);
+ NBTBase t = aNBT.getTag("cachedStack");
+ if (t instanceof NBTTagCompound)
+ cachedStack = GT_Utility.loadItem((NBTTagCompound)t);
+ }
+
+ public boolean isLastOutputFailed() {
+ return lastOutputFailed;
+ }
}
diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java
index e1dfc32aba..431241eb84 100644
--- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java
+++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java
@@ -366,7 +366,7 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch {
}
private boolean hasValidFluid() {
- return (!GT_Utility.isBlockInvalid(this.mPrimaryPumpedBlock) && !GT_Utility.isBlockInvalid(this.mSecondaryPumpedBlock));
+ return mPrimaryPumpedBlock != null && mSecondaryPumpedBlock != null;
}
private boolean moveOneDown() {
@@ -522,7 +522,7 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch {
return;
Block aBlock = getBaseMetaTileEntity().getBlock(aX, aY, aZ);
- if (GT_Utility.isBlockValid(aBlock)) {
+ if (aBlock != null) {
if ((aBlock == Blocks.water) || (aBlock == Blocks.flowing_water)) {
this.mPrimaryPumpedBlock = Blocks.water;
this.mSecondaryPumpedBlock = Blocks.flowing_water;
@@ -549,7 +549,7 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch {
Block aBlock = getBaseMetaTileEntity().getBlock(aX, aY, aZ);
- return GT_Utility.isBlockValid(aBlock) &&
+ return aBlock != null &&
(aBlock == Blocks.water ||
aBlock == Blocks.flowing_water ||
aBlock == Blocks.lava ||
@@ -565,7 +565,7 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch {
Block aBlock = getBaseMetaTileEntity().getBlock(aX, aY, aZ);
- if ((GT_Utility.isBlockValid(aBlock)) && ((this.mPrimaryPumpedBlock == aBlock) || (this.mSecondaryPumpedBlock == aBlock))) {
+ if (aBlock != null && ((this.mPrimaryPumpedBlock == aBlock) || (this.mSecondaryPumpedBlock == aBlock))) {
boolean isWaterOrLava = ((this.mPrimaryPumpedBlock == Blocks.water || this.mPrimaryPumpedBlock == Blocks.lava));
if (isWaterOrLava && getBaseMetaTileEntity().getMetaID(aX, aY, aZ) != 0) {
diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java
index 11430c6862..eba61ad1b1 100644
--- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java
+++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java
@@ -86,7 +86,7 @@ public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine {
if (tIndividual != null) {
if (tIndividual.analyze()) {
getFillableStack().amount -= 100;
- this.mOutputItems[0] = GT_Utility.copy(aStack);
+ this.mOutputItems[0] = GT_Utility.copyOrNull(aStack);
aStack.stackSize = 0;
NBTTagCompound tNBT = new NBTTagCompound();
tIndividual.writeToNBT(tNBT);
@@ -97,7 +97,7 @@ public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine {
return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS;
return 2;
}
- this.mOutputItems[0] = GT_Utility.copy(aStack);
+ this.mOutputItems[0] = GT_Utility.copyOrNull(aStack);
aStack.stackSize = 0;
this.mMaxProgresstime = 1;
this.mEUt = 1;
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java
index 6cf19d6867..e486596fe6 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java
@@ -190,7 +190,7 @@ public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_MultiBlockBas
++mGlassCount;
} else {
IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(dX, dY, dZ);
- if ((!this.addMaintenanceToMachineList(tTileEntity, 82)) && (!this.addEnergyInputToMachineList(tTileEntity, 82))) {
+ if ((!this.addMaintenanceToMachineList(tTileEntity, 210)) && (!this.addEnergyInputToMachineList(tTileEntity, 210))) {
if (tBlock instanceof ic2.core.block.BlockIC2Door) {
if ((tMeta & 8) == 0) {
// let's not fiddle with bits anymore.
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java
index d7b7e2aa4d..a57a237060 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java
@@ -207,7 +207,7 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu
if (!storedItem.isItemEqual(miningPipe)) continue;
if (pipes == null) {
- setInventorySlotContents(1, GT_Utility.copy(miningPipe));
+ setInventorySlotContents(1, GT_Utility.copyOrNull(miningPipe));
pipes = getStackInSlot(1);
}
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java
index f1b304a1b1..eab4e9c896 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java
@@ -282,7 +282,7 @@ public abstract class GT_MetaTileEntity_PrimitiveBlastFurnace extends MetaTileEn
for (int i = 0; i < limit; i++) {
int absi = INPUT_SLOTS + i;
if (this.mInventory[absi] == null) {
- this.mInventory[absi] = GT_Utility.copy(this.mOutputItems[i]);
+ this.mInventory[absi] = GT_Utility.copyOrNull(this.mOutputItems[i]);
} else if (GT_Utility.areStacksEqual(this.mInventory[absi], this.mOutputItems[i])) {
this.mInventory[absi].stackSize = Math.min(this.mInventory[absi].getMaxStackSize(),
this.mInventory[absi].stackSize + this.mOutputItems[i].stackSize);
diff --git a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java
index d78dd722fa..9c8c5faaf9 100644
--- a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java
+++ b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java
@@ -102,7 +102,10 @@ public abstract class GT_MetaTileEntity_DigitalChestBase extends GT_MetaTileEnti
@Optional.Method(modid = "appliedenergistics2")
@Override
public boolean isPrioritized(appeng.api.storage.data.IAEItemStack iaeItemStack) {
- return false;
+ ItemStack s = getItemStack();
+ if (s == null || iaeItemStack == null)
+ return false;
+ return iaeItemStack.isSameType(s);
}
@Optional.Method(modid = "appliedenergistics2")