aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/util
diff options
context:
space:
mode:
authorSteelux <70096037+Steelux8@users.noreply.github.com>2022-02-07 17:48:26 +0000
committerGitHub <noreply@github.com>2022-02-07 18:48:26 +0100
commitb5c956c38335e6fbb3519b88a894975acf0bf419 (patch)
tree9f86d3298464d4f9157b1b4246262d851f182e59 /src/main/java/gregtech/api/util
parenteeb760b14b904c7e710c82ea454bf697a7f02670 (diff)
downloadGT5-Unofficial-b5c956c38335e6fbb3519b88a894975acf0bf419.tar.gz
GT5-Unofficial-b5c956c38335e6fbb3519b88a894975acf0bf419.tar.bz2
GT5-Unofficial-b5c956c38335e6fbb3519b88a894975acf0bf419.zip
Large Boiler Whitelist and NEI Large Boiler Tab Update (#910)
* Whitelist for Advanced Boilers - Added a whitelist system to check allowed fuels for the Titanium and Tungstensteel Boilers (thanks glow for the code); - Removed fuel value checks for the advanced boilers, none are needed because the whitelist check does it all; - Changed the boiler tooltip to clarify that the advanced boilers won't work if there is a fuel in the input bus that is not allowed to be burned. * NEI Large Boiler Tab Updated - Changed the burn times to reflect the speed at which the boilers now consume fuels; - Changed the TItanium and Tungstensteel Boiler info to display "Not Allowed" on the fuels that aren't accepted by them. * Re-added Previous Constructor as a Default Case - Implemented the previous addRecipe constructor without the boolean, applying to all non-solid fuels, with a default value; - Changed the boiler code to make the advanced Boilers ignore the fluid recipes (they're only supposed to burn the allowed solid fuels); - Small NEI clarifications. * Unnecessary Burn Time Calculation - Removed the burn time calculation on the NEI handler for the fuels that can't run in the advanced boilers. * Shortened Tungstensteel Boiler Line - Made text shorter to not overflow past the NEI display. * Properly implement solid fuel whitelist for Large Titanium/Tungsten Boilers Co-authored-by: glowredman <fredcraft00@gmail.com>
Diffstat (limited to 'src/main/java/gregtech/api/util')
-rw-r--r--src/main/java/gregtech/api/util/GT_Recipe.java82
1 files changed, 70 insertions, 12 deletions
diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java
index 3b143bab4c..63f46e2c1e 100644
--- a/src/main/java/gregtech/api/util/GT_Recipe.java
+++ b/src/main/java/gregtech/api/util/GT_Recipe.java
@@ -15,6 +15,7 @@ import gregtech.nei.GT_NEI_DefaultHandler.FixedPositionedStack;
import ic2.core.Ic2Items;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
+import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntityFurnace;
@@ -1817,12 +1818,34 @@ 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"));
+
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 Boiler.");
+ 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());
+ }
+
+ public static boolean isAllowedSolidFuel(String itemRegistryName, int meta) {
+ return ALLOWED_SOLID_FUELS.contains(itemRegistryName + ":" + meta);
+ }
+
+ public static boolean addAllowedSolidFuel(ItemStack stack) {
+ return addAllowedSolidFuel(Item.itemRegistry.getNameForObject(stack.getItem()), stack.getItemDamage());
+ }
+
+ public static boolean addAllowedSolidFuel(String itemregistryName, int meta) {
+ return ALLOWED_SOLID_FUELS.add(itemregistryName + ":" + meta);
+ }
public GT_Recipe addDenseLiquidRecipe(GT_Recipe recipe) {
return addRecipe(recipe, ((double) recipe.mSpecialValue) / 10);
@@ -1839,30 +1862,65 @@ public class GT_Recipe implements Comparable<GT_Recipe> {
}
public GT_Recipe addSolidRecipe(ItemStack fuelItemStack) {
- 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);
+ boolean allowedFuel = false;
+ if (fuelItemStack != null) {
+ 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);
}
- private GT_Recipe addRecipe(GT_Recipe recipe, double baseBurnTime) {
+ 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 * 1.5 + floatErrorCorrection;
+ double steelBurnTime = baseBurnTime + floatErrorCorrection;
steelBurnTime -= steelBurnTime % 0.05;
- double titaniumBurnTime = baseBurnTime * 1.3 + floatErrorCorrection;
+ double titaniumBurnTime = baseBurnTime * 0.3 + floatErrorCorrection;
titaniumBurnTime -= titaniumBurnTime % 0.05;
- double tungstensteelBurnTime = baseBurnTime * 1.2 + floatErrorCorrection;
+ double tungstensteelBurnTime = baseBurnTime * 0.15 + floatErrorCorrection;
tungstensteelBurnTime -= tungstensteelBurnTime % 0.05;
-
- 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));
+
+ if (isAllowedFuel) {
+ 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:",
+ String.format("Bronze Boiler: %.4f", bronzeBurnTime),
+ String.format("Steel Boiler: %.4f", steelBurnTime),
+ "Titanium Boiler: Not allowed",
+ "Tungstenst. Boiler: Not allowed");
+ }
+
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
+ double floatErrorCorrection = 0.0001;
+
+ double bronzeBurnTime = baseBurnTime * 2 + floatErrorCorrection;
+ bronzeBurnTime -= bronzeBurnTime % 0.05;
+ double steelBurnTime = baseBurnTime + floatErrorCorrection;
+ steelBurnTime -= steelBurnTime % 0.05;
+
+ 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);
+ }
}