diff options
Diffstat (limited to 'src/main/java')
3 files changed, 15 insertions, 10 deletions
diff --git a/src/main/java/gregtech/api/GregTech_API.java b/src/main/java/gregtech/api/GregTech_API.java index ba7e3ab43e..3133536de2 100644 --- a/src/main/java/gregtech/api/GregTech_API.java +++ b/src/main/java/gregtech/api/GregTech_API.java @@ -426,7 +426,7 @@ public class GregTech_API { * @param aMeta the Metadata of the Blocks as Bitmask! -1 or ~0 for all Metavalues */ public static boolean registerMachineBlock(Block aBlock, int aMeta) { - if (GT_Utility.isBlockInvalid(aBlock)) + if (aBlock == null) return false; if (GregTech_API.sThaumcraftCompat != null) GregTech_API.sThaumcraftCompat.registerPortholeBlacklistedBlock(aBlock); @@ -438,7 +438,7 @@ public class GregTech_API { * Like above but with boolean Parameters instead of a BitMask */ public static boolean registerMachineBlock(Block aBlock, boolean... aMeta) { - if (GT_Utility.isBlockInvalid(aBlock) || aMeta == null || aMeta.length == 0) + if (aBlock == null || aMeta == null || aMeta.length == 0) return false; if (GregTech_API.sThaumcraftCompat != null) GregTech_API.sThaumcraftCompat.registerPortholeBlacklistedBlock(aBlock); @@ -452,9 +452,11 @@ public class GregTech_API { * if this Block is a Machine Update Conducting Block */ public static boolean isMachineBlock(Block aBlock, int aMeta) { - if (GT_Utility.isBlockInvalid(aBlock)) - return false; - return (sMachineIDs.containsKey(aBlock) && (sMachineIDs.get(aBlock) & B[aMeta]) != 0); + if (aBlock != null) { + Integer id = sMachineIDs.get(aBlock); + return id != null && (id & B[aMeta]) != 0; + } + return false; } /** diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 8e839c8ba0..165ff71927 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -1286,6 +1286,7 @@ public class GT_Utility { return rList; } + @Deprecated // why do you use Objects? public static Block getBlock(Object aBlock) { return (Block) aBlock; } @@ -1299,12 +1300,14 @@ public class GT_Utility { return Block.getBlockFromItem(item); } + @Deprecated // why do you use Objects? And if you want to check your block to be not null, check it directly! public static boolean isBlockValid(Object aBlock) { return (aBlock instanceof Block); } + @Deprecated // why do you use Objects? And if you want to check your block to be null, check it directly! public static boolean isBlockInvalid(Object aBlock) { - return aBlock == null || !(aBlock instanceof Block); + return !(aBlock instanceof Block); } public static boolean isStringValid(Object aString) { diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java index e1dfc32aba..431241eb84 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java @@ -366,7 +366,7 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch { } private boolean hasValidFluid() { - return (!GT_Utility.isBlockInvalid(this.mPrimaryPumpedBlock) && !GT_Utility.isBlockInvalid(this.mSecondaryPumpedBlock)); + return mPrimaryPumpedBlock != null && mSecondaryPumpedBlock != null; } private boolean moveOneDown() { @@ -522,7 +522,7 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch { return; Block aBlock = getBaseMetaTileEntity().getBlock(aX, aY, aZ); - if (GT_Utility.isBlockValid(aBlock)) { + if (aBlock != null) { if ((aBlock == Blocks.water) || (aBlock == Blocks.flowing_water)) { this.mPrimaryPumpedBlock = Blocks.water; this.mSecondaryPumpedBlock = Blocks.flowing_water; @@ -549,7 +549,7 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch { Block aBlock = getBaseMetaTileEntity().getBlock(aX, aY, aZ); - return GT_Utility.isBlockValid(aBlock) && + return aBlock != null && (aBlock == Blocks.water || aBlock == Blocks.flowing_water || aBlock == Blocks.lava || @@ -565,7 +565,7 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch { Block aBlock = getBaseMetaTileEntity().getBlock(aX, aY, aZ); - if ((GT_Utility.isBlockValid(aBlock)) && ((this.mPrimaryPumpedBlock == aBlock) || (this.mSecondaryPumpedBlock == aBlock))) { + if (aBlock != null && ((this.mPrimaryPumpedBlock == aBlock) || (this.mSecondaryPumpedBlock == aBlock))) { boolean isWaterOrLava = ((this.mPrimaryPumpedBlock == Blocks.water || this.mPrimaryPumpedBlock == Blocks.lava)); if (isWaterOrLava && getBaseMetaTileEntity().getMetaID(aX, aY, aZ) != 0) { |