aboutsummaryrefslogtreecommitdiff
path: root/src/Java
diff options
context:
space:
mode:
Diffstat (limited to 'src/Java')
-rw-r--r--src/Java/gtPlusPlus/api/interfaces/IGregtechPower.java6
-rw-r--r--src/Java/gtPlusPlus/api/interfaces/ILazyCoverable.java144
-rw-r--r--src/Java/gtPlusPlus/api/objects/data/Pair.java8
-rw-r--r--src/Java/gtPlusPlus/api/objects/minecraft/BTF_FluidTank.java188
-rw-r--r--src/Java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java164
-rw-r--r--src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java90
-rw-r--r--src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockEntityBase.java1
-rw-r--r--src/Java/gtPlusPlus/core/material/Material.java52
-rw-r--r--src/Java/gtPlusPlus/core/tileentities/base/TileBasicTank.java150
-rw-r--r--src/Java/gtPlusPlus/core/tileentities/base/TileEntityBase.java1148
-rw-r--r--src/Java/gtPlusPlus/core/tileentities/base/TilePoweredGT.java19
-rw-r--r--src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java399
-rw-r--r--src/Java/gtPlusPlus/core/tileentities/machines/TileEntityModularityTable.java7
-rw-r--r--src/Java/gtPlusPlus/core/tileentities/machines/TileEntityTradeTable.java1
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java21
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java6
16 files changed, 2057 insertions, 347 deletions
diff --git a/src/Java/gtPlusPlus/api/interfaces/IGregtechPower.java b/src/Java/gtPlusPlus/api/interfaces/IGregtechPower.java
index 5f624e7a8c..4bb29b3354 100644
--- a/src/Java/gtPlusPlus/api/interfaces/IGregtechPower.java
+++ b/src/Java/gtPlusPlus/api/interfaces/IGregtechPower.java
@@ -8,8 +8,6 @@ import net.minecraft.world.World;
import gregtech.api.interfaces.IDescribable;
import gregtech.api.interfaces.tileentity.*;
-import gtPlusPlus.core.tileentities.base.TilePoweredGT;
-
public abstract interface IGregtechPower extends IGearEnergyTileEntity, ITurnable, IGregTechDeviceInformation, IDescribable, IBasicEnergyContainer {
@Override
@@ -137,11 +135,11 @@ public abstract interface IGregtechPower extends IGearEnergyTileEntity, ITurnabl
return true;
}
- boolean onPreTick(TilePoweredGT tilePoweredGT, long mTickTimer2);
+/* boolean onPreTick(TilePoweredGT tilePoweredGT, long mTickTimer2);
boolean onTick(TilePoweredGT iGregTechTileEntity, long mTickTimer2);
- boolean onPostTick(TilePoweredGT iGregTechTileEntity, long mTickTimer2);
+ boolean onPostTick(TilePoweredGT iGregTechTileEntity, long mTickTimer2);*/
}
diff --git a/src/Java/gtPlusPlus/api/interfaces/ILazyCoverable.java b/src/Java/gtPlusPlus/api/interfaces/ILazyCoverable.java
new file mode 100644
index 0000000000..9e1a7431db
--- /dev/null
+++ b/src/Java/gtPlusPlus/api/interfaces/ILazyCoverable.java
@@ -0,0 +1,144 @@
+package gtPlusPlus.api.interfaces;
+
+import gregtech.api.interfaces.tileentity.ICoverable;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+
+public interface ILazyCoverable extends ICoverable {
+
+ @Override
+ default byte getColorization() {
+ return 0;
+ }
+
+ @Override
+ default byte setColorization(byte arg0) {
+ return 0;
+ }
+
+ @Override
+ default byte getInputRedstoneSignal(byte arg0) {
+ return 0;
+ }
+
+ @Override
+ default byte getStrongestRedstone() {
+ return 0;
+ }
+
+ @Override
+ default boolean getRedstone() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ default boolean getRedstone(byte arg0) {
+ return false;
+ }
+
+ @Override
+ default boolean isUniversalEnergyStored(long arg0) {
+ return false;
+ }
+
+ @Override
+ default long getUniversalEnergyStored() {
+ return 0;
+ }
+
+ @Override
+ default long getUniversalEnergyCapacity() {
+ return 0;
+ }
+
+ @Override
+ default long getStoredSteam() {
+ return 0;
+ }
+
+ @Override
+ default long getSteamCapacity() {
+ return 0;
+ }
+
+ @Override
+ default boolean increaseStoredSteam(long arg0, boolean arg2) {
+ return false;
+ }
+
+ @Override
+ default byte getOutputRedstoneSignal(byte arg0) {
+ return 0;
+ }
+
+ @Override
+ default void setOutputRedstoneSignal(byte arg0, byte arg1) {
+
+ }
+
+ @Override
+ default byte getStrongOutputRedstoneSignal(byte arg0) {
+ return 0;
+ }
+
+ @Override
+ default void setStrongOutputRedstoneSignal(byte arg0, byte arg1) {
+
+ }
+
+ @Override
+ default byte getComparatorValue(byte arg0) {
+ return 0;
+ }
+
+ @Override
+ default IGregTechTileEntity getIGregTechTileEntity(int arg0, int arg1, int arg2) {
+ return null;
+ }
+
+ @Override
+ default IGregTechTileEntity getIGregTechTileEntityOffset(int arg0, int arg1, int arg2) {
+ return null;
+ }
+
+ @Override
+ default IGregTechTileEntity getIGregTechTileEntityAtSide(byte arg0) {
+ return null;
+ }
+
+ @Override
+ default IGregTechTileEntity getIGregTechTileEntityAtSideAndDistance(byte arg0, int arg1) {
+ return null;
+ }
+
+ @Override
+ default byte getMetaID(int arg0, int arg1, int arg2) {
+ return 0;
+ }
+
+ @Override
+ default byte getMetaIDOffset(int arg0, int arg1, int arg2) {
+ return 0;
+ }
+
+ @Override
+ default byte getMetaIDAtSide(byte arg0) {
+ return 0;
+ }
+
+ @Override
+ default byte getMetaIDAtSideAndDistance(byte arg0, int arg1) {
+ return 0;
+ }
+
+ @Override
+ default boolean isDead() {
+ return false;
+ }
+
+ @Override
+ default void setLightValue(byte arg0) {
+
+ }
+
+}
diff --git a/src/Java/gtPlusPlus/api/objects/data/Pair.java b/src/Java/gtPlusPlus/api/objects/data/Pair.java
index 6ab781cf1e..e1d23e6b43 100644
--- a/src/Java/gtPlusPlus/api/objects/data/Pair.java
+++ b/src/Java/gtPlusPlus/api/objects/data/Pair.java
@@ -2,6 +2,8 @@ package gtPlusPlus.api.objects.data;
import java.io.Serializable;
+import com.google.common.base.Objects;
+
public class Pair<K,V> implements Serializable {
/**
@@ -24,4 +26,10 @@ public class Pair<K,V> implements Serializable {
return this.value;
}
+ @Override
+ public int hashCode() {
+ Integer aCode = Objects.hashCode(getKey(), getValue());
+ return aCode != null ? aCode : super.hashCode();
+ }
+
} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/BTF_FluidTank.java b/src/Java/gtPlusPlus/api/objects/minecraft/BTF_FluidTank.java
new file mode 100644
index 0000000000..0b8f97b378
--- /dev/null
+++ b/src/Java/gtPlusPlus/api/objects/minecraft/BTF_FluidTank.java
@@ -0,0 +1,188 @@
+package gtPlusPlus.api.objects.minecraft;
+
+import gtPlusPlus.core.util.minecraft.FluidUtils;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.FluidTank;
+import net.minecraftforge.fluids.FluidTankInfo;
+
+public class BTF_FluidTank extends FluidTank {
+
+ public FluidStack mFluid;
+
+ public BTF_FluidTank(int capacity) {
+ super(capacity);
+ }
+
+ /**
+ * Let's replace the Default handling with GT's own handling code, because it's probably better, right?
+ * @author Alkalus/GregoriusT
+ */
+
+
+ public FluidStack getFluid() {
+ return this.getDrainableStack();
+ }
+
+ public int getFluidAmount() {
+ return this.getDrainableStack() != null ? this.getDrainableStack().amount : 0;
+ }
+
+ public NBTTagCompound writeToNBT(NBTTagCompound aNBT) {
+ super.writeToNBT(aNBT);
+ if (this.mFluid != null) {
+ aNBT.setTag("mFluid", this.mFluid.writeToNBT(new NBTTagCompound()));
+ }
+ return aNBT;
+ }
+
+ public FluidTank readFromNBT(NBTTagCompound aNBT) {
+ this.mFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid"));
+ return this;
+ }
+
+/* public abstract boolean isLiquidInput(byte arg0);
+
+ public abstract boolean isLiquidOutput(byte arg0);
+
+ public abstract boolean doesFillContainers();
+
+ public abstract boolean doesEmptyContainers();*/
+
+ public boolean canTankBeFilled() {
+ return true;
+ }
+
+ public boolean canTankBeEmptied() {
+ return true;
+ }
+
+
+ public boolean isFluidInputAllowed(FluidStack aFluid) {
+ return true;
+ }
+
+ public FluidStack getFillableStack() {
+ return this.mFluid;
+ }
+
+ public FluidStack setFillableStack(FluidStack aFluid) {
+ this.mFluid = aFluid;
+ return this.mFluid;
+ }
+
+ public FluidStack getDrainableStack() {
+ return this.mFluid;
+ }
+
+ public FluidStack setDrainableStack(FluidStack aFluid) {
+ this.mFluid = aFluid;
+ return this.mFluid;
+ }
+
+ public FluidStack getDisplayedFluid() {
+ return this.getDrainableStack();
+ }
+
+ public boolean isFluidChangingAllowed() {
+ return true;
+ }
+
+ public int fill(FluidStack aFluid, boolean doFill) {
+ if (aFluid != null && aFluid.getFluid().getID() > 0 && aFluid.amount > 0 && this.canTankBeFilled()
+ && this.isFluidInputAllowed(aFluid)) {
+ if (this.getFillableStack() != null && this.getFillableStack().getFluid().getID() > 0) {
+ if (!this.getFillableStack().isFluidEqual(aFluid)) {
+ return 0;
+ } else {
+ int space = this.getCapacity() - this.getFillableStack().amount;
+ if (aFluid.amount <= space) {
+ if (doFill) {
+ FluidStack arg9999 = this.getFillableStack();
+ arg9999.amount += aFluid.amount;
+ }
+
+ return aFluid.amount;
+ } else {
+ if (doFill) {
+ this.getFillableStack().amount = this.getCapacity();
+ }
+
+ return space;
+ }
+ }
+ } else if (aFluid.amount <= this.getCapacity()) {
+ if (doFill) {
+ this.setFillableStack(aFluid.copy());
+ }
+
+ return aFluid.amount;
+ } else {
+ if (doFill) {
+ this.setFillableStack(aFluid.copy());
+ this.getFillableStack().amount = this.getCapacity();
+ }
+
+ return this.getCapacity();
+ }
+ } else {
+ return 0;
+ }
+ }
+
+ public FluidStack drain(int maxDrain, boolean doDrain) {
+ if (this.getDrainableStack() != null && this.canTankBeEmptied()) {
+ if (this.getDrainableStack().amount <= 0 && this.isFluidChangingAllowed()) {
+ this.setDrainableStack((FluidStack) null);
+ return null;
+ } else {
+ int used = maxDrain;
+ if (this.getDrainableStack().amount < maxDrain) {
+ used = this.getDrainableStack().amount;
+ }
+
+ if (doDrain) {
+ FluidStack arg9999 = this.getDrainableStack();
+ arg9999.amount -= used;
+ }
+
+ FluidStack drained = this.getDrainableStack().copy();
+ drained.amount = used;
+ if (this.getDrainableStack().amount <= 0 && this.isFluidChangingAllowed()) {
+ this.setDrainableStack((FluidStack) null);
+ }
+
+ return drained;
+ }
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public int getCapacity() {
+ return super.getCapacity();
+ }
+
+ @Override
+ public FluidTankInfo getInfo() {
+ return new FluidTankInfo(this);
+ }
+
+ @Override
+ public void setFluid(FluidStack fluid) {
+ setFillableStack(fluid);
+ }
+
+ @Override
+ public void setCapacity(int capacity) {
+ super.setCapacity(capacity);
+ }
+
+ public FluidStack drain(FluidStack aFluid, boolean doDrain) {
+ return drain(aFluid.amount, doDrain);
+ }
+
+
+
+}
diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java b/src/Java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java
new file mode 100644
index 0000000000..25968f1908
--- /dev/null
+++ b/src/Java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java
@@ -0,0 +1,164 @@
+package gtPlusPlus.api.objects.minecraft;
+
+import java.util.ArrayList;
+
+import gregtech.api.util.GT_Utility;
+import gtPlusPlus.core.tileentities.base.TileEntityBase;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.ISidedInventory;
+import net.minecraft.item.ItemStack;
+
+public class BTF_Inventory implements ISidedInventory{
+
+ public final ItemStack[] mInventory;
+ public final TileEntityBase mTile;
+
+ public BTF_Inventory(int aSlots, TileEntityBase tile) {
+ this.mInventory = new ItemStack[aSlots];
+ this.mTile = tile;
+ }
+
+ public ItemStack[] getRealInventory() {
+ return this.mInventory;
+ }
+
+ public int getSizeInventory() {
+ return this.mInventory.length;
+ }
+
+ public ItemStack getStackInSlot(int aIndex) {
+ return aIndex >= 0 && aIndex < this.mInventory.length ? this.mInventory[aIndex] : null;
+ }
+
+ public void setInventorySlotContents(int aIndex, ItemStack aStack) {
+ if (aIndex >= 0 && aIndex < this.mInventory.length) {
+ this.mInventory[aIndex] = aStack;
+ }
+ }
+
+ public boolean isAccessAllowed(EntityPlayer aPlayer) {
+ return true;
+ }
+
+ public boolean isValidSlot(int aIndex) {
+ return true;
+ }
+
+ public int getInventoryStackLimit() {
+ return 64;
+ }
+
+
+ public boolean setStackToZeroInsteadOfNull(int aIndex) {
+ return false;
+}
+
+ public boolean isItemValidForSlot(int aIndex, ItemStack aStack) {
+ return isValidSlot(aIndex);
+ }
+
+ public ItemStack decrStackSize(int aIndex, int aAmount) {
+ ItemStack tStack = this.getStackInSlot(aIndex);
+ ItemStack rStack = GT_Utility.copy(new Object[]{tStack});
+ if (tStack != null) {
+ if (tStack.stackSize <= aAmount) {
+ if (this.setStackToZeroInsteadOfNull(aIndex)) {
+ tStack.stackSize = 0;
+ } else {
+ this.setInventorySlotContents(aIndex, (ItemStack) null);
+ }
+ } else {
+ rStack = tStack.splitStack(aAmount);
+ if (tStack.stackSize == 0 && !this.setStackToZeroInsteadOfNull(aIndex)) {
+ this.setInventorySlotContents(aIndex, (ItemStack) null);
+ }
+ }
+ }
+
+ return rStack;
+ }
+
+ public int[] getAccessibleSlotsFromSide(int aSide) {
+ ArrayList<Integer> tList = new ArrayList<Integer>();
+ TileEntityBase tTileEntity = this.mTile;
+ 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 rArray = 0; rArray < this.getSizeInventory(); ++rArray) {
+ if (this.isValidSlot(rArray) && (tSkip
+ || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide,
+ tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide),
+ rArray, tTileEntity)
+ || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide,
+ tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getCoverDataAtSide((byte) aSide),
+ rArray, tTileEntity))) {
+ tList.add(Integer.valueOf(rArray));
+ }
+ }
+
+ int[] arg6 = new int[tList.size()];
+
+ for (int i = 0; i < arg6.length; ++i) {
+ arg6[i] = ((Integer) tList.get(i)).intValue();
+ }
+
+ return arg6;
+ }
+
+ public boolean canInsertItem(int aIndex, ItemStack aStack, 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.mTile, aIndex, (byte) aSide, aStack);
+ }
+
+ public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) {
+ return this.isValidSlot(aIndex) && aStack != null && aIndex < this.mInventory.length
+ && this.allowPullStack(this.mTile, aIndex, (byte) aSide, aStack);
+ }
+
+ public boolean allowPullStack(TileEntityBase mTile2, int aIndex, byte aSide, ItemStack aStack) {
+ return aIndex >= 0 && aIndex < this.getSizeInventory();
+ }
+
+ public boolean allowPutStack(TileEntityBase aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return (aIndex >= 0 && aIndex < this.getSizeInventory()) && (this.mInventory[aIndex] == null || GT_Utility.areStacksEqual(this.mInventory[aIndex], aStack));
+ }
+
+ public ItemStack getStackInSlotOnClosing(int i) {
+ return null;
+ }
+
+ public final boolean hasCustomInventoryName() {
+ return mTile != null ? mTile.hasCustomInventoryName() : false;
+ }
+
+
+ public void markDirty() {
+ if (mTile != null) {
+ mTile.markDirty();
+ }
+ }
+
+ public boolean isUseableByPlayer(EntityPlayer entityplayer) {
+ return true;
+ }
+
+ public void openInventory() {
+
+ }
+
+ public void closeInventory() {
+
+ }
+
+ @Override
+ public final String getInventoryName() {
+ return this.mTile != null ? mTile.getInventoryName() : "";
+ }
+
+
+}
diff --git a/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java b/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java
index bab2ecc349..215c79ed10 100644
--- a/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java
+++ b/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java
@@ -165,71 +165,18 @@ public class BlockTankXpConverter extends BlockContainer {
}
private final boolean generateRainbowMap() {
- int id = 0;
- this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(0, 255, 0));
- this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(51, 255, 0));
- this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(102, 255, 0));
- this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(153, 255, 0));
- this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(204, 255, 0));
- this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(255, 255, 0));
- this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(255, 204, 0));
- this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(255, 153, 0));
- this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(255, 102, 0));
- this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(255, 51, 0));
- this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(255, 0, 0));
- this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(255, 0, 51));
- this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(255, 0, 102));
- this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(255, 0, 153));
- this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(255, 0, 204));
- this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(255, 0, 255));
- this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(204, 0, 255));
- this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(153, 0, 255));
- this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(102, 0, 255));
- this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(51, 0, 255));
- this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(0, 0, 255));
- this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(0, 51, 255));
- this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(0, 102, 255));
- this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(0, 153, 255));
- this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(0, 204, 255));
- this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(0, 255, 255));
- this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(0, 255, 204));
- this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(0, 255, 153));
- this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(0, 255, 102));
- this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(0, 255, 51));
- this.mRainbowTickMax = this.mRainbowMap.size();
return true;
}
@Override
public int getBlockColor() {
- return Utils.rgbtoHexValue(0, 0, 0);
+ return super.getBlockColor();
}
@Override
public int colorMultiplier(final IBlockAccess p_149720_1_, final int p_149720_2_, final int p_149720_3_,
final int p_149720_4_) {
-
- if ((this.mRainbowTick < 0) || (this.mRainbowTick > this.mRainbowTickMax)) {
- this.mRainbowTick = 0;
- }
- //Utils.LOG_INFO("x: "+this.mRainbowTick);
- if (this.mRainbowTick <= this.mRainbowTickMax) {
- Triplet<Integer, Integer, Integer> mT = this.mRainbowMap.get(this.mRainbowTick);
- try {
- return Utils.rgbtoHexValue(mT.getValue_1(), mT.getValue_1(), mT.getValue_1());
- }
- catch (final Throwable t) {
- try {
- mT = this.mRainbowMap.get(this.mRainbowTick - 1);
- return Utils.rgbtoHexValue(mT.getValue_1(), mT.getValue_1(), mT.getValue_1());
- }
- catch (final Throwable t1) {
- return Utils.rgbtoHexValue(0, 0, 0);
- }
- }
- }
-
- return Utils.rgbtoHexValue(0, 0, 0);
+ return super.colorMultiplier(p_149720_1_, p_149720_2_, p_149720_3_, p_149720_4_);
}
@Override
@@ -240,7 +187,7 @@ public class BlockTankXpConverter extends BlockContainer {
@Override
public void randomDisplayTick(final World world, final int x, final int y, final int z, final Random rand) {
- this.mRainbowTick++;
+ //this.mRainbowTick++;
super.randomDisplayTick(world, x, y, z, rand);
}
@@ -251,36 +198,7 @@ public class BlockTankXpConverter extends BlockContainer {
@Override
public int getLightValue() {
- final int mTicker = this.mRainbowTick;
- if ((mTicker == 0) || (mTicker == 17)){
- return 1;
- }
- else if ((mTicker == 1) || (mTicker == 16)){
- return 2;
- }
- else if ((mTicker == 2) || (mTicker == 15)){
- return 3;
- }
- else if ((mTicker == 3) || (mTicker == 14)){
- return 4;
- }
- else if ((mTicker == 4) || (mTicker == 13)){
return 6;
- }
- else if ((mTicker == 5) || (mTicker == 12)){
- return 8;
- }
- else if ((mTicker == 6) || (mTicker == 11)){
- return 10;
- }
- else if ((mTicker == 7) || (mTicker == 10)){
- return 12;
- }
- else if ((mTicker == 8) || (mTicker == 9)){
- return 14;
- }
- return 0;
-
- }
+ }
}
diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockEntityBase.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockEntityBase.java
index 0ca5197ee0..e21e9ffdc6 100644
--- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockEntityBase.java
+++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockEntityBase.java
@@ -31,6 +31,7 @@ public class ItemBlockEntityBase extends ItemBlock {
if (Block.getBlockFromItem(stack.getItem()) instanceof BlockTankXpConverter){
list.add(EnumChatFormatting.GRAY+"Can convert Liquid Xp to Mob Essence and back.");
list.add(EnumChatFormatting.GRAY+"Right click with a Screwdriver to change mode.");
+ list.add(EnumChatFormatting.GRAY+"Shift+Right click to view tank information.");
}
else if (Block.getBlockFromItem(stack.getItem()) instanceof BlockTankXpConverter){
//list.add(EnumChatFormatting.GRAY+"A pile of " + materialName + " dust.");
diff --git a/src/Java/gtPlusPlus/core/material/Material.java b/src/Java/gtPlusPlus/core/material/Material.java
index 7d251c8682..01999ecbd4 100644
--- a/src/Java/gtPlusPlus/core/material/Material.java
+++ b/src/Java/gtPlusPlus/core/material/Material.java
@@ -945,7 +945,18 @@ public class Material {
final public int calculateMeltingPoint(){
try {
- int meltingPoint = 0;
+
+ AutoMap<Integer> aDataSet = new AutoMap<Integer>();
+ for (MaterialStack m : this.vMaterialInput) {
+ aDataSet.put(m.getStackMaterial().getMeltingPointC());
+ }
+ long aAverage = MathUtils.getAverage(aDataSet);
+ return MathUtils.safeInt(aAverage);
+
+
+
+
+ /*int meltingPoint = 0;
for (MaterialStack part : this.vMaterialInput){
if (part != null){
int incrementor = part.getStackMaterial().getMeltingPointC();
@@ -959,7 +970,7 @@ public class Material {
int divisor = (this.vMaterialInput.size()>0 ? this.vMaterialInput.size() : 1);
Logger.WARNING("Dividing "+meltingPoint+" / "+divisor+" to get average melting point.");
meltingPoint = (meltingPoint/divisor);
- return meltingPoint;
+ return meltingPoint;*/
}
catch (Throwable r){
return 500;
@@ -968,7 +979,16 @@ public class Material {
final public int calculateBoilingPoint(){
try {
- int boilingPoint = 0;
+
+ AutoMap<Integer> aDataSet = new AutoMap<Integer>();
+ for (MaterialStack m : this.vMaterialInput) {
+ aDataSet.put(m.getStackMaterial().getBoilingPointC());
+ }
+ long aAverage = MathUtils.getAverage(aDataSet);
+ return MathUtils.safeInt(aAverage);
+
+
+ /*int boilingPoint = 0;
for (MaterialStack part : this.vMaterialInput){
if (part != null){
boilingPoint += part.getStackMaterial().getBoilingPointC();
@@ -980,7 +1000,7 @@ public class Material {
}
int divisor = (this.vMaterialInput.size()>0 ? this.vMaterialInput.size() : 1);
boilingPoint = (boilingPoint/divisor);
- return boilingPoint;
+ return boilingPoint;*/
}
catch (Throwable r){
return 2500;
@@ -989,7 +1009,15 @@ public class Material {
final public long calculateProtons(){
try {
- long protonCount = 0;
+
+ AutoMap<Long> aDataSet = new AutoMap<Long>();
+ for (MaterialStack m : this.vMaterialInput) {
+ aDataSet.put(m.getStackMaterial().getProtons());
+ }
+ long aAverage = MathUtils.getAverage(aDataSet);
+ return aAverage;
+
+ /*long protonCount = 0;
for (MaterialStack part : this.vMaterialInput){
if (part != null){
protonCount += (part.getStackMaterial().getProtons());
@@ -1000,7 +1028,7 @@ public class Material {
}
int divisor = (this.vMaterialInput.size()>0 ? this.vMaterialInput.size() : 1);
protonCount = (protonCount/divisor);
- return protonCount;
+ return protonCount;*/
}
catch (Throwable r){
return 50;
@@ -1009,7 +1037,15 @@ public class Material {
final public long calculateNeutrons(){
try {
- long neutronCount = 0;
+
+ AutoMap<Long> aDataSet = new AutoMap<Long>();
+ for (MaterialStack m : this.vMaterialInput) {
+ aDataSet.put(m.getStackMaterial().getNeutrons());
+ }
+ long aAverage = MathUtils.getAverage(aDataSet);
+ return aAverage;
+
+ /*long neutronCount = 0;
for (MaterialStack part : this.vMaterialInput){
if (part != null){
neutronCount += (part.getStackMaterial().getNeutrons());
@@ -1020,7 +1056,7 @@ public class Material {
}
int divisor = (this.vMaterialInput.size()>0 ? this.vMaterialInput.size() : 1);
neutronCount = (neutronCount/divisor);
- return neutronCount;
+ return neutronCount;*/
}
catch (Throwable r){
return 75;
diff --git a/src/Java/gtPlusPlus/core/tileentities/base/TileBasicTank.java b/src/Java/gtPlusPlus/core/tileentities/base/TileBasicTank.java
new file mode 100644
index 0000000000..671a49fca5
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/tileentities/base/TileBasicTank.java
@@ -0,0 +1,150 @@
+package gtPlusPlus.core.tileentities.base;
+
+import gtPlusPlus.api.objects.minecraft.BTF_FluidTank;
+import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.FluidTankInfo;
+import net.minecraftforge.fluids.IFluidHandler;
+import net.minecraftforge.fluids.IFluidTank;
+
+public class TileBasicTank extends TileEntityBase implements IFluidHandler, IFluidTank {
+
+ public final BTF_FluidTank mTank;
+
+ public TileBasicTank(int aMaxSlots, int aFluidCapacity) {
+ super(aMaxSlots);
+ mTank = new BTF_FluidTank(aFluidCapacity);
+ }
+
+ @Override
+ public boolean onPreTick(long aTick) {
+
+ if (this.isServerSide()) {
+ if (mTank.isFluidChangingAllowed() && mTank.getFillableStack() != null
+ && mTank.getFillableStack().amount <= 0) {
+ mTank.setFillableStack((FluidStack) null);
+ }
+ }
+
+ return super.onPreTick(aTick);
+
+ }
+
+
+ private final boolean canFillEx(ForgeDirection aSide, Fluid aFluid) {
+ return this.fill(aSide, new FluidStack(aFluid, 1), false) == 1;
+ }
+
+
+ private final boolean canDrainEx(ForgeDirection aSide, Fluid aFluid) {
+ return this.drain(aSide, new FluidStack(aFluid, 1), false) != null;
+ }
+
+
+ private final FluidTankInfo[] getTankInfoEx(ForgeDirection aSide) {
+ return mTank.getCapacity() <= 0 ? new FluidTankInfo[0]
+ : new FluidTankInfo[]{mTank.getInfo()};
+ }
+
+ private final int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) {
+ return mTank.fill(aFluid, doFill);
+ }
+
+
+ private final int fillEx(ForgeDirection aSide, FluidStack aFluid, boolean doFill) {
+ return this.fill_default(aSide, aFluid, doFill);
+ }
+
+
+ private final FluidStack drainEx(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) {
+ return mTank.getFluid() != null && aFluid != null && mTank.getFluid().isFluidEqual(aFluid)
+ ? mTank.drain(aFluid.amount, doDrain)
+ : null;
+ }
+
+
+ private final FluidStack drainEx(ForgeDirection aSide, int maxDrain, boolean doDrain) {
+ return mTank.drain(maxDrain, doDrain);
+ }
+
+
+ public boolean isLiquidInput(byte aSide) {
+ return true;
+ }
+
+ public boolean isLiquidOutput(byte aSide) {
+ return true;
+ }
+
+ @Override
+ public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) {
+ if (mTickTimer > 5 && canAccessData() && (mRunningThroughTick || !mInputDisabled) && (aSide == ForgeDirection.UNKNOWN || (this.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 this.fillEx(aSide, aFluid, doFill);
+ return 0;
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection aSide, int maxDrain, boolean doDrain) {
+ if (mTickTimer > 5 && canAccessData() && (mRunningThroughTick || !mOutputDisabled) && (aSide == ForgeDirection.UNKNOWN || (this.isLiquidOutput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), this.getFluid() == null ? null : this.getFluid().getFluid(), this))))
+ return this.drainEx(aSide, maxDrain, doDrain);
+ return null;
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) {
+ if (mTickTimer > 5 && canAccessData() && (mRunningThroughTick || !mOutputDisabled) && (aSide == ForgeDirection.UNKNOWN || (this.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 this.drainEx(aSide, aFluid, doDrain);
+ return null;
+ }
+
+ @Override
+ public boolean canFill(ForgeDirection aSide, Fluid aFluid) {
+ if (mTickTimer > 5 && canAccessData() && (mRunningThroughTick || !mInputDisabled) && (aSide == ForgeDirection.UNKNOWN || (this.isLiquidInput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), aFluid, this))))
+ return this.canFillEx(aSide, aFluid);
+ return false;
+ }
+
+ @Override
+ public boolean canDrain(ForgeDirection aSide, Fluid aFluid) {
+ if (mTickTimer > 5 && canAccessData() && (mRunningThroughTick || !mOutputDisabled) && (aSide == ForgeDirection.UNKNOWN || (this.isLiquidOutput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), aFluid, this))))
+ return this.canDrainEx(aSide, aFluid);
+ return false;
+ }
+
+ @Override
+ public FluidTankInfo[] getTankInfo(ForgeDirection aSide) {
+ if (canAccessData() && (aSide == ForgeDirection.UNKNOWN || (this.isLiquidInput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), null, this)) || (this.isLiquidOutput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), null, this))))
+ return this.getTankInfoEx(aSide);
+ return new FluidTankInfo[]{};
+ }
+
+ @Override
+ public FluidStack getFluid() {
+ return mTank.getFluid();
+ }
+
+ @Override
+ public int getFluidAmount() {
+ return mTank.getFluidAmount();
+ }
+
+ @Override
+ public FluidTankInfo getInfo() {
+ return mTank.getInfo();
+ }
+
+ @Override
+ public int fill(FluidStack resource, boolean doFill) {
+ return mTank.fill(resource, doFill);
+ }
+
+ @Override
+ public FluidStack drain(int maxDrain, boolean doDrain) {
+ return mTank.drain(maxDrain, doDrain);
+ }
+
+
+
+
+}
diff --git a/src/Java/gtPlusPlus/core/tileentities/base/TileEntityBase.java b/src/Java/gtPlusPlus/core/tileentities/base/TileEntityBase.java
index 90c37e140a..c619cbb3ea 100644
--- a/src/Java/gtPlusPlus/core/tileentities/base/TileEntityBase.java
+++ b/src/Java/gtPlusPlus/core/tileentities/base/TileEntityBase.java
@@ -2,21 +2,48 @@ package gtPlusPlus.core.tileentities.base;
import java.util.UUID;
+import gregtech.GT_Mod;
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.GT_Values;
+import gregtech.api.interfaces.IDescribable;
+import gregtech.api.interfaces.tileentity.IGregTechDeviceInformation;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.net.GT_Packet_Block_Event;
+import gregtech.api.util.GT_CoverBehavior;
+import gregtech.api.util.GT_LanguageManager;
+import gregtech.api.util.GT_OreDictUnificator;
+import gregtech.api.util.GT_Utility;
+import net.minecraft.block.Block;
+import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.inventory.ISidedInventory;
+import net.minecraft.init.Blocks;
+import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
-
+import net.minecraft.world.World;
+import net.minecraft.world.biome.BiomeGenBase;
+import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraftforge.fluids.IFluidHandler;
+import gtPlusPlus.api.interfaces.ILazyCoverable;
import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.api.objects.minecraft.BTF_Inventory;
+import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils;
+import ic2.api.Direction;
-public abstract class TileEntityBase extends TileEntity implements ISidedInventory {
+public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregTechDeviceInformation, IDescribable {
private String customName;
public String mOwnerName = "null";
public String mOwnerUUID = "null";
private boolean mIsOwnerOP = false;
+ public final BTF_Inventory mInventory;
+
+ public TileEntityBase(int aCapacity) {
+ mInventory = new BTF_Inventory(aCapacity, this);
+ }
+
public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag){
if(!nbt.hasKey(tag))
{
@@ -27,13 +54,10 @@ public abstract class TileEntityBase extends TileEntity implements ISidedInvento
@Override
public void writeToNBT(final NBTTagCompound nbt){
-
super.writeToNBT(nbt);
-
if (this.hasCustomInventoryName()) {
nbt.setString("CustomName", this.getCustomName());
}
-
nbt.setBoolean("mIsOwnerOP", this.mIsOwnerOP);
nbt.setString("mOwnerName", this.mOwnerName);
nbt.setString("mOwnerUUID", this.mOwnerUUID);
@@ -55,9 +79,11 @@ public abstract class TileEntityBase extends TileEntity implements ISidedInvento
@Override
public void updateEntity() {
+ long aTick = System.currentTimeMillis();
+ this.isDead = false;
try{
if (this.isServerSide()){
- onPreTick();
+ onPreTick(aTick);
}
} catch (Throwable t){
Logger.ERROR("Tile Entity Encountered an error in it's pre-tick stage.");
@@ -65,7 +91,7 @@ public abstract class TileEntityBase extends TileEntity implements ISidedInvento
}
try{
if (this.isServerSide()){
- onTick();
+ onTick(aTick);
}
} catch (Throwable t){
Logger.ERROR("Tile Entity Encountered an error in it's tick stage.");
@@ -73,7 +99,7 @@ public abstract class TileEntityBase extends TileEntity implements ISidedInvento
}
try{
if (this.isServerSide()){
- onPostTick();
+ onPostTick(aTick);
}
} catch (Throwable t){
Logger.ERROR("Tile Entity Encountered an error in it's post-tick stage.");
@@ -81,11 +107,11 @@ public abstract class TileEntityBase extends TileEntity implements ISidedInvento
}
}
- public boolean onPreTick(){
+ public boolean onPreTick(long aTick) {
return true;
}
- public boolean onTick(){
+ public boolean onTick(long aTick){
try{
if (this.isServerSide()){
processRecipe();
@@ -97,11 +123,10 @@ public abstract class TileEntityBase extends TileEntity implements ISidedInvento
return true;
}
- public boolean onPostTick(){
-
+ public boolean onPostTick(long aTick){
return true;
}
-
+
public boolean processRecipe(){
return true;
}
@@ -145,6 +170,10 @@ public abstract class TileEntityBase extends TileEntity implements ISidedInvento
return false;
}
+ public final boolean isClientSide() {
+ return this.worldObj.isRemote;
+ }
+
public String getCustomName() {
return this.customName;
}
@@ -164,42 +193,1107 @@ public abstract class TileEntityBase extends TileEntity implements ISidedInvento
}
@Override
- public abstract int getSizeInventory();
+ public int getSizeInventory() {
+ return this.mInventory.getSizeInventory();
+ }
@Override
- public abstract ItemStack getStackInSlot(int p_70301_1_);
+ public ItemStack getStackInSlot(int aIndex) {
+ return this.mInventory.getStackInSlot(aIndex);
+ }
+
+ @Override
+ public ItemStack decrStackSize(int aIndex, int aAmount) {
+ if (canAccessData()) {
+ mInventoryChanged = true;
+ return mInventory.decrStackSize(aIndex, aAmount);
+ }
+ return null;
+ }
@Override
- public abstract ItemStack decrStackSize(int p_70298_1_, int p_70298_2_);
+ public ItemStack getStackInSlotOnClosing(int p_70304_1_) {
+ return this.mInventory.getStackInSlotOnClosing(p_70304_1_);
+ }
@Override
- public abstract ItemStack getStackInSlotOnClosing(int p_70304_1_);
+ public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) {
+ this.mInventory.setInventorySlotContents(p_70299_1_, p_70299_2_);
+ }
@Override
- public abstract void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_);
+ public int getInventoryStackLimit() {
+ return this.mInventory.getInventoryStackLimit();
+ }
@Override
- public abstract int getInventoryStackLimit();
+ public boolean isUseableByPlayer(EntityPlayer p_70300_1_) {
+ return this.mInventory.isUseableByPlayer(p_70300_1_);
+ }
@Override
- public abstract boolean isUseableByPlayer(EntityPlayer p_70300_1_);
+ public void openInventory() {
+ this.mInventory.openInventory();
+ }
@Override
- public abstract void openInventory();
+ public void closeInventory() {
+ this.mInventory.closeInventory();
+ }
+
+ /**
+ * Can put aStack into Slot
+ */
+ @Override
+ public boolean isItemValidForSlot(int aIndex, ItemStack aStack) {
+ return canAccessData() && mInventory.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 mInventory.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) && mInventory.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) && mInventory.canExtractItem(aIndex, aStack, aSide);
+ }
+
@Override
- public abstract void closeInventory();
+ public boolean isValidSlot(int aIndex) {
+ return this.canAccessData() ? this.mInventory.isValidSlot(aIndex) : false;
+ }
+
+
+
+
+ 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 TileEntityBase mMetaTileEntity;
+ protected long mStoredEnergy = 0;
+ protected int mAverageEUInputIndex = 0, mAverageEUOutputIndex = 0;
+ protected boolean mReleaseEnergy = false;
+ protected int[] mAverageEUInput = new int[11], mAverageEUOutput = new int[11];
+ 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;
+ protected boolean mRunningThroughTick = false;
+ protected boolean mInputDisabled = false;
+ protected boolean mOutputDisabled = false;
+ private boolean mMuffler = false;
+ private boolean mLockUpgrade = false;
+ private boolean mActive = false;
+ private boolean mRedstone = false;
+ private boolean mWorkUpdate = false;
+ private boolean mSteamConverter = false;
+ private boolean mInventoryChanged = false;
+ private boolean mWorks = true;
+ private boolean mNeedsUpdate = true;
+ private boolean mNeedsBlockUpdate = true;
+ private boolean mSendClientData = false;
+ private boolean oRedstone = false;
+ private boolean mEnergyStateReady = false;
+ private byte mColor = 0, oColor = 0, mStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0,
+ oTexturePage = 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;
+ protected long mTickTimer = 0;
+ private long oOutput = 0;
+ private long mAcceptedAmperes = Long.MAX_VALUE;
+
+
+ /**
+ * Cover Support
+ */
+
+ public void issueClientUpdate() {
+ this.mSendClientData = true;
+ }
+
+ protected final boolean canAccessData() {
+ return !isDead() && !this.isInvalid();
+ }
@Override
- public abstract boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_);
+ public void issueBlockUpdate() {
+ super.markDirty();
+ }
+ @Override
+ public void issueCoverUpdate(byte aSide) {
+ this.issueClientUpdate();
+ }
+
@Override
- public abstract int[] getAccessibleSlotsFromSide(int p_94128_1_);
+ public long getTimer() {
+ return this.mTickTimer;
+ }
+
+
+
+
+
+
+
+ public long getOutputAmperage() {
+ return this.canAccessData() && this.mMetaTileEntity.isElectric() ? this.mMetaTileEntity.maxAmperesOut() : 0L;
+ }
+
+ public long getOutputVoltage() {
+ return this.canAccessData() && this.mMetaTileEntity.isElectric() && this.mMetaTileEntity.isEnetOutput()
+ ? this.mMetaTileEntity.maxEUOutput()
+ : 0L;
+ }
+
+ public long getInputAmperage() {
+ return this.canAccessData() && this.mMetaTileEntity.isElectric() ? this.mMetaTileEntity.maxAmperesIn() : 0L;
+ }
+
+ public long getInputVoltage() {
+ return this.canAccessData() && this.mMetaTileEntity.isElectric()
+ ? this.mMetaTileEntity.maxEUInput()
+ : 2147483647L;
+ }
@Override
- public abstract boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_);
+ public boolean decreaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooLessEnergy) {
+ return !this.canAccessData() ? false : (this.mHasEnoughEnergy = this.decreaseStoredEU(aEnergy, aIgnoreTooLessEnergy));
+ }
@Override
- public abstract boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_);
+ public boolean increaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooMuchEnergy) {
+ if (!this.canAccessData()) {
+ return false;
+ } else if (this.getStoredEU() >= this.getEUCapacity() && !aIgnoreTooMuchEnergy) {
+ return false;
+ } else {
+ this.setStoredEU(this.mMetaTileEntity.getEUVar() + aEnergy);
+ return true;
+ }
+ }
+
+ @Override
+ public boolean inputEnergyFrom(byte aSide) {
+ return aSide == 6
+ ? true
+ : (!this.isServerSide()
+ ? this.isEnergyInputSide(aSide)
+ : aSide >= 0 && aSide < 6 && this.mActiveEUInputs[aSide] && !this.mReleaseEnergy);
+ }
+
+ @Override
+ public boolean outputsEnergyTo(byte aSide) {
+ return aSide == 6
+ ? true
+ : (!this.isServerSide()
+ ? this.isEnergyOutputSide(aSide)
+ : aSide >= 0 && aSide < 6 && this.mActiveEUOutputs[aSide] || this.mReleaseEnergy);
+ }
+
+ private boolean isEnergyInputSide(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(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;
+ }
+
+ public boolean isOutputFacing(byte aSide) {
+ return false;
+ }
+
+ public boolean isInputFacing(byte aSide) {
+ return false;
+ }
+
+ private final TileEntity[] mBufferedTileEntities = new TileEntity[6];
+ public boolean ignoreUnloadedChunks = true;
+ public boolean isDead = false;
+
+ private final void clearNullMarkersFromTileEntityBuffer() {
+ for (int i = 0; i < this.mBufferedTileEntities.length; ++i) {
+ if (this.mBufferedTileEntities[i] == this) {
+ this.mBufferedTileEntities[i] = null;
+ }
+ }
+
+ }
+
+ protected final void clearTileEntityBuffer() {
+ for (int i = 0; i < this.mBufferedTileEntities.length; ++i) {
+ this.mBufferedTileEntities[i] = null;
+ }
+
+ }
+
+ public final World getWorld() {
+ return this.worldObj;
+ }
+
+ public final int getXCoord() {
+ return this.xCoord;
+ }
+
+ public final short getYCoord() {
+ return (short) this.yCoord;
+ }
+
+ public final int getZCoord() {
+ return this.zCoord;
+ }
+
+ public final int getOffsetX(byte aSide, int aMultiplier) {
+ return this.xCoord + ForgeDirection.getOrientation(aSide).offsetX * aMultiplier;
+ }
+
+ public final short getOffsetY(byte aSide, int aMultiplier) {
+ return (short) (this.yCoord + ForgeDirection.getOrientation(aSide).offsetY * aMultiplier);
+ }
+
+ public final int getOffsetZ(byte aSide, int aMultiplier) {
+ return this.zCoord + ForgeDirection.getOrientation(aSide).offsetZ * aMultiplier;
+ }
+
+ public final boolean openGUI(EntityPlayer aPlayer) {
+ return this.openGUI(aPlayer, 0);
+ }
+
+ public final boolean openGUI(EntityPlayer aPlayer, int aID) {
+ if (aPlayer == null) {
+ return false;
+ } else {
+ aPlayer.openGui(GT_Values.GT, aID, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
+ return true;
+ }
+ }
+
+ public final int getRandomNumber(int aRange) {
+ return this.worldObj.rand.nextInt(aRange);
+ }
+
+ public final BiomeGenBase getBiome(int aX, int aZ) {
+ return this.worldObj.getBiomeGenForCoords(aX, aZ);
+ }
+
+ public final BiomeGenBase getBiome() {
+ return this.getBiome(this.xCoord, this.zCoord);
+ }
+
+ public final Block getBlockOffset(int aX, int aY, int aZ) {
+ return this.getBlock(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ);
+ }
+
+ public final Block getBlockAtSide(byte aSide) {
+ return this.getBlockAtSideAndDistance(aSide, 1);
+ }
+
+ public final Block getBlockAtSideAndDistance(byte aSide, int aDistance) {
+ return this.getBlock(this.getOffsetX(aSide, aDistance), this.getOffsetY(aSide, aDistance),
+ this.getOffsetZ(aSide, aDistance));
+ }
+
+ public final byte getMetaIDOffset(int aX, int aY, int aZ) {
+ return this.getMetaID(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ);
+ }
+
+ public final byte getMetaIDAtSide(byte aSide) {
+ return this.getMetaIDAtSideAndDistance(aSide, 1);
+ }
+
+ public final byte getMetaIDAtSideAndDistance(byte aSide, int aDistance) {
+ return this.getMetaID(this.getOffsetX(aSide, aDistance), this.getOffsetY(aSide, aDistance),
+ this.getOffsetZ(aSide, aDistance));
+ }
+
+ public final byte getLightLevelOffset(int aX, int aY, int aZ) {
+ return this.getLightLevel(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ);
+ }
+
+ public final byte getLightLevelAtSide(byte aSide) {
+ return this.getLightLevelAtSideAndDistance(aSide, 1);
+ }
+
+ public final byte getLightLevelAtSideAndDistance(byte aSide, int aDistance) {
+ return this.getLightLevel(this.getOffsetX(aSide, aDistance), this.getOffsetY(aSide, aDistance),
+ this.getOffsetZ(aSide, aDistance));
+ }
+
+ public final boolean getOpacityOffset(int aX, int aY, int aZ) {
+ return this.getOpacity(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ);
+ }
+
+ public final boolean getOpacityAtSide(byte aSide) {
+ return this.getOpacityAtSideAndDistance(aSide, 1);
+ }
+
+ public final boolean getOpacityAtSideAndDistance(byte aSide, int aDistance) {
+ return this.getOpacity(this.getOffsetX(aSide, aDistance), this.getOffsetY(aSide, aDistance),
+ this.getOffsetZ(aSide, aDistance));
+ }
+
+ public final boolean getSkyOffset(int aX, int aY, int aZ) {
+ return this.getSky(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ);
+ }
+
+ public final boolean getSkyAtSide(byte aSide) {
+ return this.getSkyAtSideAndDistance(aSide, 1);
+ }
+
+ public final boolean getSkyAtSideAndDistance(byte aSide, int aDistance) {
+ return this.getSky(this.getOffsetX(aSide, aDistance), this.getOffsetY(aSide, aDistance),
+ this.getOffsetZ(aSide, aDistance));
+ }
+
+ public final boolean getAirOffset(int aX, int aY, int aZ) {
+ return this.getAir(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ);
+ }
+
+ public final boolean getAirAtSide(byte aSide) {
+ return this.getAirAtSideAndDistance(aSide, 1);
+ }
+
+ public final boolean getAirAtSideAndDistance(byte aSide, int aDistance) {
+ return this.getAir(this.getOffsetX(aSide, aDistance), this.getOffsetY(aSide, aDistance),
+ this.getOffsetZ(aSide, aDistance));
+ }
+
+ public final TileEntity getTileEntityOffset(int aX, int aY, int aZ) {
+ return this.getTileEntity(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ);
+ }
+
+ public final TileEntity getTileEntityAtSideAndDistance(byte aSide, int aDistance) {
+ return aDistance == 1
+ ? this.getTileEntityAtSide(aSide)
+ : this.getTileEntity(this.getOffsetX(aSide, aDistance), this.getOffsetY(aSide, aDistance),
+ this.getOffsetZ(aSide, aDistance));
+ }
+
+ public final IInventory getIInventory(int aX, int aY, int aZ) {
+ TileEntity tTileEntity = this.getTileEntity(aX, aY, aZ);
+ return tTileEntity instanceof IInventory ? (IInventory) tTileEntity : null;
+ }
+
+ public final IInventory getIInventoryOffset(int aX, int aY, int aZ) {
+ TileEntity tTileEntity = this.getTileEntityOffset(aX, aY, aZ);
+ return tTileEntity instanceof IInventory ? (IInventory) tTileEntity : null;
+ }
+
+ public final IInventory getIInventoryAtSide(byte aSide) {
+ TileEntity tTileEntity = this.getTileEntityAtSide(aSide);
+ return tTileEntity instanceof IInventory ? (IInventory) tTileEntity : null;
+ }
+
+ public final IInventory getIInventoryAtSideAndDistance(byte aSide, int aDistance) {
+ TileEntity tTileEntity = this.getTileEntityAtSideAndDistance(aSide, aDistance);
+ return tTileEntity instanceof IInventory ? (IInventory) tTileEntity : null;
+ }
+
+ public final IFluidHandler getITankContainer(int aX, int aY, int aZ) {
+ TileEntity tTileEntity = this.getTileEntity(aX, aY, aZ);
+ return tTileEntity instanceof IFluidHandler ? (IFluidHandler) tTileEntity : null;
+ }
+
+ public final IFluidHandler getITankContainerOffset(int aX, int aY, int aZ) {
+ TileEntity tTileEntity = this.getTileEntityOffset(aX, aY, aZ);
+ return tTileEntity instanceof IFluidHandler ? (IFluidHandler) tTileEntity : null;
+ }
+
+ public final IFluidHandler getITankContainerAtSide(byte aSide) {
+ TileEntity tTileEntity = this.getTileEntityAtSide(aSide);
+ return tTileEntity instanceof IFluidHandler ? (IFluidHandler) tTileEntity : null;
+ }
+
+ public final IFluidHandler getITankContainerAtSideAndDistance(byte aSide, int aDistance) {
+ TileEntity tTileEntity = this.getTileEntityAtSideAndDistance(aSide, aDistance);
+ return tTileEntity instanceof IFluidHandler ? (IFluidHandler) tTileEntity : null;
+ }
+
+ public final IGregTechTileEntity getIGregTechTileEntity(int aX, int aY, int aZ) {
+ TileEntity tTileEntity = this.getTileEntity(aX, aY, aZ);
+ return tTileEntity instanceof IGregTechTileEntity ? (IGregTechTileEntity) tTileEntity : null;
+ }
+
+ public final IGregTechTileEntity getIGregTechTileEntityOffset(int aX, int aY, int aZ) {
+ TileEntity tTileEntity = this.getTileEntityOffset(aX, aY, aZ);
+ return tTileEntity instanceof IGregTechTileEntity ? (IGregTechTileEntity) tTileEntity : null;
+ }
+
+ public final IGregTechTileEntity getIGregTechTileEntityAtSide(byte aSide) {
+ TileEntity tTileEntity = this.getTileEntityAtSide(aSide);
+ return tTileEntity instanceof IGregTechTileEntity ? (IGregTechTileEntity) tTileEntity : null;
+ }
+
+ public final IGregTechTileEntity getIGregTechTileEntityAtSideAndDistance(byte aSide, int aDistance) {
+ TileEntity tTileEntity = this.getTileEntityAtSideAndDistance(aSide, aDistance);
+ return tTileEntity instanceof IGregTechTileEntity ? (IGregTechTileEntity) tTileEntity : null;
+ }
+
+ public final Block getBlock(int aX, int aY, int aZ) {
+ return this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ)
+ ? Blocks.air
+ : this.worldObj.getBlock(aX, aY, aZ);
+ }
+
+ public final byte getMetaID(int aX, int aY, int aZ) {
+ return this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ)
+ ? 0
+ : (byte) this.worldObj.getBlockMetadata(aX, aY, aZ);
+ }
+
+ public final byte getLightLevel(int aX, int aY, int aZ) {
+ return this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ)
+ ? 0
+ : (byte) ((int) (this.worldObj.getLightBrightness(aX, aY, aZ) * 15.0F));
+ }
+
+ public final boolean getSky(int aX, int aY, int aZ) {
+ return this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ)
+ ? true
+ : this.worldObj.canBlockSeeTheSky(aX, aY, aZ);
+ }
+
+ public final boolean getOpacity(int aX, int aY, int aZ) {
+ return this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ)
+ ? false
+ : GT_Utility.isOpaqueBlock(this.worldObj, aX, aY, aZ);
+ }
+
+ public final boolean getAir(int aX, int aY, int aZ) {
+ return this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ)
+ ? true
+ : GT_Utility.isBlockAir(this.worldObj, aX, aY, aZ);
+ }
+
+ public final TileEntity getTileEntity(int aX, int aY, int aZ) {
+ return this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ)
+ ? null
+ : this.worldObj.getTileEntity(aX, aY, aZ);
+ }
+
+ public final TileEntity getTileEntityAtSide(byte aSide) {
+ if (aSide >= 0 && aSide < 6 && this.mBufferedTileEntities[aSide] != this) {
+ int tX = this.getOffsetX(aSide, 1);
+ short tY = this.getOffsetY(aSide, 1);
+ int tZ = this.getOffsetZ(aSide, 1);
+ if (this.crossedChunkBorder(tX, tZ)) {
+ this.mBufferedTileEntities[aSide] = null;
+ if (this.ignoreUnloadedChunks && !this.worldObj.blockExists(tX, tY, tZ)) {
+ return null;
+ }
+ }
+
+ if (this.mBufferedTileEntities[aSide] == null) {
+ this.mBufferedTileEntities[aSide] = this.worldObj.getTileEntity(tX, tY, tZ);
+ if (this.mBufferedTileEntities[aSide] == null) {
+ this.mBufferedTileEntities[aSide] = this;
+ return null;
+ } else {
+ return this.mBufferedTileEntities[aSide];
+ }
+ } else if (this.mBufferedTileEntities[aSide].isInvalid()) {
+ this.mBufferedTileEntities[aSide] = null;
+ return this.getTileEntityAtSide(aSide);
+ } else {
+ return this.mBufferedTileEntities[aSide].xCoord == tX && this.mBufferedTileEntities[aSide].yCoord == tY
+ && this.mBufferedTileEntities[aSide].zCoord == tZ ? this.mBufferedTileEntities[aSide] : null;
+ }
+ } else {
+ return null;
+ }
+ }
+
+ public boolean isDead() {
+ return this.isDead || this.isInvalidTileEntity();
+ }
+
+ public void validate() {
+ this.clearNullMarkersFromTileEntityBuffer();
+ super.validate();
+ }
+
+ public void invalidate() {
+ this.clearNullMarkersFromTileEntityBuffer();
+ super.invalidate();
+ }
+
+ public void onChunkUnload() {
+ this.clearNullMarkersFromTileEntityBuffer();
+ super.onChunkUnload();
+ this.isDead = true;
+ }
+
+ public final void onAdjacentBlockChange(int aX, int aY, int aZ) {
+ this.clearNullMarkersFromTileEntityBuffer();
+ }
+
+ public final void sendBlockEvent(byte aID, byte aValue) {
+ GT_Values.NW.sendPacketToAllPlayersInRange(this.worldObj,
+ new GT_Packet_Block_Event(this.xCoord, (short) this.yCoord, this.zCoord, aID, aValue), this.xCoord,
+ this.zCoord);
+ }
+
+ private boolean crossedChunkBorder(int aX, int aZ) {
+ return aX >> 4 != this.xCoord >> 4 || aZ >> 4 != this.zCoord >> 4;
+ }
+
+ public final void setOnFire() {
+ GT_Utility.setCoordsOnFire(this.worldObj, this.xCoord, this.yCoord, this.zCoord, false);
+ }
+
+ public final void setToFire() {
+ this.worldObj.setBlock(this.xCoord, this.yCoord, this.zCoord, Blocks.fire);
+ }
+
+ public String trans(String aKey, String aEnglish) {
+ return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_" + aKey, aEnglish, false);
+ }
+
+ @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] : getGeneralRS(aSide);
+ }
+
+ public boolean allowGeneralRedstoneOutput() {
+ return false;
+ }
+
+ public byte getGeneralRS(byte aSide){
+ return allowGeneralRedstoneOutput() ? mSidedRedstone[aSide] : 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 hasInventoryBeenModified() {
+ return mInventoryChanged;
+ }
+
+ @Override
+ public void setGenericRedstoneOutput(boolean aOnOff) {
+ mRedstone = aOnOff;
+ }
+
+ @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 i = 0; i < mAverageEUInput.length; i++) {
+ if (i != mAverageEUInputIndex)
+ rEU += mAverageEUInput[i];
+ }
+ return rEU / (mAverageEUInput.length - 1);
+ }
+
+ @Override
+ public long getAverageElectricOutput() {
+ int rEU = 0;
+ for (int i = 0; i < mAverageEUOutput.length; i++) {
+ if (i != mAverageEUOutputIndex)
+ rEU += mAverageEUOutput[i];
+ }
+ return rEU / (mAverageEUOutput.length - 1);
+ }
+
+ public boolean hasSidedRedstoneOutputBehavior() {
+ return false;
+ }
+
+ @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;
+ }
+
+ public String getOwnerName() {
+ if (GT_Utility.isStringInvalid(mOwnerName)) return "Player";
+ return mOwnerName;
+ }
+
+ 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 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;
+ }
+
+
+ public double getOutputEnergyUnitsPerTick() {
+ return oOutput;
+ }
+
+
+ public boolean isTeleporterCompatible(ForgeDirection aSide) {
+ return false;
+ }
+
+
+ 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 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 void markDirty() {
+ super.markDirty();
+ mInventoryChanged = true;
+ }
+
+
+
+ /**
+ * To Do
+ */
+
+ public boolean isElectric() {
+ return true;
+ }
+
+ public boolean isEnetOutput() {
+ return false;
+ }
+
+ public boolean isEnetInput() {
+ return false;
+ }
+
+ public long maxEUStore() {
+ return 0L;
+ }
+
+ public long maxEUInput() {
+ return 0L;
+ }
+
+ public long maxEUOutput() {
+ return 0L;
+ }
+
+ public long maxAmperesOut() {
+ return 1L;
+ }
+
+ public long maxAmperesIn() {
+ return 1L;
+ }
+
+ public void doEnergyExplosion() {
+ if (this.getUniversalEnergyCapacity() > 0L
+ && this.getUniversalEnergyStored() >= this.getUniversalEnergyCapacity() / 5L) {
+ this.doExplosion(this.oOutput * (long) (this.getUniversalEnergyStored() >= this.getUniversalEnergyCapacity()
+ ? 4
+ : (this.getUniversalEnergyStored() >= this.getUniversalEnergyCapacity() / 2L ? 2 : 1)));
+ GT_Mod arg9999 = GT_Mod.instance;
+ GT_Mod.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(this.mOwnerName),
+ "electricproblems");
+ }
+
+ }
+
+ public void doExplosion(long aAmount) {
+ if (this.canAccessData()) {
+ if (GregTech_API.sMachineWireFire && this.mMetaTileEntity.isElectric()) {
+ try {
+ this.mReleaseEnergy = true;
+ Util.emitEnergyToNetwork(GT_Values.V[5], Math.max(1L, this.getStoredEU() / GT_Values.V[5]), this);
+ } catch (Exception arg4) {
+ }
+ }
+ this.mReleaseEnergy = false;
+ this.onExplosion();
+ PollutionUtils.addPollution(this, 100000);
+ this.mMetaTileEntity.doExplosion(aAmount);
+ }
+
+ }
+
+ public void onExplosion() {
+
+ }
+
+ @Override
+ public String[] getDescription() {
+ return this.canAccessData() ? this.mMetaTileEntity.getDescription() : new String[0];
+ }
+
+ @Override
+ public boolean isGivingInformation() {
+ return true;
+ }
+
+ @Override
+ public String[] getInfoData() {
+ return null;
+ }
+
+ public long getEUVar() {
+ return this.mStoredEnergy;
+ }
+
+ public void setEUVar(long aEnergy) {
+ this.mStoredEnergy = aEnergy;
+ }
+
+ public long getStoredEU() {
+ return this.canAccessData() ? Math.min(this.mMetaTileEntity.getEUVar(), this.getEUCapacity()) : 0L;
+ }
+
+ public long getEUCapacity() {
+ return this.canAccessData() ? this.mMetaTileEntity.maxEUStore() : 0L;
+ }
+
+ public long getMinimumStoredEU() {
+ return 512L;
+ }
+
+ public boolean setStoredEU(long aEnergy) {
+ if (!this.canAccessData()) {
+ return false;
+ } else {
+ if (aEnergy < 0L) {
+ aEnergy = 0L;
+ }
+
+ this.mMetaTileEntity.setEUVar(aEnergy);
+ return true;
+ }
+ }
+
+ public boolean decreaseStoredEU(long aEnergy, boolean aIgnoreTooLessEnergy) {
+ if (!this.canAccessData()) {
+ return false;
+ } else if (this.mMetaTileEntity.getEUVar() - aEnergy < 0L && !aIgnoreTooLessEnergy) {
+ return false;
+ } else {
+ this.setStoredEU(this.mMetaTileEntity.getEUVar() - aEnergy);
+ if (this.mMetaTileEntity.getEUVar() < 0L) {
+ this.setStoredEU(0L);
+ return false;
+ } else {
+ return true;
+ }
+ }
+ }
+
+
+
} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/tileentities/base/TilePoweredGT.java b/src/Java/gtPlusPlus/core/tileentities/base/TilePoweredGT.java
index e607dac40d..fb599b0bae 100644
--- a/src/Java/gtPlusPlus/core/tileentities/base/TilePoweredGT.java
+++ b/src/Java/gtPlusPlus/core/tileentities/base/TilePoweredGT.java
@@ -1,4 +1,4 @@
-package gtPlusPlus.core.tileentities.base;
+/*package gtPlusPlus.core.tileentities.base;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
@@ -804,33 +804,33 @@ public abstract class TilePoweredGT extends TileEntityBase implements IGregtechP
@Override
- public boolean onPreTick() {
+ public boolean onPreTick(long aTick) {
return onPreTick(this, this.mTickTimer);
}
@Override
- public boolean onTick() {
+ public boolean onTick(long aTick) {
return onTick(this, this.mTickTimer);
}
@Override
- public boolean onPostTick() {
+ public boolean onPostTick(long aTick) {
return onPostTick(this, this.mTickTimer);
}
@Override
public boolean onPreTick(TilePoweredGT tilePoweredGT, long mTickTimer2) {
- return super.onPreTick();
+ return super.onPreTick(mTickTimer2);
}
@Override
public boolean onTick(TilePoweredGT iGregTechTileEntity, long mTickTimer2) {
- return super.onTick();
+ return super.onTick(mTickTimer2);
}
@Override
public boolean onPostTick(TilePoweredGT iGregTechTileEntity, long mTickTimer2) {
- return super.onPostTick();
+ return super.onPostTick(mTickTimer2);
}
@Override
@@ -861,7 +861,7 @@ public abstract class TilePoweredGT extends TileEntityBase implements IGregtechP
int tCode = 0;
final boolean aSideServer = this.isServerSide();
final boolean aSideClient = this.isClientSide();
- /*try {
+ try {
for (tCode = 0; this.hasValidMetaTileEntity() && tCode >= 0; tCode = -1) {
Label_1743 : {
switch (tCode) {
@@ -1139,7 +1139,7 @@ public abstract class TilePoweredGT extends TileEntityBase implements IGregtechP
final boolean mWorkUpdate = false;
this.mRunningThroughTick = mWorkUpdate;
this.mInventoryChanged = mWorkUpdate;
- this.mWorkUpdate = mWorkUpdate;*/
+ this.mWorkUpdate = mWorkUpdate;
}
private void onFirstTick(TilePoweredGT tilePoweredGT) {
@@ -1165,3 +1165,4 @@ public abstract class TilePoweredGT extends TileEntityBase implements IGregtechP
}
}
+*/ \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java
index 403d331151..2816596515 100644
--- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java
+++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java
@@ -7,24 +7,21 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
-import net.minecraft.tileentity.TileEntity;
-
-import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.api.objects.minecraft.BTF_FluidTank;
+import gtPlusPlus.core.tileentities.base.TileBasicTank;
import gtPlusPlus.core.util.minecraft.EnchantingUtils;
import gtPlusPlus.core.util.minecraft.PlayerUtils;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.*;
-public class TileEntityXpConverter extends TileEntity implements IFluidHandler {
+public class TileEntityXpConverter extends TileBasicTank {
- public FluidTank tankEssence = new FluidTank((int) (64000*EnchantingUtils.RATIO_MOB_ESSENCE_TO_LIQUID_XP));
- public FluidTank tankLiquidXp = new FluidTank(64000);
- private boolean needsUpdate = false;
+ public BTF_FluidTank tankEssence = new BTF_FluidTank((int) (64000*EnchantingUtils.RATIO_MOB_ESSENCE_TO_LIQUID_XP));
+ public BTF_FluidTank tankLiquidXp = new BTF_FluidTank(64000);
private boolean mConvertToEssence = true;
- private int updateTimer = 0;
- private long mTickTime = 0;
public TileEntityXpConverter() {
+ super (4, 32000);
}
private void changeMode(){
@@ -36,278 +33,266 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler {
this.mConvertToEssence = true;
return;
}
- }
-
- private boolean isServerSide(){
- if (this.getWorldObj().isRemote){
- return false;
- }
- else {
- return true;
- }
- }
+ }
- @Override
- public int fill(final ForgeDirection from, final FluidStack resource, final boolean doFill) {
- this.needsUpdate = true;
- Logger.WARNING("Ticking. | mConvertToEssence: "+this.mConvertToEssence);
+ public float getAdjustedVolume() {
if (this.mConvertToEssence){
- if (resource.isFluidEqual(EnchantingUtils.getLiquidXP(1))){
- Logger.WARNING("fill(tankLiquidXp)");
- return this.tankLiquidXp.fill(resource, doFill);
- }
- else {
- Logger.WARNING("Looking for Liquid Xp, Instead found "+resource.getLocalizedName()+".");
+ if ((this.tankLiquidXp.getFluid() != null) && (this.tankLiquidXp.getFluidAmount() >= 100) && (this.tankEssence.getFluidAmount() <= (this.tankEssence.getCapacity()-(100*EnchantingUtils.RATIO_MOB_ESSENCE_TO_LIQUID_XP)))){
+ final FluidStack bigStorage = EnchantingUtils.getEssenceFromLiquidXp(100);
+ this.tankEssence.fill(bigStorage, true);
+ this.tankLiquidXp.drain(100, true);
+ return (this.tankEssence.getCapacity()-this.tankEssence.getFluidAmount());
}
}
else {
- if (resource.isFluidEqual(EnchantingUtils.getMobEssence(1))){
- Logger.WARNING("fill(tankEssence)");
- return this.tankEssence.fill(resource, doFill);
- }
- else {
- Logger.WARNING("Looking for Essence, Instead found "+resource.getLocalizedName()+".");
+ final double rm = EnchantingUtils.RATIO_MOB_ESSENCE_TO_LIQUID_XP;
+ if ((this.tankEssence.getFluid() != null) && (this.tankEssence.getFluidAmount() >= rm) && (this.tankLiquidXp.getFluidAmount() <= (this.tankLiquidXp.getCapacity()-rm))){
+ final FluidStack bigStorage = EnchantingUtils.getLiquidXP(1);
+ this.tankLiquidXp.fill(bigStorage, true);
+ this.tankEssence.drain((int) rm, true);
+ return (this.tankLiquidXp.getCapacity()-this.tankLiquidXp.getFluidAmount());
}
- }
- Logger.WARNING("fill(0)");
- return 0;
+ }
+ return 0f;
}
@Override
- public FluidStack drain(final ForgeDirection from, final FluidStack resource, final boolean doDrain) {
- this.needsUpdate = true;
- if (this.mConvertToEssence){
- if (resource.isFluidEqual(EnchantingUtils.getMobEssence(1))){
- Logger.WARNING("drain(mConvertToEssence)");
- return this.tankEssence.drain(resource.amount, doDrain);
- }
- }
- else {
- if (resource.isFluidEqual(EnchantingUtils.getLiquidXP(1))){
- Logger.WARNING("drain(tankLiquidXp)");
- return this.tankLiquidXp.drain(resource.amount, doDrain);
- }
- }
- Logger.WARNING("drain(null)");
- return null;
+ public void readFromNBT(final NBTTagCompound tag) {
+ this.tankEssence.readFromNBT(tag);
+ this.tankLiquidXp.readFromNBT(tag);
+ this.mConvertToEssence = tag.getBoolean("mConvertToEssence");
+ super.readFromNBT(tag);
}
@Override
- public FluidStack drain(final ForgeDirection from, final int maxDrain, final boolean doDrain) {
- this.needsUpdate = true;
- Logger.WARNING("drain(Ex)");
- final FluidStack fluid_Essence = this.tankEssence.getFluid();
- final FluidStack fluid_Xp = this.tankLiquidXp.getFluid();
- if ((fluid_Essence == null) && (fluid_Xp == null)) {
- return null;
- }
+ public void writeToNBT(final NBTTagCompound tag) {
+ this.tankEssence.writeToNBT(tag);
+ this.tankLiquidXp.writeToNBT(tag);
+ tag.setBoolean("mConvertToEssence", this.mConvertToEssence);
+ super.writeToNBT(tag);
+ }
- FluidStack fluid;
- FluidTank tank;
+ @Override
+ public Packet getDescriptionPacket() {
+ final NBTTagCompound tag = new NBTTagCompound();
+ this.writeToNBT(tag);
+ return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, this.blockMetadata, tag);
+ }
- if (this.mConvertToEssence){
- fluid = fluid_Essence;
- tank = this.tankEssence;
- }
- else {
- fluid = fluid_Xp;
- tank = this.tankLiquidXp;
- }
+ @Override
+ public void onDataPacket(final NetworkManager net, final S35PacketUpdateTileEntity pkt) {
+ final NBTTagCompound tag = pkt.func_148857_g();
+ this.readFromNBT(tag);
+ }
- int drained = maxDrain;
- if (fluid.amount < drained) {
- drained = fluid.amount;
+ public void onScrewdriverRightClick(final byte aSide, final EntityPlayer aPlayer, final float aX, final float aY, final float aZ) {
+ if (this.isServerSide()){
+ if (this.mConvertToEssence){
+ PlayerUtils.messagePlayer(aPlayer, "Converting from Mob Essence to Liquid Xp.");
+ }
+ else {
+ PlayerUtils.messagePlayer(aPlayer, "Converting from Liquid Xp to Mob Essence.");
+ }
+ //Mode Change
+ this.changeMode();
}
+ }
- final FluidStack stack = new FluidStack(fluid, drained);
- if (doDrain) {
- fluid.amount -= drained;
- if (fluid.amount <= 0) {
- fluid = null;
- }
+ public void onRightClick(final byte aSide, final EntityPlayer aPlayer, final int aX, final int aY, final int aZ) {
+ if ((Keyboard.isKeyDown(42)) || (Keyboard.isKeyDown(54))) {
+ String mInput;
+ String mOutput;
- if (this != null) {
- FluidEvent.fireEvent(new FluidEvent.FluidDrainingEvent(fluid, this.getWorldObj(), this.xCoord,
- this.yCoord, this.zCoord, tank, 0));
+ if (this.mConvertToEssence){
+ mInput = "Liquid Xp";
+ mOutput = "Mob Essence";
+ }
+ else {
+ mInput = "Mob Essence";
+ mOutput = "Liquid Xp";
}
- }
+ PlayerUtils.messagePlayer(aPlayer, "Input: "+mInput+".");
+ PlayerUtils.messagePlayer(aPlayer, "Output: "+mOutput+".");
+ }
+ }
- if (this.mConvertToEssence){
- this.tankEssence = tank;
+ @Override
+ public boolean onPreTick(long aTick) {
+ boolean aSuperResult = super.onPreTick(aTick);
+ long aTankSpaceLeft = 0;
+ double aAmount = 0;
+ int aRuns = 0;
+ if (this.mConvertToEssence) {
+ aTankSpaceLeft = (this.tankEssence.getCapacity()-this.tankEssence.getFluidAmount());
+ aAmount = EnchantingUtils.getEssenceFromLiquidXp(100).amount;
}
else {
- this.tankLiquidXp = tank;
+ aTankSpaceLeft = (this.tankLiquidXp.getCapacity()-this.tankLiquidXp.getFluidAmount());
+ aAmount = EnchantingUtils.RATIO_MOB_ESSENCE_TO_LIQUID_XP;
}
-
- Logger.WARNING("drain(Ex2)");
- return stack;
+ aRuns = (int) (aTankSpaceLeft / aAmount);
+ for (int i=0;i<aRuns;i++) {
+ if (getAdjustedVolume() == 0) {
+ break;
+ }
+ }
+ return aSuperResult;
}
@Override
- public boolean canFill(final ForgeDirection from, final Fluid fluid) {
- if (this.mConvertToEssence){
- if (this.tankEssence.getFluidAmount() < this.tankEssence.getCapacity()){
- Logger.WARNING("canFill(mConvertToEssence)");
- return true;
+ public boolean isLiquidInput(byte aSide) {
+ if (mConvertToEssence) {
+ if (aSide == 0 || aSide == 1) {
+ return false;
}
- }
- else {
- if (this.tankLiquidXp.getFluidAmount() < this.tankLiquidXp.getCapacity()){
- Logger.WARNING("canFill(tankLiquidXp)");
+ } else {
+ if (aSide == 0 || aSide == 1) {
return true;
}
}
- Logger.WARNING("canFill(false)");
return false;
}
@Override
- public boolean canDrain(final ForgeDirection from, final Fluid fluid) {
- if (this.mConvertToEssence){
- if (this.tankEssence.getFluidAmount() > 0){
+ public boolean isLiquidOutput(byte aSide) {
+ if (mConvertToEssence) {
+ if (aSide == 0 || aSide == 1) {
return true;
}
- }
- else {
- if (this.tankLiquidXp.getFluidAmount() > 0){
- return true;
+ } else {
+ if (aSide == 0 || aSide == 1) {
+ return false;
}
}
- Logger.WARNING("canDrain(false)");
return false;
}
@Override
- public FluidTankInfo[] getTankInfo(final ForgeDirection from) {
- if (this.mConvertToEssence){
- return new FluidTankInfo[] { this.tankEssence.getInfo() };
- }
- else {
- return new FluidTankInfo[] { this.tankLiquidXp.getInfo() };
+ public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) {
+ if (mConvertToEssence) {
+ if (aSide != ForgeDirection.UP && aSide != ForgeDirection.DOWN) {
+ return this.tankLiquidXp.fill(aFluid, doFill);
+ }
+ } else {
+ if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) {
+ return this.tankEssence.fill(aFluid, doFill);
+ }
}
+ return 0;
}
- public float getAdjustedVolume() {
- Logger.WARNING("AdjustedVolume()");
- this.needsUpdate = true;
- final float amount = this.tankLiquidXp.getFluidAmount();
- final float capacity = this.tankLiquidXp.getCapacity();
- final float volume = (amount / capacity) * 0.8F;
- return volume;
+ @Override
+ public FluidStack drain(ForgeDirection aSide, int maxDrain, boolean doDrain) {
+ if (mConvertToEssence) {
+ if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) {
+ return this.tankEssence.drain(maxDrain, doDrain);
+ }
+ } else {
+ if (aSide != ForgeDirection.UP && aSide != ForgeDirection.DOWN) {
+ return this.tankLiquidXp.drain(maxDrain, doDrain);
+ }
+ }
+ return null;
}
@Override
- public void updateEntity() {
-
- if (this.isServerSide()){
- this.mTickTime++;
-
- if (this.needsUpdate) {
- if (this.updateTimer == 0) {
- this.updateTimer = 10; // every 10 ticks it will send an update
- } else {
- --this.updateTimer;
- if (this.updateTimer == 0) {
- this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
- this.needsUpdate = false;
- }
- }
+ public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) {
+ if (mConvertToEssence) {
+ if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) {
+ return this.tankEssence.drain(aFluid, doDrain);
}
+ } else {
+ if (aSide != ForgeDirection.UP && aSide != ForgeDirection.DOWN) {
+ return this.tankLiquidXp.drain(aFluid, doDrain);
+ }
+ }
+ return null;
+ }
-
- if (this.mConvertToEssence){
- if ((this.tankLiquidXp.getFluid() != null) && (this.tankLiquidXp.getFluidAmount() >= 100) && (this.tankEssence.getFluidAmount() <= (this.tankEssence.getCapacity()-(100*EnchantingUtils.RATIO_MOB_ESSENCE_TO_LIQUID_XP)))){
- final FluidStack bigStorage = EnchantingUtils.getEssenceFromLiquidXp(100);
- this.tankEssence.fill(bigStorage, true);
- this.tankLiquidXp.drain(100, true);
- this.needsUpdate = true;
- Logger.WARNING("B->A");
- }
+ @Override
+ public boolean canFill(ForgeDirection aSide, Fluid aFluid) {
+ if (mConvertToEssence) {
+ if (aSide != ForgeDirection.UP && aSide != ForgeDirection.DOWN) {
+ return this.tankLiquidXp.canTankBeFilled();
}
- else {
- final double rm = EnchantingUtils.RATIO_MOB_ESSENCE_TO_LIQUID_XP;
- if ((this.tankEssence.getFluid() != null) && (this.tankEssence.getFluidAmount() >= rm) && (this.tankLiquidXp.getFluidAmount() <= (this.tankLiquidXp.getCapacity()-rm))){
- final FluidStack bigStorage = EnchantingUtils.getLiquidXP(1);
- this.tankLiquidXp.fill(bigStorage, true);
- this.tankEssence.drain((int) rm, true);
- this.needsUpdate = true;
- Logger.WARNING("A->B");
- }
+ } else {
+ if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) {
+ return this.tankEssence.canTankBeFilled();
}
}
- else {
- }
- this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
- this.markDirty();
-
- if ((this.mTickTime % 20) == 0){
+ return false;
+ }
+ @Override
+ public boolean canDrain(ForgeDirection aSide, Fluid aFluid) {
+ if (mConvertToEssence) {
+ if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) {
+ return this.tankEssence.canTankBeEmptied();
+ }
+ } else {
+ if (aSide != ForgeDirection.UP && aSide != ForgeDirection.DOWN) {
+ return this.tankLiquidXp.canTankBeEmptied();
+ }
}
-
+ return false;
}
@Override
- public void readFromNBT(final NBTTagCompound tag) {
- this.tankEssence.readFromNBT(tag);
- this.tankLiquidXp.readFromNBT(tag);
- this.mConvertToEssence = tag.getBoolean("mConvertToEssence");
- super.readFromNBT(tag);
+ public FluidTankInfo[] getTankInfo(ForgeDirection aSide) {
+ if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) {
+ return new FluidTankInfo[] { this.tankEssence.getInfo() };
+ } else {
+ return new FluidTankInfo[] { this.tankLiquidXp.getInfo() };
+
+ }
}
@Override
- public void writeToNBT(final NBTTagCompound tag) {
- this.tankEssence.writeToNBT(tag);
- this.tankLiquidXp.writeToNBT(tag);
- tag.setBoolean("mConvertToEssence", this.mConvertToEssence);
- super.writeToNBT(tag);
+ public FluidStack getFluid() {
+ if (mConvertToEssence) {
+ return this.tankEssence.getFluid();
+ }
+ else {
+ return this.tankLiquidXp.getFluid();
+ }
}
@Override
- public Packet getDescriptionPacket() {
- final NBTTagCompound tag = new NBTTagCompound();
- this.writeToNBT(tag);
- return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, this.blockMetadata, tag);
+ public int getFluidAmount() {
+ if (mConvertToEssence) {
+ return this.tankEssence.getFluidAmount();
+ }
+ else {
+ return this.tankLiquidXp.getFluidAmount();
+ }
}
@Override
- public void onDataPacket(final NetworkManager net, final S35PacketUpdateTileEntity pkt) {
- final NBTTagCompound tag = pkt.func_148857_g();
- this.readFromNBT(tag);
+ public FluidTankInfo getInfo() {
+ if (mConvertToEssence) {
+ return this.tankEssence.getInfo();
+ } else {
+ return this.tankLiquidXp.getInfo();
+ }
}
- public void onScrewdriverRightClick(final byte aSide, final EntityPlayer aPlayer, final float aX, final float aY, final float aZ) {
- if (this.isServerSide()){
- if (this.mConvertToEssence){
- PlayerUtils.messagePlayer(aPlayer, "Converting from Mob Essence to Liquid Xp.");
- }
- else {
- PlayerUtils.messagePlayer(aPlayer, "Converting from Liquid Xp to Mob Essence.");
- }
- //Mode Change
- this.changeMode();
+ @Override
+ public int fill(FluidStack resource, boolean doFill) {
+ if (mConvertToEssence) {
+ return this.tankEssence.fill(resource, doFill);
+ } else {
+ return this.tankLiquidXp.fill(resource, doFill);
}
}
- public void onRightClick(final byte aSide, final EntityPlayer aPlayer, final int aX, final int aY, final int aZ) {
-
- if ((Keyboard.isKeyDown(42)) || (Keyboard.isKeyDown(54))) {
- String mInput;
- String mOutput;
-
- if (this.mConvertToEssence){
- mInput = "Liquid Xp";
- mOutput = "Mob Essence";
- }
- else {
- mInput = "Mob Essence";
- mOutput = "Liquid Xp";
- }
-
- PlayerUtils.messagePlayer(aPlayer, "Input: "+mInput+".");
- PlayerUtils.messagePlayer(aPlayer, "Output: "+mOutput+".");
+ @Override
+ public FluidStack drain(int maxDrain, boolean doDrain) {
+ if (mConvertToEssence) {
+ return this.tankEssence.drain(maxDrain, doDrain);
+ } else {
+ return this.tankLiquidXp.drain(maxDrain, doDrain);
}
-
}
}
diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityModularityTable.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityModularityTable.java
index a97447420a..8ba43bb197 100644
--- a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityModularityTable.java
+++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityModularityTable.java
@@ -35,6 +35,7 @@ public class TileEntityModularityTable extends TileEntityBase implements ISidedI
private int mRecipeTimeRemaining = -1;
public TileEntityModularityTable() {
+ super(16);
this.inventoryGrid = new InventoryModularMain();
this.inventoryOutputs = new InventoryModularOutput();
this.mTempRecipeStorage = new InventoryModularOutput();
@@ -363,7 +364,7 @@ public class TileEntityModularityTable extends TileEntityBase implements ISidedI
@Override
public String getInventoryName() {
- return this.hasCustomInventoryName() ? this.customName : "container.fishrap";
+ return this.hasCustomInventoryName() ? this.customName : "container.fishtrap";
}
@Override
@@ -372,7 +373,7 @@ public class TileEntityModularityTable extends TileEntityBase implements ISidedI
}
@Override
- public boolean onPreTick() {
+ public boolean onPreTick(long aTick) {
//Check for active recipe
if (this.mRecipeTimeRemaining > -1 || (this.mTempRecipeStorage != null) && (this.mTempRecipeStorage.getRecipeTime() > -1)){
if ((this.mTempRecipeStorage != null) && this.mTempRecipeStorage.getRecipeTime() > -1){
@@ -393,7 +394,7 @@ public class TileEntityModularityTable extends TileEntityBase implements ISidedI
}
@Override
- public boolean onPostTick() {
+ public boolean onPostTick(long aTick) {
if (mRecipeTimeRemaining == 0){
this.inventoryOutputs.setInventorySlotContents(2, this.getPendingOutputItem());
clearRecipeData();
diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityTradeTable.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityTradeTable.java
index d766d0d02e..ad7ec3d0b3 100644
--- a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityTradeTable.java
+++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityTradeTable.java
@@ -18,6 +18,7 @@ public class TileEntityTradeTable extends TileEntityBase {
private Container_TradeTable container;
public TileEntityTradeTable(){
+ super(2);
this.inventoryGrid = new InventoryTradeMain();//number of slots - without product slot
this.inventoryOutputs = new InventoryTradeOutput();//number of slots - without product slot
}
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 fad65535ad..db787c5e80 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
@@ -14,9 +14,11 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
+import gregtech.common.GT_Pollution;
import gregtech.api.util.GT_Utility;
import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils;
import net.minecraftforge.fluids.FluidStack;
public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_BasicTank {
@@ -56,8 +58,19 @@ public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_
@Override
- public String[] getDescription() {
- return new String[]{this.mDescription, "Fuel Efficiency: " + this.getEfficiency() + "%", CORE.GT_Tooltip};
+ public String[] getDescription() {
+ if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) {
+ String aPollution = "Causes " + getPollution() + " Pollution per second";
+ return new String[]{
+ this.mDescription,
+ "Fuel Efficiency: " + this.getEfficiency() + "%",
+ aPollution,
+ CORE.GT_Tooltip};
+ }
+ return new String[]{
+ this.mDescription,
+ "Fuel Efficiency: " + this.getEfficiency() + "%",
+ CORE.GT_Tooltip};
}
@@ -209,6 +222,7 @@ public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_
else {
this.useFuel = true;
}
+ PollutionUtils.addPollution(getBaseMetaTileEntity(), 10 * getPollution());
}
}
}
@@ -219,6 +233,7 @@ public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_
if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), tEmptyContainer)) {
aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true);
aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1);
+ PollutionUtils.addPollution(getBaseMetaTileEntity(), 10 * getPollution());
}
}
}
@@ -229,6 +244,8 @@ public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_
}
}
+ public abstract int getPollution();
+
public abstract GT_Recipe_Map getRecipes();
public abstract int getEfficiency();
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java
index 3afd6e838b..b3a1fb4cee 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java
@@ -14,7 +14,7 @@ import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_Recipe;
-
+import gregtech.common.tileentities.generators.GT_MetaTileEntity_DieselGenerator;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators.GregtechRocketFuelGeneratorBase;
import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock;
@@ -142,4 +142,8 @@ extends GregtechRocketFuelGeneratorBase {
public ITexture[] getSidesActive(final byte aColor) {
return new ITexture[]{super.getSidesActive(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Horizontal_Active)};
}
+
+ public int getPollution() {
+ return (int) (GT_MetaTileEntity_DieselGenerator.BASE_POLLUTION * Math.pow(8, mTier + 1));
+ }
}