From 7d1f51a8937e0a86486267437d444696e81e8aa0 Mon Sep 17 00:00:00 2001 From: Jakub <53441451+kuba6000@users.noreply.github.com> Date: Mon, 29 Aug 2022 16:04:28 +0200 Subject: Buildscript + Spotless (#318) * Convert AES.java to readable class * Buildscript * Spotless --- .../core/tileentities/ModTileEntities.java | 75 +- .../core/tileentities/base/TILE_ENTITY_BASE.java | 56 +- .../core/tileentities/base/TileBasicTank.java | 278 +-- .../core/tileentities/base/TileEntityBase.java | 2017 ++++++++++---------- .../core/tileentities/base/TilePoweredGT.java | 95 +- .../general/TileEntityCircuitProgrammer.java | 578 +++--- .../general/TileEntityDecayablesChest.java | 692 +++---- .../tileentities/general/TileEntityEggBox.java | 692 +++---- .../tileentities/general/TileEntityFirepit.java | 48 +- .../tileentities/general/TileEntityFishTrap.java | 797 ++++---- .../general/TileEntityHeliumGenerator.java | 224 ++- .../general/TileEntityInfiniteFluid.java | 249 ++- .../general/TileEntityPlayerDoorBase.java | 487 +++-- .../tileentities/general/TileEntityReverter.java | 558 +++--- .../general/TileEntityVolumetricFlaskSetter.java | 764 ++++---- .../general/TileEntityXpConverter.java | 518 +++-- .../redstone/TileEntityRedstoneHandler.java | 762 ++++---- .../machines/TileEntityAdvPooCollector.java | 231 +-- .../machines/TileEntityBaseFluidCollector.java | 411 ++-- .../machines/TileEntityModularityTable.java | 922 +++++---- .../machines/TileEntityPestKiller.java | 927 +++++---- .../machines/TileEntityPooCollector.java | 216 +-- .../machines/TileEntityProjectTable.java | 558 +++--- .../machines/TileEntityRoundRobinator.java | 1348 +++++++------ .../machines/TileEntityTradeTable.java | 235 ++- 25 files changed, 6828 insertions(+), 6910 deletions(-) (limited to 'src/main/java/gtPlusPlus/core/tileentities') diff --git a/src/main/java/gtPlusPlus/core/tileentities/ModTileEntities.java b/src/main/java/gtPlusPlus/core/tileentities/ModTileEntities.java index 0fcbb6a576..1ec58b0813 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/ModTileEntities.java +++ b/src/main/java/gtPlusPlus/core/tileentities/ModTileEntities.java @@ -26,42 +26,43 @@ import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; public class ModTileEntities { - public static void init() { - Logger.INFO("Registering Tile Entities."); - GameRegistry.registerTileEntity(TileEntityPooCollector.class, "TileEntityPooCollector"); - GameRegistry.registerTileEntity(TileEntityAdvPooCollector.class, "TileEntityAdvPooCollector"); - GameRegistry.registerTileEntity(TileEntityFishTrap.class, "TileFishTrap"); - GameRegistry.registerTileEntity(TileEntityFirepit.class, "TileFirePit"); - GameRegistry.registerTileEntity(TileEntityInfiniteFluid.class, "TileInfiniteFluid"); - GameRegistry.registerTileEntity(TileEntityProjectTable.class, "TileProjectTable"); - GameRegistry.registerTileEntity(TileEntityTradeTable.class, "TileTradeTable"); - GameRegistry.registerTileEntity(TileEntityModularityTable.class, "TileEntityModularityTable"); - GameRegistry.registerTileEntity(TileEntityXpConverter.class, "TileEntityXpConverter"); - GameRegistry.registerTileEntity(TileEntityGenericSpawner.class, "TileEntityGenericSpawner"); - GameRegistry.registerTileEntity(TileEntityCircuitProgrammer.class, "TileCircuitProgrammer"); - GameRegistry.registerTileEntity(TileEntityPlayerDoorBase.class, "TilePlayerDoorBase"); - GameRegistry.registerTileEntity(TileEntityDecayablesChest.class, "TileDecayablesChest"); - GameRegistry.registerTileEntity(TileEntitySuperJukebox.class, "TileEntitySuperJukebox"); - GameRegistry.registerTileEntity(TileEntitySuperLight.class, "TileEntitySuperLight"); - GameRegistry.registerTileEntity(TileEntityPestKiller.class, "TileEntityPestKiller"); - GameRegistry.registerTileEntity(TileEntityRoundRobinator.class, "TileEntityRoundRobinator"); - GameRegistry.registerTileEntity(TileEntityEggBox.class, "TileEggBox"); - - if (Meta_GT_Proxy.sDoesVolumetricFlaskExist) { - GameRegistry.registerTileEntity(TileEntityVolumetricFlaskSetter.class, "TileEntityVolumetricFlaskSetter"); - } - - //Mod TEs - if (LoadedMods.Thaumcraft){ - - } - blacklistTilesFromAcceleration(); - } - - private static void blacklistTilesFromAcceleration() { - Meta_GT_Proxy.setTileEntityClassAsBlacklistedInWorldAccelerator("gtPlusPlus.core.tileentities.general.TileEntityFishTrap"); - Meta_GT_Proxy.setTileEntityClassAsBlacklistedInWorldAccelerator("gtPlusPlus.core.tileentities.general.TileEntityDecayablesChest"); - Meta_GT_Proxy.setTileEntityClassAsBlacklistedInWorldAccelerator("gtPlusPlus.core.tileentities.general.TileEggBox"); - } + public static void init() { + Logger.INFO("Registering Tile Entities."); + GameRegistry.registerTileEntity(TileEntityPooCollector.class, "TileEntityPooCollector"); + GameRegistry.registerTileEntity(TileEntityAdvPooCollector.class, "TileEntityAdvPooCollector"); + GameRegistry.registerTileEntity(TileEntityFishTrap.class, "TileFishTrap"); + GameRegistry.registerTileEntity(TileEntityFirepit.class, "TileFirePit"); + GameRegistry.registerTileEntity(TileEntityInfiniteFluid.class, "TileInfiniteFluid"); + GameRegistry.registerTileEntity(TileEntityProjectTable.class, "TileProjectTable"); + GameRegistry.registerTileEntity(TileEntityTradeTable.class, "TileTradeTable"); + GameRegistry.registerTileEntity(TileEntityModularityTable.class, "TileEntityModularityTable"); + GameRegistry.registerTileEntity(TileEntityXpConverter.class, "TileEntityXpConverter"); + GameRegistry.registerTileEntity(TileEntityGenericSpawner.class, "TileEntityGenericSpawner"); + GameRegistry.registerTileEntity(TileEntityCircuitProgrammer.class, "TileCircuitProgrammer"); + GameRegistry.registerTileEntity(TileEntityPlayerDoorBase.class, "TilePlayerDoorBase"); + GameRegistry.registerTileEntity(TileEntityDecayablesChest.class, "TileDecayablesChest"); + GameRegistry.registerTileEntity(TileEntitySuperJukebox.class, "TileEntitySuperJukebox"); + GameRegistry.registerTileEntity(TileEntitySuperLight.class, "TileEntitySuperLight"); + GameRegistry.registerTileEntity(TileEntityPestKiller.class, "TileEntityPestKiller"); + GameRegistry.registerTileEntity(TileEntityRoundRobinator.class, "TileEntityRoundRobinator"); + GameRegistry.registerTileEntity(TileEntityEggBox.class, "TileEggBox"); + if (Meta_GT_Proxy.sDoesVolumetricFlaskExist) { + GameRegistry.registerTileEntity(TileEntityVolumetricFlaskSetter.class, "TileEntityVolumetricFlaskSetter"); + } + + // Mod TEs + if (LoadedMods.Thaumcraft) {} + + blacklistTilesFromAcceleration(); + } + + private static void blacklistTilesFromAcceleration() { + Meta_GT_Proxy.setTileEntityClassAsBlacklistedInWorldAccelerator( + "gtPlusPlus.core.tileentities.general.TileEntityFishTrap"); + Meta_GT_Proxy.setTileEntityClassAsBlacklistedInWorldAccelerator( + "gtPlusPlus.core.tileentities.general.TileEntityDecayablesChest"); + Meta_GT_Proxy.setTileEntityClassAsBlacklistedInWorldAccelerator( + "gtPlusPlus.core.tileentities.general.TileEggBox"); + } } diff --git a/src/main/java/gtPlusPlus/core/tileentities/base/TILE_ENTITY_BASE.java b/src/main/java/gtPlusPlus/core/tileentities/base/TILE_ENTITY_BASE.java index 839bcc353a..ff1484a984 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/base/TILE_ENTITY_BASE.java +++ b/src/main/java/gtPlusPlus/core/tileentities/base/TILE_ENTITY_BASE.java @@ -8,32 +8,32 @@ import net.minecraft.tileentity.TileEntity; public class TILE_ENTITY_BASE extends TileEntity { - @Override - public void writeToNBT(final NBTTagCompound tag) { - super.writeToNBT(tag); - this.writeCustomNBT(tag); - } - - @Override - public void readFromNBT(final NBTTagCompound tag) { - super.readFromNBT(tag); - this.readCustomNBT(tag); - } - - public void writeCustomNBT(final NBTTagCompound tag) {} - public void readCustomNBT(final NBTTagCompound tag) {} - - @Override - public Packet getDescriptionPacket() { - final NBTTagCompound tag = new NBTTagCompound(); - this.writeCustomNBT(tag); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, -999, tag); - } - - @Override - public void onDataPacket(final NetworkManager net, final S35PacketUpdateTileEntity packet) { - super.onDataPacket(net, packet); - this.readCustomNBT(packet.func_148857_g()); - } - + @Override + public void writeToNBT(final NBTTagCompound tag) { + super.writeToNBT(tag); + this.writeCustomNBT(tag); + } + + @Override + public void readFromNBT(final NBTTagCompound tag) { + super.readFromNBT(tag); + this.readCustomNBT(tag); + } + + public void writeCustomNBT(final NBTTagCompound tag) {} + + public void readCustomNBT(final NBTTagCompound tag) {} + + @Override + public Packet getDescriptionPacket() { + final NBTTagCompound tag = new NBTTagCompound(); + this.writeCustomNBT(tag); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, -999, tag); + } + + @Override + public void onDataPacket(final NetworkManager net, final S35PacketUpdateTileEntity packet) { + super.onDataPacket(net, packet); + this.readCustomNBT(packet.func_148857_g()); + } } diff --git a/src/main/java/gtPlusPlus/core/tileentities/base/TileBasicTank.java b/src/main/java/gtPlusPlus/core/tileentities/base/TileBasicTank.java index 671a49fca5..32a39a7096 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/base/TileBasicTank.java +++ b/src/main/java/gtPlusPlus/core/tileentities/base/TileBasicTank.java @@ -10,141 +10,197 @@ 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 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); + 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); + 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); + 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); + 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); + 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); - } - - - - + 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/main/java/gtPlusPlus/core/tileentities/base/TileEntityBase.java b/src/main/java/gtPlusPlus/core/tileentities/base/TileEntityBase.java index 5b67a318be..f52ce86a99 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/base/TileEntityBase.java +++ b/src/main/java/gtPlusPlus/core/tileentities/base/TileEntityBase.java @@ -1,7 +1,5 @@ package gtPlusPlus.core.tileentities.base; -import java.util.UUID; - import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; @@ -14,6 +12,12 @@ import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; import gregtech.api.util.ISerializableObject; +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; +import java.util.UUID; import net.minecraft.block.Block; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -26,186 +30,182 @@ 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.data.ArrayUtils; -import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; -import ic2.api.Direction; 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)) - { - nbt.setTag(tag, new NBTTagCompound()); - } - return nbt.getCompoundTag(tag); - } - - @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); - } - - @Override - public void readFromNBT(final NBTTagCompound nbt){ - - super.readFromNBT(nbt); - - if (nbt.hasKey("CustomName", 8)) { - this.setCustomName(nbt.getString("CustomName")); - } - - this.mIsOwnerOP = nbt.getBoolean("mIsOwnerOP"); - this.mOwnerName = nbt.getString("mOwnerName"); - this.mOwnerUUID = nbt.getString("mOwnerUUID"); - } - - @Override - public void updateEntity() { - long aTick = System.currentTimeMillis(); - this.isDead = false; - if (!firstTicked) { - onFirstTick(); - } - try{ - if (this.isServerSide()){ - onPreTick(aTick); - } - } catch (Throwable t){ - Logger.ERROR("Tile Entity Encountered an error in it's pre-tick stage."); - t.printStackTrace(); - } - try{ - if (this.isServerSide()){ - onTick(aTick); - } - } catch (Throwable t){ - Logger.ERROR("Tile Entity Encountered an error in it's tick stage."); - t.printStackTrace(); - } - try{ - if (this.isServerSide()){ - onPostTick(aTick); - } - } catch (Throwable t){ - Logger.ERROR("Tile Entity Encountered an error in it's post-tick stage."); - t.printStackTrace(); - } - } - - public boolean onPreTick(long aTick) { - return true; - } - - public boolean onTick(long aTick){ - try{ - if (this.isServerSide()){ - processRecipe(); - } - } catch (Throwable t){ - Logger.ERROR("Tile Entity Encountered an error in it's processing of a recipe stage."); - t.printStackTrace(); - } - return true; - } - - public boolean onPostTick(long aTick){ - return true; - } - - public boolean processRecipe(){ - return true; - } - - @Override - public boolean canUpdate() { - return true; - } - - public String getOwner(){ - if (this.mOwnerName == null){ - return "null"; - } - return this.mOwnerName; - } - - public UUID getOwnerUUID(){ - return UUID.fromString(this.mOwnerUUID); - } - - public boolean isOwnerOP() { - return mIsOwnerOP; - } - - public void setOwnerInformation(String mName, String mUUID, boolean mOP){ - if (isServerSide()){ - if (this.mOwnerName == null || this.mOwnerUUID == null || this.mOwnerName.equals("null") || this.mOwnerUUID.equals("null")){ - this.mOwnerName = mName; - this.mOwnerUUID = mUUID; - this.mIsOwnerOP = mOP; - } - } - } - - public boolean isServerSide(){ - if (this.hasWorldObj()){ - if (!this.getWorldObj().isRemote){ - return true; - } - } - return false; - } - - public final boolean isClientSide() { - return this.worldObj.isRemote; - } - - public String getCustomName() { - return this.customName; - } - - public void setCustomName(String customName) { - this.customName = customName; - } - - @Override - public String getInventoryName() { - return this.hasCustomInventoryName() ? this.customName : "container.tileentity.name"; - } - - @Override - public boolean hasCustomInventoryName() { - return this.customName != null && !this.customName.equals(""); - } - - @Override - public int getSizeInventory() { - return this.mInventory.getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(int aIndex) { - return this.mInventory.getStackInSlot(aIndex); - } + 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)) { + nbt.setTag(tag, new NBTTagCompound()); + } + return nbt.getCompoundTag(tag); + } + + @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); + } + + @Override + public void readFromNBT(final NBTTagCompound nbt) { + + super.readFromNBT(nbt); + + if (nbt.hasKey("CustomName", 8)) { + this.setCustomName(nbt.getString("CustomName")); + } + + this.mIsOwnerOP = nbt.getBoolean("mIsOwnerOP"); + this.mOwnerName = nbt.getString("mOwnerName"); + this.mOwnerUUID = nbt.getString("mOwnerUUID"); + } + + @Override + public void updateEntity() { + long aTick = System.currentTimeMillis(); + this.isDead = false; + if (!firstTicked) { + onFirstTick(); + } + try { + if (this.isServerSide()) { + onPreTick(aTick); + } + } catch (Throwable t) { + Logger.ERROR("Tile Entity Encountered an error in it's pre-tick stage."); + t.printStackTrace(); + } + try { + if (this.isServerSide()) { + onTick(aTick); + } + } catch (Throwable t) { + Logger.ERROR("Tile Entity Encountered an error in it's tick stage."); + t.printStackTrace(); + } + try { + if (this.isServerSide()) { + onPostTick(aTick); + } + } catch (Throwable t) { + Logger.ERROR("Tile Entity Encountered an error in it's post-tick stage."); + t.printStackTrace(); + } + } + + public boolean onPreTick(long aTick) { + return true; + } + + public boolean onTick(long aTick) { + try { + if (this.isServerSide()) { + processRecipe(); + } + } catch (Throwable t) { + Logger.ERROR("Tile Entity Encountered an error in it's processing of a recipe stage."); + t.printStackTrace(); + } + return true; + } + + public boolean onPostTick(long aTick) { + return true; + } + + public boolean processRecipe() { + return true; + } + + @Override + public boolean canUpdate() { + return true; + } + + public String getOwner() { + if (this.mOwnerName == null) { + return "null"; + } + return this.mOwnerName; + } + + public UUID getOwnerUUID() { + return UUID.fromString(this.mOwnerUUID); + } + + public boolean isOwnerOP() { + return mIsOwnerOP; + } + + public void setOwnerInformation(String mName, String mUUID, boolean mOP) { + if (isServerSide()) { + if (this.mOwnerName == null + || this.mOwnerUUID == null + || this.mOwnerName.equals("null") + || this.mOwnerUUID.equals("null")) { + this.mOwnerName = mName; + this.mOwnerUUID = mUUID; + this.mIsOwnerOP = mOP; + } + } + } + + public boolean isServerSide() { + if (this.hasWorldObj()) { + if (!this.getWorldObj().isRemote) { + return true; + } + } + return false; + } + + public final boolean isClientSide() { + return this.worldObj.isRemote; + } + + public String getCustomName() { + return this.customName; + } + + public void setCustomName(String customName) { + this.customName = customName; + } + + @Override + public String getInventoryName() { + return this.hasCustomInventoryName() ? this.customName : "container.tileentity.name"; + } + + @Override + public boolean hasCustomInventoryName() { + return this.customName != null && !this.customName.equals(""); + } + + @Override + public int getSizeInventory() { + return this.mInventory.getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(int aIndex) { + return this.mInventory.getStackInSlot(aIndex); + } @Override public ItemStack decrStackSize(int aIndex, int aAmount) { @@ -216,37 +216,37 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT return null; } - @Override - public ItemStack getStackInSlotOnClosing(int p_70304_1_) { - return this.mInventory.getStackInSlotOnClosing(p_70304_1_); - } + @Override + public ItemStack getStackInSlotOnClosing(int p_70304_1_) { + return this.mInventory.getStackInSlotOnClosing(p_70304_1_); + } - @Override - public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) { - this.mInventory.setInventorySlotContents(p_70299_1_, p_70299_2_); - } + @Override + public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) { + this.mInventory.setInventorySlotContents(p_70299_1_, p_70299_2_); + } - @Override - public int getInventoryStackLimit() { - return this.mInventory.getInventoryStackLimit(); - } + @Override + public int getInventoryStackLimit() { + return this.mInventory.getInventoryStackLimit(); + } - @Override - public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { - return this.mInventory.isUseableByPlayer(p_70300_1_); - } + @Override + public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { + return this.mInventory.isUseableByPlayer(p_70300_1_); + } - @Override - public void openInventory() { - this.mInventory.openInventory(); - } + @Override + public void openInventory() { + this.mInventory.openInventory(); + } - @Override - public void closeInventory() { - this.mInventory.closeInventory(); - } + @Override + public void closeInventory() { + this.mInventory.closeInventory(); + } - /** + /** * Can put aStack into Slot */ @Override @@ -260,8 +260,21 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT */ @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); + 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]; } @@ -270,7 +283,16 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT */ @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); + return canAccessData() + && (mRunningThroughTick || !mInputDisabled) + && getCoverBehaviorAtSide((byte) aSide) + .letsItemsIn( + (byte) aSide, + getCoverIDAtSide((byte) aSide), + getCoverDataAtSide((byte) aSide), + aIndex, + this) + && mInventory.canInsertItem(aIndex, aStack, aSide); } /** @@ -278,566 +300,612 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT */ @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 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; - } - + 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 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 void issueBlockUpdate() { - super.markDirty(); - } - - @Override - public void issueCoverUpdate(byte aSide) { - this.issueClientUpdate(); - } - - @Override - public void receiveCoverData(byte coverSide, int coverID, int coverData) { - if ((coverSide >= 0 && coverSide < 6) && (mCoverSides[coverSide] == coverID)) - setCoverDataAtSide(coverSide, coverData); - } - - @Override - 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 boolean decreaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooLessEnergy) { - return !this.canAccessData() ? false : (this.mHasEnoughEnergy = this.decreaseStoredEU(aEnergy, aIgnoreTooLessEnergy)); - } - - @Override - 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 void issueBlockUpdate() { + super.markDirty(); + } + + @Override + public void issueCoverUpdate(byte aSide) { + this.issueClientUpdate(); + } + + @Override + public void receiveCoverData(byte coverSide, int coverID, int coverData) { + if ((coverSide >= 0 && coverSide < 6) && (mCoverSides[coverSide] == coverID)) + setCoverDataAtSide(coverSide, coverData); + } + + @Override + 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 boolean decreaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooLessEnergy) { + return !this.canAccessData() + ? false + : (this.mHasEnoughEnergy = this.decreaseStoredEU(aEnergy, aIgnoreTooLessEnergy)); + } + + @Override + 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 aSi