aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gtPlusPlus/xmod/growthcraft/fishtrap
diff options
context:
space:
mode:
authorJakub <53441451+kuba6000@users.noreply.github.com>2022-08-29 16:04:28 +0200
committerGitHub <noreply@github.com>2022-08-29 16:04:28 +0200
commit7d1f51a8937e0a86486267437d444696e81e8aa0 (patch)
treea5b145e7271998f7b4b968a2212ed487e54a92b5 /src/main/java/gtPlusPlus/xmod/growthcraft/fishtrap
parent5267969156d30b4bb5f4cb2279ebb49db6bd40e2 (diff)
downloadGT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.tar.gz
GT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.tar.bz2
GT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.zip
Buildscript + Spotless (#318)
* Convert AES.java to readable class * Buildscript * Spotless
Diffstat (limited to 'src/main/java/gtPlusPlus/xmod/growthcraft/fishtrap')
-rw-r--r--src/main/java/gtPlusPlus/xmod/growthcraft/fishtrap/FishTrapHandler.java430
-rw-r--r--src/main/java/gtPlusPlus/xmod/growthcraft/fishtrap/Growthcraft_New.java145
-rw-r--r--src/main/java/gtPlusPlus/xmod/growthcraft/fishtrap/Growthcraft_Old.java145
3 files changed, 361 insertions, 359 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/growthcraft/fishtrap/FishTrapHandler.java b/src/main/java/gtPlusPlus/xmod/growthcraft/fishtrap/FishTrapHandler.java
index a54fe8c1e3..2a86b80d00 100644
--- a/src/main/java/gtPlusPlus/xmod/growthcraft/fishtrap/FishTrapHandler.java
+++ b/src/main/java/gtPlusPlus/xmod/growthcraft/fishtrap/FishTrapHandler.java
@@ -1,8 +1,5 @@
package gtPlusPlus.xmod.growthcraft.fishtrap;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
import gregtech.api.enums.GT_Values;
import gregtech.api.util.GT_ModHandler;
import gtPlusPlus.api.objects.Logger;
@@ -11,222 +8,221 @@ import gtPlusPlus.core.lib.LoadedMods;
import gtPlusPlus.core.util.minecraft.FluidUtils;
import gtPlusPlus.core.util.minecraft.ItemUtils;
import gtPlusPlus.core.util.reflect.ReflectionUtils;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import net.minecraft.item.ItemStack;
public class FishTrapHandler {
- private static final String[] fishTypes = {"fish", "junk", "treasure"};
- private static Object mFishingRegistry;
- private static Growthcraft_Old mHandler;
-
- public static Object getFishingRegistry(){
- if (mFishingRegistry != null){
- return mFishingRegistry;
- }
- else {
- return setFishTrapRegistry();
- }
- }
-
- private final static Object setFishTrapRegistry(){
- Class mFishingRegistryClass;
- try {
- mFishingRegistryClass = ReflectionUtils.getClass("growthcraft.api.fishtrap.FishTrapRegistry");
- final Method mFishingRegistryMethod = mFishingRegistryClass.getDeclaredMethod("getInstance");
- mFishingRegistry = mFishingRegistryMethod.invoke(null);
- if (mFishingRegistry != null){
- return mFishingRegistry;
- }
- }
- catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- }
- return null;
- }
-
- protected static void addFish(final String lootType, final ItemStack lootStack, final int lootChance){
-
- if (mFishingRegistry == null){
- setFishTrapRegistry();
- }
- if (mHandler == null){
- mHandler = new Growthcraft_Old();
- }
-
- final String GCVersion = LoadedMods.getModVersion("Growthcraft");
- final String[] versionString = GCVersion.split("//.");
-
- if (LoadedMods.getModVersion("Growthcraft").contains("2.3.1") || versionString[1].equals("3")){
- if (lootType.equals(fishTypes[0])){
- mHandler.addTrapFish(lootStack, lootChance);
- Logger.INFO("Added "+lootStack.getDisplayName()+" as an extra Fish for Growthcraft Fishtraps.");
- }
- else if (lootType.equals(fishTypes[1])){
- mHandler.addTrapJunk(lootStack, lootChance);
- Logger.INFO("Added "+lootStack.getDisplayName()+" as extra Junk for Growthcraft Fishtraps.");
- }
- else if (lootType.equals(fishTypes[2])){
- mHandler.addTrapTreasure(lootStack, lootChance);
- Logger.INFO("Added "+lootStack.getDisplayName()+" as extra Treasure for Growthcraft Fishtraps.");
- }
- else {
- return;
- }
- }/*
- else if (LoadedMods.getModVersion("Growthcraft").contains("2.7.2")){
- if (lootType.equals(fishTypes[0])){
- Growthcraft_New.addTrapFish(lootStack, lootChance);
- Utils.LOG_INFO("Added "+lootStack.getDisplayName()+" as an extra Fish for Growthcraft Fishtraps.");
- }
- else if (lootType.equals(fishTypes[1])){
- Growthcraft_New.addTrapJunk(lootStack, lootChance);
- Utils.LOG_INFO("Added "+lootStack.getDisplayName()+" as extra Junk for Growthcraft Fishtraps.");
- }
- else if (lootType.equals(fishTypes[2])){
- Growthcraft_New.addTrapTreasure(lootStack, lootChance);
- Utils.LOG_INFO("Added "+lootStack.getDisplayName()+" as extra Treasure for Growthcraft Fishtraps.");
- }
- else {
- return;
- }
- }*/
-
- else {
- Logger.INFO("Extra Fish loot for Growthcraft Fishtraps disabled. Found V."+LoadedMods.getModVersion("Growthcraft"));
- }
-
- }
- //FishTrapHandler.pamsHarvestCraftCompat();
- final static String prefix = "food";
- final static String suffix = "raw";
- final static String seaweed = "cropSeaweed";
- final static String greenheartFish = "foodGreenheartfish";
- private static final String[] harvestcraftFish = {
- "Anchovy", "Bass", "Calamari", "Carp", "Catfish", "Charr", "Clam", "Crab", "Crayfish", "Eel", "Frog", "Grouper", "Herring",
- "Jellyfish", "Mudfish", "Octopus", "Perch", "Scallop", "Shrimp", "Snail", "Snapper", "Tilapia", "Trout", "Tuna", "Turtle", "Walley"};
- public static void pamsHarvestCraftCompat(){
- for (int i = 0; i < harvestcraftFish.length; i++){
- final String itemName = prefix+harvestcraftFish[i]+suffix;
- final int lootChance = getLootChance(harvestcraftFish[i]);
- if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken(itemName, 1) != null){
- //addFish("fish", ItemUtils.getItemStackOfAmountFromOreDict(itemName, 1), lootChance);
- addGregtechMaceratorRecipe(ItemUtils.getItemStackOfAmountFromOreDict(itemName, 1));
- addGregtechCentrifugeRecipe(ItemUtils.getItemStackOfAmountFromOreDict(itemName, 1));
- addGregtechFluidRecipe(ItemUtils.getItemStackOfAmountFromOreDict(itemName, 1));
- }
- }
- if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken(greenheartFish, 1) != null){
- //addFish("fish", ItemUtils.getItemStackOfAmountFromOreDict(greenheartFish, 1), getLootChance(greenheartFish));
- addGregtechMaceratorRecipe(ItemUtils.getItemStackOfAmountFromOreDict(greenheartFish, 1));
- addGregtechCentrifugeRecipe(ItemUtils.getItemStackOfAmountFromOreDict(greenheartFish, 1));
- addGregtechFluidRecipe(ItemUtils.getItemStackOfAmountFromOreDict(greenheartFish, 1));
- }
- if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken(seaweed, 1) != null){
- //addFish("junk", ItemUtils.getItemStackOfAmountFromOreDict(seaweed, 1), getLootChance(seaweed));
- }
- }
-
- private static int getLootChance(final String name){
- if (name.equals(harvestcraftFish[0])){
- return 20;
- }
- else if (name.equals(harvestcraftFish[1])){
- return 10;
- }
- else if (name.equals(harvestcraftFish[2])){
- return 15;
- }
- else if (name.equals(harvestcraftFish[3])){
- return 55;
- }
- else if (name.equals(harvestcraftFish[4])){
- return 5;
- }
- else if (name.equals(harvestcraftFish[5])){
- return 8;
- }
- else if (name.equals(harvestcraftFish[6])){
- return 11;
- }
- else if (name.equals(harvestcraftFish[7])){
- return 11;
- }
- else if (name.equals(harvestcraftFish[8])){
- return 15;
- }
- else if (name.equals(harvestcraftFish[9])){
- return 1;
- }
- else if (name.equals(harvestcraftFish[10])){
- return 5;
- }
- else if (name.equals(harvestcraftFish[11])){
- return 10;
- }
- else if (name.equals(harvestcraftFish[12])){
- return 25;
- }
- else if (name.equals(harvestcraftFish[13])){
- return 15;
- }
- else if (name.equals(harvestcraftFish[14])){
- return 20;
- } //"Perch", "Scallop", "Shrimp", "Snail", "Snapper", "Tilapia", "Trout", "Tuna", "Turtle", "Walleye"};
- else if (name.equals(harvestcraftFish[15])){
- return 22;
- }
- else if (name.equals(harvestcraftFish[16])){
- return 10;
- }
- else if (name.equals(harvestcraftFish[17])){
- return 35;
- }
- else if (name.equals(harvestcraftFish[18])){
- return 3;
- }
- else if (name.equals(harvestcraftFish[19])){
- return 20;
- }
- else if (name.equals(harvestcraftFish[20])){
- return 4;
- }
- else if (name.equals(harvestcraftFish[21])){
- return 40;
- }
- else if (name.equals(harvestcraftFish[22])){
- return 30;
- }
- else if (name.equals(harvestcraftFish[23])){
- return 5;
- }
- else if (name.equals(harvestcraftFish[24])){
- return 8;
- }
- else {
- return 25;
- }
- }
-
- private static void addGregtechCentrifugeRecipe(final ItemStack input){
- if (LoadedMods.Gregtech){
- GT_Values.RA.addCentrifugeRecipe(input, null, null, FluidUtils.getFluidStack("methane", 96), null, null, null, null, null, null, null, 19*20, 5);
- }
- }
-
- private static void addGregtechMaceratorRecipe(final ItemStack input){
- if (LoadedMods.Gregtech){
- GT_ModHandler.addPulverisationRecipe(input, ItemUtils.getItemStackOfAmountFromOreDict("dustMeatRaw", 1), ItemUtils.getItemStackOfAmountFromOreDict("dustTinyBone", 1), 0);
- }
- }
-
- private static void addGregtechFluidRecipe(final ItemStack input){
- if (LoadedMods.Gregtech){
- if (CORE.GTNH) {
- CORE.RA.addFluidExtractionRecipe(input, FluidUtils.getFluidStack("fishoil", 50), 16, 4);
- }
- else {
- CORE.RA.addFluidExtractionRecipe(input, FluidUtils.getFluidStack("fishoil", 4), 16, 4); //4eu/t total eu used = 64 so time = 64/4
- }
- }
- }
-
+ private static final String[] fishTypes = {"fish", "junk", "treasure"};
+ private static Object mFishingRegistry;
+ private static Growthcraft_Old mHandler;
+
+ public static Object getFishingRegistry() {
+ if (mFishingRegistry != null) {
+ return mFishingRegistry;
+ } else {
+ return setFishTrapRegistry();
+ }
+ }
+
+ private static final Object setFishTrapRegistry() {
+ Class mFishingRegistryClass;
+ try {
+ mFishingRegistryClass = ReflectionUtils.getClass("growthcraft.api.fishtrap.FishTrapRegistry");
+ final Method mFishingRegistryMethod = mFishingRegistryClass.getDeclaredMethod("getInstance");
+ mFishingRegistry = mFishingRegistryMethod.invoke(null);
+ if (mFishingRegistry != null) {
+ return mFishingRegistry;
+ }
+ } catch (NoSuchMethodException
+ | SecurityException
+ | IllegalAccessException
+ | IllegalArgumentException
+ | InvocationTargetException e) {
+ }
+ return null;
+ }
+
+ protected static void addFish(final String lootType, final ItemStack lootStack, final int lootChance) {
+
+ if (mFishingRegistry == null) {
+ setFishTrapRegistry();
+ }
+ if (mHandler == null) {
+ mHandler = new Growthcraft_Old();
+ }
+
+ final String GCVersion = LoadedMods.getModVersion("Growthcraft");
+ final String[] versionString = GCVersion.split("//.");
+
+ if (LoadedMods.getModVersion("Growthcraft").contains("2.3.1") || versionString[1].equals("3")) {
+ if (lootType.equals(fishTypes[0])) {
+ mHandler.addTrapFish(lootStack, lootChance);
+ Logger.INFO("Added " + lootStack.getDisplayName() + " as an extra Fish for Growthcraft Fishtraps.");
+ } else if (lootType.equals(fishTypes[1])) {
+ mHandler.addTrapJunk(lootStack, lootChance);
+ Logger.INFO("Added " + lootStack.getDisplayName() + " as extra Junk for Growthcraft Fishtraps.");
+ } else if (lootType.equals(fishTypes[2])) {
+ mHandler.addTrapTreasure(lootStack, lootChance);
+ Logger.INFO("Added " + lootStack.getDisplayName() + " as extra Treasure for Growthcraft Fishtraps.");
+ } else {
+ return;
+ }
+ } /*
+ else if (LoadedMods.getModVersion("Growthcraft").contains("2.7.2")){
+ if (lootType.equals(fishTypes[0])){
+ Growthcraft_New.addTrapFish(lootStack, lootChance);
+ Utils.LOG_INFO("Added "+lootStack.getDisplayName()+" as an extra Fish for Growthcraft Fishtraps.");
+ }
+ else if (lootType.equals(fishTypes[1])){
+ Growthcraft_New.addTrapJunk(lootStack, lootChance);
+ Utils.LOG_INFO("Added "+lootStack.getDisplayName()+" as extra Junk for Growthcraft Fishtraps.");
+ }
+ else if (lootType.equals(fishTypes[2])){
+ Growthcraft_New.addTrapTreasure(lootStack, lootChance);
+ Utils.LOG_INFO("Added "+lootStack.getDisplayName()+" as extra Treasure for Growthcraft Fishtraps.");
+ }
+ else {
+ return;
+ }
+ }*/ else {
+ Logger.INFO("Extra Fish loot for Growthcraft Fishtraps disabled. Found V."
+ + LoadedMods.getModVersion("Growthcraft"));
+ }
+ }
+ // FishTrapHandler.pamsHarvestCraftCompat();
+ static final String prefix = "food";
+ static final String suffix = "raw";
+ static final String seaweed = "cropSeaweed";
+ static final String greenheartFish = "foodGreenheartfish";
+ private static final String[] harvestcraftFish = {
+ "Anchovy", "Bass", "Calamari", "Carp", "Catfish", "Charr", "Clam", "Crab", "Crayfish", "Eel", "Frog", "Grouper",
+ "Herring",
+ "Jellyfish", "Mudfish", "Octopus", "Perch", "Scallop", "Shrimp", "Snail", "Snapper", "Tilapia", "Trout", "Tuna",
+ "Turtle", "Walley"
+ };
+
+ public static void pamsHarvestCraftCompat() {
+ for (int i = 0; i < harvestcraftFish.length; i++) {
+ final String itemName = prefix + harvestcraftFish[i] + suffix;
+ final int lootChance = getLootChance(harvestcraftFish[i]);
+ if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken(itemName, 1) != null) {
+ // addFish("fish", ItemUtils.getItemStackOfAmountFromOreDict(itemName, 1), lootChance);
+ addGregtechMaceratorRecipe(ItemUtils.getItemStackOfAmountFromOreDict(itemName, 1));
+ addGregtechCentrifugeRecipe(ItemUtils.getItemStackOfAmountFromOreDict(itemName, 1));
+ addGregtechFluidRecipe(ItemUtils.getItemStackOfAmountFromOreDict(itemName, 1));
+ }
+ }
+ if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken(greenheartFish, 1) != null) {
+ // addFish("fish", ItemUtils.getItemStackOfAmountFromOreDict(greenheartFish, 1),
+ // getLootChance(greenheartFish));
+ addGregtechMaceratorRecipe(ItemUtils.getItemStackOfAmountFromOreDict(greenheartFish, 1));
+ addGregtechCentrifugeRecipe(ItemUtils.getItemStackOfAmountFromOreDict(greenheartFish, 1));
+ addGregtechFluidRecipe(ItemUtils.getItemStackOfAmountFromOreDict(greenheartFish, 1));
+ }
+ if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken(seaweed, 1) != null) {
+ // addFish("junk", ItemUtils.getItemStackOfAmountFromOreDict(seaweed, 1), getLootChance(seaweed));
+ }
+ }
+
+ private static int getLootChance(final String name) {
+ if (name.equals(harvestcraftFish[0])) {
+ return 20;
+ } else if (name.equals(harvestcraftFish[1])) {
+ return 10;
+ } else if (name.equals(harvestcraftFish[2])) {
+ return 15;
+ } else if (name.equals(harvestcraftFish[3])) {
+ return 55;
+ } else if (name.equals(harvestcraftFish[4])) {
+ return 5;
+ } else if (name.equals(harvestcraftFish[5])) {
+ return 8;
+ } else if (name.equals(harvestcraftFish[6])) {
+ return 11;
+ } else if (name.equals(harvestcraftFish[7])) {
+ return 11;
+ } else if (name.equals(harvestcraftFish[8])) {
+ return 15;
+ } else if (name.equals(harvestcraftFish[9])) {
+ return 1;
+ } else if (name.equals(harvestcraftFish[10])) {
+ return 5;
+ } else if (name.equals(harvestcraftFish[11])) {
+ return 10;
+ } else if (name.equals(harvestcraftFish[12])) {
+ return 25;
+ } else if (name.equals(harvestcraftFish[13])) {
+ return 15;
+ } else if (name.equals(harvestcraftFish[14])) {
+ return 20;
+ } // "Perch", "Scallop", "Shrimp", "Snail", "Snapper", "Tilapia", "Trout", "Tuna", "Turtle", "Walleye"};
+ else if (name.equals(harvestcraftFish[15])) {
+ return 22;
+ } else if (name.equals(harvestcraftFish[16])) {
+ return 10;
+ } else if (name.equals(harvestcraftFish[17])) {
+ return 35;
+ } else if (name.equals(harvestcraftFish[18])) {
+ return 3;
+ } else if (name.equals(harvestcraftFish[19])) {
+ return 20;
+ } else if (name.equals(harvestcraftFish[20])) {
+ return 4;
+ } else if (name.equals(harvestcraftFish[21])) {
+ return 40;
+ } else if (name.equals(harvestcraftFish[22])) {
+ return 30;
+ } else if (name.equals(harvestcraftFish[23])) {
+ return 5;
+ } else if (name.equals(harvestcraftFish[24])) {
+ return 8;
+ } else {
+ return 25;
+ }
+ }
+
+ private static void addGregtechCentrifugeRecipe(final ItemStack input) {
+ if (LoadedMods.Gregtech) {
+ GT_Values.RA.addCentrifugeRecipe(
+ input,
+ null,
+ null,
+ FluidUtils.getFluidStack("methane", 96),
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 19 * 20,
+ 5);
+ }
+ }
+
+ private static void addGregtechMaceratorRecipe(final ItemStack input) {
+ if (LoadedMods.Gregtech) {
+ GT_ModHandler.addPulverisationRecipe(
+ input,
+ ItemUtils.getItemStackOfAmountFromOreDict("dustMeatRaw", 1),
+ ItemUtils.getItemStackOfAmountFromOreDict("dustTinyBone", 1),
+ 0);
+ }
+ }
+
+ private static void addGregtechFluidRecipe(final ItemStack input) {
+ if (LoadedMods.Gregtech) {
+ if (CORE.GTNH) {
+ CORE.RA.addFluidExtractionRecipe(input, FluidUtils.getFluidStack("fishoil", 50), 16, 4);
+ } else {
+ CORE.RA.addFluidExtractionRecipe(
+ input,
+ FluidUtils.getFluidStack("fishoil", 4),
+ 16,
+ 4); // 4eu/t total eu used = 64 so time = 64/4
+ }
+ }
+ }
}
diff --git a/src/main/java/gtPlusPlus/xmod/growthcraft/fishtrap/Growthcraft_New.java b/src/main/java/gtPlusPlus/xmod/growthcraft/fishtrap/Growthcraft_New.java
index 41fec179b5..dd8e6debc7 100644
--- a/src/main/java/gtPlusPlus/xmod/growthcraft/fishtrap/Growthcraft_New.java
+++ b/src/main/java/gtPlusPlus/xmod/growthcraft/fishtrap/Growthcraft_New.java
@@ -3,84 +3,87 @@ package gtPlusPlus.xmod.growthcraft.fishtrap;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-
import net.minecraft.item.ItemStack;
public class Growthcraft_New {
- Method addTrapJunk;
- Method addTrapTreasure;
- Method addTrapFish;
- Object FishTrapRegistryO;
-
- public Growthcraft_New(){
- setFishTrapRegistry();
- }
-
- void setFishTrapRegistry(){
- try {
- Class<?> FishTrapRegistryClass = Class.forName("gtPlusPlus.xmod.growthcraft.fishtrap.FishTrapHandler.mFishingRegistry");
- Class<?> FishTrapEntry = Class.forName("growthcraft.api.fishtrap.FishTrapEntry");
- if (FishTrapRegistryClass.isInstance(FishTrapHandler.getFishingRegistry())){
- addTrapJunk = FishTrapRegistryClass.getDeclaredMethod("addTrapJunk", FishTrapEntry);
- addTrapTreasure = FishTrapRegistryClass.getDeclaredMethod("addTrapTreasure", FishTrapEntry);
- addTrapFish = FishTrapRegistryClass.getDeclaredMethod("addTrapFish", FishTrapEntry);
- FishTrapRegistryO = FishTrapHandler.getFishingRegistry();
- }
- }
- catch (ClassNotFoundException | NoSuchMethodException | SecurityException e) {
- e.printStackTrace();
- }
- }
-
- private Object createFishTrapEntry(ItemStack loot, int chance){
- try {
- Class<?> FishTrapEntry = Class.forName("growthcraft.api.fishtrap.FishTrapEntry");
- Object o = FishTrapEntry.getConstructor(ItemStack.class, int.class);
- if (FishTrapEntry != null){
- Constructor[] constructors = FishTrapEntry.getDeclaredConstructors();
- constructors[0].setAccessible(true);
- Object x = constructors[0].newInstance(loot, chance);
- if (x != null){
- return x;
- }
- }
- }
- catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {}
-
- return null;
- }
-
- private boolean invoke(Method m, ItemStack o, int p){
- try {
- Object I = createFishTrapEntry(o, p);
- m.invoke(FishTrapRegistryO, I);
- return true;
- }
- catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {}
- return false;
- }
+ Method addTrapJunk;
+ Method addTrapTreasure;
+ Method addTrapFish;
+ Object FishTrapRegistryO;
+
+ public Growthcraft_New() {
+ setFishTrapRegistry();
+ }
+
+ void setFishTrapRegistry() {
+ try {
+ Class<?> FishTrapRegistryClass =
+ Class.forName("gtPlusPlus.xmod.growthcraft.fishtrap.FishTrapHandler.mFishingRegistry");
+ Class<?> FishTrapEntry = Class.forName("growthcraft.api.fishtrap.FishTrapEntry");
+ if (FishTrapRegistryClass.isInstance(FishTrapHandler.getFishingRegistry())) {
+ addTrapJunk = FishTrapRegistryClass.getDeclaredMethod("addTrapJunk", FishTrapEntry);
+ addTrapTreasure = FishTrapRegistryClass.getDeclaredMethod("addTrapTreasure", FishTrapEntry);
+ addTrapFish = FishTrapRegistryClass.getDeclaredMethod("addTrapFish", FishTrapEntry);
+ FishTrapRegistryO = FishTrapHandler.getFishingRegistry();
+ }
+ } catch (ClassNotFoundException | NoSuchMethodException | SecurityException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private Object createFishTrapEntry(ItemStack loot, int chance) {
+ try {
+ Class<?> FishTrapEntry = Class.forName("growthcraft.api.fishtrap.FishTrapEntry");
+ Object o = FishTrapEntry.getConstructor(ItemStack.class, int.class);
+ if (FishTrapEntry != null) {
+ Constructor[] constructors = FishTrapEntry.getDeclaredConstructors();
+ constructors[0].setAccessible(true);
+ Object x = constructors[0].newInstance(loot, chance);
+ if (x != null) {
+ return x;
+ }
+ }
+ } catch (ClassNotFoundException
+ | NoSuchMethodException
+ | SecurityException
+ | InstantiationException
+ | IllegalAccessException
+ | IllegalArgumentException
+ | InvocationTargetException e) {
+ }
- public void addTrapJunk(final ItemStack loot, final int lootChance){
- //FishTrapRegistry.instance().addTrapJunk(new FishTrapEntry(loot, lootChance));
- if (addTrapJunk != null){
- invoke(addTrapJunk, loot, lootChance);
- }
+ return null;
+ }
- }
+ private boolean invoke(Method m, ItemStack o, int p) {
+ try {
+ Object I = createFishTrapEntry(o, p);
+ m.invoke(FishTrapRegistryO, I);
+ return true;
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+ }
+ return false;
+ }
- public void addTrapTreasure(final ItemStack loot, final int lootChance){
- //FishTrapRegistry.instance().addTrapTreasure(new FishTrapEntry(loot, lootChance));
- if (addTrapTreasure != null){
- invoke(addTrapTreasure, loot, lootChance);
- }
- }
+ public void addTrapJunk(final ItemStack loot, final int lootChance) {
+ // FishTrapRegistry.instance().addTrapJunk(new FishTrapEntry(loot, lootChance));
+ if (addTrapJunk != null) {
+ invoke(addTrapJunk, loot, lootChance);
+ }
+ }
- public void addTrapFish(final ItemStack loot, final int lootChance){
- //FishTrapRegistry.instance().addTrapFish(new FishTrapEntry(loot, lootChance));
- if (addTrapFish != null){
- invoke(addTrapFish, loot, lootChance);
- }
- }
+ public void addTrapTreasure(final ItemStack loot, final int lootChance) {
+ // FishTrapRegistry.instance().addTrapTreasure(new FishTrapEntry(loot, lootChance));
+ if (addTrapTreasure != null) {
+ invoke(addTrapTreasure, loot, lootChance);
+ }
+ }
+ public void addTrapFish(final ItemStack loot, final int lootChance) {
+ // FishTrapRegistry.instance().addTrapFish(new FishTrapEntry(loot, lootChance));
+ if (addTrapFish != null) {
+ invoke(addTrapFish, loot, lootChance);
+ }
+ }
}
diff --git a/src/main/java/gtPlusPlus/xmod/growthcraft/fishtrap/Growthcraft_Old.java b/src/main/java/gtPlusPlus/xmod/growthcraft/fishtrap/Growthcraft_Old.java
index ab11c062e0..76a025667b 100644
--- a/src/main/java/gtPlusPlus/xmod/growthcraft/fishtrap/Growthcraft_Old.java
+++ b/src/main/java/gtPlusPlus/xmod/growthcraft/fishtrap/Growthcraft_Old.java
@@ -3,84 +3,87 @@ package gtPlusPlus.xmod.growthcraft.fishtrap;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-
import net.minecraft.item.ItemStack;
public class Growthcraft_Old {
- Method addTrapJunk;
- Method addTrapTreasure;
- Method addTrapFish;
- Object FishTrapRegistryO;
-
- public Growthcraft_Old(){
- setFishTrapRegistry();
- }
-
- void setFishTrapRegistry(){
- try {
- Class<?> FishTrapRegistryClass = Class.forName("gtPlusPlus.xmod.growthcraft.fishtrap.FishTrapHandler.mFishingRegistry");
- Class<?> FishTrapEntry = Class.forName("growthcraft.api.fishtrap.FishTrapEntry");
- if (FishTrapRegistryClass.isInstance(FishTrapHandler.getFishingRegistry())){
- addTrapJunk = FishTrapRegistryClass.getDeclaredMethod("addTrapJunk", FishTrapEntry);
- addTrapTreasure = FishTrapRegistryClass.getDeclaredMethod("addTrapTreasure", FishTrapEntry);
- addTrapFish = FishTrapRegistryClass.getDeclaredMethod("addTrapFish", FishTrapEntry);
- FishTrapRegistryO = FishTrapHandler.getFishingRegistry();
- }
- }
- catch (ClassNotFoundException | NoSuchMethodException | SecurityException e) {
- e.printStackTrace();
- }
- }
-
- private Object createFishTrapEntry(ItemStack loot, int chance){
- try {
- Class<?> FishTrapEntry = Class.forName("growthcraft.api.fishtrap.FishTrapEntry");
- Object o = FishTrapEntry.getConstructor(ItemStack.class, int.class);
- if (FishTrapEntry != null){
- Constructor[] constructors = FishTrapEntry.getDeclaredConstructors();
- constructors[0].setAccessible(true);
- Object x = constructors[0].newInstance(loot, chance);
- if (x != null){
- return x;
- }
- }
- }
- catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {}
-
- return null;
- }
-
- private boolean invoke(Method m, ItemStack o, int p){
- try {
- Object I = createFishTrapEntry(o, p);
- m.invoke(FishTrapRegistryO, I);
- return true;
- }
- catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {}
- return false;
- }
+ Method addTrapJunk;
+ Method addTrapTreasure;
+ Method addTrapFish;
+ Object FishTrapRegistryO;
+
+ public Growthcraft_Old() {
+ setFishTrapRegistry();
+ }
+
+ void setFishTrapRegistry() {
+ try {
+ Class<?> FishTrapRegistryClass =
+ Class.forName("gtPlusPlus.xmod.growthcraft.fishtrap.FishTrapHandler.mFishingRegistry");
+ Class<?> FishTrapEntry = Class.forName("growthcraft.api.fishtrap.FishTrapEntry");
+ if (FishTrapRegistryClass.isInstance(FishTrapHandler.getFishingRegistry())) {
+ addTrapJunk = FishTrapRegistryClass.getDeclaredMethod("addTrapJunk", FishTrapEntry);
+ addTrapTreasure = FishTrapRegistryClass.getDeclaredMethod("addTrapTreasure", FishTrapEntry);
+ addTrapFish = FishTrapRegistryClass.getDeclaredMethod("addTrapFish", FishTrapEntry);
+ FishTrapRegistryO = FishTrapHandler.getFishingRegistry();
+ }
+ } catch (ClassNotFoundException | NoSuchMethodException | SecurityException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private Object createFishTrapEntry(ItemStack loot, int chance) {
+ try {
+ Class<?> FishTrapEntry = Class.forName("growthcraft.api.fishtrap.FishTrapEntry");
+ Object o = FishTrapEntry.getConstructor(ItemStack.class, int.class);
+ if (FishTrapEntry != null) {
+ Constructor[] constructors = FishTrapEntry.getDeclaredConstructors();
+ constructors[0].setAccessible(true);
+ Object x = constructors[0].newInstance(loot, chance);
+ if (x != null) {
+ return x;
+ }
+ }
+ } catch (ClassNotFoundException
+ | NoSuchMethodException
+ | SecurityException
+ | InstantiationException
+ | IllegalAccessException
+ | IllegalArgumentException
+ | InvocationTargetException e) {
+ }
- public void addTrapJunk(final ItemStack loot, final int lootChance){
- //FishTrapRegistry.instance().addTrapJunk(new FishTrapEntry(loot, lootChance));
- if (addTrapJunk != null){
- invoke(addTrapJunk, loot, lootChance);
- }
+ return null;
+ }
- }
+ private boolean invoke(Method m, ItemStack o, int p) {
+ try {
+ Object I = createFishTrapEntry(o, p);
+ m.invoke(FishTrapRegistryO, I);
+ return true;
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+ }
+ return false;
+ }
- public void addTrapTreasure(final ItemStack loot, final int lootChance){
- //FishTrapRegistry.instance().addTrapTreasure(new FishTrapEntry(loot, lootChance));
- if (addTrapTreasure != null){
- invoke(addTrapTreasure, loot, lootChance);
- }
- }
+ public void addTrapJunk(final ItemStack loot, final int lootChance) {
+ // FishTrapRegistry.instance().addTrapJunk(new FishTrapEntry(loot, lootChance));
+ if (addTrapJunk != null) {
+ invoke(addTrapJunk, loot, lootChance);
+ }
+ }
- public void addTrapFish(final ItemStack loot, final int lootChance){
- //FishTrapRegistry.instance().addTrapFish(new FishTrapEntry(loot, lootChance));
- if (addTrapFish != null){
- invoke(addTrapFish, loot, lootChance);
- }
- }
+ public void addTrapTreasure(final ItemStack loot, final int lootChance) {
+ // FishTrapRegistry.instance().addTrapTreasure(new FishTrapEntry(loot, lootChance));
+ if (addTrapTreasure != null) {
+ invoke(addTrapTreasure, loot, lootChance);
+ }
+ }
+ public void addTrapFish(final ItemStack loot, final int lootChance) {
+ // FishTrapRegistry.instance().addTrapFish(new FishTrapEntry(loot, lootChance));
+ if (addTrapFish != null) {
+ invoke(addTrapFish, loot, lootChance);
+ }
+ }
}