diff options
| author | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2018-09-14 13:47:51 +1000 |
|---|---|---|
| committer | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2018-09-14 13:47:51 +1000 |
| commit | 678a32be304bcffe457cf869ba6c5d57bdc1b2e1 (patch) | |
| tree | 1db1454a7f2dcb3453370cea0ca995ec9188a9d2 /src/Java/gtPlusPlus/core | |
| parent | 84cce1bba9a1091f2428ebee464cbfdf57491def (diff) | |
| download | GT5-Unofficial-678a32be304bcffe457cf869ba6c5d57bdc1b2e1.tar.gz GT5-Unofficial-678a32be304bcffe457cf869ba6c5d57bdc1b2e1.tar.bz2 GT5-Unofficial-678a32be304bcffe457cf869ba6c5d57bdc1b2e1.zip | |
$ Fixed the XP Convertor.
% Rewrote base tile entity system.
% Added hashCode() to Pair.java.
% Changed some calculations on Materials.
% Made Rocket Engines produce heavy pollution.
Diffstat (limited to 'src/Java/gtPlusPlus/core')
9 files changed, 1527 insertions, 340 deletions
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; |
