diff options
| author | Alexdoru <57050655+Alexdoru@users.noreply.github.com> | 2024-10-02 07:31:08 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-02 05:31:08 +0000 |
| commit | 3b9bd1188e932e6bb8041f7bb9afbf3ce75e26d3 (patch) | |
| tree | 107d9d2442891990ef1cdef1d8bb2df6bb96952a /src/main/java/gtPlusPlus/core/util | |
| parent | bfc7b2b07f72d0903a70791ff96f9c837ddd5ff0 (diff) | |
| download | GT5-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/util')
14 files changed, 111 insertions, 215 deletions
diff --git a/src/main/java/gtPlusPlus/core/util/Utils.java b/src/main/java/gtPlusPlus/core/util/Utils.java index fb05c6aa10..ee8ff5817a 100644 --- a/src/main/java/gtPlusPlus/core/util/Utils.java +++ b/src/main/java/gtPlusPlus/core/util/Utils.java @@ -193,7 +193,7 @@ public class Utils { .substring(1) .toUpperCase()); Logger.WARNING( - "" + Integer.toHexString(0x1000000 | i) + Integer.toHexString(0x1000000 | i) .substring(1) .toUpperCase()); } diff --git a/src/main/java/gtPlusPlus/core/util/data/ArrayUtils.java b/src/main/java/gtPlusPlus/core/util/data/ArrayUtils.java index d5ab990917..f0df1cb2b9 100644 --- a/src/main/java/gtPlusPlus/core/util/data/ArrayUtils.java +++ b/src/main/java/gtPlusPlus/core/util/data/ArrayUtils.java @@ -11,26 +11,26 @@ public class ArrayUtils { public static <V> V[] insertElementAtIndex(V[] aArray, int aIndex, V aObjectToInsert) { V[] newArray = Arrays.copyOf(aArray, aArray.length + 1); - for (int i = 0; i < aIndex; i++) { - newArray[i] = aArray[i]; + if (aIndex >= 0) { + System.arraycopy(aArray, 0, newArray, 0, aIndex); } newArray[aIndex] = aObjectToInsert; - for (int i = (aIndex + 1); i < newArray.length; i++) { - newArray[i] = aArray[i - 1]; + if (newArray.length - (aIndex + 1) >= 0) { + System.arraycopy(aArray, aIndex + 1 - 1, newArray, aIndex + 1, newArray.length - (aIndex + 1)); } return newArray; } public static Object[] removeNulls(final Object[] v) { List<Object> list = new ArrayList<>(Arrays.asList(v)); - list.removeAll(Collections.singleton((Object) null)); - return list.toArray(new Object[list.size()]); + list.removeAll(Collections.singleton(null)); + return list.toArray(new Object[0]); } public static ItemStack[] removeNulls(final ItemStack[] v) { List<ItemStack> list = new ArrayList<>(Arrays.asList(v)); list.removeAll(Collections.singleton((ItemStack) null)); - return list.toArray(new ItemStack[list.size()]); + return list.toArray(new ItemStack[0]); } public static String toString(Object[] aArray, String string) { diff --git a/src/main/java/gtPlusPlus/core/util/data/FileUtils.java b/src/main/java/gtPlusPlus/core/util/data/FileUtils.java index b2e5d04375..7b720e1145 100644 --- a/src/main/java/gtPlusPlus/core/util/data/FileUtils.java +++ b/src/main/java/gtPlusPlus/core/util/data/FileUtils.java @@ -19,10 +19,7 @@ public class FileUtils { private static final Charset utf8 = StandardCharsets.UTF_8; public static boolean doesFileExist(File f) { - if (f != null && f.exists() && !f.isDirectory()) { - return true; - } - return false; + return f != null && f.exists() && !f.isDirectory(); } public static File createFile(String path, String filename, String extension) { diff --git a/src/main/java/gtPlusPlus/core/util/data/StringUtils.java b/src/main/java/gtPlusPlus/core/util/data/StringUtils.java index c2a923bb75..b19f6c45fe 100644 --- a/src/main/java/gtPlusPlus/core/util/data/StringUtils.java +++ b/src/main/java/gtPlusPlus/core/util/data/StringUtils.java @@ -75,10 +75,9 @@ public class StringUtils { return true; } else if (s.contains(StringUtils.subscript("8"))) { return true; - } else if (s.contains(StringUtils.subscript("9"))) { - return true; + } else { + return s.contains(StringUtils.subscript("9")); } - return false; } public static String firstLetterCaps(String data) { @@ -138,6 +137,7 @@ public class StringUtils { for (int o = 0; o < aInput.length(); o++) { if (isSpecialCharacter(aInput.charAt(o))) { isSpecial = true; + break; } } if (isSpecial) { diff --git a/src/main/java/gtPlusPlus/core/util/math/MathUtils.java b/src/main/java/gtPlusPlus/core/util/math/MathUtils.java index 05e238b098..ba2ad0ca41 100644 --- a/src/main/java/gtPlusPlus/core/util/math/MathUtils.java +++ b/src/main/java/gtPlusPlus/core/util/math/MathUtils.java @@ -184,10 +184,7 @@ public class MathUtils { * @return boolean Whether or not it divides evenly. */ public static boolean isNumberEven(final long x) { - if ((x % 2) == 0) { - return true; - } - return false; + return x % 2 == 0; } /** @@ -211,7 +208,7 @@ public class MathUtils { final int randomInt = randInt(1, 5); final Map<Integer, String> colours = Utils.hexColourGeneratorRandom(5); - if ((colours.get(randomInt) != null) && (colours.size() > 0)) { + if ((colours.get(randomInt) != null) && (!colours.isEmpty())) { temp = colours.get(randomInt); } else { temp = "0F0F0F"; @@ -256,8 +253,7 @@ public class MathUtils { } public static int getRgbAsHex(final short[] RGBA) { - final int returnValue = Utils.rgbtoHexValue(RGBA[0], RGBA[1], RGBA[2]); - return (returnValue == 0) ? 0 : returnValue; + return Utils.rgbtoHexValue(RGBA[0], RGBA[1], RGBA[2]); } public static byte safeByte(long number) { @@ -336,8 +332,7 @@ public class MathUtils { for (byte i : aDataSet) { total += i; } - byte result = safeByte(total / divisor); - return result; + return safeByte(total / divisor); } public static short getShortAverage(short[] aDataSet) { @@ -365,8 +360,7 @@ public class MathUtils { for (int i : aDataSet) { total += i; } - int result = safeInt(total / divisor); - return result; + return safeInt(total / divisor); } public static long getLongAverage(long[] aDataSet) { @@ -454,31 +448,26 @@ public class MathUtils { } public static byte getSafeByte(Byte b) { - Byte a = safeCast(b); - return a; + return safeCast(b); } public static short getSafeShort(Short b) { - Short a = safeCast(b); - return a; + return safeCast(b); } public static int getSafeInt(Integer b) { - Integer a = safeCast(b); - return a; + return safeCast(b); } public static long getSafeLong(Long b) { - Long a = safeCast(b); - return a; + return safeCast(b); } public static int safeCast_LongToInt(long o) { if (o > Integer.MAX_VALUE) { return Integer.MAX_VALUE; } else { - int i = (int) o; - return i; + return (int) o; } } diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/FluidUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/FluidUtils.java index 95ba020887..8897682942 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/FluidUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/FluidUtils.java @@ -31,7 +31,7 @@ import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; public class FluidUtils { - private static HashMap<String, Fluid> sFluidCache = new HashMap<>(); + private static final HashMap<String, Fluid> sFluidCache = new HashMap<>(); public static FluidStack getWater(final int amount) { return FluidUtils.getFluidStack("water", amount); @@ -506,7 +506,7 @@ public class FluidUtils { aGenerateCell); } - public static final Fluid generateFluidNonMolten(final String unlocalizedName, final String localizedName, + public static Fluid generateFluidNonMolten(final String unlocalizedName, final String localizedName, final int MeltingPoint, final short[] RGBA, ItemStack dustStack, final ItemStack dustStack2, final int amountPerItem, final boolean aGenerateCell) { if (dustStack == null) { @@ -637,10 +637,7 @@ public class FluidUtils { if (aFStack5 != null) { return aFStack5; } - if (aFStack6 != null) { - return aFStack6; - } - return null; + return aFStack6; } public static FluidStack getWildcardFluidStack(Materials aMaterial, int amount) { @@ -654,11 +651,7 @@ public class FluidUtils { return aFStack2; } else if (aFStack3 != null) { return aFStack3; - } else if (aFStack4 != null) { - return aFStack4; - } else { - return null; - } + } else return aFStack4; } public static FluidStack getAir(int aAmount) { diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/InventoryUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/InventoryUtils.java index c8a7ed26da..b690c35199 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/InventoryUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/InventoryUtils.java @@ -17,8 +17,7 @@ public class InventoryUtils { public static void dropInventoryItems(World world, int x, int y, int z, Block block) { TileEntity tileentity = world.getTileEntity(x, y, z); - if (tileentity != null && tileentity instanceof IInventory aTileInv - && ((IInventory) tileentity).getSizeInventory() > 0) { + if (tileentity instanceof IInventory aTileInv && ((IInventory) tileentity).getSizeInventory() > 0) { int aMinSlot = 0; int aMaxSlot = aTileInv.getSizeInventory() - 1; diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/ItemUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/ItemUtils.java index 7b66ffefa1..5b2065558d 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/ItemUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/ItemUtils.java @@ -103,25 +103,16 @@ public class ItemUtils { if (ItemList.Cell_Empty.hasBeenSet()) { return ItemList.Cell_Empty.get(i); } - final ItemStack temp = GTModHandler.getModItem(IndustrialCraft2.ID, "itemCellEmpty", i, 0); - return temp != null ? temp : null; + return GTModHandler.getModItem(IndustrialCraft2.ID, "itemCellEmpty", i, 0); } public static void getItemForOreDict(final String FQRN, final String oreDictName, final String itemName, final int meta) { try { - Item em = null; final Item em1 = getItemFromFQRN(FQRN); - if (em1 != null) { - em = em1; - } - - if (em != null) { - - final ItemStack metaStack = new ItemStack(em, 1, meta); + final ItemStack metaStack = new ItemStack(em1, 1, meta); GTOreDictUnificator.registerOre(oreDictName, metaStack); - } } catch (final NullPointerException e) { Logger.ERROR(itemName + " not found. [NULL]"); @@ -147,17 +138,9 @@ public class ItemUtils { final int meta, final int itemstackSize) { if (MOD) { try { - Item em = null; final Item em1 = getItemFromFQRN(FQRN); - if (em1 != null) { - if (null == em) { - em = em1; - } - if (em != null) { - final ItemStack metaStack = new ItemStack(em, itemstackSize, meta); - return metaStack; - } + return new ItemStack(em1, itemstackSize, meta); } return null; } catch (final NullPointerException e) { @@ -170,17 +153,9 @@ public class ItemUtils { public static ItemStack simpleMetaStack(final String FQRN, final int meta, final int itemstackSize) { try { - Item em = null; final Item em1 = getItemFromFQRN(FQRN); - // Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); if (em1 != null) { - if (null == em) { - em = em1; - } - if (em != null) { - final ItemStack metaStack = new ItemStack(em, itemstackSize, meta); - return metaStack; - } + return new ItemStack(em1, itemstackSize, meta); } return null; } catch (final NullPointerException e) { @@ -249,7 +224,7 @@ public class ItemUtils { if (fqrnSplit.length == 2) { Logger.INFO("Mod: " + fqrnSplit[0] + ", Item: " + fqrnSplit[1]); return GameRegistry.findItemStack(fqrnSplit[0], fqrnSplit[1], Size); - } else if (fqrnSplit.length == 3 && fqrnSplit[2] != null && fqrnSplit[2].length() > 0) { + } else if (fqrnSplit.length == 3 && fqrnSplit[2] != null && !fqrnSplit[2].isEmpty()) { Logger.INFO("Mod: " + fqrnSplit[0] + ", Item: " + fqrnSplit[1] + ", Meta: " + fqrnSplit[2]); ItemStack aStack = GameRegistry.findItemStack(fqrnSplit[0], fqrnSplit[1], Size); int aMeta = Integer.parseInt(fqrnSplit[2]); @@ -282,8 +257,7 @@ public class ItemUtils { } if (oredictName.contains("rod")) { - String s = "stick" + oredictName.substring(3); - oredictName = s; + oredictName = "stick" + oredictName.substring(3); } // Banned Materials and replacements for GT5.8 compat. @@ -471,9 +445,9 @@ public class ItemUtils { final String unlocalizedName = Utils.sanitizeString(materialName); final int Colour = material.getRgbAsHex(); final String aChemForm = material.vChemicalFormula; - final boolean isChemFormvalid = (aChemForm != null && aChemForm.length() > 0); + final boolean isChemFormvalid = (aChemForm != null && !aChemForm.isEmpty()); Item[] output = null; - if (onlyLargeDust == false) { + if (!onlyLargeDust) { output = new Item[] { new BaseItemDustUnique( "itemDust" + unlocalizedName, @@ -514,10 +488,7 @@ public class ItemUtils { .contains("thorium")) { sRadiation = 1; } - if (sRadiation >= 1) { - return true; - } - return false; + return sRadiation >= 1; } public static int getRadioactivityLevel(final String materialName) { @@ -576,14 +547,14 @@ public class ItemUtils { final GameRegistry.UniqueIdentifier id = GameRegistry.findUniqueIdentifierFor(item); if (id != null) { final String modname = (id.modId == null ? id.name : id.modId); - value = ((id == null) || id.modId.equals("")) ? Minecraft.ID : modname; + value = ((id == null) || id.modId.isEmpty()) ? Minecraft.ID : modname; } } catch (final Throwable t) { try { final UniqueIdentifier t2 = GameRegistry.findUniqueIdentifierFor(Block.getBlockFromItem(item)); if (t2 != null) { final String modname = (t2.modId == null ? t2.name : t2.modId); - value = ((t2 == null) || t2.modId.equals("")) ? Minecraft.ID : modname; + value = ((t2 == null) || t2.modId.isEmpty()) ? Minecraft.ID : modname; } } catch (final Throwable t3) { t3.printStackTrace(); @@ -640,11 +611,7 @@ public class ItemUtils { String mName = Utils.sanitizeString(mMat.getLocalizedName()); String mItemName = mPrefix.name() + mName; - ItemStack gregstack = ItemUtils.getItemStackOfAmountFromOreDictNoBroken(mItemName, mAmount); - if (gregstack == null) { - return null; - } - return (gregstack); + return ItemUtils.getItemStackOfAmountFromOreDictNoBroken(mItemName, mAmount); } public static ItemStack getOrePrefixStack(OrePrefixes mPrefix, Materials mMat, int mAmount) { @@ -710,46 +677,34 @@ public class ItemUtils { return false; } - if (mInputs.length > 0) { - for (ItemStack stack : mInputs) { - if (stack != null) { - if (stack.getItem() != null) { - if (stack.getItem() == ModItems.AAA_Broken || stack.getItem() - .getClass() == ModItems.AAA_Broken.getClass()) { + for (ItemStack stack : mInputs) { + if (stack != null) { + if (stack.getItem() != null) { + if (stack.getItem() == ModItems.AAA_Broken || stack.getItem() + .getClass() == ModItems.AAA_Broken.getClass()) { + return false; + } else if (stack.getItem() == ModItems.ZZZ_Empty || stack.getItem() + .getClass() == ModItems.ZZZ_Empty.getClass()) { return false; - } else if (stack.getItem() == ModItems.ZZZ_Empty || stack.getItem() - .getClass() == ModItems.ZZZ_Empty.getClass()) { - return false; - } else { - continue; - } - } else { - continue; - } - } else { - return false; + } } + } else { + return false; } } - if (mOutputs.length > 0) { - for (ItemStack stack : mOutputs) { - if (stack != null) { - if (stack.getItem() != null) { - if (stack.getItem() == ModItems.AAA_Broken || stack.getItem() - .getClass() == ModItems.AAA_Broken.getClass()) { + for (ItemStack stack : mOutputs) { + if (stack != null) { + if (stack.getItem() != null) { + if (stack.getItem() == ModItems.AAA_Broken || stack.getItem() + .getClass() == ModItems.AAA_Broken.getClass()) { + return false; + } else if (stack.getItem() == ModItems.ZZZ_Empty || stack.getItem() + .getClass() == ModItems.ZZZ_Empty.getClass()) { return false; - } else if (stack.getItem() == ModItems.ZZZ_Empty || stack.getItem() - .getClass() == ModItems.ZZZ_Empty.getClass()) { - return false; - } else { - continue; - } - } else { - continue; - } - } else { - return false; + } } + } else { + return false; } } @@ -763,16 +718,23 @@ public class ItemUtils { } // ItemStack[] g = organiseInventory(p); - IInventory aTemp = aInputInventory; for (int i = 0; i < p.length; ++i) { for (int j = i + 1; j < p.length; ++j) { if (p[j] != null && (p[i] == null || GTUtility.areStacksEqual(p[i], p[j]))) { - GTUtility.moveStackFromSlotAToSlotB(aTemp, aTemp, j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + GTUtility.moveStackFromSlotAToSlotB( + aInputInventory, + aInputInventory, + j, + i, + (byte) 64, + (byte) 1, + (byte) 64, + (byte) 1); } } } - return aTemp; + return aInputInventory; } public static String getFluidName(FluidStack aFluid) { @@ -786,7 +748,7 @@ public class ItemUtils { } String aDisplay = null; try { - aDisplay = ("" + StatCollector.translateToLocal( + aDisplay = (StatCollector.translateToLocal( aStack.getItem() .getUnlocalizedNameInefficiently(aStack) + ".name")).trim(); if (aStack.hasTagCompound()) { @@ -834,21 +796,15 @@ public class ItemUtils { final Item mItem = aStack.getItem(); final Item aSkookum = ItemUtils.getItemFromFQRN("miscutils:gt.plusplus.metatool.01"); final Class aSkookClass = aSkookum.getClass(); - if (aSkookClass.isInstance(mItem) || mItem instanceof MetaGeneratedTool01 + return aSkookClass.isInstance(mItem) || mItem instanceof MetaGeneratedTool01 || mItem instanceof MetaGeneratedGregtechTools || mItem instanceof GTMetaTool - || mItem == aSkookum) { - return true; - } - return false; + || mItem == aSkookum; } public static boolean isToolScrewdriver(ItemStack aScrewdriver) { - if (isItemGregtechTool(aScrewdriver) - && (aScrewdriver.getItemDamage() == 22 || aScrewdriver.getItemDamage() == 150)) { - return true; - } - return false; + return isItemGregtechTool(aScrewdriver) + && (aScrewdriver.getItemDamage() == 22 || aScrewdriver.getItemDamage() == 150); } public static ItemStack[] cleanItemStackArray(ItemStack[] input) { @@ -900,14 +856,12 @@ public class ItemUtils { public static boolean isControlCircuit(ItemStack aStack) { if (aStack != null) { Item aItem = aStack.getItem(); - if (aItem == CI.getNumberedBioCircuit(0) + return aItem == CI.getNumberedBioCircuit(0) .getItem() || aItem == GTUtility.getIntegratedCircuit(0) .getItem() || aItem == CI.getNumberedAdvancedCircuit(0) - .getItem()) { - return true; - } + .getItem(); } return false; } @@ -997,20 +951,13 @@ public class ItemUtils { if (GTUtility.areStacksEqual(aStack, GenericChem.mSynchrotronCapableCatalyst, true)) { return true; } - if (GTUtility.areStacksEqual(aStack, GenericChem.mAlgagenicGrowthPromoterCatalyst, true)) { - return true; - } - - return false; + return GTUtility.areStacksEqual(aStack, GenericChem.mAlgagenicGrowthPromoterCatalyst, true); } public static boolean isMillingBall(ItemStack aStack) { if (GTUtility.areStacksEqual(aStack, GenericChem.mMillingBallAlumina, true)) { return true; } - if (GTUtility.areStacksEqual(aStack, GenericChem.mMillingBallSoapstone, true)) { - return true; - } - return false; + return GTUtility.areStacksEqual(aStack, GenericChem.mMillingBallSoapstone, true); } } diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/MaterialUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/MaterialUtils.java index 5e75cc2050..33d68711a2 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/MaterialUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/MaterialUtils.java @@ -196,10 +196,7 @@ public class MaterialUtils { } public static boolean hasValidRGBA(final short[] rgba) { - if (rgba == null || rgba.length < 3 || rgba.length > 4) { - return false; - } - return true; + return rgba != null && rgba.length >= 3 && rgba.length <= 4; } public static int getTierOfMaterial(final double aMeltingPoint) { diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/NBTUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/NBTUtils.java index bff2a25386..51be886acd 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/NBTUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/NBTUtils.java @@ -24,7 +24,7 @@ public class NBTUtils { public static ItemStack[] readItemsFromNBT(ItemStack itemstack) { NBTTagCompound tNBT = getNBT(itemstack); final NBTTagList list = tNBT.getTagList("Items", 10); - ItemStack inventory[] = new ItemStack[list.tagCount()]; + ItemStack[] inventory = new ItemStack[list.tagCount()]; for (int i = 0; i < list.tagCount(); i++) { final NBTTagCompound data = list.getCompoundTagAt(i); final int slot = data.getInteger("Slot"); @@ -125,10 +125,7 @@ public class NBTUtils { public static boolean hasKey(ItemStack stack, String key) { final NBTTagCompound itemData = getNBT(stack); - if (itemData.hasKey(key)) { - return true; - } - return false; + return itemData.hasKey(key); } public static boolean createIntegerTagCompound(ItemStack rStack, String tagName, String keyName, int keyValue) { @@ -144,9 +141,7 @@ public class NBTUtils { NBTTagCompound aNBT = getNBT(aStack); if (aNBT != null && hasKey(aStack, tagName)) { aNBT = aNBT.getCompoundTag(tagName); - if (aNBT != null) { - return aNBT; - } + return aNBT; } return null; } diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/PlayerUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/PlayerUtils.java index 6f50da5eb2..5f639f3739 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/PlayerUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/PlayerUtils.java @@ -29,9 +29,8 @@ public class PlayerUtils { .getClass("thaumcraft.common.lib.FakeThaumcraftPlayer"); public static List<EntityPlayerMP> getOnlinePlayers() { - final List<EntityPlayerMP> onlinePlayers = MinecraftServer.getServer() + return MinecraftServer.getServer() .getConfigurationManager().playerEntityList; - return onlinePlayers; } public static void messagePlayer(final EntityPlayer P, final String S) { diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/RecipeUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/RecipeUtils.java index 792119d1bc..7f70230070 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/RecipeUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/RecipeUtils.java @@ -134,7 +134,6 @@ public class RecipeUtils { if ((is != null) && (is.getItem() == I)) { items.remove(); Logger.RECIPE("Remove a recipe with " + I.getUnlocalizedName() + " as output."); - continue; } } Logger.RECIPE("All recipes should be gone?"); @@ -195,10 +194,7 @@ public class RecipeUtils { return false; } // let gregtech handle shapeless recipes. - if (GTModHandler.addShapelessCraftingRecipe(OutputItem, inputItems)) { - return true; - } - return false; + return GTModHandler.addShapelessCraftingRecipe(OutputItem, inputItems); } public static boolean generateMortarRecipe(ItemStack aStack, ItemStack aOutput) { @@ -254,12 +250,8 @@ public class RecipeUtils { Logger.RECIPE("Using " + validCounter + " valid inputs and " + invalidCounter + " invalid inputs."); ShapedRecipe r = new ShapedRecipe(aFiltered, mOutput); - if (r != null && r.mRecipe != null) { - isValid = true; - } else { - isValid = false; - } - mRecipe = r != null ? r.mRecipe : null; + isValid = r.mRecipe != null; + mRecipe = r.mRecipe; } @Override @@ -298,7 +290,7 @@ public class RecipeUtils { int tList_sS = tList.size(); for (int i = 0; i < tList_sS; ++i) { - IRecipe tRecipe = (IRecipe) tList.get(i); + IRecipe tRecipe = tList.get(i); if (!aNotRemoveShapelessRecipes || !(tRecipe instanceof ShapelessRecipes) && !(tRecipe instanceof ShapelessOreRecipe)) { if (aOnlyRemoveNativeHandlers) { @@ -341,7 +333,7 @@ public class RecipeUtils { private static boolean addShapedRecipe(Object[] Inputs, ItemStack aOutputStack) { Object[] Slots = new Object[9]; - String aFullString = ""; + StringBuilder aFullString = new StringBuilder(); String aFullStringExpanded = "abcdefghi"; for (int i = 0; i < 9; i++) { @@ -349,23 +341,23 @@ public class RecipeUtils { if (o instanceof ItemStack) { Slots[i] = ItemUtils.getSimpleStack((ItemStack) o, 1); - aFullString += aFullStringExpanded.charAt(i); + aFullString.append(aFullStringExpanded.charAt(i)); } else if (o instanceof Item) { Slots[i] = ItemUtils.getSimpleStack((Item) o, 1); - aFullString += aFullStringExpanded.charAt(i); + aFullString.append(aFullStringExpanded.charAt(i)); } else if (o instanceof Block) { Slots[i] = ItemUtils.getSimpleStack((Block) o, 1); - aFullString += aFullStringExpanded.charAt(i); + aFullString.append(aFullStringExpanded.charAt(i)); } else if (o instanceof String) { Slots[i] = o; - aFullString += aFullStringExpanded.charAt(i); + aFullString.append(aFullStringExpanded.charAt(i)); } else if (o instanceof ItemData aData) { ItemStack aStackFromGT = ItemUtils.getOrePrefixStack(aData.mPrefix, aData.mMaterial.mMaterial, 1); Slots[i] = aStackFromGT; - aFullString += aFullStringExpanded.charAt(i); + aFullString.append(aFullStringExpanded.charAt(i)); } else if (o == null) { Slots[i] = null; - aFullString += " "; + aFullString.append(" "); } else { Slots[i] = null; Logger.INFO( @@ -380,9 +372,9 @@ public class RecipeUtils { String aRow1 = aFullString.substring(0, 3); String aRow2 = aFullString.substring(3, 6); String aRow3 = aFullString.substring(6, 9); - Logger.RECIPE("" + aRow1); - Logger.RECIPE("" + aRow2); - Logger.RECIPE("" + aRow3); + Logger.RECIPE(aRow1); + Logger.RECIPE(aRow2); + Logger.RECIPE(aRow3); String[] aStringData = new String[] { aRow1, aRow2, aRow3 }; Object[] aDataObject = new Object[19]; @@ -436,11 +428,7 @@ public class RecipeUtils { public InternalRecipeObject2(ShapedOreRecipe aRecipe) { mRecipe = aRecipe; mOutput = aRecipe.getRecipeOutput(); - if (mOutput != null) { - this.isValid = true; - } else { - this.isValid = false; - } + this.isValid = mOutput != null; } @Override diff --git a/src/main/java/gtPlusPlus/core/util/recipe/RecipeHashStrat.java b/src/main/java/gtPlusPlus/core/util/re |
