1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
package gregtech.api.util;
import static gregtech.api.util.GTRecipeBuilder.SECONDS;
import java.lang.reflect.Field;
import java.util.ArrayList;
import net.minecraft.item.ItemStack;
import net.minecraft.util.WeightedRandomFishable;
import net.minecraftforge.common.FishingHooks;
import gregtech.api.enums.GTValues;
import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.api.recipe.GTPPRecipeMaps;
import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.MTEIndustrialFishingPond;
public class FishPondFakeRecipe {
public static final ArrayList<ItemStack> fish = new ArrayList<>();
public static final ArrayList<ItemStack> junk = new ArrayList<>();
public static final ArrayList<ItemStack> treasure = new ArrayList<>();
@SuppressWarnings("unchecked")
public static void generateFishPondRecipes() {
try {
ArrayList<WeightedRandomFishable> fishList = (ArrayList<WeightedRandomFishable>) GTUtility
.getField(FishingHooks.class, "fish")
.get(null);
ArrayList<WeightedRandomFishable> junkList = (ArrayList<WeightedRandomFishable>) GTUtility
.getField(FishingHooks.class, "junk")
.get(null);
ArrayList<WeightedRandomFishable> treasureList = (ArrayList<WeightedRandomFishable>) GTUtility
.getField(FishingHooks.class, "treasure")
.get(null);
final Field stackField = GTUtility.getField(WeightedRandomFishable.class, "field_150711_b");
generateRecipesFor(MTEIndustrialFishingPond.FISH_MODE, fish, fishList, stackField);
generateRecipesFor(MTEIndustrialFishingPond.JUNK_MODE, junk, junkList, stackField);
generateRecipesFor(MTEIndustrialFishingPond.TREASURE_MODE, treasure, treasureList, stackField);
} catch (Exception e) {
Logger.INFO("Error reading the vanilla fishing loot table.");
e.printStackTrace();
}
}
private static void generateRecipesFor(int circuitType, ArrayList<ItemStack> listToFill,
ArrayList<WeightedRandomFishable> lootTable, Field stackField) {
for (WeightedRandomFishable fishable : lootTable) {
try {
ItemStack stack = (ItemStack) stackField.get(fishable);
listToFill.add(stack.copy());
GTValues.RA.stdBuilder()
.itemInputs(GTUtility.getIntegratedCircuit(circuitType))
.itemOutputs(stack)
.duration(5 * SECONDS)
.eut(0)
.ignoreCollision()
.addTo(GTPPRecipeMaps.fishPondRecipes);
} catch (IllegalArgumentException | IllegalAccessException e1) {
Logger.INFO("Error generating Fish Pond Recipes");
e1.printStackTrace();
}
}
listToFill.trimToSize();
}
}
|