diff options
Diffstat (limited to 'src/Java/gregtech')
-rw-r--r-- | src/Java/gregtech/api/enums/TAE.java | 63 | ||||
-rw-r--r-- | src/Java/gregtech/api/util/FishPondFakeRecipe.java | 75 | ||||
-rw-r--r-- | src/Java/gregtech/api/util/Recipe_GT.java | 2 |
3 files changed, 126 insertions, 14 deletions
diff --git a/src/Java/gregtech/api/enums/TAE.java b/src/Java/gregtech/api/enums/TAE.java index c6fc8c7790..248722269b 100644 --- a/src/Java/gregtech/api/enums/TAE.java +++ b/src/Java/gregtech/api/enums/TAE.java @@ -1,16 +1,22 @@ package gregtech.api.enums; +import java.lang.reflect.Field; + +import gregtech.api.enums.Textures.BlockIcons; import gregtech.api.interfaces.ITexture; import gregtech.api.objects.GT_CopiedBlockTexture; import gregtech.api.objects.GT_RenderedTexture; +import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; public class TAE { //TAE stands for Texture Array Expansion. - + public static int gtTexturesArrayStartOrigin; - public static int gtPPLastUsedIndex = 96; + public static int gtPPLastUsedIndex = 64; + public static int secondaryIndex = 0; public static boolean hasArrayBeenExpanded = false; public static boolean hookGtTextures() { @@ -42,22 +48,51 @@ public class TAE { }*/ public static boolean registerTextures(GT_CopiedBlockTexture gt_CopiedBlockTexture) { - Textures.BlockIcons.CASING_BLOCKS[gtPPLastUsedIndex] = gt_CopiedBlockTexture; - gtPPLastUsedIndex++; - //Just so I know registration is done. - return true; + try { + + //Handle page 2. + if (gtPPLastUsedIndex >= 128) { + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && Utils.getGregtechSubVersion() > 30) { + Field x = ReflectionUtils.getField(Textures.BlockIcons.class, "casingTexturePages"); + if (x != null) { + ITexture[][] h = (ITexture[][]) x.get(null); + if (h != null) { + h[64][secondaryIndex++] = gt_CopiedBlockTexture; + x.set(null, h); + return true; + } + } + } + } + + //set to page 1. + else { + Textures.BlockIcons.CASING_BLOCKS[gtPPLastUsedIndex] = gt_CopiedBlockTexture; + gtPPLastUsedIndex++; + return true; + } + } + catch (Throwable t) { + t.printStackTrace(); + } + return false; } - + public static ITexture getTexture(int index){ - if (!hasArrayBeenExpanded){ - return null; - } - else { - return Textures.BlockIcons.CASING_BLOCKS[(96+index)]; + if (gtPPLastUsedIndex >= 128) { + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && Utils.getGregtechSubVersion() > 30) { + return Textures.BlockIcons.CASING_BLOCKS[((64*128)+index)]; + } } + return Textures.BlockIcons.CASING_BLOCKS[(64+index)]; } - + public static int GTPP_INDEX(int ID){ - return (96+ID); + if (gtPPLastUsedIndex >= 128) { + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && Utils.getGregtechSubVersion() > 30) { + return (ID); + } + } + return (64+ID); } } diff --git a/src/Java/gregtech/api/util/FishPondFakeRecipe.java b/src/Java/gregtech/api/util/FishPondFakeRecipe.java new file mode 100644 index 0000000000..5aef1bcd8a --- /dev/null +++ b/src/Java/gregtech/api/util/FishPondFakeRecipe.java @@ -0,0 +1,75 @@ +package gregtech.api.util; + +import java.util.ArrayList; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.array.AutoMap; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.item.ItemStack; +import net.minecraft.util.WeightedRandomFishable; +import net.minecraftforge.common.FishingHooks; +import net.minecraftforge.fluids.FluidStack; + +public class FishPondFakeRecipe { + + public static ArrayList<WeightedRandomFishable> fish = new ArrayList<WeightedRandomFishable>(); + public static ArrayList<WeightedRandomFishable> junk = new ArrayList<WeightedRandomFishable>(); + public static ArrayList<WeightedRandomFishable> treasure = new ArrayList<WeightedRandomFishable>(); + + @SuppressWarnings("unchecked") + public static boolean generateFishPondRecipes() { + + try { + fish = (ArrayList<WeightedRandomFishable>) ReflectionUtils.getField(FishingHooks.class, "fish").get(null); + junk = (ArrayList<WeightedRandomFishable>) ReflectionUtils.getField(FishingHooks.class, "junk").get(null); + treasure = (ArrayList<WeightedRandomFishable>) ReflectionUtils.getField(FishingHooks.class, "treasure").get(null); + } + catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + Logger.INFO("Error generating Fish Pond Recipes. [1]"); + e.printStackTrace(); + } + + AutoMap<ArrayList<WeightedRandomFishable>> mega = new AutoMap<ArrayList<WeightedRandomFishable>>(); + mega.put(fish); + mega.put(junk); + mega.put(treasure); + + int mType = 14; + for (ArrayList<WeightedRandomFishable> f : mega.values()) { + for (int e=0;e<f.size();e++) { + if (f.get(e) != null) { + WeightedRandomFishable u = f.get(e); + try { + ItemStack t = (ItemStack) ReflectionUtils.getField(WeightedRandomFishable.class, "field_150711_b").get(u); + addNewFishPondLoot(mType, new ItemStack[]{t}, new int[] {10000}); + } + catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e1) { + Logger.INFO("Error generating Fish Pond Recipes. [2]"); + e1.printStackTrace(); + } + } + } + mType++; + } + + return true; + } + + public static void addNewFishPondLoot(int circuit, ItemStack[] outputItems, int[] chances) { + GT_Recipe x = new GT_Recipe( + true, + new ItemStack[]{CI.getNumberedCircuit(circuit)}, + outputItems, + null, + chances, + new FluidStack[]{null}, + new FluidStack[]{null}, + 100, //1 Tick + 0, //No Eu produced + 0 //Magic Number + ); + Recipe_GT.Gregtech_Recipe_Map.sFishPondRecipes.addRecipe(x); + } + +} diff --git a/src/Java/gregtech/api/util/Recipe_GT.java b/src/Java/gregtech/api/util/Recipe_GT.java index 351814f386..342add5b63 100644 --- a/src/Java/gregtech/api/util/Recipe_GT.java +++ b/src/Java/gregtech/api/util/Recipe_GT.java @@ -281,6 +281,8 @@ public class Recipe_GT extends GT_Recipe{ //Component Assembler public static final GT_Recipe_Map sComponentAssemblerRecipes = new GT_Recipe_Map_Assembler(new HashSet<GT_Recipe>(300), "gt.recipe.componentassembler", "Component Assembler", null, RES_PATH_GUI + "basicmachines/Assembler", 6, 1, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sFishPondRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(3), "gt.recipe.fishpond", "Zhuhai - Fishing Port", null, RES_PATH_GUI + "basicmachines/PotionBrewer", 0, 1, 0, 0, 1, E, 1, E, true, true); + /** |