From b510ec5baafd4ff69bac158631fc4e4ca93b342d Mon Sep 17 00:00:00 2001 From: chill Date: Sat, 27 May 2023 17:41:53 +0200 Subject: Refactor checkExoticAndNormalEnergyHatches (#2025) * add tests to checkExoticAndNormalEnergyHatches Add a parameterized test to GT_MetaTileEntity_MultiBlockBase::checkExoticAndNormalEnergyHatches in order to be sure that the function returns the same results after the change. * refactor checkExoticAndNormalEnergyHatches --- .../GT_MetaTileEntity_MultiBlockBase.java | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/main/java/gregtech') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java index 7eacf05b4e..af0219c4b1 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java @@ -25,6 +25,7 @@ import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.TestOnly; import org.lwjgl.input.Keyboard; import com.google.common.collect.Iterables; @@ -96,7 +97,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity public ArrayList mMufflerHatches = new ArrayList<>(); public ArrayList mEnergyHatches = new ArrayList<>(); public ArrayList mMaintenanceHatches = new ArrayList<>(); - protected final List mExoticEnergyHatches = new ArrayList<>(); + protected List mExoticEnergyHatches = new ArrayList<>(); @SideOnly(Side.CLIENT) protected GT_SoundLoop activitySoundLoop; @@ -1505,7 +1506,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity return false; } - if (mExoticEnergyHatches.size() >= 1) { + if (!mExoticEnergyHatches.isEmpty()) { if (!mEnergyHatches.isEmpty()) { return false; } @@ -1515,11 +1516,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity } } - if (mEnergyHatches.size() > 2) { - return false; - } - - return true; + return mEnergyHatches.size() <= 2; } /** @@ -1917,4 +1914,14 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity .setTooltipShowUpDelay(TOOLTIP_DELAY); return (ButtonWidget) button; } + + @TestOnly + protected void setEnergyHatches(ArrayList EnergyHatches) { + this.mEnergyHatches = EnergyHatches; + } + + @TestOnly + protected void setExoticEnergyHatches(List ExoticEnergyHatches) { + this.mExoticEnergyHatches = ExoticEnergyHatches; + } } -- cgit