diff options
| author | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2019-01-30 02:18:50 +0000 |
|---|---|---|
| committer | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2019-01-30 02:18:50 +0000 |
| commit | 7832b6223896af1b1435cdfeb52ce0210bfd2203 (patch) | |
| tree | 495a4e090f0bfadbb31e3718e50e2fc7ae5e0230 /src/Java | |
| parent | 222fbc044f89a2d272f0bace58c28db1e6927e0f (diff) | |
| download | GT5-Unofficial-7832b6223896af1b1435cdfeb52ce0210bfd2203.tar.gz GT5-Unofficial-7832b6223896af1b1435cdfeb52ce0210bfd2203.tar.bz2 GT5-Unofficial-7832b6223896af1b1435cdfeb52ce0210bfd2203.zip | |
$ Fixed 'bug' where GT wooden Pipes/Frames would require an Axe to harvest. They now require a wrench, freeing up 4 MetaIDs on BlockMachines for myself to use.
$ Fixed handling of custom BaseMetaTileEntity implementations. Meta 12-15 is now used by GT++ to deploy custom without requiring any outside items or blocks.
$ Fixed IC2 items requiring a pickaxe to mine and shitty wrench handling. You can now just mine them as usual with a wrench.
$ Fixed ALL GT/GT++ Tile Entity Tooltips. Formatted some things slighty, added additional information and additional custom tooltip support.
Diffstat (limited to 'src/Java')
50 files changed, 894 insertions, 604 deletions
diff --git a/src/Java/gtPlusPlus/GTplusplus.java b/src/Java/gtPlusPlus/GTplusplus.java index 7b340dc798..79a3bee7ba 100644 --- a/src/Java/gtPlusPlus/GTplusplus.java +++ b/src/Java/gtPlusPlus/GTplusplus.java @@ -101,6 +101,7 @@ public class GTplusplus implements ActionListener { //Mod Instance @Mod.Instance(CORE.MODID) public static GTplusplus instance; + public static Meta_GT_Proxy instanceGtProxy; //Material Loader public static GT_Material_Loader mGregMatLoader; @@ -168,8 +169,12 @@ public class GTplusplus implements ActionListener { Logger.INFO("Login Handler Initialized"); + mChunkLoading.preInit(event); proxy.preInit(event); + Logger.INFO("Setting up our own GT_Proxy."); + instanceGtProxy = Meta_GT_Proxy.instance; + instanceGtProxy.preInit(); Core_Manager.preInit(); } @@ -180,6 +185,7 @@ public class GTplusplus implements ActionListener { mChunkLoading.init(event); proxy.init(event); proxy.registerNetworkStuff(); + instanceGtProxy.init(); Core_Manager.init(); //Used by foreign players to generate .lang files for translation. @@ -196,6 +202,7 @@ public class GTplusplus implements ActionListener { mChunkLoading.postInit(event); proxy.postInit(event); BookHandler.runLater(); + instanceGtProxy.postInit(); Core_Manager.postInit(); //SprinklerHandler.registerModFerts(); diff --git a/src/Java/gtPlusPlus/core/common/CommonProxy.java b/src/Java/gtPlusPlus/core/common/CommonProxy.java index 6bced739c7..9176dcc720 100644 --- a/src/Java/gtPlusPlus/core/common/CommonProxy.java +++ b/src/Java/gtPlusPlus/core/common/CommonProxy.java @@ -2,13 +2,13 @@ package gtPlusPlus.core.common; import static gtPlusPlus.core.lib.CORE.DEBUG; -import cpw.mods.fml.common.event.*; +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 cpw.mods.fml.common.event.FMLServerStartingEvent; import cpw.mods.fml.common.registry.GameRegistry; - -import net.minecraft.entity.Entity; - import gregtech.api.enums.ItemList; - import gtPlusPlus.GTplusplus; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.minecraft.ChunkManager; @@ -18,8 +18,15 @@ import gtPlusPlus.core.entity.InternalEntityRegistry; import gtPlusPlus.core.entity.monster.EntityGiantChickenBase; import gtPlusPlus.core.entity.monster.EntitySickBlaze; import gtPlusPlus.core.entity.monster.EntityStaballoyConstruct; -import gtPlusPlus.core.handler.*; -import gtPlusPlus.core.handler.events.*; +import gtPlusPlus.core.handler.BookHandler; +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.events.BlockEventHandler; +import gtPlusPlus.core.handler.events.GeneralTooltipEventHandler; +import gtPlusPlus.core.handler.events.PickaxeBlockBreakEventHandler; +import gtPlusPlus.core.handler.events.ZombieBackupSpawnEventHandler; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.CORE.ConfigSwitches; @@ -33,12 +40,11 @@ import gtPlusPlus.core.util.player.PlayerCache; import gtPlusPlus.plugin.villagers.block.BlockGenericSpawner; import gtPlusPlus.xmod.eio.handler.HandlerTooltip_EIO; import gtPlusPlus.xmod.galacticraft.handler.HandlerTooltip_GC; -import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; +import net.minecraft.entity.Entity; import net.minecraftforge.common.ForgeChunkManager; public class CommonProxy { - public static Meta_GT_Proxy GtProxy; private boolean mFluidsGenerated = false; public CommonProxy() { @@ -49,8 +55,6 @@ public class CommonProxy { } else { Logger.INFO("We're using GTNH's Gregtech " + Utils.getGregtechVersionAsString()); } - Logger.INFO("Setting up our own GT_Proxy."); - GtProxy = Meta_GT_Proxy.instance; } public void preInit(final FMLPreInitializationEvent e) { @@ -58,38 +62,33 @@ public class CommonProxy { LoadedMods.checkLoaded(); Logger.INFO("Making sure we're ready to party!"); - - if (!DEBUG){ + if (!DEBUG) { Logger.WARNING("Development mode not enabled."); - } - else if (DEBUG){ + } else if (DEBUG) { Logger.INFO("Development mode enabled."); - } - else { + } else { Logger.WARNING("Development mode not set."); } AddToCreativeTab.initialiseTabs(); - - //Moved from Init after Debug Loading. - //29/01/18 - Alkalus - //Moved earlier into PreInit, so that Items exist before they're called upon in recipes. - //20/03/18 - Alkalus + + // Moved from Init after Debug Loading. + // 29/01/18 - Alkalus + // Moved earlier into PreInit, so that Items exist before they're called upon in + // recipes. + // 20/03/18 - Alkalus ModItems.init(); ModBlocks.init(); CI.preInit(); - - - + COMPAT_IntermodStaging.preInit(); BookHandler.run(); - //Registration of entities and renderers + // Registration of entities and renderers Logger.INFO("[Proxy] Calling Entity registrator."); registerEntities(); Logger.INFO("[Proxy] Calling Tile Entity registrator."); registerTileEntities(); - - + Logger.INFO("[Proxy] Calling Render registrator."); registerRenderThings(); @@ -97,28 +96,21 @@ public class CommonProxy { Material.generateQueuedFluids(); mFluidsGenerated = true; } - - //Must be done in pre-init. - generateMobSpawners(); - - //Internal GT Proxy - GtProxy.preInit(); - + } public void init(final FMLInitializationEvent e) { - //Debug Loading - if (CORE.DEBUG){ + // Debug Loading + if (CORE.DEBUG) { DEBUG_INIT.registerHandlers(); - } + } ModBlocks.blockCustomMobSpawner = new BlockGenericSpawner(); - + if (!mFluidsGenerated && ItemList.valueOf("Cell_Empty").hasBeenSet()) { Material.generateQueuedFluids(); mFluidsGenerated = true; - } - else { + } else { Logger.INFO("[ERROR] Did not generate fluids at all."); Logger.WARNING("[ERROR] Did not generate fluids at all."); Logger.ERROR("[ERROR] Did not generate fluids at all."); @@ -129,22 +121,22 @@ public class CommonProxy { * Register the Event Handlers. */ - //Prevents my Safes being destroyed. + // Prevents my Safes being destroyed. Utils.registerEvent(new PickaxeBlockBreakEventHandler()); - //Block Handler for all events. + // Block Handler for all events. Utils.registerEvent(new BlockEventHandler()); Utils.registerEvent(new GeneralTooltipEventHandler()); - //Handles Custom tooltips for EIO. + // Handles Custom tooltips for EIO. Utils.registerEvent(new HandlerTooltip_EIO()); - //Handles Custom Tooltips for GC + // Handles Custom Tooltips for GC Utils.registerEvent(new HandlerTooltip_GC()); - - //Register Chunkloader + + // Register Chunkloader ForgeChunkManager.setForcedChunkLoadingCallback(GTplusplus.instance, ChunkManager.getInstance()); Utils.registerEvent(ChunkManager.getInstance()); - if (ConfigSwitches.disableZombieReinforcement){ - //Make Zombie reinforcements fuck off. + if (ConfigSwitches.disableZombieReinforcement) { + // Make Zombie reinforcements fuck off. Utils.registerEvent(new ZombieBackupSpawnEventHandler()); } @@ -152,55 +144,48 @@ public class CommonProxy { * End of Subscribe Event registration. */ - //Compat Handling + // Compat Handling COMPAT_HANDLER.registerMyModsOreDictEntries(); COMPAT_HANDLER.intermodOreDictionarySupport(); COMPAT_IntermodStaging.init(); - - //Internal GT Proxy - GtProxy.init(); } public void postInit(final FMLPostInitializationEvent e) { Logger.INFO("Cleaning up, doing postInit."); PlayerCache.initCache(); - //Make Burnables burnable - if (!CORE.burnables.isEmpty()){ + // Make Burnables burnable + if (!CORE.burnables.isEmpty()) { BurnableFuelHandler fuelHandler = new BurnableFuelHandler(); GameRegistry.registerFuelHandler(fuelHandler); - Logger.INFO("[Fuel Handler] Registering "+fuelHandler.getClass().getName()); + Logger.INFO("[Fuel Handler] Registering " + fuelHandler.getClass().getName()); } - //Compat Handling + // Compat Handling COMPAT_HANDLER.RemoveRecipesFromOtherMods(); COMPAT_HANDLER.InitialiseHandlerThenAddRecipes(); COMPAT_HANDLER.startLoadingGregAPIBasedRecipes(); COMPAT_IntermodStaging.postInit(); COMPAT_HANDLER.runQueuedRecipes(); - //Internal GT Proxy - GtProxy.postInit(); } - - public void serverStarting(final FMLServerStartingEvent e) - { + public void serverStarting(final FMLServerStartingEvent e) { COMPAT_HANDLER.InitialiseLateHandlerThenAddRecipes(); } - + public void onLoadComplete(FMLLoadCompleteEvent event) { COMPAT_IntermodStaging.onLoadComplete(event); } - public void registerNetworkStuff(){ + public void registerNetworkStuff() { GuiHandler.init(); } - public void registerEntities(){ + public void registerEntities() { InternalEntityRegistry.registerEntities(); } - public void registerTileEntities(){ + public void registerTileEntities() { ModTileEntities.init(); } @@ -213,11 +198,11 @@ public class CommonProxy { } public void generateMysteriousParticles(final Entity entity) { - + } - + public void generateMobSpawners() { - //Try register some test spawners + // Try register some test spawners Utils.createNewMobSpawner(0, EntityGiantChickenBase.class); Utils.createNewMobSpawner(1, EntitySickBlaze.class); Utils.createNewMobSpawner(2, EntityStaballoyConstruct.class); diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BlockMachines_MetaPipeEntity.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BlockMachines_MetaPipeEntity.java new file mode 100644 index 0000000000..39cd8c248e --- /dev/null +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BlockMachines_MetaPipeEntity.java @@ -0,0 +1,266 @@ +package gtPlusPlus.preloader.asm.transformers; + +import static org.objectweb.asm.Opcodes.*; + +import java.io.IOException; +import org.apache.logging.log4j.Level; +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.relauncher.FMLRelaunchLog; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.enums.SubTag; +import gregtech.api.metatileentity.BaseMetaPipeEntity; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.preloader.DevHelper; +import gtPlusPlus.preloader.asm.AsmConfig; +import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class ClassTransformer_GT_BlockMachines_MetaPipeEntity { + + //The qualified name of the class we plan to transform. + //gregtech/common/blocks/GT_Block_Machines + + private final boolean isValid; + private final ClassReader reader; + private final ClassWriter writer; + + /** + * Utility Functions + */ + + public static String getHarvestTool(int aMeta) { + //FMLRelaunchLog.log("[GT++ ASM] Gregtech getTileEntityBaseType Patch", Level.INFO, "Attempting to call getHarvestTool. Meta: "+aMeta); + if (aMeta >= 8 && aMeta <= 11) { + return "cutter"; + } + return "wrench"; + } + + /** + * This determines the BaseMetaTileEntity belonging to this MetaTileEntity by using the Meta ID of the Block itself. + * <p/> + * 0 = BaseMetaTileEntity, Wrench lvl 0 to dismantle + * 1 = BaseMetaTileEntity, Wrench lvl 1 to dismantle + * <p/> + * 2 = BaseMetaTileEntity, Wrench lvl 2 to dismantle + * 3 = BaseMetaTileEntity, Wrench lvl 3 to dismantle + * <p/> + * 4 = BaseMetaPipeEntity, Wrench lvl 0 to dismantle + * 5 = BaseMetaPipeEntity, Wrench lvl 1 to dismantle + * <p/> + * 6 = BaseMetaPipeEntity, Wrench lvl 2 to dismantle + * 7 = BaseMetaPipeEntity, Wrench lvl 3 to dismantle + * <p/> + * 8 = BaseMetaPipeEntity, Cutter lvl 0 to dismantle + * 9 = BaseMetaPipeEntity, Cutter lvl 1 to dismantle + * <p/> + * 10 = BaseMetaPipeEntity, Cutter lvl 2 to dismantle + * 11 = BaseMetaPipeEntity, Cutter lvl 3 to dismantle + * <p/> + * == Reserved For Alkalus (Was previously used to allow axes on wooden blocks, but that's fucking stupid.) + * <p/> + * 12 = BaseMetaTileEntity, Wrench lvl 0 to dismantle + * 13 = BaseMetaTileEntity, Wrench lvl 1 to dismantle + * <p/> + * 14 = BaseMetaTileEntity, Wrench lvl 2 to dismantle + * 15 = BaseMetaTileEntity, Wrench lvl 3 to dismantle + */ + public static byte getTileEntityBaseType(Materials mMaterial) { + //FMLRelaunchLog.log("[GT++ ASM] Gregtech getTileEntityBaseType Patch", Level.INFO, "Attempting to call getTileEntityBaseType."); + return (byte) (mMaterial == null ? 4 : (byte) (4) + Math.max(0, Math.min(3, mMaterial.mToolQuality))); + } + + + + /** + * This determines the BaseMetaTileEntity belonging to this MetaTileEntity by using the Meta ID of the Block itself. + * <p/> + * 0 = BaseMetaTileEntity, Wrench lvl 0 to dismantle + * 1 = BaseMetaTileEntity, Wrench lvl 1 to dismantle + * <p/> + * 2 = BaseMetaTileEntity, Wrench lvl 2 to dismantle + * 3 = BaseMetaTileEntity, Wrench lvl 3 to dismantle + * <p/> + * 4 = BaseMetaPipeEntity, Wrench lvl 0 to dismantle + * 5 = BaseMetaPipeEntity, Wrench lvl 1 to dismantle + * <p/> + * 6 = BaseMetaPipeEntity, Wrench lvl 2 to dismantle + * 7 = BaseMetaPipeEntity, Wrench lvl 3 to dismantle + * <p/> + * 8 = BaseMetaPipeEntity, Cutter lvl 0 to dismantle + * 9 = BaseMetaPipeEntity, Cutter lvl 1 to dismantle + * <p/> + * 10 = BaseMetaPipeEntity, Cutter lvl 2 to dismantle + * 11 = BaseMetaPipeEntity, Cutter lvl 3 to dismantle + * <p/> + * == Reserved For Alkalus (Was previously used to allow axes on wooden blocks, but that's fucking stupid.) + * <p/> + * 12 = BaseMetaTileEntity, Wrench lvl 2 to dismantle + * 13 = BaseMetaTileEntity, Wrench lvl 2 to dismantle + * <p/> + * 14 = BaseMetaTileEntity, Wrench lvl 3 to dismantle + * 15 = BaseMetaTileEntity, Wrench lvl 3 to dismantle + */ + public static TileEntity createTileEntity(World aWorld, int aMeta) { + Logger.INFO("Creating Tile Entity with Meta of "+aMeta); + if (aMeta < 4) { + return GregTech_API.constructBaseMetaTileEntity(); + } else if (aMeta < 12) { + return new BaseMetaPipeEntity(); + } else { + return Meta_GT_Proxy.constructCustomGregtechMetaTileEntityByMeta(aMeta); + } + } + + + + String aEntityPlayer; + String aEntityPlayerMP; + String aWorld; + int mMode; + + public ClassTransformer_GT_BlockMachines_MetaPipeEntity(byte[] basicClass, boolean obfuscated, int aMode) { + mMode = aMode; + ClassReader aTempReader = null; + ClassWriter aTempWriter = null; + + FMLRelaunchLog.log("[GT++ ASM] Gregtech getTileEntityBaseType Patch", Level.INFO, "Attempting to patch in mode "+aMode+"."); + + aTempReader = new ClassReader(basicClass); + aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES); + aTempReader.accept(new localClassVisitor(aTempWriter), 0); + + if (aTempReader != null && aTempWriter != null) { + isValid = true; + } + else { + isValid = false; + } + FMLRelaunchLog.log("[GT++ ASM] Gregtech getTileEntityBaseType Patch", Level.INFO, "Valid patch? "+isValid+"."); + reader = aTempReader; + writer = aTempWriter; + + + if (reader != null && writer != null) { + aEntityPlayer = obfuscated ? DevHelper.getObfuscated("net/minecraft/entity/player/EntityPlayer") : "net/minecraft/entity/player/EntityPlayer"; + aEntityPlayerMP = obfuscated ? DevHelper.getObfuscated("net/minecraft/entity/player/EntityPlayerMP") : "net/minecraft/entity/player/EntityPlayerMP"; + aWorld = obfuscated ? DevHelper.getObfuscated("net/minecraft/world/World") : "net/minecraft/world/World"; + + FMLRelaunchLog.log("[GT++ ASM] Gregtech getTileEntityBaseType Patch", Level.INFO, "Attempting Method Injection."); + if (aMode == 0) { + injectMethod("getHarvestTool"); + injectMethod("createTileEntity"); + } + else { + injectMethod("getTileEntityBaseType"); + } + } + + } + + public boolean isValidTransformer() { + return isValid; + } + + public ClassReader getReader() { + return reader; + } + + public ClassWriter getWriter() { + return writer; + } + + public boolean injectMethod(String aMethodName) { + MethodVisitor mv; + boolean didInject = false; + FMLRelaunchLog.log("[GT++ ASM] Gregtech getTileEntityBaseType Patch", Level.INFO, "Injecting "+aMethodName+"."); + if (aMethodName.equals("getHarvestTool")) { + mv = getWriter().visitMethod(ACC_PUBLIC, "getHarvestTool", "(I)Ljava/lang/String;", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(63, l0); + mv.visitVarInsn(ILOAD, 1); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BlockMachines_MetaPipeEntity", "getHarvestTool", "(I)Ljava/lang/String;", false); + mv.visitInsn(ARETURN); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLocalVariable("this", "Lgregtech/common/blocks/GT_Block_Machines;", null, l0, l1, 0); + mv.visitLocalVariable("aMeta", "I", null, l0, l1, 1); + mv.visitMaxs(1, 2); + mv.visitEnd(); + didInject = true; + } + else if (aMethodName.equals("createTileEntity")) { + mv = getWriter().visitMethod(ACC_PUBLIC, "createTileEntity", |
