From 5507b8c0e7b2117a33dfb1fedbd14b3c30f6a01b Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Tue, 5 Feb 2019 20:02:33 +0000 Subject: + Added recipe for Nano Healer. + Added recipe for Strange Dust. + Added recipe for Slow Builders Ring. + Added recipes for Charge Packs. + Added recipes to make obtaining Zirconium a little earlier. + Added packager recipes for all ore materials. + Added lathe recipes for all materials -> rods. Closes #411. + Added way to process Silicon Carbide into Synthetic Graphite. Closes #407. + Added proper achievement localization for all new AL recipes. + Added more INIT_PHASE's. - Removed ways to obtain Trinium dust in GTNH. (Leave handling to GT instead). % Adjusted recipes for Cyclotron and Casings, it's now assembled instead of shape crafted. % Adjusted circuits used in lower tier dehydrator recipes for consistency. Closes #364. % Adjusted a few materials having '-' in their name within en_US.lang. % Adjusted power capacity of the Gem Batteries. % Adjusted tiering for Large Auto-Assembler, it has been reduced by one. % Adjusted composition of Pikyonium to now require Yttrium, instead of the rare Ytterbium. % Adjusted composition of DEEP_EARTH_REACTOR_FUEL_DEPOSIT to be slightly more balanced. % Adjusted smelting point of Zirconium Carbide. $ Fixed an NPE in GeneralTooltipEventHandler.java. $ Fixed weird invisible recipes. Closes #304. $ Confirmed Large Mixer is now working correctly. Closes #366. (Closed in previous commit https://github.com/draknyte1/GTplusplus/commit/918d763dabd82d47db739a1b0a51c01f0803adc0). $ Confirmed Matter Fabricator is now working correctly. Closes #360. + Auto Doors. Closes #338. (Closed in previous commit https://github.com/draknyte1/GTplusplus/commit/22c6a05a8a3a00294bcb8890a1e2a0fdc9196de8). % Changed Energy Buffer Recipes. Closes #52. (Closed in previous commit https://github.com/draknyte1/GTplusplus/commit/499411aa21ac4a742b6d51ef3ce9c4046d0a22c1). $ Invalid Recipe. Closes #241. (Closed in unknown, previous commit). --- .../core/handler/events/GeneralTooltipEventHandler.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/Java/gtPlusPlus/core/handler') diff --git a/src/Java/gtPlusPlus/core/handler/events/GeneralTooltipEventHandler.java b/src/Java/gtPlusPlus/core/handler/events/GeneralTooltipEventHandler.java index 6c940371b3..6d09f65f3f 100644 --- a/src/Java/gtPlusPlus/core/handler/events/GeneralTooltipEventHandler.java +++ b/src/Java/gtPlusPlus/core/handler/events/GeneralTooltipEventHandler.java @@ -7,6 +7,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import gregtech.api.enums.ItemList; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.GTplusplus.INIT_PHASE; import gtPlusPlus.core.handler.events.BlockEventHandler; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.ItemUtils; @@ -22,8 +24,13 @@ public class GeneralTooltipEventHandler { @SubscribeEvent public void onItemTooltip(ItemTooltipEvent event){ + + if (GTplusplus.CURRENT_LOAD_PHASE != INIT_PHASE.STARTED) { + return; + } + if (CORE.ConfigSwitches.chanceToDropFluoriteOre > 0) { - if (!BlockEventHandler.blockLimestone.isEmpty()) { + if (BlockEventHandler.blockLimestone != null && !BlockEventHandler.blockLimestone.isEmpty()) { for (ItemStack h : BlockEventHandler.blockLimestone) { if (h != null && Block.getBlockFromItem(h.getItem()) == Block.getBlockFromItem(event.itemStack.getItem())) { if (ItemUtils.getModId(h) != null && !ItemUtils.getModId(h).toLowerCase().contains("biomesoplenty")) { @@ -32,7 +39,7 @@ public class GeneralTooltipEventHandler { } } } - if (!BlockEventHandler.oreLimestone.isEmpty()) { + if (BlockEventHandler.oreLimestone != null && !BlockEventHandler.oreLimestone.isEmpty()) { for (ItemStack h : BlockEventHandler.oreLimestone) { if (h != null && Block.getBlockFromItem(h.getItem()) == Block.getBlockFromItem(event.itemStack.getItem())) { if (ItemUtils.getModId(h) != null && !ItemUtils.getModId(h).toLowerCase().contains("biomesoplenty")) { -- cgit From 5187791fd11da1e36f7e1c533bc46f7841772330 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Thu, 7 Feb 2019 07:03:08 +0000 Subject: + Added new achievements page for Assembly Line Recipes. + Added custom safety checks to Assembly Line Recipe/Achievement handling via ASM. + Added a safe way to get the unlocal names of items. - Removed 'Press e' Achievement when in Dev. (Thank, Fucking, God) $ Fixed a mild error concerning localization of Americium-241 Blocks. --- src/Java/gtPlusPlus/GTplusplus.java | 5 - src/Java/gtPlusPlus/core/common/CommonProxy.java | 5 + .../handler/StopAnnoyingFuckingAchievements.java | 24 + .../gtPlusPlus/core/util/minecraft/ItemUtils.java | 17 + .../ClassTransformer_GT_Achievements.java | 1896 ++++++++++++++++++++ .../transformers/ClassTransformer_GT_Client.java | 571 ++++++ .../Preloader_Transformer_Handler.java | 31 +- .../xmod/gregtech/common/Meta_GT_Proxy.java | 25 +- .../xmod/gregtech/common/StaticFields59.java | 2 + .../gregtech/loaders/misc/AssLineAchievements.java | 159 ++ src/resources/assets/miscutils/lang/en_US.lang | 2 +- 11 files changed, 2711 insertions(+), 26 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/handler/StopAnnoyingFuckingAchievements.java create mode 100644 src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Achievements.java create mode 100644 src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Client.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements.java (limited to 'src/Java/gtPlusPlus/core/handler') diff --git a/src/Java/gtPlusPlus/GTplusplus.java b/src/Java/gtPlusPlus/GTplusplus.java index 1c4789c28b..2e3133c343 100644 --- a/src/Java/gtPlusPlus/GTplusplus.java +++ b/src/Java/gtPlusPlus/GTplusplus.java @@ -221,11 +221,6 @@ public class GTplusplus implements ActionListener { Logger.INFO("Finally, we are finished. Have some cripsy bacon as a reward."); } - @EventHandler - public void load(FMLInitializationEvent event) { - - } - @EventHandler public synchronized void serverStarting(final FMLServerStartingEvent event) { INIT_PHASE.SERVER_START.setPhaseActive(true); diff --git a/src/Java/gtPlusPlus/core/common/CommonProxy.java b/src/Java/gtPlusPlus/core/common/CommonProxy.java index 9176dcc720..140019f73b 100644 --- a/src/Java/gtPlusPlus/core/common/CommonProxy.java +++ b/src/Java/gtPlusPlus/core/common/CommonProxy.java @@ -23,6 +23,7 @@ import gtPlusPlus.core.handler.BurnableFuelHandler; import gtPlusPlus.core.handler.COMPAT_HANDLER; import gtPlusPlus.core.handler.COMPAT_IntermodStaging; import gtPlusPlus.core.handler.GuiHandler; +import gtPlusPlus.core.handler.StopAnnoyingFuckingAchievements; import gtPlusPlus.core.handler.events.BlockEventHandler; import gtPlusPlus.core.handler.events.GeneralTooltipEventHandler; import gtPlusPlus.core.handler.events.PickaxeBlockBreakEventHandler; @@ -130,6 +131,10 @@ public class CommonProxy { Utils.registerEvent(new HandlerTooltip_EIO()); // Handles Custom Tooltips for GC Utils.registerEvent(new HandlerTooltip_GC()); + + if (CORE.DEVENV) { + Utils.registerEvent(new StopAnnoyingFuckingAchievements()); + } // Register Chunkloader ForgeChunkManager.setForcedChunkLoadingCallback(GTplusplus.instance, ChunkManager.getInstance()); diff --git a/src/Java/gtPlusPlus/core/handler/StopAnnoyingFuckingAchievements.java b/src/Java/gtPlusPlus/core/handler/StopAnnoyingFuckingAchievements.java new file mode 100644 index 0000000000..b10e67aeaf --- /dev/null +++ b/src/Java/gtPlusPlus/core/handler/StopAnnoyingFuckingAchievements.java @@ -0,0 +1,24 @@ +package gtPlusPlus.core.handler; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import net.minecraft.stats.AchievementList; +import net.minecraftforge.event.entity.player.AchievementEvent; + +public class StopAnnoyingFuckingAchievements { + + /** + * Stops me getting fireworks every fucking time I open my inventory upon first loading a dev client. + * @param event + */ + @SubscribeEvent + public void FUCK_OFF(AchievementEvent event) { + if (event.achievement.equals(AchievementList.openInventory)) { + if (MathUtils.randInt(0, 10) >= 9) + PlayerUtils.messagePlayer(event.entityPlayer, "Bang! Nah, Just joking, there's no fireworks. :)"); + event.setCanceled(true); + } + } + +} diff --git a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java index 6fa58804dd..2522ba56da 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java @@ -1042,4 +1042,21 @@ public class ItemUtils { return aDisplay; } + public static String getUnlocalizedItemName(ItemStack aStack) { + if (aStack == null) { + return "ERROR.Empty.Stack"; + } + String aDisplay = null; + try { + aDisplay = (aStack.getUnlocalizedName()).trim(); + + } catch (Throwable t) { + aDisplay = aStack.getItem().getUnlocalizedName(); + } + if (aDisplay == null || aDisplay.length() <= 0) { + aDisplay = aStack.getItem().getUnlocalizedNameInefficiently(aStack); + } + return aDisplay; + } + } diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Achievements.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Achievements.java new file mode 100644 index 0000000000..2b9729a8a3 --- /dev/null +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Achievements.java @@ -0,0 +1,1896 @@ +package gtPlusPlus.preloader.asm.transformers; + +import static org.objectweb.asm.Opcodes.*; + +import org.apache.logging.log4j.Level; +import org.objectweb.asm.AnnotationVisitor; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.Label; +import org.objectweb.asm.MethodVisitor; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.relauncher.FMLRelaunchLog; +import net.minecraftforge.common.MinecraftForge; + +public class ClassTransformer_GT_Achievements { + + private final boolean isValid; + private final ClassReader reader; + private final ClassWriter writer; + private static boolean mDidRemoveAssLineRecipeAdder = false; + + public ClassTransformer_GT_Achievements(byte[] basicClass) { + + ClassReader aTempReader = null; + ClassWriter aTempWriter = null; + + aTempReader = new ClassReader(basicClass); + aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES); + + aTempReader.accept(new MethodAdaptor(aTempWriter), 0); + + if (mDidRemoveAssLineRecipeAdder) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Patching GT .09"); + injectMethod(aTempWriter); + patchOnItemPickup09(aTempWriter); + } + else { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Patching GT .08"); + patchOnItemPickup08(aTempWriter); + } + + if (aTempReader != null && aTempWriter != null) { + isValid = true; + } + else { + isValid = false; + } + + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Valid? "+isValid+"."); + reader = aTempReader; + writer = aTempWriter; + } + + public boolean isValidTransformer() { + return isValid; + } + + public ClassReader getReader() { + return reader; + } + + public ClassWriter getWriter() { + return writer; + } + + public boolean injectMethod(ClassWriter cw) { + MethodVisitor mv; + boolean didInject = false; + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Injecting " + "registerAssAchievement" + "."); + + /** + * Inject new, safer code + */ + + + /*mv = cw.visitMethod(ACC_PUBLIC, "registerAssAchievement", "(Lgregtech/api/util/GT_Recipe;)Lnet/minecraft/stats/Achievement;", null, null); + mv.visitCode(); + Label l0 = new Label(); + Label l1 = new Label(); + Label l2 = new Label(); + mv.visitTryCatchBlock(l0, l1, l2, "java/lang/Throwable"); + Label l3 = new Label(); + mv.visitLabel(l3); + mv.visitLineNumber(291, l3); + mv.visitVarInsn(ALOAD, 1); + Label l4 = new Label(); + mv.visitJumpInsn(IFNONNULL, l4); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(292, l5); + mv.visitLdcInsn("Someone tried to register an achievement for an invalid recipe. Please report this to Alkalus."); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/api/objects/Logger", "INFO", "(Ljava/lang/String;)V", false); + Label l6 = new Label(); + mv.visitLabel(l6); + mv.visitLineNumber(293, l6); + mv.visitInsn(ACONST_NULL); + mv.visitInsn(ARETURN); + mv.visitLabel(l4); + mv.visitLineNumber(295, l4); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 1); + mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/util/GT_Recipe", "getOutput", "(I)Lnet/minecraft/item/ItemStack;", false); + Label l7 = new Label(); + mv.visitJumpInsn(IFNONNULL, l7); + Label l8 = new Label(); + mv.visitLabel(l8); + mv.visitLineNumber(296, l8); + mv.visitLdcInsn("Someone tried to register an achievement for a recipe with null output. Please report this to Alkalus."); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/api/objects/Logger", "INFO", "(Ljava/lang/String;)V", false); + Label l9 = new Label(); + mv.visitLabel(l9); + mv.visitLineNumber(297, l9); + mv.visitInsn(ACONST_NULL); + mv.visitInsn(ARETURN); + mv.visitLabel(l7); + mv.visitLineNumber(299, l7); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 1); + mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/util/GT_Recipe", "getOutput", "(I)Lnet/minecraft/item/ItemStack;", false); + mv.visitVarInsn(ASTORE, 3); + mv.visitLabel(l0); + mv.visitLineNumber(301, l0); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitVarInsn(ASTORE, 2); + mv.visitLabel(l1); + mv.visitLineNumber(302, l1); + Label l10 = new Label(); + mv.visitJumpInsn(GOTO, l10); + mv.visitLabel(l2); + mv.visitLineNumber(303, l2); + mv.visitFrame(F_FULL, 4, new Object[] {"gregtech/loaders/misc/GT_Achievements", "gregtech/api/util/GT_Recipe", TOP, "net/minecraft/item/ItemStack"}, 1, new Object[] {"java/lang/Throwable"}); + mv.visitVarInsn(ASTORE, 4); + Label l11 = new Label(); + mv.visitLabel(l11); + mv.visitLineNumber(304, l11); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/minecraft/ItemUtils", "getUnlocalizedItemName", "(Lnet/minecraft/item/ItemStack;)Ljava/lang/String;", false); + mv.visitVarInsn(ASTORE, 2); + mv.visitLabel(l10); + mv.visitLineNumber(306, l10); + mv.visitFrame(F_FULL, 4, new Object[] {"gregtech/loaders/misc/GT_Achievements", "gregtech/api/util/GT_Recipe", "java/lang/String", "net/minecraft/item/ItemStack"}, 0, new Object[] {}); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/loaders/misc/GT_Achievements", "achievementList", "Ljava/util/concurrent/ConcurrentHashMap;"); + mv.visitVarInsn(ALOAD, 2); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/concurrent/ConcurrentHashMap", "get", "(Ljava/lang/Object;)Ljava/lang/Object;", false); + Label l12 = new Label(); + mv.visitJumpInsn(IFNONNULL, l12); + Label l13 = new Label(); + mv.visitLabel(l13); + mv.visitLineNumber(307, l13); + mv.visitFieldInsn(GETSTATIC, "gregtech/loaders/misc/GT_Achievements", "assReg", "I"); + mv.visitInsn(ICONST_1); + mv.visitInsn(IADD); + mv.visitFieldInsn(PUTSTATIC, "gregtech/loaders/misc/GT_Achievements", "assReg", "I"); + Label l14 = new Label(); + mv.visitLabel(l14); + mv.visitLineNumber(308, l14); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitIntInsn(BIPUSH, 11); + mv.visitFieldInsn(GETSTATIC, "gregtech/loaders/misc/GT_Achievements", "assReg", "I"); + mv.visitInsn(ICONST_5); + mv.visitInsn(IREM); + mv.visitInsn(IADD); + mv.visitInsn(INEG); + mv.visitFieldInsn(GETSTATIC, "gregtech/loaders/misc/GT_Achievements", "assReg", "I"); + mv.visitInsn(ICONST_5); + mv.visitInsn(IDIV); + mv.visitIntInsn(BIPUSH, 8); + mv.visitInsn(ISUB); + mv.visitVarInsn(ALOAD, 1); + mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/util/GT_Recipe", "getOutput", "(I)Lnet/minecraft/item/ItemStack;", false); + mv.visitFieldInsn(GETSTATIC, "net/minecraft/stats/AchievementList", "openInventory", "Lnet/minecraft/stats/Achievement;"); + mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "registerAchievement", "(Ljava/lang/String;IILnet/minecraft/item/ItemStack;Lnet/minecraft/stats/Achievement;Z)Lnet/minecraft/stats/Achievement;", false); + mv.visitInsn(ARETURN); + mv.visitLabel(l12); + mv.visitLineNumber(310, l12); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitInsn(ACONST_NULL); + mv.visitInsn(ARETURN); + Label l15 = new Label(); + mv.visitLabel(l15); + mv.visitLocalVariable("this", "Lgregtech/loaders/misc/GT_Achievements;", null, l3, l15, 0); + mv.visitLocalVariable("recipe", "Lgregtech/api/util/GT_Recipe;", null, l3, l15, 1); + mv.visitLocalVariable("aSafeUnlocalName", "Ljava/lang/String;", null, l1, l2, 2); + mv.visitLocalVariable("aSafeUnlocalName", "Ljava/lang/String;", null, l10, l15, 2); + mv.visitLocalVariable("aStack", "Lnet/minecraft/item/ItemStack;", null, l0, l15, 3); + mv.visitLocalVariable("t", "Ljava/lang/Throwable;", null, l11, l10, 4); + mv.visitMaxs(7, 5); + mv.visitEnd();*/ + + //Lets just static call my replacement function + mv = cw.visitMethod(ACC_PUBLIC, "registerAssAchievement", "(Lgregtech/api/util/GT_Recipe;)Lnet/minecraft/stats/Achievement;", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(291, l0); + mv.visitVarInsn(ALOAD, 1); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements", "registerAssAchievement", "(Lgregtech/api/util/GT_Recipe;)Lnet/minecraft/stats/Achievement;", false); + mv.visitInsn(ARETURN); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLocalVariable("this", "Lgregtech/loaders/misc/GT_Achievements;", null, l0, l1, 0); + mv.visitLocalVariable("recipe", "Lgregtech/api/util/GT_Recipe;", null, l0, l1, 1); + mv.visitMaxs(1, 2); + mv.visitEnd(); + + didInject = true; + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Method injection complete."); + return didInject; + } + + + + public boolean patchOnItemPickup08(ClassWriter cw) { + MethodVisitor mv; + boolean didInject = false; + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Injecting " + "onItemPickup" + "."); + + AnnotationVisitor av0; + mv = cw.visitMethod(ACC_PUBLIC, "onItemPickup", "(Lnet/minecraftforge/event/entity/player/EntityItemPickupEvent;)V", null, null); + av0 = mv.visitAnnotation("Lcpw/mods/fml/common/eventhandler/SubscribeEvent;", true); + av0.visitEnd(); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(418, l0); + mv.visitVarInsn(ALOAD, 1); + mv.visitFieldInsn(GETFIELD, "net/minecraftforge/event/entity/player/EntityItemPickupEvent", "entityPlayer", "Lnet/minecraft/entity/player/EntityPlayer;"); + mv.visitVarInsn(ASTORE, 2); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLineNumber(419, l1); + mv.visitVarInsn(ALOAD, 1); + mv.visitFieldInsn(GETFIELD, "net/minecraftforge/event/entity/player/EntityItemPickupEvent", "item", "Lnet/minecraft/entity/item/EntityItem;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/item/EntityItem", "getEntityItem", "()Lnet/minecraft/item/ItemStack;", false); + mv.visitVarInsn(ASTORE, 3); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLineNumber(420, l2); + mv.visitVarInsn(ALOAD, 2); + Label l3 = new Label(); + mv.visitJumpInsn(IFNULL, l3); + mv.visitVarInsn(ALOAD, 3); + Label l4 = new Label(); + mv.visitJumpInsn(IFNONNULL, l4); + mv.visitLabel(l3); + mv.visitLineNumber(421, l3); + mv.visitFrame(F_APPEND,2, new Object[] {"net/minecraft/entity/player/EntityPlayer", "net/minecraft/item/ItemStack"}, 0, null); + mv.visitInsn(RETURN); + mv.visitLabel(l4); + mv.visitLineNumber(424, l4); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKESTATIC, "gregtech/api/util/GT_OreDictUnificator", "getItemData", "(Lnet/minecraft/item/ItemStack;)Lgregtech/api/objects/ItemData;", false); + mv.visitVarInsn(ASTORE, 4); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(425, l5); + mv.visitVarInsn(ALOAD, 4); + Label l6 = new Label(); + mv.visitJumpInsn(IFNULL, l6); + Label l7 = new Label(); + mv.visitLabel(l7); + mv.visitLineNumber(426, l7); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "dust", "Lgregtech/api/enums/OrePrefixes;"); + Label l8 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l8); + Label l9 = new Label(); + mv.visitLabel(l9); + mv.visitLineNumber(427, l9); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mMaterial", "Lgregtech/api/objects/MaterialStack;"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/Materials", "Lutetium", "Lgregtech/api/enums/Materials;"); + Label l10 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l10); + Label l11 = new Label(); + mv.visitLabel(l11); + mv.visitLineNumber(428, l11); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("newmetal"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + mv.visitLabel(l10); + mv.visitLineNumber(430, l10); + mv.visitFrame(F_APPEND,1, new Object[] {"gregtech/api/objects/ItemData"}, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("cleandust"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l12 = new Label(); + mv.visitLabel(l12); + mv.visitLineNumber(431, l12); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l8); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "ore", "Lgregtech/api/enums/OrePrefixes;"); + Label l13 = new Label(); + mv.visitJumpInsn(IF_ACMPEQ, l13); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "oreBlackgranite", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitJumpInsn(IF_ACMPEQ, l13); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "oreEndstone", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitJumpInsn(IF_ACMPEQ, l13); + Label l14 = new Label(); + mv.visitLabel(l14); + mv.visitLineNumber(432, l14); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "oreNetherrack", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitJumpInsn(IF_ACMPEQ, l13); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "oreRedgranite", "Lgregtech/api/enums/OrePrefixes;"); + Label l15 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l15); + mv.visitLabel(l13); + mv.visitLineNumber(433, l13); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitInsn(ICONST_0); + mv.visitVarInsn(ISTORE, 5); + Label l16 = new Label(); + mv.visitLabel(l16); + Label l17 = new Label(); + mv.visitJumpInsn(GOTO, l17); + Label l18 = new Label(); + mv.visitLabel(l18); + mv.visitLineNumber(434, l18); + mv.visitFrame(F_APPEND,1, new Object[] {INTEGER}, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/objects/ItemData", "getAllMaterialStacks", "()Ljava/util/ArrayList;", false); + mv.visitVarInsn(ILOAD, 5); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/ArrayList", "get", "(I)Ljava/lang/Object;", false); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/objects/MaterialStack"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/enums/Materials", "name", "()Ljava/lang/String;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l19 = new Label(); + mv.visitLabel(l19); + mv.visitLineNumber(435, l19); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/objects/ItemData", "getAllMaterialStacks", "()Ljava/util/ArrayList;", false); + mv.visitVarInsn(ILOAD, 5); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/ArrayList", "get", "(I)Ljava/lang/Object;", false); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/objects/MaterialStack"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/Materials", "AnyIron", "Lgregtech/api/enums/Materials;"); + Label l20 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l20); + Label l21 = new Label(); + mv.visitLabel(l21); + mv.visitLineNumber(436, l21); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("iron"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + mv.visitLabel(l20); + mv.visitLineNumber(433, l20); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitIincInsn(5, 1); + mv.visitLabel(l17); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ILOAD, 5); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/objects/ItemData", "getAllMaterialStacks", "()Ljava/util/ArrayList;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/ArrayList", "size", "()I", false); + mv.visitJumpInsn(IF_ICMPLT, l18); + Label l22 = new Label(); + mv.visitLabel(l22); + mv.visitLineNumber(439, l22); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l15); + mv.visitFrame(F_CHOP,1, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "crushed", "Lgregtech/api/enums/OrePrefixes;"); + Label l23 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l23); + Label l24 = new Label(); + mv.visitLabel(l24); + mv.visitLineNumber(440, l24); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("crushed"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l25 = new Label(); + mv.visitLabel(l25); + mv.visitLineNumber(441, l25); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l23); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "crushedPurified", "Lgregtech/api/enums/OrePrefixes;"); + Label l26 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l26); + Label l27 = new Label(); + mv.visitLabel(l27); + mv.visitLineNumber(442, l27); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("washing"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l28 = new Label(); + mv.visitLabel(l28); + mv.visitLineNumber(443, l28); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l26); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "crushedCentrifuged", "Lgregtech/api/enums/OrePrefixes;"); + Label l29 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l29); + Label l30 = new Label(); + mv.visitLabel(l30); + mv.visitLineNumber(444, l30); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("spinit"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l31 = new Label(); + mv.visitLabel(l31); + mv.visitLineNumber(445, l31); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l29); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mMaterial", "Lgregtech/api/objects/MaterialStack;"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/Materials", "Steel", "Lgregtech/api/enums/Materials;"); + Label l32 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l32); + Label l33 = new Label(); + mv.visitLabel(l33); + mv.visitLineNumber(446, l33); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "ingot", "Lgregtech/api/enums/OrePrefixes;"); + Label l34 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l34); + mv.visitVarInsn(ALOAD, 3); + mv.visitFieldInsn(GETFIELD, "net/minecraft/item/ItemStack", "stackSize", "I"); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getMaxStackSize", "()I", false); + mv.visitJumpInsn(IF_ICMPNE, l34); + Label l35 = new Label(); + mv.visitLabel(l35); + mv.visitLineNumber(447, l35); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("steel"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l36 = new Label(); + mv.visitLabel(l36); + mv.visitLineNumber(448, l36); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l34); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "nugget", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitJumpInsn(IF_ACMPNE, l6); + mv.visitLdcInsn("Thaumcraft"); + mv.visitMethodInsn(INVOKESTATIC, "cpw/mods/fml/common/Loader", "isModLoaded", "(Ljava/lang/String;)Z", false); + mv.visitJumpInsn(IFEQ, l6); + Label l37 = new Label(); + mv.visitLabel(l37); + mv.visitLineNumber(449, l37); + mv.visitVarInsn(ALOAD, 2); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/player/EntityPlayer", "getDisplayName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("GT_IRON_TO_STEEL"); + mv.visitMethodInsn(INVOKESTATIC, "thaumcraft/api/ThaumcraftApiHelper", "isResearchComplete", "(Ljava/lang/String;Ljava/lang/String;)Z", false); + mv.visitJumpInsn(IFEQ, l6); + Label l38 = new Label(); + mv.visitLabel(l38); + mv.visitLineNumber(450, l38); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("steel"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l39 = new Label(); + mv.visitLabel(l39); + mv.visitLineNumber(453, l39); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l32); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "circuit", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitJumpInsn(IF_ACMPNE, l6); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mMaterial", "Lgregtech/api/objects/MaterialStack;"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/Materials", "Advanced", "Lgregtech/api/enums/Materials;"); + mv.visitJumpInsn(IF_ACMPNE, l6); + Label l40 = new Label(); + mv.visitLabel(l40); + mv.visitLineNumber(454, l40); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("stepforward"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + mv.visitLabel(l6); + mv.visitLineNumber(457, l6); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem."); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "startsWith", "(Ljava/lang/String;)Z", false); + Label l41 = new Label(); + mv.visitJumpInsn(IFEQ, l41); + Label l42 = new Label(); + mv.visitLabel(l42); + mv.visitLineNumber(458, l42); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32500"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l43 = new Label(); + mv.visitJumpInsn(IFEQ, l43); + Label l44 = new Label(); + mv.visitLabel(l44); + mv.visitLineNumber(459, l44); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestlead"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l45 = new Label(); + mv.visitLabel(l45); + mv.visitLineNumber(460, l45); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l43); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32501"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l46 = new Label(); + mv.visitJumpInsn(IFEQ, l46); + Label l47 = new Label(); + mv.visitLabel(l47); + mv.visitLineNumber(461, l47); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestsilver"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l48 = new Label(); + mv.visitLabel(l48); + mv.visitLineNumber(462, l48); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l46); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32503"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l49 = new Label(); + mv.visitJumpInsn(IFEQ, l49); + Label l50 = new Label(); + mv.visitLabel(l50); + mv.visitLineNumber(463, l50); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestiron"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l51 = new Label(); + mv.visitLabel(l51); + mv.visitLineNumber(464, l51); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l49); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32504"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l52 = new Label(); + mv.visitJumpInsn(IFEQ, l52); + Label l53 = new Label(); + mv.visitLabel(l53); + mv.visitLineNumber(465, l53); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestgold"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l54 = new Label(); + mv.visitLabel(l54); + mv.visitLineNumber(466, l54); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l52); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32530"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l55 = new Label(); + mv.visitJumpInsn(IFEQ, l55); + Label l56 = new Label(); + mv.visitLabel(l56); + mv.visitLineNumber(467, l56); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestcopper"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l57 = new Label(); + mv.visitLabel(l57); + mv.visitLineNumber(468, l57); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l55); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32540"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l58 = new Label(); + mv.visitJumpInsn(IFEQ, l58); + Label l59 = new Label(); + mv.visitLabel(l59); + mv.visitLineNumber(469, l59); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havesttin"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l60 = new Label(); + mv.visitLabel(l60); + mv.visitLineNumber(470, l60); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l58); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32510"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l61 = new Label(); + mv.visitJumpInsn(IFEQ, l61); + Label l62 = new Label(); + mv.visitLabel(l62); + mv.visitLineNumber(471, l62); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestoil"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l63 = new Label(); + mv.visitLabel(l63); + mv.visitLineNumber(472, l63); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l61); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32511"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l64 = new Label(); + mv.visitJumpInsn(IFEQ, l64); + Label l65 = new Label(); + mv.visitLabel(l65); + mv.visitLineNumber(473, l65); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestemeralds"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l66 = new Label(); + mv.visitLabel(l66); + mv.visitLineNumber(474, l66); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l64); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32706"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l67 = new Label(); + mv.visitJumpInsn(IFEQ, l67); + Label l68 = new Label(); + mv.visitLabel(l68); + mv.visitLineNumber(475, l68); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("energyflow"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l69 = new Label(); + mv.visitLabel(l69); + mv.visitLineNumber(476, l69); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l67); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32702"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l70 = new Label(); + mv.visitJumpInsn(IFEQ, l70); + Label l71 = new Label(); + mv.visitLabel(l71); + mv.visitLineNumber(477, l71); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("bettercircuits"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l72 = new Label(); + mv.visitLabel(l72); + mv.visitLineNumber(478, l72); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l70); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32707"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l73 = new Label(); + mv.visitJumpInsn(IFEQ, l73); + Label l74 = new Label(); + mv.visitLabel(l74); + mv.visitLineNumber(479, l74); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("datasaving"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l75 = new Label(); + mv.visitLabel(l75); + mv.visitLineNumber(480, l75); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l73); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32597"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l76 = new Label(); + mv.visitJumpInsn(IFEQ, l76); + Label l77 = new Label(); + mv.visitLabel(l77); + mv.visitLineNumber(481, l77); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("orbs"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l78 = new Label(); + mv.visitLabel(l78); + mv.visitLineNumber(482, l78); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l76); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32599"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l79 = new Label(); + mv.visitJumpInsn(IFEQ, l79); + Label l80 = new Label(); + mv.visitLabel(l80); + mv.visitLineNumber(483, l80); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("thatspower"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l81 = new Label(); + mv.visitLabel(l81); + mv.visitLineNumber(484, l81); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l79); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32598"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l82 = new Label(); + mv.visitJumpInsn(IFEQ, l82); + Label l83 = new Label(); + mv.visitLabel(l83); + mv.visitLineNumber(485, l83); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("luck"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l84 = new Label(); + mv.visitLabel(l84); + mv.visitLineNumber(486, l84); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l82); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32749"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l85 = new Label(); + mv.visitJumpInsn(IFEQ, l85); + Label l86 = new Label(); + mv.visitLabel(l86); + mv.visitLineNumber(487, l86); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("closeit"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l87 = new Label(); + mv.visitLabel(l87); + mv.visitLineNumber(488, l87); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l85); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32730"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l88 = new Label(); + mv.visitJumpInsn(IFEQ, l88); + Label l89 = new Label(); + mv.visitLabel(l89); + mv.visitLineNumber(489, l89); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("manipulation"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l90 = new Label(); + mv.visitLabel(l90); + mv.visitLineNumber(490, l90); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l88); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32729"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l91 = new Label(); + mv.visitJumpInsn(IFEQ, l91); + Label l92 = new Label(); + mv.visitLabel(l92); + mv.visitLineNumber(491, l92); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("filterregulate"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l93 = new Label(); + mv.visitLabel(l93); + mv.visitLineNumber(492, l93); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l91); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32605"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l94 = new Label(); + mv.visitJumpInsn(IFEQ, l94); + Label l95 = new Label(); + mv.visitLabel(l95); + mv.visitLineNumber(493, l95); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("whatnow"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l96 = new Label(); + mv.visitLabel(l96); + mv.visitLineNumber(494, l96); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l94); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.Thoriumcell"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + mv.visitJumpInsn(IFEQ, l41); + Label l97 = new Label(); + mv.visitLabel(l97); + mv.visitLineNumber(495, l97); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("newfuel"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + mv.visitLabel(l41); + mv.visitLineNumber(498, l41); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitInsn(RETURN); + Label l98 = new Label(); + mv.visitLabel(l98); + mv.visitLocalVariable("this", "Lgregtech/loaders/misc/GT_Achievements;", null, l0, l98, 0); + mv.visitLocalVariable("event", "Lnet/minecraftforge/event/entity/player/EntityItemPickupEvent;", null, l0, l98, 1); + mv.visitLocalVariable("player", "Lnet/minecraft/entity/player/EntityPlayer;", null, l1, l98, 2); + mv.visitLocalVariable("stack", "Lnet/minecraft/item/ItemStack;", null, l2, l98, 3); + mv.visitLocalVariable("data", "Lgregtech/api/objects/ItemData;", null, l5, l98, 4); + mv.visitLocalVariable("i", "I", null, l16, l22, 5); + mv.visitMaxs(4, 6); + mv.visitEnd(); + + + didInject = true; + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Method injection complete."); + return didInject; + } + + + public boolean patchOnItemPickup09(ClassWriter cw) { + MethodVisitor mv; + boolean didInject = false; + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Injecting " + "onItemPickup" + "."); + + /** + * Inject new, safer code + */ + AnnotationVisitor av0; + mv = cw.visitMethod(ACC_PUBLIC, "onItemPickup", "(Lnet/minecraftforge/event/entity/player/EntityItemPickupEvent;)V", null, null); + av0 = mv.visitAnnotation("Lcpw/mods/fml/common/eventhandler/SubscribeEvent;", true); + av0.visitEnd(); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(546, l0); + mv.visitVarInsn(ALOAD, 1); + mv.visitFieldInsn(GETFIELD, "net/minecraftforge/event/entity/player/EntityItemPickupEvent", "entityPlayer", "Lnet/minecraft/entity/player/EntityPlayer;"); + mv.visitVarInsn(ASTORE, 2); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLineNumber(547, l1); + mv.visitVarInsn(ALOAD, 1); + mv.visitFieldInsn(GETFIELD, "net/minecraftforge/event/entity/player/EntityItemPickupEvent", "item", "Lnet/minecraft/entity/item/EntityItem;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/item/EntityItem", "getEntityItem", "()Lnet/minecraft/item/ItemStack;", false); + mv.visitVarInsn(ASTORE, 3); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLineNumber(548, l2); + mv.visitVarInsn(ALOAD, 2); + Label l3 = new Label(); + mv.visitJumpInsn(IFNULL, l3); + mv.visitVarInsn(ALOAD, 3); + Label l4 = new Label(); + mv.visitJumpInsn(IFNONNULL, l4); + mv.visitLabel(l3); + mv.visitLineNumber(549, l3); + mv.visitFrame(F_APPEND,2, new Object[] {"net/minecraft/entity/player/EntityPlayer", "net/minecraft/item/ItemStack"}, 0, null); + mv.visitInsn(RETURN); + mv.visitLabel(l4); + mv.visitLineNumber(551, l4); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKESTATIC, "gregtech/api/util/GT_OreDictUnificator", "getItemData", "(Lnet/minecraft/item/ItemStack;)Lgregtech/api/objects/ItemData;", false); + mv.visitVarInsn(ASTORE, 4); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(552, l5); + mv.visitVarInsn(ALOAD, 4); + Label l6 = new Label(); + mv.visitJumpInsn(IFNULL, l6); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitJumpInsn(IFNULL, l6); + Label l7 = new Label(); + mv.visitLabel(l7); + mv.visitLineNumber(553, l7); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "dust", "Lgregtech/api/enums/OrePrefixes;"); + Label l8 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l8); + Label l9 = new Label(); + mv.visitLabel(l9); + mv.visitLineNumber(554, l9); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mMaterial", "Lgregtech/api/objects/MaterialStack;"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/Materials", "Lutetium", "Lgregtech/api/enums/Materials;"); + Label l10 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l10); + Label l11 = new Label(); + mv.visitLabel(l11); + mv.visitLineNumber(555, l11); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("newmetal"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + mv.visitLabel(l10); + mv.visitLineNumber(557, l10); + mv.visitFrame(F_APPEND,1, new Object[] {"gregtech/api/objects/ItemData"}, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mMaterial", "Lgregtech/api/objects/MaterialStack;"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/Materials", "Gunpowder", "Lgregtech/api/enums/Materials;"); + mv.visitJumpInsn(IF_ACMPEQ, l6); + Label l12 = new Label(); + mv.visitLabel(l12); + mv.visitLineNumber(558, l12); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("cleandust"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l13 = new Label(); + mv.visitLabel(l13); + mv.visitLineNumber(560, l13); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l8); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/enums/OrePrefixes", "name", "()Ljava/lang/String;", false); + mv.visitLdcInsn("ore"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "startsWith", "(Ljava/lang/String;)Z", false); + Label l14 = new Label(); + mv.visitJumpInsn(IFEQ, l14); + Label l15 = new Label(); + mv.visitLabel(l15); + mv.visitLineNumber(561, l15); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/objects/ItemData", "getAllMaterialStacks", "()Ljava/util/ArrayList;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/ArrayList", "size", "()I", false); + mv.visitVarInsn(ISTORE, 5); + Label l16 = new Label(); + mv.visitLabel(l16); + mv.visitLineNumber(562, l16); + mv.visitInsn(ICONST_0); + mv.visitVarInsn(ISTORE, 6); + Label l17 = new Label(); + mv.visitLabel(l17); + Label l18 = new Label(); + mv.visitJumpInsn(GOTO, l18); + Label l19 = new Label(); + mv.visitLabel(l19); + mv.visitLineNumber(563, l19); + mv.visitFrame(F_APPEND,2, new Object[] {INTEGER, INTEGER}, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/objects/ItemData", "getAllMaterialStacks", "()Ljava/util/ArrayList;", false); + mv.visitVarInsn(ILOAD, 6); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/ArrayList", "get", "(I)Ljava/lang/Object;", false); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/objects/MaterialStack"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/enums/Materials", "mName", "Ljava/lang/String;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l20 = new Label(); + mv.visitLabel(l20); + mv.visitLineNumber(564, l20); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/objects/ItemData", "getAllMaterialStacks", "()Ljava/util/ArrayList;", false); + mv.visitVarInsn(ILOAD, 6); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/ArrayList", "get", "(I)Ljava/lang/Object;", false); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/objects/MaterialStack"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/Materials", "Iron", "Lgregtech/api/enums/Materials;"); + Label l21 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l21); + Label l22 = new Label(); + mv.visitLabel(l22); + mv.visitLineNumber(565, l22); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("iron"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + mv.visitLabel(l21); + mv.visitLineNumber(567, l21); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/objects/ItemData", "getAllMaterialStacks", "()Ljava/util/ArrayList;", false); + mv.visitVarInsn(ILOAD, 6); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/ArrayList", "get", "(I)Ljava/lang/Object;", false); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/objects/MaterialStack"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/Materials", "Copper", "Lgregtech/api/enums/Materials;"); + Label l23 = new Label(); + mv.visitJumpInsn(IF_ACMPEQ, l23); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/objects/ItemData", "getAllMaterialStacks", "()Ljava/util/ArrayList;", false); + mv.visitVarInsn(ILOAD, 6); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/ArrayList", "get", "(I)Ljava/lang/Object;", false); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/objects/MaterialStack"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/Materials", "Tin", "Lgregtech/api/enums/Materials;"); + Label l24 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l24); + mv.visitLabel(l23); + mv.visitLineNumber(568, l23); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 1); + mv.visitFieldInsn(GETFIELD, "net/minecraftforge/event/entity/player/EntityItemPickupEvent", "entityPlayer", "Lnet/minecraft/entity/player/EntityPlayer;"); + mv.visitLdcInsn("mineOre"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + mv.visitLabel(l24); + mv.visitLineNumber(562, l24); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitIincInsn(6, 1); + mv.visitLabel(l18); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ILOAD, 6); + mv.visitVarInsn(ILOAD, 5); + mv.visitJumpInsn(IF_ICMPLT, l19); + Label l25 = new Label(); + mv.visitLabel(l25); + mv.visitLineNumber(572, l25); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l14); + mv.visitFrame(F_CHOP,2, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "crushed", "Lgregtech/api/enums/OrePrefixes;"); + Label l26 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l26); + Label l27 = new Label(); + mv.visitLabel(l27); + mv.visitLineNumber(573, l27); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("crushed"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l28 = new Label(); + mv.visitLabel(l28); + mv.visitLineNumber(574, l28); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l26); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "crushedPurified", "Lgregtech/api/enums/OrePrefixes;"); + Label l29 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l29); + Label l30 = new Label(); + mv.visitLabel(l30); + mv.visitLineNumber(575, l30); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("washing"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l31 = new Label(); + mv.visitLabel(l31); + mv.visitLineNumber(576, l31); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l29); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "crushedCentrifuged", "Lgregtech/api/enums/OrePrefixes;"); + Label l32 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l32); + Label l33 = new Label(); + mv.visitLabel(l33); + mv.visitLineNumber(577, l33); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("spinit"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l34 = new Label(); + mv.visitLabel(l34); + mv.visitLineNumber(578, l34); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l32); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mMaterial", "Lgregtech/api/objects/MaterialStack;"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/Materials", "Steel", "Lgregtech/api/enums/Materials;"); + mv.visitJumpInsn(IF_ACMPNE, l6); + Label l35 = new Label(); + mv.visitLabel(l35); + mv.visitLineNumber(579, l35); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "ingot", "Lgregtech/api/enums/OrePrefixes;"); + Label l36 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l36); + mv.visitVarInsn(ALOAD, 3); + mv.visitFieldInsn(GETFIELD, "net/minecraft/item/ItemStack", "stackSize", "I"); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getMaxStackSize", "()I", false); + mv.visitJumpInsn(IF_ICMPNE, l36); + Label l37 = new Label(); + mv.visitLabel(l37); + mv.visitLineNumber(580, l37); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("steel"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l38 = new Label(); + mv.visitLabel(l38); + mv.visitLineNumber(581, l38); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l36); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "nugget", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitJumpInsn(IF_ACMPNE, l6); + mv.visitLdcInsn("Thaumcraft"); + mv.visitMethodInsn(INVOKESTATIC, "cpw/mods/fml/common/Loader", "isModLoaded", "(Ljava/lang/String;)Z", false); + mv.visitJumpInsn(IFEQ, l6); + mv.visitVarInsn(ALOAD, 2); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/player/EntityPlayer", "getDisplayName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("GT_IRON_TO_STEEL"); + mv.visitMethodInsn(INVOKESTATIC, "thaumcraft/api/ThaumcraftApiHelper", "isResearchComplete", "(Ljava/lang/String;Ljava/lang/String;)Z", false); + mv.visitJumpInsn(IFEQ, l6); + Label l39 = new Label(); + mv.visitLabel(l39); + mv.visitLineNumber(582, l39); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("steel"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + mv.visitLabel(l6); + mv.visitLineNumber(589, l6); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem."); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "startsWith", "(Ljava/lang/String;)Z", false); + Label l40 = new Label(); + mv.visitJumpInsn(IFEQ, l40); + Label l41 = new Label(); + mv.visitLabel(l41); + mv.visitLineNumber(590, l41); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32500"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l42 = new Label(); + mv.visitJumpInsn(IFEQ, l42); + Label l43 = new Label(); + mv.visitLabel(l43); + mv.visitLineNumber(591, l43); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestlead"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l44 = new Label(); + mv.visitLabel(l44); + mv.visitLineNumber(592, l44); + Label l45 = new Label(); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l42); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32501"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l46 = new Label(); + mv.visitJumpInsn(IFEQ, l46); + Label l47 = new Label(); + mv.visitLabel(l47); + mv.visitLineNumber(593, l47); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestsilver"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l48 = new Label(); + mv.visitLabel(l48); + mv.visitLineNumber(594, l48); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l46); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32503"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l49 = new Label(); + mv.visitJumpInsn(IFEQ, l49); + Label l50 = new Label(); + mv.visitLabel(l50); + mv.visitLineNumber(595, l50); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestiron"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l51 = new Label(); + mv.visitLabel(l51); + mv.visitLineNumber(596, l51); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l49); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32504"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l52 = new Label(); + mv.visitJumpInsn(IFEQ, l52); + Label l53 = new Label(); + mv.visitLabel(l53); + mv.visitLineNumber(597, l53); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestgold"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l54 = new Label(); + mv.visitLabel(l54); + mv.visitLineNumber(598, l54); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l52); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32530"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l55 = new Label(); + mv.visitJumpInsn(IFEQ, l55); + Label l56 = new Label(); + mv.visitLabel(l56); + mv.visitLineNumber(599, l56); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestcopper"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l57 = new Label(); + mv.visitLabel(l57); + mv.visitLineNumber(600, l57); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l55); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32540"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l58 = new Label(); + mv.visitJumpInsn(IFEQ, l58); + Label l59 = new Label(); + mv.visitLabel(l59); + mv.visitLineNumber(601, l59); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havesttin"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l60 = new Label(); + mv.visitLabel(l60); + mv.visitLineNumber(602, l60); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l58); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32510"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l61 = new Label(); + mv.visitJumpInsn(IFEQ, l61); + Label l62 = new Label(); + mv.visitLabel(l62); + mv.visitLineNumber(603, l62); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestoil"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l63 = new Label(); + mv.visitLabel(l63); + mv.visitLineNumber(604, l63); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l61); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32511"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l64 = new Label(); + mv.visitJumpInsn(IFEQ, l64); + Label l65 = new Label(); + mv.visitLabel(l65); + mv.visitLineNumber(605, l65); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestemeralds"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l66 = new Label(); + mv.visitLabel(l66); + mv.visitLineNumber(606, l66); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l64); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.03.32082"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l67 = new Label(); + mv.visitJumpInsn(IFEQ, l67); + Label l68 = new Label(); + mv.visitLabel(l68); + mv.visitLineNumber(607, l68); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("energyflow"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l69 = new Label(); + mv.visitLabel(l69); + mv.visitLineNumber(608, l69); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l67); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32702"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l70 = new Label(); + mv.visitJumpInsn(IFEQ, l70); + Label l71 = new Label(); + mv.visitLabel(l71); + mv.visitLineNumber(609, l71); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("bettercircuits"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l72 = new Label(); + mv.visitLabel(l72); + mv.visitLineNumber(610, l72); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l70); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32707"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l73 = new Label(); + mv.visitJumpInsn(IFEQ, l73); + Label l74 = new Label(); + mv.visitLabel(l74); + mv.visitLineNumber(611, l74); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("datasaving"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l75 = new Label(); + mv.visitLabel(l75); + mv.visitLineNumber(612, l75); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l73); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32597"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l76 = new Label(); + mv.visitJumpInsn(IFEQ, l76); + Label l77 = new Label(); + mv.visitLabel(l77); + mv.visitLineNumber(613, l77); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("orbs"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l78 = new Label(); + mv.visitLabel(l78); + mv.visitLineNumber(614, l78); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l76); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32599"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l79 = new Label(); + mv.visitJumpInsn(IFEQ, l79); + Label l80 = new Label(); + mv.visitLabel(l80); + mv.visitLineNumber(615, l80); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("thatspower"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l81 = new Label(); + mv.visitLabel(l81); + mv.visitLineNumber(616, l81); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l79); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32598"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l82 = new Label(); + mv.visitJumpInsn(IFEQ, l82); + Label l83 = new Label(); + mv.visitLabel(l83); + mv.visitLineNumber(617, l83); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("luck"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l84 = new Label(); + mv.visitLabel(l84); + mv.visitLineNumber(618, l84); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l82); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32749"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l85 = new Label(); + mv.visitJumpInsn(IFEQ, l85); + Label l86 = new Label(); + mv.visitLabel(l86); + mv.visitLineNumber(619, l86); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("closeit"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l87 = new Label(); + mv.visitLabel(l87); + mv.visitLineNumber(620, l87); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l85); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32730"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l88 = new Label(); + mv.visitJumpInsn(IFEQ, l88); + Label l89 = new Label(); + mv.visitLabel(l89); + mv.visitLineNumber(621, l89); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("manipulation"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l90 = new Label(); + mv.visitLabel(l90); + mv.visitLineNumber(622, l90); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l88); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32729"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l91 = new Label(); + mv.visitJumpInsn(IFEQ, l91); + Label l92 = new Label(); + mv.visitLabel(l92); + mv.visitLineNumber(623, l92); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("filterregulate"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l93 = new Label(); + mv.visitLabel(l93); + mv.visitLineNumber(624, l93); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l91); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32605"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l94 = new Label(); + mv.visitJumpInsn(IFEQ, l94); + Label l95 = new Label(); + mv.visitLabel(l95); + mv.visitLineNumber(625, l95); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("whatnow"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l96 = new Label(); + mv.visitLabel(l96); + mv.visitLineNumber(626, l96); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l94); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32736"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l97 = new Label(); + mv.visitJumpInsn(IFEQ, l97); + Label l98 = new Label(); + mv.visitLabel(l98); + mv.visitLineNumber(627, l98); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("zpmage"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l99 = new Label(); + mv.visitLabel(l99); + mv.visitLineNumber(628, l99); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l97); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32737"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l100 = new Label(); + mv.visitJumpInsn(IFEQ, l100); + Label l101 = new Label(); + mv.visitLabel(l101); + mv.visitLineNumber(629, l101); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("uvage"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l102 = new Label(); + mv.visitLabel(l102); + mv.visitLineNumber(630, l102); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l100); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.03.32030"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l103 = new Label(); + mv.visitJumpInsn(IFEQ, l103); + Label l104 = new Label(); + mv.visitLabel(l104); + mv.visitLineNumber(631, l104); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("gtmonosilicon"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l105 = new Label(); + mv.visitLabel(l105); + mv.visitLineNumber(632, l105); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l103); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.03.32036"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l106 = new Label(); + mv.visitJumpInsn(IFEQ, l106); + Label l107 = new Label(); + mv.visitLabel(l107); + mv.visitLineNumber(633, l107); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("gtlogicwafer"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l108 = new Label(); + mv.visitLabel(l108); + mv.visitLineNumber(634, l108); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l106); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32701"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l109 = new Label(); + mv.visitJumpInsn(IFEQ, l109); + Label l110 = new Label(); + mv.visitLabel(l110); + mv.visitLineNumber(635, l110); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("gtlogiccircuit"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l111 = new Label(); + mv.visitLabel(l111); + mv.visitLineNumber(636, l111); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l109); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.03.32085"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l112 = new Label(); + mv.visitJumpInsn(IFEQ, l112); + Label l113 = new Label(); + mv.visitLabel(l113); + mv.visitLineNumber(637, l113); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("gtquantumprocessor"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l114 = new Label(); + mv.visitLabel(l114); + mv.visitLineNumber(638, l114); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l112); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.03.32089"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l115 = new Label(); + mv.visitJumpInsn(IFEQ, l115); + Label l116 = new Label(); + mv.visitLabel(l116); + mv.visitLineNumber(639, l116); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("gtcrystalprocessor"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l117 = new Label(); + mv.visitLabel(l117); + mv.visitLineNumber(640, l117); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l115); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.03.32092"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l118 = new Label(); + mv.visitJumpInsn(IFEQ, l118); + Label l119 = new Label(); + mv.visitLabel(l119); + mv.visitLineNumber(641, l119); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("gtwetware"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l120 = new Label(); + mv.visitLabel(l120); + mv.visitLineNumber(642, l120); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l118); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.03.32095"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l121 = new Label(); + mv.visitJumpInsn(IFEQ, l121); + Label l122 = new Label(); + mv.visitLabel(l122); + mv.visitLineNumber(643, l122); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("gtwetmain"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l123 = new Label(); + mv.visitLabel(l123); + mv.visitLineNumber(644, l123); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l121); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32736"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l124 = new Label(); + mv.visitJumpInsn(IFEQ, l124); + Label l125 = new Label(); + mv.visitLabel(l125); + mv.visitLineNumber(645, l125); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("zpmage"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l126 = new Label(); + mv.visitLabel(l126); + mv.visitLineNumber(646, l126); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l124); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32737"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + mv.visitJumpInsn(IFEQ, l45); + Label l127 = new Label(); + mv.visitLabel(l127); + mv.visitLineNumber(647, l127); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("uvage"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l128 = new Label(); + mv.visitLabel(l128); + mv.visitLineNumber(649, l128); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l40); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.Thoriumcell"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l129 = new Label(); + mv.visitJumpInsn(IFEQ, l129); + Label l130 = new Label(); + mv.visitLabel(l130); + mv.visitLineNumber(650, l130); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("newfuel"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l131 = new Label(); + mv.visitLabel(l131); + mv.visitLineNumber(651, l131); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l129); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getItem", "()Lnet/minecraft/item/Item;", false); + mv.visitFieldInsn(GETSTATIC, "ic2/core/Ic2Items", "quantumBodyarmor", "Lnet/minecraft/item/ItemStack;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getItem", "()Lnet/minecraft/item/Item;", false); + Label l132 = new Label(); + mv.visitJumpInsn(IF_ACMPEQ, l132); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getItem", "()Lnet/minecraft/item/Item;", false); + mv.visitFieldInsn(GETSTATIC, "ic2/core/Ic2Items", "quantumBoots", "Lnet/minecraft/item/ItemStack;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getItem", "()Lnet/minecraft/item/Item;", false); + mv.visitJumpInsn(IF_ACMPEQ, l132); + Label l133 = new Label(); + mv.visitLabel(l133); + mv.visitLineNumber(652, l133); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getItem", "()Lnet/minecraft/item/Item;", false); + mv.visitFieldInsn(GETSTATIC, "ic2/core/Ic2Items", "quantumHelmet", "Lnet/minecraft/item/ItemStack;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getItem", "()Lnet/minecraft/item/Item;", false); + mv.visitJumpInsn(IF_ACMPEQ, l132); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getItem", "()Lnet/minecraft/item/Item;", false); + mv.visitFieldInsn(GETSTATIC, "ic2/core/Ic2Items", "quantumLeggings", "Lnet/minecraft/item/ItemStack;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getItem", "()Lnet/minecraft/item/Item;", false); + Label l134 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l134); + mv.visitLabel(l132); + mv.visitLineNumber(653, l132); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("buildQArmor"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l135 = new Label(); + mv.visitLabel(l135); + mv.visitLineNumber(654, l135); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l134); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("ic2.itemPartCircuitAdv"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + mv.visitJumpInsn(IFEQ, l45); + Label l136 = new Label(); + mv.visitLabel(l136); + mv.visitLineNumber(655, l136); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("stepforward"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + mv.visitLabel(l45); + mv.visitLineNumber(657, l45); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitInsn(RETURN); + Label l137 = new Label(); + mv.visitLabel(l137); + mv.visitLocalVariable("this", "Lgregtech/loaders/misc/GT_Achievements;", null, l0, l137, 0); + mv.visitLocalVariable("event", "Lnet/minecraftforge/event/entity/player/EntityItemPickupEvent;", null, l0, l137, 1); + mv.visitLocalVariable("player", "Lnet/minecraft/entity/player/EntityPlayer;", null, l1, l137, 2); + mv.visitLocalVariable("stack", "Lnet/minecraft/item/ItemStack;", null, l2, l137, 3); + mv.visitLocalVariable("data", "Lgregtech/api/objects/ItemData;", null, l5, l137, 4); + mv.visitLocalVariable("data_getAllMaterialStacks_sS", "I", null, l16, l25, 5); + mv.visitLocalVariable("i", "I", null, l17, l25, 6); + mv.visitMaxs(4, 7); + mv.visitEnd(); + + didInject = true; + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Method injection complete."); + return didInject; + } + + + + + + + + + public class MethodAdaptor extends ClassVisitor { + + public MethodAdaptor(ClassVisitor cv) { + super(ASM5, cv); + this.cv = cv; + } + + @Override + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { + MethodVisitor methodVisitor; + if (name.equals("registerAssAchievement") || name.equals("onItemPickup")) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, + "Found method " + name + ", removing."); + methodVisitor = null; + if (name.equals("registerAssAchievement")) { + mDidRemoveAssLineRecipeAdder = true; + } + } else { + methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); + } + return methodVisitor; + } + } + +} diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Client.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Client.java new file mode 100644 index 0000000000..c5b12eb248 --- /dev/null +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Client.java @@ -0,0 +1,571 @@ +package gtPlusPlus.preloader.asm.transformers; + +import static org.objectweb.asm.Opcodes.ACC_PUBLIC; +import static org.objectweb.asm.Opcodes.ALOAD; +import static org.objectweb.asm.Opcodes.ASM5; +import static org.objectweb.asm.Opcodes.INVOKESTATIC; +import static org.objectweb.asm.Opcodes.RETURN; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.lang.reflect.Field; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.UUID; +import java.util.jar.JarEntry; +import java.util.jar.JarInputStream; + +import org.apache.logging.log4j.Level; +import org.objectweb.asm.AnnotationVisitor; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.Label; +import org.objectweb.asm.MethodVisitor; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; +import com.google.common.reflect.ClassPath; +import com.google.common.reflect.ClassPath.ClassInfo; + +import cpw.mods.fml.common.gameevent.TickEvent.Phase; +import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent; +import cpw.mods.fml.relauncher.FMLRelaunchLog; +import gregtech.api.GregTech_API; +import gregtech.api.util.GT_PlayedSound; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.common.StaticFields59; +import gtPlusPlus.xmod.gregtech.loaders.misc.AssLineAchievements; +import net.minecraft.client.Minecraft; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.StatFileWriter; + +public class ClassTransformer_GT_Client { + + private final boolean valid; + private final ClassReader read; + private final ClassWriter write; + private boolean mModern; + private byte[] mTooledClass; + + public ClassTransformer_GT_Client(byte[] basicClass) { + + ClassReader aTempReader = null; + ClassWriter aTempWriter = null; + + aTempReader = new ClassReader(basicClass); + aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES); + + /** + * Let's just read the GT archive for some info + */ + mModern = findAssemblyLineClass(); + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Found Assembly Line? "+mModern+"."); + if (mModern) { + aTempReader.accept(new MethodAdaptor2(aTempWriter), 0); + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Patching Client handling of Assembly Line recipe visibility for GT 5.09"); + injectMethod(aTempWriter); + if (aTempReader != null && aTempWriter != null) { + valid = true; + mTooledClass = aTempWriter.toByteArray(); + } + else { + valid = false; + } + } + else { + mTooledClass = basicClass; + valid = true; + } + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Valid? "+valid+"."); + read = aTempReader; + write = aTempWriter; + } + + public boolean isValidTransformer() { + return valid; + } + + public ClassReader getReader() { + return read; + } + + public ClassWriter getWriter() { + return write; + } + + public boolean findAssemblyLineClass() { + ClassLoader cl = getClass().getClassLoader(); + try { + Set classesInPackage = ClassPath.from(cl).getTopLevelClassesRecursive("gregtech"); + if (classesInPackage != null && classesInPackage.size() > 0) { + for (ClassInfo x : classesInPackage) { + if (x.getResourceName().contains("GT_MetaTileEntity_AssemblyLine")) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, + "Patchable class | " + x.getResourceName()); + return true; + } + } + } + } catch (IOException e) { + } + + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Failed to find Gregtech classes using prefered method, using backup."); + + cl = ClassLoader.getSystemClassLoader(); + ImmutableMap g = getClassPathEntries(cl); + File aGregtech = null; + if (g.size() > 0) { + for (int i = 0; i < g.size(); i++) { + String aName; + try { + File aF = g.keySet().asList().get(i); + aName = aF.getName(); + if (aName != null && aName.length() > 0) { + if (aName.toLowerCase().contains("gregtech")) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Patchable class | "+aName); + aGregtech = aF; + } + } + } + catch (Throwable t) {} + } + } + + if (aGregtech != null) { + try { + File file = aGregtech; + FileInputStream fis = new FileInputStream(file); + JarInputStream jis = new JarInputStream(fis); + System.out.println(jis.markSupported()); + JarEntry je; + while((je=jis.getNextJarEntry())!=null){ + if (je.getName().contains("GT_MetaTileEntity_AssemblyLine")) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Patchable class | "+je.getName()); + return true; + } + } + jis.close(); + return true; + } catch (IOException e1) { + } + } + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Failed to find Gregtech classes using backup method, probably using GT 5.08"); + + return false; + } + + static ImmutableMap getClassPathEntries(ClassLoader classloader) { + LinkedHashMap entries = Maps.newLinkedHashMap(); + // Search parent first, since it's the order ClassLoader#loadClass() uses. + ClassLoader parent = classloader.getParent(); + if (parent != null) { + entries.putAll(getClassPathEntries(parent)); + } + if (classloader instanceof URLClassLoader) { + URLClassLoader urlClassLoader = (URLClassLoader) classloader; + for (URL entry : urlClassLoader.getURLs()) { + if (entry.getProtocol().equals("file")) { + File file = new File(entry.getFile()); + if (!entries.containsKey(file)) { + entries.put(file, classloader); + } + } + } + } + return ImmutableMap.copyOf(entries); + } + + public boolean injectMethod(ClassWriter cw) { + MethodVisitor mv; + boolean didInject = false; + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Injecting " + "onPlayerTickEventClient" + "."); + + /** + * Inject new, safer code + */ + + AnnotationVisitor av0; + + + /** + * Full Patch ASM - Original Idea, now second to static injection of a custom handler. + */ + + /*mv = cw.visitMethod(ACC_PUBLIC, "onPlayerTickEventClient", "(Lcpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent;)V", null, null); + { + av0 = mv.visitAnnotation("Lcpw/mods/fml/common/eventhandler/SubscribeEvent;", true); + av0.visitEnd(); + } + mv.visitCode(); + Label l0 = new Label(); + Label l1 = new Label(); + Label l2 = new Label(); + mv.visitTryCatchBlock(l0, l1, l2, "java/lang/Exception"); + Label l3 = new Label(); + mv.visitLabel(l3); + mv.visitLineNumber(370, l3); + mv.visitVarInsn(ALOAD, 1); + mv.visitFieldInsn(GETFIELD, "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "side", "Lcpw/mods/fml/relauncher/Side;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "cpw/mods/fml/relauncher/Side", "isClient", "()Z", false); + Label l4 = new Label(); + mv.visitJumpInsn(IFEQ, l4); + mv.visitVarInsn(ALOAD, 1); + mv.visitFieldInsn(GETFIELD, "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "phase", "Lcpw/mods/fml/common/gameevent/TickEvent$Phase;"); + mv.visitFieldInsn(GETSTATIC, "cpw/mods/fml/common/gameevent/TickEvent$Phase", "END", "Lcpw/mods/fml/common/gameevent/TickEvent$Phase;"); + mv.visitJumpInsn(IF_ACMPNE, l4); + mv.visitVarInsn(ALOAD, 1); + mv.visitFieldInsn(GETFIELD, "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "player", "Lnet/minecraft/entity/player/EntityPlayer;"); + mv.visitFieldInsn(GETFIELD, "net/minecraft/entity/player/EntityPlayer", "isDead", "Z"); + mv.visitJumpInsn(IFNE, l4); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(371, l5); + mv.visitVarInsn(ALOAD, 0); + mv.visitInsn(DUP); + mv.visitFieldInsn(GETFIELD, "gregtech/common/GT_Client", "afterSomeTime", "J"); + mv.visitInsn(LCONST_1); + mv.visitInsn(LADD); + mv.visitFieldInsn(PUTFIELD, "gregtech/common/GT_Client", "afterSomeTime", "J"); + Label l6 = new Label(); + mv.visitLabel(l6); + mv.visitLineNumber(372, l6); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/common/GT_Client", "afterSomeTime", "J"); + mv.visitLdcInsn(new Long(100L)); + mv.visitInsn(LCMP); + Label l7 = new Label(); + mv.visitJumpInsn(IFLT, l7); + Label l8 = new Label(); + mv.visitLabel(l8); + mv.visitLineNumber(373, l8); + mv.visitVarInsn(ALOAD, 0); + mv.visitInsn(LCONST_0); + mv.visitFieldInsn(PUTFIELD, "gregtech/common/GT_Client", "afterSomeTime", "J"); + Label l9 = new Label(); + mv.visitLabel(l9); + mv.visitLineNumber(374, l9); + mv.visitMethodInsn(INVOKESTATIC, "net/minecraft/client/Minecraft", "getMinecraft", "()Lnet/minecraft/client/Minecraft;", false); + mv.visitFieldInsn(GETFIELD, "net/minecraft/client/Minecraft", "thePlayer", "Lnet/minecraft/client/entity/EntityClientPlayerMP;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/client/entity/EntityClientPlayerMP", "getStatFileWriter", "()Lnet/minecraft/stats/StatFileWriter;", false); + mv.visitVarInsn(ASTORE, 2); + mv.visitLabel(l0); + mv.visitLineNumber(376, l0); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/util/GT_Recipe$GT_Recipe_Map", "sAssemblylineVisualRecipes", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/util/GT_Recipe$GT_Recipe_Map", "mRecipeList", "Ljava/util/Collection;"); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Collection", "iterator", "()Ljava/util/Iterator;", true); + mv.visitVarInsn(ASTORE, 4); + Label l10 = new Label(); + mv.visitJumpInsn(GOTO, l10); + Label l11 = new Label(); + mv.visitLabel(l11); + mv.visitFrame(F_FULL, 5, new Object[] {"gregtech/common/GT_Client", "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "net/minecraft/stats/StatFileWriter", TOP, "java/util/Iterator"}, 0, new Object[] {}); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "next", "()Ljava/lang/Object;", true); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/util/GT_Recipe"); + mv.visitVarInsn(ASTORE, 3); + Label l12 = new Label(); + mv.visitLabel(l12); + mv.visitLineNumber(377, l12); + mv.visitVarInsn(ALOAD, 3); + mv.visitVarInsn(ALOAD, 2); + mv.visitVarInsn(ALOAD, 3); + mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/util/GT_Recipe", "getOutput", "(I)Lnet/minecraft/item/ItemStack;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements", "getAchievement", "(Ljava/lang/String;)Lnet/minecraft/stats/Achievement;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/stats/StatFileWriter", "hasAchievementUnlocked", "(Lnet/minecraft/stats/Achievement;)Z", false); + Label l13 = new Label(); + mv.visitJumpInsn(IFEQ, l13); + mv.visitInsn(ICONST_0); + Label l14 = new Label(); + mv.visitJumpInsn(GOTO, l14); + mv.visitLabel(l13); + mv.visitFrame(F_FULL, 5, new Object[] {"gregtech/common/GT_Client", "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "net/minecraft/stats/StatFileWriter", "gregtech/api/util/GT_Recipe", "java/util/Iterator"}, 1, new Object[] {"gregtech/api/util/GT_Recipe"}); + mv.visitInsn(ICONST_1); + mv.visitLabel(l14); + mv.visitFrame(F_FULL, 5, new Object[] {"gregtech/common/GT_Client", "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "net/minecraft/stats/StatFileWriter", "gregtech/api/util/GT_Recipe", "java/util/Iterator"}, 2, new Object[] {"gregtech/api/util/GT_Recipe", INTEGER}); + mv.visitFieldInsn(PUTFIELD, "gregtech/api/util/GT_Recipe", "mHidden", "Z"); + mv.visitLabel(l10); + mv.visitLineNumber(376, l10); + mv.visitFrame(F_FULL, 5, new Object[] {"gregtech/common/GT_Client", "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "net/minecraft/stats/StatFileWriter", TOP, "java/util/Iterator"}, 0, new Object[] {}); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "hasNext", "()Z", true); + mv.visitJumpInsn(IFNE, l11); + mv.visitLabel(l1); + mv.visitLineNumber(379, l1); + mv.visitJumpInsn(GOTO, l7); + mv.visitLabel(l2); + mv.visitFrame(F_FULL, 3, new Object[] {"gregtech/common/GT_Client", "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "net/minecraft/stats/StatFileWriter"}, 1, new Object[] {"java/lang/Exception"}); + mv.visitVarInsn(ASTORE, 3); + mv.visitLabel(l7); + mv.visitLineNumber(381, l7); + mv.visitFrame(F_CHOP,1, null, 0, null); + mv.visitTypeInsn(NEW, "java/util/ArrayList"); + mv.visitInsn(DUP); + mv.visitMethodInsn(INVOKESPECIAL, "java/util/ArrayList", "", "()V", false); + mv.visitVarInsn(ASTORE, 2); + Label l15 = new Label(); + mv.visitLabel(l15); + mv.visitLineNumber(382, l15); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/util/GT_Utility", "sPlayedSoundMap", "Ljava/util/Map;"); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Map", "entrySet", "()Ljava/util/Set;", true); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Set", "iterator", "()Ljava/util/Iterator;", true); + mv.visitVarInsn(ASTORE, 4); + Label l16 = new Label(); + mv.visitJumpInsn(GOTO, l16); + Label l17 = new Label(); + mv.visitLabel(l17); + mv.visitFrame(F_FULL, 5, new Object[] {"gregtech/common/GT_Client", "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "java/util/ArrayList", TOP, "java/util/Iterator"}, 0, new Object[] {}); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "next", "()Ljava/lang/Object;", true); + mv.visitTypeInsn(CHECKCAST, "java/util/Map$Entry"); + mv.visitVarInsn(ASTORE, 3); + Label l18 = new Label(); + mv.visitLabel(l18); + mv.visitLineNumber(383, l18); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Map$Entry", "getValue", "()Ljava/lang/Object;", true); + mv.visitTypeInsn(CHECKCAST, "java/lang/Integer"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Integer", "intValue", "()I", false); + Label l19 = new Label(); + mv.visitJumpInsn(IFGE, l19); + Label l20 = new Label(); + mv.visitLabel(l20); + mv.visitLineNumber(384, l20); + mv.visitVarInsn(ALOAD, 2); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Map$Entry", "getKey", "()Ljava/lang/Object;", true); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/util/GT_PlayedSound"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/ArrayList", "add", "(Ljava/lang/Object;)Z", false); + mv.visitInsn(POP); + Label l21 = new Label(); + mv.visitLabel(l21); + mv.visitLineNumber(385, l21); + mv.visitJumpInsn(GOTO, l16); + mv.visitLabel(l19); + mv.visitLineNumber(386, l19); + mv.visitFrame(F_FULL, 5, new Object[] {"gregtech/common/GT_Client", "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "java/util/ArrayList", "java/util/Map$Entry", "java/util/Iterator"}, 0, new Object[] {}); + mv.visitVarInsn(ALOAD, 3); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Map$Entry", "getValue", "()Ljava/lang/Object;", true); + mv.visitTypeInsn(CHECKCAST, "java/lang/Integer"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Integer", "intValue", "()I", false); + mv.visitInsn(ICONST_1); + mv.visitInsn(ISUB); + mv.visitMethodInsn(INVOKESTATIC, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;", false); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Map$Entry", "setValue", "(Ljava/lang/Object;)Ljava/lang/Object;", true); + mv.visitInsn(POP); + mv.visitLabel(l16); + mv.visitLineNumber(382, l16); + mv.visitFrame(F_FULL, 5, new Object[] {"gregtech/common/GT_Client", "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "java/util/ArrayList", TOP, "java/util/Iterator"}, 0, new Object[] {}); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "hasNext", "()Z", true); + mv.visitJumpInsn(IFNE, l17); + Label l22 = new Label(); + mv.visitLabel(l22); + mv.visitLineNumber(390, l22); + mv.visitVarInsn(ALOAD, 2); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/ArrayList", "iterator", "()Ljava/util/Iterator;", false); + mv.visitVarInsn(ASTORE, 4); + Label l23 = new Label(); + mv.visitLabel(l23); + Label l24 = new Label(); + mv.visitJumpInsn(GOTO, l24); + Label l25 = new Label(); + mv.visitLabel(l25); + mv.visitLineNumber(391, l25); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "next", "()Ljava/lang/Object;", true); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/util/GT_PlayedSound"); + mv.visitVarInsn(ASTORE, 3); + Label l26 = new Label(); + mv.visitLabel(l26); + mv.visitLineNumber(390, l26); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/util/GT_Utility", "sPlayedSoundMap", "Ljava/util/Map;"); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Map", "remove", "(Ljava/lang/Object;)Ljava/lang/Object;", true); + mv.visitInsn(POP); + mv.visitLabel(l24); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "hasNext", "()Z", true); + mv.visitJumpInsn(IFNE, l25); + Label l27 = new Label(); + mv.visitLabel(l27); + mv.visitLineNumber(393, l27); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/GregTech_API", "mServerStarted", "Z"); + mv.visitJumpInsn(IFNE, l4); + Label l28 = new Label(); + mv.visitLabel(l28); + mv.visitLineNumber(394, l28); + mv.visitInsn(ICONST_1); + mv.visitFieldInsn(PUTSTATIC, "gregtech/api/GregTech_API", "mServerStarted", "Z"); + mv.visitLabel(l4); + mv.visitLineNumber(397, l4); + mv.visitFrame(F_FULL, 2, new Object[] {"gregtech/common/GT_Client", "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent"}, 0, new Object[] {}); + mv.visitInsn(RETURN); + Label l29 = new Label(); + mv.visitLabel(l29); + mv.visitLocalVariable("this", "Lgregtech/common/GT_Client;", null, l3, l29, 0); + mv.visitLocalVariable("aEvent", "Lcpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent;", null, l3, l29, 1); + mv.visitLocalVariable("sfw", "Lnet/minecraft/stats/StatFileWriter;", null, l0, l7, 2); + mv.visitLocalVariable("recipe", "Lgregtech/api/util/GT_Recipe;", null, l12, l10, 3); + mv.visitLocalVariable("tList", "Ljava/util/ArrayList;", "Ljava/util/ArrayList;", l15, l4, 2); + mv.visitLocalVariable("tEntry", "Ljava/util/Map$Entry;", "Ljava/util/Map$Entry;", l18, l16, 3); + mv.visitLocalVariable("tKey", "Lgregtech/api/util/GT_PlayedSound;", null, l26, l24, 3); + mv.visitLocalVariable("i", "Ljava/util/Iterator;", "Ljava/util/Iterator;", l23, l27, 4); + mv.visitMaxs(5, 5); + mv.visitEnd();*/ + + /** + * Static invocation of custom handler instead + */ + + + mv = cw.visitMethod(ACC_PUBLIC, "onPlayerTickEventClient", "(Lcpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent;)V", null, null); + av0 = mv.visitAnnotation("Lcpw/mods/fml/common/eventhandler/SubscribeEvent;", true); + av0.visitEnd(); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(371, l0); + mv.visitVarInsn(ALOAD, 1); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Client", "onPlayerTickEventClient", "(Lcpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent;)V", false); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLineNumber(372, l1); + mv.visitInsn(RETURN); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLocalVariable("this", "Lgregtech/common/GT_Client;", null, l0, l2, 0); + mv.visitLocalVariable("aEvent", "Lcpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent;", null, l0, l2, 1); + mv.visitMaxs(1, 2); + mv.visitEnd(); + + + didInject = true; + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Method injection complete."); + return didInject; + + } + + public class MethodAdaptor2 extends ClassVisitor { + + public MethodAdaptor2(ClassVisitor cv) { + super(ASM5, cv); + this.cv = cv; + } + + @Override + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { + MethodVisitor methodVisitor; + if (name.equals("onPlayerTickEventClient")) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, + "Found method " + name + ", removing."); + methodVisitor = null; + } else { + methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); + } + return methodVisitor; + } + } + + public byte[] getByteArray() { + if (mTooledClass != null) { + return mTooledClass; + } + return getWriter().toByteArray(); + } + + + private static final Map aTimeMap = new HashMap(); + + + public static void onPlayerTickEventClient(PlayerTickEvent aEvent) { + if (aEvent.side.isClient() && aEvent.phase == Phase.END && !aEvent.player.isDead) { + long aTime = 0; + if (aTimeMap.get(aEvent.player.getUniqueID()) == null) { + aTimeMap.put(aEvent.player.getUniqueID(), 0l); + } + else { + aTime = aTimeMap.get(aEvent.player.getUniqueID()) + 1; + aTimeMap.put(aEvent.player.getUniqueID(), aTime); + } + if (aTime >= 100L) { + aTimeMap.put(aEvent.player.getUniqueID(), 0l); + /** + * Remove original handling + */ + if (StaticFields59.mAssLineVisualMapNEI != null) { + StatFileWriter tList = Minecraft.getMinecraft().thePlayer.getStatFileWriter(); + GT_Recipe_Map aAssLineNei; + try { + aAssLineNei = (GT_Recipe_Map) StaticFields59.mAssLineVisualMapNEI.get(null); + for (GT_Recipe aFakeAssLineRecipe : aAssLineNei.mRecipeList) { + String aSafeUnlocalName; + if (aFakeAssLineRecipe.getOutput(0) == null) { + Logger.INFO( + "Someone tried to register an achievement for a recipe with null output. Please report this to Alkalus."); + continue; + } + ItemStack aStack = aFakeAssLineRecipe.getOutput(0); + try { + aSafeUnlocalName = aStack.getUnlocalizedName(); + } catch (Throwable t) { + aSafeUnlocalName = ItemUtils.getUnlocalizedItemName(aStack); + } + aFakeAssLineRecipe.mHidden = !tList.hasAchievementUnlocked(AssLineAchievements.getAchievement(aSafeUnlocalName)); + } + } catch (IllegalArgumentException | IllegalAccessException e) { + } + } + } + + Iterator tKey; + ArrayList arg5 = new ArrayList(); + tKey = GT_Utility.sPlayedSoundMap.entrySet().iterator(); + + while (tKey.hasNext()) { + Entry arg7 = (Entry) tKey.next(); + if (((Integer) arg7.getValue()).intValue() < 0) { + arg5.add(arg7.getKey()); + } else { + arg7.setValue(Integer.valueOf(((Integer) arg7.getValue()).intValue() - 1)); + } + } + + Iterator arg8 = arg5.iterator(); + + while (arg8.hasNext()) { + GT_PlayedSound arg6 = (GT_PlayedSound) arg8.next(); + GT_Utility.sPlayedSoundMap.remove(arg6); + } + + if (!GregTech_API.mServerStarted) { + GregTech_API.mServerStarted = true; + } + } + } + + + + + + + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java index c47984a530..7e2e6e72fc 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java @@ -2,7 +2,6 @@ package gtPlusPlus.preloader.asm.transformers; import java.io.File; import java.io.IOException; -import java.util.Random; import org.apache.logging.log4j.Level; import org.objectweb.asm.ClassReader; @@ -11,14 +10,10 @@ import org.objectweb.asm.ClassWriter; import cpw.mods.fml.relauncher.CoreModManager; import cpw.mods.fml.relauncher.FMLRelaunchLog; import cpw.mods.fml.relauncher.ReflectionHelper; -import galaxyspace.SolarSystem.core.configs.GSConfigDimensions; -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.launchwrapper.IClassTransformer; -import net.minecraft.launchwrapper.Launch; -import gtPlusPlus.core.util.Utils; import gtPlusPlus.preloader.asm.AsmConfig; import gtPlusPlus.preloader.asm.transformers.Preloader_ClassTransformer.OreDictionaryVisitor; +import net.minecraft.launchwrapper.IClassTransformer; +import net.minecraft.launchwrapper.Launch; @SuppressWarnings("static-access") public class Preloader_Transformer_Handler implements IClassTransformer { @@ -118,6 +113,28 @@ public class Preloader_Transformer_Handler implements IClassTransformer { } } + + + + + + /** + * Gregtech ASM Patches + */ + + //Try patch achievements + if (transformedName.equals("gregtech.loaders.misc.GT_Achievements")) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Transforming %s", transformedName); + return new ClassTransformer_GT_Achievements(basicClass).getWriter().toByteArray(); + } + if (transformedName.equals("gregtech.common.GT_Client")) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Transforming %s", transformedName); + return new ClassTransformer_GT_Client(basicClass).getByteArray(); + } + + + + //Patching Meta Tile Tooltips if (transformedName.equals("gregtech.common.blocks.GT_Item_Machines") && mConfig.enableGtTooltipFix) { FMLRelaunchLog.log("[GT++ ASM] Gregtech Tooltip Patch", Level.INFO, "Transforming %s", transformedName); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java index 0556a7f4fe..2549144a2a 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java @@ -15,26 +15,15 @@ import java.util.TimerTask; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.block.Block; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumChatFormatting; -import net.minecraftforge.fluids.FluidStack; import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.BaseMetaTileEntity; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; import gregtech.common.GT_Proxy; -import gregtech.common.blocks.GT_Block_Machines; -import gregtech.common.render.GT_Renderer_Block; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.data.ObjMap; @@ -44,8 +33,15 @@ import gtPlusPlus.core.util.reflect.ProxyFinder; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.BaseCustomTileEntity; import gtPlusPlus.xmod.gregtech.api.metatileentity.custom.power.BaseCustomPower_MTE; -import gtPlusPlus.xmod.gregtech.common.blocks.GTPP_Block_Machines; -import gtPlusPlus.xmod.gregtech.common.render.GTPP_Render_MachineBlock; +import gtPlusPlus.xmod.gregtech.loaders.misc.AssLineAchievements; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.fluids.FluidStack; public class Meta_GT_Proxy { @@ -64,6 +60,8 @@ public class Meta_GT_Proxy { private static Class sBaseMetaTileEntityClass; private static Class sBaseMetaTileEntityClass2; + public static AssLineAchievements mAssemblyAchievements; + public static final Map mCustomGregtechMetaTooltips = new LinkedHashMap(); @@ -97,6 +95,7 @@ public class Meta_GT_Proxy { } public void init() { + mAssemblyAchievements = new AssLineAchievements(); scheduleCoverMapCleaner(); setValidHeatingCoilMetas(); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java b/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java index c1db39b132..9068bf2ec1 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java @@ -33,6 +33,7 @@ public class StaticFields59 { public static final Field mMultiblockChemicalRecipes; public static final Field mDescriptionArray; public static final Field mCasingTexturePages; + public static final Field mAssLineVisualMapNEI; public static final Method mCalculatePollutionReduction; public static final Method mAddFurnaceRecipe; @@ -49,6 +50,7 @@ public class StaticFields59 { mMultiblockChemicalRecipes = getField(GT_Recipe_Map.class, "sMultiblockChemicalRecipes"); mDescriptionArray = getField(GT_MetaTileEntity_TieredMachineBlock.class, "mDescriptionArray"); mCasingTexturePages = getField(BlockIcons.class, "casingTexturePages"); + mAssLineVisualMapNEI = getField(GT_Recipe_Map.class, "sAssemblylineVisualRecipes"); mCalculatePollutionReduction = getMethod(GT_MetaTileEntity_Hatch_Muffler.class, "calculatePollutionReduction", int.class); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements.java new file mode 100644 index 0000000000..368332b64b --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements.java @@ -0,0 +1,159 @@ +package gtPlusPlus.xmod.gregtech.loaders.misc; + +import java.util.concurrent.ConcurrentHashMap; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import gregtech.GT_Mod; +import gregtech.api.enums.GT_Values; +import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.common.StaticFields59; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.Achievement; +import net.minecraft.stats.AchievementList; +import net.minecraft.stats.StatBase; +import net.minecraftforge.common.AchievementPage; +import net.minecraftforge.event.entity.player.EntityItemPickupEvent; + +public class AssLineAchievements { + + public static int assReg = -1; + public static ConcurrentHashMap mAchievementMap; + public static ConcurrentHashMap mIssuedAchievementMap; + public static int adjX = 5; + public static int adjY = 9; + private static boolean active = true; + + public AssLineAchievements() { + Logger.INFO(active ? "Loading custom achievement page for Assembly Line recipes." + : "Achievements are disabled."); + Utils.registerEvent(this); + } + + private static boolean ready = false; + private static int recipeTotal = 0; + private static int recipeCount = 0; + private static void init() { + if (!ready) { + active = GT_Mod.gregtechproxy.mAchievements; + try { + recipeTotal = ((GT_Recipe.GT_Recipe_Map) StaticFields59.mAssLineVisualMapNEI.get(null)).mRecipeList.size(); + } catch (IllegalArgumentException | IllegalAccessException e) { + recipeTotal = 0; + } + mAchievementMap = new ConcurrentHashMap(); + mIssuedAchievementMap = new ConcurrentHashMap(); + } + + } + + public static void registerAchievements() { + if (active && mAchievementMap.size() > 0) { + AchievementPage.registerAchievementPage(new AchievementPage("GT Assembly Line", + (Achievement[]) mAchievementMap.values().toArray(new Achievement[mAchievementMap.size()]))); + } + else if (active) { + Logger.INFO("Unable to register custom achievement page for Assembly Line recipes."); + } + } + + public static Achievement registerAssAchievement(GT_Recipe recipe) { + init(); + String aSafeUnlocalName; + // Debugging + if (recipe == null) { + Logger.INFO( + "Someone tried to register an achievement for an invalid recipe. Please report this to Alkalus."); + return null; + } + if (recipe.getOutput(0) == null) { + Logger.INFO( + "Someone tried to register an achievement for a recipe with null output. Please report this to Alkalus."); + return null; + } + ItemStack aStack = recipe.getOutput(0); + try { + aSafeUnlocalName = aStack.getUnlocalizedName(); + } catch (Throwable t) { + aSafeUnlocalName = ItemUtils.getUnlocalizedItemName(aStack); + } + + Achievement aYouDidSomethingInGT; + if (mAchievementMap.get(aSafeUnlocalName) == null) { + assReg++; + recipeCount++; + aYouDidSomethingInGT = registerAchievement(aSafeUnlocalName, -(11 + assReg % 5), ((assReg) / 5) - 8, + recipe.getOutput(0), AchievementList.openInventory, false); + } + else { + aYouDidSomethingInGT = null; + } + if (recipeCount >= recipeTotal) { + Logger.INFO("Critical mass achieved, releasing toxic Assembly Line recipes into new reservoir. ["+recipeCount+"]"); + registerAchievements(); + } + + return aYouDidSomethingInGT; + } + + public static Achievement registerAchievement(String textId, int x, int y, ItemStack icon, + Achievement requirement, boolean special) { + if (!GT_Mod.gregtechproxy.mAchievements) { + return null; + } + Achievement achievement = new Achievement(textId, textId, adjX + x, adjY + y, icon, requirement); + if (special) { + achievement.setSpecial(); + } + achievement.registerStat(); + if (GT_Values.D2) { + GT_Log.out.println("achievement." + textId + "="); + GT_Log.out.println("achievement." + textId + ".desc="); + } + mAchievementMap.put(textId, achievement); + return achievement; + } + + public static void issueAchievement(EntityPlayer entityplayer, String textId) { + if (entityplayer == null || !GT_Mod.gregtechproxy.mAchievements) { + return; + } + entityplayer.triggerAchievement((StatBase) mAchievementMap.get(textId)); + } + + public static Achievement getAchievement(String textId) { + if (mAchievementMap.containsKey(textId)) { + return (Achievement) mAchievementMap.get(textId); + } + return null; + } + + @SubscribeEvent + public void onItemPickup(EntityItemPickupEvent event) { + EntityPlayer player = event.entityPlayer; + ItemStack stack = event.item.getEntityItem(); + if (player == null || stack == null) { + return; + } + Logger.INFO("Trying to check for achievements"); + // Debug scanner unlocks all AL recipes in creative + if (player.capabilities.isCreativeMode && stack.getUnlocalizedName().equals("gt.metaitem.01.32761")) { + for (GT_Recipe recipe : GT_Recipe.GT_Recipe_Map.sAssemblylineVisualRecipes.mRecipeList) { + issueAchievement(player, recipe.getOutput(0).getUnlocalizedName()); + recipe.mHidden = false; + } + } + for (GT_Recipe recipe : GT_Recipe.GT_Recipe_Map.sAssemblylineVisualRecipes.mRecipeList) { + if (recipe.getOutput(0).getUnlocalizedName().equals(stack.getUnlocalizedName())) { + issueAchievement(player, recipe.getOutput(0).getUnlocalizedName()); + recipe.mHidden = false; + } + } + } + +} diff --git a/src/resources/assets/miscutils/lang/en_US.lang b/src/resources/assets/miscutils/lang/en_US.lang index d5e0f165c1..5fa8aebf8e 100644 --- a/src/resources/assets/miscutils/lang/en_US.lang +++ b/src/resources/assets/miscutils/lang/en_US.lang @@ -1806,7 +1806,7 @@ tile.Block of Uranium 233.name=Block of Uranium 233 tile.Block of Plutonium-238.name=Block of Plutonium 238 tile.Block of Strontium-90.name=Block of Strontium 90 tile.Block of Polonium-210.name=Block of Polonium 210 -tile.Block of r.name=Block of Americium 241 +tile.Block of Americium-241.name=Block of Americium 241 tile.Block of Silicon Carbide.name=Block of Silicon Carbide tile.Silicon Carbide Frame Box.name=Silicon Carbide Frame Box tile.Block of Zirconium Carbide.name=Block of Zirconium Carbide -- cgit From dc5119af80c7b78a33e495743584750f61692fcc Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Thu, 14 Feb 2019 16:36:51 +0000 Subject: + Added lots of custom achievements. --- .../core/handler/AchievementHandler.java | 394 +++++++++++++++++++++ .../xmod/gregtech/common/Meta_GT_Proxy.java | 5 +- 2 files changed, 397 insertions(+), 2 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/handler/AchievementHandler.java (limited to 'src/Java/gtPlusPlus/core/handler') diff --git a/src/Java/gtPlusPlus/core/handler/AchievementHandler.java b/src/Java/gtPlusPlus/core/handler/AchievementHandler.java new file mode 100644 index 0000000000..9fcdfa557c --- /dev/null +++ b/src/Java/gtPlusPlus/core/handler/AchievementHandler.java @@ -0,0 +1,394 @@ +package gtPlusPlus.core.handler; + +import java.util.concurrent.ConcurrentHashMap; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent.ItemSmeltedEvent; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.util.GT_Log; +import gregtech.common.items.GT_MetaGenerated_Tool_01; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.ALLOY; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.Achievement; +import net.minecraft.stats.StatBase; +import net.minecraftforge.common.AchievementPage; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.EntityItemPickupEvent; + +public class AchievementHandler { + + public ConcurrentHashMap achievementList = new ConcurrentHashMap(); + public ConcurrentHashMap issuedAchievements = new ConcurrentHashMap(); + + public int adjX = 5; + public int adjY = 9; + + private static final String aBaseAchievementName = "gtpp.start"; + + public AchievementHandler() { + + //register first + this.registerAchievement(aBaseAchievementName, 0, 0, GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.HARDHAMMER, 1, Materials.Neutronium, Materials.Osmium, null), "", true); + + //Useful Info + this.registerAchievement("hatch.control", -2, -2, GregtechItemList.Hatch_Control_Core.get(1), aBaseAchievementName, false); + this.registerAchievement("hatch.dynamo.buffered", 2, -2, GregtechItemList.Hatch_Buffer_Dynamo_IV.get(1), aBaseAchievementName, false); + //First multi anyone really needs + this.registerAchievement("multi.abs", -4, -2, GregtechItemList.Industrial_AlloyBlastSmelter.get(1), "hatch.control", true); + + //Material Advancement + this.registerAchievement("dust.potin", 0, 2, ALLOY.POTIN.getDust(1), aBaseAchievementName, false); + this.registerAchievement("dust.eglin", 0, 4, ALLOY.EGLIN_STEEL.getDust(1), "dust.potin", false); + this.registerAchievement("dust.staballoy", 0, 6, ALLOY.STABALLOY.getDust(1), "dust.eglin", false); + this.registerAchievement("dust.quantum", 0, 8, ALLOY.QUANTUM.getDust(1), "dust.staballoy", true); + this.registerAchievement("dust.hypogen", 0, 10, ELEMENT.STANDALONE.HYPOGEN.getDust(1), "dust.quantum", true); + + + //Blocks + this.registerAchievement("block.fishtrap", -2, 2, ItemUtils.getSimpleStack(ModBlocks.blockFishTrap), "dust.potin", false); + this.registerAchievement("block.withercage", -2, 4, ItemUtils.getSimpleStack(ModBlocks.blockWitherGuard), "dust.eglin", false); + + + //Machines (-10/-8/-6) + this.registerAchievement("rtg", -16, -10, GregtechItemList.RTG.get(1), aBaseAchievementName, false); + this.registerAchievement("dehydrate", -15, -10, GregtechItemList.GT_Dehydrator_HV.get(1), aBaseAchievementName, false); + this.registerAchievement("semifluid", -14, -10, GregtechItemList.Generator_SemiFluid_HV.get(1), aBaseAchievementName, false); + this.registerAchievement("earlywasher", -13, -10, GregtechItemList.SimpleDustWasher.get(1), aBaseAchievementName, false); + this.registerAchievement("advancedsteam", -12, -10, GregtechItemList.Boiler_Advanced_MV.get(1), aBaseAchievementName, false); + this.registerAchievement("pollutionremoval", -11, -10, GregtechItemList.Pollution_Cleaner_IV.get(1), aBaseAchievementName, false); + this.registerAchievement("hiampxform", -10, -10, GregtechItemList.Transformer_HA_HV_MV.get(1), aBaseAchievementName, false); + + + //Multis (-4/-2/0) + this.registerAchievement("multi.pss", -16, -7, GregtechItemList.PowerSubStation.get(1), "multi.abs", false); + this.registerAchievement("multi.cyclo", -15, -7, GregtechItemList.COMET_Cyclotron.get(1), "multi.abs", false); + this.registerAchievement("multi.sifter", -14, -7, GregtechItemList.Industrial_Sifter.get(1), "dust.eglin", false); + this.registerAchievement("multi.cokeoven", -13, -7, GregtechItemList.Industrial_CokeOven.get(1), "multi.abs", false); + this.registerAchievement("multi.boiler.thermal", -12, -7, GregtechItemList.GT4_Thermal_Boiler.get(1), "multi.abs", false); + this.registerAchievement("multi.zhuhai", -11, -7, GregtechItemList.Industrial_FishingPond.get(1), aBaseAchievementName, false); + //this.registerAchievement("rtg", -4, -4, GregtechItemList.RTG.get(1), aBaseAchievementName, false); + + //Casings + this.registerAchievement("casing.abs", 2, -10, GregtechItemList.Casing_Coil_BlastSmelter.get(1), aBaseAchievementName, false); + this.registerAchievement("casing.cyclotron.coil", 3, -10, GregtechItemList.Casing_Cyclotron_Coil.get(1), aBaseAchievementName, false); + this.registerAchievement("casing.multiuse", 4, -10, GregtechItemList.Casing_Multi_Use.get(1), aBaseAchievementName, false); + this.registerAchievement("casing.containment", 5, -10, GregtechItemList.Casing_Containment.get(1), aBaseAchievementName, false); + + + + + + + + + //Radioactive + this.registerAchievement("decay.neptunium238", 11, 8, ItemUtils.getSimpleStack(ModItems.dustNeptunium238), "multi.cyclo", false); + this.registerAchievement("decay.radium226", 12, 8, ItemUtils.getSimpleStack(ModItems.dustRadium226), "multi.cyclo", false); + this.registerAchievement("decay.molybdenum99", 13, 8, ItemUtils.getSimpleStack(ModItems.dustMolybdenum99), "multi.cyclo", false); + this.registerAchievement("decay.technetium99m", 14, 8, ItemUtils.getSimpleStack(ModItems.dustTechnetium99M), "multi.cyclo", true); + this.registerAchievement("decay.technetium99", 15, 8, ItemUtils.getSimpleStack(ModItems.dustTechnetium99), "multi.cyclo", true); + + + + + + + + + + + + + AchievementPage.registerAchievementPage( + new AchievementPage("GT++", (Achievement[]) ((Achievement[]) this.achievementList.values() + .toArray(new Achievement[this.achievementList.size()])))); + MinecraftForge.EVENT_BUS.register(this); + FMLCommonHandler.instance().bus().register(this); + + + } + + public Achievement registerAchievement(String textId, int x, int y, ItemStack icon, Achievement requirement, + boolean special) { + Achievement achievement = new Achievement(textId, textId, this.adjX + x, this.adjY + y, icon, requirement); + if (special) { + achievement.setSpecial(); + } + + achievement.registerStat(); + if (CORE.DEVENV) { + GT_Log.out.println("achievement." + textId + "="); + GT_Log.out.println("achievement." + textId + ".desc="); + } + + this.achievementList.put(textId, achievement); + return achievement; + } + + public Achievement registerAchievement(String textId, int x, int y, ItemStack icon, String requirement, + boolean special) { + Achievement achievement = new Achievement(textId, textId, this.adjX + x, this.adjY + y, icon, + this.getAchievement(requirement)); + if (special) { + achievement.setSpecial(); + } + + achievement.registerStat(); + if (CORE.DEVENV) { + GT_Log.out.println("achievement." + textId + "="); + GT_Log.out.println("achievement." + textId + ".desc="); + } + + this.achievementList.put(textId, achievement); + return achievement; + } + + public void issueAchievement(EntityPlayer entityplayer, String textId) { + if (entityplayer != null) { + entityplayer.triggerAchievement((StatBase) this.achievementList.get(textId)); + } + } + + public Achievement getAchievement(String textId) { + return this.achievementList.containsKey(textId) ? (Achievement) this.achievementList.get(textId) : null; + } + + + /** + * A generic handler that will give an achievement for an item. + * Useful to only write this once, then call it from all handlers. + * @param aStack - The Itemstack to check for achievements. + * @param aPlayer - The player to unlock for. + */ + private void handleAchivement(ItemStack aStack, EntityPlayer aPlayer) { + + if (aPlayer != null && aStack != null) { + /* + * Copy this to all events because I am lazy - Alk 2019 + */ + + //Safe name + String aUnlocalName = ItemUtils.getUnlocalizedItemName(aStack); + + + boolean isValid = false; + //Check if valid name // mod + if (ItemUtils.getModId(aStack).equals(CORE.MODID) || ItemUtils.getModId(aStack).equalsIgnoreCase("gregtech")) { + isValid = true; + } + if (!isValid) { + return; + } + + //Should unlock base achievement from *ANY* GT++ item. (Too lazy to special case GT machineBlocks though) + if (ItemUtils.getModId(aStack).equals(CORE.MODID)) { + this.issueAchievement(aPlayer, aBaseAchievementName); + } + + + /** + * Misc Blocks + */ + + if (aUnlocalName.equalsIgnoreCase("blockFishTrap")) { + this.issueAchievement(aPlayer, "block.fishtrap"); + } + if (aUnlocalName.equalsIgnoreCase("blockBlackGate")) { + this.issueAchievement(aPlayer, "block.withercage"); + } + + + /** + * Decayables + */ + if (aUnlocalName.equalsIgnoreCase("dustNeptunium238")) { + this.issueAchievement(aPlayer, "decay.neptunium238"); + } + else if (aUnlocalName.equalsIgnoreCase("dustRadium226")) { + this.issueAchievement(aPlayer, "decay.radium226"); + } + else if (aUnlocalName.equalsIgnoreCase("dustMolybdenum99")) { + this.issueAchievement(aPlayer, "decay.molybdenum99"); + } + else if (aUnlocalName.equalsIgnoreCase("dustTechnetium99M")) { + this.issueAchievement(aPlayer, "decay.technetium99m"); + } + else if (aUnlocalName.equalsIgnoreCase("dustTechnetium99")) { + this.issueAchievement(aPlayer, "decay.technetium99"); + } + + /** + * Random Materials worthy of Achievements + */ + else if (aUnlocalName.equalsIgnoreCase("itemDustPotin")) { + this.issueAchievement(aPlayer, "dust.potin"); + } + else if (aUnlocalName.equalsIgnoreCase("itemDustEglinSteel")) { + this.issueAchievement(aPlayer, "dust.eglin"); + } + else if (aUnlocalName.equalsIgnoreCase("itemDustStaballoy")) { + this.issueAchievement(aPlayer, "dust.staballoy"); + } + else if (aUnlocalName.equalsIgnoreCase("itemDustQuantum")) { + this.issueAchievement(aPlayer, "dust.quantum"); + } + else if (aUnlocalName.equalsIgnoreCase("itemDustHypogen")) { + this.issueAchievement(aPlayer, "dust.hypogen"); + } + + + + /** + * Machines + */ + + else if (aUnlocalName.startsWith("gt.blockmachines.")) { + + //Readability + String aStartsWith = "gt.blockmachines."; + + /** + * Single Blocks + */ + + //RTG + if (aUnlocalName.startsWith(aStartsWith + "basicgenerator.rtg")) { + this.issueAchievement(aPlayer, "rtg"); + } + //Dehydrator + else if (aUnlocalName.startsWith(aStartsWith + "machine.dehydrator.tier.")) { + this.issueAchievement(aPlayer, "dehydrate"); + } + //SemiFluids + else if (aUnlocalName.startsWith(aStartsWith + "basicgenerator.semifluid.tier.")) { + this.issueAchievement(aPlayer, "semifluid"); + } + //Simple Washer + else if (aUnlocalName.startsWith(aStartsWith + "simplewasher.01.tier.")) { + this.issueAchievement(aPlayer, "earlywasher"); + } + //Advanced Boilers + else if (aUnlocalName.startsWith(aStartsWith + "electricboiler.")) { + this.issueAchievement(aPlayer, "advancedsteam"); + } + //Scrubers + else if (aUnlocalName.startsWith(aStartsWith + "pollutioncleaner.01.tier.")) { + this.issueAchievement(aPlayer, "pollutionremoval"); + } + //High-amp xformers + else if (aUnlocalName.startsWith(aStartsWith + "transformer.ha.tier.")) { + this.issueAchievement(aPlayer, "hiampxform"); + } + //Buffered Dynamos + else if (aUnlocalName.startsWith(aStartsWith + "hatch.dynamo.buffer.tier.")) { + this.issueAchievement(aPlayer, "hatch.dynamo.buffered"); + } + //Control Core Hatch + else if (aUnlocalName.startsWith(aStartsWith + "hatch.control.adv")) { + this.issueAchievement(aPlayer, "hatch.control"); + } + + + + /** + * Multis + */ + + //ABS + else if (aUnlocalName.equals(aStartsWith + "industrialsalloyamelter.controller.tier.single")) { + this.issueAchievement(aPlayer, "multi.abs"); + } + //PSS + else if (aUnlocalName.equals(aStartsWith + "substation.01.input.single")) { + this.issueAchievement(aPlayer, "multi.pss"); + } + //Cyclotron + else if (aUnlocalName.startsWith(aStartsWith + "cyclotron.tier.single")) { + this.issueAchievement(aPlayer, "multi.cyclo"); + } + //Sifter + else if (aUnlocalName.equals(aStartsWith + "industrialsifter.controller.tier.single")) { + this.issueAchievement(aPlayer, "multi.sifter"); + } + //Coke Oven + else if (aUnlocalName.equals(aStartsWith + "industrialcokeoven.controller.tier.single")) { + this.issueAchievement(aPlayer, "multi.cokeoven"); + } + //Thermal Boiler + else if (aUnlocalName.equals(aStartsWith + "gtplusplus.thermal.boiler")) { + this.issueAchievement(aPlayer, "multi.boiler.thermal"); + } + //Zhuhai + else if (aUnlocalName.equals(aStartsWith + "industrial.fishpond.controller.tier.single")) { + this.issueAchievement(aPlayer, "multi.zhuhai"); + } + + } + + /** + * Casings + */ + + else if (aUnlocalName.equalsIgnoreCase("gtplusplus.blockcasings.14")) { + this.issueAchievement(aPlayer, "casing.abs"); + } + + else if (aUnlocalName.equalsIgnoreCase("gtplusplus.blockcasings.2.9")) { + this.issueAchievement(aPlayer, "casing.cyclotron.coil"); + } + + else if (aUnlocalName.equalsIgnoreCase("gtplusplus.blockcasings.3.2")) { + this.issueAchievement(aPlayer, "casing.multiuse"); + } + else if (aUnlocalName.equalsIgnoreCase("gtplusplus.blockcasings.3.15")) { + this.issueAchievement(aPlayer, "casing.containment"); + } + } + } + + + + + /* + * Handle achievements for all vanilla types of obtianment. + */ + + + + @SubscribeEvent + public void onCrafting(ItemCraftedEvent event) { + EntityPlayer player = event.player; + ItemStack stack = event.crafting; + if (player != null && stack != null) { + handleAchivement(stack, player); + } + } + + @SubscribeEvent + public void onSmelting(ItemSmeltedEvent event) { + EntityPlayer player = event.player; + ItemStack stack = event.smelting; + if (player != null && stack != null) { + handleAchivement(stack, player); + } + } + + @SubscribeEvent + public void onItemPickup(EntityItemPickupEvent event) { + EntityPlayer player = event.entityPlayer; + ItemStack stack = event.item.getEntityItem(); + if (player != null && stack != null) { + handleAchivement(stack, player); + } + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java index 0db8e94614..5eee77e065 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java @@ -28,6 +28,7 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.data.ObjMap; import gtPlusPlus.api.objects.minecraft.FormattedTooltipString; +import gtPlusPlus.core.handler.AchievementHandler; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.reflect.ProxyFinder; import gtPlusPlus.core.util.reflect.ReflectionUtils; @@ -60,7 +61,7 @@ public class Meta_GT_Proxy { private static Class sBaseMetaTileEntityClass; private static Class sBaseMetaTileEntityClass2; - public static AssLineAchievements mAssemblyAchievements; + public static AchievementHandler mAssemblyAchievements; public static final Map mCustomGregtechMetaTooltips = new LinkedHashMap(); @@ -100,7 +101,7 @@ public class Meta_GT_Proxy { } public void postInit() { - //mAssemblyAchievements = new AssLineAchievements(); + mAssemblyAchievements = new AchievementHandler(); } public static TileEntity constructCustomGregtechMetaTileEntityByMeta(int aMeta) { -- cgit From b23100249ecb5315babc7a4b1035ea4363d75f52 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Thu, 14 Feb 2019 17:10:56 +0000 Subject: % Localized new achievements. $ Fixed minor formatting issues on unlocal names when detecting items picked up. --- .../core/handler/AchievementHandler.java | 56 +++++++++++------- src/resources/assets/gregtech/lang/en_US.lang | 68 +++++++++++++++++++++- 2 files changed, 103 insertions(+), 21 deletions(-) (limited to 'src/Java/gtPlusPlus/core/handler') diff --git a/src/Java/gtPlusPlus/core/handler/AchievementHandler.java b/src/Java/gtPlusPlus/core/handler/AchievementHandler.java index 9fcdfa557c..e19dd01794 100644 --- a/src/Java/gtPlusPlus/core/handler/AchievementHandler.java +++ b/src/Java/gtPlusPlus/core/handler/AchievementHandler.java @@ -10,6 +10,7 @@ import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; import gregtech.api.util.GT_Log; import gregtech.common.items.GT_MetaGenerated_Tool_01; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.lib.CORE; @@ -37,14 +38,20 @@ public class AchievementHandler { public AchievementHandler() { + Logger.INFO("Initializing GT++ achievements"); + GT_Log.out.println("Initializing GT++ achievements"); + //register first this.registerAchievement(aBaseAchievementName, 0, 0, GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.HARDHAMMER, 1, Materials.Neutronium, Materials.Osmium, null), "", true); //Useful Info - this.registerAchievement("hatch.control", -2, -2, GregtechItemList.Hatch_Control_Core.get(1), aBaseAchievementName, false); + boolean cores = CORE.ConfigSwitches.requireControlCores; + if (cores) { + this.registerAchievement("hatch.control", -2, -2, GregtechItemList.Hatch_Control_Core.get(1), aBaseAchievementName, false); + } this.registerAchievement("hatch.dynamo.buffered", 2, -2, GregtechItemList.Hatch_Buffer_Dynamo_IV.get(1), aBaseAchievementName, false); //First multi anyone really needs - this.registerAchievement("multi.abs", -4, -2, GregtechItemList.Industrial_AlloyBlastSmelter.get(1), "hatch.control", true); + this.registerAchievement("multi.abs", -4, -2, GregtechItemList.Industrial_AlloyBlastSmelter.get(1), cores ? "hatch.control" : aBaseAchievementName, true); //Material Advancement this.registerAchievement("dust.potin", 0, 2, ALLOY.POTIN.getDust(1), aBaseAchievementName, false); @@ -95,8 +102,8 @@ public class AchievementHandler { this.registerAchievement("decay.neptunium238", 11, 8, ItemUtils.getSimpleStack(ModItems.dustNeptunium238), "multi.cyclo", false); this.registerAchievement("decay.radium226", 12, 8, ItemUtils.getSimpleStack(ModItems.dustRadium226), "multi.cyclo", false); this.registerAchievement("decay.molybdenum99", 13, 8, ItemUtils.getSimpleStack(ModItems.dustMolybdenum99), "multi.cyclo", false); - this.registerAchievement("decay.technetium99m", 14, 8, ItemUtils.getSimpleStack(ModItems.dustTechnetium99M), "multi.cyclo", true); - this.registerAchievement("decay.technetium99", 15, 8, ItemUtils.getSimpleStack(ModItems.dustTechnetium99), "multi.cyclo", true); + this.registerAchievement("decay.technetium99m", 14, 8, ItemUtils.getSimpleStack(ModItems.dustTechnetium99M), "multi.cyclo", false); + this.registerAchievement("decay.technetium99", 15, 8, ItemUtils.getSimpleStack(ModItems.dustTechnetium99), "multi.cyclo", false); @@ -195,15 +202,24 @@ public class AchievementHandler { this.issueAchievement(aPlayer, aBaseAchievementName); } + if (aUnlocalName.contains("item.")) { + aUnlocalName = aUnlocalName.substring(5); + } + else if (aUnlocalName.contains("tile.")) { + aUnlocalName = aUnlocalName.substring(5); + } + + //Logger.INFO("Picked up "+aUnlocalName); + /** * Misc Blocks */ - if (aUnlocalName.equalsIgnoreCase("blockFishTrap")) { + if (aUnlocalName.equals("blockFishTrap")) { this.issueAchievement(aPlayer, "block.fishtrap"); } - if (aUnlocalName.equalsIgnoreCase("blockBlackGate")) { + if (aUnlocalName.equals("blockBlackGate")) { this.issueAchievement(aPlayer, "block.withercage"); } @@ -211,38 +227,38 @@ public class AchievementHandler { /** * Decayables */ - if (aUnlocalName.equalsIgnoreCase("dustNeptunium238")) { + if (aUnlocalName.equals("dustNeptunium238")) { this.issueAchievement(aPlayer, "decay.neptunium238"); } - else if (aUnlocalName.equalsIgnoreCase("dustRadium226")) { + else if (aUnlocalName.equals("dustRadium226")) { this.issueAchievement(aPlayer, "decay.radium226"); } - else if (aUnlocalName.equalsIgnoreCase("dustMolybdenum99")) { + else if (aUnlocalName.equals("dustMolybdenum99")) { this.issueAchievement(aPlayer, "decay.molybdenum99"); } - else if (aUnlocalName.equalsIgnoreCase("dustTechnetium99M")) { + else if (aUnlocalName.equals("dustTechnetium99M")) { this.issueAchievement(aPlayer, "decay.technetium99m"); } - else if (aUnlocalName.equalsIgnoreCase("dustTechnetium99")) { + else if (aUnlocalName.equals("dustTechnetium99")) { this.issueAchievement(aPlayer, "decay.technetium99"); } /** * Random Materials worthy of Achievements */ - else if (aUnlocalName.equalsIgnoreCase("itemDustPotin")) { + else if (aUnlocalName.equals("itemDustPotin")) { this.issueAchievement(aPlayer, "dust.potin"); } - else if (aUnlocalName.equalsIgnoreCase("itemDustEglinSteel")) { + else if (aUnlocalName.equals("itemDustEglinSteel")) { this.issueAchievement(aPlayer, "dust.eglin"); } - else if (aUnlocalName.equalsIgnoreCase("itemDustStaballoy")) { + else if (aUnlocalName.equals("itemDustStaballoy")) { this.issueAchievement(aPlayer, "dust.staballoy"); } - else if (aUnlocalName.equalsIgnoreCase("itemDustQuantum")) { + else if (aUnlocalName.equals("itemDustQuantum")) { this.issueAchievement(aPlayer, "dust.quantum"); } - else if (aUnlocalName.equalsIgnoreCase("itemDustHypogen")) { + else if (aUnlocalName.equals("itemDustHypogen")) { this.issueAchievement(aPlayer, "dust.hypogen"); } @@ -339,18 +355,18 @@ public class AchievementHandler { * Casings */ - else if (aUnlocalName.equalsIgnoreCase("gtplusplus.blockcasings.14")) { + else if (aUnlocalName.equals("gtplusplus.blockcasings.14")) { this.issueAchievement(aPlayer, "casing.abs"); } - else if (aUnlocalName.equalsIgnoreCase("gtplusplus.blockcasings.2.9")) { + else if (aUnlocalName.equals("gtplusplus.blockcasings.2.9")) { this.issueAchievement(aPlayer, "casing.cyclotron.coil"); } - else if (aUnlocalName.equalsIgnoreCase("gtplusplus.blockcasings.3.2")) { + else if (aUnlocalName.equals("gtplusplus.blockcasings.3.2")) { this.issueAchievement(aPlayer, "casing.multiuse"); } - else if (aUnlocalName.equalsIgnoreCase("gtplusplus.blockcasings.3.15")) { + else if (aUnlocalName.equals("gtplusplus.blockcasings.3.15")) { this.issueAchievement(aPlayer, "casing.containment"); } } diff --git a/src/resources/assets/gregtech/lang/en_US.lang b/src/resources/assets/gregtech/lang/en_US.lang index 56479c2029..ffbb3d8a7a 100644 --- a/src/resources/assets/gregtech/lang/en_US.lang +++ b/src/resources/assets/gregtech/lang/en_US.lang @@ -98,7 +98,73 @@ achievement.item.GTPP.BattPack.09.name.desc=[AL] Pickup this item to see the rec - +//14/2/19 +achievement.gtpp.start=Gregtech++ +achievement.gtpp.start.desc=So, think you've got what it takes? +achievement.hatch.control=This is where you put the Control Core +achievement.hatch.control.desc=A special hatch required by all GT++ Multiblocks. +achievement.hatch.dynamo.buffered=Buffered Dynamo Hatch +achievement.hatch.dynamo.buffered.desc=Don't EVER use these on large turbines. +achievement.multi.abs=Alloy Blast Smelter [ABS] +achievement.multi.abs.desc=Used to create most late game alloys. +achievement.dust.potin=Potin! +achievement.dust.potin.desc=Well, you gotta start somewhere... +achievement.dust.eglin=Eglin Steel! +achievement.dust.eglin.desc=Progress, albeit slow... +achievement.dust.staballoy=Staballoy! +achievement.dust.staballoy.desc=Now we're talking... +achievement.dust.quantum=Quantum! +achievement.dust.quantum.desc=Raw Matter. +achievement.dust.hypogen=Hypogen! +achievement.dust.hypogen.desc=What even is this material? +achievement.block.fishtrap=Free Fish +achievement.block.fishtrap.desc=Better than HarvestCraft. +achievement.block.withercage=Jail +achievement.block.withercage.desc=Trap a Wither/Dragon with this. +achievement.rtg=Radioisotope Thermoelectric Generation! +achievement.rtg.desc=Probably stolen from Russia, use with care. +achievement.dehydrate=Dehydration +achievement.dehydrate.desc=Drink some water. +achievement.semifluid=It's like a fluid, but it's not +achievement.semifluid.desc=Semifluids are confusing. +achievement.earlywasher=Simple Ore Washer +achievement.earlywasher.desc=Runs on ULV only. +achievement.advancedsteam=Alternative Steam options +achievement.advancedsteam.desc=Smart fuel consumption +achievement.pollutionremoval=Pollution, no more! +achievement.pollutionremoval.desc=POLLUTION IS BAD +achievement.hiampxform=High Amp Transformers +achievement.hiampxform.desc=Advanced power transformation +achievement.multi.pss=Power Sub-Station [PSS] +achievement.multi.pss.desc=Grid Power Storage. +achievement.multi.cyclo=Cyclotron +achievement.multi.cyclo.desc=Advanced Science +achievement.multi.sifter=Industrial Sifter +achievement.multi.sifter.desc=Faster than a turtle. +achievement.multi.cokeoven=Industrial Coke Oven [ICO] +achievement.multi.cokeoven.desc=Better than a Pyrolyse +achievement.multi.boiler.thermal=Thermal Boiler +achievement.multi.boiler.thermal.desc=Pahoehoe works too! +achievement.multi.zhuhai=Zhuhai, Fishing Port +achievement.multi.zhuhai.desc=Actually exists +achievement.casing.abs=Slow Progress +achievement.casing.abs.desc=Eventually, you will have your ABS. +achievement.casing.cyclotron.coil=Slower Progress +achievement.casing.cyclotron.coil.desc=Consider why you're even doing this.. +achievement.casing.multiuse=I'm going to make lots of these +achievement.casing.multiuse.desc=Don't start counting. +achievement.casing.containment=What's this for? +achievement.casing.containment.desc=I should probably try find out. +achievement.decay.neptunium238=Neptunium 238 +achievement.decay.neptunium238.desc=Cyclotron Product +achievement.decay.radium226=Radium 226 +achievement.decay.radium226.desc=Cyclotron Product +achievement.decay.molybdenum99=Molybdenum 99 +achievement.decay.molybdenum99.desc=Cyclotron Product +achievement.decay.technetium99m=Technetium 99M +achievement.decay.technetium99m.desc=Cyclotron Product +achievement.decay.technetium99=Technetium 99 +achievement.decay.technetium99.desc=Cyclotron Product -- cgit From 27b13101ab9042eacad45f5867c8cfee23cffbe0 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Fri, 15 Feb 2019 02:49:31 +0000 Subject: $ Made achievement handling safer. $ Fixed GT Assembly Line recipe ASM, again. --- .../api/objects/data/ReverseAutoMap.java | 4 +- .../core/handler/AchievementHandler.java | 10 +- .../ClassTransformer_GT_Achievements_CrashFix.java | 153 ++++++++------------- .../Preloader_Transformer_Handler.java | 2 +- 4 files changed, 72 insertions(+), 97 deletions(-) (limited to 'src/Java/gtPlusPlus/core/handler') diff --git a/src/Java/gtPlusPlus/api/objects/data/ReverseAutoMap.java b/src/Java/gtPlusPlus/api/objects/data/ReverseAutoMap.java index 73858e8d43..72ec0bc293 100644 --- a/src/Java/gtPlusPlus/api/objects/data/ReverseAutoMap.java +++ b/src/Java/gtPlusPlus/api/objects/data/ReverseAutoMap.java @@ -151,11 +151,11 @@ public class ReverseAutoMap extends AutoMap { } @Override - public synchronized boolean clear(){ + public synchronized void clear(){ this.mInternalID = 0; this.mInternalMap.clear(); this.mInternalMapReverseLookup.clear(); - return true; + return; } @Override diff --git a/src/Java/gtPlusPlus/core/handler/AchievementHandler.java b/src/Java/gtPlusPlus/core/handler/AchievementHandler.java index e19dd01794..faca4449ce 100644 --- a/src/Java/gtPlusPlus/core/handler/AchievementHandler.java +++ b/src/Java/gtPlusPlus/core/handler/AchievementHandler.java @@ -189,8 +189,14 @@ public class AchievementHandler { boolean isValid = false; - //Check if valid name // mod - if (ItemUtils.getModId(aStack).equals(CORE.MODID) || ItemUtils.getModId(aStack).equalsIgnoreCase("gregtech")) { + //Check if valid name // mod + String aModID = ItemUtils.getModId(aStack); + + if (aModID == null || aModID.length() <= 0 || aModID.isEmpty()) { + return; + } + + if (aModID != null && (ItemUtils.getModId(aStack).equals(CORE.MODID) || ItemUtils.getModId(aStack).equalsIgnoreCase("gregtech"))) { isValid = true; } if (!isValid) { diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Achievements_CrashFix.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Achievements_CrashFix.java index b9ef955d53..fb297ed76e 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Achievements_CrashFix.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Achievements_CrashFix.java @@ -9,18 +9,21 @@ import org.objectweb.asm.Label; import org.objectweb.asm.MethodVisitor; import cpw.mods.fml.relauncher.FMLRelaunchLog; +import gtPlusPlus.preloader.DevHelper; public class ClassTransformer_GT_Achievements_CrashFix { private final boolean isValid; private final ClassReader reader; private final ClassWriter writer; + private final boolean mObfuscated; private static boolean mDidRemoveAssLineRecipeAdder = false; - public ClassTransformer_GT_Achievements_CrashFix(byte[] basicClass) { + public ClassTransformer_GT_Achievements_CrashFix(byte[] basicClass, boolean obfuscated) { ClassReader aTempReader = null; ClassWriter aTempWriter = null; + mObfuscated = obfuscated; aTempReader = new ClassReader(basicClass); aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES); @@ -62,117 +65,90 @@ public class ClassTransformer_GT_Achievements_CrashFix { public boolean injectMethod(ClassWriter cw) { MethodVisitor mv; boolean didInject = false; - FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Injecting " + "registerAssAchievement" + "."); + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Injecting " + "registerAssAchievement" + ". Obfuscated? "+mObfuscated); /** * Inject new, safer code */ - mv = cw.visitMethod(ACC_PUBLIC, "registerAssAchievement", "(Lgregtech/api/util/GT_Recipe;)Lnet/minecraft/stats/Achievement;", null, null); mv.visitCode(); Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(293, l0); + mv.visitVarInsn(ALOAD, 1); Label l1 = new Label(); + mv.visitJumpInsn(IFNONNULL, l1); Label l2 = new Label(); - mv.visitTryCatchBlock(l0, l1, l2, "java/lang/Throwable"); + mv.visitLabel(l2); + mv.visitLineNumber(294, l2); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/util/GT_Log", "err", "Ljava/io/PrintStream;"); + mv.visitLdcInsn("GTPP_MOD: Someone tried to register an achievement for an invalid recipe. Please report this to Alkalus."); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false); Label l3 = new Label(); mv.visitLabel(l3); - mv.visitLineNumber(293, l3); + mv.visitLineNumber(295, l3); + mv.visitInsn(ACONST_NULL); + mv.visitInsn(ARETURN); + mv.visitLabel(l1); + mv.visitLineNumber(297, l1); + mv.visitFrame(F_SAME, 0, null, 0, null); mv.visitVarInsn(ALOAD, 1); + mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/util/GT_Recipe", "getOutput", "(I)Lnet/minecraft/item/ItemStack;", false); Label l4 = new Label(); mv.visitJumpInsn(IFNONNULL, l4); Label l5 = new Label(); mv.visitLabel(l5); - mv.visitLineNumber(295, l5); - mv.visitLdcInsn("Someone tried to register an achievement for an invalid recipe. Please report this to Alkalus."); + mv.visitLineNumber(298, l5); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/util/GT_Log", "err", "Ljava/io/PrintStream;"); + mv.visitLdcInsn("GTPP_MOD: Someone tried to register an achievement for a recipe with null output. Please report this to Alkalus."); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false); Label l6 = new Label(); mv.visitLabel(l6); - mv.visitLineNumber(294, l6); - mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/api/objects/Logger", "INFO", "(Ljava/lang/String;)V", false); - Label l7 = new Label(); - mv.visitLabel(l7); - mv.visitLineNumber(296, l7); + mv.visitLineNumber(299, l6); mv.visitInsn(ACONST_NULL); mv.visitInsn(ARETURN); mv.visitLabel(l4); - mv.visitLineNumber(298, l4); - mv.visitFrame(F_SAME, 0, null, 0, null); - mv.visitVarInsn(ALOAD, 1); - mv.visitInsn(ICONST_0); - mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/util/GT_Recipe", "getOutput", "(I)Lnet/minecraft/item/ItemStack;", false); - Label l8 = new Label(); - mv.visitJumpInsn(IFNONNULL, l8); - Label l9 = new Label(); - mv.visitLabel(l9); - mv.visitLineNumber(300, l9); - mv.visitLdcInsn("Someone tried to register an achievement for a recipe with null output. Please report this to Alkalus."); - Label l10 = new Label(); - mv.visitLabel(l10); - mv.visitLineNumber(299, l10); - mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/api/objects/Logger", "INFO", "(Ljava/lang/String;)V", false); - Label l11 = new Label(); - mv.visitLabel(l11); - mv.visitLineNumber(301, l11); - mv.visitInsn(ACONST_NULL); - mv.visitInsn(ARETURN); - mv.visitLabel(l8); - mv.visitLineNumber(303, l8); + mv.visitLineNumber(301, l4); mv.visitFrame(F_SAME, 0, null, 0, null); mv.visitVarInsn(ALOAD, 1); mv.visitInsn(ICONST_0); mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/util/GT_Recipe", "getOutput", "(I)Lnet/minecraft/item/ItemStack;", false); mv.visitVarInsn(ASTORE, 3); - mv.visitLabel(l0); - mv.visitLineNumber(305, l0); - mv.visitVarInsn(ALOAD, 3); - mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); - mv.visitVarInsn(ASTORE, 2); - mv.visitLabel(l1); - mv.visitLineNumber(306, l1); - Label l12 = new Label(); - mv.visitJumpInsn(GOTO, l12); - mv.visitLabel(l2); - mv.visitFrame(F_FULL, 4, new Object[] {"gregtech/loaders/misc/GT_Achievements", "gregtech/api/util/GT_Recipe", TOP, "net/minecraft/item/ItemStack"}, 1, new Object[] {"java/lang/Throwable"}); - mv.visitVarInsn(ASTORE, 4); - Label l13 = new Label(); - mv.visitLabel(l13); - mv.visitLineNumber(307, l13); + Label l7 = new Label(); + mv.visitLabel(l7); + mv.visitLineNumber(302, l7); mv.visitVarInsn(ALOAD, 3); mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/minecraft/ItemUtils", "getUnlocalizedItemName", "(Lnet/minecraft/item/ItemStack;)Ljava/lang/String;", false); mv.visitVarInsn(ASTORE, 2); - mv.visitLabel(l12); - mv.visitLineNumber(311, l12); - mv.visitFrame(F_FULL, 4, new Object[] {"gregtech/loaders/misc/GT_Achievements", "gregtech/api/util/GT_Recipe", "java/lang/String", "net/minecraft/item/ItemStack"}, 0, new Object[] {}); + Label l8 = new Label(); + mv.visitLabel(l8); + mv.visitLineNumber(304, l8); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, "gregtech/loaders/misc/GT_Achievements", "achievementList", "Ljava/util/concurrent/ConcurrentHashMap;"); mv.visitVarInsn(ALOAD, 2); mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/concurrent/ConcurrentHashMap", "get", "(Ljava/lang/Object;)Ljava/lang/Object;", false); - Label l14 = new Label(); - mv.visitJumpInsn(IFNONNULL, l14); - Label l15 = new Label(); - mv.visitLabel(l15); - mv.visitLineNumber(312, l15); + Label l9 = new Label(); + mv.visitJumpInsn(IFNONNULL, l9); + Label l10 = new Label(); + mv.visitLabel(l10); + mv.visitLineNumber(305, l10); mv.visitFieldInsn(GETSTATIC, "gregtech/loaders/misc/GT_Achievements", "assReg", "I"); mv.visitInsn(ICONST_1); mv.visitInsn(IADD); mv.visitFieldInsn(PUTSTATIC, "gregtech/loaders/misc/GT_Achievements", "assReg", "I"); - Label l16 = new Label(); - mv.visitLabel(l16); - mv.visitLineNumber(313, l16); + Label l11 = new Label(); + mv.visitLabel(l11); + mv.visitLineNumber(306, l11); mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ALOAD, 1); - mv.visitInsn(ICONST_0); - mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/util/GT_Recipe", "getOutput", "(I)Lnet/minecraft/item/ItemStack;", false); - mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitVarInsn(ALOAD, 2); mv.visitIntInsn(BIPUSH, 11); mv.visitFieldInsn(GETSTATIC, "gregtech/loaders/misc/GT_Achievements", "assReg", "I"); mv.visitInsn(ICONST_5); mv.visitInsn(IREM); mv.visitInsn(IADD); mv.visitInsn(INEG); - Label l17 = new Label(); - mv.visitLabel(l17); - mv.visitLineNumber(314, l17); mv.visitFieldInsn(GETSTATIC, "gregtech/loaders/misc/GT_Achievements", "assReg", "I"); mv.visitInsn(ICONST_5); mv.visitInsn(IDIV); @@ -183,41 +159,34 @@ public class ClassTransformer_GT_Achievements_CrashFix { mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/util/GT_Recipe", "getOutput", "(I)Lnet/minecraft/item/ItemStack;", false); mv.visitLdcInsn("NO_REQUIREMENT"); mv.visitInsn(ICONST_0); - Label l18 = new Label(); - mv.visitLabel(l18); - mv.visitLineNumber(313, l18); mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "registerAchievement", "(Ljava/lang/String;IILnet/minecraft/item/ItemStack;Ljava/lang/String;Z)Lnet/minecraft/stats/Achievement;", false); mv.visitVarInsn(ASTORE, 4); - Label l19 = new Label(); - mv.visitLabel(l19); - mv.visitLineNumber(315, l19); - Label l20 = new Label(); - mv.visitJumpInsn(GOTO, l20); - mv.visitLabel(l14); - mv.visitLineNumber(317, l14); - mv.visitFrame(F_SAME, 0, null, 0, null); + Label l12 = new Label(); + mv.visitLabel(l12); + mv.visitLineNumber(307, l12); + Label l13 = new Label(); + mv.visitJumpInsn(GOTO, l13); + mv.visitLabel(l9); + mv.visitLineNumber(309, l9); + mv.visitFrame(F_APPEND,2, new Object[] {"java/lang/String", "net/minecraft/item/ItemStack"}, 0, null); mv.visitInsn(ACONST_NULL); mv.visitVarInsn(ASTORE, 4); - mv.visitLabel(l20); - mv.visitLineNumber(319, l20); + mv.visitLabel(l13); + mv.visitLineNumber(311, l13); mv.visitFrame(F_APPEND,1, new Object[] {"net/minecraft/stats/Achievement"}, 0, null); mv.visitVarInsn(ALOAD, 4); mv.visitInsn(ARETURN); - Label l21 = new Label(); - mv.visitLabel(l21); - mv.visitLocalVariable("this", "Lgregtech/loaders/misc/GT_Achievements;", null, l3, l21, 0); - mv.visitLocalVariable("recipe", "Lgregtech/api/util/GT_Recipe;", null, l3, l21, 1); - mv.visitLocalVariable("aSafeUnlocalName", "Ljava/lang/String;", null, l1, l2, 2); - mv.visitLocalVariable("aSafeUnlocalName", "Ljava/lang/String;", null, l12, l21, 2); - mv.visitLocalVariable("aStack", "Lnet/minecraft/item/ItemStack;", null, l0, l21, 3); - mv.visitLocalVariable("t", "Ljava/lang/Throwable;", null, l13, l12, 4); - mv.visitLocalVariable("aYouDidSomethingInGT", "Lnet/minecraft/stats/Achievement;", null, l19, l14, 4); - mv.visitLocalVariable("aYouDidSomethingInGT", "Lnet/minecraft/stats/Achievement;", null, l20, l21, 4); + Label l14 = new Label(); + mv.visitLabel(l14); + mv.visitLocalVariable("this", "Lgregtech/loaders/misc/GT_Achievements;", null, l0, l14, 0); + mv.visitLocalVariable("recipe", "Lgregtech/api/util/GT_Recipe;", null, l0, l14, 1); + mv.visitLocalVariable("aSafeUnlocalName", "Ljava/lang/String;", null, l8, l14, 2); + mv.visitLocalVariable("aStack", "Lnet/minecraft/item/ItemStack;", null, l7, l14, 3); + mv.visitLocalVariable("aYouDidSomethingInGT", "Lnet/minecraft/stats/Achievement;", null, l12, l9, 4); + mv.visitLocalVariable("aYouDidSomethingInGT", "Lnet/minecraft/stats/Achievement;", null, l13, l14, 4); mv.visitMaxs(7, 5); mv.visitEnd(); - - didInject = true; FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Method injection complete."); return didInject; diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java index 8c8b37eaab..e7014de089 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java @@ -125,7 +125,7 @@ public class Preloader_Transformer_Handler implements IClassTransformer { //Try patch achievements if (transformedName.equals("gregtech.loaders.misc.GT_Achievements")) { FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Transforming %s", transformedName); - return new ClassTransformer_GT_Achievements_CrashFix(basicClass).getWriter().toByteArray(); + return new ClassTransformer_GT_Achievements_CrashFix(basicClass, obfuscated).getWriter().toByteArray(); } /*if (transformedName.equals("gregtech.common.GT_Client")) { FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Transforming %s", transformedName); -- cgit From 4f435ae75b176a9d90c7afa6b1ff40e9ba9c286a Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Thu, 28 Feb 2019 20:06:01 +0000 Subject: + Added a new debug tool. + Added support for Crops++. + Added Custom Crops & framework to support more in future. + Added basic support for all GT++ Materials within Tinkers Construct. [WIP] + Moderately bad attempt at generating custom Plasma Cooling recipes in the Adv. Vacuum Freezer. [WIP #424] % Reworked logic for Material.java handling Durability, Tool Quality & Harvest Level. % Adjusted frequency of structural checks on the Cyclotron, Now 100x less frequent. % Cleaned up ReflectionUtils.java and made all getters cache their results, for much faster access. % Attempted to adjust logic of FFPP, but I probably broke it. [WIP] % Moved static array of Element Names from IonParticles.java -> ELEMENT.java. $ Greatly improved reflective performance across the mod. --- src/Java/gregtech/api/util/FishPondFakeRecipe.java | 4 +- src/Java/gtPlusPlus/GTplusplus.java | 14 + .../gen/gt/WorldGen_GT_Australia_Ore_Layer.java | 2 +- .../gtPlusPlus/core/block/base/BlockBaseOre.java | 4 +- .../core/block/machine/Machine_ProjectTable.java | 30 +- .../core/block/machine/Machine_Workbench.java | 30 +- .../core/client/renderer/RenderGiantChicken.java | 2 +- src/Java/gtPlusPlus/core/common/CommonProxy.java | 6 +- .../entity/monster/EntityStaballoyConstruct.java | 17 +- .../gtPlusPlus/core/gui/item/GuiBaseGrindle.java | 2 +- .../core/gui/machine/GUI_ScrollTest.java | 7 +- .../core/handler/COMPAT_IntermodStaging.java | 13 +- src/Java/gtPlusPlus/core/item/ModItems.java | 9 +- .../core/item/chemistry/IonParticles.java | 11 +- .../core/item/general/books/ItemBaseBook.java | 5 +- .../item/general/capture/ItemEntityCatcher.java | 13 +- .../core/item/tool/misc/DebugScanner.java | 98 +++++ src/Java/gtPlusPlus/core/lib/CORE.java | 2 +- src/Java/gtPlusPlus/core/lib/LoadedMods.java | 6 + src/Java/gtPlusPlus/core/material/ELEMENT.java | 6 +- src/Java/gtPlusPlus/core/material/Material.java | 30 +- .../gtPlusPlus/core/recipe/RECIPES_GREGTECH.java | 2 + src/Java/gtPlusPlus/core/slots/SlotToolBox.java | 18 +- src/Java/gtPlusPlus/core/util/Utils.java | 2 +- .../gtPlusPlus/core/util/minecraft/FoodUtils.java | 2 +- .../core/util/minecraft/MaterialUtils.java | 2 +- .../core/util/minecraft/MiningUtils.java | 22 +- .../util/minecraft/gregtech/PollutionUtils.java | 26 +- .../core/util/reflect/ClientProxyFinder.java | 32 -- .../gtPlusPlus/core/util/reflect/ProxyFinder.java | 4 +- .../core/util/reflect/ReflectionUtils.java | 438 ++++++++++++++------- .../everglades/gen/gt/WorldGen_GT_Ore_Layer.java | 2 +- .../gtPlusPlus/nei/GT_NEI_MultiBlockHandler.java | 2 +- .../villagers/entity/EntityBaseVillager.java | 62 +-- .../villagers/entity/EntityNativeAustralian.java | 61 +-- .../villagers/tile/TileEntityGenericSpawner.java | 2 +- .../gtPlusPlus/preloader/Preloader_GT_OreDict.java | 41 +- .../transformers/Preloader_ClassTransformer2.java | 6 +- .../xmod/bartcrops/HANDLER_CropsPlusPlus.java | 21 + .../xmod/bartcrops/LoaderOfTheCrops.java | 109 +++++ .../bartcrops/abstracts/BaseAestheticCrop.java | 37 ++ .../xmod/bartcrops/abstracts/BaseCrop.java | 56 +++ .../bartcrops/abstracts/BaseHarvestableCrop.java | 69 ++++ .../gtPlusPlus/xmod/bartcrops/crops/Crop_Hemp.java | 56 +++ .../xmod/eio/handler/HandlerTooltip_EIO.java | 8 +- src/Java/gtPlusPlus/xmod/forestry/HANDLER_FR.java | 8 +- .../forestry/bees/custom/GTPP_Bee_Definition.java | 2 +- .../xmod/forestry/bees/custom/GTPP_Bees.java | 2 +- .../galacticraft/handler/HandlerTooltip_GC.java | 5 +- .../core/world/gen/ChunkProviderGalactic.java | 46 ++- .../xmod/galacticraft/util/GalacticUtils.java | 10 +- .../GT_MetaTileEntity_Hatch_Naquadah.java | 2 +- .../GT_MetaTileEntity_Hatch_Plasma.java | 10 +- .../base/GregtechMeta_MultiBlockBase.java | 18 +- .../xmod/gregtech/api/objects/MultiblockLayer.java | 10 +- .../api/util/GregtechOreDictUnificator.java | 3 - .../xmod/gregtech/common/Meta_GT_Proxy.java | 125 +++++- .../xmod/gregtech/common/StaticFields59.java | 6 +- .../gregtech/common/helpers/ChargingHelper.java | 9 +- .../gregtech/common/helpers/TreeFarmHelper.java | 4 +- .../common/items/MetaGeneratedGregtechItems.java | 2 +- .../multi/production/GT4Entity_AutoCrafter.java | 2 +- .../GregtechMetaTileEntity_Cyclotron.java | 10 +- ...egtechMetaTileEntity_IndustrialFishingPond.java | 2 +- .../GregtechMetaTileEntity_Refinery.java | 67 ++-- .../xmod/gregtech/loaders/GT_Material_Loader.java | 17 +- .../xmod/gregtech/recipes/GregtechRecipeAdder.java | 5 +- .../gregtech/GregtechNitroDieselFix.java | 5 +- .../xmod/growthcraft/fishtrap/FishTrapHandler.java | 5 +- .../xmod/sc2/modules/ModuleExoticSeeds.java | 4 +- .../xmod/thaumcraft/HANDLER_Thaumcraft.java | 5 +- .../gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java | 4 +- .../xmod/tinkers/material/BaseTinkersMaterial.java | 200 ++++++++++ .../gtPlusPlus/xmod/tinkers/util/TinkersUtils.java | 66 +++- src/Java/gtPlusPlus/xmod/witchery/WitchUtils.java | 21 +- .../vswe/stevescarts/ModuleData/GppModuleData.java | 2 +- 76 files changed, 1470 insertions(+), 598 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/item/tool/misc/DebugScanner.java delete mode 100644 src/Java/gtPlusPlus/core/util/reflect/ClientProxyFinder.java create mode 100644 src/Java/gtPlusPlus/xmod/bartcrops/HANDLER_CropsPlusPlus.java create mode 100644 src/Java/gtPlusPlus/xmod/bartcrops/LoaderOfTheCrops.java create mode 100644 src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseAestheticCrop.java create mode 100644 src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseCrop.java create mode 100644 src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseHarvestableCrop.java create mode 100644 src/Java/gtPlusPlus/xmod/bartcrops/crops/Crop_Hemp.java create mode 100644 src/Java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java (limited to 'src/Java/gtPlusPlus/core/handler') diff --git a/src/Java/gregtech/api/util/FishPondFakeRecipe.java b/src/Java/gregtech/api/util/FishPondFakeRecipe.java index 9e0a65a6cc..5d74329135 100644 --- a/src/Java/gregtech/api/util/FishPondFakeRecipe.java +++ b/src/Java/gregtech/api/util/FishPondFakeRecipe.java @@ -27,7 +27,7 @@ public class FishPondFakeRecipe { junk = (ArrayList) ReflectionUtils.getField(FishingHooks.class, "junk").get(null); treasure = (ArrayList) ReflectionUtils.getField(FishingHooks.class, "treasure").get(null); } - catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + catch (IllegalArgumentException | IllegalAccessException e) { Logger.INFO("Error generating Fish Pond Recipes. [1]"); e.printStackTrace(); } @@ -46,7 +46,7 @@ public class FishPondFakeRecipe { 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) { + catch (IllegalArgumentException | IllegalAccessException e1) { Logger.INFO("Error generating Fish Pond Recipes. [2]"); e1.printStackTrace(); } diff --git a/src/Java/gtPlusPlus/GTplusplus.java b/src/Java/gtPlusPlus/GTplusplus.java index 2e3133c343..5c3d5fb801 100644 --- a/src/Java/gtPlusPlus/GTplusplus.java +++ b/src/Java/gtPlusPlus/GTplusplus.java @@ -301,6 +301,9 @@ public class GTplusplus implements ActionListener { if (CORE.RA.addMultiblockCentrifugeRecipe(x.mInputs, x.mFluidInputs, x.mFluidOutputs, x.mOutputs, x.mChances, x.mDuration, x.mEUt, x.mSpecialValue)) { mValidCount[0]++; } + else { + mInvalidCount[0]++; + } } else { Logger.INFO("[Recipe] Error generating Large Centrifuge recipe."); @@ -329,6 +332,9 @@ public class GTplusplus implements ActionListener { if (CORE.RA.addMultiblockElectrolyzerRecipe(x.mInputs, x.mFluidInputs, x.mFluidOutputs, x.mOutputs, x.mChances, x.mDuration, x.mEUt, x.mSpecialValue)) { mValidCount[1]++; } + else { + mInvalidCount[1]++; + } } else { Logger.INFO("[Recipe] Error generating Large Electrolyzer recipe."); @@ -370,11 +376,19 @@ public class GTplusplus implements ActionListener { mValidCount[2]++; } } + else { + mInvalidCount[2]++; + } } else { mInvalidCount[2]++; } } + + //Redo plasma recipes in Adv. Vac. + //Meta_GT_Proxy.generatePlasmaRecipesForAdvVacFreezer(); + + String[] machineName = new String[] {"Centrifuge", "Electrolyzer", "Vacuum Freezer"}; for (int i=0;i<3;i++) { Logger.INFO("[Recipe] Generated "+mValidCount[i]+" recipes for the Industrial "+machineName[i]+". The original machine can process "+mOriginalCount[i]+" recipes, meaning "+mInvalidCount[i]+" are invalid for this Multiblock's processing in some way."); diff --git a/src/Java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia_Ore_Layer.java b/src/Java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia_Ore_Layer.java index bbaa7ef008..a5e5f8b245 100644 --- a/src/Java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia_Ore_Layer.java +++ b/src/Java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia_Ore_Layer.java @@ -72,7 +72,7 @@ extends WorldGen_GT_Australia { Field temp = ReflectionUtils.getField(GregTech_API.class, "sBlockStones"); tempBlock = temp.get(null); } - catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {} + catch (IllegalArgumentException | IllegalAccessException e) {} mStoneTypes = (Block) tempBlock; } else { diff --git a/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java b/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java index 4d7478dbdd..e1bc3462be 100644 --- a/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java +++ b/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java @@ -113,7 +113,7 @@ public class BlockBaseOre extends BasicBlock implements ITexturedBlock { hiddenTextureArray = new IIconContainer[6]; } } - catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) { + catch (IllegalArgumentException | IllegalAccessException e) { hiddenTextureArray = new IIconContainer[6]; } } @@ -216,7 +216,7 @@ public class BlockBaseOre extends BasicBlock implements ITexturedBlock { hiddenTextureArray = new IIconContainer[6]; } } - catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) { + catch (IllegalArgumentException | IllegalAccessException e) { hiddenTextureArray = new IIconContainer[6]; } } diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java b/src/Java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java index eecc379290..fdb6b1a0a8 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java @@ -133,34 +133,24 @@ public class Machine_ProjectTable extends BlockContainer implements ITileTooltip } @Optional.Method(modid = "EnderIO") - private static boolean checkEnderIOWrench(final ItemStack item){ - if (ReflectionUtils.doesClassExist("crazypants.enderio.api.tool.ITool")){ + private static boolean checkEnderIOWrench(final ItemStack item) { + if (ReflectionUtils.doesClassExist("crazypants.enderio.api.tool.ITool")) { Class wrenchClass; - try { - wrenchClass = Class.forName("crazypants.enderio.api.tool.ITool"); - if (wrenchClass.isInstance(item.getItem())){ - return true; - } - } - catch (final ClassNotFoundException e1) { - return false; + wrenchClass = ReflectionUtils.getClass("crazypants.enderio.api.tool.ITool"); + if (wrenchClass.isInstance(item.getItem())) { + return true; } } return false; } @Optional.Method(modid = "Buildcraft") - private static boolean checkBuildcraftWrench(final ItemStack item){ - if (ReflectionUtils.doesClassExist("buildcraft.api.tools.IToolWrench")){ + private static boolean checkBuildcraftWrench(final ItemStack item) { + if (ReflectionUtils.doesClassExist("buildcraft.api.tools.IToolWrench")) { Class wrenchClass; - try { - wrenchClass = Class.forName("buildcraft.api.tools.IToolWrench"); - if (wrenchClass.isInstance(item.getItem())){ - return true; - } - } - catch (final ClassNotFoundException e1) { - return false; + wrenchClass = ReflectionUtils.getClass("buildcraft.api.tools.IToolWrench"); + if (wrenchClass.isInstance(item.getItem())) { + return true; } } return false; diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java b/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java index 675aeaaf2b..5c08612042 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java @@ -121,34 +121,24 @@ public class Machine_Workbench extends BlockContainer } @Optional.Method(modid = "EnderIO") - private static boolean checkEnderIOWrench(final ItemStack item){ - if (ReflectionUtils.doesClassExist("crazypants.enderio.api.tool.ITool")){ + private static boolean checkEnderIOWrench(final ItemStack item) { + if (ReflectionUtils.doesClassExist("crazypants.enderio.api.tool.ITool")) { Class wrenchClass; - try { - wrenchClass = Class.forName("crazypants.enderio.api.tool.ITool"); - if (wrenchClass.isInstance(item.getItem())){ - return true; - } - } - catch (final ClassNotFoundException e1) { - return false; + wrenchClass = ReflectionUtils.getClass("crazypants.enderio.api.tool.ITool"); + if (wrenchClass.isInstance(item.getItem())) { + return true; } } return false; } @Optional.Method(modid = "Buildcraft") - private static boolean checkBuildcraftWrench(final ItemStack item){ - if (ReflectionUtils.doesClassExist("buildcraft.api.tools.IToolWrench")){ + private static boolean checkBuildcraftWrench(final ItemStack item) { + if (ReflectionUtils.doesClassExist("buildcraft.api.tools.IToolWrench")) { Class wrenchClass; - try { - wrenchClass = Class.forName("buildcraft.api.tools.IToolWrench"); - if (wrenchClass.isInstance(item.getItem())){ - return true; - } - } - catch (final ClassNotFoundException e1) { - return false; + wrenchClass = ReflectionUtils.getClass("buildcraft.api.tools.IToolWrench"); + if (wrenchClass.isInstance(item.getItem())) { + return true; } } return false; diff --git a/src/Java/gtPlusPlus/core/client/renderer/RenderGiantChicken.java b/src/Java/gtPlusPlus/core/client/renderer/RenderGiantChicken.java index 59621ef830..bc00db7ed1 100644 --- a/src/Java/gtPlusPlus/core/client/renderer/RenderGiantChicken.java +++ b/src/Java/gtPlusPlus/core/client/renderer/RenderGiantChicken.java @@ -21,7 +21,7 @@ public class RenderGiantChicken extends RenderChicken { try { mChicken = (ResourceLocation) ReflectionUtils.getField(RenderGiantChicken.class, "chickenTextures").get(null); } - catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + catch (IllegalArgumentException | IllegalAccessException e) { mChicken = new ResourceLocation("textures/entity/chicken.png"); } chickenTexturesEx = mChicken; diff --git a/src/Java/gtPlusPlus/core/common/CommonProxy.java b/src/Java/gtPlusPlus/core/common/CommonProxy.java index 140019f73b..03b643abdb 100644 --- a/src/Java/gtPlusPlus/core/common/CommonProxy.java +++ b/src/Java/gtPlusPlus/core/common/CommonProxy.java @@ -82,7 +82,7 @@ public class CommonProxy { ModBlocks.init(); CI.preInit(); - COMPAT_IntermodStaging.preInit(); + COMPAT_IntermodStaging.preInit(e); BookHandler.run(); // Registration of entities and renderers Logger.INFO("[Proxy] Calling Entity registrator."); @@ -152,7 +152,7 @@ public class CommonProxy { // Compat Handling COMPAT_HANDLER.registerMyModsOreDictEntries(); COMPAT_HANDLER.intermodOreDictionarySupport(); - COMPAT_IntermodStaging.init(); + COMPAT_IntermodStaging.init(e); } public void postInit(final FMLPostInitializationEvent e) { @@ -170,7 +170,7 @@ public class CommonProxy { COMPAT_HANDLER.RemoveRecipesFromOtherMods(); COMPAT_HANDLER.InitialiseHandlerThenAddRecipes(); COMPAT_HANDLER.startLoadingGregAPIBasedRecipes(); - COMPAT_IntermodStaging.postInit(); + COMPAT_IntermodStaging.postInit(e); COMPAT_HANDLER.runQueuedRecipes(); } diff --git a/src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java b/src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java index bdc239b9ce..f6f397f59e 100644 --- a/src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java +++ b/src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java @@ -363,18 +363,15 @@ public class EntityStaballoyConstruct extends EntityIronGolem { } //Get a private field from a super class if it exists. - try { - if (mFirstUpdateField == null) { - mFirstUpdateField = ReflectionUtils.getField(Class.forName("net.minecraft.entity.Entity"), "firstUpdate"); - } - if (mFirstUpdateField != null && mReflectFirstUpdate == true){ - try { - this.mReflectFirstUpdate = (boolean) mFirstUpdateField.get(this); - } - catch (IllegalArgumentException | IllegalAccessException e) {} + if (mFirstUpdateField == null) { + mFirstUpdateField = ReflectionUtils.getField(this.getClass(), "firstUpdate"); + } + if (mFirstUpdateField != null && mReflectFirstUpdate == true){ + try { + this.mReflectFirstUpdate = (boolean) mFirstUpdateField.get(this); } + catch (IllegalArgumentException | IllegalAccessException e) {} } - catch (NoSuchFieldException | ClassNotFoundException e) {} } super.onEntityUpdate(); } diff --git a/src/Java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java b/src/Java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java index f4669bfe35..ed347e8d30 100644 --- a/src/Java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java +++ b/src/Java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java @@ -331,7 +331,7 @@ public class GuiBaseGrindle extends GuiContainer { try { r = (ResourceLocation) ReflectionUtils.getField(GuiScreenBook.class, "bookGuiTextures").get(null); - } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + } catch (IllegalArgumentException | IllegalAccessException e) { r = new ResourceLocation("textures/gui/book.png"); } mBookTexture = r; diff --git a/src/Java/gtPlusPlus/core/gui/machine/GUI_ScrollTest.java b/src/Java/gtPlusPlus/core/gui/machine/GUI_ScrollTest.java index 7a3a01b27c..8a1f7c3fe9 100644 --- a/src/Java/gtPlusPlus/core/gui/machine/GUI_ScrollTest.java +++ b/src/Java/gtPlusPlus/core/gui/machine/GUI_ScrollTest.java @@ -16,6 +16,7 @@ import com.google.common.collect.Lists; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiOptionButton; import net.minecraft.client.gui.GuiResourcePackAvailable; @@ -145,9 +146,9 @@ public class GUI_ScrollTest extends GuiScreen try { - Class oclass = Class.forName("java.awt.Desktop"); - Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]); - oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {file1.toURI()}); + Class oclass = ReflectionUtils.getClass("java.awt.Desktop"); + Object object = ReflectionUtils.getMethod(oclass, "getDesktop", new Class[0]).invoke((Object)null, new Object[0]); + ReflectionUtils.getMethod(oclass, "browse", new Class[] {URI.class}).invoke(object, new Object[] {file1.toURI()}); } catch (Throwable throwable) { diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java b/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java index 79a2d2a6c0..0f689325a3 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java @@ -1,6 +1,10 @@ package gtPlusPlus.core.handler; +import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLLoadCompleteEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import gtPlusPlus.xmod.bartcrops.HANDLER_CropsPlusPlus; import gtPlusPlus.xmod.bop.HANDLER_BiomesOPlenty; import gtPlusPlus.xmod.computronics.HANDLER_Computronics; import gtPlusPlus.xmod.forestry.HANDLER_FR; @@ -15,7 +19,7 @@ import gtPlusPlus.xmod.tinkers.HANDLER_Tinkers; public class COMPAT_IntermodStaging { - public static void preInit(){ + public static void preInit(FMLPreInitializationEvent preinit){ HANDLER_GT.preInit(); HANDLER_GC.preInit(); HANDLER_TF.preInit(); @@ -28,9 +32,10 @@ public class COMPAT_IntermodStaging { HANDLER_Tinkers.preInit(); HANDLER_SC2.preInit(); HANDLER_GalactiCraft.preInit(); + HANDLER_CropsPlusPlus.preInit(preinit); } - public static void init(){ + public static void init(FMLInitializationEvent init){ HANDLER_GT.init(); HANDLER_GC.init(); HANDLER_TF.init(); @@ -43,9 +48,10 @@ public class COMPAT_IntermodStaging { HANDLER_Tinkers.init(); HANDLER_SC2.init(); HANDLER_GalactiCraft.init(); + HANDLER_CropsPlusPlus.init(init); } - public static void postInit(){ + public static void postInit(FMLPostInitializationEvent postinit){ HANDLER_GT.postInit(); HANDLER_GC.postInit(); HANDLER_TF.postInit(); @@ -58,6 +64,7 @@ public class COMPAT_IntermodStaging { HANDLER_Tinkers.postInit(); HANDLER_SC2.postInit(); HANDLER_GalactiCraft.postInit(); + HANDLER_CropsPlusPlus.postInit(postinit); } public static void onLoadComplete(FMLLoadCompleteEvent event) { diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index 8d7db4f40a..17aaf5e106 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -61,6 +61,7 @@ import gtPlusPlus.core.item.general.throwables.ItemHydrofluoricAcidPotion; import gtPlusPlus.core.item.general.throwables.ItemSulfuricAcidPotion; import gtPlusPlus.core.item.init.ItemsFoods; import gtPlusPlus.core.item.materials.DustDecayable; +import gtPlusPlus.core.item.tool.misc.DebugScanner; import gtPlusPlus.core.item.tool.misc.GregtechPump; import gtPlusPlus.core.item.tool.misc.SandstoneHammer; import gtPlusPlus.core.item.tool.misc.box.AutoLunchBox; @@ -87,6 +88,7 @@ import gtPlusPlus.core.util.data.StringUtils; import gtPlusPlus.core.util.debug.DEBUG_INIT; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.everglades.GTplusplus_Everglades; import gtPlusPlus.xmod.eio.material.MaterialEIO; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechItems; @@ -328,6 +330,8 @@ public final class ModItems { public static BatteryPackBaseBauble itemChargePack3; public static BatteryPackBaseBauble itemChargePack4; + public static Item itemDebugScanner; + static { Logger.INFO("Items!"); //Default item used when recipes fail, handy for debugging. Let's make sure they exist when this class is called upon. @@ -336,6 +340,9 @@ public final class ModItems { } public static final void init(){ + + itemDebugScanner = new DebugScanner().setTextureName(CORE.MODID + ":itemStickyRubber"); + itemAlkalusDisk = new BaseItemDamageable("itemAlkalusDisk", AddToCreativeTab.tabMisc, 1, 0, "Unknown Use", EnumRarity.rare, EnumChatFormatting.AQUA, false, null); itemBigEgg = new ItemGiantEgg("itemBigEgg", "Ginourmous Chicken Egg", tabMisc, 64, 0, "I had best try disassemble this.. for science!", "fuelLargeChickenEgg", 5000, 0).setTextureName(CORE.MODID + ":itemBigEgg"); itemGenericToken = new ItemGenericToken(); @@ -1002,7 +1009,7 @@ public final class ModItems { //Baubles Mod Test try { - final Class baublesTest = Class.forName("baubles.api.IBauble"); + final Class baublesTest = ReflectionUtils.getClass("baubles.api.IBauble"); if (baublesTest != null){ COMPAT_Baubles.run(); } diff --git a/src/Java/gtPlusPlus/core/item/chemistry/IonParticles.java b/src/Java/gtPlusPlus/core/item/chemistry/IonParticles.java index 517a698e80..e08a509436 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/IonParticles.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/IonParticles.java @@ -6,6 +6,7 @@ import java.util.List; import gregtech.api.enums.Materials; import gtPlusPlus.core.item.base.misc.BaseItemParticle; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.util.Utils; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; @@ -22,18 +23,16 @@ public class IonParticles extends BaseItemParticle { public IonParticles() { - super("Ion", aElements.length, EnumRarity.rare); + super("Ion", ELEMENT.NAMES.length, EnumRarity.rare); } - private static final String[] aElements = new String[]{"Hydrogen", "Helium", "Lithium", "Beryllium", "Boron", "Carbon", "Nitrogen", "Oxygen", "Fluorine", "Neon", "Sodium", "Magnesium", "Aluminum", "Silicon", "Phosphorus", "Sulfur", "Chlorine", "Argon", "Potassium", "Calcium", "Scandium", "Titanium", "Vanadium", "Chromium", "Manganese", "Iron", "Cobalt", "Nickel", "Copper", "Zinc", "Gallium", "Germanium", "Arsenic", "Selenium", "Bromine", "Krypton", "Rubidium", "Strontium", "Yttrium", "Zirconium", "Niobium", "Molybdenum", "Technetium", "Ruthenium", "Rhodium", "Palladium", "Silver", "Cadmium", "Indium", "Tin", "Antimony", "Tellurium", "Iodine", "Xenon", "Cesium", "Barium", "Lanthanum", "Cerium", "Praseodymium", "Neodymium", "Promethium", "Samarium", "Europium", "Gadolinium", "Terbium", "Dysprosium", "Holmium", "Erbium", "Thulium", "Ytterbium", "Lutetium", "Hafnium", "Tantalum", "Tungsten", "Rhenium", "Osmium", "Iridium", "Platinum", "Gold", "Mercury", "Thallium", "Lead", "Bismuth", "Polonium", "Astatine", "Radon", "Francium", "Radium", "Actinium", "Thorium", "Protactinium", "Uranium", "Neptunium", "Plutonium", "Americium", "Curium", "Berkelium", "Californium", "Einsteinium", "Fermium", "Mendelevium", "Nobelium", "Lawrencium", "Rutherfordium", "Dubnium", "Seaborgium", "Bohrium", "Hassium", "Meitnerium", "Darmstadtium", "Roentgenium", "Copernicium", "Nihonium", "Flerovium", "Moscovium", "Livermorium", "Tennessine", "Oganesson"}; - - public static IIcon[] overlays = new IIcon[aElements.length]; + public static IIcon[] overlays = new IIcon[ELEMENT.NAMES.length]; public static IIcon baseTexture; static { //Generate Ions int key = 0; - for (String s : aElements) { + for (String s : ELEMENT.NAMES) { //Map names to Meta NameToMetaMap.put(Utils.sanitizeString(s.toLowerCase()), key); MetaToNameMap.put(key, Utils.sanitizeString(s.toLowerCase())); @@ -62,7 +61,7 @@ public class IonParticles extends BaseItemParticle { @Override public String getUnlocalizedName(final ItemStack itemStack) { - return "item.particle.ion" + "." + aElements[itemStack.getItemDamage()]; + return "item.particle.ion" + "." + ELEMENT.NAMES[itemStack.getItemDamage()]; } private static boolean createNBT(ItemStack rStack){ diff --git a/src/Java/gtPlusPlus/core/item/general/books/ItemBaseBook.java b/src/Java/gtPlusPlus/core/item/general/books/ItemBaseBook.java index 7f6a52f135..2f49ac1287 100644 --- a/src/Java/gtPlusPlus/core/item/general/books/ItemBaseBook.java +++ b/src/Java/gtPlusPlus/core/item/general/books/ItemBaseBook.java @@ -27,6 +27,7 @@ import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.handler.BookHandler; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.NBTUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; public class ItemBaseBook extends ItemWritableBook{ @@ -113,11 +114,11 @@ public class ItemBaseBook extends ItemWritableBook{ if (player.worldObj.isRemote){ try { - Class clazz = Class.forName("net.minecraft.client.gui.GuiScreenBook"); + Class clazz = ReflectionUtils.getClass("net.minecraft.client.gui.GuiScreenBook"); Constructor ctor = clazz.getConstructor(EntityPlayer.class, ItemStack.class, boolean.class); Object object = ctor.newInstance(new Object[] { player, bookstack, false }); Minecraft.getMinecraft().displayGuiScreen((GuiScreen) object); - } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } diff --git a/src/Java/gtPlusPlus/core/item/general/capture/ItemEntityCatcher.java b/src/Java/gtPlusPlus/core/item/general/capture/ItemEntityCatcher.java index 592b68d06a..a95fab4b6c 100644 --- a/src/Java/gtPlusPlus/core/item/general/capture/ItemEntityCatcher.java +++ b/src/Java/gtPlusPlus/core/item/general/capture/ItemEntityCatcher.java @@ -21,6 +21,7 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.NBTUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; public class ItemEntityCatcher extends Item implements IEntityCatcher { @@ -117,14 +118,10 @@ public class ItemEntityCatcher extends Item implements IEntityCatcher { } Class mEntityClass; String mClassName; - mClassName = NBTUtils.getString(aStack,"mClassName"); - try { - mEntityClass = (Class) Class.forName(mClassName); - if (mEntityClass != null) { - return mEntityClass; - } - } - catch (ClassNotFoundException e) { + mClassName = NBTUtils.getString(aStack, "mClassName"); + mEntityClass = (Class) ReflectionUtils.getClass(mClassName); + if (mEntityClass != null) { + return mEntityClass; } return null; } diff --git a/src/Java/gtPlusPlus/core/item/tool/misc/DebugScanner.java b/src/Java/gtPlusPlus/core/item/tool/misc/DebugScanner.java new file mode 100644 index 0000000000..bc252c95a9 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/tool/misc/DebugScanner.java @@ -0,0 +1,98 @@ +package gtPlusPlus.core.item.tool.misc; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.CoreItem; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class DebugScanner extends CoreItem { + + public DebugScanner() { + super("gtpp.debug.scanner", AddToCreativeTab.tabTools, 1, 0, + new String[] { + "Used to obtain information from GT/GT++ content", + "Right Click to use", + }, + EnumRarity.epic); + } + + @Override + public boolean isDamageable() { + return false; + } + + @Override + public boolean onItemUse(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int p_77648_4_, + int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { + // TODO Auto-generated method stub + return super.onItemUse(aStack, aPlayer, aWorld, p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_8_, + p_77648_9_, p_77648_10_); + } + + @Override + public boolean isRepairable() { + return false; + } + + @Override + public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { + // TODO Auto-generated method stub + return super.onItemRightClick(p_77659_1_, p_77659_2_, p_77659_3_); + } + + @Override + public float getDigSpeed(ItemStack itemstack, Block block, int metadata) { + return 0f; + } + + @Override + public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { + if (entity != null && player != null) { + PlayerUtils.messagePlayer(player, "Entity ID: "+entity.getEntityId()); + PlayerUtils.messagePlayer(player, "UUID: "+entity.getUniqueID()); + PlayerUtils.messagePlayer(player, "Invulnerable? "+entity.isEntityInvulnerable()); + PlayerUtils.messagePlayer(player, "Invisible? "+entity.isInvisible()); + PlayerUtils.messagePlayer(player, "Age: "+entity.ticksExisted); + + if (entity instanceof EntityLiving) { + EntityLiving g = (EntityLiving) entity; + PlayerUtils.messagePlayer(player, "Health: "+g.getHealth()+"/"+g.getMaxHealth()); + PlayerUtils.messagePlayer(player, "On ground? "+g.onGround); + PlayerUtils.messagePlayer(player, "Can Loot? "+g.canPickUpLoot()); + PlayerUtils.messagePlayer(player, "Child? "+g.isChild()); + if (entity instanceof EntityPlayer) { + EntityPlayer y = (EntityPlayer) entity; + PlayerUtils.messagePlayer(player, "Experience: "+y.experience); + PlayerUtils.messagePlayer(player, "Name: "+y.getCommandSenderName()); + } + + } + + } + return true; + } + + @Override + public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player) { + return false; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return true; + } + + @Override + public int getHarvestLevel(ItemStack stack, String toolClass) { + return 0; + } + + + +} diff --git a/src/Java/gtPlusPlus/core/lib/CORE.java b/src/Java/gtPlusPlus/core/lib/CORE.java index c7d09b959d..1f82e1cd17 100644 --- a/src/Java/gtPlusPlus/core/lib/CORE.java +++ b/src/Java/gtPlusPlus/core/lib/CORE.java @@ -52,7 +52,7 @@ public class CORE { public static final String name = "GT++"; public static final String MODID = "miscutils"; - public static final String VERSION = "1.7.02.24"; + public static final String VERSION = "1.7.02.89-debug"; public static String MASTER_VERSION = NetworkUtils.getContentFromURL("https://raw.githubusercontent.com/draknyte1/GTplusplus/master/Recommended.txt").toLowerCase(); public static String USER_COUNTRY = GeoUtils.determineUsersCountry(); public static boolean isModUpToDate = Utils.isModUpToDate(); diff --git a/src/Java/gtPlusPlus/core/lib/LoadedMods.java b/src/Java/gtPlusPlus/core/lib/LoadedMods.java index e749885dd6..5a2b75337b 100644 --- a/src/Java/gtPlusPlus/core/lib/LoadedMods.java +++ b/src/Java/gtPlusPlus/core/lib/LoadedMods.java @@ -54,6 +54,7 @@ public class LoadedMods { public static boolean StevesCarts = false; public static boolean Witchery = false; public static boolean Waila = false; + public static boolean CropsPlusPlus = false; //Barts Crop Mod @@ -96,6 +97,11 @@ public class LoadedMods { Logger.INFO("Components enabled for: PlayerAPI"); totalMods++; } + if (Loader.isModLoaded("berriespp")) { + CropsPlusPlus = true; + Logger.INFO("Components enabled for: Crops++"); + totalMods++; + } if (Loader.isModLoaded("TConstruct")){ TiCon = true; Logger.INFO("Components enabled for: Tinkers Construct"); diff --git a/src/Java/gtPlusPlus/core/material/ELEMENT.java b/src/Java/gtPlusPlus/core/material/ELEMENT.java index 99bc37444e..62e1163a39 100644 --- a/src/Java/gtPlusPlus/core/material/ELEMENT.java +++ b/src/Java/gtPlusPlus/core/material/ELEMENT.java @@ -11,6 +11,8 @@ import gtPlusPlus.core.util.minecraft.MaterialUtils; public final class ELEMENT { + public static final String[] NAMES = new String[]{"Hydrogen", "Helium", "Lithium", "Beryllium", "Boron", "Carbon", "Nitrogen", "Oxygen", "Fluorine", "Neon", "Sodium", "Magnesium", "Aluminum", "Silicon", "Phosphorus", "Sulfur", "Chlorine", "Argon", "Potassium", "Calcium", "Scandium", "Titanium", "Vanadium", "Chromium", "Manganese", "Iron", "Cobalt", "Nickel", "Copper", "Zinc", "Gallium", "Germanium", "Arsenic", "Selenium", "Bromine", "Krypton", "Rubidium", "Strontium", "Yttrium", "Zirconium", "Niobium", "Molybdenum", "Technetium", "Ruthenium", "Rhodium", "Palladium", "Silver", "Cadmium", "Indium", "Tin", "Antimony", "Tellurium", "Iodine", "Xenon", "Cesium", "Barium", "Lanthanum", "Cerium", "Praseodymium", "Neodymium", "Promethium", "Samarium", "Europium", "Gadolinium", "Terbium", "Dysprosium", "Holmium", "Erbium", "Thulium", "Ytterbium", "Lutetium", "Hafnium", "Tantalum", "Tungsten", "Rhenium", "Osmium", "Iridium", "Platinum", "Gold", "Mercury", "Thallium", "Lead", "Bismuth", "Polonium", "Astatine", "Radon", "Francium", "Radium", "Actinium", "Thorium", "Protactinium", "Uranium", "Neptunium", "Plutonium", "Americium", "Curium", "Berkelium", "Californium", "Einsteinium", "Fermium", "Mendelevium", "Nobelium", "Lawrencium", "Rutherfordium", "Dubnium", "Seaborgium", "Bohrium", "Hassium", "Meitnerium", "Darmstadtium", "Roentgenium", "Copernicium", "Nihonium", "Flerovium", "Moscovium", "Livermorium", "Tennessine", "Oganesson"}; + //First 50 Elements public final Material HYDROGEN = MaterialUtils.generateMaterialFromGtENUM(Materials.Hydrogen); public final Material HELIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Helium); @@ -148,8 +150,8 @@ public final class ELEMENT { public final Material AMERICIUM241 = new Material("Americium-241", MaterialState.SOLID, TextureSets.NUCLEAR.get(), Materials.Americium.mDurability, Materials.Americium.mRGBa, Materials.Americium.mMeltingPoint, Materials.Americium.mBlastFurnaceTemp, 95, 146, false, StringUtils.superscript("241Am"), 2, false);//Not a GT Inherited Material public final Material MAGIC = MaterialUtils.generateMaterialFromGtENUM(Materials.Magic, new short[] {10, 185, 140}); - public final Material THAUMIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Thaumium); - + public final Material THAUMIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Thaumium); + static { Logger.MATERIALS("Initialising Base Elements."); } diff --git a/src/Java/gtPlusPlus/core/material/Material.java b/src/Java/gtPlusPlus/core/material/Material.java index 03e50aa7dd..d996bed128 100644 --- a/src/Java/gtPlusPlus/core/material/Material.java +++ b/src/Java/gtPlusPlus/core/material/Material.java @@ -1,6 +1,7 @@ package gtPlusPlus.core.material; import static gregtech.api.enums.GT_Values.M; +import static gtPlusPlus.core.util.math.MathUtils.safeCast_LongToInt; import java.util.ArrayList; import java.util.HashMap; @@ -317,28 +318,13 @@ public class Material { this.vDurability = durability; } else { - if (inputs != null){ - long durabilityTemp = 0; - int counterTemp = 0; - for (final MaterialStack m : inputs){ - if (m.getStackMaterial() != null){ - if (m.getStackMaterial().vDurability != 0){ - durabilityTemp = (durabilityTemp+m.getStackMaterial().vDurability); - counterTemp++; - - } - } + long aTempDura = 0; + for (MaterialStack g : this.getComposites()) { + if (g != null) { + aTempDura += safeCast_LongToInt(g.getStackMaterial().getMass() * 2000); } - if ((durabilityTemp != 0) && (counterTemp != 0)){ - this.vDurability = (durabilityTemp/counterTemp); - } - else { - this.vDurability = 8196; - } - } - else { - this.vDurability = 0; } + this.vDurability = aTempDura > 0 ? aTempDura : (this.getComposites().isEmpty() ? 51200 : 32000 * this.getComposites().size()); } if ((this.vDurability >= 0) && (this.vDurability < 64000)){ @@ -362,8 +348,8 @@ public class Material { this.vHarvestLevel = 4; } else { - this.vToolQuality = 0; - this.vHarvestLevel = 0; + this.vToolQuality = 1; + this.vHarvestLevel = 1; } //Sets the Rad level diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index 6f4e8870d7..6210f9726c 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -1607,6 +1607,8 @@ public class RECIPES_GREGTECH { ItemUtils.getItemStackOfAmountFromOreDict("plateMeatRaw", 1)); GT_ModHandler.addCompressionRecipe(ItemUtils.getItemStackOfAmountFromOreDict("dustMeatRaw", 9), ItemUtils.getItemStackOfAmountFromOreDict("blockMeatRaw", 1)); + + CORE.RA.addCompressorRecipe(ItemList.FusionComputer_UV.get(9), GregtechItemList.Compressed_Fusion_Reactor.get(1), (int) GT_Values.V[7], (int) GT_Values.V[8]); } private static void macerationRecipes() { diff --git a/src/Java/gtPlusPlus/core/slots/SlotToolBox.java b/src/Java/gtPlusPlus/core/slots/SlotToolBox.java index c6d025fd21..87967b75b5 100644 --- a/src/Java/gtPlusPlus/core/slots/SlotToolBox.java +++ b/src/Java/gtPlusPlus/core/slots/SlotToolBox.java @@ -18,34 +18,34 @@ public class SlotToolBox extends SlotGtTool { Class temp; //IHL Pumps - temp = ReflectionUtils.getClassByName("ihl.handpump.IHLHandPump"); + temp = ReflectionUtils.getClass("ihl.handpump.IHLHandPump"); if (temp != null) { mSupportedCustomTools.put(temp); temp = null; } //IC2 Electrics - temp = ReflectionUtils.getClassByName("ic2.api.item.IElectricItem"); + temp = ReflectionUtils.getClass("ic2.api.item.IElectricItem"); if (temp != null) { mSupportedCustomTools.put(temp); temp = null; } //IC2 Boxables - temp = ReflectionUtils.getClassByName(" ic2.api.item.IBoxable"); + temp = ReflectionUtils.getClass(" ic2.api.item.IBoxable"); if (temp != null) { mSupportedCustomTools.put(temp); temp = null; } //Tinkers Tools - temp = ReflectionUtils.getClassByName("tconstruct.library.tools.Weapon"); + temp = ReflectionUtils.getClass("tconstruct.library.tools.Weapon"); if (temp != null) { mSupportedCustomTools.put(temp); temp = null; } //BattleGear Weapons - temp = ReflectionUtils.getClassByName("mods.battlegear2.api.weapons.IBattlegearWeapon"); + temp = ReflectionUtils.getClass("mods.battlegear2.api.weapons.IBattlegearWeapon"); if (temp != null) { mSupportedCustomTools.put(temp); temp = null; @@ -55,7 +55,7 @@ public class SlotToolBox extends SlotGtTool { //OpenMods String[] OpenModsContent = new String[] {"openblocks.common.item.ItemDevNull", "openblocks.common.item.ItemHangGlider", "openblocks.common.item.ItemWrench", "openblocks.common.item.ItemSleepingBag"}; for (String t : OpenModsContent) { - temp = ReflectionUtils.getClassByName(t); + temp = ReflectionUtils.getClass(t); if (temp != null) { mSupportedCustomTools.put(temp); temp = null; @@ -63,7 +63,7 @@ public class SlotToolBox extends SlotGtTool { } //GC Wrench - temp = ReflectionUtils.getClassByName("micdoodle8.mods.galacticraft.core.items.ItemUniversalWrench"); + temp = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.items.ItemUniversalWrench"); if (temp != null) { mSupportedCustomTools.put(temp); temp = null; @@ -72,7 +72,7 @@ public class SlotToolBox extends SlotGtTool { //EIO String[] EioContent = new String[] {"crazypants.enderio.api.tool.ITool", "crazypants.enderio.item.ItemMagnet", "crazypants.enderio.item.ItemConduitProbe"}; for (String t : EioContent) { - temp = ReflectionUtils.getClassByName(t); + temp = ReflectionUtils.getClass(t); if (temp != null) { mSupportedCustomTools.put(temp); temp = null; @@ -80,7 +80,7 @@ public class SlotToolBox extends SlotGtTool { } //Forestry - temp = ReflectionUtils.getClassByName("forestry.core.items.ItemForestryTool"); + temp = ReflectionUtils.getClass("forestry.core.items.ItemForestryTool"); if (temp != null) { mSupportedCustomTools.put(temp); temp = null; diff --git a/src/Java/gtPlusPlus/core/util/Utils.java b/src/Java/gtPlusPlus/core/util/Utils.java index 81e2e94154..7d1d42abf0 100644 --- a/src/Java/gtPlusPlus/core/util/Utils.java +++ b/src/Java/gtPlusPlus/core/util/Utils.java @@ -798,7 +798,7 @@ public class Utils { return new Pair(9, 28); } - clazz = (Class) Class.forName("gregtech.GT_Mod"); + clazz = (Class) ReflectionUtils.getClass("gregtech.GT_Mod"); Field mSubversion = ReflectionUtils.getField(clazz, "SUBVERSION"); if (mSubversion != null){ int mSub = 0; diff --git a/src/Java/gtPlusPlus/core/util/minecraft/FoodUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/FoodUtils.java index a1c2bf6104..9f5d4f36ca 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/FoodUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/FoodUtils.java @@ -13,7 +13,7 @@ public class FoodUtils { public static final Class IEdibleClass; static { - IEdibleClass = ReflectionUtils.getClassByName("squeek.applecore.api.food.IEdible"); + IEdibleClass = ReflectionUtils.getClass("squeek.applecore.api.food.IEdible"); } public static boolean isFood(ItemStack food) { diff --git a/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java index 45d21a3016..842b8eecb2 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java @@ -322,7 +322,7 @@ public class MaterialUtils { mName = (String) ReflectionUtils.getField(Materials.class, "mName").get(mat); } } - catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + catch (IllegalArgumentException | IllegalAccessException e) { } diff --git a/src/Java/gtPlusPlus/core/util/minecraft/MiningUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/MiningUtils.java index e7ced98f5a..080b5665a3 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/MiningUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/MiningUtils.java @@ -152,7 +152,7 @@ public class MiningUtils { try { aTextWorldGen = (String) ReflectionUtils.getField(GT_Worldgen_GT_Ore_Layer.class, "aTextWorldgen").get(h); - } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + } catch (IllegalArgumentException | IllegalAccessException e) { aTextWorldGen = h.mWorldGenName; } @@ -180,27 +180,27 @@ public class MiningUtils { boolean aEndAsteroids; try { - if (Class.forName("micdoodle8.mods.galacticraft.core.util.ConfigManagerCore") != null && mMoonID == -99) { - mMoonID = ReflectionUtils.getField(Class.forName("micdoodle8.mods.galacticraft.core.util.ConfigManagerCore"), "idDimensionMoon").getInt(null); + if (ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.util.ConfigManagerCore") != null && mMoonID == -99) { + mMoonID = ReflectionUtils.getField(ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.util.ConfigManagerCore"), "idDimensionMoon").getInt(null); } } - catch (ClassNotFoundException | IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) {} + catch (IllegalArgumentException | IllegalAccessException e) {} //Gets Mars ID try { - if (Class.forName("micdoodle8.mods.galacticraft.planets.mars.ConfigManagerMars") != null && mMarsID == -99) { - mMarsID = ReflectionUtils.getField(Class.forName("micdoodle8.mods.galacticraft.planets.mars.ConfigManagerMars"), "dimensionIDMars").getInt(null); + if (ReflectionUtils.getClass("micdoodle8.mods.galacticraft.planets.mars.ConfigManagerMars") != null && mMarsID == -99) { + mMarsID = ReflectionUtils.getField(ReflectionUtils.getClass("micdoodle8.mods.galacticraft.planets.mars.ConfigManagerMars"), "dimensionIDMars").getInt(null); } } - catch (ClassNotFoundException | IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) {} + catch (IllegalArgumentException | IllegalAccessException e) {} //Get Comets ID try { - if (Class.forName("micdoodle8.mods.galacticraft.planets.asteroids.ConfigManagerAsteroids") != null && mCometsID == -99) { - mCometsID = ReflectionUtils.getField(Class.forName("micdoodle8.mods.galacticraft.planets.asteroids.ConfigManagerAsteroids"), "dimensionIDAsteroids").getInt(null); + if (ReflectionUtils.getClass("micdoodle8.mods.galacticraft.planets.asteroids.ConfigManagerAsteroids") != null && mCometsID == -99) { + mCometsID = ReflectionUtils.getField(ReflectionUtils.getClass("micdoodle8.mods.galacticraft.planets.asteroids.ConfigManagerAsteroids"), "dimensionIDAsteroids").getInt(null); } } - catch (ClassNotFoundException | IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) {} + catch (IllegalArgumentException | IllegalAccessException e) {} //Clear Cache Ores_Overworld.clear(); @@ -215,7 +215,7 @@ public class MiningUtils { try { aEndAsteroids = ReflectionUtils.getField(GT_Worldgen_GT_Ore_Layer.class, "mEndAsteroid").getBoolean(x); } - catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + catch (IllegalArgumentException | IllegalAccessException e) { aEndAsteroids = false; } diff --git a/src/Java/gtPlusPlus/core/util/minecraft/gregtech/PollutionUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/gregtech/PollutionUtils.java index dde785cee6..aeeb4ae5be 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/gregtech/PollutionUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/gregtech/PollutionUtils.java @@ -39,7 +39,7 @@ public class PollutionUtils { return mPollution.getBoolean(GT_Pollution); } } - } catch (SecurityException | IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + } catch (SecurityException | IllegalArgumentException | IllegalAccessException e) { } return false; } @@ -53,16 +53,16 @@ public class PollutionUtils { if (mAddPollution != null) { mAddPollution.invoke(null, te, pollutionValue); } - Class GT_Pollution = Class.forName("gregtech.common.GT_Pollution"); + Class GT_Pollution = ReflectionUtils.getClass("gregtech.common.GT_Pollution"); if (GT_Pollution != null) { - Method addPollution = GT_Pollution.getMethod("addPollution", IGregTechTileEntity.class, int.class); + Method addPollution = ReflectionUtils.getMethod(GT_Pollution, "addPollution", IGregTechTileEntity.class, int.class); if (addPollution != null) { mAddPollution = addPollution; addPollution.invoke(null, te, pollutionValue); return true; } } - } catch (ClassNotFoundException | SecurityException | NoSuchMethodException | IllegalAccessException + } catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { } return false; @@ -92,16 +92,16 @@ public class PollutionUtils { mAddPollution2.invoke(null, aChunk, pollutionValue); return true; } - Class GT_Pollution = Class.forName("gregtech.common.GT_Pollution"); + Class GT_Pollution = ReflectionUtils.getClass("gregtech.common.GT_Pollution"); if (GT_Pollution != null) { - Method addPollution = GT_Pollution.getMethod("addPollution", Chunk.class, int.class); + Method addPollution = ReflectionUtils.getMethod(GT_Pollution, "addPollution", Chunk.class, int.class); if (addPollution != null) { mAddPollution2 = addPollution; mAddPollution2.invoke(null, aChunk, pollutionValue); return true; } } - } catch (ClassNotFoundException | SecurityException | NoSuchMethodException | IllegalAccessException + } catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { } return false; @@ -128,15 +128,15 @@ public class PollutionUtils { if (mGetPollution != null) { mGetPollution.invoke(null, te); } - Class GT_Pollution = Class.forName("gregtech.common.GT_Pollution"); + Class GT_Pollution = ReflectionUtils.getClass("gregtech.common.GT_Pollution"); if (GT_Pollution != null) { - Method addPollution = GT_Pollution.getMethod("getPollution", IGregTechTileEntity.class); + Method addPollution = ReflectionUtils.getMethod(GT_Pollution, "getPollution", IGregTechTileEntity.class); if (addPollution != null) { mGetPollution = addPollution; return (int) addPollution.invoke(null, te); } } - } catch (ClassNotFoundException | SecurityException | NoSuchMethodException | IllegalAccessException + } catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { } return 0; @@ -151,15 +151,15 @@ public class PollutionUtils { if (mGetPollution2 != null) { mGetPollution2.invoke(null, te); } - Class GT_Pollution = Class.forName("gregtech.common.GT_Pollution"); + Class GT_Pollution = ReflectionUtils.getClass("gregtech.common.GT_Pollution"); if (GT_Pollution != null) { - Method addPollution = GT_Pollution.getMethod("getPollution", Chunk.class); + Method addPollution = ReflectionUtils.getMethod(GT_Pollution, "getPollution", Chunk.class); if (addPollution != null) { mGetPollution2 = addPollution; return (int) addPollution.invoke(null, te); } } - } catch (ClassNotFoundException | SecurityException | NoSuchMethodException | IllegalAccessException + } catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { } return 0; diff --git a/src/Java/gtPlusPlus/core/util/reflect/ClientProxyFinder.java b/src/Java/gtPlusPlus/core/util/reflect/ClientProxyFinder.java deleted file mode 100644 index 99a9bf2fa9..0000000000 --- a/src/Java/gtPlusPlus/core/util/reflect/ClientProxyFinder.java +++ /dev/null @@ -1,32 +0,0 @@ -package gtPlusPlus.core.util.reflect; - -import java.lang.reflect.Field; - -import cpw.mods.fml.common.SidedProxy; - -public class ClientProxyFinder { - - public static Object getInstance(final Object modInstance) throws ReflectiveOperationException { - for(final Field field : modInstance.getClass().getDeclaredFields()) { - if(field.isAnnotationPresent(SidedProxy.class)) { - final SidedProxy sidedProxy = field.getAnnotation(SidedProxy.class); - final Object fieldValue = field.get(modInstance); - try { - final Class clientSideClass = Class.forName(sidedProxy.clientSide()); - if(clientSideClass.isAssignableFrom(fieldValue.getClass())) { - final Object clientProxy = clientSideClass.cast(fieldValue); - //do what you want with client proxy instance - return clientProxy; - } - - } catch (final NoClassDefFoundError err) { - //its server side - return null; - } - break; - } - } - return null; - } - -} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/util/reflect/ProxyFinder.java b/src/Java/gtPlusPlus/core/util/reflect/ProxyFinder.java index 85599e4695..d22fafb37b 100644 --- a/src/Java/gtPlusPlus/core/util/reflect/ProxyFinder.java +++ b/src/Java/gtPlusPlus/core/util/reflect/ProxyFinder.java @@ -12,7 +12,7 @@ public class ProxyFinder { final SidedProxy sidedProxy = field.getAnnotation(SidedProxy.class); final Object fieldValue = field.get(modInstance); try { - final Class serverSideClass = Class.forName(sidedProxy.serverSide()); + final Class serverSideClass = ReflectionUtils.getClass(sidedProxy.serverSide()); if(serverSideClass.isAssignableFrom(fieldValue.getClass())) { final Object serverProxy = serverSideClass.cast(fieldValue); //do what you want with server proxy instance @@ -35,7 +35,7 @@ public class ProxyFinder { final SidedProxy sidedProxy = field.getAnnotation(SidedProxy.class); final Object fieldValue = field.get(modInstance); try { - final Class clientSideClass = Class.forName(sidedProxy.clientSide()); + final Class clientSideClass = ReflectionUtils.getClass(sidedProxy.clientSide()); if(clientSideClass.isAssignableFrom(fieldValue.getClass())) { final Object clientProxy = clientSideClass.cast(fieldValue); //do what you want with client proxy instance diff --git a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java index dee9d76a4c..4ade8b1096 100644 --- a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java +++ b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java @@ -1,110 +1,216 @@ package gtPlusPlus.core.util.reflect; import java.io.IOException; -import java.lang.reflect.*; -import java.net.URL; -import java.util.HashSet; -import java.util.Scanner; - -import org.apache.commons.lang3.reflect.FieldUtils; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.LinkedHashMap; +import java.util.Map; import com.google.common.reflect.ClassPath; -import net.minecraft.client.Minecraft; - -import gregtech.GT_Mod; -import gtPlusPlus.GTplusplus; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.lib.CORE; public class ReflectionUtils { - public static Field getField(final Class clazz, final String fieldName) throws NoSuchFieldException { - try { - Field k = clazz.getDeclaredField(fieldName); - makeAccessible(k); - //Logger.REFLECTION("Got Field from Class. "+fieldName+" did exist within "+clazz.getCanonicalName()+"."); - return k; - } catch (final NoSuchFieldException e) { - final Class superClass = clazz.getSuperclass(); - if (superClass == null) { - //Logger.REFLECTION("Failed to get Field from Class. "+fieldName+" does not existing within "+clazz.getCanonicalName()+"."); - throw e; - } - //Logger.REFLECTION("Failed to get Field from Class. "+fieldName+" does not existing within "+clazz.getCanonicalName()+". Trying super class."); - return getField(superClass, fieldName); + public static Map mCachedClasses = new LinkedHashMap(); + public static Map mCachedMethods = new LinkedHashMap(); + public static Map mCachedFields = new LinkedHashMap(); + + private static class CachedMethod { + + private final boolean STATIC; + private final Method METHOD; + + public CachedMethod(Method aMethod, boolean isStatic) { + METHOD = aMethod; + STATIC = isStatic; + } + + public Method get() { + return METHOD; + } + + public boolean type() { + return STATIC; } + } - public static void makeAccessible(final Field field) { - if (!Modifier.isPublic(field.getModifiers()) || - !Modifier.isPublic(field.getDeclaringClass().getModifiers())) - { - field.setAccessible(true); + private static class CachedField { + + private final boolean STATIC; + private final Field FIELD; + + public CachedField(Field aField, boolean isStatic) { + FIELD = aField; + STATIC = isStatic; + } + + public Field get() { + return FIELD; + } + + public boolean type() { + return STATIC; } + } - //Some Reflection utils - http://stackoverflow.com/questions/14374878/using-reflection-to-set-an-object-property - @SuppressWarnings("unchecked") - public static V getField(final Object object, final String fieldName) { - Class clazz = object.getClass(); - while (clazz != null) { - try { - final Field field = clazz.getDeclaredField(fieldName); - field.setAccessible(true); - return (V) field.get(object); - } catch (final NoSuchFieldException e) { - Logger.REFLECTION("getField("+object.toString()+", "+fieldName+") failed."); - clazz = clazz.getSuperclass(); - } catch (final Exception e) { - Logger.REFLECTION("getField("+object.toString()+", "+fieldName+") failed."); - throw new IllegalStateException(e); + private static boolean cacheClass(Class aClass) { + if (aClass == null) { + return false; + } + Class y = mCachedClasses.get(aClass.getCanonicalName()); + if (y == null) { + mCachedClasses.put(aClass.getCanonicalName(), aClass); + return true; + } + return false; + } + + private static boolean cacheMethod(Method aMethod) { + if (aMethod == null) { + return false; + } + boolean isStatic = Modifier.isStatic(aMethod.getModifiers()); + CachedMethod y = mCachedMethods.get(aMethod.getName()+"."+aMethod.getParameterTypes().toString()); + if (y == null) { + mCachedMethods.put(aMethod.getName()+"."+aMethod.getParameterTypes().toString(), new CachedMethod(aMethod, isStatic)); + return true; + } + return false; + } + + private static boolean cacheField(Field aField) { + if (aField == null) { + return false; + } + boolean isStatic = Modifier.isStatic(aField.getModifiers()); + CachedField y = mCachedFields.get(aField.getName()); + if (y == null) { + mCachedFields.put(aField.getName(), new CachedField(aField, isStatic)); + return true; + } + return false; + } + + + /** + * Returns a cached {@link Class} object. + * @param aClassCanonicalName - The canonical name of the underlying class. + * @return - Valid, {@link Class} object, or {@link null}. + */ + public static Class getClass(String aClassCanonicalName) { + Class y = mCachedClasses.get(aClassCanonicalName); + if (y == null) { + y = getClass_Internal(aClassCanonicalName); + if (y != null) { + cacheClass(y); } } - return null; + return y; } - public static boolean setField(final Object object, final String fieldName, final Object fieldValue) { - Class clazz = object.getClass(); - while (clazz != null) { + + /** + * Returns a cached {@link Method} object. + * @param aClass - Class containing the Method. + * @param aMethodName - Method's name in {@link String} form. + * @param aTypes - Varags Class Types for {@link Method}'s constructor. + * @return - Valid, non-final, {@link Method} object, or {@link null}. + */ + public static Method getMethod(Class aClass, String aMethodName, Class... aTypes) { + String aMethodKey = aTypes.toString(); + CachedMethod y = mCachedMethods.get(aMethodName + "." + aMethodKey); + if (y == null) { + Method u = getMethod_Internal(aClass, aMethodKey, aTypes); + if (u != null) { + cacheMethod(u); + return u; + } else { + return null; + } + } else { + return y.get(); + } + } + + + + /** + * Returns a cached {@link Field} object. + * @param aClass - Class containing the Method. + * @param aFieldName - Field name in {@link String} form. + * @return - Valid, non-final, {@link Field} object, or {@link null}. + */ + public static Field getField(final Class aClass, final String aFieldName) { + CachedField y = mCachedFields.get(aFieldName); + if (y == null) { + Field u; try { - final Field field = getField(clazz, fieldName); - if (field != null) { - setValue(object, field, fieldValue); - return true; + u = getField_Internal(aClass, aFieldName); + if (u != null) { + cacheField(u); + return u; } - } catch (final NoSuchFieldException e) { - Logger.REFLECTION("setField("+object.toString()+", "+fieldName+") failed."); - clazz = clazz.getSuperclass(); - } catch (final Exception e) { - Logger.REFLECTION("setField("+object.toString()+", "+fieldName+") failed."); - throw new IllegalStateException(e); + } catch (NoSuchFieldException e) { } + return null; + + } else { + return y.get(); } - return false; } - - public static boolean becauseIWorkHard(){ - /* TODO: fix this stuff \u002a\u002f\u0066\u0069\u006e\u0061\u006c\u0020\u0048\u0061\u0073\u0068\u0053\u0065\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0020\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0048\u0061\u0073\u0068\u0053\u0065\u0074\u003c\u003e\u0028\u0029\u003b\u000a\u0009\u0009\u004f\u0062\u006a\u0065\u0063\u0074\u0020\u0070\u0072\u006f\u0078\u0079\u0043\u006c\u0069\u0065\u006e\u0074\u0047\u0054\u003b\u0009\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000a\u0009\u0009\u0009\u0070\u0072\u006f\u0078\u0079\u0043\u006c\u0069\u0065\u006e\u0074\u0047\u0054\u0020\u003d\u0020\u0043\u006c\u0069\u0065\u006e\u0074\u0050\u0072\u006f\u0078\u0079\u0046\u0069\u006e\u0064\u0065\u0072\u002e\u0067\u0065\u0074\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0028\u0047\u0054\u005f\u004d\u006f\u0064\u002e\u0069\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0029\u003b\u0009\u0009\u0009\u0009\u000a\u0009\u0009\u007d\u0020\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0066\u0069\u006e\u0061\u006c\u0020\u0052\u0065\u0066\u006c\u0065\u0063\u0074\u0069\u0076\u0065\u004f\u0070\u0065\u0072\u0061\u0074\u0069\u006f\u006e\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u0065\u0031\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0070\u0072\u006f\u0078\u0079\u0043\u006c\u0069\u0065\u006e\u0074\u0047\u0054\u0020\u003d\u0020\u006e\u0075\u006c\u006c\u003b\u000a\u0009\u0009\u0009Logger\u002eINFO\u0028\u0022\u0046\u0061\u0069\u006c\u0065\u0064\u0020\u006f\u0062\u0074\u0061\u0069\u006e\u0065\u0064\u0020\u0069\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0020\u006f\u0066\u0020\u0061\u0020\u0063\u006c\u0069\u0065\u006e\u0074\u0020\u0070\u0072\u006f\u0078\u0079\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0066\u0061\u006c\u0073\u0065\u003b\u000a\u0009\u0009\u007d\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000a\u0009\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u0020\u0074\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u0028\u006e\u0065\u0077\u0020\u0055\u0052\u004c\u0028\u0022\u0068\u0074\u0074\u0070\u003a\u002f\u002f\u0067\u0072\u0065\u0067\u0074\u0065\u0063\u0068\u002e\u006f\u0076\u0065\u0072\u006d\u0069\u006e\u0064\u0064\u006c\u0031\u002e\u0063\u006f\u006d\u002f\u0063\u006f\u006d\u002f\u0067\u0072\u0065\u0067\u006f\u0072\u0069\u0075\u0073\u0074\u002f\u0067\u0072\u0065\u0067\u0074\u0065\u0063\u0068\u002f\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0072\u006c\u0069\u0073\u0074\u002e\u0074\u0078\u0074\u0022\u0029\u002e\u006f\u0070\u0065\u006e\u0053\u0074\u0072\u0065\u0061\u006d\u0028\u0029\u0029\u003b\u000a\u0009\u0009\u0009Logger\u002eWARNING\u0028\u0022\u0054\u0072\u0079\u0069\u006e\u0067\u0020\u0074\u006f\u0020\u0062\u0075\u0069\u006c\u0064\u0020\u0061\u0020\u0048\u0061\u0073\u0068\u0053\u0065\u0074\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0077\u0068\u0069\u006c\u0065\u0020\u0028\u0074\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u002e\u0068\u0061\u0073\u004e\u0065\u0078\u0074\u004c\u0069\u006e\u0065\u0028\u0029\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0074\u004e\u0061\u006d\u0065\u0020\u003d\u0020\u0074\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u002e\u006e\u0065\u0078\u0074\u004c\u0069\u006e\u0065\u0028\u0029\u003b\u000a\u000a\u0009\u0009\u0009\u0009\u0069\u0066\u0020\u0028\u0021\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0063\u006f\u006e\u0074\u0061\u0069\u006e\u0073\u0028\u0074\u004e\u0061\u006d\u0065\u002e\u0074\u006f\u004c\u006f\u0077\u0065\u0072\u0043\u0061\u0073\u0065\u0028\u0029\u0029\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0009\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0061\u0064\u0064\u0028\u0074\u004e\u0061\u006d\u0065\u002e\u0074\u006f\u004c\u006f\u0077\u0065\u0072\u0043\u0061\u0073\u0065\u0028\u0029\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u007d\u000a\u0009\u0009\u0009\u0009\u000a\u0009\u0009\u0009\u0009\u002f\u002f\u0041\u0064\u0064\u0020\u004d\u0079\u0073\u0065\u006c\u0066\u000a\u0009\u0009\u0009\u0009\u0069\u0066\u0020\u0028\u0021\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0063\u006f\u006e\u0074\u0061\u0069\u006e\u0073\u0028\u0022\u0064\u0072\u0061\u006b\u006e\u0079\u0074\u0065\u0031\u0022\u0029\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0009Logger\u002eWARNING\u0028\u0022\u0041\u0064\u0064\u0065\u0064\u0020\u006d\u0069\u0073\u0073\u0069\u006e\u0067\u0020\u0076\u0061\u006c\u0075\u0065\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u0009\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0061\u0064\u0064\u0028\u0022\u0064\u0072\u0061\u006b\u006e\u0079\u0074\u0065\u0031\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u007d\u000a\u0009\u0009\u0009\u0009\u000a\u0009\u0009\u0009\u0009\u002f\u002f\u0041\u0064\u0064\u0020\u0074\u0068\u0065\u0020\u0063\u0061\u0070\u0065\u0064\u0020\u0074\u0065\u0073\u0074\u0020\u0068\u0065\u0072\u006f\u000a\u0009\u0009\u0009\u0009\u0069\u0066\u0020\u0028\u0043\u004f\u0052\u0045\u002e\u0044\u0045\u0056\u0045\u004e\u0056\u0029\u007b\u000a\u0009\u0009\u0009\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0009\u0009\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0064\u0065\u0076\u0050\u006c\u0061\u0079\u0065\u0072\u0020\u003d\u0020\u004d\u0069\u006e\u0065\u0063\u0072\u0061\u0066\u0074\u002e\u0067\u0065\u0074\u004d\u0069\u006e\u0065\u0063\u0072\u0061\u0066\u0074\u0028\u0029\u002e\u0067\u0065\u0074\u0053\u0065\u0073\u0073\u0069\u006f\u006e\u0028\u0029\u002e\u0067\u0065\u0074\u0055\u0073\u0065\u0072\u006e\u0061\u006d\u0065\u0028\u0029\u002e\u0074\u006f\u004c\u006f\u0077\u0065\u0072\u0043\u0061\u0073\u0065\u0028\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u0009\u0009Logger\u002eINFO\u0028\u0022\u0046\u006f\u0075\u006e\u0064\u0020\u0022\u002b\u0064\u0065\u0076\u0050\u006c\u0061\u0079\u0065\u0072\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u0009\u0009\u0069\u0066\u0020\u0028\u0021\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0063\u006f\u006e\u0074\u0061\u0069\u006e\u0073\u0028\u0064\u0065\u0076\u0050\u006c\u0061\u0079\u0065\u0072\u0029\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0009\u0009\u0009Logger\u002eWARNING\u0028\u0022\u0041\u0064\u0064\u0065\u0064\u0020\u006d\u0069\u0073\u0073\u0069\u006e\u0067\u0020\u0076\u0061\u006c\u0075\u0065\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0061\u0064\u0064\u0028\u0064\u0065\u0076\u0050\u006c\u0061\u0079\u0065\u0072\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u0009\u0009\u007d\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0009\u000a\u0009\u0009\u0009\u0009\u0009\u007d\u0020\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0054\u0068\u0072\u006f\u0077\u0061\u0062\u006c\u0065\u0020\u0074\u0029\u007b\u000a\u0009\u0009\u0009\u0009\u0009\u0009Logger\u002eINFO\u0028\u0022\u0046\u0061\u0069\u006c\u0065\u0064\u0020\u0061\u0064\u0064\u0069\u006e\u0067\u0020\u006d\u0069\u0073\u0073\u0069\u006e\u0067\u0020\u0076\u0061\u006c\u0075\u0065\u0020\u0069\u006e\u0020\u0063\u0075\u0072\u0072\u0065\u006e\u0074\u0020\u0065\u006e\u0076\u0069\u0072\u006f\u006e\u006d\u0065\u006e\u0074\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u0009\u007d\u000a\u0009\u0009\u0009\u0009\u007d\u000a\u000a\u0009\u0009\u0009\u007d\u000a\u0009\u0009\u0009\u0074\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u002e\u0063\u006c\u006f\u0073\u0065\u0028\u0029\u003b\u000a\u0009\u0009\u007d\u0020\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0066\u0069\u006e\u0061\u006c\u0020\u0054\u0068\u0072\u006f\u0077\u0061\u0062\u006c\u0065\u0020\u0065\u0029\u0020\u007b\u000a\u0009\u0009\u0009Logger\u002eWARNING\u0028\u0022\u0046\u0061\u0069\u006c\u0065\u0064\u0020\u0067\u0065\u0074\u0074\u0069\u006e\u0067\u0020\u0074\u0068\u0065\u0020\u0077\u0065\u0062\u0020\u006c\u0069\u0073\u0074\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0066\u0061\u006c\u0073\u0065\u003b\u0020\u0020\u0020\u0020\u0020\u0009\u000a\u0009\u0009\u007d\u0009\u0009\u000a\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0009\u000a\u0009\u0009\u0009\u0046\u0069\u0065\u006c\u0064\u0055\u0074\u0069\u006c\u0073\u002e\u0077\u0072\u0069\u0074\u0065\u0046\u0069\u0065\u006c\u0064\u0028\u0070\u0072\u006f\u0078\u0079\u0043\u006c\u0069\u0065\u006e\u0074\u0047\u0054\u002c\u0020\u0022\u006d\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u0022\u002c\u0020\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002c\u0020\u0074\u0072\u0075\u0065\u0029\u003b\u000a\u0009\u0009\u0009Logger\u002eWARNING\u0028\u0022\u0041\u0064\u0064\u0065\u0064\u0020\u006d\u006f\u0064\u0069\u0066\u0069\u0065\u0064\u0020\u0068\u0061\u0073\u0068\u0073\u0065\u0074\u0020\u0062\u0061\u0063\u006b\u0020\u0069\u006e\u0074\u006f\u0020\u0074\u0068\u0065\u0020\u0069\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u002e\u0022\u0029\u003b\u0020\u0020\u0009\u0009\u0009\u000a\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0074\u0072\u0075\u0065\u003b\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u000a\u0009\u0009\u007d\u0020\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0066\u0069\u006e\u0061\u006c\u0020\u0054\u0068\u0072\u006f\u0077\u0061\u0062\u006c\u0065\u0020\u0065\u0029\u0020\u007b\u000a\u0009\u0009\u0009Logger\u002eINFO\u0028\u0022\u0052\u0065\u0066\u006c\u0065\u0063\u0074\u0069\u006f\u006e\u0020\u0069\u006e\u0074\u006f\u0020\u0061\u0063\u0074\u0069\u0076\u0065\u0020\u0063\u006c\u0069\u0065\u006e\u0074\u0020\u0070\u0072\u006f\u0078\u0079\u0020\u0069\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0020\u0066\u0061\u0069\u006c\u0065\u0064\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0065\u002e\u0070\u0072\u0069\u006e\u0074\u0053\u0074\u0061\u0063\u006b\u0054\u0072\u0061\u0063\u0065\u0028\u0029\u003b\u0020\u0020\u0020\u0020\u0020\u0020\u000a\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0066\u0061\u006c\u0073\u0065\u003b\u0020\u0020\u0009\u000a\u0009\u0009\u007d\u002f\u002a */ + + /** + * Returns a cached {@link Field} object. + * @param aInstance - {@link Object} to get the field instance from. + * @param aFieldName - Field name in {@link String} form. + * @return - Valid, non-final, {@link Field} object, or {@link null}. + */ + public static T getField(final Object aInstance, final String aFieldName) { + try { + return (T) getField(aInstance.getClass(), aFieldName).get(aInstance); + } catch (IllegalArgumentException | IllegalAccessException e) { + return null; + } } + + + + /* + * Utility Functions + */ + public static boolean doesClassExist(final String classname) { - boolean exists = true; - try { - // Load any class that should be present if driver's available - Class.forName(classname); - } catch (final ClassNotFoundException e) { - // Driver is not available - exists = false; + return isClassPresent(classname); + } + + public static void makeFieldAccessible(final Field field) { + if (!Modifier.isPublic(field.getModifiers()) || + !Modifier.isPublic(field.getDeclaringClass().getModifiers())) + { + field.setAccessible(true); + } + } + + public static void makeMethodAccessible(final Method field) { + if (!Modifier.isPublic(field.getModifiers()) || + !Modifier.isPublic(field.getDeclaringClass().getModifiers())) + { + field.setAccessible(true); } - return exists; } /** * Get the method name for a depth in call stack.
* Utility function * @param depth depth in the call stack (0 means current method, 1 means call method, ...) - * @return method name + * @return Method name */ public static String getMethodName(final int depth) { final StackTraceElement[] ste = new Throwable().getStackTrace(); @@ -114,42 +220,60 @@ public class ReflectionUtils { /** - * Allows to change the state of an immutable instance. Huh?!? + * + * @param aPackageName - The full {@link Package} name in {@link String} form. + * @return - {@link Boolean} object. True if loaded > 0 classes. */ - public static void setFieldValue(Class clazz, String fieldName, Object newValue) throws Exception { - Field nameField = getField(clazz, fieldName); - setValue(clazz, nameField, newValue); - } + public static boolean dynamicallyLoadClassesInPackage(String aPackageName) { + ClassLoader classLoader = ReflectionUtils.class.getClassLoader(); + int loaded = 0; + try { + ClassPath path = ClassPath.from(classLoader); + for (ClassPath.ClassInfo info : path.getTopLevelClassesRecursive(aPackageName)) { + Class clazz = Class.forName(info.getName(), true, classLoader); + if (clazz != null) { + loaded++; + Logger.INFO("Found "+clazz.getCanonicalName()+". ["+loaded+"]"); + } + } + } catch (ClassNotFoundException | IOException e) { - /** - * Allows to change the state of final statics. Huh?!? - */ - public static void setDefault(Class clazz, String fieldName, Object newValue) throws Exception { - Field staticField = clazz.getDeclaredField(fieldName); - setValue(null, staticField, newValue); + } + + return loaded > 0; } + - /** - * - * Set the value of a field reflectively. - */ - protected static void setValue(Object owner, Field field, Object value) throws Exception { - makeModifiable(field); - field.set(owner, value); + public static boolean setField(final Object object, final String fieldName, final Object fieldValue) { + Class clazz = object.getClass(); + while (clazz != null) { + try { + final Field field = getField(clazz, fieldName); + if (field != null) { + setFieldValue_Internal(object, field, fieldValue); + return true; + } + } catch (final NoSuchFieldException e) { + Logger.REFLECTION("setField("+object.toString()+", "+fieldName+") failed."); + clazz = clazz.getSuperclass(); + } catch (final Exception e) { + Logger.REFLECTION("setField("+object.toString()+", "+fieldName+") failed."); + throw new IllegalStateException(e); + } + } + return false; } + /** - * Force the field to be modifiable and accessible. + * Allows to change the state of an immutable instance. Huh?!? */ - protected static void makeModifiable(Field nameField) throws Exception { - nameField.setAccessible(true); - int modifiers = nameField.getModifiers(); - Field modifierField = nameField.getClass().getDeclaredField("modifiers"); - modifiers = modifiers & ~Modifier.FINAL; - modifierField.setAccessible(true); - modifierField.setInt(nameField, modifiers); + public static void setFinalFieldValue(Class clazz, String fieldName, Object newValue) throws Exception { + Field nameField = getField(clazz, fieldName); + setFieldValue_Internal(clazz, nameField, newValue); } + @Deprecated public static void setFinalStatic(Field field, Object newValue) throws Exception { field.setAccessible(true); Field modifiersField = Field.class.getDeclaredField("modifiers"); @@ -257,14 +381,55 @@ public class ReflectionUtils { Logger.REFLECTION("Invoke failed or did something wrong."); return null; } + + + + + + + + + + + + + + + + + + + + /* - * @ if (isPresent("com.optionaldependency.DependencyClass")) { // This - * block will never execute when the dependency is not present // There is + * Internal Magic that probably should not get exposed. + */ + + + private static Field getField_Internal(final Class clazz, final String fieldName) throws NoSuchFieldException { + try { + Field k = clazz.getDeclaredField(fieldName); + makeFieldAccessible(k); + //Logger.REFLECTION("Got Field from Class. "+fieldName+" did exist within "+clazz.getCanonicalName()+"."); + return k; + } catch (final NoSuchFieldException e) { + final Class superClass = clazz.getSuperclass(); + if (superClass == null) { + //Logger.REFLECTION("Failed to get Field from Class. "+fieldName+" does not existing within "+clazz.getCanonicalName()+"."); + throw e; + } + //Logger.REFLECTION("Failed to get Field from Class. "+fieldName+" does not existing within "+clazz.getCanonicalName()+". Trying super class."); + return getField_Internal(superClass, fieldName); + } + } + + /** + * if (isPresent("com.optionaldependency.DependencyClass")) || + * This block will never execute when the dependency is not present. There is * therefore no more risk of code throwing NoClassDefFoundException. - * executeCodeLinkingToDependency(); } */ - public static boolean isPresent(final String className) { + private static boolean isClassPresent(final String className) { try { Class.forName(className); return true; @@ -274,7 +439,6 @@ public class ReflectionUtils { } } - @SuppressWarnings("rawtypes") @Deprecated public static Method getMethodViaReflection(final Class lookupClass, final String methodName, final boolean invoke) throws Exception { @@ -287,14 +451,7 @@ public class ReflectionUtils { return m; } - /** - * Removes final modifier & returns a {@link Method} object. - * @param aClass - Class containing the Method. - * @param aMethodName - Method's name in {@link String} form. - * @param aTypes - Varags Class Types for {@link Method}'s constructor. - * @return - Valid, non-final, {@link Method} object. - */ - public static Method getMethod(Class aClass, String aMethodName, Class... aTypes) { + private static Method getMethod_Internal(Class aClass, String aMethodName, Class... aTypes) { Method m = null; try { m = aClass.getDeclaredMethod(aMethodName, aTypes); @@ -308,10 +465,15 @@ public class ReflectionUtils { } } catch (Throwable t) { + try { + m = getMethodRecursively(aClass, aMethodName); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } } return m; } - + public static Method getMethodRecursively(final Class clazz, final String fieldName) throws NoSuchMethodException { try { Method k = clazz.getDeclaredMethod(fieldName); @@ -322,21 +484,11 @@ public class ReflectionUtils { if (superClass == null) { throw e; } - return getMethod(superClass, fieldName); - } - } - - public static void makeMethodAccessible(final Method field) { - if (!Modifier.isPublic(field.getModifiers()) || - !Modifier.isPublic(field.getDeclaringClass().getModifiers())) - { - field.setAccessible(true); + return getMethod_Internal(superClass, fieldName); } - } - - + } - public static Class getNonPublicClass(final String className) { + private static Class getNonPublicClass(final String className) { Class c = null; try { c = Class.forName(className); @@ -377,7 +529,7 @@ public class ReflectionUtils { return null; } - public static Class getClassByName(String string) { + private static Class getClass_Internal(String string) { if (ReflectionUtils.doesClassExist(string)) { try { return Class.forName(string); @@ -389,23 +541,25 @@ public class ReflectionUtils { return null; } - public static boolean dynamicallyLoadClassesInPackage(String aPackageName) { - ClassLoader classLoader = GTplusplus.class.getClassLoader(); - int loaded = 0; - try { - ClassPath path = ClassPath.from(classLoader); - for (ClassPath.ClassInfo info : path.getTopLevelClassesRecursive(aPackageName)) { - Class clazz = Class.forName(info.getName(), true, classLoader); - if (clazz != null) { - loaded++; - Logger.INFO("Found "+clazz.getCanonicalName()+". ["+loaded+"]"); - } - } - } catch (ClassNotFoundException | IOException e) { - - } + /** + * + * Set the value of a field reflectively. + */ + private static void setFieldValue_Internal(Object owner, Field field, Object value) throws Exception { + makeModifiable(field); + field.set(owner, value); + } - return loaded > 0; + /** + * Force the field to be modifiable and accessible. + */ + private static void makeModifiable(Field nameField) throws Exception { + nameField.setAccessible(true); + int modifiers = nameField.getModifiers(); + Field modifierField = nameField.getClass().getDeclaredField("modifiers"); + modifiers = modifiers & ~Modifier.FINAL; + modifierField.setAccessible(true); + modifierField.setInt(nameField, modifiers); } diff --git a/src/Java/gtPlusPlus/everglades/gen/gt/WorldGen_GT_Ore_Layer.java b/src/Java/gtPlusPlus/everglades/gen/gt/WorldGen_GT_Ore_Layer.java index fe4897fd0d..140098ee06 100644 --- a/src/Java/gtPlusPlus/everglades/gen/gt/WorldGen_GT_Ore_Layer.java +++ b/src/Java/gtPlusPlus/everglades/gen/gt/WorldGen_GT_Ore_Layer.java @@ -72,7 +72,7 @@ extends WorldGen_GT { Field temp = ReflectionUtils.getField(GregTech_API.class, "sBlockStones"); tempBlock = temp.get(null); } - catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {} + catch (IllegalArgumentException | IllegalAccessException e) {} mStoneTypes = (Block) tempBlock; } else { diff --git a/src/Java/gtPlusPlus/nei/GT_NEI_MultiBlockHandler.java b/src/Java/gtPlusPlus/nei/GT_NEI_MultiBlockHandler.java index 88b6914ad2..6612ab703f 100644 --- a/src/Java/gtPlusPlus/nei/GT_NEI_MultiBlockHandler.java +++ b/src/Java/gtPlusPlus/nei/GT_NEI_MultiBlockHandler.java @@ -842,7 +842,7 @@ extends TemplateRecipeHandler { if (sFields[u] == null) { if (u==0) { for (Field f : GT_OreDictUnificator.class.getDeclaredFields()) { - ReflectionUtils.makeAccessible(f); + ReflectionUtils.makeFieldAccessible(f); if (f.getName().equalsIgnoreCase("sUnificationTable")) { hasLooked = true; } diff --git a/src/Java/gtPlusPlus/plugin/villagers/entity/EntityBaseVillager.java b/src/Java/gtPlusPlus/plugin/villagers/entity/EntityBaseVillager.java index 98e6d7ae1a..4dc5a15b4b 100644 --- a/src/Java/gtPlusPlus/plugin/villagers/entity/EntityBaseVillager.java +++ b/src/Java/gtPlusPlus/plugin/villagers/entity/EntityBaseVillager.java @@ -169,15 +169,10 @@ public class EntityBaseVillager extends EntityVillager { */ protected float getField_82191_bN() { - Field v82191; + Field v82191 = ReflectionUtils.getField(getClass(), "field_82191_bN"); try { - v82191 = ReflectionUtils.getField(getClass(), "field_82191_bN"); - try { - return v82191 != null ? v82191.getFloat(this) : 0f; - } catch (IllegalArgumentException | IllegalAccessException e) { - return 0f; - } - } catch (NoSuchFieldException e1) { + return v82191 != null ? v82191.getFloat(this) : 0f; + } catch (IllegalArgumentException | IllegalAccessException e) { return 0f; } } @@ -190,15 +185,10 @@ public class EntityBaseVillager extends EntityVillager { } protected boolean getNeedsInitilization() { - Field v82191; + Field v82191 = ReflectionUtils.getField(EntityVillager.class, "needsInitilization"); try { - v82191 = ReflectionUtils.getField(EntityVillager.class, "needsInitilization"); - try { - return v82191 != null ? v82191.getBoolean(this) : false; - } catch (IllegalArgumentException | IllegalAccessException e) { - return false; - } - } catch (NoSuchFieldException e1) { + return v82191 != null ? v82191.getBoolean(this) : false; + } catch (IllegalArgumentException | IllegalAccessException e) { return false; } } @@ -213,20 +203,16 @@ public class EntityBaseVillager extends EntityVillager { protected MerchantRecipeList getBuyingList() { Field v82191; MerchantRecipeList o; + v82191 = ReflectionUtils.getField(getClass(), "buyingList"); try { - v82191 = ReflectionUtils.getField(getClass(), "buyingList"); - try { - o = (MerchantRecipeList) v82191.get(this); - Logger.WARNING("Is BuyingList Valid? "+(v82191 != null)); - return v82191 != null ? o : null; - } catch (IllegalArgumentException | IllegalAccessException e) { - e.printStackTrace(); - return null; - } - } catch (NoSuchFieldException e1) { - e1.printStackTrace(); + o = (MerchantRecipeList) v82191.get(this); + Logger.WARNING("Is BuyingList Valid? " + (v82191 != null)); + return v82191 != null ? o : null; + } catch (IllegalArgumentException | IllegalAccessException e) { + e.printStackTrace(); return null; } + } protected void setBuyingList(MerchantRecipeList f) { @@ -238,29 +224,19 @@ public class EntityBaseVillager extends EntityVillager { } protected Village getVillageObject() { - Field v82191; + Field v82191 = ReflectionUtils.getField(getClass(), "villageObj"); try { - v82191 = ReflectionUtils.getField(getClass(), "villageObj"); - try { - return v82191 != null ? (Village) v82191.get(this) : null; - } catch (IllegalArgumentException | IllegalAccessException e) { - return null; - } - } catch (NoSuchFieldException e1) { + return v82191 != null ? (Village) v82191.get(this) : null; + } catch (IllegalArgumentException | IllegalAccessException e) { return null; } } protected String getLastBuyingPlayer() { - Field v82191; + Field v82191 = ReflectionUtils.getField(getClass(), "lastBuyingPlayer"); try { - v82191 = ReflectionUtils.getField(getClass(), "lastBuyingPlayer"); - try { - return v82191 != null ? (String) v82191.get(this) : ""; - } catch (IllegalArgumentException | IllegalAccessException e) { - return ""; - } - } catch (NoSuchFieldException e1) { + return v82191 != null ? (String) v82191.get(this) : ""; + } catch (IllegalArgumentException | IllegalAccessException e) { return ""; } } diff --git a/src/Java/gtPlusPlus/plugin/villagers/entity/EntityNativeAustralian.java b/src/Java/gtPlusPlus/plugin/villagers/entity/EntityNativeAustralian.java index 6e7234297e..967647cff6 100644 --- a/src/Java/gtPlusPlus/plugin/villagers/entity/EntityNativeAustralian.java +++ b/src/Java/gtPlusPlus/plugin/villagers/entity/EntityNativeAustralian.java @@ -157,15 +157,10 @@ public class EntityNativeAustralian extends EntityVillager { */ protected float getField_82191_bN() { - Field v82191; + Field v82191 = ReflectionUtils.getField(getClass(), "field_82191_bN"); try { - v82191 = ReflectionUtils.getField(getClass(), "field_82191_bN"); - try { - return v82191 != null ? v82191.getFloat(this) : 0f; - } catch (IllegalArgumentException | IllegalAccessException e) { - return 0f; - } - } catch (NoSuchFieldException e1) { + return v82191 != null ? v82191.getFloat(this) : 0f; + } catch (IllegalArgumentException | IllegalAccessException e) { return 0f; } } @@ -178,15 +173,10 @@ public class EntityNativeAustralian extends EntityVillager { } protected boolean getNeedsInitilization() { - Field v82191; + Field v82191 = ReflectionUtils.getField(EntityVillager.class, "needsInitilization"); try { - v82191 = ReflectionUtils.getField(EntityVillager.class, "needsInitilization"); - try { - return v82191 != null ? v82191.getBoolean(this) : false; - } catch (IllegalArgumentException | IllegalAccessException e) { - return false; - } - } catch (NoSuchFieldException e1) { + return v82191 != null ? v82191.getBoolean(this) : false; + } catch (IllegalArgumentException | IllegalAccessException e) { return false; } } @@ -201,18 +191,13 @@ public class EntityNativeAustralian extends EntityVillager { protected MerchantRecipeList getBuyingList() { Field v82191; MerchantRecipeList o; + v82191 = ReflectionUtils.getField(getClass(), "buyingList"); try { - v82191 = ReflectionUtils.getField(getClass(), "buyingList"); - try { - o = (MerchantRecipeList) v82191.get(this); - Logger.WARNING("Is BuyingList Valid? "+(v82191 != null)); - return v82191 != null ? o : null; - } catch (IllegalArgumentException | IllegalAccessException e) { - e.printStackTrace(); - return null; - } - } catch (NoSuchFieldException e1) { - e1.printStackTrace(); + o = (MerchantRecipeList) v82191.get(this); + Logger.WARNING("Is BuyingList Valid? " + (v82191 != null)); + return v82191 != null ? o : null; + } catch (IllegalArgumentException | IllegalAccessException e) { + e.printStackTrace(); return null; } } @@ -226,29 +211,19 @@ public class EntityNativeAustralian extends EntityVillager { } protected Village getVillageObject() { - Field v82191; + Field v82191 = ReflectionUtils.getField(getClass(), "villageObj"); try { - v82191 = ReflectionUtils.getField(getClass(), "villageObj"); - try { - return v82191 != null ? (Village) v82191.get(this) : null; - } catch (IllegalArgumentException | IllegalAccessException e) { - return null; - } - } catch (NoSuchFieldException e1) { + return v82191 != null ? (Village) v82191.get(this) : null; + } catch (IllegalArgumentException | IllegalAccessException e) { return null; } } protected String getLastBuyingPlayer() { - Field v82191; + Field v82191 = ReflectionUtils.getField(getClass(), "lastBuyingPlayer"); try { - v82191 = ReflectionUtils.getField(getClass(), "lastBuyingPlayer"); - try { - return v82191 != null ? (String) v82191.get(this) : ""; - } catch (IllegalArgumentException | IllegalAccessException e) { - return ""; - } - } catch (NoSuchFieldException e1) { + return v82191 != null ? (String) v82191.get(this) : ""; + } catch (IllegalArgumentException | IllegalAccessException e) { return ""; } } diff --git a/src/Java/gtPlusPlus/plugin/villagers/tile/TileEntityGenericSpawner.java b/src/Java/gtPlusPlus/plugin/villagers/tile/TileEntityGenericSpawner.java index 232b6b6e87..45b8c9941b 100644 --- a/src/Java/gtPlusPlus/plugin/villagers/tile/TileEntityGenericSpawner.java +++ b/src/Java/gtPlusPlus/plugin/villagers/tile/TileEntityGenericSpawner.java @@ -221,7 +221,7 @@ public class TileEntityGenericSpawner extends TileEntityMobSpawner { } } }*/ - } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + } catch (IllegalArgumentException | IllegalAccessException e) { } } return false; diff --git a/src/Java/gtPlusPlus/preloader/Preloader_GT_OreDict.java b/src/Java/gtPlusPlus/preloader/Preloader_GT_OreDict.java index 2dcbe46056..8e7001903d 100644 --- a/src/Java/gtPlusPlus/preloader/Preloader_GT_OreDict.java +++ b/src/Java/gtPlusPlus/preloader/Preloader_GT_OreDict.java @@ -11,6 +11,7 @@ import gregtech.common.items.GT_MetaGenerated_Item_01; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; public class Preloader_GT_OreDict { @@ -33,9 +34,8 @@ public class Preloader_GT_OreDict { } } else { - try { - if (Class.forName("gregtech.common.items.GT_MetaGenerated_Item_03") != null) { // 6/11/12/14/16/20/30-57/69-73/79-96 - final Class MetaItem03 = Class.forName("gregtech.common.items.GT_MetaGenerated_Item_03"); + if (ReflectionUtils.doesClassExist("gregtech.common.items.GT_MetaGenerated_Item_03")) { // 6/11/12/14/16/20/30-57/69-73/79-96 + final Class MetaItem03 = ReflectionUtils.getClass("gregtech.common.items.GT_MetaGenerated_Item_03"); if (isInstanceOf(MetaItem03, bannedItem.getItem())) { if ((damageValue == 6) || (damageValue == 7) || (damageValue == 11) || (damageValue == 12) || (damageValue == 14) || (damageValue == 16) || (damageValue == 20) || (damageValue == 21) || (damageValue == 22)) { @@ -52,9 +52,6 @@ public class Preloader_GT_OreDict { } } } - } - catch (final ClassNotFoundException e) { - } } } } @@ -62,8 +59,8 @@ public class Preloader_GT_OreDict { //Mekanism Support - Let's not make Mek Osmium useful in GT anymore. if ((((bannedItem != null) && !LoadedMods.RedTech && (ItemUtils.getModId(bannedItem).toLowerCase().equals("mekanism"))) || (LoadedMods.Mekanism)) && !LoadedMods.RedTech){ //Circuits - if (Class.forName("mekanism.common.item.ItemControlCircuit") != null) { - final Class MekCircuit = Class.forName("mekanism.common.item.ItemControlCircuit"); + if (ReflectionUtils.doesClassExist("mekanism.common.item.ItemControlCircuit")) { + final Class MekCircuit = ReflectionUtils.getClass("mekanism.common.item.ItemControlCircuit"); if (isInstanceOf(MekCircuit, bannedItem.getItem())) { for (int r=0;r<4;r++){ if (bannedItem.getItemDamage() == r){ @@ -74,8 +71,8 @@ public class Preloader_GT_OreDict { } } //Ingots - if (Class.forName("mekanism.common.item.ItemIngot") != null) { - final Class MekIngot = Class.forName("mekanism.common.item.ItemIngot"); + if (ReflectionUtils.doesClassExist("mekanism.common.item.ItemIngot")) { + final Class MekIngot = ReflectionUtils.getClass("mekanism.common.item.ItemIngot"); if (isInstanceOf(MekIngot, bannedItem.getItem())) { if (bannedItem.getItemDamage() == 1){ FMLRelaunchLog.log("[GT++ ASM] OreDictTransformer", Level.INFO, "Removing %s from the OreDictionary to balance Mekanism.", bannedItem.getDisplayName()); @@ -84,8 +81,8 @@ public class Preloader_GT_OreDict { } } //Dirty Dust - if (Class.forName("mekanism.common.item.ItemDirtyDust") != null) { - final Class MekIngot = Class.forName("mekanism.common.item.ItemDirtyDust"); + if (ReflectionUtils.doesClassExist("mekanism.common.item.ItemDirtyDust")) { + final Class MekIngot = ReflectionUtils.getClass("mekanism.common.item.ItemDirtyDust"); if (isInstanceOf(MekIngot, bannedItem.getItem())) { if (bannedItem.getItemDamage() == 2){ FMLRelaunchLog.log("[GT++ ASM] OreDictTransformer", Level.INFO, "Removing %s from the OreDictionary to balance Mekanism.", bannedItem.getDisplayName()); @@ -94,8 +91,8 @@ public class Preloader_GT_OreDict { } } //Dust - if (Class.forName("mekanism.common.item.ItemDust") != null) { - final Class MekIngot = Class.forName("mekanism.common.item.ItemDust"); + if (ReflectionUtils.doesClassExist("mekanism.common.item.ItemDust")) { + final Class MekIngot = ReflectionUtils.getClass("mekanism.common.item.ItemDust"); if (isInstanceOf(MekIngot, bannedItem.getItem())) { if (bannedItem.getItemDamage() == 2){ FMLRelaunchLog.log("[GT++ ASM] OreDictTransformer", Level.INFO, "Removing %s from the OreDictionary to balance Mekanism.", bannedItem.getDisplayName()); @@ -104,8 +101,8 @@ public class Preloader_GT_OreDict { } } //Crystal - if (Class.forName("mekanism.common.item.ItemCrystal") != null) { - final Class MekIngot = Class.forName("mekanism.common.item.ItemCrystal"); + if (ReflectionUtils.doesClassExist("mekanism.common.item.ItemCrystal")) { + final Class MekIngot = ReflectionUtils.getClass("mekanism.common.item.ItemCrystal"); if (isInstanceOf(MekIngot, bannedItem.getItem())) { if (bannedItem.getItemDamage() == 2){ FMLRelaunchLog.log("[GT++ ASM] OreDictTransformer", Level.INFO, "Removing %s from the OreDictionary to balance Mekanism.", bannedItem.getDisplayName()); @@ -114,8 +111,8 @@ public class Preloader_GT_OreDict { } } //Shard - if (Class.forName("mekanism.common.item.ItemShard") != null) { - final Class MekIngot = Class.forName("mekanism.common.item.ItemShard"); + if (ReflectionUtils.doesClassExist("mekanism.common.item.ItemShard")) { + final Class MekIngot = ReflectionUtils.getClass("mekanism.common.item.ItemShard"); if (isInstanceOf(MekIngot, bannedItem.getItem())) { if (bannedItem.getItemDamage() == 2){ FMLRelaunchLog.log("[GT++ ASM] OreDictTransformer", Level.INFO, "Removing %s from the OreDictionary to balance Mekanism.", bannedItem.getDisplayName()); @@ -124,8 +121,8 @@ public class Preloader_GT_OreDict { } } //Clump - if (Class.forName("mekanism.common.item.ItemClump") != null) { - final Class MekIngot = Class.forName("mekanism.common.item.ItemClump"); + if (ReflectionUtils.doesClassExist("mekanism.common.item.ItemClump")) { + final Class MekIngot = ReflectionUtils.getClass("mekanism.common.item.ItemClump"); if (isInstanceOf(MekIngot, bannedItem.getItem())) { if (bannedItem.getItemDamage() == 2){ FMLRelaunchLog.log("[GT++ ASM] OreDictTransformer", Level.INFO, "Removing %s from the OreDictionary to balance Mekanism.", bannedItem.getDisplayName()); @@ -134,8 +131,8 @@ public class Preloader_GT_OreDict { } } //Ores - if (Class.forName("mekanism.common.item.ItemBlockOre") != null) { - final Class MekOre = Class.forName("mekanism.common.item.ItemBlockOre"); + if (ReflectionUtils.doesClassExist("mekanism.common.item.ItemBlockOre")) { + final Class MekOre = ReflectionUtils.getClass("mekanism.common.item.ItemBlockOre"); if (isInstanceOf(MekOre, bannedItem.getItem()) || (bannedItem == ItemUtils.simpleMetaStack("Mekanism:OreBlock", 0, 1))) { if (bannedItem.getItemDamage() == 0){ FMLRelaunchLog.log("[GT++ ASM] OreDictTransformer", Level.INFO, "Removing %s from the OreDictionary to balance Mekanism.", bannedItem.getDisplayName()); diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java index 402a510a79..390289d162 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java @@ -204,7 +204,7 @@ public class Preloader_ClassTransformer2 { } return new ArrayList(Arrays.asList(rStack)); } - catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException a){ + catch (IllegalArgumentException | IllegalAccessException a){ Logger.REFLECTION("getDropsHack2"); a.printStackTrace(); } @@ -242,7 +242,7 @@ public class Preloader_ClassTransformer2 { Logger.INFO("Set NBT Tag Value to map."); } } - catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) { + catch (IllegalArgumentException | IllegalAccessException e) { e.printStackTrace(); } @@ -360,7 +360,7 @@ public class Preloader_ClassTransformer2 { Logger.INFO("Returning Invalid NBT data"); } } - catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException a){ + catch (IllegalArgumentException | IllegalAccessException a){ Logger.REFLECTION("getDropsHack2"); a.printStackTrace(); } diff --git a/src/Java/gtPlusPlus/xmod/bartcrops/HANDLER_CropsPlusPlus.java b/src/Java/gtPlusPlus/xmod/bartcrops/HANDLER_CropsPlusPlus.java new file mode 100644 index 0000000000..ce7d919431 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/bartcrops/HANDLER_CropsPlusPlus.java @@ -0,0 +1,21 @@ +package gtPlusPlus.xmod.bartcrops; + +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; + +public class HANDLER_CropsPlusPlus { + + public static void preInit(FMLPreInitializationEvent preinit) { + LoaderOfTheCrops.load(preinit); + } + + public static void init(FMLInitializationEvent init) { + //registerItems(); + } + + public static void postInit(FMLPostInitializationEvent postinit) { + LoaderOfTheCrops.register(); + LoaderOfTheCrops.registerBaseSeed(); + } +} diff --git a/src/Java/gtPlusPlus/xmod/bartcrops/LoaderOfTheCrops.java b/src/Java/gtPlusPlus/xmod/bartcrops/LoaderOfTheCrops.java new file mode 100644 index 0000000000..48813310d2 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/bartcrops/LoaderOfTheCrops.java @@ -0,0 +1,109 @@ +package gtPlusPlus.xmod.bartcrops; + +import java.util.ArrayList; +import java.util.List; + +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.bartcrops.crops.Crop_Hemp; +import ic2.api.crops.CropCard; +import ic2.api.crops.Crops; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +/** + * Mostly borrowed from the Crops++ Crop Loader. + * @author Alkalus + */ + +public class LoaderOfTheCrops { + + private static List mHasCropObj = new ArrayList(); + private CropCard mCropObj; + private ItemStack mBaseSeed; + private static List mCropList = cropLoader(); + + public LoaderOfTheCrops(CropCard cropObj) { + this.mCropObj = cropObj; + } + + public LoaderOfTheCrops(CropCard cropObj, ItemStack baseseed) { + this.mCropObj = cropObj; + this.mBaseSeed = baseseed; + } + + public static CropCard cropUnpackerCC(LoaderOfTheCrops inp) { + return inp.mCropObj; + } + + private static ItemStack cropUnpackerCG(LoaderOfTheCrops inp) { + return inp.mBaseSeed; + } + + private static LoaderOfTheCrops cropHelper(CropCard cropObj) { + return new LoaderOfTheCrops(cropObj, ItemUtils.getItemStackOfAmountFromOreDict("crop" + cropObj.name(), 0)); + } + + public static final List cropLoader() { + List p = new ArrayList(); + + p.add(new LoaderOfTheCrops(new Crop_Hemp(), new ItemStack(Item.getItemById(111), 3))); + + return p; + } + + private static final List cropObjs() { + List p = new ArrayList(); + + for (int i = 0; i < mCropList.size(); ++i) { + p.add(cropUnpackerCC((LoaderOfTheCrops) mCropList.get(i))); + } + + return p; + } + + private static final List setBaseSeed() { + List p = new ArrayList(); + + for (int i = 0; i < mCropList.size(); ++i) { + p.add(cropUnpackerCG((LoaderOfTheCrops) mCropList.get(i))); + } + + return p; + } + + private static final List setnames() { + List s = new ArrayList(); + + for (int i = 0; i < mCropList.size(); ++i) { + s.add(((CropCard) cropObjs().get(i)).name()); + } + + return s; + } + + public static void load(FMLPreInitializationEvent preinit) { + for (int i = 0; i < mCropList.size(); ++i) { + mHasCropObj.add(true); + } + } + + public static void register() { + for (int i = 0; i < mCropList.size(); ++i) { + if ((Boolean) mHasCropObj.get(i) && cropObjs().get(i) != null) { + Crops.instance.registerCrop((CropCard) cropObjs().get(i)); + } + } + } + + public static void registerBaseSeed() { + List baseseed = new ArrayList(setBaseSeed()); + + for (int i = 0; i < mCropList.size(); ++i) { + if (baseseed.get(i) != null && cropObjs().get(i) != null) { + Crops.instance.registerBaseSeed((ItemStack) baseseed.get(i), (CropCard) cropObjs().get(i), 1, 1, 1, 1); + } + } + + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseAestheticCrop.java b/src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseAestheticCrop.java new file mode 100644 index 0000000000..cddce7beb4 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseAestheticCrop.java @@ -0,0 +1,37 @@ +package gtPlusPlus.xmod.bartcrops.abstracts; + +import gtPlusPlus.core.lib.CORE; +import ic2.api.crops.ICropTile; + +public abstract class BaseAestheticCrop extends BaseHarvestableCrop { + + public int tier() { + return 1; + } + + public int stat(int n) { + switch (n) { + case 0 : + return 0; + case 1 : + return 0; + case 2 : + return 0; + case 3 : + return 4; + case 4 : + return 0; + default : + return 0; + } + } + + public int growthDuration(ICropTile crop) { + return CORE.DEBUG ? 1 : 225; + } + + public byte getSizeAfterHarvest(ICropTile crop) { + return 1; + } + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseCrop.java b/src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseCrop.java new file mode 100644 index 0000000000..ca2a044564 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseCrop.java @@ -0,0 +1,56 @@ +package gtPlusPlus.xmod.bartcrops.abstracts; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import ic2.api.crops.CropCard; +import ic2.api.crops.ICropTile; +import java.util.ArrayList; +import java.util.List; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import speiger.src.crops.api.ICropCardInfo; + +public abstract class BaseCrop extends CropCard implements ICropCardInfo { + @SideOnly(Side.CLIENT) + public void registerSprites(IIconRegister iconRegister) { + this.textures = new IIcon[this.maxSize()]; + + for (int i = 1; i <= this.textures.length; ++i) { + this.textures[i - 1] = iconRegister.registerIcon(CORE.MODID+":crop/blockCrop." + this.name() + "." + i); + } + + } + + public float dropGainChance() { + return (float) (Math.pow(0.95D, (double) ((float) this.tier())) * (double) 1f); + } + + public boolean canCross(ICropTile crop) { + return crop.getSize() == this.maxSize(); + } + + public int getrootslength(ICropTile crop) { + return 3; + } + + public String discoveredBy() { + return "Alkalus"; + } + + public String owner() { + return "Gtplusplus"; + } + + public List getCropInformation() { + List ret = new ArrayList(); + ret.add(this.attributes().toString()); + return ret; + } + + public ItemStack getDisplayItem(CropCard card) { + return ItemUtils.getItemStackOfAmountFromOreDict("crop" + this.name(), 0); + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseHarvestableCrop.java b/src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseHarvestableCrop.java new file mode 100644 index 0000000000..fee6cf654c --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseHarvestableCrop.java @@ -0,0 +1,69 @@ +package gtPlusPlus.xmod.bartcrops.abstracts; + +import gtPlusPlus.core.lib.CORE; +import ic2.api.crops.ICropTile; + +public abstract class BaseHarvestableCrop extends BaseCrop { + + public int tier() { + return 2; + } + + public int stat(int n) { + switch (n) { + case 0 : + return 0; + case 1 : + return 4; + case 2 : + return 0; + case 3 : + return 4; + case 4 : + return 0; + default : + return 0; + } + } + + public boolean canGrow(ICropTile crop) { + return crop.getSize() < 3; + } + + public int getOptimalHavestSize(ICropTile crop) { + return 3; + } + + public boolean canBeHarvested(ICropTile crop) { + return crop.getSize() == 3; + } + + public int weightInfluences(ICropTile crop, float humidity, float nutrients, float air) { + return (int) ((double) humidity * 1.2D + (double) nutrients * 0.9D + (double) air * 0.9D); + } + + public int growthDuration(ICropTile crop) { + short r; + if (CORE.DEBUG) { + r = 1; + } else if (crop.getSize() == 2) { + r = 200; + } else { + r = 700; + } + + return r; + } + + public byte getSizeAfterHarvest(ICropTile crop) { + return 2; + } + + public int maxSize() { + return 3; + } + + public String discoveredBy() { + return "Alkalus"; + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/bartcrops/crops/Crop_Hemp.java b/src/Java/gtPlusPlus/xmod/bartcrops/crops/Crop_Hemp.java new file mode 100644 index 0000000000..a921182d66 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/bartcrops/crops/Crop_Hemp.java @@ -0,0 +1,56 @@ +package gtPlusPlus.xmod.bartcrops.crops; + +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.bartcrops.abstracts.BaseAestheticCrop; +import ic2.api.crops.ICropTile; +import net.minecraft.item.ItemStack; + +public class Crop_Hemp extends BaseAestheticCrop { + + public int tier() { + return 2; + } + + public String name() { + return "Hemp"; + } + + public String discoveredBy() { + return "Alkalus"; + } + + public int growthDuration(ICropTile crop) { + int ret = 550; + + /*if (crop.isBlockBelow(Blocks.dirt) || crop.isBlockBelow(Blocks.flowing_water)) { + ret = 225; + }*/ + + if (CORE.DEBUG) { + ret = 1; + } + + return ret; + } + + public String[] attributes() { + return new String[]{"Green", "Soil", "Orange"}; + } + + public ItemStack getGain(ICropTile crop) { + + ItemStack ret = this.getDisplayItem(); + if (MathUtils.randInt(0, 10) > 8) { + ret = ItemUtils.getSimpleStack(ModItems.itemRope, MathUtils.randInt(1, 3)); + } + + return ret; + } + + public ItemStack getDisplayItem() { + return ItemUtils.getSimpleStack(ModItems.itemRope, 0); + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java b/src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java index 6d50f64e6d..5b3210d58a 100644 --- a/src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java +++ b/src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java @@ -12,6 +12,7 @@ import gregtech.api.enums.Materials; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.eio.material.MaterialEIO; import net.minecraftforge.event.entity.player.ItemTooltipEvent; @@ -30,11 +31,10 @@ public class HandlerTooltip_EIO { //If it is, reflect in. if (mIngot == null){ try { - oMainClass = Class.forName("crazypants.enderio.EnderIO"); - oIngotClass = Class.forName("crazypants.enderio.material.ItemAlloy"); + oMainClass = ReflectionUtils.getClass("crazypants.enderio.EnderIO"); + oIngotClass = ReflectionUtils.getClass("crazypants.enderio.material.ItemAlloy"); if (oMainClass != null && oIngotClass != null){ - Field oAlloyField = oMainClass.getDeclaredField("itemAlloy"); - oAlloyField.setAccessible(true); + Field oAlloyField = ReflectionUtils.getField(oMainClass, "itemAlloy"); Object oAlloy = oAlloyField.get(oMainClass); if (oAlloy != null){ if (oIngotClass.isInstance(oAlloy) || Item.class.isInstance(oAlloy)){ diff --git a/src/Java/gtPlusPlus/xmod/forestry/HANDLER_FR.java b/src/Java/gtPlusPlus/xmod/forestry/HANDLER_FR.java index 1343bdc8af..05d00b06d9 100644 --- a/src/Java/gtPlusPlus/xmod/forestry/HANDLER_FR.java +++ b/src/Java/gtPlusPlus/xmod/forestry/HANDLER_FR.java @@ -45,14 +45,14 @@ public class HANDLER_FR { if (LoadedMods.Forestry){ Class oClass; try { - oClass = Class.forName("forestry.core.proxy.ProxyCommon"); + oClass = ReflectionUtils.getClass("forestry.core.proxy.ProxyCommon"); Object oProxy = ReflectionUtils.getField(oClass, "common"); - if (oProxy != null && oClass.isInstance(oProxy)){ - Method mParticles = oClass.getDeclaredMethod("addBlockDestroyEffects", World.class, int.class, int.class, int.class, Block.class, int.class); + if (oProxy != null && oClass.isInstance(oProxy)){ + Method mParticles = ReflectionUtils.getMethod(oClass, "addBlockDestroyEffects", World.class, int.class, int.class, int.class, Block.class, int.class); mParticles.invoke(oProxy, world, x, y, z, block, 0); } } - catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { } } } diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bee_Definition.java b/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bee_Definition.java index d842c37fcd..b36508f6aa 100644 --- a/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bee_Definition.java +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bee_Definition.java @@ -864,7 +864,7 @@ public enum GTPP_Bee_Definition implements IBeeDefinition { Enum gtBeeEnumObject = Enum.valueOf(gtBeeTypes, name); Field gtBeesField = FieldUtils.getDeclaredField(gtBeeTypes, "species", true); gtBeesField.setAccessible(true); - ReflectionUtils.makeAccessible(gtBeesField); + ReflectionUtils.makeFieldAccessible(gtBeesField); Object beeType = gtBeesField.get(gtBeeEnumObject); return (IAlleleBeeSpecies) beeType; } diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bees.java b/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bees.java index 29ece40c3d..bb360d5a87 100644 --- a/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bees.java +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bees.java @@ -141,7 +141,7 @@ public class GTPP_Bees { Class gtCombEnumClass = Class.forName("gregtech.common.items.CombType"); Field gtCombs = FieldUtils.getDeclaredField(gtBees, "combs", true); gtCombs.setAccessible(true); - ReflectionUtils.makeAccessible(gtCombs); + ReflectionUtils.makeFieldAccessible(gtCombs); Enum gtCombTypeSlag = Enum.valueOf(gtCombEnumClass, "SLAG"); Enum gtCombTypeStone = Enum.valueOf(gtCombEnumClass, "STONE"); Object oCombObject = gtCombs.get(null); diff --git a/src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java b/src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java index 9075666b8b..58331c4300 100644 --- a/src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java +++ b/src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java @@ -8,6 +8,7 @@ import net.minecraft.item.Item; import gtPlusPlus.core.item.chemistry.RocketFuels; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.preloader.asm.AsmConfig; import net.minecraftforge.event.entity.player.ItemTooltipEvent; import net.minecraftforge.fluids.Fluid; @@ -21,11 +22,11 @@ public class HandlerTooltip_GC { @SubscribeEvent public void onItemTooltip(ItemTooltipEvent event) { - if (LoadedMods.GalacticraftCore) { + if (LoadedMods.GalacticraftCore && AsmConfig.enableGcFuelChanges) { if (mBlock == null) { try { - Class GCBlocks = Class.forName("micdoodle8.mods.galacticraft.core.blocks.GCBlocks"); + Class GCBlocks = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.blocks.GCBlocks"); if (GCBlocks != null) { oMainClass = GCBlocks; diff --git a/src/Java/gtPlusPlus/xmod/galacticraft/system/core/world/gen/ChunkProviderGalactic.java b/src/Java/gtPlusPlus/xmod/galacticraft/system/core/world/gen/ChunkProviderGalactic.java index 3b9633b21d..aafa9ef9a1 100644 --- a/src/Java/gtPlusPlus/xmod/galacticraft/system/core/world/gen/ChunkProviderGalactic.java +++ b/src/Java/gtPlusPlus/xmod/galacticraft/system/core/world/gen/ChunkProviderGalactic.java @@ -4,12 +4,11 @@ import java.util.List; import com.google.common.collect.Lists; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import micdoodle8.mods.galacticraft.api.prefab.core.BlockMetaPair; import micdoodle8.mods.galacticraft.api.prefab.world.gen.BiomeDecoratorSpace; import micdoodle8.mods.galacticraft.api.prefab.world.gen.MapGenBaseMeta; -import micdoodle8.mods.galacticraft.core.entities.EntityEvolvedCreeper; -import micdoodle8.mods.galacticraft.core.entities.EntityEvolvedSkeleton; -import micdoodle8.mods.galacticraft.core.entities.EntityEvolvedSpider; import net.minecraft.block.Block; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; @@ -46,20 +45,37 @@ public abstract class ChunkProviderGalactic extends ChunkProviderGalaxyLakes { } protected SpawnListEntry[] getMonsters() { - SpawnListEntry skele = new SpawnListEntry(EntityEvolvedSkeleton.class, 100, 4, 4); - SpawnListEntry creeper = new SpawnListEntry(EntityEvolvedCreeper.class, 100, 4, 4); - SpawnListEntry spider = new SpawnListEntry(EntityEvolvedSpider.class, 100, 4, 4); + + Class aSkele = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.entities.EntityEvolvedSkeleton"); + Class aCreeper = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.entities.EntityEvolvedCreeper"); + Class aSpider = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.entities.EntityEvolvedSpider"); + Class aEnderman = ReflectionUtils.getClass("galaxyspace.SolarSystem.planets.pluto.entities.EntityEvolvedEnderman"); + + SpawnListEntry skele; + SpawnListEntry creeper; + SpawnListEntry spider; + SpawnListEntry enderman; - Class aEnderman; - try { - aEnderman = Class.forName("galaxyspace.SolarSystem.planets.pluto.entities.EntityEvolvedEnderman"); - if (aEnderman != null) { - SpawnListEntry enderman = new SpawnListEntry(aEnderman, 100, 4, 4); - return new SpawnListEntry[] { skele, creeper, spider, enderman }; - } - } catch (ClassNotFoundException e) {} + AutoMap aMobs = new AutoMap(); - return new SpawnListEntry[] { skele, creeper, spider }; + if (aSkele != null) { + skele = new SpawnListEntry(aSkele, 100, 4, 4); + aMobs.put(skele); + } + if (aCreeper != null) { + creeper = new SpawnListEntry(aCreeper, 100, 4, 4); + aMobs.put(creeper); + } + if (aSpider != null) { + spider = new SpawnListEntry(aSpider, 100, 4, 4); + aMobs.put(spider); + } + if (aEnderman != null) { + enderman = new SpawnListEntry(aEnderman, 100, 4, 4); + aMobs.put(enderman); + } + + return aMobs.toArray(); } public void onPopulate(IChunkProvider arg0, int arg1, int arg2) { diff --git a/src/Java/gtPlusPlus/xmod/galacticraft/util/GalacticUtils.java b/src/Java/gtPlusPlus/xmod/galacticraft/util/GalacticUtils.java index 94dc2d0cc0..f237aed335 100644 --- a/src/Java/gtPlusPlus/xmod/galacticraft/util/GalacticUtils.java +++ b/src/Java/gtPlusPlus/xmod/galacticraft/util/GalacticUtils.java @@ -26,11 +26,11 @@ public class GalacticUtils { Class a1, a2, a3, a4, a5; Method m1, m2, m3; try { - a1 = Class.forName("micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket"); - a2 = Class.forName("micdoodle8.mods.galacticraft.core.tile.TileEntityLandingPad"); - a3 = Class.forName("micdoodle8.mods.galacticraft.core.tile.TileEntityBuggyFueler"); - a4 = Class.forName("micdoodle8.mods.galacticraft.api.entity.IDockable"); - a5 = Class.forName("micdoodle8.mods.galacticraft.api.entity.IFuelable"); + a1 = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket"); + a2 = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.tile.TileEntityLandingPad"); + a3 = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.tile.TileEntityBuggyFueler"); + a4 = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.api.entity.IDockable"); + a5 = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.api.entity.IFuelable"); m1 = ReflectionUtils.getMethod(a1, "getRocketTier"); m2 = ReflectionUtils.getMethod(a2, "getDockedEntity"); m3 = ReflectionUtils.getMethod(a3, "getDockedEntity"); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Naquadah.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Naquadah.java index 2b7f44be59..0d4d8b6cdd 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Naquadah.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Naquadah.java @@ -184,7 +184,7 @@ public class GT_MetaTileEntity_Hatch_Naquadah extends GT_MetaTileEntity_Hatch_In a2 = F2.getByte(this); } } - catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException n) {} + catch (IllegalArgumentException | IllegalAccessException n) {} int textureIndex = a1 | a2 << 7; byte texturePointer = (byte) (a1 & 127); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java index 30c1bc2b29..bed80d8d13 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java @@ -50,11 +50,9 @@ public class GT_MetaTileEntity_Hatch_Plasma extends GT_MetaTileEntity_Hatch_Outp //Get all Plasmas, but the easiest way to do this is to just ask the Fluid Registry what exists and filter through them lazily. Field fluidNameCache; - try { - fluidNameCache = ReflectionUtils.getField(FluidRegistry.class, "fluidNames"); - } catch (NoSuchFieldException e) { - fluidNameCache = null; - } + + fluidNameCache = ReflectionUtils.getField(FluidRegistry.class, "fluidNames"); + AutoMap mValidPlasmaNameCache = new AutoMap(); if (fluidNameCache != null) { try { @@ -199,7 +197,7 @@ public class GT_MetaTileEntity_Hatch_Plasma extends GT_MetaTileEntity_Hatch_Outp a2 = F2.getByte(this); } } - catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException n) {} + catch (IllegalArgumentException | IllegalAccessException n) {} int textureIndex = a1 | a2 << 7; byte texturePointer = (byte) (a1 & 127); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index b55157e763..7103c81980 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -482,9 +482,9 @@ GT_MetaTileEntity_MultiBlockBase { public void log(String s) { boolean isDebugLogging = CORE.DEBUG; - boolean reset = false; + boolean reset = true; if (aLogger == null || reset) { - if (isDebugLogging) { + if (true) { try { aLogger = Logger.class.getMethod("INFO", String.class); } catch (NoSuchMethodException | SecurityException e) {} @@ -1141,7 +1141,8 @@ GT_MetaTileEntity_MultiBlockBase { if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input || aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input){ ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = null; - ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = aMap; + ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = aMap; + log("Remapped Input Hatch to "+aMap.mNEIName); } else { ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mRecipeMap = null; @@ -1173,7 +1174,6 @@ GT_MetaTileEntity_MultiBlockBase { * Enable Texture Casing Support if found in GT 5.09 */ - @SuppressWarnings("deprecation") public boolean updateTexture(final IGregTechTileEntity aTileEntity, int aCasingID){ final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); if (aMetaTileEntity == null) { @@ -1194,7 +1194,7 @@ GT_MetaTileEntity_MultiBlockBase { if (aMetaTileEntity == null) { return false; } - Method mProper = Class.forName("gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch").getDeclaredMethod("updateTexture", int.class); + Method mProper = ReflectionUtils.getMethod(GT_MetaTileEntity_Hatch.class, "updateTexture", int.class); if (mProper != null){ if (GT_MetaTileEntity_Hatch.class.isInstance(aMetaTileEntity)){ mProper.setAccessible(true); @@ -1202,7 +1202,6 @@ GT_MetaTileEntity_MultiBlockBase { log("Good Method Call for updateTexture."); return true; } - } else { log("Bad Method Call for updateTexture."); @@ -1223,7 +1222,7 @@ GT_MetaTileEntity_MultiBlockBase { log("updateTexture returning false. 1"); return false; } - catch (NoSuchMethodException | SecurityException | ClassNotFoundException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { log("updateTexture returning false."); log("updateTexture returning false. 2"); e.printStackTrace(); @@ -1277,15 +1276,12 @@ GT_MetaTileEntity_MultiBlockBase { @SuppressWarnings("rawtypes") public boolean isThisHatchMultiDynamo(Object aMetaTileEntity){ Class mDynamoClass; - try { - mDynamoClass = Class.forName("com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoMulti"); + mDynamoClass = ReflectionUtils.getClass("com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoMulti"); if (mDynamoClass != null){ if (mDynamoClass.isInstance(aMetaTileEntity)){ return true; } } - } - catch (ClassNotFoundException e) {} return false; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockLayer.java b/src/Java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockLayer.java index 88b4c7bc99..c5554a6679 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockLayer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockLayer.java @@ -17,6 +17,7 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import net.minecraft.block.Block; import net.minecraft.block.BlockAir; import net.minecraft.init.Blocks; @@ -124,10 +125,11 @@ public class MultiblockLayer { GT_MetaTileEntity_Hatch.class }; } - else { - try { + else { + Class aDataHatch = ReflectionUtils.getClass("gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_DataAccess"); + if (aDataHatch != null) { aHatchTypeClass = new Class[] { - Class.forName("gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_DataAccess"), + aDataHatch, GT_MetaTileEntity_Hatch_Dynamo.class, GT_MetaTileEntity_Hatch_Energy.class, GT_MetaTileEntity_Hatch_Input.class, @@ -138,7 +140,7 @@ public class MultiblockLayer { GT_MetaTileEntity_Hatch_OutputBus.class, GT_MetaTileEntity_Hatch.class }; - } catch (ClassNotFoundException e) { + } else { aHatchTypeClass = new Class[] { GT_MetaTileEntity_Hatch_Dynamo.class, GT_MetaTileEntity_Hatch_Energy.class, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/util/GregtechOreDictUnificator.java b/src/Java/gtPlusPlus/xmod/gregtech/api/util/GregtechOreDictUnificator.java index d5327a6a99..3e0084139e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/util/GregtechOreDictUnificator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/util/GregtechOreDictUnificator.java @@ -38,12 +38,9 @@ public class GregtechOreDictUnificator { private static boolean mRunThroughTheList = true; static { - try { if (ReflectionUtils.getField(GT_OreDictUnificator.class, "sUnificationTable") == null) { GregTech_API.sItemStackMappings.add(sUnificationTable); } - } - catch (NoSuchFieldException e) {} } /** diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java index 5eee77e065..6b4bab9e26 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java @@ -5,6 +5,7 @@ import static gtPlusPlus.xmod.gregtech.common.covers.GTPP_Cover_Overflow.mOverfl import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; @@ -18,11 +19,16 @@ import cpw.mods.fml.relauncher.SideOnly; import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.BaseMetaTileEntity; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; +import gregtech.api.util.Recipe_GT; +import gregtech.api.util.Recipe_GT.Gregtech_Recipe_Map; import gregtech.common.GT_Proxy; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; @@ -30,6 +36,9 @@ import gtPlusPlus.api.objects.data.ObjMap; import gtPlusPlus.api.objects.minecraft.FormattedTooltipString; import gtPlusPlus.core.handler.AchievementHandler; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.MaterialUtils; import gtPlusPlus.core.util.reflect.ProxyFinder; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.BaseCustomTileEntity; @@ -104,6 +113,120 @@ public class Meta_GT_Proxy { mAssemblyAchievements = new AchievementHandler(); } + public static boolean generatePlasmaRecipesForAdvVacFreezer() { + + AutoMap aFreezerMapRebaked = new AutoMap(); + AutoMap aRemovedRecipes = new AutoMap(); + + //Find recipes containing Plasma and map them + for (Recipe_GT y : Recipe_GT.Gregtech_Recipe_Map.sAdvFreezerRecipes.mRecipeList) { + if (y.mFluidInputs.length > 0) { + for (FluidStack r : y.mFluidInputs) { + if (r.getUnlocalizedName().toLowerCase().contains("plasma")) { + aRemovedRecipes.put(y); + continue; + } + } + aFreezerMapRebaked.put(y); + } + } + + AutoMap aNewRecipes = new AutoMap(); + int aAtomicMass = 0; + int aAtomicTier = 0; + + final FluidStack NULL_PLASMA = Materials._NULL.getPlasma(1); + + for (String s : ELEMENT.NAMES) { + + aAtomicMass++; + aAtomicTier = (aAtomicMass/30)+1; + FluidStack aMoltenFluid = null; + FluidStack aPlasma = null; + + //Try Get Material via Gregtech + Materials aGregMaterial = MaterialUtils.getMaterial(s); + if (aGregMaterial != null) { + aMoltenFluid = aGregMaterial.getMolten(1); + if (aMoltenFluid == null) { + aMoltenFluid = aGregMaterial.getFluid(1); + if (aMoltenFluid == null) { + aMoltenFluid = aGregMaterial.getGas(1); + if (aMoltenFluid == null) { + aMoltenFluid = aGregMaterial.getSolid(1); + } + } + } + aPlasma = aGregMaterial.getPlasma(100); + } + + //Just wildcard values + if (aMoltenFluid == null || aPlasma == null) { + if (aMoltenFluid == null) { + aMoltenFluid = FluidUtils.getWildcardFluidStack(s, 1); + } + if (aPlasma == null) { + aPlasma = FluidUtils.getFluidStack("plasma."+s.toLowerCase(), 1); + } + } + + //Skip this material + if (aMoltenFluid == null || aPlasma == null || aPlasma.isFluidEqual(NULL_PLASMA)) { + Logger.INFO("Could not generate Advanced Vacuum Freezer recipe. Cooling "+s+" plasma. Molten Form Exists? "+(aMoltenFluid != null)+" | Plasma Exists? "+(aPlasma != null)); + continue; + } + else { + //Build a new plasma recipe + int aTotalTickTime = (20 * 1 + (aAtomicMass)); + Recipe_GT aTempRecipe = new Recipe_GT(true, + new ItemStack[] {}, + new ItemStack[] {}, + null, + new int[] {10000}, + new FluidStack[] { + aPlasma, + FluidUtils.getFluidStack("cryotheum", aTotalTickTime) + }, + new FluidStack[] { + aMoltenFluid + }, + aTotalTickTime, + (int) GT_Values.V[4+aAtomicTier], + aAtomicMass); + + //Add it to the map if it's valid + if (aTempRecipe != null) { + aNewRecipes.put(aTempRecipe); + } + } + + } + + + //Add the new recipes to the map we will rebake over the original + for (Recipe_GT w : aNewRecipes) { + aFreezerMapRebaked.put(w); + } + + //Best not touch the original map if we don't have a valid map to override it with. + if (aFreezerMapRebaked.size() > 0) { + + int aOriginalCount = Recipe_GT.Gregtech_Recipe_Map.sAdvFreezerRecipes.mRecipeList.size(); + + //Empty the original map + Recipe_GT.Gregtech_Recipe_Map.sAdvFreezerRecipes.mRecipeList.clear(); + + //Rebake the real map + for (Recipe_GT w : aFreezerMapRebaked) { + Recipe_GT.Gregtech_Recipe_Map.sAdvFreezerRecipes.mRecipeList.add(w); + } + + return Recipe_GT.Gregtech_Recipe_Map.sAdvFreezerRecipes.mRecipeList.size() >= aOriginalCount; + } + + return false; + } + public static TileEntity constructCustomGregtechMetaTileEntityByMeta(int aMeta) { if (aMeta == 12) { return Meta_GT_Proxy.constructBaseMetaTileEntityCustomPower(); @@ -279,7 +402,7 @@ public class Meta_GT_Proxy { if (proxyGT != null && proxyGT instanceof GT_Proxy) { try { return ReflectionUtils.getField(proxyGT.getClass(), fieldName).get(proxyGT); - } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + } catch (IllegalArgumentException | IllegalAccessException e) { } } return null; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java b/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java index 63581af16c..1604cc5acd 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java @@ -108,11 +108,7 @@ public class StaticFields59 { } public static Field getField(Class a, String b) { - try { - return ReflectionUtils.getField(a, b); - } catch (NoSuchFieldException e) { - return null; - } + return ReflectionUtils.getField(a, b); } public static Method getMethod(Class a, String b, Class... params) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java index 0178bac4da..bda75be793 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java @@ -23,6 +23,7 @@ import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.NBTUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaWirelessCharger; import ic2.api.info.Info; import ic2.api.item.ElectricItem; @@ -291,12 +292,11 @@ public class ChargingHelper { } //Try get charge direct from NBT for GT and IC2 stacks - try { Logger.WARNING("3"); if (mTemp.getItem() instanceof GT_MetaGenerated_Tool_01 || mTemp.getItem() instanceof GT_MetaGenerated_Item_01 || mTemp.getItem() instanceof GT_MetaGenerated_Item_02 - || Class.forName("gregtech.common.items.GT_MetaGenerated_Item_03").isInstance(mTemp.getItem()) + || ReflectionUtils.getClass("gregtech.common.items.GT_MetaGenerated_Item_03").isInstance(mTemp.getItem()) || mTemp.getItem().getClass().getName().toLowerCase().equals(("gregtech.common.items.GT_MetaGenerated_Tool_01").toLowerCase())){ if (!NBTUtils.hasKey(mTemp, "GT.ItemCharge")){ if (!mTemp.getDisplayName().toLowerCase().contains("battery")){ @@ -314,10 +314,7 @@ public class ChargingHelper { } else if (mTemp.getItem() instanceof IElectricItem){ mitemCurrentCharge = NBTUtils.getLong(mTemp, "charge"); - } - } catch (ClassNotFoundException e) { - - } + } double mVoltageIncrease; if (mItemEuTLimit >= mVoltage){ diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java index 2bfb07ff4a..3c60ae664e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java @@ -321,14 +321,12 @@ public class TreeFarmHelper { return blockHumus; } else if (ReflectionUtils.doesClassExist("forestry.core.blocks.BlockSoil")){ - try { - final Class humusClass = Class.forName("forestry.core.blocks.BlockSoil"); + final Class humusClass = ReflectionUtils.getClass("forestry.core.blocks.BlockSoil"); final ItemStack humusStack = ItemUtils.getCorrectStacktype("Forestry:soil", 1); if (humusClass != null){ blockHumus = Block.getBlockFromItem(humusStack.getItem()); return Block.getBlockFromItem(humusStack.getItem()); } - } catch (final ClassNotFoundException e) {} } return null; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java index 411171a766..6b061c3704 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java @@ -285,7 +285,7 @@ public class MetaGeneratedGregtechItems extends Gregtech_MetaItem_X32 { //Fusion Reactor MK4 Singularity GregtechItemList.Compressed_Fusion_Reactor.set(this.addItem(100, "Hypervisor Matrix (Fusion)", "A memory unit containing an RI (Restricted Intelligence)", new Object[0])); - CORE.RA.addCompressorRecipe(ItemList.FusionComputer_UV.get(9), GregtechItemList.Compressed_Fusion_Reactor.get(1), (int) GT_Values.V[7], (int) GT_Values.V[8]); + //NanoTubes GregtechItemList.NanoTube_Base_Substrate.set(this.addItem(101, "Silicon Base Substrate", "Used in the production of Carbon Nanotubes", new Object[0])); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_AutoCrafter.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_AutoCrafter.java index 759378013c..c31a7c0758 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_AutoCrafter.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_AutoCrafter.java @@ -221,7 +221,7 @@ public class GT4Entity_AutoCrafter extends GregtechMeta_MultiBlockBase { return r; } } - } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) { + } catch (IllegalArgumentException | IllegalAccessException e) { } } return GT_Recipe.GT_Recipe_Map.sAssemblerRecipes; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java index 1623e7cb54..de5d731dd5 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java @@ -410,9 +410,13 @@ public class GregtechMetaTileEntity_Cyclotron extends GregtechMeta_MultiBlockBas //Time Counter this.mTotalRunTime++; - onRunningTick(null); + onRunningTick(null); - if (mRunningOnLoad && checkMultiblock(aBaseMetaTileEntity, mInventory[1])) { + boolean aFormCheck = (aTick % 100 == 0 ? checkMultiblock(aBaseMetaTileEntity, mInventory[1]) : true); + + + + if (mRunningOnLoad && aFormCheck) { this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); checkRecipe(mInventory[1]); } @@ -429,7 +433,7 @@ public class GregtechMetaTileEntity_Cyclotron extends GregtechMeta_MultiBlockBas mDischargeHatches.clear(); mControlCoreBus.clear(); mMultiDynamoHatches.clear(); - mMachine = checkMultiblock(aBaseMetaTileEntity, mInventory[1]); + mMachine = aFormCheck; } if (mStartUpCheck < 0) { if (mMachine) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialFishingPond.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialFishingPond.java index b1e433e276..fc0cb85bac 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialFishingPond.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialFishingPond.java @@ -459,7 +459,7 @@ public class GregtechMetaTileEntity_IndustrialFishingPond extends GregtechMeta_M ItemStack k = ItemUtils.getSimpleStack(t, 1); reflectiveFishMap.put(y, k); return t; - } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + } catch (IllegalArgumentException | IllegalAccessException e) { } return null; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java index 1a19bc7b96..e6fecf5d18 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java @@ -1,23 +1,25 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; -import java.util.ArrayList; +import static gregtech.api.enums.GT_Values.E; +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; + +import java.util.HashSet; -import gregtech.api.enums.GT_Values; import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.CustomRecipeMap; import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; public class GregtechMetaTileEntity_Refinery extends GregtechMeta_MultiBlockBase { @@ -69,42 +71,30 @@ public class GregtechMetaTileEntity_Refinery extends GregtechMeta_MultiBlockBase @Override public String getCustomGUIResourceName() { - return "LFTR"; + return "MatterFabricator"; } + private static final GT_Recipe_Map mGregTypeRecipeMap = new GT_Recipe_Map(new HashSet(), "internal.recipe.fissionfuel", "Fission Fuel Processing", null, RES_PATH_GUI + "basicmachines/FissionFuel", 0, 0, 0, 4, 1, E, 1, E, true, true); + @Override - public boolean checkRecipe(ItemStack aStack) { - ArrayList tFluidList = getStoredFluids(); - int tFluidList_sS=tFluidList.size(); - for (int i = 0; i < tFluidList_sS - 1; i++) { - for (int j = i + 1; j < tFluidList_sS; j++) { - if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { - if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { - tFluidList.remove(j--); tFluidList_sS=tFluidList.size(); - } else { - tFluidList.remove(i--); tFluidList_sS=tFluidList.size(); - break; - } - } - } - } - if (tFluidList.size() > 1) { - FluidStack[] tFluids = tFluidList.toArray(new FluidStack[tFluidList.size()]); - GT_Recipe tRecipe = CustomRecipeMap.sFissionFuelProcessing.findRecipe(this.getBaseMetaTileEntity(), this.mLastRecipe, false, GT_Values.V[4], tFluids, new ItemStack[]{}); - if (tRecipe == null) { - this.mLastRecipe = null; - return false; - } - if (tRecipe.isRecipeInputEqual(true, tFluids, new ItemStack[]{})) { - this.mLastRecipe = tRecipe; - this.mEUt = this.mLastRecipe.mEUt; - this.mMaxProgresstime = this.mLastRecipe.mDuration; - this.mEfficiencyIncrease = 10000; - this.mOutputFluids = this.mLastRecipe.mFluidOutputs; - return true; - } - } - return false; + public GT_Recipe_Map getRecipeMap() { + if (mGregTypeRecipeMap.mRecipeList.size() <= 0) { + for (GT_Recipe g : CustomRecipeMap.sFissionFuelProcessing.mRecipeList) { + mGregTypeRecipeMap.mRecipeList.add(g); + } + } + return mGregTypeRecipeMap; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + //this.resetRecipeMapForAllInputHatches(); + for (GT_MetaTileEntity_Hatch_Input g : this.mInputHatches) { + g.mRecipeMap = null; + } + boolean ab = super.checkRecipeGeneric(); + Logger.INFO("Did Recipe? "+ab); + return ab; } @Override @@ -261,7 +251,8 @@ public class GregtechMetaTileEntity_Refinery extends GregtechMeta_MultiBlockBase Logger.INFO("Your Muffler must be AT LEAST ZPM tier or higher."); } } - Logger.INFO("Fission Fuel Production Plant Formed."); + Logger.INFO("Fission Fuel Production Plant Formed. "+mGregTypeRecipeMap.mRecipeList.size()); + this.resetRecipeMapForAllInputHatches(this.getRecipeMap()); return true; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/GT_Material_Loader.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/GT_Material_Loader.java index 68f78503e8..4c8707e5e8 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/GT_Material_Loader.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/GT_Material_Loader.java @@ -38,8 +38,7 @@ public class GT_Material_Loader { instance = this; //Try Reflectively add ourselves to the GT loader. - try { - Class mInterface = Class.forName("gregtech.api.interfaces.IMaterialHandler"); + Class mInterface = ReflectionUtils.getClass("gregtech.api.interfaces.IMaterialHandler"); if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && mInterface != null){ //Make this class Dynamically implement IMaterialHandler @@ -49,7 +48,7 @@ public class GT_Material_Loader { new MaterialHandler(getInstance())); } - if (ReflectionUtils.invoke(Materials.class, "add", new Class[]{Class.forName("gregtech.api.interfaces.IMaterialHandler")}, new Object[]{mProxyObject})){ + if (ReflectionUtils.invoke(Materials.class, "add", new Class[]{ReflectionUtils.getClass("gregtech.api.interfaces.IMaterialHandler")}, new Object[]{mProxyObject})){ Logger.REFLECTION("Successfully invoked add, on the proxied object implementing IMaterialHandler."); @@ -65,9 +64,7 @@ public class GT_Material_Loader { else { Logger.REFLECTION("Failed to invoke add, on the proxied object implementing IMaterialHandler."); } - } - } - catch (ClassNotFoundException e) {} + } //Materials.add(this); //Stupid shit running twice, I don't think so. @@ -139,12 +136,12 @@ public class GT_Material_Loader { return false; } try { - Method enableComponent = Class.forName("gregtech.api.enums.OrePrefixes").getDeclaredMethod("enableComponent", Materials.class); + Method enableComponent = ReflectionUtils.getClass("gregtech.api.enums.OrePrefixes").getDeclaredMethod("enableComponent", Materials.class); enableComponent.invoke(prefix, mMaterial); Logger.DEBUG_MATERIALS("Enabled "+prefix.name()+" for "+mMaterial.mDefaultLocalName+"."); return true; } - catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException | ClassNotFoundException error) { + catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException error) { Logger.DEBUG_MATERIALS("Failed to enabled "+prefix.name()+" for "+mMaterial.mDefaultLocalName+". Caught "+error.getCause().toString()+"."); error.printStackTrace(); } @@ -228,7 +225,7 @@ public class GT_Material_Loader { //Loading the class at runtime public static void main(String[] args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, ClassNotFoundException { - Class someInterface = Class.forName("gregtech.api.interfaces.IMaterialHandler"); + Class someInterface = ReflectionUtils.getClass("gregtech.api.interfaces.IMaterialHandler"); Object instance = Proxy.newProxyInstance(someInterface.getClassLoader(), new Class[]{someInterface}, new InvocationHandler() { @Override @@ -274,7 +271,7 @@ public class GT_Material_Loader { public static void init(){ - Class someInterface = Class.forName("gregtech.api.interfaces.IMaterialHandler"); + Class someInterface = ReflectionUtils.getClass("gregtech.api.interfaces.IMaterialHandler"); GT_Material_Loader original = GT_Material_Loader.instance; MaterialHandler handler = new MaterialHandler(original); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java index 001edf3ab9..b4f7347b52 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java @@ -696,8 +696,7 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { Method T = null; if (LoadedMods.TecTech) { - try { - Class TTRecipeAdder = Class.forName("com.github.technus.tectech.recipe.TT_recipeAdder"); + Class TTRecipeAdder = ReflectionUtils.getClass("com.github.technus.tectech.recipe.TT_recipeAdder"); if (TTRecipeAdder != null) { Method ttTest = ReflectionUtils.getMethod(TTRecipeAdder, "addResearchableAssemblylineRecipe", ItemStack.class, int.class, int.class, int.class, int.class, Object[].class, @@ -706,8 +705,6 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { T = ttTest; } } - } catch (ClassNotFoundException e) { - } } else { T = null; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechNitroDieselFix.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechNitroDieselFix.java index f924e5233d..6095413150 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechNitroDieselFix.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechNitroDieselFix.java @@ -22,6 +22,7 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.MaterialUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import net.minecraftforge.fluids.FluidStack; public class GregtechNitroDieselFix { @@ -34,7 +35,7 @@ public class GregtechNitroDieselFix { int mSub = Utils.getGregtechSubVersion(); if (mSub != 0){ if (mSub >= 30){ - Class mb = Class.forName("gregtech.api.enums.MaterialBuilder"); + Class mb = ReflectionUtils.getClass("gregtech.api.enums.MaterialBuilder"); Object df = mb.getConstructor(int.class, TextureSet.class, String.class).newInstance(975, TextureSet.SET_FLUID, "Nitro-Diesel [Old]"); if (mb.isInstance(df)){ @@ -158,7 +159,7 @@ public class GregtechNitroDieselFix { } } } - catch (ClassNotFoundException | IllegalArgumentException | IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException | SecurityException e) { + catch (IllegalArgumentException | IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException | SecurityException e) { Logger.INFO("[Nitro] ================ Error ================"); e.printStackTrace(); Logger.INFO("[Nitro] ================ Error ================"); diff --git a/src/Java/gtPlusPlus/xmod/growthcraft/fishtrap/FishTrapHandler.java b/src/Java/gtPlusPlus/xmod/growthcraft/fishtrap/FishTrapHandler.java index 5410b0f619..5a9dc748ca 100644 --- a/src/Java/gtPlusPlus/xmod/growthcraft/fishtrap/FishTrapHandler.java +++ b/src/Java/gtPlusPlus/xmod/growthcraft/fishtrap/FishTrapHandler.java @@ -11,6 +11,7 @@ import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.MaterialGenerator; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import net.minecraft.item.ItemStack; public class FishTrapHandler { @@ -31,14 +32,14 @@ public class FishTrapHandler { private final static Object setFishTrapRegistry(){ Class mFishingRegistryClass; try { - mFishingRegistryClass = Class.forName("growthcraft.api.fishtrap.FishTrapRegistry"); + mFishingRegistryClass = ReflectionUtils.getClass("growthcraft.api.fishtrap.FishTrapRegistry"); final Method mFishingRegistryMethod = mFishingRegistryClass.getDeclaredMethod("getInstance"); mFishingRegistry = mFishingRegistryMethod.invoke(null); if (mFishingRegistry != null){ return mFishingRegistry; } } - catch (ClassNotFoundException | NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { } return null; } diff --git a/src/Java/gtPlusPlus/xmod/sc2/modules/ModuleExoticSeeds.java b/src/Java/gtPlusPlus/xmod/sc2/modules/ModuleExoticSeeds.java index 617c4ddd8a..dfaec8b703 100644 --- a/src/Java/gtPlusPlus/xmod/sc2/modules/ModuleExoticSeeds.java +++ b/src/Java/gtPlusPlus/xmod/sc2/modules/ModuleExoticSeeds.java @@ -87,11 +87,11 @@ public class ModuleExoticSeeds extends ModuleAddon implements ICropModule { else { if (mForestryHumusBlockClass == null || mForestryHumusBlock == null) { try { - mForestryHumusBlockClass = Class.forName("forestry.plugins.PluginCore"); + mForestryHumusBlockClass = ReflectionUtils.getClass("forestry.plugins.PluginCore"); Field blocks = ReflectionUtils.getField(mForestryHumusBlockClass, "blocks"); if (blocks != null) { Object blockRegistryCoreObject = blocks.get(null); - mForestryBlockRegistryCoreClass = Class.forName("forestry.core.blocks.BlockRegistryCore"); + mForestryBlockRegistryCoreClass = ReflectionUtils.getClass("forestry.core.blocks.BlockRegistryCore"); if (mForestryBlockRegistryCoreClass != null && blockRegistryCoreObject != null) { Field soil = ReflectionUtils.getField(mForestryBlockRegistryCoreClass, "soil"); if (soil != null) { diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/HANDLER_Thaumcraft.java b/src/Java/gtPlusPlus/xmod/thaumcraft/HANDLER_Thaumcraft.java index 558b134ea9..be3b23531c 100644 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/HANDLER_Thaumcraft.java +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/HANDLER_Thaumcraft.java @@ -37,10 +37,9 @@ public class HANDLER_Thaumcraft { public static void init(){ if (LoadedMods.Thaumcraft){ try { - mResearchNotes = (Item) ReflectionUtils.getField(Class.forName("thaumcraft.common.config.ConfigItems"), "itemResearchNotes").get(null); + mResearchNotes = (Item) ReflectionUtils.getField(ReflectionUtils.getClass("thaumcraft.common.config.ConfigItems"), "itemResearchNotes").get(null); } - catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException - | ClassNotFoundException e) { + catch (IllegalArgumentException | IllegalAccessException e) { mResearchNotes = Items.paper; } } diff --git a/src/Java/gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java b/src/Java/gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java index 501fe6579a..a6260d4246 100644 --- a/src/Java/gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java +++ b/src/Java/gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java @@ -33,7 +33,7 @@ public class HANDLER_Tinkers { public static final void postInit() { if (LoadedMods.TiCon) { - Class aTinkersSmeltery = ReflectionUtils.getClassByName("tconstruct.smeltery.TinkerSmeltery"); + Class aTinkersSmeltery = ReflectionUtils.getClass("tconstruct.smeltery.TinkerSmeltery"); AutoMap aTweakedFluids = new AutoMap(); if (aTinkersSmeltery != null) { try { @@ -84,7 +84,7 @@ public class HANDLER_Tinkers { } } } - } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) { + } catch (IllegalArgumentException | IllegalAccessException e) { } } } diff --git a/src/Java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java b/src/Java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java new file mode 100644 index 0000000000..a2ab894f53 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java @@ -0,0 +1,200 @@ +package gtPlusPlus.xmod.tinkers.material; + +import static gtPlusPlus.core.util.math.MathUtils.safeCast_LongToInt; + +import java.util.HashMap; + +import cpw.mods.fml.common.event.FMLInterModComms; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.util.Utils; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.crafting.FluidType; +import tconstruct.library.crafting.Smeltery; +import tconstruct.library.tools.ToolMaterial; +import tconstruct.smeltery.TinkerSmeltery; + +public class BaseTinkersMaterial { + + private static HashMap aInternalMaterialIdMap = new HashMap(); + private static int aNextFreeID = 440; + private final String mUnlocalName; + public final String mLocalName; + private final int aID; + + public BaseTinkersMaterial(Material aMaterial) { + mLocalName = Utils.sanitizeString(aMaterial.getLocalizedName()); + mUnlocalName = "material.gtpp."+Utils.sanitizeString(mLocalName); + aID = aNextFreeID++; + aInternalMaterialIdMap.put(mUnlocalName, aID); + + + int id = aID; + if (id > 0) { + + ToolMaterial mat = new ToolMaterial(mLocalName, mUnlocalName, 4, 100, 700, 2, + 0.6F, 4, 0.0F, EnumChatFormatting.WHITE.toString(), 16777215); + + TConstructRegistry.addtoolMaterial(id, mat); + TConstructRegistry.addDefaultToolPartMaterial(id); + TConstructRegistry.addBowMaterial(id, calcBowDrawSpeed(aMaterial), 1.0F); + TConstructRegistry.addArrowMaterial(id, calcProjectileMass(aMaterial), calcProjectileFragility(aMaterial)); + + NBTTagCompound tag = new NBTTagCompound(); + tag.setInteger("Id", id); + tag.setString("Name", mLocalName); + tag.setString("localizationString", mUnlocalName); + tag.setInteger("Durability", calcDurability(aMaterial)); // 97 + tag.setInteger("MiningSpeed", calcMiningSpeed(aMaterial)); // 150 + tag.setInteger("HarvestLevel", calcHarvestLevel(aMaterial)); // 1 + tag.setInteger("Attack", calcAttack(aMaterial)); // 0 + tag.setFloat("HandleModifier", calcHandleModifier(aMaterial)); // 1.0f + tag.setInteger("Reinforced", calcReinforced(aMaterial)); // 0 + tag.setFloat("Bow_ProjectileSpeed", calcBowProjectileSpeed(aMaterial)); // 3.0f + tag.setInteger("Bow_DrawSpeed", calcBowDrawSpeed(aMaterial)); // 18 + tag.setFloat("Projectile_Mass", calcProjectileMass(aMaterial)); // 0.69f + tag.setFloat("Projectile_Fragility", calcProjectileFragility(aMaterial)); // 0.2f + tag.setString("Style", calcStyle(aMaterial)); + tag.setInteger("Color", calcColour(aMaterial)); + FMLInterModComms.sendMessage("TConstruct", "addMaterial", tag); + + + generateRecipes(aMaterial); + + + ItemStack itemstack = aMaterial.getIngot(1); + tag = new NBTTagCompound(); + tag.setInteger("MaterialId", id); + NBTTagCompound item = new NBTTagCompound(); + itemstack.writeToNBT(item); + tag.setTag("Item", item); + tag.setInteger("Value", 2); // What is value for? + FMLInterModComms.sendMessage("TConstruct", "addPartBuilderMaterial", tag); + + tag = new NBTTagCompound(); + tag.setInteger("MaterialId", id); + tag.setInteger("Value", 2); // What is value for? + item = new NBTTagCompound(); + itemstack.writeToNBT(item); + tag.setTag("Item", item); + + FMLInterModComms.sendMessage("TConstruct", "addMaterialItem", tag); + + + } + + + + + + + + } + + public String getUnlocalName() { + return mUnlocalName; + } + + + private static int calcDurability(Material aMaterial) { + return safeCast_LongToInt(aMaterial.vDurability); + } + + private static int calcMiningSpeed(Material aMaterial) { + return (aMaterial.vHarvestLevel * 2)+aMaterial.vTier; + } + + private static int calcHarvestLevel(Material aMaterial) { + return aMaterial.vHarvestLevel; + } + + private static int calcAttack(Material aMaterial) { + return aMaterial.vHarvestLevel+aMaterial.vTier+aMaterial.vRadiationLevel; + } + + private static float calcHandleModifier(Material aMaterial) { + return 1f; + } + + private static int calcReinforced(Material aMaterial) { + return aMaterial.getMeltingPointC()/3600; + } + + private static int calcBowProjectileSpeed(Material aMaterial) { + return aMaterial.vHarvestLevel+2; + } + + private static int calcBowDrawSpeed(Material aMaterial) { + return aMaterial.vHarvestLevel+8; + } + + private static float calcProjectileMass(Material aMaterial) { + return (aMaterial.getMeltingPointC()/1800)*0.1f; + } + + private static float calcProjectileFragility(Material aMaterial) { + return 0f; + } + + private static String calcStyle(Material aMaterial) { + String aReturn = "" + EnumChatFormatting.WHITE; + int aTemp = aMaterial.getMeltingPointC(); + if (aTemp < 3600) { + aReturn = "" + EnumChatFormatting.WHITE; + } + else if (aTemp >= 3600) { + aReturn = "" + EnumChatFormatting.YELLOW; + } + else if (aTemp >= (3600*2)) { + aReturn = "" + EnumChatFormatting.GREEN; + } + else if (aTemp >= (3600*3)) { + aReturn = "" + EnumChatFormatting.RED; + } + else if (aTemp >= (3600*4)) { + aReturn = "" + EnumChatFormatting.DARK_RED; + } + else { + aReturn = "" + EnumChatFormatting.GOLD; + } + return aReturn; + } + + private static int calcColour(Material aMaterial) { + return aMaterial.getRgbAsHex(); + } + + private boolean generateRecipes(Material aMaterial) { + + //Smeltery.addMelting(new ItemStack(ExtraUtils.unstableIngot, 1, 0), ExtraUtils.decorative1, 5, 850, aMaterial.getFluid(72)); + + + + FluidType.registerFluidType(mLocalName, aMaterial.getBlock(), 0, aMaterial.getMeltingPointC(), aMaterial.getFluid(0).getFluid(), true); + + Smeltery.addMelting(aMaterial.getBlock(1), aMaterial.getBlock(), 0, aMaterial.getMeltingPointC(), aMaterial.getFluid(144*9)); + Smeltery.addMelting(aMaterial.getIngot(1), aMaterial.getBlock(), 0, aMaterial.getMeltingPointC(), aMaterial.getFluid(144)); + + if (aMaterial.getMeltingPointC() <= 3600) { + ItemStack ingotcast = new ItemStack(TinkerSmeltery.metalPattern, 1, 0); + TConstructRegistry.getBasinCasting().addCastingRecipe(aMaterial.getBlock(1), + aMaterial.getFluid(144*9), (ItemStack) null, true, 100); + TConstructRegistry.getTableCasting().addCastingRecipe(aMaterial.getIngot(1), + aMaterial.getFluid(144), ingotcast, false, 50); + } + + + return true; + } + + + + + + + + + +} diff --git a/src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java b/src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java index aed5b46e0a..10eb93b4d7 100644 --- a/src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java +++ b/src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java @@ -1,9 +1,16 @@ package gtPlusPlus.xmod.tinkers.util; import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.crafting.FluidType; +import tconstruct.library.crafting.Smeltery; +import tconstruct.smeltery.TinkerSmeltery; public class TinkersUtils { @@ -17,16 +24,13 @@ public class TinkersUtils { else { if (mSmelteryInstance == null || mSmelteryClassInstance == null) { if (mSmelteryClassInstance == null) { - try { - mSmelteryClassInstance = Class.forName("tconstruct.library.crafting.Smeltery"); - } - catch (ClassNotFoundException e) {} + mSmelteryClassInstance = ReflectionUtils.getClass("tconstruct.library.crafting.Smeltery"); } if (mSmelteryClassInstance != null) { try { mSmelteryInstance = ReflectionUtils.getField(mSmelteryClassInstance, "instance").get(null); } - catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + catch (IllegalArgumentException | IllegalAccessException e) { } } } @@ -40,9 +44,8 @@ public class TinkersUtils { public static final boolean isTiConFirstInOD() { if (LoadedMods.TiCon) { try { - return (boolean) ReflectionUtils.getField(Class.forName("PHConstruct"), "tconComesFirst").get(null); - } - catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | ClassNotFoundException e) { + return (boolean) ReflectionUtils.getField(ReflectionUtils.getClass("PHConstruct"), "tconComesFirst").get(null); + } catch (IllegalArgumentException | IllegalAccessException e) { } } return false; @@ -51,8 +54,8 @@ public class TinkersUtils { public static final boolean stopTiconLoadingFirst() { if (isTiConFirstInOD()) { try { - ReflectionUtils.setFieldValue(Class.forName("PHConstruct"), "tconComesFirst", false); - if ((boolean) ReflectionUtils.getField(Class.forName("PHConstruct"), "tconComesFirst").get(null) == false) { + 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. @@ -95,5 +98,48 @@ public class TinkersUtils { public static int getFuelDuration (Fluid fluid){ return (int) ReflectionUtils.invokeNonBool(getSmelteryInstance(), "getFuelDuration", new Class[] {Fluid.class}, new Object[] {fluid}); } + + public static boolean registerFluidType(String name, Block block, int meta, int baseTemperature, Fluid fluid, boolean isToolpart) { + + + + //FluidType.registerFluidType(mLocalName, aMaterial.getBlock(), 0, aMaterial.getMeltingPointC(), aMaterial.getFluid(0).getFluid(), true); + return false; + } + + public static boolean addMelting(Material aMaterial) { + Smeltery.addMelting(aMaterial.getBlock(1), aMaterial.getBlock(), 0, aMaterial.getMeltingPointC(), aMaterial.getFluid(144*9)); + Smeltery.addMelting(aMaterial.getIngot(1), aMaterial.getBlock(), 0, aMaterial.getMeltingPointC(), aMaterial.getFluid(144)); + return false; + } + + public static boolean addBasinRecipe(Material aMaterial) { + TConstructRegistry.getBasinCasting().addCastingRecipe(aMaterial.getBlock(1), + aMaterial.getFluid(144*9), (ItemStack) null, true, 100); + return false; + } + + public static boolean addCastingTableRecipe(Material aMaterial) { + ItemStack ingotcast = new ItemStack(TinkerSmeltery.metalPattern, 1, 0); + TConstructRegistry.getTableCasting().addCastingRecipe(aMaterial.getIngot(1), aMaterial.getFluid(144), ingotcast, false, 50); + return false; + } + + + + + + + + + + + + + + + + + } diff --git a/src/Java/gtPlusPlus/xmod/witchery/WitchUtils.java b/src/Java/gtPlusPlus/xmod/witchery/WitchUtils.java index b28ccdaa9b..9e5efb452c 100644 --- a/src/Java/gtPlusPlus/xmod/witchery/WitchUtils.java +++ b/src/Java/gtPlusPlus/xmod/witchery/WitchUtils.java @@ -67,20 +67,17 @@ public class WitchUtils { } } - public static Field getField(String aClassName, String aFieldName) { - Class c; - try { - c = Class.forName(aClassName); - if (c != null) { - Field f = ReflectionUtils.getField(c, aFieldName); - if (f != null) { - return f; - } - } - } catch (ClassNotFoundException | NoSuchFieldException e) { + public static Field getField(String aClassName, String aFieldName) { + Class c; + c = ReflectionUtils.getClass(aClassName); + if (c != null) { + Field f = ReflectionUtils.getField(c, aFieldName); + if (f != null) { + return f; + } } return null; - } + } public static boolean isEqual(final GameProfile a, final GameProfile b) { return a != null && b != null && a.getId() != null && b.getId() != null && a.getId().equals(b.getId()); diff --git a/src/Java/vswe/stevescarts/ModuleData/GppModuleData.java b/src/Java/vswe/stevescarts/ModuleData/GppModuleData.java index 0b605fb8c1..eb8a8f319f 100644 --- a/src/Java/vswe/stevescarts/ModuleData/GppModuleData.java +++ b/src/Java/vswe/stevescarts/ModuleData/GppModuleData.java @@ -41,7 +41,7 @@ public class GppModuleData extends ModuleData { validModules.put(ID_ExoticSeedAddon, true); - } catch (NoSuchFieldException | IllegalAccessException e) { + } catch (IllegalAccessException e) { e.printStackTrace(); } } -- cgit From 064c0dc0cfab1cc677dfffc4b3b56642017e412b Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Fri, 8 Mar 2019 03:14:13 +0000 Subject: + Added some AgriChem. (You can now use Raw waste as a fuel source) + Added OreDict names to vanilla items, as was done in Forge 1.8.9. + Added functions to allow other mods to add Semifluid Fuels. + Added functions to handle String data into StringUtils.java. % Renamed getItemStack -> getItemStackFromFQRN. $ Fixed handling of custom cells for fluids using '.' within their names. $ Fixed HF exploit. --- .../gregtech/api/util/SemiFluidFuelHandler.java | 48 ++- .../common/compat/COMPAT_CompactWindmills.java | 18 +- .../core/common/compat/COMPAT_ExtraUtils.java | 2 +- .../core/common/compat/COMPAT_OpenBlocks.java | 2 +- .../core/common/compat/COMPAT_Thaumcraft.java | 12 +- .../gtPlusPlus/core/handler/COMPAT_HANDLER.java | 2 +- src/Java/gtPlusPlus/core/item/ModItems.java | 8 +- .../core/item/base/BaseItemComponent.java | 24 +- .../core/item/chemistry/AgriculturalChem.java | 439 +++++++++++++++++++++ src/Java/gtPlusPlus/core/item/init/ItemsFoods.java | 12 +- .../gtPlusPlus/core/recipe/RECIPES_GREGTECH.java | 34 +- .../gtPlusPlus/core/recipe/RECIPES_General.java | 10 +- .../gtPlusPlus/core/recipe/RECIPES_Machines.java | 48 +-- src/Java/gtPlusPlus/core/recipe/common/CI.java | 20 +- .../gtPlusPlus/core/util/data/StringUtils.java | 40 ++ .../gtPlusPlus/core/util/minecraft/ItemUtils.java | 12 +- .../core/util/minecraft/RecipeUtils.java | 2 +- .../plugin/fixes/vanilla/Core_VanillaFixes.java | 38 +- .../forestry/bees/recipe/FR_Gregtech_Recipes.java | 2 +- .../interfaces/internal/IGregtech_RecipeAdder.java | 4 +- .../GregtechMetaTileEntity_MassFabricator.java | 4 +- .../xmod/gregtech/loaders/RecipeGen_Ore.java | 8 +- .../xmod/gregtech/recipes/GregtechRecipeAdder.java | 11 + .../gregtech/GregtechIndustrialMassFabricator.java | 4 +- .../textures/blocks/TileEntities/sewer_sides.png | Bin 0 -> 375 bytes .../textures/blocks/TileEntities/sewer_top.png | Bin 0 -> 375 bytes 26 files changed, 700 insertions(+), 104 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/sewer_sides.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/sewer_top.png (limited to 'src/Java/gtPlusPlus/core/handler') diff --git a/src/Java/gregtech/api/util/SemiFluidFuelHandler.java b/src/Java/gregtech/api/util/SemiFluidFuelHandler.java index f1c56c4e95..1414b3beb3 100644 --- a/src/Java/gregtech/api/util/SemiFluidFuelHandler.java +++ b/src/Java/gregtech/api/util/SemiFluidFuelHandler.java @@ -13,12 +13,58 @@ import net.minecraftforge.fluids.FluidStack; public class SemiFluidFuelHandler { + + public static boolean addSemiFluidFuel(ItemStack aFuelItem, int aFuelValue) { + FluidStack p = FluidContainerRegistry.getFluidForFilledItem(aFuelItem); + if (p != null && aFuelValue > 0) { + return addSemiFluidFuel(p, aFuelValue); + } else { + Logger.INFO("Fuel value for " + aFuelItem.getDisplayName() + " is <= 0, ignoring."); + } + return false; + } + + + public static boolean addSemiFluidFuel(FluidStack aFuel, int aFuelValue) { + FluidStack p = aFuel; + if (p != null && aFuelValue > 0) { + GT_Recipe aRecipe = + new Recipe_GT(true, + new ItemStack[] {}, + new ItemStack[] {}, + null, + new int[] {}, + new FluidStack[] { p }, + null, + 0, + 0, + aFuelValue); + if (aRecipe.mSpecialValue > 0) { + Logger.INFO("Added " + aRecipe.mFluidInputs[0].getLocalizedName() + " to the Semi-Fluid Generator fuel map. Fuel Produces "+(aRecipe.mSpecialValue*1000)+"EU per 1000L."); + sSemiFluidLiquidFuels.add(aRecipe); + return true; + } + } else { + Logger.INFO("Fuel value for " + p != null ? p.getLocalizedName() : "NULL Fluid" + " is <= 0, ignoring."); + } + return false; + } + + + + + + public static boolean generateFuels() { final FluidStack aCreosote = FluidUtils.getFluidStack("creosote", 1000); final FluidStack aHeavyFuel = FluidUtils.getFluidStack("liquid_heavy_fuel", 1000); final HashMap> aFoundFluidsFromItems = new HashMap>(); // Find Fluids From items - for (GT_Recipe g : gregtech.api.util.GT_Recipe.GT_Recipe_Map.sDenseLiquidFuels.mRecipeList) { + for (final GT_Recipe r : gregtech.api.util.GT_Recipe.GT_Recipe_Map.sDenseLiquidFuels.mRecipeList) { + + GT_Recipe g = r.copy(); + + if (g != null && g.mEnabled && g.mInputs.length > 0 && g.mInputs[0] != null) { for (ItemStack i : g.mInputs) { FluidStack f = FluidContainerRegistry.getFluidForFilledItem(i); diff --git a/src/Java/gtPlusPlus/core/common/compat/COMPAT_CompactWindmills.java b/src/Java/gtPlusPlus/core/common/compat/COMPAT_CompactWindmills.java index a5d0768e72..cd5d36b653 100644 --- a/src/Java/gtPlusPlus/core/common/compat/COMPAT_CompactWindmills.java +++ b/src/Java/gtPlusPlus/core/common/compat/COMPAT_CompactWindmills.java @@ -40,17 +40,17 @@ public class COMPAT_CompactWindmills { public static ItemStack evWindmill = ItemUtils.simpleMetaStack("CompactWindmills:blockCompactWindmill", 4, 1); //Compact Rotors - public static ItemStack rotor2 = ItemUtils.getItemStack("CompactWindmills:WOOL", 1); - public static ItemStack rotor1 = ItemUtils.getItemStack("CompactWindmills:WOOD", 1); - public static ItemStack rotor3 = ItemUtils.getItemStack("CompactWindmills:ALLOY", 1); - public static ItemStack rotor4 = ItemUtils.getItemStack("CompactWindmills:CARBON", 1); - public static ItemStack rotor5 = ItemUtils.getItemStack("CompactWindmills:IRIDIUM", 1); + public static ItemStack rotor2 = ItemUtils.getItemStackFromFQRN("CompactWindmills:WOOL", 1); + public static ItemStack rotor1 = ItemUtils.getItemStackFromFQRN("CompactWindmills:WOOD", 1); + public static ItemStack rotor3 = ItemUtils.getItemStackFromFQRN("CompactWindmills:ALLOY", 1); + public static ItemStack rotor4 = ItemUtils.getItemStackFromFQRN("CompactWindmills:CARBON", 1); + public static ItemStack rotor5 = ItemUtils.getItemStackFromFQRN("CompactWindmills:IRIDIUM", 1); //IC2 Rotors - public static ItemStack rotorIC1 = ItemUtils.getItemStack("IC2:itemwoodrotor", 1); - public static ItemStack rotorIC2 = ItemUtils.getItemStack("IC2:itemironrotor", 1); - public static ItemStack rotorIC3 = ItemUtils.getItemStack("IC2:itemsteelrotor", 1); - public static ItemStack rotorIC4 = ItemUtils.getItemStack("IC2:itemwcarbonrotor", 1); + public static ItemStack rotorIC1 = ItemUtils.getItemStackFromFQRN("IC2:itemwoodrotor", 1); + public static ItemStack rotorIC2 = ItemUtils.getItemStackFromFQRN("IC2:itemironrotor", 1); + public static ItemStack rotorIC3 = ItemUtils.getItemStackFromFQRN("IC2:itemsteelrotor", 1); + public static ItemStack rotorIC4 = ItemUtils.getItemStackFromFQRN("IC2:itemwcarbonrotor", 1); public static ItemStack rotorBlade1 = ItemUtils.simpleMetaStack("IC2:itemRecipePart", 7, 1); public static ItemStack rotorBlade2 = ItemUtils.simpleMetaStack("IC2:itemRecipePart", 8, 1); public static ItemStack rotorBlade3 = ItemUtils.simpleMetaStack("IC2:itemRecipePart", 10, 1); diff --git a/src/Java/gtPlusPlus/core/common/compat/COMPAT_ExtraUtils.java b/src/Java/gtPlusPlus/core/common/compat/COMPAT_ExtraUtils.java index 45a70997e4..4d736e1362 100644 --- a/src/Java/gtPlusPlus/core/common/compat/COMPAT_ExtraUtils.java +++ b/src/Java/gtPlusPlus/core/common/compat/COMPAT_ExtraUtils.java @@ -10,7 +10,7 @@ import gtPlusPlus.core.util.minecraft.RecipeUtils; public class COMPAT_ExtraUtils { public static void OreDict(){ - RECIPES_Tools.RECIPE_DivisionSigil = new ItemStack(ItemUtils.getItem("ExtraUtilities:divisionSigil")); + RECIPES_Tools.RECIPE_DivisionSigil = new ItemStack(ItemUtils.getItemFromFQRN("ExtraUtilities:divisionSigil")); run(); } diff --git a/src/Java/gtPlusPlus/core/common/compat/COMPAT_OpenBlocks.java b/src/Java/gtPlusPlus/core/common/compat/COMPAT_OpenBlocks.java index c7b90b780c..6381a6705e 100644 --- a/src/Java/gtPlusPlus/core/common/compat/COMPAT_OpenBlocks.java +++ b/src/Java/gtPlusPlus/core/common/compat/COMPAT_OpenBlocks.java @@ -13,7 +13,7 @@ public class COMPAT_OpenBlocks { private static final void run(){ - Item aGraveItem = ItemUtils.getItem("OpenBlocks:grave"); + Item aGraveItem = ItemUtils.getItemFromFQRN("OpenBlocks:grave"); if (aGraveItem == null) { return; } diff --git a/src/Java/gtPlusPlus/core/common/compat/COMPAT_Thaumcraft.java b/src/Java/gtPlusPlus/core/common/compat/COMPAT_Thaumcraft.java index 6247face1d..b78c10c8ce 100644 --- a/src/Java/gtPlusPlus/core/common/compat/COMPAT_Thaumcraft.java +++ b/src/Java/gtPlusPlus/core/common/compat/COMPAT_Thaumcraft.java @@ -20,9 +20,9 @@ public class COMPAT_Thaumcraft { for(int i=0; i<=6; i++){ //Utils.LOG_INFO(""+i); ItemUtils.getItemForOreDict("Thaumcraft:ItemShard", "shardAny", "TC Shard "+i, i); - GT_OreDictUnificator.registerOre("shardAny", ItemUtils.getItemStack("Thaumcraft:ItemShard:"+i, 1)); + GT_OreDictUnificator.registerOre("shardAny", ItemUtils.getItemStackFromFQRN("Thaumcraft:ItemShard:"+i, 1)); ItemUtils.getItemForOreDict("Thaumcraft:ItemShard", "gemInfusedAnything", "TC Shard "+i, i); - GT_OreDictUnificator.registerOre("gemInfusedAnything", ItemUtils.getItemStack("Thaumcraft:ItemShard:"+i, 1)); + GT_OreDictUnificator.registerOre("gemInfusedAnything", ItemUtils.getItemStackFromFQRN("Thaumcraft:ItemShard:"+i, 1)); //System.out.println("TC Shard registration count is: "+i); } @@ -30,15 +30,15 @@ public class COMPAT_Thaumcraft { for(int i=0; i<=6; i++){ //Utils.LOG_INFO(""+i); ItemUtils.getItemForOreDict("ForbiddenMagic:NetherShard", "shardAny", "FM Shard "+i, i); - GT_OreDictUnificator.registerOre("shardAny", ItemUtils.getItemStack("ForbiddenMagic:NetherShard:"+i, 1)); + GT_OreDictUnificator.registerOre("shardAny", ItemUtils.getItemStackFromFQRN("ForbiddenMagic:NetherShard:"+i, 1)); ItemUtils.getItemForOreDict("ForbiddenMagic:NetherShard", "gemInfusedAnything", "FM Shard "+i, i); - GT_OreDictUnificator.registerOre("gemInfusedAnything", ItemUtils.getItemStack("ForbiddenMagic:NetherShard:"+i, 1)); + GT_OreDictUnificator.registerOre("gemInfusedAnything", ItemUtils.getItemStackFromFQRN("ForbiddenMagic:NetherShard:"+i, 1)); //System.out.println("TC Shard registration count is: "+i); } ItemUtils.getItemForOreDict("ForbiddenMagic:GluttonyShard", "shardAny", "FM Gluttony Shard", 0); - GT_OreDictUnificator.registerOre("shardAny", ItemUtils.getItemStack("ForbiddenMagic:GluttonyShard", 1)); + GT_OreDictUnificator.registerOre("shardAny", ItemUtils.getItemStackFromFQRN("ForbiddenMagic:GluttonyShard", 1)); ItemUtils.getItemForOreDict("ForbiddenMagic:GluttonyShard", "gemInfusedAnything", "FM Gluttony Shard", 0); - GT_OreDictUnificator.registerOre("gemInfusedAnything", ItemUtils.getItemStack("ForbiddenMagic:GluttonyShard", 1)); + GT_OreDictUnificator.registerOre("gemInfusedAnything", ItemUtils.getItemStackFromFQRN("ForbiddenMagic:GluttonyShard", 1)); } } diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java index f6735de8e4..1af7c05d64 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java @@ -39,7 +39,7 @@ public class COMPAT_HANDLER { GT_OreDictUnificator.registerOre("craftingToolSandHammer", new ItemStack(ModItems.itemSandstoneHammer)); for(int i=1; i<=10; i++){ - GT_OreDictUnificator.registerOre("bufferCore_"+GT_Values.VN[i-1], new ItemStack(ItemUtils.getItem("miscutils:item.itemBufferCore"+i))); + GT_OreDictUnificator.registerOre("bufferCore_"+GT_Values.VN[i-1], new ItemStack(ItemUtils.getItemFromFQRN("miscutils:item.itemBufferCore"+i))); } } diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index 8057f6bbe1..2a7bae629e 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -32,6 +32,7 @@ import gtPlusPlus.core.item.base.plates.BaseItemPlateDouble; import gtPlusPlus.core.item.bauble.BatteryPackBaseBauble; import gtPlusPlus.core.item.bauble.HealthBoostBauble; import gtPlusPlus.core.item.bauble.ModularBauble; +import gtPlusPlus.core.item.chemistry.AgriculturalChem; import gtPlusPlus.core.item.chemistry.CoalTar; import gtPlusPlus.core.item.chemistry.IonParticles; import gtPlusPlus.core.item.chemistry.NuclearChem; @@ -366,7 +367,7 @@ public final class ModItems { //Some Simple forms of materials itemStickyRubber = new Item().setUnlocalizedName("itemStickyRubber").setCreativeTab(tabMachines).setTextureName(CORE.MODID + ":itemStickyRubber"); GameRegistry.registerItem(itemStickyRubber, "itemStickyRubber"); - GT_OreDictUnificator.registerOre("ingotRubber", ItemUtils.getItemStack(CORE.MODID+":itemStickyRubber", 1)); + GT_OreDictUnificator.registerOre("ingotRubber", ItemUtils.getItemStackFromFQRN(CORE.MODID+":itemStickyRubber", 1)); itemCoalCoke = new BaseItemBurnable("itemCoalCoke", "Coking Coal", tabMisc, 64, 0, "Used for metallurgy.", "fuelCoke", 3200, 0).setTextureName(CORE.MODID + ":itemCoalCoke"); @@ -884,7 +885,10 @@ public final class ModItems { //Nuclear Processing NuclearChem.run(); - + + //Farm Animal Fun + AgriculturalChem.run(); + //Only used for debugging. /*if (CORE.DEVENV) { new ConnectedBlockFinder(); diff --git a/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java b/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java index 522b7e900e..fd69c97ff5 100644 --- a/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java +++ b/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java @@ -18,6 +18,7 @@ import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.material.state.MaterialState; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.data.StringUtils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.EntityUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; @@ -77,18 +78,33 @@ public class BaseItemComponent extends Item{ //For Cell Generation public BaseItemComponent(final String unlocalName, final String localName, final short[] RGBA) { + + // Handles .'s from fluid internal names. + String aFormattedNameForFluids; + if (unlocalName.contains(".")) { + if (StringUtils.characterCount(unlocalName, '.') > 1) { + aFormattedNameForFluids = StringUtils.splitAndUppercase(unlocalName, "."); + } + else { + aFormattedNameForFluids = unlocalName.replace(".", ""); + } + } + else { + aFormattedNameForFluids = unlocalName; + } + this.componentMaterial = null; - this.unlocalName = "itemCell"+unlocalName; + this.unlocalName = "itemCell"+aFormattedNameForFluids; this.materialName = localName; this.componentType = ComponentTypes.CELL; this.setCreativeTab(AddToCreativeTab.tabMisc); - this.setUnlocalizedName(unlocalName); + this.setUnlocalizedName(aFormattedNameForFluids); this.setMaxStackSize(64); this.componentColour = MathUtils.getRgbAsHex(RGBA); this.extraData = RGBA; this.setTextureName(CORE.MODID + ":" + "item"+ComponentTypes.CELL.COMPONENT_NAME); - GameRegistry.registerItem(this, unlocalName); - GT_OreDictUnificator.registerOre(ComponentTypes.CELL.getOreDictName()+unlocalName, ItemUtils.getSimpleStack(this)); + GameRegistry.registerItem(this, aFormattedNameForFluids); + GT_OreDictUnificator.registerOre(ComponentTypes.CELL.getOreDictName()+aFormattedNameForFluids, ItemUtils.getSimpleStack(this)); registerComponent(); } diff --git a/src/Java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java b/src/Java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java new file mode 100644 index 0000000000..bd8630da69 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java @@ -0,0 +1,439 @@ +package gtPlusPlus.core.item.chemistry; + +import java.util.ArrayList; + +import forestry.plugins.PluginCore; +import gregtech.api.enums.GT_Values; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.material.nuclear.FLUORIDES; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; + +public class AgriculturalChem { + + + private static boolean aBOP; + private static boolean aTiCon; + + private static AutoMap mBloodFluids = new AutoMap(); + + + /** + * Fluids + */ + + //Poop Juice + public static Fluid PoopJuice; + //Manure Slurry + public static Fluid ManureSlurry; + //Fertile Manure Slurry + public static Fluid FertileManureSlurry; + //Blood + public static Fluid CustomBlood; + + + /** + * Items + */ + + //Manure Byproducts + public static Item dustManureByproducts; + //Organic Fertilizer + public static Item dustOrganicFertilizer; + //Dirt + public static Item dustDirt; + + + + + // Poop Juice + // vv - Centrifuge + // Manure Slurry && Manure Byproducts -> (Elements) Centrifuge to several tiny piles + // vv - Chem Reactor - Add Peat, Meat + // Organic Fertilizer + // vv - Dehydrate + // Fertilizer + + // Poop Juice + // vv - Mixer - Add Blood, Bone, Meat (1000L Poo, 200L Blood, x2 Bone, x3 Meat) + // Fertile Manure Slurry + // vv - Chem Reactor - Add Peat x1.5 + // Organic Fertilizer x3 + // vv - Dehydrate + // Fertilizer + + + + + + + + + + + + + + + + public static void run(){ + + aBOP = LoadedMods.BiomesOPlenty; + aTiCon = LoadedMods.TiCon; + + Logger.INFO("Adding Agrochemical content"); + + FluidStack aBlood; + if (aBOP) { + aBlood = FluidUtils.getFluidStack("hell_blood", 100); + if (aBlood != null) { + Logger.INFO("Found Biome's o Plenty, enabled Blood support."); + CustomBlood = aBlood.getFluid(); + mBloodFluids.put(aBlood); + } + } + + if (aTiCon) { + aBlood = FluidUtils.getFluidStack("hell_blood", 100); + if (aBlood != null) { + Logger.INFO("Found Tinker's Construct, enabled Blood support."); + CustomBlood = aBlood.getFluid(); + mBloodFluids.put(FluidUtils.getFluidStack("blood", 100)); + } + } + + // Handle Blood Internally, Create if required. + if (mBloodFluids.isEmpty() || CustomBlood == null) { + Logger.INFO("Did not find any existing Blood fluids. Trying to wildcard search the fluid registry, then generate our own if that fails."); + FluidStack aTempBlood = FluidUtils.getWildcardFluidStack("blood", 100); + if (aTempBlood != null) { + CustomBlood = aTempBlood.getFluid(); + } + else { + aTempBlood = FluidUtils.getWildcardFluidStack("hell_blood", 100); + if (aTempBlood == null) { + CustomBlood = FluidUtils.generateFluidNoPrefix("blood", "Blood", 32+175, new short[]{175, 25, 25, 100}, true); + } + else { + CustomBlood = aTempBlood.getFluid(); + } + } + Logger.INFO("Using "+CustomBlood.getName()); + mBloodFluids.put(FluidUtils.getFluidStack(CustomBlood, 100)); + } + + + + //Sewage + PoopJuice = FluidUtils.generateFluidNonMolten("raw.waste", "Raw Animal Waste", 32+175, new short[]{100, 70, 30, 100}, null, null, 0, true); + + //Sewage + ManureSlurry = FluidUtils.generateFluidNonMolten("manure.slurry", "Manure Slurry", 39+175, new short[]{75, 45, 15, 100}, null, null, 0, true); + + //Sewage + FertileManureSlurry = FluidUtils.generateFluidNonMolten("fertile.manure.slurry", "Fertile Manure Slurry", 45+175, new short[]{65, 50, 15, 100}, null, null, 0, true); + + + + //Ca5(PO4)3(OH) + + + // Nitrogen, Ammonium Nitrate, Phosphates, Calcium, Copper, Carbon + dustManureByproducts = ItemUtils.generateSpecialUseDusts("ManureByproducts", "Manure Byproduct", "(N2H4O3)N2P2Ca3CuC8", Utils.rgbtoHexValue(110, 75, 25))[0]; + + // Basically Guano + dustOrganicFertilizer = ItemUtils.generateSpecialUseDusts("OrganicFertilizer", "Organic Fertilizer", "Ca5(PO4)3(OH)", Utils.rgbtoHexValue(240, 240, 240))[0]; + + // Dirt Dust :) + dustDirt = ItemUtils.generateSpecialUseDusts("Dirt", "Dried Earth", Utils.rgbtoHexValue(65, 50, 15))[0]; + + + + + + + + + + createRecipes(); + } + + + + + + + private static AutoMap mMeats = new AutoMap(); + private static AutoMap mFish = new AutoMap(); + private static AutoMap mFruits = new AutoMap(); + private static AutoMap mVege = new AutoMap(); + private static AutoMap mNuts = new AutoMap(); + private static AutoMap mSeeds = new AutoMap(); + private static AutoMap mPeat = new AutoMap(); + private static AutoMap mBones = new AutoMap(); + private static AutoMap mBoneMeal = new AutoMap(); + + private static AutoMap mList_Master_Meats = new AutoMap(); + private static AutoMap mList_Master_FruitVege = new AutoMap(); + private static AutoMap mList_Master_Bones = new AutoMap(); + private static AutoMap mList_Master_Seeds = new AutoMap(); + + private static void processAllOreDict() { + processOreDict("listAllmeatraw", mMeats); + processOreDict("listAllfishraw", mFish); + processOreDict("listAllfruit", mFruits); + processOreDict("listAllVeggie", mVege); + processOreDict("listAllnut", mNuts); + processOreDict("listAllSeed", mSeeds); + processOreDict("brickPeat", mPeat); + processOreDict("bone", mBones); + processOreDict("dustBone", mBoneMeal); + //Just make a mega list, makes life easier. + if (!mMeats.isEmpty()) { + for (ItemStack g : mMeats) { + mList_Master_Meats.put(g); + } + } + if (!mFish.isEmpty()) { + for (ItemStack g : mFish) { + mList_Master_Meats.put(g); + } + } + if (!mFruits.isEmpty()) { + for (ItemStack g : mFruits) { + mList_Master_FruitVege.put(g); + } + } + if (!mVege.isEmpty()) { + for (ItemStack g : mVege) { + mList_Master_FruitVege.put(g); + } + } + if (!mNuts.isEmpty()) { + for (ItemStack g : mNuts) { + mList_Master_FruitVege.put(g); + } + } + if (!mSeeds.isEmpty()) { + for (ItemStack g : mSeeds) { + mList_Master_Seeds.put(g); + } + } + if (!mBoneMeal.isEmpty()) { + for (ItemStack g : mBoneMeal) { + mList_Master_Bones.put(g); + } + } + if (!mBones.isEmpty()) { + for (ItemStack g : mBones) { + mList_Master_Bones.put(g); + } + } + } + + private static void processOreDict(String aOreName, AutoMap aMap) { + ArrayList aTemp = OreDictionary.getOres(aOreName); + if (!aTemp.isEmpty()) { + for (ItemStack stack : aTemp) { + aMap.put(stack); + } + } + } + + + private static void createRecipes() { + + if (mBloodFluids.isEmpty()) { + Logger.INFO("Could not find, nor create Blood fluid. Unable to add recipes."); + return; + } + + // Organise OreDict + processAllOreDict(); + + // Slurry Production + addBasicSlurryRecipes(); + addAdvancedSlurryRecipes(); + + // Organic Fert. Production + addBasicOrganiseFertRecipes(); + addAdvancedOrganiseFertRecipes(); + + addMiscRecipes(); + } + + + private static void addBasicSlurryRecipes() { + + ItemStack aManureByprod = ItemUtils.getSimpleStack(dustManureByproducts, 1); + ItemStack aDirtDust = ItemUtils.getSimpleStack(dustDirt, 1); + + //Poop Juice to Basic Slurry + GT_Values.RA.addCentrifugeRecipe( + CI.getNumberedCircuit(10), + null, + FluidUtils.getFluidStack(PoopJuice, 1000), //In Fluid + FluidUtils.getFluidStack(ManureSlurry, 250), //Out Fluid + aDirtDust, + aDirtDust, + aManureByprod, + aManureByprod, + aManureByprod, + aManureByprod, + new int[]{2000, 2000, 500, 500, 250, 250}, //Chances + 10*20, //Time + 30); //EU + + // More Efficient way to get byproducts, less Slurry + GT_Values.RA.addCentrifugeRecipe( + CI.getNumberedCircuit(20), + null, + FluidUtils.getFluidStack(PoopJuice, 1000), //In Fluid + FluidUtils.getFluidStack(ManureSlurry, 50), //Out Fluid + aDirtDust, + aDirtDust, + aManureByprod, + aManureByprod, + aManureByprod, + aManureByprod, + new int[]{4000, 3000, 1250, 1250, 675, 675}, //Chances + 20*20, //Time + 60); //EU + + } + + private static void addAdvancedSlurryRecipes() { + + ItemStack aCircuit = CI.getNumberedCircuit(10); + ItemStack aBone; + ItemStack aMeat; + ItemStack aEmptyCells = CI.emptyCells(2); + ItemStack aInputCells = ItemUtils.getItemStackOfAmountFromOreDict("cellRawWaste", 2); + FluidStack aOutput = FluidUtils.getFluidStack(FertileManureSlurry, 1000); + + for (FluidStack aBloodStack : mBloodFluids) { + for (ItemStack aBoneStack : mList_Master_Bones) { + aBone = ItemUtils.getSimpleStack(aBoneStack, 2); + for (ItemStack aMeatStack : mList_Master_Meats) { + aMeat = ItemUtils.getSimpleStack(aMeatStack, 5); + // Poop Juice to Fertile Slurry + GT_Values.RA.addMixerRecipe(aCircuit, aBone, aMeat, aInputCells, + aBloodStack, // Input Fluid + aOutput, // Output Fluid + aEmptyCells, // Output Item + 20 * 8, // Time? + 60 // Eu? + ); + } + } + } + } + + private static void addBasicOrganiseFertRecipes() { + FluidStack aInputFluid = FluidUtils.getFluidStack(ManureSlurry, 1000); + ItemStack aOutputDust = ItemUtils.getSimpleStack(dustOrganicFertilizer, 3); + ItemStack aPeat; + ItemStack aMeat; + for (ItemStack aPeatStack : mPeat) { + aPeat = ItemUtils.getSimpleStack(aPeatStack, 3); + for (ItemStack aMeatStack : mList_Master_Meats) { + aMeat = ItemUtils.getSimpleStack(aMeatStack, 5); + CORE.RA.addChemicalRecipe(aPeat, aMeat, aInputFluid, null, aOutputDust, 20 * 20, 120); + } + + aPeat = ItemUtils.getSimpleStack(aPeatStack, 2); + for (ItemStack aMeatStack : mList_Master_FruitVege) { + aMeat = ItemUtils.getSimpleStack(aMeatStack, 9); + CORE.RA.addChemicalRecipe(aPeat, aMeat, aInputFluid, null, aOutputDust, 10 * 20, 120); + } + } + } + + private static void addAdvancedOrganiseFertRecipes() { + FluidStack aInputFluid = FluidUtils.getFluidStack(FertileManureSlurry, 1000); + ItemStack aOutputDust = ItemUtils.getSimpleStack(dustOrganicFertilizer, 7); + ItemStack aPeat; + ItemStack aMeat; + for (ItemStack aPeatStack : mPeat) { + aPeat = ItemUtils.getSimpleStack(aPeatStack, 5); + for (ItemStack aMeatStack : mList_Master_Meats) { + aMeat = ItemUtils.getSimpleStack(aMeatStack, 7); + CORE.RA.addChemicalRecipe(aPeat, aMeat, aInputFluid, null, aOutputDust, 10 * 20, 140); + } + aPeat = ItemUtils.getSimpleStack(aPeatStack, 3); + for (ItemStack aMeatStack : mList_Master_FruitVege) { + aMeat = ItemUtils.getSimpleStack(aMeatStack, 12); + CORE.RA.addChemicalRecipe(aPeat, aMeat, aInputFluid, null, aOutputDust, 5 * 20, 140); + } + } + } + + private static void addMiscRecipes() { + + ItemStack aDustOrganicFert = ItemUtils.getSimpleStack(dustOrganicFertilizer, 1); + ItemStack aManureByprod = ItemUtils.getSimpleStack(dustManureByproducts, 1); + + + //Dehydrate Organise Fert to Normal Fert. + + /** + * Forestry Support + */ + if (LoadedMods.Forestry) { + + Item aForestryFert = PluginCore.items.fertilizerCompound; + + CORE.RA.addDehydratorRecipe( + new ItemStack[] { + CI.getNumberedCircuit(11), + ItemUtils.getSimpleStack(aDustOrganicFert, 4) + }, + null, + null, + new ItemStack[] {ItemUtils.getSimpleStack(aForestryFert, 3), aManureByprod, aManureByprod}, + new int[] {10000, 2000, 2000}, + 20 * 20, + 240); + } + + /** + * IC2 Support + */ + if (LoadedMods.IndustrialCraft2) { + CORE.RA.addDehydratorRecipe( + new ItemStack[] { + CI.getNumberedCircuit(12), + ItemUtils.getSimpleStack(aDustOrganicFert, 4) + }, + null, + null, + new ItemStack[] {ItemUtils.getItemStackFromFQRN("IC2:itemFertilizer", 3), aManureByprod, aManureByprod}, + new int[] {10000, 2000, 2000}, + 20 * 20, + 240); + } + + + // Dirt Production + CORE.RA.addCompressorRecipe(ItemUtils.getSimpleStack(dustDirt, 9), ItemUtils.getSimpleStack(Blocks.dirt), 20 * 2, 8); + + // Add Fuel Usages + CORE.RA.addSemifluidFuel(FluidUtils.getFluidStack(PoopJuice, 1000), 12000); + CORE.RA.addSemifluidFuel(FluidUtils.getFluidStack(ManureSlurry, 1000), 24000); + CORE.RA.addSemifluidFuel(FluidUtils.getFluidStack(FertileManureSlurry, 1000), 32000); + + + } +} diff --git a/src/Java/gtPlusPlus/core/item/init/ItemsFoods.java b/src/Java/gtPlusPlus/core/item/init/ItemsFoods.java index 77a06edac2..94ebb3ffcb 100644 --- a/src/Java/gtPlusPlus/core/item/init/ItemsFoods.java +++ b/src/Java/gtPlusPlus/core/item/init/ItemsFoods.java @@ -21,24 +21,24 @@ public class ItemsFoods { //Raisin Bread ModItems.itemIngotRaisinBread = new BaseItemFood("itemIngotRaisinBread", "Raisin Bread", 3, 1.5f, false, new PotionEffect(Potion.weakness.id, 40, 1)).setAlwaysEdible(); - GT_OreDictUnificator.registerOre("foodRaisinBread", ItemUtils.getItemStack(CORE.MODID+":itemIngotRaisinBread", 1)); + GT_OreDictUnificator.registerOre("foodRaisinBread", ItemUtils.getItemStackFromFQRN(CORE.MODID+":itemIngotRaisinBread", 1)); //Hot Raisin Bread ModItems.itemHotIngotRaisinBread = new BaseItemHotFood("itemHotIngotRaisinBread", 1, 0.5f, "Raisin Bread", 120, ModItems.itemIngotRaisinBread); - GT_OreDictUnificator.registerOre("foodHotRaisinBread", ItemUtils.getItemStack(CORE.MODID+":itemHotIngotRaisinBread", 1)); + GT_OreDictUnificator.registerOre("foodHotRaisinBread", ItemUtils.getItemStackFromFQRN(CORE.MODID+":itemHotIngotRaisinBread", 1)); //Raisin Bread ModItems.itemFoodRaisinToast = new BaseItemFood("itemFoodRaisinToast", "Raisin Toast", 1, 0.5f, false).setAlwaysEdible(); - GT_OreDictUnificator.registerOre("foodRaisinToast", ItemUtils.getItemStack(CORE.MODID+":itemFoodRaisinToast", 1)); + GT_OreDictUnificator.registerOre("foodRaisinToast", ItemUtils.getItemStackFromFQRN(CORE.MODID+":itemFoodRaisinToast", 1)); //Hot Raisin Bread ModItems.itemHotFoodRaisinToast = new BaseItemHotFood("itemHotFoodRaisinToast", 1, 0.5f, "Raisin Toast", 20, ModItems.itemFoodRaisinToast); - GT_OreDictUnificator.registerOre("foodHotRaisinToast", ItemUtils.getItemStack(CORE.MODID+":itemHotFoodRaisinToast", 1)); + GT_OreDictUnificator.registerOre("foodHotRaisinToast", ItemUtils.getItemStackFromFQRN(CORE.MODID+":itemHotFoodRaisinToast", 1)); //Raisin Bread ModItems.itemFoodCurriedSausages = new BaseItemFood("itemFoodCurriedSausages", "Curried Sausages", 5, 2f, false); - GT_OreDictUnificator.registerOre("foodCurriedSausages", ItemUtils.getItemStack(CORE.MODID+":itemFoodCurriedSausages", 1)); + GT_OreDictUnificator.registerOre("foodCurriedSausages", ItemUtils.getItemStackFromFQRN(CORE.MODID+":itemFoodCurriedSausages", 1)); //Hot Raisin Bread ModItems.itemHotFoodCurriedSausages = new BaseItemHotFood("itemHotFoodCurriedSausages", 1, 0.5f, "Curried Sausages", 240, ModItems.itemFoodCurriedSausages); - GT_OreDictUnificator.registerOre("foodHotCurriedSausages", ItemUtils.getItemStack(CORE.MODID+":itemHotFoodCurriedSausages", 1)); + GT_OreDictUnificator.registerOre("foodHotCurriedSausages", ItemUtils.getItemStackFromFQRN(CORE.MODID+":itemHotFoodCurriedSausages", 1)); } diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index 37c7fef1db..7164bc20f7 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -326,7 +326,7 @@ public class RECIPES_GREGTECH { CI.getAlternativeTieredFluid(7, 144 * 18 * (GTNH ? 16 : 8)), }, - ItemUtils.getItemStack("miscutils:personalHealingDevice", 1), + ItemUtils.getItemStackFromFQRN("miscutils:personalHealingDevice", 1), 20 * 60 * 30 * (GTNH ? 2 : 1), (int) GT_Values.V[7]); @@ -335,7 +335,7 @@ public class RECIPES_GREGTECH { //Charge Pack LuV-UV ItemStack[] aChargeResearch = new ItemStack[] { - ItemUtils.getItemStack("miscutils:item.itemBufferCore7", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore7", 1), ItemUtils.getSimpleStack(ModItems.itemChargePack1, 1), ItemUtils.getSimpleStack(ModItems.itemChargePack2, 1), ItemUtils.getSimpleStack(ModItems.itemChargePack3, 1), @@ -349,10 +349,10 @@ public class RECIPES_GREGTECH { }; ItemStack[] aBufferCoreInputs = new ItemStack[] { - ItemUtils.getItemStack("miscutils:item.itemBufferCore7", GTNH ? 8 : 4), - ItemUtils.getItemStack("miscutils:item.itemBufferCore8", GTNH ? 8 : 4), - ItemUtils.getItemStack("miscutils:item.itemBufferCore9", GTNH ? 8 : 4), - ItemUtils.getItemStack("miscutils:item.itemBufferCore10", GTNH ? 8 : 4), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore7", GTNH ? 8 : 4), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore8", GTNH ? 8 : 4), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore9", GTNH ? 8 : 4), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore10", GTNH ? 8 : 4), }; int aCurrSlot = 0; @@ -696,21 +696,29 @@ public class RECIPES_GREGTECH { GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(ModItems.itemSulfuricPotion), ItemUtils.getSimpleStack(Items.glass_bottle), null, FluidUtils.getFluidStack("sulfuricacid", 250)); - // Hydrofluoric Acid - GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(Items.glass_bottle), - ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), - FluidUtils.getFluidStack("hydrofluoricacid", 250), null); - GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), - ItemUtils.getSimpleStack(Items.glass_bottle), null, FluidUtils.getFluidStack("hydrofluoricacid", 250)); + + // Hydrofluoric Acid + boolean addedGtExtraction = false; + // Try use Internal GT Fluid first if (Utils.getGregtechVersionAsInt() >= 50929) { // Hydrofluoric Acid GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(Items.glass_bottle), ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), FluidUtils.getFluidStack("hydrofluoricacid_gt5u", 250), null); - GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), + addedGtExtraction = GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), ItemUtils.getSimpleStack(Items.glass_bottle), null, FluidUtils.getFluidStack("hydrofluoricacid_gt5u", 250)); } + //Add a Fill recipe for GT++ Acid + GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(Items.glass_bottle), + ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), + FluidUtils.getFluidStack("hydrofluoricacid", 125), null); + //Add an empty recipe, but only if we didn't for the standard GT HF. Prevents Fluid transformation exploits. + if (!addedGtExtraction) + GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), + ItemUtils.getSimpleStack(Items.glass_bottle), null, FluidUtils.getFluidStack("hydrofluoricacid", 125)); + + } private static void cokeOvenRecipes() { diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java index 54380306cc..1c0f3f8a28 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java @@ -50,7 +50,7 @@ public class RECIPES_General { RECIPE_Obsidian = ItemUtils.getSimpleStack(Blocks.obsidian); RECIPE_CraftingTable = ItemUtils.getSimpleStack(Blocks.crafting_table); RECIPE_HydrogenDust = ItemUtils.getSimpleStack(ModItems.itemHydrogenBlob); - RECIPE_BasicCasingIC2 = ItemUtils.getItemStack("IC2:blockMachine", 1); + RECIPE_BasicCasingIC2 = ItemUtils.getItemStackFromFQRN("IC2:blockMachine", 1); OUTPUT_Workbench_Bronze = ItemUtils.getSimpleStack(ModBlocks.blockWorkbench); OUTPUT_Blueprint = ItemUtils.getSimpleStack(ModItems.itemBlueprintBase); run(); @@ -127,9 +127,9 @@ public class RECIPES_General { //Iron bars final ItemStack ironBars; if (CORE.GTNH) { - ironBars = ItemUtils.getItemStack("dreamcraft:item.SteelBars", 1); + ironBars = ItemUtils.getItemStackFromFQRN("dreamcraft:item.SteelBars", 1); } else { - ironBars = ItemUtils.getItemStack("minecraft:iron_bars", 1); + ironBars = ItemUtils.getItemStackFromFQRN("minecraft:iron_bars", 1); } //Fish Trap @@ -154,7 +154,7 @@ public class RECIPES_General { null, CI.craftingToolWrench, null, ironRecipe, ironRecipe, ironRecipe, ironRecipe, ironRecipe, ironRecipe, - ItemUtils.getItemStack("minecraft:iron_bars", 8))) { + ItemUtils.getItemStackFromFQRN("minecraft:iron_bars", 8))) { Logger.INFO("Re-added old GT recipe for Iron Bars."); } } @@ -287,7 +287,7 @@ public class RECIPES_General { ItemUtils.getSimpleStack(ModBlocks.blockNet, 8), ItemUtils.getSimpleStack(Blocks.vine, 8), ALLOY.TUMBAGA.getRing(1), }, FluidUtils.getWater(1000), // Fluid - ItemUtils.getItemStack("miscutils:SlowBuildingRing", 1), // Output + ItemUtils.getItemStackFromFQRN("miscutils:SlowBuildingRing", 1), // Output 20 * 30, // Dur 16); // Eu diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java index a7c0655f89..91ceb30911 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -97,16 +97,16 @@ public class RECIPES_Machines { //Buffer Cores - public static ItemStack RECIPE_BufferCore_ULV = ItemUtils.getItemStack("miscutils:item.itemBufferCore1", 1); - public static ItemStack RECIPE_BufferCore_LV = ItemUtils.getItemStack("miscutils:item.itemBufferCore2", 1); - public static ItemStack RECIPE_BufferCore_MV = ItemUtils.getItemStack("miscutils:item.itemBufferCore3", 1); - public static ItemStack RECIPE_BufferCore_HV = ItemUtils.getItemStack("miscutils:item.itemBufferCore4", 1); - public static ItemStack RECIPE_BufferCore_EV = ItemUtils.getItemStack("miscutils:item.itemBufferCore5", 1); - public static ItemStack RECIPE_BufferCore_IV = ItemUtils.getItemStack("miscutils:item.itemBufferCore6", 1); - public static ItemStack RECIPE_BufferCore_LuV = ItemUtils.getItemStack("miscutils:item.itemBufferCore7", 1); - public static ItemStack RECIPE_BufferCore_ZPM = ItemUtils.getItemStack("miscutils:item.itemBufferCore8", 1); - public static ItemStack RECIPE_BufferCore_UV = ItemUtils.getItemStack("miscutils:item.itemBufferCore9", 1); - public static ItemStack RECIPE_BufferCore_MAX = ItemUtils.getItemStack("miscutils:item.itemBufferCore10", 1); + public static ItemStack RECIPE_BufferCore_ULV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore1", 1); + public static ItemStack RECIPE_BufferCore_LV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore2", 1); + public static ItemStack RECIPE_BufferCore_MV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore3", 1); + public static ItemStack RECIPE_BufferCore_HV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore4", 1); + public static ItemStack RECIPE_BufferCore_EV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore5", 1); + public static ItemStack RECIPE_BufferCore_IV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore6", 1); + public static ItemStack RECIPE_BufferCore_LuV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore7", 1); + public static ItemStack RECIPE_BufferCore_ZPM = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore8", 1); + public static ItemStack RECIPE_BufferCore_UV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore9", 1); + public static ItemStack RECIPE_BufferCore_MAX = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore10", 1); //Wire @@ -181,7 +181,7 @@ public class RECIPES_Machines { //Lava Boiler public static ItemStack boiler_Coal; - public static ItemStack blockBricks = ItemUtils.getItemStack("minecraft:brick_block", 1); + public static ItemStack blockBricks = ItemUtils.getItemStackFromFQRN("minecraft:brick_block", 1); //Batteries public static String batteryBasic = "batteryBasic"; @@ -990,7 +990,7 @@ public class RECIPES_Machines { "plateDoubleZeron100", CI.craftingToolHammer_Hard, "plateDoubleZeron100", RECIPE_LFTRInnerCasing); - ItemStack IC2HeatPlate = ItemUtils.getItemStack("IC2:reactorPlatingHeat", 1); + ItemStack IC2HeatPlate = ItemUtils.getItemStackFromFQRN("IC2:reactorPlatingHeat", 1); RecipeUtils.addShapedGregtechRecipe( "plateDoubleHastelloyN", IC2HeatPlate, "plateDoubleHastelloyN", IC2HeatPlate, "frameGtHastelloyC276", IC2HeatPlate, @@ -1605,7 +1605,7 @@ public class RECIPES_Machines { Item aBaseCore = ModItems.itemControlCore; ItemStack[] aInputPrevTier = new ItemStack[] { - GTNH ? ItemUtils.getItemStack("miscutils:item.itemBufferCore3", 1) : ItemUtils.getItemStack("miscutils:item.itemBufferCore2", 1), + GTNH ? ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore3", 1) : ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore2", 1), ItemUtils.simpleMetaStack(aBaseCore, 0, 1), ItemUtils.simpleMetaStack(aBaseCore, 1, 1), ItemUtils.simpleMetaStack(aBaseCore, 2, 1), @@ -1636,7 +1636,7 @@ public class RECIPES_Machines { aOutput[1], aMat_A[1].getGear(GTNH ? 4 : 2), aMat_B[2].getPlateDouble(GTNH ? 16 : 8), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+(GTNH ? "2" : "1"), GTNH ? 4 : 2), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+(GTNH ? "2" : "1"), GTNH ? 4 : 2), ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(GTNH ? 3 : 2), GTNH ? 10 : 5) }, aMat_B[3].getFluid(144 * 8), //Input Fluid @@ -1806,16 +1806,16 @@ public class RECIPES_Machines { ItemStack[] aOutput = new ItemStack[] { - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"1", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"2", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"3", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"4", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"5", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"6", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"7", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"8", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"9", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"10", 1) + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"1", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"2", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"3", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"4", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"5", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"6", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"7", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"8", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"9", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"10", 1) }; int aCostMultiplier = GTNH ? 4 : 1; diff --git a/src/Java/gtPlusPlus/core/recipe/common/CI.java b/src/Java/gtPlusPlus/core/recipe/common/CI.java index 28fa12ac1a..42cb075400 100644 --- a/src/Java/gtPlusPlus/core/recipe/common/CI.java +++ b/src/Java/gtPlusPlus/core/recipe/common/CI.java @@ -631,16 +631,16 @@ public class CI { public static ItemStack getEnergyCore(int aTier, int aAmount) { ItemStack[] aOutput = new ItemStack[] { - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"1", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"2", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"3", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"4", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"5", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"6", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"7", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"8", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"9", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"10", 1) + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"1", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"2", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"3", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"4", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"5", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"6", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"7", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"8", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"9", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"10", 1) }; return ItemUtils.getSimpleStack(aOutput[MathUtils.balance(aTier, 0, 9)], aAmount); } diff --git a/src/Java/gtPlusPlus/core/util/data/StringUtils.java b/src/Java/gtPlusPlus/core/util/data/StringUtils.java index b64266b5d4..2821a0c1c9 100644 --- a/src/Java/gtPlusPlus/core/util/data/StringUtils.java +++ b/src/Java/gtPlusPlus/core/util/data/StringUtils.java @@ -1,5 +1,7 @@ package gtPlusPlus.core.util.data; +import gtPlusPlus.api.objects.data.AutoMap; + public class StringUtils { public static String superscript(String str) { @@ -131,4 +133,42 @@ public class StringUtils { return aData; } } + + public static String splitAndUppercase(String aInput, String aDelim) { + String[] aSplit = aInput.split(aDelim); + if (aSplit == null || aSplit.length == 0) { + return aInput; + } + else { + AutoMap aTemp = new AutoMap(); + for (String s : aSplit) { + aTemp.put(firstLetterCaps(s)); + } + String aReturn = ""; + for (String s : aTemp) { + aReturn += s; + } + return aReturn; + } + } + + public static int characterCount(String aString, char aChar) { + return characterCount(aString, ""+aChar); + } + + public static int characterCount(String aString, String aChar) { + int aLength = aString.length(); + int aFound = 0; + if (aLength == 0 || !aString.contains(aChar)) { + return 0; + } + else { + for (int index = 0; index < aLength; index++) { + if (aString.substring(index, index+1).equals(aChar)) { + aFound++; + } + } + return aFound; + } + } } diff --git a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java index 2522ba56da..50778e1285 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java @@ -124,7 +124,7 @@ public class ItemUtils { final int meta) { try { Item em = null; - final Item em1 = getItem(FQRN); + final Item em1 = getItemFromFQRN(FQRN); // Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); if (em1 != null) { em = em1; @@ -158,7 +158,7 @@ public class ItemUtils { if (MOD) { try { Item em = null; - final Item em1 = getItem(FQRN); + final Item em1 = getItemFromFQRN(FQRN); // Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); if (em1 != null) { if (null == em) { @@ -181,7 +181,7 @@ public class ItemUtils { public static ItemStack simpleMetaStack(final String FQRN, final int meta, final int itemstackSize) { try { Item em = null; - final Item em1 = getItem(FQRN); + final Item em1 = getItemFromFQRN(FQRN); // Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); if (em1 != null) { if (null == em) { @@ -233,7 +233,7 @@ public class ItemUtils { ItemStack temp; if (fqrn.toLowerCase().contains(oreDict.toLowerCase())) { final String sanitizedName = fqrn.replace(oreDict, ""); - temp = ItemUtils.getItemStack(sanitizedName, stackSize); + temp = ItemUtils.getItemStackFromFQRN(sanitizedName, stackSize); return temp; } final String[] fqrnSplit = fqrn.split(":"); @@ -258,13 +258,13 @@ public class ItemUtils { return null; } - public static Item getItem(final String fqrn) // fqrn = fully qualified resource name + public static Item getItemFromFQRN(final String fqrn) // fqrn = fully qualified resource name { final String[] fqrnSplit = fqrn.split(":"); return GameRegistry.findItem(fqrnSplit[0], fqrnSplit[1]); } - public static ItemStack getItemStack(final String fqrn, final int Size) // fqrn = fully qualified resource name + public static ItemStack getItemStackFromFQRN(final String fqrn, final int Size) // fqrn = fully qualified resource name { final String[] fqrnSplit = fqrn.split(":"); return GameRegistry.findItemStack(fqrnSplit[0], fqrnSplit[1], Size); diff --git a/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java index a5f5c778bf..664ab40e6f 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java @@ -212,7 +212,7 @@ public static int mInvalidID = 1; public static boolean removeCraftingRecipe(Object x){ if (null == x){return false;} if (x instanceof String){ - final Item R = ItemUtils.getItem((String) x); + final Item R = ItemUtils.getItemFromFQRN((String) x); if (R != null){ x = R; } diff --git a/src/Java/gtPlusPlus/plugin/fixes/vanilla/Core_VanillaFixes.java b/src/Java/gtPlusPlus/plugin/fixes/vanilla/Core_VanillaFixes.java index f6af6e6e5f..cf9676635d 100644 --- a/src/Java/gtPlusPlus/plugin/fixes/vanilla/Core_VanillaFixes.java +++ b/src/Java/gtPlusPlus/plugin/fixes/vanilla/Core_VanillaFixes.java @@ -1,7 +1,11 @@ package gtPlusPlus.plugin.fixes.vanilla; import gtPlusPlus.api.interfaces.IPlugin; +import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.plugin.manager.Core_Manager; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; public class Core_VanillaFixes implements IPlugin { @@ -19,18 +23,18 @@ public class Core_VanillaFixes implements IPlugin { } @Override - public boolean preInit() { - return false; + public boolean preInit() { + return fixVanillaOD(); } @Override public boolean init() { - return false; + return true; } @Override public boolean postInit() { - return false; + return true; } @Override @@ -42,5 +46,31 @@ public class Core_VanillaFixes implements IPlugin { public String getPluginAbbreviation() { return "VFIX"; } + + private boolean fixVanillaOD() { + registerToOreDict(ItemUtils.getSimpleStack(Items.nether_wart), "cropNetherWart"); + registerToOreDict(ItemUtils.getSimpleStack(Items.reeds), "sugarcane"); + registerToOreDict(ItemUtils.getSimpleStack(Items.paper), "paper"); + registerToOreDict(ItemUtils.getSimpleStack(Items.ender_pearl), "enderpearl"); + registerToOreDict(ItemUtils.getSimpleStack(Items.bone), "bone"); + registerToOreDict(ItemUtils.getSimpleStack(Items.gunpowder), "gunpowder"); + registerToOreDict(ItemUtils.getSimpleStack(Items.string), "string"); + registerToOreDict(ItemUtils.getSimpleStack(Items.nether_star), "netherStar"); + registerToOreDict(ItemUtils.getSimpleStack(Items.leather), "leather"); + registerToOreDict(ItemUtils.getSimpleStack(Items.feather), "feather"); + registerToOreDict(ItemUtils.getSimpleStack(Items.egg), "egg"); + registerToOreDict(ItemUtils.getSimpleStack(Blocks.end_stone), "endstone"); + registerToOreDict(ItemUtils.getSimpleStack(Blocks.vine), "vine"); + registerToOreDict(ItemUtils.getSimpleStack(Blocks.cactus), "blockCactus"); + registerToOreDict(ItemUtils.getSimpleStack(Blocks.grass), "grass"); + registerToOreDict(ItemUtils.getSimpleStack(Blocks.obsidian), "obsidian"); + registerToOreDict(ItemUtils.getSimpleStack(Blocks.crafting_table), "workbench"); + return true; + } + + private void registerToOreDict(ItemStack aStack, String aString) { + mInstance.log("Registering "+aStack.getDisplayName()+" to OreDictionary under the tag '"+aString+"'. (Added to Forge in 1.8.9)"); + ItemUtils.addItemToOreDictionary(aStack, aString); + } } diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/recipe/FR_Gregtech_Recipes.java b/src/Java/gtPlusPlus/xmod/forestry/bees/recipe/FR_Gregtech_Recipes.java index 0bba3d1f84..7e011a808e 100644 --- a/src/Java/gtPlusPlus/xmod/forestry/bees/recipe/FR_Gregtech_Recipes.java +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/recipe/FR_Gregtech_Recipes.java @@ -31,7 +31,7 @@ public class FR_Gregtech_Recipes { private static ItemStack hiveFrameClay = ItemUtils.getSimpleStack(FR_ItemRegistry.hiveFrameClay); private static ItemStack hiveFrameNova = ItemUtils.getSimpleStack(FR_ItemRegistry.hiveFrameNova); - private static ItemStack hiveFrameImpregnated = ItemUtils.getItemStack("Forestry:frameImpregnated", 1); + private static ItemStack hiveFrameImpregnated = ItemUtils.getItemStackFromFQRN("Forestry:frameImpregnated", 1); private static ItemStack blockSoulSand = new ItemStack(Blocks.soul_sand, 1); private static ItemStack blockIronBars = new ItemStack (Blocks.iron_bars, 1); private static ItemStack itemClayDust = new ItemStack(Items.clay_ball, 1); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java b/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java index d5b484e314..9eebeb5560 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java @@ -141,7 +141,9 @@ public interface IGregtech_RecipeAdder { public boolean addLFTRRecipe(ItemStack aInput1, FluidStack aInput2, ItemStack aOutput1, FluidStack aOutput2, int aDuration, int aEUt); public boolean addLFTRRecipe(FluidStack aInput1, FluidStack aInput2, FluidStack aOutput1, int aDuration, int aEUt); - + public boolean addSemifluidFuel(FluidStack aFuelItem, int aFuelValue); + public boolean addSemifluidFuel(ItemStack aFuelItem, int aFuelValue); + public boolean addFissionFuel( FluidStack aInput1, FluidStack aInput2, FluidStack aInput3, FluidStack aInput4, FluidStack aInput5, FluidStack aInput6, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java index f052d64a34..e531103a37 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java @@ -134,13 +134,13 @@ public class GregtechMetaTileEntity_MassFabricator extends GregtechMeta_MultiBlo public static ItemStack getScrapPile() { if (mScrap[0] == null) { - mScrap[0] = ItemUtils.getSimpleStack(ItemUtils.getItem("IC2:itemScrap")); + mScrap[0] = ItemUtils.getSimpleStack(ItemUtils.getItemFromFQRN("IC2:itemScrap")); } return mScrap[0]; } public static ItemStack getScrapBox() { if (mScrap[1] == null) { - mScrap[1] = ItemUtils.getSimpleStack(ItemUtils.getItem("IC2:itemScrapbox")); + mScrap[1] = ItemUtils.getSimpleStack(ItemUtils.getItemFromFQRN("IC2:itemScrapbox")); } return mScrap[1]; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java index 66775f7872..15627a827f 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java @@ -264,8 +264,8 @@ public class RecipeGen_Ore extends RecipeGen_Base { matDust, tinyDustA,null, null, null,null, new int[]{10000, 10000}, //Chances - 5*20, //Eu - tVoltageMultiplier/2)){ //Time + 5*20, //Time + tVoltageMultiplier/2)){ //Eu Logger.MATERIALS("[Centrifuge] Added Recipe: Purified Dust to Clean Dust"); } @@ -277,8 +277,8 @@ public class RecipeGen_Ore extends RecipeGen_Base { matDust, tinyDustB,null, null, null,null, new int[]{10000, 10000}, //Chances - 5*20, //Eu - tVoltageMultiplier/2)){ //Time + 5*20, //Time + tVoltageMultiplier/2)){ //Eu Logger.MATERIALS("[Centrifuge] Added Recipe: Inpure Dust to Clean Dust"); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java index b4f7347b52..d16bffef86 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java @@ -15,6 +15,7 @@ import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_AssemblyLine; import gregtech.api.util.GT_Utility; import gregtech.api.util.Recipe_GT; +import gregtech.api.util.SemiFluidFuelHandler; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.lib.CORE; @@ -1064,6 +1065,16 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { return true; } + + @Override + public boolean addSemifluidFuel(ItemStack aFuelItem, int aFuelValue) { + return SemiFluidFuelHandler.addSemiFluidFuel(aFuelItem, aFuelValue); + } + + @Override + public boolean addSemifluidFuel(FluidStack aFuelItem, int aFuelValue) { + return SemiFluidFuelHandler.addSemiFluidFuel(aFuelItem, aFuelValue); + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMassFabricator.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMassFabricator.java index 8064c68559..6362b07b93 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMassFabricator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMassFabricator.java @@ -221,10 +221,10 @@ public class GregtechIndustrialMassFabricator { public static ItemStack getScrapPile() { - return ItemUtils.getSimpleStack(ItemUtils.getItem("IC2:itemScrap")); + return ItemUtils.getSimpleStack(ItemUtils.getItemFromFQRN("IC2:itemScrap")); } public static ItemStack getScrapBox() { - return ItemUtils.getSimpleStack(ItemUtils.getItem("IC2:itemScrapbox")); + return ItemUtils.getSimpleStack(ItemUtils.getItemFromFQRN("IC2:itemScrapbox")); } } \ No newline at end of file diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/sewer_sides.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/sewer_sides.png new file mode 100644 index 0000000000..1754172689 Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/sewer_sides.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/sewer_top.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/sewer_top.png new file mode 100644 index 0000000000..4835240aee Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/sewer_top.png differ -- cgit From 40644c9f57ce7a931d9d955529583cc1cba623a5 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Fri, 8 Mar 2019 04:56:49 +0000 Subject: + Added ItemPackage.java. Allows better load control of item/recipe groupings. $ Improved load handling of Chemistry Packages. $ Fixed bug in StringUtils.java. --- .../api/objects/minecraft/ItemPackage.java | 41 +++ .../gtPlusPlus/core/handler/COMPAT_HANDLER.java | 17 +- src/Java/gtPlusPlus/core/item/ModItems.java | 8 +- .../core/item/chemistry/AgriculturalChem.java | 365 +++++++++------------ .../gtPlusPlus/core/item/chemistry/CoalTar.java | 252 +++++++------- .../core/item/chemistry/NuclearChem.java | 44 ++- .../core/item/chemistry/RocketFuels.java | 217 ++++++------ .../gtPlusPlus/core/util/data/StringUtils.java | 47 ++- 8 files changed, 546 insertions(+), 445 deletions(-) create mode 100644 src/Java/gtPlusPlus/api/objects/minecraft/ItemPackage.java (limited to 'src/Java/gtPlusPlus/core/handler') diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/ItemPackage.java b/src/Java/gtPlusPlus/api/objects/minecraft/ItemPackage.java new file mode 100644 index 0000000000..e725d250cc --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/minecraft/ItemPackage.java @@ -0,0 +1,41 @@ +package gtPlusPlus.api.objects.minecraft; + +import gtPlusPlus.api.interfaces.RunnableWithInfo; +import gtPlusPlus.core.handler.COMPAT_HANDLER; + +public abstract class ItemPackage implements RunnableWithInfo { + + public ItemPackage() { + // Register for late run + COMPAT_HANDLER.mObjectsToRunInPostInit.put(this); + init(); + } + + @Override + public final void run() { + generateRecipes(); + } + + @Override + public final String getInfoData() { + return errorMessage(); + } + + public abstract String errorMessage(); + + public abstract boolean generateRecipes(); + + private final void init() { + items(); + blocks(); + fluids(); + } + + public abstract void items(); + + public abstract void blocks(); + + public abstract void fluids(); + + +} diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java index 1af7c05d64..d8d43ebbd3 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java @@ -208,7 +208,9 @@ public class COMPAT_HANDLER { } public static final AutoMap> mRecipesToGenerate = new AutoMap>(); - public static final AutoMap> mGtRecipesToGenerate = new AutoMap>(); + public static final AutoMap> mGtRecipesToGenerate = new AutoMap>(); + + public static final AutoMap> mObjectsToRunInPostInit = new AutoMap>(); public static void runQueuedRecipes() { //Add autogenerated Recipes from Item Components @@ -233,4 +235,17 @@ public class COMPAT_HANDLER { } } + + public static void runQueuedMisc() { + for (RunnableWithInfo m : mObjectsToRunInPostInit) { + try { + m.run(); + } + catch (Throwable t) { + t.printStackTrace(); + Logger.INFO("[ERROR] "+m.getInfoData()); + } + + } + } } diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index 2a7bae629e..ed1df1f333 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -880,14 +880,14 @@ public final class ModItems { itemControlCore = new ItemControlCore(); //Chemistry - CoalTar.run(); - RocketFuels.run(); + new CoalTar(); + new RocketFuels(); //Nuclear Processing - NuclearChem.run(); + new NuclearChem(); //Farm Animal Fun - AgriculturalChem.run(); + new AgriculturalChem(); //Only used for debugging. /*if (CORE.DEVENV) { diff --git a/src/Java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java b/src/Java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java index a8753677be..0c2bdaa3ef 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java @@ -7,9 +7,9 @@ import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.ItemPackage; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; -import gtPlusPlus.core.material.nuclear.FLUORIDES; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.FluidUtils; @@ -18,51 +18,44 @@ import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; -import scala.xml.dtd.ELEMENTS; -public class AgriculturalChem { +public class AgriculturalChem extends ItemPackage { - private static boolean aBOP; private static boolean aTiCon; - + private static AutoMap mBloodFluids = new AutoMap(); - /** * Fluids */ - //Poop Juice - public static Fluid PoopJuice; - //Manure Slurry - public static Fluid ManureSlurry; - //Fertile Manure Slurry - public static Fluid FertileManureSlurry; - //Blood - public static Fluid CustomBlood; - + // Poop Juice + public static Fluid PoopJuice; + // Manure Slurry + public static Fluid ManureSlurry; + // Fertile Manure Slurry + public static Fluid FertileManureSlurry; + // Blood + public static Fluid CustomBlood; /** * Items */ - //Manure Byproducts + // Manure Byproducts public static Item dustManureByproducts; - //Organic Fertilizer + // Organic Fertilizer public static Item dustOrganicFertilizer; - //Dirt + // Dirt public static Item dustDirt; - - - // Poop Juice // vv - Centrifuge - // Manure Slurry && Manure Byproducts -> (Elements) Centrifuge to several tiny piles + // Manure Slurry && Manure Byproducts -> (Elements) Centrifuge to several tiny + // piles // vv - Chem Reactor - Add Peat, Meat // Organic Fertilizer // vv - Dehydrate @@ -77,24 +70,48 @@ public class AgriculturalChem { // Fertilizer + @Override + public void items() { + // Nitrogen, Ammonium Nitrate, Phosphates, Calcium, Copper, Carbon + dustManureByproducts = ItemUtils.generateSpecialUseDusts("ManureByproducts", "Manure Byproduct", + "(N2H4O3)N2P2Ca3CuC8", Utils.rgbtoHexValue(110, 75, 25))[0]; + // Basically Guano + dustOrganicFertilizer = ItemUtils.generateSpecialUseDusts("OrganicFertilizer", "Organic Fertilizer", + "Ca5(PO4)3(OH)", Utils.rgbtoHexValue(240, 240, 240))[0]; + // Dirt Dust :) + dustDirt = ItemUtils.generateSpecialUseDusts("Dirt", "Dried Earth", Utils.rgbtoHexValue(65, 50, 15))[0]; + } + @Override + public void blocks() { + // None yet + } + @Override + public void fluids() { + // Sewage + PoopJuice = FluidUtils.generateFluidNonMolten("raw.waste", "Raw Animal Waste", 32 + 175, + new short[] { 100, 70, 30, 100 }, null, null, 0, true); + // Sewage + ManureSlurry = FluidUtils.generateFluidNonMolten("manure.slurry", "Manure Slurry", 39 + 175, + new short[] { 75, 45, 15, 100 }, null, null, 0, true); + // Sewage + FertileManureSlurry = FluidUtils.generateFluidNonMolten("fertile.manure.slurry", "Fertile Manure Slurry", + 45 + 175, new short[] { 65, 50, 15, 100 }, null, null, 0, true); + } + + - - - - - - - public static void run(){ - + public AgriculturalChem() { + super(); + aBOP = LoadedMods.BiomesOPlenty; aTiCon = LoadedMods.TiCon; - + Logger.INFO("Adding Agrochemical content"); FluidStack aBlood; @@ -102,78 +119,42 @@ public class AgriculturalChem { aBlood = FluidUtils.getFluidStack("hell_blood", 100); if (aBlood != null) { Logger.INFO("Found Biome's o Plenty, enabled Blood support."); - CustomBlood = aBlood.getFluid(); + CustomBlood = aBlood.getFluid(); mBloodFluids.put(aBlood); - } + } } - - if (aTiCon) { + + if (aTiCon) { aBlood = FluidUtils.getFluidStack("hell_blood", 100); if (aBlood != null) { Logger.INFO("Found Tinker's Construct, enabled Blood support."); CustomBlood = aBlood.getFluid(); mBloodFluids.put(FluidUtils.getFluidStack("blood", 100)); - } + } } - + // Handle Blood Internally, Create if required. if (mBloodFluids.isEmpty() || CustomBlood == null) { - Logger.INFO("Did not find any existing Blood fluids. Trying to wildcard search the fluid registry, then generate our own if that fails."); + Logger.INFO( + "Did not find any existing Blood fluids. Trying to wildcard search the fluid registry, then generate our own if that fails."); FluidStack aTempBlood = FluidUtils.getWildcardFluidStack("blood", 100); if (aTempBlood != null) { CustomBlood = aTempBlood.getFluid(); - } - else { + } else { aTempBlood = FluidUtils.getWildcardFluidStack("hell_blood", 100); if (aTempBlood == null) { - CustomBlood = FluidUtils.generateFluidNoPrefix("blood", "Blood", 32+175, new short[]{175, 25, 25, 100}, true); + CustomBlood = FluidUtils.generateFluidNoPrefix("blood", "Blood", 32 + 175, + new short[] { 175, 25, 25, 100 }, true); + } else { + CustomBlood = aTempBlood.getFluid(); } - else { - CustomBlood = aTempBlood.getFluid(); - } } - Logger.INFO("Using "+CustomBlood.getName()); + Logger.INFO("Using " + CustomBlood.getName()); mBloodFluids.put(FluidUtils.getFluidStack(CustomBlood, 100)); - } - - - - //Sewage - PoopJuice = FluidUtils.generateFluidNonMolten("raw.waste", "Raw Animal Waste", 32+175, new short[]{100, 70, 30, 100}, null, null, 0, true); - - //Sewage - ManureSlurry = FluidUtils.generateFluidNonMolten("manure.slurry", "Manure Slurry", 39+175, new short[]{75, 45, 15, 100}, null, null, 0, true); - - //Sewage - FertileManureSlurry = FluidUtils.generateFluidNonMolten("fertile.manure.slurry", "Fertile Manure Slurry", 45+175, new short[]{65, 50, 15, 100}, null, null, 0, true); - - - - // Nitrogen, Ammonium Nitrate, Phosphates, Calcium, Copper, Carbon - dustManureByproducts = ItemUtils.generateSpecialUseDusts("ManureByproducts", "Manure Byproduct", "(N2H4O3)N2P2Ca3CuC8", Utils.rgbtoHexValue(110, 75, 25))[0]; - - // Basically Guano - dustOrganicFertilizer = ItemUtils.generateSpecialUseDusts("OrganicFertilizer", "Organic Fertilizer", "Ca5(PO4)3(OH)", Utils.rgbtoHexValue(240, 240, 240))[0]; - - // Dirt Dust :) - dustDirt = ItemUtils.generateSpecialUseDusts("Dirt", "Dried Earth", Utils.rgbtoHexValue(65, 50, 15))[0]; - - - - - - - - + } - createRecipes(); } - - - - - - + private static AutoMap mMeats = new AutoMap(); private static AutoMap mFish = new AutoMap(); private static AutoMap mFruits = new AutoMap(); @@ -188,7 +169,7 @@ public class AgriculturalChem { private static AutoMap mList_Master_FruitVege = new AutoMap(); private static AutoMap mList_Master_Bones = new AutoMap(); private static AutoMap mList_Master_Seeds = new AutoMap(); - + private static void processAllOreDict() { processOreDict("listAllmeatraw", mMeats); processOreDict("listAllfishraw", mFish); @@ -198,8 +179,8 @@ public class AgriculturalChem { processOreDict("listAllSeed", mSeeds); processOreDict("brickPeat", mPeat); processOreDict("bone", mBones); - processOreDict("dustBone", mBoneMeal); - //Just make a mega list, makes life easier. + processOreDict("dustBone", mBoneMeal); + // Just make a mega list, makes life easier. if (!mMeats.isEmpty()) { for (ItemStack g : mMeats) { mList_Master_Meats.put(g); @@ -209,12 +190,12 @@ public class AgriculturalChem { for (ItemStack g : mFish) { mList_Master_Meats.put(g); } - } + } if (!mFruits.isEmpty()) { for (ItemStack g : mFruits) { mList_Master_FruitVege.put(g); } - } + } if (!mVege.isEmpty()) { for (ItemStack g : mVege) { mList_Master_FruitVege.put(g); @@ -224,12 +205,12 @@ public class AgriculturalChem { for (ItemStack g : mNuts) { mList_Master_FruitVege.put(g); } - } + } if (!mSeeds.isEmpty()) { for (ItemStack g : mSeeds) { mList_Master_Seeds.put(g); } - } + } if (!mBoneMeal.isEmpty()) { for (ItemStack g : mBoneMeal) { mList_Master_Bones.put(g); @@ -241,79 +222,42 @@ public class AgriculturalChem { } } } - + private static void processOreDict(String aOreName, AutoMap aMap) { ArrayList aTemp = OreDictionary.getOres(aOreName); if (!aTemp.isEmpty()) { for (ItemStack stack : aTemp) { aMap.put(stack); } - } - } - - - private static void createRecipes() { - - if (mBloodFluids.isEmpty()) { - Logger.INFO("Could not find, nor create Blood fluid. Unable to add recipes."); - return; } - - // Organise OreDict - processAllOreDict(); - - // Slurry Production - addBasicSlurryRecipes(); - addAdvancedSlurryRecipes(); - - // Organic Fert. Production - addBasicOrganiseFertRecipes(); - addAdvancedOrganiseFertRecipes(); - - addMiscRecipes(); } - - + private static void addBasicSlurryRecipes() { ItemStack aManureByprod1 = ItemUtils.getItemStackOfAmountFromOreDict("dustTinyManureByproducts", 1); - ItemStack aManureByprod2 = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallManureByproducts", 1); + ItemStack aManureByprod2 = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallManureByproducts", 1); ItemStack aDirtDust = ItemUtils.getSimpleStack(dustDirt, 1); - - //Poop Juice to Basic Slurry - GT_Values.RA.addCentrifugeRecipe( - CI.getNumberedCircuit(10), - null, - FluidUtils.getFluidStack(PoopJuice, 1000), //In Fluid - FluidUtils.getFluidStack(ManureSlurry, 250), //Out Fluid - aDirtDust, - aDirtDust, - aManureByprod1, - aManureByprod1, - aManureByprod1, - aManureByprod1, - new int[]{2000, 2000, 500, 500, 250, 250}, //Chances - 10*20, //Time - 30); //EU - + + // Poop Juice to Basic Slurry + GT_Values.RA.addCentrifugeRecipe(CI.getNumberedCircuit(10), null, FluidUtils.getFluidStack(PoopJuice, 1000), // In + // Fluid + FluidUtils.getFluidStack(ManureSlurry, 250), // Out Fluid + aDirtDust, aDirtDust, aManureByprod1, aManureByprod1, aManureByprod1, aManureByprod1, + new int[] { 2000, 2000, 500, 500, 250, 250 }, // Chances + 10 * 20, // Time + 30); // EU + // More Efficient way to get byproducts, less Slurry - GT_Values.RA.addCentrifugeRecipe( - CI.getNumberedCircuit(20), - null, - FluidUtils.getFluidStack(PoopJuice, 1000), //In Fluid - FluidUtils.getFluidStack(ManureSlurry, 50), //Out Fluid - aDirtDust, - aDirtDust, - aManureByprod1, - aManureByprod1, - aManureByprod2, - aManureByprod2, - new int[]{4000, 3000, 1250, 1250, 675, 675}, //Chances - 20*20, //Time - 60); //EU - + GT_Values.RA.addCentrifugeRecipe(CI.getNumberedCircuit(20), null, FluidUtils.getFluidStack(PoopJuice, 1000), // In + // Fluid + FluidUtils.getFluidStack(ManureSlurry, 50), // Out Fluid + aDirtDust, aDirtDust, aManureByprod1, aManureByprod1, aManureByprod2, aManureByprod2, + new int[] { 4000, 3000, 1250, 1250, 675, 675 }, // Chances + 20 * 20, // Time + 60); // EU + } - + private static void addAdvancedSlurryRecipes() { ItemStack aCircuit = CI.getNumberedCircuit(10); @@ -322,25 +266,24 @@ public class AgriculturalChem { ItemStack aEmptyCells = CI.emptyCells(2); ItemStack aInputCells = ItemUtils.getItemStackOfAmountFromOreDict("cellRawWaste", 2); FluidStack aOutput = FluidUtils.getFluidStack(FertileManureSlurry, 1000); - + for (FluidStack aBloodStack : mBloodFluids) { for (ItemStack aBoneStack : mList_Master_Bones) { aBone = ItemUtils.getSimpleStack(aBoneStack, 2); for (ItemStack aMeatStack : mList_Master_Meats) { - aMeat = ItemUtils.getSimpleStack(aMeatStack, 5); + aMeat = ItemUtils.getSimpleStack(aMeatStack, 5); // Poop Juice to Fertile Slurry - GT_Values.RA.addMixerRecipe(aCircuit, aBone, aMeat, aInputCells, - aBloodStack, // Input Fluid + GT_Values.RA.addMixerRecipe(aCircuit, aBone, aMeat, aInputCells, aBloodStack, // Input Fluid aOutput, // Output Fluid aEmptyCells, // Output Item 20 * 8, // Time? - 60 // Eu? - ); + 60 // Eu? + ); } } } } - + private static void addBasicOrganiseFertRecipes() { FluidStack aInputFluid = FluidUtils.getFluidStack(ManureSlurry, 1000); ItemStack aOutputDust = ItemUtils.getSimpleStack(dustOrganicFertilizer, 3); @@ -360,7 +303,7 @@ public class AgriculturalChem { } } } - + private static void addAdvancedOrganiseFertRecipes() { FluidStack aInputFluid = FluidUtils.getFluidStack(FertileManureSlurry, 1000); ItemStack aOutputDust = ItemUtils.getSimpleStack(dustOrganicFertilizer, 7); @@ -379,81 +322,87 @@ public class AgriculturalChem { } } } - + private static void addMiscRecipes() { ItemStack aDustOrganicFert = ItemUtils.getSimpleStack(dustOrganicFertilizer, 1); - ItemStack aManureByprod = ItemUtils.getSimpleStack(dustManureByproducts, 1); - - - //Dehydrate Organise Fert to Normal Fert. - + ItemStack aManureByprod = ItemUtils.getSimpleStack(dustManureByproducts, 1); + + // Dehydrate Organise Fert to Normal Fert. + /** * Forestry Support */ if (LoadedMods.Forestry) { - + Item aForestryFert = PluginCore.items.fertilizerCompound; - + CORE.RA.addDehydratorRecipe( - new ItemStack[] { - CI.getNumberedCircuit(11), - ItemUtils.getSimpleStack(aDustOrganicFert, 4) - }, - null, - null, - new ItemStack[] {ItemUtils.getSimpleStack(aForestryFert, 3), aManureByprod, aManureByprod}, - new int[] {10000, 2000, 2000}, - 20 * 20, - 240); + new ItemStack[] { CI.getNumberedCircuit(11), ItemUtils.getSimpleStack(aDustOrganicFert, 4) }, null, + null, new ItemStack[] { ItemUtils.getSimpleStack(aForestryFert, 3), aManureByprod, aManureByprod }, + new int[] { 10000, 2000, 2000 }, 20 * 20, 240); } - + /** * IC2 Support */ if (LoadedMods.IndustrialCraft2) { CORE.RA.addDehydratorRecipe( - new ItemStack[] { - CI.getNumberedCircuit(12), - ItemUtils.getSimpleStack(aDustOrganicFert, 4) - }, - null, - null, - new ItemStack[] {ItemUtils.getItemStackFromFQRN("IC2:itemFertilizer", 3), aManureByprod, aManureByprod}, - new int[] {10000, 2000, 2000}, - 20 * 20, - 240); + new ItemStack[] { CI.getNumberedCircuit(12), ItemUtils.getSimpleStack(aDustOrganicFert, 4) }, null, + null, new ItemStack[] { ItemUtils.getItemStackFromFQRN("IC2:itemFertilizer", 3), aManureByprod, + aManureByprod }, + new int[] { 10000, 2000, 2000 }, 20 * 20, 240); } - // Dirt Production - CORE.RA.addCompressorRecipe(ItemUtils.getSimpleStack(dustDirt, 9), ItemUtils.getSimpleStack(Blocks.dirt), 20 * 2, 8); - - //Centrifuge Byproducts + CORE.RA.addCompressorRecipe(ItemUtils.getSimpleStack(dustDirt, 9), ItemUtils.getSimpleStack(Blocks.dirt), + 20 * 2, 8); + // Centrifuge Byproducts // Ammonium Nitrate, Phosphates, Calcium, Copper, Carbon - GT_Values.RA.addCentrifugeRecipe( - CI.getNumberedCircuit(20), - ItemUtils.getSimpleStack(aManureByprod, 4), - FluidUtils.getFluidStack("sulfuricacid", 250), //In Fluid - FluidUtils.getFluidStack("sulfuricapatite", 50), //Out Fluid - Materials.Phosphorus.getDustSmall(2), - Materials.Calcium.getDustSmall(2), - Materials.Copper.getDustTiny(1), - Materials.Carbon.getDust(1), - ItemUtils.getSimpleStack(dustDirt, 1), + GT_Values.RA.addCentrifugeRecipe(CI.getNumberedCircuit(20), ItemUtils.getSimpleStack(aManureByprod, 4), + FluidUtils.getFluidStack("sulfuricacid", 250), // In Fluid + FluidUtils.getFluidStack("sulfuricapatite", 50), // Out Fluid + Materials.Phosphorus.getDustSmall(2), Materials.Calcium.getDustSmall(2), + Materials.Copper.getDustTiny(1), Materials.Carbon.getDust(1), ItemUtils.getSimpleStack(dustDirt, 1), ItemUtils.getItemStackOfAmountFromOreDict("dustTinyAmmoniumNitrate", 1), - new int[]{2500, 2500, 750, 1000, 5000, 250}, //Chances - 20*20, //Time - 60); //EU - - + new int[] { 2500, 2500, 750, 1000, 5000, 250 }, // Chances + 20 * 20, // Time + 60); // EU + // Add Fuel Usages CORE.RA.addSemifluidFuel(FluidUtils.getFluidStack(PoopJuice, 1000), 12); CORE.RA.addSemifluidFuel(FluidUtils.getFluidStack(ManureSlurry, 1000), 24); CORE.RA.addSemifluidFuel(FluidUtils.getFluidStack(FertileManureSlurry, 1000), 32); - - + + } + + @Override + public String errorMessage() { + // TODO Auto-generated method stub + return "Failed to generate recipes for AgroChem."; + } + + @Override + public boolean generateRecipes() { + if (mBloodFluids.isEmpty()) { + Logger.INFO("Could not find, nor create Blood fluid. Unable to add recipes."); + return false; + } + + // Organise OreDict + processAllOreDict(); + + // Slurry Production + addBasicSlurryRecipes(); + addAdvancedSlurryRecipes(); + + // Organic Fert. Production + addBasicOrganiseFertRecipes(); + addAdvancedOrganiseFertRecipes(); + + addMiscRecipes(); + return true; } } diff --git a/src/Java/gtPlusPlus/core/item/chemistry/CoalTar.java b/src/Java/gtPlusPlus/core/item/chemistry/CoalTar.java index eea1aed49f..76827b32d1 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/CoalTar.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/CoalTar.java @@ -8,7 +8,7 @@ import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; - +import gtPlusPlus.api.objects.minecraft.ItemPackage; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.item.base.BaseItemComponent; import gtPlusPlus.core.lib.CORE; @@ -21,7 +21,7 @@ import gtPlusPlus.core.util.reflect.AddGregtechRecipe; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; -public class CoalTar { +public class CoalTar extends ItemPackage { public static Fluid Coal_Gas; public static Fluid Ethylene; @@ -39,116 +39,6 @@ public class CoalTar { public static Fluid Hydrogen_Peroxide; public static Fluid Lithium_Peroxide; - public static void run(){ - - //Special Compatibility for Coke - ItemUtils.addItemToOreDictionary(ItemUtils.getSimpleStack(ModItems.itemCoalCoke, 1), "fuelCoke"); - //Create Coal Gas - Coal_Gas = FluidUtils.generateFluidNonMolten("CoalGas", "Coal Gas", 500, new short[]{48, 48, 48, 100}, null, null); - //Ethanol - // v - Dehydrate cells to remove water - - - //Create Ethylene - if (!FluidUtils.doesFluidExist("Ethylene")){ - Ethylene = FluidUtils.generateFluidNonMolten("Ethylene", "Ethylene", -103, new short[]{255, 255, 255, 100}, null, null); - } - else { - Ethylene = FluidUtils.getWildcardFluidStack("Ethylene", 1).getFluid(); - } - - //Create Benzene - (Toluene + Hydrogen | 95% Benzene / 5% methane) - if (!FluidUtils.doesFluidExist("NitrousOxide")){ - Benzene = FluidUtils.generateFluidNonMolten("Benzene", "Benzene", 81, new short[]{150, 75, 0, 100}, null, null); - } - else { - Benzene = FluidUtils.getWildcardFluidStack("Benzene", 1).getFluid(); - } - - //Create Ethylbenzene - Ethylbenzene is produced in on a large scale by combining benzene and ethylene in an acid-catalyzed chemical reaction - //Use Chemical Reactor - Ethylbenzene = FluidUtils.generateFluidNonMolten("Ethylbenzene", "Ethylbenzene", 136, new short[]{255, 255, 255, 100}, null, null); - //Create Anthracene - Anthracene = FluidUtils.generateFluidNonMolten("Anthracene", "Anthracene", 340, new short[]{255, 255, 255, 100}, null, null); - //Toluene - if (!FluidUtils.doesFluidExist("Toluene")){ - Toluene = FluidUtils.generateFluidNonMolten("Toluene", "Toluene", -95, new short[]{140, 70, 20, 100}, null, null); - } - else { - Toluene = FluidUtils.getWildcardFluidStack("Toluene", 1).getFluid(); - Item itemCellToluene = new BaseItemComponent("Toluene", "Toluene", new short[]{140, 70, 20, 100}); - MaterialGenerator.addFluidCannerRecipe(ItemUtils.getEmptyCell(), ItemUtils.getSimpleStack(itemCellToluene), FluidUtils.getFluidStack(Toluene, 1000), null); - } - - //Create Coal Tar - Coal_Tar = FluidUtils.generateFluidNonMolten("CoalTar", "Coal Tar", 450, new short[]{32, 32, 32, 100}, null, null); - // v - Distill (60% Tar oil/15% Naphtha/20% Ethylbenzene/5% Anthracene) - //Create Coal Tar Oil - Coal_Tar_Oil = FluidUtils.generateFluidNonMolten("CoalTarOil", "Coal Tar Oil", 240, new short[]{240, 240, 150, 100}, null, null); - // v - Wash With Sulfuric Acid - //Create Sulfuric Coal Tar Oil - Sulfuric_Coal_Tar_Oil = FluidUtils.generateFluidNonMolten("SulfuricCoalTarOil", "Sulfuric Coal Tar Oil", 240, new short[]{250, 170, 12, 100}, null, null); - // v - Distill (No loss, just time consuming) - //Create Naphthalene - Naphthalene = FluidUtils.generateFluidNonMolten("Naphthalene", "Naphthalene", 115, new short[]{210, 185, 135, 100}, null, null); - // v - Oxidize with mercury and nitric acid - //Create Phthalic Acid - Phthalic_Acid = FluidUtils.generateFluidNonMolten("PhthalicAcid", "Phthalic Acid", 207, new short[]{210, 220, 210, 100}, null, null); - // v - Dehydrate at 180C+ - //Create Phthalic Anhydride - ItemUtils.generateSpecialUseDusts("PhthalicAnhydride", "Phthalic Anhydride", "C6H4(CO)2O", Utils.rgbtoHexValue(175, 175, 175)); - - - - //Create 2-Ethylanthraquinone - //2-Ethylanthraquinone is prepared from the reaction of phthalic anhydride and ethylbenzene - Ethylanthraquinone2 = FluidUtils.generateFluidNonMolten("2Ethylanthraquinone", "2-Ethylanthraquinone", 415, new short[]{227, 255, 159, 100}, null, null); - //Create 2-Ethylanthrahydroquinone - //Palladium plate + Hydrogen(250) + 2-Ethylanthraquinone(500) = 600 Ethylanthrahydroquinone - Ethylanthrahydroquinone2 = FluidUtils.generateFluidNonMolten("2Ethylanthrahydroquinone", "2-Ethylanthrahydroquinone", 415, new short[]{207, 225, 129, 100}, null, null); - //Create Hydrogen Peroxide - //Compressed Air(1500) + Ethylanthrahydroquinone(500) + Anthracene(5) = 450 Ethylanthraquinone && 200 Peroxide - Hydrogen_Peroxide = FluidUtils.generateFluidNonMolten("HydrogenPeroxide", "Hydrogen Peroxide", 150, new short[]{210, 255, 255, 100}, null, null); - - - - //Lithium Hydroperoxide - LiOH + H2O2 → LiOOH + 2 H2O - ItemUtils.generateSpecialUseDusts("LithiumHydroperoxide", "Lithium Hydroperoxide", "HLiO2", Utils.rgbtoHexValue(125, 125, 125)); - // v - Dehydrate - //Lithium Peroxide - 2 LiOOH → Li2O2 + H2O2 + 2 H2O - Lithium_Peroxide = FluidUtils.generateFluidNonMolten("LithiumPeroxide", "Lithium Peroxide", 446, new short[]{135, 135, 135, 100}, null, null); - - //Burn the coal gas! - GT_Values.RA.addFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalGas", 1), null, 96, 1); - GT_Values.RA.addFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellSulfuricCoalTarOil", 1), null, 32, 3); - GT_Values.RA.addFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalTarOil", 1), null, 64, 3); - GT_Values.RA.addFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalTar", 1), null, 128, 3); - createRecipes(); - - - } - - private static void createRecipes() { - recipeCreateEthylene(); - recipeCreateBenzene(); - recipeCreateEthylbenzene(); - - recipeCoalToCoalTar(); - recipeCoalTarToCoalTarOil(); - recipeCoalTarOilToSulfuricOilToNaphthalene(); - recipeNaphthaleneToPhthalicAcid(); - recipePhthalicAcidToPhthalicAnhydride(); - recipe2Ethylanthraquinone(); - recipe2Ethylanthrahydroquinone(); - recipeHydrogenPeroxide(); - recipeLithiumHydroperoxide(); - recipeLithiumPeroxide(); - - recipeEthylBenzineFuelsIntoHeavyFuel(); - } - - - private static void recipeEthylBenzineFuelsIntoHeavyFuel() { CORE.RA.addChemicalRecipe( ItemUtils.getItemStackOfAmountFromOreDict("cellFuel", 9), @@ -430,4 +320,142 @@ public class CoalTar { 240); } + @Override + public String errorMessage() { + // TODO Auto-generated method stub + return "Bad Coal Science!"; + } + + @Override + public boolean generateRecipes() { + recipeCreateEthylene(); + recipeCreateBenzene(); + recipeCreateEthylbenzene(); + + recipeCoalToCoalTar(); + recipeCoalTarToCoalTarOil(); + recipeCoalTarOilToSulfuricOilToNaphthalene(); + recipeNaphthaleneToPhthalicAcid(); + recipePhthalicAcidToPhthalicAnhydride(); + recipe2Ethylanthraquinone(); + recipe2Ethylanthrahydroquinone(); + recipeHydrogenPeroxide(); + recipeLithiumHydroperoxide(); + recipeLithiumPeroxide(); + + recipeEthylBenzineFuelsIntoHeavyFuel(); + + + //Burn the coal gas! + GT_Values.RA.addFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalGas", 1), null, 96, 1); + GT_Values.RA.addFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellSulfuricCoalTarOil", 1), null, 32, 3); + GT_Values.RA.addFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalTarOil", 1), null, 64, 3); + GT_Values.RA.addFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalTar", 1), null, 128, 3); + + return true; + } + + @Override + public void items() { + //Phthalic_Acid = FluidUtils.generateFluidNonMolten("PhthalicAcid", "Phthalic Acid", 207, new short[]{210, 220, 210, 100}, null, null); + // v - Dehydrate at 180C+ + //Create Phthalic Anhydride + ItemUtils.generateSpecialUseDusts("PhthalicAnhydride", "Phthalic Anhydride", "C6H4(CO)2O", Utils.rgbtoHexValue(175, 175, 175)); + + //Lithium Hydroperoxide - LiOH + H2O2 → LiOOH + 2 H2O + ItemUtils.generateSpecialUseDusts("LithiumHydroperoxide", "Lithium Hydroperoxide", "HLiO2", Utils.rgbtoHexValue(125, 125, 125)); + // v - Dehydrate + //Lithium Peroxide - 2 LiOOH → Li2O2 + H2O2 + 2 H2O + //Lithium_Peroxide = FluidUtils.generateFluidNonMolten("LithiumPeroxide", "Lithium Peroxide", 446, new short[]{135, 135, 135, 100}, null, null); + } + + @Override + public void blocks() { + // TODO Auto-generated method stub + + } + + @Override + public void fluids() { + + + //Special Compatibility for Coke + ItemUtils.addItemToOreDictionary(ItemUtils.getSimpleStack(ModItems.itemCoalCoke, 1), "fuelCoke"); + //Create Coal Gas + Coal_Gas = FluidUtils.generateFluidNonMolten("CoalGas", "Coal Gas", 500, new short[]{48, 48, 48, 100}, null, null); + //Ethanol + // v - Dehydrate cells to remove water + + + //Create Ethylene + if (!FluidUtils.doesFluidExist("Ethylene")){ + Ethylene = FluidUtils.generateFluidNonMolten("Ethylene", "Ethylene", -103, new short[]{255, 255, 255, 100}, null, null); + } + else { + Ethylene = FluidUtils.getWildcardFluidStack("Ethylene", 1).getFluid(); + } + + //Create Benzene - (Toluene + Hydrogen | 95% Benzene / 5% methane) + if (!FluidUtils.doesFluidExist("NitrousOxide")){ + Benzene = FluidUtils.generateFluidNonMolten("Benzene", "Benzene", 81, new short[]{150, 75, 0, 100}, null, null); + } + else { + Benzene = FluidUtils.getWildcardFluidStack("Benzene", 1).getFluid(); + } + + //Create Ethylbenzene - Ethylbenzene is produced in on a large scale by combining benzene and ethylene in an acid-catalyzed chemical reaction + //Use Chemical Reactor + Ethylbenzene = FluidUtils.generateFluidNonMolten("Ethylbenzene", "Ethylbenzene", 136, new short[]{255, 255, 255, 100}, null, null); + //Create Anthracene + Anthracene = FluidUtils.generateFluidNonMolten("Anthracene", "Anthracene", 340, new short[]{255, 255, 255, 100}, null, null); + //Toluene + if (!FluidUtils.doesFluidExist("Toluene")){ + Toluene = FluidUtils.generateFluidNonMolten("Toluene", "Toluene", -95, new short[]{140, 70, 20, 100}, null, null); + } + else { + Toluene = FluidUtils.getWildcardFluidStack("Toluene", 1).getFluid(); + Item itemCellToluene = new BaseItemComponent("Toluene", "Toluene", new short[]{140, 70, 20, 100}); + MaterialGenerator.addFluidCannerRecipe(ItemUtils.getEmptyCell(), ItemUtils.getSimpleStack(itemCellToluene), FluidUtils.getFluidStack(Toluene, 1000), null); + } + + //Create Coal Tar + Coal_Tar = FluidUtils.generateFluidNonMolten("CoalTar", "Coal Tar", 450, new short[]{32, 32, 32, 100}, null, null); + // v - Distill (60% Tar oil/15% Naphtha/20% Ethylbenzene/5% Anthracene) + //Create Coal Tar Oil + Coal_Tar_Oil = FluidUtils.generateFluidNonMolten("CoalTarOil", "Coal Tar Oil", 240, new short[]{240, 240, 150, 100}, null, null); + // v - Wash With Sulfuric Acid + //Create Sulfuric Coal Tar Oil + Sulfuric_Coal_Tar_Oil = FluidUtils.generateFluidNonMolten("SulfuricCoalTarOil", "Sulfuric Coal Tar Oil", 240, new short[]{250, 170, 12, 100}, null, null); + // v - Distill (No loss, just time consuming) + //Create Naphthalene + Naphthalene = FluidUtils.generateFluidNonMolten("Naphthalene", "Naphthalene", 115, new short[]{210, 185, 135, 100}, null, null); + // v - Oxidize with mercury and nitric acid + //Create Phthalic Acid + Phthalic_Acid = FluidUtils.generateFluidNonMolten("PhthalicAcid", "Phthalic Acid", 207, new short[]{210, 220, 210, 100}, null, null); + // v - Dehydrate at 180C+ + //Create Phthalic Anhydride + //ItemUtils.generateSpecialUseDusts("PhthalicAnhydride", "Phthalic Anhydride", "C6H4(CO)2O", Utils.rgbtoHexValue(175, 175, 175)); + + + + //Create 2-Ethylanthraquinone + //2-Ethylanthraquinone is prepared from the reaction of phthalic anhydride and ethylbenzene + Ethylanthraquinone2 = FluidUtils.generateFluidNonMolten("2Ethylanthraquinone", "2-Ethylanthraquinone", 415, new short[]{227, 255, 159, 100}, null, null); + //Create 2-Ethylanthrahydroquinone + //Palladium plate + Hydrogen(250) + 2-Ethylanthraquinone(500) = 600 Ethylanthrahydroquinone + Ethylanthrahydroquinone2 = FluidUtils.generateFluidNonMolten("2Ethylanthrahydroquinone", "2-Ethylanthrahydroquinone", 415, new short[]{207, 225, 129, 100}, null, null); + //Create Hydrogen Peroxide + //Compressed Air(1500) + Ethylanthrahydroquinone(500) + Anthracene(5) = 450 Ethylanthraquinone && 200 Peroxide + Hydrogen_Peroxide = FluidUtils.generateFluidNonMolten("HydrogenPeroxide", "Hydrogen Peroxide", 150, new short[]{210, 255, 255, 100}, null, null); + + + + //Lithium Hydroperoxide - LiOH + H2O2 → LiOOH + 2 H2O + //ItemUtils.generateSpecialUseDusts("LithiumHydroperoxide", "Lithium Hydroperoxide", "HLiO2", Utils.rgbtoHexValue(125, 125, 125)); + // v - Dehydrate + //Lithium Peroxide - 2 LiOOH → Li2O2 + H2O2 + 2 H2O + Lithium_Peroxide = FluidUtils.generateFluidNonMolten("LithiumPeroxide", "Lithium Peroxide", 446, new short[]{135, 135, 135, 100}, null, null); + + } + } diff --git a/src/Java/gtPlusPlus/core/item/chemistry/NuclearChem.java b/src/Java/gtPlusPlus/core/item/chemistry/NuclearChem.java index 1d45dec183..25beb6d9b5 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/NuclearChem.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/NuclearChem.java @@ -3,7 +3,7 @@ package gtPlusPlus.core.item.chemistry; import net.minecraft.init.Items; import gregtech.api.enums.GT_Values; - +import gtPlusPlus.api.objects.minecraft.ItemPackage; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.common.CI; @@ -11,18 +11,40 @@ import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import net.minecraftforge.fluids.Fluid; -public class NuclearChem { +public class NuclearChem extends ItemPackage { public static Fluid Burnt_LiFBeF2ThF4UF4; public static Fluid Burnt_LiFBeF2ZrF4UF4; public static Fluid Burnt_LiFBeF2ZrF4U235; public static Fluid GeneticMutagen; - private static boolean generateMutagenRecipe = false; + private static boolean generateMutagenRecipe = false; + + @Override + public String errorMessage() { + return "bad Nuclear Chemistry Recipes."; + } - public static void run(){ + @Override + public boolean generateRecipes() { + if (generateMutagenRecipe) { + chemReator_CreateMutagen(); + } + chemReactor_MutagenWithEggs(); + return true; + } + + @Override + public void items() { + } + + @Override + public void blocks() { + } - //Create Coal Gas + @Override + public void fluids() { + //Create Used Nuclear Fuels Burnt_LiFBeF2ThF4UF4 = FluidUtils.generateFluidNonMolten("BurntLiFBeF2ThF4UF4", "Burnt LiFBeF2ThF4UF4 Salt", 545, new short[]{48, 175, 48, 100}, null, null); Burnt_LiFBeF2ZrF4UF4 = FluidUtils.generateFluidNonMolten("BurntLiFBeF2ZrF4UF4", "Burnt LiFBeF2ZrF4UF4 Salt", 520, new short[]{48, 168, 68, 100}, null, null); Burnt_LiFBeF2ZrF4U235 = FluidUtils.generateFluidNonMolten("BurntLiFBeF2ZrF4U235", "Burnt LiFBeF2ZrF4U235 Salt", 533, new short[]{68, 185, 48, 100}, null, null); @@ -34,18 +56,6 @@ public class NuclearChem { else { GeneticMutagen = FluidUtils.getFluidStack("fluid.Mutagen", 1).getFluid(); } - - createRecipes(); - - - } - - private static void createRecipes() { - - if (generateMutagenRecipe) - chemReator_CreateMutagen(); - - chemReactor_MutagenWithEggs(); } private static void chemReator_CreateMutagen() { diff --git a/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java b/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java index a516cb0639..789371c9e4 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java @@ -10,6 +10,7 @@ import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; import gregtech.api.util.Recipe_GT; import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.ItemPackage; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.item.base.BaseItemComponent; import gtPlusPlus.core.lib.CORE; @@ -20,7 +21,7 @@ import gtPlusPlus.core.util.minecraft.ItemUtils; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; -public class RocketFuels { +public class RocketFuels extends ItemPackage { public static HashSet mValidRocketFuelNames = new HashSet(); public static HashMap mValidRocketFuels = new HashMap(); @@ -45,107 +46,7 @@ public class RocketFuels { public static Item Ammonium_Nitrate_Dust; public static Item Formaldehyde_Catalyst; - - public static void run(){ - - //Create Kerosene - Kerosene = FluidUtils.generateFluidNonMolten("Kerosene", "Kerosene", 500, new short[]{150, 40, 150, 100}, null, null); - - //RP! Focket Fuel - RP1 = FluidUtils.generateFluidNonMolten("RP1Fuel", "RP-1 Rocket Fuel", 500, new short[]{210, 50, 50, 100}, null, null); - - //Create Nitrogen Tetroxide - Nitrogen_Tetroxide = FluidUtils.generateFluidNonMolten("NitrogenTetroxide", "Nitrogen Tetroxide", -11, new short[]{170, 170, 0, 100}, null, null); - - //Create Hydrazine - Hydrazine = FluidUtils.generateFluidNonMolten("Hydrazine", "Hydrazine", 2, new short[]{250, 250, 250, 100}, null, null); - - //Create Monomethylhydrazine - Monomethylhydrazine = FluidUtils.generateFluidNonMolten("Monomethylhydrazine", "Monomethylhydrazine", -52, new short[]{125, 125, 125, 100}, null, null); - - //Create Anthracene - Nitrous_Oxide = FluidUtils.generateFluidNonMolten("NitrousOxide", "Nitrous Oxide", -91, new short[]{255, 255, 255, 100}, null, null); - - //Nos - if (!FluidUtils.doesFluidExist("NitrousOxide")){ - Nitrous_Oxide = FluidUtils.generateFluidNoPrefix("NitrousOxide", "Nitrous Oxide", -91, new short[]{255, 255, 255, 100}); - } - else { - Nitrous_Oxide = FluidUtils.getWildcardFluidStack("NitrousOxide", 1).getFluid(); - if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cellNitrousOxide", 1) == null){ - new BaseItemComponent("NitrousOxide", "Nitrous Oxide", new short[] {10, 10, 175}); - } - } - - //Unsymmetrical_Dimethylhydrazine - if (FluidUtils.getFluidStack("1,1dimethylhydrazine", 1) == null){ - Unsymmetrical_Dimethylhydrazine = FluidUtils.generateFluidNonMolten("UnsymmetricalDimethylhydrazine", "Unsymmetrical Dimethylhydrazine", -57, new short[]{70, 210, 20, 100}, null, null); - } - else { - Unsymmetrical_Dimethylhydrazine = FluidUtils.getFluidStack("1,1dimethylhydrazine", 1000).getFluid(); - } - - //Create Hydrated_Ammonium_Nitrate_Slurry - Hydrated_Ammonium_Nitrate_Slurry = FluidUtils.generateFluidNonMolten("AmmoniumNitrateSlurry", "Hydrated Ammonium Nitrate Slurry", 450, new short[]{150, 75, 150, 100}, null, null); - - //Lithium Hydroperoxide - LiOH + H2O2 → LiOOH + 2 H2O - Ammonium_Nitrate_Dust = ItemUtils.generateSpecialUseDusts("AmmoniumNitrate", "Ammonium Nitrate", "N2H4O3", Utils.rgbtoHexValue(150, 75, 150))[0]; - - //Create Liquid_Oxygen - if (FluidUtils.getFluidStack("LiquidOxygen", 1) == null && FluidUtils.getFluidStack("liquidoxygen", 1) == null){ - Liquid_Oxygen = FluidUtils.generateFluidNonMolten("LiquidOxygen", "Liquid Oxygen", -240, new short[]{75, 75, 220, 100}, null, null); - } - else { - if (FluidUtils.getFluidStack("LiquidOxygen", 1) != null ) { - Liquid_Oxygen = FluidUtils.getFluidStack("LiquidOxygen", 1).getFluid(); - } - else { - Liquid_Oxygen = FluidUtils.getFluidStack("liquidoxygen", 1).getFluid(); - } - if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cellLiquidOxygen", 1) == null){ - new BaseItemComponent("LiquidOxygen", "Liquid Oxygen", new short[] {10, 10, 175}); - } - } - - Formaldehyde = FluidUtils.generateFluidNonMolten("Formaldehyde", "Formaldehyde", -92, new short[]{150, 75, 150, 100}, null, null); - Formaldehyde_Catalyst = ItemUtils.generateSpecialUseDusts("FormaldehydeCatalyst", "Formaldehyde Catalyst", "Fe16V1", Utils.rgbtoHexValue(25, 5, 25))[0]; - - - Unsymmetrical_Dimethylhydrazine_Plus_Nitrogen_Tetroxide = FluidUtils.generateFluidNonMolten("RocketFuelMixA", "H8N4C2O4 Rocket Fuel", -185, new short[]{50, 220, 50, 100}, null, null); - RP1_Plus_Liquid_Oxygen = FluidUtils.generateFluidNonMolten("RocketFuelMixB", "Rp-1 Fuel Mixture", -250, new short[]{250, 50, 50, 100}, null, null); - Monomethylhydrazine_Plus_Nitric_Acid = FluidUtils.generateFluidNonMolten("RocketFuelMixC", "CN3H7O3 Rocket Fuel", -300, new short[]{125, 75, 180, 100}, null, null); - Dense_Hydrazine_Mix = FluidUtils.generateFluidNonMolten("RocketFuelMixD", "Dense Hydrazine Fuel Mixture", -250, new short[]{175, 80, 120, 100}, null, null); - - - - createRecipes(); - - - } - - private static void createRecipes() { - createKerosene(); - createRP1(); - createNitrogenTetroxide(); - createHydrazine(); - createMonomethylhydrazine(); - - if (!CORE.GTNH) { - createLOX(); - } - - - createHydratedAmmoniumNitrateSlurry(); - createAmmoniumNitrateDust(); - createFormaldehyde(); - createFormaldehydeCatalyst(); - createUnsymmetricalDimethylhydrazine(); - - createRocketFuels(); - addRocketFuelsToMap(); - - } - + public static void createKerosene(){ FluidStack fuelA = FluidUtils.getFluidStack("diesel", 400); FluidStack fuelB = FluidUtils.getFluidStack("fuel", 400); @@ -500,6 +401,118 @@ public class RocketFuels { } + @Override + public String errorMessage() { + // TODO Auto-generated method stub + return "Bad Rocket Fuel Science!"; + } + + @Override + public boolean generateRecipes() { + createKerosene(); + createRP1(); + createNitrogenTetroxide(); + createHydrazine(); + createMonomethylhydrazine(); + + if (!CORE.GTNH) { + createLOX(); + } + + + createHydratedAmmoniumNitrateSlurry(); + createAmmoniumNitrateDust(); + createFormaldehyde(); + createFormaldehydeCatalyst(); + createUnsymmetricalDimethylhydrazine(); + + createRocketFuels(); + addRocketFuelsToMap(); + + return true; + } + + @Override + public void items() { + Formaldehyde_Catalyst = ItemUtils.generateSpecialUseDusts("FormaldehydeCatalyst", "Formaldehyde Catalyst", "Fe16V1", Utils.rgbtoHexValue(25, 5, 25))[0]; + } + + @Override + public void blocks() { + } + + @Override + public void fluids() { + //Create Kerosene + Kerosene = FluidUtils.generateFluidNonMolten("Kerosene", "Kerosene", 500, new short[]{150, 40, 150, 100}, null, null); + + //RP! Focket Fuel + RP1 = FluidUtils.generateFluidNonMolten("RP1Fuel", "RP-1 Rocket Fuel", 500, new short[]{210, 50, 50, 100}, null, null); + + //Create Nitrogen Tetroxide + Nitrogen_Tetroxide = FluidUtils.generateFluidNonMolten("NitrogenTetroxide", "Nitrogen Tetroxide", -11, new short[]{170, 170, 0, 100}, null, null); + + //Create Hydrazine + Hydrazine = FluidUtils.generateFluidNonMolten("Hydrazine", "Hydrazine", 2, new short[]{250, 250, 250, 100}, null, null); + + //Create Monomethylhydrazine + Monomethylhydrazine = FluidUtils.generateFluidNonMolten("Monomethylhydrazine", "Monomethylhydrazine", -52, new short[]{125, 125, 125, 100}, null, null); + + //Create Anthracene + Nitrous_Oxide = FluidUtils.generateFluidNonMolten("NitrousOxide", "Nitrous Oxide", -91, new short[]{255, 255, 255, 100}, null, null); + + //Nos + if (!FluidUtils.doesFluidExist("NitrousOxide")){ + Nitrous_Oxide = FluidUtils.generateFluidNoPrefix("NitrousOxide", "Nitrous Oxide", -91, new short[]{255, 255, 255, 100}); + } + else { + Nitrous_Oxide = FluidUtils.getWildcardFluidStack("NitrousOxide", 1).getFluid(); + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cellNitrousOxide", 1) == null){ + new BaseItemComponent("NitrousOxide", "Nitrous Oxide", new short[] {10, 10, 175}); + } + } + + //Unsymmetrical_Dimethylhydrazine + if (FluidUtils.getFluidStack("1,1dimethylhydrazine", 1) == null){ + Unsymmetrical_Dimethylhydrazine = FluidUtils.generateFluidNonMolten("UnsymmetricalDimethylhydrazine", "Unsymmetrical Dimethylhydrazine", -57, new short[]{70, 210, 20, 100}, null, null); + } + else { + Unsymmetrical_Dimethylhydrazine = FluidUtils.getFluidStack("1,1dimethylhydrazine", 1000).getFluid(); + } + + //Create Hydrated_Ammonium_Nitrate_Slurry + Hydrated_Ammonium_Nitrate_Slurry = FluidUtils.generateFluidNonMolten("AmmoniumNitrateSlurry", "Hydrated Ammonium Nitrate Slurry", 450, new short[]{150, 75, 150, 100}, null, null); + + //Lithium Hydroperoxide - LiOH + H2O2 → LiOOH + 2 H2O + Ammonium_Nitrate_Dust = ItemUtils.generateSpecialUseDusts("AmmoniumNitrate", "Ammonium Nitrate", "N2H4O3", Utils.rgbtoHexValue(150, 75, 150))[0]; + + //Create Liquid_Oxygen + if (FluidUtils.getFluidStack("LiquidOxygen", 1) == null && FluidUtils.getFluidStack("liquidoxygen", 1) == null){ + Liquid_Oxygen = FluidUtils.generateFluidNonMolten("LiquidOxygen", "Liquid Oxygen", -240, new short[]{75, 75, 220, 100}, null, null); + } + else { + if (FluidUtils.getFluidStack("LiquidOxygen", 1) != null ) { + Liquid_Oxygen = FluidUtils.getFluidStack("LiquidOxygen", 1).getFluid(); + } + else { + Liquid_Oxygen = FluidUtils.getFluidStack("liquidoxygen", 1).getFluid(); + } + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cellLiquidOxygen", 1) == null){ + new BaseItemComponent("LiquidOxygen", "Liquid Oxygen", new short[] {10, 10, 175}); + } + } + + + Formaldehyde = FluidUtils.generateFluidNonMolten("Formaldehyde", "Formaldehyde", -92, new short[]{150, 75, 150, 100}, null, null); + + Unsymmetrical_Dimethylhydrazine_Plus_Nitrogen_Tetroxide = FluidUtils.generateFluidNonMolten("RocketFuelMixA", "H8N4C2O4 Rocket Fuel", -185, new short[]{50, 220, 50, 100}, null, null); + RP1_Plus_Liquid_Oxygen = FluidUtils.generateFluidNonMolten("RocketFuelMixB", "Rp-1 Fuel Mixture", -250, new short[]{250, 50, 50, 100}, null, null); + Monomethylhydrazine_Plus_Nitric_Acid = FluidUtils.generateFluidNonMolten("RocketFuelMixC", "CN3H7O3 Rocket Fuel", -300, new short[]{125, 75, 180, 100}, null, null); + Dense_Hydrazine_Mix = FluidUtils.generateFluidNonMolten("RocketFuelMixD", "Dense Hydrazine Fuel Mixture", -250, new short[]{175, 80, 120, 100}, null, null); + + + } + } diff --git a/src/Java/gtPlusPlus/core/util/data/StringUtils.java b/src/Java/gtPlusPlus/core/util/data/StringUtils.java index 2821a0c1c9..2372d04c15 100644 --- a/src/Java/gtPlusPlus/core/util/data/StringUtils.java +++ b/src/Java/gtPlusPlus/core/util/data/StringUtils.java @@ -1,6 +1,8 @@ package gtPlusPlus.core.util.data; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.util.Utils; public class StringUtils { @@ -134,19 +136,62 @@ public class StringUtils { } } + + + /** + * Is this a special regex character for delimination? (.$|()[]{}^?*+\\) + * @param aChar - The char to test + * @return - Is this a special character? + */ + public static boolean isSpecialCharacter(char aChar) { + if (aChar == '"' || aChar == '.' || aChar == '$' || aChar == '|' || aChar == '(' || aChar == ')' || aChar == '[' + || aChar == ']' || aChar == '{' || aChar == '}' || aChar == '^' || aChar == '?' || aChar == '*' + || aChar == '+' || aChar == '\\') { + return true; + } + return false; + } + + public static boolean isEscaped(String aString) { + return aString.substring(0, 1).equals("\\"); + } + public static String splitAndUppercase(String aInput, String aDelim) { + + if (!isEscaped(aDelim)) { + boolean isSpecial = false; + for (int o=0;o aTemp = new AutoMap(); for (String s : aSplit) { - aTemp.put(firstLetterCaps(s)); + Logger.INFO("Found: "+s); + s = s.replace(".", ""); + s = Utils.sanitizeString(s); + s = firstLetterCaps(s); + Logger.INFO("Formatted & Captilized: "+s); + aTemp.put(s); } + Logger.INFO("Rebuilding"); String aReturn = ""; for (String s : aTemp) { aReturn += s; + Logger.INFO("Step: "+aReturn); } return aReturn; } -- cgit From 4b089469f052772b65ccdbed0dbbf41339f8c924 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Fri, 8 Mar 2019 07:48:27 +0000 Subject: $ Attempted to rewrite unused fluid system. $ Made Queued Chemistry Packages load recipes in Post-Init. --- .../gtPlusPlus/core/fluids/BlockFluidBase.java | 94 ++------ src/Java/gtPlusPlus/core/fluids/FactoryFluid.java | 25 +++ src/Java/gtPlusPlus/core/fluids/FluidFactory.java | 168 ++++++++++++++ src/Java/gtPlusPlus/core/fluids/FluidPackage.java | 65 ++++++ src/Java/gtPlusPlus/core/fluids/GenericFluid.java | 70 ------ .../core/fluids/ItemGenericFluidBucket.java | 250 +++++++++++++++++++++ .../gtPlusPlus/core/handler/COMPAT_HANDLER.java | 3 +- .../core/item/chemistry/RocketFuels.java | 6 +- 8 files changed, 535 insertions(+), 146 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/fluids/FactoryFluid.java create mode 100644 src/Java/gtPlusPlus/core/fluids/FluidFactory.java create mode 100644 src/Java/gtPlusPlus/core/fluids/FluidPackage.java delete mode 100644 src/Java/gtPlusPlus/core/fluids/GenericFluid.java create mode 100644 src/Java/gtPlusPlus/core/fluids/ItemGenericFluidBucket.java (limited to 'src/Java/gtPlusPlus/core/handler') diff --git a/src/Java/gtPlusPlus/core/fluids/BlockFluidBase.java b/src/Java/gtPlusPlus/core/fluids/BlockFluidBase.java index 9a3958a908..24ebf0ecca 100644 --- a/src/Java/gtPlusPlus/core/fluids/BlockFluidBase.java +++ b/src/Java/gtPlusPlus/core/fluids/BlockFluidBase.java @@ -1,19 +1,15 @@ package gtPlusPlus.core.fluids; -import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.potion.Potion; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; - -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.material.Material; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.math.MathUtils; import net.minecraftforge.fluids.BlockFluidClassic; import net.minecraftforge.fluids.Fluid; @@ -24,90 +20,46 @@ public class BlockFluidBase extends BlockFluidClassic { @SideOnly(Side.CLIENT) protected IIcon flowingIcon; - protected int colour; - protected Material fluidMaterial; - final String displayName; - - @SuppressWarnings("deprecation") - public BlockFluidBase(final Fluid fluid, final Material material) { - super(fluid, net.minecraft.block.material.Material.lava); - final short[] tempColour = material.getRGBA(); - this.colour = Utils.rgbtoHexValue(tempColour[0], tempColour[1], tempColour[2]); - this.fluidMaterial = material; - this.setCreativeTab(AddToCreativeTab.tabOther); - this.displayName = material.getLocalizedName(); - LanguageRegistry.addName(this, "Molten "+this.displayName+" ["+MathUtils.celsiusToKelvin(this.fluidMaterial.getBoilingPointC())+"K]"); - this.setBlockName(this.GetProperName()); + public BlockFluidBase(Fluid fluid, Material material) { + super(fluid, material); } - @SuppressWarnings("deprecation") - public BlockFluidBase(final String fluidName, final Fluid fluid, final short[] colour) { - super(fluid, net.minecraft.block.material.Material.lava); - final short[] tempColour = colour; - this.colour = Utils.rgbtoHexValue(tempColour[0], tempColour[1], tempColour[2]); - this.setCreativeTab(AddToCreativeTab.tabOther); - this.displayName = fluidName; - LanguageRegistry.addName(this, "Molten "+this.displayName); - this.setBlockName(this.GetProperName()); + @Override + public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity ent) { + if (!(ent instanceof EntityLivingBase)) { + return; + } + EntityLivingBase player = (EntityLivingBase) ent; + int pot = world.rand.nextInt(Potion.potionTypes.length); + Potion.potionTypes[pot].performEffect(player, 40); } @Override - public IIcon getIcon(final int side, final int meta) { - return ((side == 0) || (side == 1))? this.stillIcon : this.flowingIcon; + public IIcon getIcon(int side, int meta) { + return (side == 0 || side == 1) ? stillIcon : flowingIcon; } @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(final IIconRegister register) { - this.stillIcon = register.registerIcon(CORE.MODID+":fluids/fluid.molten.autogenerated"); - this.flowingIcon = register.registerIcon(CORE.MODID+":fluids/fluid.molten.autogenerated"); + public void registerBlockIcons(IIconRegister register) { + stillIcon = register.registerIcon("chaotica:pureChaosStill"); + flowingIcon = register.registerIcon("chaotica:pureChaosFlowing"); } @Override - public boolean canDisplace(final IBlockAccess world, final int x, final int y, final int z) { - if (world.getBlock(x, y, z).getMaterial().isLiquid()) { + public boolean canDisplace(IBlockAccess world, int x, int y, int z) { + if (world.getBlock(x, y, z).getMaterial().isLiquid()) { return false; } return super.canDisplace(world, x, y, z); } @Override - public boolean displaceIfPossible(final World world, final int x, final int y, final int z) { - if (world.getBlock(x, y, z).getMaterial().isLiquid()) { + public boolean displaceIfPossible(World world, int x, int y, int z) { + if (world.getBlock(x, y, z).getMaterial().isLiquid()) { return false; } return super.displaceIfPossible(world, x, y, z); } - @Override - public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4){ - - if (this.colour == 0){ - return MathUtils.generateSingularRandomHexValue(); - } - - return this.colour; - } - - @Override - public int getRenderColor(final int aMeta) { - if (this.colour == 0){ - return MathUtils.generateSingularRandomHexValue(); - } - - return this.colour; - } - - public String GetProperName() { - String tempIngot; - - tempIngot = "Molten "+this.displayName; - - return tempIngot; - } - - public Material getFluidMaterial(){ - return this.fluidMaterial; - } - } diff --git a/src/Java/gtPlusPlus/core/fluids/FactoryFluid.java b/src/Java/gtPlusPlus/core/fluids/FactoryFluid.java new file mode 100644 index 0000000000..9755dd42b2 --- /dev/null +++ b/src/Java/gtPlusPlus/core/fluids/FactoryFluid.java @@ -0,0 +1,25 @@ +package gtPlusPlus.core.fluids; +import net.minecraft.block.Block; +import net.minecraft.item.EnumRarity; +import net.minecraftforge.fluids.Fluid; + +public class FactoryFluid extends Fluid { + + + public FactoryFluid(String fluidName, int luminosity, int density, int temp, int viscosity) { + this(fluidName, null, luminosity, density, temp, viscosity, false, EnumRarity.common); + } + + + public FactoryFluid(String fluidName, Block aBlock, int luminosity, int density, int temp, int viscosity, boolean gas, EnumRarity aRarity) { + super(fluidName); + this.setBlock(aBlock); + this.setLuminosity(luminosity); + this.setDensity(density); + this.setTemperature(temp); + this.setViscosity(viscosity); + this.setGaseous(gas); + this.setRarity(aRarity); + } + + } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/fluids/FluidFactory.java b/src/Java/gtPlusPlus/core/fluids/FluidFactory.java new file mode 100644 index 0000000000..fec008ecff --- /dev/null +++ b/src/Java/gtPlusPlus/core/fluids/FluidFactory.java @@ -0,0 +1,168 @@ +package gtPlusPlus.core.fluids; + +import java.util.LinkedHashMap; +import java.util.Map; + +import cpw.mods.fml.common.eventhandler.Event.Result; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.registry.GameRegistry; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.GTplusplus.INIT_PHASE; +import gtPlusPlus.api.objects.GregtechException; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import net.minecraftforge.event.entity.player.FillBucketEvent; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidRegistry; + +public class FluidFactory { + + public static final Map mNameToFluidMap = new LinkedHashMap(); + public static final Map mNameToBucketMap = new LinkedHashMap(); + public static final Map mNameToBlockMap = new LinkedHashMap(); + public static final Map mNameToMetaMap = new LinkedHashMap(); + + public static final Map mFluidToNameMap = new LinkedHashMap(); + public static final Map mFluidToBucketMap = new LinkedHashMap(); + public static final Map mFluidToBlockMap = new LinkedHashMap(); + public static final Map mFluidToMetaMap = new LinkedHashMap(); + + public static final Map mBucketToFluidMap = new LinkedHashMap(); + public static final Map mBucketToNameMap = new LinkedHashMap(); + public static final Map mBucketToBlockMap = new LinkedHashMap(); + public static final Map mBucketToMetaMap = new LinkedHashMap(); + + public static final Map mBlockToNameMap = new LinkedHashMap(); + public static final Map mBlockToFluidMap = new LinkedHashMap(); + public static final Map mBlockToBucketMap = new LinkedHashMap(); + public static final Map mBlockToMetaMap = new LinkedHashMap(); + + public static final Map mMetaToNameMap = new LinkedHashMap(); + public static final Map mMetaToFluidMap = new LinkedHashMap(); + public static final Map mMetaToBucketMap = new LinkedHashMap(); + public static final Map mMetaToBlockMap = new LinkedHashMap(); + + + private static Fluid mErrorFluid; + private static AutoMap mGeneratedFluids = new AutoMap(); + + public static void preInit() { + + } + + public static void init() { + GameRegistry.registerItem(new ItemGenericFluidBucket(Blocks.air), "gtpp.bucket.generic"); + for (FluidPackage y : mGeneratedFluids) { + FluidRegistry.registerFluid(y.get()); + GameRegistry.registerBlock(y.mBlock, "gtpp_" + y.mName); + FluidContainerRegistry.registerFluidContainer(y.get(), y.mBucket, new ItemStack(Items.bucket)); + } + Utils.registerEvent(BucketHandler.INSTANCE); + } + + public static void postInit() { + + } + + public static FluidPackage generate(int aID, String aUnlocalName, int luminosity, int density, int temp, + int viscosity) { + + FluidPackage aFluidToGenerate = null; + + // Check Load Phase for some Safety, only allow this to be called in Pre-Init. + if (GTplusplus.CURRENT_LOAD_PHASE != INIT_PHASE.PRE_INIT) { + try { + throw new GregtechException("Cannot generate Fluid Packages outside of Pre-Init!"); + } catch (GregtechException e) { + System.exit(0); + } + } + + Fluid aGenFluid = fluid(aUnlocalName, 0, 0, 0, 0); + Block aGenBlock = block(); + ItemStack aGenBucket = bucket(); + + aFluidToGenerate = new FluidPackage(aID, aUnlocalName, aGenFluid, aGenBucket, aGenBlock); + + if (aFluidToGenerate.valid()) { + FluidRegistry.registerFluid(aFluidToGenerate.get()); + } + + + // Handle Bad generation + if (mErrorFluid == null) { + mErrorFluid = new Fluid("baderrorfluid.gtpp").setViscosity(4000); + } + if (aFluidToGenerate != null) { + mGeneratedFluids.put(aFluidToGenerate); + } + return aFluidToGenerate; + } + + + + private static Fluid fluid(String aUnlocalName, int luminosity, int density, int temp, + int viscosity) { + return new FactoryFluid(aUnlocalName, 0, 0, 0, 0); + } + + private static ItemStack bucket() { + return null; + } + + private static Block block() { + return null; + } + + /** + * Copyright © SpaceToad, 2011 http://www.mod-buildcraft.com BuildCraft is + * distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. + * Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + * + * Modified version of the BC BucketHandler, except using ItemStacks > Items + * (Why?) + * + * @author Alkalus + */ + + public static class BucketHandler { + + public static BucketHandler INSTANCE = new BucketHandler(); + + private BucketHandler() { + + } + + @SubscribeEvent + public void onBucketFill(FillBucketEvent event) { + ItemStack result = fillCustomBucket(event.world, event.target); + if (result == null) { + return; + } + event.result = result; + event.setResult(Result.ALLOW); + } + + private ItemStack fillCustomBucket(World world, MovingObjectPosition pos) { + Block block = world.getBlock(pos.blockX, pos.blockY, pos.blockZ); + ItemStack bucket = mBlockToBucketMap.get(block); + if (bucket != null && world.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ) == 0) { + world.setBlockToAir(pos.blockX, pos.blockY, pos.blockZ); + return ItemUtils.getSimpleStack(bucket, 1); + } else { + return null; + } + } + + } + +} diff --git a/src/Java/gtPlusPlus/core/fluids/FluidPackage.java b/src/Java/gtPlusPlus/core/fluids/FluidPackage.java new file mode 100644 index 0000000000..7c8cf70c70 --- /dev/null +++ b/src/Java/gtPlusPlus/core/fluids/FluidPackage.java @@ -0,0 +1,65 @@ +package gtPlusPlus.core.fluids; + +import static gtPlusPlus.core.fluids.FluidFactory.*; + +import java.util.LinkedHashMap; +import java.util.Map; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; + +public class FluidPackage { + + + public final int mID; + public final String mName; + private final Fluid mFluid; + public final ItemStack mBucket; + public final Block mBlock; + + public FluidPackage(int aID, String aName, Fluid aFluid, ItemStack aBucket, Block aBlock) { + + mNameToFluidMap.put(aName, aFluid); + mNameToBucketMap.put(aName, aBucket); + mNameToBlockMap.put(aName, aBlock); + mNameToMetaMap.put(aName, aID); + + mFluidToNameMap.put(aFluid, aName); + mFluidToBucketMap.put(aFluid, aBucket); + mFluidToBlockMap.put(aFluid, aBlock); + mFluidToMetaMap.put(aFluid, aID); + + mBucketToFluidMap.put(aBucket, aFluid); + mBucketToNameMap.put(aBucket, aName); + mBucketToBlockMap.put(aBucket, aBlock); + mBucketToMetaMap.put(aBucket, aID); + + mBlockToNameMap.put(aBlock, aName); + mBlockToFluidMap.put(aBlock, aFluid); + mBlockToBucketMap.put(aBlock, aBucket); + mBlockToMetaMap.put(aBlock, aID); + + mMetaToNameMap.put(aID, aName); + mMetaToFluidMap.put(aID, aFluid); + mMetaToBucketMap.put(aID, aBucket); + mMetaToBlockMap.put(aID, aBlock); + + + mID = aID; + mName = aName; + mFluid = aFluid; + mBucket = aBucket; + mBlock = aBlock; + + } + + public Fluid get() { + return mFluid; + } + + public boolean valid() { + return mName != null && mName.length() > 0 && mFluid != null && mBucket != null && mBlock != null; + } + +} diff --git a/src/Java/gtPlusPlus/core/fluids/GenericFluid.java b/src/Java/gtPlusPlus/core/fluids/GenericFluid.java deleted file mode 100644 index 4f1f5df006..0000000000 --- a/src/Java/gtPlusPlus/core/fluids/GenericFluid.java +++ /dev/null @@ -1,70 +0,0 @@ -package gtPlusPlus.core.fluids; - -import cpw.mods.fml.common.registry.GameRegistry; - -import net.minecraft.block.Block; - -import gtPlusPlus.core.item.base.itemblock.ItemBlockFluid; -import gtPlusPlus.core.material.Material; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidRegistry; - -public class GenericFluid extends Fluid{ - - protected final String fluidName; - protected final Fluid fluidFactory; - protected final Block blockFactory; - protected final short[] rgba; - - public GenericFluid(final String displayName, final String fluidName, final int luminosity, final int density, final int temperature, final int viscosity, final boolean isGas, final short[] rgba) { - super(fluidName); - this.fluidFactory = this; - this.rgba = rgba; - this.fluidName = fluidName; - this.fluidFactory.setLuminosity(luminosity); - this.fluidFactory.setDensity(density); - this.fluidFactory.setTemperature(temperature); - this.fluidFactory.setViscosity(viscosity); - this.fluidFactory.setGaseous(isGas); - this.fluidFactory.setUnlocalizedName("fluid"+fluidName); - FluidRegistry.registerFluid(this.fluidFactory); - this.blockFactory = new BlockFluidBase(displayName, this.fluidFactory, rgba).setBlockName("fluidblock"+fluidName); - GameRegistry.registerBlock(this.blockFactory, ItemBlockFluid.class, this.blockFactory.getUnlocalizedName().substring(5)); - this.fluidFactory.setBlock(this.blockFactory); - - //fluidFactory.setUnlocalizedName(blockFactory.getUnlocalizedName()); - - } - - public GenericFluid(final Material fluidMaterial, final int luminosity, final int density, final int temperature, final int viscosity, final boolean isGas) { - - super(fluidMaterial.getUnlocalizedName()); - //IC2_ItemFluidCell fullFluidCell = emptyCell.fill(emptyCell, FluidUtils.getFluidStack(getUnlocalizedName(), 1), true); - - this.fluidFactory = this; - this.rgba = fluidMaterial.getRGBA(); - this.fluidName = fluidMaterial.getUnlocalizedName(); - this.fluidFactory.setLuminosity(luminosity); - this.fluidFactory.setDensity(density); - this.fluidFactory.setTemperature(temperature); - this.fluidFactory.setViscosity(viscosity); - this.fluidFactory.setGaseous(isGas); - this.fluidFactory.setUnlocalizedName("fluid"+this.fluidName); - FluidRegistry.registerFluid(this.fluidFactory); - this.blockFactory = new BlockFluidBase(this.fluidFactory, fluidMaterial).setBlockName("fluidblock"+this.fluidName); - GameRegistry.registerBlock(this.blockFactory, ItemBlockFluid.class, this.blockFactory.getUnlocalizedName().substring(5)); - this.fluidFactory.setBlock(this.blockFactory); - //IC2_ItemFluidCell emptyCell = new IC2_ItemFluidCell(fluidName); - /*if (aFullContainer != null && aEmptyContainer != null && !FluidContainerRegistry.registerFluidContainer(new FluidStack(rFluid, aFluidAmount), aFullContainer, aEmptyContainer)) { - GT_Values.RA.addFluidCannerRecipe(aFullContainer, container(aFullContainer, false), null, new FluidStack(rFluid, aFluidAmount)); - }*/ - //fluidFactory.setUnlocalizedName(blockFactory.getUnlocalizedName()); - - } - - @Override - public int getColor() { - return (Math.max(0, Math.min(255, this.rgba[0])) << 16) | (Math.max(0, Math.min(255, this.rgba[1])) << 8) | Math.max(0, Math.min(255, this.rgba[2])); - } - -} diff --git a/src/Java/gtPlusPlus/core/fluids/ItemGenericFluidBucket.java b/src/Java/gtPlusPlus/core/fluids/ItemGenericFluidBucket.java new file mode 100644 index 0000000000..ab2fe11d8c --- /dev/null +++ b/src/Java/gtPlusPlus/core/fluids/ItemGenericFluidBucket.java @@ -0,0 +1,250 @@ +package gtPlusPlus.core.fluids; + +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBucket; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.FillBucketEvent; + +public class ItemGenericFluidBucket extends ItemBucket { + + public ItemGenericFluidBucket(Block aFluid) { + super(aFluid); + this.setContainerItem(Items.bucket); + this.maxStackSize = 1; + } + + Map mIconCache = new LinkedHashMap(); + + /** + * Called whenever this item is equipped and the right mouse button is pressed. + * Args: itemStack, world, entityPlayer + */ + public ItemStack onItemRightClick(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { + + Block isFull = FluidFactory.mBucketToBlockMap.get(aStack); + + boolean flag = isFull == Blocks.air; + MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(aWorld, aPlayer, flag); + + if (movingobjectposition == null || isFull == null) { + return aStack; + } else { + FillBucketEvent event = new FillBucketEvent(aPlayer, aStack, aWorld, movingobjectposition); + if (MinecraftForge.EVENT_BUS.post(event)) { + return aStack; + } + + if (event.getResult() == Event.Result.ALLOW) { + if (aPlayer.capabilities.isCreativeMode) { + return aStack; + } + + if (--aStack.stackSize <= 0) { + return event.result; + } + + if (!aPlayer.inventory.addItemStackToInventory(event.result)) { + aPlayer.dropPlayerItemWithRandomChoice(event.result, false); + } + + return aStack; + } + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + int i = movingobjectposition.blockX; + int j = movingobjectposition.blockY; + int k = movingobjectposition.blockZ; + + if (!aWorld.canMineBlock(aPlayer, i, j, k)) { + return aStack; + } + + if (flag) { + if (!aPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, aStack)) { + return aStack; + } + + Material material = aWorld.getBlock(i, j, k).getMaterial(); + int l = aWorld.getBlockMetadata(i, j, k); + + if (material == Material.water && l == 0) { + aWorld.setBlockToAir(i, j, k); + return this.func_150910_a(aStack, aPlayer, Items.water_bucket); + } + + if (material == Material.lava && l == 0) { + aWorld.setBlockToAir(i, j, k); + return this.func_150910_a(aStack, aPlayer, Items.lava_bucket); + } + } else { + if (isFull == Blocks.air) { + return new ItemStack(Items.bucket); + } + + if (movingobjectposition.sideHit == 0) { + --j; + } + + if (movingobjectposition.sideHit == 1) { + ++j; + } + + if (movingobjectposition.sideHit == 2) { + --k; + } + + if (movingobjectposition.sideHit == 3) { + ++k; + } + + if (movingobjectposition.sideHit == 4) { + --i; + } + + if (movingobjectposition.sideHit == 5) { + ++i; + } + + if (!aPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, aStack)) { + return aStack; + } + + if (this.tryPlaceContainedLiquid(isFull, aWorld, i, j, k) && !aPlayer.capabilities.isCreativeMode) { + return new ItemStack(Items.bucket); + } + } + } + + return aStack; + } + } + + private ItemStack func_150910_a(ItemStack p_150910_1_, EntityPlayer p_150910_2_, Item p_150910_3_) { + if (p_150910_2_.capabilities.isCreativeMode) { + return p_150910_1_; + } else if (--p_150910_1_.stackSize <= 0) { + return new ItemStack(p_150910_3_); + } else { + if (!p_150910_2_.inventory.addItemStackToInventory(new ItemStack(p_150910_3_))) { + p_150910_2_.dropPlayerItemWithRandomChoice(new ItemStack(p_150910_3_, 1, 0), false); + } + + return p_150910_1_; + } + } + + /** + * Attempts to place the liquid contained inside the bucket. + */ + public boolean tryPlaceContainedLiquid(Block isFull, World aWorld, int aX, int aY, int aZ) { + if (isFull == Blocks.air) { + return false; + } else { + Material material = aWorld.getBlock(aX, aY, aZ).getMaterial(); + boolean flag = !material.isSolid(); + + if (!aWorld.isAirBlock(aX, aY, aZ) && !flag) { + return false; + } else { + + if (!aWorld.isRemote && flag && !material.isLiquid()) { + aWorld.func_147480_a(aX, aY, aZ, true); + } + + aWorld.setBlock(aX, aY, aZ, isFull, 0, 3); + + return true; + } + } + } + + @Override + public IIcon getIconFromDamage(int aMeta) { + IIcon aTemp = mIconCache.get(aMeta); + return aTemp != null ? aTemp : super.getIconFromDamage(aMeta); + } + + @Override + public int getMetadata(int p_77647_1_) { + // TODO Auto-generated method stub + return super.getMetadata(p_77647_1_); + } + + @Override + public boolean getHasSubtypes() { + return super.getHasSubtypes(); + } + + @Override + public int getMaxDamage() { + return super.getMaxDamage(); + } + + @Override + public boolean isDamageable() { + return false; + } + + @Override + public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List p_77624_3_, boolean p_77624_4_) { + // TODO Auto-generated method stub + super.addInformation(p_77624_1_, p_77624_2_, p_77624_3_, p_77624_4_); + } + + @Override + public int getItemEnchantability() { + return 0; + } + + @Override + public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List p_150895_3_) { + // TODO Auto-generated method stub + super.getSubItems(p_150895_1_, p_150895_2_, p_150895_3_); + } + + @Override + public boolean isRepairable() { + return false; + } + + @Override + public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { + IIcon aTemp = mIconCache.get(stack.getItemDamage()); + return aTemp != null ? aTemp : super.getIcon(stack, renderPass, player, usingItem, useRemaining); + } + + @Override + public boolean isBookEnchantable(ItemStack stack, ItemStack book) { + return false; + } + + @Override + public int getMaxDamage(ItemStack stack) { + return 0; + } + + @Override + public boolean isDamaged(ItemStack stack) { + return false; + } + + @Override + public int getItemEnchantability(ItemStack stack) { + return 0; + } + +} diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java index d8d43ebbd3..a5b876efb6 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java @@ -204,7 +204,8 @@ public class COMPAT_HANDLER { } } } - RecipeGen_Recycling.executeGenerators(); + RecipeGen_Recycling.executeGenerators(); + runQueuedMisc(); } public static final AutoMap> mRecipesToGenerate = new AutoMap>(); diff --git a/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java b/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java index 789371c9e4..ddac7f1d88 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java @@ -1,8 +1,5 @@ package gtPlusPlus.core.item.chemistry; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - import java.util.HashMap; import java.util.HashSet; @@ -11,13 +8,14 @@ import gregtech.api.enums.Materials; import gregtech.api.util.Recipe_GT; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.minecraft.ItemPackage; -import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.item.base.BaseItemComponent; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; -- cgit From dbe1827984f9dd1e87d500882c541181bdaeb542 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Tue, 12 Mar 2019 05:08:33 +0000 Subject: + Added framework for additional Oil chemistry in future updates. + Added additional processes for obtaining Kerosene. % Mild rebalance to GT++ Rocket Fuels. % Swapped Coal by-products (Coal Tar, Coal Tar Oil and Sulfuric Coal Tar Oil) from Gas Turbine fuel to Semifluid fuel. % Allowed ItemPackages to register themselves to the onLoadComplete() event. $ Fixed GT++ Rocket Fuels being unusable in Rocket Engines. $ Fixed Tooltip on GC Fuel loader when the GC-ASM is not active. --- .../api/objects/minecraft/ItemPackage.java | 19 +- src/Java/gtPlusPlus/core/common/CommonProxy.java | 1 + .../gtPlusPlus/core/handler/COMPAT_HANDLER.java | 26 ++ .../gtPlusPlus/core/item/chemistry/CoalTar.java | 28 ++- .../gtPlusPlus/core/item/chemistry/OilChem.java | 210 ++++++++++++++++ .../core/item/chemistry/RocketFuels.java | 272 +++++++++++++++++++-- .../core/util/minecraft/MaterialUtils.java | 18 ++ .../core/util/minecraft/RecipeUtils.java | 9 + .../galacticraft/handler/HandlerTooltip_GC.java | 37 +-- .../GregtechRocketFuelGeneratorBase.java | 101 ++++++-- .../GregtechMetaTileEntityRocketFuelGenerator.java | 8 +- 11 files changed, 661 insertions(+), 68 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/item/chemistry/OilChem.java (limited to 'src/Java/gtPlusPlus/core/handler') diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/ItemPackage.java b/src/Java/gtPlusPlus/api/objects/minecraft/ItemPackage.java index e725d250cc..fa85f23cf3 100644 --- a/src/Java/gtPlusPlus/api/objects/minecraft/ItemPackage.java +++ b/src/Java/gtPlusPlus/api/objects/minecraft/ItemPackage.java @@ -1,13 +1,21 @@ package gtPlusPlus.api.objects.minecraft; +import cpw.mods.fml.common.event.FMLLoadCompleteEvent; import gtPlusPlus.api.interfaces.RunnableWithInfo; import gtPlusPlus.core.handler.COMPAT_HANDLER; public abstract class ItemPackage implements RunnableWithInfo { public ItemPackage() { + this(false); + } + + public ItemPackage(boolean hasExtraLateRun) { // Register for late run - COMPAT_HANDLER.mObjectsToRunInPostInit.put(this); + COMPAT_HANDLER.mObjectsToRunInPostInit.put(this); + if (hasExtraLateRun) { + COMPAT_HANDLER.mObjectsToRunInOnLoadComplete.put(this); + } init(); } @@ -37,5 +45,14 @@ public abstract class ItemPackage implements RunnableWithInfo { public abstract void fluids(); + /** + * Override this to handle GT Recipe map manipulation after they're Baked. + * @param event - the {@link FMLLoadCompleteEvent}. + * @return - Did we do anything? + */ + public boolean onLoadComplete(FMLLoadCompleteEvent event) { + return false; + }; + } diff --git a/src/Java/gtPlusPlus/core/common/CommonProxy.java b/src/Java/gtPlusPlus/core/common/CommonProxy.java index 7d4644f275..301ca992a4 100644 --- a/src/Java/gtPlusPlus/core/common/CommonProxy.java +++ b/src/Java/gtPlusPlus/core/common/CommonProxy.java @@ -183,6 +183,7 @@ public class CommonProxy { public void onLoadComplete(FMLLoadCompleteEvent event) { COMPAT_IntermodStaging.onLoadComplete(event); + COMPAT_HANDLER.onLoadComplete(event); } public void registerNetworkStuff() { diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java index a5b876efb6..1e3cb0ffbb 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java @@ -4,11 +4,13 @@ import static gtPlusPlus.core.lib.LoadedMods.Gregtech; import java.util.*; +import cpw.mods.fml.common.event.FMLLoadCompleteEvent; import gregtech.api.enums.GT_Values; import gregtech.api.util.GT_OreDictUnificator; import gtPlusPlus.api.interfaces.RunnableWithInfo; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.ItemPackage; import gtPlusPlus.core.common.compat.*; import gtPlusPlus.core.handler.Recipes.LateRegistrationHandler; import gtPlusPlus.core.handler.Recipes.RegistrationHandler; @@ -19,6 +21,7 @@ import gtPlusPlus.core.material.MaterialGenerator; import gtPlusPlus.core.recipe.*; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.RecipeUtils; +import gtPlusPlus.xmod.gregtech.HANDLER_GT; import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Recycling; import gtPlusPlus.xmod.gregtech.registration.gregtech.*; import net.minecraft.item.ItemStack; @@ -207,11 +210,18 @@ public class COMPAT_HANDLER { RecipeGen_Recycling.executeGenerators(); runQueuedMisc(); } + + + + public static void onLoadComplete(FMLLoadCompleteEvent event) { + runQueuedOnLoadComplete(event); + } public static final AutoMap> mRecipesToGenerate = new AutoMap>(); public static final AutoMap> mGtRecipesToGenerate = new AutoMap>(); public static final AutoMap> mObjectsToRunInPostInit = new AutoMap>(); + public static final AutoMap mObjectsToRunInOnLoadComplete = new AutoMap(); public static void runQueuedRecipes() { //Add autogenerated Recipes from Item Components @@ -249,4 +259,20 @@ public class COMPAT_HANDLER { } } + + /** + * Generally used to register GT recipe map changes after they've been populated. + */ + public static void runQueuedOnLoadComplete(FMLLoadCompleteEvent event) { + for (ItemPackage m : mObjectsToRunInOnLoadComplete) { + try { + m.onLoadComplete(event); + } + catch (Throwable t) { + t.printStackTrace(); + Logger.INFO("[ERROR] "+m.getInfoData()); + } + + } + } } diff --git a/src/Java/gtPlusPlus/core/item/chemistry/CoalTar.java b/src/Java/gtPlusPlus/core/item/chemistry/CoalTar.java index 76827b32d1..1f10261b36 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/CoalTar.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/CoalTar.java @@ -24,6 +24,7 @@ import net.minecraftforge.fluids.FluidStack; public class CoalTar extends ItemPackage { public static Fluid Coal_Gas; + public static Fluid Coal_Oil; public static Fluid Ethylene; public static Fluid Benzene; public static Fluid Ethylbenzene; @@ -185,14 +186,24 @@ public class CoalTar extends ItemPackage { 900, //aDuration 30,//aEUt false //Hidden? - ); + ); + GT_Values.RA.addDistilleryRecipe( + CI.getNumberedCircuit(5), //Circuit + FluidUtils.getFluidStack("fluid.coaltar", 1430), //aInput + FluidUtils.getFluidStack("fluid.kerosene", 360), //aOutput + 300, //aDuration + 64,//aEUt + false //Hidden? + ); + GT_Values.RA.addDistillationTowerRecipe( FluidUtils.getFluidStack("fluid.coaltar", 1000), new FluidStack[]{ - FluidUtils.getFluidStack("fluid.coaltaroil", 600), //aOutput - FluidUtils.getFluidStack("liquid_naphtha", 150), //aOutput - FluidUtils.getFluidStack("fluid.ethylbenzene", 200), //aOutput + FluidUtils.getFluidStack("fluid.coaltaroil", 500), //aOutput + FluidUtils.getFluidStack("liquid_naphtha", 100), //aOutput + FluidUtils.getFluidStack("fluid.ethylbenzene", 150), //aOutput FluidUtils.getFluidStack("fluid.anthracene", 50), //aOutput + FluidUtils.getFluidStack("fluid.kerosene", 200), //aOutput }, null, 900, @@ -343,14 +354,13 @@ public class CoalTar extends ItemPackage { recipeLithiumHydroperoxide(); recipeLithiumPeroxide(); - recipeEthylBenzineFuelsIntoHeavyFuel(); - + recipeEthylBenzineFuelsIntoHeavyFuel(); //Burn the coal gas! GT_Values.RA.addFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalGas", 1), null, 96, 1); - GT_Values.RA.addFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellSulfuricCoalTarOil", 1), null, 32, 3); - GT_Values.RA.addFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalTarOil", 1), null, 64, 3); - GT_Values.RA.addFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalTar", 1), null, 128, 3); + CORE.RA.addSemifluidFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellSulfuricCoalTarOil", 1), 32); + CORE.RA.addSemifluidFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalTarOil", 1), 64); + CORE.RA.addSemifluidFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalTar", 1), 128); return true; } diff --git a/src/Java/gtPlusPlus/core/item/chemistry/OilChem.java b/src/Java/gtPlusPlus/core/item/chemistry/OilChem.java new file mode 100644 index 0000000000..fd168f24f2 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/chemistry/OilChem.java @@ -0,0 +1,210 @@ +package gtPlusPlus.core.item.chemistry; + +import java.util.ArrayList; + +import forestry.plugins.PluginCore; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.ItemPackage; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; + +public class OilChem extends ItemPackage { + + /** + * Fluids + */ + + // Poop Juice + public static Fluid PoopJuice; + // Manure Slurry + public static Fluid ManureSlurry; + // Fertile Manure Slurry + public static Fluid FertileManureSlurry; + + /** + * Items + */ + + // Manure Byproducts + public static Item dustManureByproducts; + // Organic Fertilizer + public static Item dustOrganicFertilizer; + // Dirt + public static Item dustDirt; + + // Poop Juice + // vv - Centrifuge + // Manure Slurry && Manure Byproducts -> (Elements) Centrifuge to several tiny + // piles + // vv - Chem Reactor - Add Peat, Meat + // Organic Fertilizer + // vv - Dehydrate + // Fertilizer + + // Poop Juice + // vv - Mixer - Add Blood, Bone, Meat (1000L Poo, 200L Blood, x2 Bone, x3 Meat) + // Fertile Manure Slurry + // vv - Chem Reactor - Add Peat x1.5 + // Organic Fertilizer x3 + // vv - Dehydrate + // Fertilizer + + + @Override + public void items() { + // Nitrogen, Ammonium Nitrate, Phosphates, Calcium, Copper, Carbon + dustManureByproducts = ItemUtils.generateSpecialUseDusts("ManureByproducts", "Manure Byproduct", + "(N2H4O3)N2P2Ca3CuC8", Utils.rgbtoHexValue(110, 75, 25))[0]; + + // Basically Guano + dustOrganicFertilizer = ItemUtils.generateSpecialUseDusts("OrganicFertilizer", "Organic Fertilizer", + "Ca5(PO4)3(OH)", Utils.rgbtoHexValue(240, 240, 240))[0]; + + // Dirt Dust :) + dustDirt = ItemUtils.generateSpecialUseDusts("Dirt", "Dried Earth", Utils.rgbtoHexValue(65, 50, 15))[0]; + } + + @Override + public void blocks() { + // None yet + } + + @Override + public void fluids() { + // Sewage + PoopJuice = FluidUtils.generateFluidNonMolten("raw.waste", "Raw Animal Waste", 32 + 175, + new short[] { 100, 70, 30, 100 }, null, null, 0, true); + + // Sewage + ManureSlurry = FluidUtils.generateFluidNonMolten("manure.slurry", "Manure Slurry", 39 + 175, + new short[] { 75, 45, 15, 100 }, null, null, 0, true); + + // Sewage + FertileManureSlurry = FluidUtils.generateFluidNonMolten("fertile.manure.slurry", "Fertile Manure Slurry", + 45 + 175, new short[] { 65, 50, 15, 100 }, null, null, 0, true); + } + + private static AutoMap mMeats = new AutoMap(); + private static AutoMap mFish = new AutoMap(); + private static AutoMap mFruits = new AutoMap(); + private static AutoMap mVege = new AutoMap(); + private static AutoMap mNuts = new AutoMap(); + private static AutoMap mSeeds = new AutoMap(); + private static AutoMap mPeat = new AutoMap(); + private static AutoMap mBones = new AutoMap(); + private static AutoMap mBoneMeal = new AutoMap(); + + private static AutoMap mList_Master_Meats = new AutoMap(); + private static AutoMap mList_Master_FruitVege = new AutoMap(); + private static AutoMap mList_Master_Bones = new AutoMap(); + private static AutoMap mList_Master_Seeds = new AutoMap(); + + private static void processAllOreDict() { + processOreDict("listAllmeatraw", mMeats); + processOreDict("listAllfishraw", mFish); + processOreDict("listAllfruit", mFruits); + processOreDict("listAllVeggie", mVege); + processOreDict("listAllnut", mNuts); + processOreDict("listAllSeed", mSeeds); + processOreDict("brickPeat", mPeat); + processOreDict("bone", mBones); + processOreDict("dustBone", mBoneMeal); + // Just make a mega list, makes life easier. + if (!mMeats.isEmpty()) { + for (ItemStack g : mMeats) { + mList_Master_Meats.put(g); + } + } + if (!mFish.isEmpty()) { + for (ItemStack g : mFish) { + mList_Master_Meats.put(g); + } + } + if (!mFruits.isEmpty()) { + for (ItemStack g : mFruits) { + mList_Master_FruitVege.put(g); + } + } + if (!mVege.isEmpty()) { + for (ItemStack g : mVege) { + mList_Master_FruitVege.put(g); + } + } + if (!mNuts.isEmpty()) { + for (ItemStack g : mNuts) { + mList_Master_FruitVege.put(g); + } + } + if (!mSeeds.isEmpty()) { + for (ItemStack g : mSeeds) { + mList_Master_Seeds.put(g); + } + } + if (!mBoneMeal.isEmpty()) { + for (ItemStack g : mBoneMeal) { + mList_Master_Bones.put(g); + } + } + if (!mBones.isEmpty()) { + for (ItemStack g : mBones) { + mList_Master_Bones.put(g); + } + } + } + + private static void processOreDict(String aOreName, AutoMap aMap) { + ArrayList aTemp = OreDictionary.getOres(aOreName); + if (!aTemp.isEmpty()) { + for (ItemStack stack : aTemp) { + aMap.put(stack); + } + } + } + + private static void addBasicSlurryRecipes() {} + + private static void addAdvancedSlurryRecipes() {} + + private static void addBasicOrganiseFertRecipes() {} + + private static void addAdvancedOrganiseFertRecipes() {} + + private static void addMiscRecipes() {} + + @Override + public String errorMessage() { + // TODO Auto-generated method stub + return "Failed to generate recipes for AgroChem."; + } + + @Override + public boolean generateRecipes() { + + // Organise OreDict + processAllOreDict(); + + // Slurry Production + addBasicSlurryRecipes(); + addAdvancedSlurryRecipes(); + + // Organic Fert. Production + addBasicOrganiseFertRecipes(); + addAdvancedOrganiseFertRecipes(); + + addMiscRecipes(); + return true; + } +} diff --git a/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java b/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java index ddac7f1d88..f2b5d0683c 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java @@ -2,21 +2,26 @@ package gtPlusPlus.core.item.chemistry; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashMap; +import cpw.mods.fml.common.event.FMLLoadCompleteEvent; import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; +import gregtech.api.util.GT_Recipe; import gregtech.api.util.Recipe_GT; -import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.minecraft.ItemPackage; import gtPlusPlus.core.item.base.BaseItemComponent; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.MaterialUtils; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; public class RocketFuels extends ItemPackage { @@ -24,7 +29,9 @@ public class RocketFuels extends ItemPackage { public static HashSet mValidRocketFuelNames = new HashSet(); public static HashMap mValidRocketFuels = new HashMap(); - public static Fluid Kerosene; + public static Fluid Oil_Heavy; + public static Fluid Diesel; + public static Fluid Kerosene; public static Fluid RP1; public static Fluid Nitrogen_Tetroxide; public static Fluid Hydrazine; @@ -46,15 +53,21 @@ public class RocketFuels extends ItemPackage { public static Item Formaldehyde_Catalyst; public static void createKerosene(){ - FluidStack fuelA = FluidUtils.getFluidStack("diesel", 400); - FluidStack fuelB = FluidUtils.getFluidStack("fuel", 400); + + + + FluidStack fuelA = FluidUtils.getFluidStack("diesel", 300); + FluidStack fuelB = FluidUtils.getFluidStack("fuel", 300); + + + if (fuelA != null){ //GT_Values.RA.addDistilleryRecipe(23, fuelA, FluidUtils.getFluidStack(Kerosene, 50), 200, 64, false); - GT_Values.RA.addDistilleryRecipe(CI.getNumberedCircuit(23), fuelA, FluidUtils.getFluidStack(Kerosene, 50), 200, 64, false); + GT_Values.RA.addDistilleryRecipe(CI.getNumberedCircuit(23), fuelA, FluidUtils.getFluidStack(Kerosene, 100), 200, 64, false); } if (fuelA == null && fuelB != null){ //GT_Values.RA.addDistilleryRecipe(23, fuelB, FluidUtils.getFluidStack(Kerosene, 50), 200, 64, false); - GT_Values.RA.addDistilleryRecipe(CI.getNumberedCircuit(23), fuelB, FluidUtils.getFluidStack(Kerosene, 50), 200, 64, false); + GT_Values.RA.addDistilleryRecipe(CI.getNumberedCircuit(23), fuelB, FluidUtils.getFluidStack(Kerosene, 100), 200, 64, false); } } @@ -187,9 +200,9 @@ public class RocketFuels extends ItemPackage { } - private static void addRocketFuelsToMap() { - AutoMap mRocketFuels = new AutoMap(); - mRocketFuels.put(new Recipe_GT( + private static void addRocketFuelsToMap() { + HashMap mRocketFuels = new LinkedHashMap(); + mRocketFuels.put(0, new Recipe_GT( true, new ItemStack[] {}, new ItemStack[] {}, @@ -201,7 +214,7 @@ public class RocketFuels extends ItemPackage { 0, 256)); //Fuel Value - mRocketFuels.put(new Recipe_GT( + mRocketFuels.put(1, new Recipe_GT( true, new ItemStack[] {}, new ItemStack[] {}, @@ -213,7 +226,7 @@ public class RocketFuels extends ItemPackage { 0, 512)); //Fuel Value - mRocketFuels.put(new Recipe_GT( + mRocketFuels.put(2, new Recipe_GT( true, new ItemStack[] {}, new ItemStack[] {}, @@ -225,7 +238,7 @@ public class RocketFuels extends ItemPackage { 0, 768)); //Fuel Value - mRocketFuels.put(new Recipe_GT( + mRocketFuels.put(3, new Recipe_GT( true, new ItemStack[] {}, new ItemStack[] {}, @@ -239,15 +252,15 @@ public class RocketFuels extends ItemPackage { //Add in default Diesel for the Buggy - mValidRocketFuelNames.add(Materials.Fuel.getFluid(1).getFluid().getName()); - mValidRocketFuels.put(-1, Materials.Fuel.getFluid(1).getFluid()); - - int mID = 0; - for (Recipe_GT r : mRocketFuels) { - if (r != null) { - mValidRocketFuelNames.add(r.mFluidInputs[0].getFluid().getName()); - mValidRocketFuels.put(mID++, r.mFluidInputs[0].getFluid()); - Recipe_GT.Gregtech_Recipe_Map.sRocketFuels.add(r); + mValidRocketFuels.put(-1, Diesel); + + mValidRocketFuelNames.add(FluidRegistry.getFluidName(Diesel)); + for (int mID : mRocketFuels.keySet()) { + Recipe_GT aFuelRecipe = mRocketFuels.get(mID); + if (aFuelRecipe != null) { + mValidRocketFuelNames.add(FluidRegistry.getFluidName(aFuelRecipe.mFluidInputs[0].getFluid())); + mValidRocketFuels.put(mID, aFuelRecipe.mFluidInputs[0].getFluid()); + Recipe_GT.Gregtech_Recipe_Map.sRocketFuels.add(aFuelRecipe); } } @@ -430,6 +443,214 @@ public class RocketFuels extends ItemPackage { return true; } + @Override + public boolean onLoadComplete(FMLLoadCompleteEvent event) { + + + if (MathUtils.randInt(1, 2) > 0) { + return false; + } + + + Materials aMaterial_Chloramine = MaterialUtils.getMaterial("Chloramine"); + Materials aMaterial_Dimethylamine = MaterialUtils.getMaterial("Dimethylamine"); + Materials aMaterial_DilutedHydrochloricAcid = MaterialUtils.getMaterial("DilutedHydrochloricAcid"); + Materials aMaterial_NitrogenDioxide = MaterialUtils.getMaterial("NitrogenDioxide"); + Materials aMaterial_DinitrogenTetroxide = MaterialUtils.getMaterial("DinitrogenTetroxide"); + Materials aMaterial_Dimethylhydrazine = MaterialUtils.getMaterial("Dimethylhydrazine"); + + Materials aMaterial_Oxygen = Materials.Oxygen; + Materials aMaterial_Water = Materials.Water; + Materials aMaterial_HypochlorousAcid = MaterialUtils.getMaterial("HypochlorousAcid"); + Materials aMaterial_Ammonia = MaterialUtils.getMaterial("Ammonia"); + Materials aMaterial_Methanol = MaterialUtils.getMaterial("Methanol"); + + if (aMaterial_Chloramine == null || aMaterial_Dimethylamine == null || aMaterial_DilutedHydrochloricAcid == null + || aMaterial_Dimethylhydrazine == null || aMaterial_NitrogenDioxide == null || aMaterial_DinitrogenTetroxide == null + || aMaterial_HypochlorousAcid == null || aMaterial_Ammonia == null || aMaterial_Methanol == null) { + return false; + } + + + ItemStack aCellEmpty = CI.emptyCells(1); + ItemStack aCellWater = aMaterial_Water.getCells(1); + ItemStack aCellOxygen = aMaterial_Oxygen.getCells(1); + ItemStack aCellChloramine = aMaterial_Chloramine.getCells(1); + ItemStack aCellDimethylamine = aMaterial_Dimethylamine.getCells(1); + ItemStack aCellDilutedHydrochloricAcid = aMaterial_DilutedHydrochloricAcid.getCells(1); + ItemStack aCellNitrogenDioxide = aMaterial_NitrogenDioxide.getCells(1); + ItemStack aCellDinitrogenTetroxide = aMaterial_DinitrogenTetroxide.getCells(1); + ItemStack aCellDimethylhydrazine = aMaterial_Dimethylhydrazine.getCells(1); + + + + + + + GT_Recipe aChemReactor_1 = new Recipe_GT( + true, //Optimise + new ItemStack[] {}, //I + new ItemStack[] {}, //O + null, //Special + new int[] {}, //Chance + new FluidStack[] {}, //I + new FluidStack[] {}, //O + 0, //Dura + 0, //Eu + 0); //Special + + GT_Recipe aChemReactor_2 = new Recipe_GT( + true, //Optimise + new ItemStack[] {}, //I + new ItemStack[] {}, //O + null, //Special + new int[] {}, //Chance + new FluidStack[] {}, //I + new FluidStack[] {}, //O + 0, //Dura + 0, //Eu + 0); //Special + + + + + GT_Recipe aChemReactor_Basic_1 = new Recipe_GT( + true, //Optimise + new ItemStack[] {}, //I + new ItemStack[] {}, //O + null, //Special + new int[] {}, //Chance + new FluidStack[] {}, //I + new FluidStack[] {}, //O + 0, //Dura + 0, //Eu + 0); //Special + + GT_Recipe aChemReactor_Basic_2 = new Recipe_GT( + true, //Optimise + new ItemStack[] {}, //I + new ItemStack[] {}, //O + null, //Special + new int[] {}, //Chance + new FluidStack[] {}, //I + new FluidStack[] {}, //O + 0, //Dura + 0, //Eu + 0); //Special + + GT_Recipe aChemReactor_Basic_3 = new Recipe_GT( + true, //Optimise + new ItemStack[] {}, //I + new ItemStack[] {}, //O + null, //Special + new int[] {}, //Chance + new FluidStack[] {}, //I + new FluidStack[] {}, //O + 0, //Dura + 0, //Eu + 0); //Special + + GT_Recipe aChemReactor_Basic_4 = new Recipe_GT( + true, //Optimise + new ItemStack[] {}, //I + new ItemStack[] {}, //O + null, //Special + new int[] {}, //Chance + new FluidStack[] {}, //I + new FluidStack[] {}, //O + 0, //Dura + 0, //Eu + 0); //Special + + + + + + + + + + + + + + GT_Recipe aChemReactor_Adv_1 = new Recipe_GT( + true, //Optimise + new ItemStack[] {}, //I + new ItemStack[] {}, //O + null, //Special + new int[] {}, //Chance + new FluidStack[] {}, //I + new FluidStack[] {}, //O + 0, //Dura + 0, //Eu + 0); //Special + + GT_Recipe aChemReactor_Adv_2 = new Recipe_GT( + true, //Optimise + new ItemStack[] {}, //I + new ItemStack[] {}, //O + null, //Special + new int[] {}, //Chance + new FluidStack[] {}, //I + new FluidStack[] {}, //O + 0, //Dura + 0, //Eu + 0); //Special + + + + + //RecipeUtils.removeGtRecipe(aChemReactor_Basic_1, GT_Recipe.GT_Recipe_Map.sChemicalRecipes); + //RecipeUtils.removeGtRecipe(aChemReactor_Basic_1, GT_Recipe.GT_Recipe_Map.sChemicalRecipes); + //RecipeUtils.removeGtRecipe(aChemReactor_Basic_1, GT_Recipe.GT_Recipe_Map.sChemicalRecipes); + //RecipeUtils.removeGtRecipe(aChemReactor_Basic_1, GT_Recipe.GT_Recipe_Map.sChemicalRecipes); + + + + + + + /* GT_Values.RA.addChemicalRecipe( Materials.Chloramine.getCells(2), GT_Utility.getIntegratedCircuit(1), Materials.Dimethylamine.getGas(5000), Materials.Dimethylhydrazine.getFluid(6000), Materials.DilutedHydrochloricAcid.getCells(1), Materials.Empty.getCells(1), 960, 480); + GT_Values.RA.addChemicalRecipe( Materials.Dimethylamine.getCells(5), GT_Utility.getIntegratedCircuit(1), Materials.Chloramine.getFluid(2000), Materials.Dimethylhydrazine.getFluid(6000), Materials.DilutedHydrochloricAcid.getCells(1), Materials.Empty.getCells(4), 960, 480); + GT_Values.RA.addChemicalRecipeForBasicMachineOnly(Materials.Chloramine.getCells(2), Materials.Empty.getCells(4), Materials.Dimethylamine.getGas(5000), Materials.DilutedHydrochloricAcid.getFluid(1000), Materials.Dimethylhydrazine.getCells(6), GT_Values.NI, 960, 480); + GT_Values.RA.addChemicalRecipeForBasicMachineOnly(Materials.Dimethylamine.getCells(5), Materials.Empty.getCells(1), Materials.Chloramine.getFluid(2000), Materials.DilutedHydrochloricAcid.getFluid(1000), Materials.Dimethylhydrazine.getCells(6), GT_Values.NI, 960, 480); + GT_Values.RA.addChemicalRecipeForBasicMachineOnly(Materials.Dimethylamine.getCells(5), Materials.Chloramine.getCells(2), Materials.Chloramine.getFluid(2000), Materials.DilutedHydrochloricAcid.getFluid(1000), Materials.Dimethylhydrazine.getCells(6), Materials.DilutedHydrochloricAcid.getCells(1), 960, 480); + GT_Values.RA.addMultiblockChemicalRecipe(new ItemStack[]{GT_Utility.getIntegratedCircuit(24)}, new FluidStack[]{Materials.HypochlorousAcid.getFluid(3000), Materials.Ammonia.getGas(8000), Materials.Methanol.getFluid(12000)}, new FluidStack[]{Materials.Dimethylhydrazine.getFluid(12000), Materials.DilutedHydrochloricAcid.getFluid(2000), Materials.Water.getFluid(9000)}, null, 1040, 480); + + GT_Values.RA.addChemicalRecipe(GT_Utility.getIntegratedCircuit(2), GT_Values.NI, Materials.NitrogenDioxide.getGas(1000), Materials.DinitrogenTetroxide.getGas(1000), GT_Values.NI, 640); + GT_Values.RA.addChemicalRecipe(Materials.NitrogenDioxide.getCells(1), GT_Utility.getIntegratedCircuit(2), GT_Values.NF, Materials.DinitrogenTetroxide.getGas(1000), Materials.Empty.getCells(1), 640); + GT_Values.RA.addChemicalRecipe(Materials.NitrogenDioxide.getCells(1), GT_Utility.getIntegratedCircuit(12), GT_Values.NF, GT_Values.NF, Materials.DinitrogenTetroxide.getCells(1), 640); + GT_Values.RA.addMultiblockChemicalRecipe(new ItemStack[]{GT_Utility.getIntegratedCircuit(23)}, new FluidStack[]{Materials.Ammonia.getGas(8000), Materials.Oxygen.getGas(7000)}, new FluidStack[]{Materials.DinitrogenTetroxide.getGas(6000), Materials.Water.getFluid(9000)}, null, 480, 30); + GT_Values.RA.addMultiblockChemicalRecipe(new ItemStack[]{GT_Utility.getIntegratedCircuit(23)}, new FluidStack[]{Materials.Nitrogen.getGas(2000), Materials.Hydrogen.getGas(6000), Materials.Oxygen.getGas(7000)}, new FluidStack[]{Materials.DinitrogenTetroxide.getGas(6000), Materials.Water.getFluid(9000)}, null, 1100, 480); + + GT_Values.RA.addMixerRecipe(Materials.Dimethylhydrazine.getCells(1), GT_Values.NI, GT_Values.NI, GT_Values.NI, Materials.DinitrogenTetroxide.getGas(1000), new FluidStack(ItemList.sRocketFuel, 2000), Materials.Empty.getCells(1), 60, 16); + GT_Values.RA.addMixerRecipe(Materials.DinitrogenTetroxide.getCells(1), GT_Values.NI, GT_Values.NI, GT_Values.NI, Materials.Dimethylhydrazine.getFluid(1000), new FluidStack(ItemList.sRocketFuel, 2000), Materials.Empty.getCells(1), 60, 16); + GT_Values.RA.addMixerRecipe(Materials.Dimethylhydrazine.getCells(2), GT_Values.NI, GT_Values.NI, GT_Values.NI, Materials.Oxygen.getGas(1000), new FluidStack(ItemList.sRocketFuel, 3000), Materials.Empty.getCells(2), 60, 16); + GT_Values.RA.addMixerRecipe(Materials.Oxygen.getCells(1), GT_Values.NI, GT_Values.NI, GT_Values.NI, Materials.Dimethylhydrazine.getFluid(2000), new FluidStack(ItemList.sRocketFuel, 3000), Materials.Empty.getCells(1), 60, 16); + + + */ + + + + + + + + + + //Get Rocket Fuel + + //Find recipes using default values + + //Remove + + //Rebake map + + return true; + }; + @Override public void items() { Formaldehyde_Catalyst = ItemUtils.generateSpecialUseDusts("FormaldehydeCatalyst", "Formaldehyde Catalyst", "Fe16V1", Utils.rgbtoHexValue(25, 5, 25))[0]; @@ -441,9 +662,16 @@ public class RocketFuels extends ItemPackage { @Override public void fluids() { + + //Register default fluids + Diesel = MaterialUtils.getMaterial("Fuel", "Diesel").getFluid(1).getFluid(); + Oil_Heavy = MaterialUtils.getMaterial("OilHeavy", "Oil").getFluid(1).getFluid(); + + //Create Kerosene Kerosene = FluidUtils.generateFluidNonMolten("Kerosene", "Kerosene", 500, new short[]{150, 40, 150, 100}, null, null); - + CoalTar.Coal_Oil = Kerosene; + //RP! Focket Fuel RP1 = FluidUtils.generateFluidNonMolten("RP1Fuel", "RP-1 Rocket Fuel", 500, new short[]{210, 50, 50, 100}, null, null); diff --git a/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java index 842b8eecb2..a7fc4507e8 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java @@ -348,12 +348,30 @@ public class MaterialUtils { TextureSet o = (r != null && r.isPresent() && r.get() != null) ? r.get() : null; return o;*/ } + + + + public static Materials getMaterial(String aMaterialName, String aFallbackMaterialName) { + Materials g = getMaterial(aMaterialName); + if (g == null) { + g = getMaterial(aFallbackMaterialName); + } + if (g == null) { + Logger.INFO("Failed finding material '"+aMaterialName+"' & fallback '"+aFallbackMaterialName+"', returning _NULL."); + g = Materials._NULL; + } + return g; + } public static Materials getMaterial(String aMaterialName) { Materials m = gtPlusPlus.xmod.gregtech.common.StaticFields59.getMaterial(aMaterialName); if (m == null) { m = getMaterialByName(aMaterialName); } + if (m == null) { + Logger.INFO("Failed finding material '"+aMaterialName+"', returning _NULL."); + m = Materials._NULL; + } return m; } diff --git a/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java index cc71b910c6..774c8b6f13 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java @@ -8,6 +8,7 @@ import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.enums.Materials; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gtPlusPlus.GTplusplus; import gtPlusPlus.api.interfaces.RunnableWithInfo; import gtPlusPlus.api.objects.Logger; @@ -573,5 +574,13 @@ public static int mInvalidID = 1; } + public static boolean removeGtRecipe(GT_Recipe aRecipeToRemove, GT_Recipe_Map aRecipeMap) { + if (aRecipeMap.mRecipeList.contains(aRecipeToRemove)) { + return aRecipeMap.mRecipeList.remove(aRecipeToRemove); + } + return false; + } + + } diff --git a/src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java b/src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java index 58331c4300..64f1cfbe23 100644 --- a/src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java +++ b/src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java @@ -1,6 +1,8 @@ package gtPlusPlus.xmod.galacticraft.handler; import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.LinkedHashMap; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.block.Block; @@ -18,7 +20,7 @@ public class HandlerTooltip_GC { private static Block mBlock; private static Class oMainClass; private static Class oFuelLoaderClass; - private static String[] mFuelNames; + private static HashMap mFuelNames; @SubscribeEvent public void onItemTooltip(ItemTooltipEvent event) { @@ -30,8 +32,7 @@ public class HandlerTooltip_GC { if (GCBlocks != null) { oMainClass = GCBlocks; - Class GCFuelLoader = Class - .forName("micdoodle8.mods.galacticraft.core.blocks.BlockFuelLoader"); + Class GCFuelLoader = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.blocks.BlockFuelLoader"); if (GCFuelLoader != null) { oFuelLoaderClass = GCFuelLoader; @@ -49,24 +50,26 @@ public class HandlerTooltip_GC { } catch (Throwable t) { } } - if (mFuelNames == null || mFuelNames.length == 0) { - mFuelNames = new String[RocketFuels.mValidRocketFuels.size()]; - int slot = 0; - for (Fluid f : RocketFuels.mValidRocketFuels.values()) { - mFuelNames[slot++] = f.getLocalizedName(); + + if (mFuelNames == null || mFuelNames.isEmpty()) { + mFuelNames = new LinkedHashMap(); + for (int aMapKey : RocketFuels.mValidRocketFuels.keySet()) { + Fluid aFuel = RocketFuels.mValidRocketFuels.get(aMapKey); + if (aFuel != null) { + mFuelNames.put(aMapKey, aFuel.getLocalizedName()); + } } - } - if (mItemBlock != null) { + } + if (mItemBlock != null && !mFuelNames.isEmpty()) { Item aTempItem = event.itemStack.getItem(); Block aTempBlock = Block.getBlockFromItem(aTempItem); - if (aTempItem == mItemBlock || oFuelLoaderClass.isInstance(aTempBlock) - || event.itemStack.getUnlocalizedName().toLowerCase().contains("fuelloader")) { - int aTier = 0; - for (String s : mFuelNames) { - if (s != null) { - event.toolTip.add("Tier "+aTier+": "+s); + if (aTempItem == mItemBlock || oFuelLoaderClass.isInstance(aTempBlock) || event.itemStack.getUnlocalizedName().toLowerCase().contains("fuelloader")) { + for (int aMapKey : mFuelNames.keySet()) { + String aFuel = mFuelNames.get(aMapKey); + if (aFuel != null) { + event.toolTip.add("Tier "+(aMapKey+1)+": "+aFuel); } - } + } } } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java index a88d6a4832..15c6fa00f6 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java @@ -15,8 +15,9 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; - +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; import net.minecraftforge.fluids.FluidStack; @@ -144,7 +145,7 @@ public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_ @Override public boolean isOutputFacing(final byte aSide) { - return true; + return this.getBaseMetaTileEntity().getFrontFacing() == aSide; } @Override @@ -154,7 +155,7 @@ public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_ @Override public long maxEUOutput() { - return this.getBaseMetaTileEntity().isAllowedToWork() ? V[this.mTier] : 0; + return V[this.mTier]; } @Override @@ -164,22 +165,22 @@ public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_ @Override public boolean doesFillContainers() { - return this.getBaseMetaTileEntity().isAllowedToWork(); + return false; } @Override public boolean doesEmptyContainers() { - return this.getBaseMetaTileEntity().isAllowedToWork(); + return true; } @Override public boolean canTankBeFilled() { - return this.getBaseMetaTileEntity().isAllowedToWork(); + return true; } @Override public boolean canTankBeEmptied() { - return this.getBaseMetaTileEntity().isAllowedToWork(); + return false; } @Override @@ -199,6 +200,61 @@ public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_ @Override public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + + + //super.onPostTick(aBaseMetaTileEntity, aTick); + + /*if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && aTick % 10L == 0L) { + int tFuelValue; + if (this.mFluid == null) { + if (aBaseMetaTileEntity.getUniversalEnergyStored() < this.maxEUOutput() + this.getMinimumStoredEU()) { + this.mInventory[this.getStackDisplaySlot()] = null; + } else { + if (this.mInventory[this.getStackDisplaySlot()] == null) { + this.mInventory[this.getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); + } + + this.mInventory[this.getStackDisplaySlot()].setStackDisplayName("Generating: " + + (aBaseMetaTileEntity.getUniversalEnergyStored() - this.getMinimumStoredEU()) + " EU"); + } + } else { + tFuelValue = this.getFuelValue(this.mFluid); + int tConsumed = this.consumedFluidPerOperation(this.mFluid); + if (tFuelValue > 0 && tConsumed > 0 && this.mFluid.amount > tConsumed) { + long tFluidAmountToUse = Math.min((long) (this.mFluid.amount / tConsumed), + (this.maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / (long) tFuelValue); + if (tFluidAmountToUse > 0L && aBaseMetaTileEntity + .increaseStoredEnergyUnits(tFluidAmountToUse * (long) tFuelValue, true)) { + PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollution()); + this.mFluid.amount = (int) ((long) this.mFluid.amount - tFluidAmountToUse * (long) tConsumed); + } + } + } + + if (this.mInventory[this.getInputSlot()] != null + && aBaseMetaTileEntity.getUniversalEnergyStored() < this.maxEUOutput() * 20L + + this.getMinimumStoredEU() + && GT_Utility.getFluidForFilledItem(this.mInventory[this.getInputSlot()], true) == null) { + tFuelValue = this.getFuelValue(this.mInventory[this.getInputSlot()]); + if (tFuelValue > 0) { + ItemStack tEmptyContainer = this.getEmptyContainer(this.mInventory[this.getInputSlot()]); + if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), tEmptyContainer)) { + aBaseMetaTileEntity.increaseStoredEnergyUnits((long) tFuelValue, true); + aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); + PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollution()); + } + } + } + } + + if (aBaseMetaTileEntity.isServerSide()) { + aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity + .getUniversalEnergyStored() >= this.maxEUOutput() + this.getMinimumStoredEU()); + }*/ + + + + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && ((aTick % 10) == 0)) { if (this.mFluid == null) { if (aBaseMetaTileEntity.getUniversalEnergyStored() < (this.maxEUOutput() + this.getMinimumStoredEU())) { @@ -211,16 +267,14 @@ public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_ } } else { final int tFuelValue = this.getFuelValue(this.mFluid), tConsumed = this.consumedFluidPerOperation(this.mFluid); - if ((tFuelValue > 0) && (tConsumed > 0) && (this.mFluid.amount > tConsumed)) { + if ((tFuelValue > 0) && (tConsumed > 0) && (this.mFluid.amount >= tConsumed)) { final long tFluidAmountToUse = Math.min(this.mFluid.amount / tConsumed, (((this.maxEUOutput() * 20) + this.getMinimumStoredEU()) - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue); - if ((tFluidAmountToUse > 0) && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)){ - if (this.useFuel){ - this.mFluid.amount -= tFluidAmountToUse * tConsumed; - this.useFuel = false; - } - else { - this.useFuel = true; - } + if ((tFluidAmountToUse > 0) && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)){ + useFuel = Utils.invertBoolean(useFuel); + int aSafeFloor= (int) Math.max(((tFluidAmountToUse * tConsumed)/3), 1); + int toConsumeTrue = (int) (useFuel ? aSafeFloor : 0); + //Logger.INFO("True consumption: "+toConsumeTrue+" | Consuming this tick? "+useFuel); + this.mFluid.amount -= toConsumeTrue; PollutionUtils.addPollution(getBaseMetaTileEntity(), 10 * getPollution()); } } @@ -260,14 +314,25 @@ public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_ FluidStack tLiquid; final Collection tRecipeList = this.getRecipes().mRecipeList; if (tRecipeList != null) { + //Logger.INFO("Step A"); for (final GT_Recipe tFuel : tRecipeList) { - if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null) { + //Logger.INFO("Step B"); + if ((tLiquid = tFuel.mFluidInputs[0]) != null) { + //Logger.INFO("Step C"); if (aLiquid.isFluidEqual(tLiquid)) { - return (int) (((long) tFuel.mSpecialValue * this.getEfficiency() * this.consumedFluidPerOperation(tLiquid)) / 100); + //Logger.INFO("Found some fuel?"); + int aperOp = this.consumedFluidPerOperation(tLiquid); + int aConsume = (int) (((long) tFuel.mSpecialValue * this.getEfficiency() * aperOp) / 100); + //Logger.INFO("Fuel Value: "+tFuel.mSpecialValue); + //Logger.INFO("Efficiency: "+getEfficiency()); + //Logger.INFO("Consumed per op: "+aperOp); + //Logger.INFO("Consuming "+aConsume); + return aConsume; } } } } + //Logger.INFO("No Fuel Value | Valid? "+(aLiquid != null)); return 0; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java index 288501086b..1d81e44e1f 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java @@ -15,6 +15,7 @@ import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Recipe; import gregtech.api.util.Recipe_GT; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators.GregtechRocketFuelGeneratorBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; @@ -41,6 +42,7 @@ extends GregtechRocketFuelGeneratorBase { @Override public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + Logger.INFO("Valid Fuels: "+Recipe_GT.Gregtech_Recipe_Map.sRocketFuels.mRecipeList.size()); return new GregtechMetaTileEntityRocketFuelGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); } @@ -60,7 +62,10 @@ extends GregtechRocketFuelGeneratorBase { @Override public int getEfficiency() { - return ((40+((this.mTier) * 16))/4)+(this.mTier); + int eff = ((40+((this.mTier) * 16))/4)+(this.mTier); + + return eff; + } @Override @@ -69,6 +74,7 @@ extends GregtechRocketFuelGeneratorBase { if (ItemList.Fuel_Can_Plastic_Filled.isStackEqual(aStack, false, true)) { rValue = Math.max(rValue, GameRegistry.getFuelValue(aStack) * 3); } + Logger.INFO("Fuel Item is worth: "+rValue); return rValue; } -- cgit From 2ef253ff474723d136a607c293bee44e67f634aa Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Thu, 14 Mar 2019 05:00:44 +0000 Subject: - Removed recipe for crafting XP Convertor. $ More small fixes & general QoL improvements for the Biocomposite Collector & it's simpler counterpart. --- .../core/block/machine/Machine_PooCollector.java | 8 +-- .../handler/events/GeneralTooltipEventHandler.java | 23 +++++++ .../core/item/base/itemblock/ItemBlockMeta.java | 77 ++++++++++++++++++++-- .../gtPlusPlus/core/recipe/RECIPES_General.java | 4 +- .../gtPlusPlus/core/recipe/RECIPES_Machines.java | 2 +- src/Java/gtPlusPlus/core/recipe/common/CI.java | 10 ++- .../machines/TileEntityAdvPooCollector.java | 6 +- .../machines/TileEntityBaseFluidCollector.java | 14 ++-- .../machines/TileEntityPooCollector.java | 10 --- 9 files changed, 123 insertions(+), 31 deletions(-) (limited to 'src/Java/gtPlusPlus/core/handler') diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_PooCollector.java b/src/Java/gtPlusPlus/core/block/machine/Machine_PooCollector.java index 86beb71719..23fdfe9733 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_PooCollector.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_PooCollector.java @@ -12,7 +12,6 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.tileentities.machines.TileEntityAdvPooCollector; import gtPlusPlus.core.tileentities.machines.TileEntityBaseFluidCollector; import gtPlusPlus.core.tileentities.machines.TileEntityPooCollector; -import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; import net.minecraft.block.BlockContainer; @@ -169,12 +168,7 @@ public class Machine_PooCollector extends BlockContainer { @Override public int getRenderColor(int aMeta) { - if (aMeta <= 7) { - return super.getRenderColor(aMeta); - } - else { - return Utils.rgbtoHexValue(128, 45, 45); - } + return super.getRenderColor(aMeta); } @Override diff --git a/src/Java/gtPlusPlus/core/handler/events/GeneralTooltipEventHandler.java b/src/Java/gtPlusPlus/core/handler/events/GeneralTooltipEventHandler.java index 6d09f65f3f..3acc3b6bcf 100644 --- a/src/Java/gtPlusPlus/core/handler/events/GeneralTooltipEventHandler.java +++ b/src/Java/gtPlusPlus/core/handler/events/GeneralTooltipEventHandler.java @@ -3,12 +3,14 @@ package gtPlusPlus.core.handler.events; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.block.Block; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import gregtech.api.enums.ItemList; import gtPlusPlus.GTplusplus; import gtPlusPlus.GTplusplus.INIT_PHASE; +import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.handler.events.BlockEventHandler; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.ItemUtils; @@ -28,6 +30,9 @@ public class GeneralTooltipEventHandler { if (GTplusplus.CURRENT_LOAD_PHASE != INIT_PHASE.STARTED) { return; } + if (event.itemStack == null) { + return; + } if (CORE.ConfigSwitches.chanceToDropFluoriteOre > 0) { if (BlockEventHandler.blockLimestone != null && !BlockEventHandler.blockLimestone.isEmpty()) { @@ -50,6 +55,24 @@ public class GeneralTooltipEventHandler { } } + //Material Collector Tooltips + if (event.itemStack.getItem() == Item.getItemFromBlock(ModBlocks.blockPooCollector)) { + //Normal + if (event.itemStack.getItemDamage() == 0) { + event.toolTip.add("Used to collect animal waste"); + event.toolTip.add("Collects in a 5x4x5 area starting at Y+1"); + event.toolTip.add("Use Hoppers/Pipes to empty"); + } + //Advanced + else { + event.toolTip.add("Used to collect waste (Works on more than animals)"); + event.toolTip.add("Significantly faster than the simple version"); + event.toolTip.add("Collects in a 5x4x5 area starting at Y+1"); + event.toolTip.add("Use Hoppers/Pipes to empty"); + } + } + + if (CORE.ConfigSwitches.enableAnimatedTurbines) { boolean shift = false; diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockMeta.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockMeta.java index d55ee6b707..c271ab39d0 100644 --- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockMeta.java +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockMeta.java @@ -1,8 +1,14 @@ package gtPlusPlus.core.item.base.itemblock; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.api.interfaces.ITileTooltip; +import gtPlusPlus.api.objects.data.AutoMap; import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlockWithMetadata; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; @@ -10,13 +16,36 @@ import net.minecraft.util.IIcon; public class ItemBlockMeta extends ItemBlockWithMetadata { private final Block mBlock; + private HashMap> aTooltips = new LinkedHashMap>(); - public ItemBlockMeta(final Block p_i45326_1_) + public ItemBlockMeta(final Block aBlock) { - super(p_i45326_1_, p_i45326_1_); - this.mBlock = p_i45326_1_; + super(aBlock, aBlock); + this.mBlock = aBlock; this.setMaxDamage(15); this.setHasSubtypes(true); + if (aBlock instanceof ITileTooltip) { + ITileTooltip aTooltip = (ITileTooltip) aBlock; + //aTooltips.put(aTooltip.getTooltipID(), aTooltip.getTooltipMap()); + } + } + + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + Block aThis = Block.getBlockFromItem(stack.getItem()); + if (aThis != null) { + if (!aTooltips.isEmpty()) { + AutoMap h = aTooltips.get(stack.getItemDamage()); + if (h != null && !h.isEmpty()) { + for (String s : h) { + list.add(s); + } + } + } + } + super.addInformation(stack, aPlayer, list, bool); } /** @@ -42,4 +71,44 @@ public class ItemBlockMeta extends ItemBlockWithMetadata public String getUnlocalizedName(final ItemStack stack) { return this.getUnlocalizedName() + "." + stack.getItemDamage(); } + + @Override + public boolean isDamageable() { + return false; + } + + @Override + public int getItemEnchantability() { + return 0; + } + + @Override + public boolean getIsRepairable(ItemStack p_82789_1_, ItemStack p_82789_2_) { + return false; + } + + @Override + public boolean isBookEnchantable(ItemStack stack, ItemStack book) { + return false; + } + + @Override + public int getDisplayDamage(ItemStack stack) { + return 0; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return false; + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 0; + } + + @Override + public int getItemEnchantability(ItemStack stack) { + return 0; + } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java index 1c0f3f8a28..6ed5c71bcc 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java @@ -235,14 +235,14 @@ public class RECIPES_General { Logger.INFO("Added a recipe for Wither Cages."); } - Logger.RECIPE("[Inspection] Xp Converter"); + /*Logger.RECIPE("[Inspection] Xp Converter"); if (RecipeUtils.recipeBuilder( getSimpleStack(Items.experience_bottle), ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 2, 1), getSimpleStack(Items.experience_bottle), ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 5, 1), getSimpleStack(Items.nether_star), ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 5, 1), getSimpleStack(Items.experience_bottle), ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 2, 1), getSimpleStack(Items.experience_bottle), ItemUtils.getSimpleStack(ModBlocks.blockXpConverter, 1))){ Logger.INFO("Added a recipe for XP Converter."); - } + }*/ diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java index a8b1d01115..092214a714 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -381,7 +381,7 @@ public class RECIPES_Machines { CI.getTieredComponent(OrePrefixes.screw, 6, GTNH ? 32 : 16) }, CI.getAlternativeTieredFluid(5, 144 * 9), - ItemUtils.getSimpleStack(ModBlocks.blockPooCollector, 1, 8), + ItemUtils.getSimpleStack(ModBlocks.blockPooCollector, 8, 1), 20 * 60 * 5, 500); diff --git a/src/Java/gtPlusPlus/core/recipe/common/CI.java b/src/Java/gtPlusPlus/core/recipe/common/CI.java index 35de9263c3..ba592bcb65 100644 --- a/src/Java/gtPlusPlus/core/recipe/common/CI.java +++ b/src/Java/gtPlusPlus/core/recipe/common/CI.java @@ -436,8 +436,11 @@ public class CI { else if (tier == 8){ return machineHull_UV; } + else if (tier == 9){ + return machineHull_MAX; + } else { - return machineHull_MAX; + return GregtechItemList.Casing_Multi_Use.get(1); } } @@ -469,8 +472,11 @@ public class CI { else if (tier == 8){ return machineCasing_UV; } + else if (tier == 9){ + return machineCasing_MAX; + } else { - return machineCasing_MAX; + return GregtechItemList.Casing_Multi_Use.get(1); } } diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java index 4f40dcecfa..bdf899e22d 100644 --- a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java +++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java @@ -120,7 +120,7 @@ public class TileEntityAdvPooCollector extends TileEntityBaseFluidCollector { } } aPooAmount = Math.max(Math.min(this.tank.getCapacity()-this.tank.getFluidAmount(), aPooAmount), 1); - return aPooAmount * 4; + return aPooAmount * MathUtils.getRandomFromArray(new int[] {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 4}); } else { return 0; @@ -148,6 +148,10 @@ public class TileEntityAdvPooCollector extends TileEntityBaseFluidCollector { return aItem; } + public int getBaseTickRate() { + return MathUtils.randInt(50, 200); + } + diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityBaseFluidCollector.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityBaseFluidCollector.java index 0435c0a591..2438d57355 100644 --- a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityBaseFluidCollector.java +++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityBaseFluidCollector.java @@ -2,6 +2,7 @@ package gtPlusPlus.core.tileentities.machines; import java.util.List; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.minecraft.BTF_FluidTank; import gtPlusPlus.api.objects.minecraft.BlockPos; @@ -10,7 +11,6 @@ import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -141,6 +141,10 @@ public abstract class TileEntityBaseFluidCollector extends TileEntityBase implem readFromNBT(tag); } + public int getBaseTickRate() { + return MathUtils.randInt(200, 300); + } + public abstract AutoMap aThingsToLookFor(); public abstract void onPreLogicTick(); @@ -150,7 +154,7 @@ public abstract class TileEntityBaseFluidCollector extends TileEntityBase implem if (this.worldObj == null || this.worldObj.isRemote) { return; } - if (internalTickCounter % MathUtils.randInt(200, 300) == 0) { + if (internalTickCounter % getBaseTickRate() == 0) { if (internalBlockLocation == null) { internalBlockLocation = new BlockPos(this); } @@ -173,6 +177,7 @@ public abstract class TileEntityBaseFluidCollector extends TileEntityBase implem AxisAlignedBB box = AxisAlignedBB.getBoundingBox(startX, startY, startZ, endX, endY, endZ); if (box != null) { for (Class c2 : aThingsToLookFor()) { + Logger.INFO("Looking for "+c2.getName()); tickEntityType(w, box, c2); } } else { @@ -190,9 +195,10 @@ public abstract class TileEntityBaseFluidCollector extends TileEntityBase implem @SuppressWarnings("unchecked") public final void tickEntityType(World w, AxisAlignedBB box, Class aClassToFind) { - List entities = w.getEntitiesWithinAABB(aClassToFind, box); + List entities = w.getEntitiesWithinAABB(aClassToFind, box); if (entities != null && !entities.isEmpty()) { - onPostTick(entities); + Logger.INFO("Found some "+aClassToFind.getName()); + interactWithEntities(entities); } } diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java index b14e7d80b1..3667dd6a29 100644 --- a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java +++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java @@ -11,9 +11,7 @@ import net.minecraft.entity.passive.EntityCow; import net.minecraft.entity.passive.EntityHorse; import net.minecraft.entity.passive.EntityMooshroom; import net.minecraft.entity.passive.EntitySheep; -import net.minecraft.entity.passive.EntityVillager; import net.minecraft.entity.passive.IAnimals; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; @@ -78,8 +76,6 @@ public class TileEntityPooCollector extends TileEntityBaseFluidCollector { if (aEntityToDrain.isEmpty()) { aEntityToDrain.add(EntityAnimal.class); aEntityToDrain.add(IAnimals.class); - aEntityToDrain.add(EntityVillager.class); - aEntityToDrain.add(EntityPlayer.class); } return aEntityToDrain; } @@ -109,12 +105,6 @@ public class TileEntityPooCollector extends TileEntityBaseFluidCollector { if (aPooMaker instanceof EntityAnimal || aPooMaker instanceof IAnimals) { aPooAmount = MathUtils.randInt(5, 35); } - else if (aPooMaker instanceof EntityVillager) { - aPooAmount = MathUtils.randInt(25, 30); - } - else if (aPooMaker instanceof EntityPlayer) { - aPooAmount = MathUtils.randInt(1, 3); - } else { aPooAmount = MathUtils.randInt(1, 10); } -- cgit From df8c981bd3dd0ba8c6bb3e538920f34e4e80fc76 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Thu, 14 Mar 2019 15:21:13 +0000 Subject: % Made Control Cores Optional, they will still lock to the Core's tier if present. % Tweaked Control Core recipes. % Updated CircleCI config.yml. $ Fixed mild issue where Control Core Modules could be shared between multiblocks. --- .circleci/config.yml | 26 ++++++++++++++------- src/Java/gtPlusPlus/core/config/ConfigHandler.java | 4 +++- .../core/handler/AchievementHandler.java | 3 ++- src/Java/gtPlusPlus/core/lib/CORE.java | 2 +- .../gtPlusPlus/core/recipe/RECIPES_Machines.java | 13 +++++------ .../GT_MetaTileEntity_Hatch_ControlCore.java | 24 +++++++++++++++++++ .../base/GregtechMeta_MultiBlockBase.java | 27 ++++++++++++++-------- 7 files changed, 71 insertions(+), 28 deletions(-) (limited to 'src/Java/gtPlusPlus/core/handler') diff --git a/.circleci/config.yml b/.circleci/config.yml index ab0869d286..14c330e651 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -12,7 +12,7 @@ jobs: steps: - - checkout + # - checkout - run: name: Run build @@ -21,23 +21,33 @@ jobs: - run: sudo chmod +x gradlew - #https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.7.10-10.13.4.1614-1.7.10/forge-1.7.10-10.13.4.1614-1.7.10-src.zip - - restore_cache: - key: jars-{{ checksum "build.gradle" }}-{{ checksum "build.gradle" }} - + key: jars-{{ checksum "GTPP_BuildRepo.sh" }}-{{ checksum "GTPP_BuildRepo.sh" }} + + # Build Forge and MCP - run: name: Download Build Script - command: wget https://alkcorp.overminddl1.com/GTPP_BuildScript.sh + command: wget https://alkcorp.overminddl1.com/GTPP_BuildRepo.sh - run: name: Run Build Script - command: sh GTPP_BuildScript.sh ${CIRCLE_BUILD_NUM} "${CIRCLE_BRANCH}" "${CIRCLE_USERNAME}" "${CIRCLE_SHA1}" "${CIRCLE_PROJECT_REPONAME}" "${CIRCLE_PROJECT_USERNAME}" "https://github.com/draknyte1/GTplusplus/archive/master.zip" + command: sh GTPP_BuildRepo.sh + # Cache All Libs - save_cache: paths: - ~/.gradle - key: jars-{{ checksum "build.gradle" }}-{{ checksum "build.gradle" }} + - ~/home/circleci/repo + key: jars-{{ checksum "GTPP_BuildRepo.sh" }}-{{ checksum "GTPP_BuildRepo.sh" }} + + # Build Mod + - run: + name: Download Build Script + command: wget https://alkcorp.overminddl1.com/GTPP_BuildScript.sh + + - run: + name: Run Build Script + command: sh GTPP_BuildScript.sh ${CIRCLE_BUILD_NUM} "${CIRCLE_BRANCH}" "${CIRCLE_USERNAME}" "${CIRCLE_SHA1}" "${CIRCLE_PROJECT_REPONAME}" "${CIRCLE_PROJECT_USERNAME}" "https://github.com/draknyte1/GTplusplus/archive/master.zip" - store_artifacts: # for display in Artifacts: https://circleci.com/docs/2.0/artifacts/ path: build/libs diff --git a/src/Java/gtPlusPlus/core/config/ConfigHandler.java b/src/Java/gtPlusPlus/core/config/ConfigHandler.java index 2fbd3f60c2..64c8b74b33 100644 --- a/src/Java/gtPlusPlus/core/config/ConfigHandler.java +++ b/src/Java/gtPlusPlus/core/config/ConfigHandler.java @@ -46,7 +46,9 @@ public class ConfigHandler { enableAlternativeDivisionSigilRecipe = config.getBoolean("enableAlternativeDivisionSigilRecipe", "machines", false, "Utilizes Neutronium instead."); boilerSteamPerSecond = config.getInt("boilerSteamPerSecond", "machines", 750, 0, 10000, "Sets the steam per second value in LV,MV,HV boilers (respectively 1x,2x,3x this number for the tiers)"); - requireControlCores = config.getBoolean("requireControlCores", "machines", true, "Multiblocks Require Control Cores"); + + //requireControlCores + boolean temp = config.getBoolean("requireControlCores", "machines", true, "Multiblocks Require Control Cores"); diff --git a/src/Java/gtPlusPlus/core/handler/AchievementHandler.java b/src/Java/gtPlusPlus/core/handler/AchievementHandler.java index faca4449ce..482ca66f09 100644 --- a/src/Java/gtPlusPlus/core/handler/AchievementHandler.java +++ b/src/Java/gtPlusPlus/core/handler/AchievementHandler.java @@ -18,6 +18,7 @@ import gtPlusPlus.core.material.ALLOY; import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.stats.Achievement; @@ -46,7 +47,7 @@ public class AchievementHandler { //Useful Info boolean cores = CORE.ConfigSwitches.requireControlCores; - if (cores) { + if (cores || GregtechMeta_MultiBlockBase.DEBUG_DISABLE_CORES_TEMPORARILY) { this.registerAchievement("hatch.control", -2, -2, GregtechItemList.Hatch_Control_Core.get(1), aBaseAchievementName, false); } this.registerAchievement("hatch.dynamo.buffered", 2, -2, GregtechItemList.Hatch_Buffer_Dynamo_IV.get(1), aBaseAchievementName, false); diff --git a/src/Java/gtPlusPlus/core/lib/CORE.java b/src/Java/gtPlusPlus/core/lib/CORE.java index 17b210f176..632378987a 100644 --- a/src/Java/gtPlusPlus/core/lib/CORE.java +++ b/src/Java/gtPlusPlus/core/lib/CORE.java @@ -202,7 +202,7 @@ public class CORE { public static boolean disableIC2Recipes = false; public static boolean enableAlternativeDivisionSigilRecipe = false; public static int boilerSteamPerSecond = 750; - public static boolean requireControlCores = true; + public static final boolean requireControlCores = false; //Feature Related public static boolean enableCustomCapes = false; diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java index 092214a714..54d9994edc 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -1676,11 +1676,10 @@ public class RECIPES_Machines { for (int i = 0; i < 10; i++) { - boolean aDub = i >= 5; - + boolean aDub = false; ItemStack aPlateStack = aMat_A[i].getPlateDouble((GTNH ? 16 : 8) * (aDub ? 2 : 1)); - ItemStack aGearStack = aMat_B[i].getGear(GTNH ? 8 : 4 * (aDub ? 2 : 1)); - ItemStack aRodStack = aMat_A[i].getLongRod(GTNH ? 32 : 16 * (aDub ? 2 : 1)); + ItemStack aGearStack = aMat_B[i].getGear(GTNH ? 4 : 2 * (aDub ? 2 : 1)); + ItemStack aRodStack = aMat_A[i].getLongRod(GTNH ? 16 : 8 * (aDub ? 2 : 1)); ItemStack aScrewStack = aMat_B[i].getScrew(32 * (aDub ? 2 : 1)); if (!ItemUtils.checkForInvalidItems(aPlateStack)) { @@ -1704,14 +1703,14 @@ public class RECIPES_Machines { CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { - aInputPrevTier[i], + CI.getEnergyCore(i, 4), aPlateStack, aGearStack, aRodStack, aScrewStack, - ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName((int) (4+Math.ceil((double) i / (double) 2))), GTNH ? (i * 2 * 2 * 2) : (i * 2 * 2)) + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName((int) (4+Math.ceil((double) i / (double) 2))), GTNH ? (i * 2 * 2) : (i * 2)) }, - aMat_A[i].getFluid(144 * 4 * (i+1)), //Input Fluid + CI.getTieredFluid(i, 144 * 4 * (i+1)), //Input Fluid aOutput[i], 60 * 20 * 1 * (i+1), MaterialUtils.getVoltageForTier(i)); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ControlCore.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ControlCore.java index fe0ffd5dc8..7a532807c8 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ControlCore.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ControlCore.java @@ -8,16 +8,20 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.item.general.ItemControlCore; import gtPlusPlus.xmod.gregtech.common.StaticFields59; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; public class GT_MetaTileEntity_Hatch_ControlCore extends GT_MetaTileEntity_Hatch { public GT_Recipe_Map mRecipeMap = null; + + public BlockPos mControllerLocation; public GT_MetaTileEntity_Hatch_ControlCore(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, getSlots(aTier), "Core determines maximum tier machine will operate at"); @@ -113,4 +117,24 @@ public class GT_MetaTileEntity_Hatch_ControlCore extends GT_MetaTileEntity_Hatch public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { return aSide == getBaseMetaTileEntity().getFrontFacing() && (aStack != null && aStack.getItem() instanceof ItemControlCore); } + + public boolean setOwner(TileEntity aTileEntity) { + if (mControllerLocation != null) { + return false; + } + else { + mControllerLocation = new BlockPos(aTileEntity); + return true; + } + } + + public boolean setOwner(IGregTechTileEntity aTileEntity) { + if (mControllerLocation != null) { + return false; + } + else { + mControllerLocation = new BlockPos(aTileEntity); + return true; + } + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index d011043a57..873c93aae1 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -71,7 +71,7 @@ extends GT_MetaTileEntity_MultiBlockBase { - private static final boolean DEBUG_DISABLE_CORES_TEMPORARILY = true; + public static final boolean DEBUG_DISABLE_CORES_TEMPORARILY = true; static { @@ -203,7 +203,7 @@ GT_MetaTileEntity_MultiBlockBase { } } - int tTier = requireControlCores ? this.getControlCoreTier() : -1; + int tTier = this.getControlCoreTier(); mInfo.add(getMachineTooltip()); @@ -554,8 +554,8 @@ GT_MetaTileEntity_MultiBlockBase { //Control Core to control the Multiblocks behaviour. int aControlCoreTier = getControlCoreTier(); - - //If no core, return false; + + //If no core, return false; if (aControlCoreTier == 0 && requireControlCores) { log("No control core found."); return false; @@ -640,7 +640,7 @@ GT_MetaTileEntity_MultiBlockBase { //Only Overclock as high as the control circuit. byte tTierOld = tTier; - tTier = requireControlCores ? (byte) aControlCoreTier : tTierOld; + tTier = getControlCoreTier() > 0 ? (byte) aControlCoreTier : tTierOld; // Overclock if (this.mEUt <= 16) { @@ -954,10 +954,10 @@ GT_MetaTileEntity_MultiBlockBase { public int getControlCoreTier() { //Always return best tier if config is off. - boolean aCoresConfig = gtPlusPlus.core.lib.CORE.ConfigSwitches.requireControlCores; + /*boolean aCoresConfig = gtPlusPlus.core.lib.CORE.ConfigSwitches.requireControlCores; if (!aCoresConfig) { return 10; - } + }*/ if (mControlCoreBus.isEmpty()) { log("No Control Core Modules Found."); @@ -998,9 +998,16 @@ GT_MetaTileEntity_MultiBlockBase { log("Tried to add a secondary control core module."); return false; } - - log("Adding control core module."); - return addToMachineListInternal(mControlCoreBus, aMetaTileEntity, aBaseCasingIndex); + + GT_MetaTileEntity_Hatch_ControlCore Module = (GT_MetaTileEntity_Hatch_ControlCore) aMetaTileEntity; + + if (Module != null) { + if (Module.setOwner(aTileEntity)) { + log("Adding control core module."); + return addToMachineListInternal(mControlCoreBus, aMetaTileEntity, aBaseCasingIndex); + } + } + return false; } @Override -- cgit From 0cb924d25dd80c22d000898fb27ab3ed0e0f80fb Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Thu, 14 Mar 2019 18:16:17 +0000 Subject: + Added Bombs. % Made RAW collectors produce 10x less. $ Fixed tooltips on RAW collectors. $ Fixed a bug regarding STARTUP_PHASE. --- src/Java/gtPlusPlus/GTplusplus.java | 2 +- .../core/entity/InternalEntityRegistry.java | 3 + .../entity/projectile/EntityThrowableBomb.java | 115 +++++++++++++++++++ .../handler/events/GeneralTooltipEventHandler.java | 11 +- src/Java/gtPlusPlus/core/item/ModItems.java | 16 +++ .../core/item/base/itemblock/ItemBlockMeta.java | 2 +- .../core/item/general/ItemControlCore.java | 22 ++-- .../item/general/throwables/ItemThrowableBomb.java | 123 +++++++++++++++++++++ .../gtPlusPlus/core/recipe/RECIPES_GREGTECH.java | 70 ++++++++++++ .../machines/TileEntityAdvPooCollector.java | 3 +- .../machines/TileEntityBaseFluidCollector.java | 2 - .../machines/TileEntityPooCollector.java | 4 +- .../xmod/gregtech/api/enums/GregtechItemList.java | 7 +- .../common/items/MetaGeneratedGregtechItems.java | 14 +++ .../textures/items/MU-metaitem.01/111.png | Bin 0 -> 345 bytes .../textures/items/MU-metaitem.01/112.png | Bin 0 -> 341 bytes .../textures/items/MU-metaitem.01/113.png | Bin 0 -> 337 bytes .../textures/items/MU-metaitem.01/114.png | Bin 0 -> 396 bytes .../textures/items/MU-metaitem.01/115.png | Bin 0 -> 428 bytes 19 files changed, 370 insertions(+), 24 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/entity/projectile/EntityThrowableBomb.java create mode 100644 src/Java/gtPlusPlus/core/item/general/throwables/ItemThrowableBomb.java create mode 100644 src/resources/assets/miscutils/textures/items/MU-metaitem.01/111.png create mode 100644 src/resources/assets/miscutils/textures/items/MU-metaitem.01/112.png create mode 100644 src/resources/assets/miscutils/textures/items/MU-metaitem.01/113.png create mode 100644 src/resources/assets/miscutils/textures/items/MU-metaitem.01/114.png create mode 100644 src/resources/assets/miscutils/textures/items/MU-metaitem.01/115.png (limited to 'src/Java/gtPlusPlus/core/handler') diff --git a/src/Java/gtPlusPlus/GTplusplus.java b/src/Java/gtPlusPlus/GTplusplus.java index 5c3d5fb801..e10369abe3 100644 --- a/src/Java/gtPlusPlus/GTplusplus.java +++ b/src/Java/gtPlusPlus/GTplusplus.java @@ -230,6 +230,7 @@ public class GTplusplus implements ActionListener { if (LoadedMods.Thaumcraft) { event.registerServerCommand(new CommandDumpAspects()); } + INIT_PHASE.STARTED.setPhaseActive(true); } @Mod.EventHandler @@ -257,7 +258,6 @@ public class GTplusplus implements ActionListener { */ @Mod.EventHandler public void onLoadComplete(FMLLoadCompleteEvent event) { - INIT_PHASE.STARTED.setPhaseActive(true); proxy.onLoadComplete(event); generateGregtechRecipeMaps(); } diff --git a/src/Java/gtPlusPlus/core/entity/InternalEntityRegistry.java b/src/Java/gtPlusPlus/core/entity/InternalEntityRegistry.java index 36f5b86184..e5c779adcf 100644 --- a/src/Java/gtPlusPlus/core/entity/InternalEntityRegistry.java +++ b/src/Java/gtPlusPlus/core/entity/InternalEntityRegistry.java @@ -14,6 +14,7 @@ import gtPlusPlus.core.entity.monster.EntitySickBlaze; import gtPlusPlus.core.entity.monster.EntityStaballoyConstruct; import gtPlusPlus.core.entity.projectile.EntityHydrofluoricAcidPotion; import gtPlusPlus.core.entity.projectile.EntitySulfuricAcidPotion; +import gtPlusPlus.core.entity.projectile.EntityThrowableBomb; import gtPlusPlus.core.entity.projectile.EntityToxinballSmall; import gtPlusPlus.core.util.Utils; @@ -51,6 +52,8 @@ public class InternalEntityRegistry { //EntityRegistry.registerGlobalEntityID(EntityTeslaTowerLightning.class, "plasmaBolt", EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(255, 0, 0), Utils.rgbtoHexValue(125, 125, 125)); EntityRegistry.registerModEntity(EntityTeslaTowerLightning.class, "plasmaBolt", mEntityID++, GTplusplus.instance, 64, 5, true); + EntityRegistry.registerModEntity(EntityThrowableBomb.class, "EntityThrowableBomb", mEntityID++, GTplusplus.instance, 64, 10, true); + /** * Globals, which generate spawn eggs. (Currently required for Giant chicken spawning) */ diff --git a/src/Java/gtPlusPlus/core/entity/projectile/EntityThrowableBomb.java b/src/Java/gtPlusPlus/core/entity/projectile/EntityThrowableBomb.java new file mode 100644 index 0000000000..9e72daf687 --- /dev/null +++ b/src/Java/gtPlusPlus/core/entity/projectile/EntityThrowableBomb.java @@ -0,0 +1,115 @@ +package gtPlusPlus.core.entity.projectile; + +import net.minecraft.block.Block; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.projectile.EntityThrowable; +import net.minecraft.init.Blocks; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +import gregtech.api.util.GT_Utility; + +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.EntityUtils; + +public class EntityThrowableBomb extends EntityThrowable { + + public EntityThrowableBomb(World world) { + super(world); + } + + public EntityThrowableBomb(World world, EntityLivingBase entity) { + super(world, entity); + } + + public EntityThrowableBomb(World world, double posX, double posY, double posZ) { + super(world, posX, posY, posZ); + } + + /** + * Called when this EntityThrowable hits a block or entity. + */ + @Override + protected void onImpact(MovingObjectPosition object) { + int xBlock = object.blockX; + int yBlock = object.blockY; + int zBlock = object.blockZ; + if (object.entityHit != null) { + byte b0 = 6; + if (!GT_Utility.isWearingFullRadioHazmat((EntityLivingBase) object.entityHit)){ + object.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), b0); + EntityUtils.setEntityOnFire(object.entityHit, 10); + object.entityHit.fireResistance = 0; + ravage(EntityUtils.findBlockPosUnderEntity(object.entityHit)); + } + } + if (object.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK){ + ravage(new BlockPos(xBlock, yBlock, zBlock)); + } + + String mParticleType = "reddust"; + int e=0; + for (int i = 0; i < 24; ++i) { + if ((e = MathUtils.randInt(0, 5)) <= 1){ + if (e==0) + mParticleType = "largesmoke"; + if (e==1) + mParticleType = "flame"; + } + this.worldObj.spawnParticle(mParticleType, this.posX+MathUtils.randDouble(-2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); + } + + if (!this.worldObj.isRemote) { + this.setDead(); + } + } + + private boolean ravage(BlockPos blockpos){ + + int radius = 1; + + for (int i=(blockpos.xPos-radius);i<(blockpos.xPos+radius);i++){ + for (int j=(blockpos.yPos-radius);j<(blockpos.yPos+radius);j++){ + for (int h=(blockpos.zPos-radius);h<(blockpos.zPos+radius);h++){ + + int mChance = MathUtils.randInt(1, 10); + if (mChance <= 3){ + Block mBlockhit = worldObj.getBlock(i, j, h); + this.worldObj.spawnParticle("flame", this.posX+MathUtils.randDouble(-2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); + this.worldObj.spawnParticle("largesmoke", this.posX+MathUtils.randDouble(2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); + + //GT_Pollution.addPollution(worldObj.getChunkFromBlockCoords(blockpos.xPos, blockpos.zPos), mPol); + this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 0.01f, true); + if (mBlockhit == Blocks.grass || mBlockhit == Blocks.mycelium){ + worldObj.setBlock(i, j+1, h, Blocks.fire); + worldObj.setBlock(i, j, h, Blocks.dirt); + } + else if (mBlockhit == Blocks.leaves || mBlockhit == Blocks.leaves2){ + worldObj.setBlock(i, j, h, Blocks.fire); + } + else if (mBlockhit == Blocks.tallgrass){ + worldObj.setBlock(i, j, h, Blocks.fire); + if (worldObj.getBlock(i, j-1, h) == Blocks.grass){ + worldObj.setBlock(i, j-1, h, Blocks.dirt); + } + } + else if (mBlockhit == Blocks.carrots || mBlockhit == Blocks.melon_block || mBlockhit == Blocks.pumpkin || mBlockhit == Blocks.potatoes){ + worldObj.setBlock(i, j+1, h, Blocks.fire); + worldObj.setBlock(i, j, h, Blocks.dirt); + } + else if (mBlockhit == Blocks.air){ + worldObj.setBlock(i, j, h, Blocks.fire); + } + } + } + } + } + + + return true; + } + + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/handler/events/GeneralTooltipEventHandler.java b/src/Java/gtPlusPlus/core/handler/events/GeneralTooltipEventHandler.java index 3acc3b6bcf..ef91647c1a 100644 --- a/src/Java/gtPlusPlus/core/handler/events/GeneralTooltipEventHandler.java +++ b/src/Java/gtPlusPlus/core/handler/events/GeneralTooltipEventHandler.java @@ -8,8 +8,10 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import gregtech.api.enums.ItemList; +import gregtech.api.util.GT_Utility; import gtPlusPlus.GTplusplus; import gtPlusPlus.GTplusplus.INIT_PHASE; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.handler.events.BlockEventHandler; import gtPlusPlus.core.lib.CORE; @@ -27,13 +29,12 @@ public class GeneralTooltipEventHandler { public void onItemTooltip(ItemTooltipEvent event){ - if (GTplusplus.CURRENT_LOAD_PHASE != INIT_PHASE.STARTED) { + if (GTplusplus.CURRENT_LOAD_PHASE != INIT_PHASE.STARTED && GTplusplus.CURRENT_LOAD_PHASE != INIT_PHASE.SERVER_START) { return; } if (event.itemStack == null) { return; } - if (CORE.ConfigSwitches.chanceToDropFluoriteOre > 0) { if (BlockEventHandler.blockLimestone != null && !BlockEventHandler.blockLimestone.isEmpty()) { for (ItemStack h : BlockEventHandler.blockLimestone) { @@ -55,13 +56,14 @@ public class GeneralTooltipEventHandler { } } - //Material Collector Tooltips - if (event.itemStack.getItem() == Item.getItemFromBlock(ModBlocks.blockPooCollector)) { + //Material Collector Tooltips + if (ModBlocks.blockPooCollector != null && Block.getBlockFromItem(event.itemStack.getItem()) == ModBlocks.blockPooCollector) { //Normal if (event.itemStack.getItemDamage() == 0) { event.toolTip.add("Used to collect animal waste"); event.toolTip.add("Collects in a 5x4x5 area starting at Y+1"); event.toolTip.add("Use Hoppers/Pipes to empty"); + event.toolTip.add(EnumChatFormatting.GOLD+"Capacity: "+EnumChatFormatting.AQUA+"8000L"); } //Advanced else { @@ -69,6 +71,7 @@ public class GeneralTooltipEventHandler { event.toolTip.add("Significantly faster than the simple version"); event.toolTip.add("Collects in a 5x4x5 area starting at Y+1"); event.toolTip.add("Use Hoppers/Pipes to empty"); + event.toolTip.add(EnumChatFormatting.GOLD+"Capacity: "+EnumChatFormatting.AQUA+"128000L"); } } diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index ed1df1f333..bb2ab8ae47 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -61,6 +61,7 @@ import gtPlusPlus.core.item.general.chassis.ItemDehydratorCoil; import gtPlusPlus.core.item.general.chassis.ItemDehydratorCoilWire; import gtPlusPlus.core.item.general.throwables.ItemHydrofluoricAcidPotion; import gtPlusPlus.core.item.general.throwables.ItemSulfuricAcidPotion; +import gtPlusPlus.core.item.general.throwables.ItemThrowableBomb; import gtPlusPlus.core.item.init.ItemsFoods; import gtPlusPlus.core.item.materials.DustDecayable; import gtPlusPlus.core.item.tool.misc.DebugScanner; @@ -338,6 +339,11 @@ public final class ModItems { public static ItemDummyResearch itemDummyResearch; + public static CoreItem itemBombCasing; + public static CoreItem itemBombUnf; + public static CoreItem itemDetCable; + public static ItemThrowableBomb itemBomb; + static { Logger.INFO("Items!"); //Default item used when recipes fail, handy for debugging. Let's make sure they exist when this class is called upon. @@ -889,6 +895,16 @@ public final class ModItems { //Farm Animal Fun new AgriculturalChem(); + + //Bombs + itemBombCasing = new CoreItem("itemBombCasing", "Bomb Casing", tabMisc); + itemBombCasing.setTextureName(CORE.MODID + ":bomb_casing"); + itemBombUnf = new CoreItem("itemBombUnf", "Bomb (unf)", tabMisc); + itemBombUnf.setTextureName(CORE.MODID + ":bomb_casing"); + itemDetCable = new CoreItem("itemDetCable", "Det. Cable", tabMisc); + itemDetCable.setTextureName("string"); + itemBomb = new ItemThrowableBomb(); + //Only used for debugging. /*if (CORE.DEVENV) { new ConnectedBlockFinder(); diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockMeta.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockMeta.java index c271ab39d0..b26ac67225 100644 --- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockMeta.java +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockMeta.java @@ -22,7 +22,7 @@ public class ItemBlockMeta extends ItemBlockWithMetadata { super(aBlock, aBlock); this.mBlock = aBlock; - this.setMaxDamage(15); + this.setMaxDamage(0); this.setHasSubtypes(true); if (aBlock instanceof ITileTooltip) { ITileTooltip aTooltip = (ITileTooltip) aBlock; diff --git a/src/Java/gtPlusPlus/core/item/general/ItemControlCore.java b/src/Java/gtPlusPlus/core/item/general/ItemControlCore.java index eb22f8fa07..5ef72b6f17 100644 --- a/src/Java/gtPlusPlus/core/item/general/ItemControlCore.java +++ b/src/Java/gtPlusPlus/core/item/general/ItemControlCore.java @@ -17,7 +17,7 @@ import gtPlusPlus.core.lib.CORE; public class ItemControlCore extends Item { - public IIcon[] icons = new IIcon[10]; + public static IIcon[] icons = new IIcon[10]; public ItemControlCore() { super(); @@ -31,16 +31,16 @@ public class ItemControlCore extends Item { @Override public void registerIcons(IIconRegister reg) { - this.icons[0] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_0"); - this.icons[1] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_1"); - this.icons[2] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_2"); - this.icons[3] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_3"); - this.icons[4] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_4"); - this.icons[5] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_5"); - this.icons[6] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_6"); - this.icons[7] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_7"); - this.icons[8] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_8"); - this.icons[9] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_9"); + icons[0] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_0"); + icons[1] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_1"); + icons[2] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_2"); + icons[3] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_3"); + icons[4] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_4"); + icons[5] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_5"); + icons[6] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_6"); + icons[7] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_7"); + icons[8] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_8"); + icons[9] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_9"); } @Override diff --git a/src/Java/gtPlusPlus/core/item/general/throwables/ItemThrowableBomb.java b/src/Java/gtPlusPlus/core/item/general/throwables/ItemThrowableBomb.java new file mode 100644 index 0000000000..9467c3a58c --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/general/throwables/ItemThrowableBomb.java @@ -0,0 +1,123 @@ +package gtPlusPlus.core.item.general.throwables; + +import java.util.List; + +import gregtech.api.enums.ItemList; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.entity.projectile.EntityThrowableBomb; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.item.base.CoreItem; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.NBTUtils; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class ItemThrowableBomb extends CoreItem { + + private static AutoMap mLighters = new AutoMap(); + public static IIcon[] icons = new IIcon[10]; + + public ItemThrowableBomb() { + super("gtpp.throwable.bomb", "Bomb", AddToCreativeTab.tabMisc, 16, 0, new String[] {"Just like Bomberman", "Have a fire source in inventory to prime"}, EnumRarity.uncommon, EnumChatFormatting.GRAY, false, null); + this.setHasSubtypes(true); + } + + @Override + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + + if (mLighters.isEmpty()) { + mLighters.put(ItemUtils.getSimpleStack(Items.flint_and_steel)); + mLighters.put(ItemList.Tool_Lighter_Invar_Full.get(1)); + mLighters.put(ItemList.Tool_Lighter_Invar_Used.get(1)); + mLighters.put(ItemList.Tool_Lighter_Platinum_Full.get(1)); + mLighters.put(ItemList.Tool_Lighter_Platinum_Used.get(1)); + mLighters.put(ItemUtils.getSimpleStack(ModItems.itemBasicFireMaker)); + } + + //Unlit + if (item.getItemDamage() == 0) { + boolean hasLighter = false; + for (ItemStack aPlaySlot : player.inventory.mainInventory) { + if (aPlaySlot != null) { + for (ItemStack aLighter : mLighters) { + if (GT_Utility.areStacksEqual(aPlaySlot, aLighter)) { + hasLighter = true; + break; + } + } + } + } + if (hasLighter) { + item.setItemDamage(1); + } + } + //Lit + else if (item.getItemDamage() == 1) { + if (!player.capabilities.isCreativeMode) { + --item.stackSize; + } + world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + if (!world.isRemote) { + world.spawnEntityInWorld(new EntityThrowableBomb(world, player)); + } + /*if (item.stackSize <= 0) { + item = null; + }*/ + } + return item; + } + + + + @Override + public void registerIcons(IIconRegister reg) { + icons[0] = reg.registerIcon(CORE.MODID + ":" + "bomb"); + icons[1] = reg.registerIcon(CORE.MODID + ":" + "bomb_lit"); + } + + @Override + public IIcon getIconFromDamage(int meta) { + return this.icons[meta]; + } + + @SuppressWarnings({ "unchecked" }) + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 2; i ++) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + String aLitStatus = "unlit"; + if (stack.getItemDamage() == 0) { + aLitStatus = EnumChatFormatting.BLUE+"Unlit"; + } + else if (stack.getItemDamage() == 1) { + aLitStatus = EnumChatFormatting.RED+"Lit"; + } + list.add(EnumChatFormatting.GOLD+"Fuse Status: "+aLitStatus); + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + // TODO Auto-generated method stub + return super.getItemStackDisplayName(p_77653_1_); + } + + + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index 1b24fb6e87..a22d8523ff 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -18,6 +18,7 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.item.chemistry.IonParticles; +import gtPlusPlus.core.item.chemistry.RocketFuels; import gtPlusPlus.core.item.crafting.ItemDummyResearch; import gtPlusPlus.core.item.crafting.ItemDummyResearch.ASSEMBLY_LINE_RESEARCH; import gtPlusPlus.core.lib.CORE; @@ -85,10 +86,34 @@ public class RECIPES_GREGTECH { breweryRecipes(); laserEngraverRecipes(); assemblyLineRecipes(); + latheRecipes(); + vacuumFreezerRecipes(); addFuels(); } + private static void vacuumFreezerRecipes() { + GT_Values.RA.addVacuumFreezerRecipe(GregtechItemList.Bomb_Cast_Molten.get(1), GregtechItemList.Bomb_Cast_Set.get(1), 20 * 30); + } + + private static void latheRecipes() { + + GT_Values.RA.addLatheRecipe( + ALLOY.EGLIN_STEEL.getBlock(1), + GregtechItemList.Bomb_Cast_Mold.get(1), + null, + 20 * 60 * 15, + 120); + + GT_Values.RA.addLatheRecipe( + GregtechItemList.Bomb_Cast_Set.get(1), + GregtechItemList.Bomb_Cast_Broken.get(2), + ItemUtils.getSimpleStack(ModItems.itemBombCasing, 2), + 20 * 60 * 5, + 30); + + } + private static void fusionRecipes() { /** @@ -1249,6 +1274,21 @@ public class RECIPES_GREGTECH { FluidUtils.getFluidStack("molten.krypton", 500), T6, 2000, 512000); + addAR(ItemUtils.getItemStackOfAmountFromOreDict( + "dustClay", 32), + GregtechItemList.Bomb_Cast_Mold.get(0), + FluidUtils.getWater(4000), + GregtechItemList.Bomb_Cast.get(4), + 30, 120); + addAR(ItemUtils.getSimpleStack(Items.redstone, 32), + ItemUtils.getSimpleStack(ModItems.itemRope, 16), + Materials.Glue.getFluid(500), + ItemUtils.getSimpleStack(ModItems.itemDetCable, 24), + 30, + 120); + + + /*addAR(ItemUtils.getItemStackOfAmountFromOreDict("plateIncoloy020", 16), ItemUtils.getItemStackOfAmountFromOreDict("frameGtIncoloyMA956", 4), null, GregtechItemList.Casing_Power_SubStation.get(4), 80, 120);*/ @@ -1564,6 +1604,24 @@ public class RECIPES_GREGTECH { ItemUtils.getItemStackOfAmountFromOreDict("dustLithium7", 16), FluidUtils.getFluidStack("water", 1000), FluidUtils.getFluidStack("lithiumhydroxide", 144 * 4), CI.emptyCells(1), 300 * 20); + + //Bombs + GT_Values.RA.addChemicalRecipe( + ItemUtils.getSimpleStack(ModItems.itemBombCasing, 4), + ItemUtils.getSimpleStack(RocketFuels.Ammonium_Nitrate_Dust, 8), + Materials.Fuel.getFluid(1000), + null, + ItemUtils.getSimpleStack(ModItems.itemBombUnf, 4), + 300 * 20); + + GT_Values.RA.addChemicalRecipe( + ItemUtils.getSimpleStack(ModItems.itemBombUnf, 4), + ItemUtils.getSimpleStack(ModItems.itemDetCable, 4), + FluidUtils.getFluidStack(RocketFuels.Kerosene, 100), + null, + ItemUtils.getSimpleStack(ModItems.itemBomb, 4), + 10 * 20); + // LFTR Fuel Related Compounds if (GTNH) { @@ -1666,6 +1724,18 @@ public class RECIPES_GREGTECH { MaterialUtils.getVoltageForTier(GTNH ? 5 : 4), 4500); + //Bomb Casings + GT_Values.RA.addBlastRecipe( + GregtechItemList.Bomb_Cast.get(4), + ALLOY.STEEL.getDust(16), + ELEMENT.getInstance().OXYGEN.getFluid(2000), + GT_Values.NF, + GregtechItemList.Bomb_Cast_Molten.get(4), + null, + 4 * 60 * 20, + MaterialUtils.getVoltageForTier(GTNH ? 3 : 2), + 2800); + } diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java index bdf899e22d..18954f12b6 100644 --- a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java +++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java @@ -24,7 +24,6 @@ public class TileEntityAdvPooCollector extends TileEntityBaseFluidCollector { public TileEntityAdvPooCollector() { super(18, 128000); - Logger.INFO("Created"); } @@ -120,7 +119,7 @@ public class TileEntityAdvPooCollector extends TileEntityBaseFluidCollector { } } aPooAmount = Math.max(Math.min(this.tank.getCapacity()-this.tank.getFluidAmount(), aPooAmount), 1); - return aPooAmount * MathUtils.getRandomFromArray(new int[] {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 4}); + return Math.max(1, (aPooAmount * MathUtils.getRandomFromArray(new int[] {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 4}) / 10)); } else { return 0; diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityBaseFluidCollector.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityBaseFluidCollector.java index 2438d57355..7afb4727b4 100644 --- a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityBaseFluidCollector.java +++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityBaseFluidCollector.java @@ -177,7 +177,6 @@ public abstract class TileEntityBaseFluidCollector extends TileEntityBase implem AxisAlignedBB box = AxisAlignedBB.getBoundingBox(startX, startY, startZ, endX, endY, endZ); if (box != null) { for (Class c2 : aThingsToLookFor()) { - Logger.INFO("Looking for "+c2.getName()); tickEntityType(w, box, c2); } } else { @@ -197,7 +196,6 @@ public abstract class TileEntityBaseFluidCollector extends TileEntityBase implem public final void tickEntityType(World w, AxisAlignedBB box, Class aClassToFind) { List entities = w.getEntitiesWithinAABB(aClassToFind, box); if (entities != null && !entities.isEmpty()) { - Logger.INFO("Found some "+aClassToFind.getName()); interactWithEntities(entities); } } diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java index 3667dd6a29..f6570c6cc6 100644 --- a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java +++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java @@ -20,7 +20,7 @@ import net.minecraftforge.fluids.Fluid; public class TileEntityPooCollector extends TileEntityBaseFluidCollector { public TileEntityPooCollector() { - super(9, 64000); + super(9, 8000); } @@ -109,7 +109,7 @@ public class TileEntityPooCollector extends TileEntityBaseFluidCollector { aPooAmount = MathUtils.randInt(1, 10); } } - aPooAmount = Math.max(Math.min(this.tank.getCapacity()-this.tank.getFluidAmount(), aPooAmount), 1); + aPooAmount = Math.max((Math.min(this.tank.getCapacity()-this.tank.getFluidAmount(), aPooAmount)/10), 1); return aPooAmount; } else { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index f377a2da3d..83abe22568 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -104,6 +104,11 @@ public enum GregtechItemList implements GregtechItemContainer { //End Game Laser Engraver Lens Laser_Lens_Special, + //Bombs + Bomb_Cast, Bomb_Cast_Molten, + Bomb_Cast_Set, Bomb_Cast_Broken, + Bomb_Cast_Mold, + //---------------------------------------------------------------------------- @@ -561,7 +566,7 @@ public enum GregtechItemList implements GregtechItemContainer { */ //Fluid Void Covers - Cover_Overflow_ULV, Cover_Overflow_LV, Cover_Overflow_MV, Cover_Overflow_HV, Cover_Overflow_EV, Cover_Overflow_IV, + Cover_Overflow_ULV, Cover_Overflow_LV, Cover_Overflow_MV, Cover_Overflow_HV, Cover_Overflow_EV, Cover_Overflow_IV, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java index 6b061c3704..f42fc49e53 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java @@ -304,6 +304,20 @@ public class MetaGeneratedGregtechItems extends Gregtech_MetaItem_X32 { + /* + * Bombs + */ + GregtechItemList.Bomb_Cast.set(this.addItem(111, "Bomb Cast", "Used in the production of Bombs", new Object[0])); + GregtechItemList.Bomb_Cast_Molten.set(this.addItem(112, "Bomb Cast (Hot)", "Consider cooling this off", new Object[0])); + GregtechItemList.Bomb_Cast_Set.set(this.addItem(113, "Bomb Cast (Set)", "Break it open for the goodies inside!", new Object[0])); + GregtechItemList.Bomb_Cast_Broken.set(this.addItem(114, "Bomb Cast (Broken)", "This is probably just junk", new Object[0])); + GregtechItemList.Bomb_Cast_Mold.set(this.addItem(115, "Mold (Bomb Cast)", "Used in the production of Bombs", new Object[0])); + + + + + + } private boolean registerComponents_ULV(){ diff --git a/src/resources/assets/miscutils/textures/items/MU-metaitem.01/111.png b/src/resources/assets/miscutils/textures/items/MU-metaitem.01/111.png new file mode 100644 index 0000000000..3147037815 Binary files /dev/null and b/src/resources/assets/miscutils/textures/items/MU-metaitem.01/111.png differ diff --git a/src/resources/assets/miscutils/textures/items/MU-metaitem.01/112.png b/src/resources/assets/miscutils/textures/items/MU-metaitem.01/112.png new file mode 100644 index 0000000000..dce530370f Binary files /dev/null and b/src/resources/assets/miscutils/textures/items/MU-metaitem.01/112.png differ diff --git a/src/resources/assets/miscutils/textures/items/MU-metaitem.01/113.png b/src/resources/assets/miscutils/textures/items/MU-metaitem.01/113.png new file mode 100644 index 0000000000..0c85939327 Binary files /dev/null and b/src/resources/assets/miscutils/textures/items/MU-metaitem.01/113.png differ diff --git a/src/resources/assets/miscutils/textures/items/MU-metaitem.01/114.png b/src/resources/assets/miscutils/textures/items/MU-metaitem.01/114.png new file mode 100644 index 0000000000..b3c3716abb Binary files /dev/null and b/src/resources/assets/miscutils/textures/items/MU-metaitem.01/114.png differ diff --git a/src/resources/assets/miscutils/textures/items/MU-metaitem.01/115.png b/src/resources/assets/miscutils/textures/items/MU-metaitem.01/115.png new file mode 100644 index 0000000000..a9a9c6fcee Binary files /dev/null and b/src/resources/assets/miscutils/textures/items/MU-metaitem.01/115.png differ -- cgit