diff options
Diffstat (limited to 'src/main/java/gregtech/api/metatileentity')
7 files changed, 59 insertions, 12 deletions
diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 9176d063ce..f2514f1290 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -270,7 +270,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE for (int i = 0; i < tItemList.tagCount(); i++) { NBTTagCompound tTag = tItemList.getCompoundTagAt(i); int tSlot = tTag.getInteger("IntSlot"); - tSlot = shiftInventoryIndex(tSlot, nbtVersion); + tSlot = migrateInventoryIndex(tSlot, nbtVersion); if (tSlot >= 0 && tSlot < mMetaTileEntity.getRealInventory().length) { mMetaTileEntity.getRealInventory()[tSlot] = GT_Utility.loadItem(tTag); } @@ -481,7 +481,8 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE if (mMetaTileEntity.isEnetOutput() && oOutput > 0) { - long tOutputVoltage = Math.max(oOutput, oOutput + (1 << GT_Utility.getTier(oOutput))), tUsableAmperage = Math.min(getOutputAmperage(), (getStoredEU() - mMetaTileEntity.getMinimumStoredEU()) / tOutputVoltage); + long tOutputVoltage = Math.max(oOutput, oOutput + (1L << Math.max(0, GT_Utility.getTier(oOutput) - 1))), + tUsableAmperage = Math.min(getOutputAmperage(), (getStoredEU() - mMetaTileEntity.getMinimumStoredEU()) / tOutputVoltage); if (tUsableAmperage > 0) { long tEU = tOutputVoltage * IEnergyConnected.Util.emitEnergyToNetwork(oOutput, tUsableAmperage, this); mAverageEUOutput[mAverageEUOutputIndex] += tEU; @@ -1403,7 +1404,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE } } - GT_Pollution.addPollution(this, 100000); + GT_Pollution.addPollution(this, GT_Mod.gregtechproxy.mPollutionOnExplosion); mMetaTileEntity.doExplosion(aAmount); } } @@ -2308,9 +2309,13 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE * @param nbtVersion The GregTech version in which the original Inventory Index was saved. * @return The corrected Inventory index */ - private int shiftInventoryIndex(int slotIndex, int nbtVersion){ + private int migrateInventoryIndex(int slotIndex, int nbtVersion){ int oldInputSize, newInputSize, oldOutputSize, newOutputSize; int chemistryUpdateVersion = GT_Mod.calculateTotalGTVersion(509, 31); + int configCircuitAdditionVersion = GT_Mod.calculateTotalGTVersion(509, 40); + // 4 is old GT_MetaTileEntity_BasicMachine.OTHER_SLOT_COUNT + if (nbtVersion < configCircuitAdditionVersion && getMetaTileEntity() instanceof GT_MetaTileEntity_BasicMachine && slotIndex >= 4) + slotIndex += 1; if (mID >= 211 && mID <= 218) {//Assembler if (nbtVersion < chemistryUpdateVersion) { oldInputSize = 2; diff --git a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java index b3c25ff345..3c499aea53 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java @@ -5,6 +5,8 @@ import appeng.me.helpers.AENetworkProxy; import cpw.mods.fml.common.Optional; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import gnu.trove.list.TIntList; +import gnu.trove.list.array.TIntArrayList; import gregtech.api.GregTech_API; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java index bb7b795c36..289a43fdd8 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java @@ -117,7 +117,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity @Override public boolean isFacingValid(byte aSide) { - return aSide > 1; + return true; } @Override @@ -214,7 +214,8 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue); //long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue);//TODO CHECK if (tFluidAmountToUse > 0 && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)) { - GT_Pollution.addPollution(getBaseMetaTileEntity(),10 * getPollution()); + // divided by two because this is called every 10 ticks, not 20 + GT_Pollution.addPollution(getBaseMetaTileEntity(),getPollution()/2); mFluid.amount -= tFluidAmountToUse * tConsumed; } } @@ -229,7 +230,8 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tEmptyContainer)) { aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true); aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); - GT_Pollution.addPollution(getBaseMetaTileEntity(),10 * getPollution()); + // divided by two because this is called every 10 ticks, not 20 + GT_Pollution.addPollution(getBaseMetaTileEntity(),getPollution()/2); } } } 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 e8cac808dd..8f77b6ac5a 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 @@ -31,6 +31,7 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidHandler; import java.util.Arrays; +import java.util.List; import static gregtech.api.enums.GT_Values.V; import static gregtech.api.enums.GT_Values.debugCleanroom; @@ -53,7 +54,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B DID_NOT_FIND_RECIPE = 0, FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS = 1, FOUND_AND_SUCCESSFULLY_USED_RECIPE = 2; - public static final int OTHER_SLOT_COUNT = 4; + public static final int OTHER_SLOT_COUNT = 5; public final ItemStack[] mOutputItems; public final int mInputSlotCount, mAmperage; public boolean mAllowInputFromOutputSide = false, mFluidTransfer = false, mItemTransfer = false, mHasBeenUpdated = false, mStuttering = false, mCharge = false, mDecharge = false; @@ -694,8 +695,11 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B } protected ItemStack[] getAllInputs() { - ItemStack[] rInputs = new ItemStack[mInputSlotCount]; + int tRealInputSlotCount = this.mInputSlotCount + (allowSelectCircuit() ? 1 : 0); + ItemStack[] rInputs = new ItemStack[tRealInputSlotCount]; for (int i = 0; i < mInputSlotCount; i++) rInputs[i] = getInputAt(i); + if (allowSelectCircuit()) + rInputs[mInputSlotCount] = getStackInSlot(getCircuitSlot()); return rInputs; } @@ -850,6 +854,26 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B return mInventory[aIndex] == null; } + public boolean allowSelectCircuit() { + return false; + } + + /** + * This might be non-final in the future, but for now, no, don't change this. + */ + public final int getCircuitSlot() { + return 4; + } + + /** + * Return a list of possible configuration circuit this machine expects. + * + * This list is unmodifiable. Its elements are not supposed to be modified in any way! + */ + public List<ItemStack> getConfigurationCircuits() { + return GregTech_API.getConfigurationCircuitList(); + } + /** * @return the Recipe List which is used for this Machine, this is a useful Default Handler */ 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 281d0f6541..7cd9fe65e1 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 @@ -813,6 +813,10 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ } } + @Override + public boolean allowSelectCircuit() { + return true; + } @Override public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { 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 7b99d78009..552d3d6587 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 @@ -16,7 +16,7 @@ import net.minecraftforge.fluids.FluidTankInfo; /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - * <p/> + * * This is the main construct for my generic Tanks. Filling and emptying behavior have to be implemented manually */ public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_TieredMachineBlock implements IHasFluidDisplayItem { 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 6369c48f8e..f7b15f2c44 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 @@ -398,7 +398,17 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { /** * Gets the pollution this Device outputs to a Muffler per tick (10000 = one Pullution Block) */ - public abstract int getPollutionPerTick(ItemStack aStack); + public int getPollutionPerTick(ItemStack aStack){ + return getPollutionPerSecond(aStack)/20; + } + + /** + * Gets the pollution produced per second by this multiblock, default to 0. Override this with + * its actual value in the code of the multiblock. + */ + public int getPollutionPerSecond(ItemStack aStack){ + return 0; + } /** * Gets the damage to the ItemStack, usually 0 or 1. @@ -539,7 +549,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { GT_Log.exp.println("MultiBlockExplosion at: " +this.getBaseMetaTileEntity().getXCoord()+" | "+this.getBaseMetaTileEntity().getYCoord()+" | "+this.getBaseMetaTileEntity().getZCoord()+" DIMID: "+ this.getBaseMetaTileEntity().getWorld().provider.dimensionId+"."); - GT_Pollution.addPollution(getBaseMetaTileEntity(), 300000); + GT_Pollution.addPollution(getBaseMetaTileEntity(), GT_Mod.gregtechproxy.mPollutionOnExplosion); mInventory[1] = null; for (MetaTileEntity tTileEntity : mInputBusses) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); for (MetaTileEntity tTileEntity : mOutputBusses) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); |