From 0669f5eb9d5029a8b94ec552171b0837605f7747 Mon Sep 17 00:00:00 2001 From: draknyte1 Date: Fri, 4 Nov 2016 15:23:26 +1000 Subject: $ Cleaned up the entire project. > Much neat, very nices. --- .../GT_MetaTileEntity_DeluxeTank.java | 418 +- .../implementations/GregtechMetaCondensor.java | 301 +- .../implementations/GregtechMetaEnergyBuffer.java | 564 +-- .../GregtechMetaPipeEntityFluid.java | 547 +-- .../GregtechMetaPipeEntity_Cable.java | 443 ++- .../GregtechMetaPipeEntity_SuperConductor.java | 450 ++- .../implementations/GregtechMetaSafeBlock.java | 110 +- .../GregtechMetaSuperConductorNodeBase.java | 610 +-- .../base/GregtechMetaPipeEntityBase_Cable.java | 541 ++- .../base/GregtechMetaTileEntity.java | 86 +- .../base/GregtechMeta_MultiBlockBase.java | 1826 +++++---- .../GregtechDoubleFuelGeneratorBase.java | 597 +-- .../base/generators/GregtechMetaBoilerBase.java | 621 +-- .../generators/GregtechMetaSolarGenerator.java | 377 +- .../GregtechRocketFuelGeneratorBase.java | 554 +-- .../GregtechBaseMetaTileEntityLossless.java | 4173 +++++++++++--------- .../GregtechMetaPipeEntity_BaseSuperConductor.java | 1292 +++--- .../lossless/GregtechMetaTileEntityLossless.java | 86 +- .../GregtechMetaTileEntityLosslessBasicTank.java | 494 +-- ...chMetaTileEntityLosslessTieredMachineBlock.java | 111 +- .../base/lossless/MetaTileEntityLossless.java | 1758 +++++---- .../base/machines/GregtechMetaSafeBlockBase.java | 479 ++- .../creative/GregtechMetaCreativeEnergyBuffer.java | 380 +- 23 files changed, 9442 insertions(+), 7376 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeTank.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeTank.java index 2effc58f9a..800f6cf875 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeTank.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeTank.java @@ -16,207 +16,303 @@ import net.minecraftforge.fluids.FluidStack; /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! *

- * This is the main construct for my generic Tanks. Filling and emptying behavior have to be implemented manually + * This is the main construct for my generic Tanks. Filling and emptying + * behavior have to be implemented manually */ public abstract class GT_MetaTileEntity_DeluxeTank extends GT_MetaTileEntity_BasicTank { - public FluidStack mFluid; - public FluidStack mFluid2; + public FluidStack mFluid; + public FluidStack mFluid2; /** - * @param aInvSlotCount should be 3 + * @param aInvSlotCount + * should be 3 */ - public GT_MetaTileEntity_DeluxeTank(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) { + public GT_MetaTileEntity_DeluxeTank(final int aID, final String aName, final String aNameRegional, final int aTier, + final int aInvSlotCount, final String aDescription, final ITexture... aTextures) { super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); } - public GT_MetaTileEntity_DeluxeTank(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { + public GT_MetaTileEntity_DeluxeTank(final String aName, final int aTier, final int aInvSlotCount, + final String aDescription, final ITexture[][][] aTextures) { super(aName, aTier, aInvSlotCount, aDescription, aTextures); } @Override - public boolean isSimpleMachine() { - return false; + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, + final ItemStack aStack) { + return aIndex == this.getOutputSlot(); } @Override - public boolean isValidSlot(int aIndex) { - return aIndex != getStackDisplaySlot(); + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, + final ItemStack aStack) { + return aIndex == this.getInputSlot(); } @Override - public void saveNBTData(NBTTagCompound aNBT) { - if (mFluid != null) aNBT.setTag("mFluid", mFluid.writeToNBT(new NBTTagCompound())); - if (mFluid2 != null) aNBT.setTag("mFluid2", mFluid2.writeToNBT(new NBTTagCompound())); - } + public abstract boolean canTankBeEmptied(); @Override - public void loadNBTData(NBTTagCompound aNBT) { - mFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid")); - mFluid2 = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid2")); - } + public abstract boolean canTankBeFilled(); @Override - public abstract boolean doesFillContainers(); + public abstract boolean displaysItemStack(); @Override - public abstract boolean doesEmptyContainers(); + public abstract boolean displaysStackSize(); @Override - public abstract boolean canTankBeFilled(); + public abstract boolean doesEmptyContainers(); @Override - public abstract boolean canTankBeEmptied(); + public abstract boolean doesFillContainers(); @Override - public abstract boolean displaysItemStack(); + public FluidStack drain(final int maxDrain, final boolean doDrain) { + if (this.getDrainableStack() == null || !this.canTankBeEmptied()) { + return null; + } + if (this.getDrainableStack().amount <= 0 && this.isFluidChangingAllowed()) { + this.setDrainableStack(null); + this.getBaseMetaTileEntity().markDirty(); + return null; + } + + int used = maxDrain; + if (this.getDrainableStack().amount < used) { + used = this.getDrainableStack().amount; + } + + if (doDrain) { + this.getDrainableStack().amount -= used; + this.getBaseMetaTileEntity().markDirty(); + } + + final FluidStack drained = this.getDrainableStack().copy(); + drained.amount = used; + + if (this.getDrainableStack().amount <= 0 && this.isFluidChangingAllowed()) { + this.setDrainableStack(null); + this.getBaseMetaTileEntity().markDirty(); + } + + return drained; + } @Override - public abstract boolean displaysStackSize(); + public int fill(final FluidStack aFluid, final boolean doFill) { + if (aFluid == null || aFluid.getFluid().getID() <= 0 || aFluid.amount <= 0 || !this.canTankBeFilled() + || !this.isFluidInputAllowed(aFluid)) { + return 0; + } + + if (this.getFillableStack() == null || this.getFillableStack().getFluid().getID() <= 0) { + if (aFluid.amount <= this.getCapacity()) { + if (doFill) { + this.setFillableStack(aFluid.copy()); + this.getBaseMetaTileEntity().markDirty(); + } + return aFluid.amount; + } + if (doFill) { + this.setFillableStack(aFluid.copy()); + this.getFillableStack().amount = this.getCapacity(); + this.getBaseMetaTileEntity().markDirty(); + } + return this.getCapacity(); + } + + if (!this.getFillableStack().isFluidEqual(aFluid)) { + return 0; + } + + final int space = this.getCapacity() - this.getFillableStack().amount; + if (aFluid.amount <= space) { + if (doFill) { + this.getFillableStack().amount += aFluid.amount; + this.getBaseMetaTileEntity().markDirty(); + } + return aFluid.amount; + } + if (doFill) { + this.getFillableStack().amount = this.getCapacity(); + } + return space; + } @Override - public int getInputSlot() { - return 0; + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, + final IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_DeluxeTank(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName()); } @Override - public int getOutputSlot() { - return 1; + public FluidStack getDisplayedFluid() { + return this.getDrainableStack(); } @Override - public int getStackDisplaySlot() { - return 2; + public FluidStack getDrainableStack() { + return this.getDrainableStackEx(1); } - public int getStackDisplaySlot2() { - return 3; + public FluidStack getDrainableStackEx(final int stackID) { + if (stackID <= 1) { + return this.mFluid; + } + return this.mFluid2; } @Override - public boolean isFluidInputAllowed(FluidStack aFluid) { - return true; + public FluidStack getFillableStack() { + return this.getFillableStackEx(1); + } + + public FluidStack getFillableStackEx(final int stackID) { + if (stackID <= 1) { + return this.mFluid; + } + return this.mFluid2; } @Override - public boolean isFluidChangingAllowed() { - return true; + public FluidStack getFluid() { + return this.getDrainableStack(); } @Override - public FluidStack getFillableStack() { - return getFillableStackEx(1); + public int getFluidAmount() { + return this.getDrainableStack() != null ? this.getDrainableStack().amount : 0; } - public FluidStack getFillableStackEx(int stackID) { - if (stackID <= 1){ - return mFluid; - } - return mFluid2; + @Override + public int getInputSlot() { + return 0; } @Override - public FluidStack setFillableStack(FluidStack aFluid) { - mFluid = aFluid; - return mFluid; + public int getOutputSlot() { + return 1; } - - public FluidStack setFillableStack2(FluidStack aFluid) { - mFluid2 = aFluid; - return mFluid2; + + @Override + public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, + final IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_DeluxeTank(aPlayerInventory, aBaseMetaTileEntity); } @Override - public FluidStack getDrainableStack() { - return getDrainableStackEx(1); + public int getStackDisplaySlot() { + return 2; } - public FluidStack getDrainableStackEx(int stackID) { - if (stackID <= 1){ - return mFluid; - } - return mFluid2; + public int getStackDisplaySlot2() { + return 3; } @Override - public FluidStack setDrainableStack(FluidStack aFluid) { - mFluid = aFluid; - return mFluid; + public boolean isFluidChangingAllowed() { + return true; } @Override - public FluidStack getDisplayedFluid() { - return getDrainableStack(); + public boolean isFluidInputAllowed(final FluidStack aFluid) { + return true; } @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new CONTAINER_DeluxeTank(aPlayerInventory, aBaseMetaTileEntity); + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isValidSlot(final int aIndex) { + return aIndex != this.getStackDisplaySlot(); } @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_DeluxeTank(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); + public void loadNBTData(final NBTTagCompound aNBT) { + this.mFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid")); + this.mFluid2 = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid2")); } @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + public void onPreTick(final IGregTechTileEntity aBaseMetaTileEntity, final 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 (this.isFluidChangingAllowed() && this.getFillableStack() != null + && this.getFillableStack().amount <= 0) { + this.setFillableStack(null); } - if (displaysItemStack() && getStackDisplaySlot2() >= 0 && getStackDisplaySlot2() < mInventory.length) { - if (getDrainableStackEx(2) == null) { - if (ItemList.Display_Fluid.isStackEqual(mInventory[getStackDisplaySlot2()], true, true)) - mInventory[getStackDisplaySlot2()] = null; - } else { - mInventory[getStackDisplaySlot2()] = GT_Utility.getFluidDisplayStack(getDrainableStackEx(2), displaysStackSize()); + if (this.displaysItemStack() && this.getStackDisplaySlot() >= 0 + && this.getStackDisplaySlot() < this.mInventory.length) { + if (this.getDisplayedFluid() == null) { + if (ItemList.Display_Fluid.isStackEqual(this.mInventory[this.getStackDisplaySlot()], true, true)) { + this.mInventory[this.getStackDisplaySlot()] = null; + } + } + else { + this.mInventory[this.getStackDisplaySlot()] = GT_Utility + .getFluidDisplayStack(this.getDisplayedFluid(), this.displaysStackSize()); } } - if (doesEmptyContainers()) { - FluidStack tFluid = GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true); - if (tFluid != null && isFluidInputAllowed(tFluid)) { + if (this.displaysItemStack() && this.getStackDisplaySlot2() >= 0 + && this.getStackDisplaySlot2() < this.mInventory.length) { + if (this.getDrainableStackEx(2) == null) { + if (ItemList.Display_Fluid.isStackEqual(this.mInventory[this.getStackDisplaySlot2()], true, true)) { + this.mInventory[this.getStackDisplaySlot2()] = null; + } + } + else { + this.mInventory[this.getStackDisplaySlot2()] = GT_Utility + .getFluidDisplayStack(this.getDrainableStackEx(2), this.displaysStackSize()); + } + } - if (tFluid.isFluidEqual(getDrainableStackEx(1)) || getDrainableStackEx(1) == null){ - if (getFillableStackEx(1) == null) { - if (isFluidInputAllowed(tFluid) && tFluid.amount <= getCapacity()) { - if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerItem(mInventory[getInputSlot()], true), 1)) { - setFillableStack(tFluid.copy()); - aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); + if (this.doesEmptyContainers()) { + final FluidStack tFluid = GT_Utility.getFluidForFilledItem(this.mInventory[this.getInputSlot()], true); + if (tFluid != null && this.isFluidInputAllowed(tFluid)) { + + if (tFluid.isFluidEqual(this.getDrainableStackEx(1)) || this.getDrainableStackEx(1) == null) { + if (this.getFillableStackEx(1) == null) { + if (this.isFluidInputAllowed(tFluid) && tFluid.amount <= this.getCapacity()) { + if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), + GT_Utility.getContainerItem(this.mInventory[this.getInputSlot()], true), 1)) { + this.setFillableStack(tFluid.copy()); + aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); } } - } else { - if (tFluid.isFluidEqual(getFillableStack()) && tFluid.amount + getFillableStack().amount <= getCapacity()) { - if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerItem(mInventory[getInputSlot()], true), 1)) { - getFillableStack().amount += tFluid.amount; - aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); + } + else { + if (tFluid.isFluidEqual(this.getFillableStack()) + && tFluid.amount + this.getFillableStack().amount <= this.getCapacity()) { + if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), + GT_Utility.getContainerItem(this.mInventory[this.getInputSlot()], true), 1)) { + this.getFillableStack().amount += tFluid.amount; + aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); } } } } - else if (tFluid.isFluidEqual(getDrainableStackEx(2)) || (getDrainableStackEx(2) == null)){ - if (getFillableStackEx(2) == null) { - if (isFluidInputAllowed(tFluid) && tFluid.amount <= getCapacity()) { - if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerItem(mInventory[getInputSlot()], true), 1)) { - setFillableStack2(tFluid.copy()); - aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); + else if (tFluid.isFluidEqual(this.getDrainableStackEx(2)) || this.getDrainableStackEx(2) == null) { + if (this.getFillableStackEx(2) == null) { + if (this.isFluidInputAllowed(tFluid) && tFluid.amount <= this.getCapacity()) { + if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), + GT_Utility.getContainerItem(this.mInventory[this.getInputSlot()], true), 1)) { + this.setFillableStack2(tFluid.copy()); + aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); } } - } else { - if (tFluid.isFluidEqual(getFillableStackEx(2)) && tFluid.amount + getFillableStackEx(2).amount <= getCapacity()) { - if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerItem(mInventory[getInputSlot()], true), 1)) { - getFillableStackEx(2).amount += tFluid.amount; - aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); + } + else { + if (tFluid.isFluidEqual(this.getFillableStackEx(2)) + && tFluid.amount + this.getFillableStackEx(2).amount <= this.getCapacity()) { + if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), + GT_Utility.getContainerItem(this.mInventory[this.getInputSlot()], true), 1)) { + this.getFillableStackEx(2).amount += tFluid.amount; + aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); } } } @@ -227,101 +323,47 @@ public abstract class GT_MetaTileEntity_DeluxeTank extends GT_MetaTileEntity_Bas } } - if (doesFillContainers()) { - ItemStack tOutput = GT_Utility.fillFluidContainer(getDrainableStack(), mInventory[getInputSlot()], false, true); - if (tOutput != null && aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tOutput, 1)) { - FluidStack tFluid = GT_Utility.getFluidForFilledItem(tOutput, true); - aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); - if (tFluid != null) getDrainableStack().amount -= tFluid.amount; - if (getDrainableStack().amount <= 0 && isFluidChangingAllowed()) setDrainableStack(null); + if (this.doesFillContainers()) { + final ItemStack tOutput = GT_Utility.fillFluidContainer(this.getDrainableStack(), + this.mInventory[this.getInputSlot()], false, true); + if (tOutput != null && aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), tOutput, 1)) { + final FluidStack tFluid = GT_Utility.getFluidForFilledItem(tOutput, true); + aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); + if (tFluid != null) { + this.getDrainableStack().amount -= tFluid.amount; + } + if (this.getDrainableStack().amount <= 0 && this.isFluidChangingAllowed()) { + this.setDrainableStack(null); + } } } } } @Override - public FluidStack getFluid() { - return getDrainableStack(); - } - - @Override - public int getFluidAmount() { - return getDrainableStack() != null ? getDrainableStack().amount : 0; - } - - @Override - public int fill(FluidStack aFluid, boolean doFill) { - if (aFluid == null || aFluid.getFluid().getID() <= 0 || aFluid.amount <= 0 || !canTankBeFilled() || !isFluidInputAllowed(aFluid)) - return 0; - - if (getFillableStack() == null || getFillableStack().getFluid().getID() <= 0) { - if (aFluid.amount <= getCapacity()) { - if (doFill) { - setFillableStack(aFluid.copy()); - getBaseMetaTileEntity().markDirty(); - } - return aFluid.amount; - } - if (doFill) { - setFillableStack(aFluid.copy()); - getFillableStack().amount = getCapacity(); - getBaseMetaTileEntity().markDirty(); - } - return getCapacity(); + public void saveNBTData(final NBTTagCompound aNBT) { + if (this.mFluid != null) { + aNBT.setTag("mFluid", this.mFluid.writeToNBT(new NBTTagCompound())); } - - if (!getFillableStack().isFluidEqual(aFluid)) - return 0; - - int space = getCapacity() - getFillableStack().amount; - if (aFluid.amount <= space) { - if (doFill) { - getFillableStack().amount += aFluid.amount; - getBaseMetaTileEntity().markDirty(); - } - return aFluid.amount; + if (this.mFluid2 != null) { + aNBT.setTag("mFluid2", this.mFluid2.writeToNBT(new NBTTagCompound())); } - if (doFill) - getFillableStack().amount = getCapacity(); - return space; } @Override - public FluidStack drain(int maxDrain, boolean doDrain) { - if (getDrainableStack() == null || !canTankBeEmptied()) return null; - if (getDrainableStack().amount <= 0 && isFluidChangingAllowed()) { - setDrainableStack(null); - getBaseMetaTileEntity().markDirty(); - return null; - } - - int used = maxDrain; - if (getDrainableStack().amount < used) - used = getDrainableStack().amount; - - if (doDrain) { - getDrainableStack().amount -= used; - getBaseMetaTileEntity().markDirty(); - } - - FluidStack drained = getDrainableStack().copy(); - drained.amount = used; - - if (getDrainableStack().amount <= 0 && isFluidChangingAllowed()) { - setDrainableStack(null); - getBaseMetaTileEntity().markDirty(); - } - - return drained; + public FluidStack setDrainableStack(final FluidStack aFluid) { + this.mFluid = aFluid; + return this.mFluid; } @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aIndex == getOutputSlot(); + public FluidStack setFillableStack(final FluidStack aFluid) { + this.mFluid = aFluid; + return this.mFluid; } - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aIndex == getInputSlot(); + public FluidStack setFillableStack2(final FluidStack aFluid) { + this.mFluid2 = aFluid; + return this.mFluid2; } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaCondensor.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaCondensor.java index dcecc3ff34..4836ee0e42 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaCondensor.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaCondensor.java @@ -18,148 +18,165 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidHandler; -public class GregtechMetaCondensor extends GregtechMetaBoilerBase{ +public class GregtechMetaCondensor extends GregtechMetaBoilerBase { - public GregtechMetaCondensor(int aID, String aName, String aNameRegional) - { - super(aID, aName, aNameRegional, "A Steam condenser - [IC2->Steam]", new ITexture[0]); - } - - public GregtechMetaCondensor(String aName, int aTier, String aDescription, ITexture[][][] aTextures) - { - super(aName, aTier, aDescription, aTextures); - } - - @Override - public String[] getDescription() { - return new String[] {mDescription, CORE.GT_Tooltip}; + public GregtechMetaCondensor(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional, "A Steam condenser - [IC2->Steam]", new ITexture[0]); + } + + public GregtechMetaCondensor(final String aName, final int aTier, final String aDescription, + final ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public final int fill(final FluidStack aFluid, final boolean doFill) { + if (Utils.isIC2Steam(aFluid) && this.mProcessingEnergy < 50) { + final int tFilledAmount = Math.min(50, aFluid.amount); + if (doFill) { + this.mProcessingEnergy += tFilledAmount; + } + return tFilledAmount; + } + return super.fill(aFluid, doFill); + } + + @Override + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, + final IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_SteamCondenser(aPlayerInventory, aBaseMetaTileEntity, "SteelBoiler.png", 32000); + } + + @Override + public String[] getDescription() { + return new String[] { + this.mDescription, CORE.GT_Tooltip + }; + } + + @Override + public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, + final IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_SteamCondenser(aPlayerInventory, aBaseMetaTileEntity, 32000); + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[5][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = new ITexture[] { + new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, + Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)) + }; + rTextures[1][i + 1] = new ITexture[] { + new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, + Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE) + }; + rTextures[2][i + 1] = new ITexture[] { + new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, + Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE) + }; + rTextures[3][i + 1] = new ITexture[] { + new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, + Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_POTIONBREWER) + }; + rTextures[4][i + 1] = new ITexture[] { + new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, + Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_POTIONBREWER_ACTIVE) + }; + } + return rTextures; + } + + @Override + public int maxProgresstime() { + return 1000; + } + + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaCondensor(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + this.RI = MathUtils.randLong(5L, 30L); + if (aBaseMetaTileEntity.isServerSide() && aTick > 20L) { + if (this.mTemperature <= 5) { + this.mTemperature = 5; + this.mLossTimer = 0; + } + if (++this.mLossTimer > 10) { + this.mTemperature -= 1; + this.mLossTimer = 0; + } + for (byte i = 1; this.mSteam != null && i < 6; i = (byte) (i + 1)) { + if (i != aBaseMetaTileEntity.getFrontFacing()) { + final IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(i); + if (tTileEntity != null) { + final FluidStack tDrained = aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), + Math.max(1, this.mSteam.amount / 2), false); + if (tDrained != null) { + final int tFilledAmount = tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), + tDrained, false); + if (tFilledAmount > 0) { + tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), aBaseMetaTileEntity + .drain(ForgeDirection.getOrientation(i), tFilledAmount, true), true); + } + } + } + } + } + if (aTick % 10L == 0L) { + if (this.mTemperature > 5) { + if (this.mFluid == null || !GT_ModHandler.isWater(this.mFluid) || this.mFluid.amount <= 0) { + this.mHadNoWater = true; + } + else { + if (this.mHadNoWater) { + aBaseMetaTileEntity.doExplosion(2048L); + return; + } + this.mFluid.amount -= 1; + if (this.mSteam == null) { + this.mSteam = GT_ModHandler.getSteam(30L); + } + else if (GT_ModHandler.isSteam(this.mSteam)) { + this.mSteam.amount += 30; + } + else { + this.mSteam = GT_ModHandler.getSteam(30L); + } + } + } + else { + this.mHadNoWater = false; + } + } + if (this.mSteam != null && this.mSteam.amount > 32000) { + this.sendSound((byte) 1); + this.mSteam.amount = 24000; + } + /* + * if ((this.mProcessingEnergy <= 0) && + * (aBaseMetaTileEntity.isAllowedToWork()) && + * (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], + * OrePrefixes.bucket.get(IC2.getItemFromBlock(p_150898_0_))))) { + * this.mProcessingEnergy += 1000; + * aBaseMetaTileEntity.decrStackSize(2, 1); + * aBaseMetaTileEntity.addStackToSlot(3, + * GT_OreDictUnificator.get(OrePrefixes.bucket, Materials.Empty, + * 1L)); } + */ + if (this.mTemperature < 1000 && this.mProcessingEnergy > 0 && aTick % this.RI == 0L) { + this.mProcessingEnergy -= 40; + this.mTemperature += 2; + } + aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0); } - - public ITexture[][][] getTextureSet(ITexture[] aTextures) - { - ITexture[][][] rTextures = new ITexture[5][17][]; - for (byte i = -1; i < 16; i++){ - rTextures[0][(i + 1)] = new ITexture [] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa))}; - rTextures[1][(i + 1)] = new ITexture [] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE) }; - rTextures[2][(i + 1)] = new ITexture [] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE) }; - rTextures[3][(i + 1)] = new ITexture [] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_POTIONBREWER) }; - rTextures[4][(i + 1)] = new ITexture [] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_POTIONBREWER_ACTIVE) }; - } - return rTextures; - } - - public int maxProgresstime() - { - return 1000; - } - - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) - { - return new CONTAINER_SteamCondenser(aPlayerInventory, aBaseMetaTileEntity, 32000); - } - - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) - { - return new GUI_SteamCondenser(aPlayerInventory, aBaseMetaTileEntity, "SteelBoiler.png", 32000); - } - - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) - { - return new GregtechMetaCondensor(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) - { - this.RI = MathUtils.randLong(5L, 30L); - if ((aBaseMetaTileEntity.isServerSide()) && (aTick > 20L)) - { - if (this.mTemperature <= 5) - { - this.mTemperature = 5; - this.mLossTimer = 0; - } - if (++this.mLossTimer > 10) - { - this.mTemperature -= 1; - this.mLossTimer = 0; - } - for (byte i = 1; (this.mSteam != null) && (i < 6); i = (byte)(i + 1)) { - if (i != aBaseMetaTileEntity.getFrontFacing()) - { - IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(i); - if (tTileEntity != null) - { - FluidStack tDrained = aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), Math.max(1, this.mSteam.amount / 2), false); - if (tDrained != null) - { - int tFilledAmount = tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), tDrained, false); - if (tFilledAmount > 0) { - tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), tFilledAmount, true), true); - } - } - } - } - } - if (aTick % 10L == 0L) { - if (this.mTemperature > 5) - { - if ((this.mFluid == null) || (!GT_ModHandler.isWater(this.mFluid)) || (this.mFluid.amount <= 0)) - { - this.mHadNoWater = true; - } - else - { - if (this.mHadNoWater) - { - aBaseMetaTileEntity.doExplosion(2048L); - return; - } - this.mFluid.amount -= 1; - if (this.mSteam == null) { - this.mSteam = GT_ModHandler.getSteam(30L); - } else if (GT_ModHandler.isSteam(this.mSteam)) { - this.mSteam.amount += 30; - } else { - this.mSteam = GT_ModHandler.getSteam(30L); - } - } - } - else { - this.mHadNoWater = false; - } - } - if ((this.mSteam != null) && - (this.mSteam.amount > 32000)) - { - sendSound((byte)1); - this.mSteam.amount = 24000; - } - /*if ((this.mProcessingEnergy <= 0) && (aBaseMetaTileEntity.isAllowedToWork()) && - (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.bucket.get(IC2.getItemFromBlock(p_150898_0_))))) - { - this.mProcessingEnergy += 1000; - aBaseMetaTileEntity.decrStackSize(2, 1); - aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.bucket, Materials.Empty, 1L)); - }*/ - if ((this.mTemperature < 1000) && (this.mProcessingEnergy > 0) && (aTick % RI == 0L)) - { - this.mProcessingEnergy -= 40; - this.mTemperature += 2; - } - aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0); - } - } - - public final int fill(FluidStack aFluid, boolean doFill) - { - if ((Utils.isIC2Steam(aFluid)) && (this.mProcessingEnergy < 50)) - { - int tFilledAmount = Math.min(50, aFluid.amount); - if (doFill) { - this.mProcessingEnergy += tFilledAmount; - } - return tFilledAmount; - } - return super.fill(aFluid, doFill); - } + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaEnergyBuffer.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaEnergyBuffer.java index ac17000fe8..9236d091fc 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaEnergyBuffer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaEnergyBuffer.java @@ -1,7 +1,6 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; -import static gregtech.api.enums.GT_Values.V; - +import gregtech.api.enums.GT_Values; import gregtech.api.enums.Textures; import gregtech.api.gui.GT_Container_1by1; import gregtech.api.gui.GT_GUIContainer_1by1; @@ -31,113 +30,92 @@ public class GregtechMetaEnergyBuffer extends GregtechMetaTileEntity { * setCreativeTab(GregTech_API.TAB_GREGTECH); } */ - public boolean mCharge = false, mDecharge = false; - public int mBatteryCount = 1, mChargeableCount = 1; + public boolean mCharge = false, mDecharge = false; + public int mBatteryCount = 1, mChargeableCount = 1; + + private long count = 0; + + private long mStored = 0; + + private long mMax = 0; + + /* + * MACHINE_STEEL_SIDE + */ - public GregtechMetaEnergyBuffer(int aID, String aName, String aNameRegional, int aTier, String aDescription, int aSlotCount) { + public GregtechMetaEnergyBuffer(final int aID, final String aName, final String aNameRegional, final int aTier, + final String aDescription, final int aSlotCount) { super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); } - public GregtechMetaEnergyBuffer(String aName, int aTier, String aDescription, ITexture[][][] aTextures, int aSlotCount) { + public GregtechMetaEnergyBuffer(final String aName, final int aTier, final String aDescription, + final ITexture[][][] aTextures, final int aSlotCount) { super(aName, aTier, aSlotCount, aDescription, aTextures); } @Override - public String[] getDescription() { - return new String[] {mDescription, CORE.GT_Tooltip}; + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, + final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, + final ItemStack aStack) { + return false; + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + return false; + } + + @Override + public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + return false; + } + + @Override + public void closeInventory() { + } + + @Override + public int dechargerSlotCount() { + return this.mDecharge ? this.mInventory.length : 0; + } + + @Override + public int dechargerSlotStartIndex() { + return 0; + } + + @Override + public ItemStack decrStackSize(final int p_70298_1_, final int p_70298_2_) { + return null; + } + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + return null; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange) + }; } /* - * MACHINE_STEEL_SIDE + * @Override public ITexture[][][] getTextureSet(ITexture[] aTextures) { + * ITexture[][][] rTextures = new ITexture[2][17][]; for (byte i = -1; i < + * 16; i++) { rTextures[0][i + 1] = new ITexture[] { new GT_RenderedTexture( + * Textures.BlockIcons.MACHINE_HEATPROOFCASING) }; rTextures[1][i + 1] = new + * ITexture[] { new GT_RenderedTexture( + * Textures.BlockIcons.MACHINE_HEATPROOFCASING), mInventory.length > 4 ? + * Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier] : + * Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier] }; } return rTextures; } */ - - @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = getFront(i); - rTextures[1][i + 1] = getBack(i); - rTextures[2][i + 1] = getBottom(i); - rTextures[3][i + 1] = getTop(i); - rTextures[4][i + 1] = getSides(i); - rTextures[5][i + 1] = getFrontActive(i); - rTextures[6][i + 1] = getBackActive(i); - rTextures[7][i + 1] = getBottomActive(i); - rTextures[8][i + 1] = getTopActive(i); - rTextures[9][i + 1] = getSidesActive(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; - } - - - public ITexture[] getFront(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; - } - - - public ITexture[] getBack(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; - } - - - public ITexture[] getBottom(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; - } - - - public ITexture[] getTop(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Screen_Logo)}; - } - - - public ITexture[] getSides(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; - } - - - public ITexture[] getFrontActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; - } - - - public ITexture[] getBackActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; - } - - - public ITexture[] getBottomActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; - } - - - public ITexture[] getTopActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Screen_Logo)}; - } - - - public ITexture[] getSidesActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; - } - - /*@Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - ITexture[][][] rTextures = new ITexture[2][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = new ITexture[] { new GT_RenderedTexture( - Textures.BlockIcons.MACHINE_HEATPROOFCASING) }; - rTextures[1][i + 1] = new ITexture[] { - new GT_RenderedTexture( - Textures.BlockIcons.MACHINE_HEATPROOFCASING), - mInventory.length > 4 ? Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier] - : Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier] }; - } - return rTextures; - }*/ /* * @Override public ITexture[][][] getTextureSet(ITexture[] aTextures) { @@ -161,174 +139,226 @@ public class GregtechMetaEnergyBuffer extends GregtechMetaTileEntity { * } return rTextures; } */ - /*@Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return mTextures[aSide == aFacing ? 1 : 0][aColorIndex+1]; - }*/ + /* + * @Override public ITexture[] getTexture(IGregTechTileEntity + * aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean + * aActive, boolean aRedstone) { return mTextures[aSide == aFacing ? 1 : + * 0][aColorIndex+1]; } + */ - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaEnergyBuffer(mName, mTier, mDescription, mTextures, mInventory.length); + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange) + }; } - @Override public boolean isSimpleMachine() {return false;} - @Override public boolean isElectric() {return true;} - @Override public boolean isValidSlot(int aIndex) {return true;} - @Override public boolean isFacingValid(byte aFacing) {return true;} - @Override public boolean isEnetInput() {return true;} - @Override public boolean isEnetOutput() {return true;} - @Override public boolean isInputFacing(byte aSide) {return aSide!=getBaseMetaTileEntity().getFrontFacing();} - @Override public boolean isOutputFacing(byte aSide) {return aSide==getBaseMetaTileEntity().getFrontFacing();} - @Override public boolean isTeleporterCompatible() {return false;} - @Override public long getMinimumStoredEU() {return V[mTier]*2;} - @Override public long maxEUStore() {return V[mTier]*250000;} + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange) + }; + } - @Override - public long maxEUInput() { - return V[mTier]; + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange) + }; } @Override - public long maxEUOutput() { - return V[mTier]; + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, + final IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_1by1(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName()); } @Override - public long maxAmperesIn() { - return mChargeableCount * 4; + public String[] getDescription() { + return new String[] { + this.mDescription, CORE.GT_Tooltip + }; } - @Override - public long maxAmperesOut() { - return mChargeableCount * 4; + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] + }; } - @Override public int rechargerSlotStartIndex() {return 0;} - @Override public int dechargerSlotStartIndex() {return 0;} - @Override public int rechargerSlotCount() {return mCharge?mInventory.length:0;} - @Override public int dechargerSlotCount() {return mDecharge?mInventory.length:0;} - @Override public int getProgresstime() {return (int)getBaseMetaTileEntity().getUniversalEnergyStored();} - @Override public int maxProgresstime() {return (int)getBaseMetaTileEntity().getUniversalEnergyCapacity();} - @Override public boolean isAccessAllowed(EntityPlayer aPlayer) {return true;} - @Override - public void saveNBTData(NBTTagCompound aNBT) { - // + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] + }; } @Override - public void loadNBTData(NBTTagCompound aNBT) { - // + public String[] getInfoData() { + this.count++; + if (this.mMax == 0 || this.count % 20 == 0) { + final long[] tmp = this.getStoredEnergy(); + this.mStored = tmp[0]; + this.mMax = tmp[1]; + } + + return new String[] { + this.getLocalName(), GT_Utility.formatNumbers(this.mStored) + " EU /", + GT_Utility.formatNumbers(this.mMax) + " EU" + }; } @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - Utils.LOG_WARNING("Right Click on MTE by Player"); - if (aBaseMetaTileEntity.isClientSide()) return true; - //aBaseMetaTileEntity.openGUI(aPlayer); - - Utils.LOG_WARNING("MTE is Client-side"); - showEnergy(aPlayer.getEntityWorld(), aPlayer); - return true; + public String getInventoryName() { + return null; } - private void showEnergy(World worldIn, EntityPlayer playerIn){ - long tempStorage = getStoredEnergy()[0]; - final double c = ((double) tempStorage / maxEUStore()) * 100; - final double roundOff = Math.round(c * 100.00) / 100.00; - PlayerUtils.messagePlayer(playerIn, "Energy: " + tempStorage + " EU at "+V[mTier]+"v ("+roundOff+"%)"); + @Override + public int getInventoryStackLimit() { + return 0; + } + @Override + public long getMinimumStoredEU() { + return GT_Values.V[this.mTier] * 2; } - //Utils.LOG_WARNING("Begin Show Energy"); - /* - * - //Utils.LOG_INFO("getProgresstime: "+tempStorage+" maxProgresstime: "+maxEUStore()+" C: "+c); - Utils.LOG_INFO("getProgressTime: "+getProgresstime()); - Utils.LOG_INFO("maxProgressTime: "+maxProgresstime()); - Utils.LOG_INFO("getMinimumStoredEU: "+getMinimumStoredEU()); - Utils.LOG_INFO("maxEUStore: "+maxEUStore());*/ - /*final long d = (tempStorage * 100L) / maxEUStore(); - Utils.LOG_INFO("getProgresstime: "+tempStorage+" maxProgresstime: "+maxEUStore()+" D: "+d); - final double roundOff2 = Math.round(d * 100.00) / 100.00; - Utils.messagePlayer(playerIn, "Energy: " + tempStorage + " EU at "+V[mTier]+"v ("+roundOff2+"%)"); - Utils.LOG_WARNING("Making new instance of Guihandler"); - GuiHandler block = new GuiHandler(); - Utils.LOG_WARNING("Guihandler.toString(): "+block.toString()); - block.getClientGuiElement(1, playerIn, worldIn, (int) playerIn.posX, (int) playerIn.posY, (int) playerIn.posZ);*/ + @Override + public int getProgresstime() { + return (int) this.getBaseMetaTileEntity().getUniversalEnergyStored(); + } @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, + final IGregTechTileEntity aBaseMetaTileEntity) { return new GT_Container_1by1(aPlayerInventory, aBaseMetaTileEntity); } - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_1by1(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange) + }; + } + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange) + }; } @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - + public int getSizeInventory() { + return 0; } @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; + public ItemStack getStackInSlot(final int p_70301_1_) { + return null; } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; + public ItemStack getStackInSlotOnClosing(final int p_70304_1_) { + return null; } - public long[] getStoredEnergy(){ - long tScale = getBaseMetaTileEntity().getEUCapacity(); - long tStored = getBaseMetaTileEntity().getStoredEU(); - if (mInventory != null) { - for (ItemStack aStack : mInventory) { + public long[] getStoredEnergy() { + long tScale = this.getBaseMetaTileEntity().getEUCapacity(); + long tStored = this.getBaseMetaTileEntity().getStoredEU(); + if (this.mInventory != null) { + for (final ItemStack aStack : this.mInventory) { if (GT_ModHandler.isElectricItem(aStack)) { if (aStack.getItem() instanceof GT_MetaBase_Item) { - Long[] stats = ((GT_MetaBase_Item) aStack.getItem()) - .getElectricStats(aStack); + final Long[] stats = ((GT_MetaBase_Item) aStack.getItem()).getElectricStats(aStack); if (stats != null) { tScale = tScale + stats[0]; - tStored = tStored - + ((GT_MetaBase_Item) aStack.getItem()) - .getRealCharge(aStack); + tStored = tStored + ((GT_MetaBase_Item) aStack.getItem()).getRealCharge(aStack); } - } else if (aStack.getItem() instanceof IElectricItem) { - tStored = tStored - + (long) ic2.api.item.ElectricItem.manager - .getCharge(aStack); - tScale = tScale - + (long) ((IElectricItem) aStack.getItem()) - .getMaxCharge(aStack); + } + else if (aStack.getItem() instanceof IElectricItem) { + tStored = tStored + (long) ic2.api.item.ElectricItem.manager.getCharge(aStack); + tScale = tScale + (long) ((IElectricItem) aStack.getItem()).getMaxCharge(aStack); } } } } - return new long[] { tStored, tScale }; + return new long[] { + tStored, tScale + }; } - private long count=0; - private long mStored=0; - private long mMax=0; + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, + final byte aColorIndex, final boolean aActive, final 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 String[] getInfoData() { - count++; - if(mMax==0||count%20==0){ - long[] tmp = getStoredEnergy(); - mStored=tmp[0]; - mMax=tmp[1]; + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); } + return rTextures; + } - return new String[] { - getLocalName(), - GT_Utility.formatNumbers(mStored)+" EU /", - GT_Utility.formatNumbers(mMax)+" EU"}; + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Screen_Logo) + }; + } + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Screen_Logo) + }; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isElectric() { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return true; } @Override @@ -337,62 +367,95 @@ public class GregtechMetaEnergyBuffer extends GregtechMetaTileEntity { } @Override - public int[] getAccessibleSlotsFromSide(int p_94128_1_) { - return null; + public boolean isInputFacing(final byte aSide) { + return aSide != this.getBaseMetaTileEntity().getFrontFacing(); } @Override - public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) { + public boolean isItemValidForSlot(final int p_94041_1_, final ItemStack p_94041_2_) { return false; } @Override - public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) { + public boolean isOutputFacing(final byte aSide) { + return aSide == this.getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isSimpleMachine() { + return false; + } + @Override + public boolean isTeleporterCompatible() { + return false; + } + @Override + public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { return false; } @Override - public int getSizeInventory() { - return 0; + public boolean isValidSlot(final int aIndex) { + return true; } @Override - public ItemStack getStackInSlot(int p_70301_1_) { - return null; + public void loadNBTData(final NBTTagCompound aNBT) { + // } @Override - public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) { - return null; + public long maxAmperesIn() { + return this.mChargeableCount * 4; } @Override - public ItemStack getStackInSlotOnClosing(int p_70304_1_) { - return null; + public long maxAmperesOut() { + return this.mChargeableCount * 4; } @Override - public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) { + public long maxEUInput() { + return GT_Values.V[this.mTier]; } @Override - public String getInventoryName() { - return null; + public long maxEUOutput() { + return GT_Values.V[this.mTier]; } @Override - public boolean hasCustomInventoryName() { - return false; + public long maxEUStore() { + return GT_Values.V[this.mTier] * 250000; } @Override - public int getInventoryStackLimit() { - return 0; + public int maxProgresstime() { + return (int) this.getBaseMetaTileEntity().getUniversalEnergyCapacity(); } @Override - public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { - return false; + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaEnergyBuffer(this.mName, this.mTier, this.mDescription, this.mTextures, + this.mInventory.length); + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + Utils.LOG_WARNING("Right Click on MTE by Player"); + if (aBaseMetaTileEntity.isClientSide()) { + return true; + // aBaseMetaTileEntity.openGUI(aPlayer); + } + + Utils.LOG_WARNING("MTE is Client-side"); + this.showEnergy(aPlayer.getEntityWorld(), aPlayer); + return true; } @Override @@ -400,12 +463,51 @@ public class GregtechMetaEnergyBuffer extends GregtechMetaTileEntity { } @Override - public void closeInventory() { + public int rechargerSlotCount() { + return this.mCharge ? this.mInventory.length : 0; } @Override - public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { - return false; + public int rechargerSlotStartIndex() { + return 0; + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + // } + @Override + public void setInventorySlotContents(final int p_70299_1_, final ItemStack p_70299_2_) { + } + + private void showEnergy(final World worldIn, final EntityPlayer playerIn) { + final long tempStorage = this.getStoredEnergy()[0]; + final double c = (double) tempStorage / this.maxEUStore() * 100; + final double roundOff = Math.round(c * 100.00) / 100.00; + PlayerUtils.messagePlayer(playerIn, + "Energy: " + tempStorage + " EU at " + GT_Values.V[this.mTier] + "v (" + roundOff + "%)"); + + } + // Utils.LOG_WARNING("Begin Show Energy"); + /* + * + * //Utils.LOG_INFO("getProgresstime: "+tempStorage+" maxProgresstime: " + * +maxEUStore()+" C: "+c); Utils.LOG_INFO("getProgressTime: " + * +getProgresstime()); Utils.LOG_INFO("maxProgressTime: " + * +maxProgresstime()); Utils.LOG_INFO("getMinimumStoredEU: " + * +getMinimumStoredEU()); Utils.LOG_INFO("maxEUStore: "+maxEUStore()); + */ + /* + * final long d = (tempStorage * 100L) / maxEUStore(); Utils.LOG_INFO( + * "getProgresstime: "+tempStorage+" maxProgresstime: "+maxEUStore()+ + * " D: "+d); final double roundOff2 = Math.round(d * 100.00) / 100.00; + * Utils.messagePlayer(playerIn, "Energy: " + tempStorage + " EU at " + * +V[mTier]+"v ("+roundOff2+"%)"); Utils.LOG_WARNING( + * "Making new instance of Guihandler"); GuiHandler block = new + * GuiHandler(); Utils.LOG_WARNING("Guihandler.toString(): " + * +block.toString()); block.getClientGuiElement(1, playerIn, worldIn, (int) + * playerIn.posX, (int) playerIn.posY, (int) playerIn.posZ); + */ + } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntityFluid.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntityFluid.java index 24bbfda9a1..61141417ae 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntityFluid.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntityFluid.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; -import static gregtech.api.enums.GT_Values.D1; - import java.util.ArrayList; import java.util.HashMap; import java.util.Map.Entry; @@ -30,352 +28,449 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.*; public class GregtechMetaPipeEntityFluid extends MetaPipeEntity { - public final float mThickNess; - public final GT_Materials mMaterial; - public final int mCapacity, mHeatResistance; - public final boolean mGasProof; - public FluidStack mFluid; - public byte mLastReceivedFrom = 0, oLastReceivedFrom = 0; - - public GregtechMetaPipeEntityFluid(int aID, String aName, String aNameRegional, float aThickNess, GT_Materials aMaterial, int aCapacity, int aHeatResistance, boolean aGasProof) { + public final float mThickNess; + public final GT_Materials mMaterial; + public final int mCapacity, mHeatResistance; + public final boolean mGasProof; + public FluidStack mFluid; + public byte mLastReceivedFrom = 0, oLastReceivedFrom = 0; + + public GregtechMetaPipeEntityFluid(final int aID, final String aName, final String aNameRegional, + final float aThickNess, final GT_Materials aMaterial, final int aCapacity, final int aHeatResistance, + final boolean aGasProof) { super(aID, aName, aNameRegional, 0); - mThickNess = aThickNess; - mMaterial = aMaterial; - mCapacity = aCapacity; - mGasProof = aGasProof; - mHeatResistance = aHeatResistance; + this.mThickNess = aThickNess; + this.mMaterial = aMaterial; + this.mCapacity = aCapacity; + this.mGasProof = aGasProof; + this.mHeatResistance = aHeatResistance; } - public GregtechMetaPipeEntityFluid(String aName, float aThickNess, GT_Materials aMaterial, int aCapacity, int aHeatResistance, boolean aGasProof) { + public GregtechMetaPipeEntityFluid(final String aName, final float aThickNess, final GT_Materials aMaterial, + final int aCapacity, final int aHeatResistance, final boolean aGasProof) { super(aName, 0); - mThickNess = aThickNess; - mMaterial = aMaterial; - mCapacity = aCapacity; - mGasProof = aGasProof; - mHeatResistance = aHeatResistance; + this.mThickNess = aThickNess; + this.mMaterial = aMaterial; + this.mCapacity = aCapacity; + this.mGasProof = aGasProof; + this.mHeatResistance = aHeatResistance; } @Override - public byte getTileEntityBaseType() { - return mMaterial == null ? 4 : (byte) ((mMaterial.contains(SubTag.WOOD) ? 12 : 4) + Math.max(0, Math.min(3, mMaterial.mToolQuality))); + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, + final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, + final ItemStack aStack) { + return false; } @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaPipeEntityFluid(mName, mThickNess, mMaterial, mCapacity, mHeatResistance, mGasProof); + public void doSound(final byte aIndex, final double aX, final double aY, final double aZ) { + super.doSound(aIndex, aX, aY, aZ); + if (aIndex == 9) { + GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(4), 5, 1.0F, aX, aY, aZ); + for (byte i = 0; i < 6; i++) { + for (int l = 0; l < 2; ++l) { + this.getBaseMetaTileEntity().getWorld().spawnParticle("largesmoke", aX - 0.5 + Math.random(), + aY - 0.5 + Math.random(), aZ - 0.5 + Math.random(), + ForgeDirection.getOrientation(i).offsetX / 5.0, + ForgeDirection.getOrientation(i).offsetY / 5.0, + ForgeDirection.getOrientation(i).offsetZ / 5.0); + } + } + } } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, byte aColorIndex, boolean aConnected, boolean aRedstone) { + public final FluidStack drain(final int maxDrain, final boolean doDrain) { + if (this.mFluid == null) { + return null; + } + if (this.mFluid.amount <= 0) { + this.mFluid = null; + return null; + } + + int used = maxDrain; + if (this.mFluid.amount < used) { + used = this.mFluid.amount; + } + + if (doDrain) { + this.mFluid.amount -= used; + } - short[] colours = Dyes.getModulation(aColorIndex, mMaterial.mRGBa); + final FluidStack drained = this.mFluid.copy(); + drained.amount = used; + + if (this.mFluid.amount <= 0) { + this.mFluid = null; + } + + return drained; + } + + @Override + public final int fill_default(final ForgeDirection aSide, final FluidStack aFluid, final boolean doFill) { + if (aFluid == null || aFluid.getFluid().getID() <= 0) { + return 0; + } + + if (this.mFluid == null || this.