diff options
Diffstat (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity')
46 files changed, 653 insertions, 502 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java index 60ccb1ae37..0c4a66d890 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java @@ -48,10 +48,12 @@ public class BaseCustomTileEntity extends BaseMetaTileEntity implements IBaseCus Logger.MACHINE_INFO("Created new BaseCustomTileEntity"); } + @Override public boolean doesExplode() { return true; } + @Override public void writeToNBT(NBTTagCompound aNBT) { try { super.writeToNBT(aNBT); @@ -70,6 +72,7 @@ public class BaseCustomTileEntity extends BaseMetaTileEntity implements IBaseCus } } + @Override public void doEnergyExplosion() { if (!doesExplode()) { Logger.INFO("Machine tried to explode, let's stop that. xo [doEnergyExplosion]"); @@ -87,6 +90,7 @@ public class BaseCustomTileEntity extends BaseMetaTileEntity implements IBaseCus } } + @Override public void doExplosion(long aAmount) { if (!doesExplode()) { @@ -129,6 +133,7 @@ public class BaseCustomTileEntity extends BaseMetaTileEntity implements IBaseCus } } + @Override public void dropItems(ItemStack tItem) { if (tItem != null) { Random tRandom = new Random(); @@ -161,6 +166,7 @@ public class BaseCustomTileEntity extends BaseMetaTileEntity implements IBaseCus } } + @Override public ArrayList<ItemStack> getDrops() { ArrayList<ItemStack> aDrops = new ArrayList<ItemStack>(); ItemStack rStack = new ItemStack(GregTech_API.sBlockMachines, 1, this.getMetaTileID()); @@ -193,6 +199,7 @@ public class BaseCustomTileEntity extends BaseMetaTileEntity implements IBaseCus return aDrops; } + @Override public boolean isTeleporterCompatible(Direction aSide) { return this.canAccessData() && this.mMetaTileEntity.isTeleporterCompatible(); } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/BaseCustomPower_MTE.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/BaseCustomPower_MTE.java index ba67ba6466..079a9946d1 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/BaseCustomPower_MTE.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/BaseCustomPower_MTE.java @@ -14,26 +14,27 @@ public class BaseCustomPower_MTE extends BaseCustomTileEntity { Logger.INFO("Created new BaseCustomPower_MTE"); } + @Override public boolean doesExplode() { return false; } - public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) { + public long injectEnergyUnits(ForgeDirection side, long aVoltage, long aAmperage) { if (mMetaTileEntity == null) { Logger.INFO("Bad Tile"); } if (this.canAccessData() && this.mMetaTileEntity.isElectric() - && this.inputEnergyFrom(aSide) + && this.inputEnergyFrom(side) && aAmperage > 0L && aVoltage > 0L && this.getStoredEU() < this.getEUCapacity() && this.mMetaTileEntity.maxAmperesIn() >= this.getInputAmperage()) { Logger.INFO("Injecting Energy Units"); - return super.injectEnergyUnits(aSide, aVoltage, aAmperage); + return super.injectEnergyUnits(side, aVoltage, aAmperage); } else { Logger.INFO("canAccessData(): " + canAccessData()); Logger.INFO("isElectric(): " + this.mMetaTileEntity.isElectric()); - Logger.INFO("InputEnergyFromSide(" + aSide + "): " + this.inputEnergyFrom(aSide)); + Logger.INFO("InputEnergyFromSide(" + side + "): " + this.inputEnergyFrom(side)); Logger.INFO("aAmperage: " + aAmperage); Logger.INFO("aVoltage: " + aVoltage); Logger.INFO("this.getStoredEU() < this.getEUCapacity(): " + (this.getStoredEU() < this.getEUCapacity())); @@ -46,10 +47,10 @@ public class BaseCustomPower_MTE extends BaseCustomTileEntity { } } - public boolean drainEnergyUnits(byte aSide, long aVoltage, long aAmperage) { + public boolean drainEnergyUnits(ForgeDirection side, long aVoltage, long aAmperage) { Logger.INFO("Draining Energy Units 4"); if (this.canAccessData() && this.mMetaTileEntity.isElectric() - && this.outputsEnergyTo(aSide) + && this.outputsEnergyTo(side) && this.getStoredEU() - aVoltage * aAmperage >= this.mMetaTileEntity.getMinimumStoredEU()) { if (this.decreaseStoredEU(aVoltage * aAmperage, false)) { this.mAverageEUOutput[this.mAverageEUOutputIndex] = (int) ((long) this.mAverageEUOutput[this.mAverageEUOutputIndex] @@ -77,16 +78,16 @@ public class BaseCustomPower_MTE extends BaseCustomTileEntity { } @Override - public boolean inputEnergyFrom(byte aSide) { + public boolean inputEnergyFrom(ForgeDirection side) { // TODO Auto-generated method stub - return super.inputEnergyFrom(aSide); + return super.inputEnergyFrom(side); } @Override - public boolean outputsEnergyTo(byte aSide) { + public boolean outputsEnergyTo(ForgeDirection side) { Logger.INFO("Draining Energy Units 2"); // TODO Auto-generated method stub - return super.outputsEnergyTo(aSide); + return super.outputsEnergyTo(side); } @Override diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicLosslessGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicLosslessGenerator.java index 0060cba12c..25a1cc3cca 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicLosslessGenerator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicLosslessGenerator.java @@ -1,11 +1,11 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.custom.power; import java.util.Collection; -import java.util.Iterator; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import gregtech.api.enums.GT_Values; @@ -39,6 +39,7 @@ public abstract class GTPP_MTE_BasicLosslessGenerator extends GTPP_MTE_BasicTank super(aName, aTier, 3, aDescription, aTextures); } + @Override public ITexture[][][] getTextureSet(ITexture[] aTextures) { ITexture[][][] rTextures = new ITexture[10][17][]; @@ -58,13 +59,17 @@ public abstract class GTPP_MTE_BasicLosslessGenerator extends GTPP_MTE_BasicTank return rTextures; } - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 - : (aSide == GT_Utility.getOppositeSide(aFacing) ? 1 - : (aSide == 0 ? 2 : (aSide == 1 ? 3 : 4))))][aColorIndex + 1]; + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int aColorIndex, boolean aActive, boolean aRedstone) { + return this.mTextures[(aActive ? 5 : 0) + + (side == facing ? 0 + : (side == facing.getOpposite() ? 1 + : (side == ForgeDirection.DOWN ? 2 : (side == ForgeDirection.UP ? 3 : 4))))][aColorIndex + + 1]; } + @Override public String[] getDescription() { String[] desc = new String[this.mDescriptionArray.length + 1]; System.arraycopy(this.mDescriptionArray, 0, desc, 0, this.mDescriptionArray.length); @@ -72,6 +77,7 @@ public abstract class GTPP_MTE_BasicLosslessGenerator extends GTPP_MTE_BasicTank return desc; } + @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { Logger.WARNING("Right Clicked"); GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); @@ -118,68 +124,82 @@ public abstract class GTPP_MTE_BasicLosslessGenerator extends GTPP_MTE_BasicTank return this.getSides(aColor); } - public boolean isFacingValid(byte aSide) { - return aSide > 1; + public boolean isFacingValid(ForgeDirection side) { + return side.offsetY == 0; } + @Override public boolean isSimpleMachine() { return false; } + @Override public boolean isValidSlot(int aIndex) { return aIndex < 2; } + @Override public boolean isEnetOutput() { return true; } - public boolean isOutputFacing(byte aSide) { + public boolean isOutputFacing(ForgeDirection side) { return true; } + @Override public boolean isAccessAllowed(EntityPlayer aPlayer) { return true; } + @Override public long maxEUOutput() { return this.getBaseMetaTileEntity().isAllowedToWork() ? GT_Values.V[this.mTier] : 0L; } + @Override public long maxEUStore() { return Math.max(this.getEUVar(), GT_Values.V[this.mTier] * 40L + this.getMinimumStoredEU()); } + @Override public boolean doesFillContainers() { return this.getBaseMetaTileEntity().isAllowedToWork(); } + @Override public boolean doesEmptyContainers() { return this.getBaseMetaTileEntity().isAllowedToWork(); } + @Override public boolean canTankBeFilled() { return this.getBaseMetaTileEntity().isAllowedToWork(); } + @Override public boolean canTankBeEmptied() { return this.getBaseMetaTileEntity().isAllowedToWork(); } + @Override public boolean displaysItemStack() { return true; } + @Override public boolean displaysStackSize() { return false; } + @Override public boolean isFluidInputAllowed(FluidStack aFluid) { int aVal = this.getFuelValue(aFluid); Logger.WARNING("Fuel Value: " + aVal); return aVal > 0; } + @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && aTick % 10L == 0L) { int tFuelValue; @@ -250,10 +270,8 @@ public abstract class GTPP_MTE_BasicLosslessGenerator extends GTPP_MTE_BasicTank Collection<GT_Recipe> tRecipeList = this.getRecipes().mRecipeList; if (tRecipeList != null) { Logger.WARNING("Fuels: " + tRecipeList.size()); - Iterator<GT_Recipe> var4 = tRecipeList.iterator(); - while (var4.hasNext()) { - GT_Recipe tFuel = (GT_Recipe) var4.next(); + for (GT_Recipe tFuel : tRecipeList) { FluidStack tLiquid; if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null && aLiquid.isFluidEqual(tLiquid)) { @@ -307,15 +325,19 @@ public abstract class GTPP_MTE_BasicLosslessGenerator extends GTPP_MTE_BasicTank } } - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && (this.getFuelValue(aStack) > 0 + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return super.allowPutStack(aBaseMetaTileEntity, aIndex, side, aStack) && (this.getFuelValue(aStack) > 0 || this.getFuelValue(GT_Utility.getFluidForFilledItem(aStack, true)) > 0); } + @Override public int getCapacity() { return 16000; } + @Override public int getTankPressure() { return -100; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicMachine.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicMachine.java index 6a3856aba3..4bb30d102c 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicMachine.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicMachine.java @@ -46,7 +46,8 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { public final int mInputSlotCount, mAmperage; public boolean mAllowInputFromOutputSide = false, mFluidTransfer = false, mItemTransfer = false, mHasBeenUpdated = false, mStuttering = false, mCharge = false, mDecharge = false; - public int mMainFacing = -1, mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mOutputBlocked = 0; + public int mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mOutputBlocked = 0; + public ForgeDirection mMainFacing = ForgeDirection.UNKNOWN; public FluidStack mOutputFluid; public String mGUIName = "", mNEIName = ""; public GT_MetaTileEntity_MultiBlockBase mCleanroom; @@ -122,15 +123,15 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { mNEIName = aNEIName; } - protected boolean isValidMainFacing(byte aSide) { - return aSide > 1; + protected boolean isValidMainFacing(ForgeDirection side) { + return side.offsetY == 0; } - public boolean setMainFacing(byte aSide) { - if (!isValidMainFacing(aSide)) return false; - mMainFacing = aSide; + public boolean setMainFacing(ForgeDirection side) { + if (!isValidMainFacing(side)) return false; + mMainFacing = side; if (getBaseMetaTileEntity().getFrontFacing() == mMainFacing) { - getBaseMetaTileEntity().setFrontFacing(GT_Utility.getOppositeSide(aSide)); + getBaseMetaTileEntity().setFrontFacing(side.getOpposite()); } onFacingChange(); onMachineBlockUpdate(); @@ -167,16 +168,19 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - return mTextures[mMainFacing < 2 - ? aSide == aFacing ? aActive ? 2 : 3 - : aSide == 0 ? aActive ? 6 : 7 : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1 - : aSide == mMainFacing ? aActive ? 2 : 3 - : (showPipeFacing() && aSide == aFacing) - ? aSide == 0 ? aActive ? 8 : 9 : aSide == 1 ? aActive ? 10 : 11 : aActive ? 12 : 13 - : aSide == 0 ? aActive ? 6 : 7 - : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1][aColorIndex + 1]; + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int aColorIndex, boolean aActive, boolean aRedstone) { + return mTextures[mMainFacing.offsetY != 0 + ? side == facing ? aActive ? 2 : 3 + : side == ForgeDirection.DOWN ? aActive ? 6 : 7 + : side == ForgeDirection.UP ? aActive ? 4 : 5 : aActive ? 0 : 1 + : side == mMainFacing ? aActive ? 2 : 3 + : (showPipeFacing() && side == facing) + ? side == ForgeDirection.DOWN ? aActive ? 8 : 9 + : side == ForgeDirection.UP ? aActive ? 10 : 11 : aActive ? 12 : 13 + : side == ForgeDirection.DOWN ? aActive ? 6 : 7 + : side == ForgeDirection.UP ? aActive ? 4 : 5 : aActive ? 0 : 1][aColorIndex + + 1]; } @Override @@ -206,8 +210,8 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { } @Override - public boolean isFacingValid(byte aFacing) { - return mMainFacing > 1 || aFacing > 1; + public boolean isFacingValid(ForgeDirection facing) { + return mMainFacing.offsetY == 0 || facing.offsetY == 0; } @Override @@ -216,12 +220,12 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { } @Override - public boolean isInputFacing(byte aSide) { - return aSide != mMainFacing; + public boolean isInputFacing(ForgeDirection side) { + return side != mMainFacing; } @Override - public boolean isOutputFacing(byte aSide) { + public boolean isOutputFacing(ForgeDirection side) { return false; } @@ -231,13 +235,13 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { } @Override - public boolean isLiquidInput(byte aSide) { - return aSide != mMainFacing && (mAllowInputFromOutputSide || aSide != getBaseMetaTileEntity().getFrontFacing()); + public boolean isLiquidInput(ForgeDirection side) { + return side != mMainFacing && (mAllowInputFromOutputSide || side != getBaseMetaTileEntity().getFrontFacing()); } @Override - public boolean isLiquidOutput(byte aSide) { - return aSide != mMainFacing; + public boolean isLiquidOutput(ForgeDirection side) { + return side != mMainFacing; } @Override @@ -385,7 +389,7 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { @Override public void initDefaultModes(NBTTagCompound aNBT) { - mMainFacing = -1; + mMainFacing = ForgeDirection.UNKNOWN; } @Override @@ -396,7 +400,7 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { aNBT.setBoolean("mHasBeenUpdated", mHasBeenUpdated); aNBT.setBoolean("mAllowInputFromOutputSide", mAllowInputFromOutputSide); aNBT.setInteger("mEUt", mEUt); - aNBT.setInteger("mMainFacing", mMainFacing); + aNBT.setInteger("mMainFacing", mMainFacing.ordinal()); aNBT.setInteger("mProgresstime", mProgresstime); aNBT.setInteger("mMaxProgresstime", mMaxProgresstime); if (mOutputFluid != null) aNBT.setTag("mOutputFluid", mOutputFluid.writeToNBT(new NBTTagCompound())); @@ -414,7 +418,7 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { mHasBeenUpdated = aNBT.getBoolean("mHasBeenUpdated"); mAllowInputFromOutputSide = aNBT.getBoolean("mAllowInputFromOutputSide"); mEUt = aNBT.getInteger("mEUt"); - mMainFacing = aNBT.getInteger("mMainFacing"); + mMainFacing = ForgeDirection.getOrientation(aNBT.getInteger("mMainFacing")); mProgresstime = aNBT.getInteger("mProgresstime"); mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); mOutputFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mOutputFluid")); @@ -477,14 +481,9 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { if (tTank != null) { FluidStack tDrained = drain(1000, false); if (tDrained != null) { - int tFilledAmount = tTank.fill( - ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), - tDrained, - false); - if (tFilledAmount > 0) tTank.fill( - ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), - drain(tFilledAmount, true), - true); + |
