aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gtPlusPlus/xmod/tinkers
diff options
context:
space:
mode:
authorConnor-Colenso <52056774+Connor-Colenso@users.noreply.github.com>2023-10-18 17:03:23 +0100
committerGitHub <noreply@github.com>2023-10-18 18:03:23 +0200
commitfbdbb388c369fae549cfde3eed38b536f7461d90 (patch)
treeb46f7fc949d7e4c6e3be910b81ed725e6dc1648e /src/main/java/gtPlusPlus/xmod/tinkers
parentb670446fdf49991093b485f0aa14050039632775 (diff)
downloadGT5-Unofficial-fbdbb388c369fae549cfde3eed38b536f7461d90.tar.gz
GT5-Unofficial-fbdbb388c369fae549cfde3eed38b536f7461d90.tar.bz2
GT5-Unofficial-fbdbb388c369fae549cfde3eed38b536f7461d90.zip
Cleaning up (#767)
* Kill playerAPI * Gut more events and compat that is now obsolete * Remove commented out code * Remove final modifier from methods * Make more stuff final * Remove slow building ring * Protected -> private in final classes * More cleaning * More cleaning v2 * Purging * Clean DevHelper * Clean DevHelper 2 * delete DevHelper * remove useless IFMLLoadingPlugin.MCVersion annotation from @Mod files * check for obfuscation only once in the IFMLloadingPlugin.injectData * don't instantiate the static class ASMConfig * delete unused and empty implementation of IFMLCallHook * delete empty class * delete ClassesToTransform class that just holds the class names constants * delete unused methods and unsless logging in dummymod container * delete unused transformer ClassTransformer_TT_ThaumicRestorer * spotless * Clean * Clean utils * Build checkpoint * Purge * Stage 2 * Stage 3 * Stage 4 * Stage 5 * Stage 6 * Spotless * Imports * Stage idk * Stage 1 * Fix issue * Spotless * Format numbers --------- Co-authored-by: GTNH-Colen <54497873+GTNH-Colen@users.noreply.github.com> Co-authored-by: Alexdoru <57050655+Alexdoru@users.noreply.github.com> Co-authored-by: Connor Colenso <colen@CONNORSPC>
Diffstat (limited to 'src/main/java/gtPlusPlus/xmod/tinkers')
-rw-r--r--src/main/java/gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java8
-rw-r--r--src/main/java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java45
-rw-r--r--src/main/java/gtPlusPlus/xmod/tinkers/util/TinkersDryingRecipe.java2
-rw-r--r--src/main/java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java220
4 files changed, 28 insertions, 247 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java b/src/main/java/gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java
index b148e283ac..1023d0325f 100644
--- a/src/main/java/gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java
+++ b/src/main/java/gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java
@@ -12,9 +12,9 @@ import gtPlusPlus.xmod.tinkers.util.TinkersUtils;
public class HANDLER_Tinkers {
- public static AutoMap<BaseTinkersMaterial> mTinkerMaterials = new AutoMap<BaseTinkersMaterial>();
+ public static AutoMap<BaseTinkersMaterial> mTinkerMaterials = new AutoMap<>();
- public static final void postInit() {
+ public static void postInit() {
if (TinkerConstruct.isModLoaded()) {
Fluid pyrotheumFluid = FluidRegistry.getFluid("pyrotheum");
@@ -25,10 +25,6 @@ public class HANDLER_Tinkers {
// Generate Drying Rack recipes
TinkersDryingRecipe.generateAllDryingRecipes();
-
- for (BaseTinkersMaterial y : mTinkerMaterials) {
- // y.generate();
- }
}
}
}
diff --git a/src/main/java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java b/src/main/java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java
index 06f7ad47f5..8133b1f78d 100644
--- a/src/main/java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java
+++ b/src/main/java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java
@@ -20,7 +20,7 @@ import gtPlusPlus.xmod.tinkers.util.TinkersUtils;
public class BaseTinkersMaterial {
- private static HashMap<String, Integer> aInternalMaterialIdMap = new HashMap<String, Integer>();
+ private static HashMap<String, Integer> aInternalMaterialIdMap = new HashMap<>();
private static int aNextFreeID;
public final String mLocalName;
@@ -88,7 +88,7 @@ public class BaseTinkersMaterial {
}
private static String calcStyle(Material aMaterial) {
- String aReturn = "" + EnumChatFormatting.WHITE;
+ String aReturn;
int aTemp = aMaterial.getMeltingPointC();
if (aTemp < 3600) {
aReturn = "" + EnumChatFormatting.WHITE;
@@ -110,46 +110,12 @@ public class BaseTinkersMaterial {
return aMaterial.getRgbAsHex();
}
- public Object generateToolMaterial(Material aMaterial) {
- int level, dura, speed, dmg, reinf, primColour;
- float handle, stonebound;
- level = calcHarvestLevel(aMaterial);
- dura = calcDurability(aMaterial);
- speed = calcMiningSpeed(aMaterial);
- dmg = calcAttack(aMaterial);
- reinf = calcReinforced(aMaterial);
- primColour = calcColour(aMaterial);
- handle = calcHandleModifier(aMaterial);
- // stonebound = calcHarvestLevel(aMaterial);
- stonebound = 0;
- return TinkersUtils.generateToolMaterial(
- aMaterial.getLocalizedName(),
- aMaterial.getUnlocalizedName(),
- level,
- dura,
- speed,
- dmg,
- handle,
- reinf,
- stonebound,
- calcStyle(aMaterial),
- primColour);
- }
-
public void generate() {
Logger.INFO("[TiCon] Trying to generate Material: " + mLocalName);
int id = mID;
if (id > 0) {
- // Object aTinkersCustomMaterial = generateToolMaterial(mMaterial);
- // Logger.INFO("[TiCon] Created Material: "+mLocalName);
-
- // TinkersUtils.addToolMaterial(id, aTinkersCustomMaterial);
- // TinkersUtils.addDefaultToolPartMaterial(id);
- // TinkersUtils.addBowMaterial(id, calcBowDrawSpeed(mMaterial), 1.0F);
- // TinkersUtils.addArrowMaterial(id, calcProjectileMass(mMaterial), calcProjectileFragility(mMaterial));
-
NBTTagCompound tag = new NBTTagCompound();
tag.setInteger("Id", id);
tag.setString("Name", mUnlocalName);
@@ -215,8 +181,6 @@ public class BaseTinkersMaterial {
return false;
}
- // Smeltery.addMelting(new ItemStack(ExtraUtils.unstableIngot, 1, 0), ExtraUtils.decorative1, 5, 850,
- // aMaterial.getFluid(72));
TinkersUtils.registerFluidType(mLocalName, aMatBlock, 0, aMelt, aFluid, true);
TinkersUtils.addMelting(aMaterial.getBlock(1), aMatBlock, 0, aMelt, aMaterial.getFluidStack(144 * 9));
TinkersUtils.addMelting(aMaterial.getIngot(1), aMatBlock, 0, aMelt, aMaterial.getFluidStack(144));
@@ -232,10 +196,7 @@ public class BaseTinkersMaterial {
.addCastingTableRecipe(aMaterial.getIngot(1), aMaterial.getFluidStack(144), ingotcast, false, 50);
}
- boolean extended = TinkersUtils.generateCastingRecipes(aMaterial, aID);
-
- // TConstructRegistry.getBasinCasting().addCastingRecipe(new ItemStack(ExtraUtils.decorative1, 1, 5), new
- // FluidStack(unstable, 1296), (ItemStack)null, true, 100);
+ TinkersUtils.generateCastingRecipes(aMaterial, aID);
return true;
}
diff --git a/src/main/java/gtPlusPlus/xmod/tinkers/util/TinkersDryingRecipe.java b/src/main/java/gtPlusPlus/xmod/tinkers/util/TinkersDryingRecipe.java
index ef3a0f9cd0..6cbe12c967 100644
--- a/src/main/java/gtPlusPlus/xmod/tinkers/util/TinkersDryingRecipe.java
+++ b/src/main/java/gtPlusPlus/xmod/tinkers/util/TinkersDryingRecipe.java
@@ -17,7 +17,7 @@ import gtPlusPlus.core.util.reflect.ReflectionUtils;
public class TinkersDryingRecipe {
- public static AutoMap<TinkersDryingRecipe> recipes = new AutoMap<TinkersDryingRecipe>();
+ public static AutoMap<TinkersDryingRecipe> recipes = new AutoMap<>();
public final int time;
public final ItemStack input;
diff --git a/src/main/java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java b/src/main/java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java
index 6024e5192d..fb89680e6c 100644
--- a/src/main/java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java
+++ b/src/main/java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java
@@ -45,7 +45,7 @@ public class TinkersUtils {
private static Object mSmelteryInstance;
private static Object mTinkersRegistryInstance;
- private static final HashMap<String, Method> mMethodCache = new LinkedHashMap<String, Method>();
+ private static final HashMap<String, Method> mMethodCache = new LinkedHashMap<>();
static {
mClass_Smeltery = ReflectionUtils.getClass("tconstruct.library.crafting.Smeltery");
@@ -65,10 +65,6 @@ public class TinkersUtils {
.getMethod(getCastingInstance(0), "getCastingRecipes", new Class[] {});
}
- /**
- *
- * @param aSwitch - The Registry to return
- */
private static void setTiConDataInstance() {
if (!TinkerConstruct.isModLoaded()) {
return;
@@ -78,7 +74,7 @@ public class TinkersUtils {
if (mClass_Smeltery != null) {
try {
mSmelteryInstance = ReflectionUtils.getField(mClass_Smeltery, "instance").get(null);
- } catch (IllegalArgumentException | IllegalAccessException e) {}
+ } catch (IllegalArgumentException | IllegalAccessException ignored) {}
}
}
if (mTinkersRegistryInstance == null) {
@@ -86,38 +82,11 @@ public class TinkersUtils {
try {
mTinkersRegistryInstance = ReflectionUtils.getField(mClass_TConstructRegistry, "instance")
.get(null);
- } catch (IllegalArgumentException | IllegalAccessException e) {}
+ } catch (IllegalArgumentException | IllegalAccessException ignored) {}
}
}
}
- public static final boolean isTiConFirstInOD() {
- if (TinkerConstruct.isModLoaded()) {
- try {
- return (boolean) ReflectionUtils.getField(ReflectionUtils.getClass("PHConstruct"), "tconComesFirst")
- .get(null);
- } catch (IllegalArgumentException | IllegalAccessException e) {}
- }
- return false;
- }
-
- public static final boolean stopTiconLoadingFirst() {
- if (isTiConFirstInOD()) {
- try {
- ReflectionUtils.setFinalFieldValue(ReflectionUtils.getClass("PHConstruct"), "tconComesFirst", false);
- if ((boolean) ReflectionUtils.getField(ReflectionUtils.getClass("PHConstruct"), "tconComesFirst")
- .get(null) == false) {
- return true;
- }
- // Did not work, let's see where TiCon uses this and prevent it.
- else {
- ItemUtils.getNonTinkersDust("", 1);
- }
- } catch (Exception e) {}
- }
- return false;
- }
-
/**
* Add a new fluid as a valid Smeltery fuel.
*
@@ -134,36 +103,6 @@ public class TinkersUtils {
new Object[] { fluid, power, duration });
}
- /**
- * Returns true if the liquid is a valid smeltery fuel.
- */
- public static boolean isSmelteryFuel(Fluid fluid) {
- setTiConDataInstance();
- return ReflectionUtils
- .invoke(mSmelteryInstance, "isSmelteryFuel", new Class[] { Fluid.class }, new Object[] { fluid });
- }
-
- /**
- * Returns the power of a smeltery fuel or 0 if it's not a fuel.
- */
- public static int getFuelPower(Fluid fluid) {
- setTiConDataInstance();
- return (int) ReflectionUtils
- .invokeNonBool(mSmelteryInstance, "getFuelPower", new Class[] { Fluid.class }, new Object[] { fluid });
- }
-
- /**
- * Returns the duration of a smeltery fuel or 0 if it's not a fuel.
- */
- public static int getFuelDuration(Fluid fluid) {
- setTiConDataInstance();
- return (int) ReflectionUtils.invokeNonBool(
- mSmelteryInstance,
- "getFuelDuration",
- new Class[] { Fluid.class },
- new Object[] { fluid });
- }
-
public static boolean registerFluidType(String name, Block block, int meta, int baseTemperature, Fluid fluid,
boolean isToolpart) {
if (mMethodCache.get("registerFluidType") == null) {
@@ -186,22 +125,7 @@ public class TinkersUtils {
}
}
- public static boolean addBaseMeltingRecipes(Material aMaterial) {
- return addMelting(
- aMaterial.getBlock(1),
- aMaterial.getBlock(),
- 0,
- aMaterial.getMeltingPointC(),
- aMaterial.getFluidStack(144 * 9))
- && addMelting(
- aMaterial.getIngot(1),
- aMaterial.getBlock(),
- 0,
- aMaterial.getMeltingPointC(),
- aMaterial.getFluidStack(144));
- }
-
- public static boolean addMelting(ItemStack input, Block block, int metadata, int temperature, FluidStack liquid) {
+ public static void addMelting(ItemStack input, Block block, int metadata, int temperature, FluidStack liquid) {
if (mMethodCache.get("addMelting") == null) {
Method m = ReflectionUtils.getMethod(
mClass_Smeltery,
@@ -215,13 +139,10 @@ public class TinkersUtils {
}
try {
mMethodCache.get("addMelting").invoke(null, input, block, metadata, temperature, liquid);
- return true;
- } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- return false;
- }
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ignored) {}
}
- public static boolean addMelting(Object type, ItemStack input, int temperatureDifference, int fluidAmount) {
+ public static void addMelting(Object type, ItemStack input, int temperatureDifference, int fluidAmount) {
if (mMethodCache.get("addMelting") == null) {
Method m = ReflectionUtils
.getMethod(mClass_Smeltery, "addMelting", mClass_FluidType, ItemStack.class, int.class, int.class);
@@ -229,18 +150,10 @@ public class TinkersUtils {
}
try {
mMethodCache.get("addMelting").invoke(null, type, input, temperatureDifference, fluidAmount);
- return true;
- } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- return false;
- }
- }
-
- public static boolean addBaseBasinRecipes(Material aMaterial) {
- return addBasinRecipe(aMaterial.getBlock(1), aMaterial.getFluidStack(144 * 9), (ItemStack) null, true, 100);
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ignored) {}
}
- public static boolean addBasinRecipe(ItemStack output, FluidStack metal, ItemStack cast, boolean consume,
- int delay) {
+ public static void addBasinRecipe(ItemStack output, FluidStack metal, ItemStack cast, boolean consume, int delay) {
if (mMethodCache.get("addBasinRecipe") == null) {
Method m = ReflectionUtils.getMethod(
ReflectionUtils.getClass("tconstruct.library.crafting.LiquidCasting"),
@@ -254,18 +167,10 @@ public class TinkersUtils {
}
try {
mMethodCache.get("addBasinRecipe").invoke(getCastingInstance(0), output, metal, cast, consume, delay);
- return true;
- } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- return false;
- }
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ignored) {}
}
- public static boolean addBaseCastingRecipes(Material aMaterial) {
- ItemStack ingotcast = getPattern(1);
- return addCastingTableRecipe(aMaterial.getIngot(1), aMaterial.getFluidStack(144), ingotcast, false, 50);
- }
-
- public static boolean addCastingTableRecipe(ItemStack output, FluidStack metal, ItemStack cast, boolean consume,
+ public static void addCastingTableRecipe(ItemStack output, FluidStack metal, ItemStack cast, boolean consume,
int delay) {
if (mMethodCache.get("addCastingTableRecipe") == null) {
Method m = ReflectionUtils.getMethod(
@@ -281,10 +186,7 @@ public class TinkersUtils {
try {
mMethodCache.get("addCastingTableRecipe")
.invoke(getCastingInstance(1), output, metal, cast, consume, delay);
- return true;
- } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- return false;
- }
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ignored) {}
}
/**
@@ -300,15 +202,9 @@ public class TinkersUtils {
Method m = null;
if (aType == 0) {
m = ReflectionUtils.getMethod(mTinkersRegistryInstance, "getTableCasting", new Class[] {});
- // return ReflectionUtils.invokeVoid(getTiConDataInstance(1), "getTableCasting", new Class[] {}, new
- // Object[] {});
} else if (aType == 1) {
m = ReflectionUtils.getMethod(mTinkersRegistryInstance, "getBasinCasting", new Class[] {});
- // return ReflectionUtils.invokeVoid(getTiConDataInstance(1), "getBasinCasting", new Class[] {}, new
- // Object[] {});
- } else {
- // return null;
- }
+ } // return null;
if (m != null) {
try {
@@ -328,12 +224,11 @@ public class TinkersUtils {
if (m != null) {
try {
mTinkerMetalPattern = (Item) m.get(null);
- } catch (IllegalArgumentException | IllegalAccessException e) {}
+ } catch (IllegalArgumentException | IllegalAccessException ignored) {}
}
}
if (mTinkerMetalPattern != null) {
- ItemStack ingotCast = new ItemStack(mTinkerMetalPattern, aType, 0);
- return ingotCast;
+ return new ItemStack(mTinkerMetalPattern, aType, 0);
}
return ItemUtils.getErrorStack(1, "Bad Tinkers Pattern");
}
@@ -344,7 +239,7 @@ public class TinkersUtils {
if (mDryingRackRecipes != null) {
return mDryingRackRecipes;
}
- AutoMap<Object> aData = new AutoMap<Object>();
+ AutoMap<Object> aData = new AutoMap<>();
int aCount = 0;
try {
ArrayList<?> recipes = (ArrayList<?>) ReflectionUtils
@@ -366,22 +261,6 @@ public class TinkersUtils {
return aData;
}
- /**
- * Generates Tinkers {@link ToolMaterial}'s reflectively.
- *
- * @param name
- * @param localizationString
- * @param level
- * @param durability
- * @param speed
- * @param damage
- * @param handle
- * @param reinforced
- * @param stonebound
- * @param style
- * @param primaryColor
- * @return
- */
public static Object generateToolMaterial(String name, String localizationString, int level, int durability,
int speed, int damage, float handle, int reinforced, float stonebound, String style, int primaryColor) {
try {
@@ -397,7 +276,7 @@ public class TinkersUtils {
float.class,
String.class,
int.class);
- Object myObject = constructor.newInstance(
+ return constructor.newInstance(
name,
localizationString,
level,
@@ -409,58 +288,12 @@ public class TinkersUtils {
stonebound,
style,
primaryColor);
- return myObject;
} catch (Throwable t) {
t.printStackTrace();
return null;
}
}
- public static void addToolMaterial(int id, Object aToolMaterial) {
- if (mMethodCache.get("addToolMaterial") == null) {
- Method m = ReflectionUtils
- .getMethod(mClass_TConstructRegistry, "addtoolMaterial", int.class, mClass_ToolMaterial);
- mMethodCache.put("addToolMaterial", m);
- }
- try {
- mMethodCache.get("addToolMaterial").invoke(mClass_TConstructRegistry, id, aToolMaterial);
- } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
-
- }
- }
-
- public static void addDefaultToolPartMaterial(int id) {
- if (mMethodCache.get("addDefaultToolPartMaterial") == null) {
- Method m = ReflectionUtils.getMethod(mClass_TConstructRegistry, "addDefaultToolPartMaterial", int.class);
- mMethodCache.put("addDefaultToolPartMaterial", m);
- }
- try {
- mMethodCache.get("addDefaultToolPartMaterial").invoke(mClass_TConstructRegistry, id);
- } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {}
- }
-
- public static void addBowMaterial(int id, int drawspeed, float maxSpeed) {
- if (mMethodCache.get("addBowMaterial") == null) {
- Method m = ReflectionUtils
- .getMethod(mClass_TConstructRegistry, "addBowMaterial", int.class, int.class, float.class);
- mMethodCache.put("addBowMaterial", m);
- }
- try {
- mMethodCache.get("addBowMaterial").invoke(mClass_TConstructRegistry, id, drawspeed, maxSpeed);
- } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {}
- }
-
- public static void addArrowMaterial(int id, float mass, float fragility) {
- if (mMethodCache.get("addArrowMaterial") == null) {
- Method m = ReflectionUtils
- .getMethod(mClass_TConstructRegistry, "addArrowMaterial", int.class, float.class, float.class);
- mMethodCache.put("addArrowMaterial", m);
- }
- try {
- mMethodCache.get("addArrowMaterial").invoke(mClass_TConstructRegistry, id, mass, fragility);
- } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {}
- }
-
public static List<?> getTableCastingRecipes() {
Object aCastingTableHandlerInstance = getCastingInstance(0);
List<?> aTemp;
@@ -470,12 +303,12 @@ public class TinkersUtils {
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
e.printStackTrace();
}
- return new ArrayList<Object>();
+ return new ArrayList<>();
}
- public static boolean generateCastingRecipes(Material aMaterial, int aID) {
+ public static void generateCastingRecipes(Material aMaterial, int aID) {
- List<CastingRecipeHandler> newRecipies = new LinkedList<CastingRecipeHandler>();
+ List<CastingRecipeHandler> newRecipies = new LinkedList<>();
Iterator<?> iterator1 = getTableCastingRecipes().iterator();
Fluid aMoltenIron = null;
@@ -500,16 +333,15 @@ public class TinkersUtils {
}
} catch (IllegalArgumentException e) {
e.printStackTrace();
- return false;
+ return;
}
}
Object ft;
try {
ft = mMethod_getFluidType.invoke(null, aMaterial.getLocalizedName());
- Iterator<CastingRecipeHandler> iterator2 = newRecipies.iterator();
- while (iterator2.hasNext()) {
- CastingRecipeHandler recipe = new CastingRecipeHandler(iterator2.next());
+ for (CastingRecipeHandler newRecipy : newRecipies) {
+ CastingRecipeHandler recipe = new CastingRecipeHandler(newRecipy);
if (!recipe.valid) {
continue;
}
@@ -522,10 +354,8 @@ public class TinkersUtils {
}
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
e.printStackTrace();
- return false;
}
- return true;
}
private static class CastingRecipeHandler {
@@ -562,12 +392,6 @@ public class TinkersUtils {
}
}
- public boolean matches(FluidStack metal, ItemStack inputCast) {
- return this.castingMetal.isFluidEqual(metal) && (this.cast != null && this.cast.getItemDamage() == 32767
- && inputCast.getItem() == this.cast.getItem()
- || ItemStack.areItemStacksEqual(this.cast, inputCast));
- }
-
public ItemStack getResult() {
return this.output.copy();
}