aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations
diff options
context:
space:
mode:
authorDraknyte1 <Draknyte1@hotmail.com>2016-11-06 19:32:27 +1000
committerDraknyte1 <Draknyte1@hotmail.com>2016-11-06 19:32:27 +1000
commitcbe0e497be8e466c380a5b4fa781b314ede9ada3 (patch)
treeb85848b432adf458e3abda466ee46d9dfc3e454b /src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations
parentc40416b036c0e89451e1558253ccf07bbee028d0 (diff)
downloadGT5-Unofficial-cbe0e497be8e466c380a5b4fa781b314ede9ada3.tar.gz
GT5-Unofficial-cbe0e497be8e466c380a5b4fa781b314ede9ada3.tar.bz2
GT5-Unofficial-cbe0e497be8e466c380a5b4fa781b314ede9ada3.zip
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.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations')
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeTank.java418
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaCondensor.java301
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaEnergyBuffer.java563
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntityFluid.java563
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntity_Cable.java460
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntity_SuperConductor.java466
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaSafeBlock.java110
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaSuperConductorNodeBase.java614
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaPipeEntityBase_Cable.java559
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaTileEntity.java85
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java1849
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechDoubleFuelGeneratorBase.java601
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechMetaBoilerBase.java625
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechMetaSolarGenerator.java376
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java558
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechBaseMetaTileEntityLossless.java4189
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechMetaPipeEntity_BaseSuperConductor.java1312
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechMetaTileEntityLossless.java85
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechMetaTileEntityLosslessBasicTank.java494
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechMetaTileEntityLosslessTieredMachineBlock.java110
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/MetaTileEntityLossless.java1779
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaSafeBlockBase.java483
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/creative/GregtechMetaCreativeEnergyBuffer.java388
23 files changed, 7486 insertions, 9502 deletions
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!!!
* <p/>
- * 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 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;
- }
-
- 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.mFluid.getFluid().getID() <= 0) {
- if (aFluid.amount <= this.getCapacity()) {
- if (doFill) {
- this.mFluid = aFluid.copy();
- this.mLastReceivedFrom |= 1 << aSide.ordinal();
- }
- return aFluid.amount;
- }
- if (doFill) {
- this.mFluid = aFluid.copy();
- this.mLastReceivedFrom |= 1 << aSide.ordinal();
- this.mFluid.amount = this.getCapacity();
- }
- return this.getCapacity();
- }
-
- if (!this.mFluid.isFluidEqual(aFluid)) {
- return 0;
- }
-
- final int space = this.getCapacity() - this.mFluid.amount;
- if (aFluid.amount <= space) {
- if (doFill) {
- this.mFluid.amount += aFluid.amount;
- this.mLastReceivedFrom |= 1 << aSide.ordinal();
- }
- return aFluid.amount;
- }
- if (doFill) {
- this.mFluid.amount = this.getCapacity();
- this.mLastReceivedFrom |= 1 << aSide.ordinal();
- }
- return space;
- }
-
- @Override
- public final int getCapacity() {
- return this.mCapacity * 20;
- }
-
- @Override
- public AxisAlignedBB getCollisionBoundingBoxFromPool(final World aWorld, final int aX, final int aY, final int aZ) {
- return AxisAlignedBB.getBoundingBox(aX + 0.125D, aY + 0.125D, aZ + 0.125D, aX + 0.875D, aY + 0.875D,
- aZ + 0.875D);
- }
-
- @Override
- public String[] getDescription() {
- return new String[] {
- EnumChatFormatting.BLUE + "Fluid Capacity: " + this.mCapacity * 20 + "L/sec" + EnumChatFormatting.GRAY,
- EnumChatFormatting.RED + "Heat Limit: " + this.mHeatResistance + " K" + EnumChatFormatting.GRAY,
- EnumChatFormatting.DARK_GREEN + "Gas Proof: " + this.mGasProof + EnumChatFormatting.GRAY,
- CORE.GT_Tooltip
- };
- }
-
- @Override
- public final FluidStack getFluid() {
- return this.mFluid;
- }
-
- @Override
- public final int getFluidAmount() {
- return this.mFluid != null ? this.mFluid.amount : 0;
- }
-
- @Override
- public int getProgresstime() {
- return this.getFluidAmount();
+ public byte getTileEntityBaseType() {
+ return mMaterial == null ? 4 : (byte) ((mMaterial.contains(SubTag.WOOD) ? 12 : 4) + Math.max(0, Math.min(3, mMaterial.mToolQuality)));
}
@Override
- public int getTankPressure() {
- return (this.mFluid == null ? 0 : this.mFluid.amount) - this.getCapacity() / 2;
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new GregtechMetaPipeEntityFluid(mName, mThickNess, mMaterial, mCapacity, mHeatResistance, mGasProof);
}
@Override
- public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide,
- final byte aConnections, final byte aColorIndex, final boolean aConnected, final boolean aRedstone) {
+ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, byte aColorIndex, boolean aConnected, boolean aRedstone) {
- final short[] colours = Dyes.getModulation(aColorIndex, this.mMaterial.mRGBa);
+ short[] colours = Dyes.getModulation(aColorIndex, mMaterial.mRGBa);
if (aConnected) {
- final float tThickNess = this.getThickNess();
- if (tThickNess < 0.37F) {
- return new ITexture[] {
- new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[OrePrefixes.pipeTiny.mTextureIndex],
- colours)
- };
- }
- if (tThickNess < 0.49F) {
- return new ITexture[] {
- new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[OrePrefixes.pipeSmall.mTextureIndex],
- colours)
- };
+ float tThickNess = getThickNess();
+ if (tThickNess < 0.37F){
+ return new ITexture[]{new GT_RenderedTexture(mMaterial.mIconSet.mTextures[OrePrefixes.pipeTiny.mTextureIndex], colours)};
}
- if (tThickNess < 0.74F) {
- return new ITexture[] {
- new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[OrePrefixes.pipeMedium.mTextureIndex],
- colours)
- };
+ if (tThickNess < 0.49F){
+ return new ITexture[]{new GT_RenderedTexture(mMaterial.mIconSet.mTextures[OrePrefixes.pipeSmall.mTextureIndex], colours)};
}
- if (tThickNess < 0.99F) {
- return new ITexture[] {
- new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[OrePrefixes.pipeLarge.mTextureIndex],
- colours)
- };
+ if (tThickNess < 0.74F){
+ return new ITexture[]{new GT_RenderedTexture(mMaterial.mIconSet.mTextures[OrePrefixes.pipeMedium.mTextureIndex], colours)};
}
- return new ITexture[] {
- new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[OrePrefixes.pipeHuge.mTextureIndex],
- colours)
- };
+ if (tThickNess < 0.99F){
+ return new ITexture[]{new GT_RenderedTexture(mMaterial.mIconSet.mTextures[OrePrefixes.pipeLarge.mTextureIndex], colours)};
+ }
+ return new ITexture[]{new GT_RenderedTexture(mMaterial.mIconSet.mTextures[OrePrefixes.pipeHuge.mTextureIndex], colours)};
}
- return new ITexture[] {
- new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], colours)
- };
+ return new ITexture[]{new GT_RenderedTexture(mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], colours)};
}
@Override
- public float getThickNess() {
- return this.mThickNess;
+ public boolean isSimpleMachine() {
+ return true;
}
@Override
- public byte getTileEntityBaseType() {
- return this.mMaterial == null ? 4
- : (byte) ((this.mMaterial.contains(SubTag.WOOD) ? 12 : 4)
- + Math.max(0, Math.min(3, this.mMaterial.mToolQuality)));
+ public boolean isFacingValid(byte aFacing) {
+ return false;
}
@Override
- public boolean isFacingValid(final byte aFacing) {
+ public boolean isValidSlot(int aIndex) {
return false;
}
@Override
- public boolean isSimpleMachine() {
- return true;
+ public final boolean renderInside(byte aSide) {
+ return false;
}
@Override
- public boolean isValidSlot(final int aIndex) {
- return false;
+ public int getProgresstime() {
+ return getFluidAmount();
}
@Override
- public void loadNBTData(final NBTTagCompound aNBT) {
- this.mFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid"));
- this.mLastReceivedFrom = aNBT.getByte("mLastReceivedFrom");
+ public int maxProgresstime() {
+ return getCapacity();
}
@Override
- public int maxProgresstime() {
- return this.getCapacity();
+ public void saveNBTData(NBTTagCompound aNBT) {
+ if (mFluid != null) aNBT.setTag("mFluid", mFluid.writeToNBT(new NBTTagCompound()));
+ aNBT.setByte("mLastReceivedFrom", mLastReceivedFrom);
}
@Override
- public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) {
- return new GregtechMetaPipeEntityFluid(this.mName, this.mThickNess, this.mMaterial, this.mCapacity,
- this.mHeatResistance, this.mGasProof);
+ public void loadNBTData(NBTTagCompound aNBT) {
+ mFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid"));
+ mLastReceivedFrom = aNBT.getByte("mLastReceivedFrom");
}
@Override
- public void onEntityCollidedWithBlock(final World aWorld, final int aX, final int aY, final int aZ,
- final Entity aEntity) {
- if (this.mFluid != null && (((BaseMetaPipeEntity) this.getBaseMetaTileEntity()).mConnections & -128) == 0
- && aEntity instanceof EntityLivingBase) {
- final int tTemperature = this.mFluid.getFluid().getTemperature(this.mFluid);
+ public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity aEntity) {
+ if (mFluid != null && (((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections & -128) == 0 && aEntity instanceof EntityLivingBase) {
+ int tTemperature = mFluid.getFluid().getTemperature(mFluid);
if (tTemperature > 320) {
GT_Utility.applyHeatDamage((EntityLivingBase) aEntity, (tTemperature - 300) / 50.0F);
- }
- else if (tTemperature < 260) {
+ } else if (tTemperature < 260) {
GT_Utility.applyFrostDamage((EntityLivingBase) aEntity, (270 - tTemperature) / 25.0F);
}
}
}
@Override
- public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) {
+ public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) {
+ return AxisAlignedBB.getBoundingBox(aX + 0.125D, aY + 0.125D, aZ + 0.125D, aX + 0.875D, aY + 0.875D, aZ + 0.875D);
+ }
+
+ @Override
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
if (aBaseMetaTileEntity.isServerSide() && aTick % 5 == 0) {
- this.mLastReceivedFrom &= 63;
- if (this.mLastReceivedFrom == 63) {
- this.mLastReceivedFrom = 0;
+ mLastReceivedFrom &= 63;
+ if (mLastReceivedFrom == 63) {
+ mLastReceivedFrom = 0;
}
- if (this.mFluid != null && this.mFluid.amount > 0) {
- final int tTemperature = this.mFluid.getFluid().getTemperature(this.mFluid);
- if (tTemperature > this.mHeatResistance) {
+ if (mFluid != null && mFluid.amount > 0) {
+ int tTemperature = mFluid.getFluid().getTemperature(mFluid);
+ if (tTemperature > mHeatResistance) {
if (aBaseMetaTileEntity.getRandomNumber(100) == 0) {
aBaseMetaTileEntity.setToFire();
return;
}
aBaseMetaTileEntity.setOnFire();
}
- if (!this.mGasProof && this.mFluid.getFluid().isGaseous(this.mFluid)) {
- this.mFluid.amount -= 5;
- this.sendSound((byte) 9);
+ if (!mGasProof && mFluid.getFluid().isGaseous(mFluid)) {
+ mFluid.amount -= 5;
+ sendSound((byte) 9);
if (tTemperature > 320) {
try {
- for (final EntityLivingBase tLiving : (ArrayList<EntityLivingBase>) this
- .getBaseMetaTileEntity().getWorld().getEntitiesWithinAABB(EntityLivingBase.class,
- AxisAlignedBB.getBoundingBox(this.getBaseMetaTileEntity().getXCoord() - 2,
- this.getBaseMetaTileEntity().getYCoord() - 2,
- this.getBaseMetaTileEntity().getZCoord() - 2,
- this.getBaseMetaTileEntity().getXCoord() + 3,
- this.getBaseMetaTileEntity().getYCoord() + 3,
- this.getBaseMetaTileEntity().getZCoord() + 3))) {
+ for (EntityLivingBase tLiving : (ArrayList<EntityLivingBase>) getBaseMetaTileEntity().getWorld().getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(getBaseMetaTileEntity().getXCoord() - 2, getBaseMetaTileEntity().getYCoord() - 2, getBaseMetaTileEntity().getZCoord() - 2, getBaseMetaTileEntity().getXCoord() + 3, getBaseMetaTileEntity().getYCoord() + 3, getBaseMetaTileEntity().getZCoord() + 3))) {
GT_Utility.applyHeatDamage(tLiving, (tTemperature - 300) / 25.0F);
}
+ } catch (Throwable e) {
+ if (D1) e.printStackTrace(GT_Log.err);
}
- catch (final Throwable e) {
- if (GT_Values.D1) {
- e.printStackTrace(GT_Log.err);
- }
- }
- }
- else if (tTemperature < 260) {
+ } else if (tTemperature < 260) {
try {
- for (final EntityLivingBase tLiving : (ArrayList<EntityLivingBase>) this
- .getBaseMetaTileEntity().getWorld().getEntitiesWithinAABB(EntityLivingBase.class,
- AxisAlignedBB.getBoundingBox(this.getBaseMetaTileEntity().getXCoord() - 2,
- this.getBaseMetaTileEntity().getYCoord() - 2,
- this.getBaseMetaTileEntity().getZCoord() - 2,
- this.getBaseMetaTileEntity().getXCoord() + 3,
- this.getBaseMetaTileEntity().getYCoord() + 3,
- this.getBaseMetaTileEntity().getZCoord() + 3))) {
+ for (EntityLivingBase tLiving : (ArrayList<EntityLivingBase>) getBaseMetaTileEntity().getWorld().getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(getBaseMetaTileEntity().getXCoord() - 2, getBaseMetaTileEntity().getYCoord() - 2, getBaseMetaTileEntity().getZCoord() - 2, getBaseMetaTileEntity().getXCoord() + 3, getBaseMetaTileEntity().getYCoord() + 3, getBaseMetaTileEntity().getZCoord() + 3))) {
GT_Utility.applyFrostDamage(tLiving, (270 - tTemperature) / 12.5F);
}
+ } catch (Throwable e) {
+ if (D1) e.printStackTrace(GT_Log.err);
}
- catch (final Throwable e) {
- if (GT_Values.D1) {
- e.printStackTrace(GT_Log.err);
- }
- }
- }
- if (this.mFluid.amount <= 0) {
- this.mFluid = null;
}
+ if (mFluid.amount <= 0) mFluid = null;
}
}
- if (this.mLastReceivedFrom == this.oLastReceivedFrom) {
- final HashMap<IFluidHandler, ForgeDirection> tTanks = new HashMap<IFluidHandler, ForgeDirection>();
+ if (mLastReceivedFrom == oLastReceivedFrom) {
+ HashMap<IFluidHandler, ForgeDirection> tTanks = new HashMap<IFluidHandler, ForgeDirection>();
- this.mConnections = 0;
+ mConnections = 0;
for (byte tSide = 0, i = 0, j = (byte) aBaseMetaTileEntity.getRandomNumber(6); i < 6; i++) {
tSide = (byte) ((j + i) % 6);
- final IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(tSide);
+ IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(tSide);
if (tTileEntity != null) {
if (tTileEntity instanceof IGregTechTileEntity) {
if (aBaseMetaTileEntity.getColorization() >= 0) {
- final byte tColor = ((IGregTechTileEntity) tTileEntity).getColorization();
+ byte tColor = ((IGregTechTileEntity) tTileEntity).getColorization();
if (tColor >= 0 && (tColor & 15) != (aBaseMetaTileEntity.getColorization() & 15)) {
continue;
}
}
}
- final FluidTankInfo[] tInfo = tTileEntity
- .getTankInfo(ForgeDirection.getOrientation(tSide).getOpposite());
+ FluidTankInfo[] tInfo = tTileEntity.getTankInfo(ForgeDirection.getOrientation(tSide).getOpposite());
if (tInfo != null && tInfo.length > 0) {
- if (tTileEntity instanceof ICoverable && ((ICoverable) tTileEntity)
- .getCoverBehaviorAtSide(GT_Utility.getOppositeSide(tSide))
- .alwaysLookConnected(GT_Utility.getOppositeSide(tSide),
- ((ICoverable) tTileEntity)
- .getCoverIDAtSide(GT_Utility.getOppositeSide(tSide)),
- ((ICoverable) tTileEntity).getCoverDataAtSide(
- GT_Utility.getOppositeSide(tSide)),
- (ICoverable) tTileEntity)) {
- this.mConnections |= 1 << tSide;
+ if (tTileEntity instanceof ICoverable && ((ICoverable) tTileEntity).getCoverBehaviorAtSide(GT_Utility.getOppositeSide(tSide)).alwaysLookConnected(GT_Utility.getOppositeSide(tSide), ((ICoverable) tTileEntity).getCoverIDAtSide(GT_Utility.getOppositeSide(tSide)), ((ICoverable) tTileEntity).getCoverDataAtSide(GT_Utility.getOppositeSide(tSide)), ((ICoverable) tTileEntity))) {
+ mConnections |= (1 << tSide);
}
- if (aBaseMetaTileEntity.getCoverBehaviorAtSide(tSide).letsFluidIn(tSide,
- aBaseMetaTileEntity.getCoverIDAtSide(tSide),
- aBaseMetaTileEntity.getCoverDataAtSide(tSide), null, aBaseMetaTileEntity)) {
- this.mConnections |= 1 << tSide;
+ if (aBaseMetaTileEntity.getCoverBehaviorAtSide(tSide).letsFluidIn(tSide, aBaseMetaTileEntity.getCoverIDAtSide(tSide), aBaseMetaTileEntity.getCoverDataAtSide(tSide), null, aBaseMetaTileEntity)) {
+ mConnections |= (1 << tSide);
}
- if (aBaseMetaTileEntity.getCoverBehaviorAtSide(tSide).letsFluidOut(tSide,
- aBaseMetaTileEntity.getCoverIDAtSide(tSide),
- aBaseMetaTileEntity.getCoverDataAtSide(tSide), null, aBaseMetaTileEntity)) {
- this.mConnections |= 1 << tSide;
- if ((1 << tSide & this.mLastReceivedFrom) == 0) {
+ if (aBaseMetaTileEntity.getCoverBehaviorAtSide(tSide).letsFluidOut(tSide, aBaseMetaTileEntity.getCoverIDAtSide(tSide), aBaseMetaTileEntity.getCoverDataAtSide(tSide), null, aBaseMetaTileEntity)) {
+ mConnections |= (1 << tSide);
+ if (((1 << tSide) & mLastReceivedFrom) == 0)
tTanks.put(tTileEntity, ForgeDirection.getOrientation(tSide).getOpposite());
- }
}
- if (aBaseMetaTileEntity.getCoverBehaviorAtSide(tSide).alwaysLookConnected(tSide,
- aBaseMetaTileEntity.getCoverIDAtSide(tSide),
- aBaseMetaTileEntity.getCoverDataAtSide(tSide), aBaseMetaTileEntity)) {
- this.mConnections |= 1 << tSide;
+ if (aBaseMetaTileEntity.getCoverBehaviorAtSide(tSide).alwaysLookConnected(tSide, aBaseMetaTileEntity.getCoverIDAtSide(tSide), aBaseMetaTileEntity.getCoverDataAtSide(tSide), aBaseMetaTileEntity)) {
+ mConnections |= (1 << tSide);
}
}
}
}
- if (this.mFluid != null && this.mFluid.amount > 0) {
- int tAmount = Math.max(1, Math.min(this.mCapacity * 10, this.mFluid.amount / 2)),
- tSuccessfulTankAmount = 0;
+ if (mFluid != null && mFluid.amount > 0) {
+ int tAmount = Math.max(1, Math.min(mCapacity * 10, mFluid.amount / 2)), tSuccessfulTankAmount = 0;
- for (final Entry<IFluidHandler, ForgeDirection> tEntry : tTanks.entrySet()) {
- if (tEntry.getKey().fill(tEntry.getValue(), this.drain(tAmount, false), false) > 0) {
+ for (Entry<IFluidHandler, ForgeDirection> tEntry : tTanks.entrySet())
+ if (tEntry.getKey().fill(tEntry.getValue(), drain(tAmount, false), false) > 0)
tSuccessfulTankAmount++;
- }
- }
if (tSuccessfulTankAmount > 0) {
if (tAmount >= tSuccessfulTankAmount) {
tAmount /= tSuccessfulTankAmount;
- for (final Entry<IFluidHandler, ForgeDirection> tTileEntity : tTanks.entrySet()) {
- if (this.mFluid == null || this.mFluid.amount <= 0) {
- break;
- }
- final int tFilledAmount = tTileEntity.getKey().fill(tTileEntity.getValue(),
- this.drain(tAmount, false), false);
- if (tFilledAmount > 0) {
- tTileEntity.getKey().fill(tTileEntity.getValue(), this.drain(tFilledAmount, true),
- true);
- }
+ for (Entry<IFluidHandler, ForgeDirection> tTileEntity : tTanks.entrySet()) {
+ if (mFluid == null || mFluid.amount <= 0) break;
+ int tFilledAmount = tTileEntity.getKey().fill(tTileEntity.getValue(), drain(tAmount, false), false);
+ if (tFilledAmount > 0)
+ tTileEntity.getKey().fill(tTileEntity.getValue(), drain(tFilledAmount, true), true);
}
- }
- else {
- for (final Entry<IFluidHandler, ForgeDirection> tTileEntity : tTanks.entrySet()) {
- if (this.mFluid == null || this.mFluid.amount <= 0) {
- break;
- }
- final int tFilledAmount = tTileEntity.getKey().fill(tTileEntity.getValue(),
- this.drain(this.mFluid.amount, false), false);
- if (tFilledAmount > 0) {
- tTileEntity.getKey().fill(tTileEntity.getValue(), this.drain(tFilledAmount, true),
- true);
- }
+ } else {
+ for (Entry<IFluidHandler, ForgeDirection> tTileEntity : tTanks.entrySet()) {
+ if (mFluid == null || mFluid.amount <= 0) break;
+ int tFilledAmount = tTileEntity.getKey().fill(tTileEntity.getValue(), drain(mFluid.amount, false), false);
+ if (tFilledAmount > 0)
+ tTileEntity.getKey().fill(tTileEntity.getValue(), drain(tFilledAmount, true), true);
}
}
}
}
- this.mLastReceivedFrom = 0;
+ mLastReceivedFrom = 0;
}
- this.oLastReceivedFrom = this.mLastReceivedFrom;
+ oLastReceivedFrom = mLastReceivedFrom;
+ }
+ }
+
+ @Override
+ public void doSound(byte aIndex, double aX, double aY, 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)
+ 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 boolean renderInside(final byte aSide) {
+ public final int getCapacity() {
+ return mCapacity * 20;
+ }
+
+ @Override
+ public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return false;
+ }
+
+ @Override
+ public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
return false;
}
@Override
- public void saveNBTData(final NBTTagCompound aNBT) {
- if (this.mFluid != null) {
- aNBT.setTag("mFluid", this.mFluid.writeToNBT(new NBTTagCompound()));
+ public final FluidStack getFluid() {
+ return mFluid;
+ }
+
+ @Override
+ public final int getFluidAmount() {
+ return mFluid != null ? mFluid.amount : 0;
+ }
+
+ @Override
+ public final int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) {
+ if (aFluid == null || aFluid.getFluid().getID() <= 0) return 0;
+
+ if (mFluid == null || mFluid.getFluid().getID() <= 0) {
+ if (aFluid.amount <= getCapacity()) {
+ if (doFill) {
+ mFluid = aFluid.copy();
+ mLastReceivedFrom |= (1 << aSide.ordinal());
+ }
+ return aFluid.amount;
+ }
+ if (doFill) {
+ mFluid = aFluid.copy();
+ mLastReceivedFrom |= (1 << aSide.ordinal());
+ mFluid.amount = getCapacity();
+ }
+ return getCapacity();
+ }
+
+ if (!mFluid.isFluidEqual(aFluid)) return 0;
+
+ int space = getCapacity() - mFluid.amount;
+ if (aFluid.amount <= space) {
+ if (doFill) {
+ mFluid.amount += aFluid.amount;
+ mLastReceivedFrom |= (1 << aSide.ordinal());
+ }
+ return aFluid.amount;
+ }
+ if (doFill) {
+ mFluid.amount = getCapacity();
+ mLastReceivedFrom |= (1 << aSide.ordinal());
+ }
+ return space;
+ }
+
+ @Override
+ public final FluidStack drain(int maxDrain, boolean doDrain) {
+ if (mFluid == null) return null;
+ if (mFluid.amount <= 0) {
+ mFluid = null;
+ return null;
+ }
+
+ int used = maxDrain;
+ if (mFluid.amount < used)
+ used = mFluid.amount;
+
+ if (doDrain) {
+ mFluid.amount -= used;
+ }
+
+ FluidStack drained = mFluid.copy();
+ drained.amount = used;
+
+ if (mFluid.amount <= 0) {
+ mFluid = null;
}
- aNBT.setByte("mLastReceivedFrom", this.mLastReceivedFrom);
+
+ return drained;
+ }
+
+ @Override
+ public int getTankPressure() {
+ return (mFluid == null ? 0 : mFluid.amount) - (getCapacity() / 2);
+ }
+
+ @Override
+ public String[] getDescription() {
+ return new String[]{
+ EnumChatFormatting.BLUE + "Fluid Capacity: " + (mCapacity * 20) + "L/sec" + EnumChatFormatting.GRAY,
+ EnumChatFormatting.RED + "Heat Limit: " + mHeatResistance + " K" + EnumChatFormatting.GRAY,
+ EnumChatFormatting.DARK_GREEN + "Gas Proof: " + (mGasProof) + EnumChatFormatting.GRAY,
+ CORE.GT_Tooltip
+ };
+ }
+
+ @Override
+ public float getThickNess() {
+ return mThickNess;
}
} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntity_Cable.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntity_Cable.java
index c699077b58..587996a5c6 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntity_Cable.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntity_Cable.java
@@ -1,21 +1,27 @@
package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations;
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import cofh.api.energy.IEnergyReceiver;
+import static gregtech.api.enums.GT_Values.VN;
import gregtech.api.GregTech_API;
-import gregtech.api.enums.*;
+import gregtech.api.enums.Dyes;
+import gregtech.api.enums.Materials;
+import gregtech.api.enums.TextureSet;
+import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.metatileentity.IMetaTileEntityCable;
-import gregtech.api.interfaces.tileentity.*;
+import gregtech.api.interfaces.tileentity.IColoredTileEntity;
+import gregtech.api.interfaces.tileentity.IEnergyConnected;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.BaseMetaPipeEntity;
import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Cable;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_Utility;
import gtPlusPlus.core.lib.CORE;
import ic2.api.energy.tile.IEnergySink;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.tileentity.TileEntity;
@@ -23,362 +29,208 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
+import cofh.api.energy.IEnergyReceiver;
public class GregtechMetaPipeEntity_Cable extends GT_MetaPipeEntity_Cable implements IMetaTileEntityCable {
- public long mTransferredAmperage = 0, mTransferredAmperageLast20 = 0, mTransferredVoltageLast20 = 0;
+ public long mTransferredAmperage = 0, mTransferredAmperageLast20 = 0, mTransferredVoltageLast20 = 0;
- public final float mThickNess;
- public final Materials mMaterial;
- public final long mCableLossPerMeter, mAmperage, mVoltage;
- public final boolean mInsulated, mCanShock;
- public long mRestRF;
+ public final float mThickNess;
+ public final Materials mMaterial;
+ public final long mCableLossPerMeter, mAmperage, mVoltage;
+ public final boolean mInsulated, mCanShock;
+ public long mRestRF;
- public GregtechMetaPipeEntity_Cable(final int aID, final String aName, final String aNameRegional,
- final float aThickNess, final Materials aMaterial, final long aCableLossPerMeter, final long aAmperage,
- final long aVoltage, final boolean aInsulated, final boolean aCanShock) {
+ public GregtechMetaPipeEntity_Cable(int aID, String aName, String aNameRegional, float aThickNess, Materials aMaterial, long aCableLossPerMeter, long aAmperage, long aVoltage, boolean aInsulated, boolean aCanShock) {
super(aID, aName, aNameRegional, 0, aMaterial, aCableLossPerMeter, aAmperage, aVoltage, aInsulated, aCanShock);
- this.mThickNess = aThickNess;
- this.mMaterial = aMaterial;
- this.mAmperage = aAmperage;
- this.mVoltage = aVoltage;
- this.mInsulated = aInsulated;
- this.mCanShock = aCanShock;
- this.mCableLossPerMeter = aCableLossPerMeter;
+ mThickNess = aThickNess;
+ mMaterial = aMaterial;
+ mAmperage = aAmperage;
+ mVoltage = aVoltage;
+ mInsulated = aInsulated;
+ mCanShock = aCanShock;
+ mCableLossPerMeter = aCableLossPerMeter;
}
- public GregtechMetaPipeEntity_Cable(final String aName, final float aThickNess, final Materials aMaterial,
- final long aCableLossPerMeter, final long aAmperage, final long aVoltage, final boolean aInsulated,
- final boolean aCanShock) {
+ public GregtechMetaPipeEntity_Cable(String aName, float aThickNess, Materials aMaterial, long aCableLossPerMeter, long aAmperage, long aVoltage, boolean aInsulated, boolean aCanShock) {
super(aName, 0, aMaterial, aCableLossPerMeter, aAmperage, aVoltage, aInsulated, aCanShock);
- this.mThickNess = aThickNess;
- this.mMaterial = aMaterial;
- this.mAmperage = aAmperage;
- this.mVoltage = aVoltage;
- this.mInsulated = aInsulated;
- this.mCanShock = aCanShock;
- this.mCableLossPerMeter = aCableLossPerMeter;
- }
-
- @Override
- public AxisAlignedBB getCollisionBoundingBoxFromPool(final World aWorld, final int aX, final int aY, final int aZ) {
- if (!this.mCanShock) {
- return super.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ);
- }
- return AxisAlignedBB.getBoundingBox(aX + 0.125D, aY + 0.125D, aZ + 0.125D, aX + 0.875D, aY + 0.875D,
- aZ + 0.875D);
+ mThickNess = aThickNess;
+ mMaterial = aMaterial;
+ mAmperage = aAmperage;
+ mVoltage = aVoltage;
+ mInsulated = aInsulated;
+ mCanShock = aCanShock;
+ mCableLossPerMeter = aCableLossPerMeter;
}
@Override
- public String[] getDescription() {
- return new String[] {
- "Max Voltage: " + EnumChatFormatting.GREEN + this.mVoltage + " ("
- + GT_Values.VN[GT_Utility.getTier(this.mVoltage)] + ")" + EnumChatFormatting.GRAY,
- "Max Amperage: " + EnumChatFormatting.YELLOW + this.mAmperage + EnumChatFormatting.GRAY,
- "Loss/Meter/Ampere: " + EnumChatFormatting.RED + this.mCableLossPerMeter + EnumChatFormatting.GRAY
- + " EU-Volt",
- CORE.GT_Tooltip
- };
+ public byte getTileEntityBaseType() {
+ return (byte)(mInsulated?9:8);
}
- // @Override public final boolean renderInside(byte aSide) {return false;}
@Override
- public int getProgresstime() {
- return (int) this.mTransferredAmperage * 64;
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new GregtechMetaPipeEntity_Cable(mName, mThickNess, mMaterial, mCableLossPerMeter, mAmperage, mVoltage, mInsulated, mCanShock);
}
@Override
- public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide,
- final byte aConnections, final byte aColorIndex, final boolean aConnected, final boolean aRedstone) {
- if (!this.mInsulated) {
- return new ITexture[] {
- new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire],
- this.mMaterial.mRGBa)
- };
- }
+ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, byte aColorIndex, boolean aConnected, boolean aRedstone) {
+ if (!mInsulated) return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa)};
if (aConnected) {
- final float tThickNess = this.getThickNess();
- if (tThickNess < 0.37F) {
- return new ITexture[] {
- new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire],
- this.mMaterial.mRGBa),
- new GT_RenderedTexture(Textures.BlockIcons.INSULATION_TINY,
- Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))
- };
- }
- if (tThickNess < 0.49F) {
- return new ITexture[] {
- new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire],
- this.mMaterial.mRGBa),
- new GT_RenderedTexture(Textures.BlockIcons.INSULATION_SMALL,
- Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))
- };
- }
- if (tThickNess < 0.74F) {
- return new ITexture[] {
- new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire],
- this.mMaterial.mRGBa),
- new GT_RenderedTexture(Textures.BlockIcons.INSULATION_MEDIUM,
- Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))
- };
- }
- if (tThickNess < 0.99F) {
- return new ITexture[] {
- new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire],
- this.mMaterial.mRGBa),
- new GT_RenderedTexture(Textures.BlockIcons.INSULATION_LARGE,
- Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))
- };
- }
- return new ITexture[] {
- new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire],
- this.mMaterial.mRGBa),
- new GT_RenderedTexture(Textures.BlockIcons.INSULATION_HUGE,
- Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))
- };
+ float tThickNess = getThickNess();
+ if (tThickNess < 0.37F) return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_TINY , Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))};
+ if (tThickNess < 0.49F) return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_SMALL , Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))};
+ if (tThickNess < 0.74F) return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_MEDIUM , Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))};
+ if (tThickNess < 0.99F) return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_LARGE , Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))};
+ return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_HUGE , Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))};
}
- return new ITexture[] {
- new GT_RenderedTexture(Textures.BlockIcons.INSULATION_FULL,
- Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))
- };
- }
-
- @Override
- public float getThickNess() {
- return this.mThickNess;
+ return new ITexture[] {new GT_RenderedTexture(Textures.BlockIcons.INSULATION_FULL, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))};
}
@Override
- public byte getTileEntityBaseType() {
- return (byte) (this.mInsulated ? 9 : 8);
- }
-
- @Override
- public long injectEnergyUnits(final byte aSide, final long aVoltage, final long aAmperage) {
- if (!this.getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).letsEnergyIn(aSide,
- this.getBaseMetaTileEntity().getCoverIDAtSide(aSide),
- this.getBaseMetaTileEntity().getCoverDataAtSide(aSide), this.getBaseMetaTileEntity())) {
- return 0;
- }
- return this.transferElectricity(aSide, aVoltage, aAmperage,
- new ArrayList<TileEntity>(Arrays.asList((TileEntity) this.getBaseMetaTileEntity())));
+ public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity aEntity) {
+ if (mCanShock && (((BaseMetaPipeEntity)getBaseMetaTileEntity()).mConnections & -128) == 0 && aEntity instanceof EntityLivingBase) GT_Utility.applyElectricityDamage((EntityLivingBase)aEntity, mTransferredVoltageLast20, mTransferredAmperageLast20);
}
@Override
- public boolean isFacingValid(final byte aFacing) {
- return false;
- }
-
- @Override
- public boolean isSimpleMachine() {
- return true;
- }
-
- @Override
- public boolean isValidSlot(final int aIndex) {
- return true;
- }
-
- @Override
- public int maxProgresstime() {
- return (int) this.mAmperage * 64;
- }
+ public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) {
+ if (!mCanShock) return super.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ);
+ return AxisAlignedBB.getBoundingBox(aX+0.125D, aY+0.125D, aZ+0.125D, aX+0.875D, aY+0.875D, aZ+0.875D);
+ }
+
+ @Override public boolean isSimpleMachine() {return true;}
+ @Override public boolean isFacingValid(byte aFacing) {return false;}
+ @Override public boolean isValidSlot(int aIndex) {return true;}
+ // @Override public final boolean renderInside(byte aSide) {return false;}
+ @Override public int getProgresstime() {return (int)mTransferredAmperage*64;}
+ @Override public int maxProgresstime() {return (int)mAmperage*64;}
@Override
- public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) {
- return new GregtechMetaPipeEntity_Cable(this.mName, this.mThickNess, this.mMaterial, this.mCableLossPerMeter,
- this.mAmperage, this.mVoltage, this.mInsulated, this.mCanShock);
+ public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) {
+ if (!getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).letsEnergyIn(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getCoverDataAtSide(aSide), getBaseMetaTileEntity())) return 0;
+ return transferElectricity(aSide, aVoltage, aAmperage, new ArrayList<TileEntity>(Arrays.asList((TileEntity)getBaseMetaTileEntity())));
}
@Override
- public void onEntityCollidedWithBlock(final World aWorld, final int aX, final int aY, final int aZ,
- final Entity aEntity) {
- if (this.mCanShock && (((BaseMetaPipeEntity) this.getBaseMetaTileEntity()).mConnections & -128) == 0
- && aEntity instanceof EntityLivingBase) {
- GT_Utility.applyElectricityDamage((EntityLivingBase) aEntity, this.mTransferredVoltageLast20,
- this.mTransferredAmperageLast20);
+ public long transferElectricity(byte aSide, long aVoltage, long aAmperage, ArrayList<TileEntity> aAlreadyPassedTileEntityList) {
+ long rUsedAmperes = 0;
+ aVoltage -= mCableLossPerMeter;
+ if (aVoltage > 0) for (byte i = 0; i < 6 && aAmperage > rUsedAmperes; i++) if (i != aSide && (mConnections & (1<<i)) != 0 && getBaseMetaTileEntity().getCoverBehaviorAtSide(i).letsEnergyOut(i, getBaseMetaTileEntity().getCoverIDAtSide(i), getBaseMetaTileEntity().getCoverDataAtSide(i), getBaseMetaTileEntity())) {
+ TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityAtSide(i);
+ if (!aAlreadyPassedTileEntityList.contains(tTileEntity)) {
+ aAlreadyPassedTileEntityList.add(tTileEntity);
+ if (tTileEntity instanceof IEnergyConnected) {
+ if (getBaseMetaTileEntity().getColorization() >= 0) {
+ byte tColor = ((IEnergyConnected)tTileEntity).getColorization();
+ if (tColor >= 0 && tColor != getBaseMetaTileEntity().getColorization()) continue;
+ }
+ if (tTileEntity instanceof IGregTechTileEntity && ((IGregTechTileEntity)tTileEntity).getMetaTileEntity() instanceof IMetaTileEntityCable && ((IGregTechTileEntity)tTileEntity).getCoverBehaviorAtSide(GT_Utility.getOppositeSide(i)).letsEnergyIn(GT_Utility.getOppositeSide(i), ((IGregTechTileEntity)tTileEntity).getCoverIDAtSide(GT_Utility.getOppositeSide(i)), ((IGregTechTileEntity)tTileEntity).getCoverDataAtSide(GT_Utility.getOppositeSide(i)), ((IGregTechTileEntity)tTileEntity))) {
+ if (((IGregTechTileEntity)tTileEntity).getTimer() > 50) rUsedAmperes += ((IMetaTileEntityCable)((IGregTechTileEntity)tTileEntity).getMetaTileEntity()).transferElectricity(GT_Utility.getOppositeSide(i), aVoltage, aAmperage-rUsedAmperes, aAlreadyPassedTileEntityList);
+ } else {
+ rUsedAmperes += ((IEnergyConnected)tTileEntity).injectEnergyUnits(GT_Utility.getOppositeSide(i), aVoltage, aAmperage-rUsedAmperes);
+ }
+ // } else if (tTileEntity instanceof IEnergySink) {
+ // ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite();
+ // if (((IEnergySink)tTileEntity).acceptsEnergyFrom((TileEntity)getBaseMetaTileEntity(), tDirection)) {
+ // if (((IEnergySink)tTileEntity).demandedEnergyUnits() > 0 && ((IEnergySink)tTileEntity).injectEnergyUnits(tDirection, aVoltage) < aVoltage) rUsedAmperes++;
+ // }
+ } else if (tTileEntity instanceof IEnergySink) {
+ ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite();
+ if (((IEnergySink)tTileEntity).acceptsEnergyFrom((TileEntity)getBaseMetaTileEntity(), tDirection)) {
+ if (((IEnergySink)tTileEntity).getDemandedEnergy() > 0 && ((IEnergySink)tTileEntity).injectEnergy(tDirection, aVoltage, aVoltage) < aVoltage) rUsedAmperes++;
+ }
+ } else if(GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver){
+ ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite();
+ int rfOut = (int) (aVoltage * GregTech_API.mEUtoRF / 100);
+ if(((IEnergyReceiver)tTileEntity).receiveEnergy(tDirection, rfOut, true)==rfOut){
+ ((IEnergyReceiver)tTileEntity).receiveEnergy(tDirection, rfOut, false); rUsedAmperes++;
+ }else if(((IEnergyReceiver)tTileEntity).receiveEnergy(tDirection, rfOut, true)>0){
+ if(mRestRF==0){
+ int RFtrans = ((IEnergyReceiver)tTileEntity).receiveEnergy(tDirection, (int) rfOut, false);rUsedAmperes++;
+ mRestRF = rfOut - RFtrans;
+ }else{
+ int RFtrans = ((IEnergyReceiver)tTileEntity).receiveEnergy(tDirection, (int) mRestRF, false);
+ mRestRF = mRestRF - RFtrans;
+ }
+ }
+ if(GregTech_API.mRFExplosions && ((IEnergyReceiver)tTileEntity).getMaxEnergyStored(tDirection) < rfOut * 600){
+ if(rfOut > 32 * GregTech_API.mEUtoRF / 100) this.doExplosion(rfOut);
+ }
+ }
+ }
+ }
+ mTransferredAmperage += rUsedAmperes;
+ mTransferredVoltageLast20 = Math.max(mTransferredVoltageLast20, aVoltage);
+ mTransferredAmperageLast20 = Math.max(mTransferredAmperageLast20, mTransferredAmperage);
+ if (aVoltage > mVoltage || mTransferredAmperage > mAmperage) {
+ getBaseMetaTileEntity().setToFire();
+ return aAmperage;
}
+ return rUsedAmperes;
}
@Override
- public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) {
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
if (aBaseMetaTileEntity.isServerSide()) {
- this.mTransferredAmperage = 0;
+ mTransferredAmperage = 0;
if (aTick % 20 == 0) {
- this.mTransferredVoltageLast20 = 0;
- this.mTransferredAmperageLast20 = 0;
- this.mConnections = 0;
+ mTransferredVoltageLast20 = 0;
+ mTransferredAmperageLast20 = 0;
+ mConnections = 0;
for (byte i = 0, j = 0; i < 6; i++) {
j = GT_Utility.getOppositeSide(i);
- if (aBaseMetaTileEntity.getCoverBehaviorAtSide(i).alwaysLookConnected(i,
- aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i),
- aBaseMetaTileEntity)
- || aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsEnergyIn(i,
- aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i),
- aBaseMetaTileEntity)
- || aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsEnergyOut(i,
- aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i),
- aBaseMetaTileEntity)) {
- final TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(i);
+ if (aBaseMetaTileEntity.getCoverBehaviorAtSide(i).alwaysLookConnected(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), aBaseMetaTileEntity) || aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsEnergyIn(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), aBaseMetaTileEntity) || aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsEnergyOut(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), aBaseMetaTileEntity)) {
+ TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(i);
if (tTileEntity instanceof IColoredTileEntity) {
if (aBaseMetaTileEntity.getColorization() >= 0) {
- final byte tColor = ((IColoredTileEntity) tTileEntity).getColorization();
- if (tColor >= 0 && tColor != aBaseMetaTileEntity.getColorization()) {
- continue;
- }
+ byte tColor = ((IColoredTileEntity)tTileEntity).getColorization();
+ if (tColor >= 0 && tColor != aBaseMetaTileEntity.getColorization()) continue;
}
}
- if (tTileEntity instanceof IEnergyConnected
- && (((IEnergyConnected) tTileEntity).inputEnergyFrom(j)
- || ((IEnergyConnected) tTileEntity).outputsEnergyTo(j))) {
- this.mConnections |= 1 << i;
+ if (tTileEntity instanceof IEnergyConnected && (((IEnergyConnected)tTileEntity).inputEnergyFrom(j) || ((IEnergyConnected)tTileEntity).outputsEnergyTo(j))) {
+ mConnections |= (1<<i);
continue;
}
- if (tTileEntity instanceof IGregTechTileEntity && ((IGregTechTileEntity) tTileEntity)
- .getMetaTileEntity() instanceof IMetaTileEntityCable) {
- if (((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(j).alwaysLookConnected(j,
- ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(j),
- ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(j),
- (IGregTechTileEntity) tTileEntity)
- || ((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(j).letsEnergyIn(j,
- ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(j),
- ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(j),
- (IGregTechTileEntity) tTileEntity)
- || ((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(j).letsEnergyOut(j,
- ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(j),
- ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(j),
- (IGregTechTileEntity) tTileEntity)) {
- this.mConnections |= 1 << i;
+ if (tTileEntity instanceof IGregTechTileEntity && ((IGregTechTileEntity)tTileEntity).getMetaTileEntity() instanceof IMetaTileEntityCable) {
+ if (((IGregTechTileEntity)tTileEntity).getCoverBehaviorAtSide(j).alwaysLookConnected(j, ((IGregTechTileEntity)tTileEntity).getCoverIDAtSide(j), ((IGregTechTileEntity)tTileEntity).getCoverDataAtSide(j), ((IGregTechTileEntity)tTileEntity)) || ((IGregTechTileEntity)tTileEntity).getCoverBehaviorAtSide(j).letsEnergyIn(j, ((IGregTechTileEntity)tTileEntity).getCoverIDAtSide(j), ((IGregTechTileEntity)tTileEntity).getCoverDataAtSide(j), ((IGregTechTileEntity)tTileEntity)) || ((IGregTechTileEntity)tTileEntity).getCoverBehaviorAtSide(j).letsEnergyOut(j, ((IGregTechTileEntity)tTileEntity).getCoverIDAtSide(j), ((IGregTechTileEntity)tTileEntity).getCoverDataAtSide(j), ((IGregTechTileEntity)tTileEntity))) {
+ mConnections |= (1<<i);
continue;
}
}
- if (tTileEntity instanceof IEnergySink && ((IEnergySink) tTileEntity).acceptsEnergyFrom(
- (TileEntity) aBaseMetaTileEntity, ForgeDirection.getOrientation(j))) {
- this.mConnections |= 1 << i;
- continue;
- }
- if (GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver
- && ((IEnergyReceiver) tTileEntity).canConnectEnergy(ForgeDirection.getOrientation(j))) {
- this.mConnections |= 1 << i;
+ if (tTileEntity instanceof IEnergySink && ((IEnergySink)tTileEntity).acceptsEnergyFrom((TileEntity)aBaseMetaTileEntity, ForgeDirection.getOrientation(j))) {
+ mConnections |= (1<<i);
continue;
}
+ if(GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver && ((IEnergyReceiver)tTileEntity).canConnectEnergy(ForgeDirection.getOrientation(j))){
+ mConnections |= (1<<i);
+ continue;
+ }
/*
- * if (tTileEntity instanceof IEnergyEmitter &&
- * ((IEnergyEmitter)tTileEntity).emitsEnergyTo((
- * TileEntity)aBaseMetaTileEntity,
- * ForgeDirection.getOrientation(j))) { mConnections |=
- * (1<<i); continue; }
- */
+ if (tTileEntity instanceof IEnergyEmitter && ((IEnergyEmitter)tTileEntity).emitsEnergyTo((TileEntity)aBaseMetaTileEntity, ForgeDirection.getOrientation(j))) {
+ mConnections |= (1<<i);
+ continue;
+ }*/
}
}
}
}
}
+
@Override
- public long transferElectricity(final byte aSide, long aVoltage, final long aAmperage,
- final ArrayList<TileEntity> aAlreadyPassedTileEntityList) {
- long rUsedAmperes = 0;
- aVoltage -= this.mCableLossPerMeter;
- if (aVoltage > 0) {
- for (byte i = 0; i < 6 && aAmperage > rUsedAmperes; i++) {
- if (i != aSide && (this.mConnections & 1 << i) != 0
- && this.getBaseMetaTileEntity().getCoverBehaviorAtSide(i).letsEnergyOut(i,
- this.getBaseMetaTileEntity().getCoverIDAtSide(i),
- this.getBaseMetaTileEntity().getCoverDataAtSide(i), this.getBaseMetaTileEntity())) {
- final TileEntity tTileEntity = this.getBaseMetaTileEntity().getTileEntityAtSide(i);
- if (!aAlreadyPassedTileEntityList.contains(tTileEntity)) {
- aAlreadyPassedTileEntityList.add(tTileEntity);
- if (tTileEntity instanceof IEnergyConnected) {
- if (this.getBaseMetaTileEntity().getColorization() >= 0) {
- final byte tColor = ((IEnergyConnected) tTileEntity).getColorization();
- if (tColor >= 0 && tColor != this.getBaseMetaTileEntity().getColorization()) {
- continue;
- }
- }
- if (tTileEntity instanceof IGregTechTileEntity
- && ((IGregTechTileEntity) tTileEntity)
- .getMetaTileEntity() instanceof IMetaTileEntityCable
- && ((IGregTechTileEntity) tTileEntity)
- .getCoverBehaviorAtSide(GT_Utility.getOppositeSide(i))
- .letsEnergyIn(GT_Utility.getOppositeSide(i),
- ((IGregTechTileEntity) tTileEntity)
- .getCoverIDAtSide(GT_Utility.getOppositeSide(i)),
- ((IGregTechTileEntity) tTileEntity)
- .getCoverDataAtSide(GT_Utility.getOppositeSide(i)),
- (IGregTechTileEntity) tTileEntity)) {
- if (((IGregTechTileEntity) tTileEntity).getTimer() > 50) {
- rUsedAmperes += ((IMetaTileEntityCable) ((IGregTechTileEntity) tTileEntity)
- .getMetaTileEntity()).transferElectricity(GT_Utility.getOppositeSide(i),
- aVoltage, aAmperage - rUsedAmperes, aAlreadyPassedTileEntityList);
- }
- }
- else {
- rUsedAmperes += ((IEnergyConnected) tTileEntity).injectEnergyUnits(
- GT_Utility.getOppositeSide(i), aVoltage, aAmperage - rUsedAmperes);
- }
- // } else if (tTileEntity instanceof IEnergySink) {
- // ForgeDirection tDirection =
- // ForgeDirection.getOrientation(i).getOpposite();
- // if
- // (((IEnergySink)tTileEntity).acceptsEnergyFrom((TileEntity)getBaseMetaTileEntity(),
- // tDirection)) {
- // if
- // (((IEnergySink)tTileEntity).demandedEnergyUnits()
- // > 0 &&
- // ((IEnergySink)tTileEntity).injectEnergyUnits(tDirection,
- // aVoltage) < aVoltage) rUsedAmperes++;
- // }
- }
- else if (tTileEntity instanceof IEnergySink) {
- final ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite();
- if (((IEnergySink) tTileEntity).acceptsEnergyFrom((TileEntity) this.getBaseMetaTileEntity(),
- tDirection)) {
- if (((IEnergySink) tTileEntity).getDemandedEnergy() > 0 && ((IEnergySink) tTileEntity)
- .injectEnergy(tDirection, aVoltage, aVoltage) < aVoltage) {
- rUsedAmperes++;
- }
- }
- }
- else if (GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver) {
- final ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite();
- final int rfOut = (int) (aVoltage * GregTech_API.mEUtoRF / 100);
- if (((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, true) == rfOut) {
- ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, false);
- rUsedAmperes++;
- }
- else if (((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, true) > 0) {
- if (this.mRestRF == 0) {
- final int RFtrans = ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut,
- false);
- rUsedAmperes++;
- this.mRestRF = rfOut - RFtrans;
- }
- else {
- final int RFtrans = ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection,
- (int) this.mRestRF, false);
- this.mRestRF = this.mRestRF - RFtrans;
- }
- }
- if (GregTech_API.mRFExplosions
- && ((IEnergyReceiver) tTileEntity).getMaxEnergyStored(tDirection) < rfOut * 600) {
- if (rfOut > 32 * GregTech_API.mEUtoRF / 100) {
- this.doExplosion(rfOut);
- }
- }
- }
- }
- }
- }
- }
- this.mTransferredAmperage += rUsedAmperes;
- this.mTransferredVoltageLast20 = Math.max(this.mTransferredVoltageLast20, aVoltage);
- this.mTransferredAmperageLast20 = Math.max(this.mTransferredAmperageLast20, this.mTransferredAmperage);
- if (aVoltage > this.mVoltage || this.mTransferredAmperage > this.mAmperage) {
- this.getBaseMetaTileEntity().setToFire();
- return aAmperage;
- }
- return rUsedAmperes;
+ public String[] getDescription() {
+ return new String[] {
+ "Max Voltage: " + EnumChatFormatting.GREEN + mVoltage + " (" + VN[GT_Utility.getTier(mVoltage)] + ")" + EnumChatFormatting.GRAY,
+ "Max Amperage: " + EnumChatFormatting.YELLOW + mAmperage + EnumChatFormatting.GRAY,
+ "Loss/Meter/Ampere: " + EnumChatFormatting.RED + mCableLossPerMeter + EnumChatFormatting.GRAY + " EU-Volt",
+ CORE.GT_Tooltip
+ };
+ }
+
+
+ @Override
+ public float getThickNess() {
+ return mThickNess;
}
} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntity_SuperConductor.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntity_SuperConductor.java
index 77fcdd7af1..7f903576c2 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntity_SuperConductor.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntity_SuperConductor.java
@@ -1,15 +1,16 @@
package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations;
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import cofh.api.energy.IEnergyReceiver;
+import static gregtech.api.enums.GT_Values.VN;
import gregtech.api.GregTech_API;
-import gregtech.api.enums.*;
+import gregtech.api.enums.Dyes;
+import gregtech.api.enums.TextureSet;
+import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.metatileentity.IMetaTileEntityCable;
-import gregtech.api.interfaces.tileentity.*;
+import gregtech.api.interfaces.tileentity.IColoredTileEntity;
+import gregtech.api.interfaces.tileentity.IEnergyConnected;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.BaseMetaPipeEntity;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_Utility;
@@ -17,6 +18,10 @@ import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaPipeEntityBase_Cable;
import ic2.api.energy.tile.IEnergySink;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.tileentity.TileEntity;
@@ -24,364 +29,211 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
+import cofh.api.energy.IEnergyReceiver;
-public class GregtechMetaPipeEntity_SuperConductor extends GregtechMetaPipeEntityBase_Cable
- implements IMetaTileEntityCable {
- public long mTransferredAmperage = 0, mTransferredAmperageLast20 = 0,
- mTransferredVoltageLast20 = 0;
+public class GregtechMetaPipeEntity_SuperConductor extends GregtechMetaPipeEntityBase_Cable implements IMetaTileEntityCable {
+ public long mTransferredAmperage = 0, mTransferredAmperageLast20 = 0, mTransferredVoltageLast20 = 0;
- public final float mThickNess;
- public final GT_Materials mMaterial;
- public final long mCableLossPerMeter, mAmperage, mVoltage;
- public final boolean mInsulated, mCanShock;
- public long mRestRF;
+ public final float mThickNess;
+ public final GT_Materials mMaterial;
+ public final long mCableLossPerMeter, mAmperage, mVoltage;
+ public final boolean mInsulated, mCanShock;
+ public long mRestRF;
- public GregtechMetaPipeEntity_SuperConductor(final int aID, final String aName, final String aNameRegional,
- final float aThickNess, final GT_Materials aMaterial, final long aCableLossPerMeter, final long aAmperage,
- final long aVoltage, final boolean aInsulated, final boolean aCanShock) {
+ public GregtechMetaPipeEntity_SuperConductor(int aID, String aName, String aNameRegional, float aThickNess, GT_Materials aMaterial, long aCableLossPerMeter, long aAmperage, long aVoltage, boolean aInsulated, boolean aCanShock) {
super(aID, aName, aNameRegional, 0, aMaterial, 0, aAmperage, aVoltage, aInsulated, aCanShock);
- this.mThickNess = aThickNess;
- this.mMaterial = aMaterial;
- this.mAmperage = aAmperage;
- this.mVoltage = aVoltage;
- this.mInsulated = aInsulated;
- this.mCanShock = aCanShock;
- this.mCableLossPerMeter = 0;
+ mThickNess = aThickNess;
+ mMaterial = aMaterial;
+ mAmperage = aAmperage;
+ mVoltage = aVoltage;
+ mInsulated = aInsulated;
+ mCanShock = aCanShock;
+ mCableLossPerMeter = 0;
}
- public GregtechMetaPipeEntity_SuperConductor(final String aName, final float aThickNess,
- final GT_Materials aMaterial, final long aCableLossPerMeter, final long aAmperage, final long aVoltage,
- final boolean aInsulated, final boolean aCanShock) {
+ public GregtechMetaPipeEntity_SuperConductor(String aName, float aThickNess, GT_Materials aMaterial, long aCableLossPerMeter, long aAmperage, long aVoltage, boolean aInsulated, boolean aCanShock) {
super(aName, 0, aMaterial, 0, aAmperage, aVoltage, aInsulated, aCanShock);
- this.mThickNess = aThickNess;
- this.mMaterial = aMaterial;
- this.mAmperage = aAmperage;
- this.mVoltage = aVoltage;
- this.mInsulated = aInsulated;
- this.mCanShock = aCanShock;
- this.mCableLossPerMeter = 0;
+ mThickNess = aThickNess;
+ mMaterial = aMaterial;
+ mAmperage = aAmperage;
+ mVoltage = aVoltage;
+ mInsulated = aInsulated;
+ mCanShock = aCanShock;
+ mCableLossPerMeter = 0;
}
@Override
- public AxisAlignedBB getCollisionBoundingBoxFromPool(final World aWorld, final int aX, final int aY, final int aZ) {
- if (!this.mCanShock) {
- return super.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ);
- }
- return AxisAlignedBB.getBoundingBox(aX + 0.125D, aY + 0.125D, aZ + 0.125D, aX + 0.875D, aY + 0.875D,
- aZ + 0.875D);
- }
-
- @Override
- public String[] getDescription() {
- return new String[] {
- "Max Voltage: " + EnumChatFormatting.GREEN + this.mVoltage + " ("
- + GT_Values.VN[GT_Utility.getTier(this.mVoltage)] + ")" + EnumChatFormatting.GRAY,
- "Max Amperage: " + EnumChatFormatting.YELLOW + this.mAmperage + EnumChatFormatting.GRAY,
- "Loss/Meter/Ampere: " + EnumChatFormatting.RED + this.mCableLossPerMeter + EnumChatFormatting.GRAY
- + " EU-Volt",
- CORE.GT_Tooltip, " ", "This Wire is Lossless.", "Please, adhere to cooling directions."
- };
+ public byte getTileEntityBaseType() {
+ return (byte)(mInsulated?9:8);
}
- // @Override public final boolean renderInside(byte aSide) {return false;}
@Override
- public int getProgresstime() {
- return (int) this.mTransferredAmperage * 64;
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new GregtechMetaPipeEntity_SuperConductor(mName, mThickNess, mMaterial, mCableLossPerMeter, mAmperage, mVoltage, mInsulated, mCanShock);
}
@Override
- public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide,
- final byte aConnections, final byte aColorIndex, final boolean aConnected, final boolean aRedstone) {
- if (!this.mInsulated) {
- return new ITexture[] {
- new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire],
- this.mMaterial.mRGBa)
- };
- }
+ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, byte aColorIndex, boolean aConnected, boolean aRedstone) {
+ if (!mInsulated) return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa)};
if (aConnected) {
- final float tThickNess = this.getThickNess();
- if (tThickNess < 0.37F) {
- return new ITexture[] {
- new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire],
- this.mMaterial.mRGBa),
- new GT_RenderedTexture(Textures.BlockIcons.INSULATION_TINY,
- Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))
- };
- }
- if (tThickNess < 0.49F) {
- return new ITexture[] {
- new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire],
- this.mMaterial.mRGBa),
- new GT_RenderedTexture(Textures.BlockIcons.INSULATION_SMALL,
- Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))
- };
- }
- if (tThickNess < 0.74F) {
- return new ITexture[] {
- new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire],
- this.mMaterial.mRGBa),
- new GT_RenderedTexture(Textures.BlockIcons.INSULATION_MEDIUM,
- Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))
- };
- }
- if (tThickNess < 0.99F) {
- return new ITexture[] {
- new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire],
- this.mMaterial.mRGBa),
- new GT_RenderedTexture(Textures.BlockIcons.INSULATION_LARGE,
- Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))
- };
- }
- return new ITexture[] {
- new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire],
- this.mMaterial.mRGBa),
- new GT_RenderedTexture(Textures.BlockIcons.INSULATION_HUGE,
- Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))
- };
+ float tThickNess = getThickNess();
+ if (tThickNess < 0.37F) return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_TINY , Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))};
+ if (tThickNess < 0.49F) return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_SMALL , Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))};
+ if (tThickNess < 0.74F) return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_MEDIUM , Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))};
+ if (tThickNess < 0.99F) return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_LARGE , Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))};
+ return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_HUGE , Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))};
}
- return new ITexture[] {
- new GT_RenderedTexture(Textures.BlockIcons.INSULATION_FULL,
- Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))
- };
- }
-
- @Override
- public float getThickNess() {
- return this.mThickNess;
+ return new ITexture[] {new GT_RenderedTexture(Textures.BlockIcons.INSULATION_FULL, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))};
}
@Override
- public byte getTileEntityBaseType() {
- return (byte) (this.mInsulated ? 9 : 8);
- }
-
- @Override
- public long injectEnergyUnits(final byte aSide, final long aVoltage, final long aAmperage) {
- if (!this.getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).letsEnergyIn(aSide,
- this.getBaseMetaTileEntity().getCoverIDAtSide(aSide),
- this.getBaseMetaTileEntity().getCoverDataAtSide(aSide), this.getBaseMetaTileEntity())) {
- return 0;
- }
- return this.transferElectricity(aSide, aVoltage, aAmperage,
- new ArrayList<TileEntity>(Arrays.asList((TileEntity) this.getBaseMetaTileEntity())));
+ public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity aEntity) {
+ if (mCanShock && (((BaseMetaPipeEntity)getBaseMetaTileEntity()).mConnections & -128) == 0 && aEntity instanceof EntityLivingBase) GT_Utility.applyElectricityDamage((EntityLivingBase)aEntity, mTransferredVoltageLast20, mTransferredAmperageLast20);
}
@Override
- public boolean isFacingValid(final byte aFacing) {
- return false;
- }
-
- @Override
- public boolean isSimpleMachine() {
- return true;
- }
-
- @Override
- public boolean isValidSlot(final int aIndex) {
- return true;
- }
-
- @Override
- public int maxProgresstime() {
- return (int) this.mAmperage * 64;
- }
+ public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) {
+ if (!mCanShock) return super.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ);
+ return AxisAlignedBB.getBoundingBox(aX+0.125D, aY+0.125D, aZ+0.125D, aX+0.875D, aY+0.875D, aZ+0.875D);
+ }
+
+ @Override public boolean isSimpleMachine() {return true;}
+ @Override public boolean isFacingValid(byte aFacing) {return false;}
+ @Override public boolean isValidSlot(int aIndex) {return true;}
+ // @Override public final boolean renderInside(byte aSide) {return false;}
+ @Override public int getProgresstime() {return (int)mTransferredAmperage*64;}
+ @Override public int maxProgresstime() {return (int)mAmperage*64;}
@Override
- public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) {
- return new GregtechMetaPipeEntity_SuperConductor(this.mName, this.mThickNess, this.mMaterial,
- this.mCableLossPerMeter, this.mAmperage, this.mVoltage, this.mInsulated, this.mCanShock);
+ public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) {
+ if (!getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).letsEnergyIn(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getCoverDataAtSide(aSide), getBaseMetaTileEntity())) return 0;
+ return transferElectricity(aSide, aVoltage, aAmperage, new ArrayList<TileEntity>(Arrays.asList((TileEntity)getBaseMetaTileEntity())));
}
@Override
- public void onEntityCollidedWithBlock(final World aWorld, final int aX, final int aY, final int aZ,
- final Entity aEntity) {
- if (this.mCanShock && (((BaseMetaPipeEntity) this.getBaseMetaTileEntity()).mConnections & -128) == 0
- && aEntity instanceof EntityLivingBase) {
- GT_Utility.applyElectricityDamage((EntityLivingBase) aEntity, this.mTransferredVoltageLast20,
- this.mTransferredAmperageLast20);
+ public long transferElectricity(byte aSide, long aVoltage, long aAmperage, ArrayList<TileEntity> aAlreadyPassedTileEntityList) {
+ long rUsedAmperes = 0;
+ aVoltage -= mCableLossPerMeter;
+ if (aVoltage > 0) for (byte i = 0; i < 6 && aAmperage > rUsedAmperes; i++) if (i != aSide && (mConnections & (1<<i)) != 0 && getBaseMetaTileEntity().getCoverBehaviorAtSide(i).letsEnergyOut(i, getBaseMetaTileEntity().getCoverIDAtSide(i), getBaseMetaTileEntity().getCoverDataAtSide(i), getBaseMetaTileEntity())) {
+ TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityAtSide(i);
+ if (!aAlreadyPassedTileEntityList.contains(tTileEntity)) {
+ aAlreadyPassedTileEntityList.add(tTileEntity);
+ if (tTileEntity instanceof IEnergyConnected) {
+ if (getBaseMetaTileEntity().getColorization() >= 0) {
+ byte tColor = ((IEnergyConnected)tTileEntity).getColorization();
+ if (tColor >= 0 && tColor != getBaseMetaTileEntity().getColorization()) continue;
+ }
+ if (tTileEntity instanceof IGregTechTileEntity && ((IGregTechTileEntity)tTileEntity).getMetaTileEntity() instanceof IMetaTileEntityCable && ((IGregTechTileEntity)tTileEntity).getCoverBehaviorAtSide(GT_Utility.getOppositeSide(i)).letsEnergyIn(GT_Utility.getOppositeSide(i), ((IGregTechTileEntity)tTileEntity).getCoverIDAtSide(GT_Utility.getOppositeSide(i)), ((IGregTechTileEntity)tTileEntity).getCoverDataAtSide(GT_Utility.getOppositeSide(i)), ((IGregTechTileEntity)tTileEntity))) {
+ if (((IGregTechTileEntity)tTileEntity).getTimer() > 50) rUsedAmperes += ((IMetaTileEntityCable)((IGregTechTileEntity)tTileEntity).getMetaTileEntity()).transferElectricity(GT_Utility.getOppositeSide(i), aVoltage, aAmperage-rUsedAmperes, aAlreadyPassedTileEntityList);
+ } else {
+ rUsedAmperes += ((IEnergyConnected)tTileEntity).injectEnergyUnits(GT_Utility.getOppositeSide(i), aVoltage, aAmperage-rUsedAmperes);
+ }
+ // } else if (tTileEntity instanceof IEnergySink) {
+ // ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite();
+ // if (((IEnergySink)tTileEntity).acceptsEnergyFrom((TileEntity)getBaseMetaTileEntity(), tDirection)) {
+ // if (((IEnergySink)tTileEntity).demandedEnergyUnits() > 0 && ((IEnergySink)tTileEntity).injectEnergyUnits(tDirection, aVoltage) < aVoltage) rUsedAmperes++;
+ // }
+ } else if (tTileEntity instanceof IEnergySink) {
+ ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite();
+ if (((IEnergySink)tTileEntity).acceptsEnergyFrom((TileEntity)getBaseMetaTileEntity(), tDirection)) {
+ if (((IEnergySink)tTileEntity).getDemandedEnergy() > 0 && ((IEnergySink)tTileEntity).injectEnergy(tDirection, aVoltage, aVoltage) < aVoltage) rUsedAmperes++;
+ }
+ } else if(GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver){
+ ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite();
+ int rfOut = (int) (aVoltage * GregTech_API.mEUtoRF / 100);
+ if(((IEnergyReceiver)tTileEntity).receiveEnergy(tDirection, rfOut, true)==rfOut){
+ ((IEnergyReceiver)tTileEntity).receiveEnergy(tDirection, rfOut, false); rUsedAmperes++;
+ }else if(((IEnergyReceiver)tTileEntity).receiveEnergy(tDirection, rfOut, true)>0){
+ if(mRestRF==0){
+ int RFtrans = ((IEnergyReceiver)tTileEntity).receiveEnergy(tDirection, (int) rfOut, false);rUsedAmperes++;
+ mRestRF = rfOut - RFtrans;
+ }else{
+ int RFtrans = ((IEnergyReceiver)tTileEntity).receiveEnergy(tDirection, (int) mRestRF, false);
+ mRestRF = mRestRF - RFtrans;
+ }
+ }
+ if(GregTech_API.mRFExplosions && ((IEnergyReceiver)tTileEntity).getMaxEnergyStored(tDirection) < rfOut * 600){
+ if(rfOut > 32 * GregTech_API.mEUtoRF / 100) this.doExplosion(rfOut);
+ }
+ }
+ }
+ }
+ mTransferredAmperage += rUsedAmperes;
+ mTransferredVoltageLast20 = Math.max(mTransferredVoltageLast20, aVoltage);
+ mTransferredAmperageLast20 = Math.max(mTransferredAmperageLast20, mTransferredAmperage);
+ if (aVoltage > mVoltage || mTransferredAmperage > mAmperage) {
+ getBaseMetaTileEntity().setToFire();
+ return aAmperage;
}
+ return rUsedAmperes;
}
@Override
- public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) {
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
if (aBaseMetaTileEntity.isServerSide()) {
- this.mTransferredAmperage = 0;
+ mTransferredAmperage = 0;
if (aTick % 20 == 0) {
- this.mTransferredVoltageLast20 = 0;
- this.mTransferredAmperageLast20 = 0;
- this.mConnections = 0;
+ mTransferredVoltageLast20 = 0;
+ mTransferredAmperageLast20 = 0;
+ mConnections = 0;
for (byte i = 0, j = 0; i < 6; i++) {
j = GT_Utility.getOppositeSide(i);
- if (aBaseMetaTileEntity.getCoverBehaviorAtSide(i).alwaysLookConnected(i,
- aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i),
- aBaseMetaTileEntity)
- || aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsEnergyIn(i,
- aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i),
- aBaseMetaTileEntity)
- || aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsEnergyOut(i,
- aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i),
- aBaseMetaTileEntity)) {
- final TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(i);
+ if (aBaseMetaTileEntity.getCoverBehaviorAtSide(i).alwaysLookConnected(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), aBaseMetaTileEntity) || aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsEnergyIn(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), aBaseMetaTileEntity) || aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsEnergyOut(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), aBaseMetaTileEntity)) {
+ TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(i);
if (tTileEntity instanceof IColoredTileEntity) {
if (aBaseMetaTileEntity.getColorization() >= 0) {
- final byte tColor = ((IColoredTileEntity) tTileEntity).getColorization();
- if (tColor >= 0 && tColor != aBaseMetaTileEntity.getColorization()) {
- continue;
- }
+ byte tColor = ((IColoredTileEntity)tTileEntity).getColorization();
+ if (tColor >= 0 && tColor != aBaseMetaTileEntity.getColorization()) continue;
}
}
- if (tTileEntity instanceof IEnergyConnected
- && (((IEnergyConnected) tTileEntity).inputEnergyFrom(j)
- || ((IEnergyConnected) tTileEntity).outputsEnergyTo(j))) {
- this.mConnections |= 1 << i;
+ if (tTileEntity instanceof IEnergyConnected && (((IEnergyConnected)tTileEntity).inputEnergyFrom(j) || ((IEnergyConnected)tTileEntity).outputsEnergyTo(j))) {
+ mConnections |= (1<<i);
continue;
}
- if (tTileEntity instanceof IGregTechTileEntity && ((IGregTechTileEntity) tTileEntity)
- .getMetaTileEntity() instanceof IMetaTileEntityCable) {
- if (((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(j).alwaysLookConnected(j,
- ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(j),
- ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(j),
- (IGregTechTileEntity) tTileEntity)
- || ((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(j).letsEnergyIn(j,
- ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(j),
- ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(j),
- (IGregTechTileEntity) tTileEntity)
- || ((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(j).letsEnergyOut(j,
- ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(j),
- ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(j),
- (IGregTechTileEntity) tTileEntity)) {
- this.mConnections |= 1 << i;
+ if (tTileEntity instanceof IGregTechTileEntity && ((IGregTechTileEntity)tTileEntity).getMetaTileEntity() instanceof IMetaTileEntityCable) {
+ if (((IGregTechTileEntity)tTileEntity).getCoverBehaviorAtSide(j).alwaysLookConnected(j, ((IGregTechTileEntity)tTileEntity).getCoverIDAtSide(j), ((IGregTechTileEntity)tTileEntity).getCoverDataAtSide(j), ((IGregTechTileEntity)tTileEntity)) || ((IGregTechTileEntity)tTileEntity).getCoverBehaviorAtSide(j).letsEnergyIn(j, ((IGregTechTileEntity)tTileEntity).getCoverIDAtSide(j), ((IGregTechTileEntity)tTileEntity).getCoverDataAtSide(j), ((IGregTechTileEntity)tTileEntity)) || ((IGregTechTileEntity)tTileEntity).getCoverBehaviorAtSide(j).letsEnergyOut(j, ((IGregTechTileEntity)tTileEntity).getCoverIDAtSide(j), ((IGregTechTileEntity)tTileEntity).getCoverDataAtSide(j), ((IGregTechTileEntity)tTileEntity))) {
+ mConnections |= (1<<i);
continue;
}
}
- if (tTileEntity instanceof IEnergySink && ((IEnergySink) tTileEntity).acceptsEnergyFrom(
- (TileEntity) aBaseMetaTileEntity, ForgeDirection.getOrientation(j))) {
- this.mConnections |= 1 << i;
- continue;
- }
- if (GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver
- && ((IEnergyReceiver) tTileEntity).canConnectEnergy(ForgeDirection.getOrientation(j))) {
- this.mConnections |= 1 << i;
+ if (tTileEntity instanceof IEnergySink && ((IEnergySink)tTileEntity).acceptsEnergyFrom((TileEntity)aBaseMetaTileEntity, ForgeDirection.getOrientation(j))) {
+ mConnections |= (1<<i);
continue;
}
+ if(GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver && ((IEnergyReceiver)tTileEntity).canConnectEnergy(ForgeDirection.getOrientation(j))){
+ mConnections |= (1<<i);
+ continue;
+ }
/*
- * if (tTileEntity instanceof IEnergyEmitter &&
- * ((IEnergyEmitter)tTileEntity).emitsEnergyTo((
- * TileEntity)aBaseMetaTileEntity,
- * ForgeDirection.getOrientation(j))) { mConnections |=
- * (1<<i); continue; }
- */
+ if (tTileEntity instanceof IEnergyEmitter && ((IEnergyEmitter)tTileEntity).emitsEnergyTo((TileEntity)aBaseMetaTileEntity, ForgeDirection.getOrientation(j))) {
+ mConnections |= (1<<i);
+ continue;
+ }*/
}
}
}
}
}
+
@Override
- public long transferElectricity(final byte aSide, long aVoltage, final long aAmperage,
- final ArrayList<TileEntity> aAlreadyPassedTileEntityList) {
- long rUsedAmperes = 0;
- aVoltage -= this.mCableLossPerMeter;
- if (aVoltage > 0) {
- for (byte i = 0; i < 6 && aAmperage > rUsedAmperes; i++) {
- if (i != aSide && (this.mConnections & 1 << i) != 0
- && this.getBaseMetaTileEntity().getCoverBehaviorAtSide(i).letsEnergyOut(i,
- this.getBaseMetaTileEntity().getCoverIDAtSide(i),
- this.getBaseMetaTileEntity().getCoverDataAtSide(i), this.getBaseMetaTileEntity())) {
- final TileEntity tTileEntity = this.getBaseMetaTileEntity().getTileEntityAtSide(i);
- if (!aAlreadyPassedTileEntityList.contains(tTileEntity)) {
- aAlreadyPassedTileEntityList.add(tTileEntity);
- if (tTileEntity instanceof IEnergyConnected) {
- if (this.getBaseMetaTileEntity().getColorization() >= 0) {
- final byte tColor = ((IEnergyConnected) tTileEntity).getColorization();
- if (tColor >= 0 && tColor != this.getBaseMetaTileEntity().getColorization()) {
- continue;
- }
- }
- if (tTileEntity instanceof IGregTechTileEntity
- && ((IGregTechTileEntity) tTileEntity)
- .getMetaTileEntity() instanceof IMetaTileEntityCable
- && ((IGregTechTileEntity) tTileEntity)
- .getCoverBehaviorAtSide(GT_Utility.getOppositeSide(i))
- .letsEnergyIn(GT_Utility.getOppositeSide(i),
- ((IGregTechTileEntity) tTileEntity)
- .getCoverIDAtSide(GT_Utility.getOppositeSide(i)),
- ((IGregTechTileEntity) tTileEntity)
- .getCoverDataAtSide(GT_Utility.getOppositeSide(i)),
- (IGregTechTileEntity) tTileEntity)) {
- if (((IGregTechTileEntity) tTileEntity).getTimer() > 50) {
- rUsedAmperes += ((IMetaTileEntityCable) ((IGregTechTileEntity) tTileEntity)
- .getMetaTileEntity()).transferElectricity(GT_Utility.getOppositeSide(i),
- aVoltage, aAmperage - rUsedAmperes, aAlreadyPassedTileEntityList);
- }
- }
- else {
- rUsedAmperes += ((IEnergyConnected) tTileEntity).injectEnergyUnits(
- GT_Utility.getOppositeSide(i), aVoltage, aAmperage - rUsedAmperes);
- }
- // } else if (tTileEntity instanceof IEnergySink) {
- // ForgeDirection tDirection =
- // ForgeDirection.getOrientation(i).getOpposite();
- // if
- // (((IEnergySink)tTileEntity).acceptsEnergyFrom((TileEntity)getBaseMetaTileEntity(),
- // tDirection)) {
- // if
- // (((IEnergySink)tTileEntity).demandedEnergyUnits()
- // > 0 &&
- // ((IEnergySink)tTileEntity).injectEnergyUnits(tDirection,
- // aVoltage) < aVoltage) rUsedAmperes++;
- // }
- }
- else if (tTileEntity instanceof IEnergySink) {
- final ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite();
- if (((IEnergySink) tTileEntity).acceptsEnergyFrom((TileEntity) this.getBaseMetaTileEntity(),
- tDirection)) {
- if (((IEnergySink) tTileEntity).getDemandedEnergy() > 0 && ((IEnergySink) tTileEntity)
- .injectEnergy(tDirection, aVoltage, aVoltage) < aVoltage) {
- rUsedAmperes++;
- }
- }
- }
- else if (GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver) {
- final ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite();
- final int rfOut = (int) (aVoltage * GregTech_API.mEUtoRF / 100);
- if (((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, true) == rfOut) {
- ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, false);
- rUsedAmperes++;
- }
- else if (((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, true) > 0) {
- if (this.mRestRF == 0) {
- final int RFtrans = ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut,
- false);
- rUsedAmperes++;
- this.mRestRF = rfOut - RFtrans;
- }
- else {
- final int RFtrans = ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection,
- (int) this.mRestRF, false);
- this.mRestRF = this.mRestRF - RFtrans;
- }
- }
- if (GregTech_API.mRFExplosions
- && ((IEnergyReceiver) tTileEntity).getMaxEnergyStored(tDirection) < rfOut * 600) {
- if (rfOut > 32 * GregTech_API.mEUtoRF / 100) {
- this.doExplosion(rfOut);
- }
- }
- }
- }
- }
- }
- }
- this.mTransferredAmperage += rUsedAmperes;
- this.mTransferredVoltageLast20 = Math.max(this.mTransferredVoltageLast20, aVoltage);
- this.mTransferredAmperageLast20 = Math.max(this.mTransferredAmperageLast20, this.mTransferredAmperage);
- if (aVoltage > this.mVoltage || this.mTransferredAmperage > this.mAmperage) {
- this.getBaseMetaTileEntity().setToFire();
- return aAmperage;
- }
- return rUsedAmperes;
+ public String[] getDescription() {
+ return new String[] {
+ "Max Voltage: " + EnumChatFormatting.GREEN + mVoltage + " (" + VN[GT_Utility.getTier(mVoltage)] + ")" + EnumChatFormatting.GRAY,
+ "Max Amperage: " + EnumChatFormatting.YELLOW + mAmperage + EnumChatFormatting.GRAY,
+ "Loss/Meter/Ampere: " + EnumChatFormatting.RED + mCableLossPerMeter + EnumChatFormatting.GRAY + " EU-Volt",
+ CORE.GT_Tooltip,
+ " ",
+ "This Wire is Lossless.",
+ "Please, adhere to cooling directions."
+ };
+ }
+
+
+ @Override
+ public float getThickNess() {
+ return mThickNess;
}
} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaSafeBlock.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaSafeBlock.java
index 24aeb872ed..c574087020 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaSafeBlock.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaSafeBlock.java
@@ -12,73 +12,65 @@ import gtPlusPlus.xmod.gregtech.api.gui.GUI_SafeBlock;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.machines.GregtechMetaSafeBlockBase;
import net.minecraft.entity.player.InventoryPlayer;
-public class GregtechMetaSafeBlock extends GregtechMetaSafeBlockBase {
-
- public GregtechMetaSafeBlock(final int aID, final String aName, final String aNameRegional, final int aTier) {
- super(aID, aName, aNameRegional, aTier, 28, "Protecting your items from sticky fingers.");
- }
-
- public GregtechMetaSafeBlock(final int aID, final String aName, final String aNameRegional, final int aTier,
- final int aInvSlotCount, final String aDescription) {
- super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription);
- }
-
- public GregtechMetaSafeBlock(final String aName, final int aTier, final int aInvSlotCount,
- final String aDescription, final ITexture[][][] aTextures) {
- super(aName, aTier, aInvSlotCount, aDescription, aTextures);
+public class GregtechMetaSafeBlock
+ extends GregtechMetaSafeBlockBase {
+
+ @Override
+ public String[] getDescription() {
+ return new String[] {mDescription, CORE.GT_Tooltip};
}
+
+ public GregtechMetaSafeBlock(int aID, String aName, String aNameRegional, int aTier) {
+ super(aID, aName, aNameRegional, aTier, 28, "Protecting your items from sticky fingers.");
+ }
- protected void fillStacksIntoFirstSlots() {
- for (int i = 0; i < this.mInventory.length - 1; i++) {
- for (int j = i + 1; j < this.mInventory.length - 1; j++) {
- if (this.mInventory[j] != null && (this.mInventory[i] == null
- || GT_Utility.areStacksEqual(this.mInventory[i], this.mInventory[j]))) {
- GT_Utility.moveStackFromSlotAToSlotB(this.getBaseMetaTileEntity(), this.getBaseMetaTileEntity(), j,
- i, (byte) 64, (byte) 1, (byte) 64, (byte) 1);
- }
- }
- }
- }
+ public GregtechMetaSafeBlock(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription) {
+ super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription);
+ }
- @Override
- public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory,
- final IGregTechTileEntity aBaseMetaTileEntity) {
- return new GUI_SafeBlock(aPlayerInventory, aBaseMetaTileEntity);
- }
+ public GregtechMetaSafeBlock(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) {
+ super(aName, aTier, aInvSlotCount, aDescription, aTextures);
+ }
- @Override
- public String[] getDescription() {
- return new String[] {
- this.mDescription, CORE.GT_Tooltip
- };
- }
+ @Override
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new GregtechMetaSafeBlock(this.mName, this.mTier, this.mInventory.length, this.mDescription, this.mTextures);
+ }
- @Override
+ @Override
public ITexture getOverlayIcon() {
- return new GT_RenderedTexture(Textures.BlockIcons.VOID);
- }
+ return new GT_RenderedTexture(Textures.BlockIcons.VOID);
+ }
- /*
- * @Override protected void moveItems(IGregTechTileEntity
- * aBaseMetaTileEntity, long aTimer) { fillStacksIntoFirstSlots();
- * super.moveItems(aBaseMetaTileEntity, aTimer); fillStacksIntoFirstSlots();
- * }
- */
+ @Override
+ public boolean isValidSlot(int aIndex) {
+ return aIndex < this.mInventory.length - 1;
+ }
- @Override
- public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory,
- final IGregTechTileEntity aBaseMetaTileEntity) {
- return new CONTAINER_SafeBlock(aPlayerInventory, aBaseMetaTileEntity);
- }
+ /*@Override
+ protected void moveItems(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) {
+ fillStacksIntoFirstSlots();
+ super.moveItems(aBaseMetaTileEntity, aTimer);
+ fillStacksIntoFirstSlots();
+ }*/
- @Override
- public boolean isValidSlot(final int aIndex) {
- return aIndex < this.mInventory.length - 1;
- }
+ protected void fillStacksIntoFirstSlots() {
+ for (int i = 0; i < this.mInventory.length - 1; i++) {
+ for (int j = i + 1; j < this.mInventory.length - 1; j++) {
+ if ((this.mInventory[j] != null) && ((this.mInventory[i] == null) || (GT_Utility.areStacksEqual(this.mInventory[i], this.mInventory[j])))) {
+ GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1);
+ }
+ }
+ }
+ }
- @Override
- public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) {
- return new GregtechMetaSafeBlock(this.mName, this.mTier, this.mInventory.length, this.mDescription,
- this.mTextures);
- }
+ @Override
+ public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return new CONTAINER_SafeBlock(aPlayerInventory, aBaseMetaTileEntity);
+ }
+
+ @Override
+ public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return new GUI_SafeBlock(aPlayerInventory, aBaseMetaTileEntity);
+ }
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaSuperConductorNodeBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaSuperConductorNodeBase.java
index 6e195a8e87..15cbf92516 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaSuperConductorNodeBase.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaSuperConductorNodeBase.java
@@ -1,8 +1,6 @@
package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations;
-import java.util.Collection;
-
-import gregtech.api.enums.GT_Values;
+import static gregtech.api.enums.GT_Values.V;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
@@ -11,341 +9,289 @@ import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
import gregtech.api.util.GT_Utility;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.lossless.GregtechMetaTileEntityLosslessBasicTank;
+
+import java.util.Collection;
+
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
public abstract class GregtechMetaSuperConductorNodeBase extends GregtechMetaTileEntityLosslessBasicTank {
- public GregtechMetaSuperConductorNodeBase(final int aID, final String aName, final String aNameRegional,
- final int aTier, final String aDescription, final ITexture... aTextures) {
- super(aID, aName, aNameRegional, aTier, 3, aDescription, aTextures);
- }
-
- public GregtechMetaSuperConductorNodeBase(final String aName, final int aTier, final String aDescription,
- final ITexture[][][] aTextures) {
- super(aName, aTier, 3, aDescription, aTextures);
- }
-
- @Override
- public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide,
- final ItemStack aStack) {
- return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && (this.getFuelValue(aStack) > 0
- || this.getFuelValue(GT_Utility.getFluidForFilledItem(aStack, true)) > 0);
- }
-
- @Override
- public boolean canTankBeEmptied() {
- return this.getBaseMetaTileEntity().isAllowedToWork();
- }
-
- @Override
- public boolean canTankBeFilled() {
- return this.getBaseMetaTileEntity().isAllowedToWork();
- }
-
- public int consumedFluidPerOperation(final FluidStack aLiquid) {
- return 1;
- }
-
- @Override
- public boolean displaysItemStack() {
- return true;
- }
-
- @Override
- public boolean displaysStackSize() {
- return false;
- }
-
- @Override
- public boolean doesEmptyContainers() {
- return this.getBaseMetaTileEntity().isAllowedToWork();
- }
-
- @Override
- public boolean doesFillContainers() {
- return this.getBaseMetaTileEntity().isAllowedToWork();
- }
-
- public ITexture[] getBack(final byte aColor) {
- return new ITexture[] {
- Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]
- };
- }
-
- public ITexture[] getBackActive(final byte aColor) {
- return this.getBack(aColor);
- }
-
- public ITexture[] getBottom(final byte aColor) {
- return new ITexture[] {
- Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]
- };
- }
-
- public ITexture[] getBottomActive(final byte aColor) {
- return this.getBottom(aColor);
- }
-
- @Override
- public int getCapacity() {
- return 16000;
- }
-
- @Override
- public String[] getDescription() {
- return new String[] {
- this.mDescription, "Cooling Efficiency: " + this.getEfficiency() + "%", CORE.GT_Tooltip
- };
- }
-
- public abstract int getEfficiency();
-
- public ItemStack getEmptyContainer(final ItemStack aStack) {
- if (GT_Utility.isStackInvalid(aStack) || this.getRecipes() == null) {
- return null;
- }
- final GT_Recipe tFuel = this.getRecipes().findRecipe(this.getBaseMetaTileEntity(), false, Long.MAX_VALUE, null,
- aStack);
- if (tFuel != null) {
- return GT_Utility.copy(tFuel.getOutput(0));
- }
- return GT_Utility.getContainerItem(aStack, true);
- }
-
- public ITexture[] getFront(final byte aColor) {
- return new ITexture[] {
- Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]
- };
- }
-
- public ITexture[] getFrontActive(final byte aColor) {
- return this.getFront(aColor);
- }
-
- public int getFuelValue(final FluidStack aLiquid) {
- if (aLiquid == null || this.getRecipes() == null) {
- return 0;
- }
- FluidStack tLiquid;
- final Collection<GT_Recipe> tRecipeList = this.getRecipes().mRecipeList;
- if (tRecipeList != null) {
- for (final GT_Recipe tFuel : tRecipeList) {
- if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null) {
- if (aLiquid.isFluidEqual(tLiquid)) {
- return 0;
- }
- }
- }
- }
- // return (int) (((long) tFuel.mSpecialValue * getEfficiency() *
- // consumedFluidPerOperation(tLiquid)) / 100);
- return 0;
- }
-
- public int getFuelValue(final ItemStack aStack) {
- if (GT_Utility.isStackInvalid(aStack) || this.getRecipes() == null) {
- return 0;
- }
- final GT_Recipe tFuel = this.getRecipes().findRecipe(this.getBaseMetaTileEntity(), false, Long.MAX_VALUE, null,
- aStack);
- if (tFuel != null) {
- return 0;
- }
- // return (int) ((tFuel.mSpecialValue * 1000L * getEfficiency()) / 100);
- return 0;
- }
-
- @Override
- public long getMinimumStoredEU() {
- return GT_Values.V[this.mTier] * 16 * this.mInventory.length;
- }
-
- public abstract GT_Recipe_Map getRecipes();
-
- public ITexture[] getSides(final byte aColor) {
- return new ITexture[] {
- Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]
- };
- }
-
- public ITexture[] getSidesActive(final byte aColor) {
- return this.getSides(aColor);
- }
-
- @Override
- public int getTankPressure() {
- return -100;
- }
-
- @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 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;
- }
-
- public ITexture[] getTop(final byte aColor) {
- return new ITexture[] {
- Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]
- };
- }
-
- public ITexture[] getTopActive(final byte aColor) {
- return this.getTop(aColor);
- }
-
- @Override
- public boolean isAccessAllowed(final EntityPlayer aPlayer) {
- return true;
- }
-
- @Override
- public boolean isEnetInput() {
- return true;
- }
-
- @Override
- public boolean isEnetOutput() {
- return true;
- }
-
- @Override
- public boolean isFacingValid(final byte aSide) {
- return aSide > 1;
- }
-
- @Override
- public boolean isFluidInputAllowed(final FluidStack aFluid) {
- return this.getFuelValue(aFluid) > 0;
- }
-
- @Override
- public boolean isOutputFacing(final byte aSide) {
- return true;
- }
-
- @Override
- public boolean isSimpleMachine() {
- return false;
- }
-
- @Override
- public boolean isValidSlot(final int aIndex) {
- return aIndex < 2;
- }
-
- @Override
- public long maxAmperesIn() {
- return 16;
- }
-
- @Override
- public long maxAmperesOut() {
- return 16;
- }
-
- @Override
- public long maxEUInput() {
- return GT_Values.V[this.mTier];
- }
-
- @Override
- public long maxEUOutput() {
- return GT_Values.V[this.mTier];
- }
-
- @Override
- public long maxEUStore() {
- return GT_Values.V[this.mTier] * 64;
- }
-
- @Override
- public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) {
- if (this.getEUVar() == this.maxEUStore() || this.mFluid == null) {
- aBaseMetaTileEntity.disableWorking();
- }
- else {
- aBaseMetaTileEntity.enableWorking();
- }
- if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && aTick % 10 == 0) {
- if (this.mFluid == null) {
- if (aBaseMetaTileEntity.getUniversalEnergyStored() < this.maxEUOutput() + this.getMinimumStoredEU()) {
- this.mInventory[this.getStackDisplaySlot()] = null;
- }
- else {
- if (this.mInventory[this.getStackDisplaySlot()] == null) {
- this.mInventory[this.getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1);
- }
- this.mInventory[this.getStackDisplaySlot()].setStackDisplayName("Generating: "
- + (aBaseMetaTileEntity.getUniversalEnergyStored() - this.getMinimumStoredEU()) + " EU");
- }
- }
- else {
- final int tFuelValue = this.getFuelValue(this.mFluid),
- tConsumed = this.consumedFluidPerOperation(this.mFluid);
- if (tConsumed > 0 && this.mFluid.amount > tConsumed) {
- final long tFluidAmountToUse = Math.min(this.mFluid.amount / tConsumed, this.maxEUOutput() * 20
- + this.getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored());
- if (tFluidAmountToUse > 0 /*
- * && aBaseMetaTileEntity.
- * increaseStoredEnergyUnits(
- * tFluidAmountToUse *
- * tFuelValue, true)
- */) {
- this.mFluid.amount -= tFluidAmountToUse * tConsumed;
- }
- }
- }
- if (this.mInventory[this.getInputSlot()] != null
- && aBaseMetaTileEntity.getUniversalEnergyStored() < this.maxEUOutput() * 20
- + this.getMinimumStoredEU()
- && GT_Utility.getFluidForFilledItem(this.mInventory[this.getInputSlot()], true) == null) {
- final int tFuelValue = this.getFuelValue(this.mInventory[this.getInputSlot()]);
- if (tFuelValue >= 0) {
- final ItemStack tEmptyContainer = this.getEmptyContainer(this.mInventory[this.getInputSlot()]);
- if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), tEmptyContainer)) {
- // aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue,
- // true);
- aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1);
- }
- }
- }
- }
-
- if (aBaseMetaTileEntity.isServerSide()) {
- aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity
- .getUniversalEnergyStored() >= this.maxEUOutput() + this.getMinimumStoredEU());
- }
- }
-
- @Override
- public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) {
- if (aBaseMetaTileEntity.isClientSide()) {
- return true;
- }
- aBaseMetaTileEntity.openGUI(aPlayer);
- return true;
- }
-
+ public GregtechMetaSuperConductorNodeBase(int aID, String aName, String aNameRegional, int aTier, String aDescription, ITexture... aTextures) {
+ super(aID, aName, aNameRegional, aTier, 3, aDescription, aTextures);
+ }
+
+ public GregtechMetaSuperConductorNodeBase(String aName, int aTier, String aDescription, ITexture[][][] aTextures) {
+ super(aName, aTier, 3, aDescription, aTextures);
+ }
+
+ @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];
+ }
+
+ @Override
+ public String[] getDescription() {
+ return new String[]{mDescription, "Cooling Efficiency: " + getEfficiency() + "%", CORE.GT_Tooltip};
+ }
+
+ @Override
+ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {
+ if (aBaseMetaTileEntity.isClientSide()) return true;
+ aBaseMetaTileEntity.openGUI(aPlayer);
+ return true;
+ }
+
+ public ITexture[] getFront(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]};
+ }
+
+ public ITexture[] getBack(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]};
+ }
+
+ public ITexture[] getBottom(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]};
+ }
+
+ public ITexture[] getTop(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]};
+ }
+
+ public ITexture[] getSides(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]};
+ }
+
+ public ITexture[] getFrontActive(byte aColor) {
+ return getFront(aColor);
+ }
+
+ public ITexture[] getBackActive(byte aColor) {
+ return getBack(aColor);
+ }
+
+ public ITexture[] getBottomActive(byte aColor) {
+ return getBottom(aColor);
+ }
+
+ public ITexture[] getTopActive(byte aColor) {
+ return getTop(aColor);
+ }
+
+ public ITexture[] getSidesActive(byte aColor) {
+ return getSides(aColor);
+ }
+
+ @Override
+ public boolean isFacingValid(byte aSide) {
+ return aSide > 1;
+ }
+
+ @Override
+ public boolean isSimpleMachine() {
+ return false;
+ }
+
+ @Override
+ public boolean isValidSlot(int aIndex) {
+ return aIndex < 2;
+ }
+
+ @Override
+ public boolean isEnetInput() {
+ return true;
+ }
+
+ @Override
+ public boolean isEnetOutput() {
+ return true;
+ }
+
+ @Override
+ public boolean isOutputFacing(byte aSide) {
+ return true;
+ }
+
+ @Override
+ public boolean isAccessAllowed(EntityPlayer aPlayer) {
+ return true;
+ }
+
+ @Override
+ public long getMinimumStoredEU() {
+ return V[mTier] * 16 * mInventory.length;
+ }
+
+ @Override
+ public long maxEUStore() {
+ return V[mTier] * 64;
+ }
+
+ @Override
+ public long maxEUInput() {
+ return V[mTier];
+ }
+
+ @Override
+ public long maxEUOutput() {
+ return V[mTier];
+ }
+
+ @Override
+ public long maxAmperesIn() {
+ return 16;
+ }
+
+ @Override
+ public long maxAmperesOut() {
+ return 16;
+ }
+
+ @Override
+ public boolean doesFillContainers() {
+ return getBaseMetaTileEntity().isAllowedToWork();
+ }
+
+ @Override
+ public boolean doesEmptyContainers() {
+ return getBaseMetaTileEntity().isAllowedToWork();
+ }
+
+ @Override
+ public boolean canTankBeFilled() {
+ return getBaseMetaTileEntity().isAllowedToWork();
+ }
+
+ @Override
+ public boolean canTankBeEmptied() {
+ return getBaseMetaTileEntity().isAllowedToWork();
+ }
+
+ @Override
+ public boolean displaysItemStack() {
+ return true;
+ }
+
+ @Override
+ public boolean displaysStackSize() {
+ return false;
+ }
+
+ @Override
+ public boolean isFluidInputAllowed(FluidStack aFluid) {
+ return getFuelValue(aFluid) > 0;
+ }
+
+ @Override
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
+ if (getEUVar() == maxEUStore() || mFluid == null){
+ aBaseMetaTileEntity.disableWorking();
+ }
+ else {
+ aBaseMetaTileEntity.enableWorking();
+ }
+ if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && aTick % 10 == 0) {
+ if (mFluid == null) {
+ if (aBaseMetaTileEntity.getUniversalEnergyStored() < maxEUOutput() + getMinimumStoredEU()) {
+ mInventory[getStackDisplaySlot()] = null;
+ } else {
+ if (mInventory[getStackDisplaySlot()] == null)
+ mInventory[getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1);
+ mInventory[getStackDisplaySlot()].setStackDisplayName("Generating: " + (aBaseMetaTileEntity.getUniversalEnergyStored() - getMinimumStoredEU()) + " EU");
+ }
+ } else {
+ int tFuelValue = getFuelValue(mFluid), tConsumed = consumedFluidPerOperation(mFluid);
+ if (tConsumed > 0 && mFluid.amount > tConsumed) {
+ long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()));
+ if (tFluidAmountToUse > 0 /*&& aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)*/)
+ mFluid.amount -= tFluidAmountToUse * tConsumed;
+ }
+ }
+ if (mInventory[getInputSlot()] != null && aBaseMetaTileEntity.getUniversalEnergyStored() < (maxEUOutput() * 20 + getMinimumStoredEU()) && GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true) == null) {
+ int tFuelValue = getFuelValue(mInventory[getInputSlot()]);
+ if (tFuelValue >= 0) {
+ ItemStack tEmptyContainer = getEmptyContainer(mInventory[getInputSlot()]);
+ if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tEmptyContainer)) {
+ //aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true);
+ aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1);
+ }
+ }
+ }
+ }
+
+ if (aBaseMetaTileEntity.isServerSide())
+ aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.getUniversalEnergyStored() >= maxEUOutput() + getMinimumStoredEU());
+ }
+
+ public abstract GT_Recipe_Map getRecipes();
+
+ public abstract int getEfficiency();
+
+ public int consumedFluidPerOperation(FluidStack aLiquid) {
+ return 1;
+ }
+
+ public int getFuelValue(FluidStack aLiquid) {
+ if (aLiquid == null || getRecipes() == null) return 0;
+ FluidStack tLiquid;
+ Collection<GT_Recipe> tRecipeList = getRecipes().mRecipeList;
+ if (tRecipeList != null) for (GT_Recipe tFuel : tRecipeList)
+ if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null)
+ if (aLiquid.isFluidEqual(tLiquid))
+ return 0;
+ //return (int) (((long) tFuel.mSpecialValue * getEfficiency() * consumedFluidPerOperation(tLiquid)) / 100);
+ return 0;
+ }
+
+ public int getFuelValue(ItemStack aStack) {
+ if (GT_Utility.isStackInvalid(aStack) || getRecipes() == null) return 0;
+ GT_Recipe tFuel = getRecipes().findRecipe(getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack);
+ if (tFuel != null)
+ return 0;
+ //return (int) ((tFuel.mSpecialValue * 1000L * getEfficiency()) / 100);
+ return 0;
+ }
+
+ public ItemStack getEmptyContainer(ItemStack aStack) {
+ if (GT_Utility.isStackInvalid(aStack) || getRecipes() == null) return null;
+ GT_Recipe tFuel = getRecipes().findRecipe(getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack);
+ if (tFuel != null) return GT_Utility.copy(tFuel.getOutput(0));
+ return GT_Utility.getContainerItem(aStack, true);
+ }
+
+ @Override
+ public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && (getFuelValue(aStack) > 0 || getFuelValue(GT_Utility.getFluidForFilledItem(aStack, true)) > 0);
+ }
+
+ @Override
+ public int getCapacity() {
+ return 16000;
+ }
+
+ @Override
+ public int getTankPressure() {
+ return -100;
+ }
+
+
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaPipeEntityBase_Cable.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaPipeEntityBase_Cable.java
index 7bcd29dad0..e9947464be 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaPipeEntityBase_Cable.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaPipeEntityBase_Cable.java
@@ -1,17 +1,17 @@
package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base;
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import cofh.api.energy.IEnergyReceiver;
+import static gregtech.api.enums.GT_Values.VN;
import gregtech.GT_Mod;
import gregtech.api.GregTech_API;
-import gregtech.api.enums.*;
+import gregtech.api.enums.Dyes;
+import gregtech.api.enums.TextureSet;
+import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.metatileentity.IMetaTileEntityCable;
-import gregtech.api.interfaces.tileentity.*;
+import gregtech.api.interfaces.tileentity.IColoredTileEntity;
+import gregtech.api.interfaces.tileentity.IEnergyConnected;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.BaseMetaPipeEntity;
import gregtech.api.metatileentity.MetaPipeEntity;
import gregtech.api.objects.GT_RenderedTexture;
@@ -21,6 +21,11 @@ import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.util.Utils;
import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials;
import ic2.api.energy.tile.IEnergySink;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Arrays;
+
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
@@ -30,301 +35,269 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
+import cofh.api.energy.IEnergyReceiver;
public class GregtechMetaPipeEntityBase_Cable extends MetaPipeEntity implements IMetaTileEntityCable {
- public final float mThickNess;
- public final GT_Materials mMaterial;
- public final long mCableLossPerMeter, mAmperage, mVoltage;
- public final boolean mInsulated, mCanShock;
- public long mTransferredAmperage = 0, mTransferredAmperageLast20 = 0,
- mTransferredVoltageLast20 = 0;
- public long mRestRF;
- public short mOverheat;
- public final int mWireHeatingTicks;
+ public final float mThickNess;
+ public final GT_Materials mMaterial;
+ public final long mCableLossPerMeter, mAmperage, mVoltage;
+ public final boolean mInsulated, mCanShock;
+ public long mTransferredAmperage = 0, mTransferredAmperageLast20 = 0, mTransferredVoltageLast20 = 0;
+ public long mRestRF;
+ public short mOverheat;
+ public final int mWireHeatingTicks;
- public GregtechMetaPipeEntityBase_Cable(final int aID, final String aName, final String aNameRegional,
- final float aThickNess, final GT_Materials aMaterial, final long aCableLossPerMeter, final long aAmperage,
- final long aVoltage, final boolean aInsulated, final boolean aCanShock) {
+ public GregtechMetaPipeEntityBase_Cable(int aID, String aName, String aNameRegional, float aThickNess, GT_Materials aMaterial, long aCableLossPerMeter, long aAmperage, long aVoltage, boolean aInsulated, boolean aCanShock) {
super(aID, aName, aNameRegional, 0);
- this.mThickNess = aThickNess;
- this.mMaterial = aMaterial;
- this.mAmperage = aAmperage;
- this.mVoltage = aVoltage;
- this.mInsulated = aInsulated;
- this.mCanShock = aCanShock;
- this.mCableLossPerMeter = aCableLossPerMeter;
- this.mWireHeatingTicks = this.getGT5Var();
+ mThickNess = aThickNess;
+ mMaterial = aMaterial;
+ mAmperage = aAmperage;
+ mVoltage = aVoltage;
+ mInsulated = aInsulated;
+ mCanShock = aCanShock;
+ mCableLossPerMeter = aCableLossPerMeter;
+ mWireHeatingTicks = getGT5Var();
}
- public GregtechMetaPipeEntityBase_Cable(final String aName, final float aThickNess, final GT_Materials aMaterial,
- final long aCableLossPerMeter, final long aAmperage, final long aVoltage, final boolean aInsulated,
- final boolean aCanShock) {
+ public GregtechMetaPipeEntityBase_Cable(String aName, float aThickNess, GT_Materials aMaterial, long aCableLossPerMeter, long aAmperage, long aVoltage, boolean aInsulated, boolean aCanShock) {
super(aName, 0);
- this.mThickNess = aThickNess;
- this.mMaterial = aMaterial;
- this.mAmperage = aAmperage;
- this.mVoltage = aVoltage;
- this.mInsulated = aInsulated;
- this.mCanShock = aCanShock;
- this.mCableLossPerMeter = aCableLossPerMeter;
- this.mWireHeatingTicks = this.getGT5Var();
- }
-
- @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;
+ mThickNess = aThickNess;
+ mMaterial = aMaterial;
+ mAmperage = aAmperage;
+ mVoltage = aVoltage;
+ mInsulated = aInsulated;
+ mCanShock = aCanShock;
+ mCableLossPerMeter = aCableLossPerMeter;
+ mWireHeatingTicks = getGT5Var();
}
-
- @Override
- public AxisAlignedBB getCollisionBoundingBoxFromPool(final World aWorld, final int aX, final int aY, final int aZ) {
- if (!this.mCanShock) {
- return super.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ);
- }
- return AxisAlignedBB.getBoundingBox(aX + 0.125D, aY + 0.125D, aZ + 0.125D, aX + 0.875D, aY + 0.875D,
- aZ + 0.875D);
- }
-
- @Override
- public String[] getDescription() {
- return new String[] {
- "Max Voltage: " + EnumChatFormatting.GREEN + this.mVoltage + " ("
- + GT_Values.VN[GT_Utility.getTier(this.mVoltage)] + ")" + EnumChatFormatting.GRAY,
- "Max Amperage: " + EnumChatFormatting.YELLOW + this.mAmperage + EnumChatFormatting.GRAY,
- "Loss/Meter/Ampere: " + EnumChatFormatting.RED + this.mCableLossPerMeter + EnumChatFormatting.GRAY
- + " EU-Volt"
- };
- }
-
- private int getGT5Var() {
- final Class<? extends GT_Proxy> clazz = GT_Mod.gregtechproxy.getClass();
- final String lookingForValue = "mWireHeatingTicks";
+
+ private int getGT5Var(){
+ Class<? extends GT_Proxy> clazz = GT_Mod.gregtechproxy.getClass();
+ String lookingForValue = "mWireHeatingTicks";
int temp = 4;
Field field;
- if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) {
- try {
- field = clazz.getClass().getField(lookingForValue);
- final Class<?> clazzType = field.getType();
- if (clazzType.toString().equals("int")) {
- temp = field.getInt(clazz);
- }
- else {
- temp = 4;
- }
+ if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){
+ try {
+ field = clazz.getClass().getField(lookingForValue);
+ Class<?> clazzType = field.getType();
+ if (clazzType.toString().equals("int")){
+ temp = (field.getInt(clazz));
}
- catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
- // Utils.LOG_INFO("FATAL ERROR - REFLECTION FAILED FOR GT CABLES
- // - PLEASE REPORT THIS.");
- Utils.LOG_WARNING("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - PLEASE REPORT THIS.");
- Utils.LOG_ERROR("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - PLEASE REPORT THIS.");
+ else {
temp = 4;
}
+ } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
+ //Utils.LOG_INFO("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - PLEASE REPORT THIS.");
+ Utils.LOG_WARNING("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - PLEASE REPORT THIS.");
+ Utils.LOG_ERROR("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - PLEASE REPORT THIS.");
+ temp = 4;
+ }
}
return temp;
}
@Override
- public int getProgresstime() {
- return (int) this.mTransferredAmperage * 64;
+ public byte getTileEntityBaseType() {
+ return (byte) (mInsulated ? 9 : 8);
}
@Override
- public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide,
- final byte aConnections, final byte aColorIndex, final boolean aConnected, final boolean aRedstone) {
- if (!this.mInsulated) {
- return new ITexture[] {
- new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire],
- this.mMaterial.mRGBa)
- };
- }
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new GregtechMetaPipeEntityBase_Cable(mName, mThickNess, mMaterial, mCableLossPerMeter, mAmperage, mVoltage, mInsulated, mCanShock);
+ }
+
+ @Override
+ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, byte aColorIndex, boolean aConnected, boolean aRedstone) {
+ if (!mInsulated)
+ return new ITexture[]{new GT_RenderedTexture(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa)};
if (aConnected) {
- final float tThickNess = this.getThickNess();
- if (tThickNess < 0.37F) {
- return new ITexture[] {
- new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire],
- this.mMaterial.mRGBa),
- new GT_RenderedTexture(Textures.BlockIcons.INSULATION_TINY,
- Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))
- };
- }
- if (tThickNess < 0.49F) {
- return new ITexture[] {
- new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire],
- this.mMaterial.mRGBa),
- new GT_RenderedTexture(Textures.BlockIcons.INSULATION_SMALL,
- Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))
- };
- }
- if (tThickNess < 0.74F) {
- return new ITexture[] {
- new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire],
- this.mMaterial.mRGBa),
- new GT_RenderedTexture(Textures.BlockIcons.INSULATION_MEDIUM,
- Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))
- };
- }
- if (tThickNess < 0.99F) {
- return new ITexture[] {
- new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire],
- this.mMaterial.mRGBa),
- new GT_RenderedTexture(Textures.BlockIcons.INSULATION_LARGE,
- Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))
- };
- }
- return new ITexture[] {
- new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire],
- this.mMaterial.mRGBa),
- new GT_RenderedTexture(Textures.BlockIcons.INSULATION_HUGE,
- Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))
- };
+ float tThickNess = getThickNess();
+ if (tThickNess < 0.37F)
+ return new ITexture[]{new GT_RenderedTexture(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_TINY, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))};
+ if (tThickNess < 0.49F)
+ return new ITexture[]{new GT_RenderedTexture(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_SMALL, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))};
+ if (tThickNess < 0.74F)
+ return new ITexture[]{new GT_RenderedTexture(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_MEDIUM, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))};
+ if (tThickNess < 0.99F)
+ return new ITexture[]{new GT_RenderedTexture(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_LARGE, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))};
+ return new ITexture[]{new GT_RenderedTexture(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_HUGE, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))};
}
- return new ITexture[] {
- new GT_RenderedTexture(Textures.BlockIcons.INSULATION_FULL,
- Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))
- };
+ return new ITexture[]{new GT_RenderedTexture(Textures.BlockIcons.INSULATION_FULL, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))};
}
@Override
- public float getThickNess() {
- return this.mThickNess;
+ public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity aEntity) {
+ if (mCanShock && (((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections & -128) == 0 && aEntity instanceof EntityLivingBase)
+ GT_Utility.applyElectricityDamage((EntityLivingBase) aEntity, mTransferredVoltageLast20, mTransferredAmperageLast20);
}
@Override
- public byte getTileEntityBaseType() {
- return (byte) (this.mInsulated ? 9 : 8);
+ public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) {
+ if (!mCanShock) return super.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ);
+ return AxisAlignedBB.getBoundingBox(aX + 0.125D, aY + 0.125D, aZ + 0.125D, aX + 0.875D, aY + 0.875D, aZ + 0.875D);
}
@Override
- public long injectEnergyUnits(final byte aSide, final long aVoltage, final long aAmperage) {
- if (!this.getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).letsEnergyIn(aSide,
- this.getBaseMetaTileEntity().getCoverIDAtSide(aSide),
- this.getBaseMetaTileEntity().getCoverDataAtSide(aSide), this.getBaseMetaTileEntity())) {
- return 0;
- }
- return this.transferElectricity(aSide, aVoltage, aAmperage,
- new ArrayList<TileEntity>(Arrays.asList((TileEntity) this.getBaseMetaTileEntity())));
+ public boolean isSimpleMachine() {
+ return true;
}
@Override
- public boolean isFacingValid(final byte aFacing) {
+ public boolean isFacingValid(byte aFacing) {
return false;
}
@Override
- public boolean isSimpleMachine() {
+ public boolean isValidSlot(int aIndex) {
return true;
}
@Override
- public boolean isValidSlot(final int aIndex) {
- return true;
+ public final boolean renderInside(byte aSide) {
+ return false;
}
@Override
- public void loadNBTData(final NBTTagCompound aNBT) {
- //
+ public int getProgresstime() {
+ return (int) mTransferredAmperage * 64;
}
@Override
public int maxProgresstime() {
- return (int) this.mAmperage * 64;
+ return (int) mAmperage * 64;
}
@Override
- public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) {
- return new GregtechMetaPipeEntityBase_Cable(this.mName, this.mThickNess, this.mMaterial,
- this.mCableLossPerMeter, this.mAmperage, this.mVoltage, this.mInsulated, this.mCanShock);
+ public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) {
+ if (!getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).letsEnergyIn(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getCoverDataAtSide(aSide), getBaseMetaTileEntity()))
+ return 0;
+ return transferElectricity(aSide, aVoltage, aAmperage, new ArrayList<TileEntity>(Arrays.asList((TileEntity) getBaseMetaTileEntity())));
}
@Override
- public void onEntityCollidedWithBlock(final World aWorld, final int aX, final int aY, final int aZ,
- final Entity aEntity) {
- if (this.mCanShock && (((BaseMetaPipeEntity) this.getBaseMetaTileEntity()).mConnections & -128) == 0
- && aEntity instanceof EntityLivingBase) {
- GT_Utility.applyElectricityDamage((EntityLivingBase) aEntity, this.mTransferredVoltageLast20,
- this.mTransferredAmperageLast20);
+ public long transferElectricity(byte aSide, long aVoltage, long aAmperage, ArrayList<TileEntity> aAlreadyPassedTileEntityList) {
+ long rUsedAmperes = 0;
+ aVoltage -= mCableLossPerMeter;
+ if (aVoltage > 0) for (byte i = 0; i < 6 && aAmperage > rUsedAmperes; i++)
+ if (i != aSide && (mConnections & (1 << i)) != 0 && getBaseMetaTileEntity().getCoverBehaviorAtSide(i).letsEnergyOut(i, getBaseMetaTileEntity().getCoverIDAtSide(i), getBaseMetaTileEntity().getCoverDataAtSide(i), getBaseMetaTileEntity())) {
+ TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityAtSide(i);
+ if (!aAlreadyPassedTileEntityList.contains(tTileEntity)) {
+ aAlreadyPassedTileEntityList.add(tTileEntity);
+ if (tTileEntity instanceof IEnergyConnected) {
+ if (getBaseMetaTileEntity().getColorization() >= 0) {
+ byte tColor = ((IEnergyConnected) tTileEntity).getColorization();
+ if (tColor >= 0 && tColor != getBaseMetaTileEntity().getColorization()) continue;
+ }
+ if (tTileEntity instanceof IGregTechTileEntity && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() instanceof IMetaTileEntityCable && ((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(GT_Utility.getOppositeSide(i)).letsEnergyIn(GT_Utility.getOppositeSide(i), ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(GT_Utility.getOppositeSide(i)), ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(GT_Utility.getOppositeSide(i)), ((IGregTechTileEntity) tTileEntity))) {
+ if (((IGregTechTileEntity) tTileEntity).getTimer() > 50)
+ rUsedAmperes += ((IMetaTileEntityCable) ((IGregTechTileEntity) tTileEntity).getMetaTileEntity()).transferElectricity(GT_Utility.getOppositeSide(i), aVoltage, aAmperage - rUsedAmperes, aAlreadyPassedTileEntityList);
+ } else {
+ rUsedAmperes += ((IEnergyConnected) tTileEntity).injectEnergyUnits(GT_Utility.getOppositeSide(i), aVoltage, aAmperage - rUsedAmperes);
+ }
+ // } else if (tTileEntity instanceof IEnergySink) {
+ // ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite();
+ // if (((IEnergySink)tTileEntity).acceptsEnergyFrom((TileEntity)getBaseMetaTileEntity(), tDirection)) {
+ // if (((IEnergySink)tTileEntity).demandedEnergyUnits() > 0 && ((IEnergySink)tTileEntity).injectEnergyUnits(tDirection, aVoltage) < aVoltage) rUsedAmperes++;
+ // }
+ } else if (tTileEntity instanceof IEnergySink) {
+ ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite();
+ if (((IEnergySink) tTileEntity).acceptsEnergyFrom((TileEntity) getBaseMetaTileEntity(), tDirection)) {
+ if (((IEnergySink) tTileEntity).getDemandedEnergy() > 0 && ((IEnergySink) tTileEntity).injectEnergy(tDirection, aVoltage, aVoltage) < aVoltage)
+ rUsedAmperes++;
+ }
+ } else if (GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver) {
+ ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite();
+ int rfOut = (int) (aVoltage * GregTech_API.mEUtoRF / 100);
+ if (((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, true) == rfOut) {
+ ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, false);
+ rUsedAmperes++;
+ } else if (((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, true) > 0) {
+ if (mRestRF == 0) {
+ int RFtrans = ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, (int) rfOut, false);
+ rUsedAmperes++;
+ mRestRF = rfOut - RFtrans;
+ } else {
+ int RFtrans = ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, (int) mRestRF, false);
+ mRestRF = mRestRF - RFtrans;
+ }
+ }
+ if (GregTech_API.mRFExplosions && ((IEnergyReceiver) tTileEntity).getMaxEnergyStored(tDirection) < rfOut * 600) {
+ if (rfOut > 32 * GregTech_API.mEUtoRF / 100) this.doExplosion(rfOut);
+ }
+ }
+ }
+ }
+
+
+ mTransferredAmperage += rUsedAmperes;
+ mTransferredVoltageLast20 = Math.max(mTransferredVoltageLast20, aVoltage);
+ mTransferredAmperageLast20 = Math.max(mTransferredAmperageLast20, mTransferredAmperage);
+
+
+ if (aVoltage > mVoltage || mTransferredAmperage > mAmperage){
+ //GT 5.09
+ if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) {
+ if(mOverheat>mWireHeatingTicks * 100){
+ getBaseMetaTileEntity().setToFire();
+ }
+ else{
+ mOverheat +=100;
+ }
+ return aAmperage;
+ }
+ //GT 5.08
+ else {
+ getBaseMetaTileEntity().setToFire();
+ return aAmperage;
+ }
}
+
+ return rUsedAmperes;
}
@Override
- public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) {
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
if (aBaseMetaTileEntity.isServerSide()) {
- this.mTransferredAmperage = 0;
- if (this.mOverheat > 0) {
- this.mOverheat--;
- }
+ mTransferredAmperage = 0;
+ if(mOverheat>0)mOverheat--;
if (aTick % 20 == 0) {
- this.mTransferredVoltageLast20 = 0;
- this.mTransferredAmperageLast20 = 0;
- this.mConnections = 0;
+ mTransferredVoltageLast20 = 0;
+ mTransferredAmperageLast20 = 0;
+ mConnections = 0;
for (byte i = 0, j = 0; i < 6; i++) {
j = GT_Utility.getOppositeSide(i);
- if (aBaseMetaTileEntity.getCoverBehaviorAtSide(i).alwaysLookConnected(i,
- aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i),
- aBaseMetaTileEntity)
- || aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsEnergyIn(i,
- aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i),
- aBaseMetaTileEntity)
- || aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsEnergyOut(i,
- aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i),
- aBaseMetaTileEntity)) {
- final TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(i);
+ if (aBaseMetaTileEntity.getCoverBehaviorAtSide(i).alwaysLookConnected(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), aBaseMetaTileEntity) || aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsEnergyIn(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), aBaseMetaTileEntity) || aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsEnergyOut(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), aBaseMetaTileEntity)) {
+ TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(i);
if (tTileEntity instanceof IColoredTileEntity) {
if (aBaseMetaTileEntity.getColorization() >= 0) {
- final byte tColor = ((IColoredTileEntity) tTileEntity).getColorization();
- if (tColor >= 0 && tColor != aBaseMetaTileEntity.getColorization()) {
- continue;
- }
+ byte tColor = ((IColoredTileEntity) tTileEntity).getColorization();
+ if (tColor >= 0 && tColor != aBaseMetaTileEntity.getColorization()) continue;
}
}
- if (tTileEntity instanceof IEnergyConnected
- && (((IEnergyConnected) tTileEntity).inputEnergyFrom(j)
- || ((IEnergyConnected) tTileEntity).outputsEnergyTo(j))) {
- this.mConnections |= 1 << i;
+ if (tTileEntity instanceof IEnergyConnected && (((IEnergyConnected) tTileEntity).inputEnergyFrom(j) || ((IEnergyConnected) tTileEntity).outputsEnergyTo(j))) {
+ mConnections |= (1 << i);
continue;
}
- if (tTileEntity instanceof IGregTechTileEntity && ((IGregTechTileEntity) tTileEntity)
- .getMetaTileEntity() instanceof IMetaTileEntityCable) {
- if (((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(j).alwaysLookConnected(j,
- ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(j),
- ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(j),
- (IGregTechTileEntity) tTileEntity)
- || ((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(j).letsEnergyIn(j,
- ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(j),
- ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(j),
- (IGregTechTileEntity) tTileEntity)
- || ((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(j).letsEnergyOut(j,
- ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(j),
- ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(j),
- (IGregTechTileEntity) tTileEntity)) {
- this.mConnections |= 1 << i;
+ if (tTileEntity instanceof IGregTechTileEntity && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() instanceof IMetaTileEntityCable) {
+ if (((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(j).alwaysLookConnected(j, ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(j), ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(j), ((IGregTechTileEntity) tTileEntity)) || ((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(j).letsEnergyIn(j, ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(j), ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(j), ((IGregTechTileEntity) tTileEntity)) || ((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(j).letsEnergyOut(j, ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(j), ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(j), ((IGregTechTileEntity) tTileEntity))) {
+ mConnections |= (1 << i);
continue;
}
}
- if (tTileEntity instanceof IEnergySink && ((IEnergySink) tTileEntity).acceptsEnergyFrom(
- (TileEntity) aBaseMetaTileEntity, ForgeDirection.getOrientation(j))) {
- this.mConnections |= 1 << i;
+ if (tTileEntity instanceof IEnergySink && ((IEnergySink) tTileEntity).acceptsEnergyFrom((TileEntity) aBaseMetaTileEntity, ForgeDirection.getOrientation(j))) {
+ mConnections |= (1 << i);
continue;
}
- if (GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver
- && ((IEnergyReceiver) tTileEntity).canConnectEnergy(ForgeDirection.getOrientation(j))) {
- this.mConnections |= 1 << i;
+ if (GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver && ((IEnergyReceiver) tTileEntity).canConnectEnergy(ForgeDirection.getOrientation(j))) {
+ mConnections |= (1 << i);
continue;
}
/*
- * if (tTileEntity instanceof IEnergyEmitter &&
- * ((IEnergyEmitter)tTileEntity).emitsEnergyTo((
- * TileEntity)aBaseMetaTileEntity,
- * ForgeDirection.getOrientation(j))) { mConnections |=
- * (1<<i); continue; }
- */
+ if (tTileEntity instanceof IEnergyEmitter && ((IEnergyEmitter)tTileEntity).emitsEnergyTo((TileEntity)aBaseMetaTileEntity, ForgeDirection.getOrientation(j))) {
+ mConnections |= (1<<i);
+ continue;
+ }*/
}
}
}
@@ -332,134 +305,36 @@ public class GregtechMetaPipeEntityBase_Cable extends MetaPipeEntity implements
}
@Override
- public final boolean renderInside(final byte aSide) {
+ public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
return false;
}
@Override
- public void saveNBTData(final NBTTagCompound aNBT) {
- //
+ public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return false;
}
@Override
- public long transferElectricity(final byte aSide, long aVoltage, final long aAmperage,
- final ArrayList<TileEntity> aAlreadyPassedTileEntityList) {
- long rUsedAmperes = 0;
- aVoltage -= this.mCableLossPerMeter;
- if (aVoltage > 0) {
- for (byte i = 0; i < 6 && aAmperage > rUsedAmperes; i++) {
- if (i != aSide && (this.mConnections & 1 << i) != 0
- && this.getBaseMetaTileEntity().getCoverBehaviorAtSide(i).letsEnergyOut(i,
- this.getBaseMetaTileEntity().getCoverIDAtSide(i),
- this.getBaseMetaTileEntity().getCoverDataAtSide(i), this.getBaseMetaTileEntity())) {
- final TileEntity tTileEntity = this.getBaseMetaTileEntity().getTileEntityAtSide(i);
- if (!aAlreadyPassedTileEntityList.contains(tTileEntity)) {
- aAlreadyPassedTileEntityList.add(tTileEntity);
- if (tTileEntity instanceof IEnergyConnected) {
- if (this.getBaseMetaTileEntity().getColorization() >= 0) {
- final byte tColor = ((IEnergyConnected) tTileEntity).getColorization();
- if (tColor >= 0 && tColor != this.getBaseMetaTileEntity().getColorization()) {
- continue;
- }
- }
- if (tTileEntity instanceof IGregTechTileEntity
- && ((IGregTechTileEntity) tTileEntity)
- .getMetaTileEntity() instanceof IMetaTileEntityCable
- && ((IGregTechTileEntity) tTileEntity)
- .getCoverBehaviorAtSide(GT_Utility.getOppositeSide(i))
- .letsEnergyIn(GT_Utility.getOppositeSide(i),
- ((IGregTechTileEntity) tTileEntity)
- .getCoverIDAtSide(GT_Utility.getOppositeSide(i)),
- ((IGregTechTileEntity) tTileEntity)
- .getCoverDataAtSide(GT_Utility.getOppositeSide(i)),
- (IGregTechTileEntity) tTileEntity)) {
- if (((IGregTechTileEntity) tTileEntity).getTimer() > 50) {
- rUsedAmperes += ((IMetaTileEntityCable) ((IGregTechTileEntity) tTileEntity)
- .getMetaTileEntity()).transferElectricity(GT_Utility.getOppositeSide(i),
- aVoltage, aAmperage - rUsedAmperes, aAlreadyPassedTileEntityList);
- }
- }
- else {
- rUsedAmperes += ((IEnergyConnected) tTileEntity).injectEnergyUnits(
- GT_Utility.getOppositeSide(i), aVoltage, aAmperage - rUsedAmperes);
- }
- // } else if (tTileEntity instanceof IEnergySink) {
- // ForgeDirection tDirection =
- // ForgeDirection.getOrientation(i).getOpposite();
- // if
- // (((IEnergySink)tTileEntity).acceptsEnergyFrom((TileEntity)getBaseMetaTileEntity(),
- // tDirection)) {
- // if
- // (((IEnergySink)tTileEntity).demandedEnergyUnits()
- // > 0 &&
- // ((IEnergySink)tTileEntity).injectEnergyUnits(tDirection,
- // aVoltage) < aVoltage) rUsedAmperes++;
- // }
- }
- else if (tTileEntity instanceof IEnergySink) {
- final ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite();
- if (((IEnergySink) tTileEntity).acceptsEnergyFrom((TileEntity) this.getBaseMetaTileEntity(),
- tDirection)) {
- if (((IEnergySink) tTileEntity).getDemandedEnergy() > 0 && ((IEnergySink) tTileEntity)
- .injectEnergy(tDirection, aVoltage, aVoltage) < aVoltage) {
- rUsedAmperes++;
- }
- }
- }
- else if (GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver) {
- final ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite();
- final int rfOut = (int) (aVoltage * GregTech_API.mEUtoRF / 100);
- if (((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, true) == rfOut) {
- ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, false);
- rUsedAmperes++;
- }
- else if (((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, true) > 0) {
- if (this.mRestRF == 0) {
- final int RFtrans = ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut,
- false);
- rUsedAmperes++;
- this.mRestRF = rfOut - RFtrans;
- }
- else {
- final int RFtrans = ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection,
- (int) this.mRestRF, false);
- this.mRestRF = this.mRestRF - RFtrans;
- }
- }
- if (GregTech_API.mRFExplosions
- && ((IEnergyReceiver) tTileEntity).getMaxEnergyStored(tDirection) < rfOut * 600) {
- if (rfOut > 32 * GregTech_API.mEUtoRF / 100) {
- this.doExplosion(rfOut);
- }
- }
- }
- }
- }
- }
- }
+ public String[] getDescription() {
+ return new String[]{
+ "Max Voltage: " + EnumChatFormatting.GREEN + mVoltage + " (" + VN[GT_Utility.getTier(mVoltage)] + ")" + EnumChatFormatting.GRAY,
+ "Max Amperage: " + EnumChatFormatting.YELLOW + mAmperage + EnumChatFormatting.GRAY,
+ "Loss/Meter/Ampere: " + EnumChatFormatting.RED + mCableLossPerMeter + EnumChatFormatting.GRAY + " EU-Volt"
+ };
+ }
- this.mTransferredAmperage += rUsedAmperes;
- this.mTransferredVoltageLast20 = Math.max(this.mTransferredVoltageLast20, aVoltage);
- this.mTransferredAmperageLast20 = Math.max(this.mTransferredAmperageLast20, this.mTransferredAmperage);
+ @Override
+ public float getThickNess() {
+ return mThickNess;
+ }
- if (aVoltage > this.mVoltage || this.mTransferredAmperage > this.mAmperage) {
- // GT 5.09
- if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) {
- if (this.mOverheat > this.mWireHeatingTicks * 100) {
- this.getBaseMetaTileEntity().setToFire();
- }
- else {
- this.mOverheat += 100;
- }
- return aAmperage;
- }
- // GT 5.08
- else {
- this.getBaseMetaTileEntity().setToFire();
- return aAmperage;
- }
- }
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ //
+ }
- return rUsedAmperes;
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ //
}
} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaTileEntity.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaTileEntity.java
index 45c298d769..cd91d05970 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaTileEntity.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaTileEntity.java
@@ -1,6 +1,6 @@
package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base;
-import gregtech.api.enums.GT_Values;
+import static gregtech.api.enums.GT_Values.GT;
import gregtech.api.interfaces.ITexture;
import gregtech.api.metatileentity.MetaTileEntity;
import gtPlusPlus.core.lib.CORE;
@@ -9,70 +9,59 @@ public abstract class GregtechMetaTileEntity extends MetaTileEntity {
/**
* Value between [0 - 9] to describe the Tier of this Machine.
*/
- public final byte mTier;
-
+ public final byte mTier;
+
/**
* A simple Description.
*/
- public final String mDescription;
-
+ public final String mDescription;
+
/**
* Contains all Textures used by this Block.
*/
- public final ITexture[][][] mTextures;
-
- public GregtechMetaTileEntity(final int aID, final String aName, final String aNameRegional, final int aTier,
- final int aInvSlotCount, final String aDescription, final ITexture... aTextures) {
+ public final ITexture[][][] mTextures;
+
+ public GregtechMetaTileEntity(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) {
super(aID, aName, aNameRegional, aInvSlotCount);
- this.mTier = (byte) Math.max(0, Math.min(aTier, 9));
- this.mDescription = aDescription;
-
+ mTier = (byte)Math.max(0, Math.min(aTier, 9));
+ mDescription = aDescription;
+
// must always be the last call!
- if (GT_Values.GT.isClientSide()) {
- this.mTextures = this.getTextureSet(aTextures);
- }
- else {
- this.mTextures = null;
- }
+ if (GT.isClientSide()) mTextures = getTextureSet(aTextures); else mTextures = null;
}
-
- public GregtechMetaTileEntity(final String aName, final int aTier, final int aInvSlotCount,
- final String aDescription, final ITexture[][][] aTextures) {
+
+ public GregtechMetaTileEntity(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) {
super(aName, aInvSlotCount);
- this.mTier = (byte) aTier;
- this.mDescription = aDescription;
- this.mTextures = aTextures;
-
+ mTier = (byte)aTier;
+ mDescription = aDescription;
+ mTextures = aTextures;
+
}
-
+
@Override
- public String[] getDescription() {
- return new String[] {
- this.mDescription, CORE.GT_Tooltip
- };
+ public byte getTileEntityBaseType() {
+ return (byte)(Math.min(3, mTier<=0?0:1+((mTier-1) / 4)));
}
-
- @Override
+
+ @Override
public long getInputTier() {
- return this.mTier;
- }
-
- @Override
+ return mTier;
+ }
+
+ @Override
public long getOutputTier() {
- return this.mTier;
+ return mTier;
+ }
+
+ @Override
+ public String[] getDescription() {
+ return new String[] {mDescription, CORE.GT_Tooltip};
}
-
+
/**
- * Used Client Side to get a Texture Set for this Block. Called after
- * setting the Tier and the Description so that those two are accessible.
- *
- * @param aTextures
- * is the optional Array you can give to the Constructor.
+ * Used Client Side to get a Texture Set for this Block.
+ * Called after setting the Tier and the Description so that those two are accessible.
+ * @param aTextures is the optional Array you can give to the Constructor.
*/
public abstract ITexture[][][] getTextureSet(ITexture[] aTextures);
-
- @Override
- public byte getTileEntityBaseType() {
- return (byte) Math.min(3, this.mTier <= 0 ? 0 : 1 + (this.mTier - 1) / 4);
- }
} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java
index 7a2397cf02..a6121f783d 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java
@@ -1,22 +1,37 @@
package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base;
-import java.util.ArrayList;
-
+import static gregtech.api.enums.GT_Values.V;
import gregtech.GT_Mod;
import gregtech.api.GregTech_API;
-import gregtech.api.enums.*;
+import gregtech.api.enums.ConfigCategories;
+import gregtech.api.enums.Materials;
+import gregtech.api.enums.OrePrefixes;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.items.GT_MetaGenerated_Tool;
import gregtech.api.metatileentity.MetaTileEntity;
-import gregtech.api.metatileentity.implementations.*;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus;
import gregtech.api.objects.GT_ItemStack;
-import gregtech.api.util.*;
+import gregtech.api.util.GT_ModHandler;
+import gregtech.api.util.GT_OreDictUnificator;
+import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
+import gregtech.api.util.GT_Utility;
import gregtech.common.items.GT_MetaGenerated_Tool_01;
import gtPlusPlus.core.util.array.Pair;
import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_MultiMachine;
import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine;
+
+import java.util.ArrayList;
+
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
@@ -25,1022 +40,832 @@ import net.minecraftforge.fluids.FluidStack;
public abstract class GregtechMeta_MultiBlockBase extends MetaTileEntity {
- public static boolean disableMaintenance;
- public static boolean isValidMetaTileEntity(final MetaTileEntity aMetaTileEntity) {
- return aMetaTileEntity.getBaseMetaTileEntity() != null
- && aMetaTileEntity.getBaseMetaTileEntity().getMetaTileEntity() == aMetaTileEntity
- && !aMetaTileEntity.getBaseMetaTileEntity().isDead();
- }
- public boolean mMachine = false, mWrench = false,
- mScrewdriver = false, mSoftHammer = false, mHardHammer = false, mSolderingTool = true, mCrowbar = false,
- mRunningOnLoad = false;
- public int mPollution = 0, mProgresstime = 0,
- mMaxProgresstime = 0, mEUt = 0, mEfficiencyIncrease = 0, mUpdate = 0, mStartUpCheck = 100, mRuntime = 0,
- mEfficiency = 0;
- public ItemStack[] mOutputItems = null;
- public FluidStack[] mOutputFluids = null;
- public ArrayList<GT_MetaTileEntity_Hatch_Input> mInputHatches = new ArrayList<GT_MetaTileEntity_Hatch_Input>();
- public ArrayList<GT_MetaTileEntity_Hatch_Output> mOutputHatches = new ArrayList<GT_MetaTileEntity_Hatch_Output>();
- public ArrayList<GT_MetaTileEntity_Hatch_InputBus> mInputBusses = new ArrayList<GT_MetaTileEntity_Hatch_InputBus>();
- public ArrayList<GT_MetaTileEntity_Hatch_OutputBus> mOutputBusses = new ArrayList<GT_MetaTileEntity_Hatch_OutputBus>();
- public ArrayList<GT_MetaTileEntity_Hatch_Dynamo> mDynamoHatches = new ArrayList<GT_MetaTileEntity_Hatch_Dynamo>();
- public ArrayList<GT_MetaTileEntity_Hatch_Muffler> mMufflerHatches = new ArrayList<GT_MetaTileEntity_Hatch_Muffler>();
- public ArrayList<GT_MetaTileEntity_Hatch_Energy> mEnergyHatches = new ArrayList<GT_MetaTileEntity_Hatch_Energy>();
-
- public ArrayList<GT_MetaTileEntity_Hatch_Maintenance> mMaintenanceHatches = new ArrayList<GT_MetaTileEntity_Hatch_Maintenance>();
-
- public GregtechMeta_MultiBlockBase(final int aID, final String aName, final String aNameRegional) {
- super(aID, aName, aNameRegional, 2);
- GregtechMeta_MultiBlockBase.disableMaintenance = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig,
- "MultiBlockMachines.disableMaintenance", false);
- }
-
- public GregtechMeta_MultiBlockBase(final String aName) {
- super(aName, 2);
- GregtechMeta_MultiBlockBase.disableMaintenance = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig,
- "MultiBlockMachines.disableMaintenance", false);
- }
-
- /**
- * Called whenever the Machine aborted a Process, useful for Sound Effects
- */
- public void abortProcess() {
- //
- }
-
- public boolean addDynamoToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) {
- if (aTileEntity == null) {
- return false;
- }
- final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
- if (aMetaTileEntity == null) {
- return false;
- }
- if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) {
- ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex;
- return this.mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity);
- }
- return false;
- }
-
- public boolean addEnergyInputToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) {
- if (aTileEntity == null) {
- return false;
- }
- final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
- if (aMetaTileEntity == null) {
- return false;
- }
- if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) {
- ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex;
- return this.mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity);
- }
- return false;
- }
-
- public boolean addEnergyOutput(final long aEU) {
- if (aEU <= 0) {
- return true;
- }
- for (final GT_MetaTileEntity_Hatch_Dynamo tHatch : this.mDynamoHatches) {
- if (GregtechMeta_MultiBlockBase.isValidMetaTileEntity(tHatch)) {
- if (tHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(aEU, false)) {
- return true;
- }
- }
- }
- return false;
- }
-
- private void addFluidOutputs(final FluidStack[] mOutputFluids2) {
- for (int i = 0; i < mOutputFluids2.length; i++) {
- if (this.mOutputHatches.size() > i && this.mOutputHatches.get(i) != null && mOutputFluids2[i] != null
- && GregtechMeta_MultiBlockBase.isValidMetaTileEntity(this.mOutputHatches.get(i))) {
- this.mOutputHatches.get(i).fill(mOutputFluids2[i], true);
- }
- }
-
- }
-
- public boolean addInputToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) {
- if (aTileEntity == null) {
- return false;
- }
- final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
- if (aMetaTileEntity == null) {
- return false;
- }
- if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) {
- ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex;
- ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = this.getRecipeMap();
- return this.mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity);
- }
- if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) {
- ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex;
- ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mRecipeMap = this.getRecipeMap();
- return this.mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity);
- }
- return false;
- }
-
- public boolean addMaintenanceToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) {
- if (aTileEntity == null) {
- return false;
- }
- final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
- if (aMetaTileEntity == null) {
- return false;
- }
- if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) {
- ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex;
- return this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity);
- }
- return false;
- }
-
- public boolean addMufflerToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) {
- if (aTileEntity == null) {
- return false;
- }
- final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
- if (aMetaTileEntity == null) {
- return false;
- }
- if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) {
- ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex;
- return this.mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity);
- }
- return false;
- }
-
- public boolean addOutput(final FluidStack aLiquid) {
- if (aLiquid == null) {
- return false;
- }
- final FluidStack tLiquid = aLiquid.copy();
- for (final GT_MetaTileEntity_Hatch_Output tHatch : this.mOutputHatches) {
- if (GregtechMeta_MultiBlockBase.isValidMetaTileEntity(tHatch) && GT_ModHandler.isSteam(aLiquid)
- ? tHatch.outputsSteam() : tHatch.outputsLiquids()) {
- final int tAmount = tHatch.fill(tLiquid, false);
- if (tAmount >= tLiquid.amount) {
- return tHatch.fill(tLiquid, true) >= tLiquid.amount;
- }
- else if (tAmount > 0) {
- tLiquid.amount = tLiquid.amount - tHatch.fill(tLiquid, true);
- }
- }
- }
- return false;
- }
-
- public boolean addOutput(ItemStack aStack) {
- if (GT_Utility.isStackInvalid(aStack)) {
- return false;
- }
- aStack = GT_Utility.copy(aStack);
- // FluidStack aLiquid = GT_Utility.getFluidForFilledItem(aStack, true);
- // if (aLiquid == null) {
- for (final GT_MetaTileEntity_Hatch_OutputBus tHatch : this.mOutputBusses) {
- if (GregtechMeta_MultiBlockBase.isValidMetaTileEntity(tHatch)) {
- for (int i = tHatch.getSizeInventory() - 1; i >= 0; i--) {
- if (tHatch.getBaseMetaTileEntity().addStackToSlot(i, aStack)) {
- return true;
- }
- }
- }
- }
- for (final GT_MetaTileEntity_Hatch_Output tHatch : this.mOutputHatches) {
- if (GregtechMeta_MultiBlockBase.isValidMetaTileEntity(tHatch) && tHatch.outputsItems()) {
- if (tHatch.getBaseMetaTileEntity().addStackToSlot(1, aStack)) {
- return true;
- }
- }
- }
- // }else {
- // for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) {
- // if (isValidMetaTileEntity(tHatch) &&
- // GT_ModHandler.isSteam(aLiquid)?tHatch.outputsSteam():tHatch.outputsLiquids())
- // {
- // int tAmount = tHatch.fill(aLiquid, false);
- // if (tAmount >= aLiquid.amount) {
- // return tHatch.fill(aLiquid, true) >= aLiquid.amount;
- // }
- // }
- // }
- // }
- return false;
- }
-
- public boolean addOutputToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) {
- if (aTileEntity == null) {
- return false;
- }
- final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
- if (aMetaTileEntity == null) {
- return false;
- }
- if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) {
- ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex;
- return this.mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity);
- }
- if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) {
- ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex;
- return this.mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity);
- }
- return false;
- }
-
- public boolean addToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) {
- if (aTileEntity == null) {
- return false;
- }
- final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
- if (aMetaTileEntity == null) {
- return false;
- }
- if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) {
- ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex;
- }
- if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) {
- return this.mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity);
- }
- if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) {
- return this.mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity);
- }
- if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) {
- return this.mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity);
- }
- if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) {
- return this.mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity);
- }
- if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) {
- return this.mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity);
- }
- if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) {
- return this.mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity);
- }
- if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) {
- return this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity);
- }
- if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) {
- return this.mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity);
- }
- return false;
- }
-
- @Override
- public boolean allowCoverOnSide(final byte aSide, final GT_ItemStack aCoverID) {
- return aSide != this.getBaseMetaTileEntity().getFrontFacing();
- }
-
- @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;
- }
-
- /**
- * Checks the Machine. You have to assign the MetaTileEntities for the
- * Hatches here.
- */
- public abstract boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack);
-
- /**
- * Checks the Recipe
- */
- public abstract boolean checkRecipe(ItemStack aStack);
-
- public boolean depleteInput(final FluidStack aLiquid) {
- if (aLiquid == null) {
- return false;
- }
- for (final GT_MetaTileEntity_Hatch_Input tHatch : this.mInputHatches) {
- tHatch.mRecipeMap = this.getRecipeMap();
- if (GregtechMeta_MultiBlockBase.isValidMetaTileEntity(tHatch)) {
- FluidStack tLiquid = tHatch.getFluid();
- if (tLiquid != null && tLiquid.isFluidEqual(aLiquid)) {
- tLiquid = tHatch.drain(aLiquid.amount, false);
- if (tLiquid != null && tLiquid.amount >= aLiquid.amount) {
- tLiquid = tHatch.drain(aLiquid.amount, true);
- return tLiquid != null && tLiquid.amount >= aLiquid.amount;
- }
- }
- }
- }
- return false;
- }
-
- /**
- * Checks if this is a Correct Machine Part for this kind of Machine
- * (Turbine Rotor for example)
- */
- // public abstract boolean isCorrectMachinePart(ItemStack aStack);
-
- public boolean depleteInput(final ItemStack aStack) {
- if (GT_Utility.isStackInvalid(aStack)) {
- return false;
- }
- final FluidStack aLiquid = GT_Utility.getFluidForFilledItem(aStack, true);
- if (aLiquid != null) {
- return this.depleteInput(aLiquid);
- }
- for (final GT_MetaTileEntity_Hatch_Input tHatch : this.mInputHatches) {
- tHatch.mRecipeMap = this.getRecipeMap();
- if (GregtechMeta_MultiBlockBase.isValidMetaTileEntity(tHatch)) {
- if (GT_Utility.areStacksEqual(aStack, tHatch.getBaseMetaTileEntity().getStackInSlot(0))) {
- if (tHatch.getBaseMetaTileEntity().getStackInSlot(0).stackSize >= aStack.stackSize) {
- tHatch.getBaseMetaTileEntity().decrStackSize(0, aStack.stackSize);
- return true;
- }
- }
- }
- }
- for (final GT_MetaTileEntity_Hatch_InputBus tHatch : this.mInputBusses) {
- tHatch.mRecipeMap = this.getRecipeMap();
- if (GregtechMeta_MultiBlockBase.isValidMetaTileEntity(tHatch)) {
- for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) {
- if (GT_Utility.areStacksEqual(aStack, tHatch.getBaseMetaTileEntity().getStackInSlot(i))) {
- if (tHatch.getBaseMetaTileEntity().getStackInSlot(0).stackSize >= aStack.stackSize) {
- tHatch.getBaseMetaTileEntity().decrStackSize(0, aStack.stackSize);
- return true;
- }
- }
- }
- }
- }
- return false;
- }
-
- public boolean doRandomMaintenanceDamage() {
- if (this.getRepairStatus() == 0) {
- this.stopMachine();
- return false;
- }
- if (this.mRuntime++ > 1000) {
- this.mRuntime = 0;
- if (this.getBaseMetaTileEntity().getRandomNumber(6000) == 0) {
- switch (this.getBaseMetaTileEntity().getRandomNumber(6)) {
- case 0:
- this.mWrench = false;
- break;
- case 1:
- this.mScrewdriver = false;
- break;
- case 2:
- this.mSoftHammer = false;
- break;
- case 3:
- this.mHardHammer = false;
- break;
- case 4:
- this.mSolderingTool = true;
- break;
- case 5:
- this.mCrowbar = false;
- break;
- }
- }
- if (this.mInventory[1] != null && this.getBaseMetaTileEntity().getRandomNumber(2) == 0
- && !this.mInventory[1].getUnlocalizedName().startsWith("gt.blockmachines.basicmachine.")) {
- if (this.mInventory[1].getItem() instanceof GT_MetaGenerated_Tool_01) {
- final NBTTagCompound tNBT = this.mInventory[1].getTagCompound();
- if (tNBT != null) {
- NBTTagCompound tNBT2 = tNBT.getCompoundTag("GT.CraftingComponents");
- if (!tNBT.getBoolean("mDis")) {
- tNBT2 = new NBTTagCompound();
- final Materials tMaterial = GT_MetaGenerated_Tool.getPrimaryMaterial(this.mInventory[1]);
- final ItemStack tTurbine = GT_OreDictUnificator.get(OrePrefixes.turbineBlade, tMaterial, 1);
- final int i = this.mInventory[1].getItemDamage();
- if (i == 170) {
- ItemStack tStack = GT_Utility.copyAmount(1, tTurbine);
- tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound()));
- tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound()));
- tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound()));
- tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound()));
- tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Magnalium, 1);
- tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound()));
- }
- else if (i == 172) {
- ItemStack tStack = GT_Utility.copyAmount(1, tTurbine);
- tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound()));
- tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound()));
- tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound()));
- tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound()));
- tNBT2.setTag("Ingredient.5", tStack.writeToNBT(new NBTTagCompound()));
- tNBT2.setTag("Ingredient.6", tStack.writeToNBT(new NBTTagCompound()));
- tNBT2.setTag("Ingredient.7", tStack.writeToNBT(new NBTTagCompound()));
- tNBT2.setTag("Ingredient.8", tStack.writeToNBT(new NBTTagCompound()));
- tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Titanium, 1);
- tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound()));
- }
- else if (i == 174) {
- ItemStack tStack = GT_Utility.copyAmount(2, tTurbine);
- tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound()));
- tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound()));
- tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound()));
- tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound()));
- tNBT2.setTag("Ingredient.5", tStack.writeToNBT(new NBTTagCompound()));
- tNBT2.setTag("Ingredient.6", tStack.writeToNBT(new NBTTagCompound()));
- tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.TungstenSteel, 1);
- tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound()));
- }
- else if (i == 176) {
- ItemStack tStack = GT_Utility.copyAmount(2, tTurbine);
- tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound()));
- tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound()));
- tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound()));
- tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound()));
- tNBT2.setTag("Ingredient.5", tStack.writeToNBT(new NBTTagCompound()));
- tNBT2.setTag("Ingredient.6", tStack.writeToNBT(new NBTTagCompound()));
- tNBT2.setTag("Ingredient.7", tStack.writeToNBT(new NBTTagCompound()));
- tNBT2.setTag("Ingredient.8", tStack.writeToNBT(new NBTTagCompound()));
- tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Americium, 1);
- tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound()));
- }
- tNBT.setTag("GT.CraftingComponents", tNBT2);
- tNBT.setBoolean("mDis", true);
- this.mInventory[1].setTagCompound(tNBT);
-
- }
- }
-
- ((GT_MetaGenerated_Tool) this.mInventory[1].getItem()).doDamage(this.mInventory[1],
- (long) Math.min(this.mEUt / 5, Math.pow(this.mEUt, 0.7)));
- if (this.mInventory[1].stackSize == 0) {
- this.mInventory[1] = null;
- }
- }
- }
- }
- return true;
- }
-
- public boolean drainEnergyInput(final long aEU) {
- if (aEU <= 0) {
- return true;
- }
- for (final GT_MetaTileEntity_Hatch_Energy tHatch : this.mEnergyHatches) {
- if (GregtechMeta_MultiBlockBase.isValidMetaTileEntity(tHatch)) {
- if (tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(aEU, false)) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Called whenever the Machine successfully finished a Process, useful for
- * Sound Effects
- */
- public void endProcess() {
- //
- }
-
- /**
- * Gets the damage to the ItemStack, usually 0 or 1.
- */
- // public abstract int getDamageToComponent(ItemStack aStack);
-
- public void explodeMultiblock() {
- this.mInventory[1] = null;
- for (final MetaTileEntity tTileEntity : this.mInputBusses) {
- tTileEntity.getBaseMetaTileEntity().doExplosion(GT_Values.V[8]);
- }
- for (final MetaTileEntity tTileEntity : this.mOutputBusses) {
- tTileEntity.getBaseMetaTileEntity().doExplosion(GT_Values.V[8]);
- }
- for (final MetaTileEntity tTileEntity : this.mInputHatches) {
- tTileEntity.getBaseMetaTileEntity().doExplosion(GT_Values.V[8]);
- }
- for (final MetaTileEntity tTileEntity : this.mOutputHatches) {
- tTileEntity.getBaseMetaTileEntity().doExplosion(GT_Values.V[8]);
- }
- for (final MetaTileEntity tTileEntity : this.mDynamoHatches) {
- tTileEntity.getBaseMetaTileEntity().doExplosion(GT_Values.V[8]);
- }
- for (final MetaTileEntity tTileEntity : this.mMufflerHatches) {
- tTileEntity.getBaseMetaTileEntity().doExplosion(GT_Values.V[8]);
- }
- for (final MetaTileEntity tTileEntity : this.mEnergyHatches) {
- tTileEntity.getBaseMetaTileEntity().doExplosion(GT_Values.V[8]);
- }
- for (final MetaTileEntity tTileEntity : this.mMaintenanceHatches) {
- tTileEntity.getBaseMetaTileEntity().doExplosion(GT_Values.V[8]);
- }
- this.getBaseMetaTileEntity().doExplosion(GT_Values.V[8]);
- }
-
- /**
- * If it explodes when the Component has to be replaced.
- */
- public abstract boolean explodesOnComponentBreak(ItemStack aStack);
-
- /**
- * Gets the Amount of possibly outputted Items for loading the Output Stack
- * Array from NBT. This should be the largest Amount that can ever happen
- * legitimately.
- */
- public abstract int getAmountOfOutputs();
-
- @Override
- public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory,
- final IGregTechTileEntity aBaseMetaTileEntity) {
- return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(),
- "MultiblockDisplay.png");
- }
-
- public int getIdealStatus() {
- return 6;
- }
-
- @Override
- public String[] getInfoData() {
- return new String[] {
- "Progress:", this.mProgresstime / 20 + "secs", this.mMaxProgresstime / 20 + "secs", "Efficiency:",
- this.mEfficiency / 100.0F + "%", "Problems:", "" + (this.getIdealStatus() - this.getRepairStatus())
- };
- }
-
- /**
- * Gets the maximum Efficiency that spare Part can get (0 - 10000)
- */
- public abstract int getMaxEfficiency(ItemStack aStack);
-
- public long getMaxInputVoltage() {
- long rVoltage = 0;
- for (final GT_MetaTileEntity_Hatch_Energy tHatch : this.mEnergyHatches) {
- if (GregtechMeta_MultiBlockBase.isValidMetaTileEntity(tHatch)) {
- rVoltage += tHatch.getBaseMetaTileEntity().getInputVoltage();
- }
- }
- return rVoltage;
- }
-
- /**
- * Gets the pollution this Device outputs to a Muffler per tick (10000 = one
- * Pullution Block)
- */
- public abstract int getPollutionPerTick(ItemStack aStack);
-
- @Override
- public int getProgresstime() {
- return this.mProgresstime;
- }
-
- public GT_Recipe_Map getRecipeMap() {
- return null;
- }
-
- public int getRepairStatus() {
- return (this.mWrench ? 1 : 0) + (this.mScrewdriver ? 1 : 0) + (this.mSoftHammer ? 1 : 0)
- + (this.mHardHammer ? 1 : 0) + (this.mSolderingTool ? 1 : 0) + (this.mCrowbar ? 1 : 0);
- }
-
- @Override
- public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory,
- final IGregTechTileEntity aBaseMetaTileEntity) {
- return new CONTAINER_MultiMachine(aPlayerInventory, aBaseMetaTileEntity);
- }
-
- public ArrayList<FluidStack> getStoredFluids() {
- final ArrayList<FluidStack> rList = new ArrayList<FluidStack>();
- for (final GT_MetaTileEntity_Hatch_Input tHatch : this.mInputHatches) {
- tHatch.mRecipeMap = this.getRecipeMap();
- if (GregtechMeta_MultiBlockBase.isValidMetaTileEntity(tHatch) && tHatch.getFillableStack() != null) {
- rList.add(tHatch.getFillableStack());
- }
- }
- return rList;
- }
-
- public ArrayList<ItemStack> getStoredInputs() {
- final ArrayList<ItemStack> rList = new ArrayList<ItemStack>();
- for (final GT_MetaTileEntity_Hatch_Input tHatch : this.mInputHatches) {
- tHatch.mRecipeMap = this.getRecipeMap();
- if (GregtechMeta_MultiBlockBase.isValidMetaTileEntity(tHatch)
- && tHatch.getBaseMetaTileEntity().getStackInSlot(0) != null) {
- rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(0));
- }
- }
- for (final GT_MetaTileEntity_Hatch_InputBus tHatch : this.mInputBusses) {
- tHatch.mRecipeMap = this.getRecipeMap();
- if (GregtechMeta_MultiBlockBase.isValidMetaTileEntity(tHatch)) {
- for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) {
- if (tHatch.getBaseMetaTileEntity().getStackInSlot(i) != null) {
- rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i));
- }
- }
- }
- }
- return rList;
- }
-
- public ArrayList<ItemStack> getStoredOutputs() {
- final ArrayList<ItemStack> rList = new ArrayList<ItemStack>();
- for (final GT_MetaTileEntity_Hatch_Output tHatch : this.mOutputHatches) {
- if (GregtechMeta_MultiBlockBase.isValidMetaTileEntity(tHatch)) {
- rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(1));
- }
- }
- for (final GT_MetaTileEntity_Hatch_OutputBus tHatch : this.mOutputBusses) {
- if (GregtechMeta_MultiBlockBase.isValidMetaTileEntity(tHatch)) {
- for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) {
- rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i));
- }
- }
- }
- return rList;
- }
-
- @Override
- public byte getTileEntityBaseType() {
- return 2;
- }
-
- public int getValidOutputSlots(final GT_Recipe.GT_Recipe_Map sRecipeMap, final ItemStack[] sInputs) {
- final ArrayList<ItemStack> tInputList = this.getStoredInputs();
- final GT_Recipe tRecipe = sRecipeMap.findRecipe(this.getBaseMetaTileEntity(), false, 9223372036854775807L, null,
- sInputs);
- final ArrayList<Pair<GT_MetaTileEntity_Hatch_OutputBus, Integer>> rList = new ArrayList<Pair<GT_MetaTileEntity_Hatch_OutputBus, Integer>>();
- int tTotalHatches = 0;
- for (final GT_MetaTileEntity_Hatch_OutputBus tHatch : this.mOutputBusses) {
+ public static boolean disableMaintenance;
+ public boolean mMachine = false, mWrench = false, mScrewdriver = false, mSoftHammer = false, mHardHammer = false, mSolderingTool = true, mCrowbar = false, mRunningOnLoad = false;
+ public int mPollution = 0, mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mEfficiencyIncrease = 0, mUpdate = 0, mStartUpCheck = 100, mRuntime = 0, mEfficiency = 0;
+ public ItemStack[] mOutputItems = null;
+ public FluidStack[] mOutputFluids = null;
+ public ArrayList<GT_MetaTileEntity_Hatch_Input> mInputHatches = new ArrayList<GT_MetaTileEntity_Hatch_Input>();
+ public ArrayList<GT_MetaTileEntity_Hatch_Output> mOutputHatches = new ArrayList<GT_MetaTileEntity_Hatch_Output>();
+ public ArrayList<GT_MetaTileEntity_Hatch_InputBus> mInputBusses = new ArrayList<GT_MetaTileEntity_Hatch_InputBus>();
+ public ArrayList<GT_MetaTileEntity_Hatch_OutputBus> mOutputBusses = new ArrayList<GT_MetaTileEntity_Hatch_OutputBus>();
+ public ArrayList<GT_MetaTileEntity_Hatch_Dynamo> mDynamoHatches = new ArrayList<GT_MetaTileEntity_Hatch_Dynamo>();
+ public ArrayList<GT_MetaTileEntity_Hatch_Muffler> mMufflerHatches = new ArrayList<GT_MetaTileEntity_Hatch_Muffler>();
+ public ArrayList<GT_MetaTileEntity_Hatch_Energy> mEnergyHatches = new ArrayList<GT_MetaTileEntity_Hatch_Energy>();
+ public ArrayList<GT_MetaTileEntity_Hatch_Maintenance> mMaintenanceHatches = new ArrayList<GT_MetaTileEntity_Hatch_Maintenance>();
+
+ public GregtechMeta_MultiBlockBase(int aID, String aName, String aNameRegional) {
+ super(aID, aName, aNameRegional, 2);
+ this.disableMaintenance = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "MultiBlockMachines.disableMaintenance", false);
+ }
+
+ public GregtechMeta_MultiBlockBase(String aName) {
+ super(aName, 2);
+ this.disableMaintenance = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "MultiBlockMachines.disableMaintenance", false);
+ }
+
+ public static boolean isValidMetaTileEntity(MetaTileEntity aMetaTileEntity) {
+ return aMetaTileEntity.getBaseMetaTileEntity() != null && aMetaTileEntity.getBaseMetaTileEntity().getMetaTileEntity() == aMetaTileEntity && !aMetaTileEntity.getBaseMetaTileEntity().isDead();
+ }
+
+ @Override
+ public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) {
+ return aSide != getBaseMetaTileEntity().getFrontFacing();
+ }
+
+ @Override
+ public boolean isSimpleMachine() {
+ return false;
+ }
+
+ @Override
+ public boolean isFacingValid(byte aFacing) {
+ return true;
+ }
+
+ @Override
+ public boolean isAccessAllowed(EntityPlayer aPlayer) {
+ return true;
+ }
+
+ @Override
+ public boolean isValidSlot(int aIndex) {
+ return aIndex > 0;
+ }
+
+ @Override
+ public int getProgresstime() {
+ return mProgresstime;
+ }
+
+ @Override
+ public int maxProgresstime() {
+ return mMaxProgresstime;
+ }
+
+ @Override
+ public int increaseProgress(int aProgress) {
+ return aProgress;
+ }
+
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ aNBT.setInteger("mEUt", mEUt);
+ aNBT.setInteger("mProgresstime", mProgresstime);
+ aNBT.setInteger("mMaxProgresstime", mMaxProgresstime);
+ aNBT.setInteger("mEfficiencyIncrease", mEfficiencyIncrease);
+ aNBT.setInteger("mEfficiency", mEfficiency);
+ aNBT.setInteger("mPollution", mPollution);
+ aNBT.setInteger("mRuntime", mRuntime);
+
+ if (mOutputItems != null) for (int i = 0; i < mOutputItems.length; i++)
+ if (mOutputItems[i] != null) {
+ NBTTagCompound tNBT = new NBTTagCompound();
+ mOutputItems[i].writeToNBT(tNBT);
+ aNBT.setTag("mOutputItem" + i, tNBT);
+ }
+ if (mOutputFluids != null) for (int i = 0; i < mOutputFluids.length; i++)
+ if (mOutputFluids[i] != null) {
+ NBTTagCompound tNBT = new NBTTagCompound();
+ mOutputFluids[i].writeToNBT(tNBT);
+ aNBT.setTag("mOutputFluids" + i, tNBT);
+ }
+
+ aNBT.setBoolean("mWrench", mWrench);
+ aNBT.setBoolean("mScrewdriver", mScrewdriver);
+ aNBT.setBoolean("mSoftHammer", mSoftHammer);
+ aNBT.setBoolean("mHardHammer", mHardHammer);
+ aNBT.setBoolean("mSolderingTool", mSolderingTool);
+ aNBT.setBoolean("mCrowbar", mCrowbar);
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ mEUt = aNBT.getInteger("mEUt");
+ mProgresstime = aNBT.getInteger("mProgresstime");
+ mMaxProgresstime = aNBT.getInteger("mMaxProgresstime");
+ if (mMaxProgresstime > 0) mRunningOnLoad = true;
+ mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease");
+ mEfficiency = aNBT.getInteger("mEfficiency");
+ mPollution = aNBT.getInteger("mPollution");
+ mRuntime = aNBT.getInteger("mRuntime");
+ mOutputItems = new ItemStack[getAmountOfOutputs()];
+ for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem" + i);
+ mOutputFluids = new FluidStack[getAmountOfOutputs()];
+ for (int i = 0; i < mOutputFluids.length; i++)
+ mOutputFluids[i] = GT_Utility.loadFluid(aNBT, "mOutputFluids" + i);
+ mWrench = aNBT.getBoolean("mWrench");
+ mScrewdriver = aNBT.getBoolean("mScrewdriver");
+ mSoftHammer = aNBT.getBoolean("mSoftHammer");
+ mHardHammer = aNBT.getBoolean("mHardHammer");
+ mSolderingTool = aNBT.getBoolean("mSolderingTool");
+ mCrowbar = aNBT.getBoolean("mCrowbar");
+ }
+
+ @Override
+ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {
+ if (aBaseMetaTileEntity.isClientSide()) return true;
+ aBaseMetaTileEntity.openGUI(aPlayer);
+ return true;
+ }
+
+ @Override
+ public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return new CONTAINER_MultiMachine(aPlayerInventory, aBaseMetaTileEntity);
+ }
+
+ @Override
+ public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MultiblockDisplay.png");
+ }
+
+ @Override
+ public byte getTileEntityBaseType() {
+ return 2;
+ }
+
+ @Override
+ public void onMachineBlockUpdate() {
+ mUpdate = 50;
+ }
+
+ @Override
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
+ if (aBaseMetaTileEntity.isServerSide()) {
+ if (mEfficiency < 0) mEfficiency = 0;
+ if (--mUpdate == 0 || --mStartUpCheck == 0) {
+ mInputHatches.clear();
+ mInputBusses.clear();
+ mOutputHatches.clear();
+ mOutputBusses.clear();
+ mDynamoHatches.clear();
+ mEnergyHatches.clear();
+ mMufflerHatches.clear();
+ mMaintenanceHatches.clear();
+ mMachine = checkMachine(aBaseMetaTileEntity, mInventory[1]);
+ }
+ if (mStartUpCheck < 0) {
+ if (mMachine) {
+ for (GT_MetaTileEntity_Hatch_Maintenance tHatch : mMaintenanceHatches) {
+ if (isValidMetaTileEntity(tHatch)) {
+ if (!this.disableMaintenance) {
+ if (tHatch.mWrench) mWrench = true;
+ if (tHatch.mScrewdriver) mScrewdriver = true;
+ if (tHatch.mSoftHammer) mSoftHammer = true;
+ if (tHatch.mHardHammer) mHardHammer = true;
+ if (tHatch.mSolderingTool) mSolderingTool = true;
+ if (tHatch.mCrowbar) mCrowbar = true;
+ } else {
+ mWrench = true;
+ mScrewdriver = true;
+ mSoftHammer = true;
+ mHardHammer = true;
+ mSolderingTool = true;
+ mCrowbar = true;
+ }
+
+ tHatch.mWrench = false;
+ tHatch.mScrewdriver = false;
+ tHatch.mSoftHammer = false;
+ tHatch.mHardHammer = false;
+ tHatch.mSolderingTool = true;
+ tHatch.mCrowbar = false;
+ }
+ }
+ if (getRepairStatus() > 0) {
+ if (mMaxProgresstime > 0 && doRandomMaintenanceDamage()) {
+ if (onRunningTick(mInventory[1])) {
+ if (!polluteEnvironment(getPollutionPerTick(mInventory[1]))) {
+ stopMachine();
+ }
+ if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime) {
+ if (mOutputItems != null) for (ItemStack tStack : mOutputItems)
+ if (tStack != null) {
+ try {
+ GT_Mod.instance.achievements.issueAchivementHatch(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), tStack);
+ } catch (Exception e) {
+ }
+ addOutput(tStack);
+ }
+ if (mOutputFluids != null && mOutputFluids.length == 1) {
+ for (FluidStack tStack : mOutputFluids)
+ if (tStack != null) {
+ addOutput(tStack);
+ }
+ } else if (mOutputFluids != null && mOutputFluids.length > 1) {
+ addFluidOutputs(mOutputFluids);
+ }
+ mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - ((getIdealStatus() - getRepairStatus()) * 1000)));
+ mOutputItems = null;
+ mProgresstime = 0;
+ mMaxProgresstime = 0;
+ mEfficiencyIncrease = 0;
+ if (aBaseMetaTileEntity.isAllowedToWork()) checkRecipe(mInventory[1]);
+ if (mOutputFluids != null && mOutputFluids.length > 0) {
+ if (mOutputFluids.length > 1) {
+ GT_Mod.instance.achievements.issueAchievement(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), "oilplant");
+ }
+ }
+ }
+ }
+ } else {
+ if (aTick % 100 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified()) {
+
+ if (aBaseMetaTileEntity.isAllowedToWork()) {
+ checkRecipe(mInventory[1]);
+ }
+ if (mMaxProgresstime <= 0) mEfficiency = Math.max(0, mEfficiency - 1000);
+ }
+ }
+ } else {
+ stopMachine();
+ }
+ } else {
+ stopMachine();
+ }
+ }
+ aBaseMetaTileEntity.setErrorDisplayID((aBaseMetaTileEntity.getErrorDisplayID() & ~127) | (mWrench ? 0 : 1) | (mScrewdriver ? 0 : 2) | (mSoftHammer ? 0 : 4) | (mHardHammer ? 0 : 8) | (mSolderingTool ? 0 : 16) | (mCrowbar ? 0 : 32) | (mMachine ? 0 : 64));
+ aBaseMetaTileEntity.setActive(mMaxProgresstime > 0);
+ }
+ }
+
+ public boolean polluteEnvironment(int aPollutionLevel) {
+ mPollution += aPollutionLevel;
+ for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) {
+ if (isValidMetaTileEntity(tHatch)) {
+ if (mPollution >= 10000) {
+ if (tHatch.polluteEnvironment()) {
+ mPollution -= 10000;
+ }
+ } else {
+ break;
+ }
+ }
+ }
+ return mPollution < 10000;
+ }
+
+ /**
+ * Called every tick the Machine runs
+ */
+ public boolean onRunningTick(ItemStack aStack) {
+ if (mEUt > 0) {
+ addEnergyOutput(((long) mEUt * mEfficiency) / 10000);
+ return true;
+ }
+ if (mEUt < 0) {
+ if (!drainEnergyInput(((long) -mEUt * 10000) / Math.max(1000, mEfficiency))) {
+ stopMachine();
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Checks if this is a Correct Machine Part for this kind of Machine (Turbine Rotor for example)
+ */
+ //public abstract boolean isCorrectMachinePart(ItemStack aStack);
+
+ /**
+ * Checks the Recipe
+ */
+ public abstract boolean checkRecipe(ItemStack aStack);
+
+ /**
+ * Checks the Machine. You have to assign the MetaTileEntities for the Hatches here.
+ */
+ public abstract boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack);
+
+ /**
+ * Gets the maximum Efficiency that spare Part can get (0 - 10000)
+ */
+ public abstract int getMaxEfficiency(ItemStack aStack);
+
+ /**
+ * Gets the pollution this Device outputs to a Muffler per tick (10000 = one Pullution Block)
+ */
+ public abstract int getPollutionPerTick(ItemStack aStack);
+
+ /**
+ * Gets the damage to the ItemStack, usually 0 or 1.
+ */
+ //public abstract int getDamageToComponent(ItemStack aStack);
+
+ /**
+ * Gets the Amount of possibly outputted Items for loading the Output Stack Array from NBT.
+ * This should be the largest Amount that can ever happen legitimately.
+ */
+ public abstract int getAmountOfOutputs();
+
+ /**
+ * If it explodes when the Component has to be replaced.
+ */
+ public abstract boolean explodesOnComponentBreak(ItemStack aStack);
+
+ public void stopMachine() {
+ mOutputItems = null;
+ mEUt = 0;
+ mEfficiency = 0;
+ mProgresstime = 0;
+ mMaxProgresstime = 0;
+ mEfficiencyIncrease = 0;
+ getBaseMetaTileEntity().disableWorking();
+ }
+
+ public int getRepairStatus() {
+ return (mWrench ? 1 : 0) + (mScrewdriver ? 1 : 0) + (mSoftHammer ? 1 : 0) + (mHardHammer ? 1 : 0) + (mSolderingTool ? 1 : 0) + (mCrowbar ? 1 : 0);
+ }
+
+ public int getIdealStatus() {
+ return 6;
+ }
+
+ public boolean doRandomMaintenanceDamage() {
+ if (getRepairStatus() == 0) {
+ stopMachine();
+ return false;
+ }
+ if (mRuntime++ > 1000) {
+ mRuntime = 0;
+ if (getBaseMetaTileEntity().getRandomNumber(6000) == 0) {
+ switch (getBaseMetaTileEntity().getRandomNumber(6)) {
+ case 0:
+ mWrench = false;
+ break;
+ case 1:
+ mScrewdriver = false;
+ break;
+ case 2:
+ mSoftHammer = false;
+ break;
+ case 3:
+ mHardHammer = false;
+ break;
+ case 4:
+ mSolderingTool = true;
+ break;
+ case 5:
+ mCrowbar = false;
+ break;
+ }
+ }
+ if (mInventory[1] != null && getBaseMetaTileEntity().getRandomNumber(2) == 0 && !mInventory[1].getUnlocalizedName().startsWith("gt.blockmachines.basicmachine.")) {
+ if (mInventory[1].getItem() instanceof GT_MetaGenerated_Tool_01) {
+ NBTTagCompound tNBT = mInventory[1].getTagCompound();
+ if (tNBT != null) {
+ NBTTagCompound tNBT2 = tNBT.getCompoundTag("GT.CraftingComponents");
+ if (!tNBT.getBoolean("mDis")) {
+ tNBT2 = new NBTTagCompound();
+ Materials tMaterial = GT_MetaGenerated_Tool.getPrimaryMaterial(mInventory[1]);
+ ItemStack tTurbine = GT_OreDictUnificator.get(OrePrefixes.turbineBlade, tMaterial, 1);
+ int i = mInventory[1].getItemDamage();
+ if (i == 170) {
+ ItemStack tStack = GT_Utility.copyAmount(1, tTurbine);
+ tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound()));
+ tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound()));
+ tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound()));
+ tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound()));
+ tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Magnalium, 1);
+ tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound()));
+ } else if (i == 172) {
+ ItemStack tStack = GT_Utility.copyAmount(1, tTurbine);
+ tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound()));
+ tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound()));
+ tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound()));
+ tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound()));
+ tNBT2.setTag("Ingredient.5", tStack.writeToNBT(new NBTTagCompound()));
+ tNBT2.setTag("Ingredient.6", tStack.writeToNBT(new NBTTagCompound()));
+ tNBT2.setTag("Ingredient.7", tStack.writeToNBT(new NBTTagCompound()));
+ tNBT2.setTag("Ingredient.8", tStack.writeToNBT(new NBTTagCompound()));
+ tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Titanium, 1);
+ tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound()));
+ } else if (i == 174) {
+ ItemStack tStack = GT_Utility.copyAmount(2, tTurbine);
+ tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound()));
+ tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound()));
+ tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound()));
+ tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound()));
+ tNBT2.setTag("Ingredient.5", tStack.writeToNBT(new NBTTagCompound()));
+ tNBT2.setTag("Ingredient.6", tStack.writeToNBT(new NBTTagCompound()));
+ tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.TungstenSteel, 1);
+ tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound()));
+ } else if (i == 176) {
+ ItemStack tStack = GT_Utility.copyAmount(2, tTurbine);
+ tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound()));
+ tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound()));
+ tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound()));
+ tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound()));
+ tNBT2.setTag("Ingredient.5", tStack.writeToNBT(new NBTTagCompound()));
+ tNBT2.setTag("Ingredient.6", tStack.writeToNBT(new NBTTagCompound()));
+ tNBT2.setTag("Ingredient.7", tStack.writeToNBT(new NBTTagCompound()));
+ tNBT2.setTag("Ingredient.8", tStack.writeToNBT(new NBTTagCompound()));
+ tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Americium, 1);
+ tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound()));
+ }
+ tNBT.setTag("GT.CraftingComponents", tNBT2);
+ tNBT.setBoolean("mDis", true);
+ mInventory[1].setTagCompound(tNBT);
+
+ }
+ }
+
+ ((GT_MetaGenerated_Tool) mInventory[1].getItem()).doDamage(mInventory[1], (long) Math.min(mEUt / 5, Math.pow(mEUt, 0.7)));
+ if (mInventory[1].stackSize == 0) mInventory[1] = null;
+ }
+ }
+ }
+ return true;
+ }
+
+ public void explodeMultiblock() {
+ mInventory[1] = null;
+ for (MetaTileEntity tTileEntity : mInputBusses) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]);
+ for (MetaTileEntity tTileEntity : mOutputBusses) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]);
+ for (MetaTileEntity tTileEntity : mInputHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]);
+ for (MetaTileEntity tTileEntity : mOutputHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]);
+ for (MetaTileEntity tTileEntity : mDynamoHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]);
+ for (MetaTileEntity tTileEntity : mMufflerHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]);
+ for (MetaTileEntity tTileEntity : mEnergyHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]);
+ for (MetaTileEntity tTileEntity : mMaintenanceHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]);
+ getBaseMetaTileEntity().doExplosion(V[8]);
+ }
+
+ public boolean addEnergyOutput(long aEU) {
+ if (aEU <= 0) return true;
+ for (GT_MetaTileEntity_Hatch_Dynamo tHatch : mDynamoHatches) {
+ if (isValidMetaTileEntity(tHatch)) {
+ if (tHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(aEU, false)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public long getMaxInputVoltage() {
+ long rVoltage = 0;
+ for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches)
+ if (isValidMetaTileEntity(tHatch)) rVoltage += tHatch.getBaseMetaTileEntity().getInputVoltage();
+ return rVoltage;
+ }
+
+ public boolean drainEnergyInput(long aEU) {
+ if (aEU <= 0) return true;
+ for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches)
+ if (isValidMetaTileEntity(tHatch)) {
+ if (tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(aEU, false)) return true;
+ }
+ return false;
+ }
+
+ public boolean addOutput(FluidStack aLiquid) {
+ if (aLiquid == null) return false;
+ FluidStack tLiquid = aLiquid.copy();
+ for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) {
+ if (isValidMetaTileEntity(tHatch) && GT_ModHandler.isSteam(aLiquid) ? tHatch.outputsSteam() : tHatch.outputsLiquids()) {
+ int tAmount = tHatch.fill(tLiquid, false);
+ if (tAmount >= tLiquid.amount) {
+ return tHatch.fill(tLiquid, true) >= tLiquid.amount;
+ } else if (tAmount > 0) {
+ tLiquid.amount = tLiquid.amount - tHatch.fill(tLiquid, true);
+ }
+ }
+ }
+ return false;
+ }
+
+ private void addFluidOutputs(FluidStack[] mOutputFluids2) {
+ for (int i = 0; i < mOutputFluids2.length; i++) {
+ if (mOutputHatches.size() > i && mOutputHatches.get(i) != null && mOutputFluids2[i] != null && isValidMetaTileEntity(mOutputHatches.get(i))) {
+ mOutputHatches.get(i).fill(mOutputFluids2[i], true);
+ }
+ }
+
+ }
+
+ public boolean depleteInput(FluidStack aLiquid) {
+ if (aLiquid == null) return false;
+ for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) {
+ tHatch.mRecipeMap = getRecipeMap();
+ if (isValidMetaTileEntity(tHatch)) {
+ FluidStack tLiquid = tHatch.getFluid();
+ if (tLiquid != null && tLiquid.isFluidEqual(aLiquid)) {
+ tLiquid = tHatch.drain(aLiquid.amount, false);
+ if (tLiquid != null && tLiquid.amount >= aLiquid.amount) {
+ tLiquid = tHatch.drain(aLiquid.amount, true);
+ return tLiquid != null && tLiquid.amount >= aLiquid.amount;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ public boolean addOutput(ItemStack aStack) {
+ if (GT_Utility.isStackInvalid(aStack)) return false;
+ aStack = GT_Utility.copy(aStack);
+// FluidStack aLiquid = GT_Utility.getFluidForFilledItem(aStack, true);
+// if (aLiquid == null) {
+ for (GT_MetaTileEntity_Hatch_OutputBus tHatch : mOutputBusses) {
+ if (isValidMetaTileEntity(tHatch)) {
+ for (int i = tHatch.getSizeInventory() - 1; i >= 0; i--) {
+ if (tHatch.getBaseMetaTileEntity().addStackToSlot(i, aStack)) return true;
+ }
+ }
+ }
+ for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) {
+ if (isValidMetaTileEntity(tHatch) && tHatch.outputsItems()) {
+ if (tHatch.getBaseMetaTileEntity().addStackToSlot(1, aStack)) return true;
+ }
+ }
+// }else {
+// for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) {
+// if (isValidMetaTileEntity(tHatch) && GT_ModHandler.isSteam(aLiquid)?tHatch.outputsSteam():tHatch.outputsLiquids()) {
+// int tAmount = tHatch.fill(aLiquid, false);
+// if (tAmount >= aLiquid.amount) {
+// return tHatch.fill(aLiquid, true) >= aLiquid.amount;
+// }
+// }
+// }
+// }
+ return false;
+ }
+
+ public boolean depleteInput(ItemStack aStack) {
+ if (GT_Utility.isStackInvalid(aStack)) return false;
+ FluidStack aLiquid = GT_Utility.getFluidForFilledItem(aStack, true);
+ if (aLiquid != null) return depleteInput(aLiquid);
+ for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) {
+ tHatch.mRecipeMap = getRecipeMap();
+ if (isValidMetaTileEntity(tHatch)) {
+ if (GT_Utility.areStacksEqual(aStack, tHatch.getBaseMetaTileEntity().getStackInSlot(0))) {
+ if (tHatch.getBaseMetaTileEntity().getStackInSlot(0).stackSize >= aStack.stackSize) {
+ tHatch.getBaseMetaTileEntity().decrStackSize(0, aStack.stackSize);
+ return true;
+ }
+ }
+ }
+ }
+ for (GT_MetaTileEntity_Hatch_InputBus tHatch : mInputBusses) {
+ tHatch.mRecipeMap = getRecipeMap();
+ if (isValidMetaTileEntity(tHatch)) {
+ for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) {
+ if (GT_Utility.areStacksEqual(aStack, tHatch.getBaseMetaTileEntity().getStackInSlot(i))) {
+ if (tHatch.getBaseMetaTileEntity().getStackInSlot(0).stackSize >= aStack.stackSize) {
+ tHatch.getBaseMetaTileEntity().decrStackSize(0, aStack.stackSize);
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ public ArrayList<ItemStack> getStoredOutputs() {
+ ArrayList<ItemStack> rList = new ArrayList<ItemStack>();
+ for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) {
+ if (isValidMetaTileEntity(tHatch)) {
+ rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(1));
+ }
+ }
+ for (GT_MetaTileEntity_Hatch_OutputBus tHatch : mOutputBusses) {
+ if (isValidMetaTileEntity(tHatch)) {
+ for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) {
+ rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i));
+ }
+ }
+ }
+ return rList;
+ }
+
+ public ArrayList<FluidStack> getStoredFluids() {
+ ArrayList<FluidStack> rList = new ArrayList<FluidStack>();
+ for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) {
+ tHatch.mRecipeMap = getRecipeMap();
+ if (isValidMetaTileEntity(tHatch) && tHatch.getFillableStack() != null) {
+ rList.add(tHatch.getFillableStack());
+ }
+ }
+ return rList;
+ }
+
+ public ArrayList<ItemStack> getStoredInputs() {
+ ArrayList<ItemStack> rList = new ArrayList<ItemStack>();
+ for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) {
+ tHatch.mRecipeMap = getRecipeMap();
+ if (isValidMetaTileEntity(tHatch) && tHatch.getBaseMetaTileEntity().getStackInSlot(0) != null) {
+ rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(0));
+ }
+ }
+ for (GT_MetaTileEntity_Hatch_InputBus tHatch : mInputBusses) {
+ tHatch.mRecipeMap = getRecipeMap();
+ if (isValidMetaTileEntity(tHatch)) {
+ for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) {
+ if (tHatch.getBaseMetaTileEntity().getStackInSlot(i) != null)
+ rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i));
+ }
+ }
+ }
+ return rList;
+ }
+
+ public GT_Recipe_Map getRecipeMap() {
+ return null;
+ }
+
+ public void updateSlots() {
+ for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches)
+ if (isValidMetaTileEntity(tHatch)) tHatch.updateSlots();
+ for (GT_MetaTileEntity_Hatch_InputBus tHatch : mInputBusses)
+ if (isValidMetaTileEntity(tHatch)) tHatch.updateSlots();
+ }
+
+ public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
+ if (aTileEntity == null) return false;
+ IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
+ if (aMetaTileEntity == null) return false;
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch)
+ ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex;
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input)
+ return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity);
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus)
+ return mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity);
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output)
+ return mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity);
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus)
+ return mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity);
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy)
+ return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity);
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo)
+ return mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity);
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance)
+ return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity);
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler)
+ return mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity);
+ return false;
+ }
+
+ public boolean addMaintenanceToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
+ if (aTileEntity == null) return false;
+ IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
+ if (aMetaTileEntity == null) return false;
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) {
+ ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex;
+ return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity);
+ }
+ return false;
+ }
+
+ public boolean addEnergyInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
+ if (aTileEntity == null) {
+ return false;
+ }
+ IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
+ if (aMetaTileEntity == null) return false;
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) {
+ ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex;
+ return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity);
+ }
+ return false;
+ }
+
+ public boolean addDynamoToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
+ if (aTileEntity == null) return false;
+ IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
+ if (aMetaTileEntity == null) return false;
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) {
+ ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex;
+ return mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity);
+ }
+ return false;
+ }
+
+ public boolean addMufflerToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
+ if (aTileEntity == null) return false;
+ IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
+ if (aMetaTileEntity == null) return false;
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) {
+ ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex;
+ return mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity);
+ }
+ return false;
+ }
+
+ public boolean addInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
+ if (aTileEntity == null) return false;
+ IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
+ if (aMetaTileEntity == null) return false;
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) {
+ ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex;
+ ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = getRecipeMap();
+ return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity);
+ }
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) {
+ ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex;
+ ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mRecipeMap = getRecipeMap();
+ return mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity);
+ }
+ return false;
+ }
+
+ public boolean addOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
+ if (aTileEntity == null) return false;
+ IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
+ if (aMetaTileEntity == null) return false;
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) {
+ ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex;
+ return mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity);
+ }
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) {
+ ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex;
+ return mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity);
+ }
+ return false;
+ }
+
+ @Override
+ public String[] getInfoData() {
+ return new String[]{"Progress:", (mProgresstime / 20) + "secs", (mMaxProgresstime / 20) + "secs", "Efficiency:", (mEfficiency / 100.0F) + "%", "Problems:", "" + (getIdealStatus() - getRepairStatus())};
+ }
+
+ @Override
+ public boolean isGivingInformation() {
+ return true;
+ }
+
+ @Override
+ public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return false;
+ }
+
+ @Override
+ public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return false;
+ }
+
+ /**
+ * Called whenever the Machine successfully started a Process, useful for Sound Effects
+ */
+ public void startProcess() {
+ //
+ }
+
+ /**
+ * Called whenever the Machine successfully finished a Process, useful for Sound Effects
+ */
+ public void endProcess() {
+ //
+ }
+
+ /**
+ * Called whenever the Machine aborted a Process, useful for Sound Effects
+ */
+ public void abortProcess() {
+ //
+ }
+
+ public int getValidOutputSlots(GT_Recipe.GT_Recipe_Map sRecipeMap, ItemStack[] sInputs){
+ ArrayList<ItemStack> tInputList = getStoredInputs();
+ GT_Recipe tRecipe = sRecipeMap.findRecipe(getBaseMetaTileEntity(), false, 9223372036854775807L, null, sInputs);
+ ArrayList<Pair<GT_MetaTileEntity_Hatch_OutputBus, Integer>> rList = new ArrayList<Pair<GT_MetaTileEntity_Hatch_OutputBus, Integer>>();
+ int tTotalHatches=0;
+ for (GT_MetaTileEntity_Hatch_OutputBus tHatch : mOutputBusses) {
int hatchUsedSlotCount = 0;
- if (GregtechMeta_MultiBlockBase.isValidMetaTileEntity(tHatch)) {
+ if (isValidMetaTileEntity(tHatch)) {
tTotalHatches++;
- for (int i = 0; i < tHatch.getBaseMetaTileEntity().getSizeInventory(); i++) {
- if (tHatch.getBaseMetaTileEntity().getStackInSlot(i) != null) {
- hatchUsedSlotCount++;
- }
+ for (int i=0; i<tHatch.getBaseMetaTileEntity().getSizeInventory(); i++) {
+ if (tHatch.getBaseMetaTileEntity().getStackInSlot(i) != null){hatchUsedSlotCount++;}
}
rList.add(new Pair<GT_MetaTileEntity_Hatch_OutputBus, Integer>(tHatch, hatchUsedSlotCount));
}
}
- final boolean[] mValidOutputSlots = new boolean[tTotalHatches];
- int arrayPos = 0;
- for (final Pair<GT_MetaTileEntity_Hatch_OutputBus, Integer> IE : rList) {
- final GT_MetaTileEntity_Hatch_OutputBus vTE = IE.getKey();
- final int vUsedSlots = IE.getValue();
- if (vUsedSlots == 0) {
- mValidOutputSlots[arrayPos] = true;
- }
- else if (vUsedSlots < vTE.getSizeInventory()) {
- final int outputItemCount = tRecipe.mOutputs.length;
- if (vUsedSlots < vTE.getSizeInventory() - outputItemCount) {
- mValidOutputSlots[arrayPos] = true;
- }
- else if (vUsedSlots >= vTE.getSizeInventory() - outputItemCount) {
- if (vUsedSlots > vTE.getSizeInventory() - outputItemCount) {
- if (arrayPos == tTotalHatches) {
- return 0;
- }
- /* Change to Hatch total */ }
- }
- }
- // Hatch is full
- if (vUsedSlots == vTE.getSizeInventory()) {
+ boolean[] mValidOutputSlots = new boolean[tTotalHatches];
+ int arrayPos=0;
+ for (Pair<GT_MetaTileEntity_Hatch_OutputBus, Integer> IE : rList) {
+ GT_MetaTileEntity_Hatch_OutputBus vTE = IE.getKey();
+ int vUsedSlots = IE.getValue();
+ if (vUsedSlots == 0){mValidOutputSlots[arrayPos] = true;}
+ else if (vUsedSlots < vTE.getSizeInventory()){
+ int outputItemCount = tRecipe.mOutputs.length;
+ if (vUsedSlots < vTE.getSizeInventory()-outputItemCount){mValidOutputSlots[arrayPos] = true;}
+ else if (vUsedSlots >= vTE.getSizeInventory()-outputItemCount){
+ if (vUsedSlots > vTE.getSizeInventory()-outputItemCount){if (arrayPos == tTotalHatches){return 0;} /*Change to Hatch total*/ }
+ }
+ }
+ //Hatch is full
+ if (vUsedSlots == vTE.getSizeInventory()){
mValidOutputSlots[arrayPos] = false;
- if (arrayPos == tTotalHatches) {
- return 0;
- } // Change to Hatch Total
+ if (arrayPos == tTotalHatches){return 0;} // Change to Hatch Total
}
arrayPos++;
}
int tValidOutputSlots = 0;
- for (int cr = 0; cr < mValidOutputSlots.length; cr++) {
- if (mValidOutputSlots[cr]) {
- tValidOutputSlots++;
- }
- }
- if (tValidOutputSlots >= 1) {
- return tValidOutputSlots;
- }
- return 0;
- }
-
- @Override
- public int increaseProgress(final int aProgress) {
- return aProgress;
- }
-
- @Override
- public boolean isAccessAllowed(final EntityPlayer aPlayer) {
- return true;
- }
-
- @Override
- public boolean isFacingValid(final byte aFacing) {
- return true;
- }
-
- @Override
- public boolean isGivingInformation() {
- return true;
- }
-
- @Override
- public boolean isSimpleMachine() {
- return false;
- }
-
- @Override
- public boolean isValidSlot(final int aIndex) {
- return aIndex > 0;
- }
-
- @Override
- public void loadNBTData(final NBTTagCompound aNBT) {
- this.mEUt = aNBT.getInteger("mEUt");
- this.mProgresstime = aNBT.getInteger("mProgresstime");
- this.mMaxProgresstime = aNBT.getInteger("mMaxProgresstime");
- if (this.mMaxProgresstime > 0) {
- this.mRunningOnLoad = true;
- }
- this.mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease");
- this.mEfficiency = aNBT.getInteger("mEfficiency");
- this.mPollution = aNBT.getInteger("mPollution");
- this.mRuntime = aNBT.getInteger("mRuntime");
- this.mOutputItems = new ItemStack[this.getAmountOfOutputs()];
- for (int i = 0; i < this.mOutputItems.length; i++) {
- this.mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem" + i);
- }
- this.mOutputFluids = new FluidStack[this.getAmountOfOutputs()];
- for (int i = 0; i < this.mOutputFluids.length; i++) {
- this.mOutputFluids[i] = GT_Utility.loadFluid(aNBT, "mOutputFluids" + i);
- }
- this.mWrench = aNBT.getBoolean("mWrench");
- this.mScrewdriver = aNBT.getBoolean("mScrewdriver");
- this.mSoftHammer = aNBT.getBoolean("mSoftHammer");
- this.mHardHammer = aNBT.getBoolean("mHardHammer");
- this.mSolderingTool = aNBT.getBoolean("mSolderingTool");
- this.mCrowbar = aNBT.getBoolean("mCrowbar");
- }
-
- @Override
- public int maxProgresstime() {
- return this.mMaxProgresstime;
- }
-
- @Override
- public void onMachineBlockUpdate() {
- this.mUpdate = 50;
- }
-
- @Override
- public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) {
- if (aBaseMetaTileEntity.isServerSide()) {
- if (this.mEfficiency < 0) {
- this.mEfficiency = 0;
- }
- if (--this.mUpdate == 0 || --this.mStartUpCheck == 0) {
- this.mInputHatches.clear();
- this.mInputBusses.clear();
- this.mOutputHatches.clear();
- this.mOutputBusses.clear();
- this.mDynamoHatches.clear();
- this.mEnergyHatches.clear();
- this.mMufflerHatches.clear();
- this.mMaintenanceHatches.clear();
- this.mMachine = this.checkMachine(aBaseMetaTileEntity, this.mInventory[1]);
- }
- if (this.mStartUpCheck < 0) {
- if (this.mMachine) {
- for (final GT_MetaTileEntity_Hatch_Maintenance tHatch : this.mMaintenanceHatches) {
- if (GregtechMeta_MultiBlockBase.isValidMetaTileEntity(tHatch)) {
- if (!GregtechMeta_MultiBlockBase.disableMaintenance) {
- if (tHatch.mWrench) {
- this.mWrench = true;
- }
- if (tHatch.mScrewdriver) {
- this.mScrewdriver = true;
- }
- if (tHatch.mSoftHammer) {
- this.mSoftHammer = true;
- }
- if (tHatch.mHardHammer) {
- this.mHardHammer = true;
- }
- if (tHatch.mSolderingTool) {
- this.mSolderingTool = true;
- }
- if (tHatch.mCrowbar) {
- this.mCrowbar = true;
- }
- }
- else {
- this.mWrench = true;
- this.mScrewdriver = true;
- this.mSoftHammer = true;
- this.mHardHammer = true;
- this.mSolderingTool = true;
- this.mCrowbar = true;
- }
-
- tHatch.mWrench = false;
- tHatch.mScrewdriver = false;
- tHatch.mSoftHammer = false;
- tHatch.mHardHammer = false;
- tHatch.mSolderingTool = true;
- tHatch.mCrowbar = false;
- }
- }
- if (this.getRepairStatus() > 0) {
- if (this.mMaxProgresstime > 0 && this.doRandomMaintenanceDamage()) {
- if (this.onRunningTick(this.mInventory[1])) {
- if (!this.polluteEnvironment(this.getPollutionPerTick(this.mInventory[1]))) {
- this.stopMachine();
- }
- if (this.mMaxProgresstime > 0 && ++this.mProgresstime >= this.mMaxProgresstime) {
- if (this.mOutputItems != null) {
- for (final ItemStack tStack : this.mOutputItems) {
- if (tStack != null) {
- try {
- GT_Mod.achievements.issueAchivementHatch(
- aBaseMetaTileEntity.getWorld().getPlayerEntityByName(
- aBaseMetaTileEntity.getOwnerName()),
- tStack);
- }
- catch (final Exception e) {
- }
- this.addOutput(tStack);
- }
- }
- }
- if (this.mOutputFluids != null && this.mOutputFluids.length == 1) {
- for (final FluidStack tStack : this.mOutputFluids) {
- if (tStack != null) {
- this.addOutput(tStack);
- }
- }
- }
- else if (this.mOutputFluids != null && this.mOutputFluids.length > 1) {
- this.addFluidOutputs(this.mOutputFluids);
- }
- this.mEfficiency = Math.max(0,
- Math.min(this.mEfficiency + this.mEfficiencyIncrease,
- this.getMaxEfficiency(this.mInventory[1])
- - (this.getIdealStatus() - this.getRepairStatus()) * 1000));
- this.mOutputItems = null;
- this.mProgresstime = 0;
- this.mMaxProgresstime = 0;
- this.mEfficiencyIncrease = 0;
- if (aBaseMetaTileEntity.isAllowedToWork()) {
- this.checkRecipe(this.mInventory[1]);
- }
- if (this.mOutputFluids != null && this.mOutputFluids.length > 0) {
- if (this.mOutputFluids.length > 1) {
- GT_Mod.achievements.issueAchievement(aBaseMetaTileEntity.getWorld()
- .getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()),
- "oilplant");
- }
- }
- }
- }
- }
- else {
- if (aTick % 100 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled()
- || aBaseMetaTileEntity.hasInventoryBeenModified()) {
-
- if (aBaseMetaTileEntity.isAllowedToWork()) {
- this.checkRecipe(this.mInventory[1]);
- }
- if (this.mMaxProgresstime <= 0) {
- this.mEfficiency = Math.max(0, this.mEfficiency - 1000);
- }
- }
- }
- }
- else {
- this.stopMachine();
- }
- }
- else {
- this.stopMachine();
- }
- }
- aBaseMetaTileEntity
- .setErrorDisplayID(aBaseMetaTileEntity.getErrorDisplayID() & ~127 | (this.mWrench ? 0 : 1)
- | (this.mScrewdriver ? 0 : 2) | (this.mSoftHammer ? 0 : 4) | (this.mHardHammer ? 0 : 8)
- | (this.mSolderingTool ? 0 : 16) | (this.mCrowbar ? 0 : 32) | (this.mMachine ? 0 : 64));
- aBaseMetaTileEntity.setActive(this.mMaxProgresstime > 0);
- }
- }
-
- @Override
- public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) {
- if (aBaseMetaTileEntity.isClientSide()) {
- return true;
- }
- aBaseMetaTileEntity.openGUI(aPlayer);
- return true;
- }
-
- /**
- * Called every tick the Machine runs
- */
- public boolean onRunningTick(final ItemStack aStack) {
- if (this.mEUt > 0) {
- this.addEnergyOutput((long) this.mEUt * this.mEfficiency / 10000);
- return true;
- }
- if (this.mEUt < 0) {
- if (!this.drainEnergyInput((long) -this.mEUt * 10000 / Math.max(1000, this.mEfficiency))) {
- this.stopMachine();
- return false;
- }
- }
- return true;
- }
-
- public boolean polluteEnvironment(final int aPollutionLevel) {
- this.mPollution += aPollutionLevel;
- for (final GT_MetaTileEntity_Hatch_Muffler tHatch : this.mMufflerHatches) {
- if (GregtechMeta_MultiBlockBase.isValidMetaTileEntity(tHatch)) {
- if (this.mPollution >= 10000) {
- if (tHatch.polluteEnvironment()) {
- this.mPollution -= 10000;
- }
- }
- else {
- break;
- }
- }
- }
- return this.mPollution < 10000;
- }
-
- @Override
- public void saveNBTData(final NBTTagCompound aNBT) {
- aNBT.setInteger("mEUt", this.mEUt);
- aNBT.setInteger("mProgresstime", this.mProgresstime);
- aNBT.setInteger("mMaxProgresstime", this.mMaxProgresstime);
- aNBT.setInteger("mEfficiencyIncrease", this.mEfficiencyIncrease);
- aNBT.setInteger("mEfficiency", this.mEfficiency);
- aNBT.setInteger("mPollution", this.mPollution);
- aNBT.setInteger("mRuntime", this.mRuntime);
-
- if (this.mOutputItems != null) {
- for (int i = 0; i < this.mOutputItems.length; i++) {
- if (this.mOutputItems[i] != null) {
- final NBTTagCompound tNBT = new NBTTagCompound();
- this.mOutputItems[i].writeToNBT(tNBT);
- aNBT.setTag("mOutputItem" + i, tNBT);
- }
- }
- }
- if (this.mOutputFluids != null) {
- for (int i = 0; i < this.mOutputFluids.length; i++) {
- if (this.mOutputFluids[i] != null) {
- final NBTTagCompound tNBT = new NBTTagCompound();
- this.mOutputFluids[i].writeToNBT(tNBT);
- aNBT.setTag("mOutputFluids" + i, tNBT);
- }
- }
- }
-
- aNBT.setBoolean("mWrench", this.mWrench);
- aNBT.setBoolean("mScrewdriver", this.mScrewdriver);
- aNBT.setBoolean("mSoftHammer", this.mSoftHammer);
- aNBT.setBoolean("mHardHammer", this.mHardHammer);
- aNBT.setBoolean("mSolderingTool", this.mSolderingTool);
- aNBT.setBoolean("mCrowbar", this.mCrowbar);
- }
-
- /**
- * Called whenever the Machine successfully started a Process, useful for
- * Sound Effects
- */
- public void startProcess() {
- //
- }
-
- public void stopMachine() {
- this.mOutputItems = null;
- this.mEUt = 0;
- this.mEfficiency = 0;
- this.mProgresstime = 0;
- this.mMaxProgresstime = 0;
- this.mEfficiencyIncrease = 0;
- this.getBaseMetaTileEntity().disableWorking();
- }
-
- public void updateSlots() {
- for (final GT_MetaTileEntity_Hatch_Input tHatch : this.mInputHatches) {
- if (GregtechMeta_MultiBlockBase.isValidMetaTileEntity(tHatch)) {
- tHatch.updateSlots();
- }
- }
- for (final GT_MetaTileEntity_Hatch_InputBus tHatch : this.mInputBusses) {
- if (GregtechMeta_MultiBlockBase.isValidMetaTileEntity(tHatch)) {
- tHatch.updateSlots();
- }
- }
- }
-
+ for (int cr=0;cr<mValidOutputSlots.length;cr++){if (mValidOutputSlots[cr]){tValidOutputSlots++;}}
+ if (tValidOutputSlots >= 1) {return tValidOutputSlots;}
+ return 0;
+ }
+
+
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechDoubleFuelGeneratorBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechDoubleFuelGeneratorBase.java
index b359ff1e83..49f9fb1344 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechDoubleFuelGeneratorBase.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechDoubleFuelGeneratorBase.java
@@ -1,8 +1,6 @@
package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators;
-import java.util.Collection;
-
-import gregtech.api.enums.GT_Values;
+import static gregtech.api.enums.GT_Values.V;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
@@ -12,6 +10,9 @@ import gregtech.api.util.GT_Utility;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.util.Utils;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_DeluxeTank;
+
+import java.util.Collection;
+
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
@@ -21,492 +22,386 @@ public abstract class GregtechDoubleFuelGeneratorBase extends GT_MetaTileEntity_
private boolean useFuel = false;
- public GregtechDoubleFuelGeneratorBase(final int aID, final String aName, final String aNameRegional,
- final int aTier, final String aDescription, final ITexture... aTextures) {
+ public GregtechDoubleFuelGeneratorBase(int aID, String aName, String aNameRegional, int aTier, String aDescription, ITexture... aTextures) {
super(aID, aName, aNameRegional, aTier, 4, aDescription, aTextures);
}
- public GregtechDoubleFuelGeneratorBase(final String aName, final int aTier, final String aDescription,
- final ITexture[][][] aTextures) {
+ public GregtechDoubleFuelGeneratorBase(String aName, int aTier, String aDescription, ITexture[][][] aTextures) {
super(aName, aTier, 4, aDescription, aTextures);
}
@Override
- public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide,
- final ItemStack aStack) {
- return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && (this.getFuelValue(aStack) > 0
- || this.getFuelValue(GT_Utility.getFluidForFilledItem(aStack, true)) > 0);
- }
-
- @Override
- public boolean canTankBeEmptied() {
- return this.getBaseMetaTileEntity().isAllowedToWork();
+ 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 boolean canTankBeFilled() {
- return this.getBaseMetaTileEntity().isAllowedToWork();
+ 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];
}
- /*
- * @Override public boolean onRightclick(IGregTechTileEntity
- * aBaseMetaTileEntity, EntityPlayer aPlayer) { if
- * (aBaseMetaTileEntity.isClientSide()) return true;
- * aBaseMetaTileEntity.openGUI(aPlayer); return true; }
- */
-
- public int consumedFluidPerOperation(final FluidStack aLiquid) {
- return 1;
- }
@Override
- public boolean displaysItemStack() {
- return true;
+ public String[] getDescription() {
+ return new String[]{mDescription, "Fuel Efficiency: " + getEfficiency() + "%", CORE.GT_Tooltip};
}
- @Override
- public boolean displaysStackSize() {
- return false;
- }
- @Override
- public boolean doesEmptyContainers() {
- return this.getBaseMetaTileEntity().isAllowedToWork();
- }
+ /* @Override
+ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {
+ if (aBaseMetaTileEntity.isClientSide()) return true;
+ aBaseMetaTileEntity.openGUI(aPlayer);
+ return true;
+ }*/
@Override
- public boolean doesFillContainers() {
- return this.getBaseMetaTileEntity().isAllowedToWork();
- }
-
- public ITexture[] getBack(final byte aColor) {
- return new ITexture[] {
- Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]
- };
- }
+ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {
+ if (aBaseMetaTileEntity.isClientSide()){
+ Utils.LOG_WARNING("Entity is Client side, simply returning true");
+ return true;
+ }
+ Utils.LOG_WARNING("Entity is not Client side, opening entity Container and by extension, it's GUI, then returning true");
+ aBaseMetaTileEntity.openGUI(aPlayer);
+ return true;
+ }
- public ITexture[] getBackActive(final byte aColor) {
- return this.getBack(aColor);
+ public ITexture[] getFront(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]};
}
- public ITexture[] getBottom(final byte aColor) {
- return new ITexture[] {
- Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]
- };
+ public ITexture[] getBack(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]};
}
- public ITexture[] getBottomActive(final byte aColor) {
- return this.getBottom(aColor);
+ public ITexture[] getBottom(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]};
}
- @Override
- public int getCapacity() {
- return 32000;
+ public ITexture[] getTop(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]};
}
- @Override
- public String[] getDescription() {
- return new String[] {
- this.mDescription, "Fuel Efficiency: " + this.getEfficiency() + "%", CORE.GT_Tooltip
- };
+ public ITexture[] getSides(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]};
}
- public abstract int getEfficiency();
-
- public ItemStack getEmptyContainer(final ItemStack aStack) {
- if (GT_Utility.isStackInvalid(aStack) || this.getRecipes() == null) {
- return null;
- }
- final GT_Recipe tFuel = this.getRecipes().findRecipe(this.getBaseMetaTileEntity(), false, Long.MAX_VALUE, null,
- aStack);
- if (tFuel != null) {
- return GT_Utility.copy(tFuel.getOutput(0));
- }
- return GT_Utility.getContainerItem(aStack, true);
+ public ITexture[] getFrontActive(byte aColor) {
+ return getFront(aColor);
}
- public ITexture[] getFront(final byte aColor) {
- return new ITexture[] {
- Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]
- };
+ public ITexture[] getBackActive(byte aColor) {
+ return getBack(aColor);
}
- public ITexture[] getFrontActive(final byte aColor) {
- return this.getFront(aColor);
+ public ITexture[] getBottomActive(byte aColor) {
+ return getBottom(aColor);
}
- public int getFuelValue(final FluidStack aLiquid) {
- if (aLiquid == null || this.getRecipes() == null) {
- return 0;
- }
- FluidStack tLiquid;
- final Collection<GT_Recipe> tRecipeList = this.getRecipes().mRecipeList;
- if (tRecipeList != null) {
- for (final GT_Recipe tFuel : tRecipeList) {
- if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null) {
- if (aLiquid.isFluidEqual(tLiquid)) {
- return (int) ((long) tFuel.mSpecialValue * this.getEfficiency()
- * this.consumedFluidPerOperation(tLiquid) / 100);
- }
- }
- }
- }
- return 0;
+ public ITexture[] getTopActive(byte aColor) {
+ return getTop(aColor);
}
- public int getFuelValue(final ItemStack aStack) {
- if (GT_Utility.isStackInvalid(aStack) || this.getRecipes() == null) {
- return 0;
- }
- final GT_Recipe tFuel = this.getRecipes().findRecipe(this.getBaseMetaTileEntity(), false, Long.MAX_VALUE, null,
- aStack);
- if (tFuel != null) {
- return (int) (tFuel.mSpecialValue * 1000L * this.getEfficiency() / 100);
- }
- return 0;
+ public ITexture[] getSidesActive(byte aColor) {
+ return getSides(aColor);
}
@Override
- public long getMinimumStoredEU() {
- return 512;
+ public boolean isFacingValid(byte aSide) {
+ return aSide > 1;
}
- public abstract GT_Recipe_Map getRecipes();
-
- public ITexture[] getSides(final byte aColor) {
- return new ITexture[] {
- Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]
- };
+ @Override
+ public boolean isSimpleMachine() {
+ return false;
}
- public ITexture[] getSidesActive(final byte aColor) {
- return this.getSides(aColor);
+ @Override
+ public boolean isValidSlot(int aIndex) {
+ return aIndex < 2;
}
@Override
- public int getTankPressure() {
- return -100;
+ public boolean isEnetOutput() {
+ return true;
}
@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];
+ public boolean isOutputFacing(byte aSide) {
+ return true;
}
@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);
- }
- return rTextures;
+ public boolean isAccessAllowed(EntityPlayer aPlayer) {
+ return true;
}
- public ITexture[] getTop(final byte aColor) {
- return new ITexture[] {
- Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]
- };
+ @Override
+ public long maxEUOutput() {
+ return getBaseMetaTileEntity().isAllowedToWork() ? V[mTier] : 0;
}
- public ITexture[] getTopActive(final byte aColor) {
- return this.getTop(aColor);
+ @Override
+ public long maxEUStore() {
+ return Math.max(getEUVar(), V[mTier] * 115 + getMinimumStoredEU());
}
@Override
- public boolean isAccessAllowed(final EntityPlayer aPlayer) {
- return true;
+ public boolean doesFillContainers() {
+ return getBaseMetaTileEntity().isAllowedToWork();
}
@Override
- public boolean isEnetOutput() {
- return true;
+ public boolean doesEmptyContainers() {
+ return getBaseMetaTileEntity().isAllowedToWork();
}
@Override
- public boolean isFacingValid(final byte aSide) {
- return aSide > 1;
+ public boolean canTankBeFilled() {
+ return getBaseMetaTileEntity().isAllowedToWork();
}
@Override
- public boolean isFluidInputAllowed(final FluidStack aFluid) {
- return this.getFuelValue(aFluid) > 0;
+ public boolean canTankBeEmptied() {
+ return getBaseMetaTileEntity().isAllowedToWork();
}
@Override
- public boolean isOutputFacing(final byte aSide) {
+ public boolean displaysItemStack() {
return true;
}
@Override
- public boolean isSimpleMachine() {
+ public boolean displaysStackSize() {
return false;
}
@Override
- public boolean isValidSlot(final int aIndex) {
- return aIndex < 2;
- }
-
- @Override
- public long maxEUOutput() {
- return this.getBaseMetaTileEntity().isAllowedToWork() ? GT_Values.V[this.mTier] : 0;
+ public boolean isFluidInputAllowed(FluidStack aFluid) {
+ return getFuelValue(aFluid) > 0;
}
-
+
@Override
- public long maxEUStore() {
- return Math.max(this.getEUVar(), GT_Values.V[this.mTier] * 115 + this.getMinimumStoredEU());
- }
+ public long getMinimumStoredEU() {
+ return 512;
+ }
@Override
- public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) {
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && aTick % 10 == 0) {
- if (this.mFluid == null) {
- if (aBaseMetaTileEntity.getUniversalEnergyStored() < this.maxEUOutput() + this.getMinimumStoredEU()) {
- this.mInventory[this.getStackDisplaySlot()] = null;
- }
- else {
- if (this.mInventory[this.getStackDisplaySlot()] == null) {
- this.mInventory[this.getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1);
- }
- this.mInventory[this.getStackDisplaySlot()].setStackDisplayName("Generating: "
- + (aBaseMetaTileEntity.getUniversalEnergyStored() - this.getMinimumStoredEU()) + " EU");
+ if (mFluid == null) {
+ if (aBaseMetaTileEntity.getUniversalEnergyStored() < maxEUOutput() + getMinimumStoredEU()) {
+ mInventory[getStackDisplaySlot()] = null;
+ } else {
+ if (mInventory[getStackDisplaySlot()] == null)
+ mInventory[getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1);
+ mInventory[getStackDisplaySlot()].setStackDisplayName("Generating: " + (aBaseMetaTileEntity.getUniversalEnergyStored() - getMinimumStoredEU()) + " EU");
}
- }
- else {
- if (this.mFluid != null && this.mFluid2 != null) {
- final int tFuelValue = this.getFuelValue(this.mFluid),
- tConsumed = this.consumedFluidPerOperation(this.mFluid);
- final int tFuelValue2 = this.getFuelValue(this.mFluid2),
- tConsumed2 = this.consumedFluidPerOperation(this.mFluid2);
- if (tFuelValue > 0 && tConsumed > 0
- && this.mFluid.amount > tConsumed/*
- * && (tFuelValue2
- * > 0 &&
- * tConsumed2 >
- * 0 && mFluid2.
- * amount >
- * tConsumed2)
- */) {
-
- Utils.LOG_WARNING("tFuelValue: " + tFuelValue);
- Utils.LOG_WARNING("tConsumed: " + tConsumed);
- Utils.LOG_WARNING("mFluid.name: " + this.mFluid.getFluid().getName());
- Utils.LOG_WARNING("mFluid.amount: " + this.mFluid.amount);
- Utils.LOG_WARNING("mFluid.amount > tConsumed: " + (this.mFluid.amount > tConsumed));
+ } else {
+ if (mFluid != null && mFluid2 != null){
+ int tFuelValue = getFuelValue(mFluid), tConsumed = consumedFluidPerOperation(mFluid);
+ int tFuelValue2 = getFuelValue(mFluid2), tConsumed2 = consumedFluidPerOperation(mFluid2);
+ if ((tFuelValue > 0 && tConsumed > 0 && mFluid.amount > tConsumed)/* && (tFuelValue2 > 0 && tConsumed2 > 0 && mFluid2.amount > tConsumed2)*/) {
+
+ Utils.LOG_WARNING("tFuelValue: "+tFuelValue);
+ Utils.LOG_WARNING("tConsumed: "+tConsumed);
+ Utils.LOG_WARNING("mFluid.name: "+mFluid.getFluid().getName());
+ Utils.LOG_WARNING("mFluid.amount: "+mFluid.amount);
+ Utils.LOG_WARNING("mFluid.amount > tConsumed: "+(mFluid.amount > tConsumed));
Utils.LOG_WARNING("=========================================================");
- Utils.LOG_WARNING("tFuelValue2: " + tFuelValue2);
- Utils.LOG_WARNING("tConsumed2: " + tConsumed2);
- Utils.LOG_WARNING("mFluid2.name: " + this.mFluid2.getFluid().getName());
- Utils.LOG_WARNING("mFluid2.amount: " + this.mFluid2.amount);
- Utils.LOG_WARNING("mFluid2.amount > tConsumed2: " + (this.mFluid2.amount > tConsumed2));
- long tFluidAmountToUse = Math.min(this.mFluid.amount / tConsumed,
- (this.maxEUOutput() * 30 + this.getMinimumStoredEU()
- - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue);
- long tFluidAmountToUse2 = Math.min(this.mFluid2.amount / tConsumed2,
- (this.maxEUOutput() * 30 + this.getMinimumStoredEU()
- - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue2);
-
- if (tFluidAmountToUse <= 0) {
- /*
- * if ((mFluid.amount / tConsumed) ==
- * getCapacity()){ tFluidAmountToUse = 1; }
- */
-
- if (aBaseMetaTileEntity.getUniversalEnergyStored() <= aBaseMetaTileEntity.getEUCapacity()
- - aBaseMetaTileEntity.getUniversalEnergyStored()) {
+ Utils.LOG_WARNING("tFuelValue2: "+tFuelValue2);
+ Utils.LOG_WARNING("tConsumed2: "+tConsumed2);
+ Utils.LOG_WARNING("mFluid2.name: "+mFluid2.getFluid().getName());
+ Utils.LOG_WARNING("mFluid2.amount: "+mFluid2.amount);
+ Utils.LOG_WARNING("mFluid2.amount > tConsumed2: "+(mFluid2.amount > tConsumed2));
+ long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue);
+ long tFluidAmountToUse2 = Math.min(mFluid2.amount / tConsumed2, (maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue2);
+
+ if (tFluidAmountToUse <= 0){
+ /*if ((mFluid.amount / tConsumed) == getCapacity()){
+ tFluidAmountToUse = 1;
+ }*/
+
+ if (aBaseMetaTileEntity.getUniversalEnergyStored() <= (aBaseMetaTileEntity.getEUCapacity()-aBaseMetaTileEntity.getUniversalEnergyStored())){
tFluidAmountToUse = 1;
Utils.LOG_WARNING("=========================================================");
- Utils.LOG_WARNING("tFluidAmountToUse - Updated: " + tFluidAmountToUse);
+ Utils.LOG_WARNING("tFluidAmountToUse - Updated: "+tFluidAmountToUse);
Utils.LOG_WARNING("=========================================================");
}
}
-
- if (tFluidAmountToUse2 <= 0) {
- /*
- * if ((mFluid2.amount / tConsumed) ==
- * getCapacity()){ tFluidAmountToUse2 = 1; }
- */
- if (aBaseMetaTileEntity.getUniversalEnergyStored() <= aBaseMetaTileEntity.getEUCapacity()
- - aBaseMetaTileEntity.getUniversalEnergyStored()) {
+
+ if (tFluidAmountToUse2 <= 0){
+ /*if ((mFluid2.amount / tConsumed) == getCapacity()){
+ tFluidAmountToUse2 = 1;
+ }*/
+ if (aBaseMetaTileEntity.getUniversalEnergyStored() <= (aBaseMetaTileEntity.getEUCapacity()-aBaseMetaTileEntity.getUniversalEnergyStored())){
tFluidAmountToUse2 = 1;
Utils.LOG_WARNING("=========================================================");
- Utils.LOG_WARNING("tFluidAmountToUse2 - Updated: " + tFluidAmountToUse2);
+ Utils.LOG_WARNING("tFluidAmountToUse2 - Updated: "+tFluidAmountToUse2);
Utils.LOG_WARNING("=========================================================");
}
}
-
+
Utils.LOG_WARNING("=========================================================");
- Utils.LOG_WARNING("tFluidAmountToUse: " + tFluidAmountToUse);
+ Utils.LOG_WARNING("tFluidAmountToUse: "+tFluidAmountToUse);
Utils.LOG_WARNING("=========================================================");
- /*
- * Utils.LOG_WARNING("mFluid.amount / tConsumed: "
- * +("fluidAmount:"+mFluid.amount)+(" tConsumed:"
- * +tConsumed)+" | "+(mFluid.amount / tConsumed));
- * Utils.LOG_WARNING(
- * "maxEUOutput() * 20 + getMinimumStoredEU(): "
- * +(maxEUOutput() * 30 + getMinimumStoredEU()));
- * Utils.LOG_WARNING("maxEUOutput(): "+maxEUOutput());
- * Utils.LOG_WARNING("maxEUOutput() * 20: "
- * +(maxEUOutput() * 30)); Utils.LOG_WARNING(
- * "getMinimumStoredEU(): "+(getMinimumStoredEU()));
- * Utils.LOG_WARNING(
- * "aBaseMetaTileEntity.getUniversalEnergyStored(): "
- * +(aBaseMetaTileEntity.getUniversalEnergyStored()));
- * Utils.LOG_WARNING(
- * "(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()): "
- * +((maxEUOutput() * 30 + getMinimumStoredEU() -
- * aBaseMetaTileEntity.getUniversalEnergyStored())));
- * Utils.LOG_WARNING("tFuelValue: "+(tFuelValue));
- * Utils.LOG_WARNING(
- * "(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue): "
- * +((maxEUOutput() * 30 + getMinimumStoredEU() -
- * aBaseMetaTileEntity.getUniversalEnergyStored()) /
- * tFuelValue));
- */
-
+ /*Utils.LOG_WARNING("mFluid.amount / tConsumed: "+("fluidAmount:"+mFluid.amount)+(" tConsumed:"+tConsumed)+" | "+(mFluid.amount / tConsumed));
+ Utils.LOG_WARNING("maxEUOutput() * 20 + getMinimumStoredEU(): "+(maxEUOutput() * 30 + getMinimumStoredEU()));
+ Utils.LOG_WARNING("maxEUOutput(): "+maxEUOutput());
+ Utils.LOG_WARNING("maxEUOutput() * 20: "+(maxEUOutput() * 30));
+ Utils.LOG_WARNING("getMinimumStoredEU(): "+(getMinimumStoredEU()));
+ Utils.LOG_WARNING("aBaseMetaTileEntity.getUniversalEnergyStored(): "+(aBaseMetaTileEntity.getUniversalEnergyStored()));
+ Utils.LOG_WARNING("(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()): "+((maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored())));
+ Utils.LOG_WARNING("tFuelValue: "+(tFuelValue));
+ Utils.LOG_WARNING("(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue): "+((maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue));
+ */
+
Utils.LOG_WARNING("=========================================================");
- Utils.LOG_WARNING("tFluidAmountToUse2: " + tFluidAmountToUse2);
+ Utils.LOG_WARNING("tFluidAmountToUse2: "+tFluidAmountToUse2);
Utils.LOG_WARNING("=========================================================");
- /*
- * Utils.LOG_WARNING("mFluid2.amount / tConsumed2: "
- * +("fluidAmount2:"+mFluid2.amount)+(" tConsumed2:"
- * +tConsumed2)+" | "+(mFluid2.amount / tConsumed2));
- * Utils.LOG_WARNING(
- * "maxEUOutput() * 20 + getMinimumStoredEU(): "
- * +(maxEUOutput() * 30 + getMinimumStoredEU()));
- * Utils.LOG_WARNING("maxEUOutput(): "+maxEUOutput());
- * Utils.LOG_WARNING("maxEUOutput() * 20: "
- * +(maxEUOutput() * 30)); Utils.LOG_WARNING(
- * "getMinimumStoredEU(): "+(getMinimumStoredEU()));
- * Utils.LOG_WARNING(
- * "aBaseMetaTileEntity.getUniversalEnergyStored(): "
- * +(aBaseMetaTileEntity.getUniversalEnergyStored()));
- * Utils.LOG_WARNING(
- * "(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()): "
- * +((maxEUOutput() * 30 + getMinimumStoredEU() -
- * aBaseMetaTileEntity.getUniversalEnergyStored())));
- * Utils.LOG_WARNING("tFuelValue2: "+(tFuelValue2));
- * Utils.LOG_WARNING(
- * "(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue2): "
- * +((maxEUOutput() * 30 + getMinimumStoredEU() -
- * aBaseMetaTileEntity.getUniversalEnergyStored()) /
- * tFuelValue2));
- */
- if (tFluidAmountToUse > 0
- && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)
- && tFluidAmountToUse2 > 0 && aBaseMetaTileEntity
- .increaseStoredEnergyUnits(tFluidAmountToUse2 * tFuelValue2, true)) {
-
- Utils.LOG_WARNING("tFuelValue: " + tFuelValue);
- Utils.LOG_WARNING("tConsumed: " + tConsumed);
- Utils.LOG_WARNING("mFluid.name: " + this.mFluid.getFluid().getName());
- Utils.LOG_WARNING("mFluid.amount: " + this.mFluid.amount);
- Utils.LOG_WARNING("mFluid.amount > tConsumed: " + (this.mFluid.amount > tConsumed));
+ /*Utils.LOG_WARNING("mFluid2.amount / tConsumed2: "+("fluidAmount2:"+mFluid2.amount)+(" tConsumed2:"+tConsumed2)+" | "+(mFluid2.amount / tConsumed2));
+ Utils.LOG_WARNING("maxEUOutput() * 20 + getMinimumStoredEU(): "+(maxEUOutput() * 30 + getMinimumStoredEU()));
+ Utils.LOG_WARNING("maxEUOutput(): "+maxEUOutput());
+ Utils.LOG_WARNING("maxEUOutput() * 20: "+(maxEUOutput() * 30));
+ Utils.LOG_WARNING("getMinimumStoredEU(): "+(getMinimumStoredEU()));
+ Utils.LOG_WARNING("aBaseMetaTileEntity.getUniversalEnergyStored(): "+(aBaseMetaTileEntity.getUniversalEnergyStored()));
+ Utils.LOG_WARNING("(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()): "+((maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored())));
+ Utils.LOG_WARNING("tFuelValue2: "+(tFuelValue2));
+ Utils.LOG_WARNING("(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue2): "+((maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue2));
+ */
+ if ((tFluidAmountToUse > 0 && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)) && (tFluidAmountToUse2 > 0 && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse2 * tFuelValue2, true))){
+
+ Utils.LOG_WARNING("tFuelValue: "+tFuelValue);
+ Utils.LOG_WARNING("tConsumed: "+tConsumed);
+ Utils.LOG_WARNING("mFluid.name: "+mFluid.getFluid().getName());
+ Utils.LOG_WARNING("mFluid.amount: "+mFluid.amount);
+ Utils.LOG_WARNING("mFluid.amount > tConsumed: "+(mFluid.amount > tConsumed));
Utils.LOG_WARNING("=========================================================");
- Utils.LOG_WARNING("tFuelValue2: " + tFuelValue2);
- Utils.LOG_WARNING("tConsumed2: " + tConsumed2);
- Utils.LOG_WARNING("mFluid2.name: " + this.mFluid2.getFluid().getName());
- Utils.LOG_WARNING("mFluid2.amount: " + this.mFluid2.amount);
- Utils.LOG_WARNING("mFluid2.amount > tConsumed2: " + (this.mFluid2.amount > tConsumed2));
+ Utils.LOG_WARNING("tFuelValue2: "+tFuelValue2);
+ Utils.LOG_WARNING("tConsumed2: "+tConsumed2);
+ Utils.LOG_WARNING("mFluid2.name: "+mFluid2.getFluid().getName());
+ Utils.LOG_WARNING("mFluid2.amount: "+mFluid2.amount);
+ Utils.LOG_WARNING("mFluid2.amount > tConsumed2: "+(mFluid2.amount > tConsumed2));
- if (this.useFuel) {
- this.mFluid.amount -= tFluidAmountToUse * tConsumed;
- this.mFluid2.amount -= tFluidAmountToUse2 * tConsumed2;
- this.useFuel = false;
+ if (useFuel){
+ mFluid.amount -= tFluidAmountToUse * tConsumed;
+ mFluid2.amount -= tFluidAmountToUse2 * tConsumed2;
+ useFuel = false;
}
else {
- this.useFuel = true;
+ useFuel = true;
}
}
else {
Utils.LOG_WARNING("=========================================================");
- Utils.LOG_WARNING(
- "Either tFluidAmountToUse1 <= 0, power cannot be increased of tFluidAmountToUse2 <= 0");
- Utils.LOG_WARNING("tFluidAmountToUse1: " + tFluidAmountToUse);
- Utils.LOG_WARNING("tFluidAmountToUse2: " + tFluidAmountToUse2);
+ Utils.LOG_WARNING("Either tFluidAmountToUse1 <= 0, power cannot be increased of tFluidAmountToUse2 <= 0");
+ Utils.LOG_WARNING("tFluidAmountToUse1: "+tFluidAmountToUse);
+ Utils.LOG_WARNING("tFluidAmountToUse2: "+tFluidAmountToUse2);
}
}
else {
- /*
- * Utils.LOG_WARNING(
- * "(tFuelValue > 0 && tConsumed > 0 && mFluid.amount > tConsumed) && (tFuelValue2 > 0 && tConsumed2 > 0 && mFluid2.amount > tConsumed2)"
- * ); Utils.LOG_WARNING("tFuelValue: "+tFuelValue);
- * Utils.LOG_WARNING("tConsumed: "+tConsumed);
- * Utils.LOG_WARNING("mFluid.amount: "+mFluid.amount);
- * Utils.LOG_WARNING("mFluid.amount > tConsumed: "
- * +(mFluid.amount > tConsumed));
- *
- * Utils.LOG_WARNING(
- * "========================================================="
- * );
- *
- * Utils.LOG_WARNING("tFuelValue2: "+tFuelValue2);
- * Utils.LOG_WARNING("tConsumed2: "+tConsumed2);
- * Utils.LOG_WARNING("mFluid2.amount: "+mFluid2.amount);
- * Utils.LOG_WARNING("mFluid2.amount > tConsumed2: "
- * +(mFluid2.amount > tConsumed2));
- */
+ /*Utils.LOG_WARNING("(tFuelValue > 0 && tConsumed > 0 && mFluid.amount > tConsumed) && (tFuelValue2 > 0 && tConsumed2 > 0 && mFluid2.amount > tConsumed2)");
+ Utils.LOG_WARNING("tFuelValue: "+tFuelValue);
+ Utils.LOG_WARNING("tConsumed: "+tConsumed);
+ Utils.LOG_WARNING("mFluid.amount: "+mFluid.amount);
+ Utils.LOG_WARNING("mFluid.amount > tConsumed: "+(mFluid.amount > tConsumed));
+
+ Utils.LOG_WARNING("=========================================================");
+
+ Utils.LOG_WARNING("tFuelValue2: "+tFuelValue2);
+ Utils.LOG_WARNING("tConsumed2: "+tConsumed2);
+ Utils.LOG_WARNING("mFluid2.amount: "+mFluid2.amount);
+ Utils.LOG_WARNING("mFluid2.amount > tConsumed2: "+(mFluid2.amount > tConsumed2)); */
}
- }
+ }
else {
Utils.LOG_WARNING("One mFluid is null");
- if (this.mFluid != null) {
+ if (mFluid != null)
Utils.LOG_WARNING("mFluid1 is not null");
- }
- if (this.mFluid2 != null) {
+ if (mFluid2 != null)
Utils.LOG_WARNING("mFluid2 is not null");
- }
}
}
- if (this.mInventory[this.getInputSlot()] != null
- && aBaseMetaTileEntity.getUniversalEnergyStored() < this.maxEUOutput() * 20
- + this.getMinimumStoredEU()
- && GT_Utility.getFluidForFilledItem(this.mInventory[this.getInputSlot()], true) == null) {
- final int tFuelValue = this.getFuelValue(this.mInventory[this.getInputSlot()]);
+ if (mInventory[getInputSlot()] != null && aBaseMetaTileEntity.getUniversalEnergyStored() < (maxEUOutput() * 20 + getMinimumStoredEU()) && GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true) == null) {
+ int tFuelValue = getFuelValue(mInventory[getInputSlot()]);
if (tFuelValue > 0) {
- final ItemStack tEmptyContainer = this.getEmptyContainer(this.mInventory[this.getInputSlot()]);
- if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), tEmptyContainer)) {
+ ItemStack tEmptyContainer = getEmptyContainer(mInventory[getInputSlot()]);
+ if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tEmptyContainer)) {
aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true);
- aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1);
+ aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1);
}
}
}
}
- if (aBaseMetaTileEntity.isServerSide()) {
- aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity
- .getUniversalEnergyStored() >= this.maxEUOutput() + this.getMinimumStoredEU());
- }
+ if (aBaseMetaTileEntity.isServerSide())
+ aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.getUniversalEnergyStored() >= maxEUOutput() + getMinimumStoredEU());
+ }
+
+ public abstract GT_Recipe_Map getRecipes();
+
+ public abstract int getEfficiency();
+
+ public int consumedFluidPerOperation(FluidStack aLiquid) {
+ return 1;
+ }
+
+ public int getFuelValue(FluidStack aLiquid) {
+ if (aLiquid == null || getRecipes() == null) return 0;
+ FluidStack tLiquid;
+ Collection<GT_Recipe> tRecipeList = getRecipes().mRecipeList;
+ if (tRecipeList != null) for (GT_Recipe tFuel : tRecipeList)
+ if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null)
+ if (aLiquid.isFluidEqual(tLiquid))
+ return (int) (((long) tFuel.mSpecialValue * getEfficiency() * consumedFluidPerOperation(tLiquid)) / 100);
+ return 0;
+ }
+
+ public int getFuelValue(ItemStack aStack) {
+ if (GT_Utility.isStackInvalid(aStack) || getRecipes() == null) return 0;
+ GT_Recipe tFuel = getRecipes().findRecipe(getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack);
+ if (tFuel != null) return (int) ((tFuel.mSpecialValue * 1000L * getEfficiency()) / 100);
+ return 0;
+ }
+
+ public ItemStack getEmptyContainer(ItemStack aStack) {
+ if (GT_Utility.isStackInvalid(aStack) || getRecipes() == null) return null;
+ GT_Recipe tFuel = getRecipes().findRecipe(getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack);
+ if (tFuel != null) return GT_Utility.copy(tFuel.getOutput(0));
+ return GT_Utility.getContainerItem(aStack, true);
}
@Override
- public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) {
- if (aBaseMetaTileEntity.isClientSide()) {
- Utils.LOG_WARNING("Entity is Client side, simply returning true");
- return true;
- }
- Utils.LOG_WARNING(
- "Entity is not Client side, opening entity Container and by extension, it's GUI, then returning true");
- aBaseMetaTileEntity.openGUI(aPlayer);
- return true;
+ public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && (getFuelValue(aStack) > 0 || getFuelValue(GT_Utility.getFluidForFilledItem(aStack, true)) > 0);
+ }
+
+ @Override
+ public int getCapacity() {
+ return 32000;
+ }
+
+ @Override
+ public int getTankPressure() {
+ return -100;
}
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechMetaBoilerBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechMetaBoilerBase.java
index 8e7679f770..ac27c32360 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechMetaBoilerBase.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechMetaBoilerBase.java
@@ -7,7 +7,9 @@ import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank;
import gregtech.api.objects.GT_ItemStack;
-import gregtech.api.util.*;
+import gregtech.api.util.GT_ModHandler;
+import gregtech.api.util.GT_OreDictUnificator;
+import gregtech.api.util.GT_Utility;
import gtPlusPlus.core.util.math.MathUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
@@ -17,319 +19,310 @@ import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidHandler;
-public abstract class GregtechMetaBoilerBase extends GT_MetaTileEntity_BasicTank {
- public int mTemperature = 20;
- public int mProcessingEnergy = 0;
- public int mLossTimer = 0;
- public FluidStack mSteam = null;
- public boolean mHadNoWater = false;
- public long RI = MathUtils.randLong(5L, 30L);
-
- public GregtechMetaBoilerBase(final int aID, final String aName, final String aNameRegional,
- final String aDescription, final ITexture... aTextures) {
- super(aID, aName, aNameRegional, 0, 4, aDescription, aTextures);
- }
-
- public GregtechMetaBoilerBase(final String aName, final int aTier, final String aDescription,
- final ITexture[][][] aTextures) {
- super(aName, aTier, 4, aDescription, aTextures);
- }
-
- @Override
- public boolean allowCoverOnSide(final byte aSide, final GT_ItemStack aCover) {
- return GregTech_API.getCoverBehavior(aCover.toStack()).isSimpleCover();
- }
-
- @Override
- public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide,
- final ItemStack aStack) {
- return aIndex == 1 || aIndex == 3;
- }
-
- @Override
- public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide,
- final ItemStack aStack) {
- return aIndex == 2;
- }
-
- @Override
- public boolean canTankBeEmptied() {
- return true;
- }
-
- @Override
- public boolean canTankBeFilled() {
- return true;
- }
-
- @Override
- public boolean displaysItemStack() {
- return false;
- }
-
- @Override
- public boolean displaysStackSize() {
- return false;
- }
-
- @Override
- public boolean doesEmptyContainers() {
- return true;
- }
-
- @Override
- public boolean doesFillContainers() {
- return true;
- }
-
- @Override
- public void doSound(final byte aIndex, final double aX, final double aY, final double aZ) {
- if (aIndex == 1) {
- GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(Integer.valueOf(4)), 2, 1.0F, aX, aY, aZ);
- for (int l = 0; l < 8; l++) {
- this.getBaseMetaTileEntity().getWorld().spawnParticle("largesmoke", aX - 0.5D + Math.random(), aY,
- aZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D);
- }
- }
- }
-
- @Override
- public int getCapacity() {
- return 16000;
- }
-
- @Override
- public FluidStack getDrainableStack() {
- return this.mSteam;
- }
-
- @Override
- public int getProgresstime() {
- return this.mTemperature;
- }
-
- @Override
- public int getTankPressure() {
- return 100;
- }
-
- @Override
- public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing,
- final byte aColorIndex, final boolean aActive, final boolean aRedstone) {
- ITexture[] tmp = this.mTextures[aSide >= 2 ? aSide != aFacing ? 2 : (byte) (aActive ? 4 : 3)
- : aSide][aColorIndex + 1];
- // mTextures[(aSide==aFacing?(aActive?4:3):aSide==GT_Utility.getOppositeSide(aFacing)?2:aSide==0?0:aSide==1?1:2)][aColorIndex+1];
- if (aSide != aFacing && tmp.length == 2) {
- tmp = new ITexture[] {
- tmp[0]
- };
- }
- return tmp;
- }
-
- @Override
- public boolean isAccessAllowed(final EntityPlayer aPlayer) {
- return true;
- }
-
- @Override
- public boolean isElectric() {
- return false;
- }
-
- @Override
- public boolean isFacingValid(final byte aFacing) {
- return aFacing > 1;
- }
-
- @Override
- public boolean isFluidInputAllowed(final FluidStack aFluid) {
- return GT_ModHandler.isWater(aFluid);
- }
-
- @Override
- public boolean isPneumatic() {
- return false;
- }
-
- @Override
- public boolean isSimpleMachine() {
- return false;
- }
-
- @Override
- public boolean isSteampowered() {
- return false;
- }
-
- @Override
- public boolean isValidSlot(final int aIndex) {
- return true;
- }
-
- @Override
- public void loadNBTData(final NBTTagCompound aNBT) {
- super.loadNBTData(aNBT);
- this.mLossTimer = aNBT.getInteger("mLossTimer");
- this.mTemperature = aNBT.getInteger("mTemperature");
- this.mProcessingEnergy = aNBT.getInteger("mProcessingEnergy");
- this.mSteam = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mSteam"));
- }
-
- @Override
- public int maxProgresstime() {
- return 500;
- }
-
- @Override
- public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) {
- if (aBaseMetaTileEntity.isServerSide() && aTick > 20L) {
- if (this.mTemperature <= 20) {
- this.mTemperature = 20;
- this.mLossTimer = 0;
- }
- if (++this.mLossTimer > 40) {
- 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 > 100) {
- 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(150L);
- }
- else if (GT_ModHandler.isSteam(this.mSteam)) {
- this.mSteam.amount += 150;
- }
- else {
- this.mSteam = GT_ModHandler.getSteam(150L);
- }
- }
- }
- 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() && this.mInventory[2] != null) {
- if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.gem.get(Materials.Coal))
- || GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2],
- OrePrefixes.dust.get(Materials.Coal))
- || GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2],
- OrePrefixes.dustImpure.get(Materials.Coal))
- || GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2],
- OrePrefixes.crushed.get(Materials.Coal))) {
- this.mProcessingEnergy += 160;
- aBaseMetaTileEntity.decrStackSize(2, 1);
- if (aBaseMetaTileEntity.getRandomNumber(3) == 0) {
- aBaseMetaTileEntity.addStackToSlot(3,
- GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 1L));
- }
- }
- else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2],
- OrePrefixes.gem.get(Materials.Charcoal))) {
- this.mProcessingEnergy += 160;
- aBaseMetaTileEntity.decrStackSize(2, 1);
- if (aBaseMetaTileEntity.getRandomNumber(3) == 0) {
- aBaseMetaTileEntity.addStackToSlot(3,
- GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 1L));
- }
- }
- else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], "fuelCoke")) {
- this.mProcessingEnergy += 640;
- aBaseMetaTileEntity.decrStackSize(2, 1);
- if (aBaseMetaTileEntity.getRandomNumber(2) == 0) {
- aBaseMetaTileEntity.addStackToSlot(3,
- GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 1L));
- }
- }
- else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2],
- OrePrefixes.gem.get(Materials.Lignite))
- || GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2],
- OrePrefixes.dust.get(Materials.Lignite))
- || GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2],
- OrePrefixes.dustImpure.get(Materials.Lignite))
- || GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2],
- OrePrefixes.crushed.get(Materials.Lignite))) {
- this.mProcessingEnergy += 40;
- aBaseMetaTileEntity.decrStackSize(2, 1);
- if (aBaseMetaTileEntity.getRandomNumber(8) == 0) {
- aBaseMetaTileEntity.addStackToSlot(3,
- GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 1L));
- }
- }
- }
- if (this.mTemperature < 1000 && this.mProcessingEnergy > 0 && aTick % 12L == 0L) {
- this.mProcessingEnergy -= 2;
- this.mTemperature += 1;
- }
- aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0);
- }
- }
-
- @Override
- public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) {
- if (aBaseMetaTileEntity.isClientSide()) {
- return true;
- }
- if (aPlayer != null) {
- if (GT_Utility.areStacksEqual(aPlayer.getCurrentEquippedItem(), new ItemStack(Items.water_bucket, 1))) {
- this.fill(Materials.Water.getFluid(1000 * aPlayer.getCurrentEquippedItem().stackSize), true);
- aPlayer.getCurrentEquippedItem().func_150996_a(Items.bucket);
- }
- else {
- aBaseMetaTileEntity.openGUI(aPlayer);
- }
- }
- return true;
- }
-
- @Override
- public void saveNBTData(final NBTTagCompound aNBT) {
- super.saveNBTData(aNBT);
- aNBT.setInteger("mLossTimer", this.mLossTimer);
- aNBT.setInteger("mTemperature", this.mTemperature);
- aNBT.setInteger("mProcessingEnergy", this.mProcessingEnergy);
- if (this.mSteam != null) {
- try {
- aNBT.setTag("mSteam", this.mSteam.writeToNBT(new NBTTagCompound()));
- }
- catch (final Throwable e) {
- }
- }
- }
-
- @Override
- public FluidStack setDrainableStack(final FluidStack aFluid) {
- this.mSteam = aFluid;
- return this.mSteam;
- }
+public abstract class GregtechMetaBoilerBase extends GT_MetaTileEntity_BasicTank
+{
+ public int mTemperature = 20;
+ public int mProcessingEnergy = 0;
+ public int mLossTimer = 0;
+ public FluidStack mSteam = null;
+ public boolean mHadNoWater = false;
+ public long RI = MathUtils.randLong(5L, 30L);
+
+ public GregtechMetaBoilerBase(int aID, String aName, String aNameRegional, String aDescription, ITexture... aTextures)
+ {
+ super(aID, aName, aNameRegional, 0, 4, aDescription, aTextures);
+ }
+
+ public GregtechMetaBoilerBase(String aName, int aTier, String aDescription, ITexture[][][] aTextures)
+ {
+ super(aName, aTier, 4, aDescription, aTextures);
+ }
+
+ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone)
+ {
+ ITexture[] tmp = mTextures[aSide >= 2 ? aSide != aFacing ? 2 : ((byte)(aActive ? 4 : 3)) : aSide][aColorIndex + 1];
+ //mTextures[(aSide==aFacing?(aActive?4:3):aSide==GT_Utility.getOppositeSide(aFacing)?2:aSide==0?0:aSide==1?1:2)][aColorIndex+1];
+ if(aSide!=aFacing&&tmp.length==2){
+ tmp = new ITexture[]{tmp[0]};
+ }
+ return tmp;
+ }
+
+ public boolean isElectric()
+ {
+ return false;
+ }
+
+ public boolean isPneumatic()
+ {
+ return false;
+ }
+
+ public boolean isSteampowered()
+ {
+ return false;
+ }
+
+ public boolean isSimpleMachine()
+ {
+ return false;
+ }
+
+ public boolean isFacingValid(byte aFacing)
+ {
+ return aFacing > 1;
+ }
+
+ public boolean isAccessAllowed(EntityPlayer aPlayer)
+ {
+ return true;
+ }
+
+ public boolean isValidSlot(int aIndex)
+ {
+ return true;
+ }
+
+ public int getProgresstime()
+ {
+ return this.mTemperature;
+ }
+
+ public int maxProgresstime()
+ {
+ return 500;
+ }
+
+ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer)
+ {
+ if (aBaseMetaTileEntity.isClientSide()) {
+ return true;
+ }
+ if (aPlayer != null) {
+ if (GT_Utility.areStacksEqual(aPlayer.getCurrentEquippedItem(), new ItemStack(Items.water_bucket, 1)))
+ {
+ fill(Materials.Water.getFluid(1000 * aPlayer.getCurrentEquippedItem().stackSize), true);
+ aPlayer.getCurrentEquippedItem().func_150996_a(Items.bucket);
+ }
+ else
+ {
+ aBaseMetaTileEntity.openGUI(aPlayer);
+ }
+ }
+ return true;
+ }
+
+ public boolean doesFillContainers()
+ {
+ return true;
+ }
+
+ public boolean doesEmptyContainers()
+ {
+ return true;
+ }
+
+ public boolean canTankBeFilled()
+ {
+ return true;
+ }
+
+ public boolean canTankBeEmptied()
+ {
+ return true;
+ }
+
+ public boolean displaysItemStack()
+ {
+ return false;
+ }
+
+ public boolean displaysStackSize()
+ {
+ return false;
+ }
+
+ public boolean isFluidInputAllowed(FluidStack aFluid)
+ {
+ return GT_ModHandler.isWater(aFluid);
+ }
+
+ public FluidStack getDrainableStack()
+ {
+ return this.mSteam;
+ }
+
+ public FluidStack setDrainableStack(FluidStack aFluid)
+ {
+ this.mSteam = aFluid;return this.mSteam;
+ }
+
+ public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCover)
+ {
+ return GregTech_API.getCoverBehavior(aCover.toStack()).isSimpleCover();
+ }
+
+ public void saveNBTData(NBTTagCompound aNBT)
+ {
+ super.saveNBTData(aNBT);
+ aNBT.setInteger("mLossTimer", this.mLossTimer);
+ aNBT.setInteger("mTemperature", this.mTemperature);
+ aNBT.setInteger("mProcessingEnergy", this.mProcessingEnergy);
+ if (this.mSteam != null) {
+ try
+ {
+ aNBT.setTag("mSteam", this.mSteam.writeToNBT(new NBTTagCompound()));
+ }
+ catch (Throwable e) {}
+ }
+ }
+
+ public void loadNBTData(NBTTagCompound aNBT)
+ {
+ super.loadNBTData(aNBT);
+ this.mLossTimer = aNBT.getInteger("mLossTimer");
+ this.mTemperature = aNBT.getInteger("mTemperature");
+ this.mProcessingEnergy = aNBT.getInteger("mProcessingEnergy");
+ this.mSteam = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mSteam"));
+ }
+
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick)
+ {
+ if ((aBaseMetaTileEntity.isServerSide()) && (aTick > 20L))
+ {
+ if (this.mTemperature <= 20)
+ {
+ this.mTemperature = 20;
+ this.mLossTimer = 0;
+ }
+ if (++this.mLossTimer > 40)
+ {
+ 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 > 100)
+ {
+ 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(150L);
+ } else if (GT_ModHandler.isSteam(this.mSteam)) {
+ this.mSteam.amount += 150;
+ } else {
+ this.mSteam = GT_ModHandler.getSteam(150L);
+ }
+ }
+ }
+ 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()) &&
+ (this.mInventory[2] != null)) {
+ if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.gem.get(Materials.Coal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dust.get(Materials.Coal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dustImpure.get(Materials.Coal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.crushed.get(Materials.Coal))))
+ {
+ this.mProcessingEnergy += 160;
+ aBaseMetaTileEntity.decrStackSize(2, 1);
+ if (aBaseMetaTileEntity.getRandomNumber(3) == 0) {
+ aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 1L));
+ }
+ }
+ else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.gem.get(Materials.Charcoal)))
+ {
+ this.mProcessingEnergy += 160;
+ aBaseMetaTileEntity.decrStackSize(2, 1);
+ if (aBaseMetaTileEntity.getRandomNumber(3) == 0) {
+ aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 1L));
+ }
+ }
+ else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], "fuelCoke"))
+ {
+ this.mProcessingEnergy += 640;
+ aBaseMetaTileEntity.decrStackSize(2, 1);
+ if (aBaseMetaTileEntity.getRandomNumber(2) == 0) {
+ aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 1L));
+ }
+ }
+ else if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.gem.get(Materials.Lignite))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dust.get(Materials.Lignite))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dustImpure.get(Materials.Lignite))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.crushed.get(Materials.Lignite))))
+ {
+ this.mProcessingEnergy += 40;
+ aBaseMetaTileEntity.decrStackSize(2, 1);
+ if (aBaseMetaTileEntity.getRandomNumber(8) == 0) {
+ aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 1L));
+ }
+ }
+ }
+ if ((this.mTemperature < 1000) && (this.mProcessingEnergy > 0) && (aTick % 12L == 0L))
+ {
+ this.mProcessingEnergy -= 2;
+ this.mTemperature += 1;
+ }
+ aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0);
+ }
+ }
+
+ public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack)
+ {
+ return (aIndex == 1) || (aIndex == 3);
+ }
+
+ public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack)
+ {
+ return aIndex == 2;
+ }
+
+ public void doSound(byte aIndex, double aX, double aY, double aZ)
+ {
+ if (aIndex == 1)
+ {
+ GT_Utility.doSoundAtClient((String)GregTech_API.sSoundList.get(Integer.valueOf(4)), 2, 1.0F, aX, aY, aZ);
+ for (int l = 0; l < 8; l++) {
+ getBaseMetaTileEntity().getWorld().spawnParticle("largesmoke", aX - 0.5D + Math.random(), aY, aZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D);
+ }
+ }
+ }
+
+ public int getCapacity()
+ {
+ return 16000;
+ }
+
+ public int getTankPressure()
+ {
+ return 100;
+ }
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechMetaSolarGenerator.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechMetaSolarGenerator.java
index 85ee75a4e4..e43b7db9aa 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechMetaSolarGenerator.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechMetaSolarGenerator.java
@@ -1,6 +1,6 @@
package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators;
-import gregtech.api.enums.GT_Values;
+import static gregtech.api.enums.GT_Values.V;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
@@ -9,183 +9,140 @@ import gregtech.api.util.GT_Utility;
import net.minecraft.entity.player.EntityPlayer;
public abstract class GregtechMetaSolarGenerator extends GT_MetaTileEntity_BasicTank {
-
- public static int sEnergyPerTick = 16;
- public int mEfficiency;
- public int mProcessingEnergy = 0;
- public int mSolarCharge = 20;
- public int mLossTimer = 0;
-
- public GregtechMetaSolarGenerator(final int aID, final String aName, final String aNameRegional, final int aTier,
- final String aDescription, final ITexture... aTextures) {
- super(aID, aName, aNameRegional, aTier, 3, aDescription, aTextures);
- }
-
- public GregtechMetaSolarGenerator(final String aName, final int aTier, final String aDescription,
- final ITexture[][][] aTextures) {
- super(aName, aTier, 3, aDescription, aTextures);
- }
-
- @Override
- public boolean canTankBeEmptied() {
- return false;
- }
-
- @Override
- public boolean canTankBeFilled() {
- return false;
- }
-
- @Override
- public boolean displaysItemStack() {
- return false;
- }
-
- @Override
- public boolean displaysStackSize() {
- return false;
- }
-
- @Override
- public boolean doesEmptyContainers() {
- return false;
- }
-
- @Override
- public boolean doesFillContainers() {
- return false;
- }
-
- public ITexture[] getBack(final byte aColor) {
- return new ITexture[] {
- Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]
- };
- }
-
- public ITexture[] getBackActive(final byte aColor) {
- return this.getBack(aColor);
- }
-
- public ITexture[] getBottom(final byte aColor) {
- return new ITexture[] {
- Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]
- };
- }
-
- public ITexture[] getBottomActive(final byte aColor) {
- return this.getBottom(aColor);
- }
-
- @Override
- public String[] getDescription() {
- return new String[] {
- this.mDescription, "Efficiency: " + this.getEfficiency() + "%"
- };
- }
-
- public abstract int getEfficiency();
-
- public ITexture[] getFront(final byte aColor) {
- return new ITexture[] {
- Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]
- };
- }
-
- public ITexture[] getFrontActive(final byte aColor) {
- return this.getFront(aColor);
- }
-
- public ITexture[] getSides(final byte aColor) {
- return new ITexture[] {
- Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]
- };
- }
-
- public ITexture[] getSidesActive(final byte aColor) {
- return this.getSides(aColor);
- }
-
- @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 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;
- }
-
- public ITexture[] getTop(final byte aColor) {
- return new ITexture[] {
- Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]
- };
- }
-
- public ITexture[] getTopActive(final byte aColor) {
- return this.getTop(aColor);
- }
-
- @Override
- public boolean isAccessAllowed(final EntityPlayer aPlayer) {
- return true;
- }
-
- @Override
- public boolean isEnetOutput() {
- return true;
- }
-
- @Override
- public boolean isFacingValid(final byte aSide) {
- return aSide > 1;
- }
-
- @Override
- public boolean isOutputFacing(final byte aSide) {
- return true;
- }
-
- @Override
- public boolean isSimpleMachine() {
- return false;
- }
-
- @Override
- public boolean isValidSlot(final int aIndex) {
- return aIndex < 2;
- }
-
- @Override
- public long maxEUOutput() {
- return this.getBaseMetaTileEntity().isAllowedToWork() ? GT_Values.V[this.mTier] : 0;
- }
-
- @Override
- public long maxEUStore() {
- return Math.max(this.getEUVar(), GT_Values.V[this.mTier] * 40 + this.getMinimumStoredEU());
- }
-
- @Override
- public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) {
+
+ public int mEfficiency;
+ public int mProcessingEnergy = 0;
+ public int mSolarCharge = 20;
+ public int mLossTimer = 0;
+ public static int sEnergyPerTick = 16;
+
+ public GregtechMetaSolarGenerator(int aID, String aName, String aNameRegional, int aTier, String aDescription, ITexture... aTextures) {
+ super(aID, aName, aNameRegional, aTier, 3, aDescription, aTextures);
+ }
+
+ public GregtechMetaSolarGenerator(String aName, int aTier, String aDescription, ITexture[][][] aTextures) {
+ super(aName, aTier, 3, aDescription, aTextures);
+ }
+
+ @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];
+ }
+
+ @Override
+ public String[] getDescription() {
+ return new String[]{mDescription, "Efficiency: " + getEfficiency() + "%"};
+ }
+
+ @Override
+ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {
+ if (aBaseMetaTileEntity.isClientSide()) return true;
+ aBaseMetaTileEntity.openGUI(aPlayer);
+ return true;
+ }
+
+ public ITexture[] getFront(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]};
+ }
+
+ public ITexture[] getBack(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]};
+ }
+
+ public ITexture[] getBottom(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]};
+ }
+
+ public ITexture[] getTop(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]};
+ }
+
+ public ITexture[] getSides(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]};
+ }
+
+ public ITexture[] getFrontActive(byte aColor) {
+ return getFront(aColor);
+ }
+
+ public ITexture[] getBackActive(byte aColor) {
+ return getBack(aColor);
+ }
+
+ public ITexture[] getBottomActive(byte aColor) {
+ return getBottom(aColor);
+ }
+
+ public ITexture[] getTopActive(byte aColor) {
+ return getTop(aColor);
+ }
+
+ public ITexture[] getSidesActive(byte aColor) {
+ return getSides(aColor);
+ }
+
+ @Override
+ public boolean isFacingValid(byte aSide) {
+ return aSide > 1;
+ }
+
+ @Override
+ public boolean isSimpleMachine() {
+ return false;
+ }
+
+ @Override
+ public boolean isValidSlot(int aIndex) {
+ return aIndex < 2;
+ }
+
+ @Override
+ public boolean isEnetOutput() {
+ return true;
+ }
+
+ @Override
+ public boolean isOutputFacing(byte aSide) {
+ return true;
+ }
+
+ @Override
+ public boolean isAccessAllowed(EntityPlayer aPlayer) {
+ return true;
+ }
+
+ @Override
+ public long maxEUOutput() {
+ return getBaseMetaTileEntity().isAllowedToWork() ? V[mTier] : 0;
+ }
+
+ @Override
+ public long maxEUStore() {
+ return Math.max(getEUVar(), V[mTier] * 40 + getMinimumStoredEU());
+ }
+
+ @Override
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && aTick > 20L
- && aBaseMetaTileEntity.getUniversalEnergyStored() < this.maxEUOutput()
- + aBaseMetaTileEntity.getEUCapacity()) {
+ && aBaseMetaTileEntity.getUniversalEnergyStored() < maxEUOutput() + aBaseMetaTileEntity.getEUCapacity()) {
if (this.mSolarCharge <= 20) {
this.mSolarCharge = 20;
@@ -198,42 +155,57 @@ public abstract class GregtechMetaSolarGenerator extends GT_MetaTileEntity_Basic
if (aTick % 25L == 0L) {
if (this.mSolarCharge > 100) {
- if (this.mProcessingEnergy > 0 && aBaseMetaTileEntity.isAllowedToWork() && aTick % 256L == 0L
- && !aBaseMetaTileEntity.getWorld().isThundering() && aBaseMetaTileEntity
- .getUniversalEnergyStored() < this.maxEUOutput() * 20 + this.getMinimumStoredEU()) {
- this.getBaseMetaTileEntity().increaseStoredEnergyUnits(
- GregtechMetaSolarGenerator.sEnergyPerTick * this.getEfficiency() / 10, false);
+ if ((this.mProcessingEnergy > 0) && (aBaseMetaTileEntity.isAllowedToWork()) && (aTick % 256L == 0L) && (!aBaseMetaTileEntity.getWorld().isThundering() && aBaseMetaTileEntity.getUniversalEnergyStored() < (maxEUOutput() * 20 + getMinimumStoredEU()))) {
+ getBaseMetaTileEntity().increaseStoredEnergyUnits(sEnergyPerTick * getEfficiency() / 10, false);
}
}
- }
+ }
- if (this.mSolarCharge < 500 && this.mProcessingEnergy > 0 && aTick % 12L == 0L) {
+ if ((this.mSolarCharge < 500) && (this.mProcessingEnergy > 0) && (aTick % 12L == 0L)) {
this.mProcessingEnergy -= 1;
this.mSolarCharge += 1;
}
- if (this.mProcessingEnergy <= 0 && aBaseMetaTileEntity.isAllowedToWork() && aTick % 256L == 0L
- && !aBaseMetaTileEntity.getWorld().isThundering()) {
- final boolean bRain = aBaseMetaTileEntity.getWorld().isRaining()
- && aBaseMetaTileEntity.getBiome().rainfall > 0.0F;
- this.mProcessingEnergy += bRain && aBaseMetaTileEntity.getWorld().skylightSubtracted >= 4
- || !aBaseMetaTileEntity.getSkyAtSide((byte) 1) ? 0
- : !bRain && aBaseMetaTileEntity.getWorld().isDaytime() ? 8 : 1;
+ if ((this.mProcessingEnergy <= 0) && (aBaseMetaTileEntity.isAllowedToWork()) && (aTick % 256L == 0L) && (!aBaseMetaTileEntity.getWorld().isThundering())) {
+ boolean bRain = aBaseMetaTileEntity.getWorld().isRaining() && aBaseMetaTileEntity.getBiome().rainfall > 0.0F;
+ mProcessingEnergy += bRain && aBaseMetaTileEntity.getWorld().skylightSubtracted >= 4 || !aBaseMetaTileEntity.getSkyAtSide((byte) 1) ? 0 : !bRain && aBaseMetaTileEntity.getWorld().isDaytime() ? 8 : 1;
}
- if (aBaseMetaTileEntity.isServerSide()) {
- aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity
- .getUniversalEnergyStored() >= this.maxEUOutput() + this.getMinimumStoredEU());
+ if (aBaseMetaTileEntity.isServerSide()){
+ aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.getUniversalEnergyStored() >= maxEUOutput() + getMinimumStoredEU());
}
}
}
- @Override
- public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) {
- if (aBaseMetaTileEntity.isClientSide()) {
- return true;
- }
- aBaseMetaTileEntity.openGUI(aPlayer);
- return true;
- }
+ public abstract int getEfficiency();
+
+ @Override
+ public boolean doesFillContainers() {
+ return false;
+ }
+
+ @Override
+ public boolean doesEmptyContainers() {
+ return false;
+ }
+
+ @Override
+ public boolean canTankBeFilled() {
+ return false;
+ }
+
+ @Override
+ public boolean canTankBeEmptied() {
+ return false;
+ }
+
+ @Override
+ public boolean displaysItemStack() {
+ return false;
+ }
+
+ @Override
+ public boolean displaysStackSize() {
+ return false;
+ }
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java
index 69baf01df3..ce4042148e 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java
@@ -1,8 +1,6 @@
package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators;
-import java.util.Collection;
-
-import gregtech.api.enums.GT_Values;
+import static gregtech.api.enums.GT_Values.V;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
@@ -11,311 +9,265 @@ import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
import gregtech.api.util.GT_Utility;
import gtPlusPlus.core.lib.CORE;
+
+import java.util.Collection;
+
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_BasicTank {
-
+
private boolean useFuel = false;
-
- public GregtechRocketFuelGeneratorBase(final int aID, final String aName, final String aNameRegional,
- final int aTier, final String aDescription, final ITexture... aTextures) {
- super(aID, aName, aNameRegional, aTier, 3, aDescription, aTextures);
- }
-
- public GregtechRocketFuelGeneratorBase(final String aName, final int aTier, final String aDescription,
- final ITexture[][][] aTextures) {
- super(aName, aTier, 3, aDescription, aTextures);
- }
-
- @Override
- public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide,
- final ItemStack aStack) {
- return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && (this.getFuelValue(aStack) > 0
- || this.getFuelValue(GT_Utility.getFluidForFilledItem(aStack, true)) > 0);
- }
-
- @Override
- public boolean canTankBeEmptied() {
- return this.getBaseMetaTileEntity().isAllowedToWork();
- }
-
- @Override
- public boolean canTankBeFilled() {
- return this.getBaseMetaTileEntity().isAllowedToWork();
- }
-
- public int consumedFluidPerOperation(final FluidStack aLiquid) {
- return 1;
- }
-
- @Override
- public boolean displaysItemStack() {
- return true;
- }
-
- @Override
- public boolean displaysStackSize() {
- return false;
- }
-
- @Override
- public boolean doesEmptyContainers() {
- return this.getBaseMetaTileEntity().isAllowedToWork();
- }
-
- @Override
- public boolean doesFillContainers() {
- return this.getBaseMetaTileEntity().isAllowedToWork();
- }
-
- public ITexture[] getBack(final byte aColor) {
- return new ITexture[] {
- Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]
- };
- }
-
- public ITexture[] getBackActive(final byte aColor) {
- return this.getBack(aColor);
- }
-
- public ITexture[] getBottom(final byte aColor) {
- return new ITexture[] {
- Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]
- };
- }
-
- public ITexture[] getBottomActive(final byte aColor) {
- return this.getBottom(aColor);
- }
-
- @Override
- public int getCapacity() {
- return 32000;
- }
-
- @Override
- public String[] getDescription() {
- return new String[] {
- this.mDescription, "Fuel Efficiency: " + this.getEfficiency() + "%", CORE.GT_Tooltip
- };
- }
-
- public abstract int getEfficiency();
-
- public ItemStack getEmptyContainer(final ItemStack aStack) {
- if (GT_Utility.isStackInvalid(aStack) || this.getRecipes() == null) {
- return null;
- }
- final GT_Recipe tFuel = this.getRecipes().findRecipe(this.getBaseMetaTileEntity(), false, Long.MAX_VALUE, null,
- aStack);
- if (tFuel != null) {
- return GT_Utility.copy(tFuel.getOutput(0));
- }
- return GT_Utility.getContainerItem(aStack, true);
- }
-
- public ITexture[] getFront(final byte aColor) {
- return new ITexture[] {
- Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]
- };
- }
-
- public ITexture[] getFrontActive(final byte aColor) {
- return this.getFront(aColor);
- }
-
- public int getFuelValue(final FluidStack aLiquid) {
- if (aLiquid == null || this.getRecipes() == null) {
- return 0;
- }
- FluidStack tLiquid;
- final Collection<GT_Recipe> tRecipeList = this.getRecipes().mRecipeList;
- if (tRecipeList != null) {
- for (final GT_Recipe tFuel : tRecipeList) {
- if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null) {
- if (aLiquid.isFluidEqual(tLiquid)) {
- return (int) ((long) tFuel.mSpecialValue * this.getEfficiency()
- * this.consumedFluidPerOperation(tLiquid) / 100);
- }
- }
- }
- }
- return 0;
- }
-
- public int getFuelValue(final ItemStack aStack) {
- if (GT_Utility.isStackInvalid(aStack) || this.getRecipes() == null) {
- return 0;
- }
- final GT_Recipe tFuel = this.getRecipes().findRecipe(this.getBaseMetaTileEntity(), false, Long.MAX_VALUE, null,
- aStack);
- if (tFuel != null) {
- return (int) (tFuel.mSpecialValue * 1000L * this.getEfficiency() / 100);
- }
- return 0;
- }
-
- public abstract GT_Recipe_Map getRecipes();
-
- public ITexture[] getSides(final byte aColor) {
- return new ITexture[] {
- Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]
- };
- }
-
- public ITexture[] getSidesActive(final byte aColor) {
- return this.getSides(aColor);
- }
-
- @Override
- public int getTankPressure() {
- return -100;
- }
-
- @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 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;
- }
-
- public ITexture[] getTop(final byte aColor) {
- return new ITexture[] {
- Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]
- };
- }
-
- public ITexture[] getTopActive(final byte aColor) {
- return this.getTop(aColor);
- }
-
- @Override
- public boolean isAccessAllowed(final EntityPlayer aPlayer) {
- return true;
- }
-
- @Override
- public boolean isEnetOutput() {
- return true;
- }
-
- @Override
- public boolean isFacingValid(final byte aSide) {
- return aSide > 1;
- }
-
- @Override
- public boolean isFluidInputAllowed(final FluidStack aFluid) {
- return this.getFuelValue(aFluid) > 0;
- }
-
- @Override
- public boolean isOutputFacing(final byte aSide) {
- return true;
- }
-
- @Override
- public boolean isSimpleMachine() {
- return false;
- }
-
- @Override
- public boolean isValidSlot(final int aIndex) {
- return aIndex < 2;
- }
-
- @Override
- public long maxEUOutput() {
- return this.getBaseMetaTileEntity().isAllowedToWork() ? GT_Values.V[this.mTier] : 0;
- }
-
- @Override
- public long maxEUStore() {
- return Math.max(this.getEUVar(), GT_Values.V[this.mTier] * 80 + this.getMinimumStoredEU());
- }
-
- @Override
- public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) {
- if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && aTick % 10 == 0) {
- if (this.mFluid == null) {
- if (aBaseMetaTileEntity.getUniversalEnergyStored() < this.maxEUOutput() + this.getMinimumStoredEU()) {
- this.mInventory[this.getStackDisplaySlot()] = null;
- }
- else {
- if (this.mInventory[this.getStackDisplaySlot()] == null) {
- this.mInventory[this.getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1);
- }
- this.mInventory[this.getStackDisplaySlot()].setStackDisplayName("Generating: "
- + (aBaseMetaTileEntity.getUniversalEnergyStored() - this.getMinimumStoredEU()) + " EU");
- }
- }
- else {
- final int tFuelValue = this.getFuelValue(this.mFluid),
- tConsumed = this.consumedFluidPerOperation(this.mFluid);
- if (tFuelValue > 0 && tConsumed > 0 && this.mFluid.amount > tConsumed) {
- final long tFluidAmountToUse = Math.min(this.mFluid.amount / tConsumed, (this.maxEUOutput() * 20
- + this.getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue);
- if (tFluidAmountToUse > 0
- && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)) {
- if (this.useFuel) {
- this.mFluid.amount -= tFluidAmountToUse * tConsumed;
- this.useFuel = false;
- }
- else {
- this.useFuel = true;
- }
- }
- }
- }
- if (this.mInventory[this.getInputSlot()] != null
- && aBaseMetaTileEntity.getUniversalEnergyStored() < this.maxEUOutput() * 20
- + this.getMinimumStoredEU()
- && GT_Utility.getFluidForFilledItem(this.mInventory[this.getInputSlot()], true) == null) {
- final int tFuelValue = this.getFuelValue(this.mInventory[this.getInputSlot()]);
- if (tFuelValue > 0) {
- final ItemStack tEmptyContainer = this.getEmptyContainer(this.mInventory[this.getInputSlot()]);
- if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), tEmptyContainer)) {
- aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true);
- aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1);
- }
- }
- }
- }
-
- if (aBaseMetaTileEntity.isServerSide()) {
- aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity
- .getUniversalEnergyStored() >= this.maxEUOutput() + this.getMinimumStoredEU());
- }
- }
-
- @Override
- public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) {
- if (aBaseMetaTileEntity.isClientSide()) {
- return true;
- }
- aBaseMetaTileEntity.openGUI(aPlayer);
- return true;
- }
+
+ public GregtechRocketFuelGeneratorBase(int aID, String aName, String aNameRegional, int aTier, String aDescription, ITexture... aTextures) {
+ super(aID, aName, aNameRegional, aTier, 3, aDescription, aTextures);
+ }
+
+ public GregtechRocketFuelGeneratorBase(String aName, int aTier, String aDescription, ITexture[][][] aTextures) {
+ super(aName, aTier, 3, aDescription, aTextures);
+ }
+
+ @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];
+ }
+
+
+ @Override
+ public String[] getDescription() {
+ return new String[]{mDescription, "Fuel Efficiency: " + getEfficiency() + "%", CORE.GT_Tooltip};
+ }
+
+
+ @Override
+ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {
+ if (aBaseMetaTileEntity.isClientSide()) return true;
+ aBaseMetaTileEntity.openGUI(aPlayer);
+ return true;
+ }
+
+ public ITexture[] getFront(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]};
+ }
+
+ public ITexture[] getBack(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]};
+ }
+
+ public ITexture[] getBottom(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]};
+ }
+
+ public ITexture[] getTop(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]};
+ }
+
+ public ITexture[] getSides(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]};
+ }
+
+ public ITexture[] getFrontActive(byte aColor) {
+ return getFront(aColor);
+ }
+
+ public ITexture[] getBackActive(byte aColor) {
+ return getBack(aColor);
+ }
+
+ public ITexture[] getBottomActive(byte aColor) {
+ return getBottom(aColor);
+ }
+
+ public ITexture[] getTopActive(byte aColor) {
+ return getTop(aColor);
+ }
+
+ public ITexture[] getSidesActive(byte aColor) {
+ return getSides(aColor);
+ }
+
+ @Override
+ public boolean isFacingValid(byte aSide) {
+ return aSide > 1;
+ }
+
+ @Override
+ public boolean isSimpleMachine() {
+ return false;
+ }
+
+ @Override
+ public boolean isValidSlot(int aIndex) {
+ return aIndex < 2;
+ }
+
+ @Override
+ public boolean isEnetOutput() {
+ return true;
+ }
+
+ @Override
+ public boolean isOutputFacing(byte aSide) {
+ return true;
+ }
+
+ @Override
+ public boolean isAccessAllowed(EntityPlayer aPlayer) {
+ return true;
+ }
+
+ @Override
+ public long maxEUOutput() {
+ return getBaseMetaTileEntity().isAllowedToWork() ? V[mTier] : 0;
+ }
+
+ @Override
+ public long maxEUStore() {
+ return Math.max(getEUVar(), V[mTier] * 80 + getMinimumStoredEU());
+ }
+
+ @Override
+ public boolean doesFillContainers() {
+ return getBaseMetaTileEntity().isAllowedToWork();
+ }
+
+ @Override
+ public boolean doesEmptyContainers() {
+ return getBaseMetaTileEntity().isAllowedToWork();
+ }
+
+ @Override
+ public boolean canTankBeFilled() {
+ return getBaseMetaTileEntity().isAllowedToWork();
+ }
+
+ @Override
+ public boolean canTankBeEmptied() {
+ return getBaseMetaTileEntity().isAllowedToWork();
+ }
+
+ @Override
+ public boolean displaysItemStack() {
+ return true;
+ }
+
+ @Override
+ public boolean displaysStackSize() {
+ return false;
+ }
+
+ @Override
+ public boolean isFluidInputAllowed(FluidStack aFluid) {
+ return getFuelValue(aFluid) > 0;
+ }
+
+ @Override
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
+ if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && aTick % 10 == 0) {
+ if (mFluid == null) {
+ if (aBaseMetaTileEntity.getUniversalEnergyStored() < maxEUOutput() + getMinimumStoredEU()) {
+ mInventory[getStackDisplaySlot()] = null;
+ } else {
+ if (mInventory[getStackDisplaySlot()] == null)
+ mInventory[getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1);
+ mInventory[getStackDisplaySlot()].setStackDisplayName("Generating: " + (aBaseMetaTileEntity.getUniversalEnergyStored() - getMinimumStoredEU()) + " EU");
+ }
+ } else {
+ int tFuelValue = getFuelValue(mFluid), tConsumed = consumedFluidPerOperation(mFluid);
+ if (tFuelValue > 0 && tConsumed > 0 && mFluid.amount > tConsumed) {
+ long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue);
+ if (tFluidAmountToUse > 0 && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)){
+ if (useFuel){
+ mFluid.amount -= tFluidAmountToUse * tConsumed;
+ useFuel = false;
+ }
+ else {
+ useFuel = true;
+ }
+ }
+ }
+ }
+ if (mInventory[getInputSlot()] != null && aBaseMetaTileEntity.getUniversalEnergyStored() < (maxEUOutput() * 20 + getMinimumStoredEU()) && GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true) == null) {
+ int tFuelValue = getFuelValue(mInventory[getInputSlot()]);
+ if (tFuelValue > 0) {
+ ItemStack tEmptyContainer = getEmptyContainer(mInventory[getInputSlot()]);
+ if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tEmptyContainer)) {
+ aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true);
+ aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1);
+ }
+ }
+ }
+ }
+
+ if (aBaseMetaTileEntity.isServerSide())
+ aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.getUniversalEnergyStored() >= maxEUOutput() + getMinimumStoredEU());
+ }
+
+ public abstract GT_Recipe_Map getRecipes();
+
+ public abstract int getEfficiency();
+
+ public int consumedFluidPerOperation(FluidStack aLiquid) {
+ return 1;
+ }
+
+ public int getFuelValue(FluidStack aLiquid) {
+ if (aLiquid == null || getRecipes() == null) return 0;
+ FluidStack tLiquid;
+ Collection<GT_Recipe> tRecipeList = getRecipes().mRecipeList;
+ if (tRecipeList != null) for (GT_Recipe tFuel : tRecipeList)
+ if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null)
+ if (aLiquid.isFluidEqual(tLiquid))
+ return (int) (((long) tFuel.mSpecialValue * getEfficiency() * consumedFluidPerOperation(tLiquid)) / 100);
+ return 0;
+ }
+
+ public int getFuelValue(ItemStack aStack) {
+ if (GT_Utility.isStackInvalid(aStack) || getRecipes() == null) return 0;
+ GT_Recipe tFuel = getRecipes().findRecipe(getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack);
+ if (tFuel != null) return (int) ((tFuel.mSpecialValue * 1000L * getEfficiency()) / 100);
+ return 0;
+ }
+
+ public ItemStack getEmptyContainer(ItemStack aStack) {
+ if (GT_Utility.isStackInvalid(aStack) || getRecipes() == null) return null;
+ GT_Recipe tFuel = getRecipes().findRecipe(getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack);
+ if (tFuel != null) return GT_Utility.copy(tFuel.getOutput(0));
+ return GT_Utility.getContainerItem(aStack, true);
+ }
+
+ @Override
+ public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && (getFuelValue(aStack) > 0 || getFuelValue(GT_Utility.getFluidForFilledItem(aStack, true)) > 0);
+ }
+
+ @Override
+ public int getCapacity() {
+ return 32000;
+ }
+
+ @Override
+ public int getTankPressure() {
+ return -100;
+ }
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechBaseMetaTileEntityLossless.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechBaseMetaTileEntityLossless.java
index dd45655477..e9ac788e7b 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechBaseMetaTileEntityLossless.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechBaseMetaTileEntityLossless.java
@@ -1,10 +1,11 @@
package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.lossless;
-import java.util.*;
-
+import static gregtech.api.enums.GT_Values.NW;
+import static gregtech.api.enums.GT_Values.V;
import gregtech.GT_Mod;
import gregtech.api.GregTech_API;
-import gregtech.api.enums.*;
+import gregtech.api.enums.ItemList;
+import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IEnergyConnected;
@@ -13,8 +14,17 @@ import gregtech.api.metatileentity.BaseTileEntity;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.net.GT_Packet_TileEntity;
import gregtech.api.objects.GT_ItemStack;
-import gregtech.api.util.*;
+import gregtech.api.util.GT_CoverBehavior;
+import gregtech.api.util.GT_Log;
+import gregtech.api.util.GT_ModHandler;
+import gregtech.api.util.GT_OreDictUnificator;
+import gregtech.api.util.GT_Utility;
import ic2.api.Direction;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
import net.minecraft.block.Block;
import net.minecraft.block.BlockFire;
import net.minecraft.entity.Entity;
@@ -30,7 +40,9 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.EnumSkyBlock;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
-import net.minecraftforge.fluids.*;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.FluidTankInfo;
/**
* NEVER INCLUDE THIS FILE IN YOUR MOD!!!
@@ -38,2371 +50,1808 @@ import net.minecraftforge.fluids.*;
* This is the main TileEntity for EVERYTHING.
*/
public class GregtechBaseMetaTileEntityLossless extends BaseTileEntity implements IGregTechTileEntity {
- private final GT_CoverBehavior[] mCoverBehaviors = new GT_CoverBehavior[] {
- GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior,
- GregTech_API.sNoBehavior, GregTech_API.sNoBehavior
- };
- protected MetaTileEntity mMetaTileEntity;
- protected long mStoredEnergy = 0, mStoredSteam = 0;
- protected int mAverageEUInputIndex = 0, mAverageEUOutputIndex = 0;
- protected boolean mReleaseEnergy = false;
- protected int[] mAverageEUInput = new int[] {
- 0, 0, 0, 0, 0
- }, mAverageEUOutput = new int[] {
- 0, 0, 0, 0, 0
- };
- private final boolean[] mActiveEUInputs = new boolean[] {
- false, false, false, false, false, false
- }, mActiveEUOutputs = new boolean[] {
- false, false, false, false, false, false
- };
- private byte[] mSidedRedstone = new byte[] {
- 15, 15, 15, 15, 15, 15
- };
- private int[] mCoverSides = new int[] {
- 0, 0, 0, 0, 0, 0
- }, mCoverData = new int[] {
- 0, 0, 0, 0, 0, 0
- };
- private final int[] mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING];
- private boolean mHasEnoughEnergy = true, mRunningThroughTick = false,
- mInputDisabled = false, mOutputDisabled = false, mMuffler = false, mLockUpgrade = false, mActive = false,
- mRedstone = false, mWorkUpdate = false, mSteamConverter = false, mInventoryChanged = false, mWorks = true,
- mNeedsUpdate = true, mNeedsBlockUpdate = true, mSendClientData = false, oRedstone = false;
- private byte mColor = 0, oColor = 0, mStrongRedstone = 0,
- oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, oLightValueClient = -1, oLightValue = -1,
- mLightValue = 0, mOtherUpgrades = 0, mFacing = 0, oFacing = 0, mWorkData = 0;
- private int mDisplayErrorCode = 0, oX = 0, oY = 0, oZ = 0, mTimeStatisticsIndex = 0,
- mLagWarningCount = 0;
- private short mID = 0;
- private long mTickTimer = 0, oOutput = 0, mAcceptedAmperes = Long.MAX_VALUE;
- private String mOwnerName = "";
- private NBTTagCompound mRecipeStuff = new NBTTagCompound();
-
- public GregtechBaseMetaTileEntityLossless() {
- }
-
- public boolean acceptsEnergyFrom(final TileEntity aReceiver, final Direction aDirection) {
- return this.inputEnergyFrom((byte) aDirection.toSideValue());
- }
-
- public boolean acceptsEnergyFrom(final TileEntity aEmitter, final ForgeDirection aDirection) {
- return this.inputEnergyFrom((byte) aDirection.ordinal());
- }
-
- @Override
- public boolean acceptsRotationalEnergy(final byte aSide) {
- if (!this.canAccessData() || this.getCoverIDAtSide(aSide) != 0) {
- return false;
- }
- return this.mMetaTileEntity.acceptsRotationalEnergy(aSide);
- }
-
- @Override
- public void addCollisionBoxesToList(final World aWorld, final int aX, final int aY, final int aZ,
- final AxisAlignedBB inputAABB, final List<AxisAlignedBB> outputAABB, final Entity collider) {
- this.mMetaTileEntity.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider);
- }
-
- public int addEnergy(final int aEnergy) {
- if (!this.canAccessData()) {
- return 0;
- }
- if (aEnergy > 0) {
- this.increaseStoredEnergyUnits(aEnergy, true);
- }
- else {
- this.decreaseStoredEU(-aEnergy, true);
- }
- return (int) Math.min(Integer.MAX_VALUE, this.mMetaTileEntity.getEUVar());
- }
-
- @Override
- public boolean addMufflerUpgrade() {
- if (this.isMufflerUpgradable()) {
- return this.mMuffler = true;
- }
- return false;
- }
-
- @Override
- public boolean addStackToSlot(final int aIndex, ItemStack aStack) {
- if (GT_Utility.isStackInvalid(aStack)) {
- return true;
- }
- if (aIndex < 0 || aIndex >= this.getSizeInventory()) {
- return false;
- }
- final ItemStack tStack = this.getStackInSlot(aIndex);
- if (GT_Utility.isStackInvalid(tStack)) {
- this.setInventorySlotContents(aIndex, aStack);
- return true;
- }
- aStack = GT_OreDictUnificator.get(aStack);
- if (GT_Utility.areStacksEqual(tStack, aStack) && tStack.stackSize + aStack.stackSize <= Math
- .min(aStack.getMaxStackSize(), this.getInventoryStackLimit())) {
- tStack.stackSize += aStack.stackSize;
- return true;
- }
- return false;
- }
-
- @Override
- public boolean addStackToSlot(final int aIndex, final ItemStack aStack, final int aAmount) {
- return this.addStackToSlot(aIndex, GT_Utility.copyAmount(aAmount, aStack));
- }
-
- @Override
- public boolean addSteamEngineUpgrade() {
- if (this.isSteamEngineUpgradable()) {
- this.issueBlockUpdate();
- this.mSteamConverter = true;
- return true;
- }
- return false;
- }
-
- protected boolean canAccessData() {
- return !this.isDead && this.hasValidMetaTileEntity();
- }
-
- @Override
- public boolean canDrain(final ForgeDirection aSide, final Fluid aFluid) {
- if (this.mTickTimer > 5 && this.canAccessData() && (this.mRunningThroughTick || !this.mOutputDisabled)
- && (aSide == ForgeDirection.UNKNOWN || this.mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal())
- && this.getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(),
- this.getCoverIDAtSide((byte) aSide.ordinal()),
- this.getCoverDataAtSide((byte) aSide.ordinal()), aFluid, this))) {
- return this.mMetaTileEntity.canDrain(aSide, aFluid);
- }
- return false;
- }
-
- /**
- * Can pull aStack out of Slot from Side
- */
- @Override
- public boolean canExtractItem(final int aIndex, final ItemStack aStack, final int aSide) {
- return this.canAccessData() && (this.mRunningThroughTick || !this.mOutputDisabled)
- && this.getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide,
- this.getCoverIDAtSide((byte) aSide), this.getCoverDataAtSide((byte) aSide), aIndex, this)
- && this.mMetaTileEntity.canExtractItem(aIndex, aStack, aSide);
- }
-
- @Override
- public boolean canFill(final ForgeDirection aSide, final Fluid aFluid) {
- if (this.mTickTimer > 5 && this.canAccessData() && (this.mRunningThroughTick || !this.mInputDisabled)
- && (aSide == ForgeDirection.UNKNOWN || this.mMetaTileEntity.isLiquidInput((byte) aSide.ordinal())
- && this.getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(),
- this.getCoverIDAtSide((byte) aSide.ordinal()),
- this.getCoverDataAtSide((byte) aSide.ordinal()), aFluid, this))) {
- return this.mMetaTileEntity.canFill(aSide, aFluid);
- }
- return false;
- }
-
- /**
- * Can put aStack into Slot at Side
- */
- @Override
- public boolean canInsertItem(final int aIndex, final ItemStack aStack, final int aSide) {
- return this.canAccessData() && (this.mRunningThroughTick || !this.mInputDisabled)
- && this.getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide,
- this.getCoverIDAtSide((byte) aSide), this.getCoverDataAtSide((byte) aSide), aIndex, this)
- && this.mMetaTileEntity.canInsertItem(aIndex, aStack, aSide);
- }
-
- @Override
- public boolean canPlaceCoverIDAtSide(final byte aSide, final int aID) {
- return this.getCoverIDAtSide(aSide) == 0;
- }
-
- @Override
- public boolean canPlaceCoverItemAtSide(final byte aSide, final ItemStack aCover) {
- return this.getCoverIDAtSide(aSide) == 0;
- }
-
- /**
- * Called when trying to charge Items
- */
- public void chargeItem(final ItemStack aStack) {
- this.decreaseStoredEU(
- GT_ModHandler.chargeElectricItem(aStack, (int) Math.min(Integer.MAX_VALUE, this.getStoredEU()),
- (int) Math.min(Integer.MAX_VALUE, this.mMetaTileEntity.getOutputTier()), false, false),
- true);
- }
-
- @Override
- public void closeInventory() {
- if (this.canAccessData()) {
- this.mMetaTileEntity.onCloseGUI();
- }
- }
-
- private boolean createNewMetatileEntity(final short aID) {
- if (aID <= 0 || aID >= GregTech_API.METATILEENTITIES.length || GregTech_API.METATILEENTITIES[aID] == null) {
- GT_Log.err.println("MetaID " + aID + " not loadable => locking TileEntity!");
- }
- else {
- if (aID != 0) {
- if (this.hasValidMetaTileEntity()) {
- this.mMetaTileEntity.setBaseMetaTileEntity(null);
- }
- GregTech_API.METATILEENTITIES[aID].newMetaEntity(this).setBaseMetaTileEntity(this);
- this.mTickTimer = 0;
- this.mID = aID;
- return true;
- }
- }
- return false;
- }
-
- @Override
- public boolean decreaseStoredEnergyUnits(final long aEnergy, final boolean aIgnoreTooLessEnergy) {
- if (!this.canAccessData()) {
- return false;
- }
- return this.mHasEnoughEnergy = this.decreaseStoredEU(aEnergy, aIgnoreTooLessEnergy)
- || this.decreaseStoredSteam(aEnergy, false)
- || aIgnoreTooLessEnergy && this.decreaseStoredSteam(aEnergy, true);
- }
-
- public boolean decreaseStoredEU(final long aEnergy, final boolean aIgnoreTooLessEnergy) {
- if (!this.canAccessData()) {
- return false;
- }
- if (this.mMetaTileEntity.getEUVar() - aEnergy >= 0 || aIgnoreTooLessEnergy) {
- this.setStoredEU(this.mMetaTileEntity.getEUVar() - aEnergy);
- if (this.mMetaTileEntity.getEUVar() < 0) {
- this.setStoredEU(0);
- return false;
- }
- return true;
- }
- return false;
- }
-
- public boolean decreaseStoredSteam(final long aEnergy, final boolean aIgnoreTooLessEnergy) {
- if (!this.canAccessData()) {
- return false;
- }
- if (this.mMetaTileEntity.getSteamVar() - aEnergy >= 0 || aIgnoreTooLessEnergy) {
- this.setStoredSteam(this.mMetaTileEntity.getSteamVar() - aEnergy);
- if (this.mMetaTileEntity.getSteamVar() < 0) {
- this.setStoredSteam(0);
- return false;
- }
- return true;
- }
- return false;
- }
-
- @Override
- public ItemStack decrStackSize(final int aIndex, final int aAmount) {
- if (this.canAccessData()) {
- this.mInventoryChanged = true;
- return this.mMetaTileEntity.decrStackSize(aIndex, aAmount);
- }
- return null;
- }
-
- public double demandedEnergyUnits() {
- if (this.mReleaseEnergy || !this.canAccessData() || !this.mMetaTileEntity.isEnetInput()) {
- return 0;
- }
- return this.getEUCapacity() - this.getStoredEU();
- }
-
- public int demandsEnergy() {
- if (this.mReleaseEnergy || !this.canAccessData() || !this.mMetaTileEntity.isEnetInput()) {
- return 0;
- }
- return this.getCapacity() - this.getStored();
- }
-
- @Override
- public void disableWorking() {
- this.mWorks = false;
- }
-
- /**
- * Called when trying to discharge Items
- */
- public void dischargeItem(final ItemStack aStack) {
- this.increaseStoredEnergyUnits(GT_ModHandler.dischargeElectricItem(aStack,
- (int) Math.min(Integer.MAX_VALUE, this.getEUCapacity() - this.getStoredEU()),
- (int) Math.min(Integer.MAX_VALUE, this.mMetaTileEntity.getInputTier()), false, false, false), true);
- }
-
- public void doEnergyExplosion() {
- if (this.getUniversalEnergyCapacity() > 0
- && this.getUniversalEnergyStored() >= this.getUniversalEnergyCapacity() / 5) {
- this.doExplosion(this.oOutput * (this.getUniversalEnergyStored() >= this.getUniversalEnergyCapacity() ? 4
- : this.getUniversalEnergyStored() >= this.getUniversalEnergyCapacity() / 2 ? 2 : 1));
- GT_Mod.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(this.mOwnerName),
- "electricproblems");
- }
- }
-
- @Override
- public void doExplosion(final long aAmount) {
- if (this.canAccessData()) {
- // This is only for Electric Machines
- if (GregTech_API.sMachineWireFire && this.mMetaTileEntity.isElectric()) {
- try {
- this.mReleaseEnergy = true;
- IEnergyConnected.Util.emitEnergyToNetwork(GT_Values.V[5],
- Math.max(1, this.getStoredEU() / GT_Values.V[5]), this);
- }
- catch (final Exception e) {
- /*
- * Fun Fact: all these "do nothing" Comments you see in my
- * Code, are just there to let Eclipse shut up about the
- * intended empty Brackets, but I need eclipse to yell at me
- * in some of the regular Cases where I forget to add Code
- */}
- }
- this.mReleaseEnergy = false;
- // Normal Explosion Code
- this.mMetaTileEntity.onExplosion();
- this.mMetaTileEntity.doExplosion(aAmount);
- }
- }
-
- @Override
- public FluidStack drain(final ForgeDirection aSide, final FluidStack aFluid, final boolean doDrain) {
- if (this.mTickTimer > 5 && this.canAccessData() && (this.mRunningThroughTick || !this.mOutputDisabled)
- && (aSide == ForgeDirection.UNKNOWN || this.mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal())
- && this.getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(),
- this.getCoverIDAtSide((byte) aSide.ordinal()),
- this.getCoverDataAtSide((byte) aSide.ordinal()),
- aFluid == null ? null : aFluid.getFluid(), this))) {
- return this.mMetaTileEntity.drain(aSide, aFluid, doDrain);
- }
- return null;
- }
-
- @Override
- public FluidStack drain(final ForgeDirection aSide, final int maxDrain, final boolean doDrain) {
- if (this.mTickTimer > 5 && this.canAccessData() && (this.mRunningThroughTick || !this.mOutputDisabled)
- && (aSide == ForgeDirection.UNKNOWN || this.mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal())
- && this.getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(),
- this.getCoverIDAtSide((byte) aSide.ordinal()),
- this.getCoverDataAtSide((byte) aSide.ordinal()), this.mMetaTileEntity.getFluid() == null
- ? null : this.mMetaTileEntity.getFluid().getFluid(),
- this))) {
- return this.mMetaTileEntity.drain(aSide, maxDrain, doDrain);
- }
- return null;
- }
-
- @Override
- public boolean drainEnergyUnits(final byte aSide, final long aVoltage, final long aAmperage) {
- if (!this.canAccessData() || !this.mMetaTileEntity.isElectric() || !this.outputsEnergyTo(aSide)
- || this.getStoredEU() - aVoltage * aAmperage < this.mMetaTileEntity.getMinimumStoredEU()) {
- return false;
- }
- if (this.decreaseStoredEU(aVoltage * aAmperage, false)) {
- this.mAverageEUOutput[this.mAverageEUOutputIndex] += aVoltage * aAmperage;
- return true;
- }
- return false;
- }
-
- public void drawEnergy(final double amount) {
- this.mAverageEUOutput[this.mAverageEUOutputIndex] += amount;
- this.decreaseStoredEU((int) amount, true);
- }
-
- @Override
- public boolean dropCover(final byte aSide, final byte aDroppedSide, final boolean aForced) {
- if (this.getCoverBehaviorAtSide(aSide).onCoverRemoval(aSide, this.getCoverIDAtSide(aSide),
- this.mCoverData[aSide], this, aForced) || aForced) {
- final ItemStack tStack = this.getCoverBehaviorAtSide(aSide).getDrop(aSide, this.getCoverIDAtSide(aSide),
- this.getCoverDataAtSide(aSide), this);
- if (tStack != null) {
- tStack.setTagCompound(null);
- final EntityItem tEntity = new EntityItem(this.worldObj, this.getOffsetX(aDroppedSide, 1) + 0.5,
- this.getOffsetY(aDroppedSide, 1) + 0.5, this.getOffsetZ(aDroppedSide, 1) + 0.5, tStack);
- tEntity.motionX = 0;
- tEntity.motionY = 0;
- tEntity.motionZ = 0;
- this.worldObj.spawnEntityInWorld(tEntity);
- }
- this.setCoverIDAtSide(aSide, 0);
- if (this.mMetaTileEntity.hasSidedRedstoneOutputBehavior()) {
- this.setOutputRedstoneSignal(aSide, (byte) 0);
- }
- else {
- this.setOutputRedstoneSignal(aSide, (byte) 15);
- }
- return true;
- }
- return false;
- }
-
- public boolean emitsEnergyTo(final TileEntity aReceiver, final Direction aDirection) {
- return this.outputsEnergyTo((byte) aDirection.toSideValue());
- }
-
- public boolean emitsEnergyTo(final TileEntity aReceiver, final ForgeDirection aDirection) {
- return this.outputsEnergyTo((byte) aDirection.ordinal());
- }
-
- @Override
- public void enableWorking() {
- if (!this.mWorks) {
- this.mWorkUpdate = true;
- }
- this.mWorks = true;
- }
-
- @Override
- public int fill(final ForgeDirection aSide, final FluidStack aFluid, final boolean doFill) {
- if (this.mTickTimer > 5 && this.canAccessData() && (this.mRunningThroughTick || !this.mInputDisabled)
- && (aSide == ForgeDirection.UNKNOWN || this.mMetaTileEntity.isLiquidInput((byte) aSide.ordinal())
- && this.getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(),
- this.getCoverIDAtSide((byte) aSide.ordinal()),
- this.getCoverDataAtSide((byte) aSide.ordinal()),
- aFluid == null ? null : aFluid.getFluid(), this))) {
- return this.mMetaTileEntity.fill(aSide, aFluid, doFill);
- }
- return 0;
- }
-
- /**
- * returns all valid Inventory Slots, no matter which Side (Unless it's
- * covered). The Side Stuff is done in the following two Functions.
- */
- @Override
- public int[] getAccessibleSlotsFromSide(final int aSide) {
- if (this.canAccessData() && (this.getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide,
- this.getCoverIDAtSide((byte) aSide), this.getCoverDataAtSide((byte) aSide), -1, this)
- || this.getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide,
- this.getCoverIDAtSide((byte) aSide), this.getCoverDataAtSide((byte) aSide), -1, this))) {
- return this.mMetaTileEntity.getAccessibleSlotsFromSide(aSide);
- }
- return new int[0];
- }
-
- @Override
- public long getAverageElectricInput() {
- int rEU = 0;
- for (final int tEU : this.mAverageEUInput) {
- rEU += tEU;
- }
- return rEU / this.mAverageEUInput.length;
- }
-
- @Override
- public long getAverageElectricOutput() {
- int rEU = 0;
- for (final int tEU : this.mAverageEUOutput) {
- rEU += tEU;
- }
- return rEU / this.mAverageEUOutput.length;
- }
-
- @Override
- public byte getBackFacing() {
- return GT_Utility.getOppositeSide(this.mFacing);
- }
-
- @Override
- public float getBlastResistance(final byte aSide) {
- return this.canAccessData() ? Math.max(0, this.getMetaTileEntity().getExplosionResistance(aSide)) : 10.0F;
- }
-
- public int getCapacity() {
- return (int) Math.min(Integer.MAX_VALUE, this.getEUCapacity());
- }
-
- @Override
- public AxisAlignedBB getCollisionBoundingBoxFromPool(final World aWorld, final int aX, final int aY, final int aZ) {
- return this.mMetaTileEntity.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ);
- }
-
- @Override
- public byte getColorization() {
- return (byte) (this.mColor - 1);
- }
-
- @Override
- public byte getComparatorValue(final byte aSide) {
- return this.canAccessData() ? this.mMetaTileEntity.getComparatorValue(aSide) : 0;
- }
-
- @Override
- public GT_CoverBehavior getCoverBehaviorAtSide(final byte aSide) {
- return aSide >= 0 && aSide < this.mCoverBehaviors.length ? this.mCoverBehaviors[aSide]
- : GregTech_API.sNoBehavior;
- }
-
- @Override
- public int getCoverDataAtSide(final byte aSide) {
- if (aSide >= 0 && aSide < 6) {
- return this.mCoverData[aSide];
- }
- return 0;
- }
-
- @Override
- public int getCoverIDAtSide(final byte aSide) {
- if (aSide >= 0 && aSide < 6) {
- return this.mCoverSides[aSide];
- }
- return 0;
- }
-
- @Override
- public ItemStack getCoverItemAtSide(final byte aSide) {
- return GT_Utility.intToStack(this.getCoverIDAtSide(aSide));
- }
-
- public ITexture getCoverTexture(final byte aSide) {
- return GregTech_API.sCovers.get(new GT_ItemStack(this.getCoverIDAtSide(aSide)));
- }
-
- public ArrayList<String> getDebugInfo(final EntityPlayer aPlayer, final int aLogLevel) {
- final ArrayList<String> tList = new ArrayList<String>();
- if (aLogLevel > 2) {
- tList.add("Meta-ID: " + this.mID + (this.canAccessData() ? " valid" : " invalid")
- + (this.mMetaTileEntity == null ? " MetaTileEntity == null!" : " "));
- }
- if (aLogLevel > 1) {
- if (this.mTimeStatistics.length > 0) {
- double tAverageTime = 0;
- for (final int tTime : this.mTimeStatistics) {
- tAverageTime += tTime;
- }
- tList.add("This particular TileEntity has caused an average CPU-load of ~"
- + tAverageTime / this.mTimeStatistics.length + "ms over the last " + this.mTimeStatistics.length
- + " ticks.");
- }
- if (this.mLagWarningCount > 0) {
- tList.add("This TileEntity has also caused "
- + (this.mLagWarningCount >= 10 ? "more than 10" : this.mLagWarningCount)
- + " Lag Spike Warnings (anything taking longer than "
- + GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING + "ms) on the Server.");
- }
- tList.add("Is" + (this.mMetaTileEntity.isAccessAllowed(aPlayer) ? " " : " not ") + "accessible for you");
- }
- if (aLogLevel > 0) {
- if (this.getSteamCapacity() > 0 && this.hasSteamEngineUpgrade()) {
- tList.add(this.getStoredSteam() + " of " + this.getSteamCapacity() + " Steam");
- }
- tList.add("Machine is " + (this.mActive ? "active" : "inactive"));
- if (!this.mHasEnoughEnergy) {
- tList.add(
- "ATTENTION: This Device consumes Energy at a higher Rate than you input. You could insert more to speed up the process.");
- }
- }
- return this.mMetaTileEntity.getSpecialDebugInfo(this, aPlayer, aLogLevel, tList);
- }
-
- @Override
- public String[] getDescription() {
- if (this.canAccessData()) {
- return this.mMetaTileEntity.getDescription();
- }
- return new String[0];
- }
-
- @Override
- public Packet getDescriptionPacket() {
- this.issueClientUpdate();
- return null;
- }
-
- @Override
- public ArrayList<ItemStack> getDrops() {
- final ItemStack rStack = new ItemStack(GregTech_API.sBlockMachines, 1, this.mID);
- final NBTTagCompound tNBT = new NBTTagCompound();
- if (this.mRecipeStuff != null && !this.mRecipeStuff.hasNoTags()) {
- tNBT.setTag("GT.CraftingComponents", this.mRecipeStuff);
- }
- if (this.mMuffler) {
- tNBT.setBoolean("mMuffler", this.mMuffler);
- }
- if (this.mLockUpgrade) {
- tNBT.setBoolean("mLockUpgrade", this.mLockUpgrade);
- }
- if (this.mSteamConverter) {
- tNBT.setBoolean("mSteamConverter", this.mSteamConverter);
- }
- if (this.mColor > 0) {
- tNBT.setByte("mColor", this.mColor);
- }
- if (this.mOtherUpgrades > 0) {
- tNBT.setByte("mOtherUpgrades", this.mOtherUpgrades);
- }
- if (this.mStrongRedstone > 0) {
- tNBT.setByte("mStrongRedstone", this.mStrongRedstone);
- }
- for (byte i = 0; i < this.mCoverSides.length; i++) {
- if (this.mCoverSides[i] != 0) {
- tNBT.setIntArray("mCoverData", this.mCoverData);
- tNBT.setIntArray("mCoverSides", this.mCoverSides);
- break;
- }
- }
- if (this.hasValidMetaTileEntity()) {
- this.mMetaTileEntity.setItemNBT(tNBT);
- }
- if (!tNBT.hasNoTags()) {
- rStack.setTagCompound(tNBT);
- }
- return new ArrayList<ItemStack>(Arrays.asList(rStack));
- }
-
- @Override
- public int getErrorDisplayID() {
- return this.mDisplayErrorCode;
- }
-
- @Override
- public long getEUCapacity() {
- if (this.canAccessData()) {
- return this.mMetaTileEntity.maxEUStore();
- }
- return 0;
- }
-
- @Override
- public byte getFrontFacing() {
- return this.mFacing;
- }
-
- @Override
- public String[] getInfoData() {
- {
- if (this.canAccessData()) {
- return this.getMetaTileEntity().getInfoData();
- }
- return new String[] {};
- }
- }
-
- @Override
- public long getInputAmperage() {
- if (this.canAccessData() && this.mMetaTileEntity.isElectric()) {
- return this.mMetaTileEntity.maxAmperesIn();
- }
- return 0;
- }
-
- @Override
- public byte getInputRedstoneSignal(final byte aSide) {
- return (byte) (this.worldObj.getIndirectPowerLevelTo(this.getOffsetX(aSide, 1), this.getOffsetY(aSide, 1),
- this.getOffsetZ(aSide, 1), aSide) & 15);
- }
-
- @Override
- public long getInputVoltage() {
- if (this.canAccessData() && this.mMetaTileEntity.isElectric()) {
- return this.mMetaTileEntity.maxEUInput();
- }
- return Integer.MAX_VALUE;
- }
-
- @Override
- public byte getInternalInputRedstoneSignal(final byte aSide) {
- return (byte) (this.getCoverBehaviorAtSide(aSide).getRedstoneInput(aSide, this.getInputRedstoneSignal(aSide),
- this.getCoverIDAtSide(aSide), this.getCoverDataAtSide(aSide), this) & 15);
- }
-
- @Override
- public String getInventoryName() {
- if (this.canAccessData()) {
- return this.mMetaTileEntity.getInventoryName();
- }
- if (GregTech_API.METATILEENTITIES[this.mID] != null) {
- return GregTech_API.METATILEENTITIES[this.mID].getInventoryName();
- }
- return "";
- }
-
- @Override
- public int getInventoryStackLimit() {
- if (this.canAccessData()) {
- return this.mMetaTileEntity.getInventoryStackLimit();
- }
- return 64;
- }
-
- @Override
- public int getLightOpacity() {
- return this.mMetaTileEntity == null ? this.getLightValue() > 0 ? 0 : 255
- : this.mMetaTileEntity.getLightOpacity();
- }
-
- public byte getLightValue() {
- return this.mLightValue;
- }
-
- public int getMaxEnergyOutput() {
- if (this.mReleaseEnergy) {
- return Integer.MAX_VALUE;
- }
- return this.getOutput();
- }
-
- @Override
- public int getMaxItemCount() {
- if (this.canAccessData()) {
- return this.mMetaTileEntity.getMaxItemCount();
- }
- return 0;
- }
-
- @Override
- public int getMaxProgress() {
- return this.canAccessData() ? this.mMetaTileEntity.maxProgresstime() : 0;
- }
-
- public int getMaxSafeInput() {
- return (int) Math.min(Integer.MAX_VALUE, this.getInputVoltage());
- }
-
- @Override
- public IMetaTileEntity getMetaTileEntity() {
- return this.hasValidMetaTileEntity() ? this.mMetaTileEntity : null;
- }
-
- @Override
- public int getMetaTileID() {
- return this.mID;
- }
-
- public double getOfferedEnergy() {
- return this.canAccessData() && this.getStoredEU() - this.mMetaTileEntity.getMinimumStoredEU() >= this.oOutput
- ? Math.max(0, this.oOutput) : 0;
- }
-
- public int getOutput() {
- return (int) Math.min(Integer.MAX_VALUE, this.oOutput);
- }
-
- @Override
- public long getOutputAmperage() {
- if (this.canAccessData() && this.mMetaTileEntity.isElectric()) {
- return this.mMetaTileEntity.maxAmperesOut();
- }
- return 0;
- }
-
- public double getOutputEnergyUnitsPerTick() {
- return this.oOutput;
- }
-
- @Override
- public byte getOutputRedstoneSignal(final byte aSide) {
- return this.getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, this.getCoverIDAtSide(aSide),
- this.getCoverDataAtSide(aSide), this) ? this.mSidedRedstone[aSide] : 0;
- // return
- // (byte)(getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide,
- // getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this) ||
- // (mRedstone && getCoverBehaviorAtSide(aSide).letsRedstoneGoOut(aSide,
- // getCoverIDAtSide(aSide), getCoverDataAtSide(aSide),
- // this))?mSidedRedstone[aSide]&15:0);
- }
-
- @Override
- public long getOutputVoltage() {
- if (this.canAccessData() && this.mMetaTileEntity.isElectric() && this.mMetaTileEntity.isEnetOutput()) {
- return this.mMetaTileEntity.maxEUOutput();
- }
- return 0;
- }
-
- @Override
- public String getOwnerName() {
- if (GT_Utility.isStringInvalid(this.mOwnerName)) {
- return "Player";
- }
- return this.mOwnerName;
- }
-
- @Override
- public int getProgress() {
- return this.canAccessData() ? this.mMetaTileEntity.getProgresstime() : 0;
- }
-
- @Override
- public boolean getRedstone() {
- return this.getRedstone((byte) 0) || this.getRedstone((byte) 1) || this.getRedstone((byte) 2)
- || this.getRedstone((byte) 3) || this.getRedstone((byte) 4) || this.getRedstone((byte) 5);
- }
-
- @Override
- public boolean getRedstone(final byte aSide) {
- return this.getInternalInputRedstoneSignal(aSide) > 0;
- }
-
- @Override
- public int getSizeInventory() {
- if (this.canAccessData()) {
- return this.mMetaTileEntity.getSizeInventory();
- }
- return 0;
- }
-
- @Override
- public ItemStack getStackInSlot(final int aIndex) {
- if (this.canAccessData()) {
- return this.mMetaTileEntity.getStackInSlot(aIndex);
- }
- return null;
- }
-
- @Override
- public ItemStack getStackInSlotOnClosing(final int slot) {
- final ItemStack stack = this.getStackInSlot(slot);
- if (stack != null) {
- this.setInventorySlotContents(slot, null);
- }
- return stack;
- }
-
- @Override
- public long getSteamCapacity() {
- if (this.canAccessData()) {
- return this.mMetaTileEntity.maxSteamStore();
- }
- return 0;
- }
-
- public int getStored() {
- return (int) Math.min(Integer.MAX_VALUE, Math.min(this.getStoredEU(), this.getCapacity()));
- }
-
- @Override
- public long getStoredEU() {
- if (this.canAccessData()) {
- return Math.min(this.mMetaTileEntity.getEUVar(), this.getEUCapacity());
- }
- return 0;
- }
-
- @Override
- public ItemStack[] getStoredItemData() {
- if (this.canAccessData()) {
- return this.mMetaTileEntity.getStoredItemData();
- }
- return null;
- }
-
- @Override
- public long getStoredSteam() {
- if (this.canAccessData()) {
- return Math.min(this.mMetaTileEntity.getSteamVar(), this.getSteamCapacity());
- }
- return 0;
- }
-
- @Override
- public byte getStrongestRedstone() {
- return (byte) Math.max(this.getInternalInputRedstoneSignal((byte) 0),
- Math.max(this.getInternalInputRedstoneSignal((byte) 1),
- Math.max(this.getInternalInputRedstoneSignal((byte) 2),
- Math.max(this.getInternalInputRedstoneSignal((byte) 3),
- Math.max(this.getInternalInputRedstoneSignal((byte) 4),
- this.getInternalInputRedstoneSignal((byte) 5))))));
- }
-
- @Override
- public byte getStrongOutputRedstoneSignal(final byte aSide) {
- return aSide >= 0 && aSide < 6 && (this.mStrongRedstone & 1 << aSide) != 0
- ? (byte) (this.mSidedRedstone[aSide] & 15) : 0;
- }
-
- @Override
- public FluidTankInfo[] getTankInfo(final ForgeDirection aSide) {
- if (this.canAccessData()
- && (aSide == ForgeDirection.UNKNOWN
- || this.mMetaTileEntity.isLiquidInput((byte) aSide.ordinal())
- && this.getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn(
- (byte) aSide.ordinal(), this.getCoverIDAtSide((byte) aSide.ordinal()),
- this.getCoverDataAtSide((byte) aSide.ordinal()), null, this)
- || this.mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal())
- && this.getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut(
- (byte) aSide.ordinal(), this.getCoverIDAtSide((byte) aSide.ordinal()), this
- .getCoverDataAtSide((byte) aSide.ordinal()),
- null, this))) {
- return this.mMetaTileEntity.getTankInfo(aSide);
- }
- return new FluidTankInfo[] {};
- }
-
- public ITexture[] getTexture(final Block arg0, final byte aSide) {
- final ITexture rIcon = this.getCoverTexture(aSide);
- if (rIcon != null) {
- return new ITexture[] {
- rIcon
- };
- }
- if (this.hasValidMetaTileEntity()) {
- return this.mMetaTileEntity.getTexture(this, aSide, this.mFacing, (byte) (this.mColor - 1), this.mActive,
- this.getOutputRedstoneSignal(aSide) > 0);
- }
- return Textures.BlockIcons.ERROR_RENDERING;
- }
-
- @Override
- public ITexture[] getTexture(final byte aSide) {
- final ITexture rIcon = this.getCoverTexture(aSide);
- if (rIcon != null) {
- return new ITexture[] {
- rIcon
- };
- }
- if (this.hasValidMetaTileEntity()) {
- return this.mMetaTileEntity.getTexture(this, aSide, this.mFacing, (byte) (this.mColor - 1), this.mActive,
- this.getOutputRedstoneSignal(aSide) > 0);
- }
- return Textures.BlockIcons.ERROR_RENDERING;
- }
-
- @Override
- public long getTimer() {
- return this.mTickTimer;
- }
-
- @Override
- public long getUniversalEnergyCapacity() {
- return Math.max(this.getEUCapacity(), this.getSteamCapacity());
- }
-
- @Override
- public long getUniversalEnergyStored() {
- return Math.max(this.getStoredEU(), this.getStoredSteam());
- }
-
- public int getUpgradeCount() {
- return (this.mMuffler ? 1 : 0) + (this.mLockUpgrade ? 1 : 0) + (this.mSteamConverter ? 1 : 0)
- + this.mOtherUpgrades;
- }
-
- @Override
- public byte getWorkDataValue() {
- return this.mWorkData;
- }
-
- @Override
- public boolean hasCustomInventoryName() {
- return false;
- }
-
- @Override
- public boolean hasInventoryBeenModified() {
- return this.mInventoryChanged;
- }
-
- @Override
- public boolean hasMufflerUpgrade() {
- return this.mMuffler;
- }
-
- @Override
- public boolean hasSteamEngineUpgrade() {
- if (this.canAccessData() && this.mMetaTileEntity.isSteampowered()) {
- return true;
- }
- return this.mSteamConverter;
- }
-
- @Override
- public boolean hasThingsToDo() {
- return this.getMaxProgress() > 0;
- }
-
- protected boolean hasValidMetaTileEntity() {
- return this.mMetaTileEntity != null && this.mMetaTileEntity.getBaseMetaTileEntity() == this;
- }
-
- @Override
- public boolean hasWorkJustBeenEnabled() {
- return this.mWorkUpdate;
- }
-
- @Override
- public boolean increaseProgress(final int aProgressAmountInTicks) {
- return this.canAccessData()
- ? this.mMetaTileEntity.increaseProgress(aProgressAmountInTicks) != aProgressAmountInTicks : false;
- }
-
- @Override
- public boolean increaseStoredEnergyUnits(final long aEnergy, final boolean aIgnoreTooMuchEnergy) {
- if (!this.canAccessData()) {
- return false;
- }
- if (this.getStoredEU() < this.getEUCapacity() || aIgnoreTooMuchEnergy) {
- this.setStoredEU(this.mMetaTileEntity.getEUVar() + aEnergy);
- return true;
- }
- return false;
- }
-
- @Override
- public boolean increaseStoredSteam(final long aEnergy, final boolean aIgnoreTooMuchEnergy) {
- if (!this.canAccessData()) {
- return false;
- }
- if (this.mMetaTileEntity.getSteamVar() < this.getSteamCapacity() || aIgnoreTooMuchEnergy) {
- this.setStoredSteam(this.mMetaTileEntity.getSteamVar() + aEnergy);
- return true;
- }
- return false;
- }
-
- public int injectEnergy(final Direction aDirection, final int aAmount) {
- return this.injectEnergyUnits((byte) aDirection.toSideValue(), aAmount, 1) > 0 ? 0 : aAmount;
- }
-
- public int injectEnergy(final ForgeDirection aForgeDirection, final int aAmount) {
- return this.injectEnergyUnits((byte) aForgeDirection.ordinal(), aAmount, 1) > 0 ? 0 : aAmount;
- }
-
- @Override
- public long injectEnergyUnits(final byte aSide, final long aVoltage, long aAmperage) {
- if (!this.canAccessData() || !this.mMetaTileEntity.isElectric() || !this.inputEnergyFrom(aSide)
- || aAmperage <= 0 || aVoltage <= 0 || this.getStoredEU() >= this.getEUCapacity()
- || this.mMetaTileEntity.maxAmperesIn() <= this.mAcceptedAmperes) {
- return 0;
- }
- if (aVoltage > this.getInputVoltage()) {
- this.doExplosion(aVoltage);
- return 0;
- }
- if (this.increaseStoredEnergyUnits(aVoltage
- * (aAmperage = Math.min(aAmperage, Math.min(this.mMetaTileEntity.maxAmperesIn() - this.mAcceptedAmperes,
- 1 + (this.getEUCapacity() - this.getStoredEU()) / aVoltage))),
- true)) {
- this.mAverageEUInput[this.mAverageEUInputIndex] += aVoltage * aAmperage;
- this.mAcceptedAmperes += aAmperage;
- return aAmperage;
- }
- return 0;
- }
-
- public double injectEnergyUnits(final ForgeDirection aDirection, final double aAmount) {
- return this.injectEnergyUnits((byte) aDirection.ordinal(), (int) aAmount, 1) > 0 ? 0 : aAmount;
- }
-
- @Override
- public boolean injectRotationalEnergy(final byte aSide, final long aSpeed, final long aEnergy) {
- if (!this.canAccessData() || this.getCoverIDAtSide(aSide) != 0) {
- return false;
- }
- return this.mMetaTileEntity.injectRotationalEnergy(aSide, aSpeed, aEnergy);
- }
-
- @Override
- public boolean inputEnergyFrom(final byte aSide) {
- if (aSide == 6) {
- return true;
- }
- if (this.isServerSide()) {
- return (aSide >= 0 && aSide < 6 ? this.mActiveEUInputs[aSide] : false) && !this.mReleaseEnergy;
- }
- return this.isEnergyInputSide(aSide);
- }
-
- @Override
- public void invalidate() {
- this.tileEntityInvalid = false;
- if (this.canAccessData()) {
- this.mMetaTileEntity.onRemoval();
- this.mMetaTileEntity.setBaseMetaTileEntity(null);
- }
- super.invalidate();
- }
-
- @Override
- public boolean isActive() {
- return this.mActive;
- }
-
- public boolean isAddedToEnergyNet() {
- return false;
- }
-
- @Override
- public boolean isAllowedToWork() {
- return this.mWorks;
- }
-
- @Override
- public boolean isDigitalChest() {
- if (this.canAccessData()) {
- return this.mMetaTileEntity.isDigitalChest();
- }
- return false;
- }
-
- private boolean isEnergyInputSide(final byte aSide) {
- if (aSide >= 0 && aSide < 6) {
- if (!this.getCoverBehaviorAtSide(aSide).letsEnergyIn(aSide, this.getCoverIDAtSide(aSide),
- this.getCoverDataAtSide(aSide), this)) {
- return false;
- }
- if (this.isInvalid() || this.mReleaseEnergy) {
- return false;
- }
- if (this.canAccessData() && this.mMetaTileEntity.isElectric() && this.mMetaTileEntity.isEnetInput()) {
- return this.mMetaTileEntity.isInputFacing(aSide);
- }
- }
- return false;
- }
-
- private boolean isEnergyOutputSide(final byte aSide) {
- if (aSide >= 0 && aSide < 6) {
- if (!this.getCoverBehaviorAtSide(aSide).letsEnergyOut(aSide, this.getCoverIDAtSide(aSide),
- this.getCoverDataAtSide(aSide), this)) {
- return false;
- }
- if (this.isInvalid() || this.mReleaseEnergy) {
- return this.mReleaseEnergy;
- }
- if (this.canAccessData() && this.mMetaTileEntity.isElectric() && this.mMetaTileEntity.isEnetOutput()) {
- return this.mMetaTileEntity.isOutputFacing(aSide);
- }
- }
- return false;
- }
-
- @Override
- public boolean isGivingInformation() {
- if (this.canAccessData()) {
- return this.mMetaTileEntity.isGivingInformation();
- }
- return false;
- }
-
- @Override
- public boolean isInvalidTileEntity() {
- return this.isInvalid();
- }
-
- /**
- * Can put aStack into Slot
- */
- @Override
- public boolean isItemValidForSlot(final int aIndex, final ItemStack aStack) {
- return this.canAccessData() && this.mMetaTileEntity.isItemValidForSlot(aIndex, aStack);
- }
-
- @Override
- public boolean isMufflerUpgradable() {
- return this.isUpgradable() && !this.hasMufflerUpgrade();
- }
-
- @Override
- public boolean isSteamEngineUpgradable() {
- return this.isUpgradable() && !this.hasSteamEngineUpgrade() && this.getSteamCapacity() > 0;
- }
-
- @Override
- public void issueBlockUpdate() {
- this.mNeedsBlockUpdate = true;
- }
-
- @Override
- public void issueClientUpdate() {
- this.mSendClientData = true;
- }
-
- @Override
- public void issueCoverUpdate(final byte aSide) {
- this.issueClientUpdate();
- }
-
- @Override
- public void issueTextureUpdate() {
- this.mNeedsUpdate = true;
- }
-
- public boolean isTeleporterCompatible(final Direction aSide) {
- return this.canAccessData() && this.mMetaTileEntity.isTeleporterCompatible();
- }
-
- public boolean isTeleporterCompatible(final ForgeDirection aSide) {
- return this.canAccessData() && this.mMetaTileEntity.isTeleporterCompatible();
- }
-
- @Override
- public boolean isUniversalEnergyStored(final long aEnergyAmount) {
- if (this.getUniversalEnergyStored() >= aEnergyAmount) {
- return true;
- }
- this.mHasEnoughEnergy = false;
- return false;
- }
-
- @Override
- public boolean isUpgradable() {
- return this.canAccessData() && this.getUpgradeCount() < 8;
- }
-
- @Override
- public boolean isUseableByPlayer(final EntityPlayer aPlayer) {
- return this.canAccessData() && this.playerOwnsThis(aPlayer, false) && this.mTickTimer > 40
- && this.getTileEntityOffset(0, 0, 0) == this
- && aPlayer.getDistanceSq(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5) < 64
- && this.mMetaTileEntity.isAccessAllowed(aPlayer);
- }
-
- @Override
- public boolean isValidFacing(final byte aSide) {
- if (this.canAccessData()) {
- return this.mMetaTileEntity.isFacingValid(aSide);
- }
- return false;
- }
-
- @Override
- public boolean isValidSlot(final int aIndex) {
- if (this.canAccessData()) {
- return this.mMetaTileEntity.isValidSlot(aIndex);
- }
- return false;
- }
-
- @Override
- public void markDirty() {
- super.markDirty();
- this.mInventoryChanged = true;
- }
-
- @Override
- public void onChunkUnload() {
- super.onChunkUnload();
- }
-
- @Override
- public void onEntityCollidedWithBlock(final World aWorld, final int aX, final int aY, final int aZ,
- final Entity collider) {
- this.mMetaTileEntity.onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider);
- }
-
- @Override
- public void onLeftclick(final EntityPlayer aPlayer) {
- try {
- if (aPlayer != null && this.hasValidMetaTileEntity()) {
- this.mMetaTileEntity.onLeftclick(this, aPlayer);
- }
- }
- catch (final Throwable e) {
- GT_Log.err.println(
- "Encountered Exception while leftclicking TileEntity, the Game should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!");
- e.printStackTrace(GT_Log.err);
- }
- }
-
- @Override
- public void onMachineBlockUpdate() {
- if (this.canAccessData()) {
- this.mMetaTileEntity.onMachineBlockUpdate();
- }
- }
-
- @Override
- public boolean onRightclick(final EntityPlayer aPlayer, final byte aSide, final float aX, final float aY,
- final float aZ) {
- if (this.isClientSide()) {
- if (this.getCoverBehaviorAtSide(aSide).onCoverRightclickClient(aSide, this, aPlayer, aX, aY, aZ)) {
- return true;
- }
- if (!this.getCoverBehaviorAtSide(aSide).isGUIClickable(aSide, this.getCoverIDAtSide(aSide),
- this.getCoverDataAtSide(aSide), this)) {
- return false;
- }
- }
- if (this.isServerSide()) {
- if (!this.privateAccess() || aPlayer.getDisplayName().equalsIgnoreCase(this.getOwnerName())) {
- final ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem();
- if (tCurrentItem != null) {
- if (this.getColorization() >= 0
- && GT_Utility.areStacksEqual(new ItemStack(Items.water_bucket, 1), tCurrentItem)) {
- tCurrentItem.func_150996_a(Items.bucket);
- this.setColorization((byte) (this.getColorization() >= 16 ? -2 : -1));
- return true;
- }
- if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWrenchList)) {
- if (this.mMetaTileEntity.onWrenchRightClick(aSide,
- GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ), aPlayer, aX, aY, aZ)) {
- GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer);
- GT_Utility.sendSoundToPlayers(this.worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1,
- this.xCoord, this.yCoord, this.zCoord);
- }
- return true;
- }
-
- if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sScrewdriverList)) {
- if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 200, aPlayer)) {
- this.setCoverDataAtSide(aSide,
- this.getCoverBehaviorAtSide(aSide).onCoverScrewdriverclick(aSide,
- this.getCoverIDAtSide(aSide), this.getCoverDataAtSide(aSide), this, aPlayer,
- aX, aY, aZ));
- this.mMetaTileEntity.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ);
- GT_Utility.sendSoundToPlayers(this.worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1,
- this.xCoord, this.yCoord, this.zCoord);
- }
- return true;
- }
-
- if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sHardHammerList)) {
- if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) {
- this.mInputDisabled = !this.mInputDisabled;
- if (this.mInputDisabled) {
- this.mOutputDisabled = !this.mOutputDisabled;
- }
- GT_Utility.sendChatToPlayer(aPlayer,
- "Auto-Input: " + (this.mInputDisabled ? "Disabled" : "Enabled") + " Auto-Output: "
- + (this.mOutputDisabled ? "Disabled" : "Enabled"));
- GT_Utility.sendSoundToPlayers(this.worldObj, GregTech_API.sSoundList.get(1), 1.0F, -1,
- this.xCoord, this.yCoord, this.zCoord);
- }
- return true;
- }
-
- if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSoftHammerList)) {
- if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) {
- if (this.mWorks) {
- this.disableWorking();
- }
- else {
- this.enableWorking();
- }
- GT_Utility.sendChatToPlayer(aPlayer,
- "Machine Processing: " + (this.isAllowedToWork() ? "Enabled" : "Disabled"));
- GT_Utility.sendSoundToPlayers(this.worldObj, GregTech_API.sSoundList.get(101), 1.0F, -1,
- this.xCoord, this.yCoord, this.zCoord);
- }
- return true;
- }
-
- if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSolderingToolList)) {
- final byte tSide = GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ);
- if (GT_ModHandler.useSolderingIron(tCurrentItem, aPlayer)) {
- this.mStrongRedstone ^= 1 << tSide;
- GT_Utility.sendChatToPlayer(aPlayer, "Redstone Output at Side " + tSide + " set to: "
- + ((this.mStrongRedstone & 1 << tSide) != 0 ? "Strong" : "Weak"));
- GT_Utility.sendSoundToPlayers(this.worldObj, GregTech_API.sSoundList.get(103), 3.0F, -1,
- this.xCoord, this.yCoord, this.zCoord);
- }
- return true;
- }
-
- if (this.getCoverIDAtSide(aSide) == 0) {
- if (GregTech_API.sCovers.containsKey(new GT_ItemStack(tCurrentItem))) {
- if (GregTech_API.getCoverBehavior(tCurrentItem).isCoverPlaceable(aSide,
- new GT_ItemStack(tCurrentItem), this)
- && this.mMetaTileEntity.allowCoverOnSide(aSide, new GT_ItemStack(tCurrentItem))) {
- this.setCoverItemAtSide(aSide, tCurrentItem);
- if (!aPlayer.capabilities.isCreativeMode) {
- tCurrentItem.stackSize--;
- }
- GT_Utility.sendSoundToPlayers(this.worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1,
- this.xCoord, this.yCoord, this.zCoord);
- }
- return true;
- }
- }
- else {
- if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sCrowbarList)) {
- if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) {
- GT_Utility.sendSoundToPlayers(this.worldObj, GregTech_API.sSoundList.get(0), 1.0F, -1,
- this.xCoord, this.yCoord, this.zCoord);
- this.dropCover(aSide, aSide, false);
- }
- return true;
- }
- }
- }
-
- if (this.getCoverBehaviorAtSide(aSide).onCoverRightclick(aSide, this.getCoverIDAtSide(aSide),
- this.getCoverDataAtSide(aSide), this, aPlayer, aX, aY, aZ)) {
- return true;
- }
-
- if (!this.getCoverBehaviorAtSide(aSide).isGUIClickable(aSide, this.getCoverIDAtSide(aSide),
- this.getCoverDataAtSide(aSide), this)) {
- return false;
- }
-
- if (this.isUpgradable() && aPlayer.inventory
- .getCurrentItem() != null) {/*
- * if (ItemList.
- * Upgrade_SteamEngine.
- * isStackEqual(aPlayer.
- * inventory.getCurrentItem(
- * ))) { if
- * (addSteamEngineUpgrade())
- * { GT_Utility.
- * sendSoundToPlayers(
- * worldObj,
- * GregTech_API.sSoundList.
- * get(3), 1.0F, -1, xCoord,
- * yCoord, zCoord); if
- * (!aPlayer.capabilities.
- * isCreativeMode)
- * aPlayer.inventory.
- * getCurrentItem().
- * stackSize--; } return
- * true; }
- */
- if (ItemList.Upgrade_Muffler.isStackEqual(aPlayer.inventory.getCurrentItem())) {
- if (this.addMufflerUpgrade()) {
- GT_Utility.sendSoundToPlayers(this.worldObj, GregTech_API.sSoundList.get(3), 1.0F, -1,
- this.xCoord, this.yCoord, this.zCoord);
- if (!aPlayer.capabilities.isCreativeMode) {
- aPlayer.inventory.getCurrentItem().stackSize--;
- }
- }
- return true;
- }
- if (ItemList.Upgrade_Lock.isStackEqual(aPlayer.inventory.getCurrentItem())) {
- if (this.isUpgradable() && !this.mLockUpgrade) {
- this.mLockUpgrade = true;
- this.setOwnerName(aPlayer.getDisplayName());
- GT_Utility.sendSoundToPlayers(this.worldObj, GregTech_API.sSoundList.get(3), 1.0F, -1,
- this.xCoord, this.yCoord, this.zCoord);
- if (!aPlayer.capabilities.isCreativeMode) {
- aPlayer.inventory.getCurrentItem().stackSize--;
- }
+ private final GT_CoverBehavior[] mCoverBehaviors = new GT_CoverBehavior[]{GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior};
+ protected MetaTileEntity mMetaTileEntity;
+ protected long mStoredEnergy = 0, mStoredSteam = 0;
+ protected int mAverageEUInputIndex = 0, mAverageEUOutputIndex = 0;
+ protected boolean mReleaseEnergy = false;
+ protected int[] mAverageEUInput = new int[]{0, 0, 0, 0, 0}, mAverageEUOutput = new int[]{0, 0, 0, 0, 0};
+ private boolean[] mActiveEUInputs = new boolean[]{false, false, false, false, false, false}, mActiveEUOutputs = new boolean[]{false, false, false, false, false, false};
+ private byte[] mSidedRedstone = new byte[]{15, 15, 15, 15, 15, 15};
+ private int[] mCoverSides = new int[]{0, 0, 0, 0, 0, 0}, mCoverData = new int[]{0, 0, 0, 0, 0, 0}, mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING];
+ private boolean mHasEnoughEnergy = true, mRunningThroughTick = false, mInputDisabled = false, mOutputDisabled = false, mMuffler = false, mLockUpgrade = false, mActive = false, mRedstone = false, mWorkUpdate = false, mSteamConverter = false, mInventoryChanged = false, mWorks = true, mNeedsUpdate = true, mNeedsBlockUpdate = true, mSendClientData = false, oRedstone = false;
+ private byte mColor = 0, oColor = 0, mStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, oLightValueClient = -1, oLightValue = -1, mLightValue = 0, mOtherUpgrades = 0, mFacing = 0, oFacing = 0, mWorkData = 0;
+ private int mDisplayErrorCode = 0, oX = 0, oY = 0, oZ = 0, mTimeStatisticsIndex = 0, mLagWarningCount = 0;
+ private short mID = 0;
+ private long mTickTimer = 0, oOutput = 0, mAcceptedAmperes = Long.MAX_VALUE;
+ private String mOwnerName = "";
+ private NBTTagCompound mRecipeStuff = new NBTTagCompound();
+
+ public GregtechBaseMetaTileEntityLossless() {
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound aNBT) {
+ try {
+ super.writeToNBT(aNBT);
+ } catch (Throwable e) {
+ GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!");
+ e.printStackTrace(GT_Log.err);
+ }
+ try {
+ aNBT.setInteger("mID", mID);
+ aNBT.setLong("mStoredSteam", mStoredSteam);
+ aNBT.setLong("mStoredEnergy", mStoredEnergy);
+ aNBT.setIntArray("mCoverData", mCoverData);
+ aNBT.setIntArray("mCoverSides", mCoverSides);
+ aNBT.setByteArray("mRedstoneSided", mSidedRedstone);
+ aNBT.setByte("mColor", mColor);
+ aNBT.setByte("mLightValue", mLightValue);
+ aNBT.setByte("mOtherUpgrades", mOtherUpgrades);
+ aNBT.setByte("mWorkData", mWorkData);
+ aNBT.setByte("mStrongRedstone", mStrongRedstone);
+ aNBT.setShort("mFacing", mFacing);
+ aNBT.setString("mOwnerName", mOwnerName);
+ aNBT.setBoolean("mLockUpgrade", mLockUpgrade);
+ aNBT.setBoolean("mMuffler", mMuffler);
+ aNBT.setBoolean("mSteamConverter", mSteamConverter);
+ aNBT.setBoolean("mActive", mActive);
+ aNBT.setBoolean("mRedstone", mRedstone);
+ aNBT.setBoolean("mWorks", !mWorks);
+ aNBT.setBoolean("mInputDisabled", mInputDisabled);
+ aNBT.setBoolean("mOutputDisabled", mOutputDisabled);
+ aNBT.setTag("GT.CraftingComponents", mRecipeStuff);
+ } catch (Throwable e) {
+ GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!");
+ e.printStackTrace(GT_Log.err);
+ }
+ try {
+ if (hasValidMetaTileEntity()) {
+ NBTTagList tItemList = new NBTTagList();
+ for (int i = 0; i < mMetaTileEntity.getRealInventory().length; i++) {
+ ItemStack tStack = mMetaTileEntity.getRealInventory()[i];
+ if (tStack != null) {
+ NBTTagCompound tTag = new NBTTagCompound();
+ tTag.setInteger("IntSlot", i);
+ tStack.writeToNBT(tTag);
+ tItemList.appendTag(tTag);
+ }
+ }
+ aNBT.setTag("Inventory", tItemList);
+
+ try {
+ mMetaTileEntity.saveNBTData(aNBT);
+ } catch (Throwable e) {
+ GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!");
+ e.printStackTrace(GT_Log.err);
+ }
+ }
+ } catch (Throwable e) {
+ GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!");
+ e.printStackTrace(GT_Log.err);
+ }
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound aNBT) {
+ super.readFromNBT(aNBT);
+ setInitialValuesAsNBT(aNBT, (short) 0);
+ }
+
+ @Override
+ public void setInitialValuesAsNBT(NBTTagCompound aNBT, short aID) {
+ if (aNBT == null) {
+ if (aID > 0) mID = aID;
+ else mID = mID > 0 ? mID : 0;
+ if (mID != 0) createNewMetatileEntity(mID);
+ mSidedRedstone = (hasValidMetaTileEntity() && mMetaTileEntity.hasSidedRedstoneOutputBehavior() ? new byte[]{0, 0, 0, 0, 0, 0} : new byte[]{15, 15, 15, 15, 15, 15});
+ } else {
+ if (aID <= 0) mID = (short) aNBT.getInteger("mID");
+ else mID = aID;
+ mStoredSteam = aNBT.getInteger("mStoredSteam");
+ mStoredEnergy = aNBT.getInteger("mStoredEnergy");
+ mColor = aNBT.getByte("mColor");
+ mLightValue = aNBT.getByte("mLightValue");
+ mWorkData = aNBT.getByte("mWorkData");
+ mStrongRedstone = aNBT.getByte("mStrongRedstone");
+ mFacing = oFacing = (byte) aNBT.getShort("mFacing");
+ mOwnerName = aNBT.getString("mOwnerName");
+ mLockUpgrade = aNBT.getBoolean("mLockUpgrade");
+ mMuffler = aNBT.getBoolean("mMuffler");
+ mSteamConverter = aNBT.getBoolean("mSteamConverter");
+ mActive = aNBT.getBoolean("mActive");
+ mRedstone = aNBT.getBoolean("mRedstone");
+ mWorks = !aNBT.getBoolean("mWorks");
+ mInputDisabled = aNBT.getBoolean("mInputDisabled");
+ mOutputDisabled = aNBT.getBoolean("mOutputDisabled");
+ mOtherUpgrades = (byte) (aNBT.getByte("mOtherUpgrades") + aNBT.getByte("mBatteries") + aNBT.getByte("mLiBatteries"));
+ mCoverSides = aNBT.getIntArray("mCoverSides");
+ mCoverData = aNBT.getIntArray("mCoverData");
+ mSidedRedstone = aNBT.getByteArray("mRedstoneSided");
+ mRecipeStuff = aNBT.getCompoundTag("GT.CraftingComponents");
+
+ if (mCoverData.length != 6) mCoverData = new int[]{0, 0, 0, 0, 0, 0};
+ if (mCoverSides.length != 6) mCoverSides = new int[]{0, 0, 0, 0, 0, 0};
+ if (mSidedRedstone.length != 6)
+ if (hasValidMetaTileEntity() && mMetaTileEntity.hasSidedRedstoneOutputBehavior())
+ mSidedRedstone = new byte[]{0, 0, 0, 0, 0, 0};
+ else mSidedRedstone = new byte[]{15, 15, 15, 15, 15, 15};
+
+ for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]);
+
+ if (mID != 0 && createNewMetatileEntity(mID)) {
+ NBTTagList tItemList = aNBT.getTagList("Inventory", 10);
+ for (int i = 0; i < tItemList.tagCount(); i++) {
+ NBTTagCompound tTag = tItemList.getCompoundTagAt(i);
+ int tSlot = tTag.getInteger("IntSlot");
+ if (tSlot >= 0 && tSlot < mMetaTileEntity.getRealInventory().length) {
+ mMetaTileEntity.getRealInventory()[tSlot] = GT_Utility.loadItem(tTag);
+ }
+ }
+
+ try {
+ mMetaTileEntity.loadNBTData(aNBT);
+ } catch (Throwable e) {
+ GT_Log.err.println("Encountered Exception while loading MetaTileEntity, the Server should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!");
+ e.printStackTrace(GT_Log.err);
+ }
+ }
+ }
+
+ if (mCoverData.length != 6) mCoverData = new int[]{0, 0, 0, 0, 0, 0};
+ if (mCoverSides.length != 6) mCoverSides = new int[]{0, 0, 0, 0, 0, 0};
+ if (mSidedRedstone.length != 6)
+ if (hasValidMetaTileEntity() && mMetaTileEntity.hasSidedRedstoneOutputBehavior())
+ mSidedRedstone = new byte[]{0, 0, 0, 0, 0, 0};
+ else mSidedRedstone = new byte[]{15, 15, 15, 15, 15, 15};
+
+ for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]);
+ }
+
+ private boolean createNewMetatileEntity(short aID) {
+ if (aID <= 0 || aID >= GregTech_API.METATILEENTITIES.length || GregTech_API.METATILEENTITIES[aID] == null) {
+ GT_Log.err.println("MetaID " + aID + " not loadable => locking TileEntity!");
+ } else {
+ if (aID != 0) {
+ if (hasValidMetaTileEntity()) mMetaTileEntity.setBaseMetaTileEntity(null);
+ GregTech_API.METATILEENTITIES[aID].newMetaEntity(this).setBaseMetaTileEntity(this);
+ mTickTimer = 0;
+ mID = aID;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Used for ticking special BaseMetaTileEntities, which need that for Energy Conversion
+ * It's called right before onPostTick()
+ */
+ public void updateStatus() {
+ //
+ }
+
+ /**
+ * Called when trying to charge Items
+ */
+ public void chargeItem(ItemStack aStack) {
+ decreaseStoredEU(GT_ModHandler.chargeElectricItem(aStack, (int) Math.min(Integer.MAX_VALUE, getStoredEU()), (int) Math.min(Integer.MAX_VALUE, mMetaTileEntity.getOutputTier()), false, false), true);
+ }
+
+ /**
+ * Called when trying to discharge Items
+ */
+ public void dischargeItem(ItemStack aStack) {
+ increaseStoredEnergyUnits(GT_ModHandler.dischargeElectricItem(aStack, (int) Math.min(Integer.MAX_VALUE, getEUCapacity() - getStoredEU()), (int) Math.min(Integer.MAX_VALUE, mMetaTileEntity.getInputTier()), false, false, false), true);
+ }
+
+ @Override
+ public void updateEntity() {
+ super.updateEntity();
+
+ if (!hasValidMetaTileEntity()) {
+ if (mMetaTileEntity == null) return;
+ mMetaTileEntity.setBaseMetaTileEntity(this);
+ }
+
+ mRunningThroughTick = true;
+ long tTime = System.currentTimeMillis();
+
+ for (int tCode = 0; hasValidMetaTileEntity() && tCode >= 0; ) {
+ try {
+ switch (tCode) {
+ case 0:
+ tCode++;
+ if (mTickTimer++ == 0) {
+ oX = xCoord;
+ oY = yCoord;
+ oZ = zCoord;
+ if (isServerSide()) for (byte i = 0; i < 6; i++)
+ if (getCoverIDAtSide(i) != 0)
+ if (!mMetaTileEntity.allowCoverOnSide(i, new GT_ItemStack(getCoverIDAtSide(i))))
+ dropCover(i, i, true);
+
+ worldObj.markTileEntityChunkModified(xCoord, yCoord, zCoord, this);
+
+ mMetaTileEntity.onFirstTick(this);
+ if (!hasValidMetaTileEntity()) {
+ mRunningThroughTick = false;
+ return;
+ }
+ }
+ case 1:
+ tCode++;
+ if (isClientSide()) {
+ if (mColor != oColor) {
+ mMetaTileEntity.onColorChangeClient(oColor = mColor);
+ issueTextureUpdate();
+ }
+
+ if (mLightValue != oLightValueClient) {
+ worldObj.setLightValue(EnumSkyBlock.Block, xCoord, yCoord, zCoord, mLightValue);
+ worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord);
+ worldObj.updateLightByType(EnumSkyBlock.Block, xCoord + 1, yCoord, zCoord);
+ worldObj.updateLightByType(EnumSkyBlock.Block, xCoord - 1, yCoord, zCoord);
+ worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord + 1, zCoord);
+ worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord - 1, zCoord);
+ worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord + 1);
+ worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord - 1);
+ oLightValueClient = mLightValue;
+ issueTextureUpdate();
+ }
+
+ if (mNeedsUpdate) {
+ worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
+ //worldObj.func_147479_m(xCoord, yCoord, zCoord);
+ mNeedsUpdate = false;
+ }
+ }
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ if (isServerSide() && mTickTimer > 10) {
+ for (byte i = (byte) (tCode - 2); i < 6; i++)
+ if (getCoverIDAtSide(i) != 0) {
+ tCode++;
+ GT_CoverBehavior tCover = getCoverBehaviorAtSide(i);
+ int tCoverTickRate = tCover.getTickRate(i, getCoverIDAtSide(i), mCoverData[i], this);
+ if (tCoverTickRate > 0 && mTickTimer % tCoverTickRate == 0) {
+ mCoverData[i] = tCover.doCoverThings(i, getInputRedstoneSignal(i), getCoverIDAtSide(i), mCoverData[i], this, mTickTimer);
+ if (!hasValidMetaTileEntity()) {
+ mRunningThroughTick = false;
+ return;
+ }
+ }
+ }
+
+ }
+ case 8:
+ tCode = 9;
+ if (isServerSide()) {
+ if (++mAverageEUInputIndex >= mAverageEUInput.length) mAverageEUInputIndex = 0;
+ if (++mAverageEUOutputIndex >= mAverageEUOutput.length) mAverageEUOutputIndex = 0;
+
+ mAverageEUInput[mAverageEUInputIndex] = 0;
+ mAverageEUOutput[mAverageEUOutputIndex] = 0;
+ }
+ case 9:
+ tCode++;
+ mMetaTileEntity.onPreTick(this, mTickTimer);
+ if (!hasValidMetaTileEntity()) {
+ mRunningThroughTick = false;
+ return;
+ }
+ case 10:
+ tCode++;
+ if (isServerSide()) {
+ if (mRedstone != oRedstone || mTickTimer == 10) {
+ for (byte i = 0; i < 6; i++)
+ mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]);
+ oRedstone = mRedstone;
+ issueBlockUpdate();
+ }
+
+ if (xCoord != oX || yCoord != oY || zCoord != oZ) {
+ oX = xCoord;
+ oY = yCoord;
+ oZ = zCoord;
+ issueClientUpdate();
+ clearTileEntityBuffer();
+ }
+
+ if (mFacing != oFacing) {
+ oFacing = mFacing;
+ for (byte i = 0; i < 6; i++)
+ if (getCoverIDAtSide(i) != 0)
+ if (!mMetaTileEntity.allowCoverOnSide(i, new GT_ItemStack(getCoverIDAtSide(i))))
+ dropCover(i, i, true);
+ issueBlockUpdate();
+ }
+
+ if (mTickTimer > 20 && mMetaTileEntity.isElectric()) {
+ mAcceptedAmperes = 0;
+
+ if (getOutputVoltage() != oOutput) {
+ oOutput = getOutputVoltage();
+ }
+
+ if (mMetaTileEntity.isEnetOutput() || mMetaTileEntity.isEnetInput()) {
+ for (byte i = 0; i < 6; i++) {
+ boolean
+ temp = isEnergyInputSide(i);
+ if (temp != mActiveEUInputs[i]) {
+ mActiveEUInputs[i] = temp;
+ }
+ temp = isEnergyOutputSide(i);
+ if (temp != mActiveEUOutputs[i]) {
+ mActiveEUOutputs[i] = temp;
+ }
+ }
+ }
+
+
+
+ if (mMetaTileEntity.isEnetOutput() && oOutput > 0) {
+ long tOutputVoltage = oOutput, tUsableAmperage = Math.min(getOutputAmperage(), (getStoredEU() - mMetaTileEntity.getMinimumStoredEU()) / tOutputVoltage);
+ if (tUsableAmperage > 0) {
+ long tEU = tOutputVoltage * IEnergyConnected.Util.emitEnergyToNetwork(oOutput, tUsableAmperage, this);
+ mAverageEUOutput[mAverageEUOutputIndex] += tEU;
+ decreaseStoredEU(tEU, true);
+ }
+ }
+
+
+ if (getEUCapacity() > 0) {
+ if (GregTech_API.sMachineFireExplosions && getRandomNumber(1000) == 0) {
+ Block tBlock = getBlockAtSide((byte) getRandomNumber(6));
+ if (tBlock != null && tBlock instanceof BlockFire) doEnergyExplosion();
+ }
+
+ if (!hasValidMetaTileEntity()) {
+ mRunningThroughTick = false;
+ return;
+ }
+
+ if (getRandomNumber(1000) == 0) {
+ if ((getCoverIDAtSide((byte) 1) == 0 && worldObj.getPrecipitationHeight(xCoord, zCoord) - 2 < yCoord)
+ || (getCoverIDAtSide((byte) 2) == 0 && worldObj.getPrecipitationHeight(xCoord, zCoord - 1) - 1 < yCoord)
+ || (getCoverIDAtSide((byte) 3) == 0 && worldObj.getPrecipitationHeight(xCoord, zCoord + 1) - 1 < yCoord)
+ || (getCoverIDAtSide((byte) 4) == 0 && worldObj.getPrecipitationHeight(xCoord - 1, zCoord) - 1 < yCoord)
+ || (getCoverIDAtSide((byte) 5) == 0 && worldObj.getPrecipitationHeight(xCoord + 1, zCoord) - 1 < yCoord)) {
+ if (GregTech_API.sMachineRainExplosions && worldObj.isRaining() && getBiome().rainfall > 0) {
+ if (getRandomNumber(10) == 0) {
+ try {
+ GT_Mod.instance.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather");
+ } catch (Exception e) {
+ }
+ doEnergyExplosion();
+ } else setOnFire();
+ }
+ if (!hasValidMetaTileEntity()) {
+ mRunningThroughTick = false;
+ return;
+ }
+ if (GregTech_API.sMachineThunderExplosions && worldObj.isThundering() && getBiome().rainfall > 0 && getRandomNumber(3) == 0) {
+ try {
+ GT_Mod.instance.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather");
+ } catch (Exception e) {
+ }
+ doEnergyExplosion();
+ }
+ }
+ }
+ }
+ }
+
+ if (!hasValidMetaTileEntity()) {
+ mRunningThroughTick = false;
+ return;
+ }
+ }
+ case 11:
+ tCode++;
+ if (isServerSide()) {
+ if (mMetaTileEntity.dechargerSlotCount() > 0 && getStoredEU() < getEUCapacity()) {
+ for (int i = mMetaTileEntity.dechargerSlotStartIndex(), k = mMetaTileEntity.dechargerSlotCount() + i; i < k; i++) {
+ if (mMetaTileEntity.mInventory[i] != null && getStoredEU() < getEUCapacity()) {
+ dischargeItem(mMetaTileEntity.mInventory[i]);
+ if (mMetaTileEntity.mInventory[i].stackSize <= 0)
+ mMetaTileEntity.mInventory[i] = null;
+ mInventoryChanged = true;
+ }
+ }
+ }
+ }
+ case 12:
+ tCode++;
+ if (isServerSide()) {
+ if (mMetaTileEntity.rechargerSlotCount() > 0 && getStoredEU() > 0) {
+ for (int i = mMetaTileEntity.rechargerSlotStartIndex(), k = mMetaTileEntity.rechargerSlotCount() + i; i < k; i++) {
+ if (getStoredEU() > 0 && mMetaTileEntity.mInventory[i] != null) {
+ chargeItem(mMetaTileEntity.mInventory[i]);
+ if (mMetaTileEntity.mInventory[i].stackSize <= 0)
+ mMetaTileEntity.mInventory[i] = null;
+ mInventoryChanged = true;
+ }
+ }
+ }
+ }
+ case 13:
+ tCode++;
+ updateStatus();
+ if (!hasValidMetaTileEntity()) {
+ mRunningThroughTick = false;
+ return;
+ }
+ case 14:
+ tCode++;
+ mMetaTileEntity.onPostTick(this, mTickTimer);
+ if (!hasValidMetaTileEntity()) {
+ mRunningThroughTick = false;
+ return;
+ }
+ case 15:
+ tCode++;
+ if (isServerSide()) {
+ if (mTickTimer % 10 == 0) {
+ if (mSendClientData) {
+ NW.sendPacketToAllPlayersInRange(worldObj, new GT_Packet_TileEntity(xCoord, (short) yCoord, zCoord, mID, mCoverSides[0], mCoverSides[1], mCoverSides[2], mCoverSides[3], mCoverSides[4], mCoverSides[5], oTextureData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0)), oUpdateData = hasValidMetaTileEntity() ? mMetaTileEntity.getUpdateData() : 0, oRedstoneData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) | ((mSidedRedstone[2] > 0) ? 4 : 0) | ((mSidedRedstone[3] > 0) ? 8 : 0) | ((mSidedRedstone[4] > 0) ? 16 : 0) | ((mSidedRedstone[5] > 0) ? 32 : 0)), oColor = mColor), xCoord, zCoord);
+ mSendClientData = false;
+ }
+ }
+
+ if (mTickTimer > 10) {
+ byte tData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0));
+ if (tData != oTextureData) sendBlockEvent((byte) 0, oTextureData = tData);
+ tData = mMetaTileEntity.getUpdateData();
+ if (tData != oUpdateData) sendBlockEvent((byte) 1, oUpdateData = tData);
+ if (mColor != oColor) sendBlockEvent((byte) 2, oColor = mColor);
+ tData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) | ((mSidedRedstone[2] > 0) ? 4 : 0) | ((mSidedRedstone[3] > 0) ? 8 : 0) | ((mSidedRedstone[4] > 0) ? 16 : 0) | ((mSidedRedstone[5] > 0) ? 32 : 0));
+ if (tData != oRedstoneData) sendBlockEvent((byte) 3, oRedstoneData = tData);
+ if (mLightValue != oLightValue) {
+ worldObj.setLightValue(EnumSkyBlock.Block, xCoord, yCoord, zCoord, mLightValue);
+ worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord);
+ worldObj.updateLightByType(EnumSkyBlock.Block, xCoord + 1, yCoord, zCoord);
+ worldObj.updateLightByType(EnumSkyBlock.Block, xCoord - 1, yCoord, zCoord);
+ worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord + 1, zCoord);
+ worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord - 1, zCoord);
+ worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord + 1);
+ worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord - 1);
+ issueTextureUpdate();
+ sendBlockEvent((byte) 7, oLightValue = mLightValue);
+ }
+ }
+
+ if (mNeedsBlockUpdate) {
+ worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockOffset(0, 0, 0));
+ mNeedsBlockUpdate = false;
+ }
+ }
+ default:
+ tCode = -1;
+ break;
+ }
+ } catch (Throwable e) {
+ GT_Log.err.println("Encountered Exception while ticking MetaTileEntity in Step " + (tCode - 1) + ". The Game should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!");
+ e.printStackTrace(GT_Log.err);
+ }
+ }
+
+ if (isServerSide() && hasValidMetaTileEntity()) {
+ tTime = System.currentTimeMillis() - tTime;
+ if (mTimeStatistics.length > 0)
+ mTimeStatistics[mTimeStatisticsIndex = (mTimeStatisticsIndex + 1) % mTimeStatistics.length] = (int) tTime;
+ if (tTime > 0 && tTime > GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING && mTickTimer > 1000 && getMetaTileEntity().doTickProfilingMessageDuringThisTick() && mLagWarningCount++ < 10)
+ System.out.println("WARNING: Possible Lag Source at [" + xCoord + ", " + yCoord + ", " + zCoord + "] in Dimension " + worldObj.provider.dimensionId + " with " + tTime + "ms caused by an instance of " + getMetaTileEntity().getClass());
+ }
+
+ mWorkUpdate = mInventoryChanged = mRunningThroughTick = false;
+ }
+
+ @Override
+ public Packet getDescriptionPacket() {
+ issueClientUpdate();
+ return null;
+ }
+
+ public final void receiveMetaTileEntityData(short aID, int aCover0, int aCover1, int aCover2, int aCover3, int aCover4, int aCover5, byte aTextureData, byte aUpdateData, byte aRedstoneData, byte aColorData) {
+ issueTextureUpdate();
+ if (mID != aID && aID > 0) {
+ mID = aID;
+ createNewMetatileEntity(mID);
+ }
+
+ mCoverSides[0] = aCover0;
+ mCoverSides[1] = aCover1;
+ mCoverSides[2] = aCover2;
+ mCoverSides[3] = aCover3;
+ mCoverSides[4] = aCover4;
+ mCoverSides[5] = aCover5;
+
+ for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]);
+
+ receiveClientEvent(0, aTextureData);
+ receiveClientEvent(1, aUpdateData);
+ receiveClientEvent(2, aColorData);
+ receiveClientEvent(3, aRedstoneData);
+ }
+
+ @Override
+ public boolean receiveClientEvent(int aEventID, int aValue) {
+ super.receiveClientEvent(aEventID, aValue);
+
+ if (hasValidMetaTileEntity()) {
+ try {
+ mMetaTileEntity.receiveClientEvent((byte) aEventID, (byte) aValue);
+ } catch (Throwable e) {
+ GT_Log.err.println("Encountered Exception while receiving Data from the Server, the Client should've been crashed by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!");
+ e.printStackTrace(GT_Log.err);
+ }
+ }
+
+ if (isClientSide()) {
+ issueTextureUpdate();
+ switch (aEventID) {
+ case 0:
+ mFacing = (byte) (aValue & 7);
+ mActive = ((aValue & 8) != 0);
+ mRedstone = ((aValue & 16) != 0);
+ //mLockUpgrade = ((aValue&32) != 0);
+ break;
+ case 1:
+ if (hasValidMetaTileEntity()) mMetaTileEntity.onValueUpdate((byte) aValue);
+ break;
+ case 2:
+ if (aValue > 16 || aValue < 0) aValue = 0;
+ mColor = (byte) aValue;
+ break;
+ case 3:
+ mSidedRedstone[0] = (byte) ((aValue & 1) > 0 ? 15 : 0);
+ mSidedRedstone[1] = (byte) ((aValue & 2) > 0 ? 15 : 0);
+ mSidedRedstone[2] = (byte) ((aValue & 4) > 0 ? 15 : 0);
+ mSidedRedstone[3] = (byte) ((aValue & 8) > 0 ? 15 : 0);
+ mSidedRedstone[4] = (byte) ((aValue & 16) > 0 ? 15 : 0);
+ mSidedRedstone[5] = (byte) ((aValue & 32) > 0 ? 15 : 0);
+ break;
+ case 4:
+ if (hasValidMetaTileEntity() && mTickTimer > 20)
+ mMetaTileEntity.doSound((byte) aValue, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5);
+ break;
+ case 5:
+ if (hasValidMetaTileEntity() && mTickTimer > 20)
+ mMetaTileEntity.startSoundLoop((byte) aValue, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5);
+ break;
+ case 6:
+ if (hasValidMetaTileEntity() && mTickTimer > 20)
+ mMetaTileEntity.stopSoundLoop((byte) aValue, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5);
+ break;
+ case 7:
+ mLightValue = (byte) aValue;
+ break;
+ }
+ }
+ return true;
+ }
+
+ public ArrayList<String> getDebugInfo(EntityPlayer aPlayer, int aLogLevel) {
+ ArrayList<String> tList = new ArrayList<String>();
+ if (aLogLevel > 2) {
+ tList.add("Meta-ID: " + mID + (canAccessData() ? " valid" : " invalid") + (mMetaTileEntity == null ? " MetaTileEntity == null!" : " "));
+ }
+ if (aLogLevel > 1) {
+ if (mTimeStatistics.length > 0) {
+ double tAverageTime = 0;
+ for (int tTime : mTimeStatistics) tAverageTime += tTime;
+ tList.add("This particular TileEntity has caused an average CPU-load of ~" + (tAverageTime / mTimeStatistics.length) + "ms over the last " + mTimeStatistics.length + " ticks.");
+ }
+ if (mLagWarningCount > 0) {
+ tList.add("This TileEntity has also caused " + (mLagWarningCount >= 10 ? "more than 10" : mLagWarningCount) + " Lag Spike Warnings (anything taking longer than " + GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING + "ms) on the Server.");
+ }
+ tList.add("Is" + (mMetaTileEntity.isAccessAllowed(aPlayer) ? " " : " not ") + "accessible for you");
+ }
+ if (aLogLevel > 0) {
+ if (getSteamCapacity() > 0 && hasSteamEngineUpgrade())
+ tList.add(getStoredSteam() + " of " + getSteamCapacity() + " Steam");
+ tList.add("Machine is " + (mActive ? "active" : "inactive"));
+ if (!mHasEnoughEnergy)
+ tList.add("ATTENTION: This Device consumes Energy at a higher Rate than you input. You could insert more to speed up the process.");
+ }
+ return mMetaTileEntity.getSpecialDebugInfo(this, aPlayer, aLogLevel, tList);
+ }
+
+ @Override
+ public void issueTextureUpdate() {
+ mNeedsUpdate = true;
+ }
+
+ @Override
+ public void issueBlockUpdate() {
+ mNeedsBlockUpdate = true;
+ }
+
+ @Override
+ public void issueClientUpdate() {
+ mSendClientData = true;
+ }
+
+ @Override
+ public void issueCoverUpdate(byte aSide) {
+ issueClientUpdate();
+ }
+
+ @Override
+ public byte getStrongestRedstone() {
+ return (byte) Math.max(getInternalInputRedstoneSignal((byte) 0), Math.max(getInternalInputRedstoneSignal((byte) 1), Math.max(getInternalInputRedstoneSignal((byte) 2), Math.max(getInternalInputRedstoneSignal((byte) 3), Math.max(getInternalInputRedstoneSignal((byte) 4), getInternalInputRedstoneSignal((byte) 5))))));
+ }
+
+ @Override
+ public boolean getRedstone() {
+ return getRedstone((byte) 0) || getRedstone((byte) 1) || getRedstone((byte) 2) || getRedstone((byte) 3) || getRedstone((byte) 4) || getRedstone((byte) 5);
+ }
+
+ @Override
+ public boolean getRedstone(byte aSide) {
+ return getInternalInputRedstoneSignal(aSide) > 0;
+ }
+
+ public ITexture getCoverTexture(byte aSide) {
+ return GregTech_API.sCovers.get(new GT_ItemStack(getCoverIDAtSide(aSide)));
+ }
+
+ @Override
+ public boolean isGivingInformation() {
+ if (canAccessData()) return mMetaTileEntity.isGivingInformation();
+ return false;
+ }
+
+ @Override
+ public boolean isValidFacing(byte aSide) {
+ if (canAccessData()) return mMetaTileEntity.isFacingValid(aSide);
+ return false;
+ }
+
+ @Override
+ public byte getBackFacing() {
+ return GT_Utility.getOppositeSide(mFacing);
+ }
+
+ @Override
+ public byte getFrontFacing() {
+ return mFacing;
+ }
+
+ @Override
+ public void setFrontFacing(byte aFacing) {
+ if (isValidFacing(aFacing)) {
+ mFacing = aFacing;
+ mMetaTileEntity.onFacingChange();
+ onMachineBlockUpdate();
+ }
+ }
+
+ @Override
+ public int getSizeInventory() {
+ if (canAccessData()) return mMetaTileEntity.getSizeInventory();
+ return 0;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(int aIndex) {
+ if (canAccessData()) return mMetaTileEntity.getStackInSlot(aIndex);
+ return null;
+ }
+
+ @Override
+ public void setInventorySlotContents(int aIndex, ItemStack aStack) {
+ mInventoryChanged = true;
+ if (canAccessData())
+ mMetaTileEntity.setInventorySlotContents(aIndex, worldObj.isRemote ? aStack : GT_OreDictUnificator.setStack(true, aStack));
+ }
+
+ @Override
+ public String getInventoryName() {
+ if (canAccessData()) return mMetaTileEntity.getInventoryName();
+ if (GregTech_API.METATILEENTITIES[mID] != null) return GregTech_API.METATILEENTITIES[mID].getInventoryName();
+ return "";
+ }
+
+ @Override
+ public int getInventoryStackLimit() {
+ if (canAccessData()) return mMetaTileEntity.getInventoryStackLimit();
+ return 64;
+ }
+
+ @Override
+ public void openInventory() {
+ if (canAccessData()) mMetaTileEntity.onOpenGUI();
+ }
+
+ @Override
+ public void closeInventory() {
+ if (canAccessData()) mMetaTileEntity.onCloseGUI();
+ }
+
+ @Override
+ public boolean isUseableByPlayer(EntityPlayer aPlayer) {
+ return canAccessData() && playerOwnsThis(aPlayer, false) && mTickTimer > 40 && getTileEntityOffset(0, 0, 0) == this && aPlayer.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64 && mMetaTileEntity.isAccessAllowed(aPlayer);
+ }
+
+ @Override
+ public void validate() {
+ super.validate();
+ mTickTimer = 0;
+ }
+
+ @Override
+ public void invalidate() {
+ tileEntityInvalid = false;
+ if (canAccessData()) {
+ mMetaTileEntity.onRemoval();
+ mMetaTileEntity.setBaseMetaTileEntity(null);
+ }
+ super.invalidate();
+ }
+
+ @Override
+ public void onChunkUnload() {
+ super.onChunkUnload();
+ }
+
+ @Override
+ public boolean hasCustomInventoryName() {
+ return false;
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(int slot) {
+ ItemStack stack = getStackInSlot(slot);
+ if (stack != null) setInventorySlotContents(slot, null);
+ return stack;
+ }
+
+ @Override
+ public void onMachineBlockUpdate() {
+ if (canAccessData()) mMetaTileEntity.onMachineBlockUpdate();
+ }
+
+ @Override
+ public int getProgress() {
+ return canAccessData() ? mMetaTileEntity.getProgresstime() : 0;
+ }
+
+ @Override
+ public int getMaxProgress() {
+ return canAccessData() ? mMetaTileEntity.maxProgresstime() : 0;
+ }
+
+ @Override
+ public boolean increaseProgress(int aProgressAmountInTicks) {
+ return canAccessData() ? mMetaTileEntity.increaseProgress(aProgressAmountInTicks) != aProgressAmountInTicks : false;
+ }
+
+ @Override
+ public boolean hasThingsToDo() {
+ return getMaxProgress() > 0;
+ }
+
+ @Override
+ public void enableWorking() {
+ if (!mWorks) mWorkUpdate = true;
+ mWorks = true;
+ }
+
+ @Override
+ public void disableWorking() {
+ mWorks = false;
+ }
+
+ @Override
+ public boolean isAllowedToWork() {
+ return mWorks;
+ }
+
+ @Override
+ public boolean hasWorkJustBeenEnabled() {
+ return mWorkUpdate;
+ }
+
+ @Override
+ public byte getWorkDataValue() {
+ return mWorkData;
+ }
+
+ @Override
+ public void setWorkDataValue(byte aValue) {
+ mWorkData = aValue;
+ }
+
+ @Override
+ public int getMetaTileID() {
+ return mID;
+ }
+
+ @Override
+ public int setMetaTileID(short aID) {
+ return mID = aID;
+ }
+
+ @Override
+ public boolean isActive() {
+ return mActive;
+ }
+
+ @Override
+ public void setActive(boolean aActive) {
+ mActive = aActive;
+ }
+
+ @Override
+ public long getTimer() {
+ return mTickTimer;
+ }
+
+ @Override
+ public boolean decreaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooLessEnergy) {
+ if (!canAccessData()) return false;
+ return mHasEnoughEnergy = decreaseStoredEU(aEnergy, aIgnoreTooLessEnergy) || decreaseStoredSteam(aEnergy, false) || (aIgnoreTooLessEnergy && (decreaseStoredSteam(aEnergy, true)));
+ }
+
+ @Override
+ public boolean increaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooMuchEnergy) {
+ if (!canAccessData()) return false;
+ if (getStoredEU() < getEUCapacity() || aIgnoreTooMuchEnergy) {
+ setStoredEU(mMetaTileEntity.getEUVar() + aEnergy);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean inputEnergyFrom(byte aSide) {
+ if (aSide == 6) return true;
+ if (isServerSide()) return (aSide >= 0 && aSide < 6 ? mActiveEUInputs[aSide] : false) && !mReleaseEnergy;
+ return isEnergyInputSide(aSide);
+ }
+
+ @Override
+ public boolean outputsEnergyTo(byte aSide) {
+ if (aSide == 6) return true;
+ if (isServerSide()) return (aSide >= 0 && aSide < 6 ? mActiveEUOutputs[aSide] : false) || mReleaseEnergy;
+ return isEnergyOutputSide(aSide);
+ }
+
+ @Override
+ public long getOutputAmperage() {
+ if (canAccessData() && mMetaTileEntity.isElectric()) return mMetaTileEntity.maxAmperesOut();
+ return 0;
+ }
+
+ @Override
+ public long getOutputVoltage() {
+ if (canAccessData() && mMetaTileEntity.isElectric() && mMetaTileEntity.isEnetOutput())
+ return mMetaTileEntity.maxEUOutput();
+ return 0;
+ }
+
+ @Override
+ public long getInputAmperage() {
+ if (canAccessData() && mMetaTileEntity.isElectric()) return mMetaTileEntity.maxAmperesIn();
+ return 0;
+ }
+
+ @Override
+ public long getInputVoltage() {
+ if (canAccessData() && mMetaTileEntity.isElectric()) return mMetaTileEntity.maxEUInput();
+ return Integer.MAX_VALUE;
+ }
+
+ @Override
+ public boolean increaseStoredSteam(long aEnergy, boolean aIgnoreTooMuchEnergy) {
+ if (!canAccessData()) return false;
+ if (mMetaTileEntity.getSteamVar() < getSteamCapacity() || aIgnoreTooMuchEnergy) {
+ setStoredSteam(mMetaTileEntity.getSteamVar() + aEnergy);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public String[] getDescription() {
+ if (canAccessData()) return mMetaTileEntity.getDescription();
+ return new String[0];
+ }
+
+ @Override
+ public boolean isValidSlot(int aIndex) {
+ if (canAccessData()) return mMetaTileEntity.isValidSlot(aIndex);
+ return false;
+ }
+
+ @Override
+ public long getUniversalEnergyStored() {
+ return Math.max(getStoredEU(), getStoredSteam());
+ }
+
+ @Override
+ public long getUniversalEnergyCapacity() {
+ return Math.max(getEUCapacity(), getSteamCapacity());
+ }
+
+ @Override
+ public long getStoredEU() {
+ if (canAccessData()) return Math.min(mMetaTileEntity.getEUVar(), getEUCapacity());
+ return 0;
+ }
+
+ @Override
+ public long getEUCapacity() {
+ if (canAccessData()) return mMetaTileEntity.maxEUStore();
+ return 0;
+ }
+
+ @Override
+ public long getStoredSteam() {
+ if (canAccessData()) return Math.min(mMetaTileEntity.getSteamVar(), getSteamCapacity());
+ return 0;
+ }
+
+ @Override
+ public long getSteamCapacity() {
+ if (canAccessData()) return mMetaTileEntity.maxSteamStore();
+ return 0;
+ }
+
+ private boolean isEnergyInputSide(byte aSide) {
+ if (aSide >= 0 && aSide < 6) {
+ if (!getCoverBehaviorAtSide(aSide).letsEnergyIn(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this))
+ return false;
+ if (isInvalid() || mReleaseEnergy) return false;
+ if (canAccessData() && mMetaTileEntity.isElectric() && mMetaTileEntity.isEnetInput())
+ return mMetaTileEntity.isInputFacing(aSide);
+ }
+ return false;
+ }
+
+ private boolean isEnergyOutputSide(byte aSide) {
+ if (aSide >= 0 && aSide < 6) {
+ if (!getCoverBehaviorAtSide(aSide).letsEnergyOut(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this))
+ return false;
+ if (isInvalid() || mReleaseEnergy) return mReleaseEnergy;
+ if (canAccessData() && mMetaTileEntity.isElectric() && mMetaTileEntity.isEnetOutput())
+ return mMetaTileEntity.isOutputFacing(aSide);
+ }
+ return false;
+ }
+
+ protected boolean hasValidMetaTileEntity() {
+ return mMetaTileEntity != null && mMetaTileEntity.getBaseMetaTileEntity() == this;
+ }
+
+ protected boolean canAccessData() {
+ return !isDead && hasValidMetaTileEntity();
+ }
+
+ public boolean setStoredEU(long aEnergy) {
+ if (!canAccessData()) return false;
+ if (aEnergy < 0) aEnergy = 0;
+ mMetaTileEntity.setEUVar(aEnergy);
+ return true;
+ }
+
+ public boolean setStoredSteam(long aEnergy) {
+ if (!canAccessData()) return false;
+ if (aEnergy < 0) aEnergy = 0;
+ mMetaTileEntity.setSteamVar(aEnergy);
+ return true;
+ }
+
+ public boolean decreaseStoredEU(long aEnergy, boolean aIgnoreTooLessEnergy) {
+ if (!canAccessData()) {
+ return false;
+ }
+ if (mMetaTileEntity.getEUVar() - aEnergy >= 0 || aIgnoreTooLessEnergy) {
+ setStoredEU(mMetaTileEntity.getEUVar() - aEnergy);
+ if (mMetaTileEntity.getEUVar() < 0) {
+ setStoredEU(0);
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ public boolean decreaseStoredSteam(long aEnergy, boolean aIgnoreTooLessEnergy) {
+ if (!canAccessData()) return false;
+ if (mMetaTileEntity.getSteamVar() - aEnergy >= 0 || aIgnoreTooLessEnergy) {
+ setStoredSteam(mMetaTileEntity.getSteamVar() - aEnergy);
+ if (mMetaTileEntity.getSteamVar() < 0) {
+ setStoredSteam(0);
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ public boolean playerOwnsThis(EntityPlayer aPlayer, boolean aCheckPrecicely) {
+ if (!canAccessData()) return false;
+ if (aCheckPrecicely || privateAccess() || mOwnerName.equals(""))
+ if (mOwnerName.equals("") && isServerSide()) setOwnerName(aPlayer.getDisplayName());
+ else if (privateAccess() && !aPlayer.getDisplayName().equals("Player") && !mOwnerName.equals("Player") && !mOwnerName.equals(aPlayer.getDisplayName()))
+ return false;
+ return true;
+ }
+
+ public boolean privateAccess() {
+ if (!canAccessData()) return mLockUpgrade;
+ return mLockUpgrade || mMetaTileEntity.ownerControl();
+ }
+
+ public void doEnergyExplosion() {
+ if (getUniversalEnergyCapacity() > 0 && getUniversalEnergyStored() >= getUniversalEnergyCapacity() / 5) {
+ doExplosion(oOutput * (getUniversalEnergyStored() >= getUniversalEnergyCapacity() ? 4 : getUniversalEnergyStored() >= getUniversalEnergyCapacity() / 2 ? 2 : 1));
+ GT_Mod.instance.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "electricproblems");
+ }
+ }
+
+ @Override
+ public void doExplosion(long aAmount) {
+ if (canAccessData()) {
+ // This is only for Electric Machines
+ if (GregTech_API.sMachineWireFire && mMetaTileEntity.isElectric()) {
+ try {
+ mReleaseEnergy = true;
+ IEnergyConnected.Util.emitEnergyToNetwork(V[5], Math.max(1, getStoredEU() / V[5]), this);
+ } catch (Exception e) {/* Fun Fact: all these "do nothing" Comments you see in my Code, are just there to let Eclipse shut up about the intended empty Brackets, but I need eclipse to yell at me in some of the regular Cases where I forget to add Code */}
+ }
+ mReleaseEnergy = false;
+ // Normal Explosion Code
+ mMetaTileEntity.onExplosion();
+ mMetaTileEntity.doExplosion(aAmount);
+ }
+ }
+
+ @Override
+ public ArrayList<ItemStack> getDrops() {
+ ItemStack rStack = new ItemStack(GregTech_API.sBlockMachines, 1, mID);
+ NBTTagCompound tNBT = new NBTTagCompound();
+ if (mRecipeStuff != null && !mRecipeStuff.hasNoTags()) tNBT.setTag("GT.CraftingComponents", mRecipeStuff);
+ if (mMuffler) tNBT.setBoolean("mMuffler", mMuffler);
+ if (mLockUpgrade) tNBT.setBoolean("mLockUpgrade", mLockUpgrade);
+ if (mSteamConverter) tNBT.setBoolean("mSteamConverter", mSteamConverter);
+ if (mColor > 0) tNBT.setByte("mColor", mColor);
+ if (mOtherUpgrades > 0) tNBT.setByte("mOtherUpgrades", mOtherUpgrades);
+ if (mStrongRedstone > 0) tNBT.setByte("mStrongRedstone", mStrongRedstone);
+ for (byte i = 0; i < mCoverSides.length; i++) {
+ if (mCoverSides[i] != 0) {
+ tNBT.setIntArray("mCoverData", mCoverData);
+ tNBT.setIntArray("mCoverSides", mCoverSides);
+ break;
+ }
+ }
+ if (hasValidMetaTileEntity()) mMetaTileEntity.setItemNBT(tNBT);
+ if (!tNBT.hasNoTags()) rStack.setTagCompound(tNBT);
+ return new ArrayList<ItemStack>(Arrays.asList(rStack));
+ }
+
+ public int getUpgradeCount() {
+ return (mMuffler ? 1 : 0) + (mLockUpgrade ? 1 : 0) + (mSteamConverter ? 1 : 0) + mOtherUpgrades;
+ }
+
+ @Override
+ public boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) {
+ if (isClientSide()) {
+ if (getCoverBehaviorAtSide(aSide).onCoverRightclickClient(aSide, this, aPlayer, aX, aY, aZ)) return true;
+ if (!getCoverBehaviorAtSide(aSide).isGUIClickable(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this))
+ return false;
+ }
+ if (isServerSide()) {
+ if (!privateAccess() || aPlayer.getDisplayName().equalsIgnoreCase(getOwnerName())) {
+ ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem();
+ if (tCurrentItem != null) {
+ if (getColorization() >= 0 && GT_Utility.areStacksEqual(new ItemStack(Items.water_bucket, 1), tCurrentItem)) {
+ tCurrentItem.func_150996_a(Items.bucket);
+ setColorization((byte) (getColorization() >= 16 ? -2 : -1));
+ return true;
+ }
+ if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWrenchList)) {
+ if (mMetaTileEntity.onWrenchRightClick(aSide, GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ), aPlayer, aX, aY, aZ)) {
+ GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer);
+ GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, xCoord, yCoord, zCoord);
+ }
+ return true;
+ }
+
+ if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sScrewdriverList)) {
+ if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 200, aPlayer)) {
+ setCoverDataAtSide(aSide, getCoverBehaviorAtSide(aSide).onCoverScrewdriverclick(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this, aPlayer, aX, aY, aZ));
+ mMetaTileEntity.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ);
+ GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, xCoord, yCoord, zCoord);
+ }
+ return true;
+ }
+
+ if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sHardHammerList)) {
+ if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) {
+ mInputDisabled = !mInputDisabled;
+ if (mInputDisabled) mOutputDisabled = !mOutputDisabled;
+ GT_Utility.sendChatToPlayer(aPlayer, "Auto-Input: " + (mInputDisabled ? "Disabled" : "Enabled") + " Auto-Output: " + (mOutputDisabled ? "Disabled" : "Enabled"));
+ GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(1), 1.0F, -1, xCoord, yCoord, zCoord);
+ }
+ return true;
+ }
+
+ if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSoftHammerList)) {
+ if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) {
+ if (mWorks) disableWorking();
+ else enableWorking();
+ GT_Utility.sendChatToPlayer(aPlayer, "Machine Processing: " + (isAllowedToWork() ? "Enabled" : "Disabled"));
+ GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(101), 1.0F, -1, xCoord, yCoord, zCoord);
+ }
+ return true;
+ }
+
+ if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSolderingToolList)) {
+ byte tSide = GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ);
+ if (GT_ModHandler.useSolderingIron(tCurrentItem, aPlayer)) {
+ mStrongRedstone ^= (1 << tSide);
+ GT_Utility.sendChatToPlayer(aPlayer, "Redstone Output at Side " + tSide + " set to: " + ((mStrongRedstone & (1 << tSide)) != 0 ? "Strong" : "Weak"));
+ GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(103), 3.0F, -1, xCoord, yCoord, zCoord);
+ }
+ return true;
+ }
+
+ if (getCoverIDAtSide(aSide) == 0) {
+ if (GregTech_API.sCovers.containsKey(new GT_ItemStack(tCurrentItem))) {
+ if (GregTech_API.getCoverBehavior(tCurrentItem).isCoverPlaceable(aSide, new GT_ItemStack(tCurrentItem), this) && mMetaTileEntity.allowCoverOnSide(aSide, new GT_ItemStack(tCurrentItem))) {
+ setCoverItemAtSide(aSide, tCurrentItem);
+ if (!aPlayer.capabilities.isCreativeMode) tCurrentItem.stackSize--;
+ GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, xCoord, yCoord, zCoord);
+ }
+ return true;
+ }
+ } else {
+ if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sCrowbarList)) {
+ if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) {
+ GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(0), 1.0F, -1, xCoord, yCoord, zCoord);
+ dropCover(aSide, aSide, false);
+ }
+ return true;
+ }
+ }
+ }
+
+ if (getCoverBehaviorAtSide(aSide).onCoverRightclick(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this, aPlayer, aX, aY, aZ))
+ return true;
+
+ if (!getCoverBehaviorAtSide(aSide).isGUIClickable(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this))
+ return false;
+
+ if (isUpgradable() && aPlayer.inventory.getCurrentItem() != null) {/*
+ if (ItemList.Upgrade_SteamEngine.isStackEqual(aPlayer.inventory.getCurrentItem())) {
+ if (addSteamEngineUpgrade()) {
+ GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(3), 1.0F, -1, xCoord, yCoord, zCoord);
+ if (!aPlayer.capabilities.isCreativeMode) aPlayer.inventory.getCurrentItem().stackSize--;
}
return true;
- }
- }
- }
- }
-
- try {
- if (this.hasValidMetaTileEntity()) {
- return this.mMetaTileEntity.onRightclick(this, aPlayer, aSide, aX, aY, aZ);
- }
- }
- catch (final Throwable e) {
- GT_Log.err.println(
- "Encountered Exception while rightclicking TileEntity, the Game should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!");
- e.printStackTrace(GT_Log.err);
- }
-
- return true;
- }
-
- @Override
- public void openInventory() {
- if (this.canAccessData()) {
- this.mMetaTileEntity.onOpenGUI();
- }
- }
-
- @Override
- public boolean outputsEnergyTo(final byte aSide) {
- if (aSide == 6) {
- return true;
- }
- if (this.isServerSide()) {
- return (aSide >= 0 && aSide < 6 ? this.mActiveEUOutputs[aSide] : false) || this.mReleaseEnergy;
- }
- return this.isEnergyOutputSide(aSide);
- }
-
- public boolean playerOwnsThis(final EntityPlayer aPlayer, final boolean aCheckPrecicely) {
- if (!this.canAccessData()) {
- return false;
- }
- if (aCheckPrecicely || this.privateAccess() || this.mOwnerName.equals("")) {
- if (this.mOwnerName.equals("") && this.isServerSide()) {
- this.setOwnerName(aPlayer.getDisplayName());
- }
- else if (this.privateAccess() && !aPlayer.getDisplayName().equals("Player")
- && !this.mOwnerName.equals("Player") && !this.mOwnerName.equals(aPlayer.getDisplayName())) {
- return false;
- }
- }
- return true;
- }
-
- public boolean privateAccess() {
- if (!this.canAccessData()) {
- return this.mLockUpgrade;
- }
- return this.mLockUpgrade || this.mMetaTileEntity.ownerControl();
- }
-
- @Override
- public void readFromNBT(final NBTTagCompound aNBT) {
- super.readFromNBT(aNBT);
- this.setInitialValuesAsNBT(aNBT, (short) 0);
- }
-
- @Override
- public boolean receiveClientEvent(final int aEventID, int aValue) {
- super.receiveClientEvent(aEventID, aValue);
-
- if (this.hasValidMetaTileEntity()) {
- try {
- this.mMetaTileEntity.receiveClientEvent((byte) aEventID, (byte) aValue);
- }
- catch (final Throwable e) {
- GT_Log.err.println(
- "Encountered Exception while receiving Data from the Server, the Client should've been crashed by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!");
- e.printStackTrace(GT_Log.err);
- }
- }
-
- if (this.isClientSide()) {
- this.issueTextureUpdate();
- switch (aEventID) {
- case 0:
- this.mFacing = (byte) (aValue & 7);
- this.mActive = (aValue & 8) != 0;
- this.mRedstone = (aValue & 16) != 0;
- // mLockUpgrade = ((aValue&32) != 0);
- break;
- case 1:
- if (this.hasValidMetaTileEntity()) {
- this.mMetaTileEntity.onValueUpdate((byte) aValue);
- }
- break;
- case 2:
- if (aValue > 16 || aValue < 0) {
- aValue = 0;
- }
- this.mColor = (byte) aValue;
- break;
- case 3:
- this.mSidedRedstone[0] = (byte) ((aValue & 1) > 0 ? 15 : 0);
- this.mSidedRedstone[1] = (byte) ((aValue & 2) > 0 ? 15 : 0);
- this.mSidedRedstone[2] = (byte) ((aValue & 4) > 0 ? 15 : 0);
- this.mSidedRedstone[3] = (byte) ((aValue & 8) > 0 ? 15 : 0);
- this.mSidedRedstone[4] = (byte) ((aValue & 16) > 0 ? 15 : 0);
- this.mSidedRedstone[5] = (byte) ((aValue & 32) > 0 ? 15 : 0);
- break;
- case 4:
- if (this.hasValidMetaTileEntity() && this.mTickTimer > 20) {
- this.mMetaTileEntity.doSound((byte) aValue, this.xCoord + 0.5, this.yCoord + 0.5,
- this.zCoord + 0.5);
- }
- break;
- case 5:
- if (this.hasValidMetaTileEntity() && this.mTickTimer > 20) {
- this.mMetaTileEntity.startSoundLoop((byte) aValue, this.xCoord + 0.5, this.yCoord + 0.5,
- this.zCoord + 0.5);
- }
- break;
- case 6:
- if (this.hasValidMetaTileEntity() && this.mTickTimer > 20) {
- this.mMetaTileEntity.stopSoundLoop((byte) aValue, this.xCoord + 0.5, this.yCoord + 0.5,
- this.zCoord + 0.5);
- }
- break;
- case 7:
- this.mLightValue = (byte) aValue;
- break;
- }
- }
- return true;
- }
-
- public final void receiveMetaTileEntityData(final short aID, final int aCover0, final int aCover1,
- final int aCover2, final int aCover3, final int aCover4, final int aCover5, final byte aTextureData,
- final byte aUpdateData, final byte aRedstoneData, final byte aColorData) {
- this.issueTextureUpdate();
- if (this.mID != aID && aID > 0) {
- this.mID = aID;
- this.createNewMetatileEntity(this.mID);
- }
-
- this.mCoverSides[0] = aCover0;
- this.mCoverSides[1] = aCover1;
- this.mCoverSides[2] = aCover2;
- this.mCoverSides[3] = aCover3;
- this.mCoverSides[4] = aCover4;
- this.mCoverSides[5] = aCover5;
-
- for (byte i = 0; i < 6; i++) {
- this.mCoverBehaviors[i] = GregTech_API.getCoverBehavior(this.mCoverSides[i]);
- }
-
- this.receiveClientEvent(0, aTextureData);
- this.receiveClientEvent(1, aUpdateData);
- this.receiveClientEvent(2, aColorData);
- this.receiveClientEvent(3, aRedstoneData);
- }
-
- @Override
- public void setActive(final boolean aActive) {
- this.mActive = aActive;
- }
-
- @Override
- public byte setColorization(byte aColor) {
- if (aColor > 15 || aColor < -1) {
- aColor = -1;
- }
- if (this.canAccessData()) {
- this.mMetaTileEntity.onColorChangeServer(aColor);
- }
- return this.mColor = (byte) (aColor + 1);
- }
-
- @Override
- public void setCoverDataAtSide(final byte aSide, final int aData) {
- if (aSide >= 0 && aSide < 6) {
- this.mCoverData[aSide] = aData;
- }
- }
-
- @Override
- public void setCoverIDAtSide(final byte aSide, final int aID) {
- if (aSide >= 0 && aSide < 6) {
- this.mCoverSides[aSide] = aID;
- this.mCoverData[aSide] = 0;
- this.mCoverBehaviors[aSide] = GregTech_API.getCoverBehavior(aID);
- this.issueCoverUpdate(aSide);
- this.issueBlockUpdate();
- }
- }
-
- @Override
- public void setCoverItemAtSide(final byte aSide, final ItemStack aCover) {
- GregTech_API.getCoverBehavior(aCover).placeCover(aSide, aCover, this);
- }
-
- @Override
- public void setErrorDisplayID(final int aErrorID) {
- this.mDisplayErrorCode = aErrorID;
- }
-
- @Override
- public void setFrontFacing(final byte aFacing) {
- if (this.isValidFacing(aFacing)) {
- this.mFacing = aFacing;
- this.mMetaTileEntity.onFacingChange();
- this.onMachineBlockUpdate();
- }
- }
-
- @Override
- public void setGenericRedstoneOutput(final boolean aOnOff) {
- this.mRedstone = aOnOff;
- }
-
- @Override
- public void setInitialValuesAsNBT(final NBTTagCompound aNBT, final short aID) {
- if (aNBT == null) {
- if (aID > 0) {
- this.mID = aID;
- }
- else {
- this.mID = this.mID > 0 ? this.mID : 0;
- }
- if (this.mID != 0) {
- this.createNewMetatileEntity(this.mID);
- }
- this.mSidedRedstone = this.hasValidMetaTileEntity() && this.mMetaTileEntity.hasSidedRedstoneOutputBehavior()
- ? new byte[] {
- 0, 0, 0, 0, 0, 0
- } : new byte[] {
- 15, 15, 15, 15, 15, 15
- };
- }
- else {
- if (aID <= 0) {
- this.mID = (short) aNBT.getInteger("mID");
- }
- else {
- this.mID = aID;
- }
- this.mStoredSteam = aNBT.getInteger("mStoredSteam");
- this.mStoredEnergy = aNBT.getInteger("mStoredEnergy");
- this.mColor = aNBT.getByte("mColor");
- this.mLightValue = aNBT.getByte("mLightValue");
- this.mWorkData = aNBT.getByte("mWorkData");
- this.mStrongRedstone = aNBT.getByte("mStrongRedstone");
- this.mFacing = this.oFacing = (byte) aNBT.getShort("mFacing");
- this.mOwnerName = aNBT.getString("mOwnerName");
- this.mLockUpgrade = aNBT.getBoolean("mLockUpgrade");
- this.mMuffler = aNBT.getBoolean("mMuffler");
- this.mSteamConverter = aNBT.getBoolean("mSteamConverter");
- this.mActive = aNBT.getBoolean("mActive");
- this.mRedstone = aNBT.getBoolean("mRedstone");
- this.mWorks = !aNBT.getBoolean("mWorks");
- this.mInputDisabled = aNBT.getBoolean("mInputDisabled");
- this.mOutputDisabled = aNBT.getBoolean("mOutputDisabled");
- this.mOtherUpgrades = (byte) (aNBT.getByte("mOtherUpgrades") + aNBT.getByte("mBatteries")
- + aNBT.getByte("mLiBatteries"));
- this.mCoverSides = aNBT.getIntArray("mCoverSides");
- this.mCoverData = aNBT.getIntArray("mCoverData");
- this.mSidedRedstone = aNBT.getByteArray("mRedstoneSided");
- this.mRecipeStuff = aNBT.getCompoundTag("GT.CraftingComponents");
-
- if (this.mCoverData.length != 6) {
- this.mCoverData = new int[] {
- 0, 0, 0, 0, 0, 0
- };
- }
- if (this.mCoverSides.length != 6) {
- this.mCoverSides = new int[] {
- 0, 0, 0, 0, 0, 0
- };
- }
- if (this.mSidedRedstone.length != 6) {
- if (this.hasValidMetaTileEntity() && this.mMetaTileEntity.hasSidedRedstoneOutputBehavior()) {
- this.mSidedRedstone = new byte[] {
- 0, 0, 0, 0, 0, 0
- };
- }
- else {
- this.mSidedRedstone = new byte[] {
- 15, 15, 15, 15, 15, 15
- };
- }
- }
-
- for (byte i = 0; i < 6; i++) {
- this.mCoverBehaviors[i] = GregTech_API.getCoverBehavior(this.mCoverSides[i]);
- }
-
- if (this.mID != 0 && this.createNewMetatileEntity(this.mID)) {
- final NBTTagList tItemList = aNBT.getTagList("Inventory", 10);
- for (int i = 0; i < tItemList.tagCount(); i++) {
- final NBTTagCompound tTag = tItemList.getCompoundTagAt(i);
- final int tSlot = tTag.getInteger("IntSlot");
- if (tSlot >= 0 && tSlot < this.mMetaTileEntity.getRealInventory().length) {
- this.mMetaTileEntity.getRealInventory()[tSlot] = GT_Utility.loadItem(tTag);
- }
- }
-
- try {
- this.mMetaTileEntity.loadNBTData(aNBT);
- }
- catch (final Throwable e) {
- GT_Log.err.println(
- "Encountered Exception while loading MetaTileEntity, the Server should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!");
- e.printStackTrace(GT_Log.err);
- }
- }
- }
-
- if (this.mCoverData.length != 6) {
- this.mCoverData = new int[] {
- 0, 0, 0, 0, 0, 0
- };
- }
- if (this.mCoverSides.length != 6) {
- this.mCoverSides = new int[] {
- 0, 0, 0, 0, 0, 0
- };
- }
- if (this.mSidedRedstone.length != 6) {
- if (this.hasValidMetaTileEntity() && this.mMetaTileEntity.hasSidedRedstoneOutputBehavior()) {
- this.mSidedRedstone = new byte[] {
- 0, 0, 0, 0, 0, 0
- };
- }
- else {
- this.mSidedRedstone = new byte[] {
- 15, 15, 15, 15, 15, 15
- };
- }
- }
-
- for (byte i = 0; i < 6; i++) {
- this.mCoverBehaviors[i] = GregTech_API.getCoverBehavior(this.mCoverSides[i]);
- }
- }
-
- @Override
- public void setInternalOutputRedstoneSignal(final byte aSide, final byte aStrength) {
- if (!this.getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, this.getCoverIDAtSide(aSide),
- this.getCoverDataAtSide(aSide), this)) {
- this.setOutputRedstoneSignal(aSide, aStrength);
- }
- }
-
- @Override
- public void setInventorySlotContents(final int aIndex, final ItemStack aStack) {
- this.mInventoryChanged = true;
- if (this.canAccessData()) {
- this.mMetaTileEntity.setInventorySlotContents(aIndex,
- this.worldObj.isRemote ? aStack : GT_OreDictUnificator.setStack(true, aStack));
- }
- }
-
- @Override
- public void setItemCount(final int aCount) {
- if (this.canAccessData()) {
- this.mMetaTileEntity.setItemCount(aCount);
- }
- }
-
- @Override
- public void setLightValue(final byte aLightValue) {
- this.mLightValue = (byte) (aLightValue & 15);
- }
-
- @Override
- public void setMetaTileEntity(final IMetaTileEntity aMetaTileEntity) {
- this.mMetaTileEntity = (MetaTileEntity) aMetaTileEntity;
- }
-
- @Override
- public int setMetaTileID(final short aID) {
- return this.mID = aID;
- }
-
- @Override
- public void setOutputRedstoneSignal(final byte aSide, byte aStrength) {
- aStrength = (byte) Math.min(Math.max(0, aStrength), 15);
- if (aSide >= 0 && aSide < 6 && this.mSidedRedstone[aSide] != aStrength) {
- this.mSidedRedstone[aSide] = aStrength;
- this.issueBlockUpdate();
- }
- }
-
- @Override
- public String setOwnerName(final String aName) {
- if (GT_Utility.isStringInvalid(aName)) {
- return this.mOwnerName = "Player";
- }
- return this.mOwnerName = aName;
- }
-
- public void setStored(final int aEU) {
- if (this.canAccessData()) {
- this.setStoredEU(aEU);
- }
- }
-
- public boolean setStoredEU(long aEnergy) {
- if (!this.canAccessData()) {
- return false;
- }
- if (aEnergy < 0) {
- aEnergy = 0;
- }
- this.mMetaTileEntity.setEUVar(aEnergy);
- return true;
- }
-
- public boolean setStoredSteam(long aEnergy) {
- if (!this.canAccessData()) {
- return false;
- }
- if (aEnergy < 0) {
- aEnergy = 0;
- }
- this.mMetaTileEntity.setSteamVar(aEnergy);
- return true;
- }
-
- @Override
- public void setStrongOutputRedstoneSignal(final byte aSide, final byte aStrength) {
- this.mStrongRedstone |= 1 << aSide;
- this.setOutputRedstoneSignal(aSide, aStrength);
- }
-
- @Override
- public void setWorkDataValue(final byte aValue) {
- this.mWorkData = aValue;
- }
-
- @Override
- public void updateEntity() {
- super.updateEntity();
-
- if (!this.hasValidMetaTileEntity()) {
- if (this.mMetaTileEntity == null) {
- return;
- }
- this.mMetaTileEntity.setBaseMetaTileEntity(this);
- }
-
- this.mRunningThroughTick = true;
- long tTime = System.currentTimeMillis();
-
- for (int tCode = 0; this.hasValidMetaTileEntity() && tCode >= 0;) {
- try {
- switch (tCode) {
- case 0:
- tCode++;
- if (this.mTickTimer++ == 0) {
- this.oX = this.xCoord;
- this.oY = this.yCoord;
- this.oZ = this.zCoord;
- if (this.isServerSide()) {
- for (byte i = 0; i < 6; i++) {
- if (this.getCoverIDAtSide(i) != 0) {
- if (!this.mMetaTileEntity.allowCoverOnSide(i,
- new GT_ItemStack(this.getCoverIDAtSide(i)))) {
- this.dropCover(i, i, true);
- }
- }
- }
- }
-
- this.worldObj.markTileEntityChunkModified(this.xCoord, this.yCoord, this.zCoord, this);
-
- this.mMetaTileEntity.onFirstTick(this);
- if (!this.hasValidMetaTileEntity()) {
- this.mRunningThroughTick = false;
- return;
- }
- }
- case 1:
- tCode++;
- if (this.isClientSide()) {
- if (this.mColor != this.oColor) {
- this.mMetaTileEntity.onColorChangeClient(this.oColor = this.mColor);
- this.issueTextureUpdate();
- }
-
- if (this.mLightValue != this.oLightValueClient) {
- this.worldObj.setLightValue(EnumSkyBlock.Block, this.xCoord, this.yCoord, this.zCoord,
- this.mLightValue);
- this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord,
- this.zCoord);
- this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord + 1, this.yCoord,
- this.zCoord);
- this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord - 1, this.yCoord,
- this.zCoord);
- this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord + 1,
- this.zCoord);
- this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord - 1,
- this.zCoord);
- this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord,
- this.zCoord + 1);
- this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord,
- this.zCoord - 1);
- this.oLightValueClient = this.mLightValue;
- this.issueTextureUpdate();
- }
-
- if (this.mNeedsUpdate) {
- this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
- // worldObj.func_147479_m(xCoord, yCoord,
- // zCoord);
- this.mNeedsUpdate = false;
- }
- }
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- if (this.isServerSide() && this.mTickTimer > 10) {
- for (byte i = (byte) (tCode - 2); i < 6; i++) {
- if (this.getCoverIDAtSide(i) != 0) {
- tCode++;
- final GT_CoverBehavior tCover = this.getCoverBehaviorAtSide(i);
- final int tCoverTickRate = tCover.getTickRate(i, this.getCoverIDAtSide(i),
- this.mCoverData[i], this);
- if (tCoverTickRate > 0 && this.mTickTimer % tCoverTickRate == 0) {
- this.mCoverData[i] = tCover.doCoverThings(i, this.getInputRedstoneSignal(i),
- this.getCoverIDAtSide(i), this.mCoverData[i], this, this.mTickTimer);
- if (!this.hasValidMetaTileEntity()) {
- this.mRunningThroughTick = false;
- return;
- }
- }
- }
- }
-
- }
- case 8:
- tCode = 9;
- if (this.isServerSide()) {
- if (++this.mAverageEUInputIndex >= this.mAverageEUInput.length) {
- this.mAverageEUInputIndex = 0;
- }
- if (++this.mAverageEUOutputIndex >= this.mAverageEUOutput.length) {
- this.mAverageEUOutputIndex = 0;
- }
-
- this.mAverageEUInput[this.mAverageEUInputIndex] = 0;
- this.mAverageEUOutput[this.mAverageEUOutputIndex] = 0;
- }
- case 9:
- tCode++;
- this.mMetaTileEntity.onPreTick(this, this.mTickTimer);
- if (!this.hasValidMetaTileEntity()) {
- this.mRunningThroughTick = false;
- return;
- }
- case 10:
- tCode++;
- if (this.isServerSide()) {
- if (this.mRedstone != this.oRedstone || this.mTickTimer == 10) {
- for (byte i = 0; i < 6; i++) {
- this.mCoverBehaviors[i] = GregTech_API.getCoverBehavior(this.mCoverSides[i]);
- }
- this.oRedstone = this.mRedstone;
- this.issueBlockUpdate();
- }
-
- if (this.xCoord != this.oX || this.yCoord != this.oY || this.zCoord != this.oZ) {
- this.oX = this.xCoord;
- this.oY = this.yCoord;
- this.oZ = this.zCoord;
- this.issueClientUpdate();
- this.clearTileEntityBuffer();
- }
-
- if (this.mFacing != this.oFacing) {
- this.oFacing = this.mFacing;
- for (byte i = 0; i < 6; i++) {
- if (this.getCoverIDAtSide(i) != 0) {
- if (!this.mMetaTileEntity.allowCoverOnSide(i,
- new GT_ItemStack(this.getCoverIDAtSide(i)))) {
- this.dropCover(i, i, true);
- }
- }
- }
- this.issueBlockUpdate();
- }
-
- if (this.mTickTimer > 20 && this.mMetaTileEntity.isElectric()) {
- this.mAcceptedAmperes = 0;
-
- if (this.getOutputVoltage() != this.oOutput) {
- this.oOutput = this.getOutputVoltage();
- }
-
- if (this.mMetaTileEntity.isEnetOutput() || this.mMetaTileEntity.isEnetInput()) {
- for (byte i = 0; i < 6; i++) {
- boolean temp = this.isEnergyInputSide(i);
- if (temp != this.mActiveEUInputs[i]) {
- this.mActiveEUInputs[i] = temp;
- }
- temp = this.isEnergyOutputSide(i);
- if (temp != this.mActiveEUOutputs[i]) {
- this.mActiveEUOutputs[i] = temp;
- }
- }
- }
-
- if (this.mMetaTileEntity.isEnetOutput() && this.oOutput > 0) {
- final long tOutputVoltage = this.oOutput,
- tUsableAmperage = Math
- .min(this.getOutputAmperage(),
- (this.getStoredEU()
- - this.mMetaTileEntity.getMinimumStoredEU())
- / tOutputVoltage);
- if (tUsableAmperage > 0) {
- final long tEU = tOutputVoltage * IEnergyConnected.Util
- .emitEnergyToNetwork(this.oOutput, tUsableAmperage, this);
- this.mAverageEUOutput[this.mAverageEUOutputIndex] += tEU;
- this.decreaseStoredEU(tEU, true);
- }
- }
-
- if (this.getEUCapacity() > 0) {
- if (GregTech_API.sMachineFireExplosions && this.getRandomNumber(1000) == 0) {
- final Block tBlock = this.getBlockAtSide((byte) this.getRandomNumber(6));
- if (tBlock != null && tBlock instanceof BlockFire) {
- this.doEnergyExplosion();
- }
- }
-
- if (!this.hasValidMetaTileEntity()) {
- this.mRunningThroughTick = false;
- return;
- }
-
- if (this.getRandomNumber(1000) == 0) {
- if (this.getCoverIDAtSide((byte) 1) == 0
- && this.worldObj.getPrecipitationHeight(this.xCoord, this.zCoord)
- - 2 < this.yCoord
- || this.getCoverIDAtSide((byte) 2) == 0
- && this.worldObj.getPrecipitationHeight(this.xCoord,
- this.zCoord - 1) - 1 < this.yCoord
- || this.getCoverIDAtSide((byte) 3) == 0
- && this.worldObj.getPrecipitationHeight(this.xCoord,
- this.zCoord + 1) - 1 < this.yCoord
- || this.getCoverIDAtSide((byte) 4) == 0
- && this.worldObj.getPrecipitationHeight(this.xCoord - 1,
- this.zCoord) - 1 < this.yCoord
- || this.getCoverIDAtSide((byte) 5) == 0
- && this.worldObj.getPrecipitationHeight(this.xCoord + 1,
- this.zCoord) - 1 < this.yCoord) {
- if (GregTech_API.sMachineRainExplosions && this.worldObj.isRaining()
- && this.getBiome().rainfall > 0) {
- if (this.getRandomNumber(10) == 0) {
- try {
- GT_Mod.achievements.issueAchievement(this.getWorldObj()
- .getPlayerEntityByName(this.mOwnerName), "badweather");
- }
- catch (final Exception e) {
- }
- this.doEnergyExplosion();
- }
- else {
- this.setOnFire();
- }
- }
- if (!this.hasValidMetaTileEntity()) {
- this.mRunningThroughTick = false;
- return;
- }
- if (GregTech_API.sMachineThunderExplosions && this.worldObj.isThundering()
- && this.getBiome().rainfall > 0 && this.getRandomNumber(3) == 0) {
- try {
- GT_Mod.achievements.issueAchievement(
- this.getWorldObj().getPlayerEntityByName(this.mOwnerName),
- "badweather");
- }
- catch (final Exception e) {
- }
- this.doEnergyExplosion();
- }
- }
- }
- }
- }
-
- if (!this.hasValidMetaTileEntity()) {
- this.mRunningThroughTick = false;
- return;
- }
- }
- case 11:
- tCode++;
- if (this.isServerSide()) {
- if (this.mMetaTileEntity.dechargerSlotCount() > 0
- && this.getStoredEU() < this.getEUCapacity()) {
- for (int i = this.mMetaTileEntity.dechargerSlotStartIndex(), k = this.mMetaTileEntity
- .dechargerSlotCount() + i; i < k; i++) {
- if (this.mMetaTileEntity.mInventory[i] != null
- && this.getStoredEU() < this.getEUCapacity()) {
- this.dischargeItem(this.mMetaTileEntity.mInventory[i]);
- if (this.mMetaTileEntity.mInventory[i].stackSize <= 0) {
- this.mMetaTileEntity.mInventory[i] = null;
- }
- this.mInventoryChanged = true;
- }
- }
- }
- }
- case 12:
- tCode++;
- if (this.isServerSide()) {
- if (this.mMetaTileEntity.rechargerSlotCount() > 0 && this.getStoredEU() > 0) {
- for (int i = this.mMetaTileEntity.rechargerSlotStartIndex(), k = this.mMetaTileEntity
- .rechargerSlotCount() + i; i < k; i++) {
- if (this.getStoredEU() > 0 && this.mMetaTileEntity.mInventory[i] != null) {
- this.chargeItem(this.mMetaTileEntity.mInventory[i]);
- if (this.mMetaTileEntity.mInventory[i].stackSize <= 0) {
- this.mMetaTileEntity.mInventory[i] = null;
- }
- this.mInventoryChanged = true;
- }
- }
- }
- }
- case 13:
- tCode++;
- this.updateStatus();
- if (!this.hasValidMetaTileEntity()) {
- this.mRunningThroughTick = false;
- return;
- }
- case 14:
- tCode++;
- this.mMetaTileEntity.onPostTick(this, this.mTickTimer);
- if (!this.hasValidMetaTileEntity()) {
- this.mRunningThroughTick = false;
- return;
- }
- case 15:
- tCode++;
- if (this.isServerSide()) {
- if (this.mTickTimer % 10 == 0) {
- if (this.mSendClientData) {
- GT_Values.NW.sendPacketToAllPlayersInRange(this.worldObj, new GT_Packet_TileEntity(
- this.xCoord, (short) this.yCoord, this.zCoord, this.mID,
- this.mCoverSides[0], this.mCoverSides[1], this.mCoverSides[2],
- this.mCoverSides[3], this.mCoverSides[4], this.mCoverSides[5],
- this.oTextureData = (byte) (this.mFacing & 7 | (this.mActive ? 8 : 0)
- | (this.mRedstone ? 16 : 0) | (this.mLockUpgrade ? 32 : 0)),
- this.oUpdateData = this.hasValidMetaTileEntity()
- ? this.mMetaTileEntity.getUpdateData() : 0,
- this.oRedstoneData = (byte) ((this.mSidedRedstone[0] > 0 ? 1 : 0)
- | (this.mSidedRedstone[1] > 0 ? 2 : 0)
- | (this.mSidedRedstone[2] > 0 ? 4 : 0)
- | (this.mSidedRedstone[3] > 0 ? 8 : 0)
- | (this.mSidedRedstone[4] > 0 ? 16 : 0)
- | (this.mSidedRedstone[5] > 0 ? 32 : 0)),
- this.oColor = this.mColor), this.xCoord, this.zCoord);
- this.mSendClientData = false;
- }
- }
-
- if (this.mTickTimer > 10) {
- byte tData = (byte) (this.mFacing & 7 | (this.mActive ? 8 : 0)
- | (this.mRedstone ? 16 : 0) | (this.mLockUpgrade ? 32 : 0));
- if (tData != this.oTextureData) {
- this.sendBlockEvent((byte) 0, this.oTextureData = tData);
- }
- tData = this.mMetaTileEntity.getUpdateData();
- if (tData != this.oUpdateData) {
- this.sendBlockEvent((byte) 1, this.oUpdateData = tData);
- }
- if (this.mColor != this.oColor) {
- this.sendBlockEvent((byte) 2, this.oColor = this.mColor);
- }
- tData = (byte) ((this.mSidedRedstone[0] > 0 ? 1 : 0)
- | (this.mSidedRedstone[1] > 0 ? 2 : 0) | (this.mSidedRedstone[2] > 0 ? 4 : 0)
- | (this.mSidedRedstone[3] > 0 ? 8 : 0) | (this.mSidedRedstone[4] > 0 ? 16 : 0)
- | (this.mSidedRedstone[5] > 0 ? 32 : 0));
- if (tData != this.oRedstoneData) {
- this.sendBlockEvent((byte) 3, this.oRedstoneData = tData);
- }
- if (this.mLightValue != this.oLightValue) {
- this.worldObj.setLightValue(EnumSkyBlock.Block, this.xCoord, this.yCoord,
- this.zCoord, this.mLightValue);
- this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord,
- this.zCoord);
- this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord + 1, this.yCoord,
- this.zCoord);
- this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord - 1, this.yCoord,
- this.zCoord);
- this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord + 1,
- this.zCoord);
- this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord - 1,
- this.zCoord);
- this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord,
- this.zCoord + 1);
- this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord,
- this.zCoord - 1);
- this.issueTextureUpdate();
- this.sendBlockEvent((byte) 7, this.oLightValue = this.mLightValue);
- }
- }
-
- if (this.mNeedsBlockUpdate) {
- this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord,
- this.getBlockOffset(0, 0, 0));
- this.mNeedsBlockUpdate = false;
- }
- }
- default:
- tCode = -1;
- break;
- }
- }
- catch (final Throwable e) {
- GT_Log.err.println("Encountered Exception while ticking MetaTileEntity in Step " + (tCode - 1)
- + ". The Game should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!");
- e.printStackTrace(GT_Log.err);
- }
- }
-
- if (this.isServerSide() && this.hasValidMetaTileEntity()) {
- tTime = System.currentTimeMillis() - tTime;
- if (this.mTimeStatistics.length > 0) {
- this.mTimeStatistics[this.mTimeStatisticsIndex = (this.mTimeStatisticsIndex + 1)
- % this.mTimeStatistics.length] = (int) tTime;
- }
- if (tTime > 0 && tTime > GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING && this.mTickTimer > 1000
- && this.getMetaTileEntity().doTickProfilingMessageDuringThisTick()
- && this.mLagWarningCount++ < 10) {
- System.out.println("WARNING: Possible Lag Source at [" + this.xCoord + ", " + this.yCoord + ", "
- + this.zCoord + "] in Dimension " + this.worldObj.provider.dimensionId + " with " + tTime
- + "ms caused by an instance of " + this.getMetaTileEntity().getClass());
- }
- }
-
- this.mWorkUpdate = this.mInventoryChanged = this.mRunningThroughTick = false;
- }
-
- /**
- * Used for ticking special BaseMetaTileEntities, which need that for Energy
- * Conversion It's called right before onPostTick()
- */
- public void updateStatus() {
- //
- }
-
- @Override
- public void validate() {
- super.validate();
- this.mTickTimer = 0;
- }
-
- @Override
- public void writeToNBT(final NBTTagCompound aNBT) {
- try {
- super.writeToNBT(aNBT);
- }
- catch (final Throwable e) {
- GT_Log.err.println(
- "Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!");
- e.printStackTrace(GT_Log.err);
- }
- try {
- aNBT.setInteger("mID", this.mID);
- aNBT.setLong("mStoredSteam", this.mStoredSteam);
- aNBT.setLong("mStoredEnergy", this.mStoredEnergy);
- aNBT.setIntArray("mCoverData", this.mCoverData);
- aNBT.setIntArray("mCoverSides", this.mCoverSides);
- aNBT.setByteArray("mRedstoneSided", this.mSidedRedstone);
- aNBT.setByte("mColor", this.mColor);
- aNBT.setByte("mLightValue", this.mLightValue);
- aNBT.setByte("mOtherUpgrades", this.mOtherUpgrades);
- aNBT.setByte("mWorkData", this.mWorkData);
- aNBT.setByte("mStrongRedstone", this.mStrongRedstone);
- aNBT.setShort("mFacing", this.mFacing);
- aNBT.setString("mOwnerName", this.mOwnerName);
- aNBT.setBoolean("mLockUpgrade", this.mLockUpgrade);
- aNBT.setBoolean("mMuffler", this.mMuffler);
- aNBT.setBoolean("mSteamConverter", this.mSteamConverter);
- aNBT.setBoolean("mActive", this.mActive);
- aNBT.setBoolean("mRedstone", this.mRedstone);
- aNBT.setBoolean("mWorks", !this.mWorks);
- aNBT.setBoolean("mInputDisabled", this.mInputDisabled);
- aNBT.setBoolean("mOutputDisabled", this.mOutputDisabled);
- aNBT.setTag("GT.CraftingComponents", this.mRecipeStuff);
- }
- catch (final Throwable e) {
- GT_Log.err.println(
- "Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!");
- e.printStackTrace(GT_Log.err);
- }
- try {
- if (this.hasValidMetaTileEntity()) {
- final NBTTagList tItemList = new NBTTagList();
- for (int i = 0; i < this.mMetaTileEntity.getRealInventory().length; i++) {
- final ItemStack tStack = this.mMetaTileEntity.getRealInventory()[i];
- if (tStack != null) {
- final NBTTagCompound tTag = new NBTTagCompound();
- tTag.setInteger("IntSlot", i);
- tStack.writeToNBT(tTag);
- tItemList.appendTag(tTag);
- }
- }
- aNBT.setTag("Inventory", tItemList);
-
- try {
- this.mMetaTileEntity.saveNBTData(aNBT);
- }
- catch (final Throwable e) {
- GT_Log.err.println(
- "Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!");
- e.printStackTrace(GT_Log.err);
- }
- }
- }
- catch (final Throwable e) {
- GT_Log.err.println(
- "Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!");
- e.printStackTrace(GT_Log.err);
- }
- }
+ }*/
+ if (ItemList.Upgrade_Muffler.isStackEqual(aPlayer.inventory.getCurrentItem())) {
+ if (addMufflerUpgrade()) {
+ GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(3), 1.0F, -1, xCoord, yCoord, zCoord);
+ if (!aPlayer.capabilities.isCreativeMode) aPlayer.inventory.getCurrentItem().stackSize--;
+ }
+ return true;
+ }
+ if (ItemList.Upgrade_Lock.isStackEqual(aPlayer.inventory.getCurrentItem())) {
+ if (isUpgradable() && !mLockUpgrade) {
+ mLockUpgrade = true;
+ setOwnerName(aPlayer.getDisplayName());
+ GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(3), 1.0F, -1, xCoord, yCoord, zCoord);
+ if (!aPlayer.capabilities.isCreativeMode) aPlayer.inventory.getCurrentItem().stackSize--;
+ }
+ return true;
+ }
+ }
+ }
+ }
+
+ try {
+ if (hasValidMetaTileEntity()) return mMetaTileEntity.onRightclick(this, aPlayer, aSide, aX, aY, aZ);
+ } catch (Throwable e) {
+ GT_Log.err.println("Encountered Exception while rightclicking TileEntity, the Game should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!");
+ e.printStackTrace(GT_Log.err);
+ }
+
+ return true;
+ }
+
+ @Override
+ public void onLeftclick(EntityPlayer aPlayer) {
+ try {
+ if (aPlayer != null && hasValidMetaTileEntity()) mMetaTileEntity.onLeftclick(this, aPlayer);
+ } catch (Throwable e) {
+ GT_Log.err.println("Encountered Exception while leftclicking TileEntity, the Game should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!");
+ e.printStackTrace(GT_Log.err);
+ }
+ }
+
+ @Override
+ public boolean isDigitalChest() {
+ if (canAccessData()) return mMetaTileEntity.isDigitalChest();
+ return false;
+ }
+
+ @Override
+ public ItemStack[] getStoredItemData() {
+ if (canAccessData()) return mMetaTileEntity.getStoredItemData();
+ return null;
+ }
+
+ @Override
+ public void setItemCount(int aCount) {
+ if (canAccessData()) mMetaTileEntity.setItemCount(aCount);
+ }
+
+ @Override
+ public int getMaxItemCount() {
+ if (canAccessData()) return mMetaTileEntity.getMaxItemCount();
+ return 0;
+ }
+
+ /**
+ * Can put aStack into Slot
+ */
+ @Override
+ public boolean isItemValidForSlot(int aIndex, ItemStack aStack) {
+ return canAccessData() && mMetaTileEntity.isItemValidForSlot(aIndex, aStack);
+ }
+
+ /**
+ * returns all valid Inventory Slots, no matter which Side (Unless it's covered).
+ * The Side Stuff is done in the following two Functions.
+ */
+ @Override
+ public int[] getAccessibleSlotsFromSide(int aSide) {
+ if (canAccessData() && (getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide, getCoverIDAtSide((byte) aSide), getCoverDataAtSide((byte) aSide), -1, this) || getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide, getCoverIDAtSide((byte) aSide), getCoverDataAtSide((byte) aSide), -1, this)))
+ return mMetaTileEntity.getAccessibleSlotsFromSide(aSide);
+ return new int[0];
+ }
+
+ /**
+ * Can put aStack into Slot at Side
+ */
+ @Override
+ public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) {
+ return canAccessData() && (mRunningThroughTick || !mInputDisabled) && getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide, getCoverIDAtSide((byte) aSide), getCoverDataAtSide((byte) aSide), aIndex, this) && mMetaTileEntity.canInsertItem(aIndex, aStack, aSide);
+ }
+
+ /**
+ * Can pull aStack out of Slot from Side
+ */
+ @Override
+ public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) {
+ return canAccessData() && (mRunningThroughTick || !mOutputDisabled) && getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide, getCoverIDAtSide((byte) aSide), getCoverDataAtSide((byte) aSide), aIndex, this) && mMetaTileEntity.canExtractItem(aIndex, aStack, aSide);
+ }
+
+ @Override
+ public boolean isUpgradable() {
+ return canAccessData() && getUpgradeCount() < 8;
+ }
+
+ @Override
+ public byte getInternalInputRedstoneSignal(byte aSide) {
+ return (byte) (getCoverBehaviorAtSide(aSide).getRedstoneInput(aSide, getInputRedstoneSignal(aSide), getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this) & 15);
+ }
+
+ @Override
+ public byte getInputRedstoneSignal(byte aSide) {
+ return (byte) (worldObj.getIndirectPowerLevelTo(getOffsetX(aSide, 1), getOffsetY(aSide, 1), getOffsetZ(aSide, 1), aSide) & 15);
+ }
+
+ @Override
+ public byte getOutputRedstoneSignal(byte aSide) {
+ return getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this) ? mSidedRedstone[aSide] : 0;
+// return (byte)(getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this) || (mRedstone && getCoverBehaviorAtSide(aSide).letsRedstoneGoOut(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this))?mSidedRedstone[aSide]&15:0);
+ }
+
+ @Override
+ public void setInternalOutputRedstoneSignal(byte aSide, byte aStrength) {
+ if (!getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this))
+ setOutputRedstoneSignal(aSide, aStrength);
+ }
+
+ @Override
+ public void setOutputRedstoneSignal(byte aSide, byte aStrength) {
+ aStrength = (byte) Math.min(Math.max(0, aStrength), 15);
+ if (aSide >= 0 && aSide < 6 && mSidedRedstone[aSide] != aStrength) {
+ mSidedRedstone[aSide] = aStrength;
+ issueBlockUpdate();
+ }
+ }
+
+ @Override
+ public boolean isSteamEngineUpgradable() {
+ return isUpgradable() && !hasSteamEngineUpgrade() && getSteamCapacity() > 0;
+ }
+
+ @Override
+ public boolean addSteamEngineUpgrade() {
+ if (isSteamEngineUpgradable()) {
+ issueBlockUpdate();
+ mSteamConverter = true;
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean hasSteamEngineUpgrade() {
+ if (canAccessData() && mMetaTileEntity.isSteampowered()) return true;
+ return mSteamConverter;
+ }
+
+ @Override
+ public boolean hasMufflerUpgrade() {
+ return mMuffler;
+ }
+
+ @Override
+ public boolean isMufflerUpgradable() {
+ return isUpgradable() && !hasMufflerUpgrade();
+ }
+
+ @Override
+ public boolean addMufflerUpgrade() {
+ if (isMufflerUpgradable()) return mMuffler = true;
+ return false;
+ }
+
+ @Override
+ public boolean hasInventoryBeenModified() {
+ return mInventoryChanged;
+ }
+
+ @Override
+ public void setGenericRedstoneOutput(boolean aOnOff) {
+ mRedstone = aOnOff;
+ }
+
+ @Override
+ public int getErrorDisplayID() {
+ return mDisplayErrorCode;
+ }
+
+ @Override
+ public void setErrorDisplayID(int aErrorID) {
+ mDisplayErrorCode = aErrorID;
+ }
+
+ @Override
+ public IMetaTileEntity getMetaTileEntity() {
+ return hasValidMetaTileEntity() ? mMetaTileEntity : null;
+ }
+
+ @Override
+ public void setMetaTileEntity(IMetaTileEntity aMetaTileEntity) {
+ mMetaTileEntity = (MetaTileEntity) aMetaTileEntity;
+ }
+
+ @Override
+ public GT_CoverBehavior getCoverBehaviorAtSide(byte aSide) {
+ return aSide >= 0 && aSide < mCoverBehaviors.length ? mCoverBehaviors[aSide] : GregTech_API.sNoBehavior;
+ }
+
+ @Override
+ public void setCoverIDAtSide(byte aSide, int aID) {
+ if (aSide >= 0 && aSide < 6) {
+ mCoverSides[aSide] = aID;
+ mCoverData[aSide] = 0;
+ mCoverBehaviors[aSide] = GregTech_API.getCoverBehavior(aID);
+ issueCoverUpdate(aSide);
+ issueBlockUpdate();
+ }
+ }
+
+ @Override
+ public void setCoverItemAtSide(byte aSide, ItemStack aCover) {
+ GregTech_API.getCoverBehavior(aCover).placeCover(aSide, aCover, this);
+ }
+
+ @Override
+ public int getCoverIDAtSide(byte aSide) {
+ if (aSide >= 0 && aSide < 6) return mCoverSides[aSide];
+ return 0;
+ }
+
+ @Override
+ public ItemStack getCoverItemAtSide(byte aSide) {
+ return GT_Utility.intToStack(getCoverIDAtSide(aSide));
+ }
+
+ @Override
+ public boolean canPlaceCoverIDAtSide(byte aSide, int aID) {
+ return getCoverIDAtSide(aSide) == 0;
+ }
+
+ @Override
+ public boolean canPlaceCoverItemAtSide(byte aSide, ItemStack aCover) {
+ return getCoverIDAtSide(aSide) == 0;
+ }
+
+ @Override
+ public void setCoverDataAtSide(byte aSide, int aData) {
+ if (aSide >= 0 && aSide < 6) mCoverData[aSide] = aData;
+ }
+
+ @Override
+ public int getCoverDataAtSide(byte aSide) {
+ if (aSide >= 0 && aSide < 6) return mCoverData[aSide];
+ return 0;
+ }
+
+ public byte getLightValue() {
+ return mLightValue;
+ }
+
+ @Override
+ public void setLightValue(byte aLightValue) {
+ mLightValue = (byte) (aLightValue & 15);
+ }
+
+ @Override
+ public long getAverageElectricInput() {
+ int rEU = 0;
+ for (int tEU : mAverageEUInput) rEU += tEU;
+ return rEU / mAverageEUInput.length;
+ }
+
+ @Override
+ public long getAverageElectricOutput() {
+ int rEU = 0;
+ for (int tEU : mAverageEUOutput) rEU += tEU;
+ return rEU / mAverageEUOutput.length;
+ }
+
+ @Override
+ public boolean dropCover(byte aSide, byte aDroppedSide, boolean aForced) {
+ if (getCoverBehaviorAtSide(aSide).onCoverRemoval(aSide, getCoverIDAtSide(aSide), mCoverData[aSide], this, aForced) || aForced) {
+ ItemStack tStack = getCoverBehaviorAtSide(aSide).getDrop(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this);
+ if (tStack != null) {
+ tStack.setTagCompound(null);
+ EntityItem tEntity = new EntityItem(worldObj, getOffsetX(aDroppedSide, 1) + 0.5, getOffsetY(aDroppedSide, 1) + 0.5, getOffsetZ(aDroppedSide, 1) + 0.5, tStack);
+ tEntity.motionX = 0;
+ tEntity.motionY = 0;
+ tEntity.motionZ = 0;
+ worldObj.spawnEntityInWorld(tEntity);
+ }
+ setCoverIDAtSide(aSide, 0);
+ if (mMetaTileEntity.hasSidedRedstoneOutputBehavior()) {
+ setOutputRedstoneSignal(aSide, (byte) 0);
+ } else {
+ setOutputRedstoneSignal(aSide, (byte) 15);
+ }
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public String getOwnerName() {
+ if (GT_Utility.isStringInvalid(mOwnerName)) return "Player";
+ return mOwnerName;
+ }
+
+ @Override
+ public String setOwnerName(String aName) {
+ if (GT_Utility.isStringInvalid(aName)) return mOwnerName = "Player";
+ return mOwnerName = aName;
+ }
+
+ @Override
+ public byte getComparatorValue(byte aSide) {
+ return canAccessData() ? mMetaTileEntity.getComparatorValue(aSide) : 0;
+ }
+
+ @Override
+ public byte getStrongOutputRedstoneSignal(byte aSide) {
+ return aSide >= 0 && aSide < 6 && (mStrongRedstone & (1 << aSide)) != 0 ? (byte) (mSidedRedstone[aSide] & 15) : 0;
+ }
+
+ @Override
+ public void setStrongOutputRedstoneSignal(byte aSide, byte aStrength) {
+ mStrongRedstone |= (1 << aSide);
+ setOutputRedstoneSignal(aSide, aStrength);
+ }
+
+ @Override
+ public ItemStack decrStackSize(int aIndex, int aAmount) {
+ if (canAccessData()) {
+ mInventoryChanged = true;
+ return mMetaTileEntity.decrStackSize(aIndex, aAmount);
+ }
+ return null;
+ }
+
+ @Override
+ public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) {
+ if (!canAccessData() || !mMetaTileEntity.isElectric() || !inputEnergyFrom(aSide) || aAmperage <= 0 || aVoltage <= 0 || getStoredEU() >= getEUCapacity() || mMetaTileEntity.maxAmperesIn() <= mAcceptedAmperes)
+ return 0;
+ if (aVoltage > getInputVoltage()) {
+ doExplosion(aVoltage);
+ return 0;
+ }
+ if (increaseStoredEnergyUnits(aVoltage * (aAmperage = Math.min(aAmperage, Math.min(mMetaTileEntity.maxAmperesIn() - mAcceptedAmperes, 1 + ((getEUCapacity() - getStoredEU()) / aVoltage)))), true)) {
+ mAverageEUInput[mAverageEUInputIndex] += aVoltage * aAmperage;
+ mAcceptedAmperes += aAmperage;
+ return aAmperage;
+ }
+ return 0;
+ }
+
+ @Override
+ public boolean drainEnergyUnits(byte aSide, long aVoltage, long aAmperage) {
+ if (!canAccessData() || !mMetaTileEntity.isElectric() || !outputsEnergyTo(aSide) || getStoredEU() - (aVoltage * aAmperage) < mMetaTileEntity.getMinimumStoredEU())
+ return false;
+ if (decreaseStoredEU(aVoltage * aAmperage, false)) {
+ mAverageEUOutput[mAverageEUOutputIndex] += aVoltage * aAmperage;
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean acceptsRotationalEnergy(byte aSide) {
+ if (!canAccessData() || getCoverIDAtSide(aSide) != 0) return false;
+ return mMetaTileEntity.acceptsRotationalEnergy(aSide);
+ }
+
+ @Override
+ public boolean injectRotationalEnergy(byte aSide, long aSpeed, long aEnergy) {
+ if (!canAccessData() || getCoverIDAtSide(aSide) != 0) return false;
+ return mMetaTileEntity.injectRotationalEnergy(aSide, aSpeed, aEnergy);
+ }
+
+ @Override
+ public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) {
+ if (mTickTimer > 5 && canAccessData() && (mRunningThroughTick || !mInputDisabled) && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), aFluid == null ? null : aFluid.getFluid(), this))))
+ return mMetaTileEntity.fill(aSide, aFluid, doFill);
+ return 0;
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection aSide, int maxDrain, boolean doDrain) {
+ if (mTickTimer > 5 && canAccessData() && (mRunningThroughTick || !mOutputDisabled) && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), mMetaTileEntity.getFluid() == null ? null : mMetaTileEntity.getFluid().getFluid(), this))))
+ return mMetaTileEntity.drain(aSide, maxDrain, doDrain);
+ return null;
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) {
+ if (mTickTimer > 5 && canAccessData() && (mRunningThroughTick || !mOutputDisabled) && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), aFluid == null ? null : aFluid.getFluid(), this))))
+ return mMetaTileEntity.drain(aSide, aFluid, doDrain);
+ return null;
+ }
+
+ @Override
+ public boolean canFill(ForgeDirection aSide, Fluid aFluid) {
+ if (mTickTimer > 5 && canAccessData() && (mRunningThroughTick || !mInputDisabled) && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), aFluid, this))))
+ return mMetaTileEntity.canFill(aSide, aFluid);
+ return false;
+ }
+
+ @Override
+ public boolean canDrain(ForgeDirection aSide, Fluid aFluid) {
+ if (mTickTimer > 5 && canAccessData() && (mRunningThroughTick || !mOutputDisabled) && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), aFluid, this))))
+ return mMetaTileEntity.canDrain(aSide, aFluid);
+ return false;
+ }
+
+ @Override
+ public FluidTankInfo[] getTankInfo(ForgeDirection aSide) {
+ if (canAccessData() && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), null, this)) || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), null, this))))
+ return mMetaTileEntity.getTankInfo(aSide);
+ return new FluidTankInfo[]{};
+ }
+
+ public double getOutputEnergyUnitsPerTick() {
+ return oOutput;
+ }
+
+ public boolean isTeleporterCompatible(ForgeDirection aSide) {
+ return canAccessData() && mMetaTileEntity.isTeleporterCompatible();
+ }
+
+ public double demandedEnergyUnits() {
+ if (mReleaseEnergy || !canAccessData() || !mMetaTileEntity.isEnetInput()) return 0;
+ return getEUCapacity() - getStoredEU();
+ }
+
+ public double injectEnergyUnits(ForgeDirection aDirection, double aAmount) {
+ return injectEnergyUnits((byte) aDirection.ordinal(), (int) aAmount, 1) > 0 ? 0 : aAmount;
+ }
+
+ public boolean acceptsEnergyFrom(TileEntity aEmitter, ForgeDirection aDirection) {
+ return inputEnergyFrom((byte) aDirection.ordinal());
+ }
+
+ public boolean emitsEnergyTo(TileEntity aReceiver, ForgeDirection aDirection) {
+ return outputsEnergyTo((byte) aDirection.ordinal());
+ }
+
+ public double getOfferedEnergy() {
+ return (canAccessData() && getStoredEU() - mMetaTileEntity.getMinimumStoredEU() >= oOutput) ? Math.max(0, oOutput) : 0;
+ }
+
+ public void drawEnergy(double amount) {
+ mAverageEUOutput[mAverageEUOutputIndex] += amount;
+ decreaseStoredEU((int) amount, true);
+ }
+
+ public int injectEnergy(ForgeDirection aForgeDirection, int aAmount) {
+ return injectEnergyUnits((byte) aForgeDirection.ordinal(), aAmount, 1) > 0 ? 0 : aAmount;
+ }
+
+ public int addEnergy(int aEnergy) {
+ if (!canAccessData()) return 0;
+ if (aEnergy > 0)
+ increaseStoredEnergyUnits(aEnergy, true);
+ else
+ decreaseStoredEU(-aEnergy, true);
+ return (int) Math.min(Integer.MAX_VALUE, mMetaTileEntity.getEUVar());
+ }
+
+ public boolean isAddedToEnergyNet() {
+ return false;
+ }
+
+ public int demandsEnergy() {
+ if (mReleaseEnergy || !canAccessData() || !mMetaTileEntity.isEnetInput()) return 0;
+ return getCapacity() - getStored();
+ }
+
+ public int getCapacity() {
+ return (int) Math.min(Integer.MAX_VALUE, getEUCapacity());
+ }
+
+ public int getStored() {
+ return (int) Math.min(Integer.MAX_VALUE, Math.min(getStoredEU(), getCapacity()));
+ }
+
+ public void setStored(int aEU) {
+ if (canAccessData()) setStoredEU(aEU);
+ }
+
+ public int getMaxSafeInput() {
+ return (int) Math.min(Integer.MAX_VALUE, getInputVoltage());
+ }
+
+ public int getMaxEnergyOutput() {
+ if (mReleaseEnergy) return Integer.MAX_VALUE;
+ return getOutput();
+ }
+
+ public int getOutput() {
+ return (int) Math.min(Integer.MAX_VALUE, oOutput);
+ }
+
+ public int injectEnergy(Direction aDirection, int aAmount) {
+ return injectEnergyUnits((byte) aDirection.toSideValue(), aAmount, 1) > 0 ? 0 : aAmount;
+ }
+
+ public boolean isTeleporterCompatible(Direction aSide) {
+ return canAccessData() && mMetaTileEntity.isTeleporterCompatible();
+ }
+
+ public boolean acceptsEnergyFrom(TileEntity aReceiver, Direction aDirection) {
+ return inputEnergyFrom((byte) aDirection.toSideValue());
+ }
+
+ public boolean emitsEnergyTo(TileEntity aReceiver, Direction aDirection) {
+ return outputsEnergyTo((byte) aDirection.toSideValue());
+ }
+
+ @Override
+ public boolean isInvalidTileEntity() {
+ return isInvalid();
+ }
+
+ @Override
+ public boolean addStackToSlot(int aIndex, ItemStack aStack) {
+ if (GT_Utility.isStackInvalid(aStack)) return true;
+ if (aIndex < 0 || aIndex >= getSizeInventory()) return false;
+ ItemStack tStack = getStackInSlot(aIndex);
+ if (GT_Utility.isStackInvalid(tStack)) {
+ setInventorySlotContents(aIndex, aStack);
+ return true;
+ }
+ aStack = GT_OreDictUnificator.get(aStack);
+ if (GT_Utility.areStacksEqual(tStack, aStack) && tStack.stackSize + aStack.stackSize <= Math.min(aStack.getMaxStackSize(), getInventoryStackLimit())) {
+ tStack.stackSize += aStack.stackSize;
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean addStackToSlot(int aIndex, ItemStack aStack, int aAmount) {
+ return addStackToSlot(aIndex, GT_Utility.copyAmount(aAmount, aStack));
+ }
+
+ @Override
+ public byte getColorization() {
+ return (byte) (mColor - 1);
+ }
+
+ @Override
+ public byte setColorization(byte aColor) {
+ if (aColor > 15 || aColor < -1) aColor = -1;
+ if (canAccessData()) mMetaTileEntity.onColorChangeServer(aColor);
+ return mColor = (byte) (aColor + 1);
+ }
+
+ @Override
+ public float getBlastResistance(byte aSide) {
+ return canAccessData() ? Math.max(0, getMetaTileEntity().getExplosionResistance(aSide)) : 10.0F;
+ }
+
+ @Override
+ public boolean isUniversalEnergyStored(long aEnergyAmount) {
+ if (getUniversalEnergyStored() >= aEnergyAmount) return true;
+ mHasEnoughEnergy = false;
+ return false;
+ }
+
+ @Override
+ public String[] getInfoData() {
+ {
+ if (canAccessData()) return getMetaTileEntity().getInfoData();
+ return new String[]{};
+ }
+ }
+
+ @Override
+ public void markDirty() {
+ super.markDirty();
+ mInventoryChanged = true;
+ }
+
+ @Override
+ public int getLightOpacity() {
+ return mMetaTileEntity == null ? getLightValue() > 0 ? 0 : 255 : mMetaTileEntity.getLightOpacity();
+ }
+
+ @Override
+ public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, List<AxisAlignedBB> outputAABB, Entity collider) {
+ mMetaTileEntity.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider);
+ }
+
+ @Override
+ public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) {
+ return mMetaTileEntity.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ);
+ }
+
+ @Override
+ public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity collider) {
+ mMetaTileEntity.onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider);
+ }
+
+
+ public ITexture[] getTexture(Block arg0, byte aSide) {
+ ITexture rIcon = getCoverTexture(aSide);
+ if (rIcon != null) return new ITexture[]{rIcon};
+ if (hasValidMetaTileEntity())
+ return mMetaTileEntity.getTexture(this, aSide, mFacing, (byte) (mColor - 1), mActive, getOutputRedstoneSignal(aSide) > 0);
+ return Textures.BlockIcons.ERROR_RENDERING;
+ }
+
+ public ITexture[] getTexture(byte aSide) {
+ ITexture rIcon = getCoverTexture(aSide);
+ if (rIcon != null) return new ITexture[]{rIcon};
+ if (hasValidMetaTileEntity())
+ return mMetaTileEntity.getTexture(this, aSide, mFacing, (byte) (mColor - 1), mActive, getOutputRedstoneSignal(aSide) > 0);
+ return Textures.BlockIcons.ERROR_RENDERING;
+ }
} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechMetaPipeEntity_BaseSuperConductor.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechMetaPipeEntity_BaseSuperConductor.java
index 0268ceeeca..47189bd4f4 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechMetaPipeEntity_BaseSuperConductor.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechMetaPipeEntity_BaseSuperConductor.java
@@ -1,18 +1,20 @@
package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.lossless;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
+import static gregtech.api.enums.GT_Values.GT;
+import static gregtech.api.enums.GT_Values.V;
import gregtech.api.GregTech_API;
-import gregtech.api.enums.GT_Values;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.BaseMetaPipeEntity;
import gregtech.api.objects.GT_ItemStack;
-import gregtech.api.util.*;
+import gregtech.api.util.GT_Config;
+import gregtech.api.util.GT_LanguageManager;
+import gregtech.api.util.GT_Utility;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -26,703 +28,613 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
-import net.minecraftforge.fluids.*;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.FluidTankInfo;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
/**
* NEVER INCLUDE THIS FILE IN YOUR MOD!!!
* <p/>
- * Extend this Class to add a new MetaPipe Call the Constructor with the desired
- * ID at the load-phase (not preload and also not postload!) Implement the
- * newMetaEntity-Method to return a new ready instance of your MetaTileEntity
+ * Extend this Class to add a new MetaPipe
+ * Call the Constructor with the desired ID at the load-phase (not preload and also not postload!)
+ * Implement the newMetaEntity-Method to return a new ready instance of your MetaTileEntity
* <p/>
- * Call the Constructor like the following example inside the Load Phase, to
- * register it. "new GT_MetaTileEntity_E_Furnace(54, "GT_E_Furnace", "Automatic
- * E-Furnace");"
+ * Call the Constructor like the following example inside the Load Phase, to register it.
+ * "new GT_MetaTileEntity_E_Furnace(54, "GT_E_Furnace", "Automatic E-Furnace");"
*/
public abstract class GregtechMetaPipeEntity_BaseSuperConductor implements IMetaTileEntity {
- /**
- * The Inventory of the MetaTileEntity. Amount of Slots can be larger than
- * 256. HAYO!
- */
- public final ItemStack[] mInventory;
- /**
- * This variable tells, which directions the Block is connected to. It is a
- * Bitmask.
- */
- public byte mConnections = 0;
- /**
- * Only assigned for the MetaTileEntity in the List! Also only used to get
- * the localized Name for the ItemStack and for getInvName.
- */
- public String mName;
- public boolean doTickProfilingInThisTick = true;
- /**
- * accessibility to this Field is no longer given, see below
- */
- private IGregTechTileEntity mBaseMetaTileEntity;
-
- /**
- * This registers your Machine at the List. Use only ID's larger than 2048,
- * because i reserved these ones. See also the List in the API, as it has a
- * Description containing all the reservations.
- *
- * @param aID
- * the ID
- * @example for Constructor overload.
- * <p/>
- * public GT_MetaTileEntity_EBench(int aID, String mName, String
- * mNameRegional) { super(aID, mName, mNameRegional); }
- */
- public GregtechMetaPipeEntity_BaseSuperConductor(final int aID, final String aBasicName, final String aRegionalName,
- final int aInvSlotCount) {
- if (GregTech_API.sPostloadStarted || !GregTech_API.sPreloadStarted) {
- throw new IllegalAccessError("This Constructor has to be called in the load Phase");
- }
- if (GregTech_API.METATILEENTITIES[aID] == null) {
- GregTech_API.METATILEENTITIES[aID] = this;
- }
- else {
- throw new IllegalArgumentException("MetaMachine-Slot Nr. " + aID + " is already occupied!");
- }
- this.mName = aBasicName.replaceAll(" ", "_").toLowerCase();
- this.setBaseMetaTileEntity(new BaseMetaPipeEntity());
- this.getBaseMetaTileEntity().setMetaTileID((short) aID);
- GT_LanguageManager.addStringLocalization("gt.blockmachines." + this.mName + ".name", aRegionalName);
- this.mInventory = new ItemStack[aInvSlotCount];
-
- if (GT_Values.GT.isClientSide()) {
- final ItemStack tStack = new ItemStack(GregTech_API.sBlockMachines, 1, aID);
- tStack.getItem().addInformation(tStack, null, new ArrayList<String>(), true);
- }
- }
-
- /**
- * This is the normal Constructor.
- */
- public GregtechMetaPipeEntity_BaseSuperConductor(final String aName, final int aInvSlotCount) {
- this.mInventory = new ItemStack[aInvSlotCount];
- this.mName = aName;
- }
-
- @Override
- public boolean acceptsRotationalEnergy(final byte aSide) {
- return false;
- }
-
- @Override
- public void addCollisionBoxesToList(final World aWorld, final int aX, final int aY, final int aZ,
- final AxisAlignedBB inputAABB, final List<AxisAlignedBB> outputAABB, final Entity collider) {
- final AxisAlignedBB axisalignedbb1 = this.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ);
- if (axisalignedbb1 != null && inputAABB.intersectsWith(axisalignedbb1)) {
- outputAABB.add(axisalignedbb1);
- }
- }
-
- @Override
- public boolean allowCoverOnSide(final byte aSide, final GT_ItemStack aCoverID) {
- return true;
- }
-
- @Override
- public boolean canDrain(final ForgeDirection aSide, final Fluid aFluid) {
- return this.drain(aSide, new FluidStack(aFluid, 1), false) != null;
- }
-
- @Override
- public boolean canExtractItem(final int aIndex, final ItemStack aStack, final int aSide) {
- return this.isValidSlot(aIndex) && aStack != null && aIndex < this.mInventory.length
- && this.allowPullStack(this.getBaseMetaTileEntity(), aIndex, (byte) aSide, aStack);
- }
-
- @Override
- public boolean canFill(final ForgeDirection aSide, final Fluid aFluid) {
- return this.fill(aSide, new FluidStack(aFluid, 1), false) == 1;
- }
-
- @Override
- public boolean canInsertItem(final int aIndex, final ItemStack aStack, final int aSide) {
- return this.isValidSlot(aIndex) && aStack != null && aIndex < this.mInventory.length
- && (this.mInventory[aIndex] == null || GT_Utility.areStacksEqual(aStack, this.mInventory[aIndex]))
- && this.allowPutStack(this.getBaseMetaTileEntity(), aIndex, (byte) aSide, aStack);
- }
-
- @Override
- public void closeInventory() {
- //
- }
-
- @Override
- public boolean connectsToItemPipe(final byte aSide) {
- return false;
- }
-
- @Override
- public ItemStack decrStackSize(final int aIndex, final int aAmount) {
- final ItemStack tStack = this.getStackInSlot(aIndex);
- ItemStack rStack = GT_Utility.copy(tStack);
- if (tStack != null) {
- if (tStack.stackSize <= aAmount) {
- if (this.setStackToZeroInsteadOfNull(aIndex)) {
- tStack.stackSize = 0;
- }
- else {
- this.setInventorySlotContents(aIndex, null);
- }
- }
- else {
- rStack = tStack.splitStack(aAmount);
- if (tStack.stackSize == 0 && !this.setStackToZeroInsteadOfNull(aIndex)) {
- this.setInventorySlotContents(aIndex, null);
- }
- }
- }
- return rStack;
- }
-
- @Override
- public void doExplosion(final long aExplosionPower) {
- final float tStrength = aExplosionPower < GT_Values.V[0] ? 1.0F
- : aExplosionPower < GT_Values.V[1] ? 2.0F
- : aExplosionPower < GT_Values.V[2] ? 3.0F
- : aExplosionPower < GT_Values.V[3] ? 4.0F
- : aExplosionPower < GT_Values.V[4] ? 5.0F
- : aExplosionPower < GT_Values.V[4] * 2 ? 6.0F
- : aExplosionPower < GT_Values.V[5] ? 7.0F
- : aExplosionPower < GT_Values.V[6] ? 8.0F
- : aExplosionPower < GT_Values.V[7] ? 9.0F
- : 10.0F;
- final int tX = this.getBaseMetaTileEntity().getXCoord(), tY = this.getBaseMetaTileEntity().getYCoord(),
- tZ = this.getBaseMetaTileEntity().getZCoord();
- final World tWorld = this.getBaseMetaTileEntity().getWorld();
- tWorld.setBlock(tX, tY, tZ, Blocks.air);
- if (GregTech_API.sMachineExplosions) {
- tWorld.createExplosion(null, tX + 0.5, tY + 0.5, tZ + 0.5, tStrength, true);
- }
- }
-
- @Override
- public void doSound(final byte aIndex, final double aX, final double aY, final double aZ) {
- /* Do nothing */}
-
- @Override
- public boolean doTickProfilingMessageDuringThisTick() {
- return this.doTickProfilingInThisTick;
- }
-
- @Override
- public FluidStack drain(final ForgeDirection aSide, final FluidStack aFluid, final boolean doDrain) {
- if (this.getFluid() != null && aFluid != null && this.getFluid().isFluidEqual(aFluid)) {
- return this.drain(aFluid.amount, doDrain);
- }
- return null;
- }
-
- @Override
- public FluidStack drain(final ForgeDirection aSide, final int maxDrain, final boolean doDrain) {
- return this.drain(maxDrain, doDrain);
- }
-
- /**
- * tries to empty this Tank
- */
- @Override
- public FluidStack drain(final int maxDrain, final boolean doDrain) {
- return null;
- }
-
- /**
- * tries to fill this Tank
- */
- @Override
- public int fill(final FluidStack resource, final boolean doFill) {
- return 0;
- }
-
- @Override
- public int fill(final ForgeDirection aSide, final FluidStack aFluid, final boolean doFill) {
- return this.fill_default(aSide, aFluid, doFill);
- }
-
- public int fill_default(final ForgeDirection aSide, final FluidStack aFluid, final boolean doFill) {
- return this.fill(aFluid, doFill);
- }
-
- @Override
- public int[] getAccessibleSlotsFromSide(final int aSide) {
- final ArrayList<Integer> tList = new ArrayList<Integer>();
- final IGregTechTileEntity tTileEntity = this.getBaseMetaTileEntity();
- final boolean tSkip = tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide,
- tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), -2,
- tTileEntity)
- || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide,
- tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), -2,
- tTileEntity);
- for (int i = 0; i < this.getSizeInventory(); i++) {
- if (this.isValidSlot(i) && (tSkip
- || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide,
- tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), i,
- tTileEntity)
- || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide,
- tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), i,
- tTileEntity))) {
- tList.add(i);
- }
- }
- final int[] rArray = new int[tList.size()];
- for (int i = 0; i < rArray.length; i++) {
- rArray[i] = tList.get(i);
- }
- return rArray;
- }
-
- @Override
- public IGregTechTileEntity getBaseMetaTileEntity() {
- return this.mBaseMetaTileEntity;
- }
-
- /**
- * Liquid Capacity
- */
- @Override
- public int getCapacity() {
- return 0;
- }
-
- @Override
- public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory,
- final IGregTechTileEntity aBaseMetaTileEntity) {
- return null;
- }
-
- @Override
- public AxisAlignedBB getCollisionBoundingBoxFromPool(final World aWorld, final int aX, final int aY, final int aZ) {
- return AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + 1, aY + 1, aZ + 1);
- }
-
- @Override
- public byte getComparatorValue(final byte aSide) {
- return 0;
- }
-
- @Override
- public float getExplosionResistance(final byte aSide) {
- return 10.0F;
- }
-
- /**
- * gets the contained Liquid
- */
- @Override
- public FluidStack getFluid() {
- return null;
- }
-
- @Override
- public int getFluidAmount() {
- return 0;
- }
-
- @Override
- public FluidTankInfo getInfo() {
- return new FluidTankInfo(this);
- }
-
- @Override
- public String[] getInfoData() {
- return new String[] {};
- }
-
- @Override
- public String getInventoryName() {
- if (GregTech_API.METATILEENTITIES[this.getBaseMetaTileEntity().getMetaTileID()] != null) {
- return GregTech_API.METATILEENTITIES[this.getBaseMetaTileEntity().getMetaTileID()].getMetaName();
- }
- return "";
- }
-
- @Override
- public int getInventoryStackLimit() {
- return 64;
- }
-
- @Override
- public int getLightOpacity() {
- return 0;
- }
-
- public int getMaxItemCount() {
- return 0;
- }
-
- @Override
- public String getMetaName() {
- return this.mName;
- }
-
- /**
- * Progress this machine has already made
- */
- public int getProgresstime() {
- return 0;
- }
-
- @Override
- public ItemStack[] getRealInventory() {
- return this.mInventory;
- }
-
- @Override
- public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory,
- final IGregTechTileEntity aBaseMetaTileEntity) {
- return null;
- }
-
- @Override
- public int getSizeInventory() {
- return this.mInventory.length;
- }
-
- @Override
- public ArrayList<String> getSpecialDebugInfo(final IGregTechTileEntity aBaseMetaTileEntity,
- final EntityPlayer aPlayer, final int aLogLevel, final ArrayList<String> aList) {
- return aList;
- }
-
- @Override
- public String getSpecialVoltageToolTip() {
- return null;
- }
-
- @Override
- public ItemStack getStackForm(final long aAmount) {
- return new ItemStack(GregTech_API.sBlockMachines, (int) aAmount, this.getBaseMetaTileEntity().getMetaTileID());
- }
-
- @Override
- public ItemStack getStackInSlot(final int aIndex) {
- if (aIndex >= 0 && aIndex < this.mInventory.length) {
- return this.mInventory[aIndex];
- }
- return null;
- }
-
- @Override
- public ItemStack getStackInSlotOnClosing(final int i) {
- return null;
- }
-
- public ItemStack[] getStoredItemData() {
- return null;
- }
-
- @Override
- public FluidTankInfo[] getTankInfo(final ForgeDirection aSide) {
- if (this.getCapacity() <= 0 && !this.getBaseMetaTileEntity().hasSteamEngineUpgrade()) {
- return new FluidTankInfo[] {};
- }
- return new FluidTankInfo[] {
- this.getInfo()
- };
- }
-
- /**
- * Tank pressure
- */
- public int getTankPressure() {
- return 0;
- }
-
- /**
- * For Pipe Rendering
- */
- public abstract float getThickNess();
-
- @Override
- public byte getUpdateData() {
- return 0;
- }
-
- @Override
- public boolean hasCustomInventoryName() {
- return false;
- }
-
- /**
- * Increases the Progress, returns the overflown Progress.
- */
- public int increaseProgress(final int aProgress) {
- return 0;
- }
-
- @Override
- public void initDefaultModes(final NBTTagCompound aNBT) {
- /* Do nothing */}
-
- public long injectEnergyUnits(final byte aSide, final long aVoltage, final long aAmperage) {
- return 0;
- }
-
- @Override
- public boolean injectRotationalEnergy(final byte aSide, final long aSpeed, final long aEnergy) {
- return false;
- }
-
- @Override
- public void inValidate() {
- /* Do nothing */}
-
- @Override
- public boolean isAccessAllowed(final EntityPlayer aPlayer) {
- return true;
- }
-
- public boolean isDigitalChest() {
- return false;
- }
-
- @Override
- public boolean isFacingValid(final byte aFacing) {
- return false;
- }
-
- @Override
- public boolean isGivingInformation() {
- return false;
- }
-
- @Override
- public boolean isItemValidForSlot(final int aIndex, final ItemStack aStack) {
- return this.getBaseMetaTileEntity().isValidSlot(aIndex);
- }
-
- @Override
- public boolean isLiquidInput(final byte aSide) {
- return true;
- }
-
- @Override
- public boolean isLiquidOutput(final byte aSide) {
- return true;
- }
-
- @Override
- public boolean isSimpleMachine() {
- return false;
- }
-
- @Override
- public boolean isUseableByPlayer(final EntityPlayer entityplayer) {
- return false;
- }
-
- @Override
- public boolean isValidSlot(final int aIndex) {
- return true;
- }
-
- @Override
- public void markDirty() {
- //
- }
-
- /**
- * Progress this Machine has to do to produce something
- */
- public int maxProgresstime() {
- return 0;
- }
-
- /**
- * When a GUI is closed
- */
- public void onCloseGUI() {
- /* Do nothing */}
-
- @Override
- public void onColorChangeClient(final byte aColor) {
- //
- }
-
- @Override
- public void onColorChangeServer(final byte aColor) {
- //
- }
-
- @Override
- public void onConfigLoad(final GT_Config aConfig) {
- /* Do nothing */}
-
- @Override
- public void onCreated(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) {
- //
- }
-
- @Override
- public void onEntityCollidedWithBlock(final World aWorld, final int aX, final int aY, final int aZ,
- final Entity collider) {
- //
- }
-
- @Override
- public void onExplosion() {
- /* Do nothing */}
-
- @Override
- public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) {
- /* Do nothing */}
-
- @Override
- public void onLeftclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) {
- /* Do nothing */}
-
- @Override
- public void onMachineBlockUpdate() {
- /* Do nothing */}
-
- /**
- * When a GUI is opened
- */
- public void onOpenGUI() {
- /* Do nothing */}
-
- @Override
- public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) {
- /* Do nothing */}
-
- @Override
- public void onPreTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) {
- /* Do nothing */}
-
- @Override
- public void onRemoval() {
- /* Do nothing */}
-
- /**
- * a Player rightclicks the Machine Sneaky rightclicks are not getting
- * passed to this!
- */
- @Override
- public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer,
- final byte aSide, final float aX, final float aY, final float aZ) {
- return false;
- }
-
- @Override
- public void onScrewdriverRightClick(final byte aSide, final EntityPlayer aPlayer, final float aX, final float aY,
- final float aZ) {
- /* Do nothing */}
-
- @Override
- public void onServerStart() {
- /* Do nothing */}
-
- @Override
- public void onValueUpdate(final byte aValue) {
- /* Do nothing */}
-
- @Override
- public void onWorldLoad(final File aSaveDirectory) {
- /* Do nothing */}
-
- @Override
- public void onWorldSave(final File aSaveDirectory) {
- /* Do nothing */}
-
- @Override
- public boolean onWrenchRightClick(final byte aSide, final byte aWrenchingSide, final EntityPlayer aPlayer,
- final float aX, final float aY, final float aZ) {
- return false;
- }
-
- @Override
- public void openInventory() {
- //
- }
-
- @Override
- public void receiveClientEvent(final byte aEventID, final byte aValue) {
- /* Do nothing */}
-
- @Override
- @SideOnly(Side.CLIENT)
- public void registerIcons(final IIconRegister aBlockIconRegister) {
- /* Do nothing */}
-
- @Override
- @SideOnly(Side.CLIENT)
- public boolean renderInInventory(final Block aBlock, final int aMeta, final RenderBlocks aRenderer) {
- return false;
- }
-
- /**
- * For Pipe Rendering
- */
- public abstract boolean renderInside(byte aSide);
-
- @Override
- @SideOnly(Side.CLIENT)
- public boolean renderInWorld(final IBlockAccess aWorld, final int aX, final int aY, final int aZ,
- final Block aBlock, final RenderBlocks aRenderer) {
- return false;
- }
-
- @Override
- public final void sendLoopEnd(final byte aIndex) {
- if (!this.getBaseMetaTileEntity().hasMufflerUpgrade()) {
- this.getBaseMetaTileEntity().sendBlockEvent((byte) 6, aIndex);
- }
- }
-
- @Override
- public final void sendLoopStart(final byte aIndex) {
- if (!this.getBaseMetaTileEntity().hasMufflerUpgrade()) {
- this.getBaseMetaTileEntity().sendBlockEvent((byte) 5, aIndex);
- }
- }
-
- @Override
- public final void sendSound(final byte aIndex) {
- if (!this.getBaseMetaTileEntity().hasMufflerUpgrade()) {
- this.getBaseMetaTileEntity().sendBlockEvent((byte) 4, aIndex);
- }
- }
-
- @Override
- public void setBaseMetaTileEntity(final IGregTechTileEntity aBaseMetaTileEntity) {
- if (this.mBaseMetaTileEntity != null && aBaseMetaTileEntity == null) {
- this.mBaseMetaTileEntity.getMetaTileEntity().inValidate();
- this.mBaseMetaTileEntity.setMetaTileEntity(null);
- }
- this.mBaseMetaTileEntity = aBaseMetaTileEntity;
- if (this.mBaseMetaTileEntity != null) {
- this.mBaseMetaTileEntity.setMetaTileEntity(this);
- }
- }
-
- @Override
- public void setInventorySlotContents(final int aIndex, final ItemStack aStack) {
- if (aIndex >= 0 && aIndex < this.mInventory.length) {
- this.mInventory[aIndex] = aStack;
- }
- }
-
- public void setItemCount(final int aCount) {
- /* Do nothing */}
-
- @Override
- public void setItemNBT(final NBTTagCompound aNBT) {
- /* Do nothing */}
-
- @Override
- public boolean setStackToZeroInsteadOfNull(final int aIndex) {
- return false;
- }
-
- @Override
- public void startSoundLoop(final byte aIndex, final double aX, final double aY, final double aZ) {
- /* Do nothing */}
-
- @Override
- public void stopSoundLoop(final byte aValue, final double aX, final double aY, final double aZ) {
- /* Do nothing */}
+ /**
+ * The Inventory of the MetaTileEntity. Amount of Slots can be larger than 256. HAYO!
+ */
+ public final ItemStack[] mInventory;
+ /**
+ * This variable tells, which directions the Block is connected to. It is a Bitmask.
+ */
+ public byte mConnections = 0;
+ /**
+ * Only assigned for the MetaTileEntity in the List! Also only used to get the localized Name for the ItemStack and for getInvName.
+ */
+ public String mName;
+ public boolean doTickProfilingInThisTick = true;
+ /**
+ * accessibility to this Field is no longer given, see below
+ */
+ private IGregTechTileEntity mBaseMetaTileEntity;
+
+ /**
+ * This registers your Machine at the List.
+ * Use only ID's larger than 2048, because i reserved these ones.
+ * See also the List in the API, as it has a Description containing all the reservations.
+ *
+ * @param aID the ID
+ * @example for Constructor overload.
+ * <p/>
+ * public GT_MetaTileEntity_EBench(int aID, String mName, String mNameRegional) {
+ * super(aID, mName, mNameRegional);
+ * }
+ */
+ public GregtechMetaPipeEntity_BaseSuperConductor(int aID, String aBasicName, String aRegionalName, int aInvSlotCount) {
+ if (GregTech_API.sPostloadStarted || !GregTech_API.sPreloadStarted)
+ throw new IllegalAccessError("This Constructor has to be called in the load Phase");
+ if (GregTech_API.METATILEENTITIES[aID] == null) {
+ GregTech_API.METATILEENTITIES[aID] = this;
+ } else {
+ throw new IllegalArgumentException("MetaMachine-Slot Nr. " + aID + " is already occupied!");
+ }
+ mName = aBasicName.replaceAll(" ", "_").toLowerCase();
+ setBaseMetaTileEntity(new BaseMetaPipeEntity());
+ getBaseMetaTileEntity().setMetaTileID((short) aID);
+ GT_LanguageManager.addStringLocalization("gt.blockmachines." + mName + ".name", aRegionalName);
+ mInventory = new ItemStack[aInvSlotCount];
+
+ if (GT.isClientSide()) {
+ ItemStack tStack = new ItemStack(GregTech_API.sBlockMachines, 1, aID);
+ tStack.getItem().addInformation(tStack, null, new ArrayList<String>(), true);
+ }
+ }
+
+ /**
+ * This is the normal Constructor.
+ */
+ public GregtechMetaPipeEntity_BaseSuperConductor(String aName, int aInvSlotCount) {
+ mInventory = new ItemStack[aInvSlotCount];
+ mName = aName;
+ }
+
+ /**
+ * For Pipe Rendering
+ */
+ public abstract float getThickNess();
+
+ /**
+ * For Pipe Rendering
+ */
+ public abstract boolean renderInside(byte aSide);
+
+ @Override
+ public IGregTechTileEntity getBaseMetaTileEntity() {
+ return mBaseMetaTileEntity;
+ }
+
+ @Override
+ public void setBaseMetaTileEntity(IGregTechTileEntity aBaseMetaTileEntity) {
+ if (mBaseMetaTileEntity != null && aBaseMetaTileEntity == null) {
+ mBaseMetaTileEntity.getMetaTileEntity().inValidate();
+ mBaseMetaTileEntity.setMetaTileEntity(null);
+ }
+ mBaseMetaTileEntity = aBaseMetaTileEntity;
+ if (mBaseMetaTileEntity != null) {
+ mBaseMetaTileEntity.setMetaTileEntity(this);
+ }
+ }
+
+ @Override
+ public ItemStack getStackForm(long aAmount) {
+ return new ItemStack(GregTech_API.sBlockMachines, (int) aAmount, getBaseMetaTileEntity().getMetaTileID());
+ }
+
+ @Override
+ public void onServerStart() {/*Do nothing*/}
+
+ @Override
+ public void onWorldSave(File aSaveDirectory) {/*Do nothing*/}
+
+ @Override
+ public void onWorldLoad(File aSaveDirectory) {/*Do nothing*/}
+
+ @Override
+ public void onConfigLoad(GT_Config aConfig) {/*Do nothing*/}
+
+ @Override
+ public void setItemNBT(NBTTagCompound aNBT) {/*Do nothing*/}
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IIconRegister aBlockIconRegister) {/*Do nothing*/}
+
+ @Override
+ public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) {
+ return true;
+ }
+
+ @Override
+ public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {/*Do nothing*/}
+
+ @Override
+ public boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ return false;
+ }
+
+ @Override
+ public void onExplosion() {/*Do nothing*/}
+
+ @Override
+ public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) {/*Do nothing*/}
+
+ @Override
+ public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {/*Do nothing*/}
+
+ @Override
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {/*Do nothing*/}
+
+ @Override
+ public void inValidate() {/*Do nothing*/}
+
+ @Override
+ public void onRemoval() {/*Do nothing*/}
+
+ @Override
+ public void initDefaultModes(NBTTagCompound aNBT) {/*Do nothing*/}
+
+ /**
+ * When a GUI is opened
+ */
+ public void onOpenGUI() {/*Do nothing*/}
+
+ /**
+ * When a GUI is closed
+ */
+ public void onCloseGUI() {/*Do nothing*/}
+
+ /**
+ * a Player rightclicks the Machine
+ * Sneaky rightclicks are not getting passed to this!
+ */
+ @Override
+ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) {
+ return false;
+ }
+
+ @Override
+ public void onLeftclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {/*Do nothing*/}
+
+ @Override
+ public void onValueUpdate(byte aValue) {/*Do nothing*/}
+
+ @Override
+ public byte getUpdateData() {
+ return 0;
+ }
+
+ @Override
+ public void doSound(byte aIndex, double aX, double aY, double aZ) {/*Do nothing*/}
+
+ @Override
+ public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) {/*Do nothing*/}
+
+ @Override
+ public void stopSoundLoop(byte aValue, double aX, double aY, double aZ) {/*Do nothing*/}
+
+ @Override
+ public final void sendSound(byte aIndex) {
+ if (!getBaseMetaTileEntity().hasMufflerUpgrade()) getBaseMetaTileEntity().sendBlockEvent((byte) 4, aIndex);
+ }
+
+ @Override
+ public final void sendLoopStart(byte aIndex) {
+ if (!getBaseMetaTileEntity().hasMufflerUpgrade()) getBaseMetaTileEntity().sendBlockEvent((byte) 5, aIndex);
+ }
+
+ @Override
+ public final void sendLoopEnd(byte aIndex) {
+ if (!getBaseMetaTileEntity().hasMufflerUpgrade()) getBaseMetaTileEntity().sendBlockEvent((byte) 6, aIndex);
+ }
+
+ @Override
+ public boolean isFacingValid(byte aFacing) {
+ return false;
+ }
+
+ @Override
+ public boolean isAccessAllowed(EntityPlayer aPlayer) {
+ return true;
+ }
+
+ @Override
+ public boolean isValidSlot(int aIndex) {
+ return true;
+ }
+
+ @Override
+ public boolean setStackToZeroInsteadOfNull(int aIndex) {
+ return false;
+ }
+
+ @Override
+ public ArrayList<String> getSpecialDebugInfo(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, int aLogLevel, ArrayList<String> aList) {
+ return aList;
+ }
+
+ @Override
+ public boolean isLiquidInput(byte aSide) {
+ return true;
+ }
+
+ @Override
+ public boolean isLiquidOutput(byte aSide) {
+ return true;
+ }
+
+ /**
+ * gets the contained Liquid
+ */
+ @Override
+ public FluidStack getFluid() {
+ return null;
+ }
+
+ /**
+ * tries to fill this Tank
+ */
+ @Override
+ public int fill(FluidStack resource, boolean doFill) {
+ return 0;
+ }
+
+ /**
+ * tries to empty this Tank
+ */
+ @Override
+ public FluidStack drain(int maxDrain, boolean doDrain) {
+ return null;
+ }
+
+ /**
+ * Tank pressure
+ */
+ public int getTankPressure() {
+ return 0;
+ }
+
+ /**
+ * Liquid Capacity
+ */
+ @Override
+ public int getCapacity() {
+ return 0;
+ }
+
+ /**
+ * Progress this machine has already made
+ */
+ public int getProgresstime() {
+ return 0;
+ }
+
+ /**
+ * Progress this Machine has to do to produce something
+ */
+ public int maxProgresstime() {
+ return 0;
+ }
+
+ /**
+ * Increases the Progress, returns the overflown Progress.
+ */
+ public int increaseProgress(int aProgress) {
+ return 0;
+ }
+
+ @Override
+ public void onMachineBlockUpdate() {/*Do nothing*/}
+
+ @Override
+ public void receiveClientEvent(byte aEventID, byte aValue) {/*Do nothing*/}
+
+ @Override
+ public boolean isSimpleMachine() {
+ return false;
+ }
+
+ @Override
+ public byte getComparatorValue(byte aSide) {
+ return 0;
+ }
+
+ @Override
+ public boolean acceptsRotationalEnergy(byte aSide) {
+ return false;
+ }
+
+ @Override
+ public boolean injectRotationalEnergy(byte aSide, long aSpeed, long aEnergy) {
+ return false;
+ }
+
+ @Override
+ public String getSpecialVoltageToolTip() {
+ return null;
+ }
+
+ @Override
+ public boolean isGivingInformation() {
+ return false;
+ }
+
+ @Override
+ public String[] getInfoData() {
+ return new String[]{};
+ }
+
+ public boolean isDigitalChest() {
+ return false;
+ }
+
+ public ItemStack[] getStoredItemData() {
+ return null;
+ }
+
+ public void setItemCount(int aCount) {/*Do nothing*/}
+
+ public int getMaxItemCount() {
+ return 0;
+ }
+
+ @Override
+ public int getSizeInventory() {
+ return mInventory.length;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(int aIndex) {
+ if (aIndex >= 0 && aIndex < mInventory.length) return mInventory[aIndex];
+ return null;
+ }
+
+ @Override
+ public void setInventorySlotContents(int aIndex, ItemStack aStack) {
+ if (aIndex >= 0 && aIndex < mInventory.length) mInventory[aIndex] = aStack;
+ }
+
+ @Override
+ public String getInventoryName() {
+ if (GregTech_API.METATILEENTITIES[getBaseMetaTileEntity().getMetaTileID()] != null)
+ return GregTech_API.METATILEENTITIES[getBaseMetaTileEntity().getMetaTileID()].getMetaName();
+ return "";
+ }
+
+ @Override
+ public int getInventoryStackLimit() {
+ return 64;
+ }
+
+ @Override
+ public boolean isItemValidForSlot(int aIndex, ItemStack aStack) {
+ return getBaseMetaTileEntity().isValidSlot(aIndex);
+ }
+
+ @Override
+ public ItemStack decrStackSize(int aIndex, int aAmount) {
+ ItemStack tStack = getStackInSlot(aIndex), rStack = GT_Utility.copy(tStack);
+ if (tStack != null) {
+ if (tStack.stackSize <= aAmount) {
+ if (setStackToZeroInsteadOfNull(aIndex)) tStack.stackSize = 0;
+ else setInventorySlotContents(aIndex, null);
+ } else {
+ rStack = tStack.splitStack(aAmount);
+ if (tStack.stackSize == 0 && !setStackToZeroInsteadOfNull(aIndex))
+ setInventorySlotContents(aIndex, null);
+ }
+ }
+ return rStack;
+ }
+
+ @Override
+ public int[] getAccessibleSlotsFromSide(int aSide) {
+ ArrayList<Integer> tList = new ArrayList<Integer>();
+ IGregTechTileEntity tTileEntity = getBaseMetaTileEntity();
+ boolean tSkip = tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), -2, tTileEntity) || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), -2, tTileEntity);
+ for (int i = 0; i < getSizeInventory(); i++)
+ if (isValidSlot(i) && (tSkip || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), i, tTileEntity) || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), i, tTileEntity)))
+ tList.add(i);
+ int[] rArray = new int[tList.size()];
+ for (int i = 0; i < rArray.length; i++) rArray[i] = tList.get(i);
+ return rArray;
+ }
+
+ @Override
+ public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) {
+ return isValidSlot(aIndex) && aStack != null && aIndex < mInventory.length && (mInventory[aIndex] == null || GT_Utility.areStacksEqual(aStack, mInventory[aIndex])) && allowPutStack(getBaseMetaTileEntity(), aIndex, (byte) aSide, aStack);
+ }
+
+ @Override
+ public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) {
+ return isValidSlot(aIndex) && aStack != null && aIndex < mInventory.length && allowPullStack(getBaseMetaTileEntity(), aIndex, (byte) aSide, aStack);
+ }
+
+ @Override
+ public boolean canFill(ForgeDirection aSide, Fluid aFluid) {
+ return fill(aSide, new FluidStack(aFluid, 1), false) == 1;
+ }
+
+ @Override
+ public boolean canDrain(ForgeDirection aSide, Fluid aFluid) {
+ return drain(aSide, new FluidStack(aFluid, 1), false) != null;
+ }
+
+ @Override
+ public FluidTankInfo[] getTankInfo(ForgeDirection aSide) {
+ if (getCapacity() <= 0 && !getBaseMetaTileEntity().hasSteamEngineUpgrade()) return new FluidTankInfo[]{};
+ return new FluidTankInfo[]{getInfo()};
+ }
+
+ public int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) {
+ return fill(aFluid, doFill);
+ }
+
+ @Override
+ public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) {
+ return fill_default(aSide, aFluid, doFill);
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) {
+ if (getFluid() != null && aFluid != null && getFluid().isFluidEqual(aFluid))
+ return drain(aFluid.amount, doDrain);
+ return null;
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection aSide, int maxDrain, boolean doDrain) {
+ return drain(maxDrain, doDrain);
+ }
+
+ @Override
+ public int getFluidAmount() {
+ return 0;
+ }
+
+ @Override
+ public FluidTankInfo getInfo() {
+ return new FluidTankInfo(this);
+ }
+
+ @Override
+ public String getMetaName() {
+ return mName;
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(int i) {
+ return null;
+ }
+
+ @Override
+ public boolean doTickProfilingMessageDuringThisTick() {
+ return doTickProfilingInThisTick;
+ }
+
+ @Override
+ public boolean isUseableByPlayer(EntityPlayer entityplayer) {
+ return false;
+ }
+
+ @Override
+ public boolean connectsToItemPipe(byte aSide) {
+ return false;
+ }
+
+ @Override
+ public void openInventory() {
+ //
+ }
+
+ @Override
+ public void closeInventory() {
+ //
+ }
+
+ @Override
+ public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return null;
+ }
+
+ @Override
+ public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return null;
+ }
+
+ @Override
+ public float getExplosionResistance(byte aSide) {
+ return 10.0F;
+ }
+
+ @Override
+ public ItemStack[] getRealInventory() {
+ return mInventory;
+ }
+
+ @Override
+ public boolean hasCustomInventoryName() {
+ return false;
+ }
+
+ @Override
+ public void markDirty() {
+ //
+ }
+
+ @Override
+ public void onColorChangeServer(byte aColor) {
+ //
+ }
+
+ @Override
+ public void onColorChangeClient(byte aColor) {
+ //
+ }
+
+ public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) {
+ return 0;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public boolean renderInInventory(Block aBlock, int aMeta, RenderBlocks aRenderer) {
+ return false;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public boolean renderInWorld(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, RenderBlocks aRenderer) {
+ return false;
+ }
+
+ @Override
+ public void doExplosion(long aExplosionPower) {
+ float tStrength = aExplosionPower < V[0] ? 1.0F : aExplosionPower < V[1] ? 2.0F : aExplosionPower < V[2] ? 3.0F : aExplosionPower < V[3] ? 4.0F : aExplosionPower < V[4] ? 5.0F : aExplosionPower < V[4] * 2 ? 6.0F : aExplosionPower < V[5] ? 7.0F : aExplosionPower < V[6] ? 8.0F : aExplosionPower < V[7] ? 9.0F : 10.0F;
+ int tX = getBaseMetaTileEntity().getXCoord(), tY = getBaseMetaTileEntity().getYCoord(), tZ = getBaseMetaTileEntity().getZCoord();
+ World tWorld = getBaseMetaTileEntity().getWorld();
+ tWorld.setBlock(tX, tY, tZ, Blocks.air);
+ if (GregTech_API.sMachineExplosions)
+ tWorld.createExplosion(null, tX + 0.5, tY + 0.5, tZ + 0.5, tStrength, true);
+ }
+
+ @Override
+ public int getLightOpacity() {
+ return 0;
+ }
+
+ @Override
+ public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, List<AxisAlignedBB> outputAABB, Entity collider) {
+ AxisAlignedBB axisalignedbb1 = getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ);
+ if (axisalignedbb1 != null && inputAABB.intersectsWith(axisalignedbb1)) outputAABB.add(axisalignedbb1);
+ }
+
+ @Override
+ public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) {
+ return AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + 1, aY + 1, aZ + 1);
+ }
+
+ @Override
+ public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity collider) {
+ //
+ }
+
+ @Override
+ public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) {
+ //
+ }
} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechMetaTileEntityLossless.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechMetaTileEntityLossless.java
index 1854681b63..f62b8b69ff 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechMetaTileEntityLossless.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechMetaTileEntityLossless.java
@@ -1,6 +1,6 @@
package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.lossless;
-import gregtech.api.enums.GT_Values;
+import static gregtech.api.enums.GT_Values.GT;
import gregtech.api.interfaces.ITexture;
import gtPlusPlus.core.lib.CORE;
@@ -8,70 +8,59 @@ public abstract class GregtechMetaTileEntityLossless extends MetaTileEntityLossl
/**
* Value between [0 - 9] to describe the Tier of this Machine.
*/
- public final byte mTier;
-
+ public final byte mTier;
+
/**
* A simple Description.
*/
- public final String mDescription;
-
+ public final String mDescription;
+
/**
* Contains all Textures used by this Block.
*/
- public final ITexture[][][] mTextures;
-
- public GregtechMetaTileEntityLossless(final int aID, final String aName, final String aNameRegional,
- final int aTier, final int aInvSlotCount, final String aDescription, final ITexture... aTextures) {
+ public final ITexture[][][] mTextures;
+
+ public GregtechMetaTileEntityLossless(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) {
super(aID, aName, aNameRegional, aInvSlotCount);
- this.mTier = (byte) Math.max(0, Math.min(aTier, 9));
- this.mDescription = aDescription;
-
+ mTier = (byte)Math.max(0, Math.min(aTier, 9));
+ mDescription = aDescription;
+
// must always be the last call!
- if (GT_Values.GT.isClientSide()) {
- this.mTextures = this.getTextureSet(aTextures);
- }
- else {
- this.mTextures = null;
- }
+ if (GT.isClientSide()) mTextures = getTextureSet(aTextures); else mTextures = null;
}
-
- public GregtechMetaTileEntityLossless(final String aName, final int aTier, final int aInvSlotCount,
- final String aDescription, final ITexture[][][] aTextures) {
+
+ public GregtechMetaTileEntityLossless(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) {
super(aName, aInvSlotCount);
- this.mTier = (byte) aTier;
- this.mDescription = aDescription;
- this.mTextures = aTextures;
-
+ mTier = (byte)aTier;
+ mDescription = aDescription;
+ mTextures = aTextures;
+
}
-
+
@Override
- public String[] getDescription() {
- return new String[] {
- this.mDescription, CORE.GT_Tooltip
- };
+ public byte getTileEntityBaseType() {
+ return (byte)(Math.min(3, mTier<=0?0:1+((mTier-1) / 4)));
}
-
- @Override
+
+ @Override
public long getInputTier() {
- return this.mTier;
- }
-
- @Override
+ return mTier;
+ }
+
+ @Override
public long getOutputTier() {
- return this.mTier;
+ return mTier;
+ }
+
+ @Override
+ public String[] getDescription() {
+ return new String[] {mDescription, CORE.GT_Tooltip};
}
-
+
/**
- * Used Client Side to get a Texture Set for this Block. Called after
- * setting the Tier and the Description so that those two are accessible.
- *
- * @param aTextures
- * is the optional Array you can give to the Constructor.
+ * Used Client Side to get a Texture Set for this Block.
+ * Called after setting the Tier and the Description so that those two are accessible.
+ * @param aTextures is the optional Array you can give to the Constructor.
*/
public abstract ITexture[][][] getTextureSet(ITexture[] aTextures);
-
- @Override
- public byte getTileEntityBaseType() {
- return (byte) Math.min(3, this.mTier <= 0 ? 0 : 1 + (this.mTier - 1) / 4);
- }
} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechMetaTileEntityLosslessBasicTank.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechMetaTileEntityLosslessBasicTank.java
index c25da76fac..aee474d9bf 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechMetaTileEntityLosslessBasicTank.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechMetaTileEntityLosslessBasicTank.java
@@ -14,270 +14,238 @@ import net.minecraftforge.fluids.FluidStack;
/**
* NEVER INCLUDE THIS FILE IN YOUR MOD!!!
* <p/>
- * This is the main construct for my generic Tanks. Filling and emptying
- * behavior have to be implemented manually
+ * This is the main construct for my generic Tanks. Filling and emptying behavior have to be implemented manually
*/
public abstract class GregtechMetaTileEntityLosslessBasicTank extends GregtechMetaTileEntityLosslessTieredMachineBlock {
- public FluidStack mFluid;
-
- /**
- * @param aInvSlotCount
- * should be 3
- */
- public GregtechMetaTileEntityLosslessBasicTank(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 GregtechMetaTileEntityLosslessBasicTank(final String aName, final int aTier, final int aInvSlotCount,
- final String aDescription, final 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();
- }
-
- @Override
- public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide,
- final ItemStack aStack) {
- return aIndex == this.getInputSlot();
- }
-
- public abstract boolean canTankBeEmptied();
-
- public abstract boolean canTankBeFilled();
-
- public abstract boolean displaysItemStack();
-
- public abstract boolean displaysStackSize();
-
- public abstract boolean doesEmptyContainers();
-
- public abstract boolean doesFillContainers();
-
- @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;
- }
-
- @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;
- }
-
- @Override
- public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory,
- final IGregTechTileEntity aBaseMetaTileEntity) {
- return new GT_GUIContainer_BasicTank(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName());
- }
-
- public FluidStack getDisplayedFluid() {
- return this.getDrainableStack();
- }
-
- public FluidStack getDrainableStack() {
- return this.mFluid;
- }
-
- public FluidStack getFillableStack() {
- return this.mFluid;
- }
-
- @Override
- public FluidStack getFluid() {
- return this.getDrainableStack();
- }
-
- @Override
- public int getFluidAmount() {
- return this.getDrainableStack() != null ? this.getDrainableStack().amount : 0;
- }
-
- public int getInputSlot() {
- return 0;
- }
-
- public int getOutputSlot() {
- return 1;
- }
-
- @Override
- public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory,
- final IGregTechTileEntity aBaseMetaTileEntity) {
- return new GT_Container_BasicTank(aPlayerInventory, aBaseMetaTileEntity);
- }
-
- public int getStackDisplaySlot() {
- return 2;
- }
-
- public boolean isFluidChangingAllowed() {
- return true;
- }
-
- public boolean isFluidInputAllowed(final FluidStack aFluid) {
- return true;
- }
-
- @Override
- public boolean isSimpleMachine() {
- return false;
- }
-
- @Override
- public boolean isValidSlot(final int aIndex) {
- return aIndex != this.getStackDisplaySlot();
- }
-
- @Override
- public void loadNBTData(final NBTTagCompound aNBT) {
- this.mFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid"));
- }
-
- @Override
- public void onPreTick(final IGregTechTileEntity aBaseMetaTileEntity, final 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 (this.doesEmptyContainers()) {
- final FluidStack tFluid = GT_Utility.getFluidForFilledItem(this.mInventory[this.getInputSlot()], true);
- if (tFluid != null && this.isFluidInputAllowed(tFluid)) {
- if (this.getFillableStack() == 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(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);
- }
- }
- }
- }
- }
-
- 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 void saveNBTData(final NBTTagCompound aNBT) {
- if (this.mFluid != null) {
- aNBT.setTag("mFluid", this.mFluid.writeToNBT(new NBTTagCompound()));
- }
- }
-
- public FluidStack setDrainableStack(final FluidStack aFluid) {
- this.mFluid = aFluid;
- return this.mFluid;
- }
-
- public FluidStack setFillableStack(final FluidStack aFluid) {
- this.mFluid = aFluid;
- return this.mFluid;
- }
+ public FluidStack mFluid;
+
+ /**
+ * @param aInvSlotCount should be 3
+ */
+ public GregtechMetaTileEntityLosslessBasicTank(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) {
+ super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures);
+ }
+
+ public GregtechMetaTileEntityLosslessBasicTank(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) {
+ super(aName, aTier, aInvSlotCount, aDescription, aTextures);
+ }
+
+ @Override
+ public boolean isSimpleMachine() {
+ return false;
+ }
+
+ @Override
+ public boolean isValidSlot(int aIndex) {
+ return aIndex != getStackDisplaySlot();
+ }
+
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ if (mFluid != null) aNBT.setTag("mFluid", mFluid.writeToNBT(new NBTTagCompound()));
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ mFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid"));
+ }
+
+ public abstract boolean doesFillContainers();
+
+ public abstract boolean doesEmptyContainers();
+
+ public abstract boolean canTankBeFilled();
+
+ public abstract boolean canTankBeEmptied();
+
+ public abstract boolean displaysItemStack();
+
+ public abstract boolean displaysStackSize();
+
+ public int getInputSlot() {
+ return 0;
+ }
+
+ public int getOutputSlot() {
+ return 1;
+ }
+
+ public int getStackDisplaySlot() {
+ return 2;
+ }
+
+ public boolean isFluidInputAllowed(FluidStack aFluid) {
+ return true;
+ }
+
+ public boolean isFluidChangingAllowed() {
+ return true;
+ }
+
+ public FluidStack getFillableStack() {
+ return mFluid;
+ }
+
+ public FluidStack setFillableStack(FluidStack aFluid) {
+ mFluid = aFluid;
+ return mFluid;
+ }
+
+ public FluidStack getDrainableStack() {
+ return mFluid;
+ }
+
+ public FluidStack setDrainableStack(FluidStack aFluid) {
+ mFluid = aFluid;
+ return mFluid;
+ }
+
+ public FluidStack getDisplayedFluid() {
+ return getDrainableStack();
+ }
+
+ @Override
+ public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return new GT_Container_BasicTank(aPlayerInventory, aBaseMetaTileEntity);
+ }
+
+ @Override
+ public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return new GT_GUIContainer_BasicTank(aPlayerInventory, aBaseMetaTileEntity, getLocalName());
+ }
+
+ @Override
+ public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, 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 (doesEmptyContainers()) {
+ FluidStack tFluid = GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true);
+ if (tFluid != null && isFluidInputAllowed(tFluid)) {
+ if (getFillableStack() == 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(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);
+ }
+ }
+ }
+ }
+ }
+
+ 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 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 (!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 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 boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return aIndex == getOutputSlot();
+ }
+
+ @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/base/lossless/GregtechMetaTileEntityLosslessTieredMachineBlock.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechMetaTileEntityLosslessTieredMachineBlock.java
index 3e6964eefa..7f4c1a4ed8 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechMetaTileEntityLosslessTieredMachineBlock.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechMetaTileEntityLosslessTieredMachineBlock.java
@@ -1,77 +1,67 @@
package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.lossless;
-import gregtech.api.enums.GT_Values;
+import static gregtech.api.enums.GT_Values.GT;
import gregtech.api.interfaces.ITexture;
import gregtech.api.metatileentity.MetaTileEntity;
public abstract class GregtechMetaTileEntityLosslessTieredMachineBlock extends MetaTileEntity {
- /**
- * Value between [0 - 9] to describe the Tier of this Machine.
- */
- public final byte mTier;
+ /**
+ * Value between [0 - 9] to describe the Tier of this Machine.
+ */
+ public final byte mTier;
- /**
- * A simple Description.
- */
- public final String mDescription;
+ /**
+ * A simple Description.
+ */
+ public final String mDescription;
- /**
- * Contains all Textures used by this Block.
- */
- public final ITexture[][][] mTextures;
+ /**
+ * Contains all Textures used by this Block.
+ */
+ public final ITexture[][][] mTextures;
- public GregtechMetaTileEntityLosslessTieredMachineBlock(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, aInvSlotCount);
- this.mTier = (byte) Math.max(0, Math.min(aTier, 9));
- this.mDescription = aDescription;
+ public GregtechMetaTileEntityLosslessTieredMachineBlock(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) {
+ super(aID, aName, aNameRegional, aInvSlotCount);
+ mTier = (byte) Math.max(0, Math.min(aTier, 9));
+ mDescription = aDescription;
- // must always be the last call!
- if (GT_Values.GT.isClientSide()) {
- this.mTextures = this.getTextureSet(aTextures);
- }
- else {
- this.mTextures = null;
- }
- }
+ // must always be the last call!
+ if (GT.isClientSide()) mTextures = getTextureSet(aTextures);
+ else mTextures = null;
+ }
- public GregtechMetaTileEntityLosslessTieredMachineBlock(final String aName, final int aTier,
- final int aInvSlotCount, final String aDescription, final ITexture[][][] aTextures) {
- super(aName, aInvSlotCount);
- this.mTier = (byte) aTier;
- this.mDescription = aDescription;
- this.mTextures = aTextures;
- }
+ public GregtechMetaTileEntityLosslessTieredMachineBlock(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) {
+ super(aName, aInvSlotCount);
+ mTier = (byte) aTier;
+ mDescription = aDescription;
+ mTextures = aTextures;
+ }
- @Override
- public String[] getDescription() {
- return new String[] {
- this.mDescription
- };
- }
+ @Override
+ public byte getTileEntityBaseType() {
+ return (byte) (Math.min(3, mTier <= 0 ? 0 : 1 + ((mTier - 1) / 4)));
+ }
- @Override
- public long getInputTier() {
- return this.mTier;
- }
+ @Override
+ public long getInputTier() {
+ return mTier;
+ }
- @Override
- public long getOutputTier() {
- return this.mTier;
- }
+ @Override
+ public long getOutputTier() {
+ return mTier;
+ }
- /**
- * Used Client Side to get a Texture Set for this Block. Called after
- * setting the Tier and the Description so that those two are accessible.
- *
- * @param aTextures
- * is the optional Array you can give to the Constructor.
- */
- public abstract ITexture[][][] getTextureSet(ITexture[] aTextures);
+ @Override
+ public String[] getDescription() {
+ return new String[]{mDescription};
+ }
- @Override
- public byte getTileEntityBaseType() {
- return (byte) Math.min(3, this.mTier <= 0 ? 0 : 1 + (this.mTier - 1) / 4);
- }
+ /**
+ * Used Client Side to get a Texture Set for this Block.
+ * Called after setting the Tier and the Description so that those two are accessible.
+ *
+ * @param aTextures is the optional Array you can give to the Constructor.
+ */
+ public abstract ITexture[][][] getTextureSet(ITexture[] aTextures);
} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/MetaTileEntityLossless.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/MetaTileEntityLossless.java
index 8de6ebe602..7ec9547ab4 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/MetaTileEntityLossless.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/MetaTileEntityLossless.java
@@ -1,17 +1,20 @@
package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.lossless;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
+import static gregtech.api.enums.GT_Values.GT;
+import static gregtech.api.enums.GT_Values.V;
import gregtech.api.GregTech_API;
-import gregtech.api.enums.GT_Values;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.objects.GT_ItemStack;
-import gregtech.api.util.*;
+import gregtech.api.util.GT_Config;
+import gregtech.api.util.GT_LanguageManager;
+import gregtech.api.util.GT_ModHandler;
+import gregtech.api.util.GT_Utility;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -25,944 +28,838 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
-import net.minecraftforge.fluids.*;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.FluidTankInfo;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
/**
* NEVER INCLUDE THIS FILE IN YOUR MOD!!!
* <p/>
- * Extend this Class to add a new MetaMachine Call the Constructor with the
- * desired ID at the load-phase (not preload and also not postload!) Implement
- * the newMetaEntity-Method to return a new ready instance of your
- * MetaTileEntity
+ * Extend this Class to add a new MetaMachine
+ * Call the Constructor with the desired ID at the load-phase (not preload and also not postload!)
+ * Implement the newMetaEntity-Method to return a new ready instance of your MetaTileEntity
* <p/>
- * Call the Constructor like the following example inside the Load Phase, to
- * register it. "new GT_MetaTileEntity_E_Furnace(54, "GT_E_Furnace", "Automatic
- * E-Furnace");"
+ * Call the Constructor like the following example inside the Load Phase, to register it.
+ * "new GT_MetaTileEntity_E_Furnace(54, "GT_E_Furnace", "Automatic E-Furnace");"
*/
public abstract class MetaTileEntityLossless implements IMetaTileEntity {
- /**
- * Only assigned for the MetaTileEntity in the List! Also only used to get
- * the localized Name for the ItemStack and for getInvName.
- */
- public final String mName;
- /**
- * The Inventory of the MetaTileEntity. Amount of Slots can be larger than
- * 256. HAYO!
- */
- public final ItemStack[] mInventory;
- public boolean doTickProfilingInThisTick = true;
- /**
- * accessibility to this Field is no longer given, see below
- */
- private IGregTechTileEntity mBaseMetaTileEntity;
-
- /**
- * This registers your Machine at the List. Use only ID's larger than 2048,
- * because i reserved these ones. See also the List in the API, as it has a
- * Description containing all the reservations.
- *
- * @param aID
- * the ID
- * @example for Constructor overload.
- * <p/>
- * public GT_MetaTileEntity_EBench(int aID, String mName, String
- * mNameRegional) { super(aID, mName, mNameRegional); }
- */
- public MetaTileEntityLossless(final int aID, final String aBasicName, final String aRegionalName,
- final int aInvSlotCount) {
- if (GregTech_API.sPostloadStarted || !GregTech_API.sPreloadStarted) {
- throw new IllegalAccessError("This Constructor has to be called in the load Phase");
- }
- if (GregTech_API.METATILEENTITIES[aID] == null) {
- GregTech_API.METATILEENTITIES[aID] = this;
- }
- else {
- throw new IllegalArgumentException("MetaMachine-Slot Nr. " + aID + " is already occupied!");
- }
- this.mName = aBasicName.replaceAll(" ", "_").toLowerCase();
- this.setBaseMetaTileEntity(GregTech_API.constructBaseMetaTileEntity());
- this.getBaseMetaTileEntity().setMetaTileID((short) aID);
- GT_LanguageManager.addStringLocalization("gt.blockmachines." + this.mName + ".name", aRegionalName);
- this.mInventory = new ItemStack[aInvSlotCount];
-
- if (GT_Values.GT.isClientSide()) {
- final ItemStack tStack = new ItemStack(GregTech_API.sBlockMachines, 1, aID);
- tStack.getItem().addInformation(tStack, null, new ArrayList<String>(), true);
- }
- }
-
- /**
- * This is the normal Constructor.
- */
- public MetaTileEntityLossless(final String aName, final int aInvSlotCount) {
- this.mInventory = new ItemStack[aInvSlotCount];
- this.mName = aName;
- }
-
- @Override
- public boolean acceptsRotationalEnergy(final byte aSide) {
- return false;
- }
-
- @Override
- public void addCollisionBoxesToList(final World aWorld, final int aX, final int aY, final int aZ,
- final AxisAlignedBB inputAABB, final List<AxisAlignedBB> outputAABB, final Entity collider) {
- final AxisAlignedBB axisalignedbb1 = this.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ);
- if (axisalignedbb1 != null && inputAABB.intersectsWith(axisalignedbb1)) {
- outputAABB.add(axisalignedbb1);
- }
- }
-
- @Override
- public boolean allowCoverOnSide(final byte aSide, final GT_ItemStack aStack) {
- return true;
- }
-
- @Override
- public boolean canDrain(final ForgeDirection aSide, final Fluid aFluid) {
- return this.drain(aSide, new FluidStack(aFluid, 1), false) != null;
- }
-
- @Override
- public boolean canExtractItem(final int aIndex, final ItemStack aStack, final int aSide) {
- return this.isValidSlot(aIndex) && aStack != null && aIndex < this.mInventory.length
- && this.allowPullStack(this.getBaseMetaTileEntity(), aIndex, (byte) aSide, aStack);
- }
-
- @Override
- public boolean canFill(final ForgeDirection aSide, final Fluid aFluid) {
- return this.fill(aSide, new FluidStack(aFluid, 1), false) == 1;
- }
-
- @Override
- public boolean canInsertItem(final int aIndex, final ItemStack aStack, final int aSide) {
- return this.isValidSlot(aIndex) && aStack != null && aIndex < this.mInventory.length
- && (this.mInventory[aIndex] == null || GT_Utility.areStacksEqual(aStack, this.mInventory[aIndex]))
- && this.allowPutStack(this.getBaseMetaTileEntity(), aIndex, (byte) aSide, aStack);
- }
-
- @Override
- public void closeInventory() {
- //
- }
-
- @Override
- public boolean connectsToItemPipe(final byte aSide) {
- return false;
- }
-
- /**
- * gets the amount of DechargerSlots
- */
- public int dechargerSlotCount() {
- return 0;
- }
-
- /**
- * gets the first DechargerSlot
- */
- public int dechargerSlotStartIndex() {
- return 0;
- }
-
- @Override
- public ItemStack decrStackSize(final int aIndex, final int aAmount) {
- final ItemStack tStack = this.getStackInSlot(aIndex);
- ItemStack rStack = GT_Utility.copy(tStack);
- if (tStack != null) {
- if (tStack.stackSize <= aAmount) {
- if (this.setStackToZeroInsteadOfNull(aIndex)) {
- tStack.stackSize = 0;
- }
- else {
- this.setInventorySlotContents(aIndex, null);
- }
- }
- else {
- rStack = tStack.splitStack(aAmount);
- if (tStack.stackSize == 0 && !this.setStackToZeroInsteadOfNull(aIndex)) {
- this.setInventorySlotContents(aIndex, null);
- }
- }
- }
- return rStack;
- }
-
- @Override
- public void doExplosion(final long aExplosionPower) {
- final float tStrength = aExplosionPower < GT_Values.V[0] ? 1.0F
- : aExplosionPower < GT_Values.V[1] ? 2.0F
- : aExplosionPower < GT_Values.V[2] ? 3.0F
- : aExplosionPower < GT_Values.V[3] ? 4.0F
- : aExplosionPower < GT_Values.V[4] ? 5.0F
- : aExplosionPower < GT_Values.V[4] * 2 ? 6.0F
- : aExplosionPower < GT_Values.V[5] ? 7.0F
- : aExplosionPower < GT_Values.V[6] ? 8.0F
- : aExplosionPower < GT_Values.V[7] ? 9.0F
- : 10.0F;
- final int tX = this.getBaseMetaTileEntity().getXCoord(), tY = this.getBaseMetaTileEntity().getYCoord(),
- tZ = this.getBaseMetaTileEntity().getZCoord();
- final World tWorld = this.getBaseMetaTileEntity().getWorld();
- GT_Utility.sendSoundToPlayers(tWorld, GregTech_API.sSoundList.get(209), 1.0F, -1, tX, tY, tZ);
- tWorld.setBlock(tX, tY, tZ, Blocks.air);
- if (GregTech_API.sMachineExplosions) {
- tWorld.createExplosion(null, tX + 0.5, tY + 0.5, tZ + 0.5, tStrength, true);
- }
- }
-
- @Override
- public void doSound(final byte aIndex, final double aX, final double aY, final double aZ) {
- /* Do nothing */}
-
- @Override
- public boolean doTickProfilingMessageDuringThisTick() {
- return this.doTickProfilingInThisTick;
- }
-
- @Override
- public FluidStack drain(final ForgeDirection aSide, final FluidStack aFluid, final boolean doDrain) {
- if (this.getFluid() != null && aFluid != null && this.getFluid().isFluidEqual(aFluid)) {
- return this.drain(aFluid.amount, doDrain);
- }
- return null;
- }
-
- @Override
- public FluidStack drain(final ForgeDirection aSide, final int maxDrain, final boolean doDrain) {
- return this.drain(maxDrain, doDrain);
- }
-
- /**
- * tries to empty this Tank
- */
- @Override
- public FluidStack drain(final int maxDrain, final boolean doDrain) {
- return null;
- }
-
- /**
- * tries to fill this Tank
- */
- @Override
- public int fill(final FluidStack resource, final boolean doFill) {
- return 0;
- }
-
- @Override
- public int fill(final ForgeDirection aSide, final FluidStack aFluid, final boolean doFill) {
- if (this.getBaseMetaTileEntity().hasSteamEngineUpgrade() && GT_ModHandler.isSteam(aFluid)
- && aFluid.amount > 1) {
- final int tSteam = (int) Math.min(Integer.MAX_VALUE, Math.min(aFluid.amount / 2,
- this.getBaseMetaTileEntity().getSteamCapacity() - this.getBaseMetaTileEntity().getStoredSteam()));
- if (tSteam > 0) {
- if (doFill) {
- this.getBaseMetaTileEntity().increaseStoredSteam(tSteam, true);
- }
- return tSteam * 2;
- }
- }
- else {
- return this.fill_default(aSide, aFluid, doFill);
- }
- return 0;
- }
-
- public int fill_default(final ForgeDirection aSide, final FluidStack aFluid, final boolean doFill) {
- return this.fill(aFluid, doFill);
- }
-
- @Override
- public int[] getAccessibleSlotsFromSide(final int aSide) {
- final ArrayList<Integer> tList = new ArrayList<Integer>();
- final IGregTechTileEntity tTileEntity = this.getBaseMetaTileEntity();
- final boolean tSkip = tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide,
- tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), -2,
- tTileEntity)
- || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide,
- tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), -2,
- tTileEntity);
- for (int i = 0; i < this.getSizeInventory(); i++) {
- if (this.isValidSlot(i) && (tSkip
- || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide,
- tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), i,
- tTileEntity)
- || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide,
- tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), i,
- tTileEntity))) {
- tList.add(i);
- }
- }
- final int[] rArray = new int[tList.size()];
- for (int i = 0; i < rArray.length; i++) {
- rArray[i] = tList.get(i);
- }
- return rArray;
- }
-
- @Override
- public IGregTechTileEntity getBaseMetaTileEntity() {
- return this.mBaseMetaTileEntity;
- }
-
- /**
- * Liquid Capacity
- */
- @Override
- public int getCapacity() {
- return 0;
- }
-
- @Override
- public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory,
- final IGregTechTileEntity aBaseMetaTileEntity) {
- return null;
- }
-
- @Override
- public AxisAlignedBB getCollisionBoundingBoxFromPool(final World aWorld, final int aX, final int aY, final int aZ) {
- return AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + 1, aY + 1, aZ + 1);
- }
-
- /**
- * Gets the Output for the comparator on the given Side
- */
- @Override
- public byte getComparatorValue(final byte aSide) {
- return 0;
- }
-
- /**
- * This is used to get the internal Energy. I use this for the IDSU.
- */
- public long getEUVar() {
- return ((GregtechBaseMetaTileEntityLossless) this.mBaseMetaTileEntity).mStoredEnergy;
- }
-
- @Override
- public float getExplosionResistance(final byte aSide) {
- return 10.0F;
- }
-
- /**
- * gets the contained Liquid
- */
- @Override
- public FluidStack getFluid() {
- return null;
- }
-
- @Override
- public int getFluidAmount() {
- return 0;
- }
-
- @Override
- public FluidTankInfo getInfo() {
- return new FluidTankInfo(this);
- }
-
- @Override
- public String[] getInfoData() {
- return new String[] {};
- }
-
- /**
- * Determines the Tier of the Machine, used for de-charging Tools.
- */
- public long getInputTier() {
- return GT_Utility.getTier(this.getBaseMetaTileEntity().getInputVoltage());
- }
-
- @Override
- public String getInventoryName() {
- if (GregTech_API.METATILEENTITIES[this.getBaseMetaTileEntity().getMetaTileID()] != null) {
- return GregTech_API.METATILEENTITIES[this.getBaseMetaTileEntity().getMetaTileID()].getMetaName();
- }
- return "";
- }
-
- @Override
- public int getInventoryStackLimit() {
- return 64;
- }
-
- @Override
- public int getLightOpacity() {
- return ((GregtechBaseMetaTileEntityLossless) this.getBaseMetaTileEntity()).getLightValue() > 0 ? 0 : 255;
- }
-
- public String getLocalName() {
- return GT_LanguageManager.getTranslation("gt.blockmachines." + this.mName + ".name");
- }
-
- public int getMaxItemCount() {
- return 0;
- }
-
- @Override
- public String getMetaName() {
- return this.mName;
- }
-
- /**
- * @return the amount of EU, which this Device stores before starting to
- * emit Energy. useful if you don't want to emit stored Energy until
- * a certain Level is reached.
- */
- public long getMinimumStoredEU() {
- return 512;
- }
-
- /**
- * Determines the Tier of the Machine, used for charging Tools.
- */
- public long getOutputTier() {
- return GT_Utility.getTier(this.getBaseMetaTileEntity().getOutputVoltage());
- }
-
- /**
- * Progress this machine has already made
- */
- public int getProgresstime() {
- return 0;
- }
-
- @Override
- public ItemStack[] getRealInventory() {
- return this.mInventory;
- }
-
- @Override
- public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory,
- final IGregTechTileEntity aBaseMetaTileEntity) {
- return null;
- }
-
- @Override
- public int getSizeInventory() {
- return this.mInventory.length;
- }
-
- @Override
- public ArrayList<String> getSpecialDebugInfo(final IGregTechTileEntity aBaseMetaTileEntity,
- final EntityPlayer aPlayer, final int aLogLevel, final ArrayList<String> aList) {
- return aList;
- }
-
- @Override
- public String getSpecialVoltageToolTip() {
- return null;
- }
-
- @Override
- public ItemStack getStackForm(final long aAmount) {
- return new ItemStack(GregTech_API.sBlockMachines, (int) aAmount, this.getBaseMetaTileEntity().getMetaTileID());
- }
-
- @Override
- public ItemStack getStackInSlot(final int aIndex) {
- if (aIndex >= 0 && aIndex < this.mInventory.length) {
- return this.mInventory[aIndex];
- }
- return null;
- }
-
- @Override
- public ItemStack getStackInSlotOnClosing(final int i) {
- return null;
- }
-
- /**
- * This is used to get the internal Steam Energy.
- */
- public long getSteamVar() {
- return ((GregtechBaseMetaTileEntityLossless) this.mBaseMetaTileEntity).mStoredSteam;
- }
-
- public ItemStack[] getStoredItemData() {
- return null;
- }
-
- @Override
- public FluidTankInfo[] getTankInfo(final ForgeDirection aSide) {
- if (this.getCapacity() <= 0 && !this.getBaseMetaTileEntity().hasSteamEngineUpgrade()) {
- return new FluidTankInfo[] {};
- }
- return new FluidTankInfo[] {
- this.getInfo()
- };
- }
-
- /**
- * Tank pressure
- */
- public int getTankPressure() {
- return 0;
- }
-
- @Override
- public byte getUpdateData() {
- return 0;
- }
-
- @Override
- public boolean hasCustomInventoryName() {
- return false;
- }
-
- /**
- * If this TileEntity makes use of Sided Redstone behaviors. Determines
- * only, if the Output Redstone Array is getting filled with 0 for true, or
- * 15 for false.
- */
- public boolean hasSidedRedstoneOutputBehavior() {
- return false;
- }
-
- /**
- * Increases the Progress, returns the overflown Progress.
- */
- public int increaseProgress(final int aProgress) {
- return 0;
- }
-
- @Override
- public void initDefaultModes(final NBTTagCompound aNBT) {
- /* Do nothing */}
-
- @Override
- public boolean injectRotationalEnergy(final byte aSide, final long aSpeed, final long aEnergy) {
- return false;
- }
-
- @Override
- public void inValidate() {
- /* Do nothing */}
-
- @Override
- public boolean isAccessAllowed(final EntityPlayer aPlayer) {
- return false;
- }
-
- public boolean isDigitalChest() {
- return false;
- }
-
- /**
- * @return true if this Device emits Energy at all
- */
- public boolean isElectric() {
- return true;
- }
-
- /**
- * @return true if this Device consumes Energy at all
- */
- public boolean isEnetInput() {
- return false;
- }
-
- /**
- * @return true if this Device emits Energy at all
- */
- public boolean isEnetOutput() {
- return false;
- }
-
- @Override
- public boolean isFacingValid(final byte aFacing) {
- return false;
- }
-
- @Override
- public boolean isGivingInformation() {
- return false;
- }
-
- /**
- * @return true if that Side is an Input.
- */
- public boolean isInputFacing(final byte aSide) {
- return false;
- }
-
- @Override
- public boolean isItemValidForSlot(final int aIndex, final ItemStack aStack) {
- return this.getBaseMetaTileEntity().isValidSlot(aIndex);
- }
-
- @Override
- public boolean isLiquidInput(final byte aSide) {
- return true;
- }
-
- @Override
- public boolean isLiquidOutput(final byte aSide) {
- return true;
- }
-
- /**
- * @return true if that Side is an Output.
- */
- public boolean isOutputFacing(final byte aSide) {
- return false;
- }
-
- /**
- * If this accepts up to 4 Overclockers
- */
- public boolean isOverclockerUpgradable() {
- return false;
- }
-
- /**
- * @return true if this Device emits Energy at all
- */
- public boolean isPneumatic() {
- return false;
- }
-
- @Override
- public boolean isSimpleMachine() {
- return false;
- }
-
- /**
- * @return true if this Device emits Energy at all
- */
- public boolean isSteampowered() {
- return false;
- }
-
- /**
- * if the IC2 Teleporter can drain from this.
- */
- public boolean isTeleporterCompatible() {
- return this.isEnetOutput() && this.getBaseMetaTileEntity().getOutputVoltage() >= 128
- && this.getBaseMetaTileEntity().getUniversalEnergyCapacity() >= 500000;
- }
-
- /**
- * If this accepts Transformer Upgrades
- */
- public boolean isTransformerUpgradable() {
- return false;
- }
-
- /**
- * @return true if Transformer Upgrades increase Packet Amount.
- */
- public boolean isTransformingLowEnergy() {
- return true;
- }
-
- @Override
- public boolean isUseableByPlayer(final EntityPlayer entityplayer) {
- return false;
- }
-
- @Override
- public boolean isValidSlot(final int aIndex) {
- return true;
- }
-
- @Override
- public void markDirty() {
- //
- }
-
- /**
- * How many Amperes this Block can suck at max. Surpassing this value won't
- * blow it up.
- */
- public long maxAmperesIn() {
- return 1;
- }
-
- /**
- * @return the amount of E-net Impulses of the maxEUOutput size, which can
- * be outputted by this Device. Default is 1 Pulse, this shouldn't
- * be set to smaller Values than 1, as it won't output anything in
- * that Case!
- */
- public long maxAmperesOut() {
- return 1;
- }
-
- /**
- * @return the amount of EU/t, which can be accepted by this Device before
- * it explodes.
- */
- public long maxEUInput() {
- return 0;
- }
-
- /**
- * @return the amount of EU/t, which can be outputted by this Device.
- */
- public long maxEUOutput() {
- return 0;
- }
-
- /**
- * @return the amount of EU, which can be stored in this Device. Default is
- * 0 EU.
- */
- public long maxEUStore() {
- return 0;
- }
-
- /**
- * Progress this Machine has to do to produce something
- */
- public int maxProgresstime() {
- return 0;
- }
-
- /**
- * @return the amount of Steam, which can be stored in this Device. Default
- * is 0 EU.
- */
- public long maxSteamStore() {
- return 0;
- }
-
- /**
- * When a GUI is closed
- */
- public void onCloseGUI() {
- /* Do nothing */}
-
- @Override
- public void onColorChangeClient(final byte aColor) {
- //
- }
-
- @Override
- public void onColorChangeServer(final byte aColor) {
- //
- }
-
- @Override
- public void onConfigLoad(final GT_Config aConfig) {
- /* Do nothing */}
-
- @Override
- public void onCreated(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) {
- //
- }
-
- @Override
- public void onEntityCollidedWithBlock(final World aWorld, final int aX, final int aY, final int aZ,
- final Entity collider) {
- //
- }
-
- @Override
- public void onExplosion() {
- /* Do nothing */}
-
- /**
- * When the Facing gets changed.
- */
- public void onFacingChange() {
- /* Do nothing */}
-
- @Override
- public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) {
- /* Do nothing */}
-
- @Override
- public void onLeftclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) {
- /* Do nothing */}
-
- @Override
- public void onMachineBlockUpdate() {
- /* Do nothing */}
-
- /**
- * When a GUI is opened
- */
- public void onOpenGUI() {
- /* Do nothing */}
-
- @Override
- public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) {
- /* Do nothing */}
-
- @Override
- public void onPreTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) {
- /* Do nothing */}
-
- @Override
- public void onRemoval() {
- /* Do nothing */}
-
- /**
- * a Player rightclicks the Machine Sneaky rightclicks are not getting
- * passed to this!
- */
- public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) {
- return false;
- }
-
- @Override
- public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer,
- final byte aSide, final float aX, final float aY, final float aZ) {
- return this.onRightclick(aBaseMetaTileEntity, aPlayer);
- }
-
- @Override
- public void onScrewdriverRightClick(final byte aSide, final EntityPlayer aPlayer, final float aX, final float aY,
- final float aZ) {
- /* Do nothing */}
-
- @Override
- public void onServerStart() {
- /* Do nothing */}
-
- @Override
- public void onValueUpdate(final byte aValue) {
- /* Do nothing */}
-
- @Override
- public void onWorldLoad(final File aSaveDirectory) {
- /* Do nothing */}
-
- @Override
- public void onWorldSave(final File aSaveDirectory) {
- /* Do nothing */}
-
- @Override
- public boolean onWrenchRightClick(final byte aSide, final byte aWrenchingSide, final EntityPlayer aPlayer,
- final float aX, final float aY, final float aZ) {
- if (this.getBaseMetaTileEntity().isValidFacing(aWrenchingSide)) {
- this.getBaseMetaTileEntity().setFrontFacing(aWrenchingSide);
- return true;
- }
- return false;
- }
-
- @Override
- public void openInventory() {
- //
- }
-
- /**
- * gets if this is protected from other Players per default or not
- */
- public boolean ownerControl() {
- return false;
- }
-
- @Override
- public void receiveClientEvent(final byte aEventID, final byte aValue) {
- /* Do nothing */}
-
- /**
- * gets the amount of RechargerSlots
- */
- public int rechargerSlotCount() {
- return 0;
- }
-
- /**
- * gets the first RechargerSlot
- */
- public int rechargerSlotStartIndex() {
- return 0;
- }
-
- @Override
- @SideOnly(Side.CLIENT)
- public void registerIcons(final IIconRegister aBlockIconRegister) {
- /* Do nothing */}
-
- @Override
- @SideOnly(Side.CLIENT)
- public boolean renderInInventory(final Block aBlock, final int aMeta, final RenderBlocks aRenderer) {
- return false;
- }
-
- @Override
- @SideOnly(Side.CLIENT)
- public boolean renderInWorld(final IBlockAccess aWorld, final int aX, final int aY, final int aZ,
- final Block aBlock, final RenderBlocks aRenderer) {
- return false;
- }
-
- @Override
- public final void sendLoopEnd(final byte aIndex) {
- if (!this.getBaseMetaTileEntity().hasMufflerUpgrade()) {
- this.getBaseMetaTileEntity().sendBlockEvent((byte) 6, aIndex);
- }
- }
-
- @Override
- public final void sendLoopStart(final byte aIndex) {
- if (!this.getBaseMetaTileEntity().hasMufflerUpgrade()) {
- this.getBaseMetaTileEntity().sendBlockEvent((byte) 5, aIndex);
- }
- }
-
- @Override
- public final void sendSound(final byte aIndex) {
- if (!this.getBaseMetaTileEntity().hasMufflerUpgrade()) {
- this.getBaseMetaTileEntity().sendBlockEvent((byte) 4, aIndex);
- }
- }
-
- @Override
- public void setBaseMetaTileEntity(final IGregTechTileEntity aBaseMetaTileEntity) {
- if (this.mBaseMetaTileEntity != null && aBaseMetaTileEntity == null) {
- this.mBaseMetaTileEntity.getMetaTileEntity().inValidate();
- this.mBaseMetaTileEntity.setMetaTileEntity(null);
- }
- this.mBaseMetaTileEntity = aBaseMetaTileEntity;
- if (this.mBaseMetaTileEntity != null) {
- this.mBaseMetaTileEntity.setMetaTileEntity(this);
- }
- }
-
- /**
- * This is used to set the internal Energy to the given Parameter. I use
- * this for the IDSU.
- */
- public void setEUVar(final long aEnergy) {
- ((GregtechBaseMetaTileEntityLossless) this.mBaseMetaTileEntity).mStoredEnergy = aEnergy;
- }
-
- @Override
- public void setInventorySlotContents(final int aIndex, final ItemStack aStack) {
- if (aIndex >= 0 && aIndex < this.mInventory.length) {
- this.mInventory[aIndex] = aStack;
- }
- }
-
- public void setItemCount(final int aCount) {
- /* Do nothing */}
-
- @Override
- public void setItemNBT(final NBTTagCompound aNBT) {
- /* Do nothing */}
-
- @Override
- public boolean setStackToZeroInsteadOfNull(final int aIndex) {
- return false;
- }
-
- /**
- * This is used to set the internal Steam Energy to the given Parameter.
- */
- public void setSteamVar(final long aSteam) {
- ((GregtechBaseMetaTileEntityLossless) this.mBaseMetaTileEntity).mStoredSteam = aSteam;
- }
-
- @Override
- public void startSoundLoop(final byte aIndex, final double aX, final double aY, final double aZ) {
- /* Do nothing */}
-
- @Override
- public void stopSoundLoop(final byte aValue, final double aX, final double aY, final double aZ) {
- /* Do nothing */}
+ /**
+ * Only assigned for the MetaTileEntity in the List! Also only used to get the localized Name for the ItemStack and for getInvName.
+ */
+ public final String mName;
+ /**
+ * The Inventory of the MetaTileEntity. Amount of Slots can be larger than 256. HAYO!
+ */
+ public final ItemStack[] mInventory;
+ public boolean doTickProfilingInThisTick = true;
+ /**
+ * accessibility to this Field is no longer given, see below
+ */
+ private IGregTechTileEntity mBaseMetaTileEntity;
+
+ /**
+ * This registers your Machine at the List.
+ * Use only ID's larger than 2048, because i reserved these ones.
+ * See also the List in the API, as it has a Description containing all the reservations.
+ *
+ * @param aID the ID
+ * @example for Constructor overload.
+ * <p/>
+ * public GT_MetaTileEntity_EBench(int aID, String mName, String mNameRegional) {
+ * super(aID, mName, mNameRegional);
+ * }
+ */
+ public MetaTileEntityLossless(int aID, String aBasicName, String aRegionalName, int aInvSlotCount) {
+ if (GregTech_API.sPostloadStarted || !GregTech_API.sPreloadStarted)
+ throw new IllegalAccessError("This Constructor has to be called in the load Phase");
+ if (GregTech_API.METATILEENTITIES[aID] == null) {
+ GregTech_API.METATILEENTITIES[aID] = this;
+ } else {
+ throw new IllegalArgumentException("MetaMachine-Slot Nr. " + aID + " is already occupied!");
+ }
+ mName = aBasicName.replaceAll(" ", "_").toLowerCase();
+ setBaseMetaTileEntity(GregTech_API.constructBaseMetaTileEntity());
+ getBaseMetaTileEntity().setMetaTileID((short) aID);
+ GT_LanguageManager.addStringLocalization("gt.blockmachines." + mName + ".name", aRegionalName);
+ mInventory = new ItemStack[aInvSlotCount];
+
+ if (GT.isClientSide()) {
+ ItemStack tStack = new ItemStack(GregTech_API.sBlockMachines, 1, aID);
+ tStack.getItem().addInformation(tStack, null, new ArrayList<String>(), true);
+ }
+ }
+
+ /**
+ * This is the normal Constructor.
+ */
+ public MetaTileEntityLossless(String aName, int aInvSlotCount) {
+ mInventory = new ItemStack[aInvSlotCount];
+ mName = aName;
+ }
+
+ @Override
+ public IGregTechTileEntity getBaseMetaTileEntity() {
+ return mBaseMetaTileEntity;
+ }
+
+ @Override
+ public void setBaseMetaTileEntity(IGregTechTileEntity aBaseMetaTileEntity) {
+ if (mBaseMetaTileEntity != null && aBaseMetaTileEntity == null) {
+ mBaseMetaTileEntity.getMetaTileEntity().inValidate();
+ mBaseMetaTileEntity.setMetaTileEntity(null);
+ }
+ mBaseMetaTileEntity = aBaseMetaTileEntity;
+ if (mBaseMetaTileEntity != null) {
+ mBaseMetaTileEntity.setMetaTileEntity(this);
+ }
+ }
+
+ @Override
+ public ItemStack getStackForm(long aAmount) {
+ return new ItemStack(GregTech_API.sBlockMachines, (int) aAmount, getBaseMetaTileEntity().getMetaTileID());
+ }
+
+ public String getLocalName() {
+ return GT_LanguageManager.getTranslation("gt.blockmachines." + mName + ".name");
+ }
+
+ @Override
+ public void onServerStart() {/*Do nothing*/}
+
+ @Override
+ public void onWorldSave(File aSaveDirectory) {/*Do nothing*/}
+
+ @Override
+ public void onWorldLoad(File aSaveDirectory) {/*Do nothing*/}
+
+ @Override
+ public void onConfigLoad(GT_Config aConfig) {/*Do nothing*/}
+
+ @Override
+ public void setItemNBT(NBTTagCompound aNBT) {/*Do nothing*/}
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IIconRegister aBlockIconRegister) {/*Do nothing*/}
+
+ @Override
+ public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) {
+ return true;
+ }
+
+ @Override
+ public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {/*Do nothing*/}
+
+ @Override
+ public boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ if (getBaseMetaTileEntity().isValidFacing(aWrenchingSide)) {
+ getBaseMetaTileEntity().setFrontFacing(aWrenchingSide);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public void onExplosion() {/*Do nothing*/}
+
+ @Override
+ public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) {/*Do nothing*/}
+
+ @Override
+ public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {/*Do nothing*/}
+
+ @Override
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {/*Do nothing*/}
+
+ @Override
+ public void inValidate() {/*Do nothing*/}
+
+ @Override
+ public void onRemoval() {/*Do nothing*/}
+
+ @Override
+ public void initDefaultModes(NBTTagCompound aNBT) {/*Do nothing*/}
+
+ /**
+ * When a GUI is opened
+ */
+ public void onOpenGUI() {/*Do nothing*/}
+
+ /**
+ * When a GUI is closed
+ */
+ public void onCloseGUI() {/*Do nothing*/}
+
+ /**
+ * a Player rightclicks the Machine
+ * Sneaky rightclicks are not getting passed to this!
+ */
+ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {
+ return false;
+ }
+
+ @Override
+ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) {
+ return onRightclick(aBaseMetaTileEntity, aPlayer);
+ }
+
+ @Override
+ public void onLeftclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {/*Do nothing*/}
+
+ @Override
+ public void onValueUpdate(byte aValue) {/*Do nothing*/}
+
+ @Override
+ public byte getUpdateData() {
+ return 0;
+ }
+
+ @Override
+ public void doSound(byte aIndex, double aX, double aY, double aZ) {/*Do nothing*/}
+
+ @Override
+ public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) {/*Do nothing*/}
+
+ @Override
+ public void stopSoundLoop(byte aValue, double aX, double aY, double aZ) {/*Do nothing*/}
+
+ @Override
+ public final void sendSound(byte aIndex) {
+ if (!getBaseMetaTileEntity().hasMufflerUpgrade()) getBaseMetaTileEntity().sendBlockEvent((byte) 4, aIndex);
+ }
+
+ @Override
+ public final void sendLoopStart(byte aIndex) {
+ if (!getBaseMetaTileEntity().hasMufflerUpgrade()) getBaseMetaTileEntity().sendBlockEvent((byte) 5, aIndex);
+ }
+
+ @Override
+ public final void sendLoopEnd(byte aIndex) {
+ if (!getBaseMetaTileEntity().hasMufflerUpgrade()) getBaseMetaTileEntity().sendBlockEvent((byte) 6, aIndex);
+ }
+
+ /**
+ * @return true if this Device emits Energy at all
+ */
+ public boolean isElectric() {
+ return true;
+ }
+
+ /**
+ * @return true if this Device emits Energy at all
+ */
+ public boolean isPneumatic() {
+ return false;
+ }
+
+ /**
+ * @return true if this Device emits Energy at all
+ */
+ public boolean isSteampowered() {
+ return false;
+ }
+
+ /**
+ * @return true if this Device emits Energy at all
+ */
+ public boolean isEnetOutput() {
+ return false;
+ }
+
+ /**
+ * @return true if this Device consumes Energy at all
+ */
+ public boolean isEnetInput() {
+ return false;
+ }
+
+ /**
+ * @return the amount of EU, which can be stored in this Device. Default is 0 EU.
+ */
+ public long maxEUStore() {
+ return 0;
+ }
+
+ /**
+ * @return the amount of EU/t, which can be accepted by this Device before it explodes.
+ */
+ public long maxEUInput() {
+ return 0;
+ }
+
+ /**
+ * @return the amount of EU/t, which can be outputted by this Device.
+ */
+ public long maxEUOutput() {
+ return 0;
+ }
+
+ /**
+ * @return the amount of E-net Impulses of the maxEUOutput size, which can be outputted by this Device.
+ * Default is 1 Pulse, this shouldn't be set to smaller Values than 1, as it won't output anything in that Case!
+ */
+ public long maxAmperesOut() {
+ return 1;
+ }
+
+ /**
+ * How many Amperes this Block can suck at max. Surpassing this value won't blow it up.
+ */
+ public long maxAmperesIn() {
+ return 1;
+ }
+
+ /**
+ * @return true if that Side is an Output.
+ */
+ public boolean isOutputFacing(byte aSide) {
+ return false;
+ }
+
+ /**
+ * @return true if that Side is an Input.
+ */
+ public boolean isInputFacing(byte aSide) {
+ return false;
+ }
+
+ /**
+ * @return true if Transformer Upgrades increase Packet Amount.
+ */
+ public boolean isTransformingLowEnergy() {
+ return true;
+ }
+
+ @Override
+ public boolean isFacingValid(byte aFacing) {
+ return false;
+ }
+
+ @Override
+ public boolean isAccessAllowed(EntityPlayer aPlayer) {
+ return false;
+ }
+
+ @Override
+ public boolean isValidSlot(int aIndex) {
+ return true;
+ }
+
+ @Override
+ public boolean setStackToZeroInsteadOfNull(int aIndex) {
+ return false;
+ }
+
+ /**
+ * This is used to get the internal Energy. I use this for the IDSU.
+ */
+ public long getEUVar() {
+ return ((GregtechBaseMetaTileEntityLossless) mBaseMetaTileEntity).mStoredEnergy;
+ }
+
+ /**
+ * This is used to set the internal Energy to the given Parameter. I use this for the IDSU.
+ */
+ public void setEUVar(long aEnergy) {
+ ((GregtechBaseMetaTileEntityLossless) mBaseMetaTileEntity).mStoredEnergy = aEnergy;
+ }
+
+ /**
+ * This is used to get the internal Steam Energy.
+ */
+ public long getSteamVar() {
+ return ((GregtechBaseMetaTileEntityLossless) mBaseMetaTileEntity).mStoredSteam;
+ }
+
+ /**
+ * This is used to set the internal Steam Energy to the given Parameter.
+ */
+ public void setSteamVar(long aSteam) {
+ ((GregtechBaseMetaTileEntityLossless) mBaseMetaTileEntity).mStoredSteam = aSteam;
+ }
+
+ /**
+ * @return the amount of Steam, which can be stored in this Device. Default is 0 EU.
+ */
+ public long maxSteamStore() {
+ return 0;
+ }
+
+ /**
+ * @return the amount of EU, which this Device stores before starting to emit Energy.
+ * useful if you don't want to emit stored Energy until a certain Level is reached.
+ */
+ public long getMinimumStoredEU() {
+ return 512;
+ }
+
+ /**
+ * Determines the Tier of the Machine, used for de-charging Tools.
+ */
+ public long getInputTier() {
+ return GT_Utility.getTier(getBaseMetaTileEntity().getInputVoltage());
+ }
+
+ /**
+ * Determines the Tier of the Machine, used for charging Tools.
+ */
+ public long getOutputTier() {
+ return GT_Utility.getTier(getBaseMetaTileEntity().getOutputVoltage());
+ }
+
+ /**
+ * gets the first RechargerSlot
+ */
+ public int rechargerSlotStartIndex() {
+ return 0;
+ }
+
+ /**
+ * gets the amount of RechargerSlots
+ */
+ public int rechargerSlotCount() {
+ return 0;
+ }
+
+ /**
+ * gets the first DechargerSlot
+ */
+ public int dechargerSlotStartIndex() {
+ return 0;
+ }
+
+ /**
+ * gets the amount of DechargerSlots
+ */
+ public int dechargerSlotCount() {
+ return 0;
+ }
+
+ /**
+ * gets if this is protected from other Players per default or not
+ */
+ public boolean ownerControl() {
+ return false;
+ }
+
+ @Override
+ public ArrayList<String> getSpecialDebugInfo(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, int aLogLevel, ArrayList<String> aList) {
+ return aList;
+ }
+
+ @Override
+ public boolean isLiquidInput(byte aSide) {
+ return true;
+ }
+
+ @Override
+ public boolean isLiquidOutput(byte aSide) {
+ return true;
+ }
+
+ /**
+ * gets the contained Liquid
+ */
+ @Override
+ public FluidStack getFluid() {
+ return null;
+ }
+
+ /**
+ * tries to fill this Tank
+ */
+ @Override
+ public int fill(FluidStack resource, boolean doFill) {
+ return 0;
+ }
+
+ /**
+ * tries to empty this Tank
+ */
+ @Override
+ public FluidStack drain(int maxDrain, boolean doDrain) {
+ return null;
+ }
+
+ /**
+ * Tank pressure
+ */
+ public int getTankPressure() {
+ return 0;
+ }
+
+ /**
+ * Liquid Capacity
+ */
+ @Override
+ public int getCapacity() {
+ return 0;
+ }
+
+ @Override
+ public void onMachineBlockUpdate() {/*Do nothing*/}
+
+ @Override
+ public void receiveClientEvent(byte aEventID, byte aValue) {/*Do nothing*/}
+
+ @Override
+ public boolean isSimpleMachine() {
+ return false;
+ }
+
+ /**
+ * If this accepts up to 4 Overclockers
+ */
+ public boolean isOverclockerUpgradable() {
+ return false;
+ }
+
+ /**
+ * If this accepts Transformer Upgrades
+ */
+ public boolean isTransformerUpgradable() {
+ return false;
+ }
+
+ /**
+ * Progress this machine has already made
+ */
+ public int getProgresstime() {
+ return 0;
+ }
+
+ /**
+ * Progress this Machine has to do to produce something
+ */
+ public int maxProgresstime() {
+ return 0;
+ }
+
+ /**
+ * Increases the Progress, returns the overflown Progress.
+ */
+ public int increaseProgress(int aProgress) {
+ return 0;
+ }
+
+ /**
+ * If this TileEntity makes use of Sided Redstone behaviors.
+ * Determines only, if the Output Redstone Array is getting filled with 0 for true, or 15 for false.
+ */
+ public boolean hasSidedRedstoneOutputBehavior() {
+ return false;
+ }
+
+ /**
+ * When the Facing gets changed.
+ */
+ public void onFacingChange() {/*Do nothing*/}
+
+ /**
+ * if the IC2 Teleporter can drain from this.
+ */
+ public boolean isTeleporterCompatible() {
+ return isEnetOutput() && getBaseMetaTileEntity().getOutputVoltage() >= 128 && getBaseMetaTileEntity().getUniversalEnergyCapacity() >= 500000;
+ }
+
+ /**
+ * Gets the Output for the comparator on the given Side
+ */
+ @Override
+ public byte getComparatorValue(byte aSide) {
+ return 0;
+ }
+
+ @Override
+ public boolean acceptsRotationalEnergy(byte aSide) {
+ return false;
+ }
+
+ @Override
+ public boolean injectRotationalEnergy(byte aSide, long aSpeed, long aEnergy) {
+ return false;
+ }
+
+ @Override
+ public String getSpecialVoltageToolTip() {
+ return null;
+ }
+
+ @Override
+ public boolean isGivingInformation() {
+ return false;
+ }
+
+ @Override
+ public String[] getInfoData() {
+ return new String[]{};
+ }
+
+ public boolean isDigitalChest() {
+ return false;
+ }
+
+ public ItemStack[] getStoredItemData() {
+ return null;
+ }
+
+ public void setItemCount(int aCount) {/*Do nothing*/}
+
+ public int getMaxItemCount() {
+ return 0;
+ }
+
+ @Override
+ public int getSizeInventory() {
+ return mInventory.length;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(int aIndex) {
+ if (aIndex >= 0 && aIndex < mInventory.length) return mInventory[aIndex];
+ return null;
+ }
+
+ @Override
+ public void setInventorySlotContents(int aIndex, ItemStack aStack) {
+ if (aIndex >= 0 && aIndex < mInventory.length) mInventory[aIndex] = aStack;
+ }
+
+ @Override
+ public String getInventoryName() {
+ if (GregTech_API.METATILEENTITIES[getBaseMetaTileEntity().getMetaTileID()] != null)
+ return GregTech_API.METATILEENTITIES[getBaseMetaTileEntity().getMetaTileID()].getMetaName();
+ return "";
+ }
+
+ @Override
+ public int getInventoryStackLimit() {
+ return 64;
+ }
+
+ @Override
+ public boolean isItemValidForSlot(int aIndex, ItemStack aStack) {
+ return getBaseMetaTileEntity().isValidSlot(aIndex);
+ }
+
+ @Override
+ public ItemStack decrStackSize(int aIndex, int aAmount) {
+ ItemStack tStack = getStackInSlot(aIndex), rStack = GT_Utility.copy(tStack);
+ if (tStack != null) {
+ if (tStack.stackSize <= aAmount) {
+ if (setStackToZeroInsteadOfNull(aIndex)) tStack.stackSize = 0;
+ else setInventorySlotContents(aIndex, null);
+ } else {
+ rStack = tStack.splitStack(aAmount);
+ if (tStack.stackSize == 0 && !setStackToZeroInsteadOfNull(aIndex))
+ setInventorySlotContents(aIndex, null);
+ }
+ }
+ return rStack;
+ }
+
+ @Override
+ public int[] getAccessibleSlotsFromSide(int aSide) {
+ ArrayList<Integer> tList = new ArrayList<Integer>();
+ IGregTechTileEntity tTileEntity = getBaseMetaTileEntity();
+ boolean tSkip = tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), -2, tTileEntity) || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), -2, tTileEntity);
+ for (int i = 0; i < getSizeInventory(); i++)
+ if (isValidSlot(i) && (tSkip || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), i, tTileEntity) || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide), i, tTileEntity)))
+ tList.add(i);
+ int[] rArray = new int[tList.size()];
+ for (int i = 0; i < rArray.length; i++) rArray[i] = tList.get(i);
+ return rArray;
+ }
+
+ @Override
+ public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) {
+ return isValidSlot(aIndex) && aStack != null && aIndex < mInventory.length && (mInventory[aIndex] == null || GT_Utility.areStacksEqual(aStack, mInventory[aIndex])) && allowPutStack(getBaseMetaTileEntity(), aIndex, (byte) aSide, aStack);
+ }
+
+ @Override
+ public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) {
+ return isValidSlot(aIndex) && aStack != null && aIndex < mInventory.length && allowPullStack(getBaseMetaTileEntity(), aIndex, (byte) aSide, aStack);
+ }
+
+ @Override
+ public boolean canFill(ForgeDirection aSide, Fluid aFluid) {
+ return fill(aSide, new FluidStack(aFluid, 1), false) == 1;
+ }
+
+ @Override
+ public boolean canDrain(ForgeDirection aSide, Fluid aFluid) {
+ return drain(aSide, new FluidStack(aFluid, 1), false) != null;
+ }
+
+ @Override
+ public FluidTankInfo[] getTankInfo(ForgeDirection aSide) {
+ if (getCapacity() <= 0 && !getBaseMetaTileEntity().hasSteamEngineUpgrade()) return new FluidTankInfo[]{};
+ return new FluidTankInfo[]{getInfo()};
+ }
+
+ public int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) {
+ return fill(aFluid, doFill);
+ }
+
+ @Override
+ public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) {
+ if (getBaseMetaTileEntity().hasSteamEngineUpgrade() && GT_ModHandler.isSteam(aFluid) && aFluid.amount > 1) {
+ int tSteam = (int) Math.min(Integer.MAX_VALUE, Math.min(aFluid.amount / 2, getBaseMetaTileEntity().getSteamCapacity() - getBaseMetaTileEntity().getStoredSteam()));
+ if (tSteam > 0) {
+ if (doFill) getBaseMetaTileEntity().increaseStoredSteam(tSteam, true);
+ return tSteam * 2;
+ }
+ } else {
+ return fill_default(aSide, aFluid, doFill);
+ }
+ return 0;
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) {
+ if (getFluid() != null && aFluid != null && getFluid().isFluidEqual(aFluid))
+ return drain(aFluid.amount, doDrain);
+ return null;
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection aSide, int maxDrain, boolean doDrain) {
+ return drain(maxDrain, doDrain);
+ }
+
+ @Override
+ public int getFluidAmount() {
+ return 0;
+ }
+
+ @Override
+ public FluidTankInfo getInfo() {
+ return new FluidTankInfo(this);
+ }
+
+ @Override
+ public String getMetaName() {
+ return mName;
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(int i) {
+ return null;
+ }
+
+ @Override
+ public boolean hasCustomInventoryName() {
+ return false;
+ }
+
+ @Override
+ public boolean doTickProfilingMessageDuringThisTick() {
+ return doTickProfilingInThisTick;
+ }
+
+ @Override
+ public void markDirty() {
+ //
+ }
+
+ @Override
+ public boolean isUseableByPlayer(EntityPlayer entityplayer) {
+ return false;
+ }
+
+ @Override
+ public void openInventory() {
+ //
+ }
+
+ @Override
+ public void closeInventory() {
+ //
+ }
+
+ @Override
+ public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return null;
+ }
+
+ @Override
+ public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return null;
+ }
+
+ @Override
+ public boolean connectsToItemPipe(byte aSide) {
+ return false;
+ }
+
+ @Override
+ public float getExplosionResistance(byte aSide) {
+ return 10.0F;
+ }
+
+ @Override
+ public ItemStack[] getRealInventory() {
+ return mInventory;
+ }
+
+ @Override
+ public void onColorChangeServer(byte aColor) {
+ //
+ }
+
+ @Override
+ public void onColorChangeClient(byte aColor) {
+ //
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public boolean renderInInventory(Block aBlock, int aMeta, RenderBlocks aRenderer) {
+ return false;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public boolean renderInWorld(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, RenderBlocks aRenderer) {
+ return false;
+ }
+
+ @Override
+ public void doExplosion(long aExplosionPower) {
+ float tStrength = aExplosionPower < V[0] ? 1.0F : aExplosionPower < V[1] ? 2.0F : aExplosionPower < V[2] ? 3.0F : aExplosionPower < V[3] ? 4.0F : aExplosionPower < V[4] ? 5.0F : aExplosionPower < V[4] * 2 ? 6.0F : aExplosionPower < V[5] ? 7.0F : aExplosionPower < V[6] ? 8.0F : aExplosionPower < V[7] ? 9.0F : 10.0F;
+ int tX = getBaseMetaTileEntity().getXCoord(), tY = getBaseMetaTileEntity().getYCoord(), tZ = getBaseMetaTileEntity().getZCoord();
+ World tWorld = getBaseMetaTileEntity().getWorld();
+ GT_Utility.sendSoundToPlayers(tWorld, GregTech_API.sSoundList.get(209), 1.0F, -1, tX, tY, tZ);
+ tWorld.setBlock(tX, tY, tZ, Blocks.air);
+ if (GregTech_API.sMachineExplosions)
+ tWorld.createExplosion(null, tX + 0.5, tY + 0.5, tZ + 0.5, tStrength, true);
+ }
+
+ @Override
+ public int getLightOpacity() {
+ return ((GregtechBaseMetaTileEntityLossless) getBaseMetaTileEntity()).getLightValue() > 0 ? 0 : 255;
+ }
+
+ @Override
+ public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, List<AxisAlignedBB> outputAABB, Entity collider) {
+ AxisAlignedBB axisalignedbb1 = getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ);
+ if (axisalignedbb1 != null && inputAABB.intersectsWith(axisalignedbb1)) outputAABB.add(axisalignedbb1);
+ }
+
+ @Override
+ public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) {
+ return AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + 1, aY + 1, aZ + 1);
+ }
+
+ @Override
+ public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity collider) {
+ //
+ }
+
+ @Override
+ public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) {
+ //
+ }
} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaSafeBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaSafeBlockBase.java
index 79f0ec3b9d..05661df905 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaSafeBlockBase.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaSafeBlockBase.java
@@ -1,8 +1,6 @@
package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.machines;
-import java.util.UUID;
-
-import gregtech.api.enums.GT_Values;
+import static gregtech.api.enums.GT_Values.V;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
@@ -13,140 +11,113 @@ import gtPlusPlus.core.handler.events.UnbreakableBlockManager;
import gtPlusPlus.core.util.Utils;
import gtPlusPlus.core.util.player.PlayerCache;
import gtPlusPlus.core.util.player.PlayerUtils;
+
+import java.util.UUID;
+
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public abstract class GregtechMetaSafeBlockBase extends GT_MetaTileEntity_TieredMachineBlock {
- public boolean bOutput = false, bRedstoneIfFull = false, bInvert = false, bUnbreakable = false;
- public int mSuccess = 0, mTargetStackSize = 0;
- public UUID ownerUUID;
- UnbreakableBlockManager Xasda = new UnbreakableBlockManager();
- private boolean value_last = false, value_current = false;
-
- public GregtechMetaSafeBlockBase(final int aID, final String aName, final String aNameRegional, final int aTier,
- final int aInvSlotCount, final String aDescription) {
+ public boolean bOutput = false, bRedstoneIfFull = false, bInvert = false, bUnbreakable = false;
+ public int mSuccess = 0, mTargetStackSize = 0;
+ public UUID ownerUUID;
+ UnbreakableBlockManager Xasda = new UnbreakableBlockManager();
+ private boolean value_last = false, value_current = false;
+
+ public GregtechMetaSafeBlockBase(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription) {
super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription);
}
- public GregtechMetaSafeBlockBase(final String aName, final int aTier, final int aInvSlotCount,
- final String aDescription, final ITexture[][][] aTextures) {
+ public GregtechMetaSafeBlockBase(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 true;
- }
+ public ITexture[][][] getTextureSet(ITexture[] aTextures) {
+ ITexture[][][] rTextures = new ITexture[6][17][];
+ ITexture tIcon = getOverlayIcon(), tOut = new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_QCHEST), tUp = new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT), tShitGoesWrong = new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_FLUID_SIDE_ACTIVE);
+ for (byte i = -1; i < 16; i++) {
+ rTextures[0][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tUp, tIcon}; //Back
+ rTextures[1][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tIcon}; // Right, Strangely The top side as well when facing East?
+ rTextures[2][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tIcon}; // Top And Bottom, When Facing South (What the hell?)
+ rTextures[3][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tIcon}; // Left, Top if facing West and Bottom if facing east?
+ rTextures[4][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tIcon}; // Top and Bottom when Facing North..
+ rTextures[5][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tOut}; // Front
+ }
+ return rTextures;
- @Override
- public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide,
- final ItemStack aStack) {
- return aSide != aBaseMetaTileEntity.getBackFacing();
}
@Override
- public long getMinimumStoredEU() {
- return 512;
- }
-
- public abstract ITexture getOverlayIcon();
-
- @Override
- public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing,
- final byte aColorIndex, final boolean aActive, final boolean aRedstone) {
- if (aSide == aFacing) {
- return this.mTextures[5][aColorIndex + 1];
- }
- if (GT_Utility.getOppositeSide(aSide) == aFacing) {
- return this.mTextures[0][aColorIndex + 1];
- }
+ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
+ if (aSide == aFacing) return mTextures[5][aColorIndex + 1];
+ if (GT_Utility.getOppositeSide(aSide) == aFacing) return mTextures[0][aColorIndex + 1];
switch (aFacing) {
+ case 0:
+ return mTextures[4][aColorIndex + 1];
+ case 1:
+ return mTextures[2][aColorIndex + 1];
+ case 2:
+ switch (aSide) {
case 0:
- return this.mTextures[4][aColorIndex + 1];
+ return mTextures[2][aColorIndex + 1];
case 1:
- return this.mTextures[2][aColorIndex + 1];
- case 2:
- switch (aSide) {
- case 0:
- return this.mTextures[2][aColorIndex + 1];
- case 1:
- return this.mTextures[2][aColorIndex + 1];
- case 4:
- return this.mTextures[1][aColorIndex + 1];
- case 5:
- return this.mTextures[3][aColorIndex + 1];
- }
- case 3:
- switch (aSide) {
- case 0:
- return this.mTextures[4][aColorIndex + 1];
- case 1:
- return this.mTextures[4][aColorIndex + 1];
- case 4:
- return this.mTextures[3][aColorIndex + 1];
- case 5:
- return this.mTextures[1][aColorIndex + 1];
- }
+ return mTextures[2][aColorIndex + 1];
case 4:
- switch (aSide) {
- case 0:
- return this.mTextures[3][aColorIndex + 1];
- case 1:
- return this.mTextures[1][aColorIndex + 1];
- case 2:
- return this.mTextures[3][aColorIndex + 1];
- case 3:
- return this.mTextures[1][aColorIndex + 1];
- }
+ return mTextures[1][aColorIndex + 1];
case 5:
- switch (aSide) {
- case 0:
- return this.mTextures[1][aColorIndex + 1];
- case 1:
- return this.mTextures[3][aColorIndex + 1];
- case 2:
- return this.mTextures[1][aColorIndex + 1];
- case 3:
- return this.mTextures[3][aColorIndex + 1];
- }
+ return mTextures[3][aColorIndex + 1];
+ }
+ case 3:
+ switch (aSide) {
+ case 0:
+ return mTextures[4][aColorIndex + 1];
+ case 1:
+ return mTextures[4][aColorIndex + 1];
+ case 4:
+ return mTextures[3][aColorIndex + 1];
+ case 5:
+ return mTextures[1][aColorIndex + 1];
+ }
+ case 4:
+ switch (aSide) {
+ case 0:
+ return mTextures[3][aColorIndex + 1];
+ case 1:
+ return mTextures[1][aColorIndex + 1];
+ case 2:
+ return mTextures[3][aColorIndex + 1];
+ case 3:
+ return mTextures[1][aColorIndex + 1];
+ }
+ case 5:
+ switch (aSide) {
+ case 0:
+ return mTextures[1][aColorIndex + 1];
+ case 1:
+ return mTextures[3][aColorIndex + 1];
+ case 2:
+ return mTextures[1][aColorIndex + 1];
+ case 3:
+ return mTextures[3][aColorIndex + 1];
+ }
}
- return this.mTextures[5][aColorIndex + 1];
+ return mTextures[5][aColorIndex + 1];
}
@Override
- public ITexture[][][] getTextureSet(final ITexture[] aTextures) {
- final ITexture[][][] rTextures = new ITexture[6][17][];
- final ITexture tIcon = this.getOverlayIcon(), tOut = new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_QCHEST),
- tUp = new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT),
- tShitGoesWrong = new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_FLUID_SIDE_ACTIVE);
- for (byte i = -1; i < 16; i++) {
- rTextures[0][i + 1] = new ITexture[] {
- Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tUp, tIcon
- }; // Back
- rTextures[1][i + 1] = new ITexture[] {
- Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tIcon
- }; // Right, Strangely The top side as well when facing East?
- rTextures[2][i + 1] = new ITexture[] {
- Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tIcon
- }; // Top And Bottom, When Facing South (What the hell?)
- rTextures[3][i + 1] = new ITexture[] {
- Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tIcon
- }; // Left, Top if facing West and Bottom if facing east?
- rTextures[4][i + 1] = new ITexture[] {
- Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tIcon
- }; // Top and Bottom when Facing North..
- rTextures[5][i + 1] = new ITexture[] {
- Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tOut
- }; // Front
- }
- return rTextures;
+ public boolean isSimpleMachine() {
+ return false;
+ }
+ @Override
+ public boolean isValidSlot(int aIndex) {
+ return aIndex < mInventory.length - 1;
}
@Override
- public boolean isAccessAllowed(final EntityPlayer aPlayer) {
+ public boolean isFacingValid(byte aFacing) {
return true;
}
@@ -161,44 +132,38 @@ public abstract class GregtechMetaSafeBlockBase extends GT_MetaTileEntity_Tiered
}
@Override
- public boolean isFacingValid(final byte aFacing) {
- return true;
+ public boolean isInputFacing(byte aSide) {
+ return !isOutputFacing(aSide);
}
@Override
- public boolean isInputFacing(final byte aSide) {
- return !this.isOutputFacing(aSide);
+ public boolean isOutputFacing(byte aSide) {
+ return getBaseMetaTileEntity().getBackFacing() == aSide;
}
@Override
- public boolean isOutputFacing(final byte aSide) {
- return this.getBaseMetaTileEntity().getBackFacing() == aSide;
+ public boolean isTeleporterCompatible() {
+ return false;
}
@Override
- public boolean isSimpleMachine() {
- return false;
+ public long getMinimumStoredEU() {
+ return 512;
}
@Override
- public boolean isTeleporterCompatible() {
- return false;
+ public long maxEUStore() {
+ return 512 + V[mTier] * 50;
}
@Override
- public boolean isValidSlot(final int aIndex) {
- return aIndex < this.mInventory.length - 1;
+ public long maxEUInput() {
+ return V[mTier];
}
@Override
- public void loadNBTData(final NBTTagCompound aNBT) {
- this.bUnbreakable = aNBT.getBoolean("bUnbreakable");
- this.bOutput = aNBT.getBoolean("bOutput");
- this.bRedstoneIfFull = aNBT.getBoolean("bRedstoneIfFull");
- this.mTargetStackSize = aNBT.getInteger("mTargetStackSize");
- if (aNBT.hasKey("ownerUUID")) {
- this.ownerUUID = UUID.fromString(aNBT.getString("ownerUUID"));
- }
+ public long maxEUOutput() {
+ return bOutput ? V[mTier] : 0;
}
@Override
@@ -212,190 +177,176 @@ public abstract class GregtechMetaSafeBlockBase extends GT_MetaTileEntity_Tiered
}
@Override
- public long maxEUInput() {
- return GT_Values.V[this.mTier];
- }
-
- @Override
- public long maxEUOutput() {
- return this.bOutput ? GT_Values.V[this.mTier] : 0;
- }
-
- @Override
- public long maxEUStore() {
- return 512 + GT_Values.V[this.mTier] * 50;
+ public boolean isAccessAllowed(EntityPlayer aPlayer) {
+ return true;
}
- @Override
- public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTimer) {
- /*
- * if (aBaseMetaTileEntity.isAllowedToWork() &&
- * aBaseMetaTileEntity.isServerSide() &&
- * aBaseMetaTileEntity.isUniversalEnergyStored(getMinimumStoredEU()) &&
- * (aBaseMetaTileEntity.hasWorkJustBeenEnabled() ||
- * aBaseMetaTileEntity.hasInventoryBeenModified() || aTimer % 200 == 0
- * || mSuccess > 0)) {
- */
- if (aBaseMetaTileEntity.isServerSide() && (aBaseMetaTileEntity.hasWorkJustBeenEnabled()
- || aBaseMetaTileEntity.hasInventoryBeenModified() || aTimer % 200 == 0 || this.mSuccess > 0)) {
- this.value_last = this.value_current;
- this.value_current = this.bUnbreakable;
- if (this.value_last != this.value_current) {
- Utils.LOG_WARNING("VALUE CHANGE - Ticking for a moment.");
- if (this.bUnbreakable == true) {
- // Xasda.setmTileEntity((BaseMetaTileEntity)
- // aBaseMetaTileEntity);
- // Utils.LOG_ERROR("Safe is Indestructible.");
- this.getBaseMetaTileEntity()
- .getBlock(this.getBaseMetaTileEntity().getXCoord(),
- this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord())
- .setResistance(Float.MAX_VALUE);
- this.getBaseMetaTileEntity()
- .getBlock(this.getBaseMetaTileEntity().getXCoord(),
- this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord())
- .setBlockUnbreakable();
- }
- else {
- // Xasda.setmTileEntity((BaseMetaTileEntity)
- // aBaseMetaTileEntity);
- // Utils.LOG_ERROR("Safe is not Indestructible.");
- this.getBaseMetaTileEntity()
- .getBlock(this.getBaseMetaTileEntity().getXCoord(),
- this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord())
- .setResistance(1F);
- this.getBaseMetaTileEntity()
- .getBlock(this.getBaseMetaTileEntity().getXCoord(),
- this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord())
- .setHardness(2);
-
- }
- }
- else {
-
- }
-
- /*
- * mSuccess--; moveItems(aBaseMetaTileEntity, aTimer);
- * aBaseMetaTileEntity.setGenericRedstoneOutput(bInvert); if
- * (bRedstoneIfFull) {
- * aBaseMetaTileEntity.setGenericRedstoneOutput(!bInvert); for (int
- * i = 0; i < mInventory.length; i++) if (isValidSlot(i)) { if
- * (mInventory[i] == null) {
- * aBaseMetaTileEntity.setGenericRedstoneOutput(bInvert);
- * aBaseMetaTileEntity.decreaseStoredEnergyUnits(1, true); break; }
- * } } }
- */
- }
- }
+ public abstract ITexture getOverlayIcon();
@Override
- public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) {
+ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {
- if (aBaseMetaTileEntity.isClientSide()) {
- // Utils.LOG_WARNING("Clicky Clicky.");
+ if (aBaseMetaTileEntity.isClientSide()) {
+ //Utils.LOG_WARNING("Clicky Clicky.");
return true;
}
if (!aPlayer.equals(null)) {
- final UUID tempUUID = aPlayer.getUniqueID();
- /*
- * if (!aPlayer.worldObj.isRemote){
- * //PlayerCache.appendParamChanges(aPlayer.getDisplayName(),
- * aPlayer.getUniqueID().toString()); }
- */
- // Utils.LOG_INFO("test");
- if (this.ownerUUID == null) {
+ UUID tempUUID = aPlayer.getUniqueID();
+ /*if (!aPlayer.worldObj.isRemote){
+ //PlayerCache.appendParamChanges(aPlayer.getDisplayName(), aPlayer.getUniqueID().toString());
+ }*/
+ //Utils.LOG_INFO("test");
+ if (ownerUUID == null){
Utils.LOG_INFO("No owner yet for this block.");
}
else {
- // Utils.LOG_INFO("test");
- Utils.LOG_INFO("Current Owner: " + PlayerCache.lookupPlayerByUUID(this.ownerUUID) + " - UUID: "
- + this.ownerUUID);
+ //Utils.LOG_INFO("test");
+ Utils.LOG_INFO("Current Owner: "+PlayerCache.lookupPlayerByUUID(ownerUUID)+" - UUID: "+ownerUUID);
}
Utils.LOG_WARNING("Is ownerUUID Null");
- if (this.ownerUUID == null) {
+ if (ownerUUID == null){
Utils.LOG_WARNING("OwnerUUID is Null, let's set it.");
- Utils.LOG_WARNING("Accessing Players UUID is: " + tempUUID);
- this.ownerUUID = tempUUID;
- // Utils.messagePlayer(aPlayer, "Owner of this safe, now set.
- // Try accessing it again.");
- Utils.LOG_WARNING("Block Owner is now set to: " + this.ownerUUID);
+ Utils.LOG_WARNING("Accessing Players UUID is: "+tempUUID);
+ ownerUUID = tempUUID;
+ //Utils.messagePlayer(aPlayer, "Owner of this safe, now set. Try accessing it again.");
+ Utils.LOG_WARNING("Block Owner is now set to: "+ownerUUID);
}
Utils.LOG_WARNING("No, it is not.");
Utils.LOG_WARNING("Checking ownerUUID.");
- if (this.ownerUUID != null) {
+ if (ownerUUID != null){
Utils.LOG_WARNING("ownerUUID != Null, if accessor == owner.");
- Utils.LOG_WARNING("Accessing is: " + PlayerCache.lookupPlayerByUUID(tempUUID));
- if (this.ownerUUID.equals(tempUUID)) {
- Utils.LOG_WARNING("Owner's UUID: " + this.ownerUUID);
+ Utils.LOG_WARNING("Accessing is: "+PlayerCache.lookupPlayerByUUID(tempUUID));
+ if (ownerUUID.equals(tempUUID)){
+ Utils.LOG_WARNING("Owner's UUID: "+ownerUUID);
aBaseMetaTileEntity.openGUI(aPlayer);
- // Utils.LOG_WARNING("GUI should now be open for you sir.");
+ //Utils.LOG_WARNING("GUI should now be open for you sir.");
}
else {
PlayerUtils.messagePlayer(aPlayer, "Access Denied, This does not belong to you.");
- PlayerUtils.messagePlayer(aPlayer,
- "it is owned by: " + PlayerCache.lookupPlayerByUUID(this.ownerUUID));
- Utils.LOG_WARNING("Expecting Player : " + PlayerCache.lookupPlayerByUUID(this.ownerUUID));
+ PlayerUtils.messagePlayer(aPlayer, "it is owned by: "+PlayerCache.lookupPlayerByUUID(ownerUUID));
+ Utils.LOG_WARNING("Expecting Player : "+PlayerCache.lookupPlayerByUUID(ownerUUID));
Utils.LOG_ERROR("Access Denied.");
return true;
}
}
- /*
- * else { Utils.LOG_ERROR(
- * "This is NOT good. Tell Draknyte1 your safe broke."); }
- */
- /*
- * Utils.LOG_WARNING("Clicky Clicky."); Utils.messagePlayer(aPlayer,
- * "Owner of this safe, now set.");
- * aBaseMetaTileEntity.openGUI(aPlayer);
- */
+ /*else {
+ Utils.LOG_ERROR("This is NOT good. Tell Draknyte1 your safe broke.");
+ }*/
+ /*Utils.LOG_WARNING("Clicky Clicky.");
+ Utils.messagePlayer(aPlayer, "Owner of this safe, now set.");
+ aBaseMetaTileEntity.openGUI(aPlayer); */
}
return true;
}
@Override
- public void onScrewdriverRightClick(final byte aSide, final EntityPlayer aPlayer, final float aX, final float aY,
- final float aZ) {
- if (aSide == this.getBaseMetaTileEntity().getBackFacing()) {
- this.mTargetStackSize = (byte) ((this.mTargetStackSize + (aPlayer.isSneaking() ? -1 : 1)) % 65);
- if (this.mTargetStackSize == 0) {
+ public void saveNBTData(NBTTagCompound aNBT) {
+ aNBT.setBoolean("bUnbreakable", bUnbreakable);
+ aNBT.setBoolean("bOutput", bOutput);
+ aNBT.setBoolean("bRedstoneIfFull", bRedstoneIfFull);
+ aNBT.setInteger("mTargetStackSize", mTargetStackSize);
+ aNBT.setString("ownerUUID", ownerUUID.toString());
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ bUnbreakable = aNBT.getBoolean("bUnbreakable");
+ bOutput = aNBT.getBoolean("bOutput");
+ bRedstoneIfFull = aNBT.getBoolean("bRedstoneIfFull");
+ mTargetStackSize = aNBT.getInteger("mTargetStackSize");
+ if (aNBT.hasKey("ownerUUID"))
+ ownerUUID = UUID.fromString(aNBT.getString("ownerUUID"));
+ }
+
+ @Override
+ public void setItemNBT(NBTTagCompound aNBT) {
+ super.setItemNBT(aNBT);
+ if (mTargetStackSize > 0) aNBT.setInteger("mTargetStackSize", mTargetStackSize);
+ }
+
+ @Override
+ public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ if (aSide == getBaseMetaTileEntity().getBackFacing()) {
+ mTargetStackSize = (byte) ((mTargetStackSize + (aPlayer.isSneaking()? -1 : 1)) % 65);
+ if (mTargetStackSize == 0) {
GT_Utility.sendChatToPlayer(aPlayer, "Do not regulate Item Stack Size");
+ } else {
+ GT_Utility.sendChatToPlayer(aPlayer, "Regulate Item Stack Size to: " + mTargetStackSize);
+ }
+ }
+ }
+
+ @Override
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) {
+ /*if (aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isUniversalEnergyStored(getMinimumStoredEU()) && (aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified() || aTimer % 200 == 0 || mSuccess > 0)) {
+ */
+ if (aBaseMetaTileEntity.isServerSide() && (aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified() || aTimer % 200 == 0 || mSuccess > 0)) {
+ value_last = value_current;
+ value_current = bUnbreakable;
+ if (value_last != value_current){
+ Utils.LOG_WARNING("VALUE CHANGE - Ticking for a moment.");
+ if (bUnbreakable == true){
+ //Xasda.setmTileEntity((BaseMetaTileEntity) aBaseMetaTileEntity);
+ //Utils.LOG_ERROR("Safe is Indestructible.");
+ this.getBaseMetaTileEntity().getBlock(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()).setResistance(Float.MAX_VALUE);
+ this.getBaseMetaTileEntity().getBlock(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()).setBlockUnbreakable();
+ }
+ else {
+ //Xasda.setmTileEntity((BaseMetaTileEntity) aBaseMetaTileEntity);
+ //Utils.LOG_ERROR("Safe is not Indestructible.");
+ this.getBaseMetaTileEntity().getBlock(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()).setResistance(1F);
+ this.getBaseMetaTileEntity().getBlock(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()).setHardness(2);
+
+ }
}
else {
- GT_Utility.sendChatToPlayer(aPlayer, "Regulate Item Stack Size to: " + this.mTargetStackSize);
+
}
+
+
+
+
+
+
+
+
+ /*mSuccess--;
+ moveItems(aBaseMetaTileEntity, aTimer);
+ aBaseMetaTileEntity.setGenericRedstoneOutput(bInvert);
+ if (bRedstoneIfFull) {
+ aBaseMetaTileEntity.setGenericRedstoneOutput(!bInvert);
+ for (int i = 0; i < mInventory.length; i++)
+ if (isValidSlot(i)) {
+ if (mInventory[i] == null) {
+ aBaseMetaTileEntity.setGenericRedstoneOutput(bInvert);
+ aBaseMetaTileEntity.decreaseStoredEnergyUnits(1, true);
+ break;
+ }
+ }
+ }
+ }*/
}
}
- /*
- * protected void moveItems(IGregTechTileEntity aBaseMetaTileEntity, long
- * aTimer) { int tCost = GT_Utility.moveOneItemStack(aBaseMetaTileEntity,
- * aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing
- * ()), aBaseMetaTileEntity.getBackFacing(),
- * aBaseMetaTileEntity.getFrontFacing(), null, false, mTargetStackSize == 0
- * ? 64 : (byte) mTargetStackSize, mTargetStackSize == 0 ? 1 : (byte)
- * mTargetStackSize, (byte) 64, (byte) 1); if (tCost > 0 ||
- * aBaseMetaTileEntity.hasInventoryBeenModified()) { mSuccess = 50;
- * aBaseMetaTileEntity.decreaseStoredEnergyUnits(Math.abs(tCost), true); } }
- */
+ /*protected void moveItems(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) {
+ int tCost = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()), aBaseMetaTileEntity.getBackFacing(), aBaseMetaTileEntity.getFrontFacing(), null, false, mTargetStackSize == 0 ? 64 : (byte) mTargetStackSize, mTargetStackSize == 0 ? 1 : (byte) mTargetStackSize, (byte) 64, (byte) 1);
+ if (tCost > 0 || aBaseMetaTileEntity.hasInventoryBeenModified()) {
+ mSuccess = 50;
+ aBaseMetaTileEntity.decreaseStoredEnergyUnits(Math.abs(tCost), true);
+ }
+ }*/
@Override
- public void saveNBTData(final NBTTagCompound aNBT) {
- aNBT.setBoolean("bUnbreakable", this.bUnbreakable);
- aNBT.setBoolean("bOutput", this.bOutput);
- aNBT.setBoolean("bRedstoneIfFull", this.bRedstoneIfFull);
- aNBT.setInteger("mTargetStackSize", this.mTargetStackSize);
- aNBT.setString("ownerUUID", this.ownerUUID.toString());
+ public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return true;
}
@Override
- public void setItemNBT(final NBTTagCompound aNBT) {
- super.setItemNBT(aNBT);
- if (this.mTargetStackSize > 0) {
- aNBT.setInteger("mTargetStackSize", this.mTargetStackSize);
- }
+ public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return aSide != aBaseMetaTileEntity.getBackFacing();
}
} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/creative/GregtechMetaCreativeEnergyBuffer.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/creative/GregtechMetaCreativeEnergyBuffer.java
index a00d41717f..348e7dd118 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/creative/GregtechMetaCreativeEnergyBuffer.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/creative/GregtechMetaCreativeEnergyBuffer.java
@@ -1,8 +1,15 @@
package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.creative;
-import gregtech.api.enums.GT_Values;
+import static gregtech.api.enums.GT_Values.V;
import gregtech.api.enums.Textures;
-import gregtech.api.gui.*;
+import gregtech.api.gui.GT_Container_1by1;
+import gregtech.api.gui.GT_Container_2by2;
+import gregtech.api.gui.GT_Container_3by3;
+import gregtech.api.gui.GT_Container_4by4;
+import gregtech.api.gui.GT_GUIContainer_1by1;
+import gregtech.api.gui.GT_GUIContainer_2by2;
+import gregtech.api.gui.GT_GUIContainer_3by3;
+import gregtech.api.gui.GT_GUIContainer_4by4;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
@@ -20,312 +27,243 @@ import net.minecraft.util.EnumChatFormatting;
/**
* NEVER INCLUDE THIS FILE IN YOUR MOD!!!
- *
- * This is the main construct for my Basic Machines such as the Automatic
- * Extractor Extend this class to make a simple Machine
+ *
+ * This is the main construct for my Basic Machines such as the Automatic Extractor
+ * Extend this class to make a simple Machine
*/
public class GregtechMetaCreativeEnergyBuffer extends GregtechMetaEnergyBuffer {
- public boolean mCharge = false, mDecharge = false;
- public int mBatteryCount = 1, mChargeableCount = 1;
-
- private long count = 0;
- private long mStored = 0;
-
- private long mMax = 0;
-
- public GregtechMetaCreativeEnergyBuffer(final int aID, final String aName, final String aNameRegional,
- final int aTier, final String aDescription, final int aSlotCount) {
- super(aID, aName, aNameRegional, aTier, aDescription, aSlotCount);
- }
-
- public GregtechMetaCreativeEnergyBuffer(final String aName, final int aTier, final String aDescription,
- final ITexture[][][] aTextures, final int aSlotCount) {
+ public GregtechMetaCreativeEnergyBuffer(String aName, int aTier,
+ String aDescription, ITexture[][][] aTextures, int aSlotCount) {
super(aName, aTier, aDescription, aTextures, aSlotCount);
// TODO Auto-generated constructor stub
}
- @Override
- public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide,
- final ItemStack aStack) {
- if (GT_ModHandler.isElectricItem(aStack) && aStack.getUnlocalizedName().startsWith("gt.metaitem.01.")) {
- final String name = aStack.getUnlocalizedName();
- if (name.equals("gt.metaitem.01.32510") || name.equals("gt.metaitem.01.32511")
- || name.equals("gt.metaitem.01.32520") || name.equals("gt.metaitem.01.32521")
- || name.equals("gt.metaitem.01.32530") || name.equals("gt.metaitem.01.32531")) {
- return true;
- }
- }
- return false;
- }
-
- @Override
- public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide,
- final ItemStack aStack) {
- if (!GT_Utility.isStackValid(aStack)) {
- return false;
- }
- if (GT_ModHandler.isElectricItem(aStack, this.mTier)) {
- return true;
- }
- return false;
+ public GregtechMetaCreativeEnergyBuffer(int aID, String aName,
+ String aNameRegional, int aTier, String aDescription, int aSlotCount) {
+ super(aID, aName, aNameRegional, aTier, aDescription, aSlotCount);
}
- @Override
- public int dechargerSlotCount() {
- return this.mDecharge ? this.mInventory.length : 0;
- }
-
- @Override
- public int dechargerSlotStartIndex() {
- return 0;
- }
-
- @Override
- public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory,
- final IGregTechTileEntity aBaseMetaTileEntity) {
- switch (this.mInventory.length) {
- case 1:
- return new GT_GUIContainer_1by1(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName());
- case 4:
- return new GT_GUIContainer_2by2(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName());
- case 9:
- return new GT_GUIContainer_3by3(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName());
- case 16:
- return new GT_GUIContainer_4by4(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName());
- }
- return new GT_GUIContainer_1by1(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName());
- }
+ public boolean mCharge = false, mDecharge = false;
+ public int mBatteryCount = 1, mChargeableCount = 1;
@Override
public String[] getDescription() {
- return new String[] {
- this.mDescription, "Added by: " + EnumChatFormatting.DARK_GREEN + "Alkalus"
- };
- }
-
- @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(), "THIS IS A CREATIVE ITEM - FOR TESTING",
- GT_Utility.formatNumbers(this.mStored) + " EU /", GT_Utility.formatNumbers(this.mMax) + " EU"
- };
- }
-
- @Override
- public long getMinimumStoredEU() {
- return 1;
- }
-
- @Override
- public int getProgresstime() {
- return Integer.MAX_VALUE;
- }
-
- @Override
- public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory,
- final IGregTechTileEntity aBaseMetaTileEntity) {
- switch (this.mInventory.length) {
- case 1:
- return new GT_Container_1by1(aPlayerInventory, aBaseMetaTileEntity);
- case 4:
- return new GT_Container_2by2(aPlayerInventory, aBaseMetaTileEntity);
- case 9:
- return new GT_Container_3by3(aPlayerInventory, aBaseMetaTileEntity);
- case 16:
- return new GT_Container_4by4(aPlayerInventory, aBaseMetaTileEntity);
- }
- return new GT_Container_1by1(aPlayerInventory, aBaseMetaTileEntity);
- }
-
- @Override
- public long[] getStoredEnergy() {
- long tScale = this.getBaseMetaTileEntity().getEUCapacity();
- long tStored = this.getBaseMetaTileEntity().getStoredEU();
- this.setEUVar(Long.MAX_VALUE);
- if (this.mInventory != null) {
- for (final ItemStack aStack : this.mInventory) {
- if (GT_ModHandler.isElectricItem(aStack)) {
-
- if (aStack.getItem() instanceof GT_MetaBase_Item) {
- 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);
- }
- }
- 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
- };
- }
-
- @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[aSide == aFacing ? 1 : 0][aColorIndex + 1];
+ return new String[] {mDescription, "Added by: " + EnumChatFormatting.DARK_GREEN+"Alkalus"};
}
/*
* MACHINE_STEEL_SIDE
*/
@Override
- public ITexture[][][] getTextureSet(final ITexture[] aTextures) {
- final ITexture[][][] rTextures = new ITexture[2][17][];
+ 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_CASING_MAGIC_FRONT)
- };
+ rTextures[0][i + 1] = new ITexture[] { new GT_RenderedTexture(
+ Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT) };
rTextures[1][i + 1] = new ITexture[] {
- new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT),
- this.mInventory.length > 4 ? Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]
- : Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier]
- };
+ new GT_RenderedTexture(
+ Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT),
+ mInventory.length > 4 ? Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier]
+ : Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier] };
}
return rTextures;
}
@Override
- public boolean isAccessAllowed(final EntityPlayer aPlayer) {
- return true;
+ 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 boolean isElectric() {
- return true;
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new GregtechMetaCreativeEnergyBuffer(mName, mTier, mDescription,
+ mTextures, mInventory.length);
}
- @Override
- public boolean isEnetInput() {
- return true;
- }
-
- @Override
- public boolean isEnetOutput() {
- return true;
- }
+ @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 boolean isFacingValid(final byte aFacing) {
- return true;
+ public long getMinimumStoredEU() {
+ return 1;
}
@Override
- public boolean isGivingInformation() {
- return true;
+ public long maxEUStore() {
+ return Long.MAX_VALUE;
}
@Override
- public boolean isInputFacing(final byte aSide) {
- return aSide != this.getBaseMetaTileEntity().getFrontFacing();
+ public long maxEUInput() {
+ return V[mTier];
}
@Override
- public boolean isOutputFacing(final byte aSide) {
- return aSide == this.getBaseMetaTileEntity().getFrontFacing();
+ public long maxEUOutput() {
+ return V[mTier];
}
@Override
- public boolean isSimpleMachine() {
- return false;
+ public long maxAmperesIn() {
+ return mChargeableCount * 16;
}
@Override
- public boolean isTeleporterCompatible() {
- return false;
+ public long maxAmperesOut() {
+ return mChargeableCount * 16;
}
+ @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 Integer.MAX_VALUE;}
+ @Override public int maxProgresstime() {return (int)getBaseMetaTileEntity().getUniversalEnergyCapacity();}
+ @Override public boolean isAccessAllowed(EntityPlayer aPlayer) {return true;}
@Override
- public boolean isValidSlot(final int aIndex) {
- return true;
+ public void saveNBTData(NBTTagCompound aNBT) {
+ //
}
@Override
- public void loadNBTData(final NBTTagCompound aNBT) {
+ public void loadNBTData(NBTTagCompound aNBT) {
//
}
@Override
- public long maxAmperesIn() {
- return this.mChargeableCount * 16;
+ public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory,
+ IGregTechTileEntity aBaseMetaTileEntity) {
+ switch (mInventory.length) {
+ case 1: return new GT_Container_1by1(aPlayerInventory, aBaseMetaTileEntity);
+ case 4: return new GT_Container_2by2(aPlayerInventory, aBaseMetaTileEntity);
+ case 9: return new GT_Container_3by3(aPlayerInventory, aBaseMetaTileEntity);
+ case 16: return new GT_Container_4by4(aPlayerInventory, aBaseMetaTileEntity);
+ }
+ return new GT_Container_1by1(aPlayerInventory, aBaseMetaTileEntity);
}
@Override
- public long maxAmperesOut() {
- return this.mChargeableCount * 16;
+ public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory,
+ IGregTechTileEntity aBaseMetaTileEntity) {
+ switch (mInventory.length) {
+ case 1: return new GT_GUIContainer_1by1(aPlayerInventory, aBaseMetaTileEntity, getLocalName());
+ case 4: return new GT_GUIContainer_2by2(aPlayerInventory, aBaseMetaTileEntity, getLocalName());
+ case 9: return new GT_GUIContainer_3by3(aPlayerInventory, aBaseMetaTileEntity, getLocalName());
+ case 16: return new GT_GUIContainer_4by4(aPlayerInventory, aBaseMetaTileEntity, getLocalName());
+ }
+ return new GT_GUIContainer_1by1(aPlayerInventory, aBaseMetaTileEntity, getLocalName());
}
@Override
- public long maxEUInput() {
- return GT_Values.V[this.mTier];
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
+ this.getBaseMetaTileEntity().increaseStoredEnergyUnits(Integer.MAX_VALUE, true);
+ if (aBaseMetaTileEntity.isServerSide()) {
+ mCharge = aBaseMetaTileEntity.getStoredEU() / 2 > aBaseMetaTileEntity
+ .getEUCapacity() / 3;
+ mDecharge = aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity() / 3;
+ mBatteryCount = 1;
+ mChargeableCount = 1;
+ this.getBaseMetaTileEntity().increaseStoredEnergyUnits(mMax, true);
+ for (ItemStack tStack : mInventory) if (GT_ModHandler.isElectricItem(tStack, mTier)) {
+ if (GT_ModHandler.isChargerItem(tStack)) mBatteryCount++;
+ mChargeableCount++;
+ }
+ }
}
@Override
- public long maxEUOutput() {
- return GT_Values.V[this.mTier];
+ public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ if(GT_ModHandler.isElectricItem(aStack)&&aStack.getUnlocalizedName().startsWith("gt.metaitem.01.")){
+ String name = aStack.getUnlocalizedName();
+ if(name.equals("gt.metaitem.01.32510")||
+ name.equals("gt.metaitem.01.32511")||
+ name.equals("gt.metaitem.01.32520")||
+ name.equals("gt.metaitem.01.32521")||
+ name.equals("gt.metaitem.01.32530")||
+ name.equals("gt.metaitem.01.32531")){
+ return true;
+ }
+ }
+ return false;
}
@Override
- public long maxEUStore() {
- return Long.MAX_VALUE;
+ public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ if(!GT_Utility.isStackValid(aStack)){
+ return false;
+ }
+ if(GT_ModHandler.isElectricItem(aStack, this.mTier)){
+ return true;
+ }
+ return false;
}
@Override
- public int maxProgresstime() {
- return (int) this.getBaseMetaTileEntity().getUniversalEnergyCapacity();
- }
+ public long[] getStoredEnergy(){
+ long tScale = getBaseMetaTileEntity().getEUCapacity();
+ long tStored = getBaseMetaTileEntity().getStoredEU();
+ this.setEUVar(Long.MAX_VALUE);
+ if (mInventory != null) {
+ for (ItemStack aStack : mInventory) {
+ if (GT_ModHandler.isElectricItem(aStack)) {
- @Override
- public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) {
- return new GregtechMetaCreativeEnergyBuffer(this.mName, this.mTier, this.mDescription, this.mTextures,
- this.mInventory.length);
- }
- @Override
- public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) {
- this.getBaseMetaTileEntity().increaseStoredEnergyUnits(Integer.MAX_VALUE, true);
- if (aBaseMetaTileEntity.isServerSide()) {
- this.mCharge = aBaseMetaTileEntity.getStoredEU() / 2 > aBaseMetaTileEntity.getEUCapacity() / 3;
- this.mDecharge = aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity() / 3;
- this.mBatteryCount = 1;
- this.mChargeableCount = 1;
- this.getBaseMetaTileEntity().increaseStoredEnergyUnits(this.mMax, true);
- for (final ItemStack tStack : this.mInventory) {
- if (GT_ModHandler.isElectricItem(tStack, this.mTier)) {
- if (GT_ModHandler.isChargerItem(tStack)) {
- this.mBatteryCount++;
+ if (aStack.getItem() instanceof GT_MetaBase_Item) {
+ 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);
+ }
+ } else if (aStack.getItem() instanceof IElectricItem) {
+ tStored = tStored
+ + (long) ic2.api.item.ElectricItem.manager
+ .getCharge(aStack);
+ tScale = tScale
+ + (long) ((IElectricItem) aStack.getItem())
+ .getMaxCharge(aStack);
}
- this.mChargeableCount++;
}
}
+
}
- }
- @Override
- public int rechargerSlotCount() {
- return this.mCharge ? this.mInventory.length : 0;
+ return new long[] { tStored, tScale };
}
+ private long count=0;
+ private long mStored=0;
+ private long mMax=0;
+
@Override
- public int rechargerSlotStartIndex() {
- return 0;
+ public String[] getInfoData() {
+ count++;
+ if(mMax==0||count%20==0){
+ long[] tmp = getStoredEnergy();
+ mStored=tmp[0];
+ mMax=tmp[1];
+ }
+
+ return new String[] {
+ getLocalName(),
+ "THIS IS A CREATIVE ITEM - FOR TESTING",
+ GT_Utility.formatNumbers(mStored)+" EU /",
+ GT_Utility.formatNumbers(mMax)+" EU"};
}
@Override
- public void saveNBTData(final NBTTagCompound aNBT) {
- //
+ public boolean isGivingInformation() {
+ return true;
}
} \ No newline at end of file