aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/xmod/growthcraft/fishtrap/Growthcraft_Old.java
diff options
context:
space:
mode:
authorJordan Byrne <draknyte1@hotmail.com>2017-12-24 11:54:30 +1000
committerJordan Byrne <draknyte1@hotmail.com>2017-12-24 11:54:30 +1000
commitecf908e98ccee72a713091e8ab547e35a41d7436 (patch)
treef0dade1481aa02fd0ac4fcf8a672cc7a761a0547 /src/Java/gtPlusPlus/xmod/growthcraft/fishtrap/Growthcraft_Old.java
parentb9fe3352840abe0846834cefd578895ec6f5e520 (diff)
parentfa5de3584ce7bc97ce6f32b31f6062b5b6e89e75 (diff)
downloadGT5-Unofficial-ecf908e98ccee72a713091e8ab547e35a41d7436.tar.gz
GT5-Unofficial-ecf908e98ccee72a713091e8ab547e35a41d7436.tar.bz2
GT5-Unofficial-ecf908e98ccee72a713091e8ab547e35a41d7436.zip
> Why does Git make me do these? arghhh...
Merge branch 'master' of https://github.com/draknyte1/GTplusplus # Conflicts: # src/Java/gtPlusPlus/core/material/ALLOY.java # src/Java/gtPlusPlus/core/material/ELEMENT.java # src/Java/gtPlusPlus/core/material/Material.java # src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/growthcraft/fishtrap/Growthcraft_Old.java')
-rw-r--r--src/Java/gtPlusPlus/xmod/growthcraft/fishtrap/Growthcraft_Old.java78
1 files changed, 69 insertions, 9 deletions
diff --git a/src/Java/gtPlusPlus/xmod/growthcraft/fishtrap/Growthcraft_Old.java b/src/Java/gtPlusPlus/xmod/growthcraft/fishtrap/Growthcraft_Old.java
index f988abd53a..62fe2f29cb 100644
--- a/src/Java/gtPlusPlus/xmod/growthcraft/fishtrap/Growthcraft_Old.java
+++ b/src/Java/gtPlusPlus/xmod/growthcraft/fishtrap/Growthcraft_Old.java
@@ -1,24 +1,84 @@
package gtPlusPlus.xmod.growthcraft.fishtrap;
-import growthcraft.api.fishtrap.FishTrapEntry;
-import growthcraft.api.fishtrap.FishTrapRegistry;
+import java.lang.reflect.*;
+
import net.minecraft.item.ItemStack;
public class Growthcraft_Old {
- public static void addTrapJunk(final ItemStack loot, final int lootChance){
- FishTrapRegistry.instance().addTrapJunk(new FishTrapEntry(loot, lootChance));
-
+ 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;
}
- public static void addTrapTreasure(final ItemStack loot, final int lootChance){
- FishTrapRegistry.instance().addTrapTreasure(new FishTrapEntry(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 static void addTrapFish(final ItemStack loot, final int lootChance){
- FishTrapRegistry.instance().addTrapFish(new FishTrapEntry(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);
+ }
}
}