aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gtPlusPlus/core/tileentities
diff options
context:
space:
mode:
authorAlexdoru <57050655+Alexdoru@users.noreply.github.com>2024-10-02 07:31:08 +0200
committerGitHub <noreply@github.com>2024-10-02 05:31:08 +0000
commit3b9bd1188e932e6bb8041f7bb9afbf3ce75e26d3 (patch)
tree107d9d2442891990ef1cdef1d8bb2df6bb96952a /src/main/java/gtPlusPlus/core/tileentities
parentbfc7b2b07f72d0903a70791ff96f9c837ddd5ff0 (diff)
downloadGT5-Unofficial-3b9bd1188e932e6bb8041f7bb9afbf3ce75e26d3.tar.gz
GT5-Unofficial-3b9bd1188e932e6bb8041f7bb9afbf3ce75e26d3.tar.bz2
GT5-Unofficial-3b9bd1188e932e6bb8041f7bb9afbf3ce75e26d3.zip
Cleanup the codebase (#3311)
Co-authored-by: boubou19 <miisterunknown@gmail.com>
Diffstat (limited to 'src/main/java/gtPlusPlus/core/tileentities')
-rw-r--r--src/main/java/gtPlusPlus/core/tileentities/base/TileEntityBase.java96
-rw-r--r--src/main/java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java14
-rw-r--r--src/main/java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java2
-rw-r--r--src/main/java/gtPlusPlus/core/tileentities/general/TileEntityInfiniteFluid.java23
-rw-r--r--src/main/java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java5
-rw-r--r--src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java2
-rw-r--r--src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityBaseFluidCollector.java20
-rw-r--r--src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPestKiller.java46
-rw-r--r--src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java2
9 files changed, 96 insertions, 114 deletions
diff --git a/src/main/java/gtPlusPlus/core/tileentities/base/TileEntityBase.java b/src/main/java/gtPlusPlus/core/tileentities/base/TileEntityBase.java
index d5d348e0d8..35a569578f 100644
--- a/src/main/java/gtPlusPlus/core/tileentities/base/TileEntityBase.java
+++ b/src/main/java/gtPlusPlus/core/tileentities/base/TileEntityBase.java
@@ -1,5 +1,6 @@
package gtPlusPlus.core.tileentities.base;
+import java.util.Arrays;
import java.util.UUID;
import net.minecraft.block.Block;
@@ -170,9 +171,7 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT
@Override
public boolean isServerSide() {
if (this.hasWorldObj()) {
- if (!this.getWorldObj().isRemote) {
- return true;
- }
+ return !this.getWorldObj().isRemote;
}
return false;
}
@@ -197,7 +196,7 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT
@Override
public boolean hasCustomInventoryName() {
- return this.customName != null && !this.customName.equals("");
+ return this.customName != null && !this.customName.isEmpty();
}
@Override
@@ -294,7 +293,7 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT
@Override
public boolean isValidSlot(int aIndex) {
- return this.canAccessData() ? this.mInventory.isValidSlot(aIndex) : false;
+ return this.canAccessData() && this.mInventory.isValidSlot(aIndex);
}
private final CoverBehavior[] mCoverBehaviors = new CoverBehavior[] { GregTechAPI.sNoBehavior,
@@ -305,35 +304,52 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT
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[GregTechAPI.TICKS_FOR_LAG_AVERAGING];
+ private final boolean[] mActiveEUInputs = new boolean[] { false, false, false, false, false, false };
+ private final boolean[] mActiveEUOutputs = new boolean[] { false, false, false, false, false, false };
+ private final byte[] mSidedRedstone = new byte[] { 15, 15, 15, 15, 15, 15 };
+ private final int[] mCoverSides = new int[] { 0, 0, 0, 0, 0, 0 };
+ private final int[] mCoverData = new int[] { 0, 0, 0, 0, 0, 0 };
+ private final int[] mTimeStatistics = new int[GregTechAPI.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 final boolean mMuffler = false;
+ private final boolean mLockUpgrade = false;
+ private final boolean mActive = false;
private boolean mRedstone = false;
- private boolean mWorkUpdate = false;
- private boolean mSteamConverter = false;
+ private final boolean mWorkUpdate = false;
+ private final boolean mSteamConverter = false;
private boolean mInventoryChanged = false;
- private boolean mWorks = true;
- private boolean mNeedsUpdate = true;
- private boolean mNeedsBlockUpdate = true;
+ private final boolean mWorks = true;
+ private final boolean mNeedsUpdate = true;
+ private final 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;
+ private final boolean oRedstone = false;
+ private final boolean mEnergyStateReady = false;
+ private final byte mColor = 0;
+ private final byte oColor = 0;
+ private byte mStrongRedstone = 0;
+ private final byte oRedstoneData = 63;
+ private final byte oTextureData = 0;
+ private final byte oUpdateData = 0;
+ private final byte oTexturePage = 0;
+ private final byte oLightValueClient = -1;
+ private final byte oLightValue = -1;
+ private byte mLightValue = 0;
+ private final byte mOtherUpgrades = 0;
+ private final byte mFacing = 0;
+ private final byte oFacing = 0;
+ private final byte mWorkData = 0;
+ private final int mDisplayErrorCode = 0;
+ private final int oX = 0;
+ private final int oY = 0;
+ private final int oZ = 0;
+ private final int mTimeStatisticsIndex = 0;
+ private final int mLagWarningCount = 0;
+ private final short mID = 0;
protected long mTickTimer = 0;
- private long oOutput = 0;
+ private final long oOutput = 0;
private long mAcceptedAmperes = Long.MAX_VALUE;
/**
@@ -393,8 +409,7 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT
@Override
public boolean decreaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooLessEnergy) {
- return !this.canAccessData() ? false
- : (this.mHasEnoughEnergy = this.decreaseStoredEU(aEnergy, aIgnoreTooLessEnergy));
+ return this.canAccessData() && (this.mHasEnoughEnergy = this.decreaseStoredEU(aEnergy, aIgnoreTooLessEnergy));
}
@Override
@@ -411,16 +426,14 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT
@Override
public boolean inputEnergyFrom(ForgeDirection side) {
- return side == ForgeDirection.UNKNOWN ? true
- : (!this.isServerSide() ? this.isEnergyInputSide(side)
- : side != ForgeDirection.UNKNOWN && this.mActiveEUInputs[side.ordinal()] && !this.mReleaseEnergy);
+ return side == ForgeDirection.UNKNOWN || (!this.isServerSide() ? this.isEnergyInputSide(side)
+ : side != ForgeDirection.UNKNOWN && this.mActiveEUInputs[side.ordinal()] && !this.mReleaseEnergy);
}
@Override
public boolean outputsEnergyTo(ForgeDirection side) {
- return side == ForgeDirection.UNKNOWN ? true
- : (!this.isServerSide() ? this.isEnergyOutputSide(side)
- : side != ForgeDirection.UNKNOWN && this.mActiveEUOutputs[side.ordinal()] || this.mReleaseEnergy);
+ return side == ForgeDirection.UNKNOWN || (!this.isServerSide() ? this.isEnergyOutputSide(side)
+ : side != ForgeDirection.UNKNOWN && this.mActiveEUOutputs[side.ordinal()] || this.mReleaseEnergy);
}
private boolean isEnergyInputSide(ForgeDirection side) {
@@ -482,9 +495,7 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT
}
protected final void clearTileEntityBuffer() {
- for (int i = 0; i < this.mBufferedTileEntities.length; ++i) {
- this.mBufferedTileEntities[i] = null;
- }
+ Arrays.fill(this.mBufferedTileEntities, null);
}
@Override
@@ -755,22 +766,19 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT
@Override
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);
+ || this.worldObj.canBlockSeeTheSky(aX, aY, aZ);
}
@Override
public final boolean getOpacity(int aX, int aY, int aZ) {
- return this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ)
- ? false
- : GTUtility.isOpaqueBlock(this.worldObj, aX, aY, aZ);
+ return (!this.ignoreUnloadedChunks || !this.crossedChunkBorder(aX, aZ) || this.worldObj.blockExists(aX, aY, aZ))
+ && GTUtility.isOpaqueBlock(this.worldObj, aX, aY, aZ);
}
@Override
public final boolean getAir(int aX, int aY, int aZ) {
return this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ)
- ? true
- : GTUtility.isBlockAir(this.worldObj, aX, aY, aZ);
+ || GTUtility.isBlockAir(this.worldObj, aX, aY, aZ);
}
@Override
diff --git a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java
index 4b687f63af..8a85234447 100644
--- a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java
+++ b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java
@@ -48,9 +48,7 @@ public class TileEntityCircuitProgrammer extends TileEntity implements ISidedInv
public final boolean hasCircuitToConfigure() {
for (ItemStack i : this.getInventory()
.getInventory()) {
- if (i == null) {
- continue;
- } else {
+ if (i != null) {
return true;
}
}
@@ -66,10 +64,7 @@ public class TileEntityCircuitProgrammer extends TileEntity implements ISidedInv
.getInventory()
.clone();
// Check if there is output in slot.
- Boolean hasOutput = false;
- if (aInputs[25] != null) {
- hasOutput = true;
- }
+ boolean hasOutput = aInputs[25] != null;
ArrayList<Integer> aValidSlots = new ArrayList<>();
int aSlotCount = 0;
for (ItemStack i : aInputs) {
@@ -127,7 +122,6 @@ public class TileEntityCircuitProgrammer extends TileEntity implements ISidedInv
}
}
}
- continue;
}
return false;
}
@@ -144,7 +138,7 @@ public class TileEntityCircuitProgrammer extends TileEntity implements ISidedInv
}
this.tickCount++;
}
- } catch (final Throwable t) {}
+ } catch (final Throwable ignored) {}
}
public boolean anyPlayerInRange() {
@@ -283,7 +277,7 @@ public class TileEntityCircuitProgrammer extends TileEntity implements ISidedInv
@Override
public boolean hasCustomInventoryName() {
- return (this.customName != null) && !this.customName.equals("");
+ return (this.customName != null) && !this.customName.isEmpty();
}
@Override
diff --git a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java
index a6754b00b0..dd1ea934f8 100644
--- a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java
+++ b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java
@@ -284,7 +284,7 @@ public class TileEntityDecayablesChest extends TileEntity implements ISidedInven
@Override
public boolean hasCustomInventoryName() {
- return (this.customName != null) && !this.customName.equals("");
+ return (this.customName != null) && !this.customName.isEmpty();
}
/**
diff --git a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityInfiniteFluid.java b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityInfiniteFluid.java
index fd528c589d..b0d4fb9296 100644
--- a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityInfiniteFluid.java
+++ b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityInfiniteFluid.java
@@ -54,17 +54,15 @@ public class TileEntityInfiniteFluid extends TileEntity implements IFluidHandler
fluid = null;
}
- if (this != null) {
- FluidEvent.fireEvent(
- new FluidEvent.FluidDrainingEvent(
- fluid,
- this.getWorldObj(),
- this.xCoord,
- this.yCoord,
- this.zCoord,
- this.tank,
- 0));
- }
+ FluidEvent.fireEvent(
+ new FluidEvent.FluidDrainingEvent(
+ fluid,
+ this.getWorldObj(),
+ this.xCoord,
+ this.yCoord,
+ this.zCoord,
+ this.tank,
+ 0));
}
return stack;
}
@@ -88,8 +86,7 @@ public class TileEntityInfiniteFluid extends TileEntity implements IFluidHandler
needsUpdate = true;
float amount = tank.getFluidAmount();
float capacity = tank.getCapacity();
- float volume = (amount / capacity) * 0.8F;
- return volume;
+ return (amount / capacity) * 0.8F;
}
@Override
diff --git a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java
index 14c337c088..1c5a34e2ca 100644
--- a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java
+++ b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java
@@ -124,7 +124,7 @@ public class TileEntityVolumetricFlaskSetter extends TileEntity implements ISide
.clone();
// Check if there is output in slot.
- Boolean hasOutput = false;
+ boolean hasOutput = false;
if (aInputs[ContainerVolumetricFlaskSetter.SLOT_OUTPUT] != null) {
hasOutput = true;
if (aInputs[ContainerVolumetricFlaskSetter.SLOT_OUTPUT].stackSize >= 16) {
@@ -220,7 +220,6 @@ public class TileEntityVolumetricFlaskSetter extends TileEntity implements ISide
}
}
}
- continue;
}
return false;
}
@@ -378,7 +377,7 @@ public class TileEntityVolumetricFlaskSetter extends TileEntity implements ISide
@Override
public boolean hasCustomInventoryName() {
- return (this.customName != null) && !this.customName.equals("");
+ return (this.customName != null) && !this.customName.isEmpty();
}
@Override
diff --git a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java
index 6f0d5fcea2..83a56ff287 100644
--- a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java
+++ b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java
@@ -93,7 +93,7 @@ public class TileEntityAdvPooCollector extends TileEntityBaseFluidCollector {
} else if (aPooMaker instanceof EntitySheep) {
aPooAmount = MathUtils.randInt(8, 30);
} else {
- if (aPooMaker instanceof EntityAnimal || aPooMaker instanceof IAnimals) {
+ if (aPooMaker instanceof IAnimals) {
aPooAmount = MathUtils.randInt(5, 35);
} else if (aPooMaker instanceof EntityVillager) {
aPooAmount = MathUtils.randInt(25, 30);
diff --git a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityBaseFluidCollector.java b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityBaseFluidCollector.java
index 988268f6e9..cf6ad5b663 100644
--- a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityBaseFluidCollector.java
+++ b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityBaseFluidCollector.java
@@ -73,17 +73,15 @@ public abstract class TileEntityBaseFluidCollector extends TileEntityBase implem
fluid = null;
}
- if (this != null) {
- FluidEvent.fireEvent(
- new FluidEvent.FluidDrainingEvent(
- fluid,
- this.getWorldObj(),
- this.xCoord,
- this.yCoord,
- this.zCoord,
- this.tank,
- 0));
- }
+ FluidEvent.fireEvent(
+ new FluidEvent.FluidDrainingEvent(
+ fluid,
+ this.getWorldObj(),
+ this.xCoord,
+ this.yCoord,
+ this.zCoord,
+ this.tank,
+ 0));
}
return stack;
}
diff --git a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPestKiller.java b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPestKiller.java
index 08ceed597d..71a4db157a 100644
--- a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPestKiller.java
+++ b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPestKiller.java
@@ -336,9 +336,7 @@ public class TileEntityPestKiller extends TileEntity implements ISidedInventory,
.getInventory()[0].stackSize < 64) {
int diff = 64 - this.getInventory()
.getInventory()[0].stackSize;
- if (aStack.stackSize <= diff) {
- return true;
- }
+ return aStack.stackSize <= diff;
}
}
return false;
@@ -346,12 +344,8 @@ public class TileEntityPestKiller extends TileEntity implements ISidedInventory,
@Override
public boolean canExtractItem(final int aSlot, final ItemStack aStack, final int p_102008_3_) {
- if (this.getInventory()
- .getInventory()[1] == null) {
- return false;
- } else {
- return true;
- }
+ return this.getInventory()
+ .getInventory()[1] != null;
}
public String getCustomName() {
@@ -369,7 +363,7 @@ public class TileEntityPestKiller extends TileEntity implements ISidedInventory,
@Override
public boolean hasCustomInventoryName() {
- return (this.mCustomName != null) && !this.mCustomName.equals("");
+ return (this.mCustomName != null) && !this.mCustomName.isEmpty();
}
@Override
@@ -404,17 +398,15 @@ public class TileEntityPestKiller extends TileEntity implements ISidedInventory,
fluid = null;
}
- if (this != null) {
- FluidEvent.fireEvent(
- new FluidEvent.FluidDrainingEvent(
- fluid,
- this.getWorldObj(),
- this.xCoord,
- this.yCoord,
- this.zCoord,
- this.mTank,
- 0));
- }
+ FluidEvent.fireEvent(
+ new FluidEvent.FluidDrainingEvent(
+ fluid,
+ this.getWorldObj(),
+ this.xCoord,
+ this.yCoord,
+ this.zCoord,
+ this.mTank,
+ 0));
}
updateTileEntity();
return stack;
@@ -451,10 +443,7 @@ public class TileEntityPestKiller extends TileEntity implements ISidedInventory,
}
public boolean hasFluidSpace() {
- if (this.mTank.getFluidAmount() <= 1000) {
- return true;
- }
- return false;
+ return this.mTank.getFluidAmount() <= 1000;
}
public boolean drainCell() {
@@ -464,7 +453,7 @@ public class TileEntityPestKiller extends TileEntity implements ISidedInventory,
return false;
}
aInput = aInput.copy();
- if (aInput != null && (this.getStackInSlot(1) == null || this.getStackInSlot(1).stackSize < 64)) {
+ if (this.getStackInSlot(1) == null || this.getStackInSlot(1).stackSize < 64) {
ArrayList<ItemStack> t1Cells = OreDictionary.getOres("cellFormaldehyde");
ArrayList<ItemStack> t2Cells = OreDictionary.getOres("cellHydrogenCyanide");
didFill = addFluid(t1Cells, aInput, FluidUtils.getWildcardFluidStack("formaldehyde", 1000));
@@ -496,11 +485,8 @@ public class TileEntityPestKiller extends TileEntity implements ISidedInventory,
if (GTUtility.areStacksEqual(a, aInput)) {
if (mTank.getFluid() == null || mTank.getFluid()
.isFluidEqual(aFluidForInput)) {
- boolean didFill = fill(ForgeDirection.UNKNOWN, aFluidForInput, true) > 0;
- return didFill;
+ return fill(ForgeDirection.UNKNOWN, aFluidForInput, true) > 0;
}
- } else {
- continue;
}
}
return false;
diff --git a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java
index 90864d1878..ba7433bfd2 100644
--- a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java
+++ b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java
@@ -95,7 +95,7 @@ public class TileEntityPooCollector extends TileEntityBaseFluidCollector {
} else if (aPooMaker instanceof EntitySheep) {
aPooAmount = MathUtils.randInt(8, 30);
} else {
- if (aPooMaker instanceof EntityAnimal || aPooMaker instanceof IAnimals) {
+ if (aPooMaker instanceof IAnimals) {
aPooAmount = MathUtils.randInt(5, 35);
} else {
aPooAmount = MathUtils.randInt(1, 10);