From 3b9bd1188e932e6bb8041f7bb9afbf3ce75e26d3 Mon Sep 17 00:00:00 2001 From: Alexdoru <57050655+Alexdoru@users.noreply.github.com> Date: Wed, 2 Oct 2024 07:31:08 +0200 Subject: Cleanup the codebase (#3311) Co-authored-by: boubou19 --- .../basic/MTEAtmosphericReconditioner.java | 56 +++++++--------------- .../tileentities/machines/basic/MTEAutoChisel.java | 22 ++++----- .../machines/basic/MTECropHarvestor.java | 4 +- .../machines/basic/MTEPollutionCreator.java | 4 +- .../machines/basic/MTEPollutionDetector.java | 4 +- .../machines/basic/MTEWirelessCharger.java | 23 ++++----- .../multi/processing/MTEIndustrialChisel.java | 2 +- .../multi/processing/MTEIndustrialDehydrator.java | 2 +- .../processing/MTEIndustrialVacuumFreezer.java | 2 +- .../machines/multi/processing/MTEIsaMill.java | 4 +- .../machines/multi/production/MTECyclotron.java | 2 +- .../multi/production/MTEElementalDuplicator.java | 4 +- .../multi/production/MTEFrothFlotationCell.java | 2 +- .../multi/production/MTEIndustrialRockBreaker.java | 2 +- .../multi/production/MTELargeRocketEngine.java | 12 ++--- .../multi/production/MTENuclearReactor.java | 2 +- .../machines/multi/production/MTERefinery.java | 2 +- .../machines/multi/production/MTESolarTower.java | 6 +-- .../machines/multi/production/MTETreeFarm.java | 3 +- .../multi/production/algae/MTEAlgaePondBase.java | 4 +- .../production/chemplant/MTEChemicalPlant.java | 8 ++-- .../production/turbines/MTELargeTurbineGas.java | 12 ++--- .../turbines/MTELargeTurbineSHSteam.java | 1 - .../production/turbines/MTELargeTurbineSteam.java | 1 - .../production/turbines/MTELargerTurbineBase.java | 21 ++++---- .../turbines/MTELargerTurbinePlasma.java | 25 ++++------ ...chMetaTileEntity_PowerSubStationController.java | 22 ++++----- 27 files changed, 101 insertions(+), 151 deletions(-) (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines') diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEAtmosphericReconditioner.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEAtmosphericReconditioner.java index 6988d2f43b..438fe6a536 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEAtmosphericReconditioner.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEAtmosphericReconditioner.java @@ -68,14 +68,14 @@ public class MTEAtmosphericReconditioner extends MTEBasicMachine { "Making sure you don't live in Gwalior - Uses 2A", 3, 0, - new ITexture[] { new GTRenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_MASSFAB_ACTIVE), - new GTRenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_MASSFAB), - new GTRenderedTexture(TexturesGtBlock.Overlay_MatterFab_Active), - new GTRenderedTexture(TexturesGtBlock.Overlay_MatterFab), - new GTRenderedTexture(TexturesGtBlock.Overlay_Machine_Vent_Fast), - new GTRenderedTexture(TexturesGtBlock.Overlay_Machine_Vent), - new GTRenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_MASSFAB_ACTIVE), - new GTRenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_MASSFAB) }); + new GTRenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_MASSFAB_ACTIVE), + new GTRenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_MASSFAB), + new GTRenderedTexture(TexturesGtBlock.Overlay_MatterFab_Active), + new GTRenderedTexture(TexturesGtBlock.Overlay_MatterFab), + new GTRenderedTexture(TexturesGtBlock.Overlay_Machine_Vent_Fast), + new GTRenderedTexture(TexturesGtBlock.Overlay_Machine_Vent), + new GTRenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_MASSFAB_ACTIVE), + new GTRenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_MASSFAB)); mPollutionEnabled = GTMod.gregtechproxy.mPollution; } @@ -264,8 +264,7 @@ public class MTEAtmosphericReconditioner extends MTEBasicMachine { Logger.INFO("mOptimalAirFlow[1]:" + mOptimalAirFlow); // Calculate The Voltage we are running - long tVoltage = drainEU; - byte tTier = (byte) Math.max(1, GTUtility.getTier(tVoltage)); + byte tTier = (byte) Math.max(1, GTUtility.getTier(drainEU)); // Check Sides for Air, // More air means more pollution processing. @@ -295,15 +294,8 @@ public class MTEAtmosphericReconditioner extends MTEBasicMachine { Logger.INFO("mCurrentPollution[4]:" + mCurrentPollution); Logger.INFO("mCurrentPollution[5]:" + reduction); - if (reduction <= mCurrentPollution) { - // Clean some Air. - toRemove = reduction; - } else { - // Makes sure we don't get negative pollution. - toRemove = mCurrentPollution; - } - - toRemove = toRemove / 2; + + toRemove = Math.min(reduction, mCurrentPollution) / 2; Logger.INFO("mCurrentPollution[6]:" + toRemove); // We are good to clean @@ -391,21 +383,13 @@ public class MTEAtmosphericReconditioner extends MTEBasicMachine { mCurrentChunkPollution += getPollutionInChunk(r); } } - if (mCurrentChunkPollution > 0) { - mHasPollution = true; - } else { - mHasPollution = false; - } + mHasPollution = mCurrentChunkPollution > 0; return mCurrentChunkPollution; } public int getPollutionInChunk(Chunk aChunk) { int mCurrentChunkPollution = PollutionUtils.getPollution(aChunk); - if (mCurrentChunkPollution > 0) { - mHasPollution = true; - } else { - mHasPollution = false; - } + mHasPollution = mCurrentChunkPollution > 0; return mCurrentChunkPollution; } @@ -573,9 +557,8 @@ public class MTEAtmosphericReconditioner extends MTEBasicMachine { public boolean removePollution(int toRemove) { - if (this == null || this.getBaseMetaTileEntity() == null - || this.getBaseMetaTileEntity() - .getWorld() == null) { + if (this.getBaseMetaTileEntity() == null || this.getBaseMetaTileEntity() + .getWorld() == null) { return false; } @@ -740,10 +723,8 @@ public class MTEAtmosphericReconditioner extends MTEBasicMachine { if (aStack.getItem() instanceof ItemBasicScrubberTurbine) { return true; } - if (aStack.getItem() instanceof MetaGeneratedTool && aStack.getItemDamage() >= 170 - && aStack.getItemDamage() <= 179) { - return true; - } + return aStack.getItem() instanceof MetaGeneratedTool && aStack.getItemDamage() >= 170 + && aStack.getItemDamage() <= 179; } } return false; @@ -765,8 +746,7 @@ public class MTEAtmosphericReconditioner extends MTEBasicMachine { @Override public String[] getInfoData() { - ArrayList aTooltipSuper = new ArrayList<>(); - aTooltipSuper.addAll(Arrays.asList(super.getInfoData())); + ArrayList aTooltipSuper = new ArrayList<>(Arrays.asList(super.getInfoData())); int mAirSides = getFreeSpaces(); int reduction = 0; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEAutoChisel.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEAutoChisel.java index 6cdc97130b..b4f69323f4 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEAutoChisel.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEAutoChisel.java @@ -40,14 +40,14 @@ public class MTEAutoChisel extends MTEBasicMachine { "Chisels things, Gregtech style", 1, 1, - new ITexture[] { new GTRenderedTexture(BlockIcons.OVERLAY_SIDE_MASSFAB_ACTIVE), - new GTRenderedTexture(BlockIcons.OVERLAY_SIDE_MASSFAB), - new GTRenderedTexture(BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE), - new GTRenderedTexture(BlockIcons.OVERLAY_FRONT_MULTI_SMELTER), - new GTRenderedTexture(TexturesGtBlock.Overlay_MatterFab_Active), - new GTRenderedTexture(TexturesGtBlock.Overlay_MatterFab), - new GTRenderedTexture(BlockIcons.OVERLAY_BOTTOM_MASSFAB_ACTIVE), - new GTRenderedTexture(BlockIcons.OVERLAY_BOTTOM_MASSFAB) }); + new GTRenderedTexture(BlockIcons.OVERLAY_SIDE_MASSFAB_ACTIVE), + new GTRenderedTexture(BlockIcons.OVERLAY_SIDE_MASSFAB), + new GTRenderedTexture(BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE), + new GTRenderedTexture(BlockIcons.OVERLAY_FRONT_MULTI_SMELTER), + new GTRenderedTexture(TexturesGtBlock.Overlay_MatterFab_Active), + new GTRenderedTexture(TexturesGtBlock.Overlay_MatterFab), + new GTRenderedTexture(BlockIcons.OVERLAY_BOTTOM_MASSFAB_ACTIVE), + new GTRenderedTexture(BlockIcons.OVERLAY_BOTTOM_MASSFAB)); } public MTEAutoChisel(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { @@ -90,8 +90,8 @@ public class MTEAutoChisel extends MTEBasicMachine { @Override protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, ItemStack aStack) { - return hasValidCache(aStack, this.getSpecialSlot(), false) ? true - : super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, side, aStack) && hasChiselResults(aStack); + return hasValidCache(aStack, this.getSpecialSlot(), false) + || super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, side, aStack) && hasChiselResults(aStack); } // lets make sure the user isn't trying to make something from a block that doesn't have this as a valid target @@ -108,7 +108,7 @@ public class MTEAutoChisel extends MTEBasicMachine { // lets make sure the user isn't trying to make something from a block that doesn't have this as a valid target private static boolean hasChiselResults(ItemStack from) { List results = getItemsForChiseling(from); - return results.size() > 0; + return !results.isEmpty(); } private static List getItemsForChiseling(ItemStack aStack) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTECropHarvestor.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTECropHarvestor.java index 9788abcf0c..f1f129606f 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTECropHarvestor.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTECropHarvestor.java @@ -164,7 +164,7 @@ public class MTECropHarvestor extends MTEBasicTank { }; } - private HashSet mCropCache = new HashSet<>(); + private final HashSet mCropCache = new HashSet<>(); private boolean mInvalidCache = false; public boolean doesInventoryHaveSpace() { @@ -213,7 +213,7 @@ public class MTECropHarvestor extends MTEBasicTank { for (int x = (-aSide); x <= aSide; x++) { for (int z = (-aSide); z <= aSide; z++) { TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityOffset(x, y, z); - if (tTileEntity != null && tTileEntity instanceof ICropTile tCrop) { + if (tTileEntity instanceof ICropTile tCrop) { this.mCropCache.add(tCrop); } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEPollutionCreator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEPollutionCreator.java index 2521fb703f..0226214c44 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEPollutionCreator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEPollutionCreator.java @@ -22,10 +22,10 @@ public class MTEPollutionCreator extends GTPPMetaTileEntity { int mCurrentPollution; int mAveragePollution; - int mAveragePollutionArray[] = new int[10]; + int[] mAveragePollutionArray = new int[10]; private int mArrayPos = 0; private int mTickTimer = 0; - private int mSecondTimer = 0; + private final int mSecondTimer = 0; public MTEPollutionCreator(final int aID, final String aName, final String aNameRegional, final int aTier, final String aDescription, final int aSlotCount) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEPollutionDetector.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEPollutionDetector.java index 747663f4cb..87e18931b5 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEPollutionDetector.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEPollutionDetector.java @@ -24,10 +24,10 @@ public class MTEPollutionDetector extends GTPPMetaTileEntity { int mCurrentPollution; int mAveragePollution; - int mAveragePollutionArray[] = new int[10]; + int[] mAveragePollutionArray = new int[10]; private int mArrayPos = 0; private int mTickTimer = 0; - private int mSecondTimer = 0; + private final int mSecondTimer = 0; private long mRedstoneLevel = 0; public MTEPollutionDetector(final int aID, final String aName, final String aNameRegional, final int aTier, diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEWirelessCharger.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEWirelessCharger.java index 1535140115..739a098331 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEWirelessCharger.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/MTEWirelessCharger.java @@ -323,9 +323,7 @@ public class MTEWirelessCharger extends GTPPMetaTileEntity { @Override public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } + aBaseMetaTileEntity.isClientSide(); return true; } @@ -449,18 +447,14 @@ public class MTEWirelessCharger extends GTPPMetaTileEntity { super.onFirstTick(aBaseMetaTileEntity); } - private Map mWirelessChargingMap = new HashMap<>(); - private Map mLocalChargingMap = new HashMap<>(); + private final Map mWirelessChargingMap = new HashMap<>(); + private final Map mLocalChargingMap = new HashMap<>(); private boolean isValidPlayer(EntityPlayer aPlayer) { BaseMetaTileEntity aTile = (BaseMetaTileEntity) this.getBaseMetaTileEntity(); if (mLocked || (aTile != null && aTile.privateAccess())) { - if (aPlayer.getUniqueID() - .equals(getBaseMetaTileEntity().getOwnerUuid())) { - return true; - } else { - return false; - } + return aPlayer.getUniqueID() + .equals(getBaseMetaTileEntity().getOwnerUuid()); } return true; } @@ -579,11 +573,10 @@ public class MTEWirelessCharger extends GTPPMetaTileEntity { int[] objectArray1 = new int[] { objectA.xPos, objectA.yPos, objectA.zPos }; int[] objectArray2 = new int[] { objectB.xPos, objectB.yPos, objectB.zPos }; - final double distance = Math.sqrt( + return Math.sqrt( (objectArray2[0] - objectArray1[0]) * (objectArray2[0] - objectArray1[0]) + (objectArray2[1] - objectArray1[1]) * (objectArray2[1] - objectArray1[1]) + (objectArray2[2] - objectArray1[2]) * (objectArray2[2] - objectArray1[2])); - return distance; } @Override @@ -636,7 +629,7 @@ public class MTEWirelessCharger extends GTPPMetaTileEntity { PlayerUtils.messagePlayer(aPlayer, "Players with access:"); for (String name : this.getLocalMap() .keySet()) { - PlayerUtils.messagePlayer(aPlayer, "" + name); + PlayerUtils.messagePlayer(aPlayer, name); } } else { @@ -644,7 +637,7 @@ public class MTEWirelessCharger extends GTPPMetaTileEntity { PlayerUtils.messagePlayer(aPlayer, "Players with access:"); for (String name : this.getLongRangeMap() .keySet()) { - PlayerUtils.messagePlayer(aPlayer, "" + name); + PlayerUtils.messagePlayer(aPlayer, name); } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialChisel.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialChisel.java index 40a497fa06..d68fe3f8c7 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialChisel.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialChisel.java @@ -195,7 +195,7 @@ public class MTEIndustrialChisel extends GTPPMultiBlockBase // lets make sure the user isn't trying to make something from a block that doesn't have this as a valid target private static boolean hasChiselResults(ItemStack from) { List results = getItemsForChiseling(from); - return results.size() > 0; + return !results.isEmpty(); } private static List getItemsForChiseling(ItemStack aStack) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialDehydrator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialDehydrator.java index eb7e6baa9c..8b63f34edb 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialDehydrator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialDehydrator.java @@ -62,7 +62,7 @@ public class MTEIndustrialDehydrator extends GTPPMultiBlockBase implements ISurvi if (!aEntities.isEmpty()) { for (EntityLivingBase aFoundEntity : aEntities) { if (aFoundEntity instanceof EntityPlayer aPlayer) { - if (PlayerUtils.isCreative(aPlayer) || !PlayerUtils.canTakeDamage(aPlayer)) { - continue; - } else { + if (!PlayerUtils.isCreative(aPlayer) && PlayerUtils.canTakeDamage(aPlayer)) { if (aFoundEntity.getHealth() > 0) { EntityUtils.doDamage(aFoundEntity, mIsaMillDamageSource, getPlayerDamageValue(aPlayer, 10)); if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive())) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTECyclotron.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTECyclotron.java index 4c313a3be3..6952dd5c24 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTECyclotron.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTECyclotron.java @@ -264,7 +264,7 @@ public class MTECyclotron extends GTPPMultiBlockBase implements IS @Override public boolean onRunningTick(ItemStack aStack) { - if (this.mOutputBusses.size() > 0) { + if (!this.mOutputBusses.isEmpty()) { for (MTEHatchOutputBus g : this.mOutputBusses) { if (g != null) { for (ItemStack s : g.mInventory) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEElementalDuplicator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEElementalDuplicator.java index a241238e42..32ea79cc55 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEElementalDuplicator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEElementalDuplicator.java @@ -152,7 +152,7 @@ public class MTEElementalDuplicator extends GTPPMultiBlockBase x.mReplicatorDataOrbHatches.size() >= 1) + .shouldReject(x -> !x.mReplicatorDataOrbHatches.isEmpty()) .adder(MTEElementalDuplicator::addDataOrbHatch) .casingIndex(getCasingTextureIndex()) .dot(1) @@ -172,7 +172,7 @@ public class MTEElementalDuplicator extends GTPPMultiBlockBase= 9; boolean aCheckHatch = checkHatch(); - log("" + aCheckPiece + ", " + aCasingCount + ", " + aCheckHatch); + log(aCheckPiece + ", " + aCasingCount + ", " + aCheckHatch); return aCheckPiece && aCasingCount && aCheckHatch; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTELargeRocketEngine.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTELargeRocketEngine.java index f2ddecb687..b9e1d7858c 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTELargeRocketEngine.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTELargeRocketEngine.java @@ -132,8 +132,8 @@ public class MTELargeRocketEngine extends GTPPMultiBlockBase getStructureDefinition() { - if (this.STRUCTURE_DEFINITION == null) { - this.STRUCTURE_DEFINITION = StructureDefinition.builder() + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() .addShape( this.mName, transpose( @@ -161,7 +161,7 @@ public class MTELargeRocketEngine extends GTPPMultiBlockBase= 64 - 48 - && this.mAirIntakes.size() >= 1 + && !this.mAirIntakes.isEmpty() && checkHatch(); } @@ -270,7 +270,7 @@ public class MTELargeRocketEngine extends GTPPMultiBlockBase 0 && getRecipeMap() != null) { + if (!tFluids.isEmpty() && getRecipeMap() != null) { if (this.mRuntime % 72 == 0) { if (!consumeCO2()) { this.freeFuelTicks = 0; @@ -375,7 +375,7 @@ public class MTELargeRocketEngine extends GTPPMultiBlockBase 0) { + if (!this.mAllDynamoHatches.isEmpty()) { return addEnergyOutputMultipleDynamos(aEU, true); } return false; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTENuclearReactor.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTENuclearReactor.java index 3da77cf783..31caefe8f2 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTENuclearReactor.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTENuclearReactor.java @@ -261,7 +261,7 @@ public class MTENuclearReactor extends GTPPMultiBlockBase imp public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { mCasing = 0; if (checkPiece(mName, 3, 3, 0) && mCasing >= 27) { - if ((mOutputHatches.size() >= 3 || canDumpFluidToME()) && mInputHatches.size() >= 1 + if ((mOutputHatches.size() >= 3 || canDumpFluidToME()) && !mInputHatches.isEmpty() && mDynamoHatches.size() == 4 && mMufflerHatches.size() == 4) { this.turnCasingActive(false); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTERefinery.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTERefinery.java index f7f992e191..9b28387849 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTERefinery.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTERefinery.java @@ -175,7 +175,7 @@ public class MTERefinery extends GTPPMultiBlockBase implements ISur mCasing = 0; if (checkPiece(mName, 1, 7, 0) && mCasing >= 7) { if (this.mInputHatches.size() >= 2 && this.mInputHatches.size() <= 4 - && this.mOutputHatches.size() >= 1 + && !this.mOutputHatches.isEmpty() && this.mOutputHatches.size() <= 2 && this.mMufflerHatches.size() == 1 && this.mMaintenanceHatches.size() == 1 diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTESolarTower.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTESolarTower.java index 085cb1b784..31ed44d5a3 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTESolarTower.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTESolarTower.java @@ -281,8 +281,8 @@ public class MTESolarTower extends GTPPMultiBlockBase implements boolean aAllCasings = aCasingCount1 && aCasingCount2 && aCasingCount3 && aCasingCount4; if (!aAllCasings || !aAllStructure || mMaintenanceHatches.size() != 1 - || mInputHatches.size() < 1 - || mOutputHatches.size() < 1) { + || mInputHatches.isEmpty() + || mOutputHatches.isEmpty()) { log( "Bad Hatches - Solar Heaters: " + mSolarHeaters.size() + ", Maint: " @@ -486,7 +486,7 @@ public class MTESolarTower extends GTPPMultiBlockBase implements // log("Found Ring: "+(aRing++)+", Total: "+this.mSolarHeaters.size()); } } - return mSolarHeaters.size() > 0; + return !mSolarHeaters.isEmpty(); } private boolean addSolarHeater(IGregTechTileEntity aTileEntity, int a) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTETreeFarm.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTETreeFarm.java index bb5754bef7..5478014c62 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTETreeFarm.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTETreeFarm.java @@ -266,8 +266,7 @@ public class MTETreeFarm extends GTPPMultiBlockBase implements ISur * In previous versions, a saw used to go in the controller slot. We do not want an update to stop processing of * a machine set up like this. Instead, a sapling is placed in this slot at the start of the next operation. */ - if (aStack.getItem() instanceof MetaGeneratedTool01) return true; - return false; + return aStack.getItem() instanceof MetaGeneratedTool01; } @Override diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/MTEAlgaePondBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/MTEAlgaePondBase.java index 49e9878bec..6b266908ce 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/MTEAlgaePondBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/MTEAlgaePondBase.java @@ -183,8 +183,8 @@ public class MTEAlgaePondBase extends GTPPMultiBlockBase imple if (checkPiece(mName, 4, 2, 0) && mCasing >= 64 && checkMeta > 0 - && mInputHatches.size() >= 1 - && mOutputBusses.size() >= 1) { + && !mInputHatches.isEmpty() + && !mOutputBusses.isEmpty()) { mLevel = checkMeta - 1; for (MTEHatchInput inputHatch : mInputHatches) { if (inputHatch.mTier < mLevel) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/MTEChemicalPlant.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/MTEChemicalPlant.java index a6794809ef..1e5d1bb9ea 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/MTEChemicalPlant.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/MTEChemicalPlant.java @@ -80,7 +80,7 @@ public class MTEChemicalPlant extends GTPPMultiBlockBase imple private int mPipeCasingTier = 0; private int mCoilTier = 0; private HeatingCoilLevel checkCoil; - private int[] checkCasing = new int[8]; + private final int[] checkCasing = new int[8]; private int checkMachine; private int checkPipe; private int maxTierOfHatch; @@ -114,10 +114,8 @@ public class MTEChemicalPlant extends GTPPMultiBlockBase imple if (!mTieredBlockRegistry.containsKey(aTier)) { return 10; } - int aCasingID = mTieredBlockRegistry.get(aTier) + return mTieredBlockRegistry.get(aTier) .getValue_3(); - // Logger.INFO("Found casing texture ID "+aCasingID+" for tier "+aTier); - return aCasingID; } @Override @@ -216,7 +214,7 @@ public class MTEChemicalPlant extends GTPPMultiBlockBase imple .dot(1) .build(), buildHatchAdder(MTEChemicalPlant.class).hatchClass(MTEHatchCatalysts.class) - .shouldReject(t -> t.mCatalystBuses.size() >= 1) + .shouldReject(t -> !t.mCatalystBuses.isEmpty()) .adder(MTEChemicalPlant::addChemicalPlantList) .casingIndex(getCasingTextureID()) .dot(1) diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineGas.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineGas.java index 93ec17e6ea..1e44eb95c3 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineGas.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineGas.java @@ -25,7 +25,6 @@ import gregtech.api.util.GTRecipe; import gregtech.api.util.GTUtility; import gregtech.api.util.TurbineStatCalculator; -@SuppressWarnings("deprecation") public class MTELargeTurbineGas extends MTELargerTurbineBase { private static final HashSet BLACKLIST = new HashSet<>(); @@ -110,7 +109,7 @@ public class MTELargeTurbineGas extends MTELargerTurbineBase { @Override long fluidIntoPower(ArrayList aFluids, TurbineStatCalculator turbine) { - if (aFluids.size() >= 1) { + if (!aFluids.isEmpty()) { int tEU = 0; int actualOptimalFlow = 0; FluidStack firstFuelType = new FluidStack(aFluids.get(0), 0); // Identify a SINGLE type of fluid to process. @@ -153,15 +152,12 @@ public class MTELargeTurbineGas extends MTELargerTurbineBase { if (totalFlow <= 0) return 0; tEU = GTUtility.safeInt((long) totalFlow * fuelValue); - if (totalFlow == actualOptimalFlow) { - tEU = GTUtility.safeInt( - (long) (tEU * (isLooseMode() ? turbine.getLooseGasEfficiency() : turbine.getGasEfficiency()))); - } else { + if (totalFlow != actualOptimalFlow) { float efficiency = 1.0f - Math.abs((totalFlow - actualOptimalFlow) / (float) actualOptimalFlow); tEU *= efficiency; - tEU = GTUtility.safeInt( - (long) (tEU * (isLooseMode() ? turbine.getLooseGasEfficiency() : turbine.getGasEfficiency()))); } + tEU = GTUtility + .safeInt((long) (tEU * (isLooseMode() ? turbine.getLooseGasEfficiency() : turbine.getGasEfficiency()))); return tEU; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineSHSteam.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineSHSteam.java index 25650fad08..5fbcb237fd 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineSHSteam.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineSHSteam.java @@ -14,7 +14,6 @@ import gregtech.api.util.TurbineStatCalculator; import gtPlusPlus.core.lib.GTPPCore; import gtPlusPlus.core.util.math.MathUtils; -@SuppressWarnings("deprecation") public class MTELargeTurbineSHSteam extends MTELargerTurbineBase { public boolean achievement = false; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineSteam.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineSteam.java index 0de134950c..beeaa2726b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineSteam.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargeTurbineSteam.java @@ -14,7 +14,6 @@ import gregtech.api.util.GTModHandler; import gregtech.api.util.TurbineStatCalculator; import gtPlusPlus.core.util.math.MathUtils; -@SuppressWarnings("deprecation") public class MTELargeTurbineSteam extends MTELargerTurbineBase { private float water; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargerTurbineBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargerTurbineBase.java index dc2f105bbb..fa9d60fb11 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargerTurbineBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargerTurbineBase.java @@ -214,11 +214,11 @@ public abstract class MTELargerTurbineBase extends GTPPMultiBlockBase= 0; slot--) { ItemStack aStack = aInputBus.getStackInSlot(slot); - if (aStack != null && GTUtility.areStacksEqual(aStack, aTurbine)) { + if (GTUtility.areStacksEqual(aStack, aTurbine)) { aStack.stackSize -= aTurbine.stackSize; updateSlots(); endRecipeProcessing(); @@ -421,7 +421,7 @@ public abstract class MTELargerTurbineBase extends GTPPMultiBlockBase aEmptyTurbineRotorHatches = getEmptyTurbineAssemblies(); - if (aEmptyTurbineRotorHatches.size() > 0) { + if (!aEmptyTurbineRotorHatches.isEmpty()) { hatch: for (MTEHatchTurbine aHatch : aEmptyTurbineRotorHatches) { ArrayList aTurbines = getAllBufferedTurbines(); for (ItemStack aTurbineItem : aTurbines) { @@ -436,7 +436,7 @@ public abstract class MTELargerTurbineBase extends GTPPMultiBlockBase 0 || !areAllTurbinesTheSame()) { + if (!getEmptyTurbineAssemblies().isEmpty() || !areAllTurbinesTheSame()) { stopMachine(ShutDownReasonRegistry.NO_TURBINE); return CheckRecipeResultRegistry.NO_TURBINE_FOUND; } @@ -448,7 +448,7 @@ public abstract class MTELargerTurbineBase extends GTPPMultiBlockBase 0) { + if (!tFluids.isEmpty()) { if (baseEff == 0 || optFlow == 0 || counter >= 512 || this.getBaseMetaTileEntity() @@ -606,7 +606,7 @@ public abstract class MTELargerTurbineBase extends GTPPMultiBlockBase 0) { + if (!this.mAllDynamoHatches.isEmpty()) { return addEnergyOutputMultipleDynamos(aEU, true); } return false; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargerTurbinePlasma.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargerTurbinePlasma.java index 3385125bb7..4f3626e7cd 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargerTurbinePlasma.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/MTELargerTurbinePlasma.java @@ -23,7 +23,6 @@ import gregtech.api.util.shutdown.ShutDownReasonRegistry; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.MTEHatchTurbine; -@SuppressWarnings("deprecation") public class MTELargerTurbinePlasma extends MTELargerTurbineBase { public MTELargerTurbinePlasma(int aID, String aName, String aNameRegional) { @@ -92,7 +91,7 @@ public class MTELargerTurbinePlasma extends MTELargerTurbineBase { try { ArrayList aEmptyTurbineRotorHatches = getEmptyTurbineAssemblies(); - if (aEmptyTurbineRotorHatches.size() > 0) { + if (!aEmptyTurbineRotorHatches.isEmpty()) { hatch: for (MTEHatchTurbine aHatch : aEmptyTurbineRotorHatches) { ArrayList aTurbines = getAllBufferedTurbines(); for (ItemStack aTurbineItem : aTurbines) { @@ -107,7 +106,7 @@ public class MTELargerTurbinePlasma extends MTELargerTurbineBase { } } - if (getEmptyTurbineAssemblies().size() > 0 || !areAllTurbinesTheSame()) { + if (!getEmptyTurbineAssemblies().isEmpty() || !areAllTurbinesTheSame()) { stopMachine(ShutDownReasonRegistry.NO_TURBINE); return CheckRecipeResultRegistry.NO_TURBINE_FOUND; } @@ -122,7 +121,7 @@ public class MTELargerTurbinePlasma extends MTELargerTurbineBase { ArrayList tFluids = getStoredFluids(); - if (tFluids.size() > 0) { + if (!tFluids.isEmpty()) { if (baseEff == 0 || optFlow == 0 || counter >= 512 || this.getBaseMetaTileEntity() @@ -169,7 +168,7 @@ public class MTELargerTurbinePlasma extends MTELargerTurbineBase { // formula: // EU/t = EU/t * MIN(1, ( ( (FuelValue / 200) ^ 2 ) / EUPerTurbine)) int fuelValue = 0; - if (tFluids.size() > 0) { + if (!tFluids.isEmpty()) { fuelValue = getFuelValue(new FluidStack(tFluids.get(0), 0)); } float magicValue = (fuelValue * 0.005f) * (fuelValue * 0.005f); @@ -181,7 +180,7 @@ public class MTELargerTurbinePlasma extends MTELargerTurbineBase { // Magic numbers: can always change by at least 200 eu/s, but otherwise by at most 20 percent of the // difference in power level (per second) // This is how much the turbine can actually change during this tick - int maxChangeAllowed = Math.max(200, GTUtility.safeInt((long) Math.abs(difference) / 5)); + int maxChangeAllowed = Math.max(200, GTUtility.safeInt(Math.abs(difference) / 5)); if (Math.abs(difference) > maxChangeAllowed) { // If this difference is too big, use the maximum allowed // change @@ -209,7 +208,7 @@ public class MTELargerTurbinePlasma extends MTELargerTurbineBase { } long fluidIntoPower(ArrayList aFluids, TurbineStatCalculator turbine) { - if (aFluids.size() >= 1) { + if (!aFluids.isEmpty()) { int tEU = 0; int actualOptimalFlow = 0; @@ -255,18 +254,12 @@ public class MTELargerTurbinePlasma extends MTELargerTurbineBase { if (totalFlow <= 0) return 0; tEU = GTUtility.safeInt((long) ((fuelValue / 20D) * (double) totalFlow)); - if (totalFlow == actualOptimalFlow) { - tEU = GTUtility.safeInt( - (long) ((isLooseMode() ? turbine.getLoosePlasmaEfficiency() : turbine.getPlasmaEfficiency()) - * tEU)); - } else { + if (totalFlow != actualOptimalFlow) { double efficiency = 1.0D - Math.abs((totalFlow - actualOptimalFlow) / (float) actualOptimalFlow); - tEU = (int) (tEU * efficiency); - tEU = GTUtility.safeInt( - (long) ((isLooseMode() ? turbine.getLoosePlasmaEfficiency() : turbine.getPlasmaEfficiency()) - * tEU)); } + tEU = GTUtility.safeInt( + (long) ((isLooseMode() ? turbine.getLoosePlasmaEfficiency() : turbine.getPlasmaEfficiency()) * tEU)); return tEU; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java index f392bff171..241b970ae8 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java @@ -81,7 +81,7 @@ import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMult public class GregtechMetaTileEntity_PowerSubStationController extends GTPPMultiBlockBase implements ISurvivalConstructable { - private static enum TopState { + private enum TopState { MayBeTop, Top, NotTop @@ -99,7 +99,7 @@ public class GregtechMetaTileEntity_PowerSubStationController private final int ENERGY_TAX = 5; private int mCasing; - private int[] cellCount = new int[6]; + private final int[] cellCount = new int[6]; private TopState topState = TopState.MayBeTop; private static IStructureDefinition STRUCTURE_DEFINITION = null; @@ -212,17 +212,13 @@ public class GregtechMetaTileEntity_PowerSubStationController } public static int getMaxHatchTier(int aCellTier) { - switch (aCellTier) { - case 9 -> { - return GTValues.VOLTAGE_NAMES[9].equals("Ultimate High Voltage") ? 15 : 9; - } - default -> { - if (aCellTier < 4) { - return 0; - } else { - return aCellTier; - } - } + if (aCellTier == 9) { + return GTValues.VOLTAGE_NAMES[9].equals("Ultimate High Voltage") ? 15 : 9; + } + if (aCellTier < 4) { + return 0; + } else { + return aCellTier; } } -- cgit