diff options
Diffstat (limited to 'src/main/java/gregtech/api/util')
47 files changed, 10868 insertions, 5173 deletions
diff --git a/src/main/java/gregtech/api/util/ColorsMetadataSection.java b/src/main/java/gregtech/api/util/ColorsMetadataSection.java index 2851435061..9f1c4f3ffe 100644 --- a/src/main/java/gregtech/api/util/ColorsMetadataSection.java +++ b/src/main/java/gregtech/api/util/ColorsMetadataSection.java @@ -2,10 +2,8 @@ package gregtech.api.util; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import java.util.Map; import java.util.HashMap; -import gregtech.api.util.GT_Log; -import gregtech.api.GregTech_API; +import java.util.Map; import net.minecraft.client.resources.data.IMetadataSection; @SideOnly(Side.CLIENT) @@ -16,7 +14,8 @@ public class ColorsMetadataSection implements IMetadataSection { private final Map<String, String> hexGuiTints; private final boolean guiTintEnabled; - public ColorsMetadataSection(Map<String, String> hexTextColorMap, Map<String, String> hexGuiTintMap, boolean guiTintEnabled) { + public ColorsMetadataSection( + Map<String, String> hexTextColorMap, Map<String, String> hexGuiTintMap, boolean guiTintEnabled) { this.hexTextColors = hexTextColorMap; this.textColors = convertHexMapToIntMap(hexTextColorMap); @@ -26,16 +25,15 @@ public class ColorsMetadataSection implements IMetadataSection { this.guiTintEnabled = guiTintEnabled; } - private Map<String, Integer> convertHexMapToIntMap(Map <String, String> hexMap) { + private Map<String, Integer> convertHexMapToIntMap(Map<String, String> hexMap) { Map<String, Integer> intMap = new HashMap<>(); for (String key : hexMap.keySet()) { int colorValue = -1; String hex = hexMap.get(key); try { - if (!hex.isEmpty()) colorValue = Integer.parseUnsignedInt(hex,16); - } - catch (final NumberFormatException e) { + if (!hex.isEmpty()) colorValue = Integer.parseUnsignedInt(hex, 16); + } catch (final NumberFormatException e) { GT_Log.err.println("Couldn't format color correctly of " + key + " -> " + hex); } intMap.put(key, colorValue); @@ -51,7 +49,7 @@ public class ColorsMetadataSection implements IMetadataSection { return sColorInMap(key, this.hexGuiTints) ? defaultColor : this.guiTints.get(key); } - private boolean sColorInMap(String key, Map<String,String> hexMap) { + private boolean sColorInMap(String key, Map<String, String> hexMap) { return hexMap.containsKey(key) && hexMap.get(key).isEmpty(); } diff --git a/src/main/java/gregtech/api/util/ColorsMetadataSectionSerializer.java b/src/main/java/gregtech/api/util/ColorsMetadataSectionSerializer.java index 4de8463685..718ff81854 100644 --- a/src/main/java/gregtech/api/util/ColorsMetadataSectionSerializer.java +++ b/src/main/java/gregtech/api/util/ColorsMetadataSectionSerializer.java @@ -7,26 +7,29 @@ import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import java.lang.reflect.Type; -import java.util.Map; -import java.util.HashMap; import gregtech.api.GregTech_API; import gregtech.api.enums.Dyes; -import net.minecraft.util.JsonUtils; +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.Map; import net.minecraft.client.resources.data.BaseMetadataSectionSerializer; +import net.minecraft.util.JsonUtils; @SideOnly(Side.CLIENT) public class ColorsMetadataSectionSerializer extends BaseMetadataSectionSerializer implements JsonSerializer { - public ColorsMetadataSection deserialize(JsonElement metadataColors, Type type, JsonDeserializationContext context) { + public ColorsMetadataSection deserialize( + JsonElement metadataColors, Type type, JsonDeserializationContext context) { // Default values boolean enableGuiTint = GregTech_API.sColoredGUI; Map<String, String> hexGuiTintMap = new HashMap<String, String>(); - Map<String, String> hexTextColorMap = new HashMap<String, String>() {{ - put("title", ""); - put("text", ""); - put("value", ""); - put("nei", ""); - }}; + Map<String, String> hexTextColorMap = new HashMap<String, String>() { + { + put("title", ""); + put("text", ""); + put("value", ""); + put("nei", ""); + } + }; JsonObject jsonObject = JsonUtils.getJsonElementAsJsonObject(metadataColors, "metadata section"); if (jsonObject.has("textColor")) { @@ -38,7 +41,8 @@ public class ColorsMetadataSectionSerializer extends BaseMetadataSectionSerializ if (jsonObject.has("guiTint")) { JsonObject guiTints = JsonUtils.func_152754_s(jsonObject, "guiTint"); - enableGuiTint = JsonUtils.getJsonObjectBooleanFieldValueOrDefault(guiTints, "enableGuiTintWhenPainted", true); + enableGuiTint = + JsonUtils.getJsonObjectBooleanFieldValueOrDefault(guiTints, "enableGuiTintWhenPainted", true); for (Dyes dye : Dyes.values()) { hexGuiTintMap.put(dye.mName, GT_Util.toHexString(dye.getRGBA())); @@ -46,7 +50,9 @@ public class ColorsMetadataSectionSerializer extends BaseMetadataSectionSerializ for (String key : hexGuiTintMap.keySet()) { if (enableGuiTint) { - hexGuiTintMap.replace(key, JsonUtils.getJsonObjectStringFieldValueOrDefault(guiTints, key, hexGuiTintMap.get(key))); + hexGuiTintMap.replace( + key, + JsonUtils.getJsonObjectStringFieldValueOrDefault(guiTints, key, hexGuiTintMap.get(key))); } else { hexGuiTintMap.replace(key, GT_Util.toHexString(Dyes.dyeWhite.getRGBA())); } diff --git a/src/main/java/gregtech/api/util/GT_ApiaryUpgrade.java b/src/main/java/gregtech/api/util/GT_ApiaryUpgrade.java index e74b68111a..4cbd014cbc 100644 --- a/src/main/java/gregtech/api/util/GT_ApiaryUpgrade.java +++ b/src/main/java/gregtech/api/util/GT_ApiaryUpgrade.java @@ -3,13 +3,12 @@ package gregtech.api.util; import cpw.mods.fml.common.Loader; import gregtech.api.enums.OrePrefixes; import gregtech.common.items.GT_MetaGenerated_Item_03; +import java.util.*; +import java.util.function.Consumer; import net.bdew.gendustry.api.ApiaryModifiers; import net.bdew.gendustry.api.items.IApiaryUpgrade; import net.minecraft.item.ItemStack; -import java.util.*; -import java.util.function.Consumer; - public enum GT_ApiaryUpgrade { speed1(UNIQUE_INDEX.SPEED_UPGRADE, 32200, 1, 1), speed2(UNIQUE_INDEX.SPEED_UPGRADE, 32201, 1, 2), @@ -22,15 +21,17 @@ public enum GT_ApiaryUpgrade { speed8upgraded(UNIQUE_INDEX.SPEED_UPGRADE, 32208, 1, 8), ; - private enum UNIQUE_INDEX{ + private enum UNIQUE_INDEX { SPEED_UPGRADE, ; - void apply(Consumer<GT_ApiaryUpgrade> fn){ + + void apply(Consumer<GT_ApiaryUpgrade> fn) { UNIQUE_UPGRADE_LIST.get(this).forEach(fn); } } - private static final EnumMap<UNIQUE_INDEX, ArrayList<GT_ApiaryUpgrade>> UNIQUE_UPGRADE_LIST = new EnumMap<>(UNIQUE_INDEX.class); + private static final EnumMap<UNIQUE_INDEX, ArrayList<GT_ApiaryUpgrade>> UNIQUE_UPGRADE_LIST = + new EnumMap<>(UNIQUE_INDEX.class); private int meta = 0; private int maxnumber = 1; @@ -40,9 +41,10 @@ public enum GT_ApiaryUpgrade { private final UNIQUE_INDEX unique_index; private final HashMap<GT_Utility.ItemId, ItemStack> additionalGendustryUpgrades = new HashMap<>(); - private final HashSet<GT_Utility.ItemId> blacklistedUpgrades = new HashSet<>(); // additionalGendustryUpgrades are blacklisted by default + private final HashSet<GT_Utility.ItemId> blacklistedUpgrades = + new HashSet<>(); // additionalGendustryUpgrades are blacklisted by default - GT_ApiaryUpgrade(UNIQUE_INDEX unique_index, int meta, int maxnumber, int maxspeedmodifier){ + GT_ApiaryUpgrade(UNIQUE_INDEX unique_index, int meta, int maxnumber, int maxspeedmodifier) { this.unique_index = unique_index; this.meta = meta; this.maxnumber = maxnumber; @@ -50,11 +52,14 @@ public enum GT_ApiaryUpgrade { this.id = GT_Utility.ItemId.createNoCopy(get(1)); } - private void setup_static_variables(){ + private void setup_static_variables() { quickLookup.put(this.meta, this); ArrayList<GT_ApiaryUpgrade> un = UNIQUE_UPGRADE_LIST.get(this.unique_index); - if(un != null) - un.forEach((u) -> { u.blacklistedUpgrades.add(this.id); this.blacklistedUpgrades.add(u.id); }); + if (un != null) + un.forEach((u) -> { + u.blacklistedUpgrades.add(this.id); + this.blacklistedUpgrades.add(u.id); + }); else { un = new ArrayList<>(1); UNIQUE_UPGRADE_LIST.put(this.unique_index, un); @@ -62,45 +67,43 @@ public enum GT_ApiaryUpgrade { un.add(this); } - public static GT_ApiaryUpgrade getUpgrade(ItemStack s){ - if(s == null) - return null; - if(!isUpgrade(s)) - return null; + public static GT_ApiaryUpgrade getUpgrade(ItemStack s) { + if (s == null) return null; + if (!isUpgrade(s)) return null; return quickLookup.get(s.getItemDamage()); } - public boolean isAllowedToWorkWith(ItemStack s){ + public boolean isAllowedToWorkWith(ItemStack s) { GT_Utility.ItemId id = GT_Utility.ItemId.createNoCopy(s); return !additionalGendustryUpgrades.containsKey(id) && !blacklistedUpgrades.contains(id); } - public int getMaxNumber(){ + public int getMaxNumber() { return maxnumber; } - public void applyModifiers(ApiaryModifiers mods, ItemStack s){ - additionalGendustryUpgrades.forEach((k, u) -> ((IApiaryUpgrade)u.getItem()).applyModifiers(mods, u)); + public void applyModifiers(ApiaryModifiers mods, ItemStack s) { + additionalGendustryUpgrades.forEach((k, u) -> ((IApiaryUpgrade) u.getItem()).applyModifiers(mods, u)); } - public ItemStack get(int count){ + public ItemStack get(int count) { return new ItemStack(GT_MetaGenerated_Item_03.INSTANCE, count, meta); } - public static boolean isUpgrade(ItemStack s){ + public static boolean isUpgrade(ItemStack s) { return OrePrefixes.apiaryUpgrade.contains(s); } - public int applyMaxSpeedModifier(int maxspeed){ + public int applyMaxSpeedModifier(int maxspeed) { return Math.max(maxspeed, maxspeedmodifier); } private static final HashMap<Integer, GT_ApiaryUpgrade> quickLookup = new HashMap<>(); - static{ + static { EnumSet.allOf(GT_ApiaryUpgrade.class).forEach(GT_ApiaryUpgrade::setup_static_variables); - if(Loader.isModLoaded("gendustry")) { + if (Loader.isModLoaded("gendustry")) { ItemStack s = GT_ModHandler.getModItem("gendustry", "ApiaryUpgrade", 8L, 0); GT_Utility.ItemId a = GT_Utility.ItemId.createNoCopy(s); speed8upgraded.additionalGendustryUpgrades.put(a, s); diff --git a/src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java b/src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java index 4f9036f2c7..f20a78d494 100644 --- a/src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java +++ b/src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java @@ -2,17 +2,17 @@ package gregtech.api.util; import static gregtech.GT_Mod.GT_FML_LOGGER; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Objects; - import cpw.mods.fml.common.FMLCommonHandler; import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; import gregtech.api.objects.GT_ItemStack; import gregtech.api.util.GT_Recipe.GT_Recipe_AssemblyLine; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Objects; +import javax.annotation.Nonnull; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; @@ -20,509 +20,514 @@ import net.minecraft.nbt.NBTTagString; import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.fluids.FluidStack; -import javax.annotation.Nonnull; - public class GT_AssemblyLineUtils { - /** - * A cache of Recipes using the Output as Key. - */ - private static HashMap<GT_ItemStack, GT_Recipe_AssemblyLine> sRecipeCacheByOutput = new HashMap<GT_ItemStack, GT_Recipe_AssemblyLine>(); - /** - * A cache of Recipes using the Recipe Hash String as Key. - */ - private static HashMap<String, GT_Recipe_AssemblyLine> sRecipeCacheByRecipeHash = new HashMap<String, GT_Recipe_AssemblyLine>(); - - - - /** - * Checks the DataStick for deprecated/invalid recipes, updating them as required. - * @param aDataStick - The DataStick to process - * @return Is this DataStick now valid with a current recipe? - */ - public static GT_Recipe_AssemblyLine processDataStick(ItemStack aDataStick) { - if (!isItemDataStick(aDataStick)) { - return null; - } - if (doesDataStickNeedUpdate(aDataStick)) { - ItemStack aStickOutput = getDataStickOutput(aDataStick); - if (aStickOutput != null) { - GT_Recipe_AssemblyLine aIntendedRecipe = findAssemblyLineRecipeByOutput(aStickOutput); - if (aIntendedRecipe != null && setAssemblyLineRecipeOnDataStick(aDataStick, aIntendedRecipe)) - return aIntendedRecipe; - } - } - return null; - } - - - /** - * Finds an Assembly Line recipe from a DataStick. - * @param aDataStick - The DataStick to check. - * @return The GT_Recipe_AssemblyLine recipe contained on the DataStick, if any. - */ - public static GT_Recipe_AssemblyLine findAssemblyLineRecipeFromDataStick(ItemStack aDataStick) { - return findAssemblyLineRecipeFromDataStick(aDataStick, false).getRecipe(); - } - - /** - * Finds an Assembly Line recipe from a DataStick. - * @param aDataStick - The DataStick to check. - * @param aReturnBuiltRecipe - Do we return a GT_Recipe_AssemblyLine built from the data on the Data Stick instead of searching the Recipe Map? - * @return The GT_Recipe_AssemblyLine recipe contained on the DataStick, if any. - */ - @Nonnull - public static LookupResult findAssemblyLineRecipeFromDataStick(ItemStack aDataStick, boolean aReturnBuiltRecipe) { - if (!isItemDataStick(aDataStick) || !doesDataStickHaveOutput(aDataStick)) { - return LookupResultType.INVALID_STICK.getResult(); - } - List<ItemStack> aInputs = new ArrayList<>(15); - ItemStack aOutput = getDataStickOutput(aDataStick); - List<List<ItemStack>> mOreDictAlt = new ArrayList<>(15); - List<FluidStack> aFluidInputs = new ArrayList<>(4); - - NBTTagCompound aTag = aDataStick.getTagCompound(); - if (aTag == null) { - return LookupResultType.INVALID_STICK.getResult(); - } - - //Get From Cache - if (doesDataStickHaveRecipeHash(aDataStick)) { - GT_Recipe_AssemblyLine aRecipeFromCache = sRecipeCacheByRecipeHash.get(getHashFromDataStack(aDataStick)); - if (aRecipeFromCache != null && GT_Utility.areStacksEqual(aOutput, aRecipeFromCache.mOutput)) { - return LookupResultType.VALID_STACK_AND_VALID_HASH.getResult(aRecipeFromCache); - } // else: no cache, or the old recipe run into a hash collision with a different new recipe - } - - for (int i = 0; i < 15; i++) { - int count = aTag.getInteger("a" + i); - if (!aTag.hasKey("" + i) && count <= 0) { - continue; - } - - List<ItemStack> tAltCurrent = new ArrayList<>(); - for (int j = 0; j < count; j++) { - ItemStack tLoaded = GT_Utility.loadItem(aTag, "a" + i + ":" + j); - if (tLoaded == null) { - continue; - } - tAltCurrent.add(tLoaded); - if (GT_Values.D1) { - GT_FML_LOGGER.info("Item Alt " + i + " : " + tLoaded.getUnlocalizedName()); - } - } - mOreDictAlt.add(tAltCurrent); - ItemStack tLoaded = GT_Utility.loadItem(aTag, "" + i); - if (tLoaded == null) { - continue; - } - aInputs.add(tLoaded); - if (GT_Values.D1) { - GT_FML_LOGGER.info("Item " + i + " : " + tLoaded.getUnlocalizedName()); - } - } - - if (GT_Values.D1) { - GT_FML_LOGGER.info("All Items done, start fluid check"); - } - for (int i = 0; i < 4; i++) { - if (!aTag.hasKey("f" + i)) continue; - FluidStack tLoaded = GT_Utility.loadFluid(aTag, "f" + i); - if (tLoaded == null) continue; - aFluidInputs.add(tLoaded); - if (GT_Values.D1) { - GT_FML_LOGGER.info("Fluid " + i + " " + tLoaded.getUnlocalizedName()); - } - } - if (!aTag.hasKey("output") || !aTag.hasKey("time") || aTag.getInteger("time") <= 0 || !aTag.hasKey("eu") || !GT_Utility.isStackValid(aOutput)) { - return LookupResultType.INVALID_STICK.getResult(); - } - if (GT_Values.D1) { - GT_FML_LOGGER.info("Found Data Stick recipe"); - } - - int aTime = aTag.getInteger("time"); - int aEU = aTag.getInteger("eu"); - - // Try build a recipe instance - if (aReturnBuiltRecipe) { - return LookupResultType.VALID_STACK_AND_VALID_HASH.getResult(new GT_Recipe_AssemblyLine(null, 0, aInputs.toArray(new ItemStack[0]), aFluidInputs.toArray(new FluidStack[0]), aOutput, aTime, aEU)); - } - - - for (GT_Recipe_AssemblyLine aRecipe : GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes) { - if (aRecipe.mEUt != aEU || aRecipe.mDuration != aTime) continue; - if (!GT_Utility.areStacksEqual(aOutput, aRecipe.mOutput, true)) continue; - if (!GT_Utility.areStackListsEqual(Arrays.asList(aRecipe.mInputs), aInputs, false, true)) continue; - if (!Objects.equals(Arrays.asList(aRecipe.mFluidInputs), aFluidInputs)) continue; - if (!areStacksEqual(aRecipe.mOreDictAlt, mOreDictAlt)) continue; - - // Cache it - String aRecipeHash = generateRecipeHash(aRecipe); - sRecipeCacheByRecipeHash.put(aRecipeHash, aRecipe); - sRecipeCacheByOutput.put(new GT_ItemStack(aRecipe.mOutput), aRecipe); - if (doesDataStickHaveRecipeHash(aDataStick)) { - String aStickHash = getHashFromDataStack(aDataStick); - if (aRecipeHash.equals(aStickHash)) - return LookupResultType.VALID_STACK_AND_VALID_HASH.getResult(aRecipe); - } - return LookupResultType.VALID_STACK_AND_VALID_RECIPE.getResult(aRecipe); - } - return LookupResultType.VALID_STACK_BUT_INVALID_RECIPE.getResult(); - } - - private static boolean areStacksEqual(ItemStack[][] lhs, List<List<ItemStack>> rhs) { - for (int i = 0; i < lhs.length; i++) { - if (!areStacksEqual(lhs[i], rhs.get(i))) - return false; - } - return true; - } - - private static boolean areStacksEqual(ItemStack[] lhs, List<ItemStack> rhs) { - return lhs == null ? rhs.isEmpty() : !rhs.isEmpty() && GT_Utility.areStackListsEqual(Arrays.asList(lhs), rhs, false, true); - } - - - /** - * Finds a GT_Recipe_AssemblyLine based on the expected output ItemStack. - * @param aOutput - The Output of a GT_Recipe_AssemblyLine. - * @return First found GT_Recipe_AssemblyLine with matching output. - */ - public static GT_Recipe_AssemblyLine findAssemblyLineRecipeByOutput(ItemStack aOutput) { - if (aOutput == null) { - return null; - } - - // Check the cache - GT_ItemStack aCacheStack = new GT_ItemStack(aOutput); - GT_Recipe_AssemblyLine aRecipeFromCache = sRecipeCacheByOutput.get(aCacheStack); - if (aRecipeFromCache != null) { - return aRecipeFromCache; - } - - // Iterate all recipes and return the first matching based on Output. - for (GT_Recipe_AssemblyLine aRecipe : GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes) { - ItemStack aRecipeOutput = aRecipe.mOutput; - if (GT_Utility.areStacksEqual(aRecipeOutput, aOutput)) { - // Cache it to prevent future iterations of all recipes - sRecipeCacheByOutput.put(aCacheStack, aRecipe); - sRecipeCacheByRecipeHash.put(generateRecipeHash(aRecipe), aRecipe); - return aRecipe; - } - } - return null; - } - - /** - * @param aRecipe - The recipe to generate a Recipe Hash String from. - * @return The Recipe Hash String. - */ - public static String generateRecipeHash(GT_Recipe_AssemblyLine aRecipe) { - String aHash = "Invalid.Recipe.Hash"; - if (aRecipe != null) { - aHash = "Hash."+aRecipe.getPersistentHash(); - } - return aHash; - } - - /** - * @param aRecipe - The recipe to add to internal caches - * @throws IllegalArgumentException if given recipe collide with any existing recipe in the cache - */ - public static void addRecipeToCache(GT_Recipe_AssemblyLine aRecipe) { - if (aRecipe != null) { - String aHash = "Hash." + aRecipe.getPersistentHash(); - GT_Recipe_AssemblyLine existing = sRecipeCacheByOutput.put(new GT_ItemStack(aRecipe.mOutput), aRecipe); - if (existing != null) - throw new IllegalArgumentException("Duplicate assline recipe for " + aRecipe.mOutput); - existing = sRecipeCacheByRecipeHash.put(aHash, aRecipe); - if (existing != null && !existing.equals(aRecipe)) - throw new IllegalArgumentException("Recipe hash collision for " + aRecipe + " and " + existing); - } - } - - /** - * @param aHash - Recipe hash String, may be null but will just be treated as invalid. - * @return Is this Recipe Hash String valid? - */ - public static boolean isValidHash(String aHash) { - if (aHash != null && aHash.length() > 0) { - // persistent hash can never be 0 - return !aHash.equals("Invalid.Recipe.Hash") && !aHash.equals("Hash.0"); - } - return false; - } - - /** - * @param aStack - The ItemStack to check. - * @return Is this ItemStack a Data Stick? - */ - public static boolean isItemDataStick(ItemStack aStack) { - return GT_Utility.isStackValid(aStack) && ItemList.Tool_DataStick.isStackEqual(aStack, false, true); - } - - /** - * @param aDataStick - The Data Stick to check. - * @return Does this Data Stick have a valid output ItemStack? - */ - public static boolean doesDataStickHaveOutput(ItemStack aDataStick) { - if (isItemDataStick(aDataStick) && aDataStick.hasTagCompound() && aDataStick.getTagCompound().hasKey("output")) { - return true; - } - return false; - } - - /** - * @param aDataStick - The Data Stick to check. - * @return Does this Data Stick need recipe data updated. - */ - public static boolean doesDataStickNeedUpdate(ItemStack aDataStick) { - if (isItemDataStick(aDataStick) && doesDataStickHaveRecipeHash(aDataStick)) { - String aStickHash = getHashFromDataStack(aDataStick); - if (isValidHash(aStickHash) && doesDataStickHaveOutput(aDataStick)) { - ItemStack aStickOutput = getDataStickOutput(aDataStick); - GT_Recipe_AssemblyLine aIntendedRecipe = findAssemblyLineRecipeByOutput(aStickOutput); - if (aStickHash.equals(generateRecipeHash(aIntendedRecipe))) { - return false; - } - } - } - return true; - } - - /** - * @param aDataStick - The Data Stick to check. - * @return Does this have a Recipe Hash String at all? - */ - public static boolean doesDataStickHaveRecipeHash(ItemStack aDataStick) { - if (isItemDataStick(aDataStick) && aDataStick.hasTagCompound()) { - NBTTagCompound aNBT = aDataStick.getTagCompound(); - if (aNBT.hasKey("Data.Recipe.Hash") && !aNBT.getString("Data.Recipe.Hash").equals("Hash.0")) { - return true; - } - } - return false; - } - - /** - * Get the Output ItemStack from a Data Stick. - * @param aDataStick - The Data Stick to check. - * @return Output ItemStack contained on the Data Stick. - */ - public static ItemStack getDataStickOutput(ItemStack aDataStick) { - if (doesDataStickHaveOutput(aDataStick)) { - ItemStack aOutput = GT_Utility.loadItem(aDataStick.getTagCompound(), "output"); - return aOutput; - } - return null; - } - - /** - * @param aDataStick - The Data Stick to process. - * @return The stored Recipe Hash String on the Data Stick, will return an invalid Hash if one is not found. <p> - * The hash will be guaranteed to pass isValidHash(). <p> - * Will not return Null. - */ - public static String getHashFromDataStack(ItemStack aDataStick) { - if (isItemDataStick(aDataStick) && aDataStick.hasTagCompound()) { - NBTTagCompound aNBT = aDataStick.getTagCompound(); - if (aNBT.hasKey("Data.Recipe.Hash", NBT.TAG_STRING)) { - String hash = aNBT.getString("Data.Recipe.Hash"); - if (isValidHash(hash)) - return hash; - } - } - return "Invalid.Recipe.Hash"; - } - - /** - * - * @param aDataStick - The Data Stick to update. - * @param aRecipeHash - The Recipe Hash String to update with. - * @return Did we update the Recipe Hash String on the Data Stick? - */ - public static boolean setRecipeHashOnDataStick(ItemStack aDataStick, String aRecipeHash) { - if (isItemDataStick(aDataStick) && aDataStick.hasTagCompound()) { - NBTTagCompound aNBT = aDataStick.getTagCompound(); - aNBT.setString("Data.Recipe.Hash", aRecipeHash); - aDataStick.setTagCompound(aNBT); - return true; - } - return false; - } - - /** - * - * @param aDataStick - The Data Stick to update. - * @param aNewRecipe - The New GT_Recipe_AssemblyLine recipe to update it with. - * @return Did we set the new recipe data & Recipe Hash String on the Data Stick? - */ - public static boolean setAssemblyLineRecipeOnDataStick(ItemStack aDataStick, GT_Recipe_AssemblyLine aNewRecipe) { - if (isItemDataStick(aDataStick)) { - String s = aNewRecipe.mOutput.getDisplayName(); - if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { - s = GT_Assemblyline_Server.lServerNames.get(aNewRecipe.mOutput.getDisplayName()); - if (s == null) { - s = aNewRecipe.mOutput.getDisplayName(); - } - } - - String aHash = generateRecipeHash(aNewRecipe); - if (GT_Values.D1) { - GT_Recipe_AssemblyLine aOldRecipe = findAssemblyLineRecipeFromDataStick(aDataStick, true).recipe; - GT_FML_LOGGER.info("Updating data stick: "+aDataStick.getDisplayName()+" | Old Recipe Hash: "+generateRecipeHash(aOldRecipe)+", New Recipe Hash: "+aHash); - } - - String author = "Assembling Line Recipe Generator"; - String displayName = null; - if (aDataStick.hasTagCompound()) { - NBTTagCompound tag = aDataStick.getTagCompound(); - if (tag.hasKey("author", NBT.TAG_STRING)) { - author = tag.getString("author"); - } - if (tag.hasKey("display", NBT.TAG_COMPOUND)) { - NBTTagCompound displayTag = tag.getCompoundTag("display"); - if (displayTag.hasKey("Name", NBT.TAG_STRING)) - displayName = displayTag.getString("Name"); - } - } - - //remove possible old NBTTagCompound - aDataStick.setTagCompound(new NBTTagCompound()); - if (displayName != null) - aDataStick.setStackDisplayName(displayName); - if (GT_Values.D1) { - GT_Utility.ItemNBT.setBookTitle(aDataStick, s + " Construction Data ("+aHash+")"); - } - else { - GT_Utility.ItemNBT.setBookTitle(aDataStick, s + " Construction Data"); - } - - NBTTagCompound tNBT = aDataStick.getTagCompound(); - if (tNBT == null) { - tNBT = new NBTTagCompound(); - } - - tNBT.setTag("output", aNewRecipe.mOutput.writeToNBT(new NBTTagCompound())); - tNBT.setInteger("time", aNewRecipe.mDuration); - tNBT.setInteger("eu", aNewRecipe.mEUt); - for (int i = 0; i < aNewRecipe.mInputs.length; i++) { - tNBT.setTag("" + i, aNewRecipe.mInputs[i].writeToNBT(new NBTTagCompound())); - } - for (int i = 0; i < aNewRecipe.mOreDictAlt.length; i++) { - if (aNewRecipe.mOreDictAlt[i] != null && aNewRecipe.mOreDictAlt[i].length > 0) { - tNBT.setInteger("a" + i, aNewRecipe.mOreDictAlt[i].length); - for (int j = 0; j < aNewRecipe.mOreDictAlt[i].length; j++) { - tNBT.setTag("a" + i + ":" + j, aNewRecipe.mOreDictAlt[i][j].writeToNBT(new NBTTagCompound())); - } - } - } - for (int i = 0; i < aNewRecipe.mFluidInputs.length; i++) { - tNBT.setTag("f" + i, aNewRecipe.mFluidInputs[i].writeToNBT(new NBTTagCompound())); - } - tNBT.setString("author", author); - NBTTagList tNBTList = new NBTTagList(); - s = aNewRecipe.mOutput.getDisplayName(); - if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { - s = GT_Assemblyline_Server.lServerNames.get(aNewRecipe.mOutput.getDisplayName()); - if (s == null) - s = aNewRecipe.mOutput.getDisplayName(); - } - tNBTList.appendTag(new NBTTagString("Construction plan for " + aNewRecipe.mOutput.stackSize + " " + s + ". Needed EU/t: " + aNewRecipe.mEUt + " Production time: " + (aNewRecipe.mDuration / 20))); - for (int i = 0; i < aNewRecipe.mInputs.length; i++) { - if (aNewRecipe.mOreDictAlt[i] != null) { - int count = 0; - StringBuilder tBuilder = new StringBuilder("Input Bus " + (i + 1) + ": "); - for (ItemStack tStack : aNewRecipe.mOreDictAlt[i]) { - if (tStack != null) { - s = tStack.getDisplayName(); - if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { - s = GT_Assemblyline_Server.lServerNames.get(tStack.getDisplayName()); - if (s == null) - s = tStack.getDisplayName(); - } - - - tBuilder.append(count == 0 ? "" : "\nOr ").append(tStack.stackSize).append(" ").append(s); - count++; - } - } - if (count > 0) tNBTList.appendTag(new NBTTagString(tBuilder.toString())); - } else if (aNewRecipe.mInputs[i] != null) { - s = aNewRecipe.mInputs[i].getDisplayName(); - if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { - s = GT_Assemblyline_Server.lServerNames.get(aNewRecipe.mInputs[i].getDisplayName()); - if (s == null) - s = aNewRecipe.mInputs[i].getDisplayName(); - } - tNBTList.appendTag(new NBTTagString("Input Bus " + (i + 1) + ": " + aNewRecipe.mInputs[i].stackSize + " " + s)); - } - } - for (int i = 0; i < aNewRecipe.mFluidInputs.length; i++) { - if (aNewRecipe.mFluidInputs[i] != null) { - s = aNewRecipe.mFluidInputs[i].getLocalizedName(); - if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { - s = GT_Assemblyline_Server.lServerNames.get(aNewRecipe.mFluidInputs[i].getLocalizedName()); - if (s == null) - s = aNewRecipe.mFluidInputs[i].getLocalizedName(); - } - tNBTList.appendTag(new NBTTagString("Input Hatch " + (i + 1) + ": " + aNewRecipe.mFluidInputs[i].amount + "L " + s)); - } - } - tNBT.setTag("pages", tNBTList); - tNBT.setLong("lastUpdate", System.currentTimeMillis()); - aDataStick.setTagCompound(tNBT); - // Set recipe hash - setRecipeHashOnDataStick(aDataStick, aHash); - return true; - } - return false; - } - - public enum LookupResultType { - INVALID_STICK(true), - VALID_STACK_BUT_INVALID_RECIPE(true), - VALID_STACK_AND_VALID_RECIPE(false), - VALID_STACK_AND_VALID_HASH(false); - - private final boolean recipeNull; - private LookupResult singletonResult; - - LookupResultType(boolean recipeNull) { - this.recipeNull = recipeNull; - } - - public LookupResult getResult() { - if (!recipeNull) - throw new IllegalArgumentException("This result type require a nonnull recipe"); - if (singletonResult == null) - singletonResult = new LookupResult(null, this); - return singletonResult; - } - - public LookupResult getResult(GT_Recipe_AssemblyLine recipe) { - if ((recipe == null) != recipeNull) - throw new IllegalArgumentException("This result type does not allow given input"); - return new LookupResult(recipe, this); - } - } - - public static class LookupResult { - private final GT_Recipe_AssemblyLine recipe; - private final LookupResultType type; - - LookupResult(GT_Recipe_AssemblyLine recipe, LookupResultType type) { - this.recipe = recipe; - this.type = type; - } - - public GT_Recipe_AssemblyLine getRecipe() { - return recipe; - } - - public LookupResultType getType() { - return type; - } - } + /** + * A cache of Recipes using the Output as Key. + */ + private static HashMap<GT_ItemStack, GT_Recipe_AssemblyLine> sRecipeCacheByOutput = + new HashMap<GT_ItemStack, GT_Recipe_AssemblyLine>(); + /** + * A cache of Recipes using the Recipe Hash String as Key. + */ + private static HashMap<String, GT_Recipe_AssemblyLine> sRecipeCacheByRecipeHash = + new HashMap<String, GT_Recipe_AssemblyLine>(); + + /** + * Checks the DataStick for deprecated/invalid recipes, updating them as required. + * @param aDataStick - The DataStick to process + * @return Is this DataStick now valid with a current recipe? + */ + public static GT_Recipe_AssemblyLine processDataStick(ItemStack aDataStick) { + if (!isItemDataStick(aDataStick)) { + return null; + } + if (doesDataStickNeedUpdate(aDataStick)) { + ItemStack aStickOutput = getDataStickOutput(aDataStick); + if (aStickOutput != null) { + GT_Recipe_AssemblyLine aIntendedRecipe = findAssemblyLineRecipeByOutput(aStickOutput); + if (aIntendedRecipe != null && setAssemblyLineRecipeOnDataStick(aDataStick, aIntendedRecipe)) + return aIntendedRecipe; + } + } + return null; + } + + /** + * Finds an Assembly Line recipe from a DataStick. + * @param aDataStick - The DataStick to check. + * @return The GT_Recipe_AssemblyLine recipe contained on the DataStick, if any. + */ + public static GT_Recipe_AssemblyLine findAssemblyLineRecipeFromDataStick(ItemStack aDataStick) { + return findAssemblyLineRecipeFromDataStick(aDataStick, false).getRecipe(); + } + + /** + * Finds an Assembly Line recipe from a DataStick. + * @param aDataStick - The DataStick to check. + * @param aReturnBuiltRecipe - Do we return a GT_Recipe_AssemblyLine built from the data on the Data Stick instead of searching the Recipe Map? + * @return The GT_Recipe_AssemblyLine recipe contained on the DataStick, if any. + */ + @Nonnull + public static LookupResult findAssemblyLineRecipeFromDataStick(ItemStack aDataStick, boolean aReturnBuiltRecipe) { + if (!isItemDataStick(aDataStick) || !doesDataStickHaveOutput(aDataStick)) { + return LookupResultType.INVALID_STICK.getResult(); + } + List<ItemStack> aInputs = new ArrayList<>(15); + ItemStack aOutput = getDataStickOutput(aDataStick); + List<List<ItemStack>> mOreDictAlt = new ArrayList<>(15); + List<FluidStack> aFluidInputs = new ArrayList<>(4); + + NBTTagCompound aTag = aDataStick.getTagCompound(); + if (aTag == null) { + return LookupResultType.INVALID_STICK.getResult(); + } + + // Get From Cache + if (doesDataStickHaveRecipeHash(aDataStick)) { + GT_Recipe_AssemblyLine aRecipeFromCache = sRecipeCacheByRecipeHash.get(getHashFromDataStack(aDataStick)); + if (aRecipeFromCache != null && GT_Utility.areStacksEqual(aOutput, aRecipeFromCache.mOutput)) { + return LookupResultType.VALID_STACK_AND_VALID_HASH.getResult(aRecipeFromCache); + } // else: no cache, or the old recipe run into a hash collision with a different new recipe + } + + for (int i = 0; i < 15; i++) { + int count = aTag.getInteger("a" + i); + if (!aTag.hasKey("" + i) && count <= 0) { + continue; + } + + List<ItemStack> tAltCurrent = new ArrayList<>(); + for (int j = 0; j < count; j++) { + ItemStack tLoaded = GT_Utility.loadItem(aTag, "a" + i + ":" + j); + if (tLoaded == null) { + continue; + } + tAltCurrent.add(tLoaded); + if (GT_Values.D1) { + GT_FML_LOGGER.info("Item Alt " + i + " : " + tLoaded.getUnlocalizedName()); + } + } + mOreDictAlt.add(tAltCurrent); + ItemStack tLoaded = GT_Utility.loadItem(aTag, "" + i); + if (tLoaded == null) { + continue; + } + aInputs.add(tLoaded); + if (GT_Values.D1) { + GT_FML_LOGGER.info("Item " + i + " : " + tLoaded.getUnlocalizedName()); + } + } + + if (GT_Values.D1) { + GT_FML_LOGGER.info("All Items done, start fluid check"); + } + for (int i = 0; i < 4; i++) { + if (!aTag.hasKey("f" + i)) continue; + FluidStack tLoaded = GT_Utility.loadFluid(aTag, "f" + i); + if (tLoaded == null) continue; + aFluidInputs.add(tLoaded); + if (GT_Values.D1) { + GT_FML_LOGGER.info("Fluid " + i + " " + tLoaded.getUnlocalizedName()); + } + } + if (!aTag.hasKey("output") + || !aTag.hasKey("time") + || aTag.getInteger("time") <= 0 + || !aTag.hasKey("eu") + || !GT_Utility.isStackValid(aOutput)) { + return LookupResultType.INVALID_STICK.getResult(); + } + if (GT_Values.D1) { + GT_FML_LOGGER.info("Found Data Stick recipe"); + } + + int aTime = aTag.getInteger("time"); + int aEU = aTag.getInteger("eu"); + + // Try build a recipe instance + if (aReturnBuiltRecipe) { + return LookupResultType.VALID_STACK_AND_VALID_HASH.getResult(new GT_Recipe_AssemblyLine( + null, + 0, + aInputs.toArray(new ItemStack[0]), + aFluidInputs.toArray(new FluidStack[0]), + aOutput, + aTime, + aEU)); + } + + for (GT_Recipe_AssemblyLine aRecipe : GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes) { + if (aRecipe.mEUt != aEU || aRecipe.mDuration != aTime) continue; + if (!GT_Utility.areStacksEqual(aOutput, aRecipe.mOutput, true)) continue; + if (!GT_Utility.areStackListsEqual(Arrays.asList(aRecipe.mInputs), aInputs, false, true)) continue; + if (!Objects.equals(Arrays.asList(aRecipe.mFluidInputs), aFluidInputs)) continue; + if (!areStacksEqual(aRecipe.mOreDictAlt, mOreDictAlt)) continue; + + // Cache it + String aRecipeHash = generateRecipeHash(aRecipe); + sRecipeCacheByRecipeHash.put(aRecipeHash, aRecipe); + sRecipeCacheByOutput.put(new GT_ItemStack(aRecipe.mOutput), aRecipe); + if (doesDataStickHaveRecipeHash(aDataStick)) { + String aStickHash = getHashFromDataStack(aDataStick); + if (aRecipeHash.equals(aStickHash)) + return LookupResultType.VALID_STACK_AND_VALID_HASH.getResult(aRecipe); + } + return LookupResultType.VALID_STACK_AND_VALID_RECIPE.getResult(aRecipe); + } + return LookupResultType.VALID_STACK_BUT_INVALID_RECIPE.getResult(); + } + + private static boolean areStacksEqual(ItemStack[][] lhs, List<List<ItemStack>> rhs) { + for (int i = 0; i < lhs.length; i++) { + if (!areStacksEqual(lhs[i], rhs.get(i))) return false; + } + return true; + } + + private static boolean areStacksEqual(ItemStack[] lhs, List<ItemStack> rhs) { + return lhs == null + ? rhs.isEmpty() + : !rhs.isEmpty() && GT_Utility.areStackListsEqual(Arrays.asList(lhs), rhs, false, true); + } + + /** + * Finds a GT_Recipe_AssemblyLine based on the expected output ItemStack. + * @param aOutput - The Output of a GT_Recipe_AssemblyLine. + * @return First found GT_Recipe_AssemblyLine with matching output. + */ + public static GT_Recipe_AssemblyLine findAssemblyLineRecipeByOutput(ItemStack aOutput) { + if (aOutput == null) { + return null; + } + + // Check the cache + GT_ItemStack aCacheStack = new GT_ItemStack(aOutput); + GT_Recipe_AssemblyLine aRecipeFromCache = sRecipeCacheByOutput.get(aCacheStack); + if (aRecipeFromCache != null) { + return aRecipeFromCache; + } + + // Iterate all recipes and return the first matching based on Output. + for (GT_Recipe_AssemblyLine aRecipe : GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes) { + ItemStack aRecipeOutput = aRecipe.mOutput; + if (GT_Utility.areStacksEqual(aRecipeOutput, aOutput)) { + // Cache it to prevent future iterations of all recipes + sRecipeCacheByOutput.put(aCacheStack, aRecipe); + sRecipeCacheByRecipeHash.put(generateRecipeHash(aRecipe), aRecipe); + return aRecipe; + } + } + return null; + } + + /** + * @param aRecipe - The recipe to generate a Recipe Hash String from. + * @return The Recipe Hash String. + */ + public static String generateRecipeHash(GT_Recipe_AssemblyLine aRecipe) { + String aHash = "Invalid.Recipe.Hash"; + if (aRecipe != null) { + aHash = "Hash." + aRecipe.getPersistentHash(); + } + return aHash; + } + + /** + * @param aRecipe - The recipe to add to internal caches + * @throws IllegalArgumentException if given recipe collide with any existing recipe in the cache + */ + public static void addRecipeToCache(GT_Recipe_AssemblyLine aRecipe) { + if (aRecipe != null) { + String aHash = "Hash." + aRecipe.getPersistentHash(); + GT_Recipe_AssemblyLine existing = sRecipeCacheByOutput.put(new GT_ItemStack(aRecipe.mOutput), aRecipe); + if (existing != null) throw new IllegalArgumentException("Duplicate assline recipe for " + aRecipe.mOutput); + existing = sRecipeCacheByRecipeHash.put(aHash, aRecipe); + if (existing != null && !existing.equals(aRecipe)) + throw new IllegalArgumentException("Recipe hash collision for " + aRecipe + " and " + existing); + } + } + + /** + * @param aHash - Recipe hash String, may be null but will just be treated as invalid. + * @return Is this Recipe Hash String valid? + */ + public static boolean isValidHash(String aHash) { + if (aHash != null && aHash.length() > 0) { + // persistent hash can never be 0 + return !aHash.equals("Invalid.Recipe.Hash") && !aHash.equals("Hash.0"); + } + return false; + } + + /** + * @param aStack - The ItemStack to check. + * @return Is this ItemStack a Data Stick? + */ + public static boolean isItemDataStick(ItemStack aStack) { + return GT_Utility.isStackValid(aStack) && ItemList.Tool_DataStick.isStackEqual(aStack, false, true); + } + + /** + * @param aDataStick - The Data Stick to check. + * @return Does this Data Stick have a valid output ItemStack? + */ + public static boolean doesDataStickHaveOutput(ItemStack aDataStick) { + if (isItemDataStick(aDataStick) + && aDataStick.hasTagCompound() + && aDataStick.getTagCompound().hasKey("output")) { + return true; + } + return false; + } + + /** + * @param aDataStick - The Data Stick to check. + * @return Does this Data Stick need recipe data updated. + */ + public static boolean doesDataStickNeedUpdate(ItemStack aDataStick) { + if (isItemDataStick(aDataStick) && doesDataStickHaveRecipeHash(aDataStick)) { + String aStickHash = getHashFromDataStack(aDataStick); + if (isValidHash(aStickHash) && doesDataStickHaveOutput(aDataStick)) { + ItemStack aStickOutput = getDataStickOutput(aDataStick); + GT_Recipe_AssemblyLine aIntendedRecipe = findAssemblyLineRecipeByOutput(aStickOutput); + if (aStickHash.equals(generateRecipeHash(aIntendedRecipe))) { + return false; + } + } + } + return true; + } + + /** + * @param aDataStick - The Data Stick to check. + * @return Does this have a Recipe Hash String at all? + */ + public static boolean doesDataStickHaveRecipeHash(ItemStack aDataStick) { + if (isItemDataStick(aDataStick) && aDataStick.hasTagCompound()) { + NBTTagCompound aNBT = aDataStick.getTagCompound(); + if (aNBT.hasKey("Data.Recipe.Hash") + && !aNBT.getString("Data.Recipe.Hash").equals("Hash.0")) { + return true; + } + } + return false; + } + + /** + * Get the Output ItemStack from a Data Stick. + * @param aDataStick - The Data Stick to check. + * @return Output ItemStack contained on the Data Stick. + */ + public static ItemStack getDataStickOutput(ItemStack aDataStick) { + if (doesDataStickHaveOutput(aDataStick)) { + ItemStack aOutput = GT_Utility.loadItem(aDataStick.getTagCompound(), "output"); + return aOutput; + } + return null; + } + + /** + * @param aDataStick - The Data Stick to process. + * @return The stored Recipe Hash String on the Data Stick, will return an invalid Hash if one is not found. <p> + * The hash will be guaranteed to pass isValidHash(). <p> + * Will not return Null. + */ + public static String getHashFromDataStack(ItemStack aDataStick) { + if (isItemDataStick(aDataStick) && aDataStick.hasTagCompound()) { + NBTTagCompound aNBT = aDataStick.getTagCompound(); + if (aNBT.hasKey("Data.Recipe.Hash", NBT.TAG_STRING)) { + String hash = aNBT.getString("Data.Recipe.Hash"); + if (isValidHash(hash)) return hash; + } + } + return "Invalid.Recipe.Hash"; + } + + /** + * + * @param aDataStick - The Data Stick to update. + * @param aRecipeHash - The Recipe Hash String to update with. + * @return Did we update the Recipe Hash String on the Data Stick? + */ + public static boolean setRecipeHashOnDataStick(ItemStack aDataStick, String aRecipeHash) { + if (isItemDataStick(aDataStick) && aDataStick.hasTagCompound()) { + NBTTagCompound aNBT = aDataStick.getTagCompound(); + aNBT.setString("Data.Recipe.Hash", aRecipeHash); + aDataStick.setTagCompound(aNBT); + return true; + } + return false; + } + + /** + * + * @param aDataStick - The Data Stick to update. + * @param aNewRecipe - The New GT_Recipe_AssemblyLine recipe to update it with. + * @return Did we set the new recipe data & Recipe Hash String on the Data Stick? + */ + public static boolean setAssemblyLineRecipeOnDataStick(ItemStack aDataStick, GT_Recipe_AssemblyLine aNewRecipe) { + if (isItemDataStick(aDataStick)) { + String s = aNewRecipe.mOutput.getDisplayName(); + if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { + s = GT_Assemblyline_Server.lServerNames.get(aNewRecipe.mOutput.getDisplayName()); + if (s == null) { + s = aNewRecipe.mOutput.getDisplayName(); + } + } + + String aHash = generateRecipeHash(aNewRecipe); + if (GT_Values.D1) { + GT_Recipe_AssemblyLine aOldRecipe = findAssemblyLineRecipeFromDataStick(aDataStick, true).recipe; + GT_FML_LOGGER.info("Updating data stick: " + aDataStick.getDisplayName() + " | Old Recipe Hash: " + + generateRecipeHash(aOldRecipe) + ", New Recipe Hash: " + aHash); + } + + String author = "Assembling Line Recipe Generator"; + String displayName = null; + if (aDataStick.hasTagCompound()) { + NBTTagCompound tag = aDataStick.getTagCompound(); + if (tag.hasKey("author", NBT.TAG_STRING)) { + author = tag.getString("author"); + } + if (tag.hasKey("display", NBT.TAG_COMPOUND)) { + NBTTagCompound displayTag = tag.getCompoundTag("display"); + if (displayTag.hasKey("Name", NBT.TAG_STRING)) displayName = displayTag.getString("Name"); + } + } + + // remove possible old NBTTagCompound + aDataStick.setTagCompound(new NBTTagCompound()); + if (displayName != null) aDataStick.setStackDisplayName(displayName); + if (GT_Values.D1) { + GT_Utility.ItemNBT.setBookTitle(aDataStick, s + " Construction Data (" + aHash + ")"); + } else { + GT_Utility.ItemNBT.setBookTitle(aDataStick, s + " Construction Data"); + } + + NBTTagCompound tNBT = aDataStick.getTagCompound(); + if (tNBT == null) { + tNBT = new NBTTagCompound(); + } + + tNBT.setTag("output", aNewRecipe.mOutput.writeToNBT(new NBTTagCompound())); + tNBT.setInteger("time", aNewRecipe.mDuration); + tNBT.setInteger("eu", aNewRecipe.mEUt); + for (int i = 0; i < aNewRecipe.mInputs.length; i++) { + tNBT.setTag("" + i, aNewRecipe.mInputs[i].writeToNBT(new NBTTagCompound())); + } + for (int i = 0; i < aNewRecipe.mOreDictAlt.length; i++) { + if (aNewRecipe.mOreDictAlt[i] != null && aNewRecipe.mOreDictAlt[i].length > 0) { + tNBT.setInteger("a" + i, aNewRecipe.mOreDictAlt[i].length); + for (int j = 0; j < aNewRecipe.mOreDictAlt[i].length; j++) { + tNBT.setTag("a" + i + ":" + j, aNewRecipe.mOreDictAlt[i][j].writeToNBT(new NBTTagCompound())); + } + } + } + for (int i = 0; i < aNewRecipe.mFluidInputs.length; i++) { + tNBT.setTag("f" + i, aNewRecipe.mFluidInputs[i].writeToNBT(new NBTTagCompound())); + } + tNBT.setString("author", author); + NBTTagList tNBTList = new NBTTagList(); + s = aNewRecipe.mOutput.getDisplayName(); + if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { + s = GT_Assemblyline_Server.lServerNames.get(aNewRecipe.mOutput.getDisplayName()); + if (s == null) s = aNewRecipe.mOutput.getDisplayName(); + } + tNBTList.appendTag(new NBTTagString("Construction plan for " + aNewRecipe.mOutput.stackSize + " " + s + + ". Needed EU/t: " + aNewRecipe.mEUt + " Production time: " + (aNewRecipe.mDuration / 20))); + for (int i = 0; i < aNewRecipe.mInputs.length; i++) { + if (aNewRecipe.mOreDictAlt[i] != null) { + int count = 0; + StringBuilder tBuilder = new StringBuilder("Input Bus " + (i + 1) + ": "); + for (ItemStack tStack : aNewRecipe.mOreDictAlt[i]) { + if (tStack != null) { + s = tStack.getDisplayName(); + if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { + s = GT_Assemblyline_Server.lServerNames.get(tStack.getDisplayName()); + if (s == null) s = tStack.getDisplayName(); + } + + tBuilder.append(count == 0 ? "" : "\nOr ") + .append(tStack.stackSize) + .append(" ") + .append(s); + count++; + } + } + if (count > 0) tNBTList.appendTag(new NBTTagString(tBuilder.toString())); + } else if (aNewRecipe.mInputs[i] != null) { + s = aNewRecipe.mInputs[i].getDisplayName(); + if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { + s = GT_Assemblyline_Server.lServerNames.get(aNewRecipe.mInputs[i].getDisplayName()); + if (s == null) s = aNewRecipe.mInputs[i].getDisplayName(); + } + tNBTList.appendTag(new NBTTagString( + "Input Bus " + (i + 1) + ": " + aNewRecipe.mInputs[i].stackSize + " " + s)); + } + } + for (int i = 0; i < aNewRecipe.mFluidInputs.length; i++) { + if (aNewRecipe.mFluidInputs[i] != null) { + s = aNewRecipe.mFluidInputs[i].getLocalizedName(); + if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { + s = GT_Assemblyline_Server.lServerNames.get(aNewRecipe.mFluidInputs[i].getLocalizedName()); + if (s == null) s = aNewRecipe.mFluidInputs[i].getLocalizedName(); + } + tNBTList.appendTag(new NBTTagString( + "Input Hatch " + (i + 1) + ": " + aNewRecipe.mFluidInputs[i].amount + "L " + s)); + } + } + tNBT.setTag("pages", tNBTList); + tNBT.setLong("lastUpdate", System.currentTimeMillis()); + aDataStick.setTagCompound(tNBT); + // Set recipe hash + setRecipeHashOnDataStick(aDataStick, aHash); + return true; + } + return false; + } + + public enum LookupResultType { + INVALID_STICK(true), + VALID_STACK_BUT_INVALID_RECIPE(true), + VALID_STACK_AND_VALID_RECIPE(false), + VALID_STACK_AND_VALID_HASH(false); + + private final boolean recipeNull; + private LookupResult singletonResult; + + LookupResultType(boolean recipeNull) { + this.recipeNull = recipeNull; + } + + public LookupResult getResult() { + if (!recipeNull) throw new IllegalArgumentException("This result type require a nonnull recipe"); + if (singletonResult == null) singletonResult = new LookupResult(null, this); + return singletonResult; + } + + public LookupResult getResult(GT_Recipe_AssemblyLine recipe) { + if ((recipe == null) != recipeNull) + throw new IllegalArgumentException("This result type does not allow given input"); + return new LookupResult(recipe, this); + } + } + + public static class LookupResult { + private final GT_Recipe_AssemblyLine recipe; + private final LookupResultType type; + + LookupResult(GT_Recipe_AssemblyLine recipe, LookupResultType type) { + this.recipe = recipe; + this.type = type; + } + + public GT_Recipe_AssemblyLine getRecipe() { + return recipe; + } + + public LookupResultType getType() { + return type; + } + } } diff --git a/src/main/java/gregtech/api/util/GT_Assemblyline_Server.java b/src/main/java/gregtech/api/util/GT_Assemblyline_Server.java index fa838abec1..15d11cda63 100644 --- a/src/main/java/gregtech/api/util/GT_Assemblyline_Server.java +++ b/src/main/java/gregtech/api/util/GT_Assemblyline_Server.java @@ -1,345 +1,415 @@ package gregtech.api.util; -import java.io.File; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; - import cpw.mods.fml.common.event.FMLPreInitializationEvent; import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; import gregtech.api.enums.MaterialsBotania; +import java.io.File; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; import net.minecraftforge.common.config.ConfigCategory; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; public class GT_Assemblyline_Server { + public static LinkedHashMap<String, String> lServerNames = new LinkedHashMap<String, String>(); + private static LinkedHashMap<String, String> internal2 = new LinkedHashMap<String, String>(), + internal3 = new LinkedHashMap<String, String>(), + internal4 = new LinkedHashMap<String, String>(); + private static HashMap<String, Property> internal = new HashMap<String, Property>(); - public static LinkedHashMap<String, String> lServerNames = new LinkedHashMap<String, String>(); - private static LinkedHashMap<String, String> internal2 = new LinkedHashMap<String, String>(), internal3 = new LinkedHashMap<String, String>(), internal4 = new LinkedHashMap<String, String>(); - private static HashMap<String, Property> internal = new HashMap<String, Property>(); - - public static void fillMap(FMLPreInitializationEvent aEvent) { + public static void fillMap(FMLPreInitializationEvent aEvent) { - String s = new String(aEvent.getModConfigurationDirectory().getAbsolutePath()); - s = s.substring(0, aEvent.getModConfigurationDirectory().getAbsolutePath().length() - 6); - s = s + "GregTech.lang"; - File f = new File(s); - s = ""; - Configuration conf = new Configuration(f); + String s = new String(aEvent.getModConfigurationDirectory().getAbsolutePath()); + s = s.substring( + 0, aEvent.getModConfigurationDirectory().getAbsolutePath().length() - 6); + s = s + "GregTech.lang"; + File f = new File(s); + s = ""; + Configuration conf = new Configuration(f); - ConfigCategory cat = conf.getCategory("languagefile"); - internal.putAll(cat.getValues()); - for (Map.Entry<String, Property> entry : internal.entrySet()) { - try { - s = entry.getValue().getString().replaceAll("%", ""); + ConfigCategory cat = conf.getCategory("languagefile"); + internal.putAll(cat.getValues()); + for (Map.Entry<String, Property> entry : internal.entrySet()) { + try { + s = entry.getValue().getString().replaceAll("%", ""); - if (entry.getKey().contains("metaitem") && s.contains("material")) - internal2.put(entry.getKey(), s); - else if (entry.getKey().contains("blockmachines") && s.contains("material")) - internal3.put(entry.getKey(), s); - else if ((entry.getKey().contains("blockores") || (entry.getKey().contains("blockmetal") || entry.getKey().contains("blockgem"))) && s.contains("material")) - internal4.put(entry.getKey(), s); - else - lServerNames.put(entry.getKey(), s); - } catch (Exception ignored) { - } - } - for (Map.Entry<String, String> entry : internal2.entrySet()) { - try { - if (entry.getKey().contains("name")) { - int i = Integer.parseInt(entry.getKey().substring("gt.metaitem.01.".length(), entry.getKey().length() - ".name".length())); - i = i % 1000; - if (GregTech_API.sGeneratedMaterials[i] != null) - lServerNames.put(entry.getKey(), entry.getValue().replace("material", GregTech_API.sGeneratedMaterials[i].toString())); - else - lServerNames.put(entry.getKey(), null); - } - } catch (Exception ignored) { - } - } - for (Map.Entry<String, String> entry : internal3.entrySet()) { - try { - if (entry.getKey().contains("cable")) - lServerNames.put(entry.getKey(), entry.getValue().replace("material", entry.getKey().substring("gt.blockmachines.cable.".length(), entry.getKey().length() - ".01.name".length()))); - else if (entry.getKey().contains("gt_frame_")) - lServerNames.put(entry.getKey(), entry.getValue().replace("material", entry.getKey().substring("gt.blockmachines.gt_frame_".length(), entry.getKey().length() - ".name".length()))); - else if (entry.getKey().contains("gt_pipe_")) { - if ( - !entry.getKey().contains("_huge") && - !entry.getKey().contains("_large") && - !entry.getKey().contains("_nonuple") && - !entry.getKey().contains("_quadruple") && - !entry.getKey().contains("_small") && - !entry.getKey().contains("_tiny") - ) - lServerNames.put(entry.getKey(), entry.getValue().replace("material", entry.getKey().substring("gt.blockmachines.gt_pipe_".length(), entry.getKey().length() - ".name".length()))); - else if (entry.getKey().contains("_huge") || entry.getKey().contains("_tiny")) - lServerNames.put(entry.getKey(), entry.getValue().replace("material", entry.getKey().substring("gt.blockmachines.gt_pipe_".length(), entry.getKey().length() - "_tiny.name".length()))); - else if (entry.getKey().contains("_large") || entry.getKey().contains("_small")) - lServerNames.put(entry.getKey(), entry.getValue().replace("material", entry.getKey().substring("gt.blockmachines.gt_pipe_".length(), entry.getKey().length() - "_large.name".length()))); - else if (entry.getKey().contains("_nonuple")) - lServerNames.put(entry.getKey(), entry.getValue().replace("material", entry.getKey().substring("gt.blockmachines.gt_pipe_".length(), entry.getKey().length() - "_nonuple.name".length()))); - else if (entry.getKey().contains("_quadruple")) - lServerNames.put(entry.getKey(), entry.getValue().replace("material", entry.getKey().substring("gt.blockmachines.gt_pipe_".length(), entry.getKey().length() - "_quadruple.name".length()))); - } else if (entry.getKey().contains("wire")) - lServerNames.put(entry.getKey(), entry.getValue().replace("material", entry.getKey().substring("gt.blockmachines.wire.".length(), entry.getKey().length() - ".01.name".length()))); - else - lServerNames.put(entry.getKey(), entry.getValue()); - } catch (Exception ignored) { - } - } - for (Map.Entry<String, String> entry : internal4.entrySet()) { - try { - if (entry.getKey().contains("blockores")) { - int i = Integer.parseInt(entry.getKey().substring("gt.blockores.".length(), entry.getKey().length() - ".name".length())); - i = i % 1000; - if (GregTech_API.sGeneratedMaterials[i] != null) - lServerNames.put(entry.getKey(), entry.getValue().replace("material", GregTech_API.sGeneratedMaterials[i].toString())); - else - lServerNames.put(entry.getKey(), null); - } else if (entry.getKey().contains("blockmetal")) { - Materials[] mMats = null; - String t = entry.getKey().substring("gt.blockmetal".length()); - t = t.substring(0, 1); - int i = Integer.parseInt(t); - switch (i) { - case 1: - mMats = new Materials[]{ - Materials.Adamantium, - Materials.Aluminium, - Materials.Americium, - Materials.AnnealedCopper, - Materials.Antimony, - Materials.Arsenic, - Materials.AstralSilver, - Materials.BatteryAlloy, - Materials.Beryllium, - Materials.Bismuth, - Materials.BismuthBronze, - Materials.BlackBronze, - Materials.BlackSteel, - Materials.BlueAlloy, - Materials.BlueSteel, - Materials.Brass - }; - break; - case 2: - mMats = new Materials[]{ - Materials.Bronze, - Materials.Caesium, - Materials.Cerium, - Materials.Chrome, - Materials.ChromiumDioxide, - Materials.Cobalt, - Materials.CobaltBrass, - Materials.Copper, - Materials.Cupronickel, - Materials.DamascusSteel, - Materials.DarkIron, - Materials.DeepIron, - Materials.Desh, - Materials.Duranium, - Materials.Dysprosium, - Materials.Electrum - }; - break; - case 3: - mMats = new Materials[]{ - Materials.ElectrumFlux, - Materials.Enderium, - Materials.Erbium, - Materials.Europium, - Materials.FierySteel, - Materials.Gadolinium, - Materials.Gallium, - Materials.Holmium, - Materials.HSLA, - Materials.Indium, - Materials.InfusedGold, - Materials.Invar, - Materials.Iridium, - Materials.IronMagnetic, - Materials.IronWood, - Materials.Kanthal - }; - break; - case 4: - mMats = new Materials[]{ - Materials.Knightmetal, - Materials.Lanthanum, - Materials.Lead, - Materials.Lutetium, - Materials.Magnalium, - Materials.Magnesium, - Materials.Manganese, - Materials.MeteoricIron, - Materials.MeteoricSteel, - Materials.Trinium, - Materials.Mithril, - Materials.Molybdenum, - Materials.Naquadah, - Materials.NaquadahAlloy, - Materials.NaquadahEnriched, - Materials.Naquadria - }; - break; - case 5: - mMats = new Materials[]{ - Materials.Neodymium, - Materials.NeodymiumMagnetic, - Materials.Neutronium, - Materials.Nichrome, - Materials.Nickel, - Materials.Niobium, - Materials.NiobiumNitride, - Materials.NiobiumTitanium, - Materials.Osmiridium, - Materials.Osmium, - Materials.Palladium, - Materials.PigIron, - Materials.Platinum, - Materials.Plutonium, - Materials.Plutonium241, - Materials.Praseodymium - }; - break; - case 6: - mMats = new Materials[]{ - Materials.Promethium, - Materials.RedAlloy, - Materials.RedSteel, - Materials.RoseGold, - Materials.Rubidium, - Materials.Samarium, - Materials.Scandium, - Materials.ShadowIron, - Materials.ShadowSteel, - Materials.Silicon, - Materials.Silver, - Materials.SolderingAlloy, - Materials.StainlessSteel, - Materials.Steel, - Materials.SteelMagnetic, - Materials.SterlingSilver - }; - break; - case 7: - mMats = new Materials[]{ - Materials.Sunnarium, - Materials.Tantalum, - Materials.Tellurium, - Materials.Terbium, - Materials.Thaumium, - Materials.Thorium, - Materials.Thulium, - Materials.Tin, - Materials.TinAlloy, - Materials.Titanium, - Materials.Tritanium, - Materials.Tungsten, - Materials.TungstenSteel, - Materials.Ultimet, - Materials.Uranium, - Materials.Uranium235 - }; - break; - case 8: - mMats = new Materials[]{ - Materials.Vanadium, - Materials.VanadiumGallium, - Materials.WroughtIron, - Materials.Ytterbium, - Materials.Yttrium, - Materials.YttriumBariumCuprate, - Materials.Zinc, - Materials.TungstenCarbide, - Materials.VanadiumSteel, - Materials.HSSG, - Materials.HSSE, - Materials.HSSS, - Materials.Steeleaf, - Materials.Ichorium, - Materials.Firestone - }; - break; - } - t = entry.getKey().substring("gt.blockmetal1.".length(), entry.getKey().length() - ".name".length()); - i = Integer.parseInt(t); - lServerNames.put(entry.getKey(), "Block of " + mMats[i].toString()); - mMats = null; - } else if (entry.getKey().contains("blockgem")) { - Materials[] mMats = null; - String t = entry.getKey().substring("gt.blockgem".length()); - t = t.substring(0, 1); - int i = Integer.parseInt(t); - switch (i) { - case 1: - mMats = new Materials[]{ - Materials.InfusedAir, - Materials.Amber, - Materials.Amethyst, - Materials.InfusedWater, - Materials.BlueTopaz, - Materials.CertusQuartz, - Materials.Dilithium, - Materials.EnderEye, - Materials.EnderPearl, - Materials.FoolsRuby, - Materials.Force, - Materials.Forcicium, - Materials.Forcillium, - Materials.GreenSapphire, - Materials.InfusedFire, - Materials.Jasper, - MaterialsBotania.ManaDiamond, - MaterialsBotania.BotaniaDragonstone + if (entry.getKey().contains("metaitem") && s.contains("material")) internal2.put(entry.getKey(), s); + else if (entry.getKey().contains("blockmachines") && s.contains("material")) + internal3.put(entry.getKey(), s); + else if ((entry.getKey().contains("blockores") + || (entry.getKey().contains("blockmetal") + || entry.getKey().contains("blockgem"))) + && s.contains("material")) internal4.put(entry.getKey(), s); + else lServerNames.put(entry.getKey(), s); + } catch (Exception ignored) { + } + } + for (Map.Entry<String, String> entry : internal2.entrySet()) { + try { + if (entry.getKey().contains("name")) { + int i = Integer.parseInt(entry.getKey() + .substring( + "gt.metaitem.01.".length(), entry.getKey().length() - ".name".length())); + i = i % 1000; + if (GregTech_API.sGeneratedMaterials[i] != null) + lServerNames.put( + entry.getKey(), + entry.getValue().replace("material", GregTech_API.sGeneratedMaterials[i].toString())); + else lServerNames.put(entry.getKey(), null); + } + } catch (Exception ignored) { + } + } + for (Map.Entry<String, String> entry : internal3.entrySet()) { + try { + if (entry.getKey().contains("cable")) + lServerNames.put( + entry.getKey(), + entry.getValue() + .replace( + "material", + entry.getKey() + .substring( + "gt.blockmachines.cable.".length(), + entry.getKey().length() - ".01.name".length()))); + else if (entry.getKey().contains("gt_frame_")) + lServerNames.put( + entry.getKey(), + entry.getValue() + .replace( + "material", + entry.getKey() + .substring( + "gt.blockmachines.gt_frame_".length(), + entry.getKey().length() - ".name".length()))); + else if (entry.getKey().contains("gt_pipe_")) { + if (!entry.getKey().contains("_huge") + && !entry.getKey().contains("_large") + && !entry.getKey().contains("_nonuple") + && !entry.getKey().contains("_quadruple") + && !entry.getKey().contains("_small") + && !entry.getKey().contains("_tiny")) + lServerNames.put( + entry.getKey(), + entry.getValue() + .replace( + "material", + entry.getKey() + .substring( + "gt.blockmachines.gt_pipe_".length(), + entry.getKey().length() - ".name".length()))); + else if (entry.getKey().contains("_huge") || entry.getKey().contains("_tiny")) + lServerNames.put( + entry.getKey(), + entry.getValue() + .replace( + "material", + entry.getKey() + .substring( + "gt.blockmachines.gt_pipe_".length(), + entry.getKey().length() - "_tiny.name".length()))); + else if (entry.getKey().contains("_large") || entry.getKey().contains("_small")) + lServerNames.put( + entry.getKey(), + entry.getValue() + .replace( + "material", + entry.getKey() + .substring( + "gt.blockmachines.gt_pipe_".length(), + entry.getKey().length() - "_large.name".length()))); + else if (entry.getKey().contains("_nonuple")) + lServerNames.put( + entry.getKey(), + entry.getValue() + .replace( + "material", + entry.getKey() + .substring( + "gt.blockmachines.gt_pipe_".length(), + entry.getKey().length() - "_nonuple.name".length()))); + else if (entry.getKey().contains("_quadruple")) + lServerNames.put( + entry.getKey(), + entry.getValue() + .replace( + "material", + entry.getKey() + .substring( + "gt.blockmachines.gt_pipe_".length(), + entry.getKey().length() - "_quadruple.name".length()))); + } else if (entry.getKey().contains("wire")) + lServerNames.put( + entry.getKey(), + entry.getValue() + .replace( + "material", + entry.getKey() + .substring( + "gt.blockmachines.wire.".length(), + entry.getKey().length() - ".01.name".length()))); + else lServerNames.put(entry.getKey(), entry.getValue()); + } catch (Exception ignored) { + } + } + for (Map.Entry<String, String> entry : internal4.entrySet()) { + try { + if (entry.getKey().contains("blockores")) { + int i = Integer.parseInt(entry.getKey() + .substring("gt.blockores.".length(), entry.getKey().length() - ".name".length())); + i = i % 1000; + if (GregTech_API.sGeneratedMaterials[i] != null) + lServerNames.put( + entry.getKey(), + entry.getValue().replace("material", GregTech_API.sGeneratedMaterials[i].toString())); + else lServerNames.put(entry.getKey(), null); + } else if (entry.getKey().contains("blockmetal")) { + Materials[] mMats = null; + String t = entry.getKey().substring("gt.blockmetal".length()); + t = t.substring(0, 1); + int i = Integer.parseInt(t); + switch (i) { + case 1: + mMats = new Materials[] { + Materials.Adamantium, + Materials.Aluminium, + Materials.Americium, + Materials.AnnealedCopper, + Materials.Antimony, + Materials.Arsenic, + Materials.AstralSilver, + Materials.BatteryAlloy, + Materials.Beryllium, + Materials.Bismuth, + Materials.BismuthBronze, + Materials.BlackBronze, + Materials.BlackSteel, + Materials.BlueAlloy, + Materials.BlueSteel, + Materials.Brass + }; + break; + case 2: + mMats = new Materials[] { + Materials.Bronze, + Materials.Caesium, + Materials.Cerium, + Materials.Chrome, + Materials.ChromiumDioxide, + Materials.Cobalt, + Materials.CobaltBrass, + Materials.Copper, + Materials.Cupronickel, + Materials.DamascusSteel, + Materials.DarkIron, + Materials.DeepIron, + Materials.Desh, + Materials.Duranium, + Materials.Dysprosium, + Materials.Electrum + }; + break; + case 3: + mMats = new Materials[] { + Materials.ElectrumFlux, + Materials.Enderium, + Materials.Erbium, + Materials.Europium, + Materials.FierySteel, + Materials.Gadolinium, + Materials.Gallium, + Materials.Holmium, + Materials.HSLA, + Materials.Indium, + Materials.InfusedGold, + Materials.Invar, + Materials.Iridium, + Materials.IronMagnetic, + Materials.IronWood, + Materials.Kanthal + }; + break; + case 4: + mMats = new Materials[] { + Materials.Knightmetal, + Materials.Lanthanum, + Materials.Lead, + Materials.Lutetium, + Materials.Magnalium, + Materials.Magnesium, + Materials.Manganese, + Materials.MeteoricIron, + Materials.MeteoricSteel, + Materials.Trinium, + Materials.Mithril, + Materials.Molybdenum, + Materials.Naquadah, + Materials.NaquadahAlloy, + Materials.NaquadahEnriched, + Materials.Naquadria + }; + break; + case 5: + mMats = new Materials[] { + Materials.Neodymium, + Materials.NeodymiumMagnetic, + Materials.Neutronium, + Materials.Nichrome, + Materials.Nickel, + Materials.Niobium, + Materials.NiobiumNitride, + Materials.NiobiumTitanium, + Materials.Osmiridium, + Materials.Osmium, + Materials.Palladium, + Materials.PigIron, + Materials.Platinum, + Materials.Plutonium, + Materials.Plutonium241, + Materials.Praseodymium + }; + break; + case 6: + mMats = new Materials[] { + Materials.Promethium, + Materials.RedAlloy, + Materials.RedSteel, + Materials.RoseGold, + Materials.Rubidium, + Materials.Samarium, + Materials.Scandium, + Materials.ShadowIron, + Materials.ShadowSteel, + Materials.Silicon, + Materials.Silver, + Materials.SolderingAlloy, + Materials.StainlessSteel, + Materials.Steel, + Materials.SteelMagnetic, + Materials.SterlingSilver + }; + break; + case 7: + mMats = new Materials[] { + Materials.Sunnarium, + Materials.Tantalum, + Materials.Tellurium, + Materials.Terbium, + Materials.Thaumium, + Materials.Thorium, + Materials.Thulium, + Materials.Tin, + Materials.TinAlloy, + Materials.Titanium, + Materials.Tritanium, + Materials.Tungsten, + Materials.TungstenSteel, + Materials.Ultimet, + Materials.Uranium, + Materials.Uranium235 + }; + break; + case 8: + mMats = new Materials[] { + Materials.Vanadium, + Materials.VanadiumGallium, + Materials.WroughtIron, + Materials.Ytterbium, + Materials.Yttrium, + Materials.YttriumBariumCuprate, + Materials.Zinc, + Materials.TungstenCarbide, + Materials.VanadiumSteel, + Materials.HSSG, + Materials.HSSE, + Materials.HSSS, + Materials.Steeleaf, + Materials.Ichorium, + Materials.Firestone + }; + break; + } + t = entry.getKey() + .substring( + "gt.blockmetal1.".length(), entry.getKey().length() - ".name".length()); + i = Integer.parseInt(t); + lServerNames.put(entry.getKey(), "Block of " + mMats[i].toString()); + mMats = null; + } else if (entry.getKey().contains("blockgem")) { + Materials[] mMats = null; + String t = entry.getKey().substring("gt.blockgem".length()); + t = t.substring(0, 1); + int i = Integer.parseInt(t); + switch (i) { + case 1: + mMats = new Materials[] { + Materials.InfusedAir, + Materials.Amber, + Materials.Amethyst, + Materials.InfusedWater, + Materials.BlueTopaz, + Materials.CertusQuartz, + Materials.Dilithium, + Materials.EnderEye, + Materials.EnderPearl, + Materials.FoolsRuby, + Materials.Force, + Materials.Forcicium, + Materials.Forcillium, + Materials.GreenSapphire, + Materials.InfusedFire, + Materials.Jasper, + MaterialsBotania.ManaDiamond, + MaterialsBotania.BotaniaDragonstone + }; + break; + case 2: + mMats = new Materials[] { + Materials.Lazurite, + Materials.Lignite, + Materials.Monazite, + Materials.Niter, + Materials.Olivine, + Materials.Opal, + Materials.InfusedOrder, + Materials.InfusedEntropy, + Materials.Phosphorus, + Materials.Quartzite, + Materials.GarnetRed, + Materials.Ruby, + Materials.Sapphire, + Materials.Sodalite, + Materials.Tanzanite, + Materials.InfusedEarth + }; + break; + case 3: + mMats = new Materials[] { + Materials.Topaz, + Materials.Vinteum, + Materials.GarnetYellow, + Materials.NetherStar, + Materials.Charcoal, + Materials.Blaze }; - break; - case 2: - mMats = new Materials[]{ - Materials.Lazurite, - Materials.Lignite, - Materials.Monazite, - Materials.Niter, - Materials.Olivine, - Materials.Opal, - Materials.InfusedOrder, - Materials.InfusedEntropy, - Materials.Phosphorus, - Materials.Quartzite, - Materials.GarnetRed, - Materials.Ruby, - Materials.Sapphire, - Materials.Sodalite, - Materials.Tanzanite, - Materials.InfusedEarth - }; - break; - case 3: - mMats = new Materials[]{ - Materials.Topaz, - Materials.Vinteum, - Materials.GarnetYellow, - Materials.NetherStar, - Materials.Charcoal, - Materials.Blaze - }; - break; - } - t = entry.getKey().substring("gt.blockgem1.".length(), entry.getKey().length() - ".name".length()); - i = Integer.parseInt(t); - lServerNames.put(entry.getKey(), "Block of " + mMats[i].toString()); - mMats = null; - } - } catch (Exception ignored) { - } - } + break; + } + t = entry.getKey() + .substring("gt.blockgem1.".length(), entry.getKey().length() - ".name".length()); + i = Integer.parseInt(t); + lServerNames.put(entry.getKey(), "Block of " + mMats[i].toString()); + mMats = null; + } + } catch (Exception ignored) { + } + } - internal = null; - internal2 = null; - internal3 = null; - internal4 = null; - } + internal = null; + internal2 = null; + internal3 = null; + internal4 = null; + } } diff --git a/src/main/java/gregtech/api/util/GT_BaseCrop.java b/src/main/java/gregtech/api/util/GT_BaseCrop.java index 97f8db0547..930badfdba 100644 --- a/src/main/java/gregtech/api/util/GT_BaseCrop.java +++ b/src/main/java/gregtech/api/util/GT_BaseCrop.java @@ -1,5 +1,7 @@ package gregtech.api.util; +import static gregtech.api.enums.GT_Values.E; + import cpw.mods.fml.common.Loader; import gregtech.GT_Mod; import gregtech.api.GregTech_API; @@ -12,6 +14,8 @@ import gregtech.common.blocks.GT_TileEntity_Ores; import ic2.api.crops.CropCard; import ic2.api.crops.Crops; import ic2.api.crops.ICropTile; +import java.util.ArrayList; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; @@ -19,15 +23,15 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import speiger.src.crops.api.ICropCardInfo; -import java.util.ArrayList; -import java.util.List; - -import static gregtech.api.enums.GT_Values.E; - public class GT_BaseCrop extends CropCard implements ICropCardInfo { public static ArrayList<GT_BaseCrop> sCropList = new ArrayList<GT_BaseCrop>(); private String mName = E, mDiscoveredBy = "Gregorius Techneticies", mAttributes[]; - private int mTier = 0, mMaxSize = 0, mAfterHarvestSize = 0, mHarvestSize = 0, mStats[] = new int[5], mGrowthSpeed = 0; + private int mTier = 0, + mMaxSize = 0, + mAfterHarvestSize = 0, + mHarvestSize = 0, + mStats[] = new int[5], + mGrowthSpeed = 0; private ItemStack mDrop = null, mSpecialDrops[] = null; private Materials mBlock = null; private static boolean bIc2NeiLoaded = Loader.isModLoaded("Ic2Nei"); @@ -45,8 +49,43 @@ public class GT_BaseCrop extends CropCard implements ICropCardInfo { * @param aGrowthSpeed how fast the Crop grows. if < 0 then its set to Tier*300 * @param aHarvestSize the size the Crop needs to be harvested. forced to be between 2 and max size */ - public GT_BaseCrop(int aID, String aCropName, String aDiscoveredBy, ItemStack aBaseSeed, int aTier, int aMaxSize, int aGrowthSpeed, int aAfterHarvestSize, int aHarvestSize, int aStatChemical, int aStatFood, int aStatDefensive, int aStatColor, int aStatWeed, String[] aAttributes, ItemStack aDrop, ItemStack[] aSpecialDrops) { - new GT_BaseCrop(aID, aCropName, aDiscoveredBy, aBaseSeed, aTier, aMaxSize, aGrowthSpeed, aAfterHarvestSize, aHarvestSize, aStatChemical, aStatFood, aStatDefensive, aStatColor, aStatWeed, aAttributes, null, aDrop, aSpecialDrops); + public GT_BaseCrop( + int aID, + String aCropName, + String aDiscoveredBy, + ItemStack aBaseSeed, + int aTier, + int aMaxSize, + int aGrowthSpeed, + int aAfterHarvestSize, + int aHarvestSize, + int aStatChemical, + int aStatFood, + int aStatDefensive, + int aStatColor, + int aStatWeed, + String[] aAttributes, + ItemStack aDrop, + ItemStack[] aSpecialDrops) { + new GT_BaseCrop( + aID, + aCropName, + aDiscoveredBy, + aBaseSeed, + aTier, + aMaxSize, + aGrowthSpeed, + aAfterHarvestSize, + aHarvestSize, + aStatChemical, + aStatFood, + aStatDefensive, + aStatColor, + aStatWeed, + aAttributes, + null, + aDrop, + aSpecialDrops); } /** @@ -63,7 +102,25 @@ public class GT_BaseCrop extends CropCard implements ICropCardInfo { * @param aHarvestSize the size the Crop needs to be harvested. forced to be between 2 and max size * @param aBlock the block below needed for crop to grow. If null no block needed */ - public GT_BaseCrop(int aID, String aCropName, String aDiscoveredBy, ItemStack aBaseSeed, int aTier, int aMaxSize, int aGrowthSpeed, int aAfterHarvestSize, int aHarvestSize, int aStatChemical, int aStatFood, int aStatDefensive, int aStatColor, int aStatWeed, String[] aAttributes, Materials aBlock, ItemStack aDrop, ItemStack[] aSpecialDrops) { + public GT_BaseCrop( + int aID, + String aCropName, + String aDiscoveredBy, + ItemStack aBaseSeed, + int aTier, + int aMaxSize, + int aGrowthSpeed, + int aAfterHarvestSize, + int aHarvestSize, + int aStatChemical, + int aStatFood, + int aStatDefensive, + int aStatColor, + int aStatWeed, + String[] aAttributes, + Materials aBlock, + ItemStack aDrop, + ItemStack[] aSpecialDrops) { mName = aCropName; aID = GT_Config.addIDConfig(ConfigCategories.IDs.crops, mName.replaceAll(" ", "_"), aID); if (aDiscoveredBy != null && !aDiscoveredBy.equals(E)) mDiscoveredBy = aDiscoveredBy; @@ -81,15 +138,21 @@ public class GT_BaseCrop extends CropCard implements ICropCardInfo { mStats[4] = aStatWeed; mAttributes = aAttributes; mBlock = aBlock; - if(GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.crops, aCropName, true)){ - if (!Crops.instance.registerCrop(this, aID)) - throw new GT_ItsNotMyFaultException("Make sure the Crop ID is valid!"); - if (aBaseSeed != null) Crops.instance.registerBaseSeed(aBaseSeed, this, 1, 1, 1, 1); - sCropList.add(this);} + if (GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.crops, aCropName, true)) { + if (!Crops.instance.registerCrop(this, aID)) + throw new GT_ItsNotMyFaultException("Make sure the Crop ID is valid!"); + if (aBaseSeed != null) Crops.instance.registerBaseSeed(aBaseSeed, this, 1, 1, 1, 1); + sCropList.add(this); + } } if (bIc2NeiLoaded) { try { - Class.forName("speiger.src.crops.api.CropPluginAPI").getMethod("registerCropInfo", Class.forName("speiger.src.crops.api.ICropCardInfo")).invoke(Class.forName("speiger.src.crops.api.CropPluginAPI").getField("instance"), this); + Class.forName("speiger.src.crops.api.CropPluginAPI") + .getMethod("registerCropInfo", Class.forName("speiger.src.crops.api.ICropCardInfo")) + .invoke( + Class.forName("speiger.src.crops.api.CropPluginAPI") + .getField("instance"), + this); } catch (IllegalAccessException ex) { bIc2NeiLoaded = false; } catch (IllegalArgumentException ex) { @@ -176,7 +239,10 @@ public class GT_BaseCrop extends CropCard implements ICropCardInfo { @Override public ItemStack getGain(ICropTile aCrop) { int tDrop = 0; - if (mSpecialDrops != null && (tDrop = java.util.concurrent.ThreadLocalRandom.current().nextInt(0, (mSpecialDrops.length*2) + 2)) < mSpecialDrops.length && mSpecialDrops[tDrop] != null) { + if (mSpecialDrops != null + && (tDrop = java.util.concurrent.ThreadLocalRandom.current().nextInt(0, (mSpecialDrops.length * 2) + 2)) + < mSpecialDrops.length + && mSpecialDrops[tDrop] != null) { return GT_Utility.copyOrNull(mSpecialDrops[tDrop]); } return GT_Utility.copyOrNull(mDrop); @@ -198,11 +264,15 @@ public class GT_BaseCrop extends CropCard implements ICropCardInfo { return false; } for (int i = 1; i < this.getrootslength(aCrop); i++) { - Block tBlock = aCrop.getWorld().getBlock(aCrop.getLocation().posX, aCrop.getLocation().posY - i, aCrop.getLocation().posZ); + Block tBlock = aCrop.getWorld() + .getBlock(aCrop.getLocation().posX, aCrop.getLocation().posY - i, aCrop.getLocation().posZ); if ((tBlock instanceof GT_Block_Ores_Abstract)) { - TileEntity tTileEntity = aCrop.getWorld().getTileEntity(aCrop.getLocation().posX, aCrop.getLocation().posY - i, aCrop.getLocation().posZ); + TileEntity tTileEntity = aCrop.getWorld() + .getTileEntity( + aCrop.getLocation().posX, aCrop.getLocation().posY - i, aCrop.getLocation().posZ); if ((tTileEntity instanceof GT_TileEntity_Ores)) { - Materials tMaterial = GregTech_API.sGeneratedMaterials[(((GT_TileEntity_Ores) tTileEntity).mMetaData % 1000)]; + Materials tMaterial = + GregTech_API.sGeneratedMaterials[(((GT_TileEntity_Ores) tTileEntity).mMetaData % 1000)]; if ((tMaterial != null) && (tMaterial != Materials._NULL)) { if (tMaterial == mBlock) { return true; @@ -212,24 +282,33 @@ public class GT_BaseCrop extends CropCard implements ICropCardInfo { } } } else { - int tMetaID = aCrop.getWorld().getBlockMetadata(aCrop.getLocation().posX, aCrop.getLocation().posY - i, aCrop.getLocation().posZ); + int tMetaID = aCrop.getWorld() + .getBlockMetadata( + aCrop.getLocation().posX, aCrop.getLocation().posY - i, aCrop.getLocation().posZ); ItemData tAssotiation = GT_OreDictUnificator.getAssociation(new ItemStack(tBlock, 1, tMetaID)); - if ((tAssotiation != null) && (tAssotiation.mPrefix.toString().startsWith("ore")) && (tAssotiation.mMaterial.mMaterial == mBlock)) { + if ((tAssotiation != null) + && (tAssotiation.mPrefix.toString().startsWith("ore")) + && (tAssotiation.mMaterial.mMaterial == mBlock)) { return true; } - if ((tAssotiation != null) && (tAssotiation.mPrefix == OrePrefixes.block) && (tAssotiation.mMaterial.mMaterial == mBlock)) { + if ((tAssotiation != null) + && (tAssotiation.mPrefix == OrePrefixes.block) + && (tAssotiation.mMaterial.mMaterial == mBlock)) { return true; } } -// Block block = aCrop.getWorld().getBlock(aCrop.getLocation().posX, aCrop.getLocation().posY - i, aCrop.getLocation().posZ); -// if (block.isAir(aCrop.getWorld(), aCrop.getLocation().posX, aCrop.getLocation().posY - i, aCrop.getLocation().posZ)) { -// return false; -// } -// if (block == mBlock) { -// int tMeta = aCrop.getWorld().getBlockMetadata(aCrop.getLocation().posX, aCrop.getLocation().posY - i, aCrop.getLocation().posZ); -// if(mMeta < 0 || tMeta == mMeta){ -// return true;} -// } + // Block block = aCrop.getWorld().getBlock(aCrop.getLocation().posX, aCrop.getLocation().posY - i, + // aCrop.getLocation().posZ); + // if (block.isAir(aCrop.getWorld(), aCrop.getLocation().posX, aCrop.getLocation().posY - i, + // aCrop.getLocation().posZ)) { + // return false; + // } + // if (block == mBlock) { + // int tMeta = aCrop.getWorld().getBlockMetadata(aCrop.getLocation().posX, aCrop.getLocation().posY - + // i, aCrop.getLocation().posZ); + // if(mMeta < 0 || tMeta == mMeta){ + // return true;} + // } } return false; } @@ -238,7 +317,8 @@ public class GT_BaseCrop extends CropCard implements ICropCardInfo { public List<String> getCropInformation() { if (mBlock != null) { ArrayList<String> result = new ArrayList<String>(1); - result.add(String.format("Requires %s Ore or Block of %s as soil block to reach full growth.", mBlock.mName, mBlock.mName)); + result.add(String.format( + "Requires %s Ore or Block of %s as soil block to reach full growth.", mBlock.mName, mBlock.mName)); return result; } return null; @@ -251,5 +331,4 @@ public class GT_BaseCrop extends CropCard implements ICropCardInfo { } return GT_Utility.copyOrNull(mDrop); } - } diff --git a/src/main/java/gregtech/api/util/GT_BlockMap.java b/src/main/java/gregtech/api/util/GT_BlockMap.java index cd98aae2bd..9b71abbdc3 100644 --- a/src/main/java/gregtech/api/util/GT_BlockMap.java +++ b/src/main/java/gregtech/api/util/GT_BlockMap.java @@ -2,132 +2,131 @@ package gregtech.api.util; import gnu.trove.map.TByteObjectMap; import gnu.trove.map.hash.TByteObjectHashMap; -import net.minecraft.block.Block; - import java.util.HashMap; import java.util.Map; import java.util.function.BiFunction; +import net.minecraft.block.Block; public class GT_BlockMap<V> { - public static final byte WILDCARD = -1; - private final Map<Block, TByteObjectMap<V>> backing = new HashMap<>(); - private int size = 0; + public static final byte WILDCARD = -1; + private final Map<Block, TByteObjectMap<V>> backing = new HashMap<>(); + private int size = 0; - private TByteObjectMap<V> getSubmap(Block block) { - return backing.computeIfAbsent(block, b -> new TByteObjectHashMap<>()); - } + private TByteObjectMap<V> getSubmap(Block block) { + return backing.computeIfAbsent(block, b -> new TByteObjectHashMap<>()); + } - /** - * Associate a value with that union key - * - * @param block block - * @param meta meta - * @return old mapping, or null if that doesn't exist - */ - public V put(Block block, byte meta, V value) { - V v = getSubmap(block).put(meta, value); - if (v == null) size++; - return v; - } + /** + * Associate a value with that union key + * + * @param block block + * @param meta meta + * @return old mapping, or null if that doesn't exist + */ + public V put(Block block, byte meta, V value) { + V v = getSubmap(block).put(meta, value); + if (v == null) size++; + return v; + } - /** - * Associate a value with that union key ONLY IF there isn't a prior EXACT mapping - * - * @param block block - * @param meta meta - * @return old mapping, or null if that doesn't exist - */ - public V putIfAbsent(Block block, byte meta, V value) { - V v = getSubmap(block).putIfAbsent(meta, value); - if (v == null) size++; - return v; - } + /** + * Associate a value with that union key ONLY IF there isn't a prior EXACT mapping + * + * @param block block + * @param meta meta + * @return old mapping, or null if that doesn't exist + */ + public V putIfAbsent(Block block, byte meta, V value) { + V v = getSubmap(block).putIfAbsent(meta, value); + if (v == null) size++; + return v; + } - /** - * Associate a value with that union key ONLY IF there isn't a prior EXACT mapping - * - * @param block block - * @param meta meta - * @return old mapping, or null if that doesn't exist - */ - public V computeIfAbsent(Block block, byte meta, BiFunction<Block, Byte, V> function) { - TByteObjectMap<V> submap = getSubmap(block); - V v = submap.get(meta); - if (v == null) { - v = function.apply(block, meta); - submap.put(meta, v); - size++; - } - return v; - } + /** + * Associate a value with that union key ONLY IF there isn't a prior EXACT mapping + * + * @param block block + * @param meta meta + * @return old mapping, or null if that doesn't exist + */ + public V computeIfAbsent(Block block, byte meta, BiFunction<Block, Byte, V> function) { + TByteObjectMap<V> submap = getSubmap(block); + V v = submap.get(meta); + if (v == null) { + v = function.apply(block, meta); + submap.put(meta, v); + size++; + } + return v; + } - /** - * Contains an associated value - * - * @param block block - * @param meta meta - * @return current mapping OR wildcard of that mapping exists - */ - public boolean containsKey(Block block, byte meta) { - TByteObjectMap<V> submap = backing.get(block); - if (submap == null) return false; - return submap.containsKey(meta) || submap.containsKey(WILDCARD); - } + /** + * Contains an associated value + * + * @param block block + * @param meta meta + * @return current mapping OR wildcard of that mapping exists + */ + public boolean containsKey(Block block, byte meta) { + TByteObjectMap<V> submap = backing.get(block); + if (submap == null) return false; + return submap.containsKey(meta) || submap.containsKey(WILDCARD); + } - /** - * Get the associated value - * - * @param block block - * @param meta meta - * @return current mapping OR wildcard of that block. null if neither exists - */ - public V get(Block block, byte meta) { - TByteObjectMap<V> submap = backing.get(block); - if (submap == null) return null; - V v = submap.get(meta); - if (v != null) return v; - return submap.get(WILDCARD); - } + /** + * Get the associated value + * + * @param block block + * @param meta meta + * @return current mapping OR wildcard of that block. null if neither exists + */ + public V get(Block block, byte meta) { + TByteObjectMap<V> submap = backing.get(block); + if (submap == null) return null; + V v = submap.get(meta); + if (v != null) return v; + return submap.get(WILDCARD); + } - /** - * Remove a mapping - * - * @param block block - * @param meta meta - * @return old value, or null if none - */ - public V remove(Block block, byte meta) { - TByteObjectMap<V> submap = backing.get(block); - if (submap == null) return null; - V v = submap.remove(meta); - if (v != null) { - size--; - if (submap.isEmpty()) backing.remove(block); - } - return v; - } + /** + * Remove a mapping + * + * @param block block + * @param meta meta + * @return old value, or null if none + */ + public V remove(Block block, byte meta) { + TByteObjectMap<V> submap = backing.get(block); + if (submap == null) return null; + V v = submap.remove(meta); + if (v != null) { + size--; + if (submap.isEmpty()) backing.remove(block); + } + return v; + } - /** - * Size of all mappings - * - * @return size - */ - public int size() { - return size; - } + /** + * Size of all mappings + * + * @return size + */ + public int size() { + return size; + } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; - GT_BlockMap<?> that = (GT_BlockMap<?>) o; + GT_BlockMap<?> that = (GT_BlockMap<?>) o; - return backing.equals(that.backing); - } + return backing.equals(that.backing); + } - @Override - public int hashCode() { - return backing.hashCode(); - } + @Override + public int hashCode() { + return backing.hashCode(); + } } diff --git a/src/main/java/gregtech/api/util/GT_BlockSet.java b/src/main/java/gregtech/api/util/GT_BlockSet.java index 3c9905a757..94f3c3944a 100644 --- a/src/main/java/gregtech/api/util/GT_BlockSet.java +++ b/src/main/java/gregtech/api/util/GT_BlockSet.java @@ -3,36 +3,36 @@ package gregtech.api.util; import net.minecraft.block.Block; public class GT_BlockSet { - private final GT_BlockMap<Object> backing = new GT_BlockMap<>(); + private final GT_BlockMap<Object> backing = new GT_BlockMap<>(); - public boolean add(Block block, byte meta) { - return backing.put(block, meta, this) != this; - } + public boolean add(Block block, byte meta) { + return backing.put(block, meta, this) != this; + } - public boolean contains(Block block, byte meta) { - return backing.get(block, meta) == this; - } + public boolean contains(Block block, byte meta) { + return backing.get(block, meta) == this; + } - public boolean remove(Block block, byte meta) { - return backing.remove(block, meta) == this; - } + public boolean remove(Block block, byte meta) { + return backing.remove(block, meta) == this; + } - public int size() { - return backing.size(); - } + public int size() { + return backing.size(); + } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; - GT_BlockSet that = (GT_BlockSet) o; + GT_BlockSet that = (GT_BlockSet) o; - return backing.equals(that.backing); - } + return backing.equals(that.backing); + } - @Override - public int hashCode() { - return backing.hashCode(); - } + @Override + public int hashCode() { + return backing.hashCode(); + } } diff --git a/src/main/java/gregtech/api/util/GT_CLS_Compat.java b/src/main/java/gregtech/api/util/GT_CLS_Compat.java index 83b292d274..fd01ccd00e 100644 --- a/src/main/java/gregtech/api/util/GT_CLS_Compat.java +++ b/src/main/java/gregtech/api/util/GT_CLS_Compat.java @@ -5,16 +5,14 @@ import gregtech.GT_Mod; import gregtech.api.enums.Materials; import gregtech.common.GT_Proxy; import gregtech.loaders.postload.GT_PostLoad; - import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Collection; import java.util.Optional; import java.util.Set; -import java.util.function.Function; import java.util.function.Consumer; - +import java.util.function.Function; @SuppressWarnings("rawtypes, unchecked, deprecation") public class GT_CLS_Compat { @@ -31,7 +29,7 @@ public class GT_CLS_Compat { private static Field progressBarStep; static { - //CLS + // CLS try { alexiilMinecraftDisplayer = Class.forName("alexiil.mods.load.MinecraftDisplayer"); alexiilProgressDisplayer = Class.forName("alexiil.mods.load.ProgressDisplayer"); @@ -53,7 +51,6 @@ public class GT_CLS_Compat { } catch (NoSuchMethodException | NoSuchFieldException ex) { GT_Mod.GT_FML_LOGGER.catching(ex); } - }); Optional.ofNullable(alexiilProgressDisplayer).ifPresent(e -> { @@ -72,10 +69,14 @@ public class GT_CLS_Compat { } } - private GT_CLS_Compat() { - } + private GT_CLS_Compat() {} - private static <T> void registerAndReportProgression(String materialsType, Collection<T> materials, ProgressManager.ProgressBar progressBar, Function<T,Object> getName, Consumer<T> action) { + private static <T> void registerAndReportProgression( + String materialsType, + Collection<T> materials, + ProgressManager.ProgressBar progressBar, + Function<T, Object> getName, + Consumer<T> action) { int sizeStep = materials.size(); final long progressionReportsEvery = 100; final long bakingMsgEvery = 1000; @@ -90,7 +91,7 @@ public class GT_CLS_Compat { nextProgressionReportAt = now + progressionReportsEvery; String materialName = getName.apply(m).toString(); try { - displayProgress.invoke(null, materialName, (float)currentStep / sizeStep); + displayProgress.invoke(null, materialName, (float) currentStep / sizeStep); } catch (IllegalAccessException | InvocationTargetException iae) { GT_Mod.GT_FML_LOGGER.error("While updating progression", iae); } @@ -103,11 +104,13 @@ public class GT_CLS_Compat { } if (nextBakingMsgAt < now) { nextBakingMsgAt = now + bakingMsgEvery; - GT_Mod.GT_FML_LOGGER.info(String.format("%s - Baking: %d%%", materialsType, (Integer)(currentStep * 100 / sizeStep))); + GT_Mod.GT_FML_LOGGER.info( + String.format("%s - Baking: %d%%", materialsType, (Integer) (currentStep * 100 / sizeStep))); } action.accept(m); currentStep += 1; - }; + } + ; GT_Mod.GT_FML_LOGGER.info(String.format("%s - Baking: Done", materialsType)); try { progressBarStep.set(progressBar, currentStep); @@ -116,35 +119,38 @@ public class GT_CLS_Compat { } } - public static void stepMaterialsCLS(Collection<GT_Proxy.OreDictEventContainer> mEvents, ProgressManager.ProgressBar progressBar) throws IllegalAccessException, InvocationTargetException { + public static void stepMaterialsCLS( + Collection<GT_Proxy.OreDictEventContainer> mEvents, ProgressManager.ProgressBar progressBar) + throws IllegalAccessException, InvocationTargetException { try { isRegisteringGTmaterials.set(null, true); } catch (IllegalArgumentException | IllegalAccessException e) { GT_Mod.GT_FML_LOGGER.catching(e); } - registerAndReportProgression("GregTech materials", mEvents, progressBar, - m -> m.mMaterial, - m -> GT_Proxy.registerRecipes(m) - ); + registerAndReportProgression( + "GregTech materials", mEvents, progressBar, m -> m.mMaterial, m -> GT_Proxy.registerRecipes(m)); ProgressManager.pop(progressBar); isRegisteringGTmaterials.set(null, false); - } + } - public static void doActualRegistrationCLS(ProgressManager.ProgressBar progressBar, Set<Materials> replacedVanillaItemsSet) throws InvocationTargetException, IllegalAccessException { + public static void doActualRegistrationCLS( + ProgressManager.ProgressBar progressBar, Set<Materials> replacedVanillaItemsSet) + throws InvocationTargetException, IllegalAccessException { try { - isReplacingVanillaMaterials.set(null, true); - } catch (IllegalArgumentException | IllegalAccessException e) { + isReplacingVanillaMaterials.set(null, true); + } catch (IllegalArgumentException | IllegalAccessException e) { GT_Mod.GT_FML_LOGGER.catching(e); } - registerAndReportProgression("Vanilla materials", replacedVanillaItemsSet, progressBar, - m -> m.mDefaultLocalName, - m -> GT_PostLoad.doActualRegistration(m) - ); + registerAndReportProgression( + "Vanilla materials", + replacedVanillaItemsSet, + progressBar, + m -> m.mDefaultLocalName, + m -> GT_PostLoad.doActualRegistration(m)); } public static void pushToDisplayProgress() throws InvocationTargetException, IllegalAccessException { isReplacingVanillaMaterials.set(null, false); displayProgress.invoke(null, "Post Initialization: loading GregTech", getLastPercent.invoke(null)); } - } diff --git a/src/main/java/gregtech/api/util/GT_ChunkAssociatedData.java b/src/main/java/gregtech/api/util/GT_ChunkAssociatedData.java index bb589daa80..38b147e318 100644 --- a/src/main/java/gregtech/api/util/GT_ChunkAssociatedData.java +++ b/src/main/java/gregtech/api/util/GT_ChunkAssociatedData.java @@ -3,14 +3,6 @@ package gregtech.api.util; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import gregtech.api.enums.GT_Values; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.world.ChunkCoordIntPair; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.world.WorldEvent; -import org.apache.commons.io.FileUtils; - -import javax.annotation.ParametersAreNonnullByDefault; import java.io.DataInput; import java.io.DataInputStream; import java.io.DataOutput; @@ -36,6 +28,13 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stream.Stream; +import javax.annotation.ParametersAreNonnullByDefault; +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.world.WorldEvent; +import org.apache.commons.io.FileUtils; /** * A utility to save all kinds of data that is a function of any chunk. @@ -57,400 +56,413 @@ import java.util.stream.Stream; */ @ParametersAreNonnullByDefault public abstract class GT_ChunkAssociatedData<T extends GT_ChunkAssociatedData.IData> { - private static final Map<String, GT_ChunkAssociatedData<?>> instances = new ConcurrentHashMap<>(); - private static final int IO_PARALLELISM = Math.min(8, Math.max(1, Runtime.getRuntime().availableProcessors() * 2 / 3)); - private static final ExecutorService IO_WORKERS = Executors.newWorkStealingPool(IO_PARALLELISM); - private static final Pattern FILE_PATTERN = Pattern.compile("(.+)\\.(-?\\d+)\\.(-?\\d+)\\.dat"); - - static { - // register event handler - new EventHandler(); - } - - protected final String mId; - protected final Class<T> elementtype; - private final int regionLength; - private final int version; - private final boolean saveDefaults; - /** - * Data is stored as a `(world id -> (super region id -> super region data))` hash map. - * where super region's size is determined by regionSize. - * Here it is called super region, to not confuse with vanilla's regions. - */ - private final Map<Integer, Map<ChunkCoordIntPair, SuperRegion>> masterMap = new ConcurrentHashMap<>(); - - /** - * Initialize this instance. - * - * @param aId An arbitrary, but globally unique identifier for what this data is - * @param elementType The class of this element type. Used to create arrays. - * @param regionLength The length of one super region. Each super region will contain {@code regionLength * regionLength} chunks - * @param version An integer marking the version of this data. Useful later when the data's serialized form changed. - */ - protected GT_ChunkAssociatedData(String aId, Class<T> elementType, int regionLength, byte version, boolean saveDefaults) { - if (regionLength * regionLength > Short.MAX_VALUE || regionLength <= 0) - throw new IllegalArgumentException("Region invalid: " + regionLength); - if (!IData.class.isAssignableFrom(elementType)) - throw new IllegalArgumentException("Data type invalid"); - if (aId.contains(".")) - throw new IllegalArgumentException("ID cannot contains dot"); - this.mId = aId; - this.elementtype = elementType; - this.regionLength = regionLength; - this.version = version; - this.saveDefaults = saveDefaults; - if (instances.putIfAbsent(aId, this) != null) - throw new IllegalArgumentException("Duplicate GT_ChunkAssociatedData: " + aId); - } - - private ChunkCoordIntPair getRegionID(int aChunkX, int aChunkZ) { - return new ChunkCoordIntPair(Math.floorDiv(aChunkX, regionLength), Math.floorDiv(aChunkZ, regionLength)); - } - - /** - * Get a reference to data of the chunk that tile entity is in. - * The returned reference should be mutable. - */ - public final T get(IGregTechTileEntity tileEntity) { - return get(tileEntity.getWorld(), tileEntity.getXCoord() >> 4, tileEntity.getZCoord() >> 4); - } - - public final T get(Chunk chunk) { - return get(chunk.worldObj, chunk.xPosition, chunk.zPosition); - } - - public final T get(World world, ChunkCoordIntPair coord) { - return get(world, coord.chunkXPos, coord.chunkZPos); - } - - public final T get(World world, int chunkX, int chunkZ) { - SuperRegion region = masterMap.computeIfAbsent(world.provider.dimensionId, ignored -> new ConcurrentHashMap<>()) - .computeIfAbsent(getRegionID(chunkX, chunkZ), c -> new SuperRegion(world, c)); - return region.get(Math.floorMod(chunkX, regionLength), Math.floorMod(chunkZ, regionLength)); - } - - protected final void set(World world, int chunkX, int chunkZ, T data) { - SuperRegion region = masterMap.computeIfAbsent(world.provider.dimensionId, ignored -> new ConcurrentHashMap<>()) - .computeIfAbsent(getRegionID(chunkX, chunkZ), c -> new SuperRegion(world, c)); - region.set(Math.floorMod(chunkX, regionLength), Math.floorMod(chunkZ, regionLength), data); - } - - protected final boolean isCreated(int dimId, int chunkX, int chunkZ) { - Map<ChunkCoordIntPair, SuperRegion> dimData = masterMap.getOrDefault(dimId, null); - if (dimData == null) return false; - - SuperRegion region = dimData.getOrDefault(getRegionID(chunkX, chunkZ), null); - if (region == null) return false; - - return region.isCreated(Math.floorMod(chunkX, regionLength), Math.floorMod(chunkZ, regionLength)); - } - - public void clear() { - if (GT_Values.debugWorldData) { - long dirtyRegionCount = masterMap.values().stream() - .flatMap(m -> m.values().stream()) - .filter(SuperRegion::isDirty) - .count(); - if (dirtyRegionCount > 0) - GT_Log.out.println("Clearing ChunkAssociatedData with " + dirtyRegionCount + " regions dirty. Data might have been lost!"); - } - masterMap.clear(); - } - - public void save() { - saveRegions(masterMap.values().stream().flatMap(m -> m.values().stream())); - } - - public void save(World world) { - Map<ChunkCoordIntPair, SuperRegion> map = masterMap.get(world.provider.dimensionId); - if (map != null) - saveRegions(map.values().stream()); - } - - private void saveRegions(Stream<SuperRegion> stream) { - stream.filter(r -> r.isDirty()) - .map(c -> (Runnable) c::save) - .map(r -> CompletableFuture.runAsync(r, IO_WORKERS)) - .reduce(CompletableFuture::allOf) - .ifPresent(f -> { - try { - f.get(); - } catch (Exception e) { - GT_Log.err.println("Data save error: " + mId); - e.printStackTrace(GT_Log.err); - } - }); - } - - protected abstract void writeElement(DataOutput output, T element, World world, int chunkX, int chunkZ) throws IOException; - - protected abstract T readElement(DataInput input, int version, World world, int chunkX, int chunkZ) throws IOException; - - protected abstract T createElement(World world, int chunkX, int chunkZ); - - /** - * Clear all mappings, regardless of whether they are dirty - */ - public static void clearAll() { - for (GT_ChunkAssociatedData<?> d : instances.values()) d.clear(); - } - - /** - * Save all mappings - */ - public static void saveAll() { - for (GT_ChunkAssociatedData<?> d : instances.values()) d.save(); - } - - /** - * Load data for all chunks for a given world. - * Current data for that world will be discarded. If this is what you intended, call {@link #save(World)} beforehand. - * <p> - * Be aware of the memory consumption though. - */ - protected void loadAll(World w) { - if (GT_Values.debugWorldData && masterMap.containsKey(w.provider.dimensionId)) - GT_Log.err.println("Reloading ChunkAssociatedData " + mId + " for world " + w.provider.dimensionId + " discards old data!"); - if (!getSaveDirectory(w).isDirectory()) - // nothing to load... - return; - try { - Map<ChunkCoordIntPair, SuperRegion> worldData = Files.list(getSaveDirectory(w).toPath()) - .map(f -> { - Matcher matcher = FILE_PATTERN.matcher(f.getFileName().toString()); - return matcher.matches() ? matcher : null; - }) - .filter(Objects::nonNull) - .filter(m -> mId.equals(m.group(1))) - .map(m -> CompletableFuture.supplyAsync(() -> new SuperRegion(w, Integer.parseInt(m.group(2)), Integer.parseInt(m.group(3))), IO_WORKERS)) - .map(f -> { - try { - return f.get(); - } catch (Exception e) { - GT_Log.err.println("Error loading region"); - e.printStackTrace(GT_Log.err); - return null; - } - }) - .filter(Objects::nonNull) - .collect(Collectors.toMap(SuperRegion::getCoord, Function.identity())); - masterMap.put(w.provider.dimensionId, worldData); - } catch (IOException e) { - GT_Log.err.println("Error loading all region"); - e.printStackTrace(GT_Log.err); - } - } - - protected File getSaveDirectory(World w) { - File base; - if (w.provider.getSaveFolder() == null) - base = w.getSaveHandler().getWorldDirectory(); - else - base = new File(w.getSaveHandler().getWorldDirectory(), w.provider.getSaveFolder()); - return new File(base, "gregtech"); - } - - public interface IData { - /** - * @return Whether the data is different from chunk default - */ - boolean isSameAsDefault(); - } - - protected final class SuperRegion { - private final T[] data = createData(); - private final File backingStorage; - private final WeakReference<World> world; - /** - * Be aware, this means region coord, not bottom-left chunk coord - */ - private final ChunkCoordIntPair coord; - - private SuperRegion(World world, int regionX, int regionZ) { - this.world = new WeakReference<>(world); - this.coord = new ChunkCoordIntPair(regionX, regionZ); - backingStorage = new File(getSaveDirectory(world), String.format("%s.%d.%d.dat", mId, regionX, regionZ)); - if (backingStorage.isFile()) - load(); - } - - private SuperRegion(World world, ChunkCoordIntPair regionCoord) { - this.world = new WeakReference<>(world); - this.coord = regionCoord; - backingStorage = new File(getSaveDirectory(world), String.format("%s.%d.%d.dat", mId, regionCoord.chunkXPos, regionCoord.chunkZPos)); - if (backingStorage.isFile()) - load(); - } - - @SuppressWarnings("unchecked") - private T[] createData() { - return (T[]) Array.newInstance(elementtype, regionLength * regionLength); - } - - public T get(int subRegionX, int subRegionZ) { - int index = getIndex(subRegionX, subRegionZ); - T datum = data[index]; - if (datum == null) { - World world = Objects.requireNonNull(this.world.get()); - T newElem = createElement(world, coord.chunkXPos * regionLength + subRegionX, coord.chunkZPos * regionLength + subRegionZ); - data[index] = newElem; - return newElem; - } - return datum; - } - - public void set(int subRegionX, int subRegionZ, T data) { - this.data[getIndex(subRegionX, subRegionZ)] = data; - } - - public boolean isCreated(int subRegionX, int subRegionZ) { - return this.data[getIndex(subRegionX, subRegionZ)] != null; - } - - public ChunkCoordIntPair getCoord() { - return coord; - } - - private int getIndex(int subRegionX, int subRegionY) { - return subRegionX * regionLength + subRegionY; - } - - private int getChunkX(int index) { - return index / regionLength + coord.chunkXPos * regionLength; - } - - private int getChunkZ(int index) { - return index % regionLength + coord.chunkZPos * regionLength; - } - - public boolean isDirty() { - for (T datum : data) { - if (datum != null && !datum.isSameAsDefault()) - return true; - } - return false; - } - - public void save() { - try { - save0(); - } catch (IOException e) { - GT_Log.err.println("Error saving data " + backingStorage.getPath()); - e.printStackTrace(GT_Log.err); - } - } - - private void save0() throws IOException { - //noinspection ResultOfMethodCallIgnored - backingStorage.getParentFile().mkdirs(); - File tmpFile = getTmpFile(); - World world = Objects.requireNonNull(this.world.get(), "Attempting to save region of another world!"); - try (DataOutputStream output = new DataOutputStream(new FileOutputStream(tmpFile))) { - int ptr = 0; - boolean nullRange = data[0] == null; - // write a magic byte as storage format version - output.writeByte(0); - // write a magic byte as data format version - output.writeByte(version); - output.writeBoolean(nullRange); - while (ptr < data.length) { - // work out how long is this range - int rangeStart = ptr; - while (ptr < data.length && (data[ptr] == null || (!saveDefaults && data[ptr].isSameAsDefault())) == nullRange) - ptr++; - // write range length - output.writeShort(ptr - rangeStart); - if (!nullRange) - // write element data - for (int i = rangeStart; i < ptr; i++) - writeElement(output, data[i], world, getChunkX(ptr), getChunkZ(ptr)); - // or not - nullRange = !nullRange; - } - } - // first try to replace the destination file - // since atomic operation, no need to keep the backup in place - try { - Files.move(tmpFile.toPath(), backingStorage.toPath(), StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE); - } catch (AtomicMoveNotSupportedException ignored) { - // in case some dumb system/jre combination would cause this - // or if **somehow** two file inside the same directory belongs two separate filesystem - FileUtils.copyFile(tmpFile, backingStorage); - } - } - - public void load() { - try { - loadFromFile(backingStorage); - } catch (IOException | RuntimeException e) { - GT_Log.err.println("Primary storage file broken in " + backingStorage.getPath()); - e.printStackTrace(GT_Log.err); - // in case the primary storage is broken - try { - loadFromFile(getTmpFile()); - } catch (IOException | RuntimeException e2) { - GT_Log.err.println("Backup storage file broken in " + backingStorage.getPath()); - e2.printStackTrace(GT_Log.err); - } - } - } - - private void loadFromFile(File file) throws IOException { - World world = Objects.requireNonNull(this.world.get(), "Attempting to load region of another world!"); - try (DataInputStream input = new DataInputStream(new FileInputStream(file))) { - byte b = input.readByte(); - switch (b) { - case 0: - loadV0(input, world); - break; - default: - GT_Log.err.printf("Unknown ChunkAssociatedData version %d\n", b); - } - } - } - - private void loadV0(DataInput input, World world) throws IOException { - int version = input.readByte(); - boolean nullRange = input.readBoolean(); - int ptr = 0; - while (ptr != data.length) { - int rangeEnd = ptr + input.readUnsignedShort(); - if (!nullRange) { - for (; ptr < rangeEnd; ptr++) { - data[ptr] = readElement(input, version, world, getChunkX(ptr), getChunkZ(ptr)); - } - } else { - Arrays.fill(data, ptr, rangeEnd, null); - ptr = rangeEnd; - } - nullRange = !nullRange; - } - } - - private File getTmpFile() { - return new File(backingStorage.getParentFile(), backingStorage.getName() + ".tmp"); - } - } - - public static class EventHandler { - private EventHandler() { - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - public void onWorldSave(WorldEvent.Save e) { - for (GT_ChunkAssociatedData<?> d : instances.values()) { - d.save(e.world); - } - } - - @SubscribeEvent - public void onWorldUnload(WorldEvent.Unload e) { - for (GT_ChunkAssociatedData<?> d : instances.values()) { - // there is no need to explicitly do a save here - // forge will send a WorldEvent.Save on server thread before this event is distributed - d.masterMap.remove(e.world.provider.dimensionId); - } - } - } + private static final Map<String, GT_ChunkAssociatedData<?>> instances = new ConcurrentHashMap<>(); + private static final int IO_PARALLELISM = + Math.min(8, Math.max(1, Runtime.getRuntime().availableProcessors() * 2 / 3)); + private static final ExecutorService IO_WORKERS = Executors.newWorkStealingPool(IO_PARALLELISM); + private static final Pattern FILE_PATTERN = Pattern.compile("(.+)\\.(-?\\d+)\\.(-?\\d+)\\.dat"); + + static { + // register event handler + new EventHandler(); + } + + protected final String mId; + protected final Class<T> elementtype; + private final int regionLength; + private final int version; + private final boolean saveDefaults; + /** + * Data is stored as a `(world id -> (super region id -> super region data))` hash map. + * where super region's size is determined by regionSize. + * Here it is called super region, to not confuse with vanilla's regions. + */ + private final Map<Integer, Map<ChunkCoordIntPair, SuperRegion>> masterMap = new ConcurrentHashMap<>(); + + /** + * Initialize this instance. + * + * @param aId An arbitrary, but globally unique identifier for what this data is + * @param elementType The class of this element type. Used to create arrays. + * @param regionLength The length of one super region. Each super region will contain {@code regionLength * regionLength} chunks + * @param version An integer marking the version of this data. Useful later when the data's serialized form changed. + */ + protected GT_ChunkAssociatedData( + String aId, Class<T> elementType, int regionLength, byte version, boolean saveDefaults) { + if (regionLength * regionLength > Short.MAX_VALUE || regionLength <= 0) + throw new IllegalArgumentException("Region invalid: " + regionLength); + if (!IData.class.isAssignableFrom(elementType)) throw new IllegalArgumentException("Data type invalid"); + if (aId.contains(".")) throw new IllegalArgumentException("ID cannot contains dot"); + this.mId = aId; + this.elementtype = elementType; + this.regionLength = regionLength; + this.version = version; + this.saveDefaults = saveDefaults; + if (instances.putIfAbsent(aId, this) != null) + throw new IllegalArgumentException("Duplicate GT_ChunkAssociatedData: " + aId); + } + + private ChunkCoordIntPair getRegionID(int aChunkX, int aChunkZ) { + return new ChunkCoordIntPair(Math.floorDiv(aChunkX, regionLength), Math.floorDiv(aChunkZ, regionLength)); + } + + /** + * Get a reference to data of the chunk that tile entity is in. + * The returned reference should be mutable. + */ + public final T get(IGregTechTileEntity tileEntity) { + return get(tileEntity.getWorld(), tileEntity.getXCoord() >> 4, tileEntity.getZCoord() >> 4); + } + + public final T get(Chunk chunk) { + return get(chunk.worldObj, chunk.xPosition, chunk.zPosition); + } + + public final T get(World world, ChunkCoordIntPair coord) { + return get(world, coord.chunkXPos, coord.chunkZPos); + } + + public final T get(World world, int chunkX, int chunkZ) { + SuperRegion region = masterMap + .computeIfAbsent(world.provider.dimensionId, ignored -> new ConcurrentHashMap<>()) + .computeIfAbsent(getRegionID(chunkX, chunkZ), c -> new SuperRegion(world, c)); + return region.get(Math.floorMod(chunkX, regionLength), Math.floorMod(chunkZ, regionLength)); + } + + protected final void set(World world, int chunkX, int chunkZ, T data) { + SuperRegion region = masterMap + .computeIfAbsent(world.provider.dimensionId, ignored -> new ConcurrentHashMap<>()) + .computeIfAbsent(getRegionID(chunkX, chunkZ), c -> new SuperRegion(world, c)); + region.set(Math.floorMod(chunkX, regionLength), Math.floorMod(chunkZ, regionLength), data); + } + + protected final boolean isCreated(int dimId, int chunkX, int chunkZ) { + Map<ChunkCoordIntPair, SuperRegion> dimData = masterMap.getOrDefault(dimId, null); + if (dimData == null) return false; + + SuperRegion region = dimData.getOrDefault(getRegionID(chunkX, chunkZ), null); + if (region == null) return false; + + return region.isCreated(Math.floorMod(chunkX, regionLength), Math.floorMod(chunkZ, regionLength)); + } + + public void clear() { + if (GT_Values.debugWorldData) { + long dirtyRegionCount = masterMap.values().stream() + .flatMap(m -> m.values().stream()) + .filter(SuperRegion::isDirty) + .count(); + if (dirtyRegionCount > 0) + GT_Log.out.println("Clearing ChunkAssociatedData with " + dirtyRegionCount + + " regions dirty. Data might have been lost!"); + } + masterMap.clear(); + } + + public void save() { + saveRegions(masterMap.values().stream().flatMap(m -> m.values().stream())); + } + + public void save(World world) { + Map<ChunkCoordIntPair, SuperRegion> map = masterMap.get(world.provider.dimensionId); + if (map != null) saveRegions(map.values().stream()); + } + + private void saveRegions(Stream<SuperRegion> stream) { + stream.filter(r -> r.isDirty()) + .map(c -> (Runnable) c::save) + .map(r -> CompletableFuture.runAsync(r, IO_WORKERS)) + .reduce(CompletableFuture::allOf) + .ifPresent(f -> { + try { + f.get(); + } catch (Exception e) { + GT_Log.err.println("Data save error: " + mId); + e.printStackTrace(GT_Log.err); + } + }); + } + + protected abstract void writeElement(DataOutput output, T element, World world, int chunkX, int chunkZ) + throws IOException; + + protected abstract T readElement(DataInput input, int version, World world, int chunkX, int chunkZ) + throws IOException; + + protected abstract T createElement(World world, int chunkX, int chunkZ); + + /** + * Clear all mappings, regardless of whether they are dirty + */ + public static void clearAll() { + for (GT_ChunkAssociatedData<?> d : instances.values()) d.clear(); + } + + /** + * Save all mappings + */ + public static void saveAll() { + for (GT_ChunkAssociatedData<?> d : instances.values()) d.save(); + } + + /** + * Load data for all chunks for a given world. + * Current data for that world will be discarded. If this is what you intended, call {@link #save(World)} beforehand. + * <p> + * Be aware of the memory consumption though. + */ + protected void loadAll(World w) { + if (GT_Values.debugWorldData && masterMap.containsKey(w.provider.dimensionId)) + GT_Log.err.println("Reloading ChunkAssociatedData " + mId + " for world " + w.provider.dimensionId + + " discards old data!"); + if (!getSaveDirectory(w).isDirectory()) + // nothing to load... + return; + try { + Map<ChunkCoordIntPair, SuperRegion> worldData = Files.list( + getSaveDirectory(w).toPath()) + .map(f -> { + Matcher matcher = FILE_PATTERN.matcher(f.getFileName().toString()); + return matcher.matches() ? matcher : null; + }) + .filter(Objects::nonNull) + .filter(m -> mId.equals(m.group(1))) + .map(m -> CompletableFuture.supplyAsync( + () -> new SuperRegion(w, Integer.parseInt(m.group(2)), Integer.parseInt(m.group(3))), + IO_WORKERS)) + .map(f -> { + try { + return f.get(); + } catch (Exception e) { + GT_Log.err.println("Error loading region"); + e.printStackTrace(GT_Log.err); + return null; + } + }) + .filter(Objects::nonNull) + .collect(Collectors.toMap(SuperRegion::getCoord, Function.identity())); + masterMap.put(w.provider.dimensionId, worldData); + } catch (IOException e) { + GT_Log.err.println("Error loading all region"); + e.printStackTrace(GT_Log.err); + } + } + + protected File getSaveDirectory(World w) { + File base; + if (w.provider.getSaveFolder() == null) base = w.getSaveHandler().getWorldDirectory(); + else base = new File(w.getSaveHandler().getWorldDirectory(), w.provider.getSaveFolder()); + return new File(base, "gregtech"); + } + + public interface IData { + /** + * @return Whether the data is different from chunk default + */ + boolean isSameAsDefault(); + } + + protected final class SuperRegion { + private final T[] data = createData(); + private final File backingStorage; + private final WeakReference<World> world; + /** + * Be aware, this means region coord, not bottom-left chunk coord + */ + private final ChunkCoordIntPair coord; + + private SuperRegion(World world, int regionX, int regionZ) { + this.world = new WeakReference<>(world); + this.coord = new ChunkCoordIntPair(regionX, regionZ); + backingStorage = new File(getSaveDirectory(world), String.format("%s.%d.%d.dat", mId, regionX, regionZ)); + if (backingStorage.isFile()) load(); + } + + private SuperRegion(World world, ChunkCoordIntPair regionCoord) { + this.world = new WeakReference<>(world); + this.coord = regionCoord; + backingStorage = new File( + getSaveDirectory(world), + String.format("%s.%d.%d.dat", mId, regionCoord.chunkXPos, regionCoord.chunkZPos)); + if (backingStorage.isFile()) load(); + } + + @SuppressWarnings("unchecked") + private T[] createData() { + return (T[]) Array.newInstance(elementtype, regionLength * regionLength); + } + + public T get(int subRegionX, int subRegionZ) { + int index = getIndex(subRegionX, subRegionZ); + T datum = data[index]; + if (datum == null) { + World world = Objects.requireNonNull(this.world.get()); + T newElem = createElement( + world, + coord.chunkXPos * regionLength + subRegionX, + coord.chunkZPos * regionLength + subRegionZ); + data[index] = newElem; + return newElem; + } + return datum; + } + + public void set(int subRegionX, int subRegionZ, T data) { + this.data[getIndex(subRegionX, subRegionZ)] = data; + } + + public boolean isCreated(int subRegionX, int subRegionZ) { + return this.data[getIndex(subRegionX, subRegionZ)] != null; + } + + public ChunkCoordIntPair getCoord() { + return coord; + } + + private int getIndex(int subRegionX, int subRegionY) { + return subRegionX * regionLength + subRegionY; + } + + private int getChunkX(int index) { + return index / regionLength + coord.chunkXPos * regionLength; + } + + private int getChunkZ(int index) { + return index % regionLength + coord.chunkZPos * regionLength; + } + + public boolean isDirty() { + for (T datum : data) { + if (datum != null && !datum.isSameAsDefault()) return true; + } + return false; + } + + public void save() { + try { + save0(); + } catch (IOException e) { + GT_Log.err.println("Error saving data " + backingStorage.getPath()); + e.printStackTrace(GT_Log.err); + } + } + + private void save0() throws IOException { + //noinspection ResultOfMethodCallIgnored + backingStorage.getParentFile().mkdirs(); + File tmpFile = getTmpFile(); + World world = Objects.requireNonNull(this.world.get(), "Attempting to save region of another world!"); + try (DataOutputStream output = new DataOutputStream(new FileOutputStream(tmpFile))) { + int ptr = 0; + boolean nullRange = data[0] == null; + // write a magic byte as storage format version + output.writeByte(0); + // write a magic byte as data format version + output.writeByte(version); + output.writeBoolean(nullRange); + while (ptr < data.length) { + // work out how long is this range + int rangeStart = ptr; + while (ptr < data.length + && (data[ptr] == null || (!saveDefaults && data[ptr].isSameAsDefault())) == nullRange) + ptr++; + // write range length + output.writeShort(ptr - rangeStart); + if (!nullRange) + // write element data + for (int i = rangeStart; i < ptr; i++) + writeElement(output, data[i], world, getChunkX(ptr), getChunkZ(ptr)); + // or not + nullRange = !nullRange; + } + } + // first try to replace the destination file + // since atomic operation, no need to keep the backup in place + try { + Files.move( + tmpFile.toPath(), + backingStorage.toPath(), + StandardCopyOption.REPLACE_EXISTING, + StandardCopyOption.ATOMIC_MOVE); + } catch (AtomicMoveNotSupportedException ignored) { + // in case some dumb system/jre combination would cause this + // or if **somehow** two file inside the same directory belongs two separate filesystem + FileUtils.copyFile(tmpFile, backingStorage); + } + } + + public void load() { + try { + loadFromFile(backingStorage); + } catch (IOException | RuntimeException e) { + GT_Log.err.println("Primary storage file broken in " + backingStorage.getPath()); + e.printStackTrace(GT_Log.err); + // in case the primary storage is broken + try { + loadFromFile(getTmpFile()); + } catch (IOException | RuntimeException e2) { + GT_Log.err.println("Backup storage file broken in " + backingStorage.getPath()); + e2.printStackTrace(GT_Log.err); + } + } + } + + private void loadFromFile(File file) throws IOException { + World world = Objects.requireNonNull(this.world.get(), "Attempting to load region of another world!"); + try (DataInputStream input = new DataInputStream(new FileInputStream(file))) { + byte b = input.readByte(); + switch (b) { + case 0: + loadV0(input, world); + break; + default: + GT_Log.err.printf("Unknown ChunkAssociatedData version %d\n", b); + } + } + } + + private void loadV0(DataInput input, World world) throws IOException { + int version = input.readByte(); + boolean nullRange = input.readBoolean(); + int ptr = 0; + while (ptr != data.length) { + int rangeEnd = ptr + input.readUnsignedShort(); + if (!nullRange) { + for (; ptr < rangeEnd; ptr++) { + data[ptr] = readElement(input, version, world, getChunkX(ptr), getChunkZ(ptr)); + } + } else { + Arrays.fill(data, ptr, rangeEnd, null); + ptr = rangeEnd; + } + nullRange = !nullRange; + } + } + + private File getTmpFile() { + return new File(backingStorage.getParentFile(), backingStorage.getName() + ".tmp"); + } + } + + public static class EventHandler { + private EventHandler() { + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onWorldSave(WorldEvent.Save e) { + for (GT_ChunkAssociatedData<?> d : instances.values()) { + d.save(e.world); + } + } + + @SubscribeEvent + public void onWorldUnload(WorldEvent.Unload e) { + for (GT_ChunkAssociatedData<?> d : instances.values()) { + // there is no need to explicitly do a save here + // forge will send a WorldEvent.Save on server thread before this event is distributed + d.masterMap.remove(e.world.provider.dimensionId); + } + } + } } diff --git a/src/main/java/gregtech/api/util/GT_CircuitryBehavior.java b/src/main/java/gregtech/api/util/GT_CircuitryBehavior.java index f25b88728d..b7ded54d64 100644 --- a/src/main/java/gregtech/api/util/GT_CircuitryBehavior.java +++ b/src/main/java/gregtech/api/util/GT_CircuitryBehavior.java @@ -33,7 +33,14 @@ public abstract class GT_CircuitryBehavior { */ public static final boolean getAnyRedstone(IRedstoneCircuitBlock aRedstoneCircuitBlock) { for (byte i = 0; i < 6; i++) { - if (i != aRedstoneCircuitBlock.getOutputFacing() && aRedstoneCircuitBlock.getCover(i).letsRedstoneGoIn(i, aRedstoneCircuitBlock.getCoverID(i), aRedstoneCircuitBlock.getCoverVariable(i), aRedstoneCircuitBlock.getOwnTileEntity())) { + if (i != aRedstoneCircuitBlock.getOutputFacing() + && aRedstoneCircuitBlock + .getCover(i) + .letsRedstoneGoIn( + i, + aRedstoneCircuitBlock.getCoverID(i), + aRedstoneCircuitBlock.getCoverVariable(i), + aRedstoneCircuitBlock.getOwnTileEntity())) { if (aRedstoneCircuitBlock.getInputRedstone(i) > 0) { return true; } @@ -47,7 +54,14 @@ public abstract class GT_CircuitryBehavior { */ public static final boolean getAllRedstone(IRedstoneCircuitBlock aRedstoneCircuitBlock) { for (byte i = 0; i < 6; i++) { - if (i != aRedstoneCircuitBlock.getOutputFacing() && aRedstoneCircuitBlock.getCover(i).letsRedstoneGoIn(i, aRedstoneCircuitBlock.getCoverID(i), aRedstoneCircuitBlock.getCoverVariable(i), aRedstoneCircuitBlock.getOwnTileEntity())) { + if (i != aRedstoneCircuitBlock.getOutputFacing() + && aRedstoneCircuitBlock + .getCover(i) + .letsRedstoneGoIn( + i, + aRedstoneCircuitBlock.getCoverID(i), + aRedstoneCircuitBlock.getCoverVariable(i), + aRedstoneCircuitBlock.getOwnTileEntity())) { if (aRedstoneCircuitBlock.getInputRedstone(i) == 0) { return false; } @@ -62,7 +76,14 @@ public abstract class GT_CircuitryBehavior { public static final boolean getOneRedstone(IRedstoneCircuitBlock aRedstoneCircuitBlock) { int tRedstoneAmount = 0; for (byte i = 0; i < 6; i++) { - if (i != aRedstoneCircuitBlock.getOutputFacing() && aRedstoneCircuitBlock.getCover(i).letsRedstoneGoIn(i, aRedstoneCircuitBlock.getCoverID(i), aRedstoneCircuitBlock.getCoverVariable(i), aRedstoneCircuitBlock.getOwnTileEntity())) { + if (i != aRedstoneCircuitBlock.getOutputFacing() + && aRedstoneCircuitBlock + .getCover(i) + .letsRedstoneGoIn( + i, + aRedstoneCircuitBlock.getCoverID(i), + aRedstoneCircuitBlock.getCoverVariable(i), + aRedstoneCircuitBlock.getOwnTileEntity())) { if (aRedstoneCircuitBlock.getInputRedstone(i) > 0) { tRedstoneAmount++; } @@ -77,7 +98,14 @@ public abstract class GT_CircuitryBehavior { public static final byte getStrongestRedstone(IRedstoneCircuitBlock aRedstoneCircuitBlock) { byte tRedstoneAmount = 0; for (byte i = 0; i < 6; i++) { - if (i != aRedstoneCircuitBlock.getOutputFacing() && aRedstoneCircuitBlock.getCover(i).letsRedstoneGoIn(i, aRedstoneCircuitBlock.getCoverID(i), aRedstoneCircuitBlock.getCoverVariable(i), aRedstoneCircuitBlock.getOwnTileEntity())) { + if (i != aRedstoneCircuitBlock.getOutputFacing() + && aRedstoneCircuitBlock + .getCover(i) + .letsRedstoneGoIn( + i, + aRedstoneCircuitBlock.getCoverID(i), + aRedstoneCircuitBlock.getCoverVariable(i), + aRedstoneCircuitBlock.getOwnTileEntity())) { tRedstoneAmount = (byte) Math.max(tRedstoneAmount, aRedstoneCircuitBlock.getInputRedstone(i)); } } @@ -95,7 +123,14 @@ public abstract class GT_CircuitryBehavior { if (!getAnyRedstone(aRedstoneCircuitBlock)) return 0; byte tRedstoneAmount = 15; for (byte i = 0; i < 6; i++) { - if (i != aRedstoneCircuitBlock.getOutputFacing() && aRedstoneCircuitBlock.getCover(i).letsRedstoneGoIn(i, aRedstoneCircuitBlock.getCoverID(i), aRedstoneCircuitBlock.getCoverVariable(i), aRedstoneCircuitBlock.getOwnTileEntity())) { + if (i != aRedstoneCircuitBlock.getOutputFacing() + && aRedstoneCircuitBlock + .getCover(i) + .letsRedstoneGoIn( + i, + aRedstoneCircuitBlock.getCoverID(i), + aRedstoneCircuitBlock.getCoverVariable(i), + aRedstoneCircuitBlock.getOwnTileEntity())) { if (aRedstoneCircuitBlock.getInputRedstone(i) > 0) tRedstoneAmount = (byte) Math.min(tRedstoneAmount, aRedstoneCircuitBlock.getInputRedstone(i)); } @@ -110,7 +145,14 @@ public abstract class GT_CircuitryBehavior { if (!getAnyRedstone(aRedstoneCircuitBlock)) return 0; byte tRedstoneAmount = 15; for (byte i = 0; i < 6; i++) { - if (i != aRedstoneCircuitBlock.getOutputFacing() && aRedstoneCircuitBlock.getCover(i).letsRedstoneGoIn(i, aRedstoneCircuitBlock.getCoverID(i), aRedstoneCircuitBlock.getCoverVariable(i), aRedstoneCircuitBlock.getOwnTileEntity())) { + if (i != aRedstoneCircuitBlock.getOutputFacing() + && aRedstoneCircuitBlock + .getCover(i) + .letsRedstoneGoIn( + i, + aRedstoneCircuitBlock.getCoverID(i), + aRedstoneCircuitBlock.getCoverVariable(i), + aRedstoneCircuitBlock.getOwnTileEntity())) { tRedstoneAmount = (byte) Math.min(tRedstoneAmount, aRedstoneCircuitBlock.getInputRedstone(i)); } } @@ -134,7 +176,6 @@ public abstract class GT_CircuitryBehavior { */ public abstract void validateParameters(int[] aCircuitData, IRedstoneCircuitBlock aRedstoneCircuitBlock); - /**************************** * Useful Utility Functions * ****************************/ @@ -150,7 +191,8 @@ public abstract class GT_CircuitryBehavior { /** * If the ItemStack should be displayed. Parameters are between 0 and 3. */ - public abstract boolean displayItemStack(int[] aCircuitData, IRedstoneCircuitBlock aRedstoneCircuitBlock, int aIndex); + public abstract boolean displayItemStack( + int[] aCircuitData, IRedstoneCircuitBlock aRedstoneCircuitBlock, int aIndex); /** * The Name of the Gate for the GUI diff --git a/src/main/java/gregtech/api/util/GT_ClientPreference.java b/src/main/java/gregtech/api/util/GT_ClientPreference.java index 26c7fa3da5..de3051fd37 100644 --- a/src/main/java/gregtech/api/util/GT_ClientPreference.java +++ b/src/main/java/gregtech/api/util/GT_ClientPreference.java @@ -5,7 +5,8 @@ public class GT_ClientPreference { private final boolean mSingleBlockInitialMultiStack; private final boolean mInputBusInitialFilter; - public GT_ClientPreference(boolean mSingleBlockInitialFilter, boolean mSingleBlockInitialMultiStack, boolean mInputBusInitialFilter) { + public GT_ClientPreference( + boolean mSingleBlockInitialFilter, boolean mSingleBlockInitialMultiStack, boolean mInputBusInitialFilter) { this.mSingleBlockInitialFilter = mSingleBlockInitialFilter; this.mSingleBlockInitialMultiStack = mSingleBlockInitialMultiStack; this.mInputBusInitialFilter = mInputBusInitialFilter; @@ -13,7 +14,8 @@ public class GT_ClientPreference { public GT_ClientPreference(GT_Config aClientDataFile) { this.mSingleBlockInitialFilter = aClientDataFile.get("preference", "mSingleBlockInitialFilter", false); - this.mSingleBlockInitialMultiStack = aClientDataFile.get("preference", "mSingleBlockInitialAllowMultiStack", false); + this.mSingleBlockInitialMultiStack = + aClientDataFile.get("preference", "mSingleBlockInitialAllowMultiStack", false); this.mInputBusInitialFilter = aClientDataFile.get("preference", "mInputBusInitialFilter", true); } diff --git a/src/main/java/gregtech/api/util/GT_Config.java b/src/main/java/gregtech/api/util/GT_Config.java index 4a0b15408f..362be0fe01 100644 --- a/src/main/java/gregtech/api/util/GT_Config.java +++ b/src/main/java/gregtech/api/util/GT_Config.java @@ -1,13 +1,13 @@ package gregtech.api.util; +import static gregtech.api.enums.GT_Values.E; + import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import net.minecraft.item.ItemStack; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; -import static gregtech.api.enums.GT_Values.E; - public class GT_Config implements Runnable { public static boolean troll = false; @@ -21,8 +21,7 @@ public class GT_Config implements Runnable { GregTech_API.sAfterGTPreload.add(this); // in case of crash on startup GregTech_API.sAfterGTLoad.add(this); // in case of crash on startup GregTech_API.sAfterGTPostload.add(this); - if (GT_Values.lateConfigSave) - GregTech_API.sFirstWorldTick.add(this); + if (GT_Values.lateConfigSave) GregTech_API.sFirstWorldTick.add(this); } private static boolean shouldSave() { @@ -31,7 +30,8 @@ public class GT_Config implements Runnable { public static int addIDConfig(Object aCategory, String aName, int aDefault) { if (GT_Utility.isStringInvalid(aName)) return aDefault; - Property tProperty = sConfigFileIDs.get(aCategory.toString().replaceAll("\\|", "."), aName.replaceAll("\\|", "."), aDefault); + Property tProperty = + sConfigFileIDs.get(aCategory.toString().replaceAll("\\|", "."), aName.replaceAll("\\|", "."), aDefault); int rResult = tProperty.getInt(aDefault); if (!tProperty.wasRead() && shouldSave()) sConfigFileIDs.save(); return rResult; @@ -43,7 +43,9 @@ public class GT_Config implements Runnable { if (rName != null) return rName.toString(); try { if (GT_Utility.isStringValid(rName = aStack.getUnlocalizedName())) return rName.toString(); - } catch (Throwable e) {/*Do nothing*/} + } catch (Throwable e) { + /*Do nothing*/ + } String sName = aStack.getItem().toString(); String[] tmp = sName.split("@"); if (tmp.length > 0) sName = tmp[0]; @@ -57,7 +59,8 @@ public class GT_Config implements Runnable { public boolean get(Object aCategory, String aName, boolean aDefault) { if (GT_Utility.isStringInvalid(aName)) return aDefault; - Property tProperty = mConfig.get(aCategory.toString().replaceAll("\\|", "_"), (aName + "_" + aDefault).replaceAll("\\|", "_"), aDefault); + Property tProperty = mConfig.get( + aCategory.toString().replaceAll("\\|", "_"), (aName + "_" + aDefault).replaceAll("\\|", "_"), aDefault); boolean rResult = tProperty.getBoolean(aDefault); if (!tProperty.wasRead() && shouldSave()) mConfig.save(); return rResult; @@ -69,7 +72,8 @@ public class GT_Config implements Runnable { public int get(Object aCategory, String aName, int aDefault) { if (GT_Utility.isStringInvalid(aName)) return aDefault; - Property tProperty = mConfig.get(aCategory.toString().replaceAll("\\|", "_"), (aName + "_" + aDefault).replaceAll("\\|", "_"), aDefault); + Property tProperty = mConfig.get( + aCategory.toString().replaceAll("\\|", "_"), (aName + "_" + aDefault).replaceAll("\\|", "_"), aDefault); int rResult = tProperty.getInt(aDefault); if (!tProperty.wasRead() && shouldSave()) mConfig.save(); return rResult; @@ -81,7 +85,8 @@ public class GT_Config implements Runnable { public double get(Object aCategory, String aName, double aDefault) { if (GT_Utility.isStringInvalid(aName)) return aDefault; - Property tProperty = mConfig.get(aCategory.toString().replaceAll("\\|", "_"), (aName + "_" + aDefault).replaceAll("\\|", "_"), aDefault); + Property tProperty = mConfig.get( + aCategory.toString().replaceAll("\\|", "_"), (aName + "_" + aDefault).replaceAll("\\|", "_"), aDefault); double rResult = tProperty.getDouble(aDefault); if (!tProperty.wasRead() && shouldSave()) mConfig.save(); return rResult; @@ -93,7 +98,8 @@ public class GT_Config implements Runnable { public String get(Object aCategory, String aName, String aDefault) { if (GT_Utility.isStringInvalid(aName)) return aDefault; - Property tProperty = mConfig.get(aCategory.toString().replaceAll("\\|", "_"), (aName + "_" + aDefault).replaceAll("\\|", "_"), aDefault); + Property tProperty = mConfig.get( + aCategory.toString().replaceAll("\\|", "_"), (aName + "_" + aDefault).replaceAll("\\|", "_"), aDefault); String rResult = tProperty.getString(); if (!tProperty.wasRead() && shouldSave()) mConfig.save(); return rResult; @@ -105,13 +111,13 @@ public class GT_Config implements Runnable { public String[] get(Object aCategory, String aName, String... aDefault) { if (GT_Utility.isStringInvalid(aName)) return aDefault; - Property tProperty = mConfig.get(aCategory.toString().replaceAll("\\|", "_"), aName.replaceAll("\\|", "_"), aDefault); + Property tProperty = + mConfig.get(aCategory.toString().replaceAll("\\|", "_"), aName.replaceAll("\\|", "_"), aDefault); String[] rResult = tProperty.getStringList(); if (!tProperty.wasRead() && GregTech_API.sPostloadFinished) mConfig.save(); return rResult; } - @Override public void run() { mConfig.save(); diff --git a/src/main/java/gregtech/api/util/GT_CoverBehavior.java b/src/main/java/gregtech/api/util/GT_CoverBehavior.java index 9972331eb3..de1514c956 100644 --- a/src/main/java/gregtech/api/util/GT_CoverBehavior.java +++ b/src/main/java/gregtech/api/util/GT_CoverBehavior.java @@ -1,5 +1,7 @@ package gregtech.api.util; +import static gregtech.api.enums.GT_Values.E; + import gregtech.api.enums.GT_Values; import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.net.GT_Packet_TileEntityCoverGUI; @@ -9,8 +11,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.fluids.Fluid; -import static gregtech.api.enums.GT_Values.E; - /** * For Covers with a special behavior. Has fixed storage format of 4 byte. Not very convenient... */ @@ -39,151 +39,234 @@ public abstract class GT_CoverBehavior extends GT_CoverBehaviorBase<ISerializabl } @Override - protected boolean isRedstoneSensitiveImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, long aTimer) { + protected boolean isRedstoneSensitiveImpl( + byte aSide, + int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, + ICoverable aTileEntity, + long aTimer) { return isRedstoneSensitive(aSide, aCoverID, aCoverVariable.get(), aTileEntity, aTimer); } @Override - protected ISerializableObject.LegacyCoverData doCoverThingsImpl(byte aSide, byte aInputRedstone, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, long aTimer) { - if (aCoverVariable == null) - aCoverVariable = new ISerializableObject.LegacyCoverData(); + protected ISerializableObject.LegacyCoverData doCoverThingsImpl( + byte aSide, + byte aInputRedstone, + int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, + ICoverable aTileEntity, + long aTimer) { + if (aCoverVariable == null) aCoverVariable = new ISerializableObject.LegacyCoverData(); aCoverVariable.set(doCoverThings(aSide, aInputRedstone, aCoverID, aCoverVariable.get(), aTileEntity, aTimer)); return aCoverVariable; } @Override - protected boolean onCoverRightClickImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { + protected boolean onCoverRightClickImpl( + byte aSide, + int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, + ICoverable aTileEntity, + EntityPlayer aPlayer, + float aX, + float aY, + float aZ) { return onCoverRightclick(aSide, aCoverID, convert(aCoverVariable), aTileEntity, aPlayer, aX, aY, aZ); } @Override - protected ISerializableObject.LegacyCoverData onCoverScrewdriverClickImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (aCoverVariable == null) - aCoverVariable = new ISerializableObject.LegacyCoverData(); - aCoverVariable.set(onCoverScrewdriverclick(aSide, aCoverID, convert(aCoverVariable), aTileEntity, aPlayer, aX, aY, aZ)); + protected ISerializableObject.LegacyCoverData onCoverScrewdriverClickImpl( + byte aSide, + int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, + ICoverable aTileEntity, + EntityPlayer aPlayer, + float aX, + float aY, + float aZ) { + if (aCoverVariable == null) aCoverVariable = new ISerializableObject.LegacyCoverData(); + aCoverVariable.set( + onCoverScrewdriverclick(aSide, aCoverID, convert(aCoverVariable), aTileEntity, aPlayer, aX, aY, aZ)); return aCoverVariable; } @Override - protected boolean onCoverShiftRightClickImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer) { + protected boolean onCoverShiftRightClickImpl( + byte aSide, + int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, + ICoverable aTileEntity, + EntityPlayer aPlayer) { return onCoverShiftRightclick(aSide, aCoverID, convert(aCoverVariable), aTileEntity, aPlayer); } @Override - protected Object getClientGUIImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, World aWorld) { + protected Object getClientGUIImpl( + byte aSide, + int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, + ICoverable aTileEntity, + EntityPlayer aPlayer, + World aWorld) { return getClientGUI(aSide, aCoverID, convert(aCoverVariable), aTileEntity); } @Override - protected boolean onCoverRemovalImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, boolean aForced) { + protected boolean onCoverRemovalImpl( + byte aSide, + int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, + ICoverable aTileEntity, + boolean aForced) { return onCoverRemoval(aSide, aCoverID, convert(aCoverVariable), aTileEntity, aForced); } @Override - protected String getDescriptionImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + protected String getDescriptionImpl( + byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { return getDescription(aSide, aCoverID, convert(aCoverVariable), aTileEntity); } @Override - protected float getBlastProofLevelImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + protected float getBlastProofLevelImpl( + byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { return getBlastProofLevel(aSide, aCoverID, convert(aCoverVariable), aTileEntity); } @Override - protected boolean letsRedstoneGoInImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + protected boolean letsRedstoneGoInImpl( + byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { return letsRedstoneGoIn(aSide, aCoverID, convert(aCoverVariable), aTileEntity); } @Override - protected boolean letsRedstoneGoOutImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + protected boolean letsRedstoneGoOutImpl( + byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { return letsRedstoneGoOut(aSide, aCoverID, convert(aCoverVariable), aTileEntity); } @Override - protected boolean letsFibreGoInImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + protected boolean letsFibreGoInImpl( + byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { return letsFibreGoIn(aSide, aCoverID, convert(aCoverVariable), aTileEntity); } @Override - protected boolean letsFibreGoOutImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + protected boolean letsFibreGoOutImpl( + byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { return letsFibreGoOut(aSide, aCoverID, convert(aCoverVariable), aTileEntity); } @Override - protected boolean letsEnergyInImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + protected boolean letsEnergyInImpl( + byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { return letsEnergyIn(aSide, aCoverID, convert(aCoverVariable), aTileEntity); } @Override - protected boolean letsEnergyOutImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + protected boolean letsEnergyOutImpl( + byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { return letsEnergyOut(aSide, aCoverID, convert(aCoverVariable), aTileEntity); } @Override - protected boolean letsFluidInImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + protected boolean letsFluidInImpl( + byte aSide, + int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, + Fluid aFluid, + ICoverable aTileEntity) { return letsFluidIn(aSide, aCoverID, convert(aCoverVariable), aFluid, aTileEntity); } @Override - protected boolean letsFluidOutImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + protected boolean letsFluidOutImpl( + byte aSide, + int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, + Fluid aFluid, + ICoverable aTileEntity) { return letsFluidOut(aSide, aCoverID, convert(aCoverVariable), aFluid, aTileEntity); } @Override - protected boolean letsItemsInImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, int aSlot, ICoverable aTileEntity) { + protected boolean letsItemsInImpl( + byte aSide, + int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, + int aSlot, + ICoverable aTileEntity) { return letsItemsIn(aSide, aCoverID, convert(aCoverVariable), aSlot, aTileEntity); } @Override - protected boolean letsItemsOutImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, int aSlot, ICoverable aTileEntity) { + protected boolean letsItemsOutImpl( + byte aSide, + int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, + int aSlot, + ICoverable aTileEntity) { return letsItemsOut(aSide, aCoverID, convert(aCoverVariable), aSlot, aTileEntity); } @Override - protected boolean isGUIClickableImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + protected boolean isGUIClickableImpl( + byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { return isGUIClickable(aSide, aCoverID, convert(aCoverVariable), aTileEntity); } @Override - protected boolean manipulatesSidedRedstoneOutputImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + protected boolean manipulatesSidedRedstoneOutputImpl( + byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { return manipulatesSidedRedstoneOutput(aSide, aCoverID, convert(aCoverVariable), aTileEntity); } @Override - protected boolean alwaysLookConnectedImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + protected boolean alwaysLookConnectedImpl( + byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { return alwaysLookConnected(aSide, aCoverID, convert(aCoverVariable), aTileEntity); } @Override - protected byte getRedstoneInputImpl(byte aSide, byte aInputRedstone, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + protected byte getRedstoneInputImpl( + byte aSide, + byte aInputRedstone, + int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, + ICoverable aTileEntity) { return getRedstoneInput(aSide, aInputRedstone, aCoverID, convert(aCoverVariable), aTileEntity); } @Override - protected int getTickRateImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + protected int getTickRateImpl( + byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { return getTickRate(aSide, aCoverID, convert(aCoverVariable), aTileEntity); } @Override - protected byte getLensColorImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + protected byte getLensColorImpl( + byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { return getLensColor(aSide, aCoverID, convert(aCoverVariable), aTileEntity); } @Override - protected ItemStack getDropImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + protected ItemStack getDropImpl( + byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { return getDrop(aSide, aCoverID, convert(aCoverVariable), aTileEntity); } // endregion - public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + public boolean isRedstoneSensitive( + byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { return true; } /** * Called by updateEntity inside the covered TileEntity. aCoverVariable is the Value you returned last time. */ - public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + public int doCoverThings( + byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { return aCoverVariable; } @@ -192,7 +275,15 @@ public abstract class GT_CoverBehavior extends GT_CoverBehaviorBase<ISerializabl * <p/> * return true, if something actually happens. */ - public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { + public boolean onCoverRightclick( + byte aSide, + int aCoverID, + int aCoverVariable, + ICoverable aTileEntity, + EntityPlayer aPlayer, + float aX, + float aY, + float aZ) { return false; } @@ -201,17 +292,29 @@ public abstract class GT_CoverBehavior extends GT_CoverBehaviorBase<ISerializabl * <p/> * return the new Value of the Cover Variable */ - public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { + public int onCoverScrewdriverclick( + byte aSide, + int aCoverID, + int aCoverVariable, + ICoverable aTileEntity, + EntityPlayer aPlayer, + float aX, + float aY, + float aZ) { return aCoverVariable; } /** * Called when someone shift-rightclicks this Cover with no tool. Doesn't call @onCoverRightclick in this Case. */ - public boolean onCoverShiftRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer) { - if(hasCoverGUI() && aPlayer instanceof EntityPlayerMP) { + public boolean onCoverShiftRightclick( + byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer) { + if (hasCoverGUI() && aPlayer instanceof EntityPlayerMP) { lastPlayer = aPlayer; - GT_Values.NW.sendToPlayer(new GT_Packet_TileEntityCoverGUI(aSide, aCoverID, aCoverVariable, aTileEntity, (EntityPlayerMP) aPlayer), (EntityPlayerMP) aPlayer); + GT_Values.NW.sendToPlayer( + new GT_Packet_TileEntityCoverGUI( + aSide, aCoverID, aCoverVariable, aTileEntity, (EntityPlayerMP) aPlayer), + (EntityPlayerMP) aPlayer); return true; } return false; @@ -225,7 +328,8 @@ public abstract class GT_CoverBehavior extends GT_CoverBehaviorBase<ISerializabl * Removes the Cover if this returns true, or if aForced is true. * Doesn't get called when the Machine Block is getting broken, only if you break the Cover away from the Machine. */ - public boolean onCoverRemoval(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, boolean aForced) { + public boolean onCoverRemoval( + byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, boolean aForced) { return true; } @@ -327,7 +431,8 @@ public abstract class GT_CoverBehavior extends GT_CoverBehaviorBase<ISerializabl /** * Needs to return true for Covers, which have a Redstone Output on their Facing. */ - public boolean manipulatesSidedRedstoneOutput(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean manipulatesSidedRedstoneOutput( + byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return false; } @@ -343,7 +448,8 @@ public abstract class GT_CoverBehavior extends GT_CoverBehaviorBase<ISerializabl * Returns the original Redstone per default. * The Cover should @letsRedstoneGoIn or the aInputRedstone Parameter is always 0. */ - public byte getRedstoneInput(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public byte getRedstoneInput( + byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return letsRedstoneGoIn(aSide, aCoverID, aCoverVariable, aTileEntity) ? aInputRedstone : 0; } diff --git a/src/main/java/gregtech/api/util/GT_CoverBehaviorBase.java b/src/main/java/gregtech/api/util/GT_CoverBehaviorBase.java index 1c72f9c9d9..470a250ee7 100644 --- a/src/main/java/gregtech/api/util/GT_CoverBehaviorBase.java +++ b/src/main/java/gregtech/api/util/GT_CoverBehaviorBase.java @@ -1,5 +1,7 @@ package gregtech.api.util; +import static gregtech.api.enums.GT_Values.E; + import gregtech.api.enums.GT_Values; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.ICoverable; @@ -14,8 +16,6 @@ import net.minecraft.nbt.NBTTagInt; import net.minecraft.world.World; import net.minecraftforge.fluids.Fluid; -import static gregtech.api.enums.GT_Values.E; - /** * For Covers with a special behavior. * @@ -46,8 +46,7 @@ public abstract class GT_CoverBehaviorBase<T extends ISerializableObject> { } public final T cast(ISerializableObject aData) { - if (typeToken.isInstance(aData)) - return forceCast(aData); + if (typeToken.isInstance(aData)) return forceCast(aData); return null; } @@ -66,7 +65,8 @@ public abstract class GT_CoverBehaviorBase<T extends ISerializableObject> { * in case of CTM * @return null if none, otherwise return facade target block */ - public final Block getFacadeBlock(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { + public final Block getFacadeBlock( + byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { return getFacadeBlockImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); } @@ -75,7 +75,8 @@ public abstract class GT_CoverBehaviorBase<T extends ISerializableObject> { * in case of CTM * @return 0 if none, otherwise return facade target meta */ - public final int getFacadeMeta(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { + public final int getFacadeMeta( + byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { return getFacadeMetaImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); } @@ -83,14 +84,15 @@ public abstract class GT_CoverBehaviorBase<T extends ISerializableObject> { * Get the display stack. Default to {@code int2Stack(aCoverID)} */ public final ItemStack getDisplayStack(int aCoverID, ISerializableObject aCoverVariable) { - return getDisplayStackImpl(aCoverID,forceCast(aCoverVariable)); + return getDisplayStackImpl(aCoverID, forceCast(aCoverVariable)); } /** * Get the special cover texture associated with this cover. Return null if one should use the texture passed to * {@link gregtech.api.GregTech_API#registerCover(ItemStack, ITexture, GT_CoverBehaviorBase)} or its overloads. */ - public final ITexture getSpecialCoverTexture(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { + public final ITexture getSpecialCoverTexture( + byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { return getSpecialCoverTextureImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); } @@ -100,14 +102,16 @@ public abstract class GT_CoverBehaviorBase<T extends ISerializableObject> { * Note if you want to sync the data afterwards you will have to manually do it by calling {@link ICoverable#issueCoverUpdate(byte)} * This option only affects the initial sync. */ - public final boolean isDataNeededOnClient(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { + public final boolean isDataNeededOnClient( + byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { return isDataNeededOnClientImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); } /** * Called upon receiving data from network. Use {@link ICoverable#isClientSide()} to determine the side. */ - public final void onDataChanged(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { + public final void onDataChanged( + byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { onDataChangedImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); } @@ -118,14 +122,21 @@ public abstract class GT_CoverBehaviorBase<T extends ISerializableObject> { onDroppedImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); } - public final boolean isRedstoneSensitive(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity, long aTimer) { + public final boolean isRedstoneSensitive( + byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity, long aTimer) { return isRedstoneSensitiveImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity, aTimer); } /** * Called by updateEntity inside the covered TileEntity. aCoverVariable is the Value you returned last time. */ - public final T doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity, long aTimer) { + public final T doCoverThings( + byte aSide, + byte aInputRedstone, + int aCoverID, + ISerializableObject aCoverVariable, + ICoverable aTileEntity, + long aTimer) { return doCoverThingsImpl(aSide, aInputRedstone, aCoverID, forceCast(aCoverVariable), aTileEntity, aTimer); } @@ -134,7 +145,15 @@ public abstract class GT_CoverBehaviorBase<T extends ISerializableObject> { * <p/> * return true, if something actually happens. */ - public final boolean onCoverRightClick(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { + public final boolean onCoverRightClick( + byte aSide, + int aCoverID, + ISerializableObject aCoverVariable, + ICoverable aTileEntity, + EntityPlayer aPlayer, + float aX, + float aY, + float aZ) { return onCoverRightClickImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity, aPlayer, aX, aY, aZ); } @@ -143,18 +162,38 @@ public abstract class GT_CoverBehaviorBase<T extends ISerializableObject> { * <p/> * return the new Value of the Cover Variable */ - public final T onCoverScrewdriverClick(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { - return onCoverScrewdriverClickImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity, aPlayer, aX, aY, aZ); + public final T onCoverScrewdriverClick( + byte aSide, + int aCoverID, + ISerializableObject aCoverVariable, + ICoverable aTileEntity, + EntityPlayer aPlayer, + float aX, + float aY, + float aZ) { + return onCoverScrewdriverClickImpl( + aSide, aCoverID, forceCast(aCoverVariable), aTileEntity, aPlayer, aX, aY, aZ); } /** * Called when someone shift-rightclicks this Cover with no tool. Doesn't call @onCoverRightclick in this Case. */ - public final boolean onCoverShiftRightClick(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer) { + public final boolean onCoverShiftRightClick( + byte aSide, + int aCoverID, + ISerializableObject aCoverVariable, + ICoverable aTileEntity, + EntityPlayer aPlayer) { return onCoverShiftRightClickImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity, aPlayer); } - public final Object getClientGUI(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, World aWorld) { + public final Object getClientGUI( + byte aSide, + int aCoverID, + ISerializableObject aCoverVariable, + ICoverable aTileEntity, + EntityPlayer aPlayer, + World aWorld) { return getClientGUIImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity, aPlayer, aWorld); } @@ -162,21 +201,24 @@ public abstract class GT_CoverBehaviorBase<T extends ISerializableObject> { * Removes the Cover if this returns true, or if aForced is true. * Doesn't get called when the Machine Block is getting broken, only if you break the Cover away from the Machine. */ - public final boolean onCoverRemoval(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity, boolean aForced) { + public final boolean onCoverRemoval( + byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity, boolean aForced) { return onCoverRemovalImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity, aForced); } /** * Gives a small Text for the status of the Cover. */ - public final String getDescription(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { + public final String getDescription( + byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { return getDescriptionImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); } /** * How Blast Proof the Cover is. 30 is normal. */ - public final float getBlastProofLevel(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { + public final float getBlastProofLevel( + byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { return getBlastProofLevelImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); } @@ -185,14 +227,16 @@ public abstract class GT_CoverBehaviorBase<T extends ISerializableObject> { * <p/> * This is just Informative so that Machines know if their Redstone Input is blocked or not */ - public final boolean letsRedstoneGoIn(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { + public final boolean letsRedstoneGoIn( + byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { return letsRedstoneGoInImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); } /** * If it lets RS-Signals out of the Block */ - public final boolean letsRedstoneGoOut(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { + public final boolean letsRedstoneGoOut( + byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { return letsRedstoneGoOutImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); } @@ -201,77 +245,88 @@ public abstract class GT_CoverBehaviorBase<T extends ISerializableObject> { * <p/> * This is just Informative so that Machines know if their Redstone Input is blocked or not */ - public final boolean letsFibreGoIn(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { + public final boolean letsFibreGoIn( + byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { return letsFibreGoInImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); } /** * If it lets Fibre-Signals out of the Block */ - public final boolean letsFibreGoOut(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { + public final boolean letsFibreGoOut( + byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { return letsFibreGoOutImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); } /** * If it lets Energy into the Block */ - public final boolean letsEnergyIn(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { + public final boolean letsEnergyIn( + byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { return letsEnergyInImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); } /** * If it lets Energy out of the Block */ - public final boolean letsEnergyOut(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { + public final boolean letsEnergyOut( + byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { return letsEnergyOutImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); } /** * If it lets Liquids into the Block, aFluid can be null meaning if this is generally allowing Fluids or not. */ - public final boolean letsFluidIn(byte aSide, int aCoverID, ISerializableObject aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public final boolean letsFluidIn( + byte aSide, int aCoverID, ISerializableObject aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { return letsFluidInImpl(aSide, aCoverID, forceCast(aCoverVariable), aFluid, aTileEntity); } /** * If it lets Liquids out of the Block, aFluid can be null meaning if this is generally allowing Fluids or not. */ - public final boolean letsFluidOut(byte aSide, int aCoverID, ISerializableObject aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + public final boolean letsFluidOut( + byte aSide, int aCoverID, ISerializableObject aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { return letsFluidOutImpl(aSide, aCoverID, forceCast(aCoverVariable), aFluid, aTileEntity); } /** * If it lets Items into the Block, aSlot = -1 means if it is generally accepting Items (return false for no reaction at all), aSlot = -2 means if it would accept for all Slots Impl(return true to skip the Checks for each Slot). */ - public final boolean letsItemsIn(byte aSide, int aCoverID, ISerializableObject aCoverVariable, int aSlot, ICoverable aTileEntity) { + public final boolean letsItemsIn( + byte aSide, int aCoverID, ISerializableObject aCoverVariable, int aSlot, ICoverable aTileEntity) { return letsItemsInImpl(aSide, aCoverID, forceCast(aCoverVariable), aSlot, aTileEntity); } /** * If it lets Items out of the Block, aSlot = -1 means if it is generally accepting Items (return false for no reaction at all), aSlot = -2 means if it would accept for all Slots Impl(return true to skip the Checks for each Slot). */ - public final boolean letsItemsOut(byte aSide, int aCoverID, ISerializableObject aCoverVariable, int aSlot, ICoverable aTileEntity) { + public final boolean letsItemsOut( + byte aSide, int aCoverID, ISerializableObject aCoverVariable, int aSlot, ICoverable aTileEntity) { return letsItemsOutImpl(aSide, aCoverID, forceCast(aCoverVariable), aSlot, aTileEntity); } /** * If it lets you rightclick the Machine normally */ - public final boolean isGUIClickable(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { + public final boolean isGUIClickable( + byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { return isGUIClickableImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); } /** * Needs to return true for Covers, which have a Redstone Output on their Facing. */ - public final boolean manipulatesSidedRedstoneOutput(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { + public final boolean manipulatesSidedRedstoneOutput( + byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { return manipulatesSidedRedstoneOutputImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); } /** * if this Cover should let Pipe Connections look connected even if it is not the case. */ - public final boolean alwaysLookConnected(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { + public final boolean alwaysLookConnected( + byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { return alwaysLookConnectedImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); } @@ -280,7 +335,8 @@ public abstract class GT_CoverBehaviorBase<T extends ISerializableObject> { * Returns the original Redstone per default. * The Cover should @letsRedstoneGoIn or the aInputRedstone Parameter is always 0. */ - public final byte getRedstoneInput(byte aSide, byte aInputRedstone, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { + public final byte getRedstoneInput( + byte aSide, byte aInputRedstone, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { return getRedstoneInputImpl(aSide, aInputRedstone, aCoverID, forceCast(aCoverVariable), aTileEntity); } @@ -293,18 +349,19 @@ public abstract class GT_CoverBehaviorBase<T extends ISerializableObject> { return getTickRateImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); } - /** * The MC Color of this Lens. -1 for no Color (meaning this isn't a Lens then). */ - public final byte getLensColor(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { + public final byte getLensColor( + byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { return getLensColorImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); } /** * @return the ItemStack dropped by this Cover */ - public final ItemStack getDrop(byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { + public final ItemStack getDrop( + byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { return getDropImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity); } // endregion @@ -331,21 +388,20 @@ public abstract class GT_CoverBehaviorBase<T extends ISerializableObject> { return false; } - protected void onDataChangedImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { - } - + protected void onDataChangedImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) {} - protected void onDroppedImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { - } + protected void onDroppedImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) {} - protected boolean isRedstoneSensitiveImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity, long aTimer) { + protected boolean isRedstoneSensitiveImpl( + byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity, long aTimer) { return true; } /** * Called by updateEntity inside the covered TileEntity. aCoverVariable is the Value you returned last time. */ - protected T doCoverThingsImpl(byte aSide, byte aInputRedstone, int aCoverID, T aCoverVariable, ICoverable aTileEntity, long aTimer) { + protected T doCoverThingsImpl( + byte aSide, byte aInputRedstone, int aCoverID, T aCoverVariable, ICoverable aTileEntity, long aTimer) { return aCoverVariable; } @@ -354,7 +410,15 @@ public abstract class GT_CoverBehaviorBase<T extends ISerializableObject> { * <p/> * return true, if something actually happens. */ - protected boolean onCoverRightClickImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { + protected boolean onCoverRightClickImpl( + byte aSide, + int aCoverID, + T aCoverVariable, + ICoverable aTileEntity, + EntityPlayer aPlayer, + float aX, + float aY, + float aZ) { return false; } @@ -363,23 +427,36 @@ public abstract class GT_CoverBehaviorBase<T extends ISerializableObject> { * <p/> * return the new Value of the Cover Variable */ - protected T onCoverScrewdriverClickImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { + protected T onCoverScrewdriverClickImpl( + byte aSide, + int aCoverID, + T aCoverVariable, + ICoverable aTileEntity, + EntityPlayer aPlayer, + float aX, + float aY, + float aZ) { return aCoverVariable; } /** * Called when someone shift-rightclicks this Cover with no tool. Doesn't call @onCoverRightclick in this Case. */ - protected boolean onCoverShiftRightClickImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer) { + protected boolean onCoverShiftRightClickImpl( + byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer) { if (hasCoverGUI() && aPlayer instanceof EntityPlayerMP) { lastPlayer = aPlayer; - GT_Values.NW.sendToPlayer(new GT_Packet_TileEntityCoverGUI(aSide, aCoverID, aCoverVariable, aTileEntity, (EntityPlayerMP) aPlayer), (EntityPlayerMP) aPlayer); + GT_Values.NW.sendToPlayer( + new GT_Packet_TileEntityCoverGUI( + aSide, aCoverID, aCoverVariable, aTileEntity, (EntityPlayerMP) aPlayer), + (EntityPlayerMP) aPlayer); return true; } return false; } - protected Object getClientGUIImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, World aWorld) { + protected Object getClientGUIImpl( + byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, World aWorld) { return null; } @@ -387,7 +464,8 @@ public abstract class GT_CoverBehaviorBase<T extends ISerializableObject> { * Removes the Cover if this returns true, or if aForced is true. * Doesn't get called when the Machine Block is getting broken, only if you break the Cover away from the Machine. */ - protected boolean onCoverRemovalImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity, boolean aForced) { + protected boolean onCoverRemovalImpl( + byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity, boolean aForced) { return true; } @@ -454,14 +532,16 @@ public abstract class GT_CoverBehaviorBase<T extends ISerializableObject> { /** * If it lets Liquids into the Block, aFluid can be null meaning if this is generally allowing Fluids or not. */ - protected boolean letsFluidInImpl(byte aSide, int aCoverID, T aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + protected boolean letsFluidInImpl( + byte aSide, int aCoverID, T aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { return false; } /** * If it lets Liquids out of the Block, aFluid can be null meaning if this is generally allowing Fluids or not. */ - protected boolean letsFluidOutImpl(byte aSide, int aCoverID, T aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + protected boolean letsFluidOutImpl( + byte aSide, int aCoverID, T aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { return false; } @@ -489,7 +569,8 @@ public abstract class GT_CoverBehaviorBase<T extends ISerializableObject> { /** * Needs to return true for Covers, which have a Redstone Output on their Facing. */ - protected boolean manipulatesSidedRedstoneOutputImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { + protected boolean manipulatesSidedRedstoneOutputImpl( + byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { return false; } @@ -505,7 +586,8 @@ public abstract class GT_CoverBehaviorBase<T extends ISerializableObject> { * Returns the original Redstone per default. * The Cover should @letsRedstoneGoIn or the aInputRedstone Parameter is always 0. */ - protected byte getRedstoneInputImpl(byte aSide, byte aInputRedstone, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { + protected byte getRedstoneInputImpl( + byte aSide, byte aInputRedstone, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { return letsRedstoneGoIn(aSide, aCoverID, aCoverVariable, aTileEntity) ? aInputRedstone : 0; } @@ -518,7 +600,6 @@ public abstract class GT_CoverBehaviorBase<T extends ISerializableObject> { return 0; } - /** * The MC Color of this Lens. -1 for no Color (meaning this isn't a Lens then). */ @@ -533,7 +614,7 @@ public abstract class GT_CoverBehaviorBase<T extends ISerializableObject> { return GT_OreDictUnificator.get(true, aTileEntity.getCoverItemAtSide(aSide)); } - //endregion + // endregion // region no data @@ -561,7 +642,8 @@ public abstract class GT_CoverBehaviorBase<T extends ISerializableObject> { * <p/> * return true, if something actually happens. */ - public boolean onCoverRightclickClient(byte aSide, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { + public boolean onCoverRightclickClient( + byte aSide, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { return false; } diff --git a/src/main/java/gregtech/api/util/GT_ExoticEnergyInputHelper.java b/src/main/java/gregtech/api/util/GT_ExoticEnergyInputHelper.java index 01614a0704..76cdb13f78 100644 --- a/src/main/java/gregtech/api/util/GT_ExoticEnergyInputHelper.java +++ b/src/main/java/gregtech/api/util/GT_ExoticEnergyInputHelper.java @@ -1,75 +1,77 @@ package gregtech.api.util; +import static gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity; + import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; - import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; -import static gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity; - public class GT_ExoticEnergyInputHelper { - /** - * The Valid Types of TecTech Hatch List. - */ - private static final List<Class<? extends GT_MetaTileEntity_Hatch>> sExoticEnergyHatchType = new ArrayList<>(); + /** + * The Valid Types of TecTech Hatch List. + */ + private static final List<Class<? extends GT_MetaTileEntity_Hatch>> sExoticEnergyHatchType = new ArrayList<>(); - static { - tryRegister("com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti"); - tryRegister("com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyTunnel"); - } + static { + tryRegister("com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti"); + tryRegister("com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyTunnel"); + } - public static void register(Class<? extends GT_MetaTileEntity_Hatch> clazz) { - if (!GT_MetaTileEntity_Hatch.class.isAssignableFrom(clazz)) - throw new IllegalArgumentException(clazz.getName() + " is not a subclass of " + GT_MetaTileEntity_Hatch.class.getName()); - sExoticEnergyHatchType.add(clazz); - } + public static void register(Class<? extends GT_MetaTileEntity_Hatch> clazz) { + if (!GT_MetaTileEntity_Hatch.class.isAssignableFrom(clazz)) + throw new IllegalArgumentException( + clazz.getName() + " is not a subclass of " + GT_MetaTileEntity_Hatch.class.getName()); + sExoticEnergyHatchType.add(clazz); + } - @SuppressWarnings("unchecked") + @SuppressWarnings("unchecked") public static void tryRegister(String className) { - Class<?> clazz; - try { - clazz = Class.forName(className); - } catch (ClassNotFoundException e) { - return; - } - if (!GT_MetaTileEntity_Hatch.class.isAssignableFrom(clazz)) - throw new IllegalArgumentException(clazz.getName() + " is not a subclass of " + GT_MetaTileEntity_Hatch.class.getName()); - sExoticEnergyHatchType.add((Class<? extends GT_MetaTileEntity_Hatch>) clazz); - } + Class<?> clazz; + try { + clazz = Class.forName(className); + } catch (ClassNotFoundException e) { + return; + } + if (!GT_MetaTileEntity_Hatch.class.isAssignableFrom(clazz)) + throw new IllegalArgumentException( + clazz.getName() + " is not a subclass of " + GT_MetaTileEntity_Hatch.class.getName()); + sExoticEnergyHatchType.add((Class<? extends GT_MetaTileEntity_Hatch>) clazz); + } - public static boolean drainEnergy(long aEU, Collection<? extends GT_MetaTileEntity_Hatch> hatches) { - for (GT_MetaTileEntity_Hatch tHatch : hatches) { - long tDrain = Math.min(tHatch.getBaseMetaTileEntity().getStoredEU(), aEU); - tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(tDrain, false); - aEU -= tDrain; - } - return aEU <= 0; - } + public static boolean drainEnergy(long aEU, Collection<? extends GT_MetaTileEntity_Hatch> hatches) { + for (GT_MetaTileEntity_Hatch tHatch : hatches) { + long tDrain = Math.min(tHatch.getBaseMetaTileEntity().getStoredEU(), aEU); + tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(tDrain, false); + aEU -= tDrain; + } + return aEU <= 0; + } - public static boolean isExoticEnergyInput(IMetaTileEntity aHatch) { - for (Class<?> clazz : sExoticEnergyHatchType) { - if (clazz.isInstance(aHatch)) - return true; - } - return false; - } + public static boolean isExoticEnergyInput(IMetaTileEntity aHatch) { + for (Class<?> clazz : sExoticEnergyHatchType) { + if (clazz.isInstance(aHatch)) return true; + } + return false; + } - public static long getMaxInputVoltageMulti(Collection<? extends GT_MetaTileEntity_Hatch> hatches) { - long rVoltage = 0; - for (GT_MetaTileEntity_Hatch tHatch : hatches) - if (isValidMetaTileEntity(tHatch)) rVoltage += tHatch.getBaseMetaTileEntity().getInputVoltage(); - return rVoltage; - } + public static long getMaxInputVoltageMulti(Collection<? extends GT_MetaTileEntity_Hatch> hatches) { + long rVoltage = 0; + for (GT_MetaTileEntity_Hatch tHatch : hatches) + if (isValidMetaTileEntity(tHatch)) + rVoltage += tHatch.getBaseMetaTileEntity().getInputVoltage(); + return rVoltage; + } - public static long getMaxInputAmpsMulti(Collection<? extends GT_MetaTileEntity_Hatch> hatches) { - long rAmp = 0; - for (GT_MetaTileEntity_Hatch tHatch : hatches) - if (isValidMetaTileEntity(tHatch)) rAmp += tHatch.getBaseMetaTileEntity().getInputAmperage(); - return rAmp; - } + public static long getMaxInputAmpsMulti(Collection<? extends GT_MetaTileEntity_Hatch> hatches) { + long rAmp = 0; + for (GT_MetaTileEntity_Hatch tHatch : hatches) + if (isValidMetaTileEntity(tHatch)) + rAmp += tHatch.getBaseMetaTileEntity().getInputAmperage(); + return rAmp; + } public static List<Class<? extends GT_MetaTileEntity_Hatch>> getAllClasses() { return Collections.unmodifiableList(sExoticEnergyHatchType); diff --git a/src/main/java/gregtech/api/util/GT_FoodStat.java b/src/main/java/gregtech/api/util/GT_FoodStat.java index 87c38a8073..f9a0f50c5f 100644 --- a/src/main/java/gregtech/api/util/GT_FoodStat.java +++ b/src/main/java/gregtech/api/util/GT_FoodStat.java @@ -32,7 +32,15 @@ public class GT_FoodStat implements IFoodStat { * Level of the Effect. [0, 1, 2] are for [I, II, III] * The likelihood that this Potion Effect takes place upon being eaten [1 - 100] */ - public GT_FoodStat(int aFoodLevel, float aSaturation, EnumAction aAction, ItemStack aEmptyContainer, boolean aAlwaysEdible, boolean aInvisibleParticles, boolean aIsRotten, int... aPotionEffects) { + public GT_FoodStat( + int aFoodLevel, + float aSaturation, + EnumAction aAction, + ItemStack aEmptyContainer, + boolean aAlwaysEdible, + boolean aInvisibleParticles, + boolean aIsRotten, + int... aPotionEffects) { mFoodLevel = aFoodLevel; mSaturation = aSaturation; mAction = aAction == null ? EnumAction.eat : aAction; @@ -84,7 +92,8 @@ public class GT_FoodStat implements IFoodStat { } for (int i = 3; i < mPotionEffects.length; i += 4) { if (aPlayer.worldObj.rand.nextInt(100) < mPotionEffects[i]) { - aPlayer.addPotionEffect(new PotionEffect(mPotionEffects[i - 3], mPotionEffects[i - 2], mPotionEffects[i - 1], mInvisibleParticles)); + aPlayer.addPotionEffect(new PotionEffect( + mPotionEffects[i - 3], mPotionEffects[i - 2], mPotionEffects[i - 1], mInvisibleParticles)); } } if (mExplosive) { diff --git a/src/main/java/gregtech/api/util/GT_Forestry_Compat.java b/src/main/java/gregtech/api/util/GT_Forestry_Compat.java index c59e551373..6e73c099cb 100644 --- a/src/main/java/gregtech/api/util/GT_Forestry_Compat.java +++ b/src/main/java/gregtech/api/util/GT_Forestry_Compat.java @@ -6,44 +6,124 @@ import forestry.api.recipes.RecipeManagers; import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; +import java.util.Map; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; -import java.util.Map; - public class GT_Forestry_Compat { - - public static void populateFakeNeiRecipes(){ + + public static void populateFakeNeiRecipes() { if (ItemList.FR_Bee_Drone.get(1L) != null) { - GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe(false, new ItemStack[]{ItemList.FR_Bee_Drone.getWildcard(1L)}, new ItemStack[]{ItemList.FR_Bee_Drone.getWithName(1L, "Scanned Drone")}, null, new FluidStack[]{Materials.Honey.getFluid(100L)}, null, 500, 2, 0); + GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe( + false, + new ItemStack[] {ItemList.FR_Bee_Drone.getWildcard(1L)}, + new ItemStack[] {ItemList.FR_Bee_Drone.getWithName(1L, "Scanned Drone")}, + null, + new FluidStack[] {Materials.Honey.getFluid(100L)}, + null, + 500, + 2, + 0); } if (ItemList.FR_Bee_Princess.get(1L) != null) { - GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe(false, new ItemStack[]{ItemList.FR_Bee_Princess.getWildcard(1L)}, new ItemStack[]{ItemList.FR_Bee_Princess.getWithName(1L, "Scanned Princess")}, null, new FluidStack[]{Materials.Honey.getFluid(100L)}, null, 500, 2, 0); + GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe( + false, + new ItemStack[] {ItemList.FR_Bee_Princess.getWildcard(1L)}, + new ItemStack[] {ItemList.FR_Bee_Princess.getWithName(1L, "Scanned Princess")}, + null, + new FluidStack[] {Materials.Honey.getFluid(100L)}, + null, + 500, + 2, + 0); } if (ItemList.FR_Bee_Queen.get(1L) != null) { - GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe(false, new ItemStack[]{ItemList.FR_Bee_Queen.getWildcard(1L)}, new ItemStack[]{ItemList.FR_Bee_Queen.getWithName(1L, "Scanned Queen")}, null, new FluidStack[]{Materials.Honey.getFluid(100L)}, null, 500, 2, 0); + GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe( + false, + new ItemStack[] {ItemList.FR_Bee_Queen.getWildcard(1L)}, + new ItemStack[] {ItemList.FR_Bee_Queen.getWithName(1L, "Scanned Queen")}, + null, + new FluidStack[] {Materials.Honey.getFluid(100L)}, + null, + 500, + 2, + 0); } if (ItemList.FR_Tree_Sapling.get(1L) != null) { - GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe(false, new ItemStack[]{ItemList.FR_Tree_Sapling.getWildcard(1L)}, new ItemStack[]{ItemList.FR_Tree_Sapling.getWithName(1L, "Scanned Sapling")}, null, new FluidStack[]{Materials.Honey.getFluid(100L)}, null, 500, 2, 0); + GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe( + false, + new ItemStack[] {ItemList.FR_Tree_Sapling.getWildcard(1L)}, + new ItemStack[] {ItemList.FR_Tree_Sapling.getWithName(1L, "Scanned Sapling")}, + null, + new FluidStack[] {Materials.Honey.getFluid(100L)}, + null, + 500, + 2, + 0); } if (ItemList.FR_Butterfly.get(1L) != null) { - GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe(false, new ItemStack[]{ItemList.FR_Butterfly.getWildcard(1L)}, new ItemStack[]{ItemList.FR_Butterfly.getWithName(1L, "Scanned Butterfly")}, null, new FluidStack[]{Materials.Honey.getFluid(100L)}, null, 500, 2, 0); + GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe( + false, + new ItemStack[] {ItemList.FR_Butterfly.getWildcard(1L)}, + new ItemStack[] {ItemList.FR_Butterfly.getWithName(1L, "Scanned Butterfly")}, + null, + new FluidStack[] {Materials.Honey.getFluid(100L)}, + null, + 500, + 2, + 0); } if (ItemList.FR_Larvae.get(1L) != null) { - GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe(false, new ItemStack[]{ItemList.FR_Larvae.getWildcard(1L)}, new ItemStack[]{ItemList.FR_Larvae.getWithName(1L, "Scanned Larvae")}, null, new FluidStack[]{Materials.Honey.getFluid(100L)}, null, 500, 2, 0); + GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe( + false, + new ItemStack[] {ItemList.FR_Larvae.getWildcard(1L)}, + new ItemStack[] {ItemList.FR_Larvae.getWithName(1L, "Scanned Larvae")}, + null, + new FluidStack[] {Materials.Honey.getFluid(100L)}, + null, + 500, + 2, + 0); } if (ItemList.FR_Serum.get(1L) != null) { - GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe(false, new ItemStack[]{ItemList.FR_Serum.getWildcard(1L)}, new ItemStack[]{ItemList.FR_Serum.getWithName(1L, "Scanned Serum")}, null, new FluidStack[]{Materials.Honey.getFluid(100L)}, null, 500, 2, 0); + GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe( + false, + new ItemStack[] {ItemList.FR_Serum.getWildcard(1L)}, + new ItemStack[] {ItemList.FR_Serum.getWithName(1L, "Scanned Serum")}, + null, + new FluidStack[] {Materials.Honey.getFluid(100L)}, + null, + 500, + 2, + 0); } if (ItemList.FR_Caterpillar.get(1L) != null) { - GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe(false, new ItemStack[]{ItemList.FR_Caterpillar.getWildcard(1L)}, new ItemStack[]{ItemList.FR_Caterpillar.getWithName(1L, "Scanned Caterpillar")}, null, new FluidStack[]{Materials.Honey.getFluid(100L)}, null, 500, 2, 0); + GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe( + false, + new ItemStack[] {ItemList.FR_Caterpillar.getWildcard(1L)}, + new ItemStack[] {ItemList.FR_Caterpillar.getWithName(1L, "Scanned Caterpillar")}, + null, + new FluidStack[] {Materials.Honey.getFluid(100L)}, + null, + 500, + 2, + 0); } if (ItemList.FR_PollenFertile.get(1L) != null) { - GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe(false, new ItemStack[]{ItemList.FR_PollenFertile.getWildcard(1L)}, new ItemStack[]{ItemList.FR_PollenFertile.getWithName(1L, "Scanned Pollen")}, null, new FluidStack[]{Materials.Honey.getFluid(100L)}, null, 500, 2, 0); + GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe( + false, + new ItemStack[] {ItemList.FR_PollenFertile.getWildcard(1L)}, + new ItemStack[] {ItemList.FR_PollenFertile.getWithName(1L, "Scanned Pollen")}, + null, + new FluidStack[] {Materials.Honey.getFluid(100L)}, + null, + 500, + 2, + 0); } } - - public static void transferCentrifugeRecipes(){ + + public static void transferCentrifugeRecipes() { try { for (ICentrifugeRecipe tRecipe : RecipeManagers.centrifugeManager.recipes()) { Map<ItemStack, Float> outputs = tRecipe.getAllProducts(); @@ -55,7 +135,8 @@ public class GT_Forestry_Compat { tOutputs[i] = entry.getKey().copy(); i++; } - GT_Recipe.GT_Recipe_Map.sCentrifugeRecipes.addRecipe(true, new ItemStack[]{tRecipe.getInput()}, tOutputs, null, tChances, null, null, 128, 5, 0); + GT_Recipe.GT_Recipe_Map.sCentrifugeRecipes.addRecipe( + true, new ItemStack[] {tRecipe.getInput()}, tOutputs, null, tChances, null, null, 128, 5, 0); } } catch (Throwable e) { if (GT_Values.D1) { @@ -63,12 +144,22 @@ public class GT_Forestry_Compat { } } } - - public static void transferSqueezerRecipes(){ + + public static void transferSqueezerRecipes() { try { for (ISqueezerRecipe tRecipe : RecipeManagers.squeezerManager.recipes()) { if ((tRecipe.getResources().length == 1) && (tRecipe.getFluidOutput() != null)) { - GT_Recipe.GT_Recipe_Map.sFluidExtractionRecipes.addRecipe(true, new ItemStack[]{tRecipe.getResources()[0]}, new ItemStack[]{tRecipe.getRemnants()}, null, new int[]{(int) (tRecipe.getRemnantsChance() * 10000)}, null, new FluidStack[]{tRecipe.getFluidOutput()}, 32, 8, 0); + GT_Recipe.GT_Recipe_Map.sFluidExtractionRecipes.addRecipe( + true, + new ItemStack[] {tRecipe.getResources()[0]}, + new ItemStack[] {tRecipe.getRemnants()}, + null, + new int[] {(int) (tRecipe.getRemnantsChance() * 10000)}, + null, + new FluidStack[] {tRecipe.getFluidOutput()}, + 32, + 8, + 0); } } } catch (Throwable e) { diff --git a/src/main/java/gregtech/api/util/GT_GC_Compat.java b/src/main/java/gregtech/api/util/GT_GC_Compat.java index 8131e3affb..60e0e2649d 100644 --- a/src/main/java/gregtech/api/util/GT_GC_Compat.java +++ b/src/main/java/gregtech/api/util/GT_GC_Compat.java @@ -15,16 +15,20 @@ public class GT_GC_Compat { public static long insertEnergyInto(TileEntity tTileEntity, long aVoltage, ForgeDirection tDirection) { // GC Compat if (GregTech_API.mGalacticraft && tTileEntity instanceof IEnergyHandlerGC) { - if (!(tTileEntity instanceof IConnector) || ((IConnector)tTileEntity).canConnect(tDirection, NetworkType.POWER)) { + if (!(tTileEntity instanceof IConnector) + || ((IConnector) tTileEntity).canConnect(tDirection, NetworkType.POWER)) { EnergySource eSource = new EnergySourceAdjacent(tDirection); - float tSizeToReceive = aVoltage * EnergyConfigHandler.IC2_RATIO, tStored = ((IEnergyHandlerGC)tTileEntity).getEnergyStoredGC(eSource); - if (tSizeToReceive >= tStored || tSizeToReceive <= ((IEnergyHandlerGC)tTileEntity).getMaxEnergyStoredGC(eSource) - tStored) { - float tReceived = ((IEnergyHandlerGC)tTileEntity).receiveEnergyGC(eSource, tSizeToReceive, false); + float tSizeToReceive = aVoltage * EnergyConfigHandler.IC2_RATIO, + tStored = ((IEnergyHandlerGC) tTileEntity).getEnergyStoredGC(eSource); + if (tSizeToReceive >= tStored + || tSizeToReceive <= ((IEnergyHandlerGC) tTileEntity).getMaxEnergyStoredGC(eSource) - tStored) { + float tReceived = ((IEnergyHandlerGC) tTileEntity).receiveEnergyGC(eSource, tSizeToReceive, false); if (tReceived > 0) { tSizeToReceive -= tReceived; while (tSizeToReceive > 0) { - tReceived = ((IEnergyHandlerGC)tTileEntity).receiveEnergyGC(eSource, tSizeToReceive, false); + tReceived = + ((IEnergyHandlerGC) tTileEntity).receiveEnergyGC(eSource, tSizeToReceive, false); if (tReceived < 1) break; tSizeToReceive -= tReceived; } @@ -37,11 +41,12 @@ public class GT_GC_Compat { return 2; } - public static boolean canConnect(TileEntity tTileEntity,ForgeDirection tDirection){ + public static boolean canConnect(TileEntity tTileEntity, ForgeDirection tDirection) { // GC Compat - if (GregTech_API.mGalacticraft && tTileEntity instanceof IEnergyHandlerGC && (!(tTileEntity instanceof IConnector) || ((IConnector)tTileEntity).canConnect(tDirection, NetworkType.POWER))) - return true; + if (GregTech_API.mGalacticraft + && tTileEntity instanceof IEnergyHandlerGC + && (!(tTileEntity instanceof IConnector) + || ((IConnector) tTileEntity).canConnect(tDirection, NetworkType.POWER))) return true; return false; } - } diff --git a/src/main/java/gregtech/api/util/GT_HatchElementBuilder.java b/src/main/java/gregtech/api/util/GT_HatchElementBuilder.java index 35a132da68..98f4f39297 100644 --- a/src/main/java/gregtech/api/util/GT_HatchElementBuilder.java +++ b/src/main/java/gregtech/api/util/GT_HatchElementBuilder.java @@ -1,5 +1,7 @@ package gregtech.api.util; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; + import com.gtnewhorizon.structurelib.StructureLibAPI; import com.gtnewhorizon.structurelib.structure.*; import com.gtnewhorizon.structurelib.util.ItemStackPredicate; @@ -10,6 +12,9 @@ import gregtech.api.interfaces.IHatchElement; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.common.blocks.GT_Item_Machines; +import java.util.*; +import java.util.function.*; +import java.util.stream.Collectors; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; @@ -18,16 +23,8 @@ import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.IChatComponent; import net.minecraft.world.World; -import java.util.*; -import java.util.function.*; -import java.util.stream.Collectors; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; - public class GT_HatchElementBuilder<T> { - private interface Builtin { - } + private interface Builtin {} private IGT_HatchAdder<? super T> mAdder; private int mCasingIndex = -1; @@ -39,8 +36,7 @@ public class GT_HatchElementBuilder<T> { private boolean mCacheHint; private boolean mNoStop; - private GT_HatchElementBuilder() { - } + private GT_HatchElementBuilder() {} public static <T> GT_HatchElementBuilder<T> builder() { return new GT_HatchElementBuilder<>(); @@ -55,9 +51,18 @@ public class GT_HatchElementBuilder<T> { @SafeVarargs public final GT_HatchElementBuilder<T> anyOf(IHatchElement<? super T>... elements) { if (elements == null || elements.length == 0) throw new IllegalArgumentException(); - return adder(Arrays.stream(elements).map(e -> e.adder().rebrand()).reduce(IGT_HatchAdder::orElse).get()) - .hatchClasses(Arrays.stream(elements).map(IHatchElement::mteClasses).flatMap(Collection::stream).collect(Collectors.toList())) - .cacheHint(() -> Arrays.stream(elements).map(IHatchElement::name).sorted().collect(Collectors.joining(" or ", "of type ", ""))); + return adder(Arrays.stream(elements) + .map(e -> e.adder().rebrand()) + .reduce(IGT_HatchAdder::orElse) + .get()) + .hatchClasses(Arrays.stream(elements) + .map(IHatchElement::mteClasses) + .flatMap(Collection::stream) + .collect(Collectors.toList())) + .cacheHint(() -> Arrays.stream(elements) + .map(IHatchElement::name) + .sorted() + .collect(Collectors.joining(" or ", "of type ", ""))); } /** @@ -69,7 +74,8 @@ public class GT_HatchElementBuilder<T> { @SafeVarargs public final GT_HatchElementBuilder<T> atLeast(IHatchElement<? super T>... elements) { if (elements == null || elements.length == 0) throw new IllegalArgumentException(); - return atLeast(Arrays.stream(elements).collect(Collectors.groupingBy(Function.identity(), LinkedHashMap::new, Collectors.counting()))); + return atLeast(Arrays.stream(elements) + .collect(Collectors.groupingBy(Function.identity(), LinkedHashMap::new, Collectors.counting()))); } /** @@ -80,7 +86,8 @@ public class GT_HatchElementBuilder<T> { */ public final GT_HatchElementBuilder<T> atLeastList(List<IHatchElement<? super T>> elements) { if (elements == null || elements.isEmpty()) throw new IllegalArgumentException(); - return atLeast(elements.stream().collect(Collectors.groupingBy(Function.identity(), LinkedHashMap::new, Collectors.counting()))); + return atLeast(elements.stream() + .collect(Collectors.groupingBy(Function.identity(), LinkedHashMap::new, Collectors.counting()))); } /** @@ -90,20 +97,32 @@ public class GT_HatchElementBuilder<T> { public final GT_HatchElementBuilder<T> atLeast(Map<IHatchElement<? super T>, ? extends Number> elements) { if (elements == null || elements.isEmpty() || elements.containsKey(null) || elements.containsValue(null)) throw new IllegalArgumentException(); - List<Class<? extends IMetaTileEntity>> list = elements.keySet().stream().map(IHatchElement::mteClasses).flatMap(Collection::stream).collect(Collectors.toList()); + List<Class<? extends IMetaTileEntity>> list = elements.keySet().stream() + .map(IHatchElement::mteClasses) + .flatMap(Collection::stream) + .collect(Collectors.toList()); // map cannot be null or empty, so assert Optional isPresent - return adder(elements.keySet().stream().map(e -> e.adder().rebrand()).reduce(IGT_HatchAdder::orElse).orElseThrow(AssertionError::new)) - .hatchItemFilter(obj -> GT_StructureUtility.filterByMTEClass(elements.entrySet().stream() - .filter(entry -> entry.getKey().count(obj) < entry.getValue().longValue()) - .flatMap(entry -> entry.getKey().mteClasses().stream()) - .collect(Collectors.toList()))) - .shouldReject(obj -> elements.entrySet().stream().allMatch(e-> e.getKey().count(obj) >= e.getValue().longValue())) - .shouldSkip((BiPredicate<? super T, ? super IGregTechTileEntity> & Builtin) (c, t) -> t != null && list.stream().anyMatch(clazz -> clazz.isInstance(t.getMetaTileEntity()))) - .cacheHint(() -> elements.keySet().stream().map(IHatchElement::name).sorted().collect(Collectors.joining(" or ", "of type ", ""))); + return adder(elements.keySet().stream() + .map(e -> e.adder().rebrand()) + .reduce(IGT_HatchAdder::orElse) + .orElseThrow(AssertionError::new)) + .hatchItemFilter(obj -> GT_StructureUtility.filterByMTEClass(elements.entrySet().stream() + .filter(entry -> + entry.getKey().count(obj) < entry.getValue().longValue()) + .flatMap(entry -> entry.getKey().mteClasses().stream()) + .collect(Collectors.toList()))) + .shouldReject(obj -> elements.entrySet().stream() + .allMatch(e -> e.getKey().count(obj) >= e.getValue().longValue())) + .shouldSkip((BiPredicate<? super T, ? super IGregTechTileEntity> & Builtin) + (c, t) -> t != null && list.stream().anyMatch(clazz -> clazz.isInstance(t.getMetaTileEntity()))) + .cacheHint(() -> elements.keySet().stream() + .map(IHatchElement::name) + .sorted() + .collect(Collectors.joining(" or ", "of type ", ""))); } - //endregion + // endregion - //region primitives + // region primitives public GT_HatchElementBuilder<T> adder(IGT_HatchAdder<? super T> aAdder) { if (aAdder == null) throw new IllegalArgumentException(); @@ -132,9 +151,10 @@ public class GT_HatchElementBuilder<T> { return this; } - // avoid loooooong lines like - // shouldSkip((BiPredicate<.....> & Builtin) (c, t) -> ....) - // private <P extends BiPredicate<? super T, ? super IGregTechTileEntity> & Builtin> GT_HatchElementBuilder<T> shouldSkipInternal(P aShouldSkip) { + // avoid loooooong lines like + // shouldSkip((BiPredicate<.....> & Builtin) (c, t) -> ....) + // private <P extends BiPredicate<? super T, ? super IGregTechTileEntity> & Builtin> GT_HatchElementBuilder<T> + // shouldSkipInternal(P aShouldSkip) { // if (mShouldSkip == null) mShouldSkip = aShouldSkip; // return this; // } @@ -146,26 +166,30 @@ public class GT_HatchElementBuilder<T> { return this; } - public GT_HatchElementBuilder<T> hatchItemFilter(Function<? super T, ? extends Predicate<ItemStack>> aHatchItemFilter) { + public GT_HatchElementBuilder<T> hatchItemFilter( + Function<? super T, ? extends Predicate<ItemStack>> aHatchItemFilter) { if (aHatchItemFilter == null) throw new IllegalArgumentException(); mHatchItemFilter = (t, s) -> aHatchItemFilter.apply(t); return this; } - public GT_HatchElementBuilder<T> hatchItemFilterAnd(Function<? super T, ? extends Predicate<ItemStack>> aHatchItemFilter) { + public GT_HatchElementBuilder<T> hatchItemFilterAnd( + Function<? super T, ? extends Predicate<ItemStack>> aHatchItemFilter) { if (aHatchItemFilter == null) throw new IllegalArgumentException(); BiFunction<? super T, ItemStack, ? extends Predicate<ItemStack>> tOldFilter = mHatchItemFilter; mHatchItemFilter = (t, s) -> tOldFilter.apply(t, s).and(aHatchItemFilter.apply(t)); return this; } - public GT_HatchElementBuilder<T> hatchItemFilter(BiFunction<? super T, ItemStack, ? extends Predicate<ItemStack>> aHatchItemFilter) { + public GT_HatchElementBuilder<T> hatchItemFilter( + BiFunction<? super T, ItemStack, ? extends Predicate<ItemStack>> aHatchItemFilter) { if (aHatchItemFilter == null) throw new IllegalArgumentException(); mHatchItemFilter = aHatchItemFilter; return this; } - public GT_HatchElementBuilder<T> hatchItemFilterAnd(BiFunction<? super T, ItemStack, ? extends Predicate<ItemStack>> aHatchItemFilter) { + public GT_HatchElementBuilder<T> hatchItemFilterAnd( + BiFunction<? super T, ItemStack, ? extends Predicate<ItemStack>> aHatchItemFilter) { if (aHatchItemFilter == null) throw new IllegalArgumentException(); BiFunction<? super T, ItemStack, ? extends Predicate<ItemStack>> tOldFilter = mHatchItemFilter; mHatchItemFilter = (t, s) -> tOldFilter.apply(t, s).and(aHatchItemFilter.apply(t, s)); @@ -208,8 +232,9 @@ public class GT_HatchElementBuilder<T> { // region intermediate public GT_HatchElementBuilder<T> hatchClass(Class<? extends IMetaTileEntity> clazz) { return hatchItemFilter(c -> is -> clazz.isInstance(GT_Item_Machines.getMetaTileEntity(is))) - .cacheHint(() -> "of class " + clazz.getSimpleName()) - .shouldSkip((BiPredicate<? super T, ? super IGregTechTileEntity> & Builtin) (c, t) -> clazz.isInstance(t.getMetaTileEntity())); + .cacheHint(() -> "of class " + clazz.getSimpleName()) + .shouldSkip((BiPredicate<? super T, ? super IGregTechTileEntity> & Builtin) + (c, t) -> clazz.isInstance(t.getMetaTileEntity())); } @SafeVarargs @@ -220,26 +245,39 @@ public class GT_HatchElementBuilder<T> { public final GT_HatchElementBuilder<T> hatchClasses(List<? extends Class<? extends IMetaTileEntity>> classes) { List<? extends Class<? extends IMetaTileEntity>> list = new ArrayList<>(classes); return hatchItemFilter(obj -> GT_StructureUtility.filterByMTEClass(list)) - .cacheHint(() -> list.stream().map(Class::getSimpleName).sorted().collect(Collectors.joining(" or ", "of class ", ""))) - .shouldSkip((BiPredicate<? super T, ? super IGregTechTileEntity> & Builtin) (c, t) -> t != null && list.stream().anyMatch(clazz -> clazz.isInstance(t.getMetaTileEntity()))); + .cacheHint(() -> list.stream() + .map(Class::getSimpleName) + .sorted() + .collect(Collectors.joining(" or ", "of class ", ""))) + .shouldSkip((BiPredicate<? super T, ? super IGregTechTileEntity> & Builtin) (c, t) -> + t != null && list.stream().anyMatch(clazz -> clazz.isInstance(t.getMetaTileEntity()))); } public GT_HatchElementBuilder<T> hatchId(int aId) { - return hatchItemFilter(c -> is -> GT_Utility.isStackValid(is) && is.getItem() instanceof GT_Item_Machines && is.getItemDamage() == aId) - .cacheHint(() -> "of id " + aId) - .shouldSkip((BiPredicate<? super T, ? super IGregTechTileEntity> & Builtin) (c, t) -> t != null && t.getMetaTileID() == aId); + return hatchItemFilter(c -> is -> GT_Utility.isStackValid(is) + && is.getItem() instanceof GT_Item_Machines + && is.getItemDamage() == aId) + .cacheHint(() -> "of id " + aId) + .shouldSkip((BiPredicate<? super T, ? super IGregTechTileEntity> & Builtin) + (c, t) -> t != null && t.getMetaTileID() == aId); } public GT_HatchElementBuilder<T> hatchIds(int... aIds) { if (aIds == null || aIds.length == 0) throw new IllegalArgumentException(); if (aIds.length == 1) return hatchId(aIds[0]); TIntCollection coll = aIds.length < 16 ? new TIntArrayList(aIds) : new TIntHashSet(aIds); - return hatchItemFilter(c -> is -> GT_Utility.isStackValid(is) && is.getItem() instanceof GT_Item_Machines && coll.contains(is.getItemDamage())) - .cacheHint(() -> Arrays.stream(coll.toArray()).sorted().mapToObj(String::valueOf).collect(Collectors.joining(" or ", "of id ", ""))) - .shouldSkip((BiPredicate<? super T, ? super IGregTechTileEntity> & Builtin) (c, t) -> t != null && coll.contains(t.getMetaTileID())); + return hatchItemFilter(c -> is -> GT_Utility.isStackValid(is) + && is.getItem() instanceof GT_Item_Machines + && coll.contains(is.getItemDamage())) + .cacheHint(() -> Arrays.stream(coll.toArray()) + .sorted() + .mapToObj(String::valueOf) + .collect(Collectors.joining(" or ", "of id ", ""))) + .shouldSkip((BiPredicate<? super T, ? super IGregTechTileEntity> & Builtin) + (c, t) -> t != null && coll.contains(t.getMetaTileID())); } - //endregion + // endregion @SuppressWarnings("unchecked") @SafeVarargs @@ -265,7 +303,8 @@ public class GT_HatchElementBuilder<T> { @Override public boolean check(T t, World world, int x, int y, int z) { TileEntity tileEntity = world.getTileEntity(x, y, z); - return tileEntity instanceof IGregTechTileEntity && mAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) mCasingIndex); + return tileEntity instanceof IGregTechTileEntity + && mAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) mCasingIndex); } @Override @@ -281,7 +320,8 @@ public class GT_HatchElementBuilder<T> { @Override public boolean check(T t, World world, int x, int y, int z) { TileEntity tileEntity = world.getTileEntity(x, y, z); - return tileEntity instanceof IGregTechTileEntity && mAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) mCasingIndex); + return tileEntity instanceof IGregTechTileEntity + && mAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) mCasingIndex); } @Override @@ -312,14 +352,22 @@ public class GT_HatchElementBuilder<T> { } @Override - public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor, Consumer<IChatComponent> chatter) { + public PlaceResult survivalPlaceBlock( + T t, + World world, + int x, + int y, + int z, + ItemStack trigger, + IItemSource s, + EntityPlayerMP actor, + Consumer<IChatComponent> chatter) { if (mShouldSkip != null) { TileEntity tileEntity = world.getTileEntity(x, y, z); - if (tileEntity instanceof IGregTechTileEntity && mShouldSkip.test(t, (IGregTechTileEntity) tileEntity)) - return PlaceResult.SKIP; + if (tileEntity instanceof IGregTechTileEntity + && mShouldSkip.test(t, (IGregTechTileEntity) tileEntity)) return PlaceResult.SKIP; } - if (!StructureLibAPI.isBlockTriviallyReplaceable(world, x, y, z, actor)) - return PlaceResult.REJECT; + if (!StructureLibAPI.isBlockTriviallyReplaceable(world, x, y, z, actor)) return PlaceResult.REJECT; if (mReject != null && mReject.test(t)) return PlaceResult.REJECT; ItemStack taken = s.takeOne(mHatchItemFilter.apply(t, trigger), true); if (GT_Utility.isStackInvalid(taken)) { @@ -327,7 +375,11 @@ public class GT_HatchElementBuilder<T> { chatter.accept(new ChatComponentTranslation("GT5U.autoplace.error.no_hatch", type)); return PlaceResult.REJECT; } - return StructureUtility.survivalPlaceBlock(taken, ItemStackPredicate.NBTMode.IGNORE, null, true, world, x, y, z, s, actor) == PlaceResult.ACCEPT ? (mNoStop ? PlaceResult.ACCEPT : PlaceResult.ACCEPT_STOP) : PlaceResult.REJECT; + return StructureUtility.survivalPlaceBlock( + taken, ItemStackPredicate.NBTMode.IGNORE, null, true, world, x, y, z, s, actor) + == PlaceResult.ACCEPT + ? (mNoStop ? PlaceResult.ACCEPT : PlaceResult.ACCEPT_STOP) + : PlaceResult.REJECT; } }; } diff --git a/src/main/java/gregtech/api/util/GT_ItsNotMyFaultException.java b/src/main/java/gregtech/api/util/GT_ItsNotMyFaultException.java index f742be20cb..174b4618e8 100644 --- a/src/main/java/gregtech/api/util/GT_ItsNotMyFaultException.java +++ b/src/main/java/gregtech/api/util/GT_ItsNotMyFaultException.java @@ -11,6 +11,7 @@ public class GT_ItsNotMyFaultException extends RuntimeException { @Override public String toString() { - return "The GregTech-Addon has a Problem.\nIT'S NOT MY FAULT!!! Below is how to fix it.\n" + mError + "\nDO NOT COME TO ME WITH THIS CRASH. YOU CAUSED IT YOURSELF, AND I TOLD YOU HOW TO FIX IT!!!"; + return "The GregTech-Addon has a Problem.\nIT'S NOT MY FAULT!!! Below is how to fix it.\n" + mError + + "\nDO NOT COME TO ME WITH THIS CRASH. YOU CAUSED IT YOURSELF, AND I TOLD YOU HOW TO FIX IT!!!"; } } diff --git a/src/main/java/gregtech/api/util/GT_LanguageManager.java b/src/main/java/gregtech/api/util/GT_LanguageManager.java index d6cd1553eb..50d0deeee7 100644 --- a/src/main/java/gregtech/api/util/GT_LanguageManager.java +++ b/src/main/java/gregtech/api/util/GT_LanguageManager.java @@ -1,57 +1,57 @@ package gregtech.api.util; +import static gregtech.api.enums.GT_Values.E; + import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.ReflectionHelper; import gregtech.api.GregTech_API; - +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.StatCollector; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; - -import static gregtech.api.enums.GT_Values.E; - public class GT_LanguageManager { - public static final HashMap<String, String> TEMPMAP = new HashMap<>(), BUFFERMAP = new HashMap<>(), LANGMAP = new HashMap<>(); + public static final HashMap<String, String> TEMPMAP = new HashMap<>(), + BUFFERMAP = new HashMap<>(), + LANGMAP = new HashMap<>(); public static Configuration sEnglishFile; - public static String sLanguage = "en_US"; + public static String sLanguage = "en_US"; public static boolean sUseEnglishFile = false; public static boolean i18nPlaceholder = true; - public static String - FACE_ANY = "gt.lang.face.any", - FACE_BOTTOM = "gt.lang.face.bottom", - FACE_TOP = "gt.lang.face.top", - FACE_LEFT = "gt.lang.face.left", - FACE_FRONT = "gt.lang.face.front", - FACE_RIGHT = "gt.lang.face.right", - FACE_BACK = "gt.lang.face.back", - FACE_NONE = "gt.lang.face.none"; + public static String FACE_ANY = "gt.lang.face.any", + FACE_BOTTOM = "gt.lang.face.bottom", + FACE_TOP = "gt.lang.face.top", + FACE_LEFT = "gt.lang.face.left", + FACE_FRONT = "gt.lang.face.front", + FACE_RIGHT = "gt.lang.face.right", + FACE_BACK = "gt.lang.face.back", + FACE_NONE = "gt.lang.face.none"; - public static String[] - FACES = {FACE_BOTTOM, FACE_TOP, FACE_LEFT, FACE_FRONT, FACE_RIGHT, FACE_BACK, FACE_NONE}; + public static String[] FACES = {FACE_BOTTOM, FACE_TOP, FACE_LEFT, FACE_FRONT, FACE_RIGHT, FACE_BACK, FACE_NONE}; private static Map<String, String> stringTranslateLanguageList = null; static { try { - Field fieldStringTranslateLanguageList = ReflectionHelper.findField(net.minecraft.util.StringTranslate.class, "languageList", "field_74816_c"); - Field fieldStringTranslateInstance = ReflectionHelper.findField(net.minecraft.util.StringTranslate.class, "instance", "field_74817_a"); + Field fieldStringTranslateLanguageList = ReflectionHelper.findField( + net.minecraft.util.StringTranslate.class, "languageList", "field_74816_c"); + Field fieldStringTranslateInstance = + ReflectionHelper.findField(net.minecraft.util.StringTranslate.class, "instance", "field_74817_a"); //noinspection unchecked - stringTranslateLanguageList = (Map<String, String>) fieldStringTranslateLanguageList.get(fieldStringTranslateInstance.get(null)); + stringTranslateLanguageList = + (Map<String, String>) fieldStringTranslateLanguageList.get(fieldStringTranslateInstance.get(null)); } catch (Exception e) { e.printStackTrace(); } } - - public static String addStringLocalization(String aKey, String aEnglish) { + public static String addStringLocalization(String aKey, String aEnglish) { return addStringLocalization(aKey, aEnglish, true); } @@ -67,7 +67,7 @@ public class GT_LanguageManager { TEMPMAP.put(aKey.trim(), aEnglish); LanguageRegistry.instance().injectLanguage(sLanguage, TEMPMAP); TEMPMAP.clear(); - if(sUseEnglishFile && !aWriteIntoLangFile){ + if (sUseEnglishFile && !aWriteIntoLangFile) { if (!LANGMAP.containsKey(aKey)) { Property tProperty = sEnglishFile.get("LanguageFile", aKey, aEnglish); aEnglish = tProperty.getString(); @@ -92,7 +92,9 @@ public class GT_LanguageManager { } Property tProperty = sEnglishFile.get("LanguageFile", aKey.trim(), aEnglish); if (!tProperty.wasRead() && GregTech_API.sPostloadFinished) sEnglishFile.save(); - if (sEnglishFile.get("EnableLangFile", "UseThisFileAsLanguageFile", false).getBoolean(false)){ + if (sEnglishFile + .get("EnableLangFile", "UseThisFileAsLanguageFile", false) + .getBoolean(false)) { aEnglish = tProperty.getString(); sUseEnglishFile = true; } @@ -104,9 +106,9 @@ public class GT_LanguageManager { if (aKey == null) return E; String tTrimmedKey = aKey.trim(), rTranslation; if (sUseEnglishFile) { - rTranslation = LanguageRegistry.instance().getStringLocalization(tTrimmedKey); + rTranslation = LanguageRegistry.instance().getStringLocalization(tTrimmedKey); } else { - rTranslation = StatCollector.translateToLocal(tTrimmedKey); + rTranslation = StatCollector.translateToLocal(tTrimmedKey); } if (GT_Utility.isStringInvalid(rTranslation)) { rTranslation = StatCollector.translateToLocal(tTrimmedKey); @@ -151,235 +153,240 @@ public class GT_LanguageManager { return aStack.getUnlocalizedName() + ".name"; } - public static void writePlaceholderStrings(){ - addStringLocalization("Interaction_DESCRIPTION_Index_001", "Puts out into adjacent Slot #"); - addStringLocalization("Interaction_DESCRIPTION_Index_002", "Grabs in for own Slot #"); - addStringLocalization("Interaction_DESCRIPTION_Index_003", "Normal"); - addStringLocalization("Interaction_DESCRIPTION_Index_004", "Inverted"); - addStringLocalization("Interaction_DESCRIPTION_Index_005", "No Work at all"); - addStringLocalization("Interaction_DESCRIPTION_Index_006", "Export"); - addStringLocalization("Interaction_DESCRIPTION_Index_007", "Import"); - addStringLocalization("Interaction_DESCRIPTION_Index_008", "Export (conditional)"); - addStringLocalization("Interaction_DESCRIPTION_Index_009", "Import (conditional)"); - addStringLocalization("Interaction_DESCRIPTION_Index_010", "Export (invert cond)"); - addStringLocalization("Interaction_DESCRIPTION_Index_011", "Import (invert cond)"); - addStringLocalization("Interaction_DESCRIPTION_Index_012", "Export allow Input"); - addStringLocalization("Interaction_DESCRIPTION_Index_013", "Import allow Output"); - addStringLocalization("Interaction_DESCRIPTION_Index_014", "Export allow Input (conditional)"); - addStringLocalization("Interaction_DESCRIPTION_Index_015", "Import allow Output (conditional)"); - addStringLocalization("Interaction_DESCRIPTION_Index_016", "Export allow Input (invert cond)"); - addStringLocalization("Interaction_DESCRIPTION_Index_017", "Import allow Output (invert cond)"); - addStringLocalization("Interaction_DESCRIPTION_Index_018", "Normal"); - addStringLocalization("Interaction_DESCRIPTION_Index_019", "Inverted"); - addStringLocalization("Interaction_DESCRIPTION_Index_020", "Ready to work"); - addStringLocalization("Interaction_DESCRIPTION_Index_021", "Not ready to work"); - addStringLocalization("Interaction_DESCRIPTION_Index_022", "Import"); - addStringLocalization("Interaction_DESCRIPTION_Index_023", "Import (conditional)"); - addStringLocalization("Interaction_DESCRIPTION_Index_024", "Import (invert cond)"); - addStringLocalization("Interaction_DESCRIPTION_Index_025", "Keep Liquids Away"); - addStringLocalization("Interaction_DESCRIPTION_Index_026", "Keep Liquids Away (conditional)"); - addStringLocalization("Interaction_DESCRIPTION_Index_027", "Keep Liquids Away (invert cond)"); - addStringLocalization("Interaction_DESCRIPTION_Index_028", "Allow"); - addStringLocalization("Interaction_DESCRIPTION_Index_029", "Allow (conditional)"); - addStringLocalization("Interaction_DESCRIPTION_Index_030", "Disallow (conditional)"); - addStringLocalization("Interaction_DESCRIPTION_Index_031", "Normal Universal Storage"); - addStringLocalization("Interaction_DESCRIPTION_Index_032", "Inverted Universal Storage"); - addStringLocalization("Interaction_DESCRIPTION_Index_033", "Normal Electricity Storage"); - addStringLocalization("Interaction_DESCRIPTION_Index_034", "Inverted Electricity Storage"); - addStringLocalization("Interaction_DESCRIPTION_Index_035", "Normal Steam Storage"); - addStringLocalization("Interaction_DESCRIPTION_Index_036", "Inverted Steam Storage"); - addStringLocalization("Interaction_DESCRIPTION_Index_037", "Normal Average Electric Input"); - addStringLocalization("Interaction_DESCRIPTION_Index_038", "Inverted Average Electric Input"); - addStringLocalization("Interaction_DESCRIPTION_Index_039", "Normal Average Electric Output"); - addStringLocalization("Interaction_DESCRIPTION_Index_040", "Inverted Average Electric Output"); - addStringLocalization("Interaction_DESCRIPTION_Index_041", "Normal Electricity Storage(Including Batteries)"); - addStringLocalization("Interaction_DESCRIPTION_Index_042", "Inverted Electricity Storage(Including Batteries)"); - addStringLocalization("Interaction_DESCRIPTION_Index_043", "Allow input, no output"); - addStringLocalization("Interaction_DESCRIPTION_Index_044", "Deny input, no output"); - addStringLocalization("Interaction_DESCRIPTION_Index_045", "Allow input, permit any output"); - addStringLocalization("Interaction_DESCRIPTION_Index_046", "Deny input, permit any output"); - addStringLocalization("Interaction_DESCRIPTION_Index_047", "Filter Fluid: "); - addStringLocalization("Interaction_DESCRIPTION_Index_048", "Pump speed: "); - addStringLocalization("Interaction_DESCRIPTION_Index_049", "L/tick "); - addStringLocalization("Interaction_DESCRIPTION_Index_050", "L/sec"); - addStringLocalization("Interaction_DESCRIPTION_Index_051", "Normal"); - addStringLocalization("Interaction_DESCRIPTION_Index_052", "Inverted"); - addStringLocalization("Interaction_DESCRIPTION_Index_053", "Slot: "); - addStringLocalization("Interaction_DESCRIPTION_Index_054", "Inverted"); - addStringLocalization("Interaction_DESCRIPTION_Index_055", "Normal"); - addStringLocalization("Interaction_DESCRIPTION_Index_056", "Emit if 1 Maintenance Needed"); - addStringLocalization("Interaction_DESCRIPTION_Index_057", "Emit if 1 Maintenance Needed(inverted)"); - addStringLocalization("Interaction_DESCRIPTION_Index_058", "Emit if 2 Maintenance Needed"); - addStringLocalization("Interaction_DESCRIPTION_Index_059", "Emit if 2 Maintenance Needed(inverted)"); - addStringLocalization("Interaction_DESCRIPTION_Index_060", "Emit if 3 Maintenance Needed"); - addStringLocalization("Interaction_DESCRIPTION_Index_061", "Emit if 3 Maintenance Needed(inverted)"); - addStringLocalization("Interaction_DESCRIPTION_Index_062", "Emit if 4 Maintenance Needed"); - addStringLocalization("Interaction_DESCRIPTION_Index_063", "Emit if 4 Maintenance Needed(inverted)"); - addStringLocalization("Interaction_DESCRIPTION_Index_064", "Emit if 5 Maintenance Needed"); - addStringLocalization("Interaction_DESCRIPTION_Index_065", "Emit if 5 Maintenance Needed(inverted)"); - addStringLocalization("Interaction_DESCRIPTION_Index_066", "Emit if rotor needs maintenance"); - addStringLocalization("Interaction_DESCRIPTION_Index_067", "Emit if rotor needs maintenance(inverted)"); - addStringLocalization("Interaction_DESCRIPTION_Index_068", "Emit if any Player is close"); - addStringLocalization("Interaction_DESCRIPTION_Index_069", "Emit if other player is close"); - addStringLocalization("Interaction_DESCRIPTION_Index_070", "Emit if you are close"); - addStringLocalization("Interaction_DESCRIPTION_Index_071", "Conducts strongest Input"); - addStringLocalization("Interaction_DESCRIPTION_Index_072", "Conducts from bottom Input"); - addStringLocalization("Interaction_DESCRIPTION_Index_073", "Conducts from top Input"); - addStringLocalization("Interaction_DESCRIPTION_Index_074", "Conducts from north Input"); - addStringLocalization("Interaction_DESCRIPTION_Index_075", "Conducts from south Input"); - addStringLocalization("Interaction_DESCRIPTION_Index_076", "Conducts from west Input"); - addStringLocalization("Interaction_DESCRIPTION_Index_077", "Conducts from east Input"); - addStringLocalization("Interaction_DESCRIPTION_Index_078", "Signal = "); - addStringLocalization("Interaction_DESCRIPTION_Index_079", "Conditional Signal = "); - addStringLocalization("Interaction_DESCRIPTION_Index_080", "Inverted Conditional Signal = "); - addStringLocalization("Interaction_DESCRIPTION_Index_081", "Frequency: "); - addStringLocalization("Interaction_DESCRIPTION_Index_082", "Open if work enabled"); - addStringLocalization("Interaction_DESCRIPTION_Index_083", "Open if work disabled"); - addStringLocalization("Interaction_DESCRIPTION_Index_084", "Only Output allowed"); - addStringLocalization("Interaction_DESCRIPTION_Index_085", "Only Input allowed"); - addStringLocalization("Interaction_DESCRIPTION_Index_086", "Auto-Input: "); - addStringLocalization("Interaction_DESCRIPTION_Index_087", "Disabled"); - addStringLocalization("Interaction_DESCRIPTION_Index_088", "Enabled"); - addStringLocalization("Interaction_DESCRIPTION_Index_089", " Auto-Output: "); - addStringLocalization("Interaction_DESCRIPTION_Index_090", "Machine Processing: "); - addStringLocalization("Interaction_DESCRIPTION_Index_091", "Redstone Output at Side "); - addStringLocalization("Interaction_DESCRIPTION_Index_092", " set to: "); - addStringLocalization("Interaction_DESCRIPTION_Index_093", "Strong"); - addStringLocalization("Interaction_DESCRIPTION_Index_094", "Weak"); - addStringLocalization("Interaction_DESCRIPTION_Index_095", "Input from Output Side allowed"); - addStringLocalization("Interaction_DESCRIPTION_Index_096", "Input from Output Side forbidden"); - addStringLocalization("Interaction_DESCRIPTION_Index_097", "It's dangerous to go alone! Take this."); - addStringLocalization("Interaction_DESCRIPTION_Index_098", "Do not regulate Item Stack Size"); - addStringLocalization("Interaction_DESCRIPTION_Index_099", "Regulate Item Stack Size to: "); - addStringLocalization("Interaction_DESCRIPTION_Index_100", "This is ");//Spartaaaaaaa!!! - addStringLocalization("Interaction_DESCRIPTION_Index_101", " Ore."); - addStringLocalization("Interaction_DESCRIPTION_Index_102", "There is Lava behind this Rock."); - addStringLocalization("Interaction_DESCRIPTION_Index_103", "There is a Liquid behind this Rock."); - addStringLocalization("Interaction_DESCRIPTION_Index_104", "There is an Air Pocket behind this Rock."); - addStringLocalization("Interaction_DESCRIPTION_Index_105", "Material is changing behind this Rock."); - addStringLocalization("Interaction_DESCRIPTION_Index_106", "Found traces of "); - addStringLocalization("Interaction_DESCRIPTION_Index_107", "No Ores found."); - addStringLocalization("Interaction_DESCRIPTION_Index_108", "Outputs Liquids, Steam and Items"); - addStringLocalization("Interaction_DESCRIPTION_Index_109", "Outputs Steam and Items"); - addStringLocalization("Interaction_DESCRIPTION_Index_110", "Outputs Steam and Liquids"); - addStringLocalization("Interaction_DESCRIPTION_Index_111", "Outputs Steam"); - addStringLocalization("Interaction_DESCRIPTION_Index_112", "Outputs Liquids and Items"); - addStringLocalization("Interaction_DESCRIPTION_Index_113", "Outputs only Items"); - addStringLocalization("Interaction_DESCRIPTION_Index_114", "Outputs only Liquids"); - addStringLocalization("Interaction_DESCRIPTION_Index_115", "Outputs nothing"); - addStringLocalization("Interaction_DESCRIPTION_Index_116", "Emit Energy to Outputside"); - addStringLocalization("Interaction_DESCRIPTION_Index_117", "Don't emit Energy"); - addStringLocalization("Interaction_DESCRIPTION_Index_118", "Emit Redstone if no Slot is free"); - addStringLocalization("Interaction_DESCRIPTION_Index_119", "Don't emit Redstone"); - addStringLocalization("Interaction_DESCRIPTION_Index_120", "Invert Redstone"); - addStringLocalization("Interaction_DESCRIPTION_Index_121", "Don't invert Redstone"); - addStringLocalization("Interaction_DESCRIPTION_Index_122", "Emit Redstone if slots contain something"); - addStringLocalization("Interaction_DESCRIPTION_Index_123", "Don't emit Redstone"); - addStringLocalization("Interaction_DESCRIPTION_Index_124", "Invert Filter"); - addStringLocalization("Interaction_DESCRIPTION_Index_125", "Don't invert Filter"); - addStringLocalization("Interaction_DESCRIPTION_Index_126", "Ignore NBT"); - addStringLocalization("Interaction_DESCRIPTION_Index_127", "NBT has to match"); - addStringLocalization("Interaction_DESCRIPTION_Index_128", "Redstone "); - addStringLocalization("Interaction_DESCRIPTION_Index_129", "Energy "); - addStringLocalization("Interaction_DESCRIPTION_Index_130", "Fluids "); - addStringLocalization("Interaction_DESCRIPTION_Index_131", "Items "); - addStringLocalization("Interaction_DESCRIPTION_Index_132", "Pipe is loose."); - addStringLocalization("Interaction_DESCRIPTION_Index_133", "Screws are loose."); - addStringLocalization("Interaction_DESCRIPTION_Index_134", "Something is stuck."); - addStringLocalization("Interaction_DESCRIPTION_Index_135", "Platings are dented."); - addStringLocalization("Interaction_DESCRIPTION_Index_136", "Circuitry burned out."); - addStringLocalization("Interaction_DESCRIPTION_Index_137", "That doesn't belong there."); - addStringLocalization("Interaction_DESCRIPTION_Index_138", "Incomplete Structure."); - addStringLocalization("Interaction_DESCRIPTION_Index_139", "Hit with Soft Hammer"); - addStringLocalization("Interaction_DESCRIPTION_Index_140", "to (re-)start the Machine"); - addStringLocalization("Interaction_DESCRIPTION_Index_141", "if it doesn't start."); - addStringLocalization("Interaction_DESCRIPTION_Index_142", "Running perfectly."); - addStringLocalization("Interaction_DESCRIPTION_Index_143", "Missing Mining Pipe"); - addStringLocalization("Interaction_DESCRIPTION_Index_144", "Missing Turbine Rotor"); - addStringLocalization("Interaction_DESCRIPTION_Index_145", "Step Down, In: "); - addStringLocalization("Interaction_DESCRIPTION_Index_146", "Step Up, In: "); - addStringLocalization("Interaction_DESCRIPTION_Index_147", "Amp, Out: "); - addStringLocalization("Interaction_DESCRIPTION_Index_148", " V at "); - addStringLocalization("Interaction_DESCRIPTION_Index_149", " Amp"); - addStringLocalization("Interaction_DESCRIPTION_Index_150", "Chance: "); - addStringLocalization("Interaction_DESCRIPTION_Index_151", "Does not get consumed in the process"); - addStringLocalization("Interaction_DESCRIPTION_Index_152", "Total: "); - addStringLocalization("Interaction_DESCRIPTION_Index_153", "Usage: "); - addStringLocalization("Interaction_DESCRIPTION_Index_154", "Voltage: "); - addStringLocalization("Interaction_DESCRIPTION_Index_155", "Amperage: "); - addStringLocalization("Interaction_DESCRIPTION_Index_156", "Voltage: unspecified"); - addStringLocalization("Interaction_DESCRIPTION_Index_157", "Amperage: unspecified"); - addStringLocalization("Interaction_DESCRIPTION_Index_158", "Time: "); - addStringLocalization("Interaction_DESCRIPTION_Index_159", "Needs Low Gravity"); - addStringLocalization("Interaction_DESCRIPTION_Index_160", "Needs Cleanroom"); - addStringLocalization("Interaction_DESCRIPTION_Index_161", " secs"); - addStringLocalization("Interaction_DESCRIPTION_Index_162", "Name: "); - addStringLocalization("Interaction_DESCRIPTION_Index_163", " MetaData: "); - addStringLocalization("Interaction_DESCRIPTION_Index_164", "Hardness: "); - addStringLocalization("Interaction_DESCRIPTION_Index_165", " Blast Resistance: "); - addStringLocalization("Interaction_DESCRIPTION_Index_166", "Is valid Beacon Pyramid Material"); - addStringLocalization("Interaction_DESCRIPTION_Index_167", "Tank "); - addStringLocalization("Interaction_DESCRIPTION_Index_168", "Heat: "); - addStringLocalization("Interaction_DESCRIPTION_Index_169", " HEM: "); - addStringLocalization("Interaction_DESCRIPTION_Index_170", " Base EU Output: "); - addStringLocalization("Interaction_DESCRIPTION_Index_171", "Facing: "); - addStringLocalization("Interaction_DESCRIPTION_Index_172", " / Chance: "); - addStringLocalization("Interaction_DESCRIPTION_Index_173", "You can remove this with a Wrench"); - addStringLocalization("Interaction_DESCRIPTION_Index_174", "You can NOT remove this with a Wrench"); - addStringLocalization("Interaction_DESCRIPTION_Index_175", "Conduction Loss: "); - addStringLocalization("Interaction_DESCRIPTION_Index_176", "Contained Energy: "); - addStringLocalization("Interaction_DESCRIPTION_Index_177", "Has Muffler Upgrade"); - addStringLocalization("Interaction_DESCRIPTION_Index_178", "Progress: "); - addStringLocalization("Interaction_DESCRIPTION_Index_179", "Max IN: "); - addStringLocalization("Interaction_DESCRIPTION_Index_180", " EU"); - addStringLocalization("Interaction_DESCRIPTION_Index_181", "Max OUT: "); - addStringLocalization("Interaction_DESCRIPTION_Index_182", " EU at "); - addStringLocalization("Interaction_DESCRIPTION_Index_183", " Amperes"); - addStringLocalization("Interaction_DESCRIPTION_Index_184", "Energy: "); - addStringLocalization("Interaction_DESCRIPTION_Index_185", "EU"); - addStringLocalization("Interaction_DESCRIPTION_Index_186", "Owned by: "); - addStringLocalization("Interaction_DESCRIPTION_Index_187", "Type -- Crop-Name: "); - addStringLocalization("Interaction_DESCRIPTION_Index_188", " Growth: "); - addStringLocalization("Interaction_DESCRIPTION_Index_189", " Gain: "); - addStringLocalization("Interaction_DESCRIPTION_Index_190", " Resistance: "); - addStringLocalization("Interaction_DESCRIPTION_Index_191", "Plant -- Fertilizer: "); - addStringLocalization("Interaction_DESCRIPTION_Index_192", " Water: "); - addStringLocalization("Interaction_DESCRIPTION_Index_193", " Weed-Ex: "); - addStringLocalization("Interaction_DESCRIPTION_Index_194", " Scan-Level: "); - addStringLocalization("Interaction_DESCRIPTION_Index_195", "Environment -- Nutrients: "); - addStringLocalization("Interaction_DESCRIPTION_Index_196", " Humidity: "); - addStringLocalization("Interaction_DESCRIPTION_Index_197", " Air-Quality: "); - addStringLocalization("Interaction_DESCRIPTION_Index_198", "Attributes:"); - addStringLocalization("Interaction_DESCRIPTION_Index_199", "Discovered by: "); - addStringLocalization("Interaction_DESCRIPTION_Index_200", " L"); - addStringLocalization("Interaction_DESCRIPTION_Index_201", "Nothing"); - addStringLocalization("Interaction_DESCRIPTION_Index_202", "Pollution in Chunk: "); - addStringLocalization("Interaction_DESCRIPTION_Index_203", " gibbl"); - addStringLocalization("Interaction_DESCRIPTION_Index_204", "No Pollution in Chunk! HAYO!"); - addStringLocalization("Interaction_DESCRIPTION_Index_205", " of "); - addStringLocalization("Interaction_DESCRIPTION_Index_206", "Scan for Assembly Line"); -// addStringLocalization("Interaction_DESCRIPTION_Index_207", "Grab"); -// addStringLocalization("Interaction_DESCRIPTION_Index_208", "Grab"); -// addStringLocalization("Interaction_DESCRIPTION_Index_209", "Grab"); -// addStringLocalization("Interaction_DESCRIPTION_Index_210", "Grab"); - addStringLocalization("Interaction_DESCRIPTION_Index_211", "Items per side: "); - addStringLocalization("Interaction_DESCRIPTION_Index_212", "Input enabled"); + public static void writePlaceholderStrings() { + addStringLocalization("Interaction_DESCRIPTION_Index_001", "Puts out into adjacent Slot #"); + addStringLocalization("Interaction_DESCRIPTION_Index_002", "Grabs in for own Slot #"); + addStringLocalization("Interaction_DESCRIPTION_Index_003", "Normal"); + addStringLocalization("Interaction_DESCRIPTION_Index_004", "Inverted"); + addStringLocalization("Interaction_DESCRIPTION_Index_005", "No Work at all"); + addStringLocalization("Interaction_DESCRIPTION_Index_006", "Export"); + addStringLocalization("Interaction_DESCRIPTION_Index_007", "Import"); + addStringLocalization("Interaction_DESCRIPTION_Index_008", "Export (conditional)"); + addStringLocalization("Interaction_DESCRIPTION_Index_009", "Import (conditional)"); + addStringLocalization("Interaction_DESCRIPTION_Index_010", "Export (invert cond)"); + addStringLocalization("Interaction_DESCRIPTION_Index_011", "Import (invert cond)"); + addStringLocalization("Interaction_DESCRIPTION_Index_012", "Export allow Input"); + addStringLocalization("Interaction_DESCRIPTION_Index_013", "Import allow Output"); + addStringLocalization("Interaction_DESCRIPTION_Index_014", "Export allow Input (conditional)"); + addStringLocalization("Interaction_DESCRIPTION_Index_015", "Import allow Output (conditional)"); + addStringLocalization("Interaction_DESCRIPTION_Index_016", "Export allow Input (invert cond)"); + addStringLocalization("Interaction_DESCRIPTION_Index_017", "Import allow Output (invert cond)"); + addStringLocalization("Interaction_DESCRIPTION_Index_018", "Normal"); + addStringLocalization("Interaction_DESCRIPTION_Index_019", "Inverted"); + addStringLocalization("Interaction_DESCRIPTION_Index_020", "Ready to work"); + addStringLocalization("Interaction_DESCRIPTION_Index_021", "Not ready to work"); + addStringLocalization("Interaction_DESCRIPTION_Index_022", "Import"); + addStringLocalization("Interaction_DESCRIPTION_Index_023", "Import (conditional)"); + addStringLocalization("Interaction_DESCRIPTION_Index_024", "Import (invert cond)"); + addStringLocalization("Interaction_DESCRIPTION_Index_025", "Keep Liquids Away"); + addStringLocalization("Interaction_DESCRIPTION_Index_026", "Keep Liquids Away (conditional)"); + addStringLocalization("Interaction_DESCRIPTION_Index_027", "Keep Liquids Away (invert cond)"); + addStringLocalization("Interaction_DESCRIPTION_Index_028", "Allow"); + addStringLocalization("Interaction_DESCRIPTION_Index_029", "Allow (conditional)"); + addStringLocalization("Interaction_DESCRIPTION_Index_030", "Disallow (conditional)"); + addStringLocalization("Interaction_DESCRIPTION_Index_031", "Normal Universal Storage"); + addStringLocalization("Interaction_DESCRIPTION_Index_032", "Inverted Universal Storage"); + addStringLocalization("Interaction_DESCRIPTION_Index_033", "Normal Electricity Storage"); + addStringLocalization("Interaction_DESCRIPTION_Index_034", "Inverted Electricity Storage"); + addStringLocalization("Interaction_DESCRIPTION_Index_035", "Normal Steam Storage"); + addStringLocalization("Interaction_DESCRIPTION_Index_036", "Inverted Steam Storage"); + addStringLocalization("Interaction_DESCRIPTION_Index_037", "Normal Average Electric Input"); + addStringLocalization("Interaction_DESCRIPTION_Index_038", "Inverted Average Electric Input"); + addStringLocalization("Interaction_DESCRIPTION_Index_039", "Normal Average Electric Output"); + addStringLocalization("Interaction_DESCRIPTION_Index_040", "Inverted Average Electric Output"); + addStringLocalization("Interaction_DESCRIPTION_Index_041", "Normal Electricity Storage(Including Batteries)"); + addStringLocalization("Interaction_DESCRIPTION_Index_042", "Inverted Electricity Storage(Including Batteries)"); + addStringLocalization("Interaction_DESCRIPTION_Index_043", "Allow input, no output"); + addStringLocalization("Interaction_DESCRIPTION_Index_044", "Deny input, no output"); + addStringLocalization("Interaction_DESCRIPTION_Index_045", "Allow input, permit any output"); + addStringLocalization("Interaction_DESCRIPTION_Index_046", "Deny input, permit any output"); + addStringLocalization("Interaction_DESCRIPTION_Index_047", "Filter Fluid: "); + addStringLocalization("Interaction_DESCRIPTION_Index_048", "Pump speed: "); + addStringLocalization("Interaction_DESCRIPTION_Index_049", "L/tick "); + addStringLocalization("Interaction_DESCRIPTION_Index_050", "L/sec"); + addStringLocalization("Interaction_DESCRIPTION_Index_051", "Normal"); + addStringLocalization("Interaction_DESCRIPTION_Index_052", "Inverted"); + addStringLocalization("Interaction_DESCRIPTION_Index_053", "Slot: "); + addStringLocalization("Interaction_DESCRIPTION_Index_054", "Inverted"); + addStringLocalization("Interaction_DESCRIPTION_Index_055", "Normal"); + addStringLocalization("Interaction_DESCRIPTION_Index_056", "Emit if 1 Maintenance Needed"); + addStringLocalization("Interaction_DESCRIPTION_Index_057", "Emit if 1 Maintenance Needed(inverted)"); + addStringLocalization("Interaction_DESCRIPTION_Index_058", "Emit if 2 Maintenance Needed"); + addStringLocalization("Interaction_DESCRIPTION_Index_059", "Emit if 2 Maintenance Needed(inverted)"); + addStringLocalization("Interaction_DESCRIPTION_Index_060", "Emit if 3 Maintenance Needed"); + addStringLocalization("Interaction_DESCRIPTION_Index_061", "Emit if 3 Maintenance Needed(inverted)"); + addStringLocalization("Interaction_DESCRIPTION_Index_062", "Emit if 4 Maintenance Needed"); + addStringLocalization("Interaction_DESCRIPTION_Index_063", "Emit if 4 Maintenance Needed(inverted)"); + addStringLocalization("Interaction_DESCRIPTION_Index_064", "Emit if 5 Maintenance Needed"); + addStringLocalization("Interaction_DESCRIPTION_Index_065", "Emit if 5 Maintenance Needed(inverted)"); + addStringLocalization("Interaction_DESCRIPTION_Index_066", "Emit if rotor needs maintenance"); + addStringLocalization("Interaction_DESCRIPTION_Index_067", "Emit if rotor needs maintenance(inverted)"); + addStringLocalization("Interaction_DESCRIPTION_Index_068", "Emit if any Player is close"); + addStringLocalization("Interaction_DESCRIPTION_Index_069", "Emit if other player is close"); + addStringLocalization("Interaction_DESCRIPTION_Index_070", "Emit if you are close"); + addStringLocalization("Interaction_DESCRIPTION_Index_071", "Conducts strongest Input"); + addStringLocalization("Interaction_DESCRIPTION_Index_072", "Conducts from bottom Input"); + addStringLocalization("Interaction_DESCRIPTION_Index_073", "Conducts from top Input"); + addStringLocalization("Interaction_DESCRIPTION_Index_074", "Conducts from north Input"); + addStringLocalization("Interaction_DESCRIPTION_Index_075", "Conducts from south Input"); + addStringLocalization("Interaction_DESCRIPTION_Index_076", "Conducts from west Input"); + addStringLocalization("Interaction_DESCRIPTION_Index_077", "Conducts from east Input"); + addStringLocalization("Interaction_DESCRIPTION_Index_078", "Signal = "); + addStringLocalization("Interaction_DESCRIPTION_Index_079", "Conditional Signal = "); + addStringLocalization("Interaction_DESCRIPTION_Index_080", "Inverted Conditional Signal = "); + addStringLocalization("Interaction_DESCRIPTION_Index_081", "Frequency: "); + addStringLocalization("Interaction_DESCRIPTION_Index_082", "Open if work enabled"); + addStringLocalization("Interaction_DESCRIPTION_Index_083", "Open if work disabled"); + addStringLocalization("Interaction_DESCRIPTION_Index_084", "Only Output allowed"); + addStringLocalization("Interaction_DESCRIPTION_Index_085", "Only Input allowed"); + addStringLocalization("Interaction_DESCRIPTION_Index_086", "Auto-Input: "); + addStringLocalization("Interaction_DESCRIPTION_Index_087", "Disabled"); + addStringLocalization("Interaction_DESCRIPTION_Index_088", "Enabled"); + addStringLocalization("Interaction_DESCRIPTION_Index_089", " Auto-Output: "); + addStringLocalization("Interaction_DESCRIPTION_Index_090", "Machine Processing: "); + addStringLocalization("Interaction_DESCRIPTION_Index_091", "Redstone Output at Side "); + addStringLocalization("Interaction_DESCRIPTION_Index_092", " set to: "); + addStringLocalization("Interaction_DESCRIPTION_Index_093", "Strong"); + addStringLocalization("Interaction_DESCRIPTION_Index_094", "Weak"); + addStringLocalization("Interaction_DESCRIPTION_Index_095", "Input from Output Side allowed"); + addStringLocalization("Interaction_DESCRIPTION_Index_096", "Input from Output Side forbidden"); + addStringLocalization("Interaction_DESCRIPTION_Index_097", "It's dangerous to go alone! Take this."); + addStringLocalization("Interaction_DESCRIPTION_Index_098", "Do not regulate Item Stack Size"); + addStringLocalization("Interaction_DESCRIPTION_Index_099", "Regulate Item Stack Size to: "); + addStringLocalization("Interaction_DESCRIPTION_Index_100", "This is "); // Spartaaaaaaa!!! + addStringLocalization("Interaction_DESCRIPTION_Index_101", " Ore."); + addStringLocalization("Interaction_DESCRIPTION_Index_102", "There is Lava behind this Rock."); + addStringLocalization("Interaction_DESCRIPTION_Index_103", "There is a Liquid behind this Rock."); + addStringLocalization("Interaction_DESCRIPTION_Index_104", "There is an Air Pocket behind this Rock."); + addStringLocalization("Interaction_DESCRIPTION_Index_105", "Material is changing behind this Rock."); + addStringLocalization("Interaction_DESCRIPTION_Index_106", "Found traces of "); + addStringLocalization("Interaction_DESCRIPTION_Index_107", "No Ores found."); + addStringLocalization("Interaction_DESCRIPTION_Index_108", "Outputs Liquids, Steam and Items"); + addStringLocalization("Interaction_DESCRIPTION_Index_109", "Outputs Steam and Items"); + addStringLocalization("Interaction_DESCRIPTION_Index_110", "Outputs Steam and Liquids"); + addStringLocalization("Interaction_DESCRIPTION_Index_111", "Outputs Steam"); + addStringLocalization("Interaction_DESCRIPTION_Index_112", "Outputs Liquids and Items"); + addStringLocalization("Interaction_DESCRIPTION_Index_113", "Outputs only Items"); + addStringLocalization("Interaction_DESCRIPTION_Index_114", "Outputs only Liquids"); + addStringLocalization("Interaction_DESCRIPTION_Index_115", "Outputs nothing"); + addStringLocalization("Interaction_DESCRIPTION_Index_116", "Emit Energy to Outputside"); + addStringLocalization("Interaction_DESCRIPTION_Index_117", "Don't emit Energy"); + addStringLocalization("Interaction_DESCRIPTION_Index_118", "Emit Redstone if no Slot is free"); + addStringLocalization("Interaction_DESCRIPTION_Index_119", "Don't emit Redstone"); + addStringLocalization("Interaction_DESCRIPTION_Index_120", "Invert Redstone"); + addStringLocalization("Interaction_DESCRIPTION_Index_121", "Don't invert Redstone"); + addStringLocalization("Interaction_DESCRIPTION_Index_122", "Emit Redstone if slots contain something"); + addStringLocalization("Interaction_DESCRIPTION_Index_123", "Don't emit Redstone"); + addStringLocalization("Interaction_DESCRIPTION_Index_124", "Invert Filter"); + addStringLocalization("Interaction_DESCRIPTION_Index_125", "Don't invert Filter"); + addStringLocalization("Interaction_DESCRIPTION_Index_126", "Ignore NBT"); + addStringLocalization("Interaction_DESCRIPTION_Index_127", "NBT has to match"); + addStringLocalization("Interaction_DESCRIPTION_Index_128", "Redstone "); + addStringLocalization("Interaction_DESCRIPTION_Index_129", "Energy "); + addStringLocalization("Interaction_DESCRIPTION_Index_130", "Fluids "); + addStringLocalization("Interaction_DESCRIPTION_Index_131", "Items "); + addStringLocalization("Interaction_DESCRIPTION_Index_132", "Pipe is loose."); + addStringLocalization("Interaction_DESCRIPTION_Index_133", "Screws are loose."); + addStringLocalization("Interaction_DESCRIPTION_Index_134", "Something is stuck."); + addStringLocalization("Interaction_DESCRIPTION_Index_135", "Platings are dented."); + addStringLocalization("Interaction_DESCRIPTION_Index_136", "Circuitry burned out."); + addStringLocalization("Interaction_DESCRIPTION_Index_137", "That doesn't belong there."); + addStringLocalization("Interaction_DESCRIPTION_Index_138", "Incomplete Structure."); + addStringLocalization("Interaction_DESCRIPTION_Index_139", "Hit with Soft Hammer"); + addStringLocalization("Interaction_DESCRIPTION_Index_140", "to (re-)start the Machine"); + addStringLocalization("Interaction_DESCRIPTION_Index_141", "if it doesn't start."); + addStringLocalization("Interaction_DESCRIPTION_Index_142", "Running perfectly."); + addStringLocalization("Interaction_DESCRIPTION_Index_143", "Missing Mining Pipe"); + addStringLocalization("Interaction_DESCRIPTION_Index_144", "Missing Turbine Rotor"); + addStringLocalization("Interaction_DESCRIPTION_Index_145", "Step Down, In: "); + addStringLocalization("Interaction_DESCRIPTION_Index_146", "Step Up, In: "); + addStringLocalization("Interaction_DESCRIPTION_Index_147", "Amp, Out: "); + addStringLocalization("Interaction_DESCRIPTION_Index_148", " V at "); + addStringLocalization("Interaction_DESCRIPTION_Index_149", " Amp"); + addStringLocalization("Interaction_DESCRIPTION_Index_150", "Chance: "); + addStringLocalization("Interaction_DESCRIPTION_Index_151", "Does not get consumed in the process"); + addStringLocalization("Interaction_DESCRIPTION_Index_152", "Total: "); + addStringLocalization("Interaction_DESCRIPTION_Index_153", "Usage: "); + addStringLocalization("Interaction_DESCRIPTION_Index_154", "Voltage: "); + addStringLocalization("Interaction_DESCRIPTION_Index_155", "Amperage: "); + addStringLocalization("Interaction_DESCRIPTION_Index_156", "Voltage: unspecified"); + addStringLocalization("Interaction_DESCRIPTION_Index_157", "Amperage: unspecified"); + addStringLocalization("Interaction_DESCRIPTION_Index_158", "Time: "); + addStringLocalization("Interaction_DESCRIPTION_Index_159", "Needs Low Gravity"); + addStringLocalization("Interaction_DESCRIPTION_Index_160", "Needs Cleanroom"); + addStringLocalization("Interaction_DESCRIPTION_Index_161", " secs"); + addStringLocalization("Interaction_DESCRIPTION_Index_162", "Name: "); + addStringLocalization("Interaction_DESCRIPTION_Index_163", " MetaData: "); + addStringLocalization("Interaction_DESCRIPTION_Index_164", "Hardness: "); + addStringLocalization("Interaction_DESCRIPTION_Index_165", " Blast Resistance: "); + addStringLocalization("Interaction_DESCRIPTION_Index_166", "Is valid Beacon Pyramid Material"); + addStringLocalization("Interaction_DESCRIPTION_Index_167", "Tank "); + addStringLocalization("Interaction_DESCRIPTION_Index_168", "Heat: "); + addStringLocalization("Interaction_DESCRIPTION_Index_169", " HEM: "); + addStringLocalization("Interaction_DESCRIPTION_Index_170", " Base EU Output: "); + addStringLocalization("Interaction_DESCRIPTION_Index_171", "Facing: "); + addStringLocalization("Interaction_DESCRIPTION_Index_172", " / Chance: "); + addStringLocalization("Interaction_DESCRIPTION_Index_173", "You can remove this with a Wrench"); + addStringLocalization("Interaction_DESCRIPTION_Index_174", "You can NOT remove this with a Wrench"); + addStringLocalization("Interaction_DESCRIPTION_Index_175", "Conduction Loss: "); + addStringLocalization("Interaction_DESCRIPTION_Index_176", "Contained Energy: "); + addStringLocalization("Interaction_DESCRIPTION_Index_177", "Has Muffler Upgrade"); + addStringLocalization("Interaction_DESCRIPTION_Index_178", "Progress: "); + addStringLocalization("Interaction_DESCRIPTION_Index_179", "Max IN: "); + addStringLocalization("Interaction_DESCRIPTION_Index_180", " EU"); + addStringLocalization("Interaction_DESCRIPTION_Index_181", "Max OUT: "); + addStringLocalization("Interaction_DESCRIPTION_Index_182", " EU at "); + addStringLocalization("Interaction_DESCRIPTION_Index_183", " Amperes"); + addStringLocalization("Interaction_DESCRIPTION_Index_184", "Energy: "); + addStringLocalization("Interaction_DESCRIPTION_Index_185", "EU"); + addStringLocalization("Interaction_DESCRIPTION_Index_186", "Owned by: "); + addStringLocalization("Interaction_DESCRIPTION_Index_187", "Type -- Crop-Name: "); + addStringLocalization("Interaction_DESCRIPTION_Index_188", " Growth: "); + addStringLocalization("Interaction_DESCRIPTION_Index_189", " Gain: "); + addStringLocalization("Interaction_DESCRIPTION_Index_190", " Resistance: "); + addStringLocalization("Interaction_DESCRIPTION_Index_191", "Plant -- Fertilizer: "); + addStringLocalization("Interaction_DESCRIPTION_Index_192", " Water: "); + addStringLocalization("Interaction_DESCRIPTION_Index_193", " Weed-Ex: "); + addStringLocalization("Interaction_DESCRIPTION_Index_194", " Scan-Level: "); + addStringLocalization("Interaction_DESCRIPTION_Index_195", "Environment -- Nutrients: "); + addStringLocalization("Interaction_DESCRIPTION_Index_196", " Humidity: "); + addStringLocalization("Interaction_DESCRIPTION_Index_197", " Air-Quality: "); + addStringLocalization("Interaction_DESCRIPTION_Index_198", "Attributes:"); + addStringLocalization("Interaction_DESCRIPTION_Index_199", "Discovered by: "); + addStringLocalization("Interaction_DESCRIPTION_Index_200", " L"); + addStringLocalization("Interaction_DESCRIPTION_Index_201", "Nothing"); + addStringLocalization("Interaction_DESCRIPTION_Index_202", "Pollution in Chunk: "); + addStringLocalization("Interaction_DESCRIPTION_Index_203", " gibbl"); + addStringLocalization("Interaction_DESCRIPTION_Index_204", "No Pollution in Chunk! HAYO!"); + addStringLocalization("Interaction_DESCRIPTION_Index_205", " of "); + addStringLocalization("Interaction_DESCRIPTION_Index_206", "Scan for Assembly Line"); + // addStringLocalization("Interaction_DESCRIPTION_Index_207", "Grab"); + // addStringLocalization("Interaction_DESCRIPTION_Index_208", "Grab"); + // addStringLocalization("Interaction_DESCRIPTION_Index_209", "Grab"); + // addStringLocalization("Interaction_DESCRIPTION_Index_210", "Grab"); + addStringLocalization("Interaction_DESCRIPTION_Index_211", "Items per side: "); + addStringLocalization("Interaction_DESCRIPTION_Index_212", "Input enabled"); addStringLocalization("Interaction_DESCRIPTION_Index_213", "Input disabled"); addStringLocalization("Interaction_DESCRIPTION_Index_214", "Connected"); addStringLocalization("Interaction_DESCRIPTION_Index_215", "Disconnected"); - addStringLocalization("Interaction_DESCRIPTION_Index_216", "Deprecated Recipe"); - addStringLocalization("Interaction_DESCRIPTION_Index_217", "Stocking mode. Keeps this many items in destination input slots. This mode can be server unfriendly."); - addStringLocalization("Interaction_DESCRIPTION_Index_218", "Transfer size mode. Add exactly this many items in destination input slots as long as there is room."); - addStringLocalization("Interaction_DESCRIPTION_Index_219", "Extended Facing:"); - addStringLocalization("Interaction_DESCRIPTION_Index_220", "Single recipe locking disabled."); - addStringLocalization("Interaction_DESCRIPTION_Index_221", "Item threshold"); - addStringLocalization("Interaction_DESCRIPTION_Index_222", "Fluid threshold"); - addStringLocalization("Interaction_DESCRIPTION_Index_223", "Single recipe locking enabled. Will lock to next recipe."); + addStringLocalization("Interaction_DESCRIPTION_Index_216", "Deprecated Recipe"); + addStringLocalization( + "Interaction_DESCRIPTION_Index_217", + "Stocking mode. Keeps this many items in destination input slots. This mode can be server unfriendly."); + addStringLocalization( + "Interaction_DESCRIPTION_Index_218", + "Transfer size mode. Add exactly this many items in destination input slots as long as there is room."); + addStringLocalization("Interaction_DESCRIPTION_Index_219", "Extended Facing:"); + addStringLocalization("Interaction_DESCRIPTION_Index_220", "Single recipe locking disabled."); + addStringLocalization("Interaction_DESCRIPTION_Index_221", "Item threshold"); + addStringLocalization("Interaction_DESCRIPTION_Index_222", "Fluid threshold"); + addStringLocalization( + "Interaction_DESCRIPTION_Index_223", "Single recipe locking enabled. Will lock to next recipe."); addStringLocalization("Interaction_DESCRIPTION_Index_224", " ticks"); addStringLocalization("Interaction_DESCRIPTION_Index_500", "Fitting: Loose - More Flow"); - addStringLocalization("Interaction_DESCRIPTION_Index_501", "Fitting: Tight - More Efficiency"); + addStringLocalization("Interaction_DESCRIPTION_Index_501", "Fitting: Tight - More Efficiency"); - addStringLocalization("Item_DESCRIPTION_Index_000", "Stored Heat: %s"); + addStringLocalization("Item_DESCRIPTION_Index_000", "Stored Heat: %s"); addStringLocalization("Item_DESCRIPTION_Index_001", "Durability: %s/%s"); addStringLocalization("Item_DESCRIPTION_Index_002", "%s lvl %s"); addStringLocalization("Item_DESCRIPTION_Index_003", "Attack Damage: %s"); @@ -401,14 +408,14 @@ public class GT_LanguageManager { addStringLocalization("Item_DESCRIPTION_Index_500", "Turbine Efficiency (Loose): %s"); addStringLocalization("Item_DESCRIPTION_Index_501", "Optimal Steam flow (Loose): %s L/t"); - addStringLocalization(FACE_ANY, "Any Side"); - addStringLocalization(FACE_BOTTOM, "Bottom"); - addStringLocalization(FACE_TOP, "Top"); - addStringLocalization(FACE_LEFT, "Left"); - addStringLocalization(FACE_FRONT, "Front"); - addStringLocalization(FACE_RIGHT, "Right"); - addStringLocalization(FACE_BACK, "Back"); - addStringLocalization(FACE_NONE, "None"); + addStringLocalization(FACE_ANY, "Any Side"); + addStringLocalization(FACE_BOTTOM, "Bottom"); + addStringLocalization(FACE_TOP, "Top"); + addStringLocalization(FACE_LEFT, "Left"); + addStringLocalization(FACE_FRONT, "Front"); + addStringLocalization(FACE_RIGHT, "Right"); + addStringLocalization(FACE_BACK, "Back"); + addStringLocalization(FACE_NONE, "None"); } private static void addToMCLangList(String aKey, String aEnglish) { diff --git a/src/main/java/gregtech/api/util/GT_Log.java b/src/main/java/gregtech/api/util/GT_Log.java index 888f471317..49f44b968b 100644 --- a/src/main/java/gregtech/api/util/GT_Log.java +++ b/src/main/java/gregtech/api/util/GT_Log.java @@ -28,7 +28,9 @@ public class GT_Log { public LogBuffer() { super(new OutputStream() { @Override - public void write(int arg0) {/*Do nothing*/} + public void write(int arg0) { + /*Do nothing*/ + } }); } diff --git a/src/main/java/gregtech/api/util/GT_ModHandler.java b/src/main/java/gregtech/api/util/GT_ModHandler.java index 1af913f4ee..f861f2afc7 100644 --- a/src/main/java/gregtech/api/util/GT_ModHandler.java +++ b/src/main/java/gregtech/api/util/GT_ModHandler.java @@ -1,5 +1,15 @@ package gregtech.api.util; +import static gregtech.GT_Mod.GT_FML_LOGGER; +import static gregtech.api.enums.GT_Values.B; +import static gregtech.api.enums.GT_Values.D1; +import static gregtech.api.enums.GT_Values.DW; +import static gregtech.api.enums.GT_Values.E; +import static gregtech.api.enums.GT_Values.M; +import static gregtech.api.enums.GT_Values.RA; +import static gregtech.api.enums.GT_Values.V; +import static gregtech.api.enums.GT_Values.W; + import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.GregTech_API; import gregtech.api.enums.ConfigCategories; @@ -22,6 +32,18 @@ import ic2.api.reactor.IReactorComponent; import ic2.api.recipe.IRecipeInput; import ic2.api.recipe.RecipeInputItemStack; import ic2.api.recipe.RecipeOutput; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; import net.minecraft.block.Block; import net.minecraft.enchantment.Enchantment; import net.minecraft.entity.EntityLivingBase; @@ -47,29 +69,6 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Objects; -import java.util.Set; -import java.util.stream.Collectors; - -import static gregtech.GT_Mod.GT_FML_LOGGER; -import static gregtech.api.enums.GT_Values.B; -import static gregtech.api.enums.GT_Values.D1; -import static gregtech.api.enums.GT_Values.DW; -import static gregtech.api.enums.GT_Values.E; -import static gregtech.api.enums.GT_Values.M; -import static gregtech.api.enums.GT_Values.RA; -import static gregtech.api.enums.GT_Values.V; -import static gregtech.api.enums.GT_Values.W; - /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! * <p/> @@ -81,11 +80,11 @@ public class GT_ModHandler { public static final List<IRecipe> sSingleNonBlockDamagableRecipeList = new ArrayList<>(1000); private static final Map<String, ItemStack> sIC2ItemMap = new HashMap<>(); - private static final List<IRecipe> sAllRecipeList = new ArrayList<>(5000), sBufferRecipeList = new ArrayList<>(1000); + private static final List<IRecipe> sAllRecipeList = new ArrayList<>(5000), + sBufferRecipeList = new ArrayList<>(1000); private static final List<ItemStack> delayedRemovalByOutput = new ArrayList<>(); private static final List<InventoryCrafting> delayedRemovalByRecipe = new ArrayList<>(); - public static volatile int VERSION = 509; public static Collection<String> sNativeRecipeClasses = new HashSet<>(), sSpecialRecipeClasses = new HashSet<>(); public static GT_HashSet<GT_ItemStack> sNonReplaceableItems = new GT_HashSet<>(); @@ -103,52 +102,51 @@ public class GT_ModHandler { private static final boolean sSingleNonBlockDamagableRecipeList_create = true; private static final ItemStack sMt1 = new ItemStack(Blocks.dirt, 1, 0), sMt2 = new ItemStack(Blocks.dirt, 1, 0); private static final String s_H = "h", s_F = "f", s_I = "I", s_P = "P", s_R = "R"; - private static final ItemStack[][] - sShapes1 = new ItemStack[][]{ - {sMt1, null, sMt1, sMt1, sMt1, sMt1, null, sMt1, null}, - {sMt1, null, sMt1, sMt1, null, sMt1, sMt1, sMt1, sMt1}, - {null, sMt1, null, sMt1, sMt1, sMt1, sMt1, null, sMt1}, - {sMt1, sMt1, sMt1, sMt1, null, sMt1, null, null, null}, - {sMt1, null, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1}, - {sMt1, sMt1, sMt1, sMt1, null, sMt1, sMt1, null, sMt1}, - {null, null, null, sMt1, null, sMt1, sMt1, null, sMt1}, - {null, sMt1, null, null, sMt1, null, null, sMt2, null}, - {sMt1, sMt1, sMt1, null, sMt2, null, null, sMt2, null}, - {null, sMt1, null, null, sMt2, null, null, sMt2, null}, - {sMt1, sMt1, null, sMt1, sMt2, null, null, sMt2, null}, - {null, sMt1, sMt1, null, sMt2, sMt1, null, sMt2, null}, - {sMt1, sMt1, null, null, sMt2, null, null, sMt2, null}, - {null, sMt1, sMt1, null, sMt2, null, null, sMt2, null}, - {null, sMt1, null, sMt1, null, null, null, sMt1, sMt2}, - {null, sMt1, null, null, null, sMt1, sMt2, sMt1, null}, - {null, sMt1, null, sMt1, null, sMt1, null, null, sMt2}, - {null, sMt1, null, sMt1, null, sMt1, sMt2, null, null}, - {null, sMt2, null, null, sMt1, null, null, sMt1, null}, - {null, sMt2, null, null, sMt2, null, sMt1, sMt1, sMt1}, - {null, sMt2, null, null, sMt2, null, null, sMt1, null}, - {null, sMt2, null, sMt1, sMt2, null, sMt1, sMt1, null}, - {null, sMt2, null, null, sMt2, sMt1, null, sMt1, sMt1}, - {null, sMt2, null, null, sMt2, null, sMt1, sMt1, null}, - {sMt1, null, null, null, sMt2, null, null, null, sMt2}, - {null, null, sMt1, null, sMt2, null, sMt2, null, null}, - {sMt1, null, null, null, sMt2, null, null, null, null}, - {null, null, sMt1, null, sMt2, null, null, null, null}, - {sMt1, sMt2, null, null, null, null, null, null, null}, - {sMt2, sMt1, null, null, null, null, null, null, null}, - {sMt1, null, null, sMt2, null, null, null, null, null}, - {sMt2, null, null, sMt1, null, null, null, null, null}, - {sMt1, sMt1, sMt1, sMt1, sMt1, sMt1, null, sMt2, null}, - {sMt1, sMt1, null, sMt1, sMt1, sMt2, sMt1, sMt1, null}, - {null, sMt1, sMt1, sMt2, sMt1, sMt1, null, sMt1, sMt1}, - {null, sMt2, null, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1}, - {sMt1, sMt1, sMt1, sMt1, sMt2, sMt1, null, sMt2, null}, - {sMt1, sMt1, null, sMt1, sMt2, sMt2, sMt1, sMt1, null}, - {null, sMt1, sMt1, sMt2, sMt2, sMt1, null, sMt1, sMt1}, - {null, sMt2, null, sMt1, sMt2, sMt1, sMt1, sMt1, sMt1}, - {sMt1, null, null, null, sMt1, null, null, null, null}, - {null, sMt1, null, sMt1, null, null, null, null, null}, - {sMt1, sMt1, null, sMt2, null, sMt1, sMt2, null, null}, - {null, sMt1, sMt1, sMt1, null, sMt2, null, null, sMt2} + private static final ItemStack[][] sShapes1 = new ItemStack[][] { + {sMt1, null, sMt1, sMt1, sMt1, sMt1, null, sMt1, null}, + {sMt1, null, sMt1, sMt1, null, sMt1, sMt1, sMt1, sMt1}, + {null, sMt1, null, sMt1, sMt1, sMt1, sMt1, null, sMt1}, + {sMt1, sMt1, sMt1, sMt1, null, sMt1, null, null, null}, + {sMt1, null, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1}, + {sMt1, sMt1, sMt1, sMt1, null, sMt1, sMt1, null, sMt1}, + {null, null, null, sMt1, null, sMt1, sMt1, null, sMt1}, + {null, sMt1, null, null, sMt1, null, null, sMt2, null}, + {sMt1, sMt1, sMt1, null, sMt2, null, null, sMt2, null}, + {null, sMt1, null, null, sMt2, null, null, sMt2, null}, + {sMt1, sMt1, null, sMt1, sMt2, null, null, sMt2, null}, + {null, sMt1, sMt1, null, sMt2, sMt1, null, sMt2, null}, + {sMt1, sMt1, null, null, sMt2, null, null, sMt2, null}, + {null, sMt1, sMt1, null, sMt2, null, null, sMt2, null}, + {null, sMt1, null, sMt1, null, null, null, sMt1, sMt2}, + {null, sMt1, null, null, null, sMt1, sMt2, sMt1, null}, + {null, sMt1, null, sMt1, null, sMt1, null, null, sMt2}, + {null, sMt1, null, sMt1, null, sMt1, sMt2, null, null}, + {null, sMt2, null, null, sMt1, null, null, sMt1, null}, + {null, sMt2, null, null, sMt2, null, sMt1, sMt1, sMt1}, + {null, sMt2, null, null, sMt2, null, null, sMt1, null}, + {null, sMt2, null, sMt1, sMt2, null, sMt1, sMt1, null}, + {null, sMt2, null, null, sMt2, sMt1, null, sMt1, sMt1}, + {null, sMt2, null, null, sMt2, null, sMt1, sMt1, null}, + {sMt1, null, null, null, sMt2, null, null, null, sMt2}, + {null, null, sMt1, null, sMt2, null, sMt2, null, null}, + {sMt1, null, null, null, sMt2, null, null, null, null}, + {null, null, sMt1, null, sMt2, null, null, null, null}, + {sMt1, sMt2, null, null, null, null, null, null, null}, + {sMt2, sMt1, null, null, null, null, null, null, null}, + {sMt1, null, null, sMt2, null, null, null, null, null}, + {sMt2, null, null, sMt1, null, null, null, null, null}, + {sMt1, sMt1, sMt1, sMt1, sMt1, sMt1, null, sMt2, null}, + {sMt1, sMt1, null, sMt1, sMt1, sMt2, sMt1, sMt1, null}, + {null, sMt1, sMt1, sMt2, sMt1, sMt1, null, sMt1, sMt1}, + {null, sMt2, null, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1}, + {sMt1, sMt1, sMt1, sMt1, sMt2, sMt1, null, sMt2, null}, + {sMt1, sMt1, null, sMt1, sMt2, sMt2, sMt1, sMt1, null}, + {null, sMt1, sMt1, sMt2, sMt2, sMt1, null, sMt1, sMt1}, + {null, sMt2, null, sMt1, sMt2, sMt1, sMt1, sMt1, sMt1}, + {sMt1, null, null, null, sMt1, null, null, null, null}, + {null, sMt1, null, sMt1, null, null, null, null, null}, + {sMt1, sMt1, null, sMt2, null, sMt1, sMt2, null, null}, + {null, sMt1, sMt1, sMt1, null, sMt2, null, null, sMt2} }; public static List<Integer> sSingleNonBlockDamagableRecipeList_validsShapes1 = new ArrayList<>(44); public static boolean sSingleNonBlockDamagableRecipeList_validsShapes1_update = false; @@ -220,8 +218,8 @@ public class GT_ModHandler { * Returns a Liquid Stack with given amount of distilled Water. */ public static FluidStack getDistilledWater(long aAmount) { - FluidStack tFluid = FluidRegistry.getFluidStack("ic2distilledwater", (int) aAmount); - if(tFluid==null)tFluid = getWater(aAmount); + FluidStack tFluid = FluidRegistry.getFluidStack("ic2distilledwater", (int) aAmount); + if (tFluid == null) tFluid = getWater(aAmount); return tFluid; } @@ -252,14 +250,14 @@ public class GT_ModHandler { * Returns if that Liquid is Any Steam (including other mods) */ public static boolean isAnySteam(FluidStack aFluid) { - return(aFluid != null && (isSteam(aFluid) || sAnySteamFluidIDs.contains(aFluid.getFluidID()))); + return (aFluid != null && (isSteam(aFluid) || sAnySteamFluidIDs.contains(aFluid.getFluidID()))); } /** * Returns if that Liquid is Super Heated Steam (including other mods) */ public static boolean isSuperHeatedSteam(FluidStack aFluid) { - return(aFluid != null && sSuperHeatedSteamFluidIDs.contains(aFluid.getFluidID())); + return (aFluid != null && sSuperHeatedSteamFluidIDs.contains(aFluid.getFluidID())); } /** @@ -300,7 +298,8 @@ public class GT_ModHandler { return ItemList.Cell_Water.get(aAmount); } - public static ItemStack getLavaCell(long aAmount) { return ItemList.Cell_Lava.get(aAmount); + public static ItemStack getLavaCell(long aAmount) { + return ItemList.Cell_Lava.get(aAmount); } /** @@ -347,12 +346,15 @@ public class GT_ModHandler { */ public static ItemStack getIC2Item(String aItem, long aAmount, ItemStack aReplacement) { if (GT_Utility.isStringInvalid(aItem) || !GregTech_API.sPreloadStarted) return null; - //if (D1) GT_Log.out.println("Requested the Item '" + aItem + "' from the IC2-API"); - if (!sIC2ItemMap.containsKey(aItem)) try { - ItemStack tStack = IC2Items.getItem(aItem); - sIC2ItemMap.put(aItem, tStack); - if (tStack == null && D1) GT_Log.err.println(aItem + " is not found in the IC2 Items!"); - } catch (Throwable e) {/*Do nothing*/} + // if (D1) GT_Log.out.println("Requested the Item '" + aItem + "' from the IC2-API"); + if (!sIC2ItemMap.containsKey(aItem)) + try { + ItemStack tStack = IC2Items.getItem(aItem); + sIC2ItemMap.put(aItem, tStack); + if (tStack == null && D1) GT_Log.err.println(aItem + " is not found in the IC2 Items!"); + } catch (Throwable e) { + /*Do nothing*/ + } return GT_Utility.copyAmount(aAmount, sIC2ItemMap.get(aItem), aReplacement); } @@ -442,8 +444,12 @@ public class GT_ModHandler { public static boolean addValuableOre(Block aBlock, int aMeta, int aValue) { if (aValue <= 0) return false; try { - Class.forName("ic2.core.IC2").getMethod("addValuableOre", IRecipeInput.class, int.class).invoke(null, new RecipeInputItemStack(new ItemStack(aBlock, 1, aMeta)), aValue); - } catch (Throwable e) {/*Do nothing*/} + Class.forName("ic2.core.IC2") + .getMethod("addValuableOre", IRecipeInput.class, int.class) + .invoke(null, new RecipeInputItemStack(new ItemStack(aBlock, 1, aMeta)), aValue); + } catch (Throwable e) { + /*Do nothing*/ + } return true; } @@ -458,9 +464,25 @@ public class GT_ModHandler { aChance = (float) GregTech_API.sRecipeFile.get(ConfigCategories.Machines.scrapboxdrops, aOutput, aChance); if (aChance <= 0) return false; try { - GT_Utility.callMethod(GT_Utility.getFieldContent("ic2.api.recipe.Recipes", "scrapboxDrops", true, true), "addDrop", true, false, true, GT_Utility.copyOrNull(aOutput), aChance); - GT_Utility.callMethod(GT_Utility.getFieldContent("ic2.api.recipe.Recipes", "scrapboxDrops", true, true), "addRecipe", true, true, false, GT_Utility.copyOrNull(aOutput), aChance); - } catch (Throwable e) {/*Do nothing*/} + GT_Utility.callMethod( + GT_Utility.getFieldContent("ic2.api.recipe.Recipes", "scrapboxDrops", true, true), + "addDrop", + true, + false, + true, + GT_Utility.copyOrNull(aOutput), + aChance); + GT_Utility.callMethod( + GT_Utility.getFieldContent("ic2.api.recipe.Recipes", "scrapboxDrops", true, true), + "addRecipe", + true, + true, + false, + GT_Utility.copyOrNull(aOutput), + aChance); + } catch (Throwable e) { + /*Do nothing*/ + } return true; } @@ -471,7 +493,9 @@ public class GT_ModHandler { if (aRecycledStack == null) return false; try { ic2.api.recipe.Recipes.recyclerBlacklist.add(new RecipeInputItemStack(aRecycledStack)); - } catch (Throwable e) {/*Do nothing*/} + } catch (Throwable e) { + /*Do nothing*/ + } return true; } @@ -494,33 +518,39 @@ public class GT_ModHandler { boolean temp = false; if (aInput.stackSize == 1 && addSmeltingRecipe(aInput, aOutput)) temp = true; return (RA.addAlloySmelterRecipe( - aInput, - OrePrefixes.ingot.contains(aOutput) ? ItemList.Shape_Mold_Ingot.get(0) : OrePrefixes.block.contains(aOutput) ? ItemList.Shape_Mold_Block.get(0) : OrePrefixes.nugget.contains(aOutput) ? ItemList.Shape_Mold_Nugget.get(0) : null, - aOutput, - 130, - 3, - hidden - )); + aInput, + OrePrefixes.ingot.contains(aOutput) + ? ItemList.Shape_Mold_Ingot.get(0) + : OrePrefixes.block.contains(aOutput) + ? ItemList.Shape_Mold_Block.get(0) + : OrePrefixes.nugget.contains(aOutput) ? ItemList.Shape_Mold_Nugget.get(0) : null, + aOutput, + 130, + 3, + hidden)); } /** * LiquidTransposer Recipe for both directions */ - public static boolean addLiquidTransposerRecipe(ItemStack aEmptyContainer, FluidStack aLiquid, ItemStack aFullContainer, int aMJ) { + public static boolean addLiquidTransposerRecipe( + ItemStack aEmptyContainer, FluidStack aLiquid, ItemStack aFullContainer, int aMJ) { return true; } /** * LiquidTransposer Recipe for filling Containers */ - public static boolean addLiquidTransposerFillRecipe(ItemStack aEmptyContainer, FluidStack aLiquid, ItemStack aFullContainer, int aMJ) { + public static boolean addLiquidTransposerFillRecipe( + ItemStack aEmptyContainer, FluidStack aLiquid, ItemStack aFullContainer, int aMJ) { return true; } /** * LiquidTransposer Recipe for emptying Containers */ - public static boolean addLiquidTransposerEmptyRecipe(ItemStack aFullContainer, FluidStack aLiquid, ItemStack aEmptyContainer, int aMJ) { + public static boolean addLiquidTransposerEmptyRecipe( + ItemStack aFullContainer, FluidStack aLiquid, ItemStack aEmptyContainer, int aMJ) { return true; } @@ -538,8 +568,8 @@ public class GT_ModHandler { /** * RC-BlastFurnace Recipes */ - @Deprecated - public static boolean addRCBlastFurnaceRecipe(ItemStack aInput, ItemStack aOutput, int aTime) { + @Deprecated + public static boolean addRCBlastFurnaceRecipe(ItemStack aInput, ItemStack aOutput, int aTime) { return true; } @@ -551,7 +581,8 @@ public class GT_ModHandler { return addPulverisationRecipe(aInput, aOutput1, aOutput2, 100, false); } - public static boolean addPulverisationRecipe(ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, int aChance) { + public static boolean addPulverisationRecipe( + ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, int aChance) { return addPulverisationRecipe(aInput, aOutput1, aOutput2, aChance, false); } @@ -559,34 +590,49 @@ public class GT_ModHandler { return addPulverisationRecipe(aInput, aOutput1, null, 0, aOverwrite); } - public static boolean addPulverisationRecipe(ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, boolean aOverwrite) { + public static boolean addPulverisationRecipe( + ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, boolean aOverwrite) { return addPulverisationRecipe(aInput, aOutput1, aOutput2, 100, aOverwrite); } - public static boolean addPulverisationRecipe(ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, int aChance, boolean aOverwrite) { + public static boolean addPulverisationRecipe( + ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, int aChance, boolean aOverwrite) { return addPulverisationRecipe(aInput, aOutput1, aOutput2, aChance, null, 0, aOverwrite); } /** * Adds Several Pulverizer-Type Recipes. */ - public static boolean addPulverisationRecipe(ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, int aChance2, ItemStack aOutput3, int aChance3, boolean aOverwrite) { + public static boolean addPulverisationRecipe( + ItemStack aInput, + ItemStack aOutput1, + ItemStack aOutput2, + int aChance2, + ItemStack aOutput3, + int aChance3, + boolean aOverwrite) { aOutput1 = GT_OreDictUnificator.get(true, aOutput1); aOutput2 = GT_OreDictUnificator.get(true, aOutput2); if (GT_Utility.isStackInvalid(aInput) || GT_Utility.isStackInvalid(aOutput1)) return false; if (GT_Utility.getContainerItem(aInput, false) == null) { - RA.addPulveriserRecipe(aInput, new ItemStack[]{aOutput1, aOutput2, aOutput3}, new int[]{10000, aChance2 <= 0 ? 1000 : 100 * aChance2, aChance3 <= 0 ? 1000 : 100 * aChance3}, 400, 2); + RA.addPulveriserRecipe( + aInput, + new ItemStack[] {aOutput1, aOutput2, aOutput3}, + new int[] {10000, aChance2 <= 0 ? 1000 : 100 * aChance2, aChance3 <= 0 ? 1000 : 100 * aChance3}, + 400, + 2); } return true; } - public static boolean addPulverisationRecipe(ItemStack aInputItem, ItemStack[] aOutputArray, int[] aChanceArray, int aEUt, int aRecipeDurationInTicks) { + public static boolean addPulverisationRecipe( + ItemStack aInputItem, ItemStack[] aOutputArray, int[] aChanceArray, int aEUt, int aRecipeDurationInTicks) { ItemStack[] aUnifiedOutputArray = new ItemStack[aOutputArray.length]; int counter = 0; - for (ItemStack item: aOutputArray) { + for (ItemStack item : aOutputArray) { aUnifiedOutputArray[counter] = GT_OreDictUnificator.get(true, item); counter++; } @@ -596,11 +642,13 @@ public class GT_ModHandler { return true; } - public static boolean addImmersiveEngineeringRecipe(ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, int aChance2, ItemStack aOutput3, int aChance3){ - return true; + public static boolean addImmersiveEngineeringRecipe( + ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, int aChance2, ItemStack aOutput3, int aChance3) { + return true; } - public static boolean addMagneticraftRecipe(ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, int aChance2, ItemStack aOutput3, int aChance3){ + public static boolean addMagneticraftRecipe( + ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, int aChance2, ItemStack aOutput3, int aChance3) { return true; } @@ -614,7 +662,13 @@ public class GT_ModHandler { /** * Induction Smelter Recipes and Alloy Smelter Recipes */ - public static boolean addAlloySmelterRecipe(ItemStack aInput1, ItemStack aInput2, ItemStack aOutput1, int aDuration, int aEUt, boolean aAllowSecondaryInputEmpty) { + public static boolean addAlloySmelterRecipe( + ItemStack aInput1, + ItemStack aInput2, + ItemStack aOutput1, + int aDuration, + int aEUt, + boolean aAllowSecondaryInputEmpty) { if (aInput1 == null || (aInput2 == null && !aAllowSecondaryInputEmpty) || aOutput1 == null) return false; aOutput1 = GT_OreDictUnificator.get(true, aOutput1); return RA.addAlloySmelterRecipe(aInput1, aInput2, aOutput1, aDuration, aEUt); @@ -623,7 +677,8 @@ public class GT_ModHandler { /** * Induction Smelter Recipes for TE */ - public static boolean addInductionSmelterRecipe(ItemStack aInput1, ItemStack aInput2, ItemStack aOutput1, ItemStack aOutput2, int aEnergy, int aChance) { + public static boolean addInductionSmelterRecipe( + ItemStack aInput1, ItemStack aInput2, ItemStack aOutput1, ItemStack aOutput2, int aEnergy, int aChance) { return true; } @@ -640,31 +695,73 @@ public class GT_ModHandler { /** * Adds GT versions of the IC2 recipes from the supplied IC2RecipeList. */ - public static void addIC2RecipesToGT(Map<IRecipeInput, RecipeOutput> aIC2RecipeList, GT_Recipe.GT_Recipe_Map aGTRecipeMap, boolean aAddGTRecipe, boolean aRemoveIC2Recipe, boolean aExcludeGTIC2Items) { + public static void addIC2RecipesToGT( + Map<IRecipeInput, RecipeOutput> aIC2RecipeList, + GT_Recipe.GT_Recipe_Map aGTRecipeMap, + boolean aAddGTRecipe, + boolean aRemoveIC2Recipe, + boolean aExcludeGTIC2Items) { Map<ItemStack, ItemStack> aRecipesToRemove = new HashMap<>(); for (Entry<IRecipeInput, RecipeOutput> iRecipeInputRecipeOutputEntry : aIC2RecipeList.entrySet()) { if ((iRecipeInputRecipeOutputEntry.getValue()).items.size() > 0) { for (ItemStack tStack : (iRecipeInputRecipeOutputEntry.getKey()).getInputs()) { if (GT_Utility.isStackValid(tStack)) { - if (aAddGTRecipe && (aGTRecipeMap.findRecipe(null, false, Long.MAX_VALUE, null, tStack) == null)) { + if (aAddGTRecipe + && (aGTRecipeMap.findRecipe(null, false, Long.MAX_VALUE, null, tStack) == null)) { try { - if (aExcludeGTIC2Items && ((tStack.getUnlocalizedName().contains("gt.metaitem.01") || tStack.getUnlocalizedName().contains("gt.blockores") || tStack.getUnlocalizedName().contains("ic2.itemCrushed") || tStack.getUnlocalizedName().contains("ic2.itemPurifiedCrushed")))) + if (aExcludeGTIC2Items + && ((tStack.getUnlocalizedName().contains("gt.metaitem.01") + || tStack.getUnlocalizedName().contains("gt.blockores") + || tStack.getUnlocalizedName().contains("ic2.itemCrushed") + || tStack.getUnlocalizedName().contains("ic2.itemPurifiedCrushed")))) continue; switch (aGTRecipeMap.mUnlocalizedName) { case "gt.recipe.macerator": case "gt.recipe.extractor": case "gt.recipe.compressor": - aGTRecipeMap.addRecipe(true, new ItemStack[]{GT_Utility.copyAmount((iRecipeInputRecipeOutputEntry.getKey()).getAmount(), tStack)}, (ItemStack[]) (iRecipeInputRecipeOutputEntry.getValue()).items.toArray(), null, null, null, null, 300, 2, 0); + aGTRecipeMap.addRecipe( + true, + new ItemStack[] { + GT_Utility.copyAmount( + (iRecipeInputRecipeOutputEntry.getKey()).getAmount(), + tStack) + }, + (ItemStack[]) + (iRecipeInputRecipeOutputEntry.getValue()).items.toArray(), + null, + null, + null, + null, + 300, + 2, + 0); break; case "gt.recipe.thermalcentrifuge": - aGTRecipeMap.addRecipe(true, new ItemStack[]{GT_Utility.copyAmount((iRecipeInputRecipeOutputEntry.getKey()).getAmount(), tStack)}, (ItemStack[]) (iRecipeInputRecipeOutputEntry.getValue()).items.toArray(), null, null, null, null, 500, 48, 0); + aGTRecipeMap.addRecipe( + true, + new ItemStack[] { + GT_Utility.copyAmount( + (iRecipeInputRecipeOutputEntry.getKey()).getAmount(), + tStack) + }, + (ItemStack[]) + (iRecipeInputRecipeOutputEntry.getValue()).items.toArray(), + null, + null, + null, + null, + 500, + 48, + 0); break; } } catch (Exception e) { System.err.println(e); } } - if (aRemoveIC2Recipe) aRecipesToRemove.put(tStack, ((RecipeOutput) iRecipeInputRecipeOutputEntry.getValue()).items.get(0)); + if (aRemoveIC2Recipe) + aRecipesToRemove.put( + tStack, ((RecipeOutput) iRecipeInputRecipeOutputEntry.getValue()).items.get(0)); } } } @@ -675,42 +772,54 @@ public class GT_ModHandler { public static Map<IRecipeInput, RecipeOutput> getExtractorRecipeList() { try { return ic2.api.recipe.Recipes.extractor.getRecipes(); - } catch (Throwable e) {/*Do nothing*/} + } catch (Throwable e) { + /*Do nothing*/ + } return sExtractorRecipes; } public static Map<IRecipeInput, RecipeOutput> getCompressorRecipeList() { try { return ic2.api.recipe.Recipes.compressor.getRecipes(); - } catch (Throwable e) {/*Do nothing*/} + } catch (Throwable e) { + /*Do nothing*/ + } return sCompressorRecipes; } public static Map<IRecipeInput, RecipeOutput> getMaceratorRecipeList() { try { return ic2.api.recipe.Recipes.macerator.getRecipes(); - } catch (Throwable e) {/*Do nothing*/} + } catch (Throwable e) { + /*Do nothing*/ + } return sMaceratorRecipes; } public static Map<IRecipeInput, RecipeOutput> getThermalCentrifugeRecipeList() { try { return ic2.api.recipe.Recipes.centrifuge.getRecipes(); - } catch (Throwable e) {/*Do nothing*/} + } catch (Throwable e) { + /*Do nothing*/ + } return sThermalCentrifugeRecipes; } public static Map<IRecipeInput, RecipeOutput> getOreWashingRecipeList() { try { return ic2.api.recipe.Recipes.oreWashing.getRecipes(); - } catch (Throwable e) {/*Do nothing*/} + } catch (Throwable e) { + /*Do nothing*/ + } return sOreWashingRecipes; } public static Map<IRecipeInput, RecipeOutput> getMassFabricatorList() { try { return ic2.api.recipe.Recipes.matterAmplifier.getRecipes(); - } catch (Throwable e) {/*Do nothing*/} + } catch (Throwable e) { + /*Do nothing*/ + } return sMassfabRecipes; } @@ -720,14 +829,27 @@ public class GT_ModHandler { public static boolean addThermalCentrifugeRecipe(ItemStack aInput, int[] aChances, int aHeat, Object... aOutput) { if (aInput == null || aOutput == null || aOutput.length <= 0 || aOutput[0] == null) return false; if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.thermalcentrifuge, aInput, true)) return false; - RA.addThermalCentrifugeRecipe(aInput, aOutput.length >= 1 ? (ItemStack)aOutput[0] : null, aOutput.length >= 2 ? (ItemStack)aOutput[1] : null, aOutput.length >= 3 ? (ItemStack)aOutput[2] : null, aChances, 500, 48); + RA.addThermalCentrifugeRecipe( + aInput, + aOutput.length >= 1 ? (ItemStack) aOutput[0] : null, + aOutput.length >= 2 ? (ItemStack) aOutput[1] : null, + aOutput.length >= 3 ? (ItemStack) aOutput[2] : null, + aChances, + 500, + 48); return true; } public static boolean addThermalCentrifugeRecipe(ItemStack aInput, int aHeat, Object... aOutput) { if (aInput == null || aOutput == null || aOutput.length <= 0 || aOutput[0] == null) return false; if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.thermalcentrifuge, aInput, true)) return false; - RA.addThermalCentrifugeRecipe(aInput, aOutput.length >= 1 ? (ItemStack)aOutput[0] : null, aOutput.length >= 2 ? (ItemStack)aOutput[1] : null, aOutput.length >= 3 ? (ItemStack)aOutput[2] : null, 500, 48); + RA.addThermalCentrifugeRecipe( + aInput, + aOutput.length >= 1 ? (ItemStack) aOutput[0] : null, + aOutput.length >= 2 ? (ItemStack) aOutput[1] : null, + aOutput.length >= 3 ? (ItemStack) aOutput[2] : null, + 500, + 48); return true; } @@ -737,16 +859,46 @@ public class GT_ModHandler { public static boolean addOreWasherRecipe(ItemStack aInput, int[] aChances, int aWaterAmount, Object... aOutput) { if (aInput == null || aOutput == null || aOutput.length <= 0 || aOutput[0] == null) return false; if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.orewashing, aInput, true)) return false; - RA.addOreWasherRecipe(aInput, (ItemStack)aOutput[0], (ItemStack)aOutput[1], (ItemStack)aOutput[2], GT_ModHandler.getWater(aWaterAmount), aChances, 500, 16); - RA.addOreWasherRecipe(aInput, (ItemStack)aOutput[0], (ItemStack)aOutput[1], (ItemStack)aOutput[2], GT_ModHandler.getDistilledWater(aWaterAmount / 5), aChances, 300, 16); + RA.addOreWasherRecipe( + aInput, + (ItemStack) aOutput[0], + (ItemStack) aOutput[1], + (ItemStack) aOutput[2], + GT_ModHandler.getWater(aWaterAmount), + aChances, + 500, + 16); + RA.addOreWasherRecipe( + aInput, + (ItemStack) aOutput[0], + (ItemStack) aOutput[1], + (ItemStack) aOutput[2], + GT_ModHandler.getDistilledWater(aWaterAmount / 5), + aChances, + 300, + 16); return true; } public static boolean addOreWasherRecipe(ItemStack aInput, int aWaterAmount, Object... aOutput) { if (aInput == null || aOutput == null || aOutput.length <= 0 || aOutput[0] == null) return false; if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.orewashing, aInput, true)) return false; - RA.addOreWasherRecipe(aInput, (ItemStack)aOutput[0], (ItemStack)aOutput[1], (ItemStack)aOutput[2], GT_ModHandler.getWater(aWaterAmount), 500, 16); - RA.addOreWasherRecipe(aInput, (ItemStack)aOutput[0], (ItemStack)aOutput[1], (ItemStack)aOutput[2], GT_ModHandler.getDistilledWater(aWaterAmount / 5), 300, 16); + RA.addOreWasherRecipe( + aInput, + (ItemStack) aOutput[0], + (ItemStack) aOutput[1], + (ItemStack) aOutput[2], + GT_ModHandler.getWater(aWaterAmount), + 500, + 16); + RA.addOreWasherRecipe( + aInput, + (ItemStack) aOutput[0], + (ItemStack) aOutput[1], + (ItemStack) aOutput[2], + GT_ModHandler.getDistilledWater(aWaterAmount / 5), + 300, + 16); return true; } @@ -770,8 +922,11 @@ public class GT_ModHandler { try { NBTTagCompound tNBT = new NBTTagCompound(); tNBT.setInteger("amplification", aValue); - GT_Utility.callMethod(ic2.api.recipe.Recipes.matterAmplifier, "addRecipe", false, false, false, aAmplifier, tNBT); - } catch (Throwable e) {/*Do nothing*/} + GT_Utility.callMethod( + ic2.api.recipe.Recipes.matterAmplifier, "addRecipe", false, false, false, aAmplifier, tNBT); + } catch (Throwable e) { + /*Do nothing*/ + } return true; } @@ -782,7 +937,9 @@ public class GT_ModHandler { aResult = GT_OreDictUnificator.get(true, aResult); if (aResult == null || aRecipe == null || aResult.stackSize <= 0) return false; try { - mods.railcraft.api.crafting.RailcraftCraftingManager.rollingMachine.getRecipeList().add(new ShapedOreRecipe(GT_Utility.copyOrNull(aResult), aRecipe)); + mods.railcraft.api.crafting.RailcraftCraftingManager.rollingMachine + .getRecipeList() + .add(new ShapedOreRecipe(GT_Utility.copyOrNull(aResult), aRecipe)); } catch (Throwable e) { return addCraftingRecipe(GT_Utility.copyOrNull(aResult), aRecipe); } @@ -804,8 +961,26 @@ public class GT_ModHandler { /** * Shapeless Crafting Recipes. Deletes conflicting Recipes too. */ - public static boolean addCraftingRecipe(ItemStack aResult, Enchantment[] aEnchantmentsAdded, int[] aEnchantmentLevelsAdded, Object[] aRecipe) { - return addCraftingRecipe(aResult, aEnchantmentsAdded, aEnchantmentLevelsAdded, false, true, false, false, false, false, false, false, false, false, false, false, true, aRecipe); + public static boolean addCraftingRecipe( + ItemStack aResult, Enchantment[] aEnchantmentsAdded, int[] aEnchantmentLevelsAdded, Object[] aRecipe) { + return addCraftingRecipe( + aResult, + aEnchantmentsAdded, + aEnchantmentLevelsAdded, + false, + true, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + true, + aRecipe); } /** @@ -862,47 +1037,46 @@ public class GT_ModHandler { */ public static boolean addCraftingRecipe(ItemStack aResult, long aBitMask, Object[] aRecipe) { return addCraftingRecipe( - aResult, - new Enchantment[0], - new int[0], - (aBitMask & RecipeBits.MIRRORED) != 0, - (aBitMask & RecipeBits.BUFFERED) != 0, - (aBitMask & RecipeBits.KEEPNBT) != 0, - (aBitMask & RecipeBits.DISMANTLEABLE) != 0, - (aBitMask & RecipeBits.NOT_REMOVABLE) == 0, - (aBitMask & RecipeBits.REVERSIBLE) != 0, - (aBitMask & RecipeBits.DELETE_ALL_OTHER_RECIPES) != 0, - (aBitMask & RecipeBits.DELETE_ALL_OTHER_RECIPES_IF_SAME_NBT) != 0, - (aBitMask & RecipeBits.DELETE_ALL_OTHER_SHAPED_RECIPES) != 0, - (aBitMask & RecipeBits.DELETE_ALL_OTHER_NATIVE_RECIPES) != 0, - (aBitMask & RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS) == 0, - (aBitMask & RecipeBits.ONLY_ADD_IF_THERE_IS_ANOTHER_RECIPE_FOR_IT) != 0, - (aBitMask & RecipeBits.ONLY_ADD_IF_RESULT_IS_NOT_NULL) != 0, - aRecipe); + aResult, + new Enchantment[0], + new int[0], + (aBitMask & RecipeBits.MIRRORED) != 0, + (aBitMask & RecipeBits.BUFFERED) != 0, + (aBitMask & RecipeBits.KEEPNBT) != 0, + (aBitMask & RecipeBits.DISMANTLEABLE) != 0, + (aBitMask & RecipeBits.NOT_REMOVABLE) == 0, + (aBitMask & RecipeBits.REVERSIBLE) != 0, + (aBitMask & RecipeBits.DELETE_ALL_OTHER_RECIPES) != 0, + (aBitMask & RecipeBits.DELETE_ALL_OTHER_RECIPES_IF_SAME_NBT) != 0, + (aBitMask & RecipeBits.DELETE_ALL_OTHER_SHAPED_RECIPES) != 0, + (aBitMask & RecipeBits.DELETE_ALL_OTHER_NATIVE_RECIPES) != 0, + (aBitMask & RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS) == 0, + (aBitMask & RecipeBits.ONLY_ADD_IF_THERE_IS_ANOTHER_RECIPE_FOR_IT) != 0, + (aBitMask & RecipeBits.ONLY_ADD_IF_RESULT_IS_NOT_NULL) != 0, + aRecipe); } /** * Internal realisation of the Crafting Recipe adding Process. */ private static boolean addCraftingRecipe( - ItemStack aResult, - Enchantment[] aEnchantmentsAdded, - int[] aEnchantmentLevelsAdded, - boolean aMirrored, - boolean aBuffered, - boolean aKeepNBT, - boolean aDismantleable, - boolean aRemovable, - boolean aReversible, - boolean aRemoveAllOthersWithSameOutput, - boolean aRemoveAllOthersWithSameOutputIfTheyHaveSameNBT, - boolean aRemoveAllOtherShapedsWithSameOutput, - boolean aRemoveAllOtherNativeRecipes, - boolean aCheckForCollisions, - boolean aOnlyAddIfThereIsAnyRecipeOutputtingThis, - boolean aOnlyAddIfResultIsNotNull, - Object[] aRecipe - ) { + ItemStack aResult, + Enchantment[] aEnchantmentsAdded, + int[] aEnchantmentLevelsAdded, + boolean aMirrored, + boolean aBuffered, + boolean aKeepNBT, + boolean aDismantleable, + boolean aRemovable, + boolean aReversible, + boolean aRemoveAllOthersWithSameOutput, + boolean aRemoveAllOthersWithSameOutputIfTheyHaveSameNBT, + boolean aRemoveAllOtherShapedsWithSameOutput, + boolean aRemoveAllOtherNativeRecipes, + boolean aCheckForCollisions, + boolean aOnlyAddIfThereIsAnyRecipeOutputtingThis, + boolean aOnlyAddIfResultIsNotNull, + Object[] aRecipe) { aResult = GT_OreDictUnificator.get(true, aResult); if (aOnlyAddIfResultIsNotNull && aResult == null) return false; if (aResult != null && Items.feather.getDamage(aResult) == W) Items.feather.setDamage(aResult, 0); @@ -912,12 +1086,13 @@ public class GT_ModHandler { boolean tThereWasARecipe = false; for (byte i = 0; i < aRecipe.length; i++) { - if (aRecipe[i] instanceof IItemContainer) - aRecipe[i] = ((IItemContainer) aRecipe[i]).get(1); - else if (aRecipe[i] instanceof Enum) - aRecipe[i] = ((Enum) aRecipe[i]).name(); - else if (!(aRecipe[i] == null || aRecipe[i] instanceof ItemStack || aRecipe[i] instanceof ItemData || aRecipe[i] instanceof String || aRecipe[i] instanceof Character)) - aRecipe[i] = aRecipe[i].toString(); + if (aRecipe[i] instanceof IItemContainer) aRecipe[i] = ((IItemContainer) aRecipe[i]).get(1); + else if (aRecipe[i] instanceof Enum) aRecipe[i] = ((Enum) aRecipe[i]).name(); + else if (!(aRecipe[i] == null + || aRecipe[i] instanceof ItemStack + || aRecipe[i] instanceof ItemData + || aRecipe[i] instanceof String + || aRecipe[i] instanceof Character)) aRecipe[i] = aRecipe[i].toString(); } try { @@ -1011,7 +1186,8 @@ public class GT_ModHandler { for (; idx < aRecipe.length; idx += 2) { if (aRecipe[idx] == null || aRecipe[idx + 1] == null) { if (D1) { - GT_Log.err.println("WARNING: Missing Item for shaped Recipe: " + (aResult == null ? "null" : aResult.getDisplayName())); + GT_Log.err.println("WARNING: Missing Item for shaped Recipe: " + + (aResult == null ? "null" : aResult.getDisplayName())); for (Object tContent : aRecipe) GT_Log.err.println(tContent); } return false; @@ -1084,8 +1260,7 @@ public class GT_ModHandler { } if (tDoWeCareIfThereWasARecipe || !aBuffered) tThereWasARecipe = removeRecipe(tRecipe) != null || tThereWasARecipe; - else - removeRecipeDelayed(tRecipe); + else removeRecipeDelayed(tRecipe); } } catch (Throwable e) { e.printStackTrace(GT_Log.err); @@ -1093,21 +1268,30 @@ public class GT_ModHandler { if (aResult == null || aResult.stackSize <= 0) return false; - if (aRemoveAllOthersWithSameOutput || aRemoveAllOthersWithSameOutputIfTheyHaveSameNBT || aRemoveAllOtherShapedsWithSameOutput || aRemoveAllOtherNativeRecipes) { - if(tDoWeCareIfThereWasARecipe || !aBuffered) - tThereWasARecipe = removeRecipeByOutput(aResult, !aRemoveAllOthersWithSameOutputIfTheyHaveSameNBT, aRemoveAllOtherShapedsWithSameOutput, aRemoveAllOtherNativeRecipes) || tThereWasARecipe; - else - removeRecipeByOutputDelayed(aResult); + if (aRemoveAllOthersWithSameOutput + || aRemoveAllOthersWithSameOutputIfTheyHaveSameNBT + || aRemoveAllOtherShapedsWithSameOutput + || aRemoveAllOtherNativeRecipes) { + if (tDoWeCareIfThereWasARecipe || !aBuffered) + tThereWasARecipe = removeRecipeByOutput( + aResult, + !aRemoveAllOthersWithSameOutputIfTheyHaveSameNBT, + aRemoveAllOtherShapedsWithSameOutput, + aRemoveAllOtherNativeRecipes) + || tThereWasARecipe; + else removeRecipeByOutputDelayed(aResult); } if (aOnlyAddIfThereIsAnyRecipeOutputtingThis && !tDoWeCareIfThereWasARecipe && !tThereWasARecipe) { - ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList(); - int tList_sS=tList.size(); + ArrayList<IRecipe> tList = + (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList(); + int tList_sS = tList.size(); for (int i = 0; i < tList_sS && !tThereWasARecipe; i++) { IRecipe tRecipe = tList.get(i); if (sSpecialRecipeClasses.contains(tRecipe.getClass().getName())) continue; if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get(tRecipe.getRecipeOutput()), aResult, true)) { - tList.remove(i--); tList_sS=tList.size(); + tList.remove(i--); + tList_sS = tList.size(); tThereWasARecipe = true; } } @@ -1120,9 +1304,25 @@ public class GT_ModHandler { if (tThereWasARecipe || !aOnlyAddIfThereIsAnyRecipeOutputtingThis) { if (sBufferCraftingRecipes && aBuffered) - sBufferRecipeList.add(new GT_Shaped_Recipe(GT_Utility.copyOrNull(aResult), aDismantleable, aRemovable, aKeepNBT, aEnchantmentsAdded, aEnchantmentLevelsAdded, aRecipe).setMirrored(aMirrored)); + sBufferRecipeList.add(new GT_Shaped_Recipe( + GT_Utility.copyOrNull(aResult), + aDismantleable, + aRemovable, + aKeepNBT, + aEnchantmentsAdded, + aEnchantmentLevelsAdded, + aRecipe) + .setMirrored(aMirrored)); else - GameRegistry.addRecipe(new GT_Shaped_Recipe(GT_Utility.copyOrNull(aResult), aDismantleable, aRemovable, aKeepNBT, aEnchantmentsAdded, aEnchantmentLevelsAdded, aRecipe).setMirrored(aMirrored)); + GameRegistry.addRecipe(new GT_Shaped_Recipe( + GT_Utility.copyOrNull(aResult), + aDismantleable, + aRemovable, + aKeepNBT, + aEnchantmentsAdded, + aEnchantmentLevelsAdded, + aRecipe) + .setMirrored(aMirrored)); } return true; } @@ -1130,37 +1330,56 @@ public class GT_ModHandler { /** * Shapeless Crafting Recipes. Deletes conflicting Recipes too. */ - public static boolean addShapelessEnchantingRecipe(ItemStack aResult, Enchantment[] aEnchantmentsAdded, int[] aEnchantmentLevelsAdded, Object[] aRecipe) { - return addShapelessCraftingRecipe(aResult, aEnchantmentsAdded, aEnchantmentLevelsAdded, true, false, false, false, aRecipe); + public static boolean addShapelessEnchantingRecipe( + ItemStack aResult, Enchantment[] aEnchantmentsAdded, int[] aEnchantmentLevelsAdded, Object[] aRecipe) { + return addShapelessCraftingRecipe( + aResult, aEnchantmentsAdded, aEnchantmentLevelsAdded, true, false, false, false, aRecipe); } /** * Shapeless Crafting Recipes. Deletes conflicting Recipes too. */ public static boolean addShapelessCraftingRecipe(ItemStack aResult, Object[] aRecipe) { - return addShapelessCraftingRecipe(aResult, RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | RecipeBits.BUFFERED, aRecipe); + return addShapelessCraftingRecipe( + aResult, RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | RecipeBits.BUFFERED, aRecipe); } /** * Shapeless Crafting Recipes. Deletes conflicting Recipes too. */ public static boolean addShapelessCraftingRecipe(ItemStack aResult, long aBitMask, Object[] aRecipe) { - return addShapelessCraftingRecipe(aResult, new Enchantment[0], new int[0], (aBitMask & RecipeBits.BUFFERED) != 0, (aBitMask & RecipeBits.KEEPNBT) != 0, (aBitMask & RecipeBits.DISMANTLEABLE) != 0, (aBitMask & RecipeBits.NOT_REMOVABLE) == 0, aRecipe); + return addShapelessCraftingRecipe( + aResult, + new Enchantment[0], + new int[0], + (aBitMask & RecipeBits.BUFFERED) != 0, + (aBitMask & RecipeBits.KEEPNBT) != 0, + (aBitMask & RecipeBits.DISMANTLEABLE) != 0, + (aBitMask & RecipeBits.NOT_REMOVABLE) == 0, + aRecipe); } /** * Shapeless Crafting Recipes. Deletes conflicting Recipes too. */ - private static boolean addShapelessCraftingRecipe(ItemStack aResult, Enchantment[] aEnchantmentsAdded, int[] aEnchantmentLevelsAdded, boolean aBuffered, boolean aKeepNBT, boolean aDismantleable, boolean aRemovable, Object[] aRecipe) { + private static boolean addShapelessCraftingRecipe( + ItemStack aResult, + Enchantment[] aEnchantmentsAdded, + int[] aEnchantmentLevelsAdded, + boolean aBuffered, + boolean aKeepNBT, + boolean aDismantleable, + boolean aRemovable, + Object[] aRecipe) { aResult = GT_OreDictUnificator.get(true, aResult); if (aRecipe == null || aRecipe.length <= 0) return false; for (byte i = 0; i < aRecipe.length; i++) { - if (aRecipe[i] instanceof IItemContainer) - aRecipe[i] = ((IItemContainer) aRecipe[i]).get(1); - else if (aRecipe[i] instanceof Enum) - aRecipe[i] = ((Enum) aRecipe[i]).name(); - else if (!(aRecipe[i] == null || aRecipe[i] instanceof ItemStack || aRecipe[i] instanceof String || aRecipe[i] instanceof Character)) - aRecipe[i] = aRecipe[i].toString(); + if (aRecipe[i] instanceof IItemContainer) aRecipe[i] = ((IItemContainer) aRecipe[i]).get(1); + else if (aRecipe[i] instanceof Enum) aRecipe[i] = ((Enum) aRecipe[i]).name(); + else if (!(aRecipe[i] == null + || aRecipe[i] instanceof ItemStack + || aRecipe[i] instanceof String + || aRecipe[i] instanceof Character)) aRecipe[i] = aRecipe[i].toString(); } try { ItemStack[] tRecipe = new ItemStack[9]; @@ -1168,7 +1387,8 @@ public class GT_ModHandler { for (Object tObject : aRecipe) { if (tObject == null) { if (D1) - GT_Log.err.println("WARNING: Missing Item for shapeless Recipe: " + (aResult == null ? "null" : aResult.getDisplayName())); + GT_Log.err.println("WARNING: Missing Item for shapeless Recipe: " + + (aResult == null ? "null" : aResult.getDisplayName())); for (Object tContent : aRecipe) GT_Log.err.println(tContent); return false; } @@ -1180,10 +1400,8 @@ public class GT_ModHandler { } i++; } - if (sBufferCraftingRecipes && aBuffered) - removeRecipeDelayed(tRecipe); - else - removeRecipe(tRecipe); + if (sBufferCraftingRecipes && aBuffered) removeRecipeDelayed(tRecipe); + else removeRecipe(tRecipe); } catch (Throwable e) { e.printStackTrace(GT_Log.err); } @@ -1196,9 +1414,23 @@ public class GT_ModHandler { GT_Utility.updateItemStack(aResult); if (sBufferCraftingRecipes && aBuffered) - sBufferRecipeList.add(new GT_Shapeless_Recipe(GT_Utility.copyOrNull(aResult), aDismantleable, aRemovable, aKeepNBT, aEnchantmentsAdded, aEnchantmentLevelsAdded, aRecipe)); + sBufferRecipeList.add(new GT_Shapeless_Recipe( + GT_Utility.copyOrNull(aResult), + aDismantleable, + aRemovable, + aKeepNBT, + aEnchantmentsAdded, + aEnchantmentLevelsAdded, + aRecipe)); else - GameRegistry.addRecipe(new GT_Shapeless_Recipe(GT_Utility.copyOrNull(aResult), aDismantleable, aRemovable, aKeepNBT, aEnchantmentsAdded, aEnchantmentLevelsAdded, aRecipe)); + GameRegistry.addRecipe(new GT_Shapeless_Recipe( + GT_Utility.copyOrNull(aResult), + aDismantleable, + aRemovable, + aKeepNBT, + aEnchantmentsAdded, + aEnchantmentLevelsAdded, + aRecipe)); return true; } @@ -1228,28 +1460,37 @@ public class GT_ModHandler { if (Arrays.stream(aRecipe).noneMatch(Objects::nonNull)) return null; ItemStack rReturn = null; - InventoryCrafting aCrafting = new InventoryCrafting(new Container() { - @Override - public boolean canInteractWith(EntityPlayer player) { - return false; - } - }, 3, 3); + InventoryCrafting aCrafting = new InventoryCrafting( + new Container() { + @Override + public boolean canInteractWith(EntityPlayer player) { + return false; + } + }, + 3, + 3); for (int i = 0; i < aRecipe.length && i < 9; i++) aCrafting.setInventorySlotContents(i, aRecipe[i]); - ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList(); - int tList_sS=tList.size(); + ArrayList<IRecipe> tList = + (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList(); + int tList_sS = tList.size(); try { for (int i = 0; i < tList_sS; i++) { for (; i < tList_sS; i++) { - if ((!(tList.get(i) instanceof IGT_CraftingRecipe) || ((IGT_CraftingRecipe) tList.get(i)).isRemovable()) && tList.get(i).matches(aCrafting, DW)) { + if ((!(tList.get(i) instanceof IGT_CraftingRecipe) + || ((IGT_CraftingRecipe) tList.get(i)).isRemovable()) + && tList.get(i).matches(aCrafting, DW)) { rReturn = tList.get(i).getCraftingResult(aCrafting); - if (rReturn != null) tList.remove(i--); tList_sS=tList.size(); + if (rReturn != null) tList.remove(i--); + tList_sS = tList.size(); } } - }} catch (Throwable e) {e.printStackTrace(GT_Log.err);} + } + } catch (Throwable e) { + e.printStackTrace(GT_Log.err); + } return rReturn; } - public static void removeRecipeDelayed(ItemStack... aRecipe) { if (!sBufferCraftingRecipes) { removeRecipe(aRecipe); @@ -1259,42 +1500,50 @@ public class GT_ModHandler { if (aRecipe == null) return; if (Arrays.stream(aRecipe).noneMatch(Objects::nonNull)) return; - InventoryCrafting aCrafting = new InventoryCrafting(new Container() { - @Override - public boolean canInteractWith(EntityPlayer player) { - return false; - } - }, 3, 3); + InventoryCrafting aCrafting = new InventoryCrafting( + new Container() { + @Override + public boolean canInteractWith(EntityPlayer player) { + return false; + } + }, + 3, + 3); for (int i = 0; i < aRecipe.length && i < 9; i++) aCrafting.setInventorySlotContents(i, aRecipe[i]); delayedRemovalByRecipe.add(aCrafting); } @SuppressWarnings("unchecked") public static void bulkRemoveByRecipe(List<InventoryCrafting> toRemove) { - ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList(); - GT_FML_LOGGER.info("BulkRemoveByRecipe: tList: " + tList.size() + " toRemove: " + toRemove.size() ); + ArrayList<IRecipe> tList = + (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList(); + GT_FML_LOGGER.info("BulkRemoveByRecipe: tList: " + tList.size() + " toRemove: " + toRemove.size()); - Set<IRecipe> tListToRemove = tList.parallelStream().filter(tRecipe -> { - if ((tRecipe instanceof IGT_CraftingRecipe) && !((IGT_CraftingRecipe) tRecipe).isRemovable()) return false; - return toRemove.stream().anyMatch(aCrafting -> tRecipe.matches(aCrafting, DW)); - }).collect(Collectors.toSet()); + Set<IRecipe> tListToRemove = tList.parallelStream() + .filter(tRecipe -> { + if ((tRecipe instanceof IGT_CraftingRecipe) && !((IGT_CraftingRecipe) tRecipe).isRemovable()) + return false; + return toRemove.stream().anyMatch(aCrafting -> tRecipe.matches(aCrafting, DW)); + }) + .collect(Collectors.toSet()); tList.removeIf(tListToRemove::contains); } public static boolean removeRecipeByOutputDelayed(ItemStack aOutput) { - if (sBufferCraftingRecipes) - return delayedRemovalByOutput.add(aOutput); - else - return removeRecipeByOutput(aOutput); + if (sBufferCraftingRecipes) return delayedRemovalByOutput.add(aOutput); + else return removeRecipeByOutput(aOutput); } - public static boolean removeRecipeByOutputDelayed (ItemStack aOutput, boolean aIgnoreNBT, boolean aNotRemoveShapelessRecipes, boolean aOnlyRemoveNativeHandlers) { + public static boolean removeRecipeByOutputDelayed( + ItemStack aOutput, + boolean aIgnoreNBT, + boolean aNotRemoveShapelessRecipes, + boolean aOnlyRemoveNativeHandlers) { if (sBufferCraftingRecipes && (aIgnoreNBT && !aNotRemoveShapelessRecipes && !aOnlyRemoveNativeHandlers)) // Too lazy to handle deferred versions of the parameters that aren't used very often return delayedRemovalByOutput.add(aOutput); - else - return removeRecipeByOutput(aOutput, aIgnoreNBT, aNotRemoveShapelessRecipes, aOnlyRemoveNativeHandlers); + else return removeRecipeByOutput(aOutput, aIgnoreNBT, aNotRemoveShapelessRecipes, aOnlyRemoveNativeHandlers); } public static boolean removeRecipeByOutput(ItemStack aOutput) { @@ -1307,27 +1556,31 @@ public class GT_ModHandler { * @param aOutput The output of the Recipe. * @return if it has removed at least one Recipe. */ - public static boolean removeRecipeByOutput(ItemStack aOutput, boolean aIgnoreNBT, boolean aNotRemoveShapelessRecipes, boolean aOnlyRemoveNativeHandlers) { + public static boolean removeRecipeByOutput( + ItemStack aOutput, + boolean aIgnoreNBT, + boolean aNotRemoveShapelessRecipes, + boolean aOnlyRemoveNativeHandlers) { if (aOutput == null) return false; boolean rReturn = false; - ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList(); + ArrayList<IRecipe> tList = + (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList(); aOutput = GT_OreDictUnificator.get(aOutput); - int tList_sS=tList.size(); + int tList_sS = tList.size(); for (int i = 0; i < tList_sS; i++) { IRecipe tRecipe = tList.get(i); - if (aNotRemoveShapelessRecipes && (tRecipe instanceof ShapelessRecipes || tRecipe instanceof ShapelessOreRecipe)) - continue; + if (aNotRemoveShapelessRecipes + && (tRecipe instanceof ShapelessRecipes || tRecipe instanceof ShapelessOreRecipe)) continue; if (aOnlyRemoveNativeHandlers) { if (!sNativeRecipeClasses.contains(tRecipe.getClass().getName())) continue; } else { if (sSpecialRecipeClasses.contains(tRecipe.getClass().getName())) continue; } ItemStack tStack = tRecipe.getRecipeOutput(); - if ( - (!(tRecipe instanceof IGT_CraftingRecipe) || ((IGT_CraftingRecipe) tRecipe).isRemovable()) - && GT_Utility.areStacksEqual(GT_OreDictUnificator.get(tStack), aOutput, aIgnoreNBT) - ) { - tList.remove(i--); tList_sS=tList.size(); + if ((!(tRecipe instanceof IGT_CraftingRecipe) || ((IGT_CraftingRecipe) tRecipe).isRemovable()) + && GT_Utility.areStacksEqual(GT_OreDictUnificator.get(tStack), aOutput, aIgnoreNBT)) { + tList.remove(i--); + tList_sS = tList.size(); rReturn = true; } } @@ -1335,18 +1588,23 @@ public class GT_ModHandler { } public static boolean bulkRemoveRecipeByOutput(List<ItemStack> toRemove) { - ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList(); + ArrayList<IRecipe> tList = + (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList(); - Set<ItemStack> setToRemove = toRemove.parallelStream().map(GT_OreDictUnificator::get_nocopy).collect(Collectors.toSet()); + Set<ItemStack> setToRemove = + toRemove.parallelStream().map(GT_OreDictUnificator::get_nocopy).collect(Collectors.toSet()); - GT_FML_LOGGER.info("BulkRemoveRecipeByOutput: tList: " + tList.size() + " setToRemove: " + setToRemove.size() ); + GT_FML_LOGGER.info("BulkRemoveRecipeByOutput: tList: " + tList.size() + " setToRemove: " + setToRemove.size()); - Set<IRecipe> tListToRemove = tList.parallelStream().filter(tRecipe -> { - if ((tRecipe instanceof IGT_CraftingRecipe) && !((IGT_CraftingRecipe) tRecipe).isRemovable()) return false; - if (sSpecialRecipeClasses.contains(tRecipe.getClass().getName())) return false; - final ItemStack tStack = GT_OreDictUnificator.get_nocopy(tRecipe.getRecipeOutput()); - return setToRemove.stream().anyMatch(aOutput -> GT_Utility.areStacksEqual(tStack, aOutput, true)); - }).collect(Collectors.toSet()); + Set<IRecipe> tListToRemove = tList.parallelStream() + .filter(tRecipe -> { + if ((tRecipe instanceof IGT_CraftingRecipe) && !((IGT_CraftingRecipe) tRecipe).isRemovable()) + return false; + if (sSpecialRecipeClasses.contains(tRecipe.getClass().getName())) return false; + final ItemStack tStack = GT_OreDictUnificator.get_nocopy(tRecipe.getRecipeOutput()); + return setToRemove.stream().anyMatch(aOutput -> GT_Utility.areStacksEqual(tStack, aOutput, true)); + }) + .collect(Collectors.toSet()); tList.removeIf(tListToRemove::contains); return true; @@ -1369,12 +1627,15 @@ public class GT_ModHandler { } } if (!temp) return null; - InventoryCrafting aCrafting = new InventoryCrafting(new Container() { - @Override - public boolean canInteractWith(EntityPlayer player) { - return false; - } - }, 3, 3); + InventoryCrafting aCrafting = new InventoryCrafting( + new Container() { + @Override + public boolean canInteractWith(EntityPlayer player) { + return false; + } + }, + 3, + 3); for (int i = 0; i < 9 && i < aRecipe.length; i++) aCrafting.setInventorySlotContents(i, aRecipe[i]); List<IRecipe> tList = CraftingManager.getInstance().getRecipeList(); synchronized (sAllRecipeList) { @@ -1407,8 +1668,14 @@ public class GT_ModHandler { if (tIndex == 2) { assert tStack1 != null && tStack2 != null; - if (tStack1.getItem() == tStack2.getItem() && tStack1.stackSize == 1 && tStack2.stackSize == 1 && tStack1.getItem().isRepairable()) { - int tNewDamage = tStack1.getMaxDamage() + tStack1.getItemDamage() - tStack2.getItemDamage() + tStack1.getMaxDamage() / 20; + if (tStack1.getItem() == tStack2.getItem() + && tStack1.stackSize == 1 + && tStack2.stackSize == 1 + && tStack1.getItem().isRepairable()) { + int tNewDamage = tStack1.getMaxDamage() + + tStack1.getItemDamage() + - tStack2.getItemDamage() + + tStack1.getMaxDamage() / 20; return new ItemStack(tStack1.getItem(), 1, tNewDamage < 0 ? 0 : tNewDamage); } } @@ -1425,7 +1692,7 @@ public class GT_ModHandler { } public static ItemStack getRecipeOutputNoOreDict(ItemStack... aRecipe) { - return getRecipeOutput(false,false, aRecipe); + return getRecipeOutput(false, false, aRecipe); } public static ItemStack getRecipeOutput(boolean aUncopiedStack, ItemStack... aRecipe) { @@ -1440,14 +1707,18 @@ public class GT_ModHandler { public static ItemStack getRecipeOutput(boolean aUncopiedStack, boolean allowOreDict, ItemStack... aRecipe) { if (aRecipe == null || Arrays.stream(aRecipe).noneMatch(Objects::nonNull)) return null; - InventoryCrafting aCrafting = new InventoryCrafting(new Container() { - @Override - public boolean canInteractWith(EntityPlayer player) { - return false; - } - }, 3, 3); + InventoryCrafting aCrafting = new InventoryCrafting( + new Container() { + @Override + public boolean canInteractWith(EntityPlayer player) { + return false; + } + }, + 3, + 3); for (int i = 0; i < 9 && i < aRecipe.length; i++) aCrafting.setInventorySlotContents(i, aRecipe[i]); - ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList(); + ArrayList<IRecipe> tList = + (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList(); boolean found = false; for (IRecipe iRecipe : tList) { @@ -1464,7 +1735,8 @@ public class GT_ModHandler { if (tOutput == null || tOutput.stackSize <= 0) { // Seriously, who would ever do that shit? if (!GregTech_API.sPostloadFinished) - throw new GT_ItsNotMyFaultException("Seems another Mod added a Crafting Recipe with null Output. Tell the Developer of said Mod to fix that."); + throw new GT_ItsNotMyFaultException( + "Seems another Mod added a Crafting Recipe with null Output. Tell the Developer of said Mod to fix that."); } else { if (aUncopiedStack) return tOutput; return GT_Utility.copyOrNull(tOutput); @@ -1483,15 +1755,26 @@ public class GT_ModHandler { if (!GregTech_API.sPostloadStarted || GregTech_API.sPostloadFinished) sSingleNonBlockDamagableRecipeList.clear(); if (sSingleNonBlockDamagableRecipeList.isEmpty()) { - for (IRecipe tRecipe : (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList()) { + for (IRecipe tRecipe : + (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList()) { ItemStack tStack = tRecipe.getRecipeOutput(); - if (GT_Utility.isStackValid(tStack) && tStack.getMaxStackSize() == 1 && tStack.getMaxDamage() > 0 && !(tStack.getItem() instanceof ItemBlock) && !(tStack.getItem() instanceof IReactorComponent) && !isElectricItem(tStack) && !GT_Utility.isStackInList(tStack, sNonReplaceableItems)) { + if (GT_Utility.isStackValid(tStack) + && tStack.getMaxStackSize() == 1 + && tStack.getMaxDamage() > 0 + && !(tStack.getItem() instanceof ItemBlock) + && !(tStack.getItem() instanceof IReactorComponent) + && !isElectricItem(tStack) + && !GT_Utility.isStackInList(tStack, sNonReplaceableItems)) { if (!(tRecipe instanceof ShapelessRecipes || tRecipe instanceof ShapelessOreRecipe)) { if (tRecipe instanceof ShapedOreRecipe) { boolean temp = true; for (Object tObject : ((ShapedOreRecipe) tRecipe).getInput()) if (tObject != null) { - if (tObject instanceof ItemStack && (((ItemStack) tObject).getItem() == null || ((ItemStack) tObject).getMaxStackSize() < 2 || ((ItemStack) tObject).getMaxDamage() > 0 || ((ItemStack) tObject).getItem() instanceof ItemBlock)) { + if (tObject instanceof ItemStack + && (((ItemStack) tObject).getItem() == null + || ((ItemStack) tObject).getMaxStackSize() < 2 + || ((ItemStack) tObject).getMaxDamage() > 0 + || ((ItemStack) tObject).getItem() instanceof ItemBlock)) { temp = false; break; } @@ -1504,7 +1787,11 @@ public class GT_ModHandler { } else if (tRecipe instanceof ShapedRecipes) { boolean temp = true; for (ItemStack tObject : ((ShapedRecipes) tRecipe).recipeItems) { - if (tObject != null && (tObject.getItem() == null || tObject.getMaxStackSize() < 2 || tObject.getMaxDamage() > 0 || tObject.getItem() instanceof ItemBlock)) { + if (tObject != null + && (tObject.getItem() == null + || tObject.getMaxStackSize() < 2 + || tObject.getMaxDamage() > 0 + || tObject.getItem() instanceof ItemBlock)) { temp = false; break; } @@ -1516,7 +1803,11 @@ public class GT_ModHandler { } } } - GT_Log.out.println("GT_Mod: Created a List of Tool Recipes containing " + sSingleNonBlockDamagableRecipeList.size() + " Recipes for recycling." + (sSingleNonBlockDamagableRecipeList.size() > 1024 ? " Scanning all these Recipes is the reason for the startup Lag you receive right now." : E)); + GT_Log.out.println("GT_Mod: Created a List of Tool Recipes containing " + + sSingleNonBlockDamagableRecipeList.size() + " Recipes for recycling." + + (sSingleNonBlockDamagableRecipeList.size() > 1024 + ? " Scanning all these Recipes is the reason for the startup Lag you receive right now." + : E)); } List<ItemStack> rList = getRecipeOutputs(sSingleNonBlockDamagableRecipeList, true, aRecipe); if (!GregTech_API.sPostloadStarted || GregTech_API.sPostloadFinished) @@ -1542,20 +1833,22 @@ public class GT_ModHandler { public static List<ItemStack> getRecipeOutputsBuffered(ItemStack... aRecipe) { if (bufferedRecipes == null) - bufferedRecipes = (List<IRecipe>) CraftingManager.getInstance().getRecipeList().stream().filter( - tRecipe -> !(tRecipe instanceof ShapelessRecipes) && !(tRecipe instanceof ShapelessOreRecipe) && !(tRecipe instanceof IGT_CraftingRecipe) - ) - .filter(tRecipe -> - { - try { - ItemStack tOutput = ((IRecipe) tRecipe).getRecipeOutput(); - if (tOutput.stackSize == 1 && tOutput.getMaxDamage() > 0 && tOutput.getMaxStackSize() == 1) { - return true; - } - } catch (Exception ignored) { - } - return false; - }) + bufferedRecipes = (List<IRecipe>) CraftingManager.getInstance().getRecipeList().stream() + .filter(tRecipe -> !(tRecipe instanceof ShapelessRecipes) + && !(tRecipe instanceof ShapelessOreRecipe) + && !(tRecipe instanceof IGT_CraftingRecipe)) + .filter(tRecipe -> { + try { + ItemStack tOutput = ((IRecipe) tRecipe).getRecipeOutput(); + if (tOutput.stackSize == 1 + && tOutput.getMaxDamage() > 0 + && tOutput.getMaxStackSize() == 1) { + return true; + } + } catch (Exception ignored) { + } + return false; + }) .collect(Collectors.toList()); return getRecipeOutputs(bufferedRecipes, false, aRecipe); } @@ -1566,59 +1859,66 @@ public class GT_ModHandler { */ public static List<ItemStack> getRecipeOutputs(List<IRecipe> aList, boolean aDeleteFromList, ItemStack... aRecipe) { List<ItemStack> rList = new ArrayList<>(); - if (aRecipe == null || Arrays.stream(aRecipe).noneMatch(Objects::nonNull)) - return rList; - InventoryCrafting aCrafting = new InventoryCrafting(new Container() { - @Override - public boolean canInteractWith(EntityPlayer player) { - return false; - } - }, 3, 3); - for (int i = 0; i < 9 && i < aRecipe.length; i++) - aCrafting.setInventorySlotContents(i, aRecipe[i]); + if (aRecipe == null || Arrays.stream(aRecipe).noneMatch(Objects::nonNull)) return rList; + InventoryCrafting aCrafting = new InventoryCrafting( + new Container() { + @Override + public boolean canInteractWith(EntityPlayer player) { + return false; + } + }, + 3, + 3); + for (int i = 0; i < 9 && i < aRecipe.length; i++) aCrafting.setInventorySlotContents(i, aRecipe[i]); if (!aDeleteFromList) { HashSet<ItemStack> stacks = new HashSet<>(); - aList.stream().filter( - tRecipe -> { - if (tRecipe instanceof ShapelessRecipes || tRecipe instanceof ShapelessOreRecipe || tRecipe instanceof IGT_CraftingRecipe) - return false; + aList.stream() + .filter(tRecipe -> { + if (tRecipe instanceof ShapelessRecipes + || tRecipe instanceof ShapelessOreRecipe + || tRecipe instanceof IGT_CraftingRecipe) return false; try { return tRecipe.matches(aCrafting, DW); } catch (Throwable e) { e.printStackTrace(GT_Log.err); return false; } - } - ).forEach(tRecipe -> stacks.add(tRecipe.getCraftingResult(aCrafting))); - rList = stacks.stream().filter(tOutput -> tOutput.stackSize == 1 && tOutput.getMaxDamage() > 0 && tOutput.getMaxStackSize() == 1).collect(Collectors.toList()); - } else for (Iterator<IRecipe> iterator = aList.iterator(); iterator.hasNext(); ) { - IRecipe tRecipe = iterator.next(); - boolean matched = false; - - try { - matched = tRecipe.matches(aCrafting, DW); - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - if (matched) { - ItemStack tOutput = tRecipe.getCraftingResult(aCrafting); + }) + .forEach(tRecipe -> stacks.add(tRecipe.getCraftingResult(aCrafting))); + rList = stacks.stream() + .filter(tOutput -> + tOutput.stackSize == 1 && tOutput.getMaxDamage() > 0 && tOutput.getMaxStackSize() == 1) + .collect(Collectors.toList()); + } else + for (Iterator<IRecipe> iterator = aList.iterator(); iterator.hasNext(); ) { + IRecipe tRecipe = iterator.next(); + boolean matched = false; - if (tOutput == null || tOutput.stackSize <= 0) { - // Seriously, who would ever do that shit? - if (!GregTech_API.sPostloadFinished) - throw new GT_ItsNotMyFaultException("Seems another Mod added a Crafting Recipe with null Output. Tell the Developer of said Mod to fix that."); - continue; + try { + matched = tRecipe.matches(aCrafting, DW); + } catch (Throwable e) { + e.printStackTrace(GT_Log.err); + } + if (matched) { + ItemStack tOutput = tRecipe.getCraftingResult(aCrafting); + + if (tOutput == null || tOutput.stackSize <= 0) { + // Seriously, who would ever do that shit? + if (!GregTech_API.sPostloadFinished) + throw new GT_ItsNotMyFaultException( + "Seems another Mod added a Crafting Recipe with null Output. Tell the Developer of said Mod to fix that."); + continue; + } + if (tOutput.stackSize != 1) continue; + if (tOutput.getMaxDamage() <= 0) continue; + if (tOutput.getMaxStackSize() != 1) continue; + if (tRecipe instanceof ShapelessRecipes) continue; + if (tRecipe instanceof ShapelessOreRecipe) continue; + if (tRecipe instanceof IGT_CraftingRecipe) continue; + rList.add(GT_Utility.copyOrNull(tOutput)); + iterator.remove(); } - if (tOutput.stackSize != 1) continue; - if (tOutput.getMaxDamage() <= 0) continue; - if (tOutput.getMaxStackSize() != 1) continue; - if (tRecipe instanceof ShapelessRecipes) continue; - if (tRecipe instanceof ShapelessOreRecipe) continue; - if (tRecipe instanceof IGT_CraftingRecipe) continue; - rList.add(GT_Utility.copyOrNull(tOutput)); - iterator.remove(); } - } return rList; } @@ -1627,7 +1927,8 @@ public class GT_ModHandler { */ @Deprecated public static ItemStack getMaceratorOutput(ItemStack aInput, boolean aRemoveInput, ItemStack aOutputSlot) { - return GT_Utility.copyOrNull(getMachineOutput(aInput, getMaceratorRecipeList(), aRemoveInput, new NBTTagCompound(), aOutputSlot)[0]); + return GT_Utility.copyOrNull( + getMachineOutput(aInput, getMaceratorRecipeList(), aRemoveInput, new NBTTagCompound(), aOutputSlot)[0]); } /** @@ -1635,7 +1936,8 @@ public class GT_ModHandler { */ @Deprecated public static ItemStack getExtractorOutput(ItemStack aInput, boolean aRemoveInput, ItemStack aOutputSlot) { - return GT_Utility.copyOrNull(getMachineOutput(aInput, getExtractorRecipeList(), aRemoveInput, new NBTTagCompound(), aOutputSlot)[0]); + return GT_Utility.copyOrNull( + getMachineOutput(aInput, getExtractorRecipeList(), aRemoveInput, new NBTTagCompound(), aOutputSlot)[0]); } /** @@ -1643,18 +1945,21 @@ public class GT_ModHandler { */ @Deprecated public static ItemStack getCompressorOutput(ItemStack aInput, boolean aRemoveInput, ItemStack aOutputSlot) { - return GT_Utility.copyOrNull(getMachineOutput(aInput, getCompressorRecipeList(), aRemoveInput, new NBTTagCompound(), aOutputSlot)[0]); + return GT_Utility.copyOrNull(getMachineOutput( + aInput, getCompressorRecipeList(), aRemoveInput, new NBTTagCompound(), aOutputSlot)[0]); } /** * Used in my own Furnace. */ public static ItemStack getSmeltingOutput(ItemStack aInput, boolean aRemoveInput, ItemStack aOutputSlot) { - if (aInput == null || aInput.stackSize < 1) - return null; + if (aInput == null || aInput.stackSize < 1) return null; ItemStack rStack = GT_OreDictUnificator.get(FurnaceRecipes.smelting().getSmeltingResult(aInput)); - if (rStack != null && (aOutputSlot == null || (GT_Utility.areStacksEqual(rStack, aOutputSlot) && rStack.stackSize + aOutputSlot.stackSize <= aOutputSlot.getMaxStackSize()))) { + if (rStack != null + && (aOutputSlot == null + || (GT_Utility.areStacksEqual(rStack, aOutputSlot) + && rStack.stackSize + aOutputSlot.stackSize <= aOutputSlot.getMaxStackSize()))) { if (aRemoveInput) aInput.stackSize--; return rStack; } @@ -1666,7 +1971,12 @@ public class GT_ModHandler { * <p/> * Checks also if there is enough Space in the Output Slots. */ - public static ItemStack[] getMachineOutput(ItemStack aInput, Map<IRecipeInput, RecipeOutput> aRecipeList, boolean aRemoveInput, NBTTagCompound rRecipeMetaData, ItemStack... aOutputSlots) { + public static ItemStack[] getMachineOutput( + ItemStack aInput, + Map<IRecipeInput, RecipeOutput> aRecipeList, + boolean aRemoveInput, + NBTTagCompound rRecipeMetaData, + ItemStack... aOutputSlots) { if (aOutputSlots == null || aOutputSlots.length <= 0) return new ItemStack[0]; if (aInput == null) return new ItemStack[aOutputSlots.length]; try { @@ -1679,7 +1989,10 @@ public class GT_ModHandler { rRecipeMetaData.setTag("return", tEntry.getValue().metadata); for (byte i = 0; i < aOutputSlots.length && i < tList.length; i++) { if (tList[i] != null) { - if (aOutputSlots[i] == null || (GT_Utility.areStacksEqual(tList[i], aOutputSlots[i]) && tList[i].stackSize + aOutputSlots[i].stackSize <= aOutputSlots[i].getMaxStackSize())) { + if (aOutputSlots[i] == null + || (GT_Utility.areStacksEqual(tList[i], aOutputSlots[i]) + && tList[i].stackSize + aOutputSlots[i].stackSize + <= aOutputSlots[i].getMaxStackSize())) { rList[i] = GT_Utility.copyOrNull(tList[i]); } else { return new ItemStack[aOutputSlots.length]; @@ -1711,10 +2024,14 @@ public class GT_ModHandler { if (ic2.api.recipe.Recipes.recyclerWhitelist.isEmpty()) return ic2.api.recipe.Recipes.recyclerBlacklist.contains(aInput) ? null : ItemList.IC2_Scrap.get(1); return ic2.api.recipe.Recipes.recyclerWhitelist.contains(aInput) ? ItemList.IC2_Scrap.get(1) : null; - } catch (Throwable e) {/*Do nothing*/} + } catch (Throwable e) { + /*Do nothing*/ + } try { return ic2.api.recipe.Recipes.recyclerBlacklist.contains(aInput) ? null : ItemList.IC2_Scrap.get(1); - } catch (Throwable e) {/*Do nothing*/} + } catch (Throwable e) { + /*Do nothing*/ + } return null; } @@ -1732,7 +2049,8 @@ public class GT_ModHandler { * * @return the actually used Energy. */ - public static int chargeElectricItem(ItemStack aStack, int aCharge, int aTier, boolean aIgnoreLimit, boolean aSimulate) { + public static int chargeElectricItem( + ItemStack aStack, int aCharge, int aTier, boolean aIgnoreLimit, boolean aSimulate) { try { if (isElectricItem(aStack)) { int tTier = ((ic2.api.item.IElectricItem) aStack.getItem()).getTier(aStack); @@ -1740,12 +2058,15 @@ public class GT_ModHandler { if (!aIgnoreLimit && tTier >= 0) aCharge = (int) Math.min(aCharge, V[Math.max(0, Math.min(V.length - 1, tTier))]); if (aCharge > 0) { - int rCharge = (int) Math.max(0.0, ic2.api.item.ElectricItem.manager.charge(aStack, aCharge, tTier, true, aSimulate)); + int rCharge = (int) Math.max( + 0.0, ic2.api.item.ElectricItem.manager.charge(aStack, aCharge, tTier, true, aSimulate)); return rCharge + (rCharge * 4 > aTier ? aTier : 0); } } } - } catch (Throwable e) {/*Do nothing*/} + } catch (Throwable e) { + /*Do nothing*/ + } return 0; } @@ -1756,22 +2077,43 @@ public class GT_ModHandler { * * @return the Energy got from the Item. */ - public static int dischargeElectricItem(ItemStack aStack, int aCharge, int aTier, boolean aIgnoreLimit, boolean aSimulate, boolean aIgnoreDischargability) { + public static int dischargeElectricItem( + ItemStack aStack, + int aCharge, + int aTier, + boolean aIgnoreLimit, + boolean aSimulate, + boolean aIgnoreDischargability) { try { -// if (isElectricItem(aStack) && (aIgnoreDischargability || ((ic2.api.item.IElectricItem)aStack.getItem()).canProvideEnergy(aStack))) { + // if (isElectricItem(aStack) && (aIgnoreDischargability || + // ((ic2.api.item.IElectricItem)aStack.getItem()).canProvideEnergy(aStack))) { if (isElectricItem(aStack)) { int tTier = ((ic2.api.item.IElectricItem) aStack.getItem()).getTier(aStack); if (tTier < 0 || tTier == aTier || aTier == Integer.MAX_VALUE) { if (!aIgnoreLimit && tTier >= 0) - aCharge = (int) Math.min(aCharge, V[Math.max(0, Math.min(V.length - 1, tTier))] + B[Math.max(0, Math.min(V.length - 1, tTier))]); + aCharge = (int) Math.min( + aCharge, + V[Math.max(0, Math.min(V.length - 1, tTier))] + + B[Math.max(0, Math.min(V.length - 1, tTier))]); if (aCharge > 0) { -// int rCharge = Math.max(0, ic2.api.item.ElectricItem.manager.discharge(aStack, aCharge + (aCharge * 4 > aTier ? aTier : 0), tTier, T, aSimulate)); - int rCharge = (int) Math.max(0, ic2.api.item.ElectricItem.manager.discharge(aStack, aCharge + (aCharge * 4 > aTier ? aTier : 0), tTier, true, !aIgnoreDischargability, aSimulate)); + // int rCharge = Math.max(0, ic2.api.item.ElectricItem.manager.discharge(aStack, aCharge + + // (aCharge * 4 > aTier ? aTier : 0), tTier, T, aSimulate)); + int rCharge = (int) Math.max( + 0, + ic2.api.item.ElectricItem.manager.discharge( + aStack, + aCharge + (aCharge * 4 > aTier ? aTier : 0), + tTier, + true, + !aIgnoreDischargability, + aSimulate)); return rCharge - (rCharge * 4 > aTier ? aTier : 0); } } } - } catch (Throwable e) {/*Do nothing*/} + } catch (Throwable e) { + /*Do nothing*/ + } return 0; } @@ -1785,7 +2127,9 @@ public class GT_ModHandler { if (isElectricItem(aStack)) { return ic2.api.item.ElectricItem.manager.canUse(aStack, aCharge); } - } catch (Throwable e) {/*Do nothing*/} + } catch (Throwable e) { + /*Do nothing*/ + } return false; } @@ -1802,7 +2146,9 @@ public class GT_ModHandler { return ic2.api.item.ElectricItem.manager.use(aStack, aCharge, aPlayer); } } - } catch (Throwable e) {/*Do nothing*/} + } catch (Throwable e) { + /*Do nothing*/ + } return false; } @@ -1820,7 +2166,8 @@ public class GT_ModHandler { if (aPlayer != null && aPlayer instanceof EntityPlayer) { return GT_ModHandler.useElectricItem(aStack, aDecharge, (EntityPlayer) aPlayer); } - return GT_ModHandler.dischargeElectricItem(aStack, aDecharge, Integer.MAX_VALUE, true, false, true) >= aDecharge; + return GT_ModHandler.dischargeElectricItem(aStack, aDecharge, Integer.MAX_VALUE, true, false, true) + >= aDecharge; } } else if (aStack.getItem().isDamageable()) { if (aPlayer == null) { @@ -1854,11 +2201,13 @@ public class GT_ModHandler { if (tPlayer.capabilities.isCreativeMode) return true; if (isElectricItem(aStack) && ic2.api.item.ElectricItem.manager.getCharge(aStack) > 1000.0d) { if (consumeSolderingMaterial(tPlayer) - || (aExternalInventory != null && consumeSolderingMaterial(aExternalInventory))) { - if (canUseElectricItem(aStack, 10000)) { + || (aExternalInventory != null && consumeSolderingMaterial(aExternalInventory))) { + if (canUseElectricItem(aStack, 10000)) { return GT_ModHandler.useElectricItem(aStack, 10000, (EntityPlayer) aPlayer); } - GT_ModHandler.useElectricItem(aStack, (int) ic2.api.item.ElectricItem.manager.getCharge(aStack), (EntityPlayer) aPlayer); + GT_ModHandler.useElectricItem( + aStack, (int) ic2.api.item.ElectricItem.manager.getCharge(aStack), (EntityPlayer) + aPlayer); return false; } } @@ -1875,7 +2224,7 @@ public class GT_ModHandler { } public static boolean consumeSolderingMaterial(EntityPlayer aPlayer) { - if (aPlayer.capabilities.isCreativeMode) return true; + if (aPlayer.capabilities.isCreativeMode) return true; if (consumeSolderingMaterial(aPlayer.inventory)) { if (aPlayer.inventoryContainer != null) { aPlayer.inventoryContainer.detectAndSendChanges(); @@ -1914,7 +2263,9 @@ public class GT_ModHandler { if (isElectricItem(aStack)) { return ((ic2.api.item.IElectricItem) aStack.getItem()).canProvideEnergy(aStack); } - } catch (Throwable e) {/*Do nothing*/} + } catch (Throwable e) { + /*Do nothing*/ + } return false; } @@ -1923,15 +2274,23 @@ public class GT_ModHandler { */ public static boolean isElectricItem(ItemStack aStack) { try { - return aStack != null && aStack.getItem() instanceof ic2.api.item.IElectricItem && ((IElectricItem) aStack.getItem()).getTier(aStack) < Integer.MAX_VALUE; - } catch (Throwable e) {/*Do nothing*/} + return aStack != null + && aStack.getItem() instanceof ic2.api.item.IElectricItem + && ((IElectricItem) aStack.getItem()).getTier(aStack) < Integer.MAX_VALUE; + } catch (Throwable e) { + /*Do nothing*/ + } return false; } public static boolean isElectricItem(ItemStack aStack, byte aTier) { try { - return aStack != null && aStack.getItem() instanceof ic2.api.item.IElectricItem && ((IElectricItem) aStack.getItem()).getTier(aStack) == aTier; - } catch (Throwable e) {/*Do nothing*/} + return aStack != null + && aStack.getItem() instanceof ic2.api.item.IElectricItem + && ((IElectricItem) aStack.getItem()).getTier(aStack) == aTier; + } catch (Throwable e) { + /*Do nothing*/ + } return false; } @@ -1942,7 +2301,9 @@ public class GT_ModHandler { if (aStack != null) { try { ic2.api.item.ItemWrapper.registerBoxable(aStack.getItem(), (IBoxable) sBoxableWrapper); - } catch (Throwable ignored) {/*Do nothing*/} + } catch (Throwable ignored) { + /*Do nothing*/ + } sBoxableItems.add(new GT_ItemStack(aStack)); } } @@ -2042,58 +2403,56 @@ public class GT_ModHandler { * Copy of the original Helper Class of Thermal Expansion, just to make sure it works even when other Mods include TE-APIs */ public static class ThermalExpansion { - public static void addFurnaceRecipe(int energy, ItemStack input, ItemStack output) { + public static void addFurnaceRecipe(int energy, ItemStack input, ItemStack output) {} - } - - public static void addPulverizerRecipe(int energy, ItemStack input, ItemStack primaryOutput) { - } - - public static void addPulverizerRecipe(int energy, ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput) { - } + public static void addPulverizerRecipe(int energy, ItemStack input, ItemStack primaryOutput) {} - public static void addPulverizerRecipe(int energy, ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput, int secondaryChance) { - } + public static void addPulverizerRecipe( + int energy, ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput) {} - public static void addSawmillRecipe(int energy, ItemStack input, ItemStack primaryOutput) { - } + public static void addPulverizerRecipe( + int energy, ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput, int secondaryChance) {} - public static void addSawmillRecipe(int energy, ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput) { - } + public static void addSawmillRecipe(int energy, ItemStack input, ItemStack primaryOutput) {} - public static void addSawmillRecipe(int energy, ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput, int secondaryChance) { - - } + public static void addSawmillRecipe( + int energy, ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput) {} - public static void addSmelterRecipe(int energy, ItemStack primaryInput, ItemStack secondaryInput, ItemStack primaryOutput) { - } + public static void addSawmillRecipe( + int energy, ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput, int secondaryChance) {} - public static void addSmelterRecipe(int energy, ItemStack primaryInput, ItemStack secondaryInput, ItemStack primaryOutput, ItemStack secondaryOutput) { - } + public static void addSmelterRecipe( + int energy, ItemStack primaryInput, ItemStack secondaryInput, ItemStack primaryOutput) {} - public static void addSmelterRecipe(int energy, ItemStack primaryInput, ItemStack secondaryInput, ItemStack primaryOutput, ItemStack secondaryOutput, int secondaryChance) { + public static void addSmelterRecipe( + int energy, + ItemStack primaryInput, + ItemStack secondaryInput, + ItemStack primaryOutput, + ItemStack secondaryOutput) {} - } + public static void addSmelterRecipe( + int energy, + ItemStack primaryInput, + ItemStack secondaryInput, + ItemStack primaryOutput, + ItemStack secondaryOutput, + int secondaryChance) {} - public static void addSmelterBlastOre(Materials aMaterial) { - } + public static void addSmelterBlastOre(Materials aMaterial) {} - public static void addCrucibleRecipe(int energy, ItemStack input, FluidStack output) { - } + public static void addCrucibleRecipe(int energy, ItemStack input, FluidStack output) {} - public static void addTransposerFill(int energy, ItemStack input, ItemStack output, FluidStack fluid, boolean reversible) { - } + public static void addTransposerFill( + int energy, ItemStack input, ItemStack output, FluidStack fluid, boolean reversible) {} - public static void addTransposerExtract(int energy, ItemStack input, ItemStack output, FluidStack fluid, int chance, boolean reversible) { - } + public static void addTransposerExtract( + int energy, ItemStack input, ItemStack output, FluidStack fluid, int chance, boolean reversible) {} - public static void addMagmaticFuel(String fluidName, int energy) { - } + public static void addMagmaticFuel(String fluidName, int energy) {} - public static void addCompressionFuel(String fluidName, int energy) { - } + public static void addCompressionFuel(String fluidName, int energy) {} - public static void addCoolant(String fluidName, int energy) { - } + public static void addCoolant(String fluidName, int energy) {} } } diff --git a/src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java b/src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java index 197d2bdaa5..626ca2690f 100644 --- a/src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java +++ b/src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java @@ -3,16 +3,14 @@ package gregtech.api.util; import com.google.common.collect.Multimaps; import com.google.common.collect.SetMultimap; import com.gtnewhorizon.structurelib.StructureLibAPI; -import gregtech.api.enums.Materials; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.StatCollector; - import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.stream.IntStream; import java.util.stream.Stream; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; /** * This makes it easier to build multi tooltips, with a standardized format. <br> @@ -38,433 +36,437 @@ import java.util.stream.Stream; * Originally created by kekzdealer */ public class GT_Multiblock_Tooltip_Builder { - private static final String TAB = " "; - private static final String COLON = ": "; - private static final String SEPARATOR = ", "; - - private final List<String> iLines; - private final List<String> sLines; - private final List<String> hLines; - private final SetMultimap<Integer, String> hBlocks; - - private String[] iArray; - private String[] sArray; - private String[] hArray; - - //Localized tooltips - private static final String TT_machineType = StatCollector.translateToLocal("GT5U.MBTT.MachineType"); - private static final String TT_dimensions = StatCollector.translateToLocal("GT5U.MBTT.Dimensions"); - private static final String TT_hollow = StatCollector.translateToLocal("GT5U.MBTT.Hollow"); - private static final String TT_structure = StatCollector.translateToLocal("GT5U.MBTT.Structure"); - private static final String TT_controller = StatCollector.translateToLocal("GT5U.MBTT.Controller"); - private static final String TT_minimum = StatCollector.translateToLocal("GT5U.MBTT.Minimum"); - private static final String TT_maintenancehatch = StatCollector.translateToLocal("GT5U.MBTT.MaintenanceHatch"); - private static final String TT_energyhatch = StatCollector.translateToLocal("GT5U.MBTT.EnergyHatch"); - private static final String TT_dynamohatch = StatCollector.translateToLocal("GT5U.MBTT.DynamoHatch"); - private static final String TT_mufflerhatch = StatCollector.translateToLocal("GT5U.MBTT.MufflerHatch"); - private static final String TT_inputbus = StatCollector.translateToLocal("GT5U.MBTT.InputBus"); - private static final String TT_inputhatch = StatCollector.translateToLocal("GT5U.MBTT.InputHatch"); - private static final String TT_outputbus = StatCollector.translateToLocal("GT5U.MBTT.OutputBus"); - private static final String TT_outputhatch = StatCollector.translateToLocal("GT5U.MBTT.OutputHatch"); - private static final String TT_causes = StatCollector.translateToLocal("GT5U.MBTT.Causes"); - private static final String TT_pps = StatCollector.translateToLocal("GT5U.MBTT.PPS"); - private static final String TT_hold = StatCollector.translateToLocal("GT5U.MBTT.Hold"); - private static final String TT_todisplay = StatCollector.translateToLocal("GT5U.MBTT.Display"); - private static final String TT_structurehint = StatCollector.translateToLocal("GT5U.MBTT.StructureHint"); - private static final String TT_mod = StatCollector.translateToLocal("GT5U.MBTT.Mod"); - private static final String TT_air = StatCollector.translateToLocal("GT5U.MBTT.Air"); - private static final String[] TT_dots = IntStream.range(0, 16).mapToObj(i -> StatCollector.translateToLocal("structurelib.blockhint." + i + ".name")).toArray(String[]::new); - - public GT_Multiblock_Tooltip_Builder() { - iLines = new LinkedList<>(); - sLines = new LinkedList<>(); - hLines = new LinkedList<>(); - hBlocks = Multimaps.newSetMultimap(new HashMap<>(), HashSet::new); - hBlocks.put(StructureLibAPI.HINT_BLOCK_META_AIR, TT_air); - } - - /** - * Add a line telling you what the machine type is. Usually, this will be the name of a SB version.<br> - * Machine Type: machine - * - * @param machine - * Name of the machine type - * - * @return Instance this method was called on. - */ - public GT_Multiblock_Tooltip_Builder addMachineType(String machine) { - iLines.add(TT_machineType + COLON + EnumChatFormatting.YELLOW + machine + EnumChatFormatting.RESET); - return this; - } - - /** - * Add a basic line of information about this structure - * - * @param info - * The line to be added. - * @return Instance this method was called on. - */ - public GT_Multiblock_Tooltip_Builder addInfo(String info) { - iLines.add(info); - return this; - } - - /** - * Add a separator line like this:<br> - * ----------------------------------------- - * - * @return Instance this method was called on. - */ - public GT_Multiblock_Tooltip_Builder addSeparator() { - iLines.add("-----------------------------------------"); - return this; - } - - /** - * Add a line telling how much this machine pollutes. - * - * @param pollution - * Amount of pollution per second when active - * - * @return Instance this method was called on. - */ - public GT_Multiblock_Tooltip_Builder addPollutionAmount(int pollution) { - iLines.add(TT_causes + COLON + EnumChatFormatting.DARK_PURPLE + pollution + " " + EnumChatFormatting.GRAY + TT_pps); - return this; - } - - /** - * Begin adding structural information by adding a line about the structure's dimensions - * and then inserting a "Structure:" line. - * - * @param w - * Structure width. - * @param h - * Structure height. - * @param l - * Structure depth/length. - * @param hollow - * T/F, adds a (hollow) comment if true - * @return Instance this method was called on. - */ - public GT_Multiblock_Tooltip_Builder beginStructureBlock(int w, int h, int l, boolean hollow) { - if (hollow) { - sLines.add(TT_dimensions + COLON + w + "x" + h + "x" + l + " (WxHxL) " + TT_hollow); - } - else { - sLines.add(TT_dimensions + COLON + w + "x" + h + "x" + l + " (WxHxL)"); - } - sLines.add(TT_structure + COLON); - return this; - } - - /** - * Begin adding structural information by adding a line about the structure's dimensions<br> - * and then inserting a "Structure:" line. Variable version displays min and max - * - * @param wmin - * Structure min width. - * @param wmax - * Structure max width. - * @param hmin - * Structure min height. - * @param hmax - * Structure max height. - * @param lmin - * Structure min depth/length. - * @param lmax - * Structure max depth/length. - * @param hollow - * T/F, adds a (hollow) comment if true - * @return Instance this method was called on. - */ - public GT_Multiblock_Tooltip_Builder beginVariableStructureBlock(int wmin, int wmax, int hmin, int hmax, int lmin, int lmax, boolean hollow) { - if (hollow) { - sLines.add(TT_dimensions + COLON + wmin + "-" + wmax + "x" + hmin + "-" + hmax + "x" + lmin + "-" + lmax + " (WxHxL) " + TT_hollow); - } - else { - sLines.add(TT_dimensions + COLON + wmin + "-" + wmax + "x" + hmin + "-" + hmax + "x" + lmin + "-" + lmax + " (WxHxL)"); - } - sLines.add(TT_structure + COLON); - return this; - } - - /** - * Add a line of information about the structure:<br> - * (indent)Controller: info - * @param info - * Positional information. - * @return Instance this method was called on. - */ - public GT_Multiblock_Tooltip_Builder addController(String info) { - sLines.add(TAB + TT_controller + COLON + info); - return this; - } - - /** - * Add a line of information about the structure:<br> - * (indent)minCountx casingName (minimum) - * @param casingName - * Name of the Casing. - * @param minCount - * Minimum needed for valid structure check. - * @return Instance this method was called on. - */ - public GT_Multiblock_Tooltip_Builder addCasingInfo(String casingName, int minCount) { - sLines.add(TAB + minCount +"x " + casingName + " " + TT_minimum); - return this; - } - - /** - * Use this method to add a structural part that isn't covered by the other methods.<br> - * (indent)name: info - * @param name - * Name of the hatch or other component. - * @param info - * Positional information. - * @return Instance this method was called on. - */ - public GT_Multiblock_Tooltip_Builder addOtherStructurePart(String name, String info) { - sLines.add(TAB + name + COLON + info); - return this; - } - - /** - * Add a line of information about the structure:<br> - * (indent)Maintenance Hatch: info - * @param info - * Positional information. - * @return Instance this method was called on. - */ - public GT_Multiblock_Tooltip_Builder addMaintenanceHatch(String info) { - sLines.add(TAB + TT_maintenancehatch + COLON + info); - return this; - } - - /** - * Add a line of information about the structure:<br> - * (indent)Muffler Hatch: info - * @param info - * Location where the hatch goes - * @return Instance this method was called on. - */ - public GT_Multiblock_Tooltip_Builder addMufflerHatch(String info) { - sLines.add(TAB + TT_mufflerhatch + COLON + info); - return this; - } - - /** - * Add a line of information about the structure:<br> - * (indent)Energy Hatch: info - * @param info - * Positional information. - * @return Instance this method was called on. - */ - public GT_Multiblock_Tooltip_Builder addEnergyHatch(String info) { - sLines.add(TAB + TT_energyhatch + COLON + info); - return this; - } - - /** - * Add a line of information about the structure:<br> - * (indent)Dynamo Hatch: info - * @param info - * Positional information. - * @return Instance this method was called on. - */ - public GT_Multiblock_Tooltip_Builder addDynamoHatch(String info) { - sLines.add(TAB + TT_dynamohatch + COLON + info); - return this; - } - - /** - * Add a line of information about the structure:<br> - * (indent)Input Bus: info - * @param info - * Location where the bus goes - * @return Instance this method was called on. - */ - public GT_Multiblock_Tooltip_Builder addInputBus(String info) { - sLines.add(TAB + TT_inputbus + COLON + info); - return this; - } - - /** - * Add a line of information about the structure:<br> - * (indent)Input Hatch: info - * @param info - * Location where the hatch goes - * @return Instance this method was called on. - */ - public GT_Multiblock_Tooltip_Builder addInputHatch(String info) { - sLines.add(TAB + TT_inputhatch + COLON + info); - return this; - } - - /** - * Add a line of information about the structure:<br> - * (indent)Output Bus: info - * @param info - * Location where the bus goes - * @return Instance this method was called on. - */ - public GT_Multiblock_Tooltip_Builder addOutputBus(String info) { - sLines.add(TAB + TT_outputbus + COLON + info); - return this; - } - - /** - * Add a line of information about the structure:<br> - * (indent)Output Hatch: info - * @param info - * Location where the bus goes - * @return Instance this method was called on. - */ - public GT_Multiblock_Tooltip_Builder addOutputHatch(String info) { - sLines.add(TAB + TT_outputhatch + COLON + info); - return this; - } - - /** - * Use this method to add a structural part that isn't covered by the other methods.<br> - * (indent)name: info - * @param name - * Name of the hatch or other component. - * @param info - * Positional information. - * @param dots - * The valid locations for this part when asked to display hints - * @return Instance this method was called on. - */ - public GT_Multiblock_Tooltip_Builder addOtherStructurePart(String name, String info, int... dots) { - sLines.add(TAB + name + COLON + info); - for (int dot : dots) hBlocks.put(dot, name); - return this; - } - - /** - * Add a line of information about the structure:<br> - * (indent)Maintenance Hatch: info - * - * @param info Positional information. - * @param dots The valid locations for this part when asked to display hints - * @return Instance this method was called on. - */ - public GT_Multiblock_Tooltip_Builder addMaintenanceHatch(String info, int... dots) { - sLines.add(TAB + TT_maintenancehatch + COLON + info); - for (int dot : dots) hBlocks.put(dot, TT_maintenancehatch); - return this; - } - - /** - * Add a line of information about the structure:<br> - * (indent)Muffler Hatch: info - * - * @param info Location where the hatch goes - * @param dots The valid locations for this part when asked to display hints - * @return Instance this method was called on. - */ - public GT_Multiblock_Tooltip_Builder addMufflerHatch(String info, int... dots) { - sLines.add(TAB + TT_mufflerhatch + COLON + info); - for (int dot : dots) hBlocks.put(dot, TT_mufflerhatch); - return this; - } - - /** - * Add a line of information about the structure:<br> - * (indent)Energy Hatch: info - * - * @param info Positional information. - * @param dots The valid locations for this part when asked to display hints - * @return Instance this method was called on. - */ - public GT_Multiblock_Tooltip_Builder addEnergyHatch(String info, int... dots) { - sLines.add(TAB + TT_energyhatch + COLON + info); - for (int dot : dots) hBlocks.put(dot, TT_energyhatch); - return this; - } - - /** - * Add a line of information about the structure:<br> - * (indent)Dynamo Hatch: info - * - * @param info Positional information. - * @param dots The valid locations for this part when asked to display hints - * @return Instance this method was called on. - */ - public GT_Multiblock_Tooltip_Builder addDynamoHatch(String info, int... dots) { - sLines.add(TAB + TT_dynamohatch + COLON + info); - for (int dot : dots) hBlocks.put(dot, TT_dynamohatch); - return this; - } - - /** - * Add a line of information about the structure:<br> - * (indent)Input Bus: info - * - * @param info Location where the bus goes - * @param dots The valid locations for this part when asked to display hints - * @return Instance this method was called on. - */ - public GT_Multiblock_Tooltip_Builder addInputBus(String info, int... dots) { - sLines.add(TAB + TT_inputbus + COLON + info); - for (int dot : dots) hBlocks.put(dot, TT_inputbus); - return this; - } - - /** - * Add a line of information about the structure:<br> - * (indent)Input Hatch: info - * - * @param info Location where the hatch goes - * @param dots The valid locations for this part when asked to display hints - * @return Instance this method was called on. - */ - public GT_Multiblock_Tooltip_Builder addInputHatch(String info, int... dots) { - sLines.add(TAB + TT_inputhatch + COLON + info); - for (int dot : dots) hBlocks.put(dot, TT_inputhatch); - return this; - } - - /** - * Add a line of information about the structure:<br> - * (indent)Output Bus: info - * - * @param info Location where the bus goes - * @param dots The valid locations for this part when asked to display hints - * @return Instance this method was called on. - */ - public GT_Multiblock_Tooltip_Builder addOutputBus(String info, int... dots) { - sLines.add(TAB + TT_outputbus + COLON + info); - for (int dot : dots) hBlocks.put(dot, TT_outputbus); - return this; - } - - /** - * Add a line of information about the structure:<br> - * (indent)Output Hatch: info - * - * @param info Location where the bus goes - * @param dots The valid locations for this part when asked to display hints - * @return Instance this method was called on. - */ - public GT_Multiblock_Tooltip_Builder addOutputHatch(String info, int... dots) { - sLines.add(TAB + TT_outputhatch + COLON + info); - for (int dot : dots) hBlocks.put(dot, TT_outputhatch); - return this; - } - - /** - * Use this method to add non-standard structural info.<br> - * (indent)info - * @param info - * The line to be added. - * @return Instance this method was called on. - */ - public GT_Multiblock_Tooltip_Builder addStructureInfo(String info) { - sLines.add(TAB + info); - return this; - } + private static final String TAB = " "; + private static final String COLON = ": "; + private static final String SEPARATOR = ", "; + + private final List<String> iLines; + private final List<String> sLines; + private final List<String> hLines; + private final SetMultimap<Integer, String> hBlocks; + + private String[] iArray; + private String[] sArray; + private String[] hArray; + + // Localized tooltips + private static final String TT_machineType = StatCollector.translateToLocal("GT5U.MBTT.MachineType"); + private static final String TT_dimensions = StatCollector.translateToLocal("GT5U.MBTT.Dimensions"); + private static final String TT_hollow = StatCollector.translateToLocal("GT5U.MBTT.Hollow"); + private static final String TT_structure = StatCollector.translateToLocal("GT5U.MBTT.Structure"); + private static final String TT_controller = StatCollector.translateToLocal("GT5U.MBTT.Controller"); + private static final String TT_minimum = StatCollector.translateToLocal("GT5U.MBTT.Minimum"); + private static final String TT_maintenancehatch = StatCollector.translateToLocal("GT5U.MBTT.MaintenanceHatch"); + private static final String TT_energyhatch = StatCollector.translateToLocal("GT5U.MBTT.EnergyHatch"); + private static final String TT_dynamohatch = StatCollector.translateToLocal("GT5U.MBTT.DynamoHatch"); + private static final String TT_mufflerhatch = StatCollector.translateToLocal("GT5U.MBTT.MufflerHatch"); + private static final String TT_inputbus = StatCollector.translateToLocal("GT5U.MBTT.InputBus"); + private static final String TT_inputhatch = StatCollector.translateToLocal("GT5U.MBTT.InputHatch"); + private static final String TT_outputbus = StatCollector.translateToLocal("GT5U.MBTT.OutputBus"); + private static final String TT_outputhatch = StatCollector.translateToLocal("GT5U.MBTT.OutputHatch"); + private static final String TT_causes = StatCollector.translateToLocal("GT5U.MBTT.Causes"); + private static final String TT_pps = StatCollector.translateToLocal("GT5U.MBTT.PPS"); + private static final String TT_hold = StatCollector.translateToLocal("GT5U.MBTT.Hold"); + private static final String TT_todisplay = StatCollector.translateToLocal("GT5U.MBTT.Display"); + private static final String TT_structurehint = StatCollector.translateToLocal("GT5U.MBTT.StructureHint"); + private static final String TT_mod = StatCollector.translateToLocal("GT5U.MBTT.Mod"); + private static final String TT_air = StatCollector.translateToLocal("GT5U.MBTT.Air"); + private static final String[] TT_dots = IntStream.range(0, 16) + .mapToObj(i -> StatCollector.translateToLocal("structurelib.blockhint." + i + ".name")) + .toArray(String[]::new); + + public GT_Multiblock_Tooltip_Builder() { + iLines = new LinkedList<>(); + sLines = new LinkedList<>(); + hLines = new LinkedList<>(); + hBlocks = Multimaps.newSetMultimap(new HashMap<>(), HashSet::new); + hBlocks.put(StructureLibAPI.HINT_BLOCK_META_AIR, TT_air); + } + + /** + * Add a line telling you what the machine type is. Usually, this will be the name of a SB version.<br> + * Machine Type: machine + * + * @param machine + * Name of the machine type + * + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addMachineType(String machine) { + iLines.add(TT_machineType + COLON + EnumChatFormatting.YELLOW + machine + EnumChatFormatting.RESET); + return this; + } + + /** + * Add a basic line of information about this structure + * + * @param info + * The line to be added. + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addInfo(String info) { + iLines.add(info); + return this; + } + + /** + * Add a separator line like this:<br> + * ----------------------------------------- + * + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addSeparator() { + iLines.add("-----------------------------------------"); + return this; + } + + /** + * Add a line telling how much this machine pollutes. + * + * @param pollution + * Amount of pollution per second when active + * + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addPollutionAmount(int pollution) { + iLines.add(TT_causes + COLON + EnumChatFormatting.DARK_PURPLE + pollution + " " + EnumChatFormatting.GRAY + + TT_pps); + return this; + } + + /** + * Begin adding structural information by adding a line about the structure's dimensions + * and then inserting a "Structure:" line. + * + * @param w + * Structure width. + * @param h + * Structure height. + * @param l + * Structure depth/length. + * @param hollow + * T/F, adds a (hollow) comment if true + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder beginStructureBlock(int w, int h, int l, boolean hollow) { + if (hollow) { + sLines.add(TT_dimensions + COLON + w + "x" + h + "x" + l + " (WxHxL) " + TT_hollow); + } else { + sLines.add(TT_dimensions + COLON + w + "x" + h + "x" + l + " (WxHxL)"); + } + sLines.add(TT_structure + COLON); + return this; + } + + /** + * Begin adding structural information by adding a line about the structure's dimensions<br> + * and then inserting a "Structure:" line. Variable version displays min and max + * + * @param wmin + * Structure min width. + * @param wmax + * Structure max width. + * @param hmin + * Structure min height. + * @param hmax + * Structure max height. + * @param lmin + * Structure min depth/length. + * @param lmax + * Structure max depth/length. + * @param hollow + * T/F, adds a (hollow) comment if true + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder beginVariableStructureBlock( + int wmin, int wmax, int hmin, int hmax, int lmin, int lmax, boolean hollow) { + if (hollow) { + sLines.add(TT_dimensions + COLON + wmin + "-" + wmax + "x" + hmin + "-" + hmax + "x" + lmin + "-" + lmax + + " (WxHxL) " + TT_hollow); + } else { + sLines.add(TT_dimensions + COLON + wmin + "-" + wmax + "x" + hmin + "-" + hmax + "x" + lmin + "-" + lmax + + " (WxHxL)"); + } + sLines.add(TT_structure + COLON); + return this; + } + + /** + * Add a line of information about the structure:<br> + * (indent)Controller: info + * @param info + * Positional information. + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addController(String info) { + sLines.add(TAB + TT_controller + COLON + info); + return this; + } + + /** + * Add a line of information about the structure:<br> + * (indent)minCountx casingName (minimum) + * @param casingName + * Name of the Casing. + * @param minCount + * Minimum needed for valid structure check. + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addCasingInfo(String casingName, int minCount) { + sLines.add(TAB + minCount + "x " + casingName + " " + TT_minimum); + return this; + } + + /** + * Use this method to add a structural part that isn't covered by the other methods.<br> + * (indent)name: info + * @param name + * Name of the hatch or other component. + * @param info + * Positional information. + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addOtherStructurePart(String name, String info) { + sLines.add(TAB + name + COLON + info); + return this; + } + + /** + * Add a line of information about the structure:<br> + * (indent)Maintenance Hatch: info + * @param info + * Positional information. + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addMaintenanceHatch(String info) { + sLines.add(TAB + TT_maintenancehatch + COLON + info); + return this; + } + + /** + * Add a line of information about the structure:<br> + * (indent)Muffler Hatch: info + * @param info + * Location where the hatch goes + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addMufflerHatch(String info) { + sLines.add(TAB + TT_mufflerhatch + COLON + info); + return this; + } + + /** + * Add a line of information about the structure:<br> + * (indent)Energy Hatch: info + * @param info + * Positional information. + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addEnergyHatch(String info) { + sLines.add(TAB + TT_energyhatch + COLON + info); + return this; + } + + /** + * Add a line of information about the structure:<br> + * (indent)Dynamo Hatch: info + * @param info + * Positional information. + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addDynamoHatch(String info) { + sLines.add(TAB + TT_dynamohatch + COLON + info); + return this; + } + + /** + * Add a line of information about the structure:<br> + * (indent)Input Bus: info + * @param info + * Location where the bus goes + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addInputBus(String info) { + sLines.add(TAB + TT_inputbus + COLON + info); + return this; + } + + /** + * Add a line of information about the structure:<br> + * (indent)Input Hatch: info + * @param info + * Location where the hatch goes + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addInputHatch(String info) { + sLines.add(TAB + TT_inputhatch + COLON + info); + return this; + } + + /** + * Add a line of information about the structure:<br> + * (indent)Output Bus: info + * @param info + * Location where the bus goes + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addOutputBus(String info) { + sLines.add(TAB + TT_outputbus + COLON + info); + return this; + } + + /** + * Add a line of information about the structure:<br> + * (indent)Output Hatch: info + * @param info + * Location where the bus goes + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addOutputHatch(String info) { + sLines.add(TAB + TT_outputhatch + COLON + info); + return this; + } + + /** + * Use this method to add a structural part that isn't covered by the other methods.<br> + * (indent)name: info + * @param name + * Name of the hatch or other component. + * @param info + * Positional information. + * @param dots + * The valid locations for this part when asked to display hints + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addOtherStructurePart(String name, String info, int... dots) { + sLines.add(TAB + name + COLON + info); + for (int dot : dots) hBlocks.put(dot, name); + return this; + } + + /** + * Add a line of information about the structure:<br> + * (indent)Maintenance Hatch: info + * + * @param info Positional information. + * @param dots The valid locations for this part when asked to display hints + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addMaintenanceHatch(String info, int... dots) { + sLines.add(TAB + TT_maintenancehatch + COLON + info); + for (int dot : dots) hBlocks.put(dot, TT_maintenancehatch); + return this; + } + + /** + * Add a line of information about the structure:<br> + * (indent)Muffler Hatch: info + * + * @param info Location where the hatch goes + * @param dots The valid locations for this part when asked to display hints + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addMufflerHatch(String info, int... dots) { + sLines.add(TAB + TT_mufflerhatch + COLON + info); + for (int dot : dots) hBlocks.put(dot, TT_mufflerhatch); + return this; + } + + /** + * Add a line of information about the structure:<br> + * (indent)Energy Hatch: info + * + * @param info Positional information. + * @param dots The valid locations for this part when asked to display hints + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addEnergyHatch(String info, int... dots) { + sLines.add(TAB + TT_energyhatch + COLON + info); + for (int dot : dots) hBlocks.put(dot, TT_energyhatch); + return this; + } + + /** + * Add a line of information about the structure:<br> + * (indent)Dynamo Hatch: info + * + * @param info Positional information. + * @param dots The valid locations for this part when asked to display hints + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addDynamoHatch(String info, int... dots) { + sLines.add(TAB + TT_dynamohatch + COLON + info); + for (int dot : dots) hBlocks.put(dot, TT_dynamohatch); + return this; + } + + /** + * Add a line of information about the structure:<br> + * (indent)Input Bus: info + * + * @param info Location where the bus goes + * @param dots The valid locations for this part when asked to display hints + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addInputBus(String info, int... dots) { + sLines.add(TAB + TT_inputbus + COLON + info); + for (int dot : dots) hBlocks.put(dot, TT_inputbus); + return this; + } + + /** + * Add a line of information about the structure:<br> + * (indent)Input Hatch: info + * + * @param info Location where the hatch goes + * @param dots The valid locations for this part when asked to display hints + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addInputHatch(String info, int... dots) { + sLines.add(TAB + TT_inputhatch + COLON + info); + for (int dot : dots) hBlocks.put(dot, TT_inputhatch); + return this; + } + + /** + * Add a line of information about the structure:<br> + * (indent)Output Bus: info + * + * @param info Location where the bus goes + * @param dots The valid locations for this part when asked to display hints + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addOutputBus(String info, int... dots) { + sLines.add(TAB + TT_outputbus + COLON + info); + for (int dot : dots) hBlocks.put(dot, TT_outputbus); + return this; + } + + /** + * Add a line of information about the structure:<br> + * (indent)Output Hatch: info + * + * @param info Location where the bus goes + * @param dots The valid locations for this part when asked to display hints + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addOutputHatch(String info, int... dots) { + sLines.add(TAB + TT_outputhatch + COLON + info); + for (int dot : dots) hBlocks.put(dot, TT_outputhatch); + return this; + } + + /** + * Use this method to add non-standard structural info.<br> + * (indent)info + * @param info + * The line to be added. + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addStructureInfo(String info) { + sLines.add(TAB + info); + return this; + } /** * Use this method to add non-standard structural info.<br> @@ -478,57 +480,62 @@ public class GT_Multiblock_Tooltip_Builder { return this; } - /** - * Use this method to add non-standard structural hint. This info will appear before the standard structural hint. - * @param info - * The line to be added. This should be an entry into minecraft's localization system. - * @return Instance this method was called on. - */ - public GT_Multiblock_Tooltip_Builder addStructureHint(String info) { - hLines.add(StatCollector.translateToLocal(info)); - return this; - } - - /** - * Use this method to add an entry to standard structural hint without creating a corresponding line in structure information - * @param name - * The name of block This should be an entry into minecraft's localization system. - * @param dots - * Possible locations of this block - * @return Instance this method was called on. - */ - public GT_Multiblock_Tooltip_Builder addStructureHint(String name, int... dots) { - for (int dot : dots) hBlocks.put(dot, StatCollector.translateToLocal(name)); - return this; - } - - /** - * Call at the very end.<br> - * Adds a final line with the mod name and information on how to display the structure guidelines.<br> - * Ends the building process. - * - * @param mod - * Name of the mod that adds this multiblock machine - */ - public void toolTipFinisher(String mod) { - iLines.add(TT_hold + " " + EnumChatFormatting.BOLD + "[LSHIFT]" + EnumChatFormatting.RESET + EnumChatFormatting.GRAY + " " + TT_todisplay); - iLines.add(TT_mod + COLON + EnumChatFormatting.GREEN + mod + EnumChatFormatting.GRAY); - hLines.add(TT_structurehint); - iArray = iLines.toArray(new String[0]); - sArray = sLines.toArray(new String[0]); - // e.getKey() - 1 because 1 dot is meta 0. - hArray = Stream.concat(hLines.stream(), hBlocks.asMap().entrySet().stream().map(e -> TT_dots[e.getKey() - 1] + COLON + String.join(SEPARATOR, e.getValue()))).toArray(String[]::new); - } - - public String[] getInformation() { - return iArray; - } - - public String[] getStructureInformation() { - return sArray; - } - - public String[] getStructureHint() { - return hArray; - } + /** + * Use this method to add non-standard structural hint. This info will appear before the standard structural hint. + * @param info + * The line to be added. This should be an entry into minecraft's localization system. + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addStructureHint(String info) { + hLines.add(StatCollector.translateToLocal(info)); + return this; + } + + /** + * Use this method to add an entry to standard structural hint without creating a corresponding line in structure information + * @param name + * The name of block This should be an entry into minecraft's localization system. + * @param dots + * Possible locations of this block + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addStructureHint(String name, int... dots) { + for (int dot : dots) hBlocks.put(dot, StatCollector.translateToLocal(name)); + return this; + } + + /** + * Call at the very end.<br> + * Adds a final line with the mod name and information on how to display the structure guidelines.<br> + * Ends the building process. + * + * @param mod + * Name of the mod that adds this multiblock machine + */ + public void toolTipFinisher(String mod) { + iLines.add(TT_hold + " " + EnumChatFormatting.BOLD + "[LSHIFT]" + EnumChatFormatting.RESET + + EnumChatFormatting.GRAY + " " + TT_todisplay); + iLines.add(TT_mod + COLON + EnumChatFormatting.GREEN + mod + EnumChatFormatting.GRAY); + hLines.add(TT_structurehint); + iArray = iLines.toArray(new String[0]); + sArray = sLines.toArray(new String[0]); + // e.getKey() - 1 because 1 dot is meta 0. + hArray = Stream.concat( + hLines.stream(), + hBlocks.asMap().entrySet().stream() + .map(e -> TT_dots[e.getKey() - 1] + COLON + String.join(SEPARATOR, e.getValue()))) + .toArray(String[]::new); + } + + public String[] getInformation() { + return iArray; + } + + public String[] getStructureInformation() { + return sArray; + } + + public String[] getStructureHint() { + return hArray; + } } diff --git a/src/main/java/gregtech/api/util/GT_OreDictUnificator.java b/src/main/java/gregtech/api/util/GT_OreDictUnificator.java index a017cf3bb0..81038645e9 100644 --- a/src/main/java/gregtech/api/util/GT_OreDictUnificator.java +++ b/src/main/java/gregtech/api/util/GT_OreDictUnificator.java @@ -1,5 +1,9 @@ package gregtech.api.util; +import static gregtech.api.enums.GT_Values.E; +import static gregtech.api.enums.GT_Values.M; +import static gregtech.api.enums.GT_Values.W; + import gregtech.api.GregTech_API; import gregtech.api.enums.Dyes; import gregtech.api.enums.Materials; @@ -9,21 +13,16 @@ import gregtech.api.objects.GT_HashSet; import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.ItemData; import gregtech.api.objects.MaterialStack; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraftforge.oredict.OreDictionary; - -import javax.annotation.Nullable; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; - -import static gregtech.api.enums.GT_Values.E; -import static gregtech.api.enums.GT_Values.M; -import static gregtech.api.enums.GT_Values.W; +import javax.annotation.Nullable; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! @@ -69,14 +68,23 @@ public class GT_OreDictUnificator { set(aPrefix, aMaterial, aStack, true, false); } - public static void set(OrePrefixes aPrefix, Materials aMaterial, ItemStack aStack, boolean aOverwrite, boolean aAlreadyRegistered) { - if (aMaterial == null || aPrefix == null || GT_Utility.isStackInvalid(aStack) || Items.feather.getDamage(aStack) == W) - return; + public static void set( + OrePrefixes aPrefix, + Materials aMaterial, + ItemStack aStack, + boolean aOverwrite, + boolean aAlreadyRegistered) { + if (aMaterial == null + || aPrefix == null + || GT_Utility.isStackInvalid(aStack) + || Items.feather.getDamage(aStack) == W) return; isAddingOre++; aStack = GT_Utility.copyAmount(1, aStack); if (!aAlreadyRegistered) registerOre(aPrefix.get(aMaterial), aStack); addAssociation(aPrefix, aMaterial, aStack, isBlacklisted(aStack)); - if (aOverwrite || GT_Utility.isStackInvalid(sName2StackMap.get(aPrefix.get(aMaterial).toString()))) + if (aOverwrite + || GT_Utility.isStackInvalid( + sName2StackMap.get(aPrefix.get(aMaterial).toString()))) sName2StackMap.put(aPrefix.get(aMaterial).toString(), aStack); isAddingOre--; } @@ -101,12 +109,19 @@ public class GT_OreDictUnificator { } public static ItemStack get(OrePrefixes aPrefix, Object aMaterial, ItemStack aReplacement, long aAmount) { - //if (Materials.mDefaultComponents.contains(aPrefix) && !aPrefix.mDynamicItems.contains((Materials)aMaterial)) aPrefix.mDynamicItems.add((Materials) aMaterial); - if (OrePrefixes.mPreventableComponents.contains(aPrefix) && aPrefix.mDisabledItems.contains(aMaterial)) return aReplacement; + // if (Materials.mDefaultComponents.contains(aPrefix) && !aPrefix.mDynamicItems.contains((Materials)aMaterial)) + // aPrefix.mDynamicItems.add((Materials) aMaterial); + if (OrePrefixes.mPreventableComponents.contains(aPrefix) && aPrefix.mDisabledItems.contains(aMaterial)) + return aReplacement; return get(aPrefix.get(aMaterial), aReplacement, aAmount, false, true); } - public static ItemStack get(Object aName, ItemStack aReplacement, long aAmount, boolean aMentionPossibleTypos, boolean aNoInvalidAmounts) { + public static ItemStack get( + Object aName, + ItemStack aReplacement, + long aAmount, + boolean aMentionPossibleTypos, + boolean aNoInvalidAmounts) { if (aNoInvalidAmounts && aAmount < 1) return null; final ItemStack stackFromName = sName2StackMap.get(aName.toString()); if (stackFromName != null) return GT_Utility.copyAmount(aAmount, stackFromName); @@ -154,8 +169,9 @@ public class GT_OreDictUnificator { if (GT_Utility.isStackInvalid(aStack)) return null; ItemData tPrefixMaterial = getAssociation(aStack); ItemStack rStack = null; - if (tPrefixMaterial == null || !tPrefixMaterial.hasValidPrefixMaterialData() || (aUseBlackList && tPrefixMaterial.mBlackListed)) - return GT_Utility.copyOrNull(aStack); + if (tPrefixMaterial == null + || !tPrefixMaterial.hasValidPrefixMaterialData() + || (aUseBlackList && tPrefixMaterial.mBlackListed)) return GT_Utility.copyOrNull(aStack); if (aUseBlackList && !GregTech_API.sUnificationEntriesRegistered && isBlacklisted(aStack)) { tPrefixMaterial.mBlackListed = true; return GT_Utility.copyOrNull(aStack); @@ -174,15 +190,16 @@ public class GT_OreDictUnificator { public static ItemStack get_nocopy(ItemStack aStack) { return get_nocopy(true, aStack); } - + /** Doesn't copy the returned stack or set quantity. Be careful and do not mutate it; * intended only to optimize comparisons */ static ItemStack get_nocopy(boolean aUseBlackList, ItemStack aStack) { if (GT_Utility.isStackInvalid(aStack)) return null; ItemData tPrefixMaterial = getAssociation(aStack); ItemStack rStack = null; - if (tPrefixMaterial == null || !tPrefixMaterial.hasValidPrefixMaterialData() || (aUseBlackList && tPrefixMaterial.mBlackListed)) - return aStack; + if (tPrefixMaterial == null + || !tPrefixMaterial.hasValidPrefixMaterialData() + || (aUseBlackList && tPrefixMaterial.mBlackListed)) return aStack; if (aUseBlackList && !GregTech_API.sUnificationEntriesRegistered && isBlacklisted(aStack)) { tPrefixMaterial.mBlackListed = true; return aStack; @@ -205,18 +222,14 @@ public class GT_OreDictUnificator { ItemStack rStack = null; if (tPrefixMaterial == null || !tPrefixMaterial.hasValidPrefixMaterialData()) return GT_Utility.areStacksEqual(aStack, unified_tStack, true); - else if(tPrefixMaterial.mBlackListed) { - if (GT_Utility.areStacksEqual(aStack, unified_tStack, true)) - return true; - else - alreadyCompared = true; + else if (tPrefixMaterial.mBlackListed) { + if (GT_Utility.areStacksEqual(aStack, unified_tStack, true)) return true; + else alreadyCompared = true; } if (!alreadyCompared && !GregTech_API.sUnificationEntriesRegistered && isBlacklisted(aStack)) { tPrefixMaterial.mBlackListed = true; - if (GT_Utility.areStacksEqual(aStack, unified_tStack, true)) - return true; - else - alreadyCompared = true; + if (GT_Utility.areStacksEqual(aStack, unified_tStack, true)) return true; + else alreadyCompared = true; } if (tPrefixMaterial.mUnificationTarget == null) tPrefixMaterial.mUnificationTarget = sName2StackMap.get(tPrefixMaterial.toString()); @@ -247,25 +260,22 @@ public class GT_OreDictUnificator { } } } - ItemStack[] aStacks = {}; - if (obj instanceof ItemStack) - aStacks = new ItemStack[]{(ItemStack) obj}; - else if (obj instanceof ItemStack[]) - aStacks = (ItemStack[]) obj; - else if (obj instanceof List) aStacks = (ItemStack[]) - ((List)obj).toArray(new ItemStack[0]); - List<ItemStack> rList = new ArrayList<>(); - for (ItemStack aStack : aStacks) { - rList.add(aStack); - List<ItemStack> tList = sUnificationTable.get(new GT_ItemStack(aStack)); - if (tList != null) { - for (ItemStack tStack : tList) { - ItemStack tStack1 = GT_Utility.copyAmount(aStack.stackSize, tStack); - rList.add(tStack1); - } - } - } - return rList; + ItemStack[] aStacks = {}; + if (obj instanceof ItemStack) aStacks = new ItemStack[] {(ItemStack) obj}; + else if (obj instanceof ItemStack[]) aStacks = (ItemStack[]) obj; + else if (obj instanceof List) aStacks = (ItemStack[]) ((List) obj).toArray(new ItemStack[0]); + List<ItemStack> rList = new ArrayList<>(); + for (ItemStack aStack : aStacks) { + rList.add(aStack); + List<ItemStack> tList = sUnificationTable.get(new GT_ItemStack(aStack)); + if (tList != null) { + for (ItemStack tStack : tList) { + ItemStack tStack1 = GT_Utility.copyAmount(aStack.stackSize, tStack); + rList.add(tStack1); + } + } + } + return rList; } public static void addItemData(ItemStack aStack, ItemData aData) { @@ -276,8 +286,9 @@ public class GT_OreDictUnificator { if (GT_Utility.isStackInvalid(aStack) || aData == null) return; ItemData tData = getItemData(aStack); if (tData == null || !tData.hasValidPrefixMaterialData()) { - if (tData != null) for (Object tObject : tData.mExtraData) - if (!aData.mExtraData.contains(tObject)) aData.mExtraData.add(tObject); + if (tData != null) + for (Object tObject : tData.mExtraData) + if (!aData.mExtraData.contains(tObject)) aData.mExtraData.add(tObject); if (aStack.stackSize > 1) { if (aData.mMaterial != null) aData.mMaterial.mAmount /= aStack.stackSize; for (MaterialStack tMaterial : aData.mByProducts) tMaterial.mAmount /= aStack.stackSize; @@ -285,9 +296,13 @@ public class GT_OreDictUnificator { } sItemStack2DataMap.put(new GT_ItemStack(aStack), aData); if (aData.hasValidMaterialData()) { - long tValidMaterialAmount = aData.mMaterial.mMaterial.contains(SubTag.NO_RECYCLING) ? 0 : aData.mMaterial.mAmount >= 0 ? aData.mMaterial.mAmount : M; + long tValidMaterialAmount = aData.mMaterial.mMaterial.contains(SubTag.NO_RECYCLING) + ? 0 + : aData.mMaterial.mAmount >= 0 ? aData.mMaterial.mAmount : M; for (MaterialStack tMaterial : aData.mByProducts) - tValidMaterialAmount += tMaterial.mMaterial.contains(SubTag.NO_RECYCLING) ? 0 : tMaterial.mAmount >= 0 ? tMaterial.mAmount : M; + tValidMaterialAmount += tMaterial.mMaterial.contains(SubTag.NO_RECYCLING) + ? 0 + : tMaterial.mAmount >= 0 ? tMaterial.mAmount : M; if (tValidMaterialAmount < M) GT_ModHandler.addToRecyclerBlackList(aStack); } if (mRunThroughTheList) { @@ -295,7 +310,8 @@ public class GT_OreDictUnificator { mRunThroughTheList = false; for (Entry<GT_ItemStack, ItemData> tEntry : sItemStack2DataMap.entrySet()) if (!tEntry.getValue().hasValidPrefixData() || tEntry.getValue().mPrefix.mAllowNormalRecycling) - GT_RecipeRegistrator.registerMaterialRecycling(tEntry.getKey().toStack(), tEntry.getValue()); + GT_RecipeRegistrator.registerMaterialRecycling( + tEntry.getKey().toStack(), tEntry.getValue()); } } else { if (!aData.hasValidPrefixData() || aData.mPrefix.mAllowNormalRecycling) @@ -307,11 +323,13 @@ public class GT_OreDictUnificator { } } - public static void addAssociation(OrePrefixes aPrefix, Materials aMaterial, ItemStack aStack, boolean aBlackListed) { - if (aPrefix == null || aMaterial == null || GT_Utility.isStackInvalid(aStack)) - return; - if (Items.feather.getDamage(aStack) == W) for (byte i = 0; i < 16; i++) - setItemData(GT_Utility.copyAmountAndMetaData(1, i, aStack), new ItemData(aPrefix, aMaterial, aBlackListed)); + public static void addAssociation( + OrePrefixes aPrefix, Materials aMaterial, ItemStack aStack, boolean aBlackListed) { + if (aPrefix == null || aMaterial == null || GT_Utility.isStackInvalid(aStack)) return; + if (Items.feather.getDamage(aStack) == W) + for (byte i = 0; i < 16; i++) + setItemData( + GT_Utility.copyAmountAndMetaData(1, i, aStack), new ItemData(aPrefix, aMaterial, aBlackListed)); setItemData(aStack, new ItemData(aPrefix, aMaterial, aBlackListed)); } @@ -335,12 +353,9 @@ public class GT_OreDictUnificator { } public static boolean isItemStackDye(ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack)) - return false; + if (GT_Utility.isStackInvalid(aStack)) return false; - for (Dyes tDye : Dyes.VALUES) - if (isItemStackInstanceOf(aStack, tDye.toString())) - return true; + for (Dyes tDye : Dyes.VALUES) if (isItemStackInstanceOf(aStack, tDye.toString())) return true; return false; } @@ -350,17 +365,14 @@ public class GT_OreDictUnificator { } public static boolean registerOre(Object aName, ItemStack aStack) { - if (aName == null || GT_Utility.isStackInvalid(aStack)) - return false; + if (aName == null || GT_Utility.isStackInvalid(aStack)) return false; String tName = aName.toString(); - if (GT_Utility.isStringInvalid(tName)) - return false; + if (GT_Utility.isStringInvalid(tName)) return false; for (ItemStack itemStack : getOresImmutable(tName)) - if (GT_Utility.areStacksEqual(itemStack, aStack, true)) - return false; + if (GT_Utility.areStacksEqual(itemStack, aStack, true)) return false; isRegisteringOre++; OreDictionary.registerOre(tName, GT_Utility.copyAmount(1, aStack)); @@ -377,8 +389,7 @@ public class GT_OreDictUnificator { } public static void resetUnificationEntries() { - for (ItemData tPrefixMaterial : sItemStack2DataMap.values()) - tPrefixMaterial.mUnificationTarget = null; + for (ItemData tPrefixMaterial : sItemStack2DataMap.values()) tPrefixMaterial.mUnificationTarget = null; } public static ItemStack getGem(MaterialStack aMaterial) { @@ -391,8 +402,7 @@ public class GT_OreDictUnificator { public static ItemStack getGem(Materials aMaterial, long aMaterialAmount) { ItemStack rStack = null; - if (((aMaterialAmount >= M))) - rStack = get(OrePrefixes.gem, aMaterial, aMaterialAmount / M); + if (((aMaterialAmount >= M))) rStack = get(OrePrefixes.gem, aMaterial, aMaterialAmount / M); if (rStack == null) { if ((((aMaterialAmount * 2) % M == 0) || aMaterialAmount >= M * 16)) rStack = get(OrePrefixes.gemFlawed, aMaterial, (aMaterialAmount * 2) / M); @@ -491,7 +501,9 @@ public class GT_OreDictUnificator { */ public static List<ItemStack> getOresImmutable(@Nullable Object aOreName) { String aName = aOreName == null ? E : aOreName.toString(); - - return GT_Utility.isStringValid(aName) ? Collections.unmodifiableList(OreDictionary.getOres(aName)) : Collections.emptyList(); + + return GT_Utility.isStringValid(aName) + ? Collections.unmodifiableList(OreDictionary.getOres(aName)) + : Collections.emptyList(); } } diff --git a/src/main/java/gregtech/api/util/GT_PlayedSound.java b/src/main/java/gregtech/api/util/GT_PlayedSound.java index fa27bbb9d4..87743517d0 100644 --- a/src/main/java/gregtech/api/util/GT_PlayedSound.java +++ b/src/main/java/gregtech/api/util/GT_PlayedSound.java @@ -1,9 +1,9 @@ package gregtech.api.util; -import net.minecraft.util.ResourceLocation; - import static gregtech.api.enums.GT_Values.E; +import net.minecraft.util.ResourceLocation; + public class GT_PlayedSound { public final String mSoundName; public final int mX, mY, mZ; @@ -27,7 +27,10 @@ public class GT_PlayedSound { @Override public boolean equals(Object aObject) { if (aObject instanceof GT_PlayedSound) { - return ((GT_PlayedSound) aObject).mX == mX && ((GT_PlayedSound) aObject).mY == mY && ((GT_PlayedSound) aObject).mZ == mZ && ((GT_PlayedSound) aObject).mSoundName.equals(mSoundName); + return ((GT_PlayedSound) aObject).mX == mX + && ((GT_PlayedSound) aObject).mY == mY + && ((GT_PlayedSound) aObject).mZ == mZ + && ((GT_PlayedSound) aObject).mSoundName.equals(mSoundName); } return false; } diff --git a/src/main/java/gregtech/api/util/GT_ProcessingArray_Manager.java b/src/main/java/gregtech/api/util/GT_ProcessingArray_Manager.java index 0005f20869..548795cc49 100644 --- a/src/main/java/gregtech/api/util/GT_ProcessingArray_Manager.java +++ b/src/main/java/gregtech/api/util/GT_ProcessingArray_Manager.java @@ -1,20 +1,19 @@ package gregtech.api.util; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; - import java.util.HashMap; public class GT_ProcessingArray_Manager { private static final HashMap<String, GT_Recipe_Map> mRecipeSaves = new HashMap<String, GT_Recipe_Map>(); - //Adds recipe Maps to the PA using the machines unlocalized name. - //Example: basicmachine.electrolyzer, with its recipe map will add the electrolyzer's recipe map to the PA + // Adds recipe Maps to the PA using the machines unlocalized name. + // Example: basicmachine.electrolyzer, with its recipe map will add the electrolyzer's recipe map to the PA public static void addRecipeMapToPA(String aMachineName, GT_Recipe_Map aMap) { if (aMachineName != null) { mRecipeSaves.put(aMachineName, aMap); } } - //Allows the PA to extract the recipe map for the machine inside it. + // Allows the PA to extract the recipe map for the machine inside it. public static GT_Recipe_Map giveRecipeMap(String aMachineName) { if (aMachineName != null) { return mRecipeSaves.get(aMachineName); diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index 9e46839f8c..5ec8ad16a2 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -1,5 +1,7 @@ package gregtech.api.util; +import static gregtech.api.enums.GT_Values.*; + import codechicken.nei.PositionedStack; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.ModContainer; @@ -16,6 +18,8 @@ import gregtech.api.util.extensions.ArrayExt; import gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_Replicator; import gregtech.nei.GT_NEI_DefaultHandler.FixedPositionedStack; import ic2.core.Ic2Items; +import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; @@ -27,12 +31,6 @@ import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidContainerItem; -import java.util.*; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.stream.Collectors; - -import static gregtech.api.enums.GT_Values.*; - /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! * <p/> @@ -60,6 +58,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { * An Item that needs to be inside the Special Slot, like for example the Copy Slot inside the Printer. This is only useful for Fake Recipes in NEI, since findRecipe() and containsInput() don't give a shit about this Field. Lists are also possible. */ public Object mSpecialItems; + public int mDuration, mEUt, mSpecialValue; /** * Use this to just disable a specific Recipe, but the Configuration enables that already for every single Recipe. @@ -113,19 +112,23 @@ public class GT_Recipe implements Comparable<GT_Recipe> { reloadOwner(); } - public GT_Recipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - if (aInputs == null) - aInputs = new ItemStack[0]; - if (aOutputs == null) - aOutputs = new ItemStack[0]; - if (aFluidInputs == null) - aFluidInputs = new FluidStack[0]; - if (aFluidOutputs == null) - aFluidOutputs = new FluidStack[0]; - if (aChances == null) - aChances = new int[aOutputs.length]; - if (aChances.length < aOutputs.length) - aChances = Arrays.copyOf(aChances, aOutputs.length); + public GT_Recipe( + boolean aOptimize, + ItemStack[] aInputs, + ItemStack[] aOutputs, + Object aSpecialItems, + int[] aChances, + FluidStack[] aFluidInputs, + FluidStack[] aFluidOutputs, + int aDuration, + int aEUt, + int aSpecialValue) { + if (aInputs == null) aInputs = new ItemStack[0]; + if (aOutputs == null) aOutputs = new ItemStack[0]; + if (aFluidInputs == null) aFluidInputs = new FluidStack[0]; + if (aFluidOutputs == null) aFluidOutputs = new FluidStack[0]; + if (aChances == null) aChances = new int[aOutputs.length]; + if (aChances.length < aOutputs.length) aChances = Arrays.copyOf(aChances, aOutputs.length); aInputs = ArrayExt.withoutTrailingNulls(aInputs, ItemStack[]::new); aOutputs = ArrayExt.withoutTrailingNulls(aOutputs, ItemStack[]::new); @@ -135,16 +138,11 @@ public class GT_Recipe implements Comparable<GT_Recipe> { GT_OreDictUnificator.setStackArray(true, aInputs); GT_OreDictUnificator.setStackArray(true, aOutputs); - for (ItemStack tStack : aOutputs) - GT_Utility.updateItemStack(tStack); + for (ItemStack tStack : aOutputs) GT_Utility.updateItemStack(tStack); - for (int i = 0; i < aChances.length; i++) - if (aChances[i] <= 0) - aChances[i] = 10000; - for (int i = 0; i < aFluidInputs.length; i++) - aFluidInputs[i] = new GT_FluidStack(aFluidInputs[i]); - for (int i = 0; i < aFluidOutputs.length; i++) - aFluidOutputs[i] = new GT_FluidStack(aFluidOutputs[i]); + for (int i = 0; i < aChances.length; i++) if (aChances[i] <= 0) aChances[i] = 10000; + for (int i = 0; i < aFluidInputs.length; i++) aFluidInputs[i] = new GT_FluidStack(aFluidInputs[i]); + for (int i = 0; i < aFluidOutputs.length; i++) aFluidOutputs[i] = new GT_FluidStack(aFluidOutputs[i]); for (ItemStack aInput : aInputs) if (aInput != null && Items.feather.getDamage(aInput) != W) @@ -186,12 +184,9 @@ public class GT_Recipe implements Comparable<GT_Recipe> { break; } if (temp) { - for (ItemStack itemStack : tList) - itemStack.stackSize /= i; - for (FluidStack aFluidInput : aFluidInputs) - aFluidInput.amount /= i; - for (FluidStack aFluidOutput : aFluidOutputs) - aFluidOutput.amount /= i; + for (ItemStack itemStack : tList) itemStack.stackSize /= i; + for (FluidStack aFluidInput : aFluidInputs) aFluidInput.amount /= i; + for (FluidStack aFluidOutput : aFluidOutputs) aFluidOutput.amount /= i; aDuration /= i; } } @@ -206,7 +201,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { mDuration = aDuration; mSpecialValue = aSpecialValue; mEUt = aEUt; -// checkCellBalance(); + // checkCellBalance(); reloadOwner(); } @@ -220,33 +215,50 @@ public class GT_Recipe implements Comparable<GT_Recipe> { } // aSpecialValue = EU per Liter! If there is no Liquid for this Object, then it gets multiplied with 1000! - public GT_Recipe(ItemStack aInput1, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, ItemStack aOutput4, int aSpecialValue, int aType) { - this(true, new ItemStack[]{aInput1}, new ItemStack[]{aOutput1, aOutput2, aOutput3, aOutput4}, null, null, null, null, 0, 0, Math.max(1, aSpecialValue)); + public GT_Recipe( + ItemStack aInput1, + ItemStack aOutput1, + ItemStack aOutput2, + ItemStack aOutput3, + ItemStack aOutput4, + int aSpecialValue, + int aType) { + this( + true, + new ItemStack[] {aInput1}, + new ItemStack[] {aOutput1, aOutput2, aOutput3, aOutput4}, + null, + null, + null, + null, + 0, + 0, + Math.max(1, aSpecialValue)); if (mInputs.length > 0 && aSpecialValue > 0) { switch (aType) { - // Diesel Generator + // Diesel Generator case 0: GT_Recipe_Map.sDieselFuels.addRecipe(this); GT_Recipe_Map.sLargeBoilerFakeFuels.addDieselRecipe(this); break; - // Gas Turbine + // Gas Turbine case 1: GT_Recipe_Map.sTurbineFuels.addRecipe(this); break; - // Thermal Generator + // Thermal Generator case 2: GT_Recipe_Map.sHotFuels.addRecipe(this); break; - // Plasma Generator + // Plasma Generator case 4: GT_Recipe_Map.sPlasmaFuels.addRecipe(this); break; - // Magic Generator + // Magic Generator case 5: GT_Recipe_Map.sMagicFuels.addRecipe(this); break; - // Fluid Generator. Usually 3. Every wrong Type ends up in the Semifluid Generator + // Fluid Generator. Usually 3. Every wrong Type ends up in the Semifluid Generator default: GT_Recipe_Map.sDenseLiquidFuels.addRecipe(this); GT_Recipe_Map.sLargeBoilerFakeFuels.addDenseLiquidRecipe(this); @@ -255,85 +267,221 @@ public class GT_Recipe implements Comparable<GT_Recipe> { } } - public GT_Recipe(FluidStack aInput1, FluidStack aInput2, FluidStack aOutput1, int aDuration, int aEUt, int aSpecialValue) { - this(true, null, null, null, null, new FluidStack[]{aInput1, aInput2}, new FluidStack[]{aOutput1}, Math.max(aDuration, 1), aEUt, Math.max(Math.min(aSpecialValue, 160000000), 0)); + public GT_Recipe( + FluidStack aInput1, FluidStack aInput2, FluidStack aOutput1, int aDuration, int aEUt, int aSpecialValue) { + this( + true, + null, + null, + null, + null, + new FluidStack[] {aInput1, aInput2}, + new FluidStack[] {aOutput1}, + Math.max(aDuration, 1), + aEUt, + Math.max(Math.min(aSpecialValue, 160000000), 0)); if (mInputs.length > 1) { GT_Recipe_Map.sFusionRecipes.addRecipe(this); } } public GT_Recipe(ItemStack aInput1, ItemStack aOutput1, ItemStack aOutput2, int aDuration, int aEUt) { - this(true, new ItemStack[]{aInput1}, new ItemStack[]{aOutput1, aOutput2}, null, null, null, null, aDuration, aEUt, 0); + this( + true, + new ItemStack[] {aInput1}, + new ItemStack[] {aOutput1, aOutput2}, + null, + null, + null, + null, + aDuration, + aEUt, + 0); if (mInputs.length > 0 && mOutputs[0] != null) { GT_Recipe_Map.sLatheRecipes.addRecipe(this); } } - public GT_Recipe(ItemStack aInput1, int aCellAmount, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, ItemStack aOutput4, int aDuration, int aEUt) { - this(true, new ItemStack[]{aInput1, aCellAmount > 0 ? ItemList.Cell_Empty.get(Math.min(64, Math.max(1, aCellAmount))) : null}, new ItemStack[]{aOutput1, aOutput2, aOutput3, aOutput4}, null, null, null, null, Math.max(aDuration, 1), Math.max(aEUt, 1), 0); + public GT_Recipe( + ItemStack aInput1, + int aCellAmount, + ItemStack aOutput1, + ItemStack aOutput2, + ItemStack aOutput3, + ItemStack aOutput4, + int aDuration, + int aEUt) { + this( + true, + new ItemStack[] { + aInput1, aCellAmount > 0 ? ItemList.Cell_Empty.get(Math.min(64, Math.max(1, aCellAmount))) : null + }, + new ItemStack[] {aOutput1, aOutput2, aOutput3, aOutput4}, + null, + null, + null, + null, + Math.max(aDuration, 1), + Math.max(aEUt, 1), + 0); if (mInputs.length > 0 && mOutputs[0] != null) { GT_Recipe_Map.sDistillationRecipes.addRecipe(this); } } public GT_Recipe(ItemStack aInput1, int aInput2, ItemStack aOutput1, ItemStack aOutput2) { - this(true, new ItemStack[]{aInput1, GT_ModHandler.getIC2Item("industrialTnt", aInput2 > 0 ? Math.min(aInput2, 64) : 1, new ItemStack(Blocks.tnt, aInput2 > 0 ? Math.min(aInput2, 64) : 1))}, new ItemStack[]{aOutput1, aOutput2}, null, null, null, null, 20, 30, 0); + this( + true, + new ItemStack[] { + aInput1, + GT_ModHandler.getIC2Item( + "industrialTnt", + aInput2 > 0 ? Math.min(aInput2, 64) : 1, + new ItemStack(Blocks.tnt, aInput2 > 0 ? Math.min(aInput2, 64) : 1)) + }, + new ItemStack[] {aOutput1, aOutput2}, + null, + null, + null, + null, + 20, + 30, + 0); if (mInputs.length > 0 && mOutputs[0] != null) { GT_Recipe_Map.sImplosionRecipes.addRecipe(this); } } public GT_Recipe(int aEUt, int aDuration, ItemStack aInput1, ItemStack aOutput1) { - this(true, new ItemStack[]{aInput1, ItemList.Circuit_Integrated.getWithDamage(0, aInput1.stackSize)}, new ItemStack[]{aOutput1}, null, null, null, null, Math.max(aDuration, 1), Math.max(aEUt, 1), 0); + this( + true, + new ItemStack[] {aInput1, ItemList.Circuit_Integrated.getWithDamage(0, aInput1.stackSize)}, + new ItemStack[] {aOutput1}, + null, + null, + null, + null, + Math.max(aDuration, 1), + Math.max(aEUt, 1), + 0); if (mInputs.length > 0 && mOutputs[0] != null) { GT_Recipe_Map.sBenderRecipes.addRecipe(this); } } public GT_Recipe(ItemStack aInput1, ItemStack aInput2, int aEUt, int aDuration, ItemStack aOutput1) { - this(true, aInput2 == null ? new ItemStack[]{aInput1} : new ItemStack[]{aInput1, aInput2}, new ItemStack[]{aOutput1}, null, null, null, null, Math.max(aDuration, 1), Math.max(aEUt, 1), 0); + this( + true, + aInput2 == null ? new ItemStack[] {aInput1} : new ItemStack[] {aInput1, aInput2}, + new ItemStack[] {aOutput1}, + null, + null, + null, + null, + Math.max(aDuration, 1), + Math.max(aEUt, 1), + 0); if (mInputs.length > 0 && mOutputs[0] != null) { GT_Recipe_Map.sAlloySmelterRecipes.addRecipe(this); } } - public GT_Recipe(ItemStack aInput1, int aEUt, ItemStack aInput2, int aDuration, ItemStack aOutput1, ItemStack aOutput2) { - this(true, aInput2 == null ? new ItemStack[]{aInput1} : new ItemStack[]{aInput1, aInput2}, new ItemStack[]{aOutput1, aOutput2}, null, null, null, null, Math.max(aDuration, 1), Math.max(aEUt, 1), 0); + public GT_Recipe( + ItemStack aInput1, int aEUt, ItemStack aInput2, int aDuration, ItemStack aOutput1, ItemStack aOutput2) { + this( + true, + aInput2 == null ? new ItemStack[] {aInput1} : new ItemStack[] {aInput1, aInput2}, + new ItemStack[] {aOutput1, aOutput2}, + null, + null, + null, + null, + Math.max(aDuration, 1), + Math.max(aEUt, 1), + 0); if (mInputs.length > 0 && mOutputs[0] != null) { GT_Recipe_Map.sCannerRecipes.addRecipe(this); } } public GT_Recipe(ItemStack aInput1, ItemStack aOutput1, int aDuration) { - this(true, new ItemStack[]{aInput1}, new ItemStack[]{aOutput1}, null, null, null, null, Math.max(aDuration, 1), 120, 0); + this( + true, + new ItemStack[] {aInput1}, + new ItemStack[] {aOutput1}, + null, + null, + null, + null, + Math.max(aDuration, 1), + 120, + 0); if (mInputs.length > 0 && mOutputs[0] != null) { GT_Recipe_Map.sVacuumRecipes.addRecipe(this); } } public GT_Recipe(ItemStack aInput1, ItemStack aOutput1, int aDuration, int aEUt, int VACUUM) { - this(true, new ItemStack[]{aInput1}, new ItemStack[]{aOutput1}, null, null, null, null, Math.max(aDuration, 1), aEUt, 0); + this( + true, + new ItemStack[] {aInput1}, + new ItemStack[] {aOutput1}, + null, + null, + null, + null, + Math.max(aDuration, 1), + aEUt, + 0); if (mInputs.length > 0 && mOutputs[0] != null) { GT_Recipe_Map.sVacuumRecipes.addRecipe(this); } } public GT_Recipe(FluidStack aInput1, FluidStack aOutput1, int aDuration, int aEUt) { - this(false, null, null, null, null, new FluidStack[]{aInput1}, new FluidStack[]{aOutput1}, Math.max(aDuration, 1), aEUt, 0); + this( + false, + null, + null, + null, + null, + new FluidStack[] {aInput1}, + new FluidStack[] {aOutput1}, + Math.max(aDuration, 1), + aEUt, + 0); if (mFluidInputs.length > 0 && mFluidOutputs[0] != null) { GT_Recipe_Map.sVacuumRecipes.addRecipe(this); } } - //Dummy GT_Recipe maker... - public GT_Recipe(ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue){ - this(true, aInputs, aOutputs, aSpecialItems, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue); + // Dummy GT_Recipe maker... + public GT_Recipe( + ItemStack[] aInputs, + ItemStack[] aOutputs, + Object aSpecialItems, + int[] aChances, + FluidStack[] aFluidInputs, + FluidStack[] aFluidOutputs, + int aDuration, + int aEUt, + int aSpecialValue) { + this( + true, + aInputs, + aOutputs, + aSpecialItems, + aChances, + aFluidInputs, + aFluidOutputs, + aDuration, + aEUt, + aSpecialValue); } public static void reInit() { GT_Log.out.println("GT_Mod: Re-Unificating Recipes."); - for (GT_Recipe_Map tMapEntry : GT_Recipe_Map.sMappings) - tMapEntry.reInit(); + for (GT_Recipe_Map tMapEntry : GT_Recipe_Map.sMappings) tMapEntry.reInit(); } // ----- @@ -388,7 +536,8 @@ public class GT_Recipe implements Comparable<GT_Recipe> { return new GT_Recipe(this); } - public boolean isRecipeInputEqual(boolean aDecreaseStacksizeBySuccess, FluidStack[] aFluidInputs, ItemStack... aInputs) { + public boolean isRecipeInputEqual( + boolean aDecreaseStacksizeBySuccess, FluidStack[] aFluidInputs, ItemStack... aInputs) { return isRecipeInputEqual(aDecreaseStacksizeBySuccess, false, aFluidInputs, aInputs); } @@ -411,7 +560,11 @@ public class GT_Recipe implements Comparable<GT_Recipe> { * WARNING: Do not call this method with both {@code aDecreaseStacksizeBySuccess} and {@code aDontCheckStackSizes} set to {@code true}! * You'll get weird behavior. */ - public boolean isRecipeInputEqual(boolean aDecreaseStacksizeBySuccess, boolean aDontCheckStackSizes, FluidStack[] aFluidInputs, ItemStack... aInputs) { + public boolean isRecipeInputEqual( + boolean aDecreaseStacksizeBySuccess, + boolean aDontCheckStackSizes, + FluidStack[] aFluidInputs, + ItemStack... aInputs) { if (mInputs.length > 0 && aInputs == null) return false; if (mFluidInputs.length > 0 && aFluidInputs == null) return false; @@ -473,9 +626,12 @@ public class GT_Recipe implements Comparable<GT_Recipe> { ItemStack providedItem = aInputs[i]; if (GT_OreDictUnificator.isInputStackEqual(providedItem, unifiedItemCost)) { if (GTppRecipeHelper) { // Please see JavaDoc on GTppRecipeHelper for why this is here. - if (GT_Utility.areStacksEqual(providedItem, Ic2Items.FluidCell.copy(), true) || GT_Utility.areStacksEqual(providedItem, ItemList.Tool_DataStick.get(1L), true) || GT_Utility.areStacksEqual(providedItem, ItemList.Tool_DataOrb.get(1L), true)) { - if (!GT_Utility.areStacksEqual(providedItem, recipeItemCost, false)) - continue; + if (GT_Utility.areStacksEqual(providedItem, Ic2Items.FluidCell.copy(), true) + || GT_Utility.areStacksEqual( + providedItem, ItemList.Tool_DataStick.get(1L), true) + || GT_Utility.areStacksEqual( + providedItem, ItemList.Tool_DataOrb.get(1L), true)) { + if (!GT_Utility.areStacksEqual(providedItem, recipeItemCost, false)) continue; } } @@ -559,8 +715,8 @@ public class GT_Recipe implements Comparable<GT_Recipe> { */ @SuppressWarnings("DeprecatedIsStillUsed") @Deprecated - public ArrayList<PositionedStack> getInputPositionedStacks(){ - return null; + public ArrayList<PositionedStack> getInputPositionedStacks() { + return null; } /** @@ -568,21 +724,20 @@ public class GT_Recipe implements Comparable<GT_Recipe> { */ @SuppressWarnings("DeprecatedIsStillUsed") @Deprecated - public ArrayList<PositionedStack> getOutputPositionedStacks(){ - return null; + public ArrayList<PositionedStack> getOutputPositionedStacks() { + return null; } public void reloadOwner() { setOwner(Loader.instance().activeModContainer()); - final List<String> excludedClasses = Arrays.asList( - "java.lang.Thread", - "gregtech.api.util.GT_Recipe", - "gregtech.common.GT_RecipeAdder"); + final List<String> excludedClasses = + Arrays.asList("java.lang.Thread", "gregtech.api.util.GT_Recipe", "gregtech.common.GT_RecipeAdder"); if (GT_Mod.gregtechproxy.mNEIRecipeOwnerStackTrace) { List<StackTraceElement> toAdd = new ArrayList<>(); for (StackTraceElement stackTrace : Thread.currentThread().getStackTrace()) { - if (excludedClasses.stream().noneMatch(c -> stackTrace.getClassName().contains(c))) { + if (excludedClasses.stream() + .noneMatch(c -> stackTrace.getClassName().contains(c))) { toAdd.add(stackTrace); } } @@ -609,14 +764,14 @@ public class GT_Recipe implements Comparable<GT_Recipe> { } } - public static class GT_Recipe_AssemblyLine{ - public static final ArrayList<GT_Recipe_AssemblyLine> sAssemblylineRecipes = new ArrayList<GT_Recipe_AssemblyLine>(); + public static class GT_Recipe_AssemblyLine { + public static final ArrayList<GT_Recipe_AssemblyLine> sAssemblylineRecipes = + new ArrayList<GT_Recipe_AssemblyLine>(); static { if (!Boolean.getBoolean("com.gtnh.gt5u.ignore-invalid-assline-recipe")) GregTech_API.sFirstWorldTick.add(GT_Recipe_AssemblyLine::checkInvalidRecipes); - else - GT_Log.out.println("NOT CHECKING INVALID ASSLINE RECIPE."); + else GT_Log.out.println("NOT CHECKING INVALID ASSLINE RECIPE."); } private static void checkInvalidRecipes() { @@ -629,7 +784,8 @@ public class GT_Recipe implements Comparable<GT_Recipe> { } } if (invalidCount > 0) - throw new RuntimeException("There are " + invalidCount + " invalid assembly line recipe(s)! Check GregTech.log for details!"); + throw new RuntimeException("There are " + invalidCount + + " invalid assembly line recipe(s)! Check GregTech.log for details!"); } public ItemStack mResearchItem; @@ -647,8 +803,23 @@ public class GT_Recipe implements Comparable<GT_Recipe> { * * if you set one yourself, it will give you one of the RunetimeExceptions! */ - public GT_Recipe_AssemblyLine(ItemStack aResearchItem, int aResearchTime, ItemStack[] aInputs, FluidStack[] aFluidInputs, ItemStack aOutput, int aDuration, int aEUt) { - this(aResearchItem, aResearchTime, aInputs, aFluidInputs, aOutput, aDuration, aEUt, new ItemStack[aInputs.length][]); + public GT_Recipe_AssemblyLine( + ItemStack aResearchItem, + int aResearchTime, + ItemStack[] aInputs, + FluidStack[] aFluidInputs, + ItemStack aOutput, + int aDuration, + int aEUt) { + this( + aResearchItem, + aResearchTime, + aInputs, + aFluidInputs, + aOutput, + aDuration, + aEUt, + new ItemStack[aInputs.length][]); int tPersistentHash = 1; for (ItemStack tInput : aInputs) tPersistentHash = tPersistentHash * 31 + GT_Utility.persistentHash(tInput, true, false); @@ -667,94 +838,97 @@ public class GT_Recipe implements Comparable<GT_Recipe> { * * if you don't set one yourself, it will break a lot of stuff! */ - public GT_Recipe_AssemblyLine(ItemStack aResearchItem, int aResearchTime, ItemStack[] aInputs, FluidStack[] aFluidInputs, ItemStack aOutput, int aDuration, int aEUt, ItemStack[][] aAlt) { - mResearchItem = aResearchItem; - mResearchTime = aResearchTime; - mInputs = aInputs; - mFluidInputs = aFluidInputs; - mOutput = aOutput; - mDuration = aDuration; - mEUt = aEUt; - mOreDictAlt = aAlt; + public GT_Recipe_AssemblyLine( + ItemStack aResearchItem, + int aResearchTime, + ItemStack[] aInputs, + FluidStack[] aFluidInputs, + ItemStack aOutput, + int aDuration, + int aEUt, + ItemStack[][] aAlt) { + mResearchItem = aResearchItem; + mResearchTime = aResearchTime; + mInputs = aInputs; + mFluidInputs = aFluidInputs; + mOutput = aOutput; + mDuration = aDuration; + mEUt = aEUt; + mOreDictAlt = aAlt; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + GT_ItemStack[] thisInputs = new GT_ItemStack[this.mInputs.length]; + int totalInputStackSize = 0; + for (int i = 0; i < this.mInputs.length; i++) { + thisInputs[i] = new GT_ItemStack(this.mInputs[i]); + totalInputStackSize += thisInputs[i].mStackSize; + } + int inputHash = Arrays.deepHashCode(thisInputs); + int inputFluidHash = Arrays.deepHashCode(this.mFluidInputs); + GT_ItemStack thisOutput = new GT_ItemStack(mOutput); + GT_ItemStack thisResearch = new GT_ItemStack(mResearchItem); + int miscRecipeDataHash = Arrays.deepHashCode( + new Object[] {totalInputStackSize, mDuration, mEUt, thisOutput, thisResearch, mResearchTime}); + result = prime * result + inputFluidHash; + result = prime * result + inputHash; + result = prime * result + miscRecipeDataHash; + return result; } @Override - public int hashCode() { - final int prime = 31; - int result = 1; - GT_ItemStack[] thisInputs = new GT_ItemStack[this.mInputs.length]; - int totalInputStackSize = 0; - for (int i=0;i<this.mInputs.length;i++) { - thisInputs[i] = new GT_ItemStack(this.mInputs[i]); - totalInputStackSize += thisInputs[i].mStackSize; - } - int inputHash = Arrays.deepHashCode(thisInputs); - int inputFluidHash = Arrays.deepHashCode(this.mFluidInputs); - GT_ItemStack thisOutput = new GT_ItemStack(mOutput); - GT_ItemStack thisResearch = new GT_ItemStack(mResearchItem); - int miscRecipeDataHash = Arrays.deepHashCode(new Object[] { - totalInputStackSize, - mDuration, mEUt, - thisOutput, - thisResearch, - mResearchTime - }); - result = prime * result + inputFluidHash; - result = prime * result + inputHash; - result = prime * result + miscRecipeDataHash; - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof GT_Recipe_AssemblyLine)) { - return false; - } - GT_Recipe_AssemblyLine other = (GT_Recipe_AssemblyLine) obj; - if (this.mInputs.length != other.mInputs.length) { - return false; - } - if (this.mFluidInputs.length != other.mFluidInputs.length) { - return false; - } - // Check Outputs Match - GT_ItemStack output1 = new GT_ItemStack(this.mOutput); - GT_ItemStack output2 = new GT_ItemStack(other.mOutput); - if (!output1.equals(output2)) { - return false; - } - // Check Scanned Item Match - GT_ItemStack scan1 = new GT_ItemStack(this.mResearchItem); - GT_ItemStack scan2 = new GT_ItemStack(other.mResearchItem); - if (!scan1.equals(scan2)) { - return false; - } - // Check Items Match - GT_ItemStack[] thisInputs = new GT_ItemStack[this.mInputs.length]; - GT_ItemStack[] otherInputs = new GT_ItemStack[other.mInputs.length]; - for (int i=0;i<thisInputs.length;i++) { - thisInputs[i] = new GT_ItemStack(this.mInputs[i]); - otherInputs[i] = new GT_ItemStack(other.mInputs[i]); - } - for (int i=0;i<thisInputs.length;i++) { - if (!thisInputs[i].equals(otherInputs[i]) || thisInputs[i].mStackSize != otherInputs[i].mStackSize) { - return false; - } - } - // Check Fluids Match - for (int i=0;i<this.mFluidInputs.length;i++) { - if (!this.mFluidInputs[i].isFluidStackIdentical(other.mFluidInputs[i])) { - return false; - } - } - - return this.mDuration == other.mDuration - && this.mEUt == other.mEUt - && this.mResearchTime == other.mResearchTime; - } + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof GT_Recipe_AssemblyLine)) { + return false; + } + GT_Recipe_AssemblyLine other = (GT_Recipe_AssemblyLine) obj; + if (this.mInputs.length != other.mInputs.length) { + return false; + } + if (this.mFluidInputs.length != other.mFluidInputs.length) { + return false; + } + // Check Outputs Match + GT_ItemStack output1 = new GT_ItemStack(this.mOutput); + GT_ItemStack output2 = new GT_ItemStack(other.mOutput); + if (!output1.equals(output2)) { + return false; + } + // Check Scanned Item Match + GT_ItemStack scan1 = new GT_ItemStack(this.mResearchItem); + GT_ItemStack scan2 = new GT_ItemStack(other.mResearchItem); + if (!scan1.equals(scan2)) { + return false; + } + // Check Items Match + GT_ItemStack[] thisInputs = new GT_ItemStack[this.mInputs.length]; + GT_ItemStack[] otherInputs = new GT_ItemStack[other.mInputs.length]; + for (int i = 0; i < thisInputs.length; i++) { + thisInputs[i] = new GT_ItemStack(this.mInputs[i]); + otherInputs[i] = new GT_ItemStack(other.mInputs[i]); + } + for (int i = 0; i < thisInputs.length; i++) { + if (!thisInputs[i].equals(otherInputs[i]) || thisInputs[i].mStackSize != otherInputs[i].mStackSize) { + return false; + } + } + // Check Fluids Match + for (int i = 0; i < this.mFluidInputs.length; i++) { + if (!this.mFluidInputs[i].isFluidStackIdentical(other.mFluidInputs[i])) { + return false; + } + } + + return this.mDuration == other.mDuration + && this.mEUt == other.mEUt + && this.mResearchTime == other.mResearchTime; + } public int getPersistentHash() { if (mPersistentHash == 0) @@ -764,16 +938,15 @@ public class GT_Recipe implements Comparable<GT_Recipe> { @Override public String toString() { - return "GT_Recipe_AssemblyLine{" + - "mResearchItem=" + mResearchItem + - ", mResearchTime=" + mResearchTime + - ", mInputs=" + Arrays.toString(mInputs) + - ", mFluidInputs=" + Arrays.toString(mFluidInputs) + - ", mOutput=" + mOutput + - ", mDuration=" + mDuration + - ", mEUt=" + mEUt + - ", mOreDictAlt=" + Arrays.toString(mOreDictAlt) + - '}'; + return "GT_Recipe_AssemblyLine{" + "mResearchItem=" + + mResearchItem + ", mResearchTime=" + + mResearchTime + ", mInputs=" + + Arrays.toString(mInputs) + ", mFluidInputs=" + + Arrays.toString(mFluidInputs) + ", mOutput=" + + mOutput + ", mDuration=" + + mDuration + ", mEUt=" + + mEUt + ", mOreDictAlt=" + + Arrays.toString(mOreDictAlt) + '}'; } /** @@ -782,12 +955,9 @@ public class GT_Recipe implements Comparable<GT_Recipe> { * @throws IllegalStateException if the persistent hash has been set already */ public void setPersistentHash(int aPersistentHash) { - if (this.mPersistentHash != 0) - throw new IllegalStateException("Cannot set persistent hash twice!"); - if (aPersistentHash == 0) - this.mPersistentHash = 1; - else - this.mPersistentHash = aPersistentHash; + if (this.mPersistentHash != 0) throw new IllegalStateException("Cannot set persistent hash twice!"); + if (aPersistentHash == 0) this.mPersistentHash = 1; + else this.mPersistentHash = aPersistentHash; } } @@ -801,53 +971,716 @@ public class GT_Recipe implements Comparable<GT_Recipe> { */ public static final Map<String, GT_Recipe_Map> sIndexedMappings = new HashMap<>(); - public static final GT_Recipe_Map sOreWasherRecipes = new GT_Recipe_Map(new HashSet<>(500), "gt.recipe.orewasher", "Ore Washing Plant", null, RES_PATH_GUI + "basicmachines/OreWasher", 1, 3, 1, 1, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sThermalCentrifugeRecipes = new GT_Recipe_Map(new HashSet<>(1000), "gt.recipe.thermalcentrifuge", "Thermal Centrifuge", null, RES_PATH_GUI + "basicmachines/ThermalCentrifuge", 1, 3, 1, 0, 2, E, 1, E, true, true); - public static final GT_Recipe_Map sCompressorRecipes = new GT_Recipe_Map(new HashSet<>(750), "gt.recipe.compressor", "Compressor", null, RES_PATH_GUI + "basicmachines/Compressor", 1, 1, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sExtractorRecipes = new GT_Recipe_Map(new HashSet<>(250), "gt.recipe.extractor", "Extractor", null, RES_PATH_GUI + "basicmachines/Extractor", 1, 1, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sRecyclerRecipes = new GT_Recipe_Map_Recycler(new HashSet<>(0), "ic.recipe.recycler", "Recycler", "ic2.recycler", RES_PATH_GUI + "basicmachines/Recycler", 1, 1, 1, 0, 1, E, 1, E, true, false); - public static final GT_Recipe_Map sFurnaceRecipes = new GT_Recipe_Map_Furnace(new HashSet<>(0), "mc.recipe.furnace", "Furnace", "smelting", RES_PATH_GUI + "basicmachines/E_Furnace", 1, 1, 1, 0, 1, E, 1, E, true, false); - public static final GT_Recipe_Map sMicrowaveRecipes = new GT_Recipe_Map_Microwave(new HashSet<>(0), "gt.recipe.microwave", "Microwave", "smelting", RES_PATH_GUI + "basicmachines/E_Furnace", 1, 1, 1, 0, 1, E, 1, E, true, false); + public static final GT_Recipe_Map sOreWasherRecipes = new GT_Recipe_Map( + new HashSet<>(500), + "gt.recipe.orewasher", + "Ore Washing Plant", + null, + RES_PATH_GUI + "basicmachines/OreWasher", + 1, + 3, + 1, + 1, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sThermalCentrifugeRecipes = new GT_Recipe_Map( + new HashSet<>(1000), + "gt.recipe.thermalcentrifuge", + "Thermal Centrifuge", + null, + RES_PATH_GUI + "basicmachines/ThermalCentrifuge", + 1, + 3, + 1, + 0, + 2, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sCompressorRecipes = new GT_Recipe_Map( + new HashSet<>(750), + "gt.recipe.compressor", + "Compressor", + null, + RES_PATH_GUI + "basicmachines/Compressor", + 1, + 1, + 1, + 0, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sExtractorRecipes = new GT_Recipe_Map( + new HashSet<>(250), + "gt.recipe.extractor", + "Extractor", + null, + RES_PATH_GUI + "basicmachines/Extractor", + 1, + 1, + 1, + 0, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sRecyclerRecipes = new GT_Recipe_Map_Recycler( + new HashSet<>(0), + "ic.recipe.recycler", + "Recycler", + "ic2.recycler", + RES_PATH_GUI + "basicmachines/Recycler", + 1, + 1, + 1, + 0, + 1, + E, + 1, + E, + true, + false); + public static final GT_Recipe_Map sFurnaceRecipes = new GT_Recipe_Map_Furnace( + new HashSet<>(0), + "mc.recipe.furnace", + "Furnace", + "smelting", + RES_PATH_GUI + "basicmachines/E_Furnace", + 1, + 1, + 1, + 0, + 1, + E, + 1, + E, + true, + false); + public static final GT_Recipe_Map sMicrowaveRecipes = new GT_Recipe_Map_Microwave( + new HashSet<>(0), + "gt.recipe.microwave", + "Microwave", + "smelting", + RES_PATH_GUI + "basicmachines/E_Furnace", + 1, + 1, + 1, + 0, + 1, + E, + 1, + E, + true, + false); /** Set {@code aSpecialValue = -100} to bypass the disassembler tier check and default recipe duration. */ - public static final GT_Recipe_Map sDisassemblerRecipes = new GT_Recipe_Map(new HashSet<>(250), "gt.recipe.disassembler", "Disassembler", null, RES_PATH_GUI + "basicmachines/Disassembler", 1, 9, 1, 0, 1, E, 1, E, true, false); - public static final GT_Recipe_Map sScannerFakeRecipes = new GT_Recipe_Map(new HashSet<>(300), "gt.recipe.scanner", "Scanner", null, RES_PATH_GUI + "basicmachines/Scanner", 1, 1, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sRockBreakerFakeRecipes = new GT_Recipe_Map(new HashSet<>(200), "gt.recipe.rockbreaker", "Rock Breaker", null, RES_PATH_GUI + "basicmachines/RockBreaker", 1, 1, 0, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sByProductList = new GT_Recipe_Map(new HashSet<>(1000), "gt.recipe.byproductlist", "Ore Byproduct List", null, RES_PATH_GUI + "basicmachines/Default", 1, 6, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sReplicatorFakeRecipes = new ReplicatorFakeMap(new HashSet<>(100), "gt.recipe.replicator", "Replicator", null, RES_PATH_GUI + "basicmachines/Replicator", 0, 1, 0, 1, 1, E, 1, E, true, true); - //public static final GT_Recipe_Map sAssemblylineFakeRecipes = new GT_Recipe_Map(new HashSet<>(30), "gt.recipe.scanner", "Scanner", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sAssemblylineVisualRecipes = new GT_Recipe_Map(new HashSet<>(110), "gt.recipe.fakeAssemblylineProcess", "Assemblyline Process", null, RES_PATH_GUI + "FakeAssemblyline", 1, 1, 1, 0, 1, E, 1, E, true, false); - public static final GT_Recipe_Map sPlasmaArcFurnaceRecipes = new GT_Recipe_Map(new HashSet<>(20000), "gt.recipe.plasmaarcfurnace", "Plasma Arc Furnace", null, RES_PATH_GUI + "basicmachines/PlasmaArcFurnace", 1, 4, 1, 1, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sArcFurnaceRecipes = new GT_Recipe_Map(new HashSet<>(20000), "gt.recipe.arcfurnace", "Arc Furnace", null, RES_PATH_GUI + "basicmachines/ArcFurnace", 1, 4, 1, 1, 3, E, 1, E, true, true); - public static final GT_Recipe_Map sPrinterRecipes = new GT_Recipe_Map_Printer(new HashSet<>(5), "gt.recipe.printer", "Printer", null, RES_PATH_GUI + "basicmachines/Printer", 1, 1, 1, 1, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sSifterRecipes = new GT_Recipe_Map(new HashSet<>(105), "gt.recipe.sifter", "Sifter", null, RES_PATH_GUI + "basicmachines/Sifter", 1, 9, 0, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sPressRecipes = new GT_Recipe_Map_FormingPress(new HashSet<>(300), "gt.recipe.press", "Forming Press", null, RES_PATH_GUI + "basicmachines/Press", 2, 1, 2, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sLaserEngraverRecipes = new GT_Recipe_Map(new HashSet<>(810), "gt.recipe.laserengraver", "Precision Laser Engraver", null, RES_PATH_GUI + "basicmachines/LaserEngraverNEI", 2, 1, 0, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sMixerRecipes = new GT_Recipe_Map(new HashSet<>(900), "gt.recipe.mixer", "Mixer", null, RES_PATH_GUI + "basicmachines/Mixer6", 9, 4, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sAutoclaveRecipes = new GT_Recipe_Map(new HashSet<>(300), "gt.recipe.autoclave", "Autoclave", null, RES_PATH_GUI + "basicmachines/Autoclave4", 2, 4, 1, 1, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sElectroMagneticSeparatorRecipes = new GT_Recipe_Map(new HashSet<>(50), "gt.recipe.electromagneticseparator", "Electromagnetic Separator", null, RES_PATH_GUI + "basicmachines/ElectromagneticSeparator", 1, 3, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sPolarizerRecipes = new GT_Recipe_Map(new HashSet<>(300), "gt.recipe.polarizer", "Electromagnetic Polarizer", null, RES_PATH_GUI + "basicmachines/Polarizer", 1, 1, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sMaceratorRecipes = new GT_Recipe_Map_Macerator(new HashSet<>(16600), "gt.recipe.macerator", "Pulverization", null, RES_PATH_GUI + "basicmachines/Macerator4", 1, 4, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sChemicalBathRecipes = new GT_Recipe_Map(new HashSet<>(2550), "gt.recipe.chemicalbath", "Chemical Bath", null, RES_PATH_GUI + "basicmachines/ChemicalBath", 1, 3, 1, 1, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sFluidCannerRecipes = new GT_Recipe_Map_FluidCanner(new HashSet<>(2100), "gt.recipe.fluidcanner", "Fluid Canning Machine", null, RES_PATH_GUI + "basicmachines/FluidCanner", 1, 1, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sBrewingRecipes = new GT_Recipe_Map(new HashSet<>(450), "gt.recipe.brewer", "Brewing Machine", null, RES_PATH_GUI + "basicmachines/PotionBrewer", 1, 0, 1, 1, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sFluidHeaterRecipes = new GT_Recipe_Map(new HashSet<>(10), "gt.recipe.fluidheater", "Fluid Heater", null, RES_PATH_GUI + "basicmachines/FluidHeater", 1, 0, 1, 1, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sDistilleryRecipes = new GT_Recipe_Map(new HashSet<>(400), "gt.recipe.distillery", "Distillery", null, RES_PATH_GUI + "basicmachines/Distillery", 1, 1, 1, 1, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sFermentingRecipes = new GT_Recipe_Map(new HashSet<>(50), "gt.recipe.fermenter", "Fermenter", null, RES_PATH_GUI + "basicmachines/Fermenter", 0, 0, 0, 1, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sFluidSolidficationRecipes = new GT_Recipe_Map(new HashSet<>(35000), "gt.recipe.fluidsolidifier", "Fluid Solidifier", null, RES_PATH_GUI + "basicmachines/FluidSolidifier", 1, 1, 1, 1, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sFluidExtractionRecipes = new GT_Recipe_Map(new HashSet<>(15000), "gt.recipe.fluidextractor", "Fluid Extractor", null, RES_PATH_GUI + "basicmachines/FluidExtractor", 1, 1, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sBoxinatorRecipes = new GT_Recipe_Map(new HashSet<>(2500), "gt.recipe.packager", "Packager", null, RES_PATH_GUI + "basicmachines/Packager", 2, 1, 2, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sUnboxinatorRecipes = new GT_Recipe_Map_Unboxinator(new HashSet<>(2500), "gt.recipe.unpackager", "Unpackager", null, RES_PATH_GUI + "basicmachines/Unpackager", 1, 2, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sFusionRecipes = new GT_Recipe_Map(new HashSet<>(50), "gt.recipe.fusionreactor", "Fusion Reactor", null, RES_PATH_GUI + "basicmachines/FusionReactor", 0, 0, 0, 2, 1, "Start: ", 1, " EU", true, true); - public static final GT_Recipe_Map sComplexFusionRecipes = new GT_Recipe_Map_ComplexFusion(new HashSet<>(50), "gt.recipe.complexfusionreactor", "Complex Fusion Reactor", null, RES_PATH_GUI + "basicmachines/ComplexFusionReactor", 3, 0, 0, 2, 1, "Start: ", 1, " EU", true, true); - public static final GT_Recipe_Map sCentrifugeRecipes = new GT_Recipe_Map(new HashSet<>(1200), "gt.recipe.centrifuge", "Centrifuge", null, RES_PATH_GUI + "basicmachines/Centrifuge", 2, 6, 0, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sElectrolyzerRecipes = new GT_Recipe_Map(new HashSet<>(300), "gt.recipe.electrolyzer", "Electrolyzer", null, RES_PATH_GUI + "basicmachines/Electrolyzer", 2, 6, 0, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sBlastRecipes = new GT_Recipe_Map(new HashSet<>(800), "gt.recipe.blastfurnace", "Blast Furnace", null, RES_PATH_GUI + "basicmachines/Default", 6, 6, 1, 0, 1, "Heat Capacity: ", 1, " K", false, true); - public static final GT_Recipe_Map sPlasmaForgeRecipes = new GT_Recipe_Map_PlasmaForge(new HashSet<>(20), "gt.recipe.plasmaforge", "DTPF", null, RES_PATH_GUI + "basicmachines/PlasmaForge", 1, 1, 0, 0, 1, "Heat Capacity: ", 1, " K", false, true); - public static final GT_Recipe_Map sPrimitiveBlastRecipes = new GT_Recipe_Map(new HashSet<>(200), "gt.recipe.primitiveblastfurnace", "Primitive Blast Furnace", null, RES_PATH_GUI + "basicmachines/Default", 3, 3, 1, 0, 1, E, 1, E, false, true); - public static final GT_Recipe_Map sImplosionRecipes = new GT_Recipe_Map(new HashSet<>(900), "gt.recipe.implosioncompressor", "Implosion Compressor", null, RES_PATH_GUI + "basicmachines/Default", 2, 2, 2, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sVacuumRecipes = new GT_Recipe_Map(new HashSet<>(305), "gt.recipe.vacuumfreezer", "Vacuum Freezer", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, E, 1, E, false, true); - public static final GT_Recipe_Map sChemicalRecipes = new GT_Recipe_Map(new HashSet<>(1170), "gt.recipe.chemicalreactor", "Chemical Reactor", null, RES_PATH_GUI + "basicmachines/ChemicalReactor", 2, 2, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sDisassemblerRecipes = new GT_Recipe_Map( + new HashSet<>(250), + "gt.recipe.disassembler", + "Disassembler", + null, + RES_PATH_GUI + "basicmachines/Disassembler", + 1, + 9, + 1, + 0, + 1, + E, + 1, + E, + true, + false); + + public static final GT_Recipe_Map sScannerFakeRecipes = new GT_Recipe_Map( + new HashSet<>(300), + "gt.recipe.scanner", + "Scanner", + null, + RES_PATH_GUI + "basicmachines/Scanner", + 1, + 1, + 1, + 0, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sRockBreakerFakeRecipes = new GT_Recipe_Map( + new HashSet<>(200), + "gt.recipe.rockbreaker", + "Rock Breaker", + null, + RES_PATH_GUI + "basicmachines/RockBreaker", + 1, + 1, + 0, + 0, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sByProductList = new GT_Recipe_Map( + new HashSet<>(1000), + "gt.recipe.byproductlist", + "Ore Byproduct List", + null, + RES_PATH_GUI + "basicmachines/Default", + 1, + 6, + 1, + 0, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sReplicatorFakeRecipes = new ReplicatorFakeMap( + new HashSet<>(100), + "gt.recipe.replicator", + "Replicator", + null, + RES_PATH_GUI + "basicmachines/Replicator", + 0, + 1, + 0, + 1, + 1, + E, + 1, + E, + true, + true); + // public static final GT_Recipe_Map sAssemblylineFakeRecipes = new GT_Recipe_Map(new HashSet<>(30), + // "gt.recipe.scanner", "Scanner", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 1, 0, 1, E, 1, E, true, + // true); + public static final GT_Recipe_Map sAssemblylineVisualRecipes = new GT_Recipe_Map( + new HashSet<>(110), + "gt.recipe.fakeAssemblylineProcess", + "Assemblyline Process", + null, + RES_PATH_GUI + "FakeAssemblyline", + 1, + 1, + 1, + 0, + 1, + E, + 1, + E, + true, + false); + public static final GT_Recipe_Map sPlasmaArcFurnaceRecipes = new GT_Recipe_Map( + new HashSet<>(20000), + "gt.recipe.plasmaarcfurnace", + "Plasma Arc Furnace", + null, + RES_PATH_GUI + "basicmachines/PlasmaArcFurnace", + 1, + 4, + 1, + 1, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sArcFurnaceRecipes = new GT_Recipe_Map( + new HashSet<>(20000), + "gt.recipe.arcfurnace", + "Arc Furnace", + null, + RES_PATH_GUI + "basicmachines/ArcFurnace", + 1, + 4, + 1, + 1, + 3, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sPrinterRecipes = new GT_Recipe_Map_Printer( + new HashSet<>(5), + "gt.recipe.printer", + "Printer", + null, + RES_PATH_GUI + "basicmachines/Printer", + 1, + 1, + 1, + 1, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sSifterRecipes = new GT_Recipe_Map( + new HashSet<>(105), + "gt.recipe.sifter", + "Sifter", + null, + RES_PATH_GUI + "basicmachines/Sifter", + 1, + 9, + 0, + 0, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sPressRecipes = new GT_Recipe_Map_FormingPress( + new HashSet<>(300), + "gt.recipe.press", + "Forming Press", + null, + RES_PATH_GUI + "basicmachines/Press", + 2, + 1, + 2, + 0, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sLaserEngraverRecipes = new GT_Recipe_Map( + new HashSet<>(810), + "gt.recipe.laserengraver", + "Precision Laser Engraver", + null, + RES_PATH_GUI + "basicmachines/LaserEngraverNEI", + 2, + 1, + 0, + 0, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sMixerRecipes = new GT_Recipe_Map( + new HashSet<>(900), + "gt.recipe.mixer", + "Mixer", + null, + RES_PATH_GUI + "basicmachines/Mixer6", + 9, + 4, + 1, + 0, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sAutoclaveRecipes = new GT_Recipe_Map( + new HashSet<>(300), + "gt.recipe.autoclave", + "Autoclave", + null, + RES_PATH_GUI + "basicmachines/Autoclave4", + 2, + 4, + 1, + 1, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sElectroMagneticSeparatorRecipes = new GT_Recipe_Map( + new HashSet<>(50), + "gt.recipe.electromagneticseparator", + "Electromagnetic Separator", + null, + RES_PATH_GUI + "basicmachines/ElectromagneticSeparator", + 1, + 3, + 1, + 0, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sPolarizerRecipes = new GT_Recipe_Map( + new HashSet<>(300), + "gt.recipe.polarizer", + "Electromagnetic Polarizer", + null, + RES_PATH_GUI + "basicmachines/Polarizer", + 1, + 1, + 1, + 0, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sMaceratorRecipes = new GT_Recipe_Map_Macerator( + new HashSet<>(16600), + "gt.recipe.macerator", + "Pulverization", + null, + RES_PATH_GUI + "basicmachines/Macerator4", + 1, + 4, + 1, + 0, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sChemicalBathRecipes = new GT_Recipe_Map( + new HashSet<>(2550), + "gt.recipe.chemicalbath", + "Chemical Bath", + null, + RES_PATH_GUI + "basicmachines/ChemicalBath", + 1, + 3, + 1, + 1, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sFluidCannerRecipes = new GT_Recipe_Map_FluidCanner( + new HashSet<>(2100), + "gt.recipe.fluidcanner", + "Fluid Canning Machine", + null, + RES_PATH_GUI + "basicmachines/FluidCanner", + 1, + 1, + 1, + 0, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sBrewingRecipes = new GT_Recipe_Map( + new HashSet<>(450), + "gt.recipe.brewer", + "Brewing Machine", + null, + RES_PATH_GUI + "basicmachines/PotionBrewer", + 1, + 0, + 1, + 1, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sFluidHeaterRecipes = new GT_Recipe_Map( + new HashSet<>(10), + "gt.recipe.fluidheater", + "Fluid Heater", + null, + RES_PATH_GUI + "basicmachines/FluidHeater", + 1, + 0, + 1, + 1, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sDistilleryRecipes = new GT_Recipe_Map( + new HashSet<>(400), + "gt.recipe.distillery", + "Distillery", + null, + RES_PATH_GUI + "basicmachines/Distillery", + 1, + 1, + 1, + 1, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sFermentingRecipes = new GT_Recipe_Map( + new HashSet<>(50), + "gt.recipe.fermenter", + "Fermenter", + null, + RES_PATH_GUI + "basicmachines/Fermenter", + 0, + 0, + 0, + 1, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sFluidSolidficationRecipes = new GT_Recipe_Map( + new HashSet<>(35000), + "gt.recipe.fluidsolidifier", + "Fluid Solidifier", + null, + RES_PATH_GUI + "basicmachines/FluidSolidifier", + 1, + 1, + 1, + 1, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sFluidExtractionRecipes = new GT_Recipe_Map( + new HashSet<>(15000), + "gt.recipe.fluidextractor", + "Fluid Extractor", + null, + RES_PATH_GUI + "basicmachines/FluidExtractor", + 1, + 1, + 1, + 0, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sBoxinatorRecipes = new GT_Recipe_Map( + new HashSet<>(2500), + "gt.recipe.packager", + "Packager", + null, + RES_PATH_GUI + "basicmachines/Packager", + 2, + 1, + 2, + 0, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sUnboxinatorRecipes = new GT_Recipe_Map_Unboxinator( + new HashSet<>(2500), + "gt.recipe.unpackager", + "Unpackager", + null, + RES_PATH_GUI + "basicmachines/Unpackager", + 1, + 2, + 1, + 0, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sFusionRecipes = new GT_Recipe_Map( + new HashSet<>(50), + "gt.recipe.fusionreactor", + "Fusion Reactor", + null, + RES_PATH_GUI + "basicmachines/FusionReactor", + 0, + 0, + 0, + 2, + 1, + "Start: ", + 1, + " EU", + true, + true); + public static final GT_Recipe_Map sComplexFusionRecipes = new GT_Recipe_Map_ComplexFusion( + new HashSet<>(50), + "gt.recipe.complexfusionreactor", + "Complex Fusion Reactor", + null, + RES_PATH_GUI + "basicmachines/ComplexFusionReactor", + 3, + 0, + 0, + 2, + 1, + "Start: ", + 1, + " EU", + true, + true); + public static final GT_Recipe_Map sCentrifugeRecipes = new GT_Recipe_Map( + new HashSet<>(1200), + "gt.recipe.centrifuge", + "Centrifuge", + null, + RES_PATH_GUI + "basicmachines/Centrifuge", + 2, + 6, + 0, + 0, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sElectrolyzerRecipes = new GT_Recipe_Map( + new HashSet<>(300), + "gt.recipe.electrolyzer", + "Electrolyzer", + null, + RES_PATH_GUI + "basicmachines/Electrolyzer", + 2, + 6, + 0, + 0, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sBlastRecipes = new GT_Recipe_Map( + new HashSet<>(800), + "gt.recipe.blastfurnace", + "Blast Furnace", + null, + RES_PATH_GUI + "basicmachines/Default", + 6, + 6, + 1, + 0, + 1, + "Heat Capacity: ", + 1, + " K", + false, + true); + public static final GT_Recipe_Map sPlasmaForgeRecipes = new GT_Recipe_Map_PlasmaForge( + new HashSet<>(20), + "gt.recipe.plasmaforge", + "DTPF", + null, + RES_PATH_GUI + "basicmachines/PlasmaForge", + 1, + 1, + 0, + 0, + 1, + "Heat Capacity: ", + 1, + " K", + false, + true); + public static final GT_Recipe_Map sPrimitiveBlastRecipes = new GT_Recipe_Map( + new HashSet<>(200), + "gt.recipe.primitiveblastfurnace", + "Primitive Blast Furnace", + null, + RES_PATH_GUI + "basicmachines/Default", + 3, + 3, + 1, + 0, + 1, + E, + 1, + E, + false, + true); + public static final GT_Recipe_Map sImplosionRecipes = new GT_Recipe_Map( + new HashSet<>(900), + "gt.recipe.implosioncompressor", + "Implosion Compressor", + null, + RES_PATH_GUI + "basicmachines/Default", + 2, + 2, + 2, + 0, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sVacuumRecipes = new GT_Recipe_Map( + new HashSet<>(305), + "gt.recipe.vacuumfreezer", + "Vacuum Freezer", + null, + RES_PATH_GUI + "basicmachines/Default", + 1, + 1, + 0, + 0, + 1, + E, + 1, + E, + false, + true); + public static final GT_Recipe_Map sChemicalRecipes = new GT_Recipe_Map( + new HashSet<>(1170), + "gt.recipe.chemicalreactor", + "Chemical Reactor", + null, + RES_PATH_GUI + "basicmachines/ChemicalReactor", + 2, + 2, + 1, + 0, + 1, + E, + 1, + E, + true, + true); public static final GT_Recipe_Map sMultiblockChemicalRecipes = new GT_Recipe_Map_LargeChemicalReactor(); public static final GT_Recipe_Map sDistillationRecipes = new GT_Recipe_Map_DistillationTower(); public static final GT_Recipe_Map_OilCracker sCrackingRecipes = new GT_Recipe_Map_OilCracker(); @@ -856,44 +1689,468 @@ public class GT_Recipe implements Comparable<GT_Recipe> { */ @Deprecated public static final GT_Recipe_Map sCrakingRecipes = sCrackingRecipes; - public static final GT_Recipe_Map sPyrolyseRecipes = new GT_Recipe_Map(new HashSet<>(150), "gt.recipe.pyro", "Pyrolyse Oven", null, RES_PATH_GUI + "basicmachines/Default", 2, 1, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sWiremillRecipes = new GT_Recipe_Map(new HashSet<>(450), "gt.recipe.wiremill", "Wiremill", null, RES_PATH_GUI + "basicmachines/Wiremill", 1, 1, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sBenderRecipes = new GT_Recipe_Map(new HashSet<>(5000), "gt.recipe.metalbender", "Bending Machine", null, RES_PATH_GUI + "basicmachines/Bender", 2, 1, 2, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sAlloySmelterRecipes = new GT_Recipe_Map(new HashSet<>(12000), "gt.recipe.alloysmelter", "Alloy Smelter", null, RES_PATH_GUI + "basicmachines/AlloySmelter", 2, 1, 2, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sAssemblerRecipes = new GT_Recipe_Map_Assembler(new HashSet<>(8200), "gt.recipe.assembler", "Assembler", null, RES_PATH_GUI + "basicmachines/Assembler2", 9, 1, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sCircuitAssemblerRecipes = new GT_Recipe_Map_Assembler(new HashSet<>(605), "gt.recipe.circuitassembler", "Circuit Assembler", null, RES_PATH_GUI + "basicmachines/CircuitAssembler", 6, 1, 1, 0, 1, E, 1, E, true, true, !Loader.isModLoaded("neicustomdiagram")); - public static final GT_Recipe_Map sCannerRecipes = new GT_Recipe_Map(new HashSet<>(900), "gt.recipe.canner", "Canning Machine", null, RES_PATH_GUI + "basicmachines/Canner", 2, 2, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sCNCRecipes = new GT_Recipe_Map(new HashSet<>(100), "gt.recipe.cncmachine", "CNC Machine", null, RES_PATH_GUI + "basicmachines/Default", 2, 1, 2, 1, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sLatheRecipes = new GT_Recipe_Map(new HashSet<>(1150), "gt.recipe.lathe", "Lathe", null, RES_PATH_GUI + "basicmachines/Lathe", 1, 2, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sCutterRecipes = new GT_Recipe_Map(new HashSet<>(5125), "gt.recipe.cuttingsaw", "Cutting Machine", null, RES_PATH_GUI + "basicmachines/Cutter4", 2, 4, 1, 1, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sSlicerRecipes = new GT_Recipe_Map(new HashSet<>(20), "gt.recipe.slicer", "Slicing Machine", null, RES_PATH_GUI + "basicmachines/Slicer", 2, 1, 2, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sExtruderRecipes = new GT_Recipe_Map(new HashSet<>(13000), "gt.recipe.extruder", "Extruder", null, RES_PATH_GUI + "basicmachines/Extruder", 2, 1, 2, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sHammerRecipes = new GT_Recipe_Map(new HashSet<>(3800), "gt.recipe.hammer", "Forge Hammer", null, RES_PATH_GUI + "basicmachines/Hammer", 1, 1, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sAmplifiers = new GT_Recipe_Map(new HashSet<>(2), "gt.recipe.uuamplifier", "Amplifabricator", null, RES_PATH_GUI + "basicmachines/Amplifabricator", 1, 0, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sMassFabFakeRecipes = new GT_Recipe_Map(new HashSet<>(2), "gt.recipe.massfab", "Mass Fabrication", null, RES_PATH_GUI + "basicmachines/Massfabricator", 1, 0, 1, 0, 8, E, 1, E, true, true); - public static final GT_Recipe_Map_Fuel sDieselFuels = new GT_Recipe_Map_Fuel(new HashSet<>(20), "gt.recipe.dieselgeneratorfuel", "Combustion Generator Fuels", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); - public static final GT_Recipe_Map_Fuel sExtremeDieselFuels = new GT_Recipe_Map_Fuel(new HashSet<>(20), "gt.recipe.extremedieselgeneratorfuel", "Extreme Diesel Engine Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); - public static final GT_Recipe_Map_Fuel sTurbineFuels = new GT_Recipe_Map_Fuel(new HashSet<>(25), "gt.recipe.gasturbinefuel", "Gas Turbine Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); - public static final GT_Recipe_Map_Fuel sHotFuels = new GT_Recipe_Map_Fuel(new HashSet<>(10), "gt.recipe.thermalgeneratorfuel", "Thermal Generator Fuels", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, false); - public static final GT_Recipe_Map_Fuel sDenseLiquidFuels = new GT_Recipe_Map_Fuel(new HashSet<>(15), "gt.recipe.semifluidboilerfuels", "Semifluid Boiler Fuels", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); - public static final GT_Recipe_Map_Fuel sPlasmaFuels = new GT_Recipe_Map_Fuel(new HashSet<>(100), "gt.recipe.plasmageneratorfuels", "Plasma Generator Fuels", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); - public static final GT_Recipe_Map_Fuel sMagicFuels = new GT_Recipe_Map_Fuel(new HashSet<>(100), "gt.recipe.magicfuels", "Magic Energy Absorber Fuels", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); - public static final GT_Recipe_Map_Fuel sSmallNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<>(1), "gt.recipe.smallnaquadahreactor", "Naquadah Reactor MkI", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); - public static final GT_Recipe_Map_Fuel sLargeNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<>(1), "gt.recipe.largenaquadahreactor", "Naquadah Reactor MkII", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); - public static final GT_Recipe_Map_Fuel sHugeNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<>(1), "gt.recipe.fluidnaquadahreactor", "Naquadah Reactor MkIII", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); - public static final GT_Recipe_Map_Fuel sExtremeNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<>(1), "gt.recipe.hugenaquadahreactor", "Naquadah Reactor MkIV", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); - public static final GT_Recipe_Map_Fuel sUltraHugeNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<>(1), "gt.recipe.extrahugenaquadahreactor", "Naquadah Reactor MkV", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); - public static final GT_Recipe_Map_Fuel sFluidNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<>(1), "gt.recipe.fluidfuelnaquadahreactor", "Fluid Naquadah Reactor", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); - public static final GT_Recipe_Map_LargeBoilerFakeFuels sLargeBoilerFakeFuels = new GT_Recipe_Map_LargeBoilerFakeFuels(); + + public static final GT_Recipe_Map sPyrolyseRecipes = new GT_Recipe_Map( + new HashSet<>(150), + "gt.recipe.pyro", + "Pyrolyse Oven", + null, + RES_PATH_GUI + "basicmachines/Default", + 2, + 1, + 1, + 0, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sWiremillRecipes = new GT_Recipe_Map( + new HashSet<>(450), + "gt.recipe.wiremill", + "Wiremill", + null, + RES_PATH_GUI + "basicmachines/Wiremill", + 1, + 1, + 1, + 0, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sBenderRecipes = new GT_Recipe_Map( + new HashSet<>(5000), + "gt.recipe.metalbender", + "Bending Machine", + null, + RES_PATH_GUI + "basicmachines/Bender", + 2, + 1, + 2, + 0, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sAlloySmelterRecipes = new GT_Recipe_Map( + new HashSet<>(12000), + "gt.recipe.alloysmelter", + "Alloy Smelter", + null, + RES_PATH_GUI + "basicmachines/AlloySmelter", + 2, + 1, + 2, + 0, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sAssemblerRecipes = new GT_Recipe_Map_Assembler( + new HashSet<>(8200), + "gt.recipe.assembler", + "Assembler", + null, + RES_PATH_GUI + "basicmachines/Assembler2", + 9, + 1, + 1, + 0, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sCircuitAssemblerRecipes = new GT_Recipe_Map_Assembler( + new HashSet<>(605), + "gt.recipe.circuitassembler", + "Circuit Assembler", + null, + RES_PATH_GUI + "basicmachines/CircuitAssembler", + 6, + 1, + 1, + 0, + 1, + E, + 1, + E, + true, + true, + !Loader.isModLoaded("neicustomdiagram")); + public static final GT_Recipe_Map sCannerRecipes = new GT_Recipe_Map( + new HashSet<>(900), + "gt.recipe.canner", + "Canning Machine", + null, + RES_PATH_GUI + "basicmachines/Canner", + 2, + 2, + 1, + 0, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sCNCRecipes = new GT_Recipe_Map( + new HashSet<>(100), + "gt.recipe.cncmachine", + "CNC Machine", + null, + RES_PATH_GUI + "basicmachines/Default", + 2, + 1, + 2, + 1, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sLatheRecipes = new GT_Recipe_Map( + new HashSet<>(1150), + "gt.recipe.lathe", + "Lathe", + null, + RES_PATH_GUI + "basicmachines/Lathe", + 1, + 2, + 1, + 0, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sCutterRecipes = new GT_Recipe_Map( + new HashSet<>(5125), + "gt.recipe.cuttingsaw", + "Cutting Machine", + null, + RES_PATH_GUI + "basicmachines/Cutter4", + 2, + 4, + 1, + 1, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sSlicerRecipes = new GT_Recipe_Map( + new HashSet<>(20), + "gt.recipe.slicer", + "Slicing Machine", + null, + RES_PATH_GUI + "basicmachines/Slicer", + 2, + 1, + 2, + 0, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sExtruderRecipes = new GT_Recipe_Map( + new HashSet<>(13000), + "gt.recipe.extruder", + "Extruder", + null, + RES_PATH_GUI + "basicmachines/Extruder", + 2, + 1, + 2, + 0, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sHammerRecipes = new GT_Recipe_Map( + new HashSet<>(3800), + "gt.recipe.hammer", + "Forge Hammer", + null, + RES_PATH_GUI + "basicmachines/Hammer", + 1, + 1, + 1, + 0, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sAmplifiers = new GT_Recipe_Map( + new HashSet<>(2), + "gt.recipe.uuamplifier", + "Amplifabricator", + null, + RES_PATH_GUI + "basicmachines/Amplifabricator", + 1, + 0, + 1, + 0, + 1, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map sMassFabFakeRecipes = new GT_Recipe_Map( + new HashSet<>(2), + "gt.recipe.massfab", + "Mass Fabrication", + null, + RES_PATH_GUI + "basicmachines/Massfabricator", + 1, + 0, + 1, + 0, + 8, + E, + 1, + E, + true, + true); + public static final GT_Recipe_Map_Fuel sDieselFuels = new GT_Recipe_Map_Fuel( + new HashSet<>(20), + "gt.recipe.dieselgeneratorfuel", + "Combustion Generator Fuels", + null, + RES_PATH_GUI + "basicmachines/Default", + 1, + 1, + 0, + 0, + 1, + "Fuel Value: ", + 1000, + " EU", + true, + true); + public static final GT_Recipe_Map_Fuel sExtremeDieselFuels = new GT_Recipe_Map_Fuel( + new HashSet<>(20), + "gt.recipe.extremedieselgeneratorfuel", + "Extreme Diesel Engine Fuel", + null, + RES_PATH_GUI + "basicmachines/Default", + 1, + 1, + 0, + 0, + 1, + "Fuel Value: ", + 1000, + " EU", + true, + true); + public static final GT_Recipe_Map_Fuel sTurbineFuels = new GT_Recipe_Map_Fuel( + new HashSet<>(25), + "gt.recipe.gasturbinefuel", + "Gas Turbine Fuel", + null, + RES_PATH_GUI + "basicmachines/Default", + 1, + 1, + 0, + 0, + 1, + "Fuel Value: ", + 1000, + " EU", + true, + true); + public static final GT_Recipe_Map_Fuel sHotFuels = new GT_Recipe_Map_Fuel( + new HashSet<>(10), + "gt.recipe.thermalgeneratorfuel", + "Thermal Generator Fuels", + null, + RES_PATH_GUI + "basicmachines/Default", + 1, + 1, + 0, + 0, + 1, + "Fuel Value: ", + 1000, + " EU", + true, + false); + public static final GT_Recipe_Map_Fuel sDenseLiquidFuels = new GT_Recipe_Map_Fuel( + new HashSet<>(15), + "gt.recipe.semifluidboilerfuels", + "Semifluid Boiler Fuels", + null, + RES_PATH_GUI + "basicmachines/Default", + 1, + 1, + 0, + 0, + 1, + "Fuel Value: ", + 1000, + " EU", + true, + true); + public static final GT_Recipe_Map_Fuel sPlasmaFuels = new GT_Recipe_Map_Fuel( + new HashSet<>(100), + "gt.recipe.plasmageneratorfuels", + "Plasma Generator Fuels", + null, + RES_PATH_GUI + "basicmachines/Default", + 1, + 1, + 0, + 0, + 1, + "Fuel Value: ", + 1000, + " EU", + true, + true); + public static final GT_Recipe_Map_Fuel sMagicFuels = new GT_Recipe_Map_Fuel( + new HashSet<>(100), + "gt.recipe.magicfuels", + "Magic Energy Absorber Fuels", + null, + RES_PATH_GUI + "basicmachines/Default", + 1, + 1, + 0, + 0, + 1, + "Fuel Value: ", + 1000, + " EU", + true, + true); + public static final GT_Recipe_Map_Fuel sSmallNaquadahReactorFuels = new GT_Recipe_Map_Fuel( + new HashSet<>(1), + "gt.recipe.smallnaquadahreactor", + "Naquadah Reactor MkI", + null, + RES_PATH_GUI + "basicmachines/Default", + 1, + 1, + 0, + 0, + 1, + "Fuel Value: ", + 1000, + " EU", + true, + true); + public static final GT_Recipe_Map_Fuel sLargeNaquadahReactorFuels = new GT_Recipe_Map_Fuel( + new HashSet<>(1), + "gt.recipe.largenaquadahreactor", + "Naquadah Reactor MkII", + null, + RES_PATH_GUI + "basicmachines/Default", + 1, + 1, + 0, + 0, + 1, + "Fuel Value: ", + 1000, + " EU", + true, + true); + public static final GT_Recipe_Map_Fuel sHugeNaquadahReactorFuels = new GT_Recipe_Map_Fuel( + new HashSet<>(1), + "gt.recipe.fluidnaquadahreactor", + "Naquadah Reactor MkIII", + null, + RES_PATH_GUI + "basicmachines/Default", + 1, + 1, + 0, + 0, + 1, + "Fuel Value: ", + 1000, + " EU", + true, + true); + public static final GT_Recipe_Map_Fuel sExtremeNaquadahReactorFuels = new GT_Recipe_Map_Fuel( + new HashSet<>(1), + "gt.recipe.hugenaquadahreactor", + "Naquadah Reactor MkIV", + null, + RES_PATH_GUI + "basicmachines/Default", + 1, + 1, + 0, + 0, + 1, + "Fuel Value: ", + 1000, + " EU", + true, + true); + public static final GT_Recipe_Map_Fuel sUltraHugeNaquadahReactorFuels = new GT_Recipe_Map_Fuel( + new HashSet<>(1), + "gt.recipe.extrahugenaquadahreactor", + "Naquadah Reactor MkV", + null, + RES_PATH_GUI + "basicmachines/Default", + 1, + 1, + 0, + 0, + 1, + "Fuel Value: ", + 1000, + " EU", + true, + true); + public static final GT_Recipe_Map_Fuel sFluidNaquadahReactorFuels = new GT_Recipe_Map_Fuel( + new HashSet<>(1), + "gt.recipe.fluidfuelnaquadahreactor", + "Fluid Naquadah Reactor", + null, + RES_PATH_GUI + "basicmachines/Default", + 1, + 1, + 0, + 0, + 1, + "Fuel Value: ", + 1000, + " EU", + true, + true); + public static final GT_Recipe_Map_LargeBoilerFakeFuels sLargeBoilerFakeFuels = + new GT_Recipe_Map_LargeBoilerFakeFuels(); /** * HashMap of Recipes based on their Items */ - public final Map<GT_ItemStack, Collection<GT_Recipe>> mRecipeItemMap = new /*Concurrent*/HashMap<>(); + public final Map<GT_ItemStack, Collection<GT_Recipe>> mRecipeItemMap = new /*Concurrent*/ HashMap<>(); /** * HashMap of Recipes based on their Fluids */ - public final Map<Fluid, Collection<GT_Recipe>> mRecipeFluidMap = new /*Concurrent*/HashMap<>(); + public final Map<Fluid, Collection<GT_Recipe>> mRecipeFluidMap = new /*Concurrent*/ HashMap<>(); + public final HashSet<String> mRecipeFluidNameMap = new HashSet<>(); /** * The List of all Recipes @@ -911,8 +2168,14 @@ public class GT_Recipe implements Comparable<GT_Recipe> { * GUI used for NEI Display. Usually the GUI of the Machine itself */ public final String mNEIGUIPath; + public final String mNEISpecialValuePre, mNEISpecialValuePost; - public final int mUsualInputCount, mUsualOutputCount, mNEISpecialValueMultiplier, mMinimalInputItems, mMinimalInputFluids, mAmperage; + public final int mUsualInputCount, + mUsualOutputCount, + mNEISpecialValueMultiplier, + mMinimalInputItems, + mMinimalInputFluids, + mAmperage; public final boolean mNEIAllowed, mShowVoltageAmperageInNEI, mNEIUnificateOutput; /** @@ -946,7 +2209,23 @@ public class GT_Recipe implements Comparable<GT_Recipe> { * @param aNEIAllowed if NEI is allowed to display this Recipe Handler in general. * @param aNEIUnificateOutput if NEI generate oredict equivalents */ - public GT_Recipe_Map(Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed, boolean aNEIUnificateOutput) { + public GT_Recipe_Map( + Collection<GT_Recipe> aRecipeList, + String aUnlocalizedName, + String aLocalName, + String aNEIName, + String aNEIGUIPath, + int aUsualInputCount, + int aUsualOutputCount, + int aMinimalInputItems, + int aMinimalInputFluids, + int aAmperage, + String aNEISpecialValuePre, + int aNEISpecialValueMultiplier, + String aNEISpecialValuePost, + boolean aShowVoltageAmperageInNEI, + boolean aNEIAllowed, + boolean aNEIUnificateOutput) { sMappings.add(this); mNEIAllowed = aNEIAllowed; mShowVoltageAmperageInNEI = aShowVoltageAmperageInNEI; @@ -965,37 +2244,136 @@ public class GT_Recipe implements Comparable<GT_Recipe> { GregTech_API.sFluidMappings.add(mRecipeFluidMap); GregTech_API.sItemStackMappings.add(mRecipeItemMap); GT_LanguageManager.addStringLocalization(mUnlocalizedName = aUnlocalizedName, aLocalName); - mUniqueIdentifier = String.format("%s_%d_%d_%d_%d_%d", aUnlocalizedName, aAmperage, aUsualInputCount, aUsualOutputCount, aMinimalInputFluids, aMinimalInputItems); + mUniqueIdentifier = String.format( + "%s_%d_%d_%d_%d_%d", + aUnlocalizedName, + aAmperage, + aUsualInputCount, + aUsualOutputCount, + aMinimalInputFluids, + aMinimalInputItems); if (sIndexedMappings.put(mUniqueIdentifier, this) != null) throw new IllegalArgumentException("Duplicate recipe map registered: " + mUniqueIdentifier); } - public GT_Recipe_Map(Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { - this(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, aUsualInputCount, aUsualOutputCount, aMinimalInputItems, aMinimalInputFluids, aAmperage, aNEISpecialValuePre, aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed, true); - } - - public GT_Recipe addRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, int[] aOutputChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - return addRecipe(new GT_Recipe(aOptimize, aInputs, aOutputs, aSpecial, aOutputChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)); - } - - public GT_Recipe addRecipe(int[] aOutputChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - return addRecipe(new GT_Recipe(false, null, null, null, aOutputChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue), false, false, false); - } - - public GT_Recipe addRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - return addRecipe(new GT_Recipe(aOptimize, aInputs, aOutputs, aSpecial, null, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)); + public GT_Recipe_Map( + Collection<GT_Recipe> aRecipeList, + String aUnlocalizedName, + String aLocalName, + String aNEIName, + String aNEIGUIPath, + int aUsualInputCount, + int aUsualOutputCount, + int aMinimalInputItems, + int aMinimalInputFluids, + int aAmperage, + String aNEISpecialValuePre, + int aNEISpecialValueMultiplier, + String aNEISpecialValuePost, + boolean aShowVoltageAmperageInNEI, + boolean aNEIAllowed) { + this( + aRecipeList, + aUnlocalizedName, + aLocalName, + aNEIName, + aNEIGUIPath, + aUsualInputCount, + aUsualOutputCount, + aMinimalInputItems, + aMinimalInputFluids, + aAmperage, + aNEISpecialValuePre, + aNEISpecialValueMultiplier, + aNEISpecialValuePost, + aShowVoltageAmperageInNEI, + aNEIAllowed, + true); + } + + public GT_Recipe addRecipe( + boolean aOptimize, + ItemStack[] aInputs, + ItemStack[] aOutputs, + Object aSpecial, + int[] aOutputChances, + FluidStack[] aFluidInputs, + FluidStack[] aFluidOutputs, + int aDuration, + int aEUt, + int aSpecialValue) { + return addRecipe(new GT_Recipe( + aOptimize, + aInputs, + aOutputs, + aSpecial, + aOutputChances, + aFluidInputs, + aFluidOutputs, + aDuration, + aEUt, + aSpecialValue)); + } + + public GT_Recipe addRecipe( + int[] aOutputChances, + FluidStack[] aFluidInputs, + FluidStack[] aFluidOutputs, + int aDuration, + int aEUt, + int aSpecialValue) { + return addRecipe( + new GT_Recipe( + false, + null, + null, + null, + aOutputChances, + aFluidInputs, + aFluidOutputs, + aDuration, + aEUt, + aSpecialValue), + false, + false, + false); + } + + public GT_Recipe addRecipe( + boolean aOptimize, + ItemStack[] aInputs, + ItemStack[] aOutputs, + Object aSpecial, + FluidStack[] aFluidInputs, + FluidStack[] aFluidOutputs, + int aDuration, + int aEUt, + int aSpecialValue) { + return addRecipe(new GT_Recipe( + aOptimize, + aInputs, + aOutputs, + aSpecial, + null, + aFluidInputs, + aFluidOutputs, + aDuration, + aEUt, + aSpecialValue)); } public GT_Recipe addRecipe(GT_Recipe aRecipe) { return addRecipe(aRecipe, true, false, false); } - protected GT_Recipe addRecipe(GT_Recipe aRecipe, boolean aCheckForCollisions, boolean aFakeRecipe, boolean aHidden) { + protected GT_Recipe addRecipe( + GT_Recipe aRecipe, boolean aCheckForCollisions, boolean aFakeRecipe, boolean aHidden) { aRecipe.mHidden = aHidden; aRecipe.mFakeRecipe = aFakeRecipe; if (aRecipe.mFluidInputs.length < mMinimalInputFluids && aRecipe.mInputs.length < mMinimalInputItems) return null; - if (aCheckForCollisions && findRecipe(null, false, true, Long.MAX_VALUE, aRecipe.mFluidInputs, aRecipe.mInputs) != null) + if (aCheckForCollisions + && findRecipe(null, false, true, Long.MAX_VALUE, aRecipe.mFluidInputs, aRecipe.mInputs) != null) return null; return add(aRecipe); } @@ -1003,22 +2381,114 @@ public class GT_Recipe implements Comparable<GT_Recipe> { /** * Only used for fake Recipe Handlers to show something in NEI, do not use this for adding actual Recipes! findRecipe wont find fake Recipes, containsInput WILL find fake Recipes */ - public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, int[] aOutputChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - return addFakeRecipe(aCheckForCollisions, new GT_Recipe(false, aInputs, aOutputs, aSpecial, aOutputChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)); + public GT_Recipe addFakeRecipe( + boolean aCheckForCollisions, + ItemStack[] aInputs, + ItemStack[] aOutputs, + Object aSpecial, + int[] aOutputChances, + FluidStack[] aFluidInputs, + FluidStack[] aFluidOutputs, + int aDuration, + int aEUt, + int aSpecialValue) { + return addFakeRecipe( + aCheckForCollisions, + new GT_Recipe( + false, + aInputs, + aOutputs, + aSpecial, + aOutputChances, + aFluidInputs, + aFluidOutputs, + aDuration, + aEUt, + aSpecialValue)); } /** * Only used for fake Recipe Handlers to show something in NEI, do not use this for adding actual Recipes! findRecipe wont find fake Recipes, containsInput WILL find fake Recipes */ - public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - return addFakeRecipe(aCheckForCollisions, new GT_Recipe(false, aInputs, aOutputs, aSpecial, null, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)); - } - public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue,boolean hidden) { - return addFakeRecipe(aCheckForCollisions, new GT_Recipe(false, aInputs, aOutputs, aSpecial, null, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue),hidden); - } - - public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue, ItemStack[][] aAlt ,boolean hidden) { - return addFakeRecipe(aCheckForCollisions, new GT_Recipe_WithAlt(false, aInputs, aOutputs, aSpecial, null, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue, aAlt),hidden); + public GT_Recipe addFakeRecipe( + boolean aCheckForCollisions, + ItemStack[] aInputs, + ItemStack[] aOutputs, + Object aSpecial, + FluidStack[] aFluidInputs, + FluidStack[] aFluidOutputs, + int aDuration, + int aEUt, + int aSpecialValue) { + return addFakeRecipe( + aCheckForCollisions, + new GT_Recipe( + false, + aInputs, + aOutputs, + aSpecial, + null, + aFluidInputs, + aFluidOutputs, + aDuration, + aEUt, + aSpecialValue)); + } + + public GT_Recipe addFakeRecipe( + boolean aCheckForCollisions, + ItemStack[] aInputs, + ItemStack[] aOutputs, + Object aSpecial, + FluidStack[] aFluidInputs, + FluidStack[] aFluidOutputs, + int aDuration, + int aEUt, + int aSpecialValue, + boolean hidden) { + return addFakeRecipe( + aCheckForCollisions, + new GT_Recipe( + false, + aInputs, + aOutputs, + aSpecial, + null, + aFluidInputs, + aFluidOutputs, + aDuration, + aEUt, + aSpecialValue), + hidden); + } + + public GT_Recipe addFakeRecipe( + boolean aCheckForCollisions, + ItemStack[] aInputs, + ItemStack[] aOutputs, + Object aSpecial, + FluidStack[] aFluidInputs, + FluidStack[] aFluidOutputs, + int aDuration, + int aEUt, + int aSpecialValue, + ItemStack[][] aAlt, + boolean hidden) { + return addFakeRecipe( + aCheckForCollisions, + new GT_Recipe_WithAlt( + false, + aInputs, + aOutputs, + aSpecial, + null, + aFluidInputs, + aFluidOutputs, + aDuration, + aEUt, + aSpecialValue, + aAlt), + hidden); } /** @@ -1027,7 +2497,8 @@ public class GT_Recipe implements Comparable<GT_Recipe> { public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, GT_Recipe aRecipe) { return addRecipe(aRecipe, aCheckForCollisions, true, false); } - public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, GT_Recipe aRecipe,boolean hidden) { + + public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, GT_Recipe aRecipe, boolean hidden) { return addRecipe(aRecipe, aCheckForCollisions, true, hidden); } @@ -1035,7 +2506,8 @@ public class GT_Recipe implements Comparable<GT_Recipe> { mRecipeList.add(aRecipe); for (FluidStack aFluid : aRecipe.mFluidInputs) { if (aFluid != null) { - Collection<GT_Recipe> tList = mRecipeFluidMap.computeIfAbsent(aFluid.getFluid(), k -> new HashSet<>(1)); + Collection<GT_Recipe> tList = + mRecipeFluidMap.computeIfAbsent(aFluid.getFluid(), k -> new HashSet<>(1)); tList.add(aRecipe); mRecipeFluidNameMap.add(aFluid.getFluid().getName()); } @@ -1062,7 +2534,9 @@ public class GT_Recipe implements Comparable<GT_Recipe> { * @return if this Item is a valid Input for any for the Recipes */ public boolean containsInput(ItemStack aStack) { - return aStack != null && (mRecipeItemMap.containsKey(new GT_ItemStack(aStack)) || mRecipeItemMap.containsKey(new GT_ItemStack(aStack, true))); + return aStack != null + && (mRecipeItemMap.containsKey(new GT_ItemStack(aStack)) + || mRecipeItemMap.containsKey(new GT_ItemStack(aStack, true))); } /** @@ -1076,27 +2550,60 @@ public class GT_Recipe implements Comparable<GT_Recipe> { * @return if this Fluid is a valid Input for any for the Recipes */ public boolean containsInput(Fluid aFluid) { - return aFluid != null && mRecipeFluidNameMap.contains(aFluid.getName()); + return aFluid != null && mRecipeFluidNameMap.contains(aFluid.getName()); } - public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack... aInputs) { + public GT_Recipe findRecipe( + IHasWorldObjectAndCoords aTileEntity, + boolean aNotUnificated, + long aVoltage, + FluidStack[] aFluids, + ItemStack... aInputs) { return findRecipe(aTileEntity, null, aNotUnificated, aVoltage, aFluids, null, aInputs); } - public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, boolean aNotUnificated, boolean aDontCheckStackSizes, long aVoltage, FluidStack[] aFluids, ItemStack... aInputs) { - return findRecipe(aTileEntity, null, aNotUnificated, aDontCheckStackSizes, aVoltage, aFluids, null, aInputs); - } - - public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack... aInputs) { + public GT_Recipe findRecipe( + IHasWorldObjectAndCoords aTileEntity, + boolean aNotUnificated, + boolean aDontCheckStackSizes, + long aVoltage, + FluidStack[] aFluids, + ItemStack... aInputs) { + return findRecipe( + aTileEntity, null, aNotUnificated, aDontCheckStackSizes, aVoltage, aFluids, null, aInputs); + } + + public GT_Recipe findRecipe( + IHasWorldObjectAndCoords aTileEntity, + GT_Recipe aRecipe, + boolean aNotUnificated, + long aVoltage, + FluidStack[] aFluids, + ItemStack... aInputs) { return findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, null, aInputs); } - public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, boolean aDontCheckStackSizes, long aVoltage, FluidStack[] aFluids, ItemStack... aInputs) { - return findRecipe(aTileEntity, aRecipe, aNotUnificated, aDontCheckStackSizes, aVoltage, aFluids, null, aInputs); - } - - public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { - return findRecipe(aTileEntity, aRecipe, aNotUnificated, false, aVoltage, aFluids, aSpecialSlot, aInputs); + public GT_Recipe findRecipe( + IHasWorldObjectAndCoords aTileEntity, + GT_Recipe aRecipe, + boolean aNotUnificated, + boolean aDontCheckStackSizes, + long aVoltage, + FluidStack[] aFluids, + ItemStack... aInputs) { + return findRecipe( + aTileEntity, aRecipe, aNotUnificated, aDontCheckStackSizes, aVoltage, aFluids, null, aInputs); + } + + public GT_Recipe findRecipe( + IHasWorldObjectAndCoords aTileEntity, + GT_Recipe aRecipe, + boolean aNotUnificated, + long aVoltage, + FluidStack[] aFluids, + ItemStack aSpecialSlot, + ItemStack... aInputs) { + return findRecipe(aTileEntity, aRecipe, aNotUnificated, false, aVoltage, aFluids, aSpecialSlot, aInputs); } /** * finds a Recipe matching the aFluid and ItemStack Inputs. @@ -1111,12 +2618,22 @@ public class GT_Recipe implements Comparable<GT_Recipe> { * @param aInputs the Item Inputs * @return the Recipe it has found or null for no matching Recipe */ - public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, boolean aDontCheckStackSizes, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { + public GT_Recipe findRecipe( + IHasWorldObjectAndCoords aTileEntity, + GT_Recipe aRecipe, + boolean aNotUnificated, + boolean aDontCheckStackSizes, + long aVoltage, + FluidStack[] aFluids, + ItemStack aSpecialSlot, + ItemStack... aInputs) { // No Recipes? Well, nothing to be found then. if (mRecipeList.isEmpty()) return null; - // Some Recipe Classes require a certain amount of Inputs of certain kinds. Like "at least 1 Fluid + 1 Stack" or "at least 2 Stacks" before they start searching for Recipes. - // This improves Performance massively, especially if people leave things like Circuits, Molds or Shapes in their Machines to select Sub Recipes. + // Some Recipe Classes require a certain amount of Inputs of certain kinds. Like "at least 1 Fluid + 1 + // Stack" or "at least 2 Stacks" before they start searching for Recipes. + // This improves Performance massively, especially if people leave things like Circuits, Molds or Shapes in + // their Machines to select Sub Recipes. if (GregTech_API.sPostloadFinished) { if (mMinimalInputFluids > 0) { if (aFluids == null) return null; @@ -1128,7 +2645,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { if (aInputs == null) return null; int tAmount = 0; for (ItemStack aInput : aInputs) if (aInput != null) tAmount++; - if (tAmount < mMinimalInputItems) return null; + if (tAmount < mMinimalInputItems) return null; } } @@ -1137,32 +2654,41 @@ public class GT_Recipe implements Comparable<GT_Recipe> { // Check the Recipe which has been used last time in order to not have to search for it again, if possible. if (aRecipe != null) - if (!aRecipe.mFakeRecipe && aRecipe.mCanBeBuffered && aRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) + if (!aRecipe.mFakeRecipe + && aRecipe.mCanBeBuffered + && aRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) return aRecipe.mEnabled && aVoltage * mAmperage >= aRecipe.mEUt ? aRecipe : null; // Now look for the Recipes inside the Item HashMaps, but only when the Recipes usually have Items. - if (mUsualInputCount > 0 && aInputs != null) for (ItemStack tStack : aInputs) - if (tStack != null) { - Collection<GT_Recipe> - tRecipes = mRecipeItemMap.get(new GT_ItemStack(tStack)); - if (tRecipes != null) for (GT_Recipe tRecipe : tRecipes) - if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) - return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null; - tRecipes = mRecipeItemMap.get(new GT_ItemStack(tStack, true)); - if (tRecipes != null) for (GT_Recipe tRecipe : tRecipes) - if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) - return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null; - } + if (mUsualInputCount > 0 && aInputs != null) + for (ItemStack tStack : aInputs) + if (tStack != null) { + Collection<GT_Recipe> tRecipes = mRecipeItemMap.get(new GT_ItemStack(tStack)); + if (tRecipes != null) + for (GT_Recipe tRecipe : tRecipes) + if (!tRecipe.mFakeRecipe + && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) + return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null; + tRecipes = mRecipeItemMap.get(new GT_ItemStack(tStack, true)); + if (tRecipes != null) + for (GT_Recipe tRecipe : tRecipes) + if (!tRecipe.mFakeRecipe + && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) + return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null; + } - // If the minimal Amount of Items for the Recipe is 0, then it could be a Fluid-Only Recipe, so check that Map too. - if (mMinimalInputItems == 0 && aFluids != null) for (FluidStack aFluid : aFluids) - if (aFluid != null) { - Collection<GT_Recipe> - tRecipes = mRecipeFluidMap.get(aFluid.getFluid()); - if (tRecipes != null) for (GT_Recipe tRecipe : tRecipes) - if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) - return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null; - } + // If the minimal Amount of Items for the Recipe is 0, then it could be a Fluid-Only Recipe, so check that + // Map too. + if (mMinimalInputItems == 0 && aFluids != null) + for (FluidStack aFluid : aFluids) + if (aFluid != null) { + Collection<GT_Recipe> tRecipes = mRecipeFluidMap.get(aFluid.getFluid()); + if (tRecipes != null) + for (GT_Recipe tRecipe : tRecipes) + if (!tRecipe.mFakeRecipe + && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) + return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null; + } // And nothing has been found. return null; @@ -1203,7 +2729,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { * Overriding this method and getOutputPositionedStacks allows custom NEI stack placement * @return A list of input stacks */ - public ArrayList<PositionedStack> getInputPositionedStacks(GT_Recipe recipe){ + public ArrayList<PositionedStack> getInputPositionedStacks(GT_Recipe recipe) { return null; } @@ -1211,12 +2737,11 @@ public class GT_Recipe implements Comparable<GT_Recipe> { * Overriding this method and getInputPositionedStacks allows custom NEI stack placement * @return A list of output stacks */ - public ArrayList<PositionedStack> getOutputPositionedStacks(GT_Recipe recipe){ + public ArrayList<PositionedStack> getOutputPositionedStacks(GT_Recipe recipe) { return null; } - public void addRecipe(Object o, FluidStack[] fluidInputArray, FluidStack[] fluidOutputArray) { - } + public void addRecipe(Object o, FluidStack[] fluidInputArray, FluidStack[] fluidOutputArray) {} } // ----------------------------------------------------------------------------------------------------------------- @@ -1227,8 +2752,38 @@ public class GT_Recipe implements Comparable<GT_Recipe> { * Abstract Class for general Recipe Handling of non GT Recipes */ public abstract static class GT_Recipe_Map_NonGTRecipes extends GT_Recipe_Map { - public GT_Recipe_Map_NonGTRecipes(Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { - super(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, aUsualInputCount, aUsualOutputCount, aMinimalInputItems, aMinimalInputFluids, aAmperage, aNEISpecialValuePre, aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed); + public GT_Recipe_Map_NonGTRecipes( + Collection<GT_Recipe> aRecipeList, + String aUnlocalizedName, + String aLocalName, + String aNEIName, + String aNEIGUIPath, + int aUsualInputCount, + int aUsualOutputCount, + int aMinimalInputItems, + int aMinimalInputFluids, + int aAmperage, + String aNEISpecialValuePre, + int aNEISpecialValueMultiplier, + String aNEISpecialValuePost, + boolean aShowVoltageAmperageInNEI, + boolean aNEIAllowed) { + super( + aRecipeList, + aUnlocalizedName, + aLocalName, + aNEIName, + aNEIGUIPath, + aUsualInputCount, + aUsualOutputCount, + aMinimalInputItems, + aMinimalInputFluids, + aAmperage, + aNEISpecialValuePre, + aNEISpecialValueMultiplier, + aNEISpecialValuePost, + aShowVoltageAmperageInNEI, + aNEIAllowed); } @Override @@ -1247,12 +2802,31 @@ public class GT_Recipe implements Comparable<GT_Recipe> { } @Override - public GT_Recipe addRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, int[] aOutputChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { + public GT_Recipe addRecipe( + boolean aOptimize, + ItemStack[] aInputs, + ItemStack[] aOutputs, + Object aSpecial, + int[] aOutputChances, + FluidStack[] aFluidInputs, + FluidStack[] aFluidOutputs, + int aDuration, + int aEUt, + int aSpecialValue) { return null; } @Override - public GT_Recipe addRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { + public GT_Recipe addRecipe( + boolean aOptimize, + ItemStack[] aInputs, + ItemStack[] aOutputs, + Object aSpecial, + FluidStack[] aFluidInputs, + FluidStack[] aFluidOutputs, + int aDuration, + int aEUt, + int aSpecialValue) { return null; } @@ -1262,17 +2836,46 @@ public class GT_Recipe implements Comparable<GT_Recipe> { } @Override - public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, int[] aOutputChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { + public GT_Recipe addFakeRecipe( + boolean aCheckForCollisions, + ItemStack[] aInputs, + ItemStack[] aOutputs, + Object aSpecial, + int[] aOutputChances, + FluidStack[] aFluidInputs, + FluidStack[] aFluidOutputs, + int aDuration, + int aEUt, + int aSpecialValue) { return null; } @Override - public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { + public GT_Recipe addFakeRecipe( + boolean aCheckForCollisions, + ItemStack[] aInputs, + ItemStack[] aOutputs, + Object aSpecial, + FluidStack[] aFluidInputs, + FluidStack[] aFluidOutputs, + int aDuration, + int aEUt, + int aSpecialValue) { return null; } @Override - public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue,boolean hidden) { + public GT_Recipe addFakeRecipe( + boolean aCheckForCollisions, + ItemStack[] aInputs, + ItemStack[] aOutputs, + Object aSpecial, + FluidStack[] aFluidInputs, + FluidStack[] aFluidOutputs, + int aDuration, + int aEUt, + int aSpecialValue, + boolean hidden) { return null; } @@ -1287,7 +2890,9 @@ public class GT_Recipe implements Comparable<GT_Recipe> { } @Override - public void reInit() {/**/} + public void reInit() { + /**/ + } @Override protected GT_Recipe addToItemMap(GT_Recipe aRecipe) { @@ -1300,8 +2905,39 @@ public class GT_Recipe implements Comparable<GT_Recipe> { */ public static class GT_Recipe_Map_Fuel extends GT_Recipe_Map { private final Map<String, GT_Recipe> mRecipesByFluidInput = new HashMap<>(); - public GT_Recipe_Map_Fuel(Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { - super(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, aUsualInputCount, aUsualOutputCount, aMinimalInputItems, aMinimalInputFluids, aAmperage, aNEISpecialValuePre, aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed); + + public GT_Recipe_Map_Fuel( + Collection<GT_Recipe> aRecipeList, + String aUnlocalizedName, + String aLocalName, + String aNEIName, + String aNEIGUIPath, + int aUsualInputCount, + int aUsualOutputCount, + int aMinimalInputItems, + int aMinimalInputFluids, + int aAmperage, + String aNEISpecialValuePre, + int aNEISpecialValueMultiplier, + String aNEISpecialValuePost, + boolean aShowVoltageAmperageInNEI, + boolean aNEIAllowed) { + super( + aRecipeList, + aUnlocalizedName, + aLocalName, + aNEIName, + aNEIGUIPath, + aUsualInputCount, + aUsualOutputCount, + aMinimalInputItems, + aMinimalInputFluids, + aAmperage, + aNEISpecialValuePre, + aNEISpecialValueMultiplier, + aNEISpecialValuePost, + aShowVoltageAmperageInNEI, + aNEIAllowed); } public GT_Recipe addFuel(ItemStack aInput, ItemStack aOutput, int aFuelValueInEU) { @@ -1316,27 +2952,50 @@ public class GT_Recipe implements Comparable<GT_Recipe> { return addFuel(null, null, aFluidInput, aFluidOutput, 10000, aFuelValueInEU); } - public GT_Recipe addFuel(ItemStack aInput, ItemStack aOutput, FluidStack aFluidInput, FluidStack aFluidOutput, int aFuelValueInEU) { + public GT_Recipe addFuel( + ItemStack aInput, + ItemStack aOutput, + FluidStack aFluidInput, + FluidStack aFluidOutput, + int aFuelValueInEU) { return addFuel(aInput, aOutput, aFluidInput, aFluidOutput, 10000, aFuelValueInEU); } - public GT_Recipe addFuel(ItemStack aInput, ItemStack aOutput, FluidStack aFluidInput, FluidStack aFluidOutput, int aChance, int aFuelValueInEU) { - return addRecipe(true, new ItemStack[]{aInput}, new ItemStack[]{aOutput}, null, new int[]{aChance}, new FluidStack[]{aFluidInput}, new FluidStack[]{aFluidOutput}, 0, 0, aFuelValueInEU); + public GT_Recipe addFuel( + ItemStack aInput, + ItemStack aOutput, + FluidStack aFluidInput, + FluidStack aFluidOutput, + int aChance, + int aFuelValueInEU) { + return addRecipe( + true, + new ItemStack[] {aInput}, + new ItemStack[] {aOutput}, + null, + new int[] {aChance}, + new FluidStack[] {aFluidInput}, + new FluidStack[] {aFluidOutput}, + 0, + 0, + aFuelValueInEU); } @Override public GT_Recipe add(GT_Recipe aRecipe) { aRecipe = super.add(aRecipe); - if (aRecipe.mInputs != null && GT_Utility.getNonnullElementCount(aRecipe.mInputs) == 1 && - (aRecipe.mFluidInputs == null || GT_Utility.getNonnullElementCount(aRecipe.mFluidInputs) == 0)) { + if (aRecipe.mInputs != null + && GT_Utility.getNonnullElementCount(aRecipe.mInputs) == 1 + && (aRecipe.mFluidInputs == null || GT_Utility.getNonnullElementCount(aRecipe.mFluidInputs) == 0)) { FluidStack tFluid = GT_Utility.getFluidForFilledItem(aRecipe.mInputs[0], true); if (tFluid != null) { tFluid.amount = 0; mRecipesByFluidInput.put(tFluid.getUnlocalizedName(), aRecipe); } - } else if ((aRecipe.mInputs == null || GT_Utility.getNonnullElementCount(aRecipe.mInputs) == 0) && - aRecipe.mFluidInputs != null && GT_Utility.getNonnullElementCount(aRecipe.mFluidInputs) == 1 && - aRecipe.mFluidInputs[0] != null) { + } else if ((aRecipe.mInputs == null || GT_Utility.getNonnullElementCount(aRecipe.mInputs) == 0) + && aRecipe.mFluidInputs != null + && GT_Utility.getNonnullElementCount(aRecipe.mFluidInputs) == 1 + && aRecipe.mFluidInputs[0] != null) { mRecipesByFluidInput.put(aRecipe.mFluidInputs[0].getUnlocalizedName(), aRecipe); } return aRecipe; @@ -1351,16 +3010,65 @@ public class GT_Recipe implements Comparable<GT_Recipe> { * Special Class for Furnace Recipe handling. */ public static class GT_Recipe_Map_Furnace extends GT_Recipe_Map_NonGTRecipes { - public GT_Recipe_Map_Furnace(Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { - super(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, aUsualInputCount, aUsualOutputCount, aMinimalInputItems, aMinimalInputFluids, aAmperage, aNEISpecialValuePre, aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed); + public GT_Recipe_Map_Furnace( + Collection<GT_Recipe> aRecipeList, + String aUnlocalizedName, + String aLocalName, + String aNEIName, + String aNEIGUIPath, + int aUsualInputCount, + int aUsualOutputCount, + int aMinimalInputItems, + int aMinimalInputFluids, + int aAmperage, + String aNEISpecialValuePre, + int aNEISpecialValueMultiplier, + String aNEISpecialValuePost, + boolean aShowVoltageAmperageInNEI, + boolean aNEIAllowed) { + super( + aRecipeList, + aUnlocalizedName, + aLocalName, + aNEIName, + aNEIGUIPath, + aUsualInputCount, + aUsualOutputCount, + aMinimalInputItems, + aMinimalInputFluids, + aAmperage, + aNEISpecialValuePre, + aNEISpecialValueMultiplier, + aNEISpecialValuePost, + aShowVoltageAmperageInNEI, + aNEIAllowed); } @Override - public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { + public GT_Recipe findRecipe( + IHasWorldObjectAndCoords aTileEntity, + GT_Recipe aRecipe, + boolean aNotUnificated, + long aVoltage, + FluidStack[] aFluids, + ItemStack aSpecialSlot, + ItemStack... aInputs) { if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null) return null; if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe; ItemStack tOutput = GT_ModHandler.getSmeltingOutput(aInputs[0], false, null); - return tOutput == null ? null : new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(1, aInputs[0])}, new ItemStack[]{tOutput}, null, null, null, null, 128, 4, 0); + return tOutput == null + ? null + : new GT_Recipe( + false, + new ItemStack[] {GT_Utility.copyAmount(1, aInputs[0])}, + new ItemStack[] {tOutput}, + null, + null, + null, + null, + 128, + 4, + 0); } @Override @@ -1373,42 +3081,96 @@ public class GT_Recipe implements Comparable<GT_Recipe> { * Special Class for Microwave Recipe handling. */ public static class GT_Recipe_Map_Microwave extends GT_Recipe_Map_NonGTRecipes { - public GT_Recipe_Map_Microwave(Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { - super(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, aUsualInputCount, aUsualOutputCount, aMinimalInputItems, aMinimalInputFluids, aAmperage, aNEISpecialValuePre, aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed); + public GT_Recipe_Map_Microwave( + Collection<GT_Recipe> aRecipeList, + String aUnlocalizedName, + String aLocalName, + String aNEIName, + String aNEIGUIPath, + int aUsualInputCount, + int aUsualOutputCount, + int aMinimalInputItems, + int aMinimalInputFluids, + int aAmperage, + String aNEISpecialValuePre, + int aNEISpecialValueMultiplier, + String aNEISpecialValuePost, + boolean aShowVoltageAmperageInNEI, + boolean aNEIAllowed) { + super( + aRecipeList, + aUnlocalizedName, + aLocalName, + aNEIName, + aNEIGUIPath, + aUsualInputCount, + aUsualOutputCount, + aMinimalInputItems, + aMinimalInputFluids, + aAmperage, + aNEISpecialValuePre, + aNEISpecialValueMultiplier, + aNEISpecialValuePost, + aShowVoltageAmperageInNEI, + aNEIAllowed); } @Override - public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { + public GT_Recipe findRecipe( + IHasWorldObjectAndCoords aTileEntity, + GT_Recipe aRecipe, + boolean aNotUnificated, + long aVoltage, + FluidStack[] aFluids, + ItemStack aSpecialSlot, + ItemStack... aInputs) { if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null) return null; if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe; ItemStack tOutput = GT_ModHandler.getSmeltingOutput(aInputs[0], false, null); if (GT_Utility.areStacksEqual(aInputs[0], new ItemStack(Items.book, 1, W))) { - return new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(1, aInputs[0])}, new ItemStack[]{GT_Utility.getWrittenBook("Manual_Microwave", ItemList.Book_Written_03.get(1))}, null, null, null, null, 32, 4, 0); + return new GT_Recipe( + false, + new ItemStack[] {GT_Utility.copyAmount(1, aInputs[0])}, + new ItemStack[] {GT_Utility.getWrittenBook("Manual_Microwave", ItemList.Book_Written_03.get(1)) + }, + null, + null, + null, + null, + 32, + 4, + 0); } - // Check Container Item of Input since it is around the Input, then the Input itself, then Container Item of Output and last check the Output itself - for (ItemStack tStack : new ItemStack[]{GT_Utility.getContainerItem(aInputs[0], true), aInputs[0], GT_Utility.getContainerItem(tOutput, true), tOutput}) + // Check Container Item of Input since it is around the Input, then the Input itself, then Container Item of + // Output and last check the Output itself + for (ItemStack tStack : new ItemStack[] { + GT_Utility.getContainerItem(aInputs[0], true), + aInputs[0], + GT_Utility.getContainerItem(tOutput, true), + tOutput + }) if (tStack != null) { if (GT_Utility.areStacksEqual(tStack, new ItemStack(Blocks.netherrack, 1, W), true) || GT_Utility.areStacksEqual(tStack, new ItemStack(Blocks.tnt, 1, W), true) || GT_Utility.areStacksEqual(tStack, new ItemStack(Items.egg, 1, W), true) || GT_Utility.areStacksEqual(tStack, new ItemStack(Items.firework_charge, 1, W), true) || GT_Utility.areStacksEqual(tStack, new ItemStack(Items.fireworks, 1, W), true) - || GT_Utility.areStacksEqual(tStack, new ItemStack(Items.fire_charge, 1, W), true) - ) { + || GT_Utility.areStacksEqual(tStack, new ItemStack(Items.fire_charge, 1, W), true)) { if (aTileEntity instanceof IGregTechTileEntity) { - GT_Log.exp.println("Microwave Explosion due to TNT || EGG || FIREWORKCHARGE || FIREWORK || FIRE CHARGE"); + GT_Log.exp.println( + "Microwave Explosion due to TNT || EGG || FIREWORKCHARGE || FIREWORK || FIRE CHARGE"); ((IGregTechTileEntity) aTileEntity).doExplosion(aVoltage * 4); } return null; } ItemData tData = GT_OreDictUnificator.getItemData(tStack); - if (tData != null) { if (tData.mMaterial != null && tData.mMaterial.mMaterial != null) { - if (tData.mMaterial.mMaterial.contains(SubTag.METAL) || tData.mMaterial.mMaterial.contains(SubTag.EXPLOSIVE)) { + if (tData.mMaterial.mMaterial.contains(SubTag.METAL) + || tData.mMaterial.mMaterial.contains(SubTag.EXPLOSIVE)) { if (aTileEntity instanceof IGregTechTileEntity) { GT_Log.exp.println("Microwave Explosion due to METAL insertion"); ((IGregTechTileEntity) aTileEntity).doExplosion(aVoltage * 4); @@ -1425,7 +3187,8 @@ public class GT_Recipe implements Comparable<GT_Recipe> { } for (MaterialStack tMaterial : tData.mByProducts) if (tMaterial != null) { - if (tMaterial.mMaterial.contains(SubTag.METAL) || tMaterial.mMaterial.contains(SubTag.EXPLOSIVE)) { + if (tMaterial.mMaterial.contains(SubTag.METAL) + || tMaterial.mMaterial.contains(SubTag.EXPLOSIVE)) { if (aTileEntity instanceof IGregTechTileEntity) { GT_Log.exp.println("Microwave Explosion due to METAL insertion"); ((IGregTechTileEntity) aTileEntity).doExplosion(aVoltage * 4); @@ -1448,10 +3211,21 @@ public class GT_Recipe implements Comparable<GT_Recipe> { } return null; } - } - return tOutput == null ? null : new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(1, aInputs[0])}, new ItemStack[]{tOutput}, null, null, null, null, 32, 4, 0); + return tOutput == null + ? null + : new GT_Recipe( + false, + new ItemStack[] {GT_Utility.copyAmount(1, aInputs[0])}, + new ItemStack[] {tOutput}, + null, + null, + null, + null, + 32, + 4, + 0); } @Override @@ -1464,21 +3238,69 @@ public class GT_Recipe implements Comparable<GT_Recipe> { * Special Class for Unboxinator handling. */ public static class GT_Recipe_Map_Unboxinator extends GT_Recipe_Map { - public GT_Recipe_Map_Unboxinator(Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { - super(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, aUsualInputCount, aUsualOutputCount, aMinimalInputItems, aMinimalInputFluids, aAmperage, aNEISpecialValuePre, aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed); + public GT_Recipe_Map_Unboxinator( + Collection<GT_Recipe> aRecipeList, + String aUnlocalizedName, + String aLocalName, + String aNEIName, + String aNEIGUIPath, + int aUsualInputCount, + int aUsualOutputCount, + int aMinimalInputItems, + int aMinimalInputFluids, + int aAmperage, + String aNEISpecialValuePre, + int aNEISpecialValueMultiplier, + String aNEISpecialValuePost, + boolean aShowVoltageAmperageInNEI, + boolean aNEIAllowed) { + super( + aRecipeList, + aUnlocalizedName, + aLocalName, + aNEIName, + aNEIGUIPath, + aUsualInputCount, + aUsualOutputCount, + aMinimalInputItems, + aMinimalInputFluids, + aAmperage, + aNEISpecialValuePre, + aNEISpecialValueMultiplier, + aNEISpecialValuePost, + aShowVoltageAmperageInNEI, + aNEIAllowed); } @Override - public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { + public GT_Recipe findRecipe( + IHasWorldObjectAndCoords aTileEntity, + GT_Recipe aRecipe, + boolean aNotUnificated, + long aVoltage, + FluidStack[] aFluids, + ItemStack aSpecialSlot, + ItemStack... aInputs) { if (aInputs == null || aInputs.length <= 0 || !ItemList.IC2_Scrapbox.isStackEqual(aInputs[0], false, true)) return super.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot, aInputs); ItemStack tOutput = GT_ModHandler.getRandomScrapboxDrop(); if (tOutput == null) return super.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot, aInputs); - GT_Recipe rRecipe = new GT_Recipe(false, new ItemStack[]{ItemList.IC2_Scrapbox.get(1)}, new ItemStack[]{tOutput}, null, null, null, null, 16, 1, 0); + GT_Recipe rRecipe = new GT_Recipe( + false, + new ItemStack[] {ItemList.IC2_Scrapbox.get(1)}, + new ItemStack[] {tOutput}, + null, + null, + null, + null, + 16, + 1, + 0); // It is not allowed to be buffered due to the random Output rRecipe.mCanBeBuffered = false; - // Due to its randomness it is not good if there are Items in the Output Slot, because those Items could manipulate the outcome. + // Due to its randomness it is not good if there are Items in the Output Slot, because those Items could + // manipulate the outcome. rRecipe.mNeedsEmptyOutput = true; return rRecipe; } @@ -1493,25 +3315,86 @@ public class GT_Recipe implements Comparable<GT_Recipe> { * Special Class for Fluid Canner handling. */ public static class GT_Recipe_Map_FluidCanner extends GT_Recipe_Map { - public GT_Recipe_Map_FluidCanner(Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { - super(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, aUsualInputCount, aUsualOutputCount, aMinimalInputItems, aMinimalInputFluids, aAmperage, aNEISpecialValuePre, aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed); + public GT_Recipe_Map_FluidCanner( + Collection<GT_Recipe> aRecipeList, + String aUnlocalizedName, + String aLocalName, + String aNEIName, + String aNEIGUIPath, + int aUsualInputCount, + int aUsualOutputCount, + int aMinimalInputItems, + int aMinimalInputFluids, + int aAmperage, + String aNEISpecialValuePre, + int aNEISpecialValueMultiplier, + String aNEISpecialValuePost, + boolean aShowVoltageAmperageInNEI, + boolean aNEIAllowed) { + super( + aRecipeList, + aUnlocalizedName, + aLocalName, + aNEIName, + aNEIGUIPath, + aUsualInputCount, + aUsualOutputCount, + aMinimalInputItems, + aMinimalInputFluids, + aAmperage, + aNEISpecialValuePre, + aNEISpecialValueMultiplier, + aNEISpecialValuePost, + aShowVoltageAmperageInNEI, + aNEIAllowed); } @Override - public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { - GT_Recipe rRecipe = super.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot, aInputs); - if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null || rRecipe != null || !GregTech_API.sPostloadFinished) - return rRecipe; + public GT_Recipe findRecipe( + IHasWorldObjectAndCoords aTileEntity, + GT_Recipe aRecipe, + boolean aNotUnificated, + long aVoltage, + FluidStack[] aFluids, + ItemStack aSpecialSlot, + ItemStack... aInputs) { + GT_Recipe rRecipe = + super.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot, aInputs); + if (aInputs == null + || aInputs.length <= 0 + || aInputs[0] == null + || rRecipe != null + || !GregTech_API.sPostloadFinished) return rRecipe; if (aFluids != null && aFluids.length > 0 && aFluids[0] != null) { ItemStack tOutput = GT_Utility.fillFluidContainer(aFluids[0], aInputs[0], false, true); FluidStack tFluid = GT_Utility.getFluidForFilledItem(tOutput, true); if (tFluid != null) - rRecipe = new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(1, aInputs[0])}, new ItemStack[]{tOutput}, null, null, new FluidStack[]{tFluid}, null, Math.max(tFluid.amount / 64, 16), 1, 0); + rRecipe = new GT_Recipe( + false, + new ItemStack[] {GT_Utility.copyAmount(1, aInputs[0])}, + new ItemStack[] {tOutput}, + null, + null, + new FluidStack[] {tFluid}, + null, + Math.max(tFluid.amount / 64, 16), + 1, + 0); } if (rRecipe == null) { FluidStack tFluid = GT_Utility.getFluidForFilledItem(aInputs[0], true); if (tFluid != null) - rRecipe = new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(1, aInputs[0])}, new ItemStack[]{GT_Utility.getContainerItem(aInputs[0], true)}, null, null, null, new FluidStack[]{tFluid}, Math.max(tFluid.amount / 64, 16), 1, 0); + rRecipe = new GT_Recipe( + false, + new ItemStack[] {GT_Utility.copyAmount(1, aInputs[0])}, + new ItemStack[] {GT_Utility.getContainerItem(aInputs[0], true)}, + null, + null, + null, + new FluidStack[] {tFluid}, + Math.max(tFluid.amount / 64, 16), + 1, + 0); } if (rRecipe != null) rRecipe.mCanBeBuffered = false; return rRecipe; @@ -1519,7 +3402,10 @@ public class GT_Recipe implements Comparable<GT_Recipe> { @Override public boolean containsInput(ItemStack aStack) { - return aStack != null && (super.containsInput(aStack) || (aStack.getItem() instanceof IFluidContainerItem && ((IFluidContainerItem) aStack.getItem()).getCapacity(aStack) > 0)); + return aStack != null + && (super.containsInput(aStack) + || (aStack.getItem() instanceof IFluidContainerItem + && ((IFluidContainerItem) aStack.getItem()).getCapacity(aStack) > 0)); } @Override @@ -1537,15 +3423,64 @@ public class GT_Recipe implements Comparable<GT_Recipe> { * Special Class for Recycler Recipe handling. */ public static class GT_Recipe_Map_Recycler extends GT_Recipe_Map_NonGTRecipes { - public GT_Recipe_Map_Recycler(Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { - super(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, aUsualInputCount, aUsualOutputCount, aMinimalInputItems, aMinimalInputFluids, aAmperage, aNEISpecialValuePre, aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed); + public GT_Recipe_Map_Recycler( + Collection<GT_Recipe> aRecipeList, + String aUnlocalizedName, + String aLocalName, + String aNEIName, + String aNEIGUIPath, + int aUsualInputCount, + int aUsualOutputCount, + int aMinimalInputItems, + int aMinimalInputFluids, + int aAmperage, + String aNEISpecialValuePre, + int aNEISpecialValueMultiplier, + String aNEISpecialValuePost, + boolean aShowVoltageAmperageInNEI, + boolean aNEIAllowed) { + super( + aRecipeList, + aUnlocalizedName, + aLocalName, + aNEIName, + aNEIGUIPath, + aUsualInputCount, + aUsualOutputCount, + aMinimalInputItems, + aMinimalInputFluids, + aAmperage, + aNEISpecialValuePre, + aNEISpecialValueMultiplier, + aNEISpecialValuePost, + aShowVoltageAmperageInNEI, + aNEIAllowed); } @Override - public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { + public GT_Recipe findRecipe( + IHasWorldObjectAndCoords aTileEntity, + GT_Recipe aRecipe, + boolean aNotUnificated, + long aVoltage, + FluidStack[] aFluids, + ItemStack aSpecialSlot, + ItemStack... aInputs) { if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null) return null; if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe; - return new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(1, aInputs[0])}, GT_ModHandler.getRecyclerOutput(GT_Utility.copyAmount(64, aInputs[0]), 0) == null ? null : new ItemStack[]{ItemList.IC2_Scrap.get(1)}, null, new int[]{1250}, null, null, 45, 1, 0); + return new GT_Recipe( + false, + new ItemStack[] {GT_Utility.copyAmount(1, aInputs[0])}, + GT_ModHandler.getRecyclerOutput(GT_Utility.copyAmount(64, aInputs[0]), 0) == null + ? null + : new ItemStack[] {ItemList.IC2_Scrap.get(1)}, + null, + new int[] {1250}, + null, + null, + 45, + 1, + 0); } @Override @@ -1558,22 +3493,87 @@ public class GT_Recipe implements Comparable<GT_Recipe> { * Special Class for Compressor Recipe handling. */ public static class GT_Recipe_Map_Compressor extends GT_Recipe_Map_NonGTRecipes { - public GT_Recipe_Map_Compressor(Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { - super(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, aUsualInputCount, aUsualOutputCount, aMinimalInputItems, aMinimalInputFluids, aAmperage, aNEISpecialValuePre, aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed); + public GT_Recipe_Map_Compressor( + Collection<GT_Recipe> aRecipeList, + String aUnlocalizedName, + String aLocalName, + String aNEIName, + String aNEIGUIPath, + int aUsualInputCount, + int aUsualOutputCount, + int aMinimalInputItems, + int aMinimalInputFluids, + int aAmperage, + String aNEISpecialValuePre, + int aNEISpecialValueMultiplier, + String aNEISpecialValuePost, + boolean aShowVoltageAmperageInNEI, + boolean aNEIAllowed) { + super( + aRecipeList, + aUnlocalizedName, + aLocalName, + aNEIName, + aNEIGUIPath, + aUsualInputCount, + aUsualOutputCount, + aMinimalInputItems, + aMinimalInputFluids, + aAmperage, + aNEISpecialValuePre, + aNEISpecialValueMultiplier, + aNEISpecialValuePost, + aShowVoltageAmperageInNEI, + aNEIAllowed); } @Override - public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { + public GT_Recipe findRecipe( + IHasWorldObjectAndCoords aTileEntity, + GT_Recipe aRecipe, + boolean aNotUnificated, + long aVoltage, + FluidStack[] aFluids, + ItemStack aSpecialSlot, + ItemStack... aInputs) { if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null) return null; if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe; ItemStack tComparedInput = GT_Utility.copyOrNull(aInputs[0]); - ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput(tComparedInput, ic2.api.recipe.Recipes.compressor.getRecipes(), true, new NBTTagCompound(), null, null, null); - return GT_Utility.arrayContainsNonNull(tOutputItems) ? new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(aInputs[0].stackSize - tComparedInput.stackSize, aInputs[0])}, tOutputItems, null, null, null, null, 400, 2, 0) : null; + ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput( + tComparedInput, + ic2.api.recipe.Recipes.compressor.getRecipes(), + true, + new NBTTagCompound(), + null, + null, + null); + return GT_Utility.arrayContainsNonNull(tOutputItems) + ? new GT_Recipe( + false, + new ItemStack[] { + GT_Utility.copyAmount(aInputs[0].stackSize - tComparedInput.stackSize, aInputs[0]) + }, + tOutputItems, + null, + null, + null, + null, + 400, + 2, + 0) + : null; } @Override public boolean containsInput(ItemStack aStack) { - return GT_Utility.arrayContainsNonNull(GT_ModHandler.getMachineOutput(GT_Utility.copyAmount(64, aStack), ic2.api.recipe.Recipes.compressor.getRecipes(), false, new NBTTagCompound(), null, null, null)); + return GT_Utility.arrayContainsNonNull(GT_ModHandler.getMachineOutput( + GT_Utility.copyAmount(64, aStack), + ic2.api.recipe.Recipes.compressor.getRecipes(), + false, + new NBTTagCompound(), + null, + null, + null)); } } @@ -1581,22 +3581,87 @@ public class GT_Recipe implements Comparable<GT_Recipe> { * Special Class for Extractor Recipe handling. */ public static class GT_Recipe_Map_Extractor extends GT_Recipe_Map_NonGTRecipes { - public GT_Recipe_Map_Extractor(Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { - super(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, aUsualInputCount, aUsualOutputCount, aMinimalInputItems, aMinimalInputFluids, aAmperage, aNEISpecialValuePre, aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed); + public GT_Recipe_Map_Extractor( + Collection<GT_Recipe> aRecipeList, + String aUnlocalizedName, + String aLocalName, + String aNEIName, + String aNEIGUIPath, + int aUsualInputCount, + int aUsualOutputCount, + int aMinimalInputItems, + int aMinimalInputFluids, + int aAmperage, + String aNEISpecialValuePre, + int aNEISpecialValueMultiplier, + String aNEISpecialValuePost, + boolean aShowVoltageAmperageInNEI, + boolean aNEIAllowed) { + super( + aRecipeList, + aUnlocalizedName, + aLocalName, + aNEIName, + aNEIGUIPath, + aUsualInputCount, + aUsualOutputCount, + aMinimalInputItems, + aMinimalInputFluids, + aAmperage, + aNEISpecialValuePre, + aNEISpecialValueMultiplier, + aNEISpecialValuePost, + aShowVoltageAmperageInNEI, + aNEIAllowed); } @Override - public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { + public GT_Recipe findRecipe( + IHasWorldObjectAndCoords aTileEntity, + GT_Recipe aRecipe, + boolean aNotUnificated, + long aVoltage, + FluidStack[] aFluids, + ItemStack aSpecialSlot, + ItemStack... aInputs) { if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null) return null; if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe; ItemStack tComparedInput = GT_Utility.copyOrNull(aInputs[0]); - ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput(tComparedInput, ic2.api.recipe.Recipes.extractor.getRecipes(), true, new NBTTagCompound(), null, null, null); - return GT_Utility.arrayContainsNonNull(tOutputItems) ? new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(aInputs[0].stackSize - tComparedInput.stackSize, aInputs[0])}, tOutputItems, null, null, null, null, 400, 2, 0) : null; + ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput( + tComparedInput, + ic2.api.recipe.Recipes.extractor.getRecipes(), + true, + new NBTTagCompound(), + null, + null, + null); + return GT_Utility.arrayContainsNonNull(tOutputItems) + ? new GT_Recipe( + false, + new ItemStack[] { + GT_Utility.copyAmount(aInputs[0].stackSize - tComparedInput.stackSize, aInputs[0]) + }, + tOutputItems, + null, + null, + null, + null, + 400, + 2, + 0) + : null; } @Override public boolean containsInput(ItemStack aStack) { - return GT_Utility.arrayContainsNonNull(GT_ModHandler.getMachineOutput(GT_Utility.copyAmount(64, aStack), ic2.api.recipe.Recipes.extractor.getRecipes(), false, new NBTTagCompound(), null, null, null)); + return GT_Utility.arrayContainsNonNull(GT_ModHandler.getMachineOutput( + GT_Utility.copyAmount(64, aStack), + ic2.api.recipe.Recipes.extractor.getRecipes(), + false, + new NBTTagCompound(), + null, + null, + null)); } } @@ -1604,22 +3669,87 @@ public class GT_Recipe implements Comparable<GT_Recipe> { * Special Class for Thermal Centrifuge Recipe handling. */ public static class GT_Recipe_Map_ThermalCentrifuge extends GT_Recipe_Map_NonGTRecipes { - public GT_Recipe_Map_ThermalCentrifuge(Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { - super(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, aUsualInputCount, aUsualOutputCount, aMinimalInputItems, aMinimalInputFluids, aAmperage, aNEISpecialValuePre, aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed); + public GT_Recipe_Map_ThermalCentrifuge( + Collection<GT_Recipe> aRecipeList, + String aUnlocalizedName, + String aLocalName, + String aNEIName, + String aNEIGUIPath, + int aUsualInputCount, + int aUsualOutputCount, + int aMinimalInputItems, + int aMinimalInputFluids, + int aAmperage, + String aNEISpecialValuePre, + int aNEISpecialValueMultiplier, + String aNEISpecialValuePost, + boolean aShowVoltageAmperageInNEI, + boolean aNEIAllowed) { + super( + aRecipeList, + aUnlocalizedName, + aLocalName, + aNEIName, + aNEIGUIPath, + aUsualInputCount, + aUsualOutputCount, + aMinimalInputItems, + aMinimalInputFluids, + aAmperage, + aNEISpecialValuePre, + aNEISpecialValueMultiplier, + aNEISpecialValuePost, + aShowVoltageAmperageInNEI, + aNEIAllowed); } @Override - public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { + public GT_Recipe findRecipe( + IHasWorldObjectAndCoords aTileEntity, + GT_Recipe aRecipe, + boolean aNotUnificated, + long aVoltage, + FluidStack[] aFluids, + ItemStack aSpecialSlot, + ItemStack... aInputs) { if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null) return null; if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe; ItemStack tComparedInput = GT_Utility.copyOrNull(aInputs[0]); - ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput(tComparedInput, ic2.api.recipe.Recipes.centrifuge.getRecipes(), true, new NBTTagCompound(), null, null, null); - return GT_Utility.arrayContainsNonNull(tOutputItems) ? new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(aInputs[0].stackSize - tComparedInput.stackSize, aInputs[0])}, tOutputItems, null, null, null, null, 400, 48, 0) : null; + ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput( + tComparedInput, + ic2.api.recipe.Recipes.centrifuge.getRecipes(), + true, + new NBTTagCompound(), + null, + null, + null); + return GT_Utility.arrayContainsNonNull(tOutputItems) + ? new GT_Recipe( + false, + new ItemStack[] { + GT_Utility.copyAmount(aInputs[0].stackSize - tComparedInput.stackSize, aInputs[0]) + }, + tOutputItems, + null, + null, + null, + null, + 400, + 48, + 0) + : null; } @Override public boolean containsInput(ItemStack aStack) { - return GT_Utility.arrayContainsNonNull(GT_ModHandler.getMachineOutput(GT_Utility.copyAmount(64, aStack), ic2.api.recipe.Recipes.centrifuge.getRecipes(), false, new NBTTagCompound(), null, null, null)); + return GT_Utility.arrayContainsNonNull(GT_ModHandler.getMachineOutput( + GT_Utility.copyAmount(64, aStack), + ic2.api.recipe.Recipes.centrifuge.getRecipes(), + false, + new NBTTagCompound(), + null, + null, + null)); } } @@ -1627,24 +3757,97 @@ public class GT_Recipe implements Comparable<GT_Recipe> { * Special Class for Ore Washer Recipe handling. */ public static class GT_Recipe_Map_OreWasher extends GT_Recipe_Map_NonGTRecipes { - public GT_Recipe_Map_OreWasher(Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { - super(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, aUsualInputCount, aUsualOutputCount, aMinimalInputItems, aMinimalInputFluids, aAmperage, aNEISpecialValuePre, aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed); + public GT_Recipe_Map_OreWasher( + Collection<GT_Recipe> aRecipeList, + String aUnlocalizedName, + String aLocalName, + String aNEIName, + String aNEIGUIPath, + int aUsualInputCount, + int aUsualOutputCount, + int aMinimalInputItems, + int aMinimalInputFluids, + int aAmperage, + String aNEISpecialValuePre, + int aNEISpecialValueMultiplier, + String aNEISpecialValuePost, + boolean aShowVoltageAmperageInNEI, + boolean aNEIAllowed) { + super( + aRecipeList, + aUnlocalizedName, + aLocalName, + aNEIName, + aNEIGUIPath, + aUsualInputCount, + aUsualOutputCount, + aMinimalInputItems, + aMinimalInputFluids, + aAmperage, + aNEISpecialValuePre, + aNEISpecialValueMultiplier, + aNEISpecialValuePost, + aShowVoltageAmperageInNEI, + aNEIAllowed); } @Override - public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { - if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null || aFluids == null || aFluids.length < 1 || !GT_ModHandler.isWater(aFluids[0])) - return null; + public GT_Recipe findRecipe( + IHasWorldObjectAndCoords aTileEntity, + GT_Recipe aRecipe, + boolean aNotUnificated, + long aVoltage, + FluidStack[] aFluids, + ItemStack aSpecialSlot, + ItemStack... aInputs) { + if (aInputs == null + || aInputs.length <= 0 + || aInputs[0] == null + || aFluids == null + || aFluids.length < 1 + || !GT_ModHandler.isWater(aFluids[0])) return null; if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe; ItemStack tComparedInput = GT_Utility.copyOrNull(aInputs[0]); NBTTagCompound aRecipeMetaData = new NBTTagCompound(); - ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput(tComparedInput, ic2.api.recipe.Recipes.oreWashing.getRecipes(), true, aRecipeMetaData, null, null, null); - return GT_Utility.arrayContainsNonNull(tOutputItems) ? new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(aInputs[0].stackSize - tComparedInput.stackSize, aInputs[0])}, tOutputItems, null, null, new FluidStack[]{new FluidStack(aFluids[0].getFluid(), ((NBTTagCompound) aRecipeMetaData.getTag("return")).getInteger("amount"))}, null, 400, 16, 0) : null; + ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput( + tComparedInput, + ic2.api.recipe.Recipes.oreWashing.getRecipes(), + true, + aRecipeMetaData, + null, + null, + null); + return GT_Utility.arrayContainsNonNull(tOutputItems) + ? new GT_Recipe( + false, + new ItemStack[] { + GT_Utility.copyAmount(aInputs[0].stackSize - tComparedInput.stackSize, aInputs[0]) + }, + tOutputItems, + null, + null, + new FluidStack[] { + new FluidStack( + aFluids[0].getFluid(), + ((NBTTagCompound) aRecipeMetaData.getTag("return")).getInteger("amount")) + }, + null, + 400, + 16, + 0) + : null; } @Override public boolean containsInput(ItemStack aStack) { - return GT_Utility.arrayContainsNonNull(GT_ModHandler.getMachineOutput(GT_Utility.copyAmount(64, aStack), ic2.api.recipe.Recipes.oreWashing.getRecipes(), false, new NBTTagCompound(), null, null, null)); + return GT_Utility.arrayContainsNonNull(GT_ModHandler.getMachineOutput( + GT_Utility.copyAmount(64, aStack), + ic2.api.recipe.Recipes.oreWashing.getRecipes(), + false, + new NBTTagCompound(), + null, + null, + null)); } @Override @@ -1662,37 +3865,117 @@ public class GT_Recipe implements Comparable<GT_Recipe> { * Special Class for Macerator/RockCrusher Recipe handling. */ public static class GT_Recipe_Map_Macerator extends GT_Recipe_Map { - public GT_Recipe_Map_Macerator(Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { - super(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, aUsualInputCount, aUsualOutputCount, aMinimalInputItems, aMinimalInputFluids, aAmperage, aNEISpecialValuePre, aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed); + public GT_Recipe_Map_Macerator( + Collection<GT_Recipe> aRecipeList, + String aUnlocalizedName, + String aLocalName, + String aNEIName, + String aNEIGUIPath, + int aUsualInputCount, + int aUsualOutputCount, + int aMinimalInputItems, + int aMinimalInputFluids, + int aAmperage, + String aNEISpecialValuePre, + int aNEISpecialValueMultiplier, + String aNEISpecialValuePost, + boolean aShowVoltageAmperageInNEI, + boolean aNEIAllowed) { + super( + aRecipeList, + aUnlocalizedName, + aLocalName, + aNEIName, + aNEIGUIPath, + aUsualInputCount, + aUsualOutputCount, + aMinimalInputItems, + aMinimalInputFluids, + aAmperage, + aNEISpecialValuePre, + aNEISpecialValueMultiplier, + aNEISpecialValuePost, + aShowVoltageAmperageInNEI, + aNEIAllowed); } @Override - public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { + public GT_Recipe findRecipe( + IHasWorldObjectAndCoords aTileEntity, + GT_Recipe aRecipe, + boolean aNotUnificated, + long aVoltage, + FluidStack[] aFluids, + ItemStack aSpecialSlot, + ItemStack... aInputs) { if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null || !GregTech_API.sPostloadFinished) return super.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot, aInputs); aRecipe = super.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot, aInputs); if (aRecipe != null) return aRecipe; try { - List<ItemStack> tRecipeOutputs = mods.railcraft.api.crafting.RailcraftCraftingManager.rockCrusher.getRecipe(GT_Utility.copyAmount(1, aInputs[0])).getRandomizedOuputs(); + List<ItemStack> tRecipeOutputs = mods.railcraft.api.crafting.RailcraftCraftingManager.rockCrusher + .getRecipe(GT_Utility.copyAmount(1, aInputs[0])) + .getRandomizedOuputs(); if (tRecipeOutputs != null) { - aRecipe = new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(1, aInputs[0])}, tRecipeOutputs.toArray(new ItemStack[0]), null, null, null, null, 800, 2, 0); + aRecipe = new GT_Recipe( + false, + new ItemStack[] {GT_Utility.copyAmount(1, aInputs[0])}, + tRecipeOutputs.toArray(new ItemStack[0]), + null, + null, + null, + null, + 800, + 2, + 0); aRecipe.mCanBeBuffered = false; aRecipe.mNeedsEmptyOutput = true; return aRecipe; } } catch (NoClassDefFoundError e) { if (D1) GT_Log.err.println("Railcraft Not loaded"); - } catch (NullPointerException e) {/**/} + } catch (NullPointerException e) { + /**/ + } ItemStack tComparedInput = GT_Utility.copyOrNull(aInputs[0]); - ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput(tComparedInput, ic2.api.recipe.Recipes.macerator.getRecipes(), true, new NBTTagCompound(), null, null, null); - return GT_Utility.arrayContainsNonNull(tOutputItems) ? new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(aInputs[0].stackSize - tComparedInput.stackSize, aInputs[0])}, tOutputItems, null, null, null, null, 400, 2, 0) : null; + ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput( + tComparedInput, + ic2.api.recipe.Recipes.macerator.getRecipes(), + true, + new NBTTagCompound(), + null, + null, + null); + return GT_Utility.arrayContainsNonNull(tOutputItems) + ? new GT_Recipe( + false, + new ItemStack[] { + GT_Utility.copyAmount(aInputs[0].stackSize - tComparedInput.stackSize, aInputs[0]) + }, + tOutputItems, + null, + null, + null, + null, + 400, + 2, + 0) + : null; } @Override public boolean containsInput(ItemStack aStack) { - return super.containsInput(aStack) || GT_Utility.arrayContainsNonNull(GT_ModHandler.getMachineOutput(GT_Utility.copyAmount(64, aStack), ic2.api.recipe.Recipes.macerator.getRecipes(), false, new NBTTagCompound(), null, null, null)); + return super.containsInput(aStack) + || GT_Utility.arrayContainsNonNull(GT_ModHandler.getMachineOutput( + GT_Utility.copyAmount(64, aStack), + ic2.api.recipe.Recipes.macerator.getRecipes(), + false, + new NBTTagCompound(), + null, + null, + null)); } } @@ -1701,62 +3984,135 @@ public class GT_Recipe implements Comparable<GT_Recipe> { */ public static class GT_Recipe_Map_Assembler extends GT_Recipe_Map { - public GT_Recipe_Map_Assembler(Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed, boolean aNEIUnificateOutput) { - super(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, aUsualInputCount, aUsualOutputCount, aMinimalInputItems, aMinimalInputFluids, aAmperage, aNEISpecialValuePre, aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed, aNEIUnificateOutput); - } - - public GT_Recipe_Map_Assembler(Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { - this(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, aUsualInputCount, aUsualOutputCount, aMinimalInputItems, aMinimalInputFluids, aAmperage, aNEISpecialValuePre, aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed, true); + public GT_Recipe_Map_Assembler( + Collection<GT_Recipe> aRecipeList, + String aUnlocalizedName, + String aLocalName, + String aNEIName, + String aNEIGUIPath, + int aUsualInputCount, + int aUsualOutputCount, + int aMinimalInputItems, + int aMinimalInputFluids, + int aAmperage, + String aNEISpecialValuePre, + int aNEISpecialValueMultiplier, + String aNEISpecialValuePost, + boolean aShowVoltageAmperageInNEI, + boolean aNEIAllowed, + boolean aNEIUnificateOutput) { + super( + aRecipeList, + aUnlocalizedName, + aLocalName, + aNEIName, + aNEIGUIPath, + aUsualInputCount, + aUsualOutputCount, + aMinimalInputItems, + aMinimalInputFluids, + aAmperage, + aNEISpecialValuePre, + aNEISpecialValueMultiplier, + aNEISpecialValuePost, + aShowVoltageAmperageInNEI, + aNEIAllowed, + aNEIUnificateOutput); + } + + public GT_Recipe_Map_Assembler( + Collection<GT_Recipe> aRecipeList, + String aUnlocalizedName, + String aLocalName, + String aNEIName, + String aNEIGUIPath, + int aUsualInputCount, + int aUsualOutputCount, + int aMinimalInputItems, + int aMinimalInputFluids, + int aAmperage, + String aNEISpecialValuePre, + int aNEISpecialValueMultiplier, + String aNEISpecialValuePost, + boolean aShowVoltageAmperageInNEI, + boolean aNEIAllowed) { + this( + aRecipeList, + aUnlocalizedName, + aLocalName, + aNEIName, + aNEIGUIPath, + aUsualInputCount, + aUsualOutputCount, + aMinimalInputItems, + aMinimalInputFluids, + aAmperage, + aNEISpecialValuePre, + aNEISpecialValueMultiplier, + aNEISpecialValuePost, + aShowVoltageAmperageInNEI, + aNEIAllowed, + true); } @Override - public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { + public GT_Recipe findRecipe( + IHasWorldObjectAndCoords aTileEntity, + GT_Recipe aRecipe, + boolean aNotUnificated, + long aVoltage, + FluidStack[] aFluids, + ItemStack aSpecialSlot, + ItemStack... aInputs) { GT_Recipe rRecipe = super.findRecipe(aTileEntity, aRecipe, true, aVoltage, aFluids, aSpecialSlot, aInputs); -/* + /* - Doesnt work, keep it as a reminder tho + Doesnt work, keep it as a reminder tho - if (rRecipe == null){ - Set<ItemStack> aInputs2 = new TreeSet<ItemStack>(); - for (ItemStack aInput : aInputs) { - aInputs2.add(aInput); - } + if (rRecipe == null){ + Set<ItemStack> aInputs2 = new TreeSet<ItemStack>(); + for (ItemStack aInput : aInputs) { + aInputs2.add(aInput); + } - for (ItemStack aInput : aInputs) { - aInputs2.remove(aInput); - int[] oredictIDs = OreDictionary.getOreIDs(aInput); - if ( oredictIDs.length > 1){ - for (final int i : oredictIDs){ - final ItemStack[] oredictIS = (ItemStack[]) OreDictionary.getOres(OreDictionary.getOreName(i)).toArray(); - if (oredictIS != null && oredictIS.length > 1){ - for (final ItemStack IS : oredictIS){ - aInputs2.add(IS); - ItemStack[] temp = (ItemStack[]) aInputs2.toArray(); - rRecipe = super.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot,temp); - if(rRecipe!= null){ - break; + for (ItemStack aInput : aInputs) { + aInputs2.remove(aInput); + int[] oredictIDs = OreDictionary.getOreIDs(aInput); + if ( oredictIDs.length > 1){ + for (final int i : oredictIDs){ + final ItemStack[] oredictIS = (ItemStack[]) OreDictionary.getOres(OreDictionary.getOreName(i)).toArray(); + if (oredictIS != null && oredictIS.length > 1){ + for (final ItemStack IS : oredictIS){ + aInputs2.add(IS); + ItemStack[] temp = (ItemStack[]) aInputs2.toArray(); + rRecipe = super.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot,temp); + if(rRecipe!= null){ + break; + } + else { + aInputs2.remove(IS); + } + } + if(rRecipe!= null) + break; + } } - else { - aInputs2.remove(IS); - } - } + if(rRecipe!= null) + break; + }else + aInputs2.add(aInput); if(rRecipe!= null) - break; + break; } } - if(rRecipe!= null) - break; - }else - aInputs2.add(aInput); - if(rRecipe!= null) - break; - } - } -*/ - if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null || rRecipe == null || !GregTech_API.sPostloadFinished) - return rRecipe; + */ + if (aInputs == null + || aInputs.length <= 0 + || aInputs[0] == null + || rRecipe == null + || !GregTech_API.sPostloadFinished) return rRecipe; for (ItemStack aInput : aInputs) { if (ItemList.Paper_Printed_Pages.isStackEqual(aInput, false, true)) { @@ -1764,28 +4120,74 @@ public class GT_Recipe implements Comparable<GT_Recipe> { rRecipe.mCanBeBuffered = false; rRecipe.mOutputs[0].setTagCompound(aInput.getTagCompound()); } - } return rRecipe; } - } /** * Special Class for Forming Press handling. */ public static class GT_Recipe_Map_FormingPress extends GT_Recipe_Map { - public GT_Recipe_Map_FormingPress(Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { - super(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, aUsualInputCount, aUsualOutputCount, aMinimalInputItems, aMinimalInputFluids, aAmperage, aNEISpecialValuePre, aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed); + public GT_Recipe_Map_FormingPress( + Collection<GT_Recipe> aRecipeList, + String aUnlocalizedName, + String aLocalName, + String aNEIName, + String aNEIGUIPath, + int aUsualInputCount, + int aUsualOutputCount, + int aMinimalInputItems, + int aMinimalInputFluids, + int aAmperage, + String aNEISpecialValuePre, + int aNEISpecialValueMultiplier, + String aNEISpecialValuePost, + boolean aShowVoltageAmperageInNEI, + boolean aNEIAllowed) { + super( + aRecipeList, + aUnlocalizedName, + aLocalName, + aNEIName, + aNEIGUIPath, + aUsualInputCount, + aUsualOutputCount, + aMinimalInputItems, + aMinimalInputFluids, + aAmperage, + aNEISpecialValuePre, + aNEISpecialValueMultiplier, + aNEISpecialValuePost, + aShowVoltageAmperageInNEI, + aNEIAllowed); } @Override - public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, boolean aDontCheckStackSizes, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { - GT_Recipe rRecipe = super.findRecipe(aTileEntity, aRecipe, aNotUnificated, aDontCheckStackSizes, aVoltage, aFluids, aSpecialSlot, aInputs); - if (aInputs == null || aInputs.length < 2 || aInputs[0] == null || aInputs[1] == null || !GregTech_API.sPostloadFinished) - return rRecipe; - if (rRecipe == null) - return findRenamingRecipe(aInputs); + public GT_Recipe findRecipe( + IHasWorldObjectAndCoords aTileEntity, + GT_Recipe aRecipe, + boolean aNotUnificated, + boolean aDontCheckStackSizes, + long aVoltage, + FluidStack[] aFluids, + ItemStack aSpecialSlot, + ItemStack... aInputs) { + GT_Recipe rRecipe = super.findRecipe( + aTileEntity, + aRecipe, + aNotUnificated, + aDontCheckStackSizes, + aVoltage, + aFluids, + aSpecialSlot, + aInputs); + if (aInputs == null + || aInputs.length < 2 + || aInputs[0] == null + || aInputs[1] == null + || !GregTech_API.sPostloadFinished) return rRecipe; + if (rRecipe == null) return findRenamingRecipe(aInputs); for (ItemStack aMold : aInputs) { if (ItemList.Shape_Mold_Credit.isStackEqual(aMold, false, true)) { NBTTagCompound tNBT = aMold.getTagCompound(); @@ -1803,17 +4205,15 @@ public class GT_Recipe implements Comparable<GT_Recipe> { } private ItemStack findNameMoldIndex(ItemStack[] inputs) { - for (ItemStack stack: inputs) { - if (ItemList.Shape_Mold_Name.isStackEqual(stack, false, true)) - return stack; + for (ItemStack stack : inputs) { + if (ItemList.Shape_Mold_Name.isStackEqual(stack, false, true)) return stack; } return null; } private ItemStack findStackToRename(ItemStack[] inputs, ItemStack mold) { - for (ItemStack stack: inputs) { - if (stack == mold || stack == null) - continue; + for (ItemStack stack : inputs) { + if (stack == mold || stack == null) continue; return stack; } return null; @@ -1821,17 +4221,22 @@ public class GT_Recipe implements Comparable<GT_Recipe> { private GT_Recipe findRenamingRecipe(ItemStack[] inputs) { ItemStack mold = findNameMoldIndex(inputs); - if (mold == null) - return null; + if (mold == null) return null; ItemStack input = findStackToRename(inputs, mold); - if (input == null) - return null; + if (input == null) return null; ItemStack output = GT_Utility.copyAmount(1, input); output.setStackDisplayName(mold.getDisplayName()); - GT_Recipe recipe = new GT_Recipe(false, - new ItemStack[]{ ItemList.Shape_Mold_Name.get(0), GT_Utility.copyAmount(1, input) }, - new ItemStack[]{ output }, - null, null, null, null, 128, 8, 0); + GT_Recipe recipe = new GT_Recipe( + false, + new ItemStack[] {ItemList.Shape_Mold_Name.get(0), GT_Utility.copyAmount(1, input)}, + new ItemStack[] {output}, + null, + null, + null, + null, + 128, + 8, + 0); recipe.mCanBeBuffered = false; return recipe; } @@ -1841,15 +4246,58 @@ public class GT_Recipe implements Comparable<GT_Recipe> { * Special Class for Printer handling. */ public static class GT_Recipe_Map_Printer extends GT_Recipe_Map { - public GT_Recipe_Map_Printer(Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { - super(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, aUsualInputCount, aUsualOutputCount, aMinimalInputItems, aMinimalInputFluids, aAmperage, aNEISpecialValuePre, aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed); + public GT_Recipe_Map_Printer( + Collection<GT_Recipe> aRecipeList, + String aUnlocalizedName, + String aLocalName, + String aNEIName, + String aNEIGUIPath, + int aUsualInputCount, + int aUsualOutputCount, + int aMinimalInputItems, + int aMinimalInputFluids, + int aAmperage, + String aNEISpecialValuePre, + int aNEISpecialValueMultiplier, + String aNEISpecialValuePost, + boolean aShowVoltageAmperageInNEI, + boolean aNEIAllowed) { + super( + aRecipeList, + aUnlocalizedName, + aLocalName, + aNEIName, + aNEIGUIPath, + aUsualInputCount, + aUsualOutputCount, + aMinimalInputItems, + aMinimalInputFluids, + aAmperage, + aNEISpecialValuePre, + aNEISpecialValueMultiplier, + aNEISpecialValuePost, + aShowVoltageAmperageInNEI, + aNEIAllowed); } @Override - public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { - GT_Recipe rRecipe = super.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot, aInputs); - if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null || aFluids == null || aFluids.length <= 0 || aFluids[0] == null || !GregTech_API.sPostloadFinished) - return rRecipe; + public GT_Recipe findRecipe( + IHasWorldObjectAndCoords aTileEntity, + GT_Recipe aRecipe, + boolean aNotUnificated, + long aVoltage, + FluidStack[] aFluids, + ItemStack aSpecialSlot, + ItemStack... aInputs) { + GT_Recipe rRecipe = + super.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot, aInputs); + if (aInputs == null + || aInputs.length <= 0 + || aInputs[0] == null + || aFluids == null + || aFluids.length <= 0 + || aFluids[0] == null + || !GregTech_API.sPostloadFinished) return rRecipe; Dyes aDye = null; for (Dyes tDye : Dyes.VALUES) @@ -1861,20 +4309,61 @@ public class GT_Recipe implements Comparable<GT_Recipe> { if (aDye == null) return rRecipe; if (rRecipe == null) { - ItemStack - tOutput = GT_ModHandler.getAllRecipeOutput(aTileEntity == null ? null : aTileEntity.getWorld(), aInputs[0], aInputs[0], aInputs[0], aInputs[0], ItemList.DYE_ONLY_ITEMS[aDye.mIndex].get(1), aInputs[0], aInputs[0], aInputs[0], aInputs[0]); + ItemStack tOutput = GT_ModHandler.getAllRecipeOutput( + aTileEntity == null ? null : aTileEntity.getWorld(), + aInputs[0], + aInputs[0], + aInputs[0], + aInputs[0], + ItemList.DYE_ONLY_ITEMS[aDye.mIndex].get(1), + aInputs[0], + aInputs[0], + aInputs[0], + aInputs[0]); if (tOutput != null) - return addRecipe(new GT_Recipe(true, new ItemStack[]{GT_Utility.copyAmount(8, aInputs[0])}, new ItemStack[]{tOutput}, null, null, new FluidStack[]{new FluidStack(aFluids[0].getFluid(), (int) L)}, null, 256, 2, 0), false, false, true); - - tOutput = GT_ModHandler.getAllRecipeOutput(aTileEntity == null ? null : aTileEntity.getWorld(), aInputs[0], ItemList.DYE_ONLY_ITEMS[aDye.mIndex].get(1)); + return addRecipe( + new GT_Recipe( + true, + new ItemStack[] {GT_Utility.copyAmount(8, aInputs[0])}, + new ItemStack[] {tOutput}, + null, + null, + new FluidStack[] {new FluidStack(aFluids[0].getFluid(), (int) L)}, + null, + 256, + 2, + 0), + false, + false, + true); + + tOutput = GT_ModHandler.getAllRecipeOutput( + aTileEntity == null ? null : aTileEntity.getWorld(), + aInputs[0], + ItemList.DYE_ONLY_ITEMS[aDye.mIndex].get(1)); if (tOutput != null) - return addRecipe(new GT_Recipe(true, new ItemStack[]{GT_Utility.copyAmount(1, aInputs[0])}, new ItemStack[]{tOutput}, null, null, new FluidStack[]{new FluidStack(aFluids[0].getFluid(), (int) L)}, null, 32, 2, 0), false, false, true); + return addRecipe( + new GT_Recipe( + true, + new ItemStack[] {GT_Utility.copyAmount(1, aInputs[0])}, + new ItemStack[] {tOutput}, + null, + null, + new FluidStack[] {new FluidStack(aFluids[0].getFluid(), (int) L)}, + null, + 32, + 2, + 0), + false, + false, + true); } else { if (aInputs[0].getItem() == Items.paper) { if (!ItemList.Tool_DataStick.isStackEqual(aSpecialSlot, false, true)) return null; NBTTagCompound tNBT = aSpecialSlot.getTagCompound(); - if (tNBT == null || GT_Utility.isStringInvalid(tNBT.getString("title")) || GT_Utility.isStringInvalid(tNBT.getString("author"))) - return null; + if (tNBT == null + || GT_Utility.isStringInvalid(tNBT.getString("title")) + || GT_Utility.isStringInvalid(tNBT.getString("author"))) return null; rRecipe = rRecipe.copy(); rRecipe.mCanBeBuffered = false; @@ -1898,7 +4387,8 @@ public class GT_Recipe implements Comparable<GT_Recipe> { rRecipe = rRecipe.copy(); rRecipe.mCanBeBuffered = false; - rRecipe.mOutputs[0].setTagCompound(GT_Utility.getNBTContainingString(new NBTTagCompound(), "GT.PunchCardData", tNBT.getString("GT.PunchCardData"))); + rRecipe.mOutputs[0].setTagCompound(GT_Utility.getNBTContainingString( + new NBTTagCompound(), "GT.PunchCardData", tNBT.getString("GT.PunchCardData"))); return rRecipe; } } @@ -1923,33 +4413,54 @@ public class GT_Recipe implements Comparable<GT_Recipe> { public static class GT_Recipe_Map_LargeBoilerFakeFuels extends GT_Recipe_Map { - private static final List<String> ALLOWED_SOLID_FUELS = Arrays.asList(GregTech_API.sMachineFile.mConfig.getStringList( - "LargeBoiler.allowedFuels", - ConfigCategories.machineconfig.toString(), - new String[] {"gregtech:gt.blockreinforced:6", "gregtech:gt.blockreinforced:7"}, - "Allowed fuels for the Large Titanium Boiler and Large Tungstensteel Boiler")); + private static final List<String> ALLOWED_SOLID_FUELS = + Arrays.asList(GregTech_API.sMachineFile.mConfig.getStringList( + "LargeBoiler.allowedFuels", + ConfigCategories.machineconfig.toString(), + new String[] {"gregtech:gt.blockreinforced:6", "gregtech:gt.blockreinforced:7"}, + "Allowed fuels for the Large Titanium Boiler and Large Tungstensteel Boiler")); public GT_Recipe_Map_LargeBoilerFakeFuels() { - super(new HashSet<>(55), "gt.recipe.largeboilerfakefuels", "Large Boiler", null, RES_PATH_GUI + "basicmachines/Default", 1, 0, 1, 0, 1, E, 1, E, true, true); - GT_Recipe explanatoryRecipe = new GT_Recipe(true, new ItemStack[]{}, new ItemStack[]{}, null, null, null, null, 1, 1, 1); - explanatoryRecipe.setNeiDesc("Not all solid fuels are listed.", "Any item that burns in a", "vanilla furnace will burn in", "a Large Bronze or Steel Boiler."); + super( + new HashSet<>(55), + "gt.recipe.largeboilerfakefuels", + "Large Boiler", + null, + RES_PATH_GUI + "basicmachines/Default", + 1, + 0, + 1, + 0, + 1, + E, + 1, + E, + true, + true); + GT_Recipe explanatoryRecipe = + new GT_Recipe(true, new ItemStack[] {}, new ItemStack[] {}, null, null, null, null, 1, 1, 1); + explanatoryRecipe.setNeiDesc( + "Not all solid fuels are listed.", + "Any item that burns in a", + "vanilla furnace will burn in", + "a Large Bronze or Steel Boiler."); addRecipe(explanatoryRecipe); } public static boolean isAllowedSolidFuel(ItemStack stack) { - return isAllowedSolidFuel(Item.itemRegistry.getNameForObject(stack.getItem()), stack.getItemDamage()); + return isAllowedSolidFuel(Item.itemRegistry.getNameForObject(stack.getItem()), stack.getItemDamage()); } public static boolean isAllowedSolidFuel(String itemRegistryName, int meta) { - return ALLOWED_SOLID_FUELS.contains(itemRegistryName + ":" + meta); + return ALLOWED_SOLID_FUELS.contains(itemRegistryName + ":" + meta); } public static boolean addAllowedSolidFuel(ItemStack stack) { - return addAllowedSolidFuel(Item.itemRegistry.getNameForObject(stack.getItem()), stack.getItemDamage()); + return addAllowedSolidFuel(Item.itemRegistry.getNameForObject(stack.getItem()), stack.getItemDamage()); } public static boolean addAllowedSolidFuel(String itemregistryName, int meta) { - return ALLOWED_SOLID_FUELS.add(itemregistryName + ":" + meta); + return ALLOWED_SOLID_FUELS.add(itemregistryName + ":" + meta); } public GT_Recipe addDenseLiquidRecipe(GT_Recipe recipe) { @@ -1969,48 +4480,61 @@ public class GT_Recipe implements Comparable<GT_Recipe> { public GT_Recipe addSolidRecipe(ItemStack fuelItemStack) { boolean allowedFuel = false; if (fuelItemStack != null) { - String registryName = Item.itemRegistry.getNameForObject(fuelItemStack.getItem()); - allowedFuel = ALLOWED_SOLID_FUELS.contains(registryName + ":" + fuelItemStack.getItemDamage()); + String registryName = Item.itemRegistry.getNameForObject(fuelItemStack.getItem()); + allowedFuel = ALLOWED_SOLID_FUELS.contains(registryName + ":" + fuelItemStack.getItemDamage()); } - return addRecipe(new GT_Recipe(true, new ItemStack[]{fuelItemStack}, new ItemStack[]{}, null, null, null, null, 1, 0, GT_ModHandler.getFuelValue(fuelItemStack) / 1600), ((double) GT_ModHandler.getFuelValue(fuelItemStack)) / 1600, allowedFuel); + return addRecipe( + new GT_Recipe( + true, + new ItemStack[] {fuelItemStack}, + new ItemStack[] {}, + null, + null, + null, + null, + 1, + 0, + GT_ModHandler.getFuelValue(fuelItemStack) / 1600), + ((double) GT_ModHandler.getFuelValue(fuelItemStack)) / 1600, + allowedFuel); } private GT_Recipe addRecipe(GT_Recipe recipe, double baseBurnTime, boolean isAllowedFuel) { - recipe = new GT_Recipe(recipe); - //Some recipes will have a burn time like 15.9999999 and % always rounds down - double floatErrorCorrection = 0.0001; - - double bronzeBurnTime = baseBurnTime * 2 + floatErrorCorrection; - bronzeBurnTime -= bronzeBurnTime % 0.05; - double steelBurnTime = baseBurnTime + floatErrorCorrection; - steelBurnTime -= steelBurnTime % 0.05; - double titaniumBurnTime = baseBurnTime * 0.3 + floatErrorCorrection; - titaniumBurnTime -= titaniumBurnTime % 0.05; - double tungstensteelBurnTime = baseBurnTime * 0.15 + floatErrorCorrection; - tungstensteelBurnTime -= tungstensteelBurnTime % 0.05; + recipe = new GT_Recipe(recipe); + // Some recipes will have a burn time like 15.9999999 and % always rounds down + double floatErrorCorrection = 0.0001; + + double bronzeBurnTime = baseBurnTime * 2 + floatErrorCorrection; + bronzeBurnTime -= bronzeBurnTime % 0.05; + double steelBurnTime = baseBurnTime + floatErrorCorrection; + steelBurnTime -= steelBurnTime % 0.05; + double titaniumBurnTime = baseBurnTime * 0.3 + floatErrorCorrection; + titaniumBurnTime -= titaniumBurnTime % 0.05; + double tungstensteelBurnTime = baseBurnTime * 0.15 + floatErrorCorrection; + tungstensteelBurnTime -= tungstensteelBurnTime % 0.05; if (isAllowedFuel) { - recipe.setNeiDesc("Burn time in seconds:", + recipe.setNeiDesc( + "Burn time in seconds:", String.format("Bronze Boiler: %.4f", bronzeBurnTime), String.format("Steel Boiler: %.4f", steelBurnTime), String.format("Titanium Boiler: %.4f", titaniumBurnTime), String.format("Tungstensteel Boiler: %.4f", tungstensteelBurnTime)); - } - - else { - recipe.setNeiDesc("Burn time in seconds:", + } else { + recipe.setNeiDesc( + "Burn time in seconds:", String.format("Bronze Boiler: %.4f", bronzeBurnTime), String.format("Steel Boiler: %.4f", steelBurnTime), "Titanium Boiler: Not allowed", "Tungstenst. Boiler: Not allowed"); } - return super.addRecipe(recipe); - } + return super.addRecipe(recipe); + } private GT_Recipe addRecipe(GT_Recipe recipe, double baseBurnTime) { recipe = new GT_Recipe(recipe); - //Some recipes will have a burn time like 15.9999999 and % always rounds down + // Some recipes will have a burn time like 15.9999999 and % always rounds down double floatErrorCorrection = 0.0001; double bronzeBurnTime = baseBurnTime * 2 + floatErrorCorrection; @@ -2018,7 +4542,8 @@ public class GT_Recipe implements Comparable<GT_Recipe> { double steelBurnTime = baseBurnTime + floatErrorCorrection; steelBurnTime -= steelBurnTime % 0.05; - recipe.setNeiDesc("Burn time in seconds:", + recipe.setNeiDesc( + "Burn time in seconds:", String.format("Bronze Boiler: %.4f", bronzeBurnTime), String.format("Steel Boiler: %.4f", steelBurnTime), "Titanium Boiler: Not allowed", @@ -2026,7 +4551,6 @@ public class GT_Recipe implements Comparable<GT_Recipe> { return super.addRecipe(recipe); } - } public static class GT_Recipe_Map_LargeChemicalReactor extends GT_Recipe_Map { @@ -2035,11 +4559,36 @@ public class GT_Recipe implements Comparable<GT_Recipe> { private static final int FLUID_OUTPUT_COUNT = 6; public GT_Recipe_Map_LargeChemicalReactor() { - super(new HashSet<>(1000), "gt.recipe.largechemicalreactor", "Large Chemical Reactor", null, RES_PATH_GUI + "basicmachines/LCRNEI", 2, OUTPUT_COUNT, 0, 0, 1, E, 1, E, true, true); + super( + new HashSet<>(1000), + "gt.recipe.largechemicalreactor", + "Large Chemical Reactor", + null, + RES_PATH_GUI + "basicmachines/LCRNEI", + 2, + OUTPUT_COUNT, + 0, + 0, + 1, + E, + 1, + E, + true, + true); } @Override - public GT_Recipe addRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, int[] aOutputChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { + public GT_Recipe addRecipe( + boolean aOptimize, + ItemStack[] aInputs, + ItemStack[] aOutputs, + Object aSpecial, + int[] aOutputChances, + FluidStack[] aFluidInputs, + FluidStack[] aFluidOutputs, + int aDuration, + int aEUt, + int aSpecialValue) { aOptimize = false; ArrayList<ItemStack> adjustedInputs = new ArrayList<>(); ArrayList<ItemStack> adjustedOutputs = new ArrayList<>(); @@ -2055,23 +4604,27 @@ public class GT_Recipe implements Comparable<GT_Recipe> { for (ItemStack input : aInputs) { FluidStack inputFluidContent = FluidContainerRegistry.getFluidForFilledItem(input); if (inputFluidContent != null) { - inputFluidContent.amount *= input.stackSize; + inputFluidContent.amount *= input.stackSize; if (inputFluidContent.getFluid().getName().equals("ic2steam")) { inputFluidContent = GT_ModHandler.getSteam(inputFluidContent.amount); } - adjustedFluidInputs.add(inputFluidContent); - } else { - ItemData itemData = GT_OreDictUnificator.getItemData(input); - if (itemData != null && itemData.hasValidPrefixMaterialData() && itemData.mMaterial.mMaterial == Materials.Empty) { - continue; - } else { - if (itemData != null && itemData.hasValidPrefixMaterialData() && itemData.mPrefix == OrePrefixes.cell) { - ItemStack dustStack = itemData.mMaterial.mMaterial.getDust(input.stackSize); - if (dustStack != null) { - adjustedInputs.add(dustStack); - } else { - adjustedInputs.add(input); - } + adjustedFluidInputs.add(inputFluidContent); + } else { + ItemData itemData = GT_OreDictUnificator.getItemData(input); + if (itemData != null + && itemData.hasValidPrefixMaterialData() + && itemData.mMaterial.mMaterial == Materials.Empty) { + continue; + } else { + if (itemData != null + && itemData.hasValidPrefixMaterialData() + && itemData.mPrefix == OrePrefixes.cell) { + ItemStack dustStack = itemData.mMaterial.mMaterial.getDust(input.stackSize); + if (dustStack != null) { + adjustedInputs.add(dustStack); + } else { + adjustedInputs.add(input); + } } else { adjustedInputs.add(input); } @@ -2095,14 +4648,16 @@ public class GT_Recipe implements Comparable<GT_Recipe> { for (ItemStack output : aOutputs) { FluidStack outputFluidContent = FluidContainerRegistry.getFluidForFilledItem(output); if (outputFluidContent != null) { - outputFluidContent.amount *= output.stackSize; + outputFluidContent.amount *= output.stackSize; if (outputFluidContent.getFluid().getName().equals("ic2steam")) { outputFluidContent = GT_ModHandler.getSteam(outputFluidContent.amount); } - adjustedFluidOutputs.add(outputFluidContent); + adjustedFluidOutputs.add(outputFluidContent); } else { ItemData itemData = GT_OreDictUnificator.getItemData(output); - if (!(itemData != null && itemData.hasValidPrefixMaterialData() && itemData.mMaterial.mMaterial == Materials.Empty)) { + if (!(itemData != null + && itemData.hasValidPrefixMaterialData() + && itemData.mMaterial.mMaterial == Materials.Empty)) { adjustedOutputs.add(output); } } @@ -2114,7 +4669,17 @@ public class GT_Recipe implements Comparable<GT_Recipe> { aOutputs = adjustedOutputs.toArray(new ItemStack[0]); aFluidOutputs = adjustedFluidOutputs.toArray(new FluidStack[0]); - return super.addRecipe(aOptimize, aInputs, aOutputs, aSpecial, aOutputChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue); + return super.addRecipe( + aOptimize, + aInputs, + aOutputs, + aSpecial, + aOutputChances, + aFluidInputs, + aFluidOutputs, + aDuration, + aEUt, + aSpecialValue); } @Override @@ -2129,32 +4694,37 @@ public class GT_Recipe implements Comparable<GT_Recipe> { for (int i = 0; i < itemLimit; i++, j++) { if (recipe.mInputs == null || (recipe.mInputs[i] == null && (i == 0 && itemLimit == 1))) { if (recipe.mOutputs != null && recipe.mOutputs.length > 0 && recipe.mOutputs[0] != null) - GT_Log.out.println("recipe " + recipe + " Output 0:" + recipe.mOutputs[0].getDisplayName() + " has errored!"); - else - GT_Log.out.println("recipe " + recipe + " has errored!"); + GT_Log.out.println("recipe " + recipe + " Output 0:" + recipe.mOutputs[0].getDisplayName() + + " has errored!"); + else GT_Log.out.println("recipe " + recipe + " has errored!"); new Exception("Recipe Fixme").printStackTrace(GT_Log.out); } - if ((recipe.mInputs != null && recipe.mInputs[i] != null) || !GT_Values.allow_broken_recipemap) - inputStacks.add(new FixedPositionedStack(recipe.mInputs[i].copy(), 48 - j % 3 * 18, (j >= 3 ? 5 : 23))); + inputStacks.add( + new FixedPositionedStack(recipe.mInputs[i].copy(), 48 - j % 3 * 18, (j >= 3 ? 5 : 23))); else - inputStacks.add(new FixedPositionedStack(new ItemStack(Items.command_block_minecart), 48 - j % 3 * 18, (j >= 3 ? 5 : 23))); + inputStacks.add(new FixedPositionedStack( + new ItemStack(Items.command_block_minecart), 48 - j % 3 * 18, (j >= 3 ? 5 : 23))); } for (int i = 0; i < fluidLimit; i++, j++) { if (recipe.mFluidInputs == null || recipe.mFluidInputs[i] == null) { if (recipe.mOutputs != null && recipe.mOutputs.length > 0 && recipe.mOutputs[0] != null) - GT_Log.out.println("recipe " + recipe + " Output 0:" + recipe.mOutputs[0].getDisplayName() + " has errored!"); - else - GT_Log.out.println("recipe " + recipe + " has errored!"); + GT_Log.out.println("recipe " + recipe + " Output 0:" + recipe.mOutputs[0].getDisplayName() + + " has errored!"); + else GT_Log.out.println("recipe " + recipe + " has errored!"); new Exception("Recipe Fixme").printStackTrace(GT_Log.out); } - if ((recipe.mFluidInputs != null && recipe.mFluidInputs[i] != null) || !GT_Values.allow_broken_recipemap) - inputStacks.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(recipe.mFluidInputs[i], true), 48 - j % 3 * 18, (j >= 3 ? 5 : 23))); + if ((recipe.mFluidInputs != null && recipe.mFluidInputs[i] != null) + || !GT_Values.allow_broken_recipemap) + inputStacks.add(new FixedPositionedStack( + GT_Utility.getFluidDisplayStack(recipe.mFluidInputs[i], true), + 48 - j % 3 * 18, + (j >= 3 ? 5 : 23))); } return inputStacks; @@ -2169,24 +4739,44 @@ public class GT_Recipe implements Comparable<GT_Recipe> { int j = 0; for (int i = 0; i < itemLimit; i++, j++) { - outputStacks.add(new FixedPositionedStack(recipe.mOutputs[i].copy(), 102 + j % 3 * 18, (j >= 3 ? 5 : 23))); + outputStacks.add( + new FixedPositionedStack(recipe.mOutputs[i].copy(), 102 + j % 3 * 18, (j >= 3 ? 5 : 23))); } for (int i = 0; i < fluidLimit; i++, j++) { - outputStacks.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(recipe.mFluidOutputs[i], true), 102 + j % 3 * 18, (j >= 3 ? 5 : 23))); + outputStacks.add(new FixedPositionedStack( + GT_Utility.getFluidDisplayStack(recipe.mFluidOutputs[i], true), + 102 + j % 3 * 18, + (j >= 3 ? 5 : 23))); } return outputStacks; } } - public static class GT_Recipe_Map_DistillationTower extends GT_Recipe_Map { - private static final int TOTAL_INPUT_COUNT = 6; - private static final int FLUID_OUTPUT_COUNT = 11; - private static final int ROW_SIZE = 3; - public GT_Recipe_Map_DistillationTower() { - super(new HashSet<>(110), "gt.recipe.distillationtower", "Distillation Tower", null, RES_PATH_GUI + "basicmachines/DistillationTower", 2, 4, 0, 0, 1, E, 1, E, true, true); - } + public static class GT_Recipe_Map_DistillationTower extends GT_Recipe_Map { + private static final int TOTAL_INPUT_COUNT = 6; + private static final int FLUID_OUTPUT_COUNT = 11; + private static final int ROW_SIZE = 3; + + public GT_Recipe_Map_DistillationTower() { + super( + new HashSet<>(110), + "gt.recipe.distillationtower", + "Distillation Tower", + null, + RES_PATH_GUI + "basicmachines/DistillationTower", + 2, + 4, + 0, + 0, + 1, + E, + 1, + E, + true, + true); + } @Override public ArrayList<PositionedStack> getInputPositionedStacks(GT_Recipe recipe) { @@ -2200,33 +4790,40 @@ public class GT_Recipe implements Comparable<GT_Recipe> { for (int i = 0; i < itemLimit; i++, j++) { if (recipe.mInputs == null || (recipe.mInputs[i] == null && (i == 0 && itemLimit == 1))) { if (recipe.mOutputs != null && recipe.mOutputs.length > 0 && recipe.mOutputs[0] != null) - GT_Log.out.println("recipe " + recipe + " Output 0:" + recipe.mOutputs[0].getDisplayName() + " has errored!"); - else - GT_Log.out.println("recipe " + recipe + " has errored!"); + GT_Log.out.println("recipe " + recipe + " Output 0:" + recipe.mOutputs[0].getDisplayName() + + " has errored!"); + else GT_Log.out.println("recipe " + recipe + " has errored!"); new Exception("Recipe Fixme").printStackTrace(GT_Log.out); } if ((recipe.mInputs != null && recipe.mInputs[i] != null) || !GT_Values.allow_broken_recipemap) - inputStacks.add(new FixedPositionedStack(recipe.mInputs[i].copy(), 48 - j % 3 * 18, (j >= 3 ? 5 : 23))); + inputStacks.add( + new FixedPositionedStack(recipe.mInputs[i].copy(), 48 - j % 3 * 18, (j >= 3 ? 5 : 23))); else - inputStacks.add(new FixedPositionedStack(new ItemStack(Items.command_block_minecart), 48 - j % 3 * 18, (j >= 3 ? 5 : 23))); + inputStacks.add(new FixedPositionedStack( + new ItemStack(Items.command_block_minecart), 48 - j % 3 * 18, (j >= 3 ? 5 : 23))); } for (int i = 0; i < fluidLimit; i++, j++) { if (recipe.mFluidInputs == null || recipe.mFluidInputs[i] == null) { if (recipe.mOutputs != null && recipe.mOutputs.length > 0 && recipe.mOutputs[0] != null) - GT_Log.out.println("recipe " + recipe + " Output 0:" + recipe.mOutputs[0].getDisplayName() + " has errored!"); - else - GT_Log.out.println("recipe " + recipe + " has errored!"); + GT_Log.out.println("recipe " + recipe + " Output 0:" + recipe.mOutputs[0].getDisplayName() + + " has errored!"); + else GT_Log.out.println("recipe " + recipe + " has errored!"); new Exception("Recipe Fixme").printStackTrace(GT_Log.out); } - if ((recipe.mFluidInputs != null && recipe.mFluidInputs[i] != null) || !GT_Values.allow_broken_recipemap) - inputStacks.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(recipe.mFluidInputs[i], true), 48 - j % 3 * 18, (j >= 3 ? 5 : 23))); + if ((recipe.mFluidInputs != null && recipe.mFluidInputs[i] != null) + || !GT_Values.allow_broken_recipemap) + inputStacks.add(new FixedPositionedStack( + GT_Utility.getFluidDisplayStack(recipe.mFluidInputs[i], true), + 48 - j % 3 * 18, + (j >= 3 ? 5 : 23))); } return inputStacks; } + @Override public ArrayList<PositionedStack> getOutputPositionedStacks(GT_Recipe recipe) { int fluidLimit = Math.min(recipe.mFluidOutputs.length, FLUID_OUTPUT_COUNT); @@ -2238,8 +4835,9 @@ public class GT_Recipe implements Comparable<GT_Recipe> { for (int i = 0; i < fluidLimit; i++) { int x = 102 + ((i + 1) % ROW_SIZE) * 18; - int y = 52 - ((i + 1) / ROW_SIZE) * 18; - outputStacks.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(recipe.mFluidOutputs[i], true), x, y)); + int y = 52 - ((i + 1) / ROW_SIZE) * 18; + outputStacks.add( + new FixedPositionedStack(GT_Utility.getFluidDisplayStack(recipe.mFluidOutputs[i], true), x, y)); } return outputStacks; } @@ -2247,14 +4845,30 @@ public class GT_Recipe implements Comparable<GT_Recipe> { public static class GT_Recipe_Map_OilCracker extends GT_Recipe_Map { private final Set<String> mValidCatalystFluidNames = new HashSet<>(); + public GT_Recipe_Map_OilCracker() { - super(new HashSet<>(70), "gt.recipe.craker", "Oil Cracker", null, RES_PATH_GUI + "basicmachines/OilCracker", 1, 1, 1, 2, 1, E, 1, E, true, true); + super( + new HashSet<>(70), + "gt.recipe.craker", + "Oil Cracker", + null, + RES_PATH_GUI + "basicmachines/OilCracker", + 1, + 1, + 1, + 2, + 1, + E, + 1, + E, + true, + true); } @Override public GT_Recipe add(GT_Recipe aRecipe) { GT_Recipe ret = super.add(aRecipe); - if (ret != null && ret.mFluidInputs != null && ret.mFluidInputs.length>1 && ret.mFluidInputs[1] != null) { + if (ret != null && ret.mFluidInputs != null && ret.mFluidInputs.length > 1 && ret.mFluidInputs[1] != null) { mValidCatalystFluidNames.add(ret.mFluidInputs[1].getFluid().getName()); } return ret; @@ -2267,60 +4881,158 @@ public class GT_Recipe implements Comparable<GT_Recipe> { public static class GT_Recipe_WithAlt extends GT_Recipe { - ItemStack[][] mOreDictAlt; - - public GT_Recipe_WithAlt(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue, ItemStack[][] aAlt) { - super(aOptimize, aInputs, aOutputs, aSpecialItems, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue); - mOreDictAlt = aAlt; - } - - - public Object getAltRepresentativeInput(int aIndex) { - if (aIndex < 0) return null; - if (aIndex < mOreDictAlt.length) { - if (mOreDictAlt[aIndex] != null && mOreDictAlt[aIndex].length > 0) { - ItemStack[] rStacks = new ItemStack[mOreDictAlt[aIndex].length]; - for (int i = 0; i < mOreDictAlt[aIndex].length; i++) { - rStacks[i] = GT_Utility.copyOrNull(mOreDictAlt[aIndex][i]); - } - return rStacks; - } - } - if (aIndex >= mInputs.length) return null; - return GT_Utility.copyOrNull(mInputs[aIndex]); - } - + ItemStack[][] mOreDictAlt; + + public GT_Recipe_WithAlt( + boolean aOptimize, + ItemStack[] aInputs, + ItemStack[] aOutputs, + Object aSpecialItems, + int[] aChances, + FluidStack[] aFluidInputs, + FluidStack[] aFluidOutputs, + int aDuration, + int aEUt, + int aSpecialValue, + ItemStack[][] aAlt) { + super( + aOptimize, + aInputs, + aOutputs, + aSpecialItems, + aChances, + aFluidInputs, + aFluidOutputs, + aDuration, + aEUt, + aSpecialValue); + mOreDictAlt = aAlt; + } + + public Object getAltRepresentativeInput(int aIndex) { + if (aIndex < 0) return null; + if (aIndex < mOreDictAlt.length) { + if (mOreDictAlt[aIndex] != null && mOreDictAlt[aIndex].length > 0) { + ItemStack[] rStacks = new ItemStack[mOreDictAlt[aIndex].length]; + for (int i = 0; i < mOreDictAlt[aIndex].length; i++) { + rStacks[i] = GT_Utility.copyOrNull(mOreDictAlt[aIndex][i]); + } + return rStacks; + } + } + if (aIndex >= mInputs.length) return null; + return GT_Utility.copyOrNull(mInputs[aIndex]); + } } private static class ReplicatorFakeMap extends GT_Recipe_Map { - public ReplicatorFakeMap(Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { - super(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, aUsualInputCount, aUsualOutputCount, aMinimalInputItems, aMinimalInputFluids, aAmperage, aNEISpecialValuePre, aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed); + public ReplicatorFakeMap( + Collection<GT_Recipe> aRecipeList, + String aUnlocalizedName, + String aLocalName, + String aNEIName, + String aNEIGUIPath, + int aUsualInputCount, + int aUsualOutputCount, + int aMinimalInputItems, + int aMinimalInputFluids, + int aAmperage, + String aNEISpecialValuePre, + int aNEISpecialValueMultiplier, + String aNEISpecialValuePost, + boolean aShowVoltageAmperageInNEI, + boolean aNEIAllowed) { + super( + aRecipeList, + aUnlocalizedName, + aLocalName, + aNEIName, + aNEIGUIPath, + aUsualInputCount, + aUsualOutputCount, + aMinimalInputItems, + aMinimalInputFluids, + aAmperage, + aNEISpecialValuePre, + aNEISpecialValueMultiplier, + aNEISpecialValuePost, + aShowVoltageAmperageInNEI, + aNEIAllowed); } @Override - public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { + public GT_Recipe addFakeRecipe( + boolean aCheckForCollisions, + ItemStack[] aInputs, + ItemStack[] aOutputs, + Object aSpecial, + FluidStack[] aFluidInputs, + FluidStack[] aFluidOutputs, + int aDuration, + int aEUt, + int aSpecialValue) { AtomicInteger ai = new AtomicInteger(); Optional.ofNullable(GT_OreDictUnificator.getAssociation(aOutputs[0])) .map(itemData -> itemData.mMaterial) .map(materialsStack -> materialsStack.mMaterial) .map(materials -> materials.mElement) .map(Element::getMass) - .ifPresent(e -> - { - aFluidInputs[0].amount = (int) GT_MetaTileEntity_Replicator.cubicFluidMultiplier(e); - ai.set(GT_Utility.safeInt(aFluidInputs[0].amount * 512L, 1)); - } - ); - return addFakeRecipe(aCheckForCollisions, new GT_Recipe(false, aInputs, aOutputs, aSpecial, null, aFluidInputs, aFluidOutputs, ai.get(), aEUt, aSpecialValue)); + .ifPresent(e -> { + aFluidInputs[0].amount = (int) GT_MetaTileEntity_Replicator.cubicFluidMultiplier(e); + ai.set(GT_Utility.safeInt(aFluidInputs[0].amount * 512L, 1)); + }); + return addFakeRecipe( + aCheckForCollisions, + new GT_Recipe( + false, + aInputs, + aOutputs, + aSpecial, + null, + aFluidInputs, + aFluidOutputs, + ai.get(), + aEUt, + aSpecialValue)); } - } public static class GT_Recipe_Map_PlasmaForge extends GT_Recipe_Map { - public GT_Recipe_Map_PlasmaForge(Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { - super(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, aUsualInputCount, aUsualOutputCount, aMinimalInputItems, aMinimalInputFluids, aAmperage, aNEISpecialValuePre, aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed, true); + public GT_Recipe_Map_PlasmaForge( + Collection<GT_Recipe> aRecipeList, + String aUnlocalizedName, + String aLocalName, + String aNEIName, + String aNEIGUIPath, + int aUsualInputCount, + int aUsualOutputCount, + int aMinimalInputItems, + int aMinimalInputFluids, + int aAmperage, + String aNEISpecialValuePre, + int aNEISpecialValueMultiplier, + String aNEISpecialValuePost, + boolean aShowVoltageAmperageInNEI, + boolean aNEIAllowed) { + super( + aRecipeList, + aUnlocalizedName, + aLocalName, + aNEIName, + aNEIGUIPath, + aUsualInputCount, + aUsualOutputCount, + aMinimalInputItems, + aMinimalInputFluids, + aAmperage, + aNEISpecialValuePre, + aNEISpecialValueMultiplier, + aNEISpecialValuePost, + aShowVoltageAmperageInNEI, + aNEIAllowed, + true); } @Override @@ -2328,15 +5040,19 @@ public class GT_Recipe implements Comparable<GT_Recipe> { ArrayList<PositionedStack> inputStacks = new ArrayList<>(); int i = 0; if (recipe.mInputs != null) { - for (int j = 0; j < recipe.mInputs.length; j ++, i ++) { + for (int j = 0; j < recipe.mInputs.length; j++, i++) { if (recipe.mInputs[j] == NI) continue; - inputStacks.add(new FixedPositionedStack(recipe.mInputs[j].copy(), 12 + 18 * (i % 3), 5 + 18 * (i / 3))); + inputStacks.add( + new FixedPositionedStack(recipe.mInputs[j].copy(), 12 + 18 * (i % 3), 5 + 18 * (i / 3))); } } if (recipe.mFluidInputs != null) { - for (int j = 0; j < recipe.mFluidInputs.length; j ++, i ++) { + for (int j = 0; j < recipe.mFluidInputs.length; j++, i++) { if (recipe.mFluidInputs[j] == NF) continue; - inputStacks.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(recipe.mFluidInputs[j], true), 12 + 18 * (i % 3), 5 + 18 * (i / 3))); + inputStacks.add(new FixedPositionedStack( + GT_Utility.getFluidDisplayStack(recipe.mFluidInputs[j], true), + 12 + 18 * (i % 3), + 5 + 18 * (i / 3))); } } return inputStacks; @@ -2347,15 +5063,19 @@ public class GT_Recipe implements Comparable<GT_Recipe> { ArrayList<PositionedStack> outputStacks = new ArrayList<>(); int i = 0; if (recipe.mOutputs != null) { - for (int j = 0; j < recipe.mOutputs.length; j ++, i ++) { + for (int j = 0; j < recipe.mOutputs.length; j++, i++) { if (recipe.mOutputs[j] == NI) continue; - outputStacks.add(new FixedPositionedStack(recipe.mOutputs[j].copy(), 102 + 18 * (i % 3), 5 + 18 * (i / 3))); + outputStacks.add( + new FixedPositionedStack(recipe.mOutputs[j].copy(), 102 + 18 * (i % 3), 5 + 18 * (i / 3))); } } if (recipe.mFluidOutputs != null) { - for (int j = 0; j < recipe.mFluidOutputs.length; j ++, i ++) { + for (int j = 0; j < recipe.mFluidOutputs.length; j++, i++) { if (recipe.mFluidOutputs[j] == NF) continue; - outputStacks.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(recipe.mFluidOutputs[j], true), 102 + 18 * (i % 3), 5 + 18 * (i / 3))); + outputStacks.add(new FixedPositionedStack( + GT_Utility.getFluidDisplayStack(recipe.mFluidOutputs[j], true), + 102 + 18 * (i % 3), + 5 + 18 * (i / 3))); } } return outputStacks; @@ -2364,13 +5084,64 @@ public class GT_Recipe implements Comparable<GT_Recipe> { public static class GT_Recipe_Map_ComplexFusion extends GT_Recipe_Map { - public GT_Recipe_Map_ComplexFusion(Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { - super(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, aUsualInputCount, aUsualOutputCount, aMinimalInputItems, aMinimalInputFluids, aAmperage, aNEISpecialValuePre, aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed, true); + public GT_Recipe_Map_ComplexFusion( + Collection<GT_Recipe> aRecipeList, + String aUnlocalizedName, + String aLocalName, + String aNEIName, + String aNEIGUIPath, + int aUsualInputCount, + int aUsualOutputCount, + int aMinimalInputItems, + int aMinimalInputFluids, + int aAmperage, + String aNEISpecialValuePre, + int aNEISpecialValueMultiplier, + String aNEISpecialValuePost, + boolean aShowVoltageAmperageInNEI, + boolean aNEIAllowed) { + super( + aRecipeList, + aUnlocalizedName, + aLocalName, + aNEIName, + aNEIGUIPath, + aUsualInputCount, + aUsualOutputCount, + aMinimalInputItems, + aMinimalInputFluids, + aAmperage, + aNEISpecialValuePre, + aNEISpecialValueMultiplier, + aNEISpecialValuePost, + aShowVoltageAmperageInNEI, + aNEIAllowed, + true); } @Override - public GT_Recipe addRecipe(int[] aOutputChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - return addRecipe(new GT_Recipe(false, null, null, null, aOutputChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue), false, false, false); + public GT_Recipe addRecipe( + int[] aOutputChances, + FluidStack[] aFluidInputs, + FluidStack[] aFluidOutputs, + int aDuration, + int aEUt, + int aSpecialValue) { + return addRecipe( + new GT_Recipe( + false, + null, + null, + null, + aOutputChances, + aFluidInputs, + aFluidOutputs, + aDuration, + aEUt, + aSpecialValue), + false, + false, + false); } @Override @@ -2378,9 +5149,12 @@ public class GT_Recipe implements Comparable<GT_Recipe> { ArrayList<PositionedStack> inputStacks = new ArrayList<>(); int i = 0; if (recipe.mFluidInputs != null) { - for (int j = 0; j < recipe.mFluidInputs.length; j ++, i ++) { + for (int j = 0; j < recipe.mFluidInputs.length; j++, i++) { if (recipe.mFluidInputs[j] == NF) continue; - inputStacks.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(recipe.mFluidInputs[j], true), 3 + 18 * (i % 4), -1 + 18 * (i / 4))); + inputStacks.add(new FixedPositionedStack( + GT_Utility.getFluidDisplayStack(recipe.mFluidInputs[j], true), + 3 + 18 * (i % 4), + -1 + 18 * (i / 4))); } } return inputStacks; @@ -2391,13 +5165,15 @@ public class GT_Recipe implements Comparable<GT_Recipe> { ArrayList<PositionedStack> outputStacks = new ArrayList<>(); int i = 0; if (recipe.mFluidOutputs != null) { - for (int j = 0; j < recipe.mFluidOutputs.length; j ++, i ++) { + for (int j = 0; j < recipe.mFluidOutputs.length; j++, i++) { if (recipe.mFluidOutputs[j] == NF) continue; - outputStacks.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(recipe.mFluidOutputs[j], true), 93 + 18 * (i % 4), -1 + 18 * (i / 4))); + outputStacks.add(new FixedPositionedStack( + GT_Utility.getFluidDisplayStack(recipe.mFluidOutputs[j], true), + 93 + 18 * (i % 4), + -1 + 18 * (i / 4))); } } return outputStacks; } } - } diff --git a/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java b/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java index 9ce949f274..1b1654d8a6 100644 --- a/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java +++ b/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java @@ -1,24 +1,21 @@ package gregtech.api.util; -import com.google.common.base.Stopwatch; +import static gregtech.api.enums.GT_Values.*; +import static gregtech.api.enums.Materials.*; +import static gregtech.api.enums.Materials.Void; + import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.*; -import gregtech.api.enums.TC_Aspects.TC_AspectStack; -import gregtech.api.interfaces.internal.IThaumcraftCompat; import gregtech.api.objects.ItemData; import gregtech.api.objects.MaterialStack; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; - import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; -import static gregtech.api.enums.GT_Values.*; -import static gregtech.api.enums.Materials.Void; -import static gregtech.api.enums.Materials.*; /** * Class for Automatic Recipe registering. */ @@ -27,118 +24,130 @@ public class GT_RecipeRegistrator { * List of Materials, which are used in the Creation of Sticks. All Rod Materials are automatically added to this List. */ public static final List<Materials> sRodMaterialList = new ArrayList<Materials>(); + private static final ItemStack sMt1 = new ItemStack(Blocks.dirt, 1, 0), sMt2 = new ItemStack(Blocks.dirt, 1, 0); private static final String s_H = "h", s_F = "f", s_I = "I", s_P = "P", s_R = "R"; - private static final RecipeShape[] - sShapes = new RecipeShape[]{ - new RecipeShape(sMt1, null, sMt1, sMt1, sMt1, sMt1, null, sMt1, null), - new RecipeShape(sMt1, null, sMt1, sMt1, null, sMt1, sMt1, sMt1, sMt1), - new RecipeShape(null, sMt1, null, sMt1, sMt1, sMt1, sMt1, null, sMt1), - new RecipeShape(sMt1, sMt1, sMt1, sMt1, null, sMt1, null, null, null), - new RecipeShape(sMt1, null, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1), - new RecipeShape(sMt1, sMt1, sMt1, sMt1, null, sMt1, sMt1, null, sMt1), - new RecipeShape(null, null, null, sMt1, null, sMt1, sMt1, null, sMt1), - new RecipeShape(null, sMt1, null, null, sMt1, null, null, sMt2, null), - new RecipeShape(sMt1, sMt1, sMt1, null, sMt2, null, null, sMt2, null), - new RecipeShape(null, sMt1, null, null, sMt2, null, null, sMt2, null), - new RecipeShape(sMt1, sMt1, null, sMt1, sMt2, null, null, sMt2, null), - new RecipeShape(null, sMt1, sMt1, null, sMt2, sMt1, null, sMt2, null), - new RecipeShape(sMt1, sMt1, null, null, sMt2, null, null, sMt2, null), - new RecipeShape(null, sMt1, sMt1, null, sMt2, null, null, sMt2, null), - new RecipeShape(null, sMt1, null, sMt1, null, null, null, sMt1, sMt2), - new RecipeShape(null, sMt1, null, null, null, sMt1, sMt2, sMt1, null), - new RecipeShape(null, sMt1, null, sMt1, null, sMt1, null, null, sMt2), - new RecipeShape(null, sMt1, null, sMt1, null, sMt1, sMt2, null, null), - new RecipeShape(null, sMt2, null, null, sMt1, null, null, sMt1, null), - new RecipeShape(null, sMt2, null, null, sMt2, null, sMt1, sMt1, sMt1), - new RecipeShape(null, sMt2, null, null, sMt2, null, null, sMt1, null), - new RecipeShape(null, sMt2, null, sMt1, sMt2, null, sMt1, sMt1, null), - new RecipeShape(null, sMt2, null, null, sMt2, sMt1, null, sMt1, sMt1), - new RecipeShape(null, sMt2, null, null, sMt2, null, sMt1, sMt1, null), - new RecipeShape(sMt1, null, null, null, sMt2, null, null, null, sMt2), - new RecipeShape(null, null, sMt1, null, sMt2, null, sMt2, null, null), - new RecipeShape(sMt1, null, null, null, sMt2, null, null, null, null), - new RecipeShape(null, null, sMt1, null, sMt2, null, null, null, null), - new RecipeShape(sMt1, sMt2, null, null, null, null, null, null, null), - new RecipeShape(sMt2, sMt1, null, null, null, null, null, null, null), - new RecipeShape(sMt1, null, null, sMt2, null, null, null, null, null), - new RecipeShape(sMt2, null, null, sMt1, null, null, null, null, null), - new RecipeShape(sMt1, sMt1, sMt1, sMt1, sMt1, sMt1, null, sMt2, null), - new RecipeShape(sMt1, sMt1, null, sMt1, sMt1, sMt2, sMt1, sMt1, null), - new RecipeShape(null, sMt1, sMt1, sMt2, sMt1, sMt1, null, sMt1, sMt1), - new RecipeShape(null, sMt2, null, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1), - new RecipeShape(sMt1, sMt1, sMt1, sMt1, sMt2, sMt1, null, sMt2, null), - new RecipeShape(sMt1, sMt1, null, sMt1, sMt2, sMt2, sMt1, sMt1, null), - new RecipeShape(null, sMt1, sMt1, sMt2, sMt2, sMt1, null, sMt1, sMt1), - new RecipeShape(null, sMt2, null, sMt1, sMt2, sMt1, sMt1, sMt1, sMt1), - new RecipeShape(sMt1, null, null, null, sMt1, null, null, null, null), - new RecipeShape(null, sMt1, null, sMt1, null, null, null, null, null), - new RecipeShape(sMt1, sMt1, null, sMt2, null, sMt1, sMt2, null, null), - new RecipeShape(null, sMt1, sMt1, sMt1, null, sMt2, null, null, sMt2) + private static final RecipeShape[] sShapes = new RecipeShape[] { + new RecipeShape(sMt1, null, sMt1, sMt1, sMt1, sMt1, null, sMt1, null), + new RecipeShape(sMt1, null, sMt1, sMt1, null, sMt1, sMt1, sMt1, sMt1), + new RecipeShape(null, sMt1, null, sMt1, sMt1, sMt1, sMt1, null, sMt1), + new RecipeShape(sMt1, sMt1, sMt1, sMt1, null, sMt1, null, null, null), + new RecipeShape(sMt1, null, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1), + new RecipeShape(sMt1, sMt1, sMt1, sMt1, null, sMt1, sMt1, null, sMt1), + new RecipeShape(null, null, null, sMt1, null, sMt1, sMt1, null, sMt1), + new RecipeShape(null, sMt1, null, null, sMt1, null, null, sMt2, null), + new RecipeShape(sMt1, sMt1, sMt1, null, sMt2, null, null, sMt2, null), + new RecipeShape(null, sMt1, null, null, sMt2, null, null, sMt2, null), + new RecipeShape(sMt1, sMt1, null, sMt1, sMt2, null, null, sMt2, null), + new RecipeShape(null, sMt1, sMt1, null, sMt2, sMt1, null, sMt2, null), + new RecipeShape(sMt1, sMt1, null, null, sMt2, null, null, sMt2, null), + new RecipeShape(null, sMt1, sMt1, null, sMt2, null, null, sMt2, null), + new RecipeShape(null, sMt1, null, sMt1, null, null, null, sMt1, sMt2), + new RecipeShape(null, sMt1, null, null, null, sMt1, sMt2, sMt1, null), + new RecipeShape(null, sMt1, null, sMt1, null, sMt1, null, null, sMt2), + new RecipeShape(null, sMt1, null, sMt1, null, sMt1, sMt2, null, null), + new RecipeShape(null, sMt2, null, null, sMt1, null, null, sMt1, null), + new RecipeShape(null, sMt2, null, null, sMt2, null, sMt1, sMt1, sMt1), + new RecipeShape(null, sMt2, null, null, sMt2, null, null, sMt1, null), + new RecipeShape(null, sMt2, null, sMt1, sMt2, null, sMt1, sMt1, null), + new RecipeShape(null, sMt2, null, null, sMt2, sMt1, null, sMt1, sMt1), + new RecipeShape(null, sMt2, null, null, sMt2, null, sMt1, sMt1, null), + new RecipeShape(sMt1, null, null, null, sMt2, null, null, null, sMt2), + new RecipeShape(null, null, sMt1, null, sMt2, null, sMt2, null, null), + new RecipeShape(sMt1, null, null, null, sMt2, null, null, null, null), + new RecipeShape(null, null, sMt1, null, sMt2, null, null, null, null), + new RecipeShape(sMt1, sMt2, null, null, null, null, null, null, null), + new RecipeShape(sMt2, sMt1, null, null, null, null, null, null, null), + new RecipeShape(sMt1, null, null, sMt2, null, null, null, null, null), + new RecipeShape(sMt2, null, null, sMt1, null, null, null, null, null), + new RecipeShape(sMt1, sMt1, sMt1, sMt1, sMt1, sMt1, null, sMt2, null), + new RecipeShape(sMt1, sMt1, null, sMt1, sMt1, sMt2, sMt1, sMt1, null), + new RecipeShape(null, sMt1, sMt1, sMt2, sMt1, sMt1, null, sMt1, sMt1), + new RecipeShape(null, sMt2, null, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1), + new RecipeShape(sMt1, sMt1, sMt1, sMt1, sMt2, sMt1, null, sMt2, null), + new RecipeShape(sMt1, sMt1, null, sMt1, sMt2, sMt2, sMt1, sMt1, null), + new RecipeShape(null, sMt1, sMt1, sMt2, sMt2, sMt1, null, sMt1, sMt1), + new RecipeShape(null, sMt2, null, sMt1, sMt2, sMt1, sMt1, sMt1, sMt1), + new RecipeShape(sMt1, null, null, null, sMt1, null, null, null, null), + new RecipeShape(null, sMt1, null, sMt1, null, null, null, null, null), + new RecipeShape(sMt1, sMt1, null, sMt2, null, sMt1, sMt2, null, null), + new RecipeShape(null, sMt1, sMt1, sMt1, null, sMt2, null, null, sMt2) }; - private static final String[][] sShapesA = new String[][]{ - null, - null, - null, - {"Helmet", s_P + s_P + s_P, s_P + s_H + s_P}, - {"ChestPlate", s_P + s_H + s_P, s_P + s_P + s_P, s_P + s_P + s_P}, - {"Pants", s_P + s_P + s_P, s_P + s_H + s_P, s_P + " " + s_P}, - {"Boots", s_P + " " + s_P, s_P + s_H + s_P}, - {"Sword", " " + s_P + " ", s_F + s_P + s_H, " " + s_R + " "}, - {"Pickaxe", s_P + s_I + s_I, s_F + s_R + s_H, " " + s_R + " "}, - {"Shovel", s_F + s_P + s_H, " " + s_R + " ", " " + s_R + " "}, - {"Axe", s_P + s_I + s_H, s_P + s_R + " ", s_F + s_R + " "}, - {"Axe", s_P + s_I + s_H, s_P + s_R + " ", s_F + s_R + " "}, - {"Hoe", s_P + s_I + s_H, s_F + s_R + " ", " " + s_R + " "}, - {"Hoe", s_P + s_I + s_H, s_F + s_R + " ", " " + s_R + " "}, - {"Sickle", " " + s_P + " ", s_P + s_F + " ", s_H + s_P + s_R}, - {"Sickle", " " + s_P + " ", s_P + s_F + " ", s_H + s_P + s_R}, - {"Sickle", " " + s_P + " ", s_P + s_F + " ", s_H + s_P + s_R}, - {"Sickle", " " + s_P + " ", s_P + s_F + " ", s_H + s_P + s_R}, - {"Sword", " " + s_R + " ", s_F + s_P + s_H, " " + s_P + " "}, - {"Pickaxe", " " + s_R + " ", s_F + s_R + s_H, s_P + s_I + s_I}, - {"Shovel", " " + s_R + " ", " " + s_R + " ", s_F + s_P + s_H}, - {"Axe", s_F + s_R + " ", s_P + s_R + " ", s_P + s_I + s_H}, - {"Axe", s_F + s_R + " ", s_P + s_R + " ", s_P + s_I + s_H}, - {"Hoe", " " + s_R + " ", s_F + s_R + " ", s_P + s_I + s_H}, - {"Hoe", " " + s_R + " ", s_F + s_R + " ", s_P + s_I + s_H}, - {"Spear", s_P + s_H + " ", s_F + s_R + " ", " " + " " + s_R}, - {"Spear", s_P + s_H + " ", s_F + s_R + " ", " " + " " + s_R}, - {"Knive", s_H + s_P, s_R + s_F}, - {"Knive", s_F + s_H, s_P + s_R}, - {"Knive", s_F + s_H, s_P + s_R}, - {"Knive", s_P + s_F, s_R + s_H}, - {"Knive", s_P + s_F, s_R + s_H}, - null, - null, - null, - null, - {"WarAxe", s_P + s_P + s_P, s_P + s_R + s_P, s_F + s_R + s_H}, - null, - null, - null, - {"Shears", s_H + s_P, s_P + s_F}, - {"Shears", s_H + s_P, s_P + s_F}, - {"Scythe", s_I + s_P + s_H, s_R + s_F + s_P, s_R + " " + " "}, - {"Scythe", s_H + s_P + s_I, s_P + s_F + s_R, " " + " " + s_R} + private static final String[][] sShapesA = new String[][] { + null, + null, + null, + {"Helmet", s_P + s_P + s_P, s_P + s_H + s_P}, + {"ChestPlate", s_P + s_H + s_P, s_P + s_P + s_P, s_P + s_P + s_P}, + {"Pants", s_P + s_P + s_P, s_P + s_H + s_P, s_P + " " + s_P}, + {"Boots", s_P + " " + s_P, s_P + s_H + s_P}, + {"Sword", " " + s_P + " ", s_F + s_P + s_H, " " + s_R + " "}, + {"Pickaxe", s_P + s_I + s_I, s_F + s_R + s_H, " " + s_R + " "}, + {"Shovel", s_F + s_P + s_H, " " + s_R + " ", " " + s_R + " "}, + {"Axe", s_P + s_I + s_H, s_P + s_R + " ", s_F + s_R + " "}, + {"Axe", s_P + s_I + s_H, s_P + s_R + " ", s_F + s_R + " "}, + {"Hoe", s_P + s_I + s_H, s_F + s_R + " ", " " + s_R + " "}, + {"Hoe", s_P + s_I + s_H, s_F + s_R + " ", " " + s_R + " "}, + {"Sickle", " " + s_P + " ", s_P + s_F + " ", s_H + s_P + s_R}, + {"Sickle", " " + s_P + " ", s_P + s_F + " ", s_H + s_P + s_R}, + {"Sickle", " " + s_P + " ", s_P + s_F + " ", s_H + s_P + s_R}, + {"Sickle", " " + s_P + " ", s_P + s_F + " ", s_H + s_P + s_R}, + {"Sword", " " + s_R + " ", s_F + s_P + s_H, " " + s_P + " "}, + {"Pickaxe", " " + s_R + " ", s_F + s_R + s_H, s_P + s_I + s_I}, + {"Shovel", " " + s_R + " ", " " + s_R + " ", s_F + s_P + s_H}, + {"Axe", s_F + s_R + " ", s_P + s_R + " ", s_P + s_I + s_H}, + {"Axe", s_F + s_R + " ", s_P + s_R + " ", s_P + s_I + s_H}, + {"Hoe", " " + s_R + " ", s_F + s_R + " ", s_P + s_I + s_H}, + {"Hoe", " " + s_R + " ", s_F + s_R + " ", s_P + s_I + s_H}, + {"Spear", s_P + s_H + " ", s_F + s_R + " ", " " + " " + s_R}, + {"Spear", s_P + s_H + " ", s_F + s_R + " ", " " + " " + s_R}, + {"Knive", s_H + s_P, s_R + s_F}, + {"Knive", s_F + s_H, s_P + s_R}, + {"Knive", s_F + s_H, s_P + s_R}, + {"Knive", s_P + s_F, s_R + s_H}, + {"Knive", s_P + s_F, s_R + s_H}, + null, + null, + null, + null, + {"WarAxe", s_P + s_P + s_P, s_P + s_R + s_P, s_F + s_R + s_H}, + null, + null, + null, + {"Shears", s_H + s_P, s_P + s_F}, + {"Shears", s_H + s_P, s_P + s_F}, + {"Scythe", s_I + s_P + s_H, s_R + s_F + s_P, s_R + " " + " "}, + {"Scythe", s_H + s_P + s_I, s_P + s_F + s_R, " " + " " + s_R} }; public static volatile int VERSION = 509; - public static void registerMaterialRecycling(ItemStack aStack, Materials aMaterial, long aMaterialAmount, MaterialStack aByproduct) { + public static void registerMaterialRecycling( + ItemStack aStack, Materials aMaterial, long aMaterialAmount, MaterialStack aByproduct) { if (GT_Utility.isStackInvalid(aStack)) return; if (aByproduct != null) { aByproduct = aByproduct.clone(); aByproduct.mAmount /= aStack.stackSize; } - GT_OreDictUnificator.addItemData(GT_Utility.copyAmount(1, aStack), new ItemData(aMaterial, aMaterialAmount / aStack.stackSize, aByproduct)); + GT_OreDictUnificator.addItemData( + GT_Utility.copyAmount(1, aStack), + new ItemData(aMaterial, aMaterialAmount / aStack.stackSize, aByproduct)); } public static void registerMaterialRecycling(ItemStack aStack, ItemData aData) { - if (GT_Utility.isStackInvalid(aStack) || GT_Utility.areStacksEqual(new ItemStack(Items.blaze_rod), aStack) || aData == null || !aData.hasValidMaterialData() || aData.mMaterial.mAmount <= 0 || GT_Utility.getFluidForFilledItem(aStack, false) != null) - return; + if (GT_Utility.isStackInvalid(aStack) + || GT_Utility.areStacksEqual(new ItemStack(Items.blaze_rod), aStack) + || aData == null + || !aData.hasValidMaterialData() + || aData.mMaterial.mAmount <= 0 + || GT_Utility.getFluidForFilledItem(aStack, false) != null) return; registerReverseMacerating(GT_Utility.copyAmount(1, aStack), aData, aData.mPrefix == null); - registerReverseSmelting(GT_Utility.copyAmount(1, aStack), aData.mMaterial.mMaterial, aData.mMaterial.mAmount, true); - registerReverseFluidSmelting(GT_Utility.copyAmount(1, aStack), aData.mMaterial.mMaterial, aData.mMaterial.mAmount, aData.getByProduct(0)); + registerReverseSmelting( + GT_Utility.copyAmount(1, aStack), aData.mMaterial.mMaterial, aData.mMaterial.mAmount, true); + registerReverseFluidSmelting( + GT_Utility.copyAmount(1, aStack), + aData.mMaterial.mMaterial, + aData.mMaterial.mAmount, + aData.getByProduct(0)); registerReverseArcSmelting(GT_Utility.copyAmount(1, aStack), aData); } @@ -147,17 +156,48 @@ public class GT_RecipeRegistrator { * @param aMaterial the Material. * @param aMaterialAmount the amount of it in Material Units. */ - public static void registerReverseFluidSmelting(ItemStack aStack, Materials aMaterial, long aMaterialAmount, MaterialStack aByproduct) { - if (aStack == null || aMaterial == null || aMaterial.mSmeltInto.mStandardMoltenFluid == null || !aMaterial.contains(SubTag.SMELTING_TO_FLUID) || (L * aMaterialAmount) / (M * aStack.stackSize) <= 0) - return; + public static void registerReverseFluidSmelting( + ItemStack aStack, Materials aMaterial, long aMaterialAmount, MaterialStack aByproduct) { + if (aStack == null + || aMaterial == null + || aMaterial.mSmeltInto.mStandardMoltenFluid == null + || !aMaterial.contains(SubTag.SMELTING_TO_FLUID) + || (L * aMaterialAmount) / (M * aStack.stackSize) <= 0) return; ItemData tData = GT_OreDictUnificator.getItemData(aStack); - boolean tHide = aStack.getUnlocalizedName().startsWith("gt.blockmachines")&&(GT_Mod.gregtechproxy.mHideRecyclingRecipes); - if(GT_Mod.gregtechproxy.mHideRecyclingRecipes&&tData!=null&&tData.hasValidPrefixData()&&!(tData.mPrefix==OrePrefixes.dust||tData.mPrefix==OrePrefixes.ingot||tData.mPrefix==OrePrefixes.block|tData.mPrefix==OrePrefixes.plate)){tHide=true;} -// boolean tHide = (aMaterial != Materials.Iron && aMaterial!= Materials.Redstone)&&(GT_Mod.gregtechproxy.mHideRecyclingRecipes); -// if(tHide && tData!=null&&tData.hasValidPrefixData()&&tData.mPrefix==OrePrefixes.ingot){ -// tHide=false; -// } - RA.addFluidSmelterRecipe(GT_Utility.copyAmount(1, aStack), aByproduct == null ? null : aByproduct.mMaterial.contains(SubTag.NO_SMELTING) || !aByproduct.mMaterial.contains(SubTag.METAL) ? aByproduct.mMaterial.contains(SubTag.FLAMMABLE) ? GT_OreDictUnificator.getDust(Materials.Ash, aByproduct.mAmount / 2) : aByproduct.mMaterial.contains(SubTag.UNBURNABLE) ? GT_OreDictUnificator.getDustOrIngot(aByproduct.mMaterial.mSmeltInto, aByproduct.mAmount) : null : GT_OreDictUnificator.getIngotOrDust(aByproduct.mMaterial.mSmeltInto, aByproduct.mAmount), aMaterial.mSmeltInto.getMolten((L * aMaterialAmount) / (M * aStack.stackSize)), 10000, (int) Math.max(1, (24 * aMaterialAmount) / M), Math.max(8, (int) Math.sqrt(2 * aMaterial.mSmeltInto.mStandardMoltenFluid.getTemperature())), tHide); + boolean tHide = aStack.getUnlocalizedName().startsWith("gt.blockmachines") + && (GT_Mod.gregtechproxy.mHideRecyclingRecipes); + if (GT_Mod.gregtechproxy.mHideRecyclingRecipes + && tData != null + && tData.hasValidPrefixData() + && !(tData.mPrefix == OrePrefixes.dust + || tData.mPrefix == OrePrefixes.ingot + || tData.mPrefix == OrePrefixes.block | tData.mPrefix == OrePrefixes.plate)) { + tHide = true; + } + // boolean tHide = (aMaterial != Materials.Iron && aMaterial!= + // Materials.Redstone)&&(GT_Mod.gregtechproxy.mHideRecyclingRecipes); + // if(tHide && tData!=null&&tData.hasValidPrefixData()&&tData.mPrefix==OrePrefixes.ingot){ + // tHide=false; + // } + RA.addFluidSmelterRecipe( + GT_Utility.copyAmount(1, aStack), + aByproduct == null + ? null + : aByproduct.mMaterial.contains(SubTag.NO_SMELTING) + || !aByproduct.mMaterial.contains(SubTag.METAL) + ? aByproduct.mMaterial.contains(SubTag.FLAMMABLE) + ? GT_OreDictUnificator.getDust(Materials.Ash, aByproduct.mAmount / 2) + : aByproduct.mMaterial.contains(SubTag.UNBURNABLE) + ? GT_OreDictUnificator.getDustOrIngot( + aByproduct.mMaterial.mSmeltInto, aByproduct.mAmount) + : null + : GT_OreDictUnificator.getIngotOrDust( + aByproduct.mMaterial.mSmeltInto, aByproduct.mAmount), + aMaterial.mSmeltInto.getMolten((L * aMaterialAmount) / (M * aStack.stackSize)), + 10000, + (int) Math.max(1, (24 * aMaterialAmount) / M), + Math.max(8, (int) Math.sqrt(2 * aMaterial.mSmeltInto.mStandardMoltenFluid.getTemperature())), + tHide); } /** @@ -166,21 +206,42 @@ public class GT_RecipeRegistrator { * @param aMaterialAmount the amount of it in Material Units. * @param aAllowAlloySmelter if it is allowed to be recycled inside the Alloy Smelter. */ - public static void registerReverseSmelting(ItemStack aStack, Materials aMaterial, long aMaterialAmount, boolean aAllowAlloySmelter) { - if (aStack == null || aMaterial == null || aMaterialAmount <= 0 || aMaterial.contains(SubTag.NO_SMELTING) || (aMaterialAmount > M && aMaterial.contains(SubTag.METAL))) - return; + public static void registerReverseSmelting( + ItemStack aStack, Materials aMaterial, long aMaterialAmount, boolean aAllowAlloySmelter) { + if (aStack == null + || aMaterial == null + || aMaterialAmount <= 0 + || aMaterial.contains(SubTag.NO_SMELTING) + || (aMaterialAmount > M && aMaterial.contains(SubTag.METAL))) return; aMaterialAmount /= aStack.stackSize; - if(aMaterial==Materials.Naquadah||aMaterial==Materials.NaquadahEnriched)return; + if (aMaterial == Materials.Naquadah || aMaterial == Materials.NaquadahEnriched) return; - boolean tHide = (aMaterial != Materials.Iron)&&(GT_Mod.gregtechproxy.mHideRecyclingRecipes); + boolean tHide = (aMaterial != Materials.Iron) && (GT_Mod.gregtechproxy.mHideRecyclingRecipes); if (aAllowAlloySmelter) - GT_ModHandler.addSmeltingAndAlloySmeltingRecipe(GT_Utility.copyAmount(1, aStack), GT_OreDictUnificator.getIngot(aMaterial.mSmeltInto, aMaterialAmount),tHide); + GT_ModHandler.addSmeltingAndAlloySmeltingRecipe( + GT_Utility.copyAmount(1, aStack), + GT_OreDictUnificator.getIngot(aMaterial.mSmeltInto, aMaterialAmount), + tHide); else - GT_ModHandler.addSmeltingRecipe(GT_Utility.copyAmount(1, aStack), GT_OreDictUnificator.getIngot(aMaterial.mSmeltInto, aMaterialAmount)); + GT_ModHandler.addSmeltingRecipe( + GT_Utility.copyAmount(1, aStack), + GT_OreDictUnificator.getIngot(aMaterial.mSmeltInto, aMaterialAmount)); } - public static void registerReverseArcSmelting(ItemStack aStack, Materials aMaterial, long aMaterialAmount, MaterialStack aByProduct01, MaterialStack aByProduct02, MaterialStack aByProduct03) { - registerReverseArcSmelting(aStack, new ItemData(aMaterial == null ? null : new MaterialStack(aMaterial, aMaterialAmount), aByProduct01, aByProduct02, aByProduct03)); + public static void registerReverseArcSmelting( + ItemStack aStack, + Materials aMaterial, + long aMaterialAmount, + MaterialStack aByProduct01, + MaterialStack aByProduct02, + MaterialStack aByProduct03) { + registerReverseArcSmelting( + aStack, + new ItemData( + aMaterial == null ? null : new MaterialStack(aMaterial, aMaterialAmount), + aByProduct01, + aByProduct02, + aByProduct03)); } public static void registerReverseArcSmelting(ItemStack aStack, ItemData aData) { @@ -190,10 +251,11 @@ public class GT_RecipeRegistrator { if (!aData.hasValidMaterialData()) return; boolean tIron = false; - for (MaterialStack tMaterial : aData.getAllMaterialStacks()) { - if (tMaterial.mMaterial == Materials.Iron||tMaterial.mMaterial == Materials.Copper || - tMaterial.mMaterial == Materials.WroughtIron||tMaterial.mMaterial == Materials.AnnealedCopper) tIron = true; + if (tMaterial.mMaterial == Materials.Iron + || tMaterial.mMaterial == Materials.Copper + || tMaterial.mMaterial == Materials.WroughtIron + || tMaterial.mMaterial == Materials.AnnealedCopper) tIron = true; if (tMaterial.mMaterial.contains(SubTag.UNBURNABLE)) { tMaterial.mMaterial = tMaterial.mMaterial.mSmeltInto.mArcSmeltInto; @@ -214,20 +276,21 @@ public class GT_RecipeRegistrator { continue; } if (tMaterial.mMaterial.contains(SubTag.METAL)) { - if(GT_Mod.gregtechproxy.mArcSmeltIntoAnnealed){ - tMaterial.mMaterial = tMaterial.mMaterial.mSmeltInto.mArcSmeltInto; - }else{ - tMaterial.mMaterial = tMaterial.mMaterial.mSmeltInto.mSmeltInto; - } + if (GT_Mod.gregtechproxy.mArcSmeltIntoAnnealed) { + tMaterial.mMaterial = tMaterial.mMaterial.mSmeltInto.mArcSmeltInto; + } else { + tMaterial.mMaterial = tMaterial.mMaterial.mSmeltInto.mSmeltInto; + } continue; } tMaterial.mAmount = 0; } aData = new ItemData(aData); - if (aData.mByProducts.length > 3) for (MaterialStack tMaterial : aData.getAllMaterialStacks()){ - if (tMaterial.mMaterial == Materials.Ash) tMaterial.mAmount = 0; - } + if (aData.mByProducts.length > 3) + for (MaterialStack tMaterial : aData.getAllMaterialStacks()) { + if (tMaterial.mMaterial == Materials.Ash) tMaterial.mAmount = 0; + } aData = new ItemData(aData); @@ -238,11 +301,36 @@ public class GT_RecipeRegistrator { tAmount += tMaterial.mAmount * tMaterial.mMaterial.getMass(); boolean tHide = !tIron && GT_Mod.gregtechproxy.mHideRecyclingRecipes; - RA.addArcFurnaceRecipe(aStack, new ItemStack[]{GT_OreDictUnificator.getIngotOrDust(aData.mMaterial), GT_OreDictUnificator.getIngotOrDust(aData.getByProduct(0)), GT_OreDictUnificator.getIngotOrDust(aData.getByProduct(1)), GT_OreDictUnificator.getIngotOrDust(aData.getByProduct(2))}, null, (int) Math.max(16, tAmount / M), 90, tHide); + RA.addArcFurnaceRecipe( + aStack, + new ItemStack[] { + GT_OreDictUnificator.getIngotOrDust(aData.mMaterial), + GT_OreDictUnificator.getIngotOrDust(aData.getByProduct(0)), + GT_OreDictUnificator.getIngotOrDust(aData.getByProduct(1)), + GT_OreDictUnificator.getIngotOrDust(aData.getByProduct(2)) + }, + null, + (int) Math.max(16, tAmount / M), + 90, + tHide); } - public static void registerReverseMacerating(ItemStack aStack, Materials aMaterial, long aMaterialAmount, MaterialStack aByProduct01, MaterialStack aByProduct02, MaterialStack aByProduct03, boolean aAllowHammer) { - registerReverseMacerating(aStack, new ItemData(aMaterial == null ? null : new MaterialStack(aMaterial, aMaterialAmount), aByProduct01, aByProduct02, aByProduct03), aAllowHammer); + public static void registerReverseMacerating( + ItemStack aStack, + Materials aMaterial, + long aMaterialAmount, + MaterialStack aByProduct01, + MaterialStack aByProduct02, + MaterialStack aByProduct03, + boolean aAllowHammer) { + registerReverseMacerating( + aStack, + new ItemData( + aMaterial == null ? null : new MaterialStack(aMaterial, aMaterialAmount), + aByProduct01, + aByProduct02, + aByProduct03), + aAllowHammer); } public static void registerReverseMacerating(ItemStack aStack, ItemData aData, boolean aAllowHammer) { @@ -262,36 +350,50 @@ public class GT_RecipeRegistrator { for (MaterialStack tMaterial : aData.getAllMaterialStacks()) tAmount += tMaterial.mAmount * tMaterial.mMaterial.getMass(); boolean tHide = (aData.mMaterial.mMaterial != Materials.Iron) && (GT_Mod.gregtechproxy.mHideRecyclingRecipes); - RA.addPulveriserRecipe(aStack, new ItemStack[]{GT_OreDictUnificator.getDust(aData.mMaterial), GT_OreDictUnificator.getDust(aData.getByProduct(0)), GT_OreDictUnificator.getDust(aData.getByProduct(1)), GT_OreDictUnificator.getDust(aData.getByProduct(2))}, null, aData.mMaterial.mMaterial==Materials.Marble ? 1 : (int) Math.max(16, tAmount / M), 4, tHide); + RA.addPulveriserRecipe( + aStack, + new ItemStack[] { + GT_OreDictUnificator.getDust(aData.mMaterial), + GT_OreDictUnificator.getDust(aData.getByProduct(0)), + GT_OreDictUnificator.getDust(aData.getByProduct(1)), + GT_OreDictUnificator.getDust(aData.getByProduct(2)) + }, + null, + aData.mMaterial.mMaterial == Materials.Marble ? 1 : (int) Math.max(16, tAmount / M), + 4, + tHide); if (aAllowHammer) - for (MaterialStack tMaterial : aData.getAllMaterialStacks()) - if (tMaterial.mMaterial.contains(SubTag.CRYSTAL) && !tMaterial.mMaterial.contains(SubTag.METAL) && tMaterial.mMaterial != Materials.Glass) { - if (RA.addForgeHammerRecipe(GT_Utility.copyAmount(1, aStack), GT_OreDictUnificator.getDust(aData.mMaterial), 200, 30)) - break; - } + for (MaterialStack tMaterial : aData.getAllMaterialStacks()) + if (tMaterial.mMaterial.contains(SubTag.CRYSTAL) + && !tMaterial.mMaterial.contains(SubTag.METAL) + && tMaterial.mMaterial != Materials.Glass) { + if (RA.addForgeHammerRecipe( + GT_Utility.copyAmount(1, aStack), GT_OreDictUnificator.getDust(aData.mMaterial), 200, 30)) + break; + } } /** * Place Materials which you want to replace in Non-GT-Recipes here (warning HUGHE impact on loading times!) */ private static final Materials[] VANILLA_MATS = { - Cobalt, - Gold, - Iron, - Lead, - FierySteel, - Void, - Bronze, - Diamond, - Ruby, - Sapphire, - Steel, - IronWood, - Steeleaf, - Knightmetal, - Thaumium, - DarkSteel, + Cobalt, + Gold, + Iron, + Lead, + FierySteel, + Void, + Bronze, + Diamond, + Ruby, + Sapphire, + Steel, + IronWood, + Steeleaf, + Knightmetal, + Thaumium, + DarkSteel, }; /** @@ -301,12 +403,12 @@ public class GT_RecipeRegistrator { * @param aPlate the Plate referenced to aMat * @param aRecipeReplacing allows to replace the Recipe with a Plate variant */ - public static synchronized void registerUsagesForMaterials(String aPlate, boolean aRecipeReplacing, ItemStack... aMats) { + public static synchronized void registerUsagesForMaterials( + String aPlate, boolean aRecipeReplacing, ItemStack... aMats) { for (ItemStack aMat : aMats) { aMat = GT_Utility.copyOrNull(aMat); - if (aMat == null) - continue; + if (aMat == null) continue; ItemData aItemData = GT_OreDictUnificator.getItemData(aMat); if (aItemData == null || aItemData.mPrefix != OrePrefixes.ingot) aPlate = null; @@ -320,15 +422,22 @@ public class GT_RecipeRegistrator { sMt2.stackSize = 1; Items.feather.setDamage(sMt2, 0); - if(aItemData != null && aItemData.hasValidPrefixMaterialData()) { + if (aItemData != null && aItemData.hasValidPrefixMaterialData()) { for (RecipeShape tRecipe : sShapes) { for (ItemStack tCrafted : GT_ModHandler.getRecipeOutputsBuffered(tRecipe.shape)) { - GT_OreDictUnificator.addItemData(tCrafted, new ItemData(aItemData.mMaterial.mMaterial, aItemData.mMaterial.mAmount * tRecipe.amount1)); - // GT_Log.out.println("###################################################################################"); + GT_OreDictUnificator.addItemData( + tCrafted, + new ItemData( + aItemData.mMaterial.mMaterial, aItemData.mMaterial.mAmount * tRecipe.amount1)); + // + // GT_Log.out.println("###################################################################################"); // GT_Log.out.println("registerUsagesForMaterials used aPlate: "+aPlate); - // GT_Log.out.println("registerUsagesForMaterials used aPlate: "+aMat.getUnlocalizedName()); - // GT_Log.out.println("registerUsagesForMaterials used aPlate: "+aMat.getDisplayName()); - // GT_Log.out.println("###################################################################################"); + // GT_Log.out.println("registerUsagesForMaterials used aPlate: + // "+aMat.getUnlocalizedName()); + // GT_Log.out.println("registerUsagesForMaterials used aPlate: + // "+aMat.getDisplayName()); + // + // GT_Log.out.println("###################################################################################"); } } } @@ -350,24 +459,66 @@ public class GT_RecipeRegistrator { for (ItemStack tCrafted : GT_ModHandler.getVanillyToolRecipeOutputs(tRecipe.shape)) { if (aItemData != null && aItemData.hasValidPrefixMaterialData()) - GT_OreDictUnificator.addItemData(tCrafted, new ItemData(aItemData.mMaterial.mMaterial, aItemData.mMaterial.mAmount * tRecipe.amount1, new MaterialStack(tMaterial, OrePrefixes.stick.mMaterialAmount * tRecipe.amount2))); + GT_OreDictUnificator.addItemData( + tCrafted, + new ItemData( + aItemData.mMaterial.mMaterial, + aItemData.mMaterial.mAmount * tRecipe.amount1, + new MaterialStack( + tMaterial, OrePrefixes.stick.mMaterialAmount * tRecipe.amount2))); if (aRecipeReplacing && aPlate != null && sShapesA[i] != null && sShapesA[i].length > 1) { assert aItemData != null; - if (GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.recipereplacements, aItemData.mMaterial.mMaterial + "." + sShapesA[i][0], true)) { + if (GregTech_API.sRecipeFile.get( + ConfigCategories.Recipes.recipereplacements, + aItemData.mMaterial.mMaterial + "." + sShapesA[i][0], + true)) { if (null != (tStack = GT_ModHandler.removeRecipe(tRecipe.shape))) { -// GT_Log.out.println("###################################################################################"); -// GT_Log.out.println("registerStickStuff used aPlate: "+aPlate); -// GT_Log.out.println("###################################################################################"); + // + // GT_Log.out.println("###################################################################################"); + // GT_Log.out.println("registerStickStuff used + // aPlate: "+aPlate); + // + // GT_Log.out.println("###################################################################################"); switch (sShapesA[i].length) { case 2: - GT_ModHandler.addCraftingRecipe(tStack, GT_ModHandler.RecipeBits.BUFFERED, new Object[]{sShapesA[i][1], s_P.charAt(0), aPlate, s_R.charAt(0), OrePrefixes.stick.get(tMaterial), s_I.charAt(0), aItemData}); + GT_ModHandler.addCraftingRecipe( + tStack, GT_ModHandler.RecipeBits.BUFFERED, new Object[] { + sShapesA[i][1], + s_P.charAt(0), + aPlate, + s_R.charAt(0), + OrePrefixes.stick.get(tMaterial), + s_I.charAt(0), + aItemData + }); break; case 3: - GT_ModHandler.addCraftingRecipe(tStack, GT_ModHandler.RecipeBits.BUFFERED, new Object[]{sShapesA[i][1], sShapesA[i][2], s_P.charAt(0), aPlate, s_R.charAt(0), OrePrefixes.stick.get(tMaterial), s_I.charAt(0), aItemData}); + GT_ModHandler.addCraftingRecipe( + tStack, GT_ModHandler.RecipeBits.BUFFERED, new Object[] { + sShapesA[i][1], + sShapesA[i][2], + s_P.charAt(0), + aPlate, + s_R.charAt(0), + OrePrefixes.stick.get(tMaterial), + s_I.charAt(0), + aItemData + }); break; default: - GT_ModHandler.addCraftingRecipe(tStack, GT_ModHandler.RecipeBits.BUFFERED, new Object[]{sShapesA[i][1], sShapesA[i][2], sShapesA[i][3], s_P.charAt(0), aPlate, s_R.charAt(0), OrePrefixes.stick.get(tMaterial), s_I.charAt(0), aItemData}); + GT_ModHandler.addCraftingRecipe( + tStack, GT_ModHandler.RecipeBits.BUFFERED, new Object[] { + sShapesA[i][1], + sShapesA[i][2], + sShapesA[i][3], + s_P.charAt(0), + aPlate, + s_R.charAt(0), + OrePrefixes.stick.get(tMaterial), + s_I.charAt(0), + aItemData + }); break; } } @@ -392,8 +543,8 @@ public class GT_RecipeRegistrator { this.shape = shape; for (ItemStack stack : shape) { - if(stack == sMt1) this.amount1++; - if(stack == sMt2) this.amount2++; + if (stack == sMt1) this.amount1++; + if (stack == sMt2) this.amount2++; } } } diff --git a/src/main/java/gregtech/api/util/GT_RenderingWorld.java b/src/main/java/gregtech/api/util/GT_RenderingWorld.java index 920ce76357..173631e99c 100644 --- a/src/main/java/gregtech/api/util/GT_RenderingWorld.java +++ b/src/main/java/gregtech/api/util/GT_RenderingWorld.java @@ -4,6 +4,10 @@ import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.tileentity.TileEntity; @@ -16,176 +20,164 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.event.world.ChunkEvent; import net.minecraftforge.event.world.WorldEvent; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - /** * Provide a fake IBlockAccess to support CTM. Facade are supposed to set these when they are placed/received by client. */ public class GT_RenderingWorld implements IBlockAccess { - private static final GT_RenderingWorld INSTANCE = new GT_RenderingWorld(); - /* - * I do not think this map would ever grow too huge, so I won't go too overcomplicated on this one - */ - private final Map<ChunkPosition, BlockInfo> infos = new HashMap<>(); - private final Map<ChunkCoordIntPair, Set<ChunkPosition>> index = new HashMap<>(); - private IBlockAccess mWorld = Minecraft.getMinecraft().theWorld; - - private GT_RenderingWorld() { - new FMLEventHandler(); - new ForgeEventHandler(); - } - - public static GT_RenderingWorld getInstance() { - return INSTANCE; - } - - public static GT_RenderingWorld getInstance(IBlockAccess aWorld) { - if (aWorld == INSTANCE) - return INSTANCE; - if (aWorld == null) - INSTANCE.mWorld = Minecraft.getMinecraft().theWorld; - else - INSTANCE.mWorld = aWorld; - return INSTANCE; - } - - private void setWorld(IBlockAccess aWorld) { - if (aWorld == null) - mWorld = Minecraft.getMinecraft().theWorld; - else - mWorld = aWorld; - } - - public void register(int x, int y, int z, Block block, int meta) { - ChunkPosition key = new ChunkPosition(x, y, z); - infos.put(key, new BlockInfo(block, meta)); - index.computeIfAbsent(new ChunkCoordIntPair(x >> 4, z >> 4), p -> new HashSet<>()).add(key); - } - - public void unregister(int x, int y, int z, Block block, int meta) { - ChunkPosition key = new ChunkPosition(x, y, z); - if (infos.remove(key, new BlockInfo(block, meta))) { - ChunkCoordIntPair chunkKey = new ChunkCoordIntPair(x >> 4, z >> 4); - Set<ChunkPosition> set = index.get(chunkKey); - set.remove(key); - if (set.isEmpty()) - index.remove(chunkKey); - } - } - - @Override - public Block getBlock(int p_147439_1_, int p_147439_2_, int p_147439_3_) { - BlockInfo blockInfo = infos.get(new ChunkPosition(p_147439_1_, p_147439_2_, p_147439_3_)); - return blockInfo != null ? blockInfo.block : mWorld.getBlock(p_147439_1_, p_147439_2_, p_147439_3_); - } - - @Override - public TileEntity getTileEntity(int p_147438_1_, int p_147438_2_, int p_147438_3_) { - return mWorld.getTileEntity(p_147438_1_, p_147438_2_, p_147438_3_); - } - - @Override - public int getLightBrightnessForSkyBlocks(int p_72802_1_, int p_72802_2_, int p_72802_3_, int p_72802_4_) { - return mWorld.getLightBrightnessForSkyBlocks(p_72802_1_, p_72802_2_, p_72802_3_, p_72802_4_); - } - - @Override - public int getBlockMetadata(int p_72805_1_, int p_72805_2_, int p_72805_3_) { - BlockInfo blockInfo = infos.get(new ChunkPosition(p_72805_1_, p_72805_2_, p_72805_3_)); - return blockInfo != null ? blockInfo.meta : mWorld.getBlockMetadata(p_72805_1_, p_72805_2_, p_72805_3_); - } - - @Override - public int isBlockProvidingPowerTo(int p_72879_1_, int p_72879_2_, int p_72879_3_, int p_72879_4_) { - return mWorld.isBlockProvidingPowerTo(p_72879_1_, p_72879_2_, p_72879_3_, p_72879_4_); - } - - @Override - public boolean isAirBlock(int p_147437_1_, int p_147437_2_, int p_147437_3_) { - return getBlock(p_147437_1_, p_147437_2_, p_147437_3_).isAir(mWorld, p_147437_1_, p_147437_2_, p_147437_3_); - } - - @Override - public BiomeGenBase getBiomeGenForCoords(int p_72807_1_, int p_72807_2_) { - return mWorld.getBiomeGenForCoords(p_72807_1_, p_72807_2_); - } - - @Override - public int getHeight() { - return mWorld.getHeight(); - } - - @Override - public boolean extendedLevelsInChunkCache() { - return mWorld.extendedLevelsInChunkCache(); - } - - @Override - public boolean isSideSolid(int x, int y, int z, ForgeDirection side, boolean _default) { - return getBlock(x, y, z).isSideSolid(this, x, y, z, side); - } - - public class FMLEventHandler { - public FMLEventHandler() { - FMLCommonHandler.instance().bus().register(this); - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onRenderTickStart(TickEvent.RenderTickEvent e) { - if (e.phase == TickEvent.Phase.START) - mWorld = Minecraft.getMinecraft().theWorld; - } - } - - public class ForgeEventHandler { - private ForgeEventHandler() { - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - public void onChunkUnloaded(ChunkEvent.Unload e) { - if (!e.world.isRemote) return; - Set<ChunkPosition> set = index.remove(e.getChunk().getChunkCoordIntPair()); - if (set != null) - infos.keySet().removeAll(set); - } - - @SubscribeEvent - public void onWorldUnloaded(WorldEvent.Unload e) { - if (!e.world.isRemote) return; - infos.clear(); - index.clear(); - } - } - - private static class BlockInfo { - private final Block block; - private final int meta; - - public BlockInfo(Block block, int meta) { - this.block = block; - this.meta = meta; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - BlockInfo blockInfo = (BlockInfo) o; - - if (meta != blockInfo.meta) return false; - return block != null ? block.equals(blockInfo.block) : blockInfo.block == null; - } - - @Override - public int hashCode() { - int result = block != null ? block.hashCode() : 0; - result = 31 * result + meta; - return result; - } - } + private static final GT_RenderingWorld INSTANCE = new GT_RenderingWorld(); + /* + * I do not think this map would ever grow too huge, so I won't go too overcomplicated on this one + */ + private final Map<ChunkPosition, BlockInfo> infos = new HashMap<>(); + private final Map<ChunkCoordIntPair, Set<ChunkPosition>> index = new HashMap<>(); + private IBlockAccess mWorld = Minecraft.getMinecraft().theWorld; + + private GT_RenderingWorld() { + new FMLEventHandler(); + new ForgeEventHandler(); + } + + public static GT_RenderingWorld getInstance() { + return INSTANCE; + } + + public static GT_RenderingWorld getInstance(IBlockAccess aWorld) { + if (aWorld == INSTANCE) return INSTANCE; + if (aWorld == null) INSTANCE.mWorld = Minecraft.getMinecraft().theWorld; + else INSTANCE.mWorld = aWorld; + return INSTANCE; + } + + private void setWorld(IBlockAccess aWorld) { + if (aWorld == null) mWorld = Minecraft.getMinecraft().theWorld; + else mWorld = aWorld; + } + + public void register(int x, int y, int z, Block block, int meta) { + ChunkPosition key = new ChunkPosition(x, y, z); + infos.put(key, new BlockInfo(block, meta)); + index.computeIfAbsent(new ChunkCoordIntPair(x >> 4, z >> 4), p -> new HashSet<>()) + .add(key); + } + + public void unregister(int x, int y, int z, Block block, int meta) { + ChunkPosition key = new ChunkPosition(x, y, z); + if (infos.remove(key, new BlockInfo(block, meta))) { + ChunkCoordIntPair chunkKey = new ChunkCoordIntPair(x >> 4, z >> 4); + Set<ChunkPosition> set = index.get(chunkKey); + set.remove(key); + if (set.isEmpty()) index.remove(chunkKey); + } + } + + @Override + public Block getBlock(int p_147439_1_, int p_147439_2_, int p_147439_3_) { + BlockInfo blockInfo = infos.get(new ChunkPosition(p_147439_1_, p_147439_2_, p_147439_3_)); + return blockInfo != null ? blockInfo.block : mWorld.getBlock(p_147439_1_, p_147439_2_, p_147439_3_); + } + + @Override + public TileEntity getTileEntity(int p_147438_1_, int p_147438_2_, int p_147438_3_) { + return mWorld.getTileEntity(p_147438_1_, p_147438_2_, p_147438_3_); + } + + @Override + public int getLightBrightnessForSkyBlocks(int p_72802_1_, int p_72802_2_, int p_72802_3_, int p_72802_4_) { + return mWorld.getLightBrightnessForSkyBlocks(p_72802_1_, p_72802_2_, p_72802_3_, p_72802_4_); + } + + @Override + public int getBlockMetadata(int p_72805_1_, int p_72805_2_, int p_72805_3_) { + BlockInfo blockInfo = infos.get(new ChunkPosition(p_72805_1_, p_72805_2_, p_72805_3_)); + return blockInfo != null ? blockInfo.meta : mWorld.getBlockMetadata(p_72805_1_, p_72805_2_, p_72805_3_); + } + + @Override + public int isBlockProvidingPowerTo(int p_72879_1_, int p_72879_2_, int p_72879_3_, int p_72879_4_) { + return mWorld.isBlockProvidingPowerTo(p_72879_1_, p_72879_2_, p_72879_3_, p_72879_4_); + } + + @Override + public boolean isAirBlock(int p_147437_1_, int p_147437_2_, int p_147437_3_) { + return getBlock(p_147437_1_, p_147437_2_, p_147437_3_).isAir(mWorld, p_147437_1_, p_147437_2_, p_147437_3_); + } + + @Override + public BiomeGenBase getBiomeGenForCoords(int p_72807_1_, int p_72807_2_) { + return mWorld.getBiomeGenForCoords(p_72807_1_, p_72807_2_); + } + + @Override + public int getHeight() { + return mWorld.getHeight(); + } + + @Override + public boolean extendedLevelsInChunkCache() { + return mWorld.extendedLevelsInChunkCache(); + } + + @Override + public boolean isSideSolid(int x, int y, int z, ForgeDirection side, boolean _default) { + return getBlock(x, y, z).isSideSolid(this, x, y, z, side); + } + + public class FMLEventHandler { + public FMLEventHandler() { + FMLCommonHandler.instance().bus().register(this); + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onRenderTickStart(TickEvent.RenderTickEvent e) { + if (e.phase == TickEvent.Phase.START) mWorld = Minecraft.getMinecraft().theWorld; + } + } + + public class ForgeEventHandler { + private ForgeEventHandler() { + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onChunkUnloaded(ChunkEvent.Unload e) { + if (!e.world.isRemote) return; + Set<ChunkPosition> set = index.remove(e.getChunk().getChunkCoordIntPair()); + if (set != null) infos.keySet().removeAll(set); + } + + @SubscribeEvent + public void onWorldUnloaded(WorldEvent.Unload e) { + if (!e.world.isRemote) return; + infos.clear(); + index.clear(); + } + } + + private static class BlockInfo { + private final Block block; + private final int meta; + + public BlockInfo(Block block, int meta) { + this.block = block; + this.meta = meta; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + BlockInfo blockInfo = (BlockInfo) o; + + if (meta != blockInfo.meta) return false; + return block != null ? block.equals(blockInfo.block) : blockInfo.block == null; + } + + @Override + public int hashCode() { + int result = block != null ? block.hashCode() : 0; + result = 31 * result + meta; + return result; + } + } } diff --git a/src/main/java/gregtech/api/util/GT_Shaped_Recipe.java b/src/main/java/gregtech/api/util/GT_Shaped_Recipe.java index 7ecabaffeb..ae8d804ee9 100644 --- a/src/main/java/gregtech/api/util/GT_Shaped_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Shaped_Recipe.java @@ -15,7 +15,14 @@ public class GT_Shaped_Recipe extends ShapedOreRecipe implements IGT_CraftingRec private final Enchantment[] mEnchantmentsAdded; private final int[] mEnchantmentLevelsAdded; - public GT_Shaped_Recipe(ItemStack aResult, boolean aDismantleAble, boolean aRemovableByGT, boolean aKeepingNBT, Enchantment[] aEnchantmentsAdded, int[] aEnchantmentLevelsAdded, Object... aRecipe) { + public GT_Shaped_Recipe( + ItemStack aResult, + boolean aDismantleAble, + boolean aRemovableByGT, + boolean aKeepingNBT, + Enchantment[] aEnchantmentsAdded, + int[] aEnchantmentLevelsAdded, + Object... aRecipe) { super(aResult, aRecipe); mEnchantmentsAdded = aEnchantmentsAdded; mEnchantmentLevelsAdded = aEnchantmentLevelsAdded; @@ -33,8 +40,10 @@ public class GT_Shaped_Recipe extends ShapedOreRecipe implements IGT_CraftingRec for (int i = 0; i < aGrid.getSizeInventory(); i++) { if (aGrid.getStackInSlot(i) != null) { if (tStack != null) { - if ((tStack.hasTagCompound() != aGrid.getStackInSlot(i).hasTagCompound()) || (tStack.hasTagCompound() && !tStack.getTagCompound().equals(aGrid.getStackInSlot(i).getTagCompound()))) - return false; + if ((tStack.hasTagCompound() != aGrid.getStackInSlot(i).hasTagCompound()) + || (tStack.hasTagCompound() + && !tStack.getTagCompound() + .equals(aGrid.getStackInSlot(i).getTagCompound()))) return false; } tStack = aGrid.getStackInSlot(i); } @@ -51,25 +60,33 @@ public class GT_Shaped_Recipe extends ShapedOreRecipe implements IGT_CraftingRec GT_Utility.updateItemStack(rStack); // Keeping NBT - if (mKeepingNBT) for (int i = 0; i < aGrid.getSizeInventory(); i++) { - if (aGrid.getStackInSlot(i) != null && aGrid.getStackInSlot(i).hasTagCompound()) { - rStack.setTagCompound((NBTTagCompound) aGrid.getStackInSlot(i).getTagCompound().copy()); - break; + if (mKeepingNBT) + for (int i = 0; i < aGrid.getSizeInventory(); i++) { + if (aGrid.getStackInSlot(i) != null + && aGrid.getStackInSlot(i).hasTagCompound()) { + rStack.setTagCompound((NBTTagCompound) + aGrid.getStackInSlot(i).getTagCompound().copy()); + break; + } } - } // Charge Values if (GT_ModHandler.isElectricItem(rStack)) { GT_ModHandler.dischargeElectricItem(rStack, Integer.MAX_VALUE, Integer.MAX_VALUE, true, false, true); int tCharge = 0; for (int i = 0; i < aGrid.getSizeInventory(); i++) - tCharge += GT_ModHandler.dischargeElectricItem(aGrid.getStackInSlot(i), Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, true); + tCharge += GT_ModHandler.dischargeElectricItem( + aGrid.getStackInSlot(i), Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, true); if (tCharge > 0) GT_ModHandler.chargeElectricItem(rStack, tCharge, Integer.MAX_VALUE, true, false); } // Add Enchantments for (int i = 0; i < mEnchantmentsAdded.length; i++) - GT_Utility.ItemNBT.addEnchantment(rStack, mEnchantmentsAdded[i], EnchantmentHelper.getEnchantmentLevel(mEnchantmentsAdded[i].effectId, rStack) + mEnchantmentLevelsAdded[i]); + GT_Utility.ItemNBT.addEnchantment( + rStack, + mEnchantmentsAdded[i], + EnchantmentHelper.getEnchantmentLevel(mEnchantmentsAdded[i].effectId, rStack) + + mEnchantmentLevelsAdded[i]); // Update the Stack again GT_Utility.updateItemStack(rStack); diff --git a/src/main/java/gregtech/api/util/GT_Shapeless_Recipe.java b/src/main/java/gregtech/api/util/GT_Shapeless_Recipe.java index 2718ea3efa..09d8730df5 100644 --- a/src/main/java/gregtech/api/util/GT_Shapeless_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Shapeless_Recipe.java @@ -15,13 +15,20 @@ public class GT_Shapeless_Recipe extends ShapelessOreRecipe implements IGT_Craft private final Enchantment[] mEnchantmentsAdded; private final int[] mEnchantmentLevelsAdded; - public GT_Shapeless_Recipe(ItemStack aResult, boolean aDismantleAble, boolean aRemovableByGT, boolean aKeepingNBT, Enchantment[] aEnchantmentsAdded, int[] aEnchantmentLevelsAdded, Object... aRecipe) { + public GT_Shapeless_Recipe( + ItemStack aResult, + boolean aDismantleAble, + boolean aRemovableByGT, + boolean aKeepingNBT, + Enchantment[] aEnchantmentsAdded, + int[] aEnchantmentLevelsAdded, + Object... aRecipe) { super(aResult, aRecipe); mEnchantmentsAdded = aEnchantmentsAdded; mEnchantmentLevelsAdded = aEnchantmentLevelsAdded; mRemovableByGT = aRemovableByGT; mKeepingNBT = aKeepingNBT; - if (aDismantleAble){ + if (aDismantleAble) { new ReverseShapelessRecipe(aResult, aRecipe); } } @@ -33,8 +40,10 @@ public class GT_Shapeless_Recipe extends ShapelessOreRecipe implements IGT_Craft for (int i = 0; i < aGrid.getSizeInventory(); i++) { if (aGrid.getStackInSlot(i) != null) { if (tStack != null) { - if ((tStack.hasTagCompound() != aGrid.getStackInSlot(i).hasTagCompound()) || (tStack.hasTagCompound() && !tStack.getTagCompound().equals(aGrid.getStackInSlot(i).getTagCompound()))) - return false; + if ((tStack.hasTagCompound() != aGrid.getStackInSlot(i).hasTagCompound()) + || (tStack.hasTagCompound() + && !tStack.getTagCompound() + .equals(aGrid.getStackInSlot(i).getTagCompound()))) return false; } tStack = aGrid.getStackInSlot(i); } @@ -51,41 +60,51 @@ public class GT_Shapeless_Recipe extends ShapelessOreRecipe implements IGT_Craft GT_Utility.updateItemStack(rStack); // Keeping NBT - if (mKeepingNBT) for (int i = 0; i < aGrid.getSizeInventory(); i++) { - if (aGrid.getStackInSlot(i) != null && aGrid.getStackInSlot(i).hasTagCompound()) { - rStack.setTagCompound((NBTTagCompound) aGrid.getStackInSlot(i).getTagCompound().copy()); - break; + if (mKeepingNBT) + for (int i = 0; i < aGrid.getSizeInventory(); i++) { + if (aGrid.getStackInSlot(i) != null + && aGrid.getStackInSlot(i).hasTagCompound()) { + rStack.setTagCompound((NBTTagCompound) + aGrid.getStackInSlot(i).getTagCompound().copy()); + break; + } } - } // Charge Values if (GT_ModHandler.isElectricItem(rStack)) { GT_ModHandler.dischargeElectricItem(rStack, Integer.MAX_VALUE, Integer.MAX_VALUE, true, false, true); int tCharge = 0; for (int i = 0; i < aGrid.getSizeInventory(); i++) - tCharge += GT_ModHandler.dischargeElectricItem(aGrid.getStackInSlot(i), Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, true); + tCharge += GT_ModHandler.dischargeElectricItem( + aGrid.getStackInSlot(i), Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, true); if (tCharge > 0) GT_ModHandler.chargeElectricItem(rStack, tCharge, Integer.MAX_VALUE, true, false); } // Saving Ingredients inside the Item. -// if (mDismantleable) { -// NBTTagCompound rNBT = rStack.getTagCompound(), tNBT = new NBTTagCompound(); -// if (rNBT == null) rNBT = new NBTTagCompound(); -// for (int i = 0; i < 9; i++) { -// ItemStack tStack = aGrid.getStackInSlot(i); -// if (tStack != null && GT_Utility.getContainerItem(tStack, true) == null && !(tStack.getItem() instanceof GT_MetaGenerated_Tool)) { -// tStack = GT_Utility.copyAmount(1, tStack); -// GT_ModHandler.dischargeElectricItem(tStack, Integer.MAX_VALUE, Integer.MAX_VALUE, true, false, true); -// tNBT.setTag("Ingredient." + i, tStack.writeToNBT(new NBTTagCompound())); -// } -// } -// rNBT.setTag("GT.CraftingComponents", tNBT); -// rStack.setTagCompound(rNBT); -// } + // if (mDismantleable) { + // NBTTagCompound rNBT = rStack.getTagCompound(), tNBT = new NBTTagCompound(); + // if (rNBT == null) rNBT = new NBTTagCompound(); + // for (int i = 0; i < 9; i++) { + // ItemStack tStack = aGrid.getStackInSlot(i); + // if (tStack != null && GT_Utility.getContainerItem(tStack, true) == null && + // !(tStack.getItem() instanceof GT_MetaGenerated_Tool)) { + // tStack = GT_Utility.copyAmount(1, tStack); + // GT_ModHandler.dischargeElectricItem(tStack, Integer.MAX_VALUE, Integer.MAX_VALUE, + // true, false, true); + // tNBT.setTag("Ingredient." + i, tStack.writeToNBT(new NBTTagCompound())); + // } + // } + // rNBT.setTag("GT.CraftingComponents", tNBT); + // rStack.setTagCompound(rNBT); + // } // Add Enchantments for (int i = 0; i < mEnchantmentsAdded.length; i++) - GT_Utility.ItemNBT.addEnchantment(rStack, mEnchantmentsAdded[i], EnchantmentHelper.getEnchantmentLevel(mEnchantmentsAdded[i].effectId, rStack) + mEnchantmentLevelsAdded[i]); + GT_Utility.ItemNBT.addEnchantment( + rStack, + mEnchantmentsAdded[i], + EnchantmentHelper.getEnchantmentLevel(mEnchantmentsAdded[i].effectId, rStack) + + mEnchantmentLevelsAdded[i]); // Update the Stack again GT_Utility.updateItemStack(rStack); diff --git a/src/main/java/gregtech/api/util/GT_Single_Recipe_Check.java b/src/main/java/gregtech/api/util/GT_Single_Recipe_Check.java index 0be96a2e05..5ff631fad6 100644 --- a/src/main/java/gregtech/api/util/GT_Single_Recipe_Check.java +++ b/src/main/java/gregtech/api/util/GT_Single_Recipe_Check.java @@ -3,13 +3,12 @@ package gregtech.api.util; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; - import java.util.HashMap; import java.util.List; import java.util.Map; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; /** Used by machines that are locked to a single recipe, for fast computation. */ public class GT_Single_Recipe_Check { @@ -31,8 +30,10 @@ public class GT_Single_Recipe_Check { this.itemCost = itemCost; this.fluidCost = fluidCost; - this.totalItemCost = itemCost.values().stream().mapToInt(Integer::intValue).sum(); - this.totalFluidCost = fluidCost.values().stream().mapToInt(Integer::intValue).sum(); + this.totalItemCost = + itemCost.values().stream().mapToInt(Integer::intValue).sum(); + this.totalFluidCost = + fluidCost.values().stream().mapToInt(Integer::intValue).sum(); } public GT_Recipe getRecipe() { @@ -51,7 +52,8 @@ public class GT_Single_Recipe_Check { itemMap = new HashMap<>(); for (ItemStack itemStack : multiBlockBase.getStoredInputs()) { itemMap.merge( - GT_Utility.ItemId.createNoCopy(itemStack), itemStack, + GT_Utility.ItemId.createNoCopy(itemStack), + itemStack, (a, b) -> a.stackSize >= b.stackSize ? a : b); } @@ -67,9 +69,7 @@ public class GT_Single_Recipe_Check { if (totalFluidCost > 0) { fluidMap = new HashMap<>(); for (FluidStack fluidStack : multiBlockBase.getStoredFluids()) { - fluidMap.merge( - fluidStack.getFluid(), fluidStack, - (a, b) -> a.amount >= b.amount ? a : b); + fluidMap.merge(fluidStack.getFluid(), fluidStack, (a, b) -> a.amount >= b.amount ? a : b); } for (Map.Entry<Fluid, Integer> entry : fluidCost.entrySet()) { @@ -173,8 +173,7 @@ public class GT_Single_Recipe_Check { return true; } - protected static Map<GT_Utility.ItemId, Integer> buildItemMap( - GT_MetaTileEntity_MultiBlockBase multiBlockBase) { + protected static Map<GT_Utility.ItemId, Integer> buildItemMap(GT_MetaTileEntity_MultiBlockBase multiBlockBase) { Map<GT_Utility.ItemId, Integer> itemMap = new HashMap<>(); for (ItemStack itemStack : multiBlockBase.getStoredInputs()) { itemMap.merge(GT_Utility.ItemId.create(itemStack), itemStack.stackSize, Integer::sum); @@ -182,8 +181,7 @@ public class GT_Single_Recipe_Check { return itemMap; } - protected static Map<Fluid, Integer> buildFluidMap( - GT_MetaTileEntity_MultiBlockBase multiBlockBase) { + protected static Map<Fluid, Integer> buildFluidMap(GT_MetaTileEntity_MultiBlockBase multiBlockBase) { Map<Fluid, Integer> fluidMap = new HashMap<>(); for (FluidStack fluidStack : multiBlockBase.getStoredFluids()) { fluidMap.merge(fluidStack.getFluid(), fluidStack.amount, Integer::sum); @@ -251,6 +249,4 @@ public class GT_Single_Recipe_Check { multiBlockBase, recipe, itemCostBuilder.build(), fluidCostBuilder.build()); } } - - } diff --git a/src/main/java/gregtech/api/util/GT_Single_Recipe_Check_Processing_Array.java b/src/main/java/gregtech/api/util/GT_Single_Recipe_Check_Processing_Array.java index 871cb642c4..585460842d 100644 --- a/src/main/java/gregtech/api/util/GT_Single_Recipe_Check_Processing_Array.java +++ b/src/main/java/gregtech/api/util/GT_Single_Recipe_Check_Processing_Array.java @@ -2,14 +2,13 @@ package gregtech.api.util; import com.google.common.collect.ImmutableMap; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; - import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; /** Processing Array-specialized version of {@link gregtech.api.util.GT_Single_Recipe_Check}. */ public class GT_Single_Recipe_Check_Processing_Array extends GT_Single_Recipe_Check { @@ -94,12 +93,8 @@ public class GT_Single_Recipe_Check_Processing_Array extends GT_Single_Recipe_Ch if (consumeInputs) { if (totalItemCost > 0) { int remainingItemCost = totalItemCost * finalParallel; - Map<GT_Utility.ItemId, Integer> runningItemCost = - itemCost.entrySet().stream() - .collect( - Collectors.toMap( - Map.Entry::getKey, - entry -> entry.getValue() * finalParallel)); + Map<GT_Utility.ItemId, Integer> runningItemCost = itemCost.entrySet().stream() + .collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue() * finalParallel)); for (ItemStack itemStack : items) { GT_Utility.ItemId key = GT_Utility.ItemId.createNoCopy(itemStack); @@ -117,12 +112,8 @@ public class GT_Single_Recipe_Check_Processing_Array extends GT_Single_Recipe_Ch if (totalFluidCost > 0) { int remainingFluidCost = totalFluidCost * finalParallel; - Map<Fluid, Integer> runningFluidCost = - fluidCost.entrySet().stream() - .collect( - Collectors.toMap( - Map.Entry::getKey, - entry -> entry.getValue() * finalParallel)); + Map<Fluid, Integer> runningFluidCost = fluidCost.entrySet().stream() + .collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue() * finalParallel)); for (FluidStack fluidStack : fluids) { Fluid key = fluidStack.getFluid(); @@ -205,8 +196,12 @@ public class GT_Single_Recipe_Check_Processing_Array extends GT_Single_Recipe_Ch } return new GT_Single_Recipe_Check_Processing_Array( - multiBlockBase, recipe, itemCostBuilder.build(), fluidCostBuilder.build(), - recipeAmperage, multiBlockBase.mInventory[1].copy()); + multiBlockBase, + recipe, + itemCostBuilder.build(), + fluidCostBuilder.build(), + recipeAmperage, + multiBlockBase.mInventory[1].copy()); } } } diff --git a/src/main/java/gregtech/api/util/GT_SpawnEventHandler.java b/src/main/java/gregtech/api/util/GT_SpawnEventHandler.java index 9edb64a196..38c43da7c2 100644 --- a/src/main/java/gregtech/api/util/GT_SpawnEventHandler.java +++ b/src/main/java/gregtech/api/util/GT_SpawnEventHandler.java @@ -4,15 +4,14 @@ import cpw.mods.fml.common.eventhandler.Event; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import gregtech.api.metatileentity.BaseMetaTileEntity; import gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_MonsterRepellent; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.monster.EntitySlime; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingSpawnEvent.CheckSpawn; -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; - public class GT_SpawnEventHandler { public static volatile List<int[]> mobReps = new CopyOnWriteArrayList<>(); @@ -23,8 +22,9 @@ public class GT_SpawnEventHandler { @SubscribeEvent public void denyMobSpawn(CheckSpawn event) { - if (event.entityLiving instanceof EntitySlime && !(((EntitySlime) event.entityLiving).getCustomNameTag().length() > 0)) { - if(event.getResult() == Event.Result.ALLOW) event.setResult(Event.Result.DEFAULT); + if (event.entityLiving instanceof EntitySlime + && !(((EntitySlime) event.entityLiving).getCustomNameTag().length() > 0)) { + if (event.getResult() == Event.Result.ALLOW) event.setResult(Event.Result.DEFAULT); } if (event.getResult() == Event.Result.ALLOW) { @@ -35,13 +35,17 @@ public class GT_SpawnEventHandler { for (int[] rep : mobReps) { if (rep[3] == event.entity.worldObj.provider.dimensionId) { TileEntity tTile = event.entity.worldObj.getTileEntity(rep[0], rep[1], rep[2]); - if (tTile instanceof BaseMetaTileEntity && ((BaseMetaTileEntity) tTile).getMetaTileEntity() instanceof GT_MetaTileEntity_MonsterRepellent) { - int r = ((GT_MetaTileEntity_MonsterRepellent) ((BaseMetaTileEntity) tTile).getMetaTileEntity()).mRange; + if (tTile instanceof BaseMetaTileEntity + && ((BaseMetaTileEntity) tTile).getMetaTileEntity() + instanceof GT_MetaTileEntity_MonsterRepellent) { + int r = ((GT_MetaTileEntity_MonsterRepellent) ((BaseMetaTileEntity) tTile).getMetaTileEntity()) + .mRange; double dx = rep[0] + 0.5F - event.entity.posX; double dy = rep[1] + 0.5F - event.entity.posY; double dz = rep[2] + 0.5F - event.entity.posZ; if ((dx * dx + dz * dz + dy * dy) <= Math.pow(r, 2)) { - if(event.entityLiving instanceof EntitySlime) ((EntitySlime) event.entityLiving).setCustomNameTag("DoNotSpawnSlimes"); + if (event.entityLiving instanceof EntitySlime) + ((EntitySlime) event.entityLiving).setCustomNameTag("DoNotSpawnSlimes"); event.setResult(Event.Result.DENY); } } diff --git a/src/main/java/gregtech/api/util/GT_StructureUtility.java b/src/main/java/gregtech/api/util/GT_StructureUtility.java index dc3112621e..ef7724db0a 100644 --- a/src/main/java/gregtech/api/util/GT_StructureUtility.java +++ b/src/main/java/gregtech/api/util/GT_StructureUtility.java @@ -15,11 +15,13 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Frame; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; import gregtech.common.blocks.GT_Block_Casings5; import gregtech.common.blocks.GT_Item_Machines; +import java.util.Arrays; +import java.util.List; +import java.util.function.*; +import javax.annotation.Nonnull; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Items; @@ -32,11 +34,6 @@ import net.minecraft.util.IChatComponent; import net.minecraft.util.IIcon; import net.minecraft.world.World; -import javax.annotation.Nonnull; -import java.util.Arrays; -import java.util.List; -import java.util.function.*; - public class GT_StructureUtility { // private static final Map<Class<?>, String> customNames = new HashMap<>(); private GT_StructureUtility() { @@ -47,7 +44,8 @@ public class GT_StructureUtility { return aTile != null && clazz.isInstance(aTile.getMetaTileEntity()); } - public static <T> IStructureElementNoPlacement<T> ofHatchAdder(IGT_HatchAdder<T> aHatchAdder, int aTextureIndex, int aDots) { + public static <T> IStructureElementNoPlacement<T> ofHatchAdder( + IGT_HatchAdder<T> aHatchAdder, int aTextureIndex, int aDots) { return ofHatchAdder(aHatchAdder, aTextureIndex, StructureLibAPI.getBlockHint(), aDots - 1); } @@ -85,16 +83,37 @@ public class GT_StructureUtility { if (!GT_Utility.isStackValid(tFrameStack) || !(tFrameStack.getItem() instanceof ItemBlock)) return false; ItemBlock tFrameStackItem = (ItemBlock) tFrameStack.getItem(); - return tFrameStackItem.placeBlockAt(tFrameStack, null, world, x, y, z, 6, 0, 0, 0, Items.feather.getDamage(tFrameStack)); + return tFrameStackItem.placeBlockAt( + tFrameStack, null, world, x, y, z, 6, 0, 0, 0, Items.feather.getDamage(tFrameStack)); } @Override - public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor, Consumer<IChatComponent> chatter) { + public PlaceResult survivalPlaceBlock( + T t, + World world, + int x, + int y, + int z, + ItemStack trigger, + IItemSource s, + EntityPlayerMP actor, + Consumer<IChatComponent> chatter) { if (check(t, world, x, y, z)) return PlaceResult.SKIP; ItemStack tFrameStack = GT_OreDictUnificator.get(OrePrefixes.frameGt, aFrameMaterial, 1); if (!GT_Utility.isStackValid(tFrameStack) || !(tFrameStack.getItem() instanceof ItemBlock)) return PlaceResult.REJECT; // honestly, this is more like a programming error or pack issue - return StructureUtility.survivalPlaceBlock(tFrameStack, ItemStackPredicate.NBTMode.IGNORE_KNOWN_INSIGNIFICANT_TAGS, null, false, world, x, y, z, s, actor, chatter); + return StructureUtility.survivalPlaceBlock( + tFrameStack, + ItemStackPredicate.NBTMode.IGNORE_KNOWN_INSIGNIFICANT_TAGS, + null, + false, + world, + x, + y, + z, + s, + actor, + chatter); } }; } @@ -110,7 +129,8 @@ public class GT_StructureUtility { return GT_HatchElementBuilder.builder(); } - public static <T> IStructureElementNoPlacement<T> ofHatchAdder(IGT_HatchAdder<T> aHatchAdder, int aTextureIndex, Block aHintBlock, int aHintMeta) { + public static <T> IStructureElementNoPlacement<T> ofHatchAdder( + IGT_HatchAdder<T> aHatchAdder, int aTextureIndex, Block aHintBlock, int aHintMeta) { if (aHatchAdder == null || aHintBlock == null) { throw new IllegalArgumentException(); } @@ -118,7 +138,8 @@ public class GT_StructureUtility { @Override public boolean check(T t, World world, int x, int y, int z) { TileEntity tileEntity = world.getTileEntity(x, y, z); - return tileEntity instanceof IGregTechTileEntity && aHatchAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) aTextureIndex); + return tileEntity instanceof IGregTechTileEntity + && aHatchAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) aTextureIndex); } @Override @@ -129,7 +150,14 @@ public class GT_StructureUtility { }; } - public static <T> IStructureElement<T> ofHatchAdder(IGT_HatchAdder<T> aHatchAdder, int aTextureIndex, Block aHintBlock, int aHintMeta, BiPredicate<T, IGregTechTileEntity> shouldSkip, Function<T, Class<? extends IMetaTileEntity>> aMetaId, final IStructureElement.PlaceResult acceptType) { + public static <T> IStructureElement<T> ofHatchAdder( + IGT_HatchAdder<T> aHatchAdder, + int aTextureIndex, + Block aHintBlock, + int aHintMeta, + BiPredicate<T, IGregTechTileEntity> shouldSkip, + Function<T, Class<? extends IMetaTileEntity>> aMetaId, + final IStructureElement.PlaceResult acceptType) { if (aHatchAdder == null) { throw new IllegalArgumentException(); } @@ -137,7 +165,8 @@ public class GT_StructureUtility { @Override public boolean check(T t, World world, int x, int y, int z) { TileEntity tileEntity = world.getTileEntity(x, y, z); - return tileEntity instanceof IGregTechTileEntity && aHatchAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) aTextureIndex); + return tileEntity instanceof IGregTechTileEntity + && aHatchAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) aTextureIndex); } @Override @@ -153,29 +182,45 @@ public class GT_StructureUtility { } @Override - public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor, Consumer<IChatComponent> chatter) { + public PlaceResult survivalPlaceBlock( + T t, + World world, + int x, + int y, + int z, + ItemStack trigger, + IItemSource s, + EntityPlayerMP actor, + Consumer<IChatComponent> chatter) { if (shouldSkip != null) { TileEntity tileEntity = world.getTileEntity(x, y, z); - if (tileEntity instanceof IGregTechTileEntity && shouldSkip.test(t, (IGregTechTileEntity) tileEntity)) - return PlaceResult.SKIP; + if (tileEntity instanceof IGregTechTileEntity + && shouldSkip.test(t, (IGregTechTileEntity) tileEntity)) return PlaceResult.SKIP; } - if (!StructureLibAPI.isBlockTriviallyReplaceable(world, x, y, z, actor)) - return PlaceResult.REJECT; + if (!StructureLibAPI.isBlockTriviallyReplaceable(world, x, y, z, actor)) return PlaceResult.REJECT; Class<? extends IMetaTileEntity> clazz = aMetaId.apply(t); if (clazz == null) return PlaceResult.REJECT; ItemStack taken = s.takeOne(is -> clazz.isInstance(GT_Item_Machines.getMetaTileEntity(is)), true); if (GT_Utility.isStackInvalid(taken)) { - chatter.accept(new ChatComponentTranslation("GT5U.autoplace.error.no_mte.class_name", clazz.getSimpleName())); + chatter.accept(new ChatComponentTranslation( + "GT5U.autoplace.error.no_mte.class_name", clazz.getSimpleName())); return PlaceResult.REJECT; } - if (StructureUtility.survivalPlaceBlock(taken, ItemStackPredicate.NBTMode.IGNORE, null, true, world, x, y, z, s, actor) == PlaceResult.ACCEPT) - return acceptType; + if (StructureUtility.survivalPlaceBlock( + taken, ItemStackPredicate.NBTMode.IGNORE, null, true, world, x, y, z, s, actor) + == PlaceResult.ACCEPT) return acceptType; return PlaceResult.REJECT; } }; } - public static <T> IStructureElement<T> ofHatchAdder(IGT_HatchAdder<T> aHatchAdder, int aTextureIndex, Block aHintBlock, int aHintMeta, BiPredicate<T, IGregTechTileEntity> shouldSkip, ToIntFunction<T> aMetaId) { + public static <T> IStructureElement<T> ofHatchAdder( + IGT_HatchAdder<T> aHatchAdder, + int aTextureIndex, + Block aHintBlock, + int aHintMeta, + BiPredicate<T, IGregTechTileEntity> shouldSkip, + ToIntFunction<T> aMetaId) { if (aHatchAdder == null) { throw new IllegalArgumentException(); } @@ -183,7 +228,8 @@ public class GT_StructureUtility { @Override public boolean check(T t, World world, int x, int y, int z) { TileEntity tileEntity = world.getTileEntity(x, y, z); - return tileEntity instanceof IGregTechTileEntity && aHatchAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) aTextureIndex); + return tileEntity instanceof IGregTechTileEntity + && aHatchAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) aTextureIndex); } @Override @@ -199,14 +245,22 @@ public class GT_StructureUtility { } @Override - public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor, Consumer<IChatComponent> chatter) { + public PlaceResult survivalPlaceBlock( + T t, + World world, + int x, + int y, + int z, + ItemStack trigger, + IItemSource s, + EntityPlayerMP actor, + Consumer<IChatComponent> chatter) { if (shouldSkip != null) { TileEntity tileEntity = world.getTileEntity(x, y, z); - if (tileEntity instanceof IGregTechTileEntity && shouldSkip.test(t, (IGregTechTileEntity) tileEntity)) - return PlaceResult.SKIP; + if (tileEntity instanceof IGregTechTileEntity + && shouldSkip.test(t, (IGregTechTileEntity) tileEntity)) return PlaceResult.SKIP; } - if (!StructureLibAPI.isBlockTriviallyReplaceable(world, x, y, z, actor)) - return PlaceResult.REJECT; + if (!StructureLibAPI.isBlockTriviallyReplaceable(world, x, y, z, actor)) return PlaceResult.REJECT; GT_Item_Machines item = (GT_Item_Machines) Item.getItemFromBlock(GregTech_API.sBlockMachines); int meta = aMetaId.applyAsInt(t); if (meta < 0) return PlaceResult.REJECT; @@ -215,16 +269,28 @@ public class GT_StructureUtility { chatter.accept(new ChatComponentTranslation("GT5U.autoplace.error.no_mte.id", meta)); return PlaceResult.REJECT; } - return StructureUtility.survivalPlaceBlock(taken, ItemStackPredicate.NBTMode.IGNORE, null, true, world, x, y, z, s, actor) == PlaceResult.ACCEPT ? PlaceResult.ACCEPT_STOP : PlaceResult.REJECT; + return StructureUtility.survivalPlaceBlock( + taken, ItemStackPredicate.NBTMode.IGNORE, null, true, world, x, y, z, s, actor) + == PlaceResult.ACCEPT + ? PlaceResult.ACCEPT_STOP + : PlaceResult.REJECT; } }; } - public static <T> IStructureElement<T> ofHatchAdderOptional(IGT_HatchAdder<T> aHatchAdder, int textureIndex, int dots, Block placeCasing, int placeCasingMeta) { - return ofHatchAdderOptional(aHatchAdder, textureIndex, StructureLibAPI.getBlockHint(), dots - 1, placeCasing, placeCasingMeta); + public static <T> IStructureElement<T> ofHatchAdderOptional( + IGT_HatchAdder<T> aHatchAdder, int textureIndex, int dots, Block placeCasing, int placeCasingMeta) { + return ofHatchAdderOptional( + aHatchAdder, textureIndex, StructureLibAPI.getBlockHint(), dots - 1, placeCasing, placeCasingMeta); } - public static <T> IStructureElement<T> ofHatchAdderOptional(IGT_HatchAdder<T> aHatchAdder, int aTextureIndex, Block aHintBlock, int hintMeta, Block placeCasing, int placeCasingMeta) { + public static <T> IStructureElement<T> ofHatchAdderOptional( + IGT_HatchAdder<T> aHatchAdder, + int aTextureIndex, + Block aHintBlock, + int hintMeta, + Block placeCasing, + int placeCasingMeta) { if (aHatchAdder == null || aHintBlock == null) { throw new IllegalArgumentException(); } @@ -233,9 +299,9 @@ public class GT_StructureUtility { public boolean check(T t, World world, int x, int y, int z) { TileEntity tileEntity = world.getTileEntity(x, y, z); Block worldBlock = world.getBlock(x, y, z); - return (tileEntity instanceof IGregTechTileEntity && - aHatchAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) aTextureIndex)) || - (worldBlock == placeCasing && worldBlock.getDamageValue(world, x, y, z) == placeCasingMeta); + return (tileEntity instanceof IGregTechTileEntity + && aHatchAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) aTextureIndex)) + || (worldBlock == placeCasing && worldBlock.getDamageValue(world, x, y, z) == placeCasingMeta); } @Override @@ -251,9 +317,19 @@ public class GT_StructureUtility { } @Override - public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor, Consumer<IChatComponent> chatter) { + public PlaceResult survivalPlaceBlock( + T t, + World world, + int x, + int y, + int z, + ItemStack trigger, + IItemSource s, + EntityPlayerMP actor, + Consumer<IChatComponent> chatter) { if (check(t, world, x, y, z)) return PlaceResult.SKIP; - return StructureUtility.survivalPlaceBlock(placeCasing, placeCasingMeta, world, x, y, z, s, actor, chatter); + return StructureUtility.survivalPlaceBlock( + placeCasing, placeCasingMeta, world, x, y, z, s, actor, chatter); } }; } @@ -263,11 +339,14 @@ public class GT_StructureUtility { * * @see #ofCoil(BiPredicate, Function) */ - public static <T> IStructureElement<T> ofCoil(BiConsumer<T, HeatingCoilLevel> aHeatingCoilSetter, Function<T, HeatingCoilLevel> aHeatingCoilGetter) { - return ofCoil((t, l) -> { - aHeatingCoilSetter.accept(t, l); - return true; - }, aHeatingCoilGetter); + public static <T> IStructureElement<T> ofCoil( + BiConsumer<T, HeatingCoilLevel> aHeatingCoilSetter, Function<T, HeatingCoilLevel> aHeatingCoilGetter) { + return ofCoil( + (t, l) -> { + aHeatingCoilSetter.accept(t, l); + return true; + }, + aHeatingCoilGetter); } /** @@ -279,7 +358,8 @@ public class GT_StructureUtility { * If the setter returns false then it assumes the coil is rejected. * @param aHeatingCoilGetter Get the current heating level. Null means no coil recorded yet. */ - public static <T> IStructureElement<T> ofCoil(BiPredicate<T, HeatingCoilLevel> aHeatingCoilSetter, Function<T, HeatingCoilLevel> aHeatingCoilGetter) { + public static <T> IStructureElement<T> ofCoil( + BiPredicate<T, HeatingCoilLevel> aHeatingCoilSetter, Function<T, HeatingCoilLevel> aHeatingCoilGetter) { if (aHeatingCoilSetter == null || aHeatingCoilGetter == null) { throw new IllegalArgumentException(); } @@ -287,10 +367,9 @@ public class GT_StructureUtility { @Override public boolean check(T t, World world, int x, int y, int z) { Block block = world.getBlock(x, y, z); - if (!(block instanceof IHeatingCoil)) - return false; + if (!(block instanceof IHeatingCoil)) return false; HeatingCoilLevel existingLevel = aHeatingCoilGetter.apply(t), - newLevel = ((IHeatingCoil) block).getCoilHeat(world.getBlockMetadata(x, y, z)); + newLevel = ((IHeatingCoil) block).getCoilHeat(world.getBlockMetadata(x, y, z)); if (existingLevel == null || existingLevel == HeatingCoilLevel.None) { return aHeatingCoilSetter.test(t, newLevel); } else { @@ -309,7 +388,8 @@ public class GT_StructureUtility { } private HeatingCoilLevel getHeatFromHint(ItemStack trigger) { - return HeatingCoilLevel.getFromTier((byte) Math.min(HeatingCoilLevel.getMaxTier() , Math.max(0, trigger.stackSize - 1))); + return HeatingCoilLevel.getFromTier( + (byte) Math.min(HeatingCoilLevel.getMaxTier(), Math.max(0, trigger.stackSize - 1))); } @Override @@ -318,11 +398,23 @@ public class GT_StructureUtility { } @Override - public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor, Consumer<IChatComponent> chatter) { + public PlaceResult survivalPlaceBlock( + T t, + World world, + int x, + int y, + int z, + ItemStack trigger, + IItemSource s, + EntityPlayerMP actor, + Consumer<IChatComponent> chatter) { Block block = world.getBlock(x, y, z); - boolean isCoil = block instanceof IHeatingCoil && ((IHeatingCoil) block).getCoilHeat(world.getBlockMetadata(x, y, z)) == getHeatFromHint(trigger); + boolean isCoil = block instanceof IHeatingCoil + && ((IHeatingCoil) block).getCoilHeat(world.getBlockMetadata(x, y, z)) + == getHeatFromHint(trigger); if (isCoil) return PlaceResult.SKIP; - return StructureUtility.survivalPlaceBlock(GregTech_API.sBlockCasings5, getMetaFromHint(trigger), world, x, y, z, s, actor, chatter); + return StructureUtility.survivalPlaceBlock( + GregTech_API.sBlockCasings5, getMetaFromHint(trigger), world, x, y, z, s, actor, chatter); } }; } @@ -339,9 +431,9 @@ public class GT_StructureUtility { public static Predicate<ItemStack> filterByMTETier(int aMinTier, int aMaxTier) { return is -> { IMetaTileEntity tile = GT_Item_Machines.getMetaTileEntity(is); - return tile instanceof GT_MetaTileEntity_TieredMachineBlock && - ((GT_MetaTileEntity_TieredMachineBlock) tile).mTier <= aMaxTier && - ((GT_MetaTileEntity_TieredMachineBlock) tile).mTier >= aMinTier; + return tile instanceof GT_MetaTileEntity_TieredMachineBlock + && ((GT_MetaTileEntity_TieredMachineBlock) tile).mTier <= aMaxTier + && ((GT_MetaTileEntity_TieredMachineBlock) tile).mTier >= aMinTier; }; } } diff --git a/src/main/java/gregtech/api/util/GT_ToolHarvestHelper.java b/src/main/java/gregtech/api/util/GT_ToolHarvestHelper.java index 271b361da0..7416289c79 100644 --- a/src/main/java/gregtech/api/util/GT_ToolHarvestHelper.java +++ b/src/main/java/gregtech/api/util/GT_ToolHarvestHelper.java @@ -1,61 +1,57 @@ -package gregtech.api.util;
-
-import net.minecraft.block.Block;
-import net.minecraft.block.material.Material;
-
-public class GT_ToolHarvestHelper {
-
- public static boolean isAppropriateTool(Block aBlock, byte aMetaData, String... tTools) {
-
- if (aBlock == null || tTools == null) {
- return false;
- }
- String targetTool = aBlock.getHarvestTool(aMetaData);
- return !isStringEmpty(targetTool) && isArrayContains(targetTool, tTools);
- }
-
- public static boolean isAppropriateMaterial(Block aBlock, Material... tMats) {
- if (aBlock == null || tMats == null) {
- return false;
- }
- return isArrayContains(aBlock.getMaterial(), tMats);
- }
-
-
- public static boolean isSpecialBlock(Block aBlock, Block... tBlocks) {
- if (aBlock == null || tBlocks == null) {
- return false;
- }
- return isArrayContains(aBlock, tBlocks);
- }
-
-
- public static <T> boolean isArrayContains(T obj, T[] list) {
-
- if (obj == null || list == null) {
- return false;
- }
-
- for (T iObj : list) {
- if (obj == iObj || obj.equals(iObj)) {
- return true;
- }
- }
- return false;
- }
-
- public static boolean isStringEmpty(String s) {
- return s == null || s.length() == 0;
- }
-
- public static boolean hasNull(Object... obj) {
- for (Object iObj : obj) {
- if (iObj == null) {
- return true;
- }
- }
- return false;
- }
-
-
-}
+package gregtech.api.util; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; + +public class GT_ToolHarvestHelper { + + public static boolean isAppropriateTool(Block aBlock, byte aMetaData, String... tTools) { + + if (aBlock == null || tTools == null) { + return false; + } + String targetTool = aBlock.getHarvestTool(aMetaData); + return !isStringEmpty(targetTool) && isArrayContains(targetTool, tTools); + } + + public static boolean isAppropriateMaterial(Block aBlock, Material... tMats) { + if (aBlock == null || tMats == null) { + return false; + } + return isArrayContains(aBlock.getMaterial(), tMats); + } + + public static boolean isSpecialBlock(Block aBlock, Block... tBlocks) { + if (aBlock == null || tBlocks == null) { + return false; + } + return isArrayContains(aBlock, tBlocks); + } + + public static <T> boolean isArrayContains(T obj, T[] list) { + + if (obj == null || list == null) { + return false; + } + + for (T iObj : list) { + if (obj == iObj || obj.equals(iObj)) { + return true; + } + } + return false; + } + + public static boolean isStringEmpty(String s) { + return s == null || s.length() == 0; + } + + public static boolean hasNull(Object... obj) { + for (Object iObj : obj) { + if (iObj == null) { + return true; + } + } + return false; + } +} diff --git a/src/main/java/gregtech/api/util/GT_TooltipDataCache.java b/src/main/java/gregtech/api/util/GT_TooltipDataCache.java index 4309958b82..15f7b69248 100644 --- a/src/main/java/gregtech/api/util/GT_TooltipDataCache.java +++ b/src/main/java/gregtech/api/util/GT_TooltipDataCache.java @@ -1,11 +1,10 @@ package gregtech.api.util; +import gregtech.GT_Mod; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; - -import gregtech.GT_Mod; import net.minecraft.util.StatCollector; public class GT_TooltipDataCache { @@ -19,6 +18,7 @@ public class GT_TooltipDataCache { this.shiftText = shiftText; } } + private final Map<String, TooltipData> fetchedTooltipData = new HashMap<>(); /** @@ -48,14 +48,16 @@ public class GT_TooltipDataCache { List<String> lines = getAllLines(key, args); int normalLines = lines.size(); if (Math.max(GT_Mod.gregtechproxy.mTooltipVerbosity, GT_Mod.gregtechproxy.mTooltipShiftVerbosity) >= 3) { - lines.addAll(getAllLines(key + ".extended", args)); // Are extended lines enabled? If so add them to the lines + lines.addAll( + getAllLines(key + ".extended", args)); // Are extended lines enabled? If so add them to the lines } if (lines.size() == 0) { lines.add(key); // Fallback in case no lines could be found at all } return new TooltipData( - lines.subList(0, getVerbosityIndex(GT_Mod.gregtechproxy.mTooltipVerbosity, normalLines, lines.size())), - lines.subList(0, getVerbosityIndex(GT_Mod.gregtechproxy.mTooltipShiftVerbosity, normalLines, lines.size()))); + lines.subList(0, getVerbosityIndex(GT_Mod.gregtechproxy.mTooltipVerbosity, normalLines, lines.size())), + lines.subList( + 0, getVerbosityIndex(GT_Mod.gregtechproxy.mTooltipShiftVerbosity, normalLines, lines.size()))); } /** @@ -65,7 +67,7 @@ public class GT_TooltipDataCache { * @param args arguments for string formatting (prefer using positional arguments) * @return The lines for the key and all of it's subkeys */ - private List<String> getAllLines(String key, Object... args) { + private List<String> getAllLines(String key, Object... args) { List<String> lines = new ArrayList<String>(); String keyToLookup = key; int i = 1; // First loop has no .number postfix diff --git a/src/main/java/gregtech/api/util/GT_Util.java b/src/main/java/gregtech/api/util/GT_Util.java index 2d1a1e389d..9de1726162 100644 --- a/src/main/java/gregtech/api/util/GT_Util.java +++ b/src/main/java/gregtech/api/util/GT_Util.java @@ -20,10 +20,11 @@ public class GT_Util { } public static NBTTagCompound fuseNBT(NBTTagCompound aNBT1, NBTTagCompound aNBT2) { - if (aNBT1 == null) return aNBT2 == null ? new NBTTagCompound() : (NBTTagCompound)aNBT2.copy(); - final NBTTagCompound rNBT = (NBTTagCompound)aNBT1.copy(); + if (aNBT1 == null) return aNBT2 == null ? new NBTTagCompound() : (NBTTagCompound) aNBT2.copy(); + final NBTTagCompound rNBT = (NBTTagCompound) aNBT1.copy(); if (aNBT2 == null) return rNBT; - for (Object tKey : aNBT2.func_150296_c/*getKeySet*/()) if (!rNBT.hasKey(tKey.toString())) rNBT.setTag(tKey.toString(), aNBT2.getTag(tKey.toString())); + for (Object tKey : aNBT2.func_150296_c /*getKeySet*/()) + if (!rNBT.hasKey(tKey.toString())) rNBT.setTag(tKey.toString(), aNBT2.getTag(tKey.toString())); return rNBT; } @@ -32,29 +33,22 @@ public class GT_Util { */ public static NBTTagCompound makeNBT(Tuple... aTags) { final NBTTagCompound rNBT = new NBTTagCompound(); - for(Tuple t : aTags) { + for (Tuple t : aTags) { if (t.getSecond() == null) continue; - if (t.getSecond() instanceof Boolean) - rNBT.setBoolean(t.getFirst().toString(), (Boolean) t.getSecond()); - else if (t.getSecond() instanceof Byte) - rNBT.setByte(t.getFirst().toString(), (Byte) t.getSecond()); - else if (t.getSecond() instanceof Short) - rNBT.setShort(t.getFirst().toString(), (Short) t.getSecond()); + if (t.getSecond() instanceof Boolean) rNBT.setBoolean(t.getFirst().toString(), (Boolean) t.getSecond()); + else if (t.getSecond() instanceof Byte) rNBT.setByte(t.getFirst().toString(), (Byte) t.getSecond()); + else if (t.getSecond() instanceof Short) rNBT.setShort(t.getFirst().toString(), (Short) t.getSecond()); else if (t.getSecond() instanceof Integer) rNBT.setInteger(t.getFirst().toString(), (Integer) t.getSecond()); - else if (t.getSecond() instanceof Long) - rNBT.setLong(t.getFirst().toString(), (Long) t.getSecond()); - else if (t.getSecond() instanceof Float) - rNBT.setFloat(t.getFirst().toString(), (Float) t.getSecond()); + else if (t.getSecond() instanceof Long) rNBT.setLong(t.getFirst().toString(), (Long) t.getSecond()); + else if (t.getSecond() instanceof Float) rNBT.setFloat(t.getFirst().toString(), (Float) t.getSecond()); else if (t.getSecond() instanceof Double) rNBT.setDouble(t.getFirst().toString(), (Double) t.getSecond()); else if (t.getSecond() instanceof String) rNBT.setString(t.getFirst().toString(), (String) t.getSecond()); - else if (t.getSecond() instanceof NBTBase) - rNBT.setTag(t.getFirst().toString(), (NBTBase) t.getSecond()); - else - rNBT.setString(t.getFirst().toString(), t.getSecond().toString()); + else if (t.getSecond() instanceof NBTBase) rNBT.setTag(t.getFirst().toString(), (NBTBase) t.getSecond()); + else rNBT.setString(t.getFirst().toString(), t.getSecond().toString()); } return rNBT; @@ -66,37 +60,41 @@ public class GT_Util { public static TileEntity getTileEntity(World aWorld, int aX, int aY, int aZ, boolean aLoadUnloadedChunks) { if (aLoadUnloadedChunks || aWorld.blockExists(aX, aY, aZ)) { TileEntity rTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (rTileEntity instanceof IMultiTileEntity && ((IMultiTileEntity)rTileEntity).isDead()) return null; + if (rTileEntity instanceof IMultiTileEntity && ((IMultiTileEntity) rTileEntity).isDead()) return null; if (rTileEntity != null) return rTileEntity; rTileEntity = LAST_BROKEN_TILEENTITY.get(); - if (rTileEntity != null && rTileEntity.xCoord == aX && rTileEntity.yCoord == aY && rTileEntity.zCoord == aZ) return rTileEntity; + if (rTileEntity != null && rTileEntity.xCoord == aX && rTileEntity.yCoord == aY && rTileEntity.zCoord == aZ) + return rTileEntity; } return null; } /** Sets the TileEntity at the passed position, with the option of turning adjacent TileEntity updates off. */ - public static TileEntity setTileEntity(World aWorld, int aX, int aY, int aZ, TileEntity aTileEntity, boolean aCauseTileEntityUpdates) { - if (aCauseTileEntityUpdates) aWorld.setTileEntity(aX, aY, aZ, aTileEntity); else { + public static TileEntity setTileEntity( + World aWorld, int aX, int aY, int aZ, TileEntity aTileEntity, boolean aCauseTileEntityUpdates) { + if (aCauseTileEntityUpdates) aWorld.setTileEntity(aX, aY, aZ, aTileEntity); + else { Chunk tChunk = aWorld.getChunkFromChunkCoords(aX >> 4, aZ >> 4); if (tChunk != null) { aWorld.addTileEntity(aTileEntity); - tChunk.func_150812_a/*setBlockTileEntityInChunk*/(aX & 15, aY, aZ & 15, aTileEntity); + tChunk.func_150812_a /*setBlockTileEntityInChunk*/(aX & 15, aY, aZ & 15, aTileEntity); tChunk.setChunkModified(); } } return aTileEntity; } - public static boolean setTileEntity(World aWorld, int aX, int aY, int aZ, Block aBlock, short aMeta, long aFlags, boolean aRemoveGrassBelow) { + public static boolean setTileEntity( + World aWorld, int aX, int aY, int aZ, Block aBlock, short aMeta, long aFlags, boolean aRemoveGrassBelow) { if (aRemoveGrassBelow) { - final Block tBlock = aWorld.getBlock(aX, aY-1, aZ); - if (tBlock == Blocks.grass || tBlock == Blocks.mycelium) aWorld.setBlock(aX, aY-1, aZ, Blocks.dirt, 0, (byte)aFlags); + final Block tBlock = aWorld.getBlock(aX, aY - 1, aZ); + if (tBlock == Blocks.grass || tBlock == Blocks.mycelium) + aWorld.setBlock(aX, aY - 1, aZ, Blocks.dirt, 0, (byte) aFlags); } - return aWorld.setBlock(aX, aY, aZ, aBlock, aMeta, (byte)aFlags); + return aWorld.setBlock(aX, aY, aZ, aBlock, aMeta, (byte) aFlags); } - - public static TileEntity getTileEntity (World aWorld, ChunkCoordinates aCoords, boolean aLoadUnloadedChunks) { + public static TileEntity getTileEntity(World aWorld, ChunkCoordinates aCoords, boolean aLoadUnloadedChunks) { return getTileEntity(aWorld, aCoords.posX, aCoords.posY, aCoords.posZ, aLoadUnloadedChunks); } @@ -108,7 +106,8 @@ public class GT_Util { aWorld.getBlockMetadata(aX, 0, aZ); aChunk = aWorld.getChunkFromBlockCoords(aX, aZ); if (aChunk == null) { - GT_Log.err.println("Some important Chunk does not exist for some reason at Coordinates X: " + aX + " and Z: " + aZ); + GT_Log.err.println("Some important Chunk does not exist for some reason at Coordinates X: " + aX + + " and Z: " + aZ); return false; } } @@ -117,11 +116,19 @@ public class GT_Util { } /** Marks a Chunk dirty so it is saved */ public static boolean markChunkDirty(Object aTileEntity) { - return aTileEntity instanceof TileEntity && markChunkDirty(((TileEntity)aTileEntity).getWorldObj(), ((TileEntity)aTileEntity).xCoord, ((TileEntity)aTileEntity).zCoord); + return aTileEntity instanceof TileEntity + && markChunkDirty( + ((TileEntity) aTileEntity).getWorldObj(), + ((TileEntity) aTileEntity).xCoord, + ((TileEntity) aTileEntity).zCoord); } public static int mixRGBInt(int aRGB1, int aRGB2) { - return getRGBInt(new short[] {(short)((getR(aRGB1) + getR(aRGB2)) >> 1), (short)((getG(aRGB1) + getG(aRGB2)) >> 1), (short)((getB(aRGB1) + getB(aRGB2)) >> 1)}); + return getRGBInt(new short[] { + (short) ((getR(aRGB1) + getR(aRGB2)) >> 1), + (short) ((getG(aRGB1) + getG(aRGB2)) >> 1), + (short) ((getB(aRGB1) + getB(aRGB2)) >> 1) + }); } public static int getRGBInt(short[] aColors) { @@ -145,12 +152,27 @@ public class GT_Util { } public static short[] getRGBaArray(int aColors) { - return new short[] {(short)((aColors >>> 16) & 255), (short)((aColors >>> 8) & 255), (short)(aColors & 255), (short)((aColors >>> 24) & 255)}; + return new short[] { + (short) ((aColors >>> 16) & 255), + (short) ((aColors >>> 8) & 255), + (short) (aColors & 255), + (short) ((aColors >>> 24) & 255) + }; + } + + public static short getR(int aColors) { + return (short) ((aColors >>> 16) & 255); } - public static short getR(int aColors) {return (short)((aColors >>> 16) & 255);} - public static short getG(int aColors) {return (short)((aColors >>> 8) & 255);} - public static short getB(int aColors) {return (short) (aColors & 255);} - public static short getA(int aColors) {return (short)((aColors >>> 24) & 255);} + public static short getG(int aColors) { + return (short) ((aColors >>> 8) & 255); + } + public static short getB(int aColors) { + return (short) (aColors & 255); + } + + public static short getA(int aColors) { + return (short) ((aColors >>> 24) & 255); + } } diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index b03c3ab13e..dc192a7d57 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -1,5 +1,16 @@ package gregtech.api.util; +import static gregtech.GT_Mod.GT_FML_LOGGER; +import static gregtech.api.enums.GT_Values.D1; +import static gregtech.api.enums.GT_Values.E; +import static gregtech.api.enums.GT_Values.GT; +import static gregtech.api.enums.GT_Values.L; +import static gregtech.api.enums.GT_Values.M; +import static gregtech.api.enums.GT_Values.NW; +import static gregtech.api.enums.GT_Values.V; +import static gregtech.api.enums.GT_Values.W; +import static gregtech.common.GT_UndergroundOil.undergroundOilReadInformation; + import cofh.api.transport.IItemDuct; import com.google.auto.value.AutoValue; import com.google.common.base.Suppliers; @@ -42,6 +53,32 @@ import ic2.api.recipe.IRecipeInput; import ic2.api.recipe.RecipeInputItemStack; import ic2.api.recipe.RecipeInputOreDict; import ic2.api.recipe.RecipeOutput; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.math.BigInteger; +import java.math.RoundingMode; +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Objects; +import java.util.Optional; +import java.util.UUID; +import java.util.function.Function; +import java.util.function.IntFunction; +import java.util.function.Supplier; +import javax.annotation.Nullable; import net.minecraft.block.Block; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; @@ -92,44 +129,6 @@ import net.minecraftforge.fluids.IFluidContainerItem; import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.oredict.OreDictionary; -import javax.annotation.Nullable; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.math.BigInteger; -import java.math.RoundingMode; -import java.text.DecimalFormat; -import java.text.DecimalFormatSymbols; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Objects; -import java.util.Optional; -import java.util.UUID; -import java.util.function.Function; -import java.util.function.IntFunction; -import java.util.function.Supplier; - -import static gregtech.GT_Mod.GT_FML_LOGGER; -import static gregtech.api.enums.GT_Values.D1; -import static gregtech.api.enums.GT_Values.E; -import static gregtech.api.enums.GT_Values.GT; -import static gregtech.api.enums.GT_Values.L; -import static gregtech.api.enums.GT_Values.M; -import static gregtech.api.enums.GT_Values.NW; -import static gregtech.api.enums.GT_Values.V; -import static gregtech.api.enums.GT_Values.W; -import static gregtech.common.GT_UndergroundOil.undergroundOilReadInformation; - /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! * <p/> @@ -137,24 +136,28 @@ import static gregtech.common.GT_UndergroundOil.undergroundOilReadInformation; */ public class GT_Utility { /** Formats a number with group separator and at most 2 fraction digits. */ - private static final Map<Locale, DecimalFormat> decimalFormatters=new HashMap<>(); + private static final Map<Locale, DecimalFormat> decimalFormatters = new HashMap<>(); /** * Forge screwed the Fluid Registry up again, so I make my own, which is also much more efficient than the stupid Stuff over there. */ private static final List<FluidContainerData> sFluidContainerList = new ArrayList<>(); - private static final Map<GT_ItemStack, FluidContainerData> sFilledContainerToData = new /*Concurrent*/HashMap<>(); - private static final Map<GT_ItemStack, Map<Fluid, FluidContainerData>> sEmptyContainerToFluidToData = new /*Concurrent*/HashMap<>(); + + private static final Map<GT_ItemStack, FluidContainerData> sFilledContainerToData = new /*Concurrent*/ HashMap<>(); + private static final Map<GT_ItemStack, Map<Fluid, FluidContainerData>> sEmptyContainerToFluidToData = + new /*Concurrent*/ HashMap<>(); private static final Map<Fluid, List<ItemStack>> sFluidToContainers = new HashMap<>(); private static final Map<String, Fluid> sFluidUnlocalizedNameToFluid = new HashMap<>(); /** Must use {@code Supplier} here because the ore prefixes have not yet been registered at class load time. */ private static final Map<OrePrefixes, Supplier<ItemStack>> sOreToCobble = new HashMap<>(); - private final static Map<Integer, Boolean> sOreTable = new HashMap<>(); + + private static final Map<Integer, Boolean> sOreTable = new HashMap<>(); public static volatile int VERSION = 509; public static boolean TE_CHECK = false, BC_CHECK = false, CHECK_ALL = true, RF_CHECK = false; - public static Map<GT_PlayedSound, Integer> sPlayedSoundMap = new /*Concurrent*/HashMap<>(); + public static Map<GT_PlayedSound, Integer> sPlayedSoundMap = new /*Concurrent*/ HashMap<>(); private static int sBookCount = 0; - public static UUID defaultUuid = null; // maybe default non-null? UUID.fromString("00000000-0000-0000-0000-000000000000"); + public static UUID defaultUuid = + null; // maybe default non-null? UUID.fromString("00000000-0000-0000-0000-000000000000"); static { GregTech_API.sItemStackMappings.add(sFilledContainerToData); @@ -162,41 +165,33 @@ public class GT_Utility { // 1 is the magic index to get the cobblestone block. // See: GT_Block_Stones.java, GT_Block_Granites.java - Function<Materials, Supplier<ItemStack>> materialToCobble = - m -> Suppliers.memoize(() -> GT_OreDictUnificator.getOres(OrePrefixes.stone, m).get(1))::get; - sOreToCobble.put( - OrePrefixes.oreBlackgranite, - materialToCobble.apply(Materials.GraniteBlack)); - sOreToCobble.put( - OrePrefixes.oreRedgranite, - materialToCobble.apply(Materials.GraniteRed)); - sOreToCobble.put( - OrePrefixes.oreMarble, - materialToCobble.apply(Materials.Marble)); - sOreToCobble.put( - OrePrefixes.oreBasalt, - materialToCobble.apply(Materials.Basalt)); - sOreToCobble.put( - OrePrefixes.oreNetherrack, - () -> new ItemStack(Blocks.netherrack)); - sOreToCobble.put( - OrePrefixes.oreEndstone, - () -> new ItemStack(Blocks.end_stone)); - } - - public static int safeInt(long number, int margin){ - return number>Integer.MAX_VALUE-margin ? Integer.MAX_VALUE-margin :(int)number; - } - - public static int safeInt(long number){ - return number> V[V.length-1] ? safeInt(V[V.length-1],1) : number<Integer.MIN_VALUE ? Integer.MIN_VALUE : (int)number; + Function<Materials, Supplier<ItemStack>> materialToCobble = m -> Suppliers.memoize( + () -> GT_OreDictUnificator.getOres(OrePrefixes.stone, m).get(1))::get; + sOreToCobble.put(OrePrefixes.oreBlackgranite, materialToCobble.apply(Materials.GraniteBlack)); + sOreToCobble.put(OrePrefixes.oreRedgranite, materialToCobble.apply(Materials.GraniteRed)); + sOreToCobble.put(OrePrefixes.oreMarble, materialToCobble.apply(Materials.Marble)); + sOreToCobble.put(OrePrefixes.oreBasalt, materialToCobble.apply(Materials.Basalt)); + sOreToCobble.put(OrePrefixes.oreNetherrack, () -> new ItemStack(Blocks.netherrack)); + sOreToCobble.put(OrePrefixes.oreEndstone, () -> new ItemStack(Blocks.end_stone)); + } + + public static int safeInt(long number, int margin) { + return number > Integer.MAX_VALUE - margin ? Integer.MAX_VALUE - margin : (int) number; + } + + public static int safeInt(long number) { + return number > V[V.length - 1] + ? safeInt(V[V.length - 1], 1) + : number < Integer.MIN_VALUE ? Integer.MIN_VALUE : (int) number; } public static Field getPublicField(Object aObject, String aField) { Field rField = null; try { rField = aObject.getClass().getDeclaredField(aField); - } catch (Throwable e) {/*Do nothing*/} + } catch (Throwable e) { + /*Do nothing*/ + } return rField; } @@ -205,7 +200,9 @@ public class GT_Utility { try { rField = aObject.getClass().getDeclaredField(aField); rField.setAccessible(true); - } catch (Throwable e) {/*Do nothing*/} + } catch (Throwable e) { + /*Do nothing*/ + } return rField; } @@ -214,7 +211,9 @@ public class GT_Utility { try { rField = aObject.getDeclaredField(aField); rField.setAccessible(true); - } catch (Throwable e) {/*Do nothing*/} + } catch (Throwable e) { + /*Do nothing*/ + } return rField; } @@ -223,7 +222,9 @@ public class GT_Utility { try { rMethod = aObject.getMethod(aMethod, aParameterTypes); rMethod.setAccessible(true); - } catch (Throwable e) {/*Do nothing*/} + } catch (Throwable e) { + /*Do nothing*/ + } return rMethod; } @@ -232,13 +233,19 @@ public class GT_Utility { try { rMethod = aObject.getClass().getMethod(aMethod, aParameterTypes); rMethod.setAccessible(true); - } catch (Throwable e) {/*Do nothing*/} + } catch (Throwable e) { + /*Do nothing*/ + } return rMethod; } public static Field getField(Object aObject, String aField, boolean aPrivate, boolean aLogErrors) { try { - Field tField = (aObject instanceof Class) ? ((Class) aObject).getDeclaredField(aField) : (aObject instanceof String) ? Class.forName((String) aObject).getDeclaredField(aField) : aObject.getClass().getDeclaredField(aField); + Field tField = (aObject instanceof Class) + ? ((Class) aObject).getDeclaredField(aField) + : (aObject instanceof String) + ? Class.forName((String) aObject).getDeclaredField(aField) + : aObject.getClass().getDeclaredField(aField); if (aPrivate) tField.setAccessible(true); return tField; } catch (Throwable e) { @@ -249,7 +256,11 @@ public class GT_Utility { public static Object getFieldContent(Object aObject, String aField, boolean aPrivate, boolean aLogErrors) { try { - Field tField = (aObject instanceof Class) ? ((Class) aObject).getDeclaredField(aField) : (aObject instanceof String) ? Class.forName((String) aObject).getDeclaredField(aField) : aObject.getClass().getDeclaredField(aField); + Field tField = (aObject instanceof Class) + ? ((Class) aObject).getDeclaredField(aField) + : (aObject instanceof String) + ? Class.forName((String) aObject).getDeclaredField(aField) + : aObject.getClass().getDeclaredField(aField); if (aPrivate) tField.setAccessible(true); return tField.get(aObject instanceof Class || aObject instanceof String ? null : aObject); } catch (Throwable e) { @@ -266,7 +277,13 @@ public class GT_Utility { return callMethod(aObject, aMethod, true, false, true, aParameters); } - public static Object callMethod(Object aObject, String aMethod, boolean aPrivate, boolean aUseUpperCasedDataTypes, boolean aLogErrors, Object... aParameters) { + public static Object callMethod( + Object aObject, + String aMethod, + boolean aPrivate, + boolean aUseUpperCasedDataTypes, + boolean aLogErrors, + Object... aParameters) { try { Class<?>[] tParameterTypes = new Class<?>[aParameters.length]; for (byte i = 0; i < aParameters.length; i++) { @@ -287,7 +304,9 @@ public class GT_Utility { } } - Method tMethod = (aObject instanceof Class) ? ((Class) aObject).getMethod(aMethod, tParameterTypes) : aObject.getClass().getMethod(aMethod, tParameterTypes); + Method tMethod = (aObject instanceof Class) + ? ((Class) aObject).getMethod(aMethod, tParameterTypes) + : aObject.getClass().getMethod(aMethod, tParameterTypes); if (aPrivate) tMethod.setAccessible(true); return tMethod.invoke(aObject, aParameters); } catch (Throwable e) { @@ -296,22 +315,34 @@ public class GT_Utility { return null; } - public static Object callConstructor(String aClass, int aConstructorIndex, Object aReplacementObject, boolean aLogErrors, Object... aParameters) { + public static Object callConstructor( + String aClass, + int aConstructorIndex, + Object aReplacementObject, + boolean aLogErrors, + Object... aParameters) { try { - return callConstructor(Class.forName(aClass), aConstructorIndex, aReplacementObject, aLogErrors, aParameters); + return callConstructor( + Class.forName(aClass), aConstructorIndex, aReplacementObject, aLogErrors, aParameters); } catch (Throwable e) { if (aLogErrors) e.printStackTrace(GT_Log.err); } return aReplacementObject; } - public static Object callConstructor(Class<?> aClass, int aConstructorIndex, Object aReplacementObject, boolean aLogErrors, Object... aParameters) { + public static Object callConstructor( + Class<?> aClass, + int aConstructorIndex, + Object aReplacementObject, + boolean aLogErrors, + Object... aParameters) { if (aConstructorIndex < 0) { try { for (Constructor<?> tConstructor : aClass.getConstructors()) { try { return tConstructor.newInstance(aParameters); - } catch (Throwable ignored) {} + } catch (Throwable ignored) { + } } } catch (Throwable e) { if (aLogErrors) e.printStackTrace(GT_Log.err); @@ -346,8 +377,7 @@ public class GT_Utility { } } - if (tPotionHashmap != null) - return ((HashMap) tPotionHashmap.get(aPlayer)).get(aPotionIndex) != null; + if (tPotionHashmap != null) return ((HashMap) tPotionHashmap.get(aPlayer)).get(aPotionIndex) != null; } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); } @@ -356,7 +386,9 @@ public class GT_Utility { public static String getClassName(Object aObject) { if (aObject == null) return "null"; - return aObject.getClass().getName().substring(aObject.getClass().getName().lastIndexOf(".") + 1); + return aObject.getClass() + .getName() + .substring(aObject.getClass().getName().lastIndexOf(".") + 1); } public static void removePotion(EntityLivingBase aPlayer, int aPotionIndex) { @@ -385,7 +417,8 @@ public class GT_Utility { for (int i = 0; i < 4; i++) { if (aPlayer.inventory.armorInventory[i] != null) { if (aPlayer.inventory.armorInventory[i].getItem() instanceof GT_EnergyArmor_Item) { - if ((((GT_EnergyArmor_Item) aPlayer.inventory.armorInventory[i].getItem()).mSpecials & 512) != 0) { + if ((((GT_EnergyArmor_Item) aPlayer.inventory.armorInventory[i].getItem()).mSpecials & 512) + != 0) { if (GT_ModHandler.canUseElectricItem(aPlayer.inventory.armorInventory[i], 10000)) { return true; } @@ -400,8 +433,10 @@ public class GT_Utility { return false; } - public static ItemStack suckOneItemStackAt(World aWorld, double aX, double aY, double aZ, double aL, double aH, double aW) { - for (EntityItem tItem : (ArrayList<EntityItem>) aWorld.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + aL, aY + aH, aZ + aW))) { + public static ItemStack suckOneItemStackAt( + World aWorld, double aX, double aY, double aZ, double aL, double aH, double aW) { + for (EntityItem tItem : (ArrayList<EntityItem>) aWorld.getEntitiesWithinAABB( + EntityItem.class, AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + aL, aY + aH, aZ + aW))) { if (!tItem.isDead) { aWorld.removeEntity(tItem); tItem.setDead(); @@ -433,17 +468,23 @@ public class GT_Utility { Class tClass = IItemDuct.class; tClass.getCanonicalName(); TE_CHECK = true; - } catch (Throwable e) {/**/} + } catch (Throwable e) { + /**/ + } try { Class tClass = buildcraft.api.transport.IPipeTile.class; tClass.getCanonicalName(); BC_CHECK = true; - } catch (Throwable e) {/**/} + } catch (Throwable e) { + /**/ + } try { Class tClass = cofh.api.energy.IEnergyReceiver.class; tClass.getCanonicalName(); RF_CHECK = true; - } catch (Throwable e) {/**/} + } catch (Throwable e) { + /**/ + } CHECK_ALL = false; } } @@ -453,7 +494,8 @@ public class GT_Utility { checkAvailabilities(); if (TE_CHECK && aTileEntity instanceof IItemDuct) return true; if (BC_CHECK && aTileEntity instanceof buildcraft.api.transport.IPipeTile) - return ((buildcraft.api.transport.IPipeTile) aTileEntity).isPipeConnected(ForgeDirection.getOrientation(aSide)); + return ((buildcraft.api.transport.IPipeTile) aTileEntity) + .isPipeConnected(ForgeDirection.getOrientation(aSide)); return GregTech_API.mTranslocator && aTileEntity instanceof codechicken.translocator.TileItemTranslocator; } /** @@ -461,8 +503,31 @@ public class GT_Utility { * * @return the Amount of moved Items */ - public static byte moveStackIntoPipe(IInventory aTileEntity1, Object aTileEntity2, int[] aGrabSlots, int aGrabFrom, int aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce) { - return moveStackIntoPipe(aTileEntity1, aTileEntity2, aGrabSlots, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, true); + public static byte moveStackIntoPipe( + IInventory aTileEntity1, + Object aTileEntity2, + int[] aGrabSlots, + int aGrabFrom, + int aPutTo, + List<ItemStack> aFilter, + boolean aInvertFilter, + byte aMaxTargetStackSize, + byte aMinTargetStackSize, + byte aMaxMoveAtOnce, + byte aMinMoveAtOnce) { + return moveStackIntoPipe( + aTileEntity1, + aTileEntity2, + aGrabSlots, + aGrabFrom, + aPutTo, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + true); } /** @@ -470,21 +535,45 @@ public class GT_Utility { * * @return the Amount of moved Items */ - public static byte moveStackIntoPipe(IInventory aTileEntity1, Object aTileEntity2, int[] aGrabSlots, int aGrabFrom, int aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce, boolean dropItem) { - if (aTileEntity1 == null || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0 || aMinTargetStackSize > aMaxTargetStackSize || aMaxMoveAtOnce <= 0 || aMinMoveAtOnce > aMaxMoveAtOnce) - return 0; + public static byte moveStackIntoPipe( + IInventory aTileEntity1, + Object aTileEntity2, + int[] aGrabSlots, + int aGrabFrom, + int aPutTo, + List<ItemStack> aFilter, + boolean aInvertFilter, + byte aMaxTargetStackSize, + byte aMinTargetStackSize, + byte aMaxMoveAtOnce, + byte aMinMoveAtOnce, + boolean dropItem) { + if (aTileEntity1 == null + || aMaxTargetStackSize <= 0 + || aMinTargetStackSize <= 0 + || aMinTargetStackSize > aMaxTargetStackSize + || aMaxMoveAtOnce <= 0 + || aMinMoveAtOnce > aMaxMoveAtOnce) return 0; if (aTileEntity2 != null) { checkAvailabilities(); if (TE_CHECK && aTileEntity2 instanceof IItemDuct) { for (int aGrabSlot : aGrabSlots) { if (listContainsItem(aFilter, aTileEntity1.getStackInSlot(aGrabSlot), true, aInvertFilter)) { - if (isAllowedToTakeFromSlot(aTileEntity1, aGrabSlot, (byte) aGrabFrom, aTileEntity1.getStackInSlot(aGrabSlot))) { - if (Math.max(aMinMoveAtOnce, aMinTargetStackSize) <= aTileEntity1.getStackInSlot(aGrabSlot).stackSize) { - ItemStack tStack = copyAmount(Math.min(aTileEntity1.getStackInSlot(aGrabSlot).stackSize, Math.min(aMaxMoveAtOnce, aMaxTargetStackSize)), aTileEntity1.getStackInSlot(aGrabSlot)); - ItemStack rStack = ((IItemDuct) aTileEntity2).insertItem(ForgeDirection.getOrientation(aPutTo), copyOrNull(tStack)); - byte tMovedItemCount = (byte) (tStack.stackSize - (rStack == null ? 0 : rStack.stackSize)); - if (tMovedItemCount >= 1/*Math.max(aMinMoveAtOnce, aMinTargetStackSize)*/) { - //((cofh.api.transport.IItemConduit)aTileEntity2).insertItem(ForgeDirection.getOrientation(aPutTo), copyAmount(tMovedItemCount, tStack), F); + if (isAllowedToTakeFromSlot( + aTileEntity1, aGrabSlot, (byte) aGrabFrom, aTileEntity1.getStackInSlot(aGrabSlot))) { + if (Math.max(aMinMoveAtOnce, aMinTargetStackSize) + <= aTileEntity1.getStackInSlot(aGrabSlot).stackSize) { + ItemStack tStack = copyAmount( + Math.min( + aTileEntity1.getStackInSlot(aGrabSlot).stackSize, + Math.min(aMaxMoveAtOnce, aMaxTargetStackSize)), + aTileEntity1.getStackInSlot(aGrabSlot)); + ItemStack rStack = ((IItemDuct) aTileEntity2) + .insertItem(ForgeDirection.getOrientation(aPutTo), copyOrNull(tStack)); + byte tMovedItemCount = + (byte) (tStack.stackSize - (rStack == null ? 0 : rStack.stackSize)); + if (tMovedItemCount >= 1 /*Math.max(aMinMoveAtOnce, aMinTargetStackSize)*/) { + // ((cofh.api.transport.IItemConduit)aTileEntity2).insertItem(ForgeDirection.getOrientation(aPutTo), copyAmount(tMovedItemCount, tStack), F); aTileEntity1.decrStackSize(aGrabSlot, tMovedItemCount); aTileEntity1.markDirty(); return tMovedItemCount; @@ -498,12 +587,23 @@ public class GT_Utility { if (BC_CHECK && aTileEntity2 instanceof buildcraft.api.transport.IPipeTile) { for (int aGrabSlot : aGrabSlots) { if (listContainsItem(aFilter, aTileEntity1.getStackInSlot(aGrabSlot), true, aInvertFilter)) { - if (isAllowedToTakeFromSlot(aTileEntity1, aGrabSlot, (byte) aGrabFrom, aTileEntity1.getStackInSlot(aGrabSlot))) { - if (Math.max(aMinMoveAtOnce, aMinTargetStackSize) <= aTileEntity1.getStackInSlot(aGrabSlot).stackSize) { - ItemStack tStack = copyAmount(Math.min(aTileEntity1.getStackInSlot(aGrabSlot).stackSize, Math.min(aMaxMoveAtOnce, aMaxTargetStackSize)), aTileEntity1.getStackInSlot(aGrabSlot)); - byte tMovedItemCount = (byte) ((buildcraft.api.transport.IPipeTile) aTileEntity2).injectItem(copyOrNull(tStack), false, ForgeDirection.getOrientation(aPutTo)); + if (isAllowedToTakeFromSlot( + aTileEntity1, aGrabSlot, (byte) aGrabFrom, aTileEntity1.getStackInSlot(aGrabSlot))) { + if (Math.max(aMinMoveAtOnce, aMinTargetStackSize) + <= aTileEntity1.getStackInSlot(aGrabSlot).stackSize) { + ItemStack tStack = copyAmount( + Math.min( + aTileEntity1.getStackInSlot(aGrabSlot).stackSize, + Math.min(aMaxMoveAtOnce, aMaxTargetStackSize)), + aTileEntity1.getStackInSlot(aGrabSlot)); + byte tMovedItemCount = (byte) ((buildcraft.api.transport.IPipeTile) aTileEntity2) + .injectItem(copyOrNull(tStack), false, ForgeDirection.getOrientation(aPutTo)); if (tMovedItemCount >= Math.max(aMinMoveAtOnce, aMinTargetStackSize)) { - tMovedItemCount = (byte) (((buildcraft.api.transport.IPipeTile) aTileEntity2).injectItem(copyAmount(tMovedItemCount, tStack), true, ForgeDirection.getOrientation(aPutTo))); + tMovedItemCount = (byte) (((buildcraft.api.transport.IPipeTile) aTileEntity2) + .injectItem( + copyAmount(tMovedItemCount, tStack), + true, + ForgeDirection.getOrientation(aPutTo))); aTileEntity1.decrStackSize(aGrabSlot, tMovedItemCount); aTileEntity1.markDirty(); return tMovedItemCount; @@ -517,15 +617,30 @@ public class GT_Utility { } ForgeDirection tDirection = ForgeDirection.getOrientation(aGrabFrom); - if (aTileEntity1 instanceof TileEntity && tDirection != ForgeDirection.UNKNOWN && tDirection.getOpposite() == ForgeDirection.getOrientation(aPutTo)) { - int tX = ((TileEntity) aTileEntity1).xCoord + tDirection.offsetX, tY = ((TileEntity) aTileEntity1).yCoord + tDirection.offsetY, tZ = ((TileEntity) aTileEntity1).zCoord + tDirection.offsetZ; + if (aTileEntity1 instanceof TileEntity + && tDirection != ForgeDirection.UNKNOWN + && tDirection.getOpposite() == ForgeDirection.getOrientation(aPutTo)) { + int tX = ((TileEntity) aTileEntity1).xCoord + tDirection.offsetX, + tY = ((TileEntity) aTileEntity1).yCoord + tDirection.offsetY, + tZ = ((TileEntity) aTileEntity1).zCoord + tDirection.offsetZ; if (!hasBlockHitBox(((TileEntity) aTileEntity1).getWorldObj(), tX, tY, tZ) && dropItem) { for (int aGrabSlot : aGrabSlots) { if (listContainsItem(aFilter, aTileEntity1.getStackInSlot(aGrabSlot), true, aInvertFilter)) { - if (isAllowedToTakeFromSlot(aTileEntity1, aGrabSlot, (byte) aGrabFrom, aTileEntity1.getStackInSlot(aGrabSlot))) { - if (Math.max(aMinMoveAtOnce, aMinTargetStackSize) <= aTileEntity1.getStackInSlot(aGrabSlot).stackSize) { - ItemStack tStack = copyAmount(Math.min(aTileEntity1.getStackInSlot(aGrabSlot).stackSize, Math.min(aMaxMoveAtOnce, aMaxTargetStackSize)), aTileEntity1.getStackInSlot(aGrabSlot)); - EntityItem tEntity = new EntityItem(((TileEntity) aTileEntity1).getWorldObj(), tX + 0.5, tY + 0.5, tZ + 0.5, tStack); + if (isAllowedToTakeFromSlot( + aTileEntity1, aGrabSlot, (byte) aGrabFrom, aTileEntity1.getStackInSlot(aGrabSlot))) { + if (Math.max(aMinMoveAtOnce, aMinTargetStackSize) + <= aTileEntity1.getStackInSlot(aGrabSlot).stackSize) { + ItemStack tStack = copyAmount( + Math.min( + aTileEntity1.getStackInSlot(aGrabSlot).stackSize, + Math.min(aMaxMoveAtOnce, aMaxTargetStackSize)), + aTileEntity1.getStackInSlot(aGrabSlot)); + EntityItem tEntity = new EntityItem( + ((TileEntity) aTileEntity1).getWorldObj(), + tX + 0.5, + tY + 0.5, + tZ + 0.5, + tStack); tEntity.motionX = tEntity.motionY = tEntity.motionZ = 0; ((TileEntity) aTileEntity1).getWorldObj().spawnEntityInWorld(tEntity); aTileEntity1.decrStackSize(aGrabSlot, tStack.stackSize); @@ -545,18 +660,42 @@ public class GT_Utility { * * @return the Amount of moved Items */ - public static byte moveStackFromSlotAToSlotB(IInventory aTileEntity1, IInventory aTileEntity2, int aGrabFrom, int aPutTo, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce) { - if (aTileEntity1 == null || aTileEntity2 == null || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0 || aMinTargetStackSize > aMaxTargetStackSize || aMaxMoveAtOnce <= 0 || aMinMoveAtOnce > aMaxMoveAtOnce) - return 0; - - ItemStack tStack1 = aTileEntity1.getStackInSlot(aGrabFrom), tStack2 = aTileEntity2.getStackInSlot(aPutTo), tStack3 = null; + public static byte moveStackFromSlotAToSlotB( + IInventory aTileEntity1, + IInventory aTileEntity2, + int aGrabFrom, + int aPutTo, + byte aMaxTargetStackSize, + byte aMinTargetStackSize, + byte aMaxMoveAtOnce, + byte aMinMoveAtOnce) { + if (aTileEntity1 == null + || aTileEntity2 == null + || aMaxTargetStackSize <= 0 + || aMinTargetStackSize <= 0 + || aMinTargetStackSize > aMaxTargetStackSize + || aMaxMoveAtOnce <= 0 + || aMinMoveAtOnce > aMaxMoveAtOnce) return 0; + + ItemStack tStack1 = aTileEntity1.getStackInSlot(aGrabFrom), + tStack2 = aTileEntity2.getStackInSlot(aPutTo), + tStack3 = null; if (tStack1 != null) { if (tStack2 != null && !areStacksEqual(tStack1, tStack2)) return 0; tStack3 = copyOrNull(tStack1); - aMaxTargetStackSize = (byte) Math.min(aMaxTargetStackSize, Math.min(tStack3.getMaxStackSize(), Math.min(tStack2 == null ? Integer.MAX_VALUE : tStack2.getMaxStackSize(), aTileEntity2.getInventoryStackLimit()))); - tStack3.stackSize = Math.min(tStack3.stackSize, aMaxTargetStackSize - (tStack2 == null ? 0 : tStack2.stackSize)); + aMaxTargetStackSize = (byte) Math.min( + aMaxTargetStackSize, + Math.min( + tStack3.getMaxStackSize(), + Math.min( + tStack2 == null ? Integer.MAX_VALUE : tStack2.getMaxStackSize(), + aTileEntity2.getInventoryStackLimit()))); + tStack3.stackSize = + Math.min(tStack3.stackSize, aMaxTargetStackSize - (tStack2 == null ? 0 : tStack2.stackSize)); if (tStack3.stackSize > aMaxMoveAtOnce) tStack3.stackSize = aMaxMoveAtOnce; - if (tStack3.stackSize + (tStack2 == null ? 0 : tStack2.stackSize) >= Math.min(tStack3.getMaxStackSize(), aMinTargetStackSize) && tStack3.stackSize >= aMinMoveAtOnce) { + if (tStack3.stackSize + (tStack2 == null ? 0 : tStack2.stackSize) + >= Math.min(tStack3.getMaxStackSize(), aMinTargetStackSize) + && tStack3.stackSize >= aMinMoveAtOnce) { tStack3 = aTileEntity1.decrStackSize(aGrabFrom, tStack3.stackSize); aTileEntity1.markDirty(); if (tStack3 != null) { @@ -587,7 +726,8 @@ public class GT_Utility { return true; } - public static boolean isAllowedToPutIntoSlot(IInventory aTileEntity, int aSlot, byte aSide, ItemStack aStack, byte aMaxStackSize) { + public static boolean isAllowedToPutIntoSlot( + IInventory aTileEntity, int aSlot, byte aSide, ItemStack aStack, byte aMaxStackSize) { ItemStack tStack = aTileEntity.getStackInSlot(aSlot); if (tStack != null && (!areStacksEqual(tStack, aStack) || tStack.stackSize >= tStack.getMaxStackSize())) return false; @@ -599,8 +739,8 @@ public class GT_Utility { || isAllowedToPutIntoSlot(aTileEntity, aSlot, (byte) 4, aStack, aMaxStackSize) || isAllowedToPutIntoSlot(aTileEntity, aSlot, (byte) 5, aStack, aMaxStackSize); } - if (aTileEntity instanceof ISidedInventory && !((ISidedInventory) aTileEntity).canInsertItem(aSlot, aStack, aSide)) - return false; + if (aTileEntity instanceof ISidedInventory + && !((ISidedInventory) aTileEntity).canInsertItem(aSlot, aStack, aSide)) return false; return aSlot < aTileEntity.getSizeInventory() && aTileEntity.isItemValidForSlot(aSlot, aStack); } @@ -609,31 +749,70 @@ public class GT_Utility { * * @return the Amount of moved Items */ - - public static int moveMultipleItemStacks(Object aTileEntity1, Object aTileEntity2, byte aGrabFrom, byte aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce,int aStackAmount) { - if (aTileEntity1 instanceof IInventory) - return moveMultipleItemStacks((IInventory) aTileEntity1, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce,aStackAmount, true); + public static int moveMultipleItemStacks( + Object aTileEntity1, + Object aTileEntity2, + byte aGrabFrom, + byte aPutTo, + List<ItemStack> aFilter, + boolean aInvertFilter, + byte aMaxTargetStackSize, + byte aMinTargetStackSize, + byte aMaxMoveAtOnce, + byte aMinMoveAtOnce, + int aStackAmount) { + if (aTileEntity1 instanceof IInventory) + return moveMultipleItemStacks( + (IInventory) aTileEntity1, + aTileEntity2, + aGrabFrom, + aPutTo, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + aStackAmount, + true); return 0; } - public static int moveMultipleItemStacks(IInventory aTileEntity1, Object aTileEntity2, byte aGrabFrom, byte aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce,int aMaxStackTransfer, boolean aDoCheckChests) { - if (aTileEntity1 == null || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0 || aMaxMoveAtOnce <= 0 || aMinTargetStackSize > aMaxTargetStackSize || aMinMoveAtOnce > aMaxMoveAtOnce || aMaxStackTransfer == 0) - return 0; + public static int moveMultipleItemStacks( + IInventory aTileEntity1, + Object aTileEntity2, + byte aGrabFrom, + byte aPutTo, + List<ItemStack> aFilter, + boolean aInvertFilter, + byte aMaxTargetStackSize, + byte aMinTargetStackSize, + byte aMaxMoveAtOnce, + byte aMinMoveAtOnce, + int aMaxStackTransfer, + boolean aDoCheckChests) { + if (aTileEntity1 == null + || aMaxTargetStackSize <= 0 + || aMinTargetStackSize <= 0 + || aMaxMoveAtOnce <= 0 + || aMinTargetStackSize > aMaxTargetStackSize + || aMinMoveAtOnce > aMaxMoveAtOnce + || aMaxStackTransfer == 0) return 0; // find where to take from int[] tGrabSlots = new int[aTileEntity1.getSizeInventory()]; int tGrabSlotsSize = 0; if (aTileEntity1 instanceof ISidedInventory) { - for(int i : ((ISidedInventory) aTileEntity1).getAccessibleSlotsFromSide(aGrabFrom)) { + for (int i : ((ISidedInventory) aTileEntity1).getAccessibleSlotsFromSide(aGrabFrom)) { ItemStack s = aTileEntity1.getStackInSlot(i); - if (s == null || !isAllowedToTakeFromSlot(aTileEntity1, i, aGrabFrom, s) || s.stackSize < aMinMoveAtOnce || !listContainsItem(aFilter, s, true, aInvertFilter)) - continue; + if (s == null + || !isAllowedToTakeFromSlot(aTileEntity1, i, aGrabFrom, s) + || s.stackSize < aMinMoveAtOnce + || !listContainsItem(aFilter, s, true, aInvertFilter)) continue; tGrabSlots[tGrabSlotsSize++] = i; } - } - else { - for (int i = 0; i < tGrabSlots.length; i++) - { + } else { + for (int i = 0; i < tGrabSlots.length; i++) { ItemStack s = aTileEntity1.getStackInSlot(i); if (s == null || s.stackSize < aMinMoveAtOnce || !listContainsItem(aFilter, s, true, aInvertFilter)) continue; @@ -642,10 +821,21 @@ public class GT_Utility { } // no source, bail out - if(tGrabSlotsSize == 0) { + if (tGrabSlotsSize == 0) { // maybe source is a double chest. check it if (aDoCheckChests && aTileEntity1 instanceof TileEntityChest) - return moveFromAdjacentChests((TileEntityChest) aTileEntity1, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, aMaxStackTransfer); + return moveFromAdjacentChests( + (TileEntityChest) aTileEntity1, + aTileEntity2, + aGrabFrom, + aPutTo, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + aMaxStackTransfer); return 0; } @@ -667,32 +857,45 @@ public class GT_Utility { accessibleSlots = ((ISidedInventory) tPutInventory).getAccessibleSlotsFromSide(aPutTo); for (int i = 0; i < tPutInventory.getSizeInventory(); i++) { int slot = i; - if(accessibleSlots != null) - { - if(accessibleSlots.length <= i) - break; + if (accessibleSlots != null) { + if (accessibleSlots.length <= i) break; slot = accessibleSlots[slot]; } ItemStack s = tPutInventory.getStackInSlot(slot); - if(s == null) { + if (s == null) { tPutFreeSlots.add(slot); - } else if((s.stackSize < s.getMaxStackSize() && s.stackSize < tPutInventory.getInventoryStackLimit()) && aMinMoveAtOnce <= s.getMaxStackSize() - s.stackSize) { + } else if ((s.stackSize < s.getMaxStackSize() && s.stackSize < tPutInventory.getInventoryStackLimit()) + && aMinMoveAtOnce <= s.getMaxStackSize() - s.stackSize) { ItemId sID = ItemId.createNoCopy(s); - tPutItems.merge(sID, (Math.min(s.getMaxStackSize(), tPutInventory.getInventoryStackLimit()) - s.stackSize), Integer::sum); + tPutItems.merge( + sID, + (Math.min(s.getMaxStackSize(), tPutInventory.getInventoryStackLimit()) - s.stackSize), + Integer::sum); tPutItemStacks.computeIfAbsent(sID, k -> new ArrayList<>()).add(s); } } // target completely filled, bail out - if(tPutItems.isEmpty() && tPutFreeSlots.isEmpty()) { + if (tPutItems.isEmpty() && tPutFreeSlots.isEmpty()) { // maybe target is a double chest. check it. if (aDoCheckChests && aTileEntity2 instanceof TileEntityChest) - return moveToAdjacentChests(aTileEntity1, (TileEntityChest) aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, aMaxStackTransfer); + return moveToAdjacentChests( + aTileEntity1, + (TileEntityChest) aTileEntity2, + aGrabFrom, + aPutTo, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + aMaxStackTransfer); return 0; } // go over source stacks one by one - int tStacksMoved = 0,tTotalItemsMoved = 0; + int tStacksMoved = 0, tTotalItemsMoved = 0; for (int j = 0; j < tGrabSlotsSize; j++) { int grabSlot = tGrabSlots[j]; int tMovedItems; @@ -700,8 +903,7 @@ public class GT_Utility { do { tMovedItems = 0; ItemStack tGrabStack = aTileEntity1.getStackInSlot(grabSlot); - if (tGrabStack == null) - break; + if (tGrabStack == null) break; tStackSize = tGrabStack.stackSize; ItemId sID = ItemId.createNoCopy(tGrabStack); @@ -716,22 +918,23 @@ public class GT_Utility { tMovedItems = toPut; for (int i = 0; i < putStack.size(); i++) { ItemStack s = putStack.get(i); - int sToPut = Math.min(Math.min(Math.min(toPut, s.getMaxStackSize() - s.stackSize), tPutInventory.getInventoryStackLimit() - s.stackSize), aMaxTargetStackSize - s.stackSize); - if (sToPut <= 0) - continue; - if (sToPut < aMinMoveAtOnce) - continue; - if (s.stackSize + sToPut < aMinTargetStackSize) - continue; + int sToPut = Math.min( + Math.min( + Math.min(toPut, s.getMaxStackSize() - s.stackSize), + tPutInventory.getInventoryStackLimit() - s.stackSize), + aMaxTargetStackSize - s.stackSize); + if (sToPut <= 0) continue; + if (sToPut < aMinMoveAtOnce) continue; + if (s.stackSize + sToPut < aMinTargetStackSize) continue; toPut -= sToPut; s.stackSize += sToPut; - if (s.stackSize == s.getMaxStackSize() || s.stackSize == tPutInventory.getInventoryStackLimit()) { + if (s.stackSize == s.getMaxStackSize() + || s.stackSize == tPutInventory.getInventoryStackLimit()) { // this slot is full. remove this stack from candidate list putStack.remove(i); i--; } - if (toPut == 0) - break; + if (toPut == 0) break; } tMovedItems -= toPut; if (tMovedItems > 0) { @@ -740,10 +943,8 @@ public class GT_Utility { // deduct spare space tPutItems.merge(sID, tMovedItems, (a, b) -> a.equals(b) ? null : a - b); - if (tStackSize == 0) - aTileEntity1.setInventorySlotContents(grabSlot, null); - else - tGrabStack.stackSize = tStackSize; + if (tStackSize == 0) aTileEntity1.setInventorySlotContents(grabSlot, null); + else tGrabStack.stackSize = tStackSize; aTileEntity1.markDirty(); tPutInventory.markDirty(); @@ -757,19 +958,31 @@ public class GT_Utility { int tPutSlot = tPutFreeSlots.get(i); if (isAllowedToPutIntoSlot(tPutInventory, tPutSlot, aPutTo, tGrabStack, (byte) 64)) { // allowed, now do moving - int tMoved = moveStackFromSlotAToSlotB(aTileEntity1, tPutInventory, grabSlot, tPutSlot, aMaxTargetStackSize, aMinTargetStackSize, (byte) (aMaxMoveAtOnce - tMovedItems), aMinMoveAtOnce); + int tMoved = moveStackFromSlotAToSlotB( + aTileEntity1, + tPutInventory, + grabSlot, + tPutSlot, + aMaxTargetStackSize, + aMinTargetStackSize, + (byte) (aMaxMoveAtOnce - tMovedItems), + aMinMoveAtOnce); if (tMoved > 0) { ItemStack s = tPutInventory.getStackInSlot(tPutSlot); if (s != null) { // s might be null if tPutInventory is very special, e.g. infinity chest // if s is null, we will not mark this slot as target candidate for anything - int spare = Math.min(s.getMaxStackSize(), tPutInventory.getInventoryStackLimit()) - s.stackSize; + int spare = + Math.min(s.getMaxStackSize(), tPutInventory.getInventoryStackLimit()) + - s.stackSize; if (spare > 0) { ItemId ssID = ItemId.createNoCopy(s); // add back to spare space count tPutItems.merge(ssID, spare, Integer::sum); // add to partially filled slot list - tPutItemStacks.computeIfAbsent(ssID, k -> new ArrayList<>()).add(s); + tPutItemStacks + .computeIfAbsent(ssID, k -> new ArrayList<>()) + .add(s); } // this is no longer free tPutFreeSlots.remove(i); @@ -780,8 +993,7 @@ public class GT_Utility { tTotalItemsMoved += tMoved; tMovedItems += tMoved; tStackSize -= tMoved; - if (tStackSize == 0) - break; + if (tStackSize == 0) break; } } } @@ -789,22 +1001,44 @@ public class GT_Utility { if (tMovedItems > 0) { // check if we have moved enough stacks - if (++tStacksMoved >= aMaxStackTransfer) - return tTotalItemsMoved; + if (++tStacksMoved >= aMaxStackTransfer) return tTotalItemsMoved; } - } while (tMovedItems > 0 && tStackSize > 0); //support inventories that store more than a stack in a slot + } while (tMovedItems > 0 + && tStackSize > 0); // support inventories that store more than a stack in a slot } // check if source is a double chest, if yes, try move from the adjacent as well if (aDoCheckChests && aTileEntity1 instanceof TileEntityChest) { - int tAmount = moveFromAdjacentChests((TileEntityChest) aTileEntity1, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, aMaxStackTransfer - tStacksMoved); - if (tAmount != 0) return tAmount+tTotalItemsMoved; + int tAmount = moveFromAdjacentChests( + (TileEntityChest) aTileEntity1, + aTileEntity2, + aGrabFrom, + aPutTo, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + aMaxStackTransfer - tStacksMoved); + if (tAmount != 0) return tAmount + tTotalItemsMoved; } // check if target is a double chest, if yes, try move to the adjacent as well if (aDoCheckChests && aTileEntity2 instanceof TileEntityChest) { - int tAmount = moveToAdjacentChests(aTileEntity1, (TileEntityChest) aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, aMaxStackTransfer - tStacksMoved); - if (tAmount != 0) return tAmount+tTotalItemsMoved; + int tAmount = moveToAdjacentChests( + aTileEntity1, + (TileEntityChest) aTileEntity2, + aGrabFrom, + aPutTo, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + aMaxStackTransfer - tStacksMoved); + if (tAmount != 0) return tAmount + tTotalItemsMoved; } return tTotalItemsMoved; @@ -814,61 +1048,224 @@ public class GT_Utility { int tTotalItemsMoved = 0; int tGrabInventorySize = tGrabSlots.length; for (int i = 0; i < tGrabInventorySize; i++) { - int tMoved = moveStackIntoPipe(aTileEntity1, aTileEntity2, tGrabSlots, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, aDoCheckChests); - if (tMoved == 0) - return tTotalItemsMoved; - else - tTotalItemsMoved += tMoved; + int tMoved = moveStackIntoPipe( + aTileEntity1, + aTileEntity2, + tGrabSlots, + aGrabFrom, + aPutTo, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + aDoCheckChests); + if (tMoved == 0) return tTotalItemsMoved; + else tTotalItemsMoved += tMoved; } - return 0; + return 0; } - private static int moveToAdjacentChests(IInventory aTileEntity1, TileEntityChest aTargetChest, byte aGrabFrom, byte aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce, int aMaxStackTransfer) { + private static int moveToAdjacentChests( + IInventory aTileEntity1, + TileEntityChest aTargetChest, + byte aGrabFrom, + byte aPutTo, + List<ItemStack> aFilter, + boolean aInvertFilter, + byte aMaxTargetStackSize, + byte aMinTargetStackSize, + byte aMaxMoveAtOnce, + byte aMinMoveAtOnce, + int aMaxStackTransfer) { if (aTargetChest.adjacentChestChecked) { if (aTargetChest.adjacentChestXNeg != null) { - return moveMultipleItemStacks(aTileEntity1, aTargetChest.adjacentChestXNeg, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, aMaxStackTransfer, false); + return moveMultipleItemStacks( + aTileEntity1, + aTargetChest.adjacentChestXNeg, + aGrabFrom, + aPutTo, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + aMaxStackTransfer, + false); } else if (aTargetChest.adjacentChestZNeg != null) { - return moveMultipleItemStacks(aTileEntity1, aTargetChest.adjacentChestZNeg, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, aMaxStackTransfer, false); + return moveMultipleItemStacks( + aTileEntity1, + aTargetChest.adjacentChestZNeg, + aGrabFrom, + aPutTo, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + aMaxStackTransfer, + false); } else if (aTargetChest.adjacentChestXPos != null) { - return moveMultipleItemStacks(aTileEntity1, aTargetChest.adjacentChestXPos, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, aMaxStackTransfer, false); + return moveMultipleItemStacks( + aTileEntity1, + aTargetChest.adjacentChestXPos, + aGrabFrom, + aPutTo, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + aMaxStackTransfer, + false); } else if (aTargetChest.adjacentChestZPos != null) { - return moveMultipleItemStacks(aTileEntity1, aTargetChest.adjacentChestZPos, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, aMaxStackTransfer, false); + return moveMultipleItemStacks( + aTileEntity1, + aTargetChest.adjacentChestZPos, + aGrabFrom, + aPutTo, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + aMaxStackTransfer, + false); } } return 0; } - private static int moveFromAdjacentChests(TileEntityChest aChest, Object aTileEntity2, byte aGrabFrom, byte aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce, int aMaxStackTransfer) { + private static int moveFromAdjacentChests( + TileEntityChest aChest, + Object aTileEntity2, + byte aGrabFrom, + byte aPutTo, + List<ItemStack> aFilter, + boolean aInvertFilter, + byte aMaxTargetStackSize, + byte aMinTargetStackSize, + byte aMaxMoveAtOnce, + byte aMinMoveAtOnce, + int aMaxStackTransfer) { if (aChest.adjacentChestXNeg != null) { - return moveMultipleItemStacks(aChest.adjacentChestXNeg, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, aMaxStackTransfer, false); + return moveMultipleItemStacks( + aChest.adjacentChestXNeg, + aTileEntity2, + aGrabFrom, + aPutTo, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + aMaxStackTransfer, + false); } else if (aChest.adjacentChestZNeg != null) { - return moveMultipleItemStacks(aChest.adjacentChestZNeg, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, aMaxStackTransfer, false); + return moveMultipleItemStacks( + aChest.adjacentChestZNeg, + aTileEntity2, + aGrabFrom, + aPutTo, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + aMaxStackTransfer, + false); } else if (aChest.adjacentChestXPos != null) { - return moveMultipleItemStacks(aChest.adjacentChestXPos, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, aMaxStackTransfer, false); + return moveMultipleItemStacks( + aChest.adjacentChestXPos, + aTileEntity2, + aGrabFrom, + aPutTo, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + aMaxStackTransfer, + false); } else if (aChest.adjacentChestZPos != null) { - return moveMultipleItemStacks(aChest.adjacentChestZPos, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, aMaxStackTransfer, false); + return moveMultipleItemStacks( + aChest.adjacentChestZPos, + aTileEntity2, + aGrabFrom, + aPutTo, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + aMaxStackTransfer, + false); } return 0; } - /** * Moves Stack from Inv-Side to Inv-Side. * * @return the Amount of moved Items */ - public static byte moveOneItemStack(Object aTileEntity1, Object aTileEntity2, byte aGrabFrom, byte aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce) { + public static byte moveOneItemStack( + Object aTileEntity1, + Object aTileEntity2, + byte aGrabFrom, + byte aPutTo, + List<ItemStack> aFilter, + boolean aInvertFilter, + byte aMaxTargetStackSize, + byte aMinTargetStackSize, + byte aMaxMoveAtOnce, + byte aMinMoveAtOnce) { if (aTileEntity1 instanceof IInventory) - return moveOneItemStack((IInventory) aTileEntity1, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, true); + return moveOneItemStack( + (IInventory) aTileEntity1, + aTileEntity2, + aGrabFrom, + aPutTo, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + true); return 0; } /** * This is only because I needed an additional Parameter for the Double Chest Check. */ - private static byte moveOneItemStack(IInventory aTileEntity1, Object aTileEntity2, byte aGrabFrom, byte aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce, boolean aDoCheckChests) { - if (aTileEntity1 == null || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0 || aMaxMoveAtOnce <= 0 || aMinTargetStackSize > aMaxTargetStackSize || aMinMoveAtOnce > aMaxMoveAtOnce) - return 0; + private static byte moveOneItemStack( + IInventory aTileEntity1, + Object aTileEntity2, + byte aGrabFrom, + byte aPutTo, + List<ItemStack> aFilter, + boolean aInvertFilter, + byte aMaxTargetStackSize, + byte aMinTargetStackSize, + byte aMaxMoveAtOnce, + byte aMinMoveAtOnce, + boolean aDoCheckChests) { + if (aTileEntity1 == null + || aMaxTargetStackSize <= 0 + || aMinTargetStackSize <= 0 + || aMaxMoveAtOnce <= 0 + || aMinTargetStackSize > aMaxTargetStackSize + || aMinMoveAtOnce > aMaxMoveAtOnce) return 0; int[] tGrabSlots = null; if (aTileEntity1 instanceof ISidedInventory) @@ -892,12 +1289,22 @@ public class GT_Utility { byte tMovedItemCount = 0; ItemStack tGrabStack = aTileEntity1.getStackInSlot(tGrabSlot); if (listContainsItem(aFilter, tGrabStack, true, aInvertFilter)) { - if (tGrabStack.stackSize >= aMinMoveAtOnce && isAllowedToTakeFromSlot(aTileEntity1, tGrabSlot, aGrabFrom, tGrabStack)) { + if (tGrabStack.stackSize >= aMinMoveAtOnce + && isAllowedToTakeFromSlot(aTileEntity1, tGrabSlot, aGrabFrom, tGrabStack)) { for (int tPutSlot : tPutSlots) { - if (isAllowedToPutIntoSlot((IInventory) aTileEntity2, tPutSlot, aPutTo, tGrabStack, aMaxTargetStackSize)) { - tMovedItemCount += moveStackFromSlotAToSlotB(aTileEntity1, (IInventory) aTileEntity2, tGrabSlot, tPutSlot, aMaxTargetStackSize, aMinTargetStackSize, (byte) (aMaxMoveAtOnce - tMovedItemCount), aMinMoveAtOnce); - if (tMovedItemCount >= aMaxMoveAtOnce || (tMovedItemCount > 0 && aMaxTargetStackSize < 64)) - return tMovedItemCount; + if (isAllowedToPutIntoSlot( + (IInventory) aTileEntity2, tPutSlot, aPutTo, tGrabStack, aMaxTargetStackSize)) { + tMovedItemCount += moveStackFromSlotAToSlotB( + aTileEntity1, + (IInventory) aTileEntity2, + tGrabSlot, + tPutSlot, + aMaxTargetStackSize, + aMinTargetStackSize, + (byte) (aMaxMoveAtOnce - tMovedItemCount), + aMinMoveAtOnce); + if (tMovedItemCount >= aMaxMoveAtOnce + || (tMovedItemCount > 0 && aMaxTargetStackSize < 64)) return tMovedItemCount; } } } @@ -910,13 +1317,57 @@ public class GT_Utility { if (tTileEntity1.adjacentChestChecked) { byte tAmount = 0; if (tTileEntity1.adjacentChestXNeg != null) { - tAmount = moveOneItemStack(tTileEntity1.adjacentChestXNeg, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false); + tAmount = moveOneItemStack( + tTileEntity1.adjacentChestXNeg, + aTileEntity2, + aGrabFrom, + aPutTo, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + false); } else if (tTileEntity1.adjacentChestZNeg != null) { - tAmount = moveOneItemStack(tTileEntity1.adjacentChestZNeg, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false); + tAmount = moveOneItemStack( + tTileEntity1.adjacentChestZNeg, + aTileEntity2, + aGrabFrom, + aPutTo, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + false); } else if (tTileEntity1.adjacentChestXPos != null) { - tAmount = moveOneItemStack(tTileEntity1.adjacentChestXPos, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false); + tAmount = moveOneItemStack( + tTileEntity1.adjacentChestXPos, + aTileEntity2, + aGrabFrom, + aPutTo, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + false); } else if (tTileEntity1.adjacentChestZPos != null) { - tAmount = moveOneItemStack(tTileEntity1.adjacentChestZPos, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false); + tAmount = moveOneItemStack( + tTileEntity1.adjacentChestZPos, + aTileEntity2, + aGrabFrom, + aPutTo, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + false); } if (tAmount != 0) return tAmount; } @@ -926,20 +1377,76 @@ public class GT_Utility { if (tTileEntity2.adjacentChestChecked) { byte tAmount = 0; if (tTileEntity2.adjacentChestXNeg != null) { - tAmount = moveOneItemStack(aTileEntity1, tTileEntity2.adjacentChestXNeg, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false); + tAmount = moveOneItemStack( + aTileEntity1, + tTileEntity2.adjacentChestXNeg, + aGrabFrom, + aPutTo, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + false); } else if (tTileEntity2.adjacentChestZNeg != null) { - tAmount = moveOneItemStack(aTileEntity1, tTileEntity2.adjacentChestZNeg, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false); + tAmount = moveOneItemStack( + aTileEntity1, + tTileEntity2.adjacentChestZNeg, + aGrabFrom, + aPutTo, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + false); } else if (tTileEntity2.adjacentChestXPos != null) { - tAmount = moveOneItemStack(aTileEntity1, tTileEntity2.adjacentChestXPos, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false); + tAmount = moveOneItemStack( + aTileEntity1, + tTileEntity2.adjacentChestXPos, + aGrabFrom, + aPutTo, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + false); } else if (tTileEntity2.adjacentChestZPos != null) { - tAmount = moveOneItemStack(aTileEntity1, tTileEntity2.adjacentChestZPos, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false); + tAmount = moveOneItemStack( + aTileEntity1, + tTileEntity2.adjacentChestZPos, + aGrabFrom, + aPutTo, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + false); } if (tAmount != 0) return tAmount; } } } - return moveStackIntoPipe(aTileEntity1, aTileEntity2, tGrabSlots, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, aDoCheckChests); + return moveStackIntoPipe( + aTileEntity1, + aTileEntity2, + tGrabSlots, + aGrabFrom, + aPutTo, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + aDoCheckChests); } /** @@ -947,9 +1454,25 @@ public class GT_Utility { * * @return the Amount of moved Items */ - public static byte moveOneItemStackIntoSlot(Object aTileEntity1, Object aTileEntity2, byte aGrabFrom, int aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce) { - if (aTileEntity1 == null || !(aTileEntity1 instanceof IInventory) || aPutTo < 0 || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0 || aMaxMoveAtOnce <= 0 || aMinTargetStackSize > aMaxTargetStackSize || aMinMoveAtOnce > aMaxMoveAtOnce) - return 0; + public static byte moveOneItemStackIntoSlot( + Object aTileEntity1, + Object aTileEntity2, + byte aGrabFrom, + int aPutTo, + List<ItemStack> aFilter, + boolean aInvertFilter, + byte aMaxTargetStackSize, + byte aMinTargetStackSize, + byte aMaxMoveAtOnce, + byte aMinMoveAtOnce) { + if (aTileEntity1 == null + || !(aTileEntity1 instanceof IInventory) + || aPutTo < 0 + || aMaxTargetStackSize <= 0 + || aMinTargetStackSize <= 0 + || aMaxMoveAtOnce <= 0 + || aMinTargetStackSize > aMaxTargetStackSize + || aMinMoveAtOnce > aMaxMoveAtOnce) return 0; int[] tGrabSlots = null; if (aTileEntity1 instanceof ISidedInventory) @@ -961,10 +1484,28 @@ public class GT_Utility { if (aTileEntity2 instanceof IInventory) { for (int tGrabSlot : tGrabSlots) { - if (listContainsItem(aFilter, ((IInventory) aTileEntity1).getStackInSlot(tGrabSlot), true, aInvertFilter)) { - if (isAllowedToTakeFromSlot((IInventory) aTileEntity1, tGrabSlot, aGrabFrom, ((IInventory) aTileEntity1).getStackInSlot(tGrabSlot))) { - if (isAllowedToPutIntoSlot((IInventory) aTileEntity2, aPutTo, (byte) 6, ((IInventory) aTileEntity1).getStackInSlot(tGrabSlot), aMaxTargetStackSize)) { - byte tMovedItemCount = moveStackFromSlotAToSlotB((IInventory) aTileEntity1, (IInventory) aTileEntity2, tGrabSlot, aPutTo, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce); + if (listContainsItem( + aFilter, ((IInventory) aTileEntity1).getStackInSlot(tGrabSlot), true, aInvertFilter)) { + if (isAllowedToTakeFromSlot( + (IInventory) aTileEntity1, + tGrabSlot, + aGrabFrom, + ((IInventory) aTileEntity1).getStackInSlot(tGrabSlot))) { + if (isAllowedToPutIntoSlot( + (IInventory) aTileEntity2, + aPutTo, + (byte) 6, + ((IInventory) aTileEntity1).getStackInSlot(tGrabSlot), + aMaxTargetStackSize)) { + byte tMovedItemCount = moveStackFromSlotAToSlotB( + (IInventory) aTileEntity1, + (IInventory) aTileEntity2, + tGrabSlot, + aPutTo, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce); if (tMovedItemCount > 0) return tMovedItemCount; } } @@ -972,7 +1513,18 @@ public class GT_Utility { } } - moveStackIntoPipe(((IInventory) aTileEntity1), aTileEntity2, tGrabSlots, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce); + moveStackIntoPipe( + ((IInventory) aTileEntity1), + aTileEntity2, + tGrabSlots, + aGrabFrom, + aPutTo, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce); return 0; } @@ -981,13 +1533,39 @@ public class GT_Utility { * * @return the Amount of moved Items */ - public static byte moveFromSlotToSlot(IInventory aTileEntity1, IInventory aTileEntity2, int aGrabFrom, int aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce) { - if (aTileEntity1 == null || aTileEntity2 == null || aGrabFrom < 0 || aPutTo < 0 || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0 || aMaxMoveAtOnce <= 0 || aMinTargetStackSize > aMaxTargetStackSize || aMinMoveAtOnce > aMaxMoveAtOnce) - return 0; + public static byte moveFromSlotToSlot( + IInventory aTileEntity1, + IInventory aTileEntity2, + int aGrabFrom, + int aPutTo, + List<ItemStack> aFilter, + boolean aInvertFilter, + byte aMaxTargetStackSize, + byte aMinTargetStackSize, + byte aMaxMoveAtOnce, + byte aMinMoveAtOnce) { + if (aTileEntity1 == null + || aTileEntity2 == null + || aGrabFrom < 0 + || aPutTo < 0 + || aMaxTargetStackSize <= 0 + || aMinTargetStackSize <= 0 + || aMaxMoveAtOnce <= 0 + || aMinTargetStackSize > aMaxTargetStackSize + || aMinMoveAtOnce > aMaxMoveAtOnce) return 0; if (listContainsItem(aFilter, aTileEntity1.getStackInSlot(aGrabFrom), true, aInvertFilter)) { if (isAllowedToTakeFromSlot(aTileEntity1, aGrabFrom, (byte) 6, aTileEntity1.getStackInSlot(aGrabFrom))) { - if (isAllowedToPutIntoSlot(aTileEntity2, aPutTo, (byte) 6, aTileEntity1.getStackInSlot(aGrabFrom), aMaxTargetStackSize)) { - byte tMovedItemCount = moveStackFromSlotAToSlotB(aTileEntity1, aTileEntity2, aGrabFrom, aPutTo, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce); + if (isAllowedToPutIntoSlot( + aTileEntity2, aPutTo, (byte) 6, aTileEntity1.getStackInSlot(aGrabFrom), aMaxTargetStackSize)) { + byte tMovedItemCount = moveStackFromSlotAToSlotB( + aTileEntity1, + aTileEntity2, + aGrabFrom, + aPutTo, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce); if (tMovedItemCount > 0) return tMovedItemCount; } } @@ -1000,12 +1578,27 @@ public class GT_Utility { * * @return the Amount of moved Items */ - public static byte moveFromSlotToSide(IInventory fromTile, Object toTile, int aGrabFrom, byte aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce, boolean aDoCheckChests) { - if (fromTile == null || aGrabFrom < 0 || aMinTargetStackSize <= 0 || aMaxMoveAtOnce <= 0 || aMinTargetStackSize > aMaxTargetStackSize || aMinMoveAtOnce > aMaxMoveAtOnce) - return 0; - - if (!listContainsItem(aFilter, fromTile.getStackInSlot(aGrabFrom), true, aInvertFilter) || - !isAllowedToTakeFromSlot(fromTile, aGrabFrom, (byte) 6, fromTile.getStackInSlot(aGrabFrom))) + public static byte moveFromSlotToSide( + IInventory fromTile, + Object toTile, + int aGrabFrom, + byte aPutTo, + List<ItemStack> aFilter, + boolean aInvertFilter, + byte aMaxTargetStackSize, + byte aMinTargetStackSize, + byte aMaxMoveAtOnce, + byte aMinMoveAtOnce, + boolean aDoCheckChests) { + if (fromTile == null + || aGrabFrom < 0 + || aMinTargetStackSize <= 0 + || aMaxMoveAtOnce <= 0 + || aMinTargetStackSize > aMaxTargetStackSize + || aMinMoveAtOnce > aMaxMoveAtOnce) return 0; + + if (!listContainsItem(aFilter, fromTile.getStackInSlot(aGrabFrom), true, aInvertFilter) + || !isAllowedToTakeFromSlot(fromTile, aGrabFrom, (byte) 6, fromTile.getStackInSlot(aGrabFrom))) return 0; if (toTile instanceof IInventory) { @@ -1020,11 +1613,23 @@ public class GT_Utility { byte tMovedItemCount = 0; for (int tPutSlot : tPutSlots) { - if (isAllowedToPutIntoSlot((IInventory) toTile, tPutSlot, aPutTo, fromTile.getStackInSlot(aGrabFrom), aMaxTargetStackSize)) { - tMovedItemCount += moveStackFromSlotAToSlotB(fromTile, (IInventory) toTile, aGrabFrom, tPutSlot, aMaxTargetStackSize, aMinTargetStackSize, (byte) (aMaxMoveAtOnce - tMovedItemCount), aMinMoveAtOnce); + if (isAllowedToPutIntoSlot( + (IInventory) toTile, + tPutSlot, + aPutTo, + fromTile.getStackInSlot(aGrabFrom), + aMaxTargetStackSize)) { + tMovedItemCount += moveStackFromSlotAToSlotB( + fromTile, + (IInventory) toTile, + aGrabFrom, + tPutSlot, + aMaxTargetStackSize, + aMinTargetStackSize, + (byte) (aMaxMoveAtOnce - tMovedItemCount), + aMinMoveAtOnce); if (tMovedItemCount >= aMaxMoveAtOnce) { return tMovedItemCount; - } } } @@ -1034,26 +1639,104 @@ public class GT_Utility { TileEntityChest tTileEntity2 = (TileEntityChest) toTile; if (tTileEntity2.adjacentChestChecked) { if (tTileEntity2.adjacentChestXNeg != null) { - tMovedItemCount = moveFromSlotToSide(fromTile, tTileEntity2.adjacentChestXNeg, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false); + tMovedItemCount = moveFromSlotToSide( + fromTile, + tTileEntity2.adjacentChestXNeg, + aGrabFrom, + aPutTo, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + false); } else if (tTileEntity2.adjacentChestZNeg != null) { - tMovedItemCount = moveFromSlotToSide(fromTile, tTileEntity2.adjacentChestZNeg, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false); + tMovedItemCount = moveFromSlotToSide( + fromTile, + tTileEntity2.adjacentChestZNeg, + aGrabFrom, + aPutTo, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + false); } else if (tTileEntity2.adjacentChestXPos != null) { - tMovedItemCount = moveFromSlotToSide(fromTile, tTileEntity2.adjacentChestXPos, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false); + tMovedItemCount = moveFromSlotToSide( + fromTile, + tTileEntity2.adjacentChestXPos, + aGrabFrom, + aPutTo, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + false); } else if (tTileEntity2.adjacentChestZPos != null) { - tMovedItemCount = moveFromSlotToSide(fromTile, tTileEntity2.adjacentChestZPos, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false); + tMovedItemCount = moveFromSlotToSide( + fromTile, + tTileEntity2.adjacentChestZPos, + aGrabFrom, + aPutTo, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + false); } if (tMovedItemCount > 0) return tMovedItemCount; } } } - return moveStackIntoPipe(fromTile, toTile, new int[]{aGrabFrom}, (byte) 6, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, aDoCheckChests); - } - - public static byte moveFromSlotToSide(IInventory fromTile, Object toTile, int aGrabFrom, byte aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce) { - return moveFromSlotToSide(fromTile, toTile, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, true); - } - - public static boolean listContainsItem(Collection<ItemStack> aList, ItemStack aStack, boolean aTIfListEmpty, boolean aInvertFilter) { + return moveStackIntoPipe( + fromTile, + toTile, + new int[] {aGrabFrom}, + (byte) 6, + aPutTo, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + aDoCheckChests); + } + + public static byte moveFromSlotToSide( + IInventory fromTile, + Object toTile, + int aGrabFrom, + byte aPutTo, + List<ItemStack> aFilter, + boolean aInvertFilter, + byte aMaxTargetStackSize, + byte aMinTargetStackSize, + byte aMaxMoveAtOnce, + byte aMinMoveAtOnce) { + return moveFromSlotToSide( + fromTile, + toTile, + aGrabFrom, + aPutTo, + aFilter, + aInvertFilter, + aMaxTargetStackSize, + aMinTargetStackSize, + aMaxMoveAtOnce, + aMinMoveAtOnce, + true); + } + + public static boolean listContainsItem( + Collection<ItemStack> aList, ItemStack aStack, boolean aTIfListEmpty, boolean aInvertFilter) { if (aStack == null || aStack.stackSize < 1) return false; if (aList == null) return aTIfListEmpty; boolean tEmpty = true; @@ -1071,7 +1754,12 @@ public class GT_Utility { public static boolean areStacksOrToolsEqual(ItemStack aStack1, ItemStack aStack2) { if (aStack1 != null && aStack2 != null && aStack1.getItem() == aStack2.getItem()) { if (aStack1.getItem().isDamageable()) return true; - return ((aStack1.getTagCompound() == null) == (aStack2.getTagCompound() == null)) && (aStack1.getTagCompound() == null || aStack1.getTagCompound().equals(aStack2.getTagCompound())) && (Items.feather.getDamage(aStack1) == Items.feather.getDamage(aStack2) || Items.feather.getDamage(aStack1) == W || Items.feather.getDamage(aStack2) == W); + return ((aStack1.getTagCompound() == null) == (aStack2.getTagCompound() == null)) + && (aStack1.getTagCompound() == null + || aStack1.getTagCompound().equals(aStack2.getTagCompound())) + && (Items.feather.getDamage(aStack1) == Items.feather.getDamage(aStack2) + || Items.feather.getDamage(aStack1) == W + || Items.feather.getDamage(aStack2) == W); } return false; } @@ -1081,7 +1769,12 @@ public class GT_Utility { } public static boolean areFluidsEqual(FluidStack aFluid1, FluidStack aFluid2, boolean aIgnoreNBT) { - return aFluid1 != null && aFluid2 != null && aFluid1.getFluid() == aFluid2.getFluid() && (aIgnoreNBT || ((aFluid1.tag == null) == (aFluid2.tag == null)) && (aFluid1.tag == null || aFluid1.tag.equals(aFluid2.tag))); + return aFluid1 != null + && aFluid2 != null + && aFluid1.getFluid() == aFluid2.getFluid() + && (aIgnoreNBT + || ((aFluid1.tag == null) == (aFluid2.tag == null)) + && (aFluid1.tag == null || aFluid1.tag.equals(aFluid2.tag))); } public static boolean areStacksEqual(ItemStack aStack1, ItemStack aStack2) { @@ -1089,9 +1782,16 @@ public class GT_Utility { } public static boolean areStacksEqual(ItemStack aStack1, ItemStack aStack2, boolean aIgnoreNBT) { - return aStack1 != null && aStack2 != null && aStack1.getItem() == aStack2.getItem() - && (aIgnoreNBT || (((aStack1.getTagCompound() == null) == (aStack2.getTagCompound() == null)) && (aStack1.getTagCompound() == null || aStack1.getTagCompound().equals(aStack2.getTagCompound())))) - && (Items.feather.getDamage(aStack1) == Items.feather.getDamage(aStack2) || Items.feather.getDamage(aStack1) == W || Items.feather.getDamage(aStack2) == W); + return aStack1 != null + && aStack2 != null + && aStack1.getItem() == aStack2.getItem() + && (aIgnoreNBT + || (((aStack1.getTagCompound() == null) == (aStack2.getTagCompound() == null)) + && (aStack1.getTagCompound() == null + || aStack1.getTagCompound().equals(aStack2.getTagCompound())))) + && (Items.feather.getDamage(aStack1) == Items.feather.getDamage(aStack2) + || Items.feather.getDamage(aStack1) == W + || Items.feather.getDamage(aStack2) == W); } /** @@ -1099,23 +1799,24 @@ public class GT_Utility { * * Since ItemStack doesn't override equals and hashCode, you cannot just use Objects.equals */ - public static boolean areStackListsEqual(List<ItemStack> lhs, List<ItemStack> rhs, boolean ignoreStackSize, boolean ignoreNBT) { + public static boolean areStackListsEqual( + List<ItemStack> lhs, List<ItemStack> rhs, boolean ignoreStackSize, boolean ignoreNBT) { if (lhs == null) return rhs == null; if (rhs == null) return false; if (lhs.size() != rhs.size()) return false; for (Iterator<ItemStack> it1 = lhs.iterator(), it2 = rhs.iterator(); it1.hasNext() && it2.hasNext(); ) { - if (!areStacksEqualExtended(it1.next(), it2.next(), ignoreStackSize, ignoreNBT)) - return false; + if (!areStacksEqualExtended(it1.next(), it2.next(), ignoreStackSize, ignoreNBT)) return false; } return true; } - private static boolean areStacksEqualExtended(ItemStack lhs, ItemStack rhs, boolean ignoreStackSize, boolean ignoreNBT) { + private static boolean areStacksEqualExtended( + ItemStack lhs, ItemStack rhs, boolean ignoreStackSize, boolean ignoreNBT) { if (lhs == null) return rhs == null; if (rhs == null) return false; - return lhs.getItem() == rhs.getItem() && - (ignoreNBT || Objects.equals(lhs.stackTagCompound, rhs.stackTagCompound)) && - (ignoreStackSize || lhs.stackSize == rhs.stackSize); + return lhs.getItem() == rhs.getItem() + && (ignoreNBT || Objects.equals(lhs.stackTagCompound, rhs.stackTagCompound)) + && (ignoreStackSize || lhs.stackSize == rhs.stackSize); } public static boolean areUnificationsEqual(ItemStack aStack1, ItemStack aStack2) { @@ -1123,7 +1824,8 @@ public class GT_Utility { } public static boolean areUnificationsEqual(ItemStack aStack1, ItemStack aStack2, boolean aIgnoreNBT) { - return areStacksEqual(GT_OreDictUnificator.get_nocopy(aStack1), GT_OreDictUnificator.get_nocopy(aStack2), aIgnoreNBT); + return areStacksEqual( + GT_OreDictUnificator.get_nocopy(aStack1), GT_OreDictUnificator.get_nocopy(aStack2), aIgnoreNBT); } public static String getFluidName(Fluid aFluid, boolean aLocalized) { @@ -1146,10 +1848,12 @@ public class GT_Utility { sFluidUnlocalizedNameToFluid.clear(); for (FluidContainerData tData : sFluidContainerList) { sFilledContainerToData.put(new GT_ItemStack(tData.filledContainer), tData); - Map<Fluid, FluidContainerData> tFluidToContainer = sEmptyContainerToFluidToData.get(new GT_ItemStack(tData.emptyContainer)); + Map<Fluid, FluidContainerData> tFluidToContainer = + sEmptyContainerToFluidToData.get(new GT_ItemStack(tData.emptyContainer)); List<ItemStack> tContainers = sFluidToContainers.get(tData.fluid.getFluid()); if (tFluidToContainer == null) { - sEmptyContainerToFluidToData.put(new GT_ItemStack(tData.emptyContainer), tFluidToContainer = new /*Concurrent*/HashMap<>()); + sEmptyContainerToFluidToData.put( + new GT_ItemStack(tData.emptyContainer), tFluidToContainer = new /*Concurrent*/ HashMap<>()); GregTech_API.sFluidMappings.add(tFluidToContainer); } tFluidToContainer.put(tData.fluid.getFluid(), tData); @@ -1157,8 +1861,7 @@ public class GT_Utility { tContainers = new ArrayList<>(); tContainers.add(tData.filledContainer); sFluidToContainers.put(tData.fluid.getFluid(), tContainers); - } - else tContainers.add(tData.filledContainer); + } else tContainers.add(tData.filledContainer); } for (Fluid tFluid : FluidRegistry.getRegisteredFluids().values()) { sFluidUnlocalizedNameToFluid.put(tFluid.getUnlocalizedName(), tFluid); @@ -1172,10 +1875,12 @@ public class GT_Utility { public static void addFluidContainerData(FluidContainerData aData) { sFluidContainerList.add(aData); sFilledContainerToData.put(new GT_ItemStack(aData.filledContainer), aData); - Map<Fluid, FluidContainerData> tFluidToContainer = sEmptyContainerToFluidToData.get(new GT_ItemStack(aData.emptyContainer)); + Map<Fluid, FluidContainerData> tFluidToContainer = + sEmptyContainerToFluidToData.get(new GT_ItemStack(aData.emptyContainer)); List<ItemStack> tContainers = sFluidToContainers.get(aData.fluid.getFluid()); if (tFluidToContainer == null) { - sEmptyContainerToFluidToData.put(new GT_ItemStack(aData.emptyContainer), tFluidToContainer = new /*Concurrent*/HashMap<>()); + sEmptyContainerToFluidToData.put( + new GT_ItemStack(aData.emptyContainer), tFluidToContainer = new /*Concurrent*/ HashMap<>()); GregTech_API.sFluidMappings.add(tFluidToContainer); } tFluidToContainer.put(aData.fluid.getFluid(), aData); @@ -1183,8 +1888,7 @@ public class GT_Utility { tContainers = new ArrayList<>(); tContainers.add(aData.filledContainer); sFluidToContainers.put(aData.fluid.getFluid(), tContainers); - } - else tContainers.add(aData.filledContainer); + } else tContainers.add(aData.filledContainer); } public static List<ItemStack> getContainersFromFluid(FluidStack tFluidStack) { @@ -1196,7 +1900,8 @@ public class GT_Utility { return new ArrayList<>(); } - public static ItemStack fillFluidContainer(FluidStack aFluid, ItemStack aStack, boolean aRemoveFluidDirectly, boolean aCheckIFluidContainerItems) { + public static ItemStack fillFluidContainer( + FluidStack aFluid, ItemStack aStack, boolean aRemoveFluidDirectly, boolean aCheckIFluidContainerItems) { if (isStackInvalid(aStack) || aFluid == null) return null; if (GT_ModHandler.isWater(aFluid) && ItemList.Bottle_Empty.isStackEqual(aStack)) { if (aFluid.amount >= 250) { @@ -1205,11 +1910,14 @@ public class GT_Utility { } return null; } - if (aCheckIFluidContainerItems && aStack.getItem() instanceof IFluidContainerItem && ((IFluidContainerItem) aStack.getItem()).getFluid(aStack) == null && ((IFluidContainerItem) aStack.getItem()).getCapacity(aStack) <= aFluid.amount) { + if (aCheckIFluidContainerItems + && aStack.getItem() instanceof IFluidContainerItem + && ((IFluidContainerItem) aStack.getItem()).getFluid(aStack) == null + && ((IFluidContainerItem) aStack.getItem()).getCapacity(aStack) <= aFluid.amount) { if (aRemoveFluidDirectly) - aFluid.amount -= ((IFluidContainerItem) aStack.getItem()).fill(aStack = copyAmount(1, aStack), aFluid, true); - else - ((IFluidContainerItem) aStack.getItem()).fill(aStack = copyAmount(1, aStack), aFluid, true); + aFluid.amount -= + ((IFluidContainerItem) aStack.getItem()).fill(aStack = copyAmount(1, aStack), aFluid, true); + else ((IFluidContainerItem) aStack.getItem()).fill(aStack = copyAmount(1, aStack), aFluid, true); return aStack; } Map<Fluid, FluidContainerData> tFluidToContainer = sEmptyContainerToFluidToData.get(new GT_ItemStack(aStack)); @@ -1247,25 +1955,29 @@ public class GT_Utility { } public static FluidStack getFluidFromDisplayStack(ItemStack aDisplayStack) { - if (!isStackValid(aDisplayStack) || - aDisplayStack.getItem() != ItemList.Display_Fluid.getItem() || - !aDisplayStack.hasTagCompound()) - return null; + if (!isStackValid(aDisplayStack) + || aDisplayStack.getItem() != ItemList.Display_Fluid.getItem() + || !aDisplayStack.hasTagCompound()) return null; Fluid tFluid = FluidRegistry.getFluid(ItemList.Display_Fluid.getItem().getDamage(aDisplayStack)); return new FluidStack(tFluid, (int) aDisplayStack.getTagCompound().getLong("mFluidDisplayAmount")); } public static boolean containsFluid(ItemStack aStack, FluidStack aFluid, boolean aCheckIFluidContainerItems) { if (isStackInvalid(aStack) || aFluid == null) return false; - if (aCheckIFluidContainerItems && aStack.getItem() instanceof IFluidContainerItem && ((IFluidContainerItem) aStack.getItem()).getCapacity(aStack) > 0) - return aFluid.isFluidEqual(((IFluidContainerItem) aStack.getItem()).getFluid(aStack = copyAmount(1, aStack))); + if (aCheckIFluidContainerItems + && aStack.getItem() instanceof IFluidContainerItem + && ((IFluidContainerItem) aStack.getItem()).getCapacity(aStack) > 0) + return aFluid.isFluidEqual( + ((IFluidContainerItem) aStack.getItem()).getFluid(aStack = copyAmount(1, aStack))); FluidContainerData tData = sFilledContainerToData.get(new GT_ItemStack(aStack)); return tData != null && tData.fluid.isFluidEqual(aFluid); } public static FluidStack getFluidForFilledItem(ItemStack aStack, boolean aCheckIFluidContainerItems) { if (isStackInvalid(aStack)) return null; - if (aCheckIFluidContainerItems && aStack.getItem() instanceof IFluidContainerItem && ((IFluidContainerItem) aStack.getItem()).getCapacity(aStack) > 0) + if (aCheckIFluidContainerItems + && aStack.getItem() instanceof IFluidContainerItem + && ((IFluidContainerItem) aStack.getItem()).getCapacity(aStack) > 0) return ((IFluidContainerItem) aStack.getItem()).drain(copyAmount(1, aStack), Integer.MAX_VALUE, true); FluidContainerData tData = sFilledContainerToData.get(new GT_ItemStack(aStack)); return tData == null ? null : tData.fluid.copy(); @@ -1278,7 +1990,9 @@ public class GT_Utility { if (isStackInvalid(aStack)) return null; FluidContainerData tData = sFilledContainerToData.get(new GT_ItemStack(aStack)); if (tData != null) return copyAmount(1, tData.emptyContainer); - if (aCheckIFluidContainerItems && aStack.getItem() instanceof IFluidContainerItem && ((IFluidContainerItem) aStack.getItem()).getCapacity(aStack) > 0) { + if (aCheckIFluidContainerItems + && aStack.getItem() instanceof IFluidContainerItem + && ((IFluidContainerItem) aStack.getItem()).getCapacity(aStack) > 0) { ((IFluidContainerItem) aStack.getItem()).drain(aStack = copyAmount(1, aStack), Integer.MAX_VALUE, true); return aStack; } @@ -1295,10 +2009,14 @@ public class GT_Utility { /** These are all special Cases, in which it is intended to have only GT Blocks outputting those Container Items */ if (ItemList.Cell_Empty.isStackEqual(aStack, false, true)) return null; if (ItemList.IC2_Fuel_Can_Filled.isStackEqual(aStack, false, true)) return ItemList.IC2_Fuel_Can_Empty.get(1); - if (aStack.getItem() == Items.potionitem || aStack.getItem() == Items.experience_bottle || ItemList.TF_Vial_FieryBlood.isStackEqual(aStack) || ItemList.TF_Vial_FieryTears.isStackEqual(aStack)) - return ItemList.Bottle_Empty.get(1); - - if (aCheckIFluidContainerItems && aStack.getItem() instanceof IFluidContainerItem && ((IFluidContainerItem) aStack.getItem()).getCapacity(aStack) > 0) { + if (aStack.getItem() == Items.potionitem + || aStack.getItem() == Items.experience_bottle + || ItemList.TF_Vial_FieryBlood.isStackEqual(aStack) + || ItemList.TF_Vial_FieryTears.isStackEqual(aStack)) return ItemList.Bottle_Empty.get(1); + + if (aCheckIFluidContainerItems + && aStack.getItem() instanceof IFluidContainerItem + && ((IFluidContainerItem) aStack.getItem()).getCapacity(aStack) > 0) { ItemStack tStack = copyAmount(1, aStack); ((IFluidContainerItem) aStack.getItem()).drain(tStack, Integer.MAX_VALUE, true); if (!areStacksEqual(aStack, tStack)) return tStack; @@ -1313,63 +2031,79 @@ public class GT_Utility { return null; } - public static synchronized boolean removeIC2BottleRecipe(ItemStack aContainer, ItemStack aInput, Map<ic2.api.recipe.ICannerBottleRecipeManager.Input, RecipeOutput> aRecipeList, ItemStack aOutput){ - if ((isStackInvalid(aInput) && isStackInvalid(aOutput) && isStackInvalid(aContainer)) || aRecipeList == null) return false; + public static synchronized boolean removeIC2BottleRecipe( + ItemStack aContainer, + ItemStack aInput, + Map<ic2.api.recipe.ICannerBottleRecipeManager.Input, RecipeOutput> aRecipeList, + ItemStack aOutput) { + if ((isStackInvalid(aInput) && isStackInvalid(aOutput) && isStackInvalid(aContainer)) || aRecipeList == null) + return false; boolean rReturn = false; - Iterator<Map.Entry<ic2.api.recipe.ICannerBottleRecipeManager.Input, RecipeOutput>> tIterator = aRecipeList.entrySet().iterator(); + Iterator<Map.Entry<ic2.api.recipe.ICannerBottleRecipeManager.Input, RecipeOutput>> tIterator = + aRecipeList.entrySet().iterator(); aOutput = GT_OreDictUnificator.get(aOutput); while (tIterator.hasNext()) { Map.Entry<ic2.api.recipe.ICannerBottleRecipeManager.Input, RecipeOutput> tEntry = tIterator.next(); if (aInput == null || tEntry.getKey().matches(aContainer, aInput)) { List<ItemStack> tList = tEntry.getValue().items; - if (tList != null) for (ItemStack tOutput : tList) - if (aOutput == null || areStacksEqual(GT_OreDictUnificator.get(tOutput), aOutput)) { - tIterator.remove(); - rReturn = true; - break; - } + if (tList != null) + for (ItemStack tOutput : tList) + if (aOutput == null || areStacksEqual(GT_OreDictUnificator.get(tOutput), aOutput)) { + tIterator.remove(); + rReturn = true; + break; + } } } return rReturn; } - public static synchronized boolean removeSimpleIC2MachineRecipe(ItemStack aInput, Map<IRecipeInput, RecipeOutput> aRecipeList, ItemStack aOutput) { + public static synchronized boolean removeSimpleIC2MachineRecipe( + ItemStack aInput, Map<IRecipeInput, RecipeOutput> aRecipeList, ItemStack aOutput) { if ((isStackInvalid(aInput) && isStackInvalid(aOutput)) || aRecipeList == null) return false; boolean rReturn = false; - Iterator<Map.Entry<IRecipeInput, RecipeOutput>> tIterator = aRecipeList.entrySet().iterator(); + Iterator<Map.Entry<IRecipeInput, RecipeOutput>> tIterator = + aRecipeList.entrySet().iterator(); aOutput = GT_OreDictUnificator.get(aOutput); while (tIterator.hasNext()) { Map.Entry<IRecipeInput, RecipeOutput> tEntry = tIterator.next(); if (aInput == null || tEntry.getKey().matches(aInput)) { List<ItemStack> tList = tEntry.getValue().items; - if (tList != null) for (ItemStack tOutput : tList) - if (aOutput == null || areStacksEqual(GT_OreDictUnificator.get(tOutput), aOutput)) { - tIterator.remove(); - rReturn = true; - break; - } + if (tList != null) + for (ItemStack tOutput : tList) + if (aOutput == null || areStacksEqual(GT_OreDictUnificator.get(tOutput), aOutput)) { + tIterator.remove(); + rReturn = true; + break; + } } } return rReturn; } - public static synchronized void bulkRemoveSimpleIC2MachineRecipe(Map<ItemStack, ItemStack> toRemove, Map<IRecipeInput, RecipeOutput> aRecipeList) { + public static synchronized void bulkRemoveSimpleIC2MachineRecipe( + Map<ItemStack, ItemStack> toRemove, Map<IRecipeInput, RecipeOutput> aRecipeList) { if (aRecipeList == null || aRecipeList.isEmpty()) return; toRemove.entrySet().removeIf(aEntry -> (isStackInvalid(aEntry.getKey()) && isStackInvalid(aEntry.getValue()))); - final Map<ItemStack, ItemStack> finalToRemove = Maps.transformValues(toRemove, GT_OreDictUnificator::get_nocopy); + final Map<ItemStack, ItemStack> finalToRemove = + Maps.transformValues(toRemove, GT_OreDictUnificator::get_nocopy); - aRecipeList.entrySet().removeIf(tEntry -> finalToRemove.entrySet().stream().anyMatch(aEntry -> { - final ItemStack aInput = aEntry.getKey(), aOutput = aEntry.getValue(); - final List<ItemStack> tList = tEntry.getValue().items; + aRecipeList.entrySet().removeIf(tEntry -> finalToRemove.entrySet().stream() + .anyMatch(aEntry -> { + final ItemStack aInput = aEntry.getKey(), aOutput = aEntry.getValue(); + final List<ItemStack> tList = tEntry.getValue().items; - if (tList == null) return false; - if (aInput != null && !tEntry.getKey().matches(aInput)) return false; + if (tList == null) return false; + if (aInput != null && !tEntry.getKey().matches(aInput)) return false; - return tList.stream().anyMatch(tOutput -> (aOutput == null || areStacksEqual(GT_OreDictUnificator.get(tOutput), aOutput))); - })); + return tList.stream() + .anyMatch(tOutput -> + (aOutput == null || areStacksEqual(GT_OreDictUnificator.get(tOutput), aOutput))); + })); } - public static boolean addSimpleIC2MachineRecipe(ItemStack aInput, Map<IRecipeInput, RecipeOutput> aRecipeList, NBTTagCompound aNBT, Object... aOutput) { + public static boolean addSimpleIC2MachineRecipe( + ItemStack aInput, Map<IRecipeInput, RecipeOutput> aRecipeList, NBTTagCompound aNBT, Object... aOutput) { if (isStackInvalid(aInput) || aOutput.length == 0 || aRecipeList == null) return false; ItemData tOreName = GT_OreDictUnificator.getAssociation(aInput); for (Object o : aOutput) { @@ -1379,12 +2113,15 @@ public class GT_Utility { } } ItemStack[] tStack = GT_OreDictUnificator.getStackArray(true, aOutput); - if(tStack.length > 0 && areStacksEqual(aInput, tStack[0]))return false; + if (tStack.length > 0 && areStacksEqual(aInput, tStack[0])) return false; if (tOreName != null) { - if(tOreName.toString().equals("dustAsh")&&tStack[0].getUnlocalizedName().equals("tile.volcanicAsh"))return false; - aRecipeList.put(new RecipeInputOreDict(tOreName.toString(), aInput.stackSize), new RecipeOutput(aNBT, tStack)); + if (tOreName.toString().equals("dustAsh") + && tStack[0].getUnlocalizedName().equals("tile.volcanicAsh")) return false; + aRecipeList.put( + new RecipeInputOreDict(tOreName.toString(), aInput.stackSize), new RecipeOutput(aNBT, tStack)); } else { - aRecipeList.put(new RecipeInputItemStack(copyOrNull(aInput), aInput.stackSize), new RecipeOutput(aNBT, tStack)); + aRecipeList.put( + new RecipeInputItemStack(copyOrNull(aInput), aInput.stackSize), new RecipeOutput(aNBT, tStack)); } return true; } @@ -1412,21 +2149,22 @@ public class GT_Utility { tNBT.setString("author", aAuthor); NBTTagList tNBTList = new NBTTagList(); for (byte i = 0; i < aPages.length; i++) { - aPages[i] = GT_LanguageManager.addStringLocalization("Book." + aTitle + ".Page" + ((i < 10) ? "0" + i : i), aPages[i]); + aPages[i] = GT_LanguageManager.addStringLocalization( + "Book." + aTitle + ".Page" + ((i < 10) ? "0" + i : i), aPages[i]); if (i < 48) { - if (aPages[i].length() < 256) - tNBTList.appendTag(new NBTTagString(aPages[i])); - else - GT_Log.err.println("WARNING: String for written Book too long! -> " + aPages[i]); + if (aPages[i].length() < 256) tNBTList.appendTag(new NBTTagString(aPages[i])); + else GT_Log.err.println("WARNING: String for written Book too long! -> " + aPages[i]); } else { GT_Log.err.println("WARNING: Too much Pages for written Book! -> " + aTitle); break; } } - tNBTList.appendTag(new NBTTagString("Credits to " + aAuthor + " for writing this Book. This was Book Nr. " + sBookCount + " at its creation. Gotta get 'em all!")); + tNBTList.appendTag(new NBTTagString("Credits to " + aAuthor + " for writing this Book. This was Book Nr. " + + sBookCount + " at its creation. Gotta get 'em all!")); tNBT.setTag("pages", tNBTList); rStack.setTagCompound(tNBT); - GT_Log.out.println("GT_Mod: Added Book to Book List - Mapping: '" + aMapping + "' - Name: '" + aTitle + "' - Author: '" + aAuthor + "'"); + GT_Log.out.println("GT_Mod: Added Book to Book List - Mapping: '" + aMapping + "' - Name: '" + aTitle + + "' - Author: '" + aAuthor + "'"); GregTech_API.sBookList.put(aMapping, rStack); return copyOrNull(rStack); } @@ -1440,21 +2178,37 @@ public class GT_Utility { return doSoundAtClient(sound.resourceLocation, aTimeUntilNextSound, aSoundStrength, GT.getThePlayer()); } - public static boolean doSoundAtClient(ResourceLocation aSoundResourceLocation, int aTimeUntilNextSound, float aSoundStrength) { + public static boolean doSoundAtClient( + ResourceLocation aSoundResourceLocation, int aTimeUntilNextSound, float aSoundStrength) { return doSoundAtClient(aSoundResourceLocation, aTimeUntilNextSound, aSoundStrength, GT.getThePlayer()); } - public static boolean doSoundAtClient(String aSoundName, int aTimeUntilNextSound, float aSoundStrength, Entity aEntity) { + public static boolean doSoundAtClient( + String aSoundName, int aTimeUntilNextSound, float aSoundStrength, Entity aEntity) { if (aEntity == null || aSoundName == null) return false; - return doSoundAtClient(aSoundName, aTimeUntilNextSound, aSoundStrength, aEntity.posX, aEntity.posY, aEntity.posZ); + return doSoundAtClient( + aSoundName, aTimeUntilNextSound, aSoundStrength, aEntity.posX, aEntity.posY, aEntity.posZ); } - public static boolean doSoundAtClient(ResourceLocation aSoundResourceLocation, int aTimeUntilNextSound, float aSoundStrength, Entity aEntity) { + public static boolean doSoundAtClient( + ResourceLocation aSoundResourceLocation, int aTimeUntilNextSound, float aSoundStrength, Entity aEntity) { if (aEntity == null) return false; - return doSoundAtClient(aSoundResourceLocation.toString(), aTimeUntilNextSound, aSoundStrength, aEntity.posX, aEntity.posY, aEntity.posZ); + return doSoundAtClient( + aSoundResourceLocation.toString(), + aTimeUntilNextSound, + aSoundStrength, + aEntity.posX, + aEntity.posY, + aEntity.posZ); } - public static boolean doSoundAtClient(ResourceLocation aSoundResourceLocation, int aTimeUntilNextSound, float aSoundStrength, double aX, double aY, double aZ) { + public static boolean doSoundAtClient( + ResourceLocation aSoundResourceLocation, + int aTimeUntilNextSound, + float aSoundStrength, + double aX, + double aY, + double aZ) { return doSoundAtClient(aSoundResourceLocation, aTimeUntilNextSound, aSoundStrength, 1.01818028F, aX, aY, aZ); } @@ -1463,40 +2217,65 @@ public class GT_Utility { * @deprecated Use {@link #doSoundAtClient(ResourceLocation, int, float, double, double, double)} */ @Deprecated - public static boolean doSoundAtClient(String aSoundName, int aTimeUntilNextSound, float aSoundStrength, double aX, double aY, double aZ) { + public static boolean doSoundAtClient( + String aSoundName, int aTimeUntilNextSound, float aSoundStrength, double aX, double aY, double aZ) { if (aSoundName == null) return false; - return doSoundAtClient(new ResourceLocation(aSoundName), aTimeUntilNextSound, aSoundStrength, 1.01818028F, aX, aY, aZ); + return doSoundAtClient( + new ResourceLocation(aSoundName), aTimeUntilNextSound, aSoundStrength, 1.01818028F, aX, aY, aZ); } - public static boolean doSoundAtClient(SoundResource aSound, int aTimeUntilNextSound, float aSoundStrength, double aX, double aY, double aZ) { + public static boolean doSoundAtClient( + SoundResource aSound, int aTimeUntilNextSound, float aSoundStrength, double aX, double aY, double aZ) { return doSoundAtClient(aSound.resourceLocation, aTimeUntilNextSound, aSoundStrength, aX, aY, aZ); } public static boolean doSoundAtClient( - SoundResource aSound, int aTimeUntilNextSound, float aSoundStrength, float aSoundModulation, - double aX, double aY, double aZ) { - return doSoundAtClient(aSound.resourceLocation, aTimeUntilNextSound, aSoundStrength, aSoundModulation, aX, aY, aZ); + SoundResource aSound, + int aTimeUntilNextSound, + float aSoundStrength, + float aSoundModulation, + double aX, + double aY, + double aZ) { + return doSoundAtClient( + aSound.resourceLocation, aTimeUntilNextSound, aSoundStrength, aSoundModulation, aX, aY, aZ); } - public static boolean doSoundAtClient( - ResourceLocation aSoundResourceLocation, int aTimeUntilNextSound, float aSoundStrength, float aSoundModulation, - double aX, double aY, double aZ) { + ResourceLocation aSoundResourceLocation, + int aTimeUntilNextSound, + float aSoundStrength, + float aSoundModulation, + double aX, + double aY, + double aZ) { if (!FMLCommonHandler.instance().getEffectiveSide().isClient() - || GT.getThePlayer() == null - || !GT.getThePlayer().worldObj.isRemote) - return false; + || GT.getThePlayer() == null + || !GT.getThePlayer().worldObj.isRemote) return false; if (GregTech_API.sMultiThreadedSounds) - new Thread(new GT_Runnable_Sound( - GT.getThePlayer().worldObj, - MathHelper.floor_double(aX), MathHelper.floor_double(aY), MathHelper.floor_double(aZ), - aTimeUntilNextSound, aSoundResourceLocation, aSoundStrength, aSoundModulation), "Sound Effect") - .start(); + new Thread( + new GT_Runnable_Sound( + GT.getThePlayer().worldObj, + MathHelper.floor_double(aX), + MathHelper.floor_double(aY), + MathHelper.floor_double(aZ), + aTimeUntilNextSound, + aSoundResourceLocation, + aSoundStrength, + aSoundModulation), + "Sound Effect") + .start(); else new GT_Runnable_Sound( - GT.getThePlayer().worldObj, - MathHelper.floor_double(aX), MathHelper.floor_double(aY), MathHelper.floor_double(aZ), - aTimeUntilNextSound, aSoundResourceLocation, aSoundStrength, aSoundModulation).run(); + GT.getThePlayer().worldObj, + MathHelper.floor_double(aX), + MathHelper.floor_double(aY), + MathHelper.floor_double(aZ), + aTimeUntilNextSound, + aSoundResourceLocation, + aSoundStrength, + aSoundModulation) + .run(); return true; } @@ -1505,20 +2284,36 @@ public class GT_Utility { * @Deprecated Use {@link #doSoundAtClient(ResourceLocation, int, float, float, double, double, double)} */ @Deprecated - public static boolean doSoundAtClient(String aSoundName, int aTimeUntilNextSound, float aSoundStrength, float aSoundModulation, double aX, double aY, double aZ) { + public static boolean doSoundAtClient( + String aSoundName, + int aTimeUntilNextSound, + float aSoundStrength, + float aSoundModulation, + double aX, + double aY, + double aZ) { if (isStringInvalid(aSoundName)) return false; - return doSoundAtClient(new ResourceLocation(aSoundName), aTimeUntilNextSound, aSoundStrength, aSoundModulation, aX, aY, aZ); + return doSoundAtClient( + new ResourceLocation(aSoundName), aTimeUntilNextSound, aSoundStrength, aSoundModulation, aX, aY, aZ); } - public static boolean sendSoundToPlayers(World aWorld, String aSoundName, float aSoundStrength, float aSoundModulation, int aX, int aY, int aZ) { + public static boolean sendSoundToPlayers( + World aWorld, String aSoundName, float aSoundStrength, float aSoundModulation, int aX, int aY, int aZ) { if (isStringInvalid(aSoundName) || aWorld == null || aWorld.isRemote) return false; - NW.sendPacketToAllPlayersInRange(aWorld, new GT_Packet_Sound(aSoundName, aSoundStrength, aSoundModulation, aX, (short) aY, aZ), aX, aZ); + NW.sendPacketToAllPlayersInRange( + aWorld, new GT_Packet_Sound(aSoundName, aSoundStrength, aSoundModulation, aX, (short) aY, aZ), aX, aZ); return true; } - public static boolean sendSoundToPlayers(World aWorld, SoundResource sound, float aSoundStrength, float aSoundModulation, int aX, int aY, int aZ) { + public static boolean sendSoundToPlayers( + World aWorld, SoundResource sound, float aSoundStrength, float aSoundModulation, int aX, int aY, int aZ) { if (aWorld == null || aWorld.isRemote) return false; - NW.sendPacketToAllPlayersInRange(aWorld, new GT_Packet_Sound(sound.resourceLocation.toString(), aSoundStrength, aSoundModulation, aX, (short) aY, aZ), aX, aZ); + NW.sendPacketToAllPlayersInRange( + aWorld, + new GT_Packet_Sound( + sound.resourceLocation.toString(), aSoundStrength, aSoundModulation, aX, (short) aY, aZ), + aX, + aZ); return true; } @@ -1626,15 +2421,21 @@ public class GT_Utility { } public static boolean isStackValid(Object aStack) { - return (aStack instanceof ItemStack) && ((ItemStack) aStack).getItem() != null && ((ItemStack) aStack).stackSize >= 0; + return (aStack instanceof ItemStack) + && ((ItemStack) aStack).getItem() != null + && ((ItemStack) aStack).stackSize >= 0; } public static boolean isStackInvalid(Object aStack) { - return aStack == null || !(aStack instanceof ItemStack) || ((ItemStack) aStack).getItem() == null || ((ItemStack) aStack).stackSize < 0; + return aStack == null + || !(aStack instanceof ItemStack) + || ((ItemStack) aStack).getItem() == null + || ((ItemStack) aStack).stackSize < 0; } public static boolean isDebugItem(ItemStack aStack) { - return /*ItemList.Armor_Cheat.isStackEqual(aStack, T, T) || */areStacksEqual(GT_ModHandler.getIC2Item("debug", 1), aStack, true); + return /*ItemList.Armor_Cheat.isStackEqual(aStack, T, T) || */ areStacksEqual( + GT_ModHandler.getIC2Item("debug", 1), aStack, true); } public static ItemStack updateItemStack(ItemStack aStack) { @@ -1674,20 +2475,24 @@ public class GT_Utility { } public static ItemStack getProjectile(SubTag aProjectileType, IInventory aInventory) { - if (aInventory != null) for (int i = 0, j = aInventory.getSizeInventory(); i < j; i++) { - ItemStack rStack = aInventory.getStackInSlot(i); - if (isStackValid(rStack) && rStack.getItem() instanceof IProjectileItem && ((IProjectileItem) rStack.getItem()).hasProjectile(aProjectileType, rStack)) - return updateItemStack(rStack); - } + if (aInventory != null) + for (int i = 0, j = aInventory.getSizeInventory(); i < j; i++) { + ItemStack rStack = aInventory.getStackInSlot(i); + if (isStackValid(rStack) + && rStack.getItem() instanceof IProjectileItem + && ((IProjectileItem) rStack.getItem()).hasProjectile(aProjectileType, rStack)) + return updateItemStack(rStack); + } return null; } public static void removeNullStacksFromInventory(IInventory aInventory) { - if (aInventory != null) for (int i = 0, j = aInventory.getSizeInventory(); i < j; i++) { - ItemStack tStack = aInventory.getStackInSlot(i); - if (tStack != null && (tStack.stackSize == 0 || tStack.getItem() == null)) - aInventory.setInventorySlotContents(i, null); - } + if (aInventory != null) + for (int i = 0, j = aInventory.getSizeInventory(); i < j; i++) { + ItemStack tStack = aInventory.getStackInSlot(i); + if (tStack != null && (tStack.stackSize == 0 || tStack.getItem() == null)) + aInventory.setInventorySlotContents(i, null); + } } /** @@ -1702,9 +2507,9 @@ public class GT_Utility { * @param page 0 to 127 * @return true if it made empty page, false if one already existed... */ - public static boolean addTexturePage(byte page){ - if(Textures.BlockIcons.casingTexturePages[page]==null){ - Textures.BlockIcons.casingTexturePages[page]=new ITexture[128]; + public static boolean addTexturePage(byte page) { + if (Textures.BlockIcons.casingTexturePages[page] == null) { + Textures.BlockIcons.casingTexturePages[page] = new ITexture[128]; return true; } return false; @@ -1717,11 +2522,11 @@ public class GT_Utility { * @param index 0 to 127 texture index * @return casing texture 0 to 16383 */ - public static int getTextureId(byte page,byte index){ - if(page>=0 && index>=0){ - return (page<<7)+index; + public static int getTextureId(byte page, byte index) { + if (page >= 0 && index >= 0) { + return (page << 7) + index; } - throw new RuntimeException("Index out of range: ["+page+"]["+index+"]"); + throw new RuntimeException("Index out of range: [" + page + "][" + index + "]"); } /** @@ -1732,11 +2537,12 @@ public class GT_Utility { * @param blockMeta meta of the block * @return casing texture 0 to 16383 */ - public static int getTextureId(byte page,byte startIndex,byte blockMeta){ - if(page>=0 && startIndex>=0 && blockMeta>=0 && (startIndex+blockMeta)<=127){ - return (page<<7)+(startIndex+blockMeta); + public static int getTextureId(byte page, byte startIndex, byte blockMeta) { + if (page >= 0 && startIndex >= 0 && blockMeta >= 0 && (startIndex + blockMeta) <= 127) { + return (page << 7) + (startIndex + blockMeta); } - throw new RuntimeException("Index out of range: ["+page+"]["+startIndex+"+"+blockMeta+"="+(startIndex+blockMeta)+"]"); + throw new RuntimeException("Index out of range: [" + page + "][" + startIndex + "+" + blockMeta + "=" + + (startIndex + blockMeta) + "]"); } /** @@ -1744,8 +2550,8 @@ public class GT_Utility { * @return casing texture 0 to 16383 */ @Deprecated - public static int getTextureId(ItemStack stack){ - return getTextureId(Block.getBlockFromItem(stack.getItem()),(byte)stack.getItemDamage()); + public static int getTextureId(ItemStack stack) { + return getTextureId(Block.getBlockFromItem(stack.getItem()), (byte) stack.getItemDamage()); } /** @@ -1768,8 +2574,8 @@ public class GT_Utility { } } } - throw new RuntimeException("Probably missing mapping or different texture class used for: " + - blockFromBlock.getUnlocalizedName() + " meta:" + metaFromBlock); + throw new RuntimeException("Probably missing mapping or different texture class used for: " + + blockFromBlock.getUnlocalizedName() + " meta:" + metaFromBlock); } /** @@ -1881,7 +2687,10 @@ public class GT_Utility { public static float getHeatDamageFromItem(ItemStack aStack) { ItemData tData = GT_OreDictUnificator.getItemData(aStack); - return tData == null ? 0 : (tData.mPrefix == null ? 0 : tData.mPrefix.mHeatDamage) + (tData.hasValidMaterialData() ? tData.mMaterial.mMaterial.mHeatDamage : 0); + return tData == null + ? 0 + : (tData.mPrefix == null ? 0 : tData.mPrefix.mHeatDamage) + + (tData.hasValidMaterialData() ? tData.mMaterial.mMaterial.mHeatDamage : 0); } public static int getRadioactivityLevel(ItemStack aStack) { @@ -1908,7 +2717,10 @@ public class GT_Utility { } private static boolean applyHeatDamage(EntityLivingBase aEntity, float aDamage, DamageSource source) { - if (aDamage > 0 && aEntity != null && aEntity.getActivePotionEffect(Potion.fireResistance) == null && !isWearingFullHeatHazmat(aEntity)) { + if (aDamage > 0 + && aEntity != null + && aEntity.getActivePotionEffect(Potion.fireResistance) == null + && !isWearingFullHeatHazmat(aEntity)) { aEntity.attackEntityFrom(source, aDamage); return true; } @@ -1933,14 +2745,66 @@ public class GT_Utility { } public static boolean applyRadioactivity(EntityLivingBase aEntity, int aLevel, int aAmountOfItems) { - if (aLevel > 0 && aEntity != null && aEntity.getCreatureAttribute() != EnumCreatureAttribute.UNDEAD && aEntity.getCreatureAttribute() != EnumCreatureAttribute.ARTHROPOD && !isWearingFullRadioHazmat(aEntity)) { + if (aLevel > 0 + && aEntity != null + && aEntity.getCreatureAttribute() != EnumCreatureAttribute.UNDEAD + && aEntity.getCreatureAttribute() != EnumCreatureAttribute.ARTHROPOD + && !isWearingFullRadioHazmat(aEntity)) { PotionEffect tEffect = null; - aEntity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, aLevel * 140 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.moveSlowdown)) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7))); - aEntity.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, aLevel * 150 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.digSlowdown)) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7))); - aEntity.addPotionEffect(new PotionEffect(Potion.confusion.id, aLevel * 130 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.confusion)) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7))); - aEntity.addPotionEffect(new PotionEffect(Potion.weakness.id, aLevel * 150 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.weakness)) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7))); - aEntity.addPotionEffect(new PotionEffect(Potion.hunger.id, aLevel * 130 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.hunger)) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7))); - aEntity.addPotionEffect(new PotionEffect(24 /* IC2 Radiation */, aLevel * 180 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.potionTypes[24])) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7))); + aEntity.addPotionEffect(new PotionEffect( + Potion.moveSlowdown.id, + aLevel * 140 * aAmountOfItems + + Math.max( + 0, + ((tEffect = aEntity.getActivePotionEffect(Potion.moveSlowdown)) == null + ? 0 + : tEffect.getDuration())), + Math.max(0, (5 * aLevel) / 7))); + aEntity.addPotionEffect(new PotionEffect( + Potion.digSlowdown.id, + aLevel * 150 * aAmountOfItems + + Math.max( + 0, + ((tEffect = aEntity.getActivePotionEffect(Potion.digSlowdown)) == null + ? 0 + : tEffect.getDuration())), + Math.max(0, (5 * aLevel) / 7))); + aEntity.addPotionEffect(new PotionEffect( + Potion.confusion.id, + aLevel * 130 * aAmountOfItems + + Math.max( + 0, + ((tEffect = aEntity.getActivePotionEffect(Potion.confusion)) == null + ? 0 + : tEffect.getDuration())), + Math.max(0, (5 * aLevel) / 7))); + aEntity.addPotionEffect(new PotionEffect( + Potion.weakness.id, + aLevel * 150 * aAmountOfItems + + Math.max( + 0, + ((tEffect = aEntity.getActivePotionEffect(Potion.weakness)) == null + ? 0 + : tEffect.getDuration())), + Math.max(0, (5 * aLevel) / 7))); + aEntity.addPotionEffect(new PotionEffect( + Potion.hunger.id, + aLevel * 130 * aAmountOfItems + + Math.max( + 0, + ((tEffect = aEntity.getActivePotionEffect(Potion.hunger)) == null + ? 0 + : tEffect.getDuration())), + Math.max(0, (5 * aLevel) / 7))); + aEntity.addPotionEffect(new PotionEffect( + 24 /* IC2 Radiation */, + aLevel * 180 * aAmountOfItems + + Math.max( + 0, + ((tEffect = aEntity.getActivePotionEffect(Potion.potionTypes[24])) == null + ? 0 + : tEffect.getDuration())), + Math.max(0, (5 * aLevel) / 7))); return true; } return false; @@ -2070,7 +2934,8 @@ public class GT_Utility { } public static boolean isStackInList(GT_ItemStack aStack, Collection<GT_ItemStack> aList) { - return aStack != null && (aList.contains(aStack) || aList.contains(new GT_ItemStack(aStack.mItem, aStack.mStackSize, W))); + return aStack != null + && (aList.contains(aStack) || aList.contains(new GT_ItemStack(aStack.mItem, aStack.mStackSize, W))); } /** @@ -2084,7 +2949,9 @@ public class GT_Utility { } public static <X, Y extends Comparable<Y>> LinkedHashMap<X, Y> sortMapByValuesAcending(Map<X, Y> map) { - return map.entrySet().stream().sorted(Entry.comparingByValue()).collect(CollectorUtils.entriesToMap(LinkedHashMap::new)); + return map.entrySet().stream() + .sorted(Entry.comparingByValue()) + .collect(CollectorUtils.entriesToMap(LinkedHashMap::new)); } /** @@ -2093,7 +2960,7 @@ public class GT_Utility { public static <X, Y extends Comparable> LinkedHashMap<X, Y> sortMapByValuesDescending(Map<X, Y> aMap) { List<Map.Entry<X, Y>> tEntrySet = new LinkedList<>(aMap.entrySet()); tEntrySet.sort((aValue1, aValue2) -> { - return aValue2.getValue().compareTo(aValue1.getValue());//FB: RV - RV_NEGATING_RESULT_OF_COMPARETO + return aValue2.getValue().compareTo(aValue1.getValue()); // FB: RV - RV_NEGATING_RESULT_OF_COMPARETO }); LinkedHashMap<X, Y> rMap = new LinkedHashMap<>(); for (Map.Entry<X, Y> tEntry : tEntrySet) rMap.put(tEntry.getKey(), tEntry.getValue()); @@ -2111,7 +2978,10 @@ public class GT_Utility { * Translates a Material Amount into an Amount of Fluid. Second Parameter for things like Bucket Amounts (1000) and similar */ public static long translateMaterialToAmount(long aMaterialAmount, long aAmountPerUnit, boolean aRoundUp) { - return Math.max(0, ((aMaterialAmount * aAmountPerUnit) / M) + (aRoundUp && (aMaterialAmount * aAmountPerUnit) % M > 0 ? 1 : 0)); + return Math.max( + 0, + ((aMaterialAmount * aAmountPerUnit) / M) + + (aRoundUp && (aMaterialAmount * aAmountPerUnit) % M > 0 ? 1 : 0)); } /** @@ -2119,31 +2989,41 @@ public class GT_Utility { * Used for my Teleporter. */ public static boolean isRealDimension(int aDimensionID) { - if(aDimensionID<=1 && aDimensionID>=-1 && !GregTech_API.sDimensionalList.contains(aDimensionID)) return true; - return !GregTech_API.sDimensionalList.contains(aDimensionID) && DimensionManager.isDimensionRegistered(aDimensionID); + if (aDimensionID <= 1 && aDimensionID >= -1 && !GregTech_API.sDimensionalList.contains(aDimensionID)) + return true; + return !GregTech_API.sDimensionalList.contains(aDimensionID) + && DimensionManager.isDimensionRegistered(aDimensionID); } - public static boolean moveEntityToDimensionAtCoords(Entity entity, int aDimension, double aX, double aY, double aZ) { - //Credit goes to BrandonCore Author :!: + public static boolean moveEntityToDimensionAtCoords( + Entity entity, int aDimension, double aX, double aY, double aZ) { + // Credit goes to BrandonCore Author :!: if (entity == null || entity.worldObj.isRemote) return false; if (entity.ridingEntity != null) entity.mountEntity(null); if (entity.riddenByEntity != null) entity.riddenByEntity.mountEntity(null); World startWorld = entity.worldObj; - World destinationWorld = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(aDimension); + World destinationWorld = + FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(aDimension); - if (destinationWorld == null) {return false;} + if (destinationWorld == null) { + return false; + } boolean interDimensional = startWorld.provider.dimensionId != destinationWorld.provider.dimensionId; - if(!interDimensional)return false; - startWorld.updateEntityWithOptionalForce(entity, false);//added + if (!interDimensional) return false; + startWorld.updateEntityWithOptionalForce(entity, false); // added if ((entity instanceof EntityPlayerMP) && interDimensional) { EntityPlayerMP player = (EntityPlayerMP) entity; - player.closeScreen();//added + player.closeScreen(); // added player.dimension = aDimension; - player.playerNetServerHandler.sendPacket(new S07PacketRespawn(player.dimension, player.worldObj.difficultySetting, destinationWorld.getWorldInfo().getTerrainType(), player.theItemInWorldManager.getGameType())); + player.playerNetServerHandler.sendPacket(new S07PacketRespawn( + player.dimension, + player.worldObj.difficultySetting, + destinationWorld.getWorldInfo().getTerrainType(), + player.theItemInWorldManager.getGameType())); ((WorldServer) startWorld).getPlayerManager().removePlayer(player); startWorld.playerEntities.remove(player); @@ -2197,15 +3077,19 @@ public class GT_Utility { if (((entity instanceof EntityPlayerMP)) && interDimensional) { EntityPlayerMP player = (EntityPlayerMP) entity; player.theItemInWorldManager.setWorld((WorldServer) destinationWorld); - player.mcServer.getConfigurationManager().updateTimeAndWeatherForPlayer(player, (WorldServer) destinationWorld); + player.mcServer.getConfigurationManager().updateTimeAndWeatherForPlayer(player, (WorldServer) + destinationWorld); player.mcServer.getConfigurationManager().syncPlayerInventory(player); for (PotionEffect potionEffect : (Iterable<PotionEffect>) player.getActivePotionEffects()) { player.playerNetServerHandler.sendPacket(new S1DPacketEntityEffect(player.getEntityId(), potionEffect)); } - player.playerNetServerHandler.sendPacket(new S1FPacketSetExperience(player.experience, player.experienceTotal, player.experienceLevel)); - FMLCommonHandler.instance().firePlayerChangedDimensionEvent(player, startWorld.provider.dimensionId, destinationWorld.provider.dimensionId); + player.playerNetServerHandler.sendPacket( + new S1FPacketSetExperience(player.experience, player.experienceTotal, player.experienceLevel)); + FMLCommonHandler.instance() + .firePlayerChangedDimensionEvent( + player, startWorld.provider.dimensionId, destinationWorld.provider.dimensionId); } entity.setLocationAndAngles(aX, aY, aZ, entity.rotationYaw, entity.rotationPitch); @@ -2215,10 +3099,21 @@ public class GT_Utility { } public static int getScaleCoordinates(double aValue, int aScale) { - return (int)Math.floor(aValue / aScale); - } - - public static int getCoordinateScan(ArrayList<String> aList, EntityPlayer aPlayer, World aWorld, int aScanLevel, int aX, int aY, int aZ, int aSide, float aClickX, float aClickY, float aClickZ) { + return (int) Math.floor(aValue / aScale); + } + + public static int getCoordinateScan( + ArrayList<String> aList, + EntityPlayer aPlayer, + World aWorld, + int aScanLevel, + int aX, + int aY, + int aZ, + int aSide, + float aClickX, + float aClickY, + float aClickZ) { if (aList == null) return 0; ArrayList<String> tList = new ArrayList<>(); @@ -2228,25 +3123,43 @@ public class GT_Utility { final Block tBlock = aWorld.getBlock(aX, aY, aZ); - tList.add( - "----- X: " + EnumChatFormatting.AQUA + formatNumbers(aX) + EnumChatFormatting.RESET + - " Y: " + EnumChatFormatting.AQUA + formatNumbers(aY) + EnumChatFormatting.RESET + - " Z: " + EnumChatFormatting.AQUA + formatNumbers(aZ) + EnumChatFormatting.RESET + - " D: " + EnumChatFormatting.AQUA + aWorld.provider.dimensionId + EnumChatFormatting.RESET + " -----"); + tList.add("----- X: " + EnumChatFormatting.AQUA + formatNumbers(aX) + EnumChatFormatting.RESET + " Y: " + + EnumChatFormatting.AQUA + formatNumbers(aY) + EnumChatFormatting.RESET + " Z: " + + EnumChatFormatting.AQUA + formatNumbers(aZ) + EnumChatFormatting.RESET + " D: " + + EnumChatFormatting.AQUA + aWorld.provider.dimensionId + EnumChatFormatting.RESET + " -----"); try { if (tTileEntity instanceof IInventory) - tList.add( - GT_Utility.trans("162","Name: ") + EnumChatFormatting.BLUE + ((IInventory) tTileEntity).getInventoryName() + EnumChatFormatting.RESET + - GT_Utility.trans("163"," MetaData: ") + EnumChatFormatting.AQUA + aWorld.getBlockMetadata(aX, aY, aZ) + EnumChatFormatting.RESET); + tList.add(GT_Utility.trans("162", "Name: ") + + EnumChatFormatting.BLUE + + ((IInventory) tTileEntity).getInventoryName() + + EnumChatFormatting.RESET + + GT_Utility.trans("163", " MetaData: ") + + EnumChatFormatting.AQUA + + aWorld.getBlockMetadata(aX, aY, aZ) + + EnumChatFormatting.RESET); else - tList.add( - GT_Utility.trans("162","Name: ") + EnumChatFormatting.BLUE + tBlock.getUnlocalizedName() + EnumChatFormatting.RESET + - GT_Utility.trans("163"," MetaData: ") + EnumChatFormatting.AQUA + aWorld.getBlockMetadata(aX, aY, aZ) + EnumChatFormatting.RESET); - - tList.add( - GT_Utility.trans("164","Hardness: ") + EnumChatFormatting.YELLOW + tBlock.getBlockHardness(aWorld, aX, aY, aZ) + EnumChatFormatting.RESET + - GT_Utility.trans("165"," Blast Resistance: ") + EnumChatFormatting.YELLOW + tBlock.getExplosionResistance(aPlayer, aWorld, aX, aY, aZ, aPlayer.posX, aPlayer.posY, aPlayer.posZ) + EnumChatFormatting.RESET); - if (tBlock.isBeaconBase(aWorld, aX, aY, aZ, aX, aY + 1, aZ)) tList.add(EnumChatFormatting.GOLD + GT_Utility.trans("166","Is valid Beacon Pyramid Material") + EnumChatFormatting.RESET); + tList.add(GT_Utility.trans("162", "Name: ") + + EnumChatFormatting.BLUE + + tBlock.getUnlocalizedName() + + EnumChatFormatting.RESET + + GT_Utility.trans("163", " MetaData: ") + + EnumChatFormatting.AQUA + + aWorld.getBlockMetadata(aX, aY, aZ) + + EnumChatFormatting.RESET); + + tList.add(GT_Utility.trans("164", "Hardness: ") + + EnumChatFormatting.YELLOW + + tBlock.getBlockHardness(aWorld, aX, aY, aZ) + + EnumChatFormatting.RESET + + GT_Utility.trans("165", " Blast Resistance: ") + + EnumChatFormatting.YELLOW + + tBlock.getExplosionResistance( + aPlayer, aWorld, aX, aY, aZ, aPlayer.posX, aPlayer.posY, aPlayer.posZ) + + EnumChatFormatting.RESET); + if (tBlock.isBeaconBase(aWorld, aX, aY, aZ, aX, aY + 1, aZ)) + tList.add(EnumChatFormatting.GOLD + + GT_Utility.trans("166", "Is valid Beacon Pyramid Material") + + EnumChatFormatting.RESET); } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); } @@ -2254,13 +3167,17 @@ public class GT_Utility { try { if (tTileEntity instanceof IFluidHandler) { rEUAmount += 500; - final FluidTankInfo[] tTanks = ((IFluidHandler) tTileEntity).getTankInfo(ForgeDirection.getOrientation(aSide)); - if (tTanks != null) for (byte i = 0; i < tTanks.length; i++) { - tList.add( - GT_Utility.trans("167","Tank ") + i + ": " + - EnumChatFormatting.GREEN + formatNumbers((tTanks[i].fluid == null ? 0 : tTanks[i].fluid.amount)) + EnumChatFormatting.RESET + " L / " + - EnumChatFormatting.YELLOW + formatNumbers(tTanks[i].capacity) + EnumChatFormatting.RESET + " L " + EnumChatFormatting.GOLD + getFluidName(tTanks[i].fluid, true) + EnumChatFormatting.RESET); - } + final FluidTankInfo[] tTanks = + ((IFluidHandler) tTileEntity).getTankInfo(ForgeDirection.getOrientation(aSide)); + if (tTanks != null) + for (byte i = 0; i < tTanks.length; i++) { + tList.add(GT_Utility.trans("167", "Tank ") + i + ": " + EnumChatFormatting.GREEN + + formatNumbers((tTanks[i].fluid == null ? 0 : tTanks[i].fluid.amount)) + + EnumChatFormatting.RESET + " L / " + EnumChatFormatting.YELLOW + + formatNumbers(tTanks[i].capacity) + EnumChatFormatting.RESET + " L " + + EnumChatFormatting.GOLD + getFluidName(tTanks[i].fluid, true) + + EnumChatFormatting.RESET); + } } } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); @@ -2276,12 +3193,17 @@ public class GT_Utility { try { if (tTileEntity instanceof ic2.api.reactor.IReactor) { rEUAmount += 500; + tList.add(GT_Utility.trans("168", "Heat: ") + EnumChatFormatting.GREEN + + formatNumbers(((ic2.api.reactor.IReactor) tTileEntity).getHeat()) + + EnumChatFormatting.RESET + " / " + EnumChatFormatting.YELLOW + + formatNumbers(((ic2.api.reactor.IReactor) tTileEntity).getMaxHeat()) + + EnumChatFormatting.RESET); tList.add( - GT_Utility.trans("168","Heat: ") + EnumChatFormatting.GREEN + formatNumbers(((ic2.api.reactor.IReactor) tTileEntity).getHeat()) + EnumChatFormatting.RESET + " / " + - EnumChatFormatting.YELLOW + formatNumbers(((ic2.api.reactor.IReactor) tTileEntity).getMaxHeat()) + EnumChatFormatting.RESET); - tList.add( - GT_Utility.trans("169","HEM: ") + EnumChatFormatting.YELLOW + ((ic2.api.reactor.IReactor) tTileEntity).getHeatEffectModifier() + EnumChatFormatting.RESET - /* + GT_Utility.trans("170"," Base EU Output: ")/* + ((ic2.api.reactor.IReactor)tTileEntity).getOutput()*/); + GT_Utility.trans("169", "HEM: ") + + EnumChatFormatting.YELLOW + + ((ic2.api.reactor.IReactor) tTileEntity).getHeatEffectModifier() + + EnumChatFormatting.RESET + /* + GT_Utility.trans("170"," Base EU Output: ")/* + ((ic2.api.reactor.IReactor)tTileEntity).getOutput()*/ ); } } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); @@ -2291,7 +3213,10 @@ public class GT_Utility { final IAlignment tAlignment = ((IAlignmentProvider) tTileEntity).getAlignment(); if (tAlignment != null) { rEUAmount += 100; - tList.add(GT_Utility.trans("219", "Extended Facing: ") + EnumChatFormatting.GREEN + tAlignment.getExtendedFacing() + EnumChatFormatting.RESET); + tList.add(GT_Utility.trans("219", "Extended Facing: ") + + EnumChatFormatting.GREEN + + tAlignment.getExtendedFacing() + + EnumChatFormatting.RESET); } } } catch (Throwable e) { @@ -2300,8 +3225,19 @@ public class GT_Utility { try { if (tTileEntity instanceof ic2.api.tile.IWrenchable) { rEUAmount += 100; - tList.add(GT_Utility.trans("171","Facing: ") +EnumChatFormatting.GREEN+ ((ic2.api.tile.IWrenchable) tTileEntity).getFacing() +EnumChatFormatting.RESET+ GT_Utility.trans("172"," / Chance: ") +EnumChatFormatting.YELLOW+ (((ic2.api.tile.IWrenchable) tTileEntity).getWrenchDropRate() * 100) +EnumChatFormatting.RESET+ "%"); - tList.add(((ic2.api.tile.IWrenchable) tTileEntity).wrenchCanRemove(aPlayer) ? EnumChatFormatting.GREEN+ GT_Utility.trans("173","You can remove this with a Wrench") +EnumChatFormatting.RESET : EnumChatFormatting.RED+ GT_Utility.trans("174","You can NOT remove this with a Wrench") +EnumChatFormatting.RESET); + tList.add(GT_Utility.trans("171", "Facing: ") + EnumChatFormatting.GREEN + + ((ic2.api.tile.IWrenchable) tTileEntity).getFacing() + EnumChatFormatting.RESET + + GT_Utility.trans("172", " / Chance: ") + EnumChatFormatting.YELLOW + + (((ic2.api.tile.IWrenchable) tTileEntity).getWrenchDropRate() * 100) + + EnumChatFormatting.RESET + "%"); + tList.add( + ((ic2.api.tile.IWrenchable) tTileEntity).wrenchCanRemove(aPlayer) + ? EnumChatFormatting.GREEN + + GT_Utility.trans("173", "You can remove this with a Wrench") + + EnumChatFormatting.RESET + : EnumChatFormatting.RED + + GT_Utility.trans("174", "You can NOT remove this with a Wrench") + + EnumChatFormatting.RESET); } } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); @@ -2309,7 +3245,10 @@ public class GT_Utility { try { if (tTileEntity instanceof ic2.api.energy.tile.IEnergyConductor) { rEUAmount += 200; - tList.add(GT_Utility.trans("175","Conduction Loss: ") + EnumChatFormatting.YELLOW + ((ic2.api.energy.tile.IEnergyConductor) tTileEntity).getConductionLoss() + EnumChatFormatting.RESET); + tList.add(GT_Utility.trans("175", "Conduction Loss: ") + + EnumChatFormatting.YELLOW + + ((ic2.api.energy.tile.IEnergyConductor) tTileEntity).getConductionLoss() + + EnumChatFormatting.RESET); } } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); @@ -2317,9 +3256,11 @@ public class GT_Utility { try { if (tTileEntity instanceof ic2.api.tile.IEnergyStorage) { rEUAmount += 200; - tList.add( - GT_Utility.trans("176","Contained Energy: ") + EnumChatFormatting.YELLOW + formatNumbers(((ic2.api.tile.IEnergyStorage) tTileEntity).getStored()) + EnumChatFormatting.RESET + " EU / " + - EnumChatFormatting.YELLOW + formatNumbers(((ic2.api.tile.IEnergyStorage) tTileEntity).getCapacity()) + EnumChatFormatting.RESET + " EU"); + tList.add(GT_Utility.trans("176", "Contained Energy: ") + EnumChatFormatting.YELLOW + + formatNumbers(((ic2.api.tile.IEnergyStorage) tTileEntity).getStored()) + + EnumChatFormatting.RESET + " EU / " + EnumChatFormatting.YELLOW + + formatNumbers(((ic2.api.tile.IEnergyStorage) tTileEntity).getCapacity()) + + EnumChatFormatting.RESET + " EU"); } } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); @@ -2327,7 +3268,10 @@ public class GT_Utility { try { if (tTileEntity instanceof IUpgradableMachine) { rEUAmount += 500; - if (((IUpgradableMachine) tTileEntity).hasMufflerUpgrade()) tList.add(EnumChatFormatting.GREEN + GT_Utility.trans("177","Has Muffler Upgrade") + EnumChatFormatting.RESET); + if (((IUpgradableMachine) tTileEntity).hasMufflerUpgrade()) + tList.add(EnumChatFormatting.GREEN + + GT_Utility.trans("177", "Has Muffler Upgrade") + + EnumChatFormatting.RESET); } } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); @@ -2343,8 +3287,10 @@ public class GT_Utility { rEUAmount += 400; int tValue = 0; if (0 < (tValue = ((IMachineProgress) tTileEntity).getMaxProgress())) - tList.add(GT_Utility.trans("178","Progress/Load: ") + EnumChatFormatting.GREEN + formatNumbers(((IMachineProgress) tTileEntity).getProgress()) + EnumChatFormatting.RESET + " / " + - EnumChatFormatting.YELLOW + formatNumbers(tValue) + EnumChatFormatting.RESET); + tList.add(GT_Utility.trans("178", "Progress/Load: ") + EnumChatFormatting.GREEN + + formatNumbers(((IMachineProgress) tTileEntity).getProgress()) + + EnumChatFormatting.RESET + " / " + EnumChatFormatting.YELLOW + formatNumbers(tValue) + + EnumChatFormatting.RESET); } } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); @@ -2352,36 +3298,55 @@ public class GT_Utility { try { if (tTileEntity instanceof ICoverable) { rEUAmount += 300; - final String tString = ((ICoverable) tTileEntity).getCoverBehaviorAtSideNew((byte) aSide).getDescription((byte) aSide, ((ICoverable) tTileEntity).getCoverIDAtSide((byte) aSide), ((ICoverable) tTileEntity).getComplexCoverDataAtSide((byte) aSide), (ICoverable) tTileEntity); + final String tString = ((ICoverable) tTileEntity) + .getCoverBehaviorAtSideNew((byte) aSide) + .getDescription( + (byte) aSide, + ((ICoverable) tTileEntity).getCoverIDAtSide((byte) aSide), + ((ICoverable) tTileEntity).getComplexCoverDataAtSide((byte) aSide), + (ICoverable) tTileEntity); if (tString != null && !tString.equals(E)) tList.add(tString); } } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); } try { - if (tTileEntity instanceof IBasicEnergyContainer && ((IBasicEnergyContainer) tTileEntity).getEUCapacity() > 0) { - tList.add( - GT_Utility.trans("179","Max IN: ") + EnumChatFormatting.RED + formatNumbers(((IBasicEnergyContainer) tTileEntity).getInputVoltage()) + " (" + GT_Values.VN[getTier(((IBasicEnergyContainer) tTileEntity).getInputVoltage())] + ") " + EnumChatFormatting.RESET + - GT_Utility.trans("182"," EU at ") + EnumChatFormatting.RED + formatNumbers(((IBasicEnergyContainer)tTileEntity).getInputAmperage()) + EnumChatFormatting.RESET + GT_Utility.trans("183"," A")); - tList.add( - GT_Utility.trans("181","Max OUT: ") + EnumChatFormatting.RED + formatNumbers(((IBasicEnergyContainer) tTileEntity).getOutputVoltage()) + " (" + GT_Values.VN[getTier(((IBasicEnergyContainer) tTileEntity).getOutputVoltage())] + ") " + EnumChatFormatting.RESET + - GT_Utility.trans("182"," EU at ") + EnumChatFormatting.RED + formatNumbers(((IBasicEnergyContainer) tTileEntity).getOutputAmperage()) + EnumChatFormatting.RESET + GT_Utility.trans("183"," A")); - tList.add( - GT_Utility.trans("184","Energy: ") + EnumChatFormatting.GREEN + formatNumbers(((IBasicEnergyContainer) tTileEntity).getStoredEU()) + EnumChatFormatting.RESET + " EU / " + - EnumChatFormatting.YELLOW + formatNumbers(((IBasicEnergyContainer) tTileEntity).getEUCapacity()) + EnumChatFormatting.RESET + " EU"); + if (tTileEntity instanceof IBasicEnergyContainer + && ((IBasicEnergyContainer) tTileEntity).getEUCapacity() > 0) { + tList.add(GT_Utility.trans("179", "Max IN: ") + EnumChatFormatting.RED + + formatNumbers(((IBasicEnergyContainer) tTileEntity).getInputVoltage()) + " (" + + GT_Values.VN[getTier(((IBasicEnergyContainer) tTileEntity).getInputVoltage())] + ") " + + EnumChatFormatting.RESET + GT_Utility.trans("182", " EU at ") + EnumChatFormatting.RED + + formatNumbers(((IBasicEnergyContainer) tTileEntity).getInputAmperage()) + + EnumChatFormatting.RESET + GT_Utility.trans("183", " A")); + tList.add(GT_Utility.trans("181", "Max OUT: ") + EnumChatFormatting.RED + + formatNumbers(((IBasicEnergyContainer) tTileEntity).getOutputVoltage()) + " (" + + GT_Values.VN[getTier(((IBasicEnergyContainer) tTileEntity).getOutputVoltage())] + ") " + + EnumChatFormatting.RESET + GT_Utility.trans("182", " EU at ") + EnumChatFormatting.RED + + formatNumbers(((IBasicEnergyContainer) tTileEntity).getOutputAmperage()) + + EnumChatFormatting.RESET + GT_Utility.trans("183", " A")); + tList.add(GT_Utility.trans("184", "Energy: ") + EnumChatFormatting.GREEN + + formatNumbers(((IBasicEnergyContainer) tTileEntity).getStoredEU()) + + EnumChatFormatting.RESET + " EU / " + EnumChatFormatting.YELLOW + + formatNumbers(((IBasicEnergyContainer) tTileEntity).getEUCapacity()) + + EnumChatFormatting.RESET + " EU"); } } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); } try { if (tTileEntity instanceof IGregTechTileEntity) { - tList.add(GT_Utility.trans("186","Owned by: ") + EnumChatFormatting.BLUE + ((IGregTechTileEntity) tTileEntity).getOwnerName() + EnumChatFormatting.RESET); + tList.add(GT_Utility.trans("186", "Owned by: ") + + EnumChatFormatting.BLUE + + ((IGregTechTileEntity) tTileEntity).getOwnerName() + + EnumChatFormatting.RESET); } } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); } try { - if (tTileEntity instanceof IGregTechDeviceInformation && ((IGregTechDeviceInformation) tTileEntity).isGivingInformation()) { + if (tTileEntity instanceof IGregTechDeviceInformation + && ((IGregTechDeviceInformation) tTileEntity).isGivingInformation()) { tList.addAll(Arrays.asList(((IGregTechDeviceInformation) tTileEntity).getInfoData())); } } catch (Throwable e) { @@ -2391,32 +3356,40 @@ public class GT_Utility { if (tTileEntity instanceof ic2.api.crops.ICropTile) { rEUAmount += 1000; final ic2.api.crops.ICropTile crop = (ic2.api.crops.ICropTile) tTileEntity; - if (crop.getScanLevel() < 4) - crop.setScanLevel((byte) 4); + if (crop.getScanLevel() < 4) crop.setScanLevel((byte) 4); if (crop.getCrop() != null) { - tList.add(GT_Utility.trans("187", "Type -- Crop-Name: ") + crop.getCrop().name() - + GT_Utility.trans("188", " Growth: ") + crop.getGrowth() - + GT_Utility.trans("189", " Gain: ") + crop.getGain() - + GT_Utility.trans("190", " Resistance: ") + crop.getResistance() - ); + tList.add(GT_Utility.trans("187", "Type -- Crop-Name: ") + + crop.getCrop().name() + + GT_Utility.trans("188", " Growth: ") + + crop.getGrowth() + + GT_Utility.trans("189", " Gain: ") + + crop.getGain() + + GT_Utility.trans("190", " Resistance: ") + + crop.getResistance()); } - tList.add(GT_Utility.trans("191","Plant -- Fertilizer: ") + crop.getNutrientStorage() - + GT_Utility.trans("192"," Water: ") + crop.getHydrationStorage() - + GT_Utility.trans("193"," Weed-Ex: ") + crop.getWeedExStorage() - + GT_Utility.trans("194"," Scan-Level: ") + crop.getScanLevel() - ); - tList.add(GT_Utility.trans("195","Environment -- Nutrients: ") + crop.getNutrients() - + GT_Utility.trans("196"," Humidity: ") + crop.getHumidity() - + GT_Utility.trans("197"," Air-Quality: ") + crop.getAirQuality() - ); + tList.add(GT_Utility.trans("191", "Plant -- Fertilizer: ") + + crop.getNutrientStorage() + + GT_Utility.trans("192", " Water: ") + + crop.getHydrationStorage() + + GT_Utility.trans("193", " Weed-Ex: ") + + crop.getWeedExStorage() + + GT_Utility.trans("194", " Scan-Level: ") + + crop.getScanLevel()); + tList.add(GT_Utility.trans("195", "Environment -- Nutrients: ") + + crop.getNutrients() + + GT_Utility.trans("196", " Humidity: ") + + crop.getHumidity() + + GT_Utility.trans("197", " Air-Quality: ") + + crop.getAirQuality()); if (crop.getCrop() != null) { final StringBuilder tStringB = new StringBuilder(); for (String tAttribute : crop.getCrop().attributes()) { tStringB.append(", ").append(tAttribute); } final String tString = tStringB.toString(); - tList.add(GT_Utility.trans("198","Attributes:") + tString.replaceFirst(",", E)); - tList.add(GT_Utility.trans("199","Discovered by: ") + crop.getCrop().discoveredBy()); + tList.add(GT_Utility.trans("198", "Attributes:") + tString.replaceFirst(",", E)); + tList.add(GT_Utility.trans("199", "Discovered by: ") + + crop.getCrop().discoveredBy()); } } } catch (Throwable e) { @@ -2425,34 +3398,41 @@ public class GT_Utility { try { if (tTileEntity instanceof forestry.arboriculture.tiles.TileLeaves) { - final forestry.arboriculture.tiles.TileLeaves tileLeaves = (forestry.arboriculture.tiles.TileLeaves)tTileEntity; + final forestry.arboriculture.tiles.TileLeaves tileLeaves = + (forestry.arboriculture.tiles.TileLeaves) tTileEntity; final forestry.api.arboriculture.ITree tree = tileLeaves.getTree(); - if (tree != null ) { + if (tree != null) { rEUAmount += 1000; - if (!tree.isAnalyzed()) - tree.analyze(); + if (!tree.isAnalyzed()) tree.analyze(); tree.addTooltip(tList); } } } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); } - } final Chunk currentChunk = aWorld.getChunkFromBlockCoords(aX, aZ); if (aPlayer.capabilities.isCreativeMode) { - final FluidStack tFluid = undergroundOilReadInformation(currentChunk);//-# to only read - if (tFluid!=null) - tList.add(EnumChatFormatting.GOLD + tFluid.getLocalizedName() + EnumChatFormatting.RESET + ": " + EnumChatFormatting.YELLOW + formatNumbers(tFluid.amount) + EnumChatFormatting.RESET + " L"); + final FluidStack tFluid = undergroundOilReadInformation(currentChunk); // -# to only read + if (tFluid != null) + tList.add(EnumChatFormatting.GOLD + tFluid.getLocalizedName() + EnumChatFormatting.RESET + ": " + + EnumChatFormatting.YELLOW + formatNumbers(tFluid.amount) + EnumChatFormatting.RESET + " L"); else - tList.add(EnumChatFormatting.GOLD + GT_Utility.trans("201","Nothing") + EnumChatFormatting.RESET + ": " + EnumChatFormatting.YELLOW + '0' + EnumChatFormatting.RESET + " L"); + tList.add(EnumChatFormatting.GOLD + GT_Utility.trans("201", "Nothing") + EnumChatFormatting.RESET + ": " + + EnumChatFormatting.YELLOW + '0' + EnumChatFormatting.RESET + " L"); } -// if(aPlayer.capabilities.isCreativeMode){ + // if(aPlayer.capabilities.isCreativeMode){ if (GT_Pollution.hasPollution(currentChunk)) { - tList.add(GT_Utility.trans("202", "Pollution in Chunk: ") + EnumChatFormatting.RED + formatNumbers(GT_Pollution.getPollution(currentChunk)) + EnumChatFormatting.RESET + GT_Utility.trans("203", " gibbl")); + tList.add(GT_Utility.trans("202", "Pollution in Chunk: ") + + EnumChatFormatting.RED + + formatNumbers(GT_Pollution.getPollution(currentChunk)) + + EnumChatFormatting.RESET + + GT_Utility.trans("203", " gibbl")); } else { - tList.add(EnumChatFormatting.GREEN + GT_Utility.trans("204", "No Pollution in Chunk! HAYO!") + EnumChatFormatting.RESET); + tList.add(EnumChatFormatting.GREEN + + GT_Utility.trans("204", "No Pollution in Chunk! HAYO!") + + EnumChatFormatting.RESET); } try { @@ -2465,15 +3445,28 @@ public class GT_Utility { if (D1) e.printStackTrace(GT_Log.err); } - final BlockScanningEvent tEvent = new BlockScanningEvent(aWorld, aPlayer, aX, aY, aZ, (byte) aSide, aScanLevel, tBlock, tTileEntity, tList, aClickX, aClickY, aClickZ); + final BlockScanningEvent tEvent = new BlockScanningEvent( + aWorld, + aPlayer, + aX, + aY, + aZ, + (byte) aSide, + aScanLevel, + tBlock, + tTileEntity, + tList, + aClickX, + aClickY, + aClickZ); tEvent.mEUCost = rEUAmount; MinecraftForge.EVENT_BUS.post(tEvent); if (!tEvent.isCanceled()) aList.addAll(tList); return tEvent.mEUCost; } - public static String trans(String aKey, String aEnglish){ - return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_" + aKey, aEnglish, false); + public static String trans(String aKey, String aEnglish) { + return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_" + aKey, aEnglish, false); } /** @@ -2482,19 +3475,19 @@ public class GT_Utility { public static float[] getClickedFacingCoords(byte aSide, float aX, float aY, float aZ) { switch (aSide) { case 0: - return new float[]{Math.min(0.99F, Math.max(0, 1 - aX)), Math.min(0.99F, Math.max(0, aZ))}; + return new float[] {Math.min(0.99F, Math.max(0, 1 - aX)), Math.min(0.99F, Math.max(0, aZ))}; case 1: - return new float[]{Math.min(0.99F, Math.max(0, aX)), Math.min(0.99F, Math.max(0, aZ))}; + return new float[] {Math.min(0.99F, Math.max(0, aX)), Math.min(0.99F, Math.max(0, aZ))}; case 2: - return new float[]{Math.min(0.99F, Math.max(0, 1 - aX)), Math.min(0.99F, Math.max(0, 1 - aY))}; + return new float[] {Math.min(0.99F, Math.max(0, 1 - aX)), Math.min(0.99F, Math.max(0, 1 - aY))}; case 3: - return new float[]{Math.min(0.99F, Math.max(0, aX)), Math.min(0.99F, Math.max(0, 1 - aY))}; + return new float[] {Math.min(0.99F, Math.max(0, aX)), Math.min(0.99F, Math.max(0, 1 - aY))}; case 4: - return new float[]{Math.min(0.99F, Math.max(0, aZ)), Math.min(0.99F, Math.max(0, 1 - aY))}; + return new float[] {Math.min(0.99F, Math.max(0, aZ)), Math.min(0.99F, Math.max(0, 1 - aY))}; case 5: - return new float[]{Math.min(0.99F, Math.max(0, 1 - aZ)), Math.min(0.99F, Math.max(0, 1 - aY))}; + return new float[] {Math.min(0.99F, Math.max(0, 1 - aZ)), Math.min(0.99F, Math.max(0, 1 - aY))}; default: - return new float[]{0.5F, 0.5F}; + return new float[] {0.5F, 0.5F}; } } @@ -2554,15 +3547,15 @@ public class GT_Utility { return -1; } - private static DecimalFormat getDecimalFormat(){ + private static DecimalFormat getDecimalFormat() { return decimalFormatters.computeIfAbsent(Locale.getDefault(Locale.Category.FORMAT), locale -> { - DecimalFormat numberFormat =new DecimalFormat();//uses the necessary locale inside anyway + DecimalFormat numberFormat = new DecimalFormat(); // uses the necessary locale inside anyway numberFormat.setGroupingUsed(true); numberFormat.setMaximumFractionDigits(2); numberFormat.setRoundingMode(RoundingMode.HALF_UP); DecimalFormatSymbols decimalFormatSymbols = numberFormat.getDecimalFormatSymbols(); - decimalFormatSymbols.setGroupingSeparator(',');// Use sensible separator for best clarity. - numberFormat.setDecimalFormatSymbols(decimalFormatSymbols); + decimalFormatSymbols.setGroupingSeparator(','); // Use sensible separator for best clarity. + numberFormat.setDecimalFormatSymbols(decimalFormatSymbols); return numberFormat; }); } @@ -2584,48 +3577,44 @@ public class GT_Utility { */ public static boolean consumeItems(EntityPlayer player, ItemStack stack, Item item, int count) { if (stack != null && stack.getItem() == item && stack.stackSize >= count) { - if ((!player.capabilities.isCreativeMode) && (stack.stackSize != 111)) - stack.stackSize -= count; + if ((!player.capabilities.isCreativeMode) && (stack.stackSize != 111)) stack.stackSize -= count; return true; } return false; - } + } /* * Check if stack has enough items of given gregtech material (will be oredicted) * and subtract from stack, if there's no creative or 111 stack. */ - public static boolean consumeItems(EntityPlayer player, ItemStack stack, gregtech.api.enums.Materials mat, int count) { + public static boolean consumeItems( + EntityPlayer player, ItemStack stack, gregtech.api.enums.Materials mat, int count) { if (stack != null - && GT_OreDictUnificator.getItemData(stack).mMaterial.mMaterial == mat - && stack.stackSize >= count) { - if ((!player.capabilities.isCreativeMode) && (stack.stackSize != 111)) - stack.stackSize -= count; + && GT_OreDictUnificator.getItemData(stack).mMaterial.mMaterial == mat + && stack.stackSize >= count) { + if ((!player.capabilities.isCreativeMode) && (stack.stackSize != 111)) stack.stackSize -= count; return true; - } + } return false; } - public static ArrayList<String> sortByValueToList( Map<String, Integer> map ) { - List<Map.Entry<String, Integer>> list = - new LinkedList<>(map.entrySet()); + public static ArrayList<String> sortByValueToList(Map<String, Integer> map) { + List<Map.Entry<String, Integer>> list = new LinkedList<>(map.entrySet()); list.sort((o1, o2) -> o2.getValue() - o1.getValue()); ArrayList<String> result = new ArrayList<>(); - for (Map.Entry<String, Integer> e : list) - result.add(e.getKey()); + for (Map.Entry<String, Integer> e : list) result.add(e.getKey()); return result; } public static String joinListToString(List<String> list) { StringBuilder result = new StringBuilder(32); - for (String s : list) - result.append(result.length()==0?s:'|'+s); + for (String s : list) result.append(result.length() == 0 ? s : '|' + s); return result.toString(); } - public static ItemStack getIntegratedCircuit(int config){ - return ItemList.Circuit_Integrated.getWithDamage(0, config); + public static ItemStack getIntegratedCircuit(int config) { + return ItemList.Circuit_Integrated.getWithDamage(0, config); } public static float getBlockHardnessAt(World aWorld, int aX, int aY, int aZ) { @@ -2634,7 +3623,9 @@ public class GT_Utility { public static FakePlayer getFakePlayer(IGregTechTileEntity aBaseMetaTileEntity) { if (aBaseMetaTileEntity.getWorld() instanceof WorldServer) { - return FakePlayerFactory.get((WorldServer) aBaseMetaTileEntity.getWorld(), new GameProfile(aBaseMetaTileEntity.getOwnerUuid(), aBaseMetaTileEntity.getOwnerName())); + return FakePlayerFactory.get( + (WorldServer) aBaseMetaTileEntity.getWorld(), + new GameProfile(aBaseMetaTileEntity.getOwnerUuid(), aBaseMetaTileEntity.getOwnerName())); } return null; } @@ -2642,7 +3633,8 @@ public class GT_Utility { public static boolean eraseBlockByFakePlayer(FakePlayer aPlayer, int aX, int aY, int aZ, boolean isSimulate) { if (aPlayer == null) return false; World aWorld = aPlayer.worldObj; - BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(aX, aY, aZ, aWorld, aWorld.getBlock(aX, aY, aZ), aWorld.getBlockMetadata(aX, aY, aZ), aPlayer); + BlockEvent.BreakEvent event = new BlockEvent.BreakEvent( + aX, aY, aZ, aWorld, aWorld.getBlock(aX, aY, aZ), aWorld.getBlockMetadata(aX, aY, aZ), aPlayer); MinecraftForge.EVENT_BUS.post(event); if (!event.isCanceled()) { if (!isSimulate) return aWorld.setBlockToAir(aX, aY, aZ); @@ -2651,10 +3643,12 @@ public class GT_Utility { return false; } - public static boolean setBlockByFakePlayer(FakePlayer aPlayer, int aX, int aY, int aZ, Block aBlock, int aMeta, boolean isSimulate) { + public static boolean setBlockByFakePlayer( + FakePlayer aPlayer, int aX, int aY, int aZ, Block aBlock, int aMeta, boolean isSimulate) { if (aPlayer == null) return false; World aWorld = aPlayer.worldObj; - BlockEvent.PlaceEvent event = ForgeEventFactory.onPlayerBlockPlace(aPlayer, new BlockSnapshot(aWorld, aX, aY, aZ, aBlock, aMeta), ForgeDirection.UNKNOWN); + BlockEvent.PlaceEvent event = ForgeEventFactory.onPlayerBlockPlace( + aPlayer, new BlockSnapshot(aWorld, aX, aY, aZ, aBlock, aMeta), ForgeDirection.UNKNOWN); if (!event.isCanceled()) { if (!isSimulate) return aWorld.setBlock(aX, aY, aZ, aBlock, aMeta, 3); return true; @@ -2662,18 +3656,16 @@ public class GT_Utility { return false; } - public static int findMatchingStackInList(List<ItemStack> aStacks, ItemStack aStack) { - if (isStackInvalid(aStack)) - return -1; + public static int findMatchingStackInList(List<ItemStack> aStacks, ItemStack aStack) { + if (isStackInvalid(aStack)) return -1; for (int i = 0, aStacksSize = aStacks.size(); i < aStacksSize; i++) { ItemStack tStack = aStacks.get(i); - if (areStacksEqual(aStack, tStack)) - return i; + if (areStacksEqual(aStack, tStack)) return i; } return -1; } - public static class ItemNBT { + public static class ItemNBT { public static void setNBT(ItemStack aStack, NBTTagCompound aNBT) { if (aNBT == null) { aStack.setTagCompound(null); @@ -2682,7 +3674,10 @@ public class GT_Utility { ArrayList<String> tTagsToRemove = new ArrayList<>(); for (Object tKey : aNBT.func_150296_c()) { NBTBase tValue = aNBT.getTag((String) tKey); - if (tValue == null || (tValue instanceof NBTPrimitive && ((NBTPrimitive) tValue).func_150291_c() == 0) || (tValue instanceof NBTTagString && isStringInvalid(((NBTTagString) tValue).func_150285_a_()))) + if (tValue == null + || (tValue instanceof NBTPrimitive && ((NBTPrimitive) tValue).func_150291_c() == 0) + || (tValue instanceof NBTTagString + && isStringInvalid(((NBTTagString) tValue).func_150285_a_()))) tTagsToRemove.add((String) tKey); } for (Object tKey : tTagsToRemove) aNBT.removeTag((String) tKey); @@ -2750,11 +3745,15 @@ public class GT_Utility { return tNBT.getString("author"); } - public static void setProspectionData(ItemStack aStack, int aX, int aY, int aZ, int aDim, FluidStack aFluid, String... aOres) { + public static void setProspectionData( + ItemStack aStack, int aX, int aY, int aZ, int aDim, FluidStack aFluid, String... aOres) { NBTTagCompound tNBT = getNBT(aStack); StringBuilder tData = new StringBuilder(aX + "," + aY + "," + aZ + "," + aDim + ","); - if (aFluid!=null) - tData.append(aFluid.amount).append(",").append(aFluid.getLocalizedName()).append(",");//TODO CHECK IF THAT /5000 is needed (Not needed) + if (aFluid != null) + tData.append(aFluid.amount) + .append(",") + .append(aFluid.getLocalizedName()) + .append(","); // TODO CHECK IF THAT /5000 is needed (Not needed) for (String tString : aOres) { tData.append(tString).append(","); } @@ -2765,7 +3764,10 @@ public class GT_Utility { public static void setAdvancedProspectionData( byte aTier, ItemStack aStack, - int aX, short aY, int aZ, int aDim, + int aX, + short aY, + int aZ, + int aDim, ArrayList<String> aOils, ArrayList<String> aOres, int aRadius) { @@ -2784,38 +3786,40 @@ public class GT_Utility { // oils ArrayList<String> tOilsTransformed = new ArrayList<>(aOils.size()); for (String aStr : aOils) { - String[] aStats = aStr.split(","); - tOilsTransformed.add(aStats[0] + ": " + aStats[1] + "L " + aStats[2]); + String[] aStats = aStr.split(","); + tOilsTransformed.add(aStats[0] + ": " + aStats[1] + "L " + aStats[2]); } tNBT.setString("prospection_oils", joinListToString(tOilsTransformed)); - String tOilsPosStr = "X: " + Math.floorDiv(aX, 16*8)*16*8 + " Z: " + Math.floorDiv(aZ, 16*8)*16*8 + "\n"; - int xOff = aX - Math.floorDiv(aX, 16*8)*16*8; - xOff = xOff/16; + String tOilsPosStr = + "X: " + Math.floorDiv(aX, 16 * 8) * 16 * 8 + " Z: " + Math.floorDiv(aZ, 16 * 8) * 16 * 8 + "\n"; + int xOff = aX - Math.floorDiv(aX, 16 * 8) * 16 * 8; + xOff = xOff / 16; int xOffRemain = 7 - xOff; - int zOff = aZ - Math.floorDiv(aZ, 16*8)*16*8; - zOff = zOff/16; + int zOff = aZ - Math.floorDiv(aZ, 16 * 8) * 16 * 8; + zOff = zOff / 16; int zOffRemain = 7 - zOff; - for( ; zOff > 0; zOff-- ) { + for (; zOff > 0; zOff--) { tOilsPosStr = tOilsPosStr.concat("--------\n"); } - for( ; xOff > 0; xOff-- ) { + for (; xOff > 0; xOff--) { tOilsPosStr = tOilsPosStr.concat("-"); } tOilsPosStr = tOilsPosStr.concat("P"); - for( ; xOffRemain > 0; xOffRemain-- ) { + for (; xOffRemain > 0; xOffRemain--) { tOilsPosStr = tOilsPosStr.concat("-"); } tOilsPosStr = tOilsPosStr.concat("\n"); - for( ; zOffRemain > 0; zOffRemain-- ) { + for (; zOffRemain > 0; zOffRemain--) { tOilsPosStr = tOilsPosStr.concat("--------\n"); } - tOilsPosStr = tOilsPosStr.concat( " X: " + (Math.floorDiv(aX, 16*8) + 1)*16*8 + " Z: " + (Math.floorDiv(aZ, 16*8) + 1)*16*8 ); // +1 oilfied to find bottomright of [5] + tOilsPosStr = tOilsPosStr.concat(" X: " + (Math.floorDiv(aX, 16 * 8) + 1) * 16 * 8 + " Z: " + + (Math.floorDiv(aZ, 16 * 8) + 1) * 16 * 8); // +1 oilfied to find bottomright of [5] tNBT.setString("prospection_oils_pos", tOilsPosStr); @@ -2832,13 +3836,18 @@ public class GT_Utility { String tData = tNBT.getString("prospection"); String[] tDataArray = tData.split(","); if (tDataArray.length > 6) { - tNBT.setString("author", " Dim: " + tDataArray[3] + "X: " + tDataArray[0] + " Y: " + tDataArray[1] + " Z: " + tDataArray[2]); + tNBT.setString( + "author", + " Dim: " + tDataArray[3] + "X: " + tDataArray[0] + " Y: " + tDataArray[1] + " Z: " + + tDataArray[2]); NBTTagList tNBTList = new NBTTagList(); StringBuilder tOres = new StringBuilder(" Prospected Ores: "); for (int i = 6; tDataArray.length > i; i++) { tOres.append(tDataArray[i]).append(" "); } - tNBTList.appendTag(new NBTTagString("Tier " + tTier + " Prospecting Data From: X" + tDataArray[0] + " Z:" + tDataArray[2] + " Dim:" + tDataArray[3] + " Produces " + tDataArray[4] + "L " + tDataArray[5] + " " + tOres)); + tNBTList.appendTag(new NBTTagString("Tier " + tTier + " Prospecting Data From: X" + tDataArray[0] + + " Z:" + tDataArray[2] + " Dim:" + tDataArray[3] + " Produces " + tDataArray[4] + "L " + + tDataArray[5] + " " + tOres)); tNBT.setTag("pages", tNBTList); } } else { // advanced prospection data @@ -2855,19 +3864,16 @@ public class GT_Utility { NBTTagList tNBTList = new NBTTagList(); String tPageText = "Prospector report\n" - + tPos + "\n\n" - + "Oils: " + (tOils != null ? tOils.length : 0) + "\n\n" - + "Ores within " + tRadius + " blocks\n\n" - + "Location is center of orevein\n\n" - + "Check NEI to confirm orevein type"; + + tPos + "\n\n" + + "Oils: " + (tOils != null ? tOils.length : 0) + "\n\n" + + "Ores within " + tRadius + " blocks\n\n" + + "Location is center of orevein\n\n" + + "Check NEI to confirm orevein type"; tNBTList.appendTag(new NBTTagString(tPageText)); - if (tOres != null) - fillBookWithList(tNBTList, "Ores Found %s\n\n", "\n", 7, tOres); - + if (tOres != null) fillBookWithList(tNBTList, "Ores Found %s\n\n", "\n", 7, tOres); - if (tOils != null) - fillBookWithList(tNBTList, "Oils%s\n\n", "\n", 9, tOils); + if (tOils != null) fillBookWithList(tNBTList, "Oils%s\n\n", "\n", 9, tOils); tPageText = "Oil notes\n\n" + "Prospects from NW to SE 576 chunks" @@ -2879,26 +3885,27 @@ public class GT_Utility { + "[5] - Prospector in this 8x8 area"; tNBTList.appendTag(new NBTTagString(tPageText)); - tPageText = "Corners of [5] are \n" + - tOilsPosStr + "\n" + - "P - Prospector in 8x8 field"; + tPageText = "Corners of [5] are \n" + tOilsPosStr + "\n" + "P - Prospector in 8x8 field"; tNBTList.appendTag(new NBTTagString(tPageText)); - tNBT.setString("author", tPos.replace("\n"," ")); + tNBT.setString("author", tPos.replace("\n", " ")); tNBT.setTag("pages", tNBTList); } setNBT(aStack, tNBT); } - public static void fillBookWithList(NBTTagList aBook, String aPageHeader, String aListDelimiter, int aItemsPerPage, String[] list) { + public static void fillBookWithList( + NBTTagList aBook, String aPageHeader, String aListDelimiter, int aItemsPerPage, String[] list) { String aPageFormatter = " %d/%d"; int tTotalPages = list.length / aItemsPerPage + (list.length % aItemsPerPage > 0 ? 1 : 0); int tPage = 0; StringBuilder tPageText; do { tPageText = new StringBuilder(); - for (int i = tPage*aItemsPerPage; i < (tPage+1)*aItemsPerPage && i < list.length; i += 1) - tPageText.append((tPageText.length() == 0) ? "" : aListDelimiter).append(list[i]); + for (int i = tPage * aItemsPerPage; i < (tPage + 1) * aItemsPerPage && i < list.length; i += 1) + tPageText + .append((tPageText.length() == 0) ? "" : aListDelimiter) + .append(list[i]); if (tPageText.length() > 0) { String tPageCounter = tTotalPages > 1 ? String.format(aPageFormatter, tPage + 1, tTotalPages) : ""; @@ -2955,7 +3962,9 @@ public class GT_Utility { if (Enchantment.enchantmentsList[short1] != null) aBullshitModifier.calculateModifier(Enchantment.enchantmentsList[short1], short2); } - } catch (Throwable e) {/**/} + } catch (Throwable e) { + /**/ + } } } } @@ -2991,8 +4000,7 @@ public class GT_Utility { public EntityLivingBase mPlayer; public Entity mEntity; - BullshitIteratorA() { - } + BullshitIteratorA() {} @Override public void calculateModifier(Enchantment aEnchantment, int aLevel) { @@ -3004,8 +4012,7 @@ public class GT_Utility { public EntityLivingBase mPlayer; public Entity mEntity; - BullshitIteratorB() { - } + BullshitIteratorB() {} @Override public void calculateModifier(Enchantment aEnchantment, int aLevel) { @@ -3014,27 +4021,31 @@ public class GT_Utility { } } - public static String toSubscript(long no){ - char[] chars=Long.toString(no).toCharArray(); - for(int i=0;i<chars.length;i++){ - chars[i]+=8272; + public static String toSubscript(long no) { + char[] chars = Long.toString(no).toCharArray(); + for (int i = 0; i < chars.length; i++) { + chars[i] += 8272; } return new String(chars); } - public static boolean isPartOfMaterials(ItemStack aStack, Materials aMaterials){ - return GT_OreDictUnificator.getAssociation(aStack) != null && GT_OreDictUnificator.getAssociation(aStack).mMaterial.mMaterial.equals(aMaterials); + public static boolean isPartOfMaterials(ItemStack aStack, Materials aMaterials) { + return GT_OreDictUnificator.getAssociation(aStack) != null + && GT_OreDictUnificator.getAssociation(aStack) + .mMaterial + .mMaterial + .equals(aMaterials); } - public static boolean isPartOfOrePrefix(ItemStack aStack, OrePrefixes aPrefix){ - return GT_OreDictUnificator.getAssociation(aStack) != null && GT_OreDictUnificator.getAssociation(aStack).mPrefix.equals(aPrefix); + public static boolean isPartOfOrePrefix(ItemStack aStack, OrePrefixes aPrefix) { + return GT_OreDictUnificator.getAssociation(aStack) != null + && GT_OreDictUnificator.getAssociation(aStack).mPrefix.equals(aPrefix); } public static final ImmutableSet<String> ORE_BLOCK_CLASSES = ImmutableSet.of( "com.github.bartimaeusnek.bartworks.system.material.BW_MetaGenerated_Ores", "com.github.bartimaeusnek.bartworks.system.material.BW_MetaGenerated_SmallOres", - "gtPlusPlus.core.block.base.BlockBaseOre" - ); + "gtPlusPlus.core.block.base.BlockBaseOre"); public static boolean isOre(Block aBlock, int aMeta) { return (aBlock instanceof GT_Block_Ores_Abstract) @@ -3047,7 +4058,7 @@ public class GT_Utility { if (sOreTable.containsKey(tItem)) { return sOreTable.get(tItem); } - for (int id: OreDictionary.getOreIDs(aStack)) { + for (int id : OreDictionary.getOreIDs(aStack)) { if (OreDictionary.getOreName(id).startsWith("ore")) { sOreTable.put(tItem, true); return true; @@ -3063,9 +4074,11 @@ public class GT_Utility { */ public static ItemStack getCobbleForOre(Block ore, short metaData) { // We need to convert small ores to regular ores because small ores don't have associated ItemData. - // We take the modulus of the metadata by 16000 because that is the magic number to convert small ores to regular ores. + // We take the modulus of the metadata by 16000 because that is the magic number to convert small ores to + // regular ores. // See: GT_TileEntity_Ores.java - ItemData association = GT_OreDictUnificator.getAssociation(new ItemStack(Item.getItemFromBlock(ore), 1, metaData % 16000)); + ItemData association = + GT_OreDictUnificator.getAssociation(new ItemStack(Item.getItemFromBlock(ore), 1, metaData % 16000)); if (association != null) { Supplier<ItemStack> supplier = sOreToCobble.get(association.mPrefix); if (supplier != null) { @@ -3089,9 +4102,8 @@ public class GT_Utility { } else if (o instanceof String) { ItemStack stack = GT_OreDictUnificator.get(o, 1); if (stack == null) { - Optional<ItemStack> oStack = OreDictionary.getOres((String) o) - .stream() - .findAny(); + Optional<ItemStack> oStack = + OreDictionary.getOres((String) o).stream().findAny(); if (oStack.isPresent()) { ItemStack copy = oStack.get().copy(); inputs.add(copy); @@ -3100,29 +4112,17 @@ public class GT_Utility { ItemStack copy = stack.copy(); inputs.add(copy); } - } else if (o instanceof Item) - inputs.add(new ItemStack((Item) o)); - else if (o instanceof Block) - inputs.add(new ItemStack((Block) o)); - else - throw new IllegalStateException("A Recipe contains an invalid input! Output: " + output); + } else if (o instanceof Item) inputs.add(new ItemStack((Item) o)); + else if (o instanceof Block) inputs.add(new ItemStack((Block) o)); + else throw new IllegalStateException("A Recipe contains an invalid input! Output: " + output); } inputs.removeIf(x -> x.getItem() instanceof GT_MetaGenerated_Tool); - return Optional.of( - new GT_Recipe( - false, - new ItemStack[]{output}, - inputs.toArray(new ItemStack[0]), - null, null, - null, null, - 300, 30, 0 - ) - ); + return Optional.of(new GT_Recipe( + false, new ItemStack[] {output}, inputs.toArray(new ItemStack[0]), null, null, null, null, 300, 30, 0)); } - public static Optional<GT_Recipe> reverseShapedRecipe(ItemStack output, Object... aRecipe) { if (output == null) { return Optional.empty(); @@ -3136,17 +4136,13 @@ public class GT_Utility { Object o = aRecipe[i]; if (!startFound) { if (o instanceof String) { - for (Character c : ((String) o).toCharArray()) - amounts.merge(c, 1, (a, b) -> ++a); - } else if (o instanceof Character) - startFound = true; - } else if (!(o instanceof Character)) - ingridients.put((Character) aRecipe[i - 1], o); + for (Character c : ((String) o).toCharArray()) amounts.merge(c, 1, (a, b) -> ++a); + } else if (o instanceof Character) startFound = true; + } else if (!(o instanceof Character)) ingridients.put((Character) aRecipe[i - 1], o); } for (Map.Entry<Character, Object> characterObjectEntry : ingridients.entrySet()) { for (Map.Entry<Character, Integer> characterIntegerEntry : amounts.entrySet()) { - if (characterObjectEntry.getKey() != characterIntegerEntry.getKey()) - continue; + if (characterObjectEntry.getKey() != characterIntegerEntry.getKey()) continue; recipeAsMap.put(characterObjectEntry.getValue(), characterIntegerEntry.getValue()); } } @@ -3164,9 +4160,8 @@ public class GT_Utility { if (ToolDictNames.contains(dictName)) continue; ItemStack stack = GT_OreDictUnificator.get(dictName, null, amount, false, true); if (stack == null) { - Optional<ItemStack> oStack = OreDictionary.getOres(dictName) - .stream() - .findAny(); + Optional<ItemStack> oStack = + OreDictionary.getOres(dictName).stream().findAny(); if (oStack.isPresent()) { ItemStack copy = oStack.get().copy(); copy.stackSize = amount; @@ -3177,27 +4172,16 @@ public class GT_Utility { copy.stackSize = amount; inputs.add(copy); } - } else if (o.getKey() instanceof Item) - inputs.add(new ItemStack((Item) o.getKey(), amount)); - else if (o.getKey() instanceof Block) - inputs.add(new ItemStack((Block) o.getKey(), amount)); - else - throw new IllegalStateException("A Recipe contains an invalid input! Output: " + output); + } else if (o.getKey() instanceof Item) inputs.add(new ItemStack((Item) o.getKey(), amount)); + else if (o.getKey() instanceof Block) inputs.add(new ItemStack((Block) o.getKey(), amount)); + else throw new IllegalStateException("A Recipe contains an invalid input! Output: " + output); } // Remove tools from inputs in case a recipe has one as a direct Item or ItemStack reference inputs.removeIf(x -> x.getItem() instanceof GT_MetaGenerated_Tool); - return Optional.of( - new GT_Recipe( - false, - new ItemStack[]{output}, - inputs.toArray(new ItemStack[0]), - null, null, - null, null, - 300, 30, 0 - ) - ); + return Optional.of(new GT_Recipe( + false, new ItemStack[] {output}, inputs.toArray(new ItemStack[0]), null, null, null, null, 300, 30, 0)); } /** @@ -3224,8 +4208,7 @@ public class GT_Utility { * Hash an item stack for the purpose of storing hash across launches */ public static int persistentHash(ItemStack aStack, boolean aUseStackSize, boolean aUseNBT) { - if (aStack == null) - return 0; + if (aStack == null) return 0; int result = Objects.hashCode(GameRegistry.findUniqueIdentifierFor(aStack.getItem())); result = result * 31 + Items.feather.getDamage(aStack); @@ -3238,8 +4221,7 @@ public class GT_Utility { * Hash an item stack for the purpose of storing hash across launches */ public static int persistentHash(FluidStack aStack, boolean aUseStackSize, boolean aUseNBT) { - if (aStack == null) - return 0; + if (aStack == null) return 0; int base = Objects.hashCode(aStack.getFluid().getName()); if (aUseStackSize) base = base * 31 + aStack.amount; @@ -3248,8 +4230,7 @@ public class GT_Utility { } public static int getCasingTextureIndex(Block block, int meta) { - if (block instanceof IHasIndexedTexture) - return ((IHasIndexedTexture) block).getTextureIndex(meta); + if (block instanceof IHasIndexedTexture) return ((IHasIndexedTexture) block).getTextureIndex(meta); return Textures.BlockIcons.ERROR_TEXTURE_INDEX; } @@ -3262,17 +4243,17 @@ public class GT_Utility { nbt = (NBTTagCompound) nbt.copy(); } - return new AutoValue_GT_Utility_ItemId( - itemStack.getItem(), itemStack.getItemDamage(), nbt); + return new AutoValue_GT_Utility_ItemId(itemStack.getItem(), itemStack.getItemDamage(), nbt); } /** This method does not copy NBT in order to save time. Make sure not to mutate it! */ public static ItemId createNoCopy(ItemStack itemStack) { return new AutoValue_GT_Utility_ItemId( - itemStack.getItem(), itemStack.getItemDamage(), itemStack.getTagCompound()); + itemStack.getItem(), itemStack.getItemDamage(), itemStack.getTagCompound()); } protected abstract Item item(); + protected abstract int metaData(); @Nullable diff --git a/src/main/java/gregtech/api/util/GT_UtilityClient.java b/src/main/java/gregtech/api/util/GT_UtilityClient.java index bb161802ed..8cbf6bf4ad 100644 --- a/src/main/java/gregtech/api/util/GT_UtilityClient.java +++ b/src/main/java/gregtech/api/util/GT_UtilityClient.java @@ -2,45 +2,49 @@ package gregtech.api.util; import com.google.common.collect.Lists; import cpw.mods.fml.relauncher.ReflectionHelper; +import java.lang.reflect.Field; +import java.util.List; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Tessellator; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; -import java.lang.reflect.Field; -import java.util.List; - public class GT_UtilityClient { - private static final Field isDrawingField = ReflectionHelper.findField(Tessellator.class, "isDrawing", "field_78415_z"); - - public static boolean isDrawing(Tessellator tess) { - try { - return isDrawingField.getBoolean(tess); - } catch (IllegalAccessException e) { - e.printStackTrace(); - return false; - } - } - + private static final Field isDrawingField = + ReflectionHelper.findField(Tessellator.class, "isDrawing", "field_78415_z"); - @SuppressWarnings("unchecked") - public static List<String> getTooltip(ItemStack aStack, boolean aGuiStyle) { - try { - List<String> tooltip = aStack.getTooltip(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().gameSettings.advancedItemTooltips); - if (aGuiStyle) { - tooltip.set(0, (aStack.getRarity() == null ? EnumRarity.common : aStack.getRarity()).rarityColor +tooltip.get(0)); - for (int i = 1; i < tooltip.size(); i++) { - tooltip.set(i, EnumChatFormatting.GRAY + tooltip.get(i)); - } - } - return tooltip; - } catch (RuntimeException e) { - // Collections.singletonList() can not be added to. we don't want that - if (aGuiStyle) - return Lists.newArrayList((aStack.getRarity() == null ? EnumRarity.common : aStack.getRarity()).rarityColor + aStack.getDisplayName()); - return Lists.newArrayList(aStack.getDisplayName()); - } - } + public static boolean isDrawing(Tessellator tess) { + try { + return isDrawingField.getBoolean(tess); + } catch (IllegalAccessException e) { + e.printStackTrace(); + return false; + } + } + @SuppressWarnings("unchecked") + public static List<String> getTooltip(ItemStack aStack, boolean aGuiStyle) { + try { + List<String> tooltip = aStack.getTooltip( + Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().gameSettings.advancedItemTooltips); + if (aGuiStyle) { + tooltip.set( + 0, + (aStack.getRarity() == null ? EnumRarity.common : aStack.getRarity()).rarityColor + + tooltip.get(0)); + for (int i = 1; i < tooltip.size(); i++) { + tooltip.set(i, EnumChatFormatting.GRAY + tooltip.get(i)); + } + } + return tooltip; + } catch (RuntimeException e) { + // Collections.singletonList() can not be added to. we don't want that + if (aGuiStyle) + return Lists.newArrayList( + (aStack.getRarity() == null ? EnumRarity.common : aStack.getRarity()).rarityColor + + aStack.getDisplayName()); + return Lists.newArrayList(aStack.getDisplayName()); + } + } } diff --git a/src/main/java/gregtech/api/util/IGT_HatchAdder.java b/src/main/java/gregtech/api/util/IGT_HatchAdder.java index 16fdd90e62..ecf2921d36 100644 --- a/src/main/java/gregtech/api/util/IGT_HatchAdder.java +++ b/src/main/java/gregtech/api/util/IGT_HatchAdder.java @@ -1,6 +1,5 @@ package gregtech.api.util; - import gregtech.api.interfaces.tileentity.IGregTechTileEntity; public interface IGT_HatchAdder<T> { @@ -22,6 +21,7 @@ public interface IGT_HatchAdder<T> { } default IGT_HatchAdder<T> orElse(IGT_HatchAdder<? super T> fallback) { - return (t, iGregTechTileEntity, aShort) -> IGT_HatchAdder.this.apply(t, iGregTechTileEntity, aShort) || fallback.apply(t, iGregTechTileEntity, aShort); + return (t, iGregTechTileEntity, aShort) -> IGT_HatchAdder.this.apply(t, iGregTechTileEntity, aShort) + || fallback.apply(t, iGregTechTileEntity, aShort); } } diff --git a/src/main/java/gregtech/api/util/ISerializableObject.java b/src/main/java/gregtech/api/util/ISerializableObject.java index 536aea7545..b8014860f8 100644 --- a/src/main/java/gregtech/api/util/ISerializableObject.java +++ b/src/main/java/gregtech/api/util/ISerializableObject.java @@ -2,6 +2,9 @@ package gregtech.api.util; import com.google.common.io.ByteArrayDataInput; import io.netty.buffer.ByteBuf; +import java.io.IOException; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -11,10 +14,6 @@ import net.minecraft.nbt.NBTSizeTracker; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagInt; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.io.IOException; - /** * We could well have used {@link java.io.Serializable}, but that's too slow and should generally be avoided * @@ -58,9 +57,8 @@ public interface ISerializableObject { */ static NBTTagCompound readCompoundTagFromGreggyByteBuf(ByteArrayDataInput aBuf) { short size = aBuf.readShort(); - if (size < 0) - return null; - else { + if (size < 0) return null; + else { byte[] buf = new byte[size]; // this is shit, how many copies have we been doing? aBuf.readFully(buf); try { @@ -90,8 +88,7 @@ public interface ISerializableObject { final class LegacyCoverData implements ISerializableObject { private int mData; - public LegacyCoverData() { - } + public LegacyCoverData() {} public LegacyCoverData(int mData) { this.mData = mData; diff --git a/src/main/java/gregtech/api/util/LightingHelper.java b/src/main/java/gregtech/api/util/LightingHelper.java index f131ef74a0..7bffbfd00d 100644 --- a/src/main/java/gregtech/api/util/LightingHelper.java +++ b/src/main/java/gregtech/api/util/LightingHelper.java @@ -42,6 +42,7 @@ public class LightingHelper { * Ambient occlusion values for all four corners of side. */ private float aoTopLeft, aoBottomLeft, aoBottomRight, aoTopRight; + private boolean hasLightnessOverride; private float lightnessOverride; private boolean hasBrightnessOverride; @@ -93,7 +94,7 @@ public class LightingHelper { float green = color[1] / 255.0F; float blue = color[2] / 255.0F; - return new float[]{red, green, blue}; + return new float[] {red, green, blue}; } /** @@ -229,15 +230,21 @@ public class LightingHelper { if (renderBlocks.hasOverrideBlockTexture()) { - renderBlocks.colorRedTopLeft = renderBlocks.colorRedBottomLeft = renderBlocks.colorRedBottomRight = renderBlocks.colorRedTopRight = rgb[0]; - renderBlocks.colorGreenTopLeft = renderBlocks.colorGreenBottomLeft = renderBlocks.colorGreenBottomRight = renderBlocks.colorGreenTopRight = rgb[1]; - renderBlocks.colorBlueTopLeft = renderBlocks.colorBlueBottomLeft = renderBlocks.colorBlueBottomRight = renderBlocks.colorBlueTopRight = rgb[2]; + renderBlocks.colorRedTopLeft = renderBlocks.colorRedBottomLeft = + renderBlocks.colorRedBottomRight = renderBlocks.colorRedTopRight = rgb[0]; + renderBlocks.colorGreenTopLeft = renderBlocks.colorGreenBottomLeft = + renderBlocks.colorGreenBottomRight = renderBlocks.colorGreenTopRight = rgb[1]; + renderBlocks.colorBlueTopLeft = renderBlocks.colorBlueBottomLeft = + renderBlocks.colorBlueBottomRight = renderBlocks.colorBlueTopRight = rgb[2]; } else { - renderBlocks.colorRedTopLeft = renderBlocks.colorRedBottomLeft = renderBlocks.colorRedBottomRight = renderBlocks.colorRedTopRight = rgb[0] * lightness; - renderBlocks.colorGreenTopLeft = renderBlocks.colorGreenBottomLeft = renderBlocks.colorGreenBottomRight = renderBlocks.colorGreenTopRight = rgb[1] * lightness; - renderBlocks.colorBlueTopLeft = renderBlocks.colorBlueBottomLeft = renderBlocks.colorBlueBottomRight = renderBlocks.colorBlueTopRight = rgb[2] * lightness; + renderBlocks.colorRedTopLeft = renderBlocks.colorRedBottomLeft = + renderBlocks.colorRedBottomRight = renderBlocks.colorRedTopRight = rgb[0] * lightness; + renderBlocks.colorGreenTopLeft = renderBlocks.colorGreenBottomLeft = + renderBlocks.colorGreenBottomRight = renderBlocks.colorGreenTopRight = rgb[1] * lightness; + renderBlocks.colorBlueTopLeft = renderBlocks.colorBlueBottomLeft = + renderBlocks.colorBlueBottomRight = renderBlocks.colorBlueTopRight = rgb[2] * lightness; renderBlocks.colorRedTopLeft *= aoTopLeft; renderBlocks.colorGreenTopLeft *= aoTopLeft; @@ -257,7 +264,6 @@ public class LightingHelper { if (hasBrightnessOverride) tessellator.setBrightness(brightnessOverride); tessellator.setColorOpaque_F(rgb[0] * lightness, rgb[1] * lightness, rgb[2] * lightness); - } } @@ -272,7 +278,7 @@ public class LightingHelper { float green = (color >> 8 & 0xff) / 255.0F; float blue = (color & 0xff) / 255.0F; - return new float[]{red, green, blue}; + return new float[] {red, green, blue}; } /** @@ -335,43 +341,150 @@ public class LightingHelper { float ratio = (float) (1.0F - renderBlocks.renderMinX); float aoLightValue = renderBlocks.blockAccess.getBlock(x - 1, y, z).getAmbientOcclusionLightValue(); - renderBlocks.aoBrightnessXYNN = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y - 1, z); - renderBlocks.aoBrightnessXZNN = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y, z - 1); - renderBlocks.aoBrightnessXZNP = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y, z + 1); - renderBlocks.aoBrightnessXYNP = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y + 1, z); - renderBlocks.aoBrightnessXYZNNN = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y - 1, z - 1); - renderBlocks.aoBrightnessXYZNNP = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y - 1, z + 1); - renderBlocks.aoBrightnessXYZNPN = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y + 1, z - 1); - renderBlocks.aoBrightnessXYZNPP = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y + 1, z + 1); - renderBlocks.aoLightValueScratchXYNN = getMixedAo(renderBlocks.blockAccess.getBlock(x - 1, y - 1, z).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x, y - 1, z).getAmbientOcclusionLightValue(), ratio); - renderBlocks.aoLightValueScratchXZNN = getMixedAo(renderBlocks.blockAccess.getBlock(x - 1, y, z - 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x, y, z - 1).getAmbientOcclusionLightValue(), ratio); - renderBlocks.aoLightValueScratchXZNP = getMixedAo(renderBlocks.blockAccess.getBlock(x - 1, y, z + 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x, y, z + 1).getAmbientOcclusionLightValue(), ratio); - renderBlocks.aoLightValueScratchXYNP = getMixedAo(renderBlocks.blockAccess.getBlock(x - 1, y + 1, z).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x, y + 1, z).getAmbientOcclusionLightValue(), ratio); - renderBlocks.aoLightValueScratchXYZNNN = getMixedAo(renderBlocks.blockAccess.getBlock(x - 1, y - 1, z - 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x, y - 1, z - 1).getAmbientOcclusionLightValue(), ratio); - renderBlocks.aoLightValueScratchXYZNNP = getMixedAo(renderBlocks.blockAccess.getBlock(x - 1, y - 1, z + 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x, y - 1, z + 1).getAmbientOcclusionLightValue(), ratio); - renderBlocks.aoLightValueScratchXYZNPN = getMixedAo(renderBlocks.blockAccess.getBlock(x - 1, y + 1, z - 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x, y + 1, z - 1).getAmbientOcclusionLightValue(), ratio); - renderBlocks.aoLightValueScratchXYZNPP = getMixedAo(renderBlocks.blockAccess.getBlock(x - 1, y + 1, z + 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x, y + 1, z + 1).getAmbientOcclusionLightValue(), ratio); - - int brightnessMixedXYZNPN = renderBlocks.getAoBrightness(renderBlocks.aoBrightnessXZNN, renderBlocks.aoBrightnessXYZNPN, renderBlocks.aoBrightnessXYNP, mixedBrightness); - int brightnessMixedXYZNNN = renderBlocks.getAoBrightness(renderBlocks.aoBrightnessXYZNNN, renderBlocks.aoBrightnessXYNN, renderBlocks.aoBrightnessXZNN, mixedBrightness); - int brightnessMixedXYZNNP = renderBlocks.getAoBrightness(renderBlocks.aoBrightnessXYNN, renderBlocks.aoBrightnessXYZNNP, renderBlocks.aoBrightnessXZNP, mixedBrightness); - int brightnessMixedXYZNPP = renderBlocks.getAoBrightness(renderBlocks.aoBrightnessXZNP, renderBlocks.aoBrightnessXYNP, renderBlocks.aoBrightnessXYZNPP, mixedBrightness); - - float aoMixedXYZNPN = (renderBlocks.aoLightValueScratchXZNN + aoLightValue + renderBlocks.aoLightValueScratchXYZNPN + renderBlocks.aoLightValueScratchXYNP) / 4.0F; - float aoMixedXYZNNN = (renderBlocks.aoLightValueScratchXYZNNN + renderBlocks.aoLightValueScratchXYNN + renderBlocks.aoLightValueScratchXZNN + aoLightValue) / 4.0F; - float aoMixedXYZNNP = (renderBlocks.aoLightValueScratchXYNN + renderBlocks.aoLightValueScratchXYZNNP + aoLightValue + renderBlocks.aoLightValueScratchXZNP) / 4.0F; - float aoMixedXYZNPP = (aoLightValue + renderBlocks.aoLightValueScratchXZNP + renderBlocks.aoLightValueScratchXYNP + renderBlocks.aoLightValueScratchXYZNPP) / 4.0F; - - aoTopLeft = (float) (aoMixedXYZNPP * renderBlocks.renderMaxY * renderBlocks.renderMaxZ + aoMixedXYZNPN * renderBlocks.renderMaxY * (1.0D - renderBlocks.renderMaxZ) + aoMixedXYZNNN * (1.0D - renderBlocks.renderMaxY) * (1.0D - renderBlocks.renderMaxZ) + aoMixedXYZNNP * (1.0D - renderBlocks.renderMaxY) * renderBlocks.renderMaxZ); - aoBottomLeft = (float) (aoMixedXYZNPP * renderBlocks.renderMaxY * renderBlocks.renderMinZ + aoMixedXYZNPN * renderBlocks.renderMaxY * (1.0D - renderBlocks.renderMinZ) + aoMixedXYZNNN * (1.0D - renderBlocks.renderMaxY) * (1.0D - renderBlocks.renderMinZ) + aoMixedXYZNNP * (1.0D - renderBlocks.renderMaxY) * renderBlocks.renderMinZ); - aoBottomRight = (float) (aoMixedXYZNPP * renderBlocks.renderMinY * renderBlocks.renderMinZ + aoMixedXYZNPN * renderBlocks.renderMinY * (1.0D - renderBlocks.renderMinZ) + aoMixedXYZNNN * (1.0D - renderBlocks.renderMinY) * (1.0D - renderBlocks.renderMinZ) + aoMixedXYZNNP * (1.0D - renderBlocks.renderMinY) * renderBlocks.renderMinZ); - aoTopRight = (float) (aoMixedXYZNPP * renderBlocks.renderMinY * renderBlocks.renderMaxZ + aoMixedXYZNPN * renderBlocks.renderMinY * (1.0D - renderBlocks.renderMaxZ) + aoMixedXYZNNN * (1.0D - renderBlocks.renderMinY) * (1.0D - renderBlocks.renderMaxZ) + aoMixedXYZNNP * (1.0D - renderBlocks.renderMinY) * renderBlocks.renderMaxZ); - - renderBlocks.brightnessTopLeft = renderBlocks.mixAoBrightness(brightnessMixedXYZNPP, brightnessMixedXYZNPN, brightnessMixedXYZNNN, brightnessMixedXYZNNP, renderBlocks.renderMaxY * renderBlocks.renderMaxZ, renderBlocks.renderMaxY * (1.0D - renderBlocks.renderMaxZ), (1.0D - renderBlocks.renderMaxY) * (1.0D - renderBlocks.renderMaxZ), (1.0D - renderBlocks.renderMaxY) * renderBlocks.renderMaxZ); - renderBlocks.brightnessBottomLeft = renderBlocks.mixAoBrightness(brightnessMixedXYZNPP, brightnessMixedXYZNPN, brightnessMixedXYZNNN, brightnessMixedXYZNNP, renderBlocks.renderMaxY * renderBlocks.renderMinZ, renderBlocks.renderMaxY * (1.0D - renderBlocks.renderMinZ), (1.0D - renderBlocks.renderMaxY) * (1.0D - renderBlocks.renderMinZ), (1.0D - renderBlocks.renderMaxY) * renderBlocks.renderMinZ); - renderBlocks.brightnessBottomRight = renderBlocks.mixAoBrightness(brightnessMixedXYZNPP, brightnessMixedXYZNPN, brightnessMixedXYZNNN, brightnessMixedXYZNNP, renderBlocks.renderMinY * renderBlocks.renderMinZ, renderBlocks.renderMinY * (1.0D - renderBlocks.renderMinZ), (1.0D - renderBlocks.renderMinY) * (1.0D - renderBlocks.renderMinZ), (1.0D - renderBlocks.renderMinY) * renderBlocks.renderMinZ); - renderBlocks.brightnessTopRight = renderBlocks.mixAoBrightness(brightnessMixedXYZNPP, brightnessMixedXYZNPN, brightnessMixedXYZNNN, brightnessMixedXYZNNP, renderBlocks.renderMinY * renderBlocks.renderMaxZ, renderBlocks.renderMinY * (1.0D - renderBlocks.renderMaxZ), (1.0D - renderBlocks.renderMinY) * (1.0D - renderBlocks.renderMaxZ), (1.0D - renderBlocks.renderMinY) * renderBlocks.renderMaxZ); - + renderBlocks.aoBrightnessXYNN = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y - 1, z); + renderBlocks.aoBrightnessXZNN = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y, z - 1); + renderBlocks.aoBrightnessXZNP = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y, z + 1); + renderBlocks.aoBrightnessXYNP = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y + 1, z); + renderBlocks.aoBrightnessXYZNNN = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y - 1, z - 1); + renderBlocks.aoBrightnessXYZNNP = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y - 1, z + 1); + renderBlocks.aoBrightnessXYZNPN = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y + 1, z - 1); + renderBlocks.aoBrightnessXYZNPP = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y + 1, z + 1); + renderBlocks.aoLightValueScratchXYNN = getMixedAo( + renderBlocks.blockAccess.getBlock(x - 1, y - 1, z).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x, y - 1, z).getAmbientOcclusionLightValue(), + ratio); + renderBlocks.aoLightValueScratchXZNN = getMixedAo( + renderBlocks.blockAccess.getBlock(x - 1, y, z - 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x, y, z - 1).getAmbientOcclusionLightValue(), + ratio); + renderBlocks.aoLightValueScratchXZNP = getMixedAo( + renderBlocks.blockAccess.getBlock(x - 1, y, z + 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x, y, z + 1).getAmbientOcclusionLightValue(), + ratio); + renderBlocks.aoLightValueScratchXYNP = getMixedAo( + renderBlocks.blockAccess.getBlock(x - 1, y + 1, z).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x, y + 1, z).getAmbientOcclusionLightValue(), + ratio); + renderBlocks.aoLightValueScratchXYZNNN = getMixedAo( + renderBlocks.blockAccess.getBlock(x - 1, y - 1, z - 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x, y - 1, z - 1).getAmbientOcclusionLightValue(), + ratio); + renderBlocks.aoLightValueScratchXYZNNP = getMixedAo( + renderBlocks.blockAccess.getBlock(x - 1, y - 1, z + 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x, y - 1, z + 1).getAmbientOcclusionLightValue(), + ratio); + renderBlocks.aoLightValueScratchXYZNPN = getMixedAo( + renderBlocks.blockAccess.getBlock(x - 1, y + 1, z - 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x, y + 1, z - 1).getAmbientOcclusionLightValue(), + ratio); + renderBlocks.aoLightValueScratchXYZNPP = getMixedAo( + renderBlocks.blockAccess.getBlock(x - 1, y + 1, z + 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x, y + 1, z + 1).getAmbientOcclusionLightValue(), + ratio); + + int brightnessMixedXYZNPN = renderBlocks.getAoBrightness( + renderBlocks.aoBrightnessXZNN, + renderBlocks.aoBrightnessXYZNPN, + renderBlocks.aoBrightnessXYNP, + mixedBrightness); + int brightnessMixedXYZNNN = renderBlocks.getAoBrightness( + renderBlocks.aoBrightnessXYZNNN, + renderBlocks.aoBrightnessXYNN, + renderBlocks.aoBrightnessXZNN, + mixedBrightness); + int brightnessMixedXYZNNP = renderBlocks.getAoBrightness( + renderBlocks.aoBrightnessXYNN, + renderBlocks.aoBrightnessXYZNNP, + renderBlocks.aoBrightnessXZNP, + mixedBrightness); + int brightnessMixedXYZNPP = renderBlocks.getAoBrightness( + renderBlocks.aoBrightnessXZNP, + renderBlocks.aoBrightnessXYNP, + renderBlocks.aoBrightnessXYZNPP, + mixedBrightness); + + float aoMixedXYZNPN = (renderBlocks.aoLightValueScratchXZNN + + aoLightValue + + renderBlocks.aoLightValueScratchXYZNPN + + renderBlocks.aoLightValueScratchXYNP) + / 4.0F; + float aoMixedXYZNNN = (renderBlocks.aoLightValueScratchXYZNNN + + renderBlocks.aoLightValueScratchXYNN + + renderBlocks.aoLightValueScratchXZNN + + aoLightValue) + / 4.0F; + float aoMixedXYZNNP = (renderBlocks.aoLightValueScratchXYNN + + renderBlocks.aoLightValueScratchXYZNNP + + aoLightValue + + renderBlocks.aoLightValueScratchXZNP) + / 4.0F; + float aoMixedXYZNPP = (aoLightValue + + renderBlocks.aoLightValueScratchXZNP + + renderBlocks.aoLightValueScratchXYNP + + renderBlocks.aoLightValueScratchXYZNPP) + / 4.0F; + + aoTopLeft = (float) (aoMixedXYZNPP * renderBlocks.renderMaxY * renderBlocks.renderMaxZ + + aoMixedXYZNPN * renderBlocks.renderMaxY * (1.0D - renderBlocks.renderMaxZ) + + aoMixedXYZNNN * (1.0D - renderBlocks.renderMaxY) * (1.0D - renderBlocks.renderMaxZ) + + aoMixedXYZNNP * (1.0D - renderBlocks.renderMaxY) * renderBlocks.renderMaxZ); + aoBottomLeft = (float) (aoMixedXYZNPP * renderBlocks.renderMaxY * renderBlocks.renderMinZ + + aoMixedXYZNPN * renderBlocks.renderMaxY * (1.0D - renderBlocks.renderMinZ) + + aoMixedXYZNNN * (1.0D - renderBlocks.renderMaxY) * (1.0D - renderBlocks.renderMinZ) + + aoMixedXYZNNP * (1.0D - renderBlocks.renderMaxY) * renderBlocks.renderMinZ); + aoBottomRight = (float) (aoMixedXYZNPP * renderBlocks.renderMinY * renderBlocks.renderMinZ + + aoMixedXYZNPN * renderBlocks.renderMinY * (1.0D - renderBlocks.renderMinZ) + + aoMixedXYZNNN * (1.0D - renderBlocks.renderMinY) * (1.0D - renderBlocks.renderMinZ) + + aoMixedXYZNNP * (1.0D - renderBlocks.renderMinY) * renderBlocks.renderMinZ); + aoTopRight = (float) (aoMixedXYZNPP * renderBlocks.renderMinY * renderBlocks.renderMaxZ + + aoMixedXYZNPN * renderBlocks.renderMinY * (1.0D - renderBlocks.renderMaxZ) + + aoMixedXYZNNN * (1.0D - renderBlocks.renderMinY) * (1.0D - renderBlocks.renderMaxZ) + + aoMixedXYZNNP * (1.0D - renderBlocks.renderMinY) * renderBlocks.renderMaxZ); + + renderBlocks.brightnessTopLeft = renderBlocks.mixAoBrightness( + brightnessMixedXYZNPP, + brightnessMixedXYZNPN, + brightnessMixedXYZNNN, + brightnessMixedXYZNNP, + renderBlocks.renderMaxY * renderBlocks.renderMaxZ, + renderBlocks.renderMaxY * (1.0D - renderBlocks.renderMaxZ), + (1.0D - renderBlocks.renderMaxY) * (1.0D - renderBlocks.renderMaxZ), + (1.0D - renderBlocks.renderMaxY) * renderBlocks.renderMaxZ); + renderBlocks.brightnessBottomLeft = renderBlocks.mixAoBrightness( + brightnessMixedXYZNPP, + brightnessMixedXYZNPN, + brightnessMixedXYZNNN, + brightnessMixedXYZNNP, + renderBlocks.renderMaxY * renderBlocks.renderMinZ, + renderBlocks.renderMaxY * (1.0D - renderBlocks.renderMinZ), + (1.0D - renderBlocks.renderMaxY) * (1.0D - renderBlocks.renderMinZ), + (1.0D - renderBlocks.renderMaxY) * renderBlocks.renderMinZ); + renderBlocks.brightnessBottomRight = renderBlocks.mixAoBrightness( + brightnessMixedXYZNPP, + brightnessMixedXYZNPN, + brightnessMixedXYZNNN, + brightnessMixedXYZNNP, + renderBlocks.renderMinY * renderBlocks.renderMinZ, + renderBlocks.renderMinY * (1.0D - renderBlocks.renderMinZ), + (1.0D - renderBlocks.renderMinY) * (1.0D - renderBlocks.renderMinZ), + (1.0D - renderBlocks.renderMinY) * renderBlocks.renderMinZ); + renderBlocks.brightnessTopRight = renderBlocks.mixAoBrightness( + brightnessMixedXYZNPP, + brightnessMixedXYZNPN, + brightnessMixedXYZNNN, + brightnessMixedXYZNNP, + renderBlocks.renderMinY * renderBlocks.renderMaxZ, + renderBlocks.renderMinY * (1.0D - renderBlocks.renderMaxZ), + (1.0D - renderBlocks.renderMinY) * (1.0D - renderBlocks.renderMaxZ), + (1.0D - renderBlocks.renderMinY) * renderBlocks.renderMaxZ); } return this; @@ -405,43 +518,150 @@ public class LightingHelper { float aoLightValue = renderBlocks.blockAccess.getBlock(x + 1, y, z).getAmbientOcclusionLightValue(); - renderBlocks.aoBrightnessXYPN = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y - 1, z); - renderBlocks.aoBrightnessXZPN = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y, z - 1); - renderBlocks.aoBrightnessXZPP = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y, z + 1); - renderBlocks.aoBrightnessXYPP = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y + 1, z); - renderBlocks.aoBrightnessXYZPNN = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y - 1, z - 1); - renderBlocks.aoBrightnessXYZPNP = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y - 1, z + 1); - renderBlocks.aoBrightnessXYZPPN = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y + 1, z - 1); - renderBlocks.aoBrightnessXYZPPP = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y + 1, z + 1); - renderBlocks.aoLightValueScratchXYPN = getMixedAo(renderBlocks.blockAccess.getBlock(x + 1, y - 1, z).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x, y - 1, z).getAmbientOcclusionLightValue(), renderBlocks.renderMaxX); - renderBlocks.aoLightValueScratchXZPN = getMixedAo(renderBlocks.blockAccess.getBlock(x + 1, y, z - 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x, y, z - 1).getAmbientOcclusionLightValue(), renderBlocks.renderMaxX); - renderBlocks.aoLightValueScratchXZPP = getMixedAo(renderBlocks.blockAccess.getBlock(x + 1, y, z + 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x, y, z + 1).getAmbientOcclusionLightValue(), renderBlocks.renderMaxX); - renderBlocks.aoLightValueScratchXYPP = getMixedAo(renderBlocks.blockAccess.getBlock(x + 1, y + 1, z).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x, y + 1, z).getAmbientOcclusionLightValue(), renderBlocks.renderMaxX); - renderBlocks.aoLightValueScratchXYZPNN = getMixedAo(renderBlocks.blockAccess.getBlock(x + 1, y - 1, z - 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x, y - 1, z - 1).getAmbientOcclusionLightValue(), renderBlocks.renderMaxX); - renderBlocks.aoLightValueScratchXYZPNP = getMixedAo(renderBlocks.blockAccess.getBlock(x + 1, y - 1, z + 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x, y - 1, z + 1).getAmbientOcclusionLightValue(), renderBlocks.renderMaxX); - renderBlocks.aoLightValueScratchXYZPPN = getMixedAo(renderBlocks.blockAccess.getBlock(x + 1, y + 1, z - 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x, y + 1, z - 1).getAmbientOcclusionLightValue(), renderBlocks.renderMaxX); - renderBlocks.aoLightValueScratchXYZPPP = getMixedAo(renderBlocks.blockAccess.getBlock(x + 1, y + 1, z + 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x, y + 1, z + 1).getAmbientOcclusionLightValue(), renderBlocks.renderMaxX); - - int brightnessMixedXYZPPP = renderBlocks.getAoBrightness(renderBlocks.aoBrightnessXZPP, renderBlocks.aoBrightnessXYPP, renderBlocks.aoBrightnessXYZPPP, mixedBrightness); - int brightnessMixedXYZPNP = renderBlocks.getAoBrightness(renderBlocks.aoBrightnessXYPN, renderBlocks.aoBrightnessXYZPNP, renderBlocks.aoBrightnessXZPP, mixedBrightness); - int brightnessMixedXYZPNN = renderBlocks.getAoBrightness(renderBlocks.aoBrightnessXYZPNN, renderBlocks.aoBrightnessXYPN, renderBlocks.aoBrightnessXZPN, mixedBrightness); - int brightnessMixedXYZPPN = renderBlocks.getAoBrightness(renderBlocks.aoBrightnessXZPN, renderBlocks.aoBrightnessXYZPPN, renderBlocks.aoBrightnessXYPP, mixedBrightness); - - float aoMixedXYZPPP = (aoLightValue + renderBlocks.aoLightValueScratchXZPP + renderBlocks.aoLightValueScratchXYPP + renderBlocks.aoLightValueScratchXYZPPP) / 4.0F; - float aoMixedXYZPNP = (renderBlocks.aoLightValueScratchXYPN + renderBlocks.aoLightValueScratchXYZPNP + aoLightValue + renderBlocks.aoLightValueScratchXZPP) / 4.0F; - float aoMixedXYZPNN = (renderBlocks.aoLightValueScratchXYZPNN + renderBlocks.aoLightValueScratchXYPN + renderBlocks.aoLightValueScratchXZPN + aoLightValue) / 4.0F; - float aoMixedXYZPPN = (renderBlocks.aoLightValueScratchXZPN + aoLightValue + renderBlocks.aoLightValueScratchXYZPPN + renderBlocks.aoLightValueScratchXYPP) / 4.0F; - - aoTopLeft = (float) (aoMixedXYZPNP * (1.0D - renderBlocks.renderMinY) * renderBlocks.renderMaxZ + aoMixedXYZPNN * (1.0D - renderBlocks.renderMinY) * (1.0D - renderBlocks.renderMaxZ) + aoMixedXYZPPN * renderBlocks.renderMinY * (1.0D - renderBlocks.renderMaxZ) + aoMixedXYZPPP * renderBlocks.renderMinY * renderBlocks.renderMaxZ); - aoBottomLeft = (float) (aoMixedXYZPNP * (1.0D - renderBlocks.renderMinY) * renderBlocks.renderMinZ + aoMixedXYZPNN * (1.0D - renderBlocks.renderMinY) * (1.0D - renderBlocks.renderMinZ) + aoMixedXYZPPN * renderBlocks.renderMinY * (1.0D - renderBlocks.renderMinZ) + aoMixedXYZPPP * renderBlocks.renderMinY * renderBlocks.renderMinZ); - aoBottomRight = (float) (aoMixedXYZPNP * (1.0D - renderBlocks.renderMaxY) * renderBlocks.renderMinZ + aoMixedXYZPNN * (1.0D - renderBlocks.renderMaxY) * (1.0D - renderBlocks.renderMinZ) + aoMixedXYZPPN * renderBlocks.renderMaxY * (1.0D - renderBlocks.renderMinZ) + aoMixedXYZPPP * renderBlocks.renderMaxY * renderBlocks.renderMinZ); - aoTopRight = (float) (aoMixedXYZPNP * (1.0D - renderBlocks.renderMaxY) * renderBlocks.renderMaxZ + aoMixedXYZPNN * (1.0D - renderBlocks.renderMaxY) * (1.0D - renderBlocks.renderMaxZ) + aoMixedXYZPPN * renderBlocks.renderMaxY * (1.0D - renderBlocks.renderMaxZ) + aoMixedXYZPPP * renderBlocks.renderMaxY * renderBlocks.renderMaxZ); - - renderBlocks.brightnessTopLeft = renderBlocks.mixAoBrightness(brightnessMixedXYZPNP, brightnessMixedXYZPNN, brightnessMixedXYZPPN, brightnessMixedXYZPPP, (1.0D - renderBlocks.renderMinY) * renderBlocks.renderMaxZ, (1.0D - renderBlocks.renderMinY) * (1.0D - renderBlocks.renderMaxZ), renderBlocks.renderMinY * (1.0D - renderBlocks.renderMaxZ), renderBlocks.renderMinY * renderBlocks.renderMaxZ); - renderBlocks.brightnessBottomLeft = renderBlocks.mixAoBrightness(brightnessMixedXYZPNP, brightnessMixedXYZPNN, brightnessMixedXYZPPN, brightnessMixedXYZPPP, (1.0D - renderBlocks.renderMinY) * renderBlocks.renderMinZ, (1.0D - renderBlocks.renderMinY) * (1.0D - renderBlocks.renderMinZ), renderBlocks.renderMinY * (1.0D - renderBlocks.renderMinZ), renderBlocks.renderMinY * renderBlocks.renderMinZ); - renderBlocks.brightnessBottomRight = renderBlocks.mixAoBrightness(brightnessMixedXYZPNP, brightnessMixedXYZPNN, brightnessMixedXYZPPN, brightnessMixedXYZPPP, (1.0D - renderBlocks.renderMaxY) * renderBlocks.renderMinZ, (1.0D - renderBlocks.renderMaxY) * (1.0D - renderBlocks.renderMinZ), renderBlocks.renderMaxY * (1.0D - renderBlocks.renderMinZ), renderBlocks.renderMaxY * renderBlocks.renderMinZ); - renderBlocks.brightnessTopRight = renderBlocks.mixAoBrightness(brightnessMixedXYZPNP, brightnessMixedXYZPNN, brightnessMixedXYZPPN, brightnessMixedXYZPPP, (1.0D - renderBlocks.renderMaxY) * renderBlocks.renderMaxZ, (1.0D - renderBlocks.renderMaxY) * (1.0D - renderBlocks.renderMaxZ), renderBlocks.renderMaxY * (1.0D - renderBlocks.renderMaxZ), renderBlocks.renderMaxY * renderBlocks.renderMaxZ); - + renderBlocks.aoBrightnessXYPN = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y - 1, z); + renderBlocks.aoBrightnessXZPN = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y, z - 1); + renderBlocks.aoBrightnessXZPP = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y, z + 1); + renderBlocks.aoBrightnessXYPP = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y + 1, z); + renderBlocks.aoBrightnessXYZPNN = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y - 1, z - 1); + renderBlocks.aoBrightnessXYZPNP = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y - 1, z + 1); + renderBlocks.aoBrightnessXYZPPN = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y + 1, z - 1); + renderBlocks.aoBrightnessXYZPPP = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y + 1, z + 1); + renderBlocks.aoLightValueScratchXYPN = getMixedAo( + renderBlocks.blockAccess.getBlock(x + 1, y - 1, z).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x, y - 1, z).getAmbientOcclusionLightValue(), + renderBlocks.renderMaxX); + renderBlocks.aoLightValueScratchXZPN = getMixedAo( + renderBlocks.blockAccess.getBlock(x + 1, y, z - 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x, y, z - 1).getAmbientOcclusionLightValue(), + renderBlocks.renderMaxX); + renderBlocks.aoLightValueScratchXZPP = getMixedAo( + renderBlocks.blockAccess.getBlock(x + 1, y, z + 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x, y, z + 1).getAmbientOcclusionLightValue(), + renderBlocks.renderMaxX); + renderBlocks.aoLightValueScratchXYPP = getMixedAo( + renderBlocks.blockAccess.getBlock(x + 1, y + 1, z).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x, y + 1, z).getAmbientOcclusionLightValue(), + renderBlocks.renderMaxX); + renderBlocks.aoLightValueScratchXYZPNN = getMixedAo( + renderBlocks.blockAccess.getBlock(x + 1, y - 1, z - 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x, y - 1, z - 1).getAmbientOcclusionLightValue(), + renderBlocks.renderMaxX); + renderBlocks.aoLightValueScratchXYZPNP = getMixedAo( + renderBlocks.blockAccess.getBlock(x + 1, y - 1, z + 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x, y - 1, z + 1).getAmbientOcclusionLightValue(), + renderBlocks.renderMaxX); + renderBlocks.aoLightValueScratchXYZPPN = getMixedAo( + renderBlocks.blockAccess.getBlock(x + 1, y + 1, z - 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x, y + 1, z - 1).getAmbientOcclusionLightValue(), + renderBlocks.renderMaxX); + renderBlocks.aoLightValueScratchXYZPPP = getMixedAo( + renderBlocks.blockAccess.getBlock(x + 1, y + 1, z + 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x, y + 1, z + 1).getAmbientOcclusionLightValue(), + renderBlocks.renderMaxX); + + int brightnessMixedXYZPPP = renderBlocks.getAoBrightness( + renderBlocks.aoBrightnessXZPP, + renderBlocks.aoBrightnessXYPP, + renderBlocks.aoBrightnessXYZPPP, + mixedBrightness); + int brightnessMixedXYZPNP = renderBlocks.getAoBrightness( + renderBlocks.aoBrightnessXYPN, + renderBlocks.aoBrightnessXYZPNP, + renderBlocks.aoBrightnessXZPP, + mixedBrightness); + int brightnessMixedXYZPNN = renderBlocks.getAoBrightness( + renderBlocks.aoBrightnessXYZPNN, + renderBlocks.aoBrightnessXYPN, + renderBlocks.aoBrightnessXZPN, + mixedBrightness); + int brightnessMixedXYZPPN = renderBlocks.getAoBrightness( + renderBlocks.aoBrightnessXZPN, + renderBlocks.aoBrightnessXYZPPN, + renderBlocks.aoBrightnessXYPP, + mixedBrightness); + + float aoMixedXYZPPP = (aoLightValue + + renderBlocks.aoLightValueScratchXZPP + + renderBlocks.aoLightValueScratchXYPP + + renderBlocks.aoLightValueScratchXYZPPP) + / 4.0F; + float aoMixedXYZPNP = (renderBlocks.aoLightValueScratchXYPN + + renderBlocks.aoLightValueScratchXYZPNP + + aoLightValue + + renderBlocks.aoLightValueScratchXZPP) + / 4.0F; + float aoMixedXYZPNN = (renderBlocks.aoLightValueScratchXYZPNN + + renderBlocks.aoLightValueScratchXYPN + + renderBlocks.aoLightValueScratchXZPN + + aoLightValue) + / 4.0F; + float aoMixedXYZPPN = (renderBlocks.aoLightValueScratchXZPN + + aoLightValue + + renderBlocks.aoLightValueScratchXYZPPN + + renderBlocks.aoLightValueScratchXYPP) + / 4.0F; + + aoTopLeft = (float) (aoMixedXYZPNP * (1.0D - renderBlocks.renderMinY) * renderBlocks.renderMaxZ + + aoMixedXYZPNN * (1.0D - renderBlocks.renderMinY) * (1.0D - renderBlocks.renderMaxZ) + + aoMixedXYZPPN * renderBlocks.renderMinY * (1.0D - renderBlocks.renderMaxZ) + + aoMixedXYZPPP * renderBlocks.renderMinY * renderBlocks.renderMaxZ); + aoBottomLeft = (float) (aoMixedXYZPNP * (1.0D - renderBlocks.renderMinY) * renderBlocks.renderMinZ + + aoMixedXYZPNN * (1.0D - renderBlocks.renderMinY) * (1.0D - renderBlocks.renderMinZ) + + aoMixedXYZPPN * renderBlocks.renderMinY * (1.0D - renderBlocks.renderMinZ) + + aoMixedXYZPPP * renderBlocks.renderMinY * renderBlocks.renderMinZ); + aoBottomRight = (float) (aoMixedXYZPNP * (1.0D - renderBlocks.renderMaxY) * renderBlocks.renderMinZ + + aoMixedXYZPNN * (1.0D - renderBlocks.renderMaxY) * (1.0D - renderBlocks.renderMinZ) + + aoMixedXYZPPN * renderBlocks.renderMaxY * (1.0D - renderBlocks.renderMinZ) + + aoMixedXYZPPP * renderBlocks.renderMaxY * renderBlocks.renderMinZ); + aoTopRight = (float) (aoMixedXYZPNP * (1.0D - renderBlocks.renderMaxY) * renderBlocks.renderMaxZ + + aoMixedXYZPNN * (1.0D - renderBlocks.renderMaxY) * (1.0D - renderBlocks.renderMaxZ) + + aoMixedXYZPPN * renderBlocks.renderMaxY * (1.0D - renderBlocks.renderMaxZ) + + aoMixedXYZPPP * renderBlocks.renderMaxY * renderBlocks.renderMaxZ); + + renderBlocks.brightnessTopLeft = renderBlocks.mixAoBrightness( + brightnessMixedXYZPNP, + brightnessMixedXYZPNN, + brightnessMixedXYZPPN, + brightnessMixedXYZPPP, + (1.0D - renderBlocks.renderMinY) * renderBlocks.renderMaxZ, + (1.0D - renderBlocks.renderMinY) * (1.0D - renderBlocks.renderMaxZ), + renderBlocks.renderMinY * (1.0D - renderBlocks.renderMaxZ), + renderBlocks.renderMinY * renderBlocks.renderMaxZ); + renderBlocks.brightnessBottomLeft = renderBlocks.mixAoBrightness( + brightnessMixedXYZPNP, + brightnessMixedXYZPNN, + brightnessMixedXYZPPN, + brightnessMixedXYZPPP, + (1.0D - renderBlocks.renderMinY) * renderBlocks.renderMinZ, + (1.0D - renderBlocks.renderMinY) * (1.0D - renderBlocks.renderMinZ), + renderBlocks.renderMinY * (1.0D - renderBlocks.renderMinZ), + renderBlocks.renderMinY * renderBlocks.renderMinZ); + renderBlocks.brightnessBottomRight = renderBlocks.mixAoBrightness( + brightnessMixedXYZPNP, + brightnessMixedXYZPNN, + brightnessMixedXYZPPN, + brightnessMixedXYZPPP, + (1.0D - renderBlocks.renderMaxY) * renderBlocks.renderMinZ, + (1.0D - renderBlocks.renderMaxY) * (1.0D - renderBlocks.renderMinZ), + renderBlocks.renderMaxY * (1.0D - renderBlocks.renderMinZ), + renderBlocks.renderMaxY * renderBlocks.renderMinZ); + renderBlocks.brightnessTopRight = renderBlocks.mixAoBrightness( + brightnessMixedXYZPNP, + brightnessMixedXYZPNN, + brightnessMixedXYZPPN, + brightnessMixedXYZPPP, + (1.0D - renderBlocks.renderMaxY) * renderBlocks.renderMaxZ, + (1.0D - renderBlocks.renderMaxY) * (1.0D - renderBlocks.renderMaxZ), + renderBlocks.renderMaxY * (1.0D - renderBlocks.renderMaxZ), + renderBlocks.renderMaxY * renderBlocks.renderMaxZ); } return this; @@ -476,43 +696,150 @@ public class LightingHelper { float ratio = (float) (1.0F - renderBlocks.renderMinY); float aoLightValue = renderBlocks.blockAccess.getBlock(x, y - 1, z).getAmbientOcclusionLightValue(); - renderBlocks.aoBrightnessXYNN = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x - 1, yOffset, z); - renderBlocks.aoBrightnessYZNN = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x, yOffset, z - 1); - renderBlocks.aoBrightnessYZNP = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x, yOffset, z + 1); - renderBlocks.aoBrightnessXYPN = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x + 1, yOffset, z); - renderBlocks.aoBrightnessXYZNNN = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x - 1, yOffset, z - 1); - renderBlocks.aoBrightnessXYZNNP = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x - 1, yOffset, z + 1); - renderBlocks.aoBrightnessXYZPNN = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x + 1, yOffset, z - 1); - renderBlocks.aoBrightnessXYZPNP = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x + 1, yOffset, z + 1); - renderBlocks.aoLightValueScratchXYNN = getMixedAo(renderBlocks.blockAccess.getBlock(x - 1, y - 1, z).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x - 1, y, z).getAmbientOcclusionLightValue(), ratio); - renderBlocks.aoLightValueScratchYZNN = getMixedAo(renderBlocks.blockAccess.getBlock(x, y - 1, z - 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x, y, z - 1).getAmbientOcclusionLightValue(), ratio); - renderBlocks.aoLightValueScratchYZNP = getMixedAo(renderBlocks.blockAccess.getBlock(x, y - 1, z + 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x, y, z + 1).getAmbientOcclusionLightValue(), ratio); - renderBlocks.aoLightValueScratchXYPN = getMixedAo(renderBlocks.blockAccess.getBlock(x + 1, y - 1, z).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x + 1, y, z).getAmbientOcclusionLightValue(), ratio); - renderBlocks.aoLightValueScratchXYZNNN = getMixedAo(renderBlocks.blockAccess.getBlock(x - 1, y - 1, z - 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x - 1, y, z - 1).getAmbientOcclusionLightValue(), ratio); - renderBlocks.aoLightValueScratchXYZNNP = getMixedAo(renderBlocks.blockAccess.getBlock(x - 1, y - 1, z + 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x - 1, y, z + 1).getAmbientOcclusionLightValue(), ratio); - renderBlocks.aoLightValueScratchXYZPNN = getMixedAo(renderBlocks.blockAccess.getBlock(x + 1, y - 1, z - 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x + 1, y, z - 1).getAmbientOcclusionLightValue(), ratio); - renderBlocks.aoLightValueScratchXYZPNP = getMixedAo(renderBlocks.blockAccess.getBlock(x + 1, y - 1, z + 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x + 1, y, z + 1).getAmbientOcclusionLightValue(), ratio); - - int brightnessMixedXYZPNP = renderBlocks.getAoBrightness(renderBlocks.aoBrightnessYZNP, renderBlocks.aoBrightnessXYZPNP, renderBlocks.aoBrightnessXYPN, mixedBrightness); - int brightnessMixedXYZPNN = renderBlocks.getAoBrightness(renderBlocks.aoBrightnessYZNN, renderBlocks.aoBrightnessXYPN, renderBlocks.aoBrightnessXYZPNN, mixedBrightness); - int brightnessMixedXYZNNN = renderBlocks.getAoBrightness(renderBlocks.aoBrightnessXYNN, renderBlocks.aoBrightnessXYZNNN, renderBlocks.aoBrightnessYZNN, mixedBrightness); - int brightnessMixedXYZNNP = renderBlocks.getAoBrightness(renderBlocks.aoBrightnessXYZNNP, renderBlocks.aoBrightnessXYNN, renderBlocks.aoBrightnessYZNP, mixedBrightness); - - float aoMixedXYZPNP = (renderBlocks.aoLightValueScratchYZNP + aoLightValue + renderBlocks.aoLightValueScratchXYZPNP + renderBlocks.aoLightValueScratchXYPN) / 4.0F; - float aoMixedXYZPNN = (aoLightValue + renderBlocks.aoLightValueScratchYZNN + renderBlocks.aoLightValueScratchXYPN + renderBlocks.aoLightValueScratchXYZPNN) / 4.0F; - float aoMixedXYZNNN = (renderBlocks.aoLightValueScratchXYNN + renderBlocks.aoLightValueScratchXYZNNN + aoLightValue + renderBlocks.aoLightValueScratchYZNN) / 4.0F; - float aoMixedXYZNNP = (renderBlocks.aoLightValueScratchXYZNNP + renderBlocks.aoLightValueScratchXYNN + renderBlocks.aoLightValueScratchYZNP + aoLightValue) / 4.0F; - - aoTopLeft = (float) (aoMixedXYZNNP * renderBlocks.renderMaxZ * (1.0D - renderBlocks.renderMinX) + aoMixedXYZPNP * renderBlocks.renderMaxZ * renderBlocks.renderMinX + aoMixedXYZPNN * (1.0D - renderBlocks.renderMaxZ) * renderBlocks.renderMinX + aoMixedXYZNNN * (1.0D - renderBlocks.renderMaxZ) * (1.0D - renderBlocks.renderMinX)); - aoBottomLeft = (float) (aoMixedXYZNNP * renderBlocks.renderMinZ * (1.0D - renderBlocks.renderMinX) + aoMixedXYZPNP * renderBlocks.renderMinZ * renderBlocks.renderMinX + aoMixedXYZPNN * (1.0D - renderBlocks.renderMinZ) * renderBlocks.renderMinX + aoMixedXYZNNN * (1.0D - renderBlocks.renderMinZ) * (1.0D - renderBlocks.renderMinX)); - aoBottomRight = (float) (aoMixedXYZNNP * renderBlocks.renderMinZ * (1.0D - renderBlocks.renderMaxX) + aoMixedXYZPNP * renderBlocks.renderMinZ * renderBlocks.renderMaxX + aoMixedXYZPNN * (1.0D - renderBlocks.renderMinZ) * renderBlocks.renderMaxX + aoMixedXYZNNN * (1.0D - renderBlocks.renderMinZ) * (1.0D - renderBlocks.renderMaxX)); - aoTopRight = (float) (aoMixedXYZNNP * renderBlocks.renderMaxZ * (1.0D - renderBlocks.renderMaxX) + aoMixedXYZPNP * renderBlocks.renderMaxZ * renderBlocks.renderMaxX + aoMixedXYZPNN * (1.0D - renderBlocks.renderMaxZ) * renderBlocks.renderMaxX + aoMixedXYZNNN * (1.0D - renderBlocks.renderMaxZ) * (1.0D - renderBlocks.renderMaxX)); - - renderBlocks.brightnessTopLeft = renderBlocks.mixAoBrightness(brightnessMixedXYZNNP, brightnessMixedXYZPNP, brightnessMixedXYZPNN, brightnessMixedXYZNNN, renderBlocks.renderMaxZ * (1.0D - renderBlocks.renderMinX), renderBlocks.renderMaxZ * renderBlocks.renderMinX, (1.0D - renderBlocks.renderMaxZ) * renderBlocks.renderMinX, (1.0D - renderBlocks.renderMaxZ) * (1.0D - renderBlocks.renderMinX)); - renderBlocks.brightnessBottomLeft = renderBlocks.mixAoBrightness(brightnessMixedXYZNNP, brightnessMixedXYZPNP, brightnessMixedXYZPNN, brightnessMixedXYZNNN, renderBlocks.renderMinZ * (1.0D - renderBlocks.renderMinX), renderBlocks.renderMinZ * renderBlocks.renderMinX, (1.0D - renderBlocks.renderMinZ) * renderBlocks.renderMinX, (1.0D - renderBlocks.renderMinZ) * (1.0D - renderBlocks.renderMinX)); - renderBlocks.brightnessBottomRight = renderBlocks.mixAoBrightness(brightnessMixedXYZNNP, brightnessMixedXYZPNP, brightnessMixedXYZPNN, brightnessMixedXYZNNN, renderBlocks.renderMinZ * (1.0D - renderBlocks.renderMaxX), renderBlocks.renderMinZ * renderBlocks.renderMaxX, (1.0D - renderBlocks.renderMinZ) * renderBlocks.renderMaxX, (1.0D - renderBlocks.renderMinZ) * (1.0D - renderBlocks.renderMaxX)); - renderBlocks.brightnessTopRight = renderBlocks.mixAoBrightness(brightnessMixedXYZNNP, brightnessMixedXYZPNP, brightnessMixedXYZPNN, brightnessMixedXYZNNN, renderBlocks.renderMaxZ * (1.0D - renderBlocks.renderMaxX), renderBlocks.renderMaxZ * renderBlocks.renderMaxX, (1.0D - renderBlocks.renderMaxZ) * renderBlocks.renderMaxX, (1.0D - renderBlocks.renderMaxZ) * (1.0D - renderBlocks.renderMaxX)); - + renderBlocks.aoBrightnessXYNN = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x - 1, yOffset, z); + renderBlocks.aoBrightnessYZNN = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x, yOffset, z - 1); + renderBlocks.aoBrightnessYZNP = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x, yOffset, z + 1); + renderBlocks.aoBrightnessXYPN = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x + 1, yOffset, z); + renderBlocks.aoBrightnessXYZNNN = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x - 1, yOffset, z - 1); + renderBlocks.aoBrightnessXYZNNP = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x - 1, yOffset, z + 1); + renderBlocks.aoBrightnessXYZPNN = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x + 1, yOffset, z - 1); + renderBlocks.aoBrightnessXYZPNP = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x + 1, yOffset, z + 1); + renderBlocks.aoLightValueScratchXYNN = getMixedAo( + renderBlocks.blockAccess.getBlock(x - 1, y - 1, z).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x - 1, y, z).getAmbientOcclusionLightValue(), + ratio); + renderBlocks.aoLightValueScratchYZNN = getMixedAo( + renderBlocks.blockAccess.getBlock(x, y - 1, z - 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x, y, z - 1).getAmbientOcclusionLightValue(), + ratio); + renderBlocks.aoLightValueScratchYZNP = getMixedAo( + renderBlocks.blockAccess.getBlock(x, y - 1, z + 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x, y, z + 1).getAmbientOcclusionLightValue(), + ratio); + renderBlocks.aoLightValueScratchXYPN = getMixedAo( + renderBlocks.blockAccess.getBlock(x + 1, y - 1, z).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x + 1, y, z).getAmbientOcclusionLightValue(), + ratio); + renderBlocks.aoLightValueScratchXYZNNN = getMixedAo( + renderBlocks.blockAccess.getBlock(x - 1, y - 1, z - 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x - 1, y, z - 1).getAmbientOcclusionLightValue(), + ratio); + renderBlocks.aoLightValueScratchXYZNNP = getMixedAo( + renderBlocks.blockAccess.getBlock(x - 1, y - 1, z + 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x - 1, y, z + 1).getAmbientOcclusionLightValue(), + ratio); + renderBlocks.aoLightValueScratchXYZPNN = getMixedAo( + renderBlocks.blockAccess.getBlock(x + 1, y - 1, z - 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x + 1, y, z - 1).getAmbientOcclusionLightValue(), + ratio); + renderBlocks.aoLightValueScratchXYZPNP = getMixedAo( + renderBlocks.blockAccess.getBlock(x + 1, y - 1, z + 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x + 1, y, z + 1).getAmbientOcclusionLightValue(), + ratio); + + int brightnessMixedXYZPNP = renderBlocks.getAoBrightness( + renderBlocks.aoBrightnessYZNP, + renderBlocks.aoBrightnessXYZPNP, + renderBlocks.aoBrightnessXYPN, + mixedBrightness); + int brightnessMixedXYZPNN = renderBlocks.getAoBrightness( + renderBlocks.aoBrightnessYZNN, + renderBlocks.aoBrightnessXYPN, + renderBlocks.aoBrightnessXYZPNN, + mixedBrightness); + int brightnessMixedXYZNNN = renderBlocks.getAoBrightness( + renderBlocks.aoBrightnessXYNN, + renderBlocks.aoBrightnessXYZNNN, + renderBlocks.aoBrightnessYZNN, + mixedBrightness); + int brightnessMixedXYZNNP = renderBlocks.getAoBrightness( + renderBlocks.aoBrightnessXYZNNP, + renderBlocks.aoBrightnessXYNN, + renderBlocks.aoBrightnessYZNP, + mixedBrightness); + + float aoMixedXYZPNP = (renderBlocks.aoLightValueScratchYZNP + + aoLightValue + + renderBlocks.aoLightValueScratchXYZPNP + + renderBlocks.aoLightValueScratchXYPN) + / 4.0F; + float aoMixedXYZPNN = (aoLightValue + + renderBlocks.aoLightValueScratchYZNN + + renderBlocks.aoLightValueScratchXYPN + + renderBlocks.aoLightValueScratchXYZPNN) + / 4.0F; + float aoMixedXYZNNN = (renderBlocks.aoLightValueScratchXYNN + + renderBlocks.aoLightValueScratchXYZNNN + + aoLightValue + + renderBlocks.aoLightValueScratchYZNN) + / 4.0F; + float aoMixedXYZNNP = (renderBlocks.aoLightValueScratchXYZNNP + + renderBlocks.aoLightValueScratchXYNN + + renderBlocks.aoLightValueScratchYZNP + + aoLightValue) + / 4.0F; + + aoTopLeft = (float) (aoMixedXYZNNP * renderBlocks.renderMaxZ * (1.0D - renderBlocks.renderMinX) + + aoMixedXYZPNP * renderBlocks.renderMaxZ * renderBlocks.renderMinX + + aoMixedXYZPNN * (1.0D - renderBlocks.renderMaxZ) * renderBlocks.renderMinX + + aoMixedXYZNNN * (1.0D - renderBlocks.renderMaxZ) * (1.0D - renderBlocks.renderMinX)); + aoBottomLeft = (float) (aoMixedXYZNNP * renderBlocks.renderMinZ * (1.0D - renderBlocks.renderMinX) + + aoMixedXYZPNP * renderBlocks.renderMinZ * renderBlocks.renderMinX + + aoMixedXYZPNN * (1.0D - renderBlocks.renderMinZ) * renderBlocks.renderMinX + + aoMixedXYZNNN * (1.0D - renderBlocks.renderMinZ) * (1.0D - renderBlocks.renderMinX)); + aoBottomRight = (float) (aoMixedXYZNNP * renderBlocks.renderMinZ * (1.0D - renderBlocks.renderMaxX) + + aoMixedXYZPNP * renderBlocks.renderMinZ * renderBlocks.renderMaxX + + aoMixedXYZPNN * (1.0D - renderBlocks.renderMinZ) * renderBlocks.renderMaxX + + aoMixedXYZNNN * (1.0D - renderBlocks.renderMinZ) * (1.0D - renderBlocks.renderMaxX)); + aoTopRight = (float) (aoMixedXYZNNP * renderBlocks.renderMaxZ * (1.0D - renderBlocks.renderMaxX) + + aoMixedXYZPNP * renderBlocks.renderMaxZ * renderBlocks.renderMaxX + + aoMixedXYZPNN * (1.0D - renderBlocks.renderMaxZ) * renderBlocks.renderMaxX + + aoMixedXYZNNN * (1.0D - renderBlocks.renderMaxZ) * (1.0D - renderBlocks.renderMaxX)); + + renderBlocks.brightnessTopLeft = renderBlocks.mixAoBrightness( + brightnessMixedXYZNNP, + brightnessMixedXYZPNP, + brightnessMixedXYZPNN, + brightnessMixedXYZNNN, + renderBlocks.renderMaxZ * (1.0D - renderBlocks.renderMinX), + renderBlocks.renderMaxZ * renderBlocks.renderMinX, + (1.0D - renderBlocks.renderMaxZ) * renderBlocks.renderMinX, + (1.0D - renderBlocks.renderMaxZ) * (1.0D - renderBlocks.renderMinX)); + renderBlocks.brightnessBottomLeft = renderBlocks.mixAoBrightness( + brightnessMixedXYZNNP, + brightnessMixedXYZPNP, + brightnessMixedXYZPNN, + brightnessMixedXYZNNN, + renderBlocks.renderMinZ * (1.0D - renderBlocks.renderMinX), + renderBlocks.renderMinZ * renderBlocks.renderMinX, + (1.0D - renderBlocks.renderMinZ) * renderBlocks.renderMinX, + (1.0D - renderBlocks.renderMinZ) * (1.0D - renderBlocks.renderMinX)); + renderBlocks.brightnessBottomRight = renderBlocks.mixAoBrightness( + brightnessMixedXYZNNP, + brightnessMixedXYZPNP, + brightnessMixedXYZPNN, + brightnessMixedXYZNNN, + renderBlocks.renderMinZ * (1.0D - renderBlocks.renderMaxX), + renderBlocks.renderMinZ * renderBlocks.renderMaxX, + (1.0D - renderBlocks.renderMinZ) * renderBlocks.renderMaxX, + (1.0D - renderBlocks.renderMinZ) * (1.0D - renderBlocks.renderMaxX)); + renderBlocks.brightnessTopRight = renderBlocks.mixAoBrightness( + brightnessMixedXYZNNP, + brightnessMixedXYZPNP, + brightnessMixedXYZPNN, + brightnessMixedXYZNNN, + renderBlocks.renderMaxZ * (1.0D - renderBlocks.renderMaxX), + renderBlocks.renderMaxZ * renderBlocks.renderMaxX, + (1.0D - renderBlocks.renderMaxZ) * renderBlocks.renderMaxX, + (1.0D - renderBlocks.renderMaxZ) * (1.0D - renderBlocks.renderMaxX)); } return this; @@ -546,42 +873,150 @@ public class LightingHelper { float aoLightValue = renderBlocks.blockAccess.getBlock(x, y + 1, z).getAmbientOcclusionLightValue(); - renderBlocks.aoBrightnessXYNP = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x - 1, yOffset, z); - renderBlocks.aoBrightnessXYPP = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x + 1, yOffset, z); - renderBlocks.aoBrightnessYZPN = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x, yOffset, z - 1); - renderBlocks.aoBrightnessYZPP = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x, yOffset, z + 1); - renderBlocks.aoBrightnessXYZNPN = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x - 1, yOffset, z - 1); - renderBlocks.aoBrightnessXYZPPN = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x + 1, yOffset, z - 1); - renderBlocks.aoBrightnessXYZNPP = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x - 1, yOffset, z + 1); - renderBlocks.aoBrightnessXYZPPP = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x + 1, yOffset, z + 1); - renderBlocks.aoLightValueScratchXYNP = getMixedAo(renderBlocks.blockAccess.getBlock(x - 1, y + 1, z).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x - 1, y, z).getAmbientOcclusionLightValue(), renderBlocks.renderMaxY); - renderBlocks.aoLightValueScratchXYPP = getMixedAo(renderBlocks.blockAccess.getBlock(x + 1, y + 1, z).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x + 1, y, z).getAmbientOcclusionLightValue(), renderBlocks.renderMaxY); - renderBlocks.aoLightValueScratchYZPN = getMixedAo(renderBlocks.blockAccess.getBlock(x, y + 1, z - 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x, y, z - 1).getAmbientOcclusionLightValue(), renderBlocks.renderMaxY); - renderBlocks.aoLightValueScratchYZPP = getMixedAo(renderBlocks.blockAccess.getBlock(x, y + 1, z + 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x, y, z + 1).getAmbientOcclusionLightValue(), renderBlocks.renderMaxY); - renderBlocks.aoLightValueScratchXYZNPN = getMixedAo(renderBlocks.blockAccess.getBlock(x - 1, y + 1, z - 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x - 1, y, z - 1).getAmbientOcclusionLightValue(), renderBlocks.renderMaxY); - renderBlocks.aoLightValueScratchXYZPPN = getMixedAo(renderBlocks.blockAccess.getBlock(x + 1, y + 1, z - 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x + 1, y, z - 1).getAmbientOcclusionLightValue(), renderBlocks.renderMaxY); - renderBlocks.aoLightValueScratchXYZNPP = getMixedAo(renderBlocks.blockAccess.getBlock(x - 1, y + 1, z + 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x - 1, y, z + 1).getAmbientOcclusionLightValue(), renderBlocks.renderMaxY); - renderBlocks.aoLightValueScratchXYZPPP = getMixedAo(renderBlocks.blockAccess.getBlock(x + 1, y + 1, z + 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x + 1, y, z + 1).getAmbientOcclusionLightValue(), renderBlocks.renderMaxY); - - int brightnessMixedXYZPPP = renderBlocks.getAoBrightness(renderBlocks.aoBrightnessYZPP, renderBlocks.aoBrightnessXYZPPP, renderBlocks.aoBrightnessXYPP, mixedBrightness); - int brightnessMixedXYZPPN = renderBlocks.getAoBrightness(renderBlocks.aoBrightnessYZPN, renderBlocks.aoBrightnessXYPP, renderBlocks.aoBrightnessXYZPPN, mixedBrightness); - int brightnessMixedXYZNPN = renderBlocks.getAoBrightness(renderBlocks.aoBrightnessXYNP, renderBlocks.aoBrightnessXYZNPN, renderBlocks.aoBrightnessYZPN, mixedBrightness); - int brightnessMixedXYZNPP = renderBlocks.getAoBrightness(renderBlocks.aoBrightnessXYZNPP, renderBlocks.aoBrightnessXYNP, renderBlocks.aoBrightnessYZPP, mixedBrightness); - - float aoMixedXYZPPP = (renderBlocks.aoLightValueScratchYZPP + aoLightValue + renderBlocks.aoLightValueScratchXYZPPP + renderBlocks.aoLightValueScratchXYPP) / 4.0F; - float aoMixedXYZPPN = (aoLightValue + renderBlocks.aoLightValueScratchYZPN + renderBlocks.aoLightValueScratchXYPP + renderBlocks.aoLightValueScratchXYZPPN) / 4.0F; - float aoMixedXYZNPN = (renderBlocks.aoLightValueScratchXYNP + renderBlocks.aoLightValueScratchXYZNPN + aoLightValue + renderBlocks.aoLightValueScratchYZPN) / 4.0F; - float aoMixedXYZNPP = (renderBlocks.aoLightValueScratchXYZNPP + renderBlocks.aoLightValueScratchXYNP + renderBlocks.aoLightValueScratchYZPP + aoLightValue) / 4.0F; - - aoTopLeft /*SE*/ = (float) (aoMixedXYZNPP * renderBlocks.renderMaxZ * (1.0D - renderBlocks.renderMaxX) + aoMixedXYZPPP * renderBlocks.renderMaxZ * renderBlocks.renderMaxX + aoMixedXYZPPN * (1.0D - renderBlocks.renderMaxZ) * renderBlocks.renderMaxX + aoMixedXYZNPN * (1.0D - renderBlocks.renderMaxZ) * (1.0D - renderBlocks.renderMaxX)); - aoBottomLeft /*NE*/ = (float) (aoMixedXYZNPP * renderBlocks.renderMinZ * (1.0D - renderBlocks.renderMaxX) + aoMixedXYZPPP * renderBlocks.renderMinZ * renderBlocks.renderMaxX + aoMixedXYZPPN * (1.0D - renderBlocks.renderMinZ) * renderBlocks.renderMaxX + aoMixedXYZNPN * (1.0D - renderBlocks.renderMinZ) * (1.0D - renderBlocks.renderMaxX)); - aoBottomRight /*NW*/ = (float) (aoMixedXYZNPP * renderBlocks.renderMinZ * (1.0D - renderBlocks.renderMinX) + aoMixedXYZPPP * renderBlocks.renderMinZ * renderBlocks.renderMinX + aoMixedXYZPPN * (1.0D - renderBlocks.renderMinZ) * renderBlocks.renderMinX + aoMixedXYZNPN * (1.0D - renderBlocks.renderMinZ) * (1.0D - renderBlocks.renderMinX)); - aoTopRight /*SW*/ = (float) (aoMixedXYZNPP * renderBlocks.renderMaxZ * (1.0D - renderBlocks.renderMinX) + aoMixedXYZPPP * renderBlocks.renderMaxZ * renderBlocks.renderMinX + aoMixedXYZPPN * (1.0D - renderBlocks.renderMaxZ) * renderBlocks.renderMinX + aoMixedXYZNPN * (1.0D - renderBlocks.renderMaxZ) * (1.0D - renderBlocks.renderMinX)); - - renderBlocks.brightnessTopLeft = renderBlocks.mixAoBrightness(brightnessMixedXYZNPP, brightnessMixedXYZPPP, brightnessMixedXYZPPN, brightnessMixedXYZNPN, renderBlocks.renderMaxZ * (1.0D - renderBlocks.renderMaxX), renderBlocks.renderMaxZ * renderBlocks.renderMaxX, (1.0D - renderBlocks.renderMaxZ) * renderBlocks.renderMaxX, (1.0D - renderBlocks.renderMaxZ) * (1.0D - renderBlocks.renderMaxX)); - renderBlocks.brightnessBottomLeft = renderBlocks.mixAoBrightness(brightnessMixedXYZNPP, brightnessMixedXYZPPP, brightnessMixedXYZPPN, brightnessMixedXYZNPN, renderBlocks.renderMinZ * (1.0D - renderBlocks.renderMaxX), renderBlocks.renderMinZ * renderBlocks.renderMaxX, (1.0D - renderBlocks.renderMinZ) * renderBlocks.renderMaxX, (1.0D - renderBlocks.renderMinZ) * (1.0D - renderBlocks.renderMaxX)); - renderBlocks.brightnessBottomRight = renderBlocks.mixAoBrightness(brightnessMixedXYZNPP, brightnessMixedXYZPPP, brightnessMixedXYZPPN, brightnessMixedXYZNPN, renderBlocks.renderMinZ * (1.0D - renderBlocks.renderMinX), renderBlocks.renderMinZ * renderBlocks.renderMinX, (1.0D - renderBlocks.renderMinZ) * renderBlocks.renderMinX, (1.0D - renderBlocks.renderMinZ) * (1.0D - renderBlocks.renderMinX)); - renderBlocks.brightnessTopRight = renderBlocks.mixAoBrightness(brightnessMixedXYZNPP, brightnessMixedXYZPPP, brightnessMixedXYZPPN, brightnessMixedXYZNPN, renderBlocks.renderMaxZ * (1.0D - renderBlocks.renderMinX), renderBlocks.renderMaxZ * renderBlocks.renderMinX, (1.0D - renderBlocks.renderMaxZ) * renderBlocks.renderMinX, (1.0D - renderBlocks.renderMaxZ) * (1.0D - renderBlocks.renderMinX)); + renderBlocks.aoBrightnessXYNP = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x - 1, yOffset, z); + renderBlocks.aoBrightnessXYPP = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x + 1, yOffset, z); + renderBlocks.aoBrightnessYZPN = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x, yOffset, z - 1); + renderBlocks.aoBrightnessYZPP = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x, yOffset, z + 1); + renderBlocks.aoBrightnessXYZNPN = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x - 1, yOffset, z - 1); + renderBlocks.aoBrightnessXYZPPN = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x + 1, yOffset, z - 1); + renderBlocks.aoBrightnessXYZNPP = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x - 1, yOffset, z + 1); + renderBlocks.aoBrightnessXYZPPP = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x + 1, yOffset, z + 1); + renderBlocks.aoLightValueScratchXYNP = getMixedAo( + renderBlocks.blockAccess.getBlock(x - 1, y + 1, z).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x - 1, y, z).getAmbientOcclusionLightValue(), + renderBlocks.renderMaxY); + renderBlocks.aoLightValueScratchXYPP = getMixedAo( + renderBlocks.blockAccess.getBlock(x + 1, y + 1, z).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x + 1, y, z).getAmbientOcclusionLightValue(), + renderBlocks.renderMaxY); + renderBlocks.aoLightValueScratchYZPN = getMixedAo( + renderBlocks.blockAccess.getBlock(x, y + 1, z - 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x, y, z - 1).getAmbientOcclusionLightValue(), + renderBlocks.renderMaxY); + renderBlocks.aoLightValueScratchYZPP = getMixedAo( + renderBlocks.blockAccess.getBlock(x, y + 1, z + 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x, y, z + 1).getAmbientOcclusionLightValue(), + renderBlocks.renderMaxY); + renderBlocks.aoLightValueScratchXYZNPN = getMixedAo( + renderBlocks.blockAccess.getBlock(x - 1, y + 1, z - 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x - 1, y, z - 1).getAmbientOcclusionLightValue(), + renderBlocks.renderMaxY); + renderBlocks.aoLightValueScratchXYZPPN = getMixedAo( + renderBlocks.blockAccess.getBlock(x + 1, y + 1, z - 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x + 1, y, z - 1).getAmbientOcclusionLightValue(), + renderBlocks.renderMaxY); + renderBlocks.aoLightValueScratchXYZNPP = getMixedAo( + renderBlocks.blockAccess.getBlock(x - 1, y + 1, z + 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x - 1, y, z + 1).getAmbientOcclusionLightValue(), + renderBlocks.renderMaxY); + renderBlocks.aoLightValueScratchXYZPPP = getMixedAo( + renderBlocks.blockAccess.getBlock(x + 1, y + 1, z + 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x + 1, y, z + 1).getAmbientOcclusionLightValue(), + renderBlocks.renderMaxY); + + int brightnessMixedXYZPPP = renderBlocks.getAoBrightness( + renderBlocks.aoBrightnessYZPP, + renderBlocks.aoBrightnessXYZPPP, + renderBlocks.aoBrightnessXYPP, + mixedBrightness); + int brightnessMixedXYZPPN = renderBlocks.getAoBrightness( + renderBlocks.aoBrightnessYZPN, + renderBlocks.aoBrightnessXYPP, + renderBlocks.aoBrightnessXYZPPN, + mixedBrightness); + int brightnessMixedXYZNPN = renderBlocks.getAoBrightness( + renderBlocks.aoBrightnessXYNP, + renderBlocks.aoBrightnessXYZNPN, + renderBlocks.aoBrightnessYZPN, + mixedBrightness); + int brightnessMixedXYZNPP = renderBlocks.getAoBrightness( + renderBlocks.aoBrightnessXYZNPP, + renderBlocks.aoBrightnessXYNP, + renderBlocks.aoBrightnessYZPP, + mixedBrightness); + + float aoMixedXYZPPP = (renderBlocks.aoLightValueScratchYZPP + + aoLightValue + + renderBlocks.aoLightValueScratchXYZPPP + + renderBlocks.aoLightValueScratchXYPP) + / 4.0F; + float aoMixedXYZPPN = (aoLightValue + + renderBlocks.aoLightValueScratchYZPN + + renderBlocks.aoLightValueScratchXYPP + + renderBlocks.aoLightValueScratchXYZPPN) + / 4.0F; + float aoMixedXYZNPN = (renderBlocks.aoLightValueScratchXYNP + + renderBlocks.aoLightValueScratchXYZNPN + + aoLightValue + + renderBlocks.aoLightValueScratchYZPN) + / 4.0F; + float aoMixedXYZNPP = (renderBlocks.aoLightValueScratchXYZNPP + + renderBlocks.aoLightValueScratchXYNP + + renderBlocks.aoLightValueScratchYZPP + + aoLightValue) + / 4.0F; + + aoTopLeft /*SE*/ = (float) (aoMixedXYZNPP * renderBlocks.renderMaxZ * (1.0D - renderBlocks.renderMaxX) + + aoMixedXYZPPP * renderBlocks.renderMaxZ * renderBlocks.renderMaxX + + aoMixedXYZPPN * (1.0D - renderBlocks.renderMaxZ) * renderBlocks.renderMaxX + + aoMixedXYZNPN * (1.0D - renderBlocks.renderMaxZ) * (1.0D - renderBlocks.renderMaxX)); + aoBottomLeft /*NE*/ = (float) (aoMixedXYZNPP * renderBlocks.renderMinZ * (1.0D - renderBlocks.renderMaxX) + + aoMixedXYZPPP * renderBlocks.renderMinZ * renderBlocks.renderMaxX + + aoMixedXYZPPN * (1.0D - renderBlocks.renderMinZ) * renderBlocks.renderMaxX + + aoMixedXYZNPN * (1.0D - renderBlocks.renderMinZ) * (1.0D - renderBlocks.renderMaxX)); + aoBottomRight /*NW*/ = (float) (aoMixedXYZNPP * renderBlocks.renderMinZ * (1.0D - renderBlocks.renderMinX) + + aoMixedXYZPPP * renderBlocks.renderMinZ * renderBlocks.renderMinX + + aoMixedXYZPPN * (1.0D - renderBlocks.renderMinZ) * renderBlocks.renderMinX + + aoMixedXYZNPN * (1.0D - renderBlocks.renderMinZ) * (1.0D - renderBlocks.renderMinX)); + aoTopRight /*SW*/ = (float) (aoMixedXYZNPP * renderBlocks.renderMaxZ * (1.0D - renderBlocks.renderMinX) + + aoMixedXYZPPP * renderBlocks.renderMaxZ * renderBlocks.renderMinX + + aoMixedXYZPPN * (1.0D - renderBlocks.renderMaxZ) * renderBlocks.renderMinX + + aoMixedXYZNPN * (1.0D - renderBlocks.renderMaxZ) * (1.0D - renderBlocks.renderMinX)); + + renderBlocks.brightnessTopLeft = renderBlocks.mixAoBrightness( + brightnessMixedXYZNPP, + brightnessMixedXYZPPP, + brightnessMixedXYZPPN, + brightnessMixedXYZNPN, + renderBlocks.renderMaxZ * (1.0D - renderBlocks.renderMaxX), + renderBlocks.renderMaxZ * renderBlocks.renderMaxX, + (1.0D - renderBlocks.renderMaxZ) * renderBlocks.renderMaxX, + (1.0D - renderBlocks.renderMaxZ) * (1.0D - renderBlocks.renderMaxX)); + renderBlocks.brightnessBottomLeft = renderBlocks.mixAoBrightness( + brightnessMixedXYZNPP, + brightnessMixedXYZPPP, + brightnessMixedXYZPPN, + brightnessMixedXYZNPN, + renderBlocks.renderMinZ * (1.0D - renderBlocks.renderMaxX), + renderBlocks.renderMinZ * renderBlocks.renderMaxX, + (1.0D - renderBlocks.renderMinZ) * renderBlocks.renderMaxX, + (1.0D - renderBlocks.renderMinZ) * (1.0D - renderBlocks.renderMaxX)); + renderBlocks.brightnessBottomRight = renderBlocks.mixAoBrightness( + brightnessMixedXYZNPP, + brightnessMixedXYZPPP, + brightnessMixedXYZPPN, + brightnessMixedXYZNPN, + renderBlocks.renderMinZ * (1.0D - renderBlocks.renderMinX), + renderBlocks.renderMinZ * renderBlocks.renderMinX, + (1.0D - renderBlocks.renderMinZ) * renderBlocks.renderMinX, + (1.0D - renderBlocks.renderMinZ) * (1.0D - renderBlocks.renderMinX)); + renderBlocks.brightnessTopRight = renderBlocks.mixAoBrightness( + brightnessMixedXYZNPP, + brightnessMixedXYZPPP, + brightnessMixedXYZPPN, + brightnessMixedXYZNPN, + renderBlocks.renderMaxZ * (1.0D - renderBlocks.renderMinX), + renderBlocks.renderMaxZ * renderBlocks.renderMinX, + (1.0D - renderBlocks.renderMaxZ) * renderBlocks.renderMinX, + (1.0D - renderBlocks.renderMaxZ) * (1.0D - renderBlocks.renderMinX)); } return this; @@ -616,43 +1051,150 @@ public class LightingHelper { float ratio = (float) (1.0F - renderBlocks.renderMinZ); float aoLightValue = renderBlocks.blockAccess.getBlock(x, y, z - 1).getAmbientOcclusionLightValue(); - renderBlocks.aoBrightnessXZNN = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x - 1, y, zOffset); - renderBlocks.aoBrightnessYZNN = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x, y - 1, zOffset); - renderBlocks.aoBrightnessYZPN = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x, y + 1, zOffset); - renderBlocks.aoBrightnessXZPN = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x + 1, y, zOffset); - renderBlocks.aoBrightnessXYZNNN = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x - 1, y - 1, zOffset); - renderBlocks.aoBrightnessXYZNPN = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x - 1, y + 1, zOffset); - renderBlocks.aoBrightnessXYZPNN = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x + 1, y - 1, zOffset); - renderBlocks.aoBrightnessXYZPPN = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x + 1, y + 1, zOffset); - renderBlocks.aoLightValueScratchXZNN = getMixedAo(renderBlocks.blockAccess.getBlock(x - 1, y, z - 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x - 1, y, z).getAmbientOcclusionLightValue(), ratio); - renderBlocks.aoLightValueScratchYZNN = getMixedAo(renderBlocks.blockAccess.getBlock(x, y - 1, z - 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x, y - 1, z).getAmbientOcclusionLightValue(), ratio); - renderBlocks.aoLightValueScratchYZPN = getMixedAo(renderBlocks.blockAccess.getBlock(x, y + 1, z - 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x, y + 1, z).getAmbientOcclusionLightValue(), ratio); - renderBlocks.aoLightValueScratchXZPN = getMixedAo(renderBlocks.blockAccess.getBlock(x + 1, y, z - 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x + 1, y, z).getAmbientOcclusionLightValue(), ratio); - renderBlocks.aoLightValueScratchXYZNNN = getMixedAo(renderBlocks.blockAccess.getBlock(x - 1, y - 1, z - 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x - 1, y - 1, z).getAmbientOcclusionLightValue(), ratio); - renderBlocks.aoLightValueScratchXYZNPN = getMixedAo(renderBlocks.blockAccess.getBlock(x - 1, y + 1, z - 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x - 1, y + 1, z).getAmbientOcclusionLightValue(), ratio); - renderBlocks.aoLightValueScratchXYZPNN = getMixedAo(renderBlocks.blockAccess.getBlock(x + 1, y - 1, z - 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x + 1, y - 1, z).getAmbientOcclusionLightValue(), ratio); - renderBlocks.aoLightValueScratchXYZPPN = getMixedAo(renderBlocks.blockAccess.getBlock(x + 1, y + 1, z - 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x + 1, y + 1, z).getAmbientOcclusionLightValue(), ratio); - - int brightnessMixedXYZPPN = renderBlocks.getAoBrightness(renderBlocks.aoBrightnessYZPN, renderBlocks.aoBrightnessXZPN, renderBlocks.aoBrightnessXYZPPN, mixedBrightness); - int brightnessMixedXYZPNN = renderBlocks.getAoBrightness(renderBlocks.aoBrightnessYZNN, renderBlocks.aoBrightnessXYZPNN, renderBlocks.aoBrightnessXZPN, mixedBrightness); - int brightnessMixedXYZNNN = renderBlocks.getAoBrightness(renderBlocks.aoBrightnessXYZNNN, renderBlocks.aoBrightnessXZNN, renderBlocks.aoBrightnessYZNN, mixedBrightness); - int brightnessMixedXYZNPN = renderBlocks.getAoBrightness(renderBlocks.aoBrightnessXZNN, renderBlocks.aoBrightnessXYZNPN, renderBlocks.aoBrightnessYZPN, mixedBrightness); - - float aoMixedXYZPPN = (aoLightValue + renderBlocks.aoLightValueScratchYZPN + renderBlocks.aoLightValueScratchXZPN + renderBlocks.aoLightValueScratchXYZPPN) / 4.0F; - float aoMixedXYZPNN = (renderBlocks.aoLightValueScratchYZNN + aoLightValue + renderBlocks.aoLightValueScratchXYZPNN + renderBlocks.aoLightValueScratchXZPN) / 4.0F; - float aoMixedXYZNNN = (renderBlocks.aoLightValueScratchXYZNNN + renderBlocks.aoLightValueScratchXZNN + renderBlocks.aoLightValueScratchYZNN + aoLightValue) / 4.0F; - float aoMixedXYZNPN = (renderBlocks.aoLightValueScratchXZNN + renderBlocks.aoLightValueScratchXYZNPN + aoLightValue + renderBlocks.aoLightValueScratchYZPN) / 4.0F; - - aoTopLeft = (float) (aoMixedXYZNPN * renderBlocks.renderMaxY * (1.0D - renderBlocks.renderMinX) + aoMixedXYZPPN * renderBlocks.renderMaxY * renderBlocks.renderMinX + aoMixedXYZPNN * (1.0D - renderBlocks.renderMaxY) * renderBlocks.renderMinX + aoMixedXYZNNN * (1.0D - renderBlocks.renderMaxY) * (1.0D - renderBlocks.renderMinX)); - aoBottomLeft = (float) (aoMixedXYZNPN * renderBlocks.renderMaxY * (1.0D - renderBlocks.renderMaxX) + aoMixedXYZPPN * renderBlocks.renderMaxY * renderBlocks.renderMaxX + aoMixedXYZPNN * (1.0D - renderBlocks.renderMaxY) * renderBlocks.renderMaxX + aoMixedXYZNNN * (1.0D - renderBlocks.renderMaxY) * (1.0D - renderBlocks.renderMaxX)); - aoBottomRight = (float) (aoMixedXYZNPN * renderBlocks.renderMinY * (1.0D - renderBlocks.renderMaxX) + aoMixedXYZPPN * renderBlocks.renderMinY * renderBlocks.renderMaxX + aoMixedXYZPNN * (1.0D - renderBlocks.renderMinY) * renderBlocks.renderMaxX + aoMixedXYZNNN * (1.0D - renderBlocks.renderMinY) * (1.0D - renderBlocks.renderMaxX)); - aoTopRight = (float) (aoMixedXYZNPN * renderBlocks.renderMinY * (1.0D - renderBlocks.renderMinX) + aoMixedXYZPPN * renderBlocks.renderMinY * renderBlocks.renderMinX + aoMixedXYZPNN * (1.0D - renderBlocks.renderMinY) * renderBlocks.renderMinX + aoMixedXYZNNN * (1.0D - renderBlocks.renderMinY) * (1.0D - renderBlocks.renderMinX)); - - renderBlocks.brightnessTopLeft = renderBlocks.mixAoBrightness(brightnessMixedXYZNPN, brightnessMixedXYZPPN, brightnessMixedXYZPNN, brightnessMixedXYZNNN, renderBlocks.renderMaxY * (1.0D - renderBlocks.renderMinX), renderBlocks.renderMaxY * renderBlocks.renderMinX, (1.0D - renderBlocks.renderMaxY) * renderBlocks.renderMinX, (1.0D - renderBlocks.renderMaxY) * (1.0D - renderBlocks.renderMinX)); - renderBlocks.brightnessBottomLeft = renderBlocks.mixAoBrightness(brightnessMixedXYZNPN, brightnessMixedXYZPPN, brightnessMixedXYZPNN, brightnessMixedXYZNNN, renderBlocks.renderMaxY * (1.0D - renderBlocks.renderMaxX), renderBlocks.renderMaxY * renderBlocks.renderMaxX, (1.0D - renderBlocks.renderMaxY) * renderBlocks.renderMaxX, (1.0D - renderBlocks.renderMaxY) * (1.0D - renderBlocks.renderMaxX)); - renderBlocks.brightnessBottomRight = renderBlocks.mixAoBrightness(brightnessMixedXYZNPN, brightnessMixedXYZPPN, brightnessMixedXYZPNN, brightnessMixedXYZNNN, renderBlocks.renderMinY * (1.0D - renderBlocks.renderMaxX), renderBlocks.renderMinY * renderBlocks.renderMaxX, (1.0D - renderBlocks.renderMinY) * renderBlocks.renderMaxX, (1.0D - renderBlocks.renderMinY) * (1.0D - renderBlocks.renderMaxX)); - renderBlocks.brightnessTopRight = renderBlocks.mixAoBrightness(brightnessMixedXYZNPN, brightnessMixedXYZPPN, brightnessMixedXYZPNN, brightnessMixedXYZNNN, renderBlocks.renderMinY * (1.0D - renderBlocks.renderMinX), renderBlocks.renderMinY * renderBlocks.renderMinX, (1.0D - renderBlocks.renderMinY) * renderBlocks.renderMinX, (1.0D - renderBlocks.renderMinY) * (1.0D - renderBlocks.renderMinX)); - + renderBlocks.aoBrightnessXZNN = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x - 1, y, zOffset); + renderBlocks.aoBrightnessYZNN = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x, y - 1, zOffset); + renderBlocks.aoBrightnessYZPN = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x, y + 1, zOffset); + renderBlocks.aoBrightnessXZPN = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x + 1, y, zOffset); + renderBlocks.aoBrightnessXYZNNN = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x - 1, y - 1, zOffset); + renderBlocks.aoBrightnessXYZNPN = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x - 1, y + 1, zOffset); + renderBlocks.aoBrightnessXYZPNN = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x + 1, y - 1, zOffset); + renderBlocks.aoBrightnessXYZPPN = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x + 1, y + 1, zOffset); + renderBlocks.aoLightValueScratchXZNN = getMixedAo( + renderBlocks.blockAccess.getBlock(x - 1, y, z - 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x - 1, y, z).getAmbientOcclusionLightValue(), + ratio); + renderBlocks.aoLightValueScratchYZNN = getMixedAo( + renderBlocks.blockAccess.getBlock(x, y - 1, z - 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x, y - 1, z).getAmbientOcclusionLightValue(), + ratio); + renderBlocks.aoLightValueScratchYZPN = getMixedAo( + renderBlocks.blockAccess.getBlock(x, y + 1, z - 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x, y + 1, z).getAmbientOcclusionLightValue(), + ratio); + renderBlocks.aoLightValueScratchXZPN = getMixedAo( + renderBlocks.blockAccess.getBlock(x + 1, y, z - 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x + 1, y, z).getAmbientOcclusionLightValue(), + ratio); + renderBlocks.aoLightValueScratchXYZNNN = getMixedAo( + renderBlocks.blockAccess.getBlock(x - 1, y - 1, z - 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x - 1, y - 1, z).getAmbientOcclusionLightValue(), + ratio); + renderBlocks.aoLightValueScratchXYZNPN = getMixedAo( + renderBlocks.blockAccess.getBlock(x - 1, y + 1, z - 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x - 1, y + 1, z).getAmbientOcclusionLightValue(), + ratio); + renderBlocks.aoLightValueScratchXYZPNN = getMixedAo( + renderBlocks.blockAccess.getBlock(x + 1, y - 1, z - 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x + 1, y - 1, z).getAmbientOcclusionLightValue(), + ratio); + renderBlocks.aoLightValueScratchXYZPPN = getMixedAo( + renderBlocks.blockAccess.getBlock(x + 1, y + 1, z - 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x + 1, y + 1, z).getAmbientOcclusionLightValue(), + ratio); + + int brightnessMixedXYZPPN = renderBlocks.getAoBrightness( + renderBlocks.aoBrightnessYZPN, + renderBlocks.aoBrightnessXZPN, + renderBlocks.aoBrightnessXYZPPN, + mixedBrightness); + int brightnessMixedXYZPNN = renderBlocks.getAoBrightness( + renderBlocks.aoBrightnessYZNN, + renderBlocks.aoBrightnessXYZPNN, + renderBlocks.aoBrightnessXZPN, + mixedBrightness); + int brightnessMixedXYZNNN = renderBlocks.getAoBrightness( + renderBlocks.aoBrightnessXYZNNN, + renderBlocks.aoBrightnessXZNN, + renderBlocks.aoBrightnessYZNN, + mixedBrightness); + int brightnessMixedXYZNPN = renderBlocks.getAoBrightness( + renderBlocks.aoBrightnessXZNN, + renderBlocks.aoBrightnessXYZNPN, + renderBlocks.aoBrightnessYZPN, + mixedBrightness); + + float aoMixedXYZPPN = (aoLightValue + + renderBlocks.aoLightValueScratchYZPN + + renderBlocks.aoLightValueScratchXZPN + + renderBlocks.aoLightValueScratchXYZPPN) + / 4.0F; + float aoMixedXYZPNN = (renderBlocks.aoLightValueScratchYZNN + + aoLightValue + + renderBlocks.aoLightValueScratchXYZPNN + + renderBlocks.aoLightValueScratchXZPN) + / 4.0F; + float aoMixedXYZNNN = (renderBlocks.aoLightValueScratchXYZNNN + + renderBlocks.aoLightValueScratchXZNN + + renderBlocks.aoLightValueScratchYZNN + + aoLightValue) + / 4.0F; + float aoMixedXYZNPN = (renderBlocks.aoLightValueScratchXZNN + + renderBlocks.aoLightValueScratchXYZNPN + + aoLightValue + + renderBlocks.aoLightValueScratchYZPN) + / 4.0F; + + aoTopLeft = (float) (aoMixedXYZNPN * renderBlocks.renderMaxY * (1.0D - renderBlocks.renderMinX) + + aoMixedXYZPPN * renderBlocks.renderMaxY * renderBlocks.renderMinX + + aoMixedXYZPNN * (1.0D - renderBlocks.renderMaxY) * renderBlocks.renderMinX + + aoMixedXYZNNN * (1.0D - renderBlocks.renderMaxY) * (1.0D - renderBlocks.renderMinX)); + aoBottomLeft = (float) (aoMixedXYZNPN * renderBlocks.renderMaxY * (1.0D - renderBlocks.renderMaxX) + + aoMixedXYZPPN * renderBlocks.renderMaxY * renderBlocks.renderMaxX + + aoMixedXYZPNN * (1.0D - renderBlocks.renderMaxY) * renderBlocks.renderMaxX + + aoMixedXYZNNN * (1.0D - renderBlocks.renderMaxY) * (1.0D - renderBlocks.renderMaxX)); + aoBottomRight = (float) (aoMixedXYZNPN * renderBlocks.renderMinY * (1.0D - renderBlocks.renderMaxX) + + aoMixedXYZPPN * renderBlocks.renderMinY * renderBlocks.renderMaxX + + aoMixedXYZPNN * (1.0D - renderBlocks.renderMinY) * renderBlocks.renderMaxX + + aoMixedXYZNNN * (1.0D - renderBlocks.renderMinY) * (1.0D - renderBlocks.renderMaxX)); + aoTopRight = (float) (aoMixedXYZNPN * renderBlocks.renderMinY * (1.0D - renderBlocks.renderMinX) + + aoMixedXYZPPN * renderBlocks.renderMinY * renderBlocks.renderMinX + + aoMixedXYZPNN * (1.0D - renderBlocks.renderMinY) * renderBlocks.renderMinX + + aoMixedXYZNNN * (1.0D - renderBlocks.renderMinY) * (1.0D - renderBlocks.renderMinX)); + + renderBlocks.brightnessTopLeft = renderBlocks.mixAoBrightness( + brightnessMixedXYZNPN, + brightnessMixedXYZPPN, + brightnessMixedXYZPNN, + brightnessMixedXYZNNN, + renderBlocks.renderMaxY * (1.0D - renderBlocks.renderMinX), + renderBlocks.renderMaxY * renderBlocks.renderMinX, + (1.0D - renderBlocks.renderMaxY) * renderBlocks.renderMinX, + (1.0D - renderBlocks.renderMaxY) * (1.0D - renderBlocks.renderMinX)); + renderBlocks.brightnessBottomLeft = renderBlocks.mixAoBrightness( + brightnessMixedXYZNPN, + brightnessMixedXYZPPN, + brightnessMixedXYZPNN, + brightnessMixedXYZNNN, + renderBlocks.renderMaxY * (1.0D - renderBlocks.renderMaxX), + renderBlocks.renderMaxY * renderBlocks.renderMaxX, + (1.0D - renderBlocks.renderMaxY) * renderBlocks.renderMaxX, + (1.0D - renderBlocks.renderMaxY) * (1.0D - renderBlocks.renderMaxX)); + renderBlocks.brightnessBottomRight = renderBlocks.mixAoBrightness( + brightnessMixedXYZNPN, + brightnessMixedXYZPPN, + brightnessMixedXYZPNN, + brightnessMixedXYZNNN, + renderBlocks.renderMinY * (1.0D - renderBlocks.renderMaxX), + renderBlocks.renderMinY * renderBlocks.renderMaxX, + (1.0D - renderBlocks.renderMinY) * renderBlocks.renderMaxX, + (1.0D - renderBlocks.renderMinY) * (1.0D - renderBlocks.renderMaxX)); + renderBlocks.brightnessTopRight = renderBlocks.mixAoBrightness( + brightnessMixedXYZNPN, + brightnessMixedXYZPPN, + brightnessMixedXYZPNN, + brightnessMixedXYZNNN, + renderBlocks.renderMinY * (1.0D - renderBlocks.renderMinX), + renderBlocks.renderMinY * renderBlocks.renderMinX, + (1.0D - renderBlocks.renderMinY) * renderBlocks.renderMinX, + (1.0D - renderBlocks.renderMinY) * (1.0D - renderBlocks.renderMinX)); } return this; @@ -686,42 +1228,150 @@ public class LightingHelper { float aoLightValue = renderBlocks.blockAccess.getBlock(x, y, z + 1).getAmbientOcclusionLightValue(); - renderBlocks.aoBrightnessXZNP = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x - 1, y, zOffset); - renderBlocks.aoBrightnessXZPP = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x + 1, y, zOffset); - renderBlocks.aoBrightnessYZNP = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x, y - 1, zOffset); - renderBlocks.aoBrightnessYZPP = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x, y + 1, zOffset); - renderBlocks.aoBrightnessXYZNNP = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x - 1, y - 1, zOffset); - renderBlocks.aoBrightnessXYZNPP = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x - 1, y + 1, zOffset); - renderBlocks.aoBrightnessXYZPNP = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x + 1, y - 1, zOffset); - renderBlocks.aoBrightnessXYZPPP = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x + 1, y + 1, zOffset); - renderBlocks.aoLightValueScratchXZNP = getMixedAo(renderBlocks.blockAccess.getBlock(x - 1, y, z + 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x - 1, y, z).getAmbientOcclusionLightValue(), renderBlocks.renderMaxZ); - renderBlocks.aoLightValueScratchXZPP = getMixedAo(renderBlocks.blockAccess.getBlock(x + 1, y, z + 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x + 1, y, z).getAmbientOcclusionLightValue(), renderBlocks.renderMaxZ); - renderBlocks.aoLightValueScratchYZNP = getMixedAo(renderBlocks.blockAccess.getBlock(x, y - 1, z + 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x, y - 1, z).getAmbientOcclusionLightValue(), renderBlocks.renderMaxZ); - renderBlocks.aoLightValueScratchYZPP = getMixedAo(renderBlocks.blockAccess.getBlock(x, y + 1, z + 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x, y + 1, z).getAmbientOcclusionLightValue(), renderBlocks.renderMaxZ); - renderBlocks.aoLightValueScratchXYZNNP = getMixedAo(renderBlocks.blockAccess.getBlock(x - 1, y - 1, z + 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x - 1, y - 1, z).getAmbientOcclusionLightValue(), renderBlocks.renderMaxZ); - renderBlocks.aoLightValueScratchXYZNPP = getMixedAo(renderBlocks.blockAccess.getBlock(x - 1, y + 1, z + 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x - 1, y + 1, z).getAmbientOcclusionLightValue(), renderBlocks.renderMaxZ); - renderBlocks.aoLightValueScratchXYZPNP = getMixedAo(renderBlocks.blockAccess.getBlock(x + 1, y - 1, z + 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x + 1, y - 1, z).getAmbientOcclusionLightValue(), renderBlocks.renderMaxZ); - renderBlocks.aoLightValueScratchXYZPPP = getMixedAo(renderBlocks.blockAccess.getBlock(x + 1, y + 1, z + 1).getAmbientOcclusionLightValue(), renderBlocks.blockAccess.getBlock(x + 1, y + 1, z).getAmbientOcclusionLightValue(), renderBlocks.renderMaxZ); - - int brightnessMixedXYZNPP = renderBlocks.getAoBrightness(renderBlocks.aoBrightnessXZNP, renderBlocks.aoBrightnessXYZNPP, renderBlocks.aoBrightnessYZPP, mixedBrightness); - int brightnessMixedXYZNNP = renderBlocks.getAoBrightness(renderBlocks.aoBrightnessXYZNNP, renderBlocks.aoBrightnessXZNP, renderBlocks.aoBrightnessYZNP, mixedBrightness); - int brightnessMixedXYZPNP = renderBlocks.getAoBrightness(renderBlocks.aoBrightnessYZNP, renderBlocks.aoBrightnessXYZPNP, renderBlocks.aoBrightnessXZPP, mixedBrightness); - int brightnessMixedXYZPPP = renderBlocks.getAoBrightness(renderBlocks.aoBrightnessYZPP, renderBlocks.aoBrightnessXZPP, renderBlocks.aoBrightnessXYZPPP, mixedBrightness); - - float aoMixedXYZNPP = (renderBlocks.aoLightValueScratchXZNP + renderBlocks.aoLightValueScratchXYZNPP + aoLightValue + renderBlocks.aoLightValueScratchYZPP) / 4.0F; - float aoMixedXYZNNP = (renderBlocks.aoLightValueScratchXYZNNP + renderBlocks.aoLightValueScratchXZNP + renderBlocks.aoLightValueScratchYZNP + aoLightValue) / 4.0F; - float aoMixedXYZPNP = (renderBlocks.aoLightValueScratchYZNP + aoLightValue + renderBlocks.aoLightValueScratchXYZPNP + renderBlocks.aoLightValueScratchXZPP) / 4.0F; - float aoMixedXYZPPP = (aoLightValue + renderBlocks.aoLightValueScratchYZPP + renderBlocks.aoLightValueScratchXZPP + renderBlocks.aoLightValueScratchXYZPPP) / 4.0F; - - aoTopLeft = (float) (aoMixedXYZNPP * renderBlocks.renderMaxY * (1.0D - renderBlocks.renderMinX) + aoMixedXYZPPP * renderBlocks.renderMaxY * renderBlocks.renderMinX + aoMixedXYZPNP * (1.0D - renderBlocks.renderMaxY) * renderBlocks.renderMinX + aoMixedXYZNNP * (1.0D - renderBlocks.renderMaxY) * (1.0D - renderBlocks.renderMinX)); - aoBottomLeft = (float) (aoMixedXYZNPP * renderBlocks.renderMinY * (1.0D - renderBlocks.renderMinX) + aoMixedXYZPPP * renderBlocks.renderMinY * renderBlocks.renderMinX + aoMixedXYZPNP * (1.0D - renderBlocks.renderMinY) * renderBlocks.renderMinX + aoMixedXYZNNP * (1.0D - renderBlocks.renderMinY) * (1.0D - renderBlocks.renderMinX)); - aoBottomRight = (float) (aoMixedXYZNPP * renderBlocks.renderMinY * (1.0D - renderBlocks.renderMaxX) + aoMixedXYZPPP * renderBlocks.renderMinY * renderBlocks.renderMaxX + aoMixedXYZPNP * (1.0D - renderBlocks.renderMinY) * renderBlocks.renderMaxX + aoMixedXYZNNP * (1.0D - renderBlocks.renderMinY) * (1.0D - renderBlocks.renderMaxX)); - aoTopRight = (float) (aoMixedXYZNPP * renderBlocks.renderMaxY * (1.0D - renderBlocks.renderMaxX) + aoMixedXYZPPP * renderBlocks.renderMaxY * renderBlocks.renderMaxX + aoMixedXYZPNP * (1.0D - renderBlocks.renderMaxY) * renderBlocks.renderMaxX + aoMixedXYZNNP * (1.0D - renderBlocks.renderMaxY) * (1.0D - renderBlocks.renderMaxX)); - - renderBlocks.brightnessTopLeft = renderBlocks.mixAoBrightness(brightnessMixedXYZNPP, brightnessMixedXYZNNP, brightnessMixedXYZPNP, brightnessMixedXYZPPP, renderBlocks.renderMaxY * (1.0D - renderBlocks.renderMinX), (1.0D - renderBlocks.renderMaxY) * (1.0D - renderBlocks.renderMinX), (1.0D - renderBlocks.renderMaxY) * renderBlocks.renderMinX, renderBlocks.renderMaxY * renderBlocks.renderMinX); - renderBlocks.brightnessBottomLeft = renderBlocks.mixAoBrightness(brightnessMixedXYZNPP, brightnessMixedXYZNNP, brightnessMixedXYZPNP, brightnessMixedXYZPPP, renderBlocks.renderMinY * (1.0D - renderBlocks.renderMinX), (1.0D - renderBlocks.renderMinY) * (1.0D - renderBlocks.renderMinX), (1.0D - renderBlocks.renderMinY) * renderBlocks.renderMinX, renderBlocks.renderMinY * renderBlocks.renderMinX); - renderBlocks.brightnessBottomRight = renderBlocks.mixAoBrightness(brightnessMixedXYZNPP, brightnessMixedXYZNNP, brightnessMixedXYZPNP, brightnessMixedXYZPPP, renderBlocks.renderMinY * (1.0D - renderBlocks.renderMaxX), (1.0D - renderBlocks.renderMinY) * (1.0D - renderBlocks.renderMaxX), (1.0D - renderBlocks.renderMinY) * renderBlocks.renderMaxX, renderBlocks.renderMinY * renderBlocks.renderMaxX); - renderBlocks.brightnessTopRight = renderBlocks.mixAoBrightness(brightnessMixedXYZNPP, brightnessMixedXYZNNP, brightnessMixedXYZPNP, brightnessMixedXYZPPP, renderBlocks.renderMaxY * (1.0D - renderBlocks.renderMaxX), (1.0D - renderBlocks.renderMaxY) * (1.0D - renderBlocks.renderMaxX), (1.0D - renderBlocks.renderMaxY) * renderBlocks.renderMaxX, renderBlocks.renderMaxY * renderBlocks.renderMaxX); + renderBlocks.aoBrightnessXZNP = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x - 1, y, zOffset); + renderBlocks.aoBrightnessXZPP = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x + 1, y, zOffset); + renderBlocks.aoBrightnessYZNP = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x, y - 1, zOffset); + renderBlocks.aoBrightnessYZPP = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x, y + 1, zOffset); + renderBlocks.aoBrightnessXYZNNP = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x - 1, y - 1, zOffset); + renderBlocks.aoBrightnessXYZNPP = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x - 1, y + 1, zOffset); + renderBlocks.aoBrightnessXYZPNP = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x + 1, y - 1, zOffset); + renderBlocks.aoBrightnessXYZPPP = + block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x + 1, y + 1, zOffset); + renderBlocks.aoLightValueScratchXZNP = getMixedAo( + renderBlocks.blockAccess.getBlock(x - 1, y, z + 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x - 1, y, z).getAmbientOcclusionLightValue(), + renderBlocks.renderMaxZ); + renderBlocks.aoLightValueScratchXZPP = getMixedAo( + renderBlocks.blockAccess.getBlock(x + 1, y, z + 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x + 1, y, z).getAmbientOcclusionLightValue(), + renderBlocks.renderMaxZ); + renderBlocks.aoLightValueScratchYZNP = getMixedAo( + renderBlocks.blockAccess.getBlock(x, y - 1, z + 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x, y - 1, z).getAmbientOcclusionLightValue(), + renderBlocks.renderMaxZ); + renderBlocks.aoLightValueScratchYZPP = getMixedAo( + renderBlocks.blockAccess.getBlock(x, y + 1, z + 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x, y + 1, z).getAmbientOcclusionLightValue(), + renderBlocks.renderMaxZ); + renderBlocks.aoLightValueScratchXYZNNP = getMixedAo( + renderBlocks.blockAccess.getBlock(x - 1, y - 1, z + 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x - 1, y - 1, z).getAmbientOcclusionLightValue(), + renderBlocks.renderMaxZ); + renderBlocks.aoLightValueScratchXYZNPP = getMixedAo( + renderBlocks.blockAccess.getBlock(x - 1, y + 1, z + 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x - 1, y + 1, z).getAmbientOcclusionLightValue(), + renderBlocks.renderMaxZ); + renderBlocks.aoLightValueScratchXYZPNP = getMixedAo( + renderBlocks.blockAccess.getBlock(x + 1, y - 1, z + 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x + 1, y - 1, z).getAmbientOcclusionLightValue(), + renderBlocks.renderMaxZ); + renderBlocks.aoLightValueScratchXYZPPP = getMixedAo( + renderBlocks.blockAccess.getBlock(x + 1, y + 1, z + 1).getAmbientOcclusionLightValue(), + renderBlocks.blockAccess.getBlock(x + 1, y + 1, z).getAmbientOcclusionLightValue(), + renderBlocks.renderMaxZ); + + int brightnessMixedXYZNPP = renderBlocks.getAoBrightness( + renderBlocks.aoBrightnessXZNP, + renderBlocks.aoBrightnessXYZNPP, + renderBlocks.aoBrightnessYZPP, + mixedBrightness); + int brightnessMixedXYZNNP = renderBlocks.getAoBrightness( + renderBlocks.aoBrightnessXYZNNP, + renderBlocks.aoBrightnessXZNP, + renderBlocks.aoBrightnessYZNP, + mixedBrightness); + int brightnessMixedXYZPNP = renderBlocks.getAoBrightness( + renderBlocks.aoBrightnessYZNP, + renderBlocks.aoBrightnessXYZPNP, + renderBlocks.aoBrightnessXZPP, + mixedBrightness); + int brightnessMixedXYZPPP = renderBlocks.getAoBrightness( + renderBlocks.aoBrightnessYZPP, + renderBlocks.aoBrightnessXZPP, + renderBlocks.aoBrightnessXYZPPP, + mixedBrightness); + + float aoMixedXYZNPP = (renderBlocks.aoLightValueScratchXZNP + + renderBlocks.aoLightValueScratchXYZNPP + + aoLightValue + + renderBlocks.aoLightValueScratchYZPP) + / 4.0F; + float aoMixedXYZNNP = (renderBlocks.aoLightValueScratchXYZNNP + + renderBlocks.aoLightValueScratchXZNP + + renderBlocks.aoLightValueScratchYZNP + + aoLightValue) + / 4.0F; + float aoMixedXYZPNP = (renderBlocks.aoLightValueScratchYZNP + + aoLightValue + + renderBlocks.aoLightValueScratchXYZPNP + + renderBlocks.aoLightValueScratchXZPP) + / 4.0F; + float aoMixedXYZPPP = (aoLightValue + + renderBlocks.aoLightValueScratchYZPP + + renderBlocks.aoLightValueScratchXZPP + + renderBlocks.aoLightValueScratchXYZPPP) + / 4.0F; + + aoTopLeft = (float) (aoMixedXYZNPP * renderBlocks.renderMaxY * (1.0D - renderBlocks.renderMinX) + + aoMixedXYZPPP * renderBlocks.renderMaxY * renderBlocks.renderMinX + + aoMixedXYZPNP * (1.0D - renderBlocks.renderMaxY) * renderBlocks.renderMinX + + aoMixedXYZNNP * (1.0D - renderBlocks.renderMaxY) * (1.0D - renderBlocks.renderMinX)); + aoBottomLeft = (float) (aoMixedXYZNPP * renderBlocks.renderMinY * (1.0D - renderBlocks.renderMinX) + + aoMixedXYZPPP * renderBlocks.renderMinY * renderBlocks.renderMinX + + aoMixedXYZPNP * (1.0D - renderBlocks.renderMinY) * renderBlocks.renderMinX + + aoMixedXYZNNP * (1.0D - renderBlocks.renderMinY) * (1.0D - renderBlocks.renderMinX)); + aoBottomRight = (float) (aoMixedXYZNPP * renderBlocks.renderMinY * (1.0D - renderBlocks.renderMaxX) + + aoMixedXYZPPP * renderBlocks.renderMinY * renderBlocks.renderMaxX + + aoMixedXYZPNP * (1.0D - renderBlocks.renderMinY) * renderBlocks.renderMaxX + + aoMixedXYZNNP * (1.0D - renderBlocks.renderMinY) * (1.0D - renderBlocks.renderMaxX)); + aoTopRight = (float) (aoMixedXYZNPP * renderBlocks.renderMaxY * (1.0D - renderBlocks.renderMaxX) + + aoMixedXYZPPP * renderBlocks.renderMaxY * renderBlocks.renderMaxX + + aoMixedXYZPNP * (1.0D - renderBlocks.renderMaxY) * renderBlocks.renderMaxX + + aoMixedXYZNNP * (1.0D - renderBlocks.renderMaxY) * (1.0D - renderBlocks.renderMaxX)); + + renderBlocks.brightnessTopLeft = renderBlocks.mixAoBrightness( + brightnessMixedXYZNPP, + brightnessMixedXYZNNP, + brightnessMixedXYZPNP, + brightnessMixedXYZPPP, + renderBlocks.renderMaxY * (1.0D - renderBlocks.renderMinX), + (1.0D - renderBlocks.renderMaxY) * (1.0D - renderBlocks.renderMinX), + (1.0D - renderBlocks.renderMaxY) * renderBlocks.renderMinX, + renderBlocks.renderMaxY * renderBlocks.renderMinX); + renderBlocks.brightnessBottomLeft = renderBlocks.mixAoBrightness( + brightnessMixedXYZNPP, + brightnessMixedXYZNNP, + brightnessMixedXYZPNP, + brightnessMixedXYZPPP, + renderBlocks.renderMinY * (1.0D - renderBlocks.renderMinX), + (1.0D - renderBlocks.renderMinY) * (1.0D - renderBlocks.renderMinX), + (1.0D - renderBlocks.renderMinY) * renderBlocks.renderMinX, + renderBlocks.renderMinY * renderBlocks.renderMinX); + renderBlocks.brightnessBottomRight = renderBlocks.mixAoBrightness( + brightnessMixedXYZNPP, + brightnessMixedXYZNNP, + brightnessMixedXYZPNP, + brightnessMixedXYZPPP, + renderBlocks.renderMinY * (1.0D - renderBlocks.renderMaxX), + (1.0D - renderBlocks.renderMinY) * (1.0D - renderBlocks.renderMaxX), + (1.0D - renderBlocks.renderMinY) * renderBlocks.renderMaxX, + renderBlocks.renderMinY * renderBlocks.renderMaxX); + renderBlocks.brightnessTopRight = renderBlocks.mixAoBrightness( + brightnessMixedXYZNPP, + brightnessMixedXYZNNP, + brightnessMixedXYZPNP, + brightnessMixedXYZPPP, + renderBlocks.renderMaxY * (1.0D - renderBlocks.renderMaxX), + (1.0D - renderBlocks.renderMaxY) * (1.0D - renderBlocks.renderMaxX), + (1.0D - renderBlocks.renderMaxY) * renderBlocks.renderMaxX, + renderBlocks.renderMaxY * renderBlocks.renderMaxX); } return this; diff --git a/src/main/java/gregtech/api/util/WorldSpawnedEventBuilder.java b/src/main/java/gregtech/api/util/WorldSpawnedEventBuilder.java index f2bb79657a..50566f79a3 100644 --- a/src/main/java/gregtech/api/util/WorldSpawnedEventBuilder.java +++ b/src/main/java/gregtech/api/util/WorldSpawnedEventBuilder.java @@ -1,14 +1,13 @@ package gregtech.api.util; +import java.util.Objects; +import java.util.function.BiConsumer; +import java.util.function.Consumer; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.Vec3; import net.minecraft.world.World; -import java.util.Objects; -import java.util.function.BiConsumer; -import java.util.function.Consumer; - @SuppressWarnings("unused") public abstract class WorldSpawnedEventBuilder implements Runnable { private static final String ILLEGAL_STATE_STR1 = "Position, identifier and world must be set"; @@ -49,36 +48,46 @@ public abstract class WorldSpawnedEventBuilder implements Runnable { private interface IPositionedWorldSpawnedEvent { Vec3 getPosition(); + IPositionedWorldSpawnedEvent setPosition(Vec3 position); + IPositionedWorldSpawnedEvent setPosition(double x, double y, double z); } private interface IEntityWorldSpawnedEvent { Entity getEntity(); + IEntityWorldSpawnedEvent setEntity(Entity entity); } private interface IEntityPlayerWorldSpawnedEvent { EntityPlayer getEntityPlayer(); + IEntityPlayerWorldSpawnedEvent setEntityPlayer(EntityPlayer entity); } private interface IStringIdentifierWorldSpawnedEvent { - String getIdentifier(); - IStringIdentifierWorldSpawnedEvent setIdentifier(String identifier); - IStringIdentifierWorldSpawnedEvent setIdentifier(Enum<?> identifier); + String getIdentifier(); + + IStringIdentifierWorldSpawnedEvent setIdentifier(String identifier); + + IStringIdentifierWorldSpawnedEvent setIdentifier(Enum<?> identifier); } private interface ISoundWorldSpawnedEvent { float getPitch(); + float getVolume(); + ISoundWorldSpawnedEvent setPitch(float pitch); + ISoundWorldSpawnedEvent setVolume(float volume); } /* Abstract Classes */ - private abstract static class EntityWorldSpawnedEventBuilder extends WorldSpawnedEventBuilder implements IEntityWorldSpawnedEvent { + private abstract static class EntityWorldSpawnedEventBuilder extends WorldSpawnedEventBuilder + implements IEntityWorldSpawnedEvent { private Entity entity; @@ -94,7 +103,8 @@ public abstract class WorldSpawnedEventBuilder implements Runnable { } } - private abstract static class PositionedEntityWorldSpawnedEventBuilder extends EntityWorldSpawnedEventBuilder implements IPositionedWorldSpawnedEvent { + private abstract static class PositionedEntityWorldSpawnedEventBuilder extends EntityWorldSpawnedEventBuilder + implements IPositionedWorldSpawnedEvent { private Vec3 position; @@ -114,10 +124,10 @@ public abstract class WorldSpawnedEventBuilder implements Runnable { this.position = Vec3.createVectorHelper(x, y, z); return this; } - } - private abstract static class PositionedWorldSpawnedEventBuilder extends WorldSpawnedEventBuilder implements IPositionedWorldSpawnedEvent { + private abstract static class PositionedWorldSpawnedEventBuilder extends WorldSpawnedEventBuilder + implements IPositionedWorldSpawnedEvent { private Vec3 position; @Override @@ -138,7 +148,8 @@ public abstract class WorldSpawnedEventBuilder implements Runnable { } } - private abstract static class StringIdentifierPositionedWorldSpawnedEventBuilder extends PositionedWorldSpawnedEventBuilder implements IStringIdentifierWorldSpawnedEvent { + private abstract static class StringIdentifierPositionedWorldSpawnedEventBuilder + extends PositionedWorldSpawnedEventBuilder implements IStringIdentifierWorldSpawnedEvent { private String identifier; @Override @@ -153,13 +164,14 @@ public abstract class WorldSpawnedEventBuilder implements Runnable { } @Override - public StringIdentifierPositionedWorldSpawnedEventBuilder setIdentifier(Enum<?> identifier){ + public StringIdentifierPositionedWorldSpawnedEventBuilder setIdentifier(Enum<?> identifier) { this.identifier = identifier.toString(); return this; } } - private abstract static class SoundStringIdentifierPositionedWorldSpawnedEventBuilder extends StringIdentifierPositionedWorldSpawnedEventBuilder implements ISoundWorldSpawnedEvent { + private abstract static class SoundStringIdentifierPositionedWorldSpawnedEventBuilder + extends StringIdentifierPositionedWorldSpawnedEventBuilder implements ISoundWorldSpawnedEvent { private float pitch; private float volume; @@ -237,11 +249,15 @@ public abstract class WorldSpawnedEventBuilder implements Runnable { if (getPosition() == null || getIdentifier() == null || getMotion() == null || getWorld() == null) throw new IllegalStateException("Position, identifier, motion and world must be set"); - getWorld().spawnParticle( - getIdentifier(), - getPosition().xCoord, getPosition().yCoord, getPosition().zCoord, - getMotion().xCoord, getMotion().yCoord, getMotion().zCoord - ); + getWorld() + .spawnParticle( + getIdentifier(), + getPosition().xCoord, + getPosition().yCoord, + getPosition().zCoord, + getMotion().xCoord, + getMotion().yCoord, + getMotion().zCoord); } } @@ -287,11 +303,14 @@ public abstract class WorldSpawnedEventBuilder implements Runnable { if (getPosition() == null || getIdentifier() == null || getWorld() == null) throw new IllegalStateException(ILLEGAL_STATE_STR1); - getWorld().playSoundEffect( - getPosition().xCoord, getPosition().yCoord, getPosition().zCoord, - getIdentifier(), - getPitch(), getVolume() - ); + getWorld() + .playSoundEffect( + getPosition().xCoord, + getPosition().yCoord, + getPosition().zCoord, + getIdentifier(), + getPitch(), + getVolume()); } } @@ -343,11 +362,15 @@ public abstract class WorldSpawnedEventBuilder implements Runnable { if (getPosition() == null || getIdentifier() == null || getWorld() == null) throw new IllegalStateException(ILLEGAL_STATE_STR1); - getWorld().playSound( - getPosition().xCoord, getPosition().yCoord, getPosition().zCoord, - getIdentifier(), - getPitch(), getVolume(), isProximity() - ); + getWorld() + .playSound( + getPosition().xCoord, + getPosition().yCoord, + getPosition().zCoord, + getIdentifier(), + getPitch(), + getVolume(), + isProximity()); } } @@ -381,10 +404,8 @@ public abstract class WorldSpawnedEventBuilder implements Runnable { if (getPosition() == null || getIdentifier() == null || getWorld() == null) throw new IllegalStateException(ILLEGAL_STATE_STR1); - getWorld().playRecord( - getIdentifier(), - (int) getPosition().xCoord,(int) getPosition().yCoord,(int) getPosition().zCoord - ); + getWorld().playRecord(getIdentifier(), (int) getPosition().xCoord, (int) getPosition().yCoord, (int) + getPosition().zCoord); } } @@ -392,7 +413,6 @@ public abstract class WorldSpawnedEventBuilder implements Runnable { private boolean isFlaming, isSmoking; private float strength; - public float getStrength() { return strength; } @@ -440,14 +460,23 @@ public abstract class WorldSpawnedEventBuilder implements Runnable { if (getPosition() == null || getWorld() == null) throw new IllegalStateException("Position and world must be set"); - getWorld().newExplosion(getEntity(), getPosition().xCoord, getPosition().yCoord, getPosition().zCoord, strength, isFlaming, isSmoking); + getWorld() + .newExplosion( + getEntity(), + getPosition().xCoord, + getPosition().yCoord, + getPosition().zCoord, + strength, + isFlaming, + isSmoking); } } /** * Positional Data is rounded down due to this targeting a block. */ - public static final class ExtinguishFireEffectEventBuilder extends PositionedWorldSpawnedEventBuilder implements IEntityPlayerWorldSpawnedEvent { + public static final class ExtinguishFireEffectEventBuilder extends PositionedWorldSpawnedEventBuilder + implements IEntityPlayerWorldSpawnedEvent { private int side; private EntityPlayer entityPlayer; @@ -492,11 +521,18 @@ public abstract class WorldSpawnedEventBuilder implements Runnable { if (getEntityPlayer() == null || getPosition() == null || getWorld() == null) throw new IllegalStateException("EntityPlayer, position and world must be set"); - getWorld().extinguishFire(getEntityPlayer(), (int) getPosition().xCoord, (int) getPosition().yCoord, (int) getPosition().zCoord, side); + getWorld() + .extinguishFire( + getEntityPlayer(), + (int) getPosition().xCoord, + (int) getPosition().yCoord, + (int) getPosition().zCoord, + side); } } - public static final class SoundAtEntityEventBuilder extends EntityWorldSpawnedEventBuilder implements ISoundWorldSpawnedEvent, IStringIdentifierWorldSpawnedEvent { + public static final class SoundAtEntityEventBuilder extends EntityWorldSpawnedEventBuilder + implements ISoundWorldSpawnedEvent, IStringIdentifierWorldSpawnedEvent { private float pitch; private float volume; @@ -553,14 +589,15 @@ public abstract class WorldSpawnedEventBuilder implements Runnable { @Override public void run() { - if (getWorld() == null || getIdentifier() == null || getEntity() == null) + if (getWorld() == null || getIdentifier() == null || getEntity() == null) throw new IllegalStateException("World, Identifier and entity must be set!"); getWorld().playSoundAtEntity(getEntity(), getIdentifier(), volume, pitch); } } - public static final class SoundToNearExceptEventBuilder extends WorldSpawnedEventBuilder implements ISoundWorldSpawnedEvent, IStringIdentifierWorldSpawnedEvent, IEntityPlayerWorldSpawnedEvent { + public static final class SoundToNearExceptEventBuilder extends WorldSpawnedEventBuilder + implements ISoundWorldSpawnedEvent, IStringIdentifierWorldSpawnedEvent, IEntityPlayerWorldSpawnedEvent { private float pitch; private float volume; @@ -613,7 +650,7 @@ public abstract class WorldSpawnedEventBuilder implements Runnable { @Override public void run() { - if (getWorld() == null || getIdentifier() == null || getEntityPlayer() == null) + if (getWorld() == null || getIdentifier() == null || getEntityPlayer() == null) throw new IllegalStateException("World, Identifier and EntityPlayer must be set!"); getWorld().playSoundAtEntity(getEntityPlayer(), getIdentifier(), volume, pitch); diff --git a/src/main/java/gregtech/api/util/extensions/IteratorExt.java b/src/main/java/gregtech/api/util/extensions/IteratorExt.java index d59bb298a4..8662870921 100644 --- a/src/main/java/gregtech/api/util/extensions/IteratorExt.java +++ b/src/main/java/gregtech/api/util/extensions/IteratorExt.java @@ -1,7 +1,6 @@ package gregtech.api.util.extensions; import gregtech.api.objects.iterators.MergedIterator; - import java.util.Iterator; public class IteratorExt { |