Posted September 29, 201212 yr Since I couldn't get the mod to not edit any base classes, I ended up just having it be a jar mod for now. Since it was working perfectly in Eclipse, I thought I was finally ready to release my first Forge mod. But, when I recompiled it, reobfuscated it, and installed it on my game, it crashed. --- BEGIN ERROR REPORT 6f4e5afd -------- Generated 9/29/12 3:07 PM - Minecraft Version: 1.3.2 - Operating System: Mac OS X (x86_64) version 10.7.3 - Java Version: 1.6.0_31, Apple Inc. - Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Apple Inc. - Memory: 478579176 bytes (456 MB) / 534708224 bytes (509 MB) up to 1060372480 bytes (1011 MB) - JVM Flags: 2 total; -Xmx1024m -Xms512m - FML: FML v3.1.30.390 Minecraft Forge 4.1.4.295 Optifine OptiFine_1.3.2_HD_U_B3 9 mods loaded, 9 mods active FML [Forge Mod Loader] (coremods) Unloaded->Constructed->Pre-initialized->Initialized Forge [Minecraft Forge] (coremods) Unloaded->Constructed->Pre-initialized->Initialized mod_CodeChickenCore [CodeChicken Core] (coremods) Unloaded->Constructed->Pre-initialized->Initialized mod_NotEnoughItems [Not Enough Items] (coremods) Unloaded->Constructed->Pre-initialized->Initialized mod_SmartMoving [mod_SmartMoving] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized RealPumpkins [Real Pumpkins] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Errored AutoJoin [Auto Join] (Forge_AutoJoinv1.3.2.0) Unloaded->Constructed->Pre-initialized->Initialized SP [soundPacks] (SoundPacksMod V2.0.jar) Unloaded->Constructed->Pre-initialized->Initialized TerraFirmaCraft [TerraFirmaCraft] (TFCraft-Universal-Core-B2-Build52e.zip) Unloaded->Constructed->Pre-initialized->Initialized - LWJGL: 2.4.2 - OpenGL: AMD Radeon HD 6750M OpenGL Engine GL version 2.1 ATI-7.18.11, ATI Technologies Inc. - Is Modded: Definitely; 'forge,fml' - Type: Client - Texture Pack: Default - Profiler Position: N/A (disabled) cpw.mods.fml.common.LoaderException: java.lang.reflect.InvocationTargetException at cpw.mods.fml.common.LoadController.transition(LoadController.java:102) at cpw.mods.fml.common.Loader.initializeMods(Loader.java:632) at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:176) at net.minecraft.client.Minecraft.a(Minecraft.java:461) at net.minecraft.client.Minecraft.run(Minecraft.java:748) at java.lang.Thread.run(Thread.java:680) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:424) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:69) at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:317) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:300) at com.google.common.eventbus.EventBus.post(EventBus.java:268) at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:124) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:69) at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:317) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:300) at com.google.common.eventbus.EventBus.post(EventBus.java:268) at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:81) at cpw.mods.fml.common.Loader.initializeMods(Loader.java:631) ... 4 more Caused by: cpw.mods.fml.relauncher.ReflectionHelper$UnableToAccessFieldException: cpw.mods.fml.relauncher.ReflectionHelper$UnableToFindFieldException: java.lang.NoSuchFieldException: fruitType at cpw.mods.fml.relauncher.ReflectionHelper.setPrivateValue(ReflectionHelper.java:140) at cpw.mods.fml.common.ObfuscationReflectionHelper.setPrivateValue(ObfuscationReflectionHelper.java:94) at ModLoader.setPrivateValue(ModLoader.java:842) at realPumpkins.common.RealPumpkins.load(RealPumpkins.java:103) ... 30 more Caused by: cpw.mods.fml.relauncher.ReflectionHelper$UnableToFindFieldException: java.lang.NoSuchFieldException: fruitType at cpw.mods.fml.relauncher.ReflectionHelper.findField(ReflectionHelper.java:87) at cpw.mods.fml.relauncher.ReflectionHelper.setPrivateValue(ReflectionHelper.java:136) ... 33 more Caused by: java.lang.NoSuchFieldException: fruitType at java.lang.Class.getDeclaredField(Class.java:1882) at cpw.mods.fml.relauncher.ReflectionHelper.findField(ReflectionHelper.java:78) ... 34 more --- END ERROR REPORT 673f440a ---------- This is my mod file: package realPumpkins.common; import java.util.ArrayList; import net.minecraft.src.Block; import net.minecraft.src.BlockPumpkin; import net.minecraft.src.BlockStem; import net.minecraft.src.CraftingManager; import net.minecraft.src.EntityEnderman; import net.minecraft.src.IRecipe; import net.minecraft.src.Item; import net.minecraft.src.ItemBlock; import net.minecraft.src.ItemStack; import net.minecraft.src.ModLoader; import net.minecraft.src.ShapedRecipes; import net.minecraft.src.ShapelessRecipes; import net.minecraftforge.common.Configuration; import net.minecraftforge.common.Property; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.Init; import cpw.mods.fml.common.Mod.PreInit; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.registry.GameRegistry; @Mod(modid="RealPumpkins",name="Real Pumpkins",version="1.3.2.0") public class RealPumpkins { public static Block realPumpkin; public static int realPumpkinID; private static void removeRecipe(ItemStack resultItem) //Code by yope_fried inspired by pigalot { ItemStack recipeResult = null; ArrayList recipes = (ArrayList) CraftingManager.getInstance().getRecipeList(); for (int scan = 0; scan < recipes.size(); scan++) { IRecipe tmpRecipe = (IRecipe) recipes.get(scan); if (tmpRecipe instanceof ShapedRecipes) { ShapedRecipes recipe = (ShapedRecipes)tmpRecipe; recipeResult = recipe.getRecipeOutput(); } if (tmpRecipe instanceof ShapelessRecipes) { ShapelessRecipes recipe = (ShapelessRecipes)tmpRecipe; recipeResult = recipe.getRecipeOutput(); } if (ItemStack.areItemStacksEqual(resultItem, recipeResult)) { System.out.println("Real Pumpkins Removed Recipe: " + recipes.get(scan) + " -> " + recipeResult); recipes.remove(scan); } } } @SidedProxy(clientSide = "realPumpkins.client.ClientProxyRealPumpkins", serverSide = "realPumpkins.common.CommonProxyRealPumpkins") public static CommonProxyRealPumpkins proxy; @PreInit public void preInit(FMLPreInitializationEvent event) { Configuration config = new Configuration(event.getSuggestedConfigurationFile()); config.load(); realPumpkinID = config.getOrCreateBlockIdProperty("Natural Pumpkin", 3130).getInt(); Property RemovePumpkinSeedsRecipe = config.getOrCreateProperty("Disable Vanilla Pumpkin Seeds Recipe", Configuration.CATEGORY_GENERAL, "true"); RemovePumpkinSeedsRecipe.comment = "Set to true by default since you can get them by using a natural pumpkin in crafting recipes, and it didn't make sense to be able to get seeds from an already carved pumpkin. However, you can enable it again by setting it to false. This is just in case you don't have access to pumpkin seeds or natural pumpkins, like in a custom map, for example, so you aren't locked out of farming pumpkins. You can always set it to true again once you've crafted the seeds."; boolean PumpkinSeedsBoolean = RemovePumpkinSeedsRecipe.getBoolean(true); Property EasyPumpkinPlacement = config.getOrCreateProperty("Enable Placing Carved Pumpkins Anywhere", Configuration.CATEGORY_GENERAL, "false"); EasyPumpkinPlacement.comment = "Set to false by default so that the jack 'o' lantern won't outclass glowstone. You are still welcome to set it to true yourself, though. When Mojang adds directional lighting, the default will be true to compensate for the jack 'o' lantern's nerf."; boolean EasyPlacementBoolean = EasyPumpkinPlacement.getBoolean(true); config.save(); if (PumpkinSeedsBoolean) { removeRecipe(new ItemStack(Item.pumpkinSeeds, 4)); } if (EasyPlacementBoolean == true) { ModLoader.setPrivateValue(net.minecraft.src.BlockPumpkin.class, (BlockPumpkin)Block.pumpkin, "easyPlacement", true); ModLoader.setPrivateValue(net.minecraft.src.BlockPumpkin.class, (BlockPumpkin)Block.pumpkinLantern, "easyPlacement", true); } } @Init public void load(FMLInitializationEvent evt){ realPumpkin = new BlockRealPumpkin(realPumpkinID, 0).setHardness(1.0F).setStepSound(Block.soundWoodFootstep).setBlockName("pumpkin"); GameRegistry.registerBlock(realPumpkin); Item.itemsList[realPumpkin.blockID] = (new ItemBlock(realPumpkin.blockID - 256)).setItemName("pumpkin").setContainerItem(Item.pumpkinSeeds); // Block.blocksList[block.pumpkin.blockID] = null; // Block.blocksList[block.pumpkin.blockID] = (new BlockCarvedPumpkin(86, 102, false)).setHardness(1.0F).setStepSound(Block.soundWoodFootstep).setBlockName("pumpkin"); // Block.blocksList[block.pumpkinLantern.blockID] = null; // Block.blocksList[block.pumpkinLantern.blockID] = (new BlockCarvedPumpkin(91, 102, true)).setHardness(1.0F).setStepSound(Block.soundWoodFootstep).setLightValue(1.0F).setBlockName("litpumpkin"); EntityEnderman.carriableBlocks[realPumpkin.blockID] = true; GameRegistry.addShapelessRecipe(new ItemStack(Block.pumpkin), new ItemStack(realPumpkin)); ModLoader.setPrivateValue(net.minecraft.src.BlockStem.class, (BlockStem)Block.pumpkinStem, "fruitType", realPumpkin); proxy.registerRenderThings(); } } It seems to be tripping up at the part where I set the pumpkin stem to grow my custom pumpkin instead of the vanilla pumpkin.
September 29, 201212 yr Shouldn't you use an access transformer (asm thingy) and make it a coremod, rather than editing base classes?
September 29, 201212 yr Author Shouldn't you use an access transformer (asm thingy) and make it a coremod, rather than editing base classes? I didn't know about that. How do I do that? Although I doubt it'd solve the problem I'm having now, I am interested in doing this. The class that I edit is WorldGenPumpkin.
September 29, 201212 yr cpw.mods.fml.relauncher.ReflectionHelper$UnableToAccessFieldException: cpw.mods.fml.relauncher.ReflectionHelper$UnableToFindFieldException: java.lang.NoSuchFieldException: fruitType Looks like it cannot find that field you're trying to access to. You try to use: ModLoader.setPrivateValue(net.minecraft.src.BlockStem.class, (BlockStem)Block.pumpkinStem, "fruitType", realPumpkin); and fruitType will be obfuscated, that means it has a name like field_2124 or something like that. So it works in eclipse (with the readable name) but not after obfuscation. I believe there's a method similar to that, just with an int parameter instead of a String one for the field. Try something like that: ReflectionHelper.setPrivateValue(net.minecraft.src.BlockStem.class, (BlockStem)Block.pumpkinStem, 0, realPumpkin) The 0 is the index of the field in the BlockStem class, means that this is the first field in it. Also try to use the ReflectionHelper directly instead of ModLoader methods for Reflection things like these. ModLoader stuff in a forge mod doesn't look good / clean. Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! | mah twitter This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.
September 30, 201212 yr Author cpw.mods.fml.relauncher.ReflectionHelper$UnableToAccessFieldException: cpw.mods.fml.relauncher.ReflectionHelper$UnableToFindFieldException: java.lang.NoSuchFieldException: fruitType Looks like it cannot find that field you're trying to access to. You try to use: ModLoader.setPrivateValue(net.minecraft.src.BlockStem.class, (BlockStem)Block.pumpkinStem, "fruitType", realPumpkin); and fruitType will be obfuscated, that means it has a name like field_2124 or something like that. So it works in eclipse (with the readable name) but not after obfuscation. I believe there's a method similar to that, just with an int parameter instead of a String one for the field. Try something like that: ReflectionHelper.setPrivateValue(net.minecraft.src.BlockStem.class, (BlockStem)Block.pumpkinStem, 0, realPumpkin) The 0 is the index of the field in the BlockStem class, means that this is the first field in it. Also try to use the ReflectionHelper directly instead of ModLoader methods for Reflection things like these. ModLoader stuff in a forge mod doesn't look good / clean. That particular code for ReflectionHelper isn't valid, so I just did ModLoader instead and it worked. The OP's issue is solved, but I still want to find out how to make it a coremod.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.