From cbe0e497be8e466c380a5b4fa781b314ede9ada3 Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Sun, 6 Nov 2016 19:32:27 +1000 Subject: Revert "$ Cleaned up the entire project." This reverts commit 0669f5eb9d5029a8b94ec552171b0837605f7747. # Conflicts: # src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_NuclearReactor.java # src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java Revert "% Cleaned up Imports." This reverts commit 3654052fb63a571c5eaca7f20714b87c17f7e966. --- .../GT_MetaTileEntity_DeluxeTank.java | 418 +- .../implementations/GregtechMetaCondensor.java | 301 +- .../implementations/GregtechMetaEnergyBuffer.java | 563 ++- .../GregtechMetaPipeEntityFluid.java | 563 ++- .../GregtechMetaPipeEntity_Cable.java | 460 +-- .../GregtechMetaPipeEntity_SuperConductor.java | 466 +-- .../implementations/GregtechMetaSafeBlock.java | 110 +- .../GregtechMetaSuperConductorNodeBase.java | 614 ++- .../base/GregtechMetaPipeEntityBase_Cable.java | 559 +-- .../base/GregtechMetaTileEntity.java | 85 +- .../base/GregtechMeta_MultiBlockBase.java | 1849 ++++----- .../GregtechDoubleFuelGeneratorBase.java | 601 ++- .../base/generators/GregtechMetaBoilerBase.java | 625 ++- .../generators/GregtechMetaSolarGenerator.java | 376 +- .../GregtechRocketFuelGeneratorBase.java | 558 ++- .../GregtechBaseMetaTileEntityLossless.java | 4189 +++++++++----------- .../GregtechMetaPipeEntity_BaseSuperConductor.java | 1312 +++--- .../lossless/GregtechMetaTileEntityLossless.java | 85 +- .../GregtechMetaTileEntityLosslessBasicTank.java | 494 ++- ...chMetaTileEntityLosslessTieredMachineBlock.java | 110 +- .../base/lossless/MetaTileEntityLossless.java | 1779 ++++----- .../base/machines/GregtechMetaSafeBlockBase.java | 483 +-- .../creative/GregtechMetaCreativeEnergyBuffer.java | 388 +- 23 files changed, 7486 insertions(+), 9502 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 800f6cf875..2effc58f9a 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,303 +16,207 @@ 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(final int aID, final String aName, final String aNameRegional, final int aTier, - final int aInvSlotCount, final String aDescription, final ITexture... aTextures) { + public GT_MetaTileEntity_DeluxeTank(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) { super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); } - public GT_MetaTileEntity_DeluxeTank(final String aName, final int aTier, final int aInvSlotCount, - final String aDescription, final ITexture[][][] aTextures) { + public GT_MetaTileEntity_DeluxeTank(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, aInvSlotCount, aDescription, aTextures); } @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { - return aIndex == this.getOutputSlot(); + public boolean isSimpleMachine() { + return false; } @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { - return aIndex == this.getInputSlot(); + public boolean isValidSlot(int aIndex) { + return aIndex != getStackDisplaySlot(); } @Override - public abstract boolean canTankBeEmptied(); - - @Override - public abstract boolean canTankBeFilled(); + 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())); + } @Override - public abstract boolean displaysItemStack(); + public void loadNBTData(NBTTagCompound aNBT) { + mFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid")); + mFluid2 = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid2")); + } @Override - public abstract boolean displaysStackSize(); + public abstract boolean doesFillContainers(); @Override public abstract boolean doesEmptyContainers(); @Override - public abstract boolean doesFillContainers(); + public abstract boolean canTankBeFilled(); @Override - 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; - } + public abstract boolean canTankBeEmptied(); @Override - 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; - } + public abstract boolean displaysItemStack(); @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_DeluxeTank(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName()); - } + public abstract boolean displaysStackSize(); @Override - public FluidStack getDisplayedFluid() { - return this.getDrainableStack(); + public int getInputSlot() { + return 0; } @Override - public FluidStack getDrainableStack() { - return this.getDrainableStackEx(1); - } - - public FluidStack getDrainableStackEx(final int stackID) { - if (stackID <= 1) { - return this.mFluid; - } - return this.mFluid2; + public int getOutputSlot() { + return 1; } @Override - public FluidStack getFillableStack() { - return this.getFillableStackEx(1); + public int getStackDisplaySlot() { + return 2; } - public FluidStack getFillableStackEx(final int stackID) { - if (stackID <= 1) { - return this.mFluid; - } - return this.mFluid2; + public int getStackDisplaySlot2() { + return 3; } @Override - public FluidStack getFluid() { - return this.getDrainableStack(); + public boolean isFluidInputAllowed(FluidStack aFluid) { + return true; } @Override - public int getFluidAmount() { - return this.getDrainableStack() != null ? this.getDrainableStack().amount : 0; + public boolean isFluidChangingAllowed() { + return true; } @Override - public int getInputSlot() { - return 0; + public FluidStack getFillableStack() { + return getFillableStackEx(1); } - @Override - public int getOutputSlot() { - return 1; + public FluidStack getFillableStackEx(int stackID) { + if (stackID <= 1){ + return mFluid; + } + return mFluid2; } @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new CONTAINER_DeluxeTank(aPlayerInventory, aBaseMetaTileEntity); + public FluidStack setFillableStack(FluidStack aFluid) { + mFluid = aFluid; + return mFluid; } - - @Override - public int getStackDisplaySlot() { - return 2; + + public FluidStack setFillableStack2(FluidStack aFluid) { + mFluid2 = aFluid; + return mFluid2; } - public int getStackDisplaySlot2() { - return 3; + @Override + public FluidStack getDrainableStack() { + return getDrainableStackEx(1); } - @Override - public boolean isFluidChangingAllowed() { - return true; + public FluidStack getDrainableStackEx(int stackID) { + if (stackID <= 1){ + return mFluid; + } + return mFluid2; } @Override - public boolean isFluidInputAllowed(final FluidStack aFluid) { - return true; + public FluidStack setDrainableStack(FluidStack aFluid) { + mFluid = aFluid; + return mFluid; } @Override - public boolean isSimpleMachine() { - return false; + public FluidStack getDisplayedFluid() { + return getDrainableStack(); } @Override - public boolean isValidSlot(final int aIndex) { - return aIndex != this.getStackDisplaySlot(); + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_DeluxeTank(aPlayerInventory, aBaseMetaTileEntity); } @Override - public void loadNBTData(final NBTTagCompound aNBT) { - this.mFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid")); - this.mFluid2 = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid2")); + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_DeluxeTank(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); } @Override - public void onPreTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isServerSide()) { - if (this.isFluidChangingAllowed() && this.getFillableStack() != null - && this.getFillableStack().amount <= 0) { - this.setFillableStack(null); - } - - 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 (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.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 (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.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); + if (doesEmptyContainers()) { + FluidStack tFluid = GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true); + if (tFluid != null && isFluidInputAllowed(tFluid)) { + + 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); } } - } - 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(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.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(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.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); + } 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); } } } @@ -323,47 +227,101 @@ public abstract class GT_MetaTileEntity_DeluxeTank extends GT_MetaTileEntity_Bas } } - 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); - } + 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); } } } } @Override - public void saveNBTData(final NBTTagCompound aNBT) { - if (this.mFluid != null) { - aNBT.setTag("mFluid", this.mFluid.writeToNBT(new NBTTagCompound())); + 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(); } - if (this.mFluid2 != null) { - aNBT.setTag("mFluid2", this.mFluid2.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 (doFill) + getFillableStack().amount = getCapacity(); + return space; } @Override - public FluidStack setDrainableStack(final FluidStack aFluid) { - this.mFluid = aFluid; - return this.mFluid; + 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; } @Override - public FluidStack setFillableStack(final FluidStack aFluid) { - this.mFluid = aFluid; - return this.mFluid; + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aIndex == getOutputSlot(); } - public FluidStack setFillableStack2(final FluidStack aFluid) { - this.mFluid2 = aFluid; - return this.mFluid2; + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aIndex == getInputSlot(); } } \ 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 4836ee0e42..dcecc3ff34 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaCondensor.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaCondensor.java @@ -18,165 +18,148 @@ 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(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 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 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 9236d091fc..4f4f3f931f 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaEnergyBuffer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaEnergyBuffer.java @@ -1,6 +1,6 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; -import gregtech.api.enums.GT_Values; +import static gregtech.api.enums.GT_Values.V; import gregtech.api.enums.Textures; import gregtech.api.gui.GT_Container_1by1; import gregtech.api.gui.GT_GUIContainer_1by1; @@ -30,92 +30,113 @@ 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(final int aID, final String aName, final String aNameRegional, final int aTier, - final String aDescription, final int aSlotCount) { + public GregtechMetaEnergyBuffer(int aID, String aName, String aNameRegional, int aTier, String aDescription, int aSlotCount) { super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); } - public GregtechMetaEnergyBuffer(final String aName, final int aTier, final String aDescription, - final ITexture[][][] aTextures, final int aSlotCount) { + public GregtechMetaEnergyBuffer(String aName, int aTier, String aDescription, ITexture[][][] aTextures, int aSlotCount) { super(aName, aTier, aSlotCount, aDescription, aTextures); } @Override - 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) - }; + public String[] getDescription() { + return new String[] {mDescription, CORE.GT_Tooltip}; } /* - * @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; } + * MACHINE_STEEL_SIDE */ + + @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) { @@ -139,226 +160,174 @@ 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]; } - */ - - 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 ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return mTextures[aSide == aFacing ? 1 : 0][aColorIndex+1]; + }*/ - 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 IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaEnergyBuffer(mName, mTier, mDescription, mTextures, mInventory.length); } - 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 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;} @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_1by1(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName()); + public long maxEUInput() { + return V[mTier]; } @Override - public String[] getDescription() { - return new String[] { - this.mDescription, CORE.GT_Tooltip - }; - } - - 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] - }; + public long maxEUOutput() { + return V[mTier]; } - 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 long maxAmperesIn() { + return mChargeableCount * 4; } @Override - 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" - }; + public long maxAmperesOut() { + return mChargeableCount * 4; } + @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 String getInventoryName() { - return null; + public void saveNBTData(NBTTagCompound aNBT) { + // } @Override - public int getInventoryStackLimit() { - return 0; + public void loadNBTData(NBTTagCompound aNBT) { + // } @Override - public long getMinimumStoredEU() { - return GT_Values.V[this.mTier] * 2; + 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; } - @Override - public int getProgresstime() { - return (int) this.getBaseMetaTileEntity().getUniversalEnergyStored(); + 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+"%)"); + } + //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 Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { return new GT_Container_1by1(aPlayerInventory, aBaseMetaTileEntity); } - 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 Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_1by1(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); } @Override - public int getSizeInventory() { - return 0; + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + } @Override - public ItemStack getStackInSlot(final int p_70301_1_) { - return null; + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; } @Override - public ItemStack getStackInSlotOnClosing(final int p_70304_1_) { - return null; + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; } - public long[] getStoredEnergy() { - long tScale = this.getBaseMetaTileEntity().getEUCapacity(); - long tStored = this.getBaseMetaTileEntity().getStoredEU(); - if (this.mInventory != null) { - for (final ItemStack aStack : this.mInventory) { + public long[] getStoredEnergy(){ + long tScale = getBaseMetaTileEntity().getEUCapacity(); + long tStored = getBaseMetaTileEntity().getStoredEU(); + if (mInventory != null) { + for (ItemStack aStack : mInventory) { if (GT_ModHandler.isElectricItem(aStack)) { if (aStack.getItem() instanceof GT_MetaBase_Item) { - final Long[] stats = ((GT_MetaBase_Item) aStack.getItem()).getElectricStats(aStack); + 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 }; } - @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]; - } + private long count=0; + private long mStored=0; + private long mMax=0; @Override - 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); + public String[] getInfoData() { + count++; + if(mMax==0||count%20==0){ + long[] tmp = getStoredEnergy(); + mStored=tmp[0]; + mMax=tmp[1]; } - return rTextures; - } - - 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; + return new String[] { + getLocalName(), + GT_Utility.formatNumbers(mStored)+" EU /", + GT_Utility.formatNumbers(mMax)+" EU"}; } @Override @@ -367,95 +336,62 @@ public class GregtechMetaEnergyBuffer extends GregtechMetaTileEntity { } @Override - public boolean isInputFacing(final byte aSide) { - return aSide != this.getBaseMetaTileEntity().getFrontFacing(); + public int[] getAccessibleSlotsFromSide(int p_94128_1_) { + return null; } @Override - public boolean isItemValidForSlot(final int p_94041_1_, final ItemStack p_94041_2_) { + public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) { return false; } @Override - 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_) { + public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) { return false; } @Override - public boolean isValidSlot(final int aIndex) { - return true; - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - // - } - - @Override - public long maxAmperesIn() { - return this.mChargeableCount * 4; + public int getSizeInventory() { + return 0; } @Override - public long maxAmperesOut() { - return this.mChargeableCount * 4; + public ItemStack getStackInSlot(int p_70301_1_) { + return null; } @Override - public long maxEUInput() { - return GT_Values.V[this.mTier]; + public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) { + return null; } @Override - public long maxEUOutput() { - return GT_Values.V[this.mTier]; + public ItemStack getStackInSlotOnClosing(int p_70304_1_) { + return null; } @Override - public long maxEUStore() { - return GT_Values.V[this.mTier] * 250000; + public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) { } @Override - public int maxProgresstime() { - return (int) this.getBaseMetaTileEntity().getUniversalEnergyCapacity(); + public String getInventoryName() { + return null; } @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaEnergyBuffer(this.mName, this.mTier, this.mDescription, this.mTextures, - this.mInventory.length); + public boolean hasCustomInventoryName() { + return false; } @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - + public int getInventoryStackLimit() { + return 0; } @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; + public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { + return false; } @Override @@ -463,51 +399,12 @@ public class GregtechMetaEnergyBuffer extends GregtechMetaTileEntity { } @Override - public int rechargerSlotCount() { - return this.mCharge ? this.mInventory.length : 0; - } - - @Override - public int rechargerSlotStartIndex() { - return 0; - } - - @Override - public void saveNBTData(final NBTTagCompound aNBT) { - // + public void closeInventory() { } @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 + "%)"); - + public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { + return false; } - // 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 61141417ae..9fe37dd2dc 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntityFluid.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntityFluid.java @@ -1,11 +1,10 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map.Entry; - +import static gregtech.api.enums.GT_Values.D1; import gregtech.api.GregTech_API; -import gregtech.api.enums.*; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SubTag; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.ICoverable; @@ -17,6 +16,11 @@ import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map.Entry; + import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; @@ -25,452 +29,357 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.*; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; 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(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) { + 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) { super(aID, aName, aNameRegional, 0); - this.mThickNess = aThickNess; - this.mMaterial = aMaterial; - this.mCapacity = aCapacity; - this.mGasProof = aGasProof; - this.mHeatResistance = aHeatResistance; + mThickNess = aThickNess; + mMaterial = aMaterial; + mCapacity = aCapacity; + mGasProof = aGasProof; + mHeatResistance = aHeatResistance; } - public GregtechMetaPipeEntityFluid(final String aName, final float aThickNess, final GT_Materials aMaterial, - final int aCapacity, final int aHeatResistance, final boolean aGasProof) { + public GregtechMetaPipeEntityFluid(String aName, float aThickNess, GT_Materials aMaterial, int aCapacity, int aHeatResistance, boolean aGasProof) { super(aName, 0); - this.mThickNess = aThickNess; - this.mMaterial = aMaterial; - this.mCapacity = aCapacity; - this.mGasProof = aGasProof; - this.mHeatResistance = aHeatResistance; - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { - return false; + mThickNess = aThickNess; + mMaterial = aMaterial; + mCapacity = aCapacity; + mGasProof = aGasProof; + mHeatResistance = aHeatResistance; } @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { - return false; - } - - @Override - 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 final FluidStack drain(final int m