From 55f64675b42ac8d3c557cc850f78664bee006f6f Mon Sep 17 00:00:00 2001 From: Jason Mitchell Date: Sat, 28 Jan 2023 19:32:44 -0800 Subject: [ci skip] spotlessApply with the new settings --- .../core/tileentities/ModTileEntities.java | 4 +- .../core/tileentities/base/TileBasicTank.java | 144 +- .../core/tileentities/base/TileEntityBase.java | 238 ++-- .../core/tileentities/base/TilePoweredGT.java | 1436 ++++---------------- .../general/TileEntityCircuitProgrammer.java | 14 +- .../general/TileEntityDecayablesChest.java | 33 +- .../tileentities/general/TileEntityEggBox.java | 33 +- .../tileentities/general/TileEntityFirepit.java | 1 + .../tileentities/general/TileEntityFishTrap.java | 91 +- .../general/TileEntityHeliumGenerator.java | 9 +- .../general/TileEntityInfiniteFluid.java | 13 +- .../general/TileEntityPlayerDoorBase.java | 13 +- .../tileentities/general/TileEntityReverter.java | 64 +- .../general/TileEntityVolumetricFlaskSetter.java | 30 +- .../general/TileEntityXpConverter.java | 33 +- .../redstone/TileEntityRedstoneHandler.java | 73 +- .../machines/TileEntityAdvPooCollector.java | 22 +- .../machines/TileEntityBaseFluidCollector.java | 34 +- .../machines/TileEntityModularityTable.java | 74 +- .../machines/TileEntityPestKiller.java | 37 +- .../machines/TileEntityPooCollector.java | 9 +- .../machines/TileEntityProjectTable.java | 272 ++-- .../machines/TileEntityRoundRobinator.java | 35 +- .../machines/TileEntityTradeTable.java | 7 +- 24 files changed, 912 insertions(+), 1807 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 1ec58b0813..921415ee5d 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/ModTileEntities.java +++ b/src/main/java/gtPlusPlus/core/tileentities/ModTileEntities.java @@ -62,7 +62,7 @@ public class ModTileEntities { "gtPlusPlus.core.tileentities.general.TileEntityFishTrap"); Meta_GT_Proxy.setTileEntityClassAsBlacklistedInWorldAccelerator( "gtPlusPlus.core.tileentities.general.TileEntityDecayablesChest"); - Meta_GT_Proxy.setTileEntityClassAsBlacklistedInWorldAccelerator( - "gtPlusPlus.core.tileentities.general.TileEggBox"); + Meta_GT_Proxy + .setTileEntityClassAsBlacklistedInWorldAccelerator("gtPlusPlus.core.tileentities.general.TileEggBox"); } } diff --git a/src/main/java/gtPlusPlus/core/tileentities/base/TileBasicTank.java b/src/main/java/gtPlusPlus/core/tileentities/base/TileBasicTank.java index 32a39a7096..650d11f172 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/base/TileBasicTank.java +++ b/src/main/java/gtPlusPlus/core/tileentities/base/TileBasicTank.java @@ -1,6 +1,5 @@ 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; @@ -8,6 +7,8 @@ import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.fluids.IFluidTank; +import gtPlusPlus.api.objects.minecraft.BTF_FluidTank; + public class TileBasicTank extends TileEntityBase implements IFluidHandler, IFluidTank { public final BTF_FluidTank mTank; @@ -21,8 +22,7 @@ public class TileBasicTank extends TileEntityBase implements IFluidHandler, IFlu public boolean onPreTick(long aTick) { if (this.isServerSide()) { - if (mTank.isFluidChangingAllowed() - && mTank.getFillableStack() != null + if (mTank.isFluidChangingAllowed() && mTank.getFillableStack() != null && mTank.getFillableStack().amount <= 0) { mTank.setFillableStack((FluidStack) null); } @@ -40,7 +40,7 @@ public class TileBasicTank extends TileEntityBase implements IFluidHandler, IFlu } private final FluidTankInfo[] getTankInfoEx(ForgeDirection aSide) { - return mTank.getCapacity() <= 0 ? new FluidTankInfo[0] : new FluidTankInfo[] {mTank.getInfo()}; + return mTank.getCapacity() <= 0 ? new FluidTankInfo[0] : new FluidTankInfo[] { mTank.getInfo() }; } private final int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { @@ -71,111 +71,97 @@ public class TileBasicTank extends TileEntityBase implements IFluidHandler, IFlu @Override public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { - if (mTickTimer > 5 - && canAccessData() + 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); + && (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() + 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); + && (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() + 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); + && (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() + 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); + && (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() + 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); + && (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); + 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[] {}; } diff --git a/src/main/java/gtPlusPlus/core/tileentities/base/TileEntityBase.java b/src/main/java/gtPlusPlus/core/tileentities/base/TileEntityBase.java index 59516e4231..164c42cc3f 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/base/TileEntityBase.java +++ b/src/main/java/gtPlusPlus/core/tileentities/base/TileEntityBase.java @@ -1,5 +1,20 @@ package gtPlusPlus.core.tileentities.base; +import java.util.UUID; + +import net.minecraft.block.Block; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +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 gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; @@ -17,19 +32,6 @@ 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; -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; public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregTechDeviceInformation, IDescribable { @@ -155,8 +157,7 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT public void setOwnerInformation(String mName, String mUUID, boolean mOP) { if (isServerSide()) { - if (this.mOwnerName == null - || this.mOwnerUUID == null + if (this.mOwnerName == null || this.mOwnerUUID == null || this.mOwnerName.equals("null") || this.mOwnerUUID.equals("null")) { this.mOwnerName = mName; @@ -255,26 +256,20 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT } /** - * returns all valid Inventory Slots, no matter which Side (Unless it's covered). - * The Side Stuff is done in the following two Functions. + * 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); + 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]; } @@ -283,15 +278,13 @@ 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) + return canAccessData() && (mRunningThroughTick || !mInputDisabled) + && getCoverBehaviorAtSide((byte) aSide).letsItemsIn( + (byte) aSide, + getCoverIDAtSide((byte) aSide), + getCoverDataAtSide((byte) aSide), + aIndex, + this) && mInventory.canInsertItem(aIndex, aStack, aSide); } @@ -300,15 +293,13 @@ 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) + return canAccessData() && (mRunningThroughTick || !mOutputDisabled) + && getCoverBehaviorAtSide((byte) aSide).letsItemsOut( + (byte) aSide, + getCoverIDAtSide((byte) aSide), + getCoverDataAtSide((byte) aSide), + aIndex, + this) && mInventory.canExtractItem(aIndex, aStack, aSide); } @@ -317,24 +308,18 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT 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 - }; + 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}, + 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; @@ -353,20 +338,9 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT 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 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; @@ -420,15 +394,13 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT } public long getInputVoltage() { - return this.canAccessData() && this.mMetaTileEntity.isElectric() - ? this.mMetaTileEntity.maxEUInput() + return this.canAccessData() && this.mMetaTileEntity.isElectric() ? this.mMetaTileEntity.maxEUInput() : 2147483647L; } @Override public boolean decreaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooLessEnergy) { - return !this.canAccessData() - ? false + return !this.canAccessData() ? false : (this.mHasEnoughEnergy = this.decreaseStoredEU(aEnergy, aIgnoreTooLessEnergy)); } @@ -446,19 +418,15 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT @Override public boolean inputEnergyFrom(byte aSide) { - return aSide == 6 - ? true - : (!this.isServerSide() - ? this.isEnergyInputSide(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) + return aSide == 6 ? true + : (!this.isServerSide() ? this.isEnergyOutputSide(aSide) : aSide >= 0 && aSide < 6 && this.mActiveEUOutputs[aSide] || this.mReleaseEnergy); } @@ -661,8 +629,7 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT } public final TileEntity getTileEntityAtSideAndDistance(byte aSide, int aDistance) { - return aDistance == 1 - ? this.getTileEntityAtSide(aSide) + return aDistance == 1 ? this.getTileEntityAtSide(aSide) : this.getTileEntity( this.getOffsetX(aSide, aDistance), this.getOffsetY(aSide, aDistance), @@ -795,11 +762,8 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT 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; + return this.mBufferedTileEntities[aSide].xCoord == tX && this.mBufferedTileEntities[aSide].yCoord == tY + && this.mBufferedTileEntities[aSide].zCoord == tZ ? this.mBufferedTileEntities[aSide] : null; } } else { return null; @@ -856,29 +820,26 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT @Override public byte getInternalInputRedstoneSignal(byte aSide) { - return (byte) (getCoverBehaviorAtSide(aSide) - .getRedstoneInput( - aSide, - getInputRedstoneSignal(aSide), - getCoverIDAtSide(aSide), - getCoverDataAtSide(aSide), - this) - & 15); + 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); + 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); + .manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this) + ? mSidedRedstone[aSide] + : getGeneralRS(aSide); } public boolean allowGeneralRedstoneOutput() { @@ -1016,8 +977,7 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT @Override public boolean dropCover(byte aSide, byte aDroppedSide, boolean aForced) { if (getCoverBehaviorAtSide(aSide) - .onCoverRemoval(aSide, getCoverIDAtSide(aSide), mCoverData[aSide], this, aForced) - || aForced) { + .onCoverRemoval(aSide, getCoverIDAtSide(aSide), mCoverData[aSide], this, aForced) || aForced) { ItemStack tStack = getCoverBehaviorAtSide(aSide) .getDrop(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this); if (tStack != null) { @@ -1061,8 +1021,7 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT @Override public byte getStrongOutputRedstoneSignal(byte aSide) { - return aSide >= 0 && aSide < 6 && (mStrongRedstone & (1 << aSide)) != 0 - ? (byte) (mSidedRedstone[aSide] & 15) + return aSide >= 0 && aSide < 6 && (mStrongRedstone & (1 << aSide)) != 0 ? (byte) (mSidedRedstone[aSide] & 15) : 0; } @@ -1074,24 +1033,23 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT @Override public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) { - if (!canAccessData() - || !mMetaTileEntity.isElectric() + if (!canAccessData() || !mMetaTileEntity.isElectric() || !inputEnergyFrom(aSide) || aAmperage <= 0 || aVoltage <= 0 || getStoredEU() >= getEUCapacity() - || mMetaTileEntity.maxAmperesIn() <= mAcceptedAmperes) return 0; + || 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)))), + aVoltage * (aAmperage = Math.min( + aAmperage, + Math.min( + mMetaTileEntity.maxAmperesIn() - mAcceptedAmperes, + 1 + ((getEUCapacity() - getStoredEU()) / aVoltage)))), true)) { mAverageEUInput[mAverageEUInputIndex] += aVoltage * aAmperage; mAcceptedAmperes += aAmperage; @@ -1102,10 +1060,10 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT @Override public boolean drainEnergyUnits(byte aSide, long aVoltage, long aAmperage) { - if (!canAccessData() - || !mMetaTileEntity.isElectric() + if (!canAccessData() || !mMetaTileEntity.isElectric() || !outputsEnergyTo(aSide) - || getStoredEU() - (aVoltage * aAmperage) < mMetaTileEntity.getMinimumStoredEU()) return false; + || getStoredEU() - (aVoltage * aAmperage) < mMetaTileEntity.getMinimumStoredEU()) + return false; if (decreaseStoredEU(aVoltage * aAmperage, false)) { mAverageEUOutput[mAverageEUOutputIndex] += aVoltage * aAmperage; return true; @@ -1221,9 +1179,8 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT return true; } aStack = GT_OreDictUnificator.get(aStack); - if (GT_Utility.areStacksEqual(tStack, aStack) - && tStack.stackSize + aStack.stackSize - <= Math.min(aStack.getMaxStackSize(), getInventoryStackLimit())) { + if (GT_Utility.areStacksEqual(tStack, aStack) && tStack.stackSize + aStack.stackSize + <= Math.min(aStack.getMaxStackSize(), getInventoryStackLimit())) { tStack.stackSize += aStack.stackSize; return true; } @@ -1279,16 +1236,12 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT 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))); + 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"); + GT_Mod.achievements + .issueAchievement(this.getWorldObj().getPlayerEntityByName(this.mOwnerName), "electricproblems"); } } @@ -1298,8 +1251,7 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT try { this.mReleaseEnergy = true; Util.emitEnergyToNetwork(GT_Values.V[5], Math.max(1L, this.getStoredEU() / GT_Values.V[5]), this); - } catch (Exception arg4) { - } + } catch (Exception arg4) {} } this.mReleaseEnergy = false; this.onExplosion(); @@ -1393,7 +1345,8 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT } /** - * Adds support for the newer function added by https://github.com/Blood-Asp/GT5-Unofficial/commit/73ee102b63efd92c0f164a7ed7a79ebcd2619617#diff-3051838621d8ae87aa5ccd1345e1f07d + * Adds support for the newer function added by + * https://github.com/Blood-Asp/GT5-Unofficial/commit/73ee102b63efd92c0f164a7ed7a79ebcd2619617#diff-3051838621d8ae87aa5ccd1345e1f07d */ public boolean inputEnergyFrom(byte arg0, boolean arg1) { // TODO Auto-generated method stub @@ -1401,7 +1354,8 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT } /** - * Adds support for the newer function added by https://github.com/Blood-Asp/GT5-Unofficial/commit/73ee102b63efd92c0f164a7ed7a79ebcd2619617#diff-3051838621d8ae87aa5ccd1345e1f07d + * Adds support for the newer function added by + * https://github.com/Blood-Asp/GT5-Unofficial/commit/73ee102b63efd92c0f164a7ed7a79ebcd2619617#diff-3051838621d8ae87aa5ccd1345e1f07d */ public boolean outputsEnergyTo(byte arg0, boolean arg1) { // TODO Auto-generated method stub diff --git a/src/main/java/gtPlusPlus/core/tileentities/base/TilePoweredGT.java b/src/main/java/gtPlusPlus/core/tileentities/base/TilePoweredGT.java index 257dc740ea..1bbf7aa302 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/base/TilePoweredGT.java +++ b/src/main/java/gtPlusPlus/core/tileentities/base/TilePoweredGT.java @@ -1,1147 +1,289 @@ -/*package gtPlusPlus.core.tileentities.base; - - -public abstract class TilePoweredGT extends TileEntityBase implements IGregtechPower { - - public static AutoMap mPoweredEntities = new AutoMap(); - - //Base Tile Fields - public boolean ignoreUnloadedChunks; - public boolean isDead; - //Meta Tile Fields - private long mAcceptedAmperes; - - private boolean[] mActiveEUInputs; - private boolean[] mActiveEUOutputs; - protected int[] mAverageEUInput; - protected int mAverageEUInputIndex; - protected int[] mAverageEUOutput; - protected int mAverageEUOutputIndex; - private final TileEntity[] mBufferedTileEntities; - private byte mFacing = 0; - private boolean mHasEnoughEnergy; - private boolean mNeedsUpdate; - private boolean mNeedsBlockUpdate; - private boolean mRunningThroughTick; - private boolean mSendClientData; - protected boolean mReleaseEnergy; - private long mTickTimer; - protected long mStoredEnergy; - protected long mStoredSteam; - - public TilePoweredGT() { - super(); - this.mBufferedTileEntities = new TileEntity[6]; - this.ignoreUnloadedChunks = true; - this.isDead = false; - mPoweredEntities.put(this); - } - - @Override - public boolean acceptsRotationalEnergy(byte p0) { - return false; - } - - private boolean canAccessData() { - return this.isInvalid() ? false : true; - } - - 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; - } - } - - private boolean crossedChunkBorder(final int aX, final int aZ) { - return aX >> 4 != this.xCoord >> 4 || aZ >> 4 != this.zCoord >> 4; - } - - @Override - public boolean decreaseStoredEnergyUnits(final long aEnergy, final boolean aIgnoreTooLessEnergy) { - return this.canAccessData() && (this.mHasEnoughEnergy = (this.decreaseStoredEU(aEnergy, aIgnoreTooLessEnergy) - || this.decreaseStoredSteam(aEnergy, false) - || (aIgnoreTooLessEnergy && this.decreaseStoredSteam(aEnergy, true)))); - } - - public boolean decreaseStoredEU(final long aEnergy, final boolean aIgnoreTooLessEnergy) { - if (!this.canAccessData()) { - return false; - } - if (this.getEUVar() - aEnergy < 0L && !aIgnoreTooLessEnergy) { - return false; - } - this.setStoredEU(this.getEUVar() - aEnergy); - if (this.getEUVar() < 0L) { - this.setStoredEU(0L); - return false; - } - return true; - } - - public boolean decreaseStoredSteam(final long aEnergy, final boolean aIgnoreTooLessEnergy) { - if (!this.canAccessData()) { - return false; - } - if (this.getSteamVar() - aEnergy < 0L && !aIgnoreTooLessEnergy) { - return false; - } - this.setStoredSteam(this.getSteamVar() - aEnergy); - if (this.getSteamVar() < 0L) { - this.setStoredSteam(0L); - return false; - } - return true; - } - - public void doExplosion(final long aExplosionPower) { - final float tStrength = (aExplosionPower < GT_Values.V[0]) - ? 1.0f - : ((aExplosionPower < GT_Values.V[1]) - ? 2.0f - : ((aExplosionPower < GT_Values.V[2]) - ? 3.0f - : ((aExplosionPower < GT_Values.V[3]) - ? 4.0f - : ((aExplosionPower < GT_Values.V[4]) - ? 5.0f - : ((aExplosionPower < GT_Values.V[4] * 2L) - ? 6.0f - : ((aExplosionPower < GT_Values.V[5]) - ? 7.0f - : ((aExplosionPower < GT_Values.V[6]) - ? 8.0f - : ((aExplosionPower < GT_Values.V[7]) - ? 9.0f - : 10.0f)))))))); - final int tX = this.getXCoord(); - final int tY = this.getYCoord(); - final int tZ = this.getZCoord(); - final World tWorld = this.getWorld(); - GT_Utility.sendSoundToPlayers(tWorld, (String) GregTech_API.sSoundList.get(209), 1.0f, -1.0f, tX, tY, tZ); - tWorld.setBlock(tX, tY, tZ, Blocks.air); - if (GregTech_API.sMachineExplosions) { - tWorld.createExplosion((Entity) null, tX + 0.5, tY + 0.5, tZ + 0.5, tStrength, true); - } - } - - public boolean drainEnergyUnits(final byte aSide, final long aVoltage, final long aAmperage) { - if (!this.canAccessData() || !this.isElectric() || !this.outputsEnergyTo(aSide) - || this.getStoredEU() - aVoltage * aAmperage < this.getMinimumStoredEU()) { - return false; - } - if (this.decreaseStoredEU(aVoltage * aAmperage, false)) { - final int[] mAverageEUOutput = this.mAverageEUOutput; - final int mAverageEUOutputIndex = this.mAverageEUOutputIndex; - mAverageEUOutput[mAverageEUOutputIndex] += (int) (aVoltage * aAmperage); - return true; - } - return false; - } - - @Override - public final boolean getAir(final int aX, final int aY, final int aZ) { - return (this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ)) - || GT_Utility.isBlockAir(this.worldObj, aX, aY, aZ); - } - - @Override - public final boolean getAirAtSide(final byte aSide) { - return this.getAirAtSideAndDistance(aSide, 1); - } - - @Override - public final boolean getAirAtSideAndDistance(final byte aSide, final int aDistance) { - return this.getAir(this.getOffsetX(aSide, aDistance), this.getOffsetY(aSide, aDistance), - this.getOffsetZ(aSide, aDistance)); - } - - @Override - public final boolean getAirOffset(final int aX, final int aY, final int aZ) { - return this.getAir(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ); - } - - @Override - public long getAverageElectricInput() { - int rEU = 0; - for (int i = 0; i < this.mAverageEUInput.length; ++i) { - if (i != this.mAverageEUInputIndex) { - rEU += this.mAverageEUInput[i]; - } - } - return rEU / (this.mAverageEUInput.length - 1); - } - - public long getAverageElectricOutput() { - int rEU = 0; - for (int i = 0; i < this.mAverageEUOutput.length; ++i) { - if (i != this.mAverageEUOutputIndex) { - rEU += this.mAverageEUOutput[i]; - } - } - return rEU / (this.mAverageEUOutput.length - 1); - } - - @Override - public byte getBackFacing() { - return GT_Utility.getOppositeSide((int) this.mFacing); - } - - @Override - public final Block getBlock(final int aX, final int aY, final int aZ) { - if (this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ)) { - return Blocks.air; - } - return this.worldObj.getBlock(aX, aY, aZ); - } - - - @Override - public final Block getBlockAtSide(final byte aSide) { - return this.getBlockAtSideAndDistance(aSide, 1); - } - - @Override - public final Block getBlockAtSideAndDistance(final byte aSide, final int aDistance) { - return this.getBlock(this.getOffsetX(aSide, aDistance), this.getOffsetY(aSide, aDistance), - this.getOffsetZ(aSide, aDistance)); - } - - @Override - public final Block getBlockOffset(final int aX, final int aY, final int aZ) { - return this.getBlock(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ); - } - - @Override - public String[] getDescription() { - // TODO Auto-generated method stub - return null; - } - - - - - - - - - @Override - public long getEUCapacity() { - if (this.canAccessData()) { - return this.maxEUStore(); - } - return 0L; - } - - public long getEUVar() { - return mStoredEnergy; - } - - @Override - public byte getFrontFacing() { - return this.mFacing; - } - - @Override - public final IGregTechTileEntity getIGregTechTileEntity(final int aX, final int aY, final int aZ) { - final TileEntity tTileEntity = this.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity) { - return (IGregTechTileEntity) tTileEntity; - } - return null; - } - - @Override - public final IGregTechTileEntity getIGregTechTileEntityAtSide(final byte aSide) { - final TileEntity tTileEntity = this.getTileEntityAtSide(aSide); - if (tTileEntity instanceof IGregTechTileEntity) { - return (IGregTechTileEntity) tTileEntity; - } - return null; - } - - @Override - public final IGregTechTileEntity getIGregTechTileEntityAtSideAndDistance(final byte aSide, final int aDistance) { - final TileEntity tTileEntity = this.getTileEntityAtSideAndDistance(aSide, aDistance); - if (tTileEntity instanceof IGregTechTileEntity) { - return (IGregTechTileEntity) tTileEntity; - } - return null; - } - - @Override - public final IGregTechTileEntity getIGregTechTileEntityOffset(final int aX, final int aY, final int aZ) { - final TileEntity tTileEntity = this.getTileEntityOffset(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity) { - return (IGregTechTileEntity) tTileEntity; - } - return null; - } - - @Override - public final IInventory getIInventory(final int aX, final int aY, final int aZ) { - final TileEntity tTileEntity = this.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IInventory) { - return (IInventory) tTileEntity; - } - return null; - } - - @Override - public final IInventory getIInventoryAtSide(final byte aSide) { - final TileEntity tTileEntity = this.getTileEntityAtSide(aSide); - if (tTileEntity instanceof IInventory) { - return (IInventory) tTileEntity; - } - return null; - } - - @Override - public final IInventory getIInventoryAtSideAndDistance(final byte aSide, final int aDistance) { - final TileEntity tTileEntity = this.getTileEntityAtSideAndDistance(aSide, aDistance); - if (tTileEntity instanceof IInventory) { - return (IInventory) tTileEntity; - } - return null; - } - - @Override - public final IInventory getIInventoryOffset(final int aX, final int aY, final int aZ) { - final TileEntity tTileEntity = this.getTileEntityOffset(aX, aY, aZ); - if (tTileEntity instanceof IInventory) { - return (IInventory) tTileEntity; - } - return null; - } - - @Override - public String[] getInfoData() { - // TODO Auto-generated method stub - return null; - } - - @Override - public long getInputAmperage() { - if (this.canAccessData() && this.isElectric()) { - return this.maxAmperesIn(); - } - return 0L; - } - - public long getInputTier() { - return GT_Utility.getTier(this.getInputVoltage()); - } - - @Override - public long getInputVoltage() { - if (this.canAccessData() && this.isElectric()) { - return this.maxEUInput(); - } - return 2147483647L; - } - - private long getMinimumStoredEU() { - return 0; - } - - @Override - public final int getOffsetX(final byte aSide, final int aMultiplier) { - return this.xCoord + ForgeDirection.getOrientation((int) aSide).offsetX * aMultiplier; - } - - public final short getOffsetY(final byte aSide, final int aMultiplier) { - return (short) (this.yCoord + ForgeDirection.getOrientation((int) aSide).offsetY * aMultiplier); - } - - public final int getOffsetZ(final byte aSide, final int aMultiplier) { - return this.zCoord + ForgeDirection.getOrientation((int) aSide).offsetZ * aMultiplier; - } - - @Override - public long getOutputAmperage() { - if (this.canAccessData() && this.isElectric()) { - return this.maxAmperesOut(); - } - return 0L; - } - - public long getOutputTier() { - return GT_Utility.getTier(this.getOutputVoltage()); - } - - @Override - public long getOutputVoltage() { - if (this.canAccessData() && this.isElectric() && this.isEnetOutput()) { - return this.maxEUOutput(); - } - return 0L; - } - - @Override - public int getRandomNumber(int p0) { - return CORE.RANDOM.nextInt(); - } - - @Override - public long getSteamCapacity() { - if (this.canAccessData()) { - return this.maxSteamStore(); - } - return 0L; - } - - public long getSteamVar() { - return mStoredSteam; - } - - @Override - public long getStoredEU() { - if (this.canAccessData()) { - return Math.min(this.getEUVar(), this.getEUCapacity()); - } - return 0L; - } - - - - - - - - - - @Override - public long getStoredSteam() { - if (this.canAccessData()) { - return Math.min(this.getSteamVar(), this.getSteamCapacity()); - } - return 0L; - } - - @Override - public final TileEntity getTileEntity(final int aX, final int aY, final int aZ) { - if (this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ)) { - return null; - } - return this.worldObj.getTileEntity(aX, aY, aZ); - } - - public final TileEntity getTileEntityAtSide(final byte aSide) { - if (aSide < 0 || aSide >= 6 || this.mBufferedTileEntities[aSide] == this) { - return null; - } - final int tX = this.getOffsetX(aSide, 1); - final int tY = this.getOffsetY(aSide, 1); - final 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; - } - return this.mBufferedTileEntities[aSide]; - } else { - if (this.mBufferedTileEntities[aSide].isInvalid()) { - this.mBufferedTileEntities[aSide] = null; - return this.getTileEntityAtSide(aSide); - } - if (this.mBufferedTileEntities[aSide].xCoord == tX && this.mBufferedTileEntities[aSide].yCoord == tY - && this.mBufferedTileEntities[aSide].zCoord == tZ) { - return this.mBufferedTileEntities[aSide]; - } - return null; - } - } - - @Override - public final TileEntity getTileEntityAtSideAndDistance(final byte aSide, final int aDistance) { - if (aDistance == 1) { - return this.getTileEntityAtSide(aSide); - } - return this.getTileEntity(this.getOffsetX(aSide, aDistance), this.getOffsetY(aSide, aDistance), - this.getOffsetZ(aSide, aDistance)); - } - - - - - - - - - - - @Override - public final TileEntity getTileEntityOffset(final int aX, final int aY, final int aZ) { - return this.getTileEntity(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ); - } - - @Override - public long getUniversalEnergyCapacity() { - return 0; - } - - @Override - public long getUniversalEnergyStored() { - return 0; - } - - @Override - public World getWorld() { - return this.getWorldObj(); - } - - - - - - - @Override - public int getXCoord() { - return this.xCoord; - } - - - - - - @Override - public short getYCoord() { - return (short) this.yCoord; - } - - @Override - public int getZCoord() { - return this.zCoord; - } - - public boolean hasEnoughEnergy() { - return (this.getStoredEU() > 0 ? (mHasEnoughEnergy = true) : (mHasEnoughEnergy = false)); - } - - - - - @Override - public boolean increaseStoredEnergyUnits(final long aEnergy, final boolean aIgnoreTooMuchEnergy) { - if (!this.canAccessData()) { - return false; - } - if (this.getStoredEU() < this.getEUCapacity() || aIgnoreTooMuchEnergy) { - this.setStoredEU(this.getEUVar() + aEnergy); - return true; - } - return false; - } - - @Override - public boolean increaseStoredSteam(final long aEnergy, final boolean aIgnoreTooMuchEnergy) { - if (!this.canAccessData()) { - return false; - } - if (this.getSteamVar() < this.getSteamCapacity() || aIgnoreTooMuchEnergy) { - this.setStoredSteam(this.getSteamVar() + aEnergy); - return true; - } - return false; - } - - public long injectEnergyUnits(final byte aSide, final long aVoltage, long aAmperage) { - if (!this.canAccessData() || !this.isElectric() || !this.inputEnergyFrom(aSide) - || aAmperage <= 0L || aVoltage <= 0L || this.getStoredEU() >= this.getEUCapacity() - || this.maxAmperesIn() <= this.mAcceptedAmperes) { - return 0L; - } - if (aVoltage > this.getInputVoltage()) { - this.doExplosion(aVoltage); - return 0L; - } - if (this.increaseStoredEnergyUnits(aVoltage - * (aAmperage = Math.min(aAmperage, Math.min(this.maxAmperesIn() - this.mAcceptedAmperes, - 1L + (this.getEUCapacity() - this.getStoredEU()) / aVoltage))), - true)) { - final int[] mAverageEUInput = this.mAverageEUInput; - final int mAverageEUInputIndex = this.mAverageEUInputIndex; - mAverageEUInput[mAverageEUInputIndex] += (int) (aVoltage * aAmperage); - this.mAcceptedAmperes += aAmperage; - return aAmperage; - } - return 0L; - } - - @Override - public boolean injectRotationalEnergy(byte p0, long p1, long p2) { - return false; - } - - @Override - public boolean inputEnergyFrom(final byte aSide) { - if (aSide == 6) { - return true; - } - if (this.isServerSide()) { - return aSide >= 0 && aSide < 6 && this.mActiveEUInputs[aSide] && !this.mReleaseEnergy; - } - return this.isEnergyInputSide(aSide); - } - - - public final boolean isClientSide() { - return this.worldObj.isRemote; - } - - @Override - public boolean isDead() { - return this.isDead; - } - - private boolean isElectric() { - return true; - } - - private boolean isEnergyInputSide(final byte aSide) { - if (aSide >= 0 && aSide < 6) { - if (this.isInvalid() || this.mReleaseEnergy) { - return false; - } - if (this.canAccessData() && this.isElectric() && this.isEnetInput()) { - return this.isInputFacing(aSide); - } - } - return false; - } - - private boolean isEnergyOutputSide(final byte aSide) { - if (aSide >= 0 && aSide < 6) { - if (this.isInvalid() || this.mReleaseEnergy) { - return this.mReleaseEnergy; - } - if (this.canAccessData() && this.isElectric() && this.isEnetOutput()) { - return this.isOutputFacing(aSide); - } - } - return false; - } - - public boolean isEnetInput() { - return false; - } - - public boolean isEnetOutput() { - return false; - } - - @Override - public boolean isGivingInformation() { - return this.canAccessData() && this.isGivingInformation(); - } - - public boolean isInputFacing(final byte aSide) { - return false; - } - - - - - @Override - public boolean isInvalidTileEntity() { - return isDead() ? true : false; - } - - public boolean isOutputFacing(final byte aSide) { - return false; - } - - public final boolean isServerSide() { - return !this.worldObj.isRemote; - } - - public boolean isUniversalEnergyStored(final long aEnergyAmount) { - return this.getUniversalEnergyStored() >= aEnergyAmount || (this.mHasEnoughEnergy = false); - } - - @Override - public boolean isValidFacing(final byte aSide) { - return this.canAccessData(); - } - - public long maxAmperesIn() { - return 1L; - } - - public long maxAmperesOut() { - return 1L; - } - - public long maxEUInput() { - return 0L; - } - - public long maxEUOutput() { - return 0L; - } - - public long maxEUStore() { - return 0L; - } - - public long maxSteamStore() { - return 256000L; - } - - public final void onAdjacentBlockChange(final int aX, final int aY, final int aZ) { - this.clearNullMarkersFromTileEntityBuffer(); - } - - @Override - public boolean outputsEnergyTo(final byte aSide) { - if (aSide == 6) { - return true; - } - if (this.isServerSide()) { - if (aSide < 0 || aSide >= 6 || !this.mActiveEUOutputs[aSide]) { - if (!this.mReleaseEnergy) { - return false; - } - } - return true; - } - return this.isEnergyOutputSide(aSide); - } - - public final void sendBlockEvent(final byte aID, final byte aValue) { - GT_Values.NW.sendPacketToAllPlayersInRange(this.worldObj, - (GT_Packet) new GT_Packet_Block_Event(this.xCoord, (short) this.yCoord, this.zCoord, aID, aValue), - this.xCoord, this.zCoord); - } - - public void setEUVar(final long aEnergy) { - mStoredEnergy = aEnergy; - } - - @Override - public void setFrontFacing(byte aFacing) { - if (this.isValidFacing(aFacing)) { - this.mFacing = aFacing; - //this.onFacingChange(); - //this.onMachineBlockUpdate(); - } - } - - public void setSteamVar(final long aSteam) { - mStoredSteam = aSteam; - } - - public boolean setStoredEU(long aEnergy) { - if (!this.canAccessData()) { - return false; - } - if (aEnergy < 0L) { - aEnergy = 0L; - } - this.setEUVar(aEnergy); - return true; - } - - public boolean setStoredSteam(long aEnergy) { - if (!this.canAccessData()) { - return false; - } - if (aEnergy < 0L) { - aEnergy = 0L; - } - this.setSteamVar(aEnergy); - return true; - } - - @Override - public void writeToNBT(NBTTagCompound nbt) { - // TODO Auto-generated method stub - super.writeToNBT(nbt); - } - - @Override - public void readFromNBT(NBTTagCompound nbt) { - // TODO Auto-generated method stub - super.readFromNBT(nbt); - } - - - - - @Override - public boolean onPreTick(long aTick) { - return onPreTick(this, this.mTickTimer); - } - - @Override - public boolean onTick(long aTick) { - return onTick(this, this.mTickTimer); - } - - @Override - public boolean onPostTick(long aTick) { - return onPostTick(this, this.mTickTimer); - } - - @Override - public boolean onPreTick(TilePoweredGT tilePoweredGT, long mTickTimer2) { - return super.onPreTick(mTickTimer2); - } - - @Override - public boolean onTick(TilePoweredGT iGregTechTileEntity, long mTickTimer2) { - return super.onTick(mTickTimer2); - } - - @Override - public boolean onPostTick(TilePoweredGT iGregTechTileEntity, long mTickTimer2) { - return super.onPostTick(mTickTimer2); - } - - @Override - public void markDirty() { - super.markDirty(); - } - - @Override - public boolean receiveClientEvent(int p_145842_1_, int p_145842_2_) { - // TODO Auto-generated method stub - return super.receiveClientEvent(p_145842_1_, p_145842_2_); - } - - @Override - public void onChunkUnload() { - this.clearNullMarkersFromTileEntityBuffer(); - super.onChunkUnload(); - this.isDead = true; - } - - - public void updateEntity() { - super.updateEntity(); - this.isDead = false; - - this.mRunningThroughTick = true; - long tTime = System.currentTimeMillis(); - int tCode = 0; - final boolean aSideServer = this.isServerSide(); - final boolean aSideClient = this.isClientSide(); - try { - for (tCode = 0; this.hasValidMetaTileEntity() && tCode >= 0; tCode = -1) { - Label_1743 : { - switch (tCode) { - case 0 : { - ++tCode; - if (this.mTickTimer++ != 0L) { - break Label_1743; - } - this.oX = this.xCoord; - this.oY = this.yCoord; - this.oZ = this.zCoord; - - this.worldObj.markTileEntityChunkModified(this.xCoord, this.yCoord, this.zCoord, - (TileEntity) this); - this.onFirstTick(this); - if (!this.hasValidMetaTileEntity()) { - this.mRunningThroughTick = false; - return; - } - break Label_1743; - } - case 1 : { - ++tCode; - if (!aSideClient) { - break Label_1743; - } - if (this.mNeedsUpdate) { - this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); - this.mNeedsUpdate = false; - } - break Label_1743; - } - case 2 : - case 3 : - case 4 : - case 5 : - case 6 : - case 7 : { - if (aSideServer && this.mTickTimer > 10L) { - for (byte i = (byte) (tCode - 2); i < 6; ++i) { - - } - } - } - case 8 : { - tCode = 9; - if (aSideServer) { - if (++this.mAverageEUInputIndex >= this.mAverageEUInput.length) { - this.mAverageEUInputIndex = 0; - } - if (++this.mAverageEUOutputIndex >= this.mAverageEUOutput.length) { - this.mAverageEUOutputIndex = 0; - } - this.mAverageEUInput[this.mAverageEUInputIndex] = 0; - this.mAverageEUOutput[this.mAverageEUOutputIndex] = 0; - } - } - case 9 : { - ++tCode; - this.onPreTick(this, this.mTickTimer); - if (!this.hasValidMetaTileEntity()) { - this.mRunningThroughTick = false; - return; - } - } - case 10 : { - ++tCode; - if (!aSideServer) { - break Label_1743; - } - - if (this.xCoord != this.oX || this.yCoord != this.oY || this.zCoord != this.oZ) { - this.oX = this.xCoord; - this.oY = this.yCoord; - this.oZ = this.zCoord; - this.issueClientUpdate(); - this.clearTileEntityBuffer(); - } - if (this.mFacing != this.oFacing) { - this.oFacing = this.mFacing; - this.issueBlockUpdate(); - } - if (this.mTickTimer > 20L && this.isElectric()) { - this.mAcceptedAmperes = 0L; - if (this.getOutputVoltage() != this.oOutput) { - this.oOutput = this.getOutputVoltage(); - } - if (this.isEnetOutput() || this.isEnetInput()) { - for (byte i = 0; i < 6; ++i) { - boolean temp = this.isEnergyInputSide(i); - if (temp != this.mActiveEUInputs[i]) { - this.mActiveEUInputs[i] = temp; - } - temp = this.isEnergyOutputSide(i); - if (temp != this.mActiveEUOutputs[i]) { - this.mActiveEUOutputs[i] = temp; - } - } - } - if (this.isEnetOutput() && this.oOutput > 0L) { - final long tOutputVoltage = Math.max(this.oOutput, - this.oOutput + (1 << GT_Utility.getTier(this.oOutput))); - final long tUsableAmperage = Math.min(this.getOutputAmperage(), - (this.getStoredEU() - this.getMinimumStoredEU()) - / tOutputVoltage); - if (tUsableAmperage > 0L) { - final long tEU = tOutputVoltage * IEnergyConnected.Util.emitEnergyToNetwork( - this.oOutput, tUsableAmperage, (IEnergyConnected) this); - final int[] mAverageEUOutput = this.mAverageEUOutput; - final int mAverageEUOutputIndex = this.mAverageEUOutputIndex; - mAverageEUOutput[mAverageEUOutputIndex] += (int) tEU; - this.decreaseStoredEU(tEU, true); - } - } - if (this.getEUCapacity() > 0L) { - if (GregTech_API.sMachineFireExplosions && this.getRandomNumber(1000) == 0) { - final Block tBlock = this.getBlockAtSide((byte) this.getRandomNumber(6)); - if (tBlock instanceof BlockFire) { - this.doEnergyExplosion(); - } - } - if (!this.hasValidMetaTileEntity()) { - this.mRunningThroughTick = false; - return; - } - } - } - if (!this.hasValidMetaTileEntity()) { - this.mRunningThroughTick = false; - return; - } - break Label_1743; - } - case 13 : { - ++tCode; - this.updateStatus(); - if (!this.hasValidMetaTileEntity()) { - this.mRunningThroughTick = false; - return; - } - } - case 14 : { - ++tCode; - this.onPostTick((IGregTechTileEntity) this, this.mTickTimer); - if (!this.hasValidMetaTileEntity()) { - this.mRunningThroughTick = false; - return; - } - } - case 15 : { - ++tCode; - if (!aSideServer) { - break; - } - if (this.mTickTimer % 10L == 0L && this.mSendClientData) { - final IGT_NetworkHandler nw = GT_Values.NW; - final World worldObj = this.worldObj; - final int xCoord = this.xCoord; - final short n = (short) this.yCoord; - final int zCoord = this.zCoord; - final short mid = this.mID; - final int n2 = this.mCoverSides[0]; - final int n3 = this.mCoverSides[1]; - final int n4 = this.mCoverSides[2]; - final int n5 = this.mCoverSides[3]; - final int n6 = this.mCoverSides[4]; - final int n7 = this.mCoverSides[5]; - final byte oTextureData = (byte) ((this.mFacing & 0x7) | (this.mActive ? 8 : 0) - | (this.mRedstone ? 16 : 0) | (this.mLockUpgrade ? 32 : 0)); - this.oTextureData = oTextureData; - final byte oTexturePage = (byte) ((this.hasValidMetaTileEntity() - && this.mMetaTileEntity instanceof GT_MetaTileEntity_Hatch) -