Posted June 29, 201312 yr Hey folks, I'm having this code... Method m = ReflectionHelper.findMethod(Material.class, Material.wood, new String[] {"f", "setRequiresTool"}); try { m.invoke(Material.wood); } catch (Throwable t) { t.printStackTrace(); } public void breakSpeed(PlayerEvent.BreakSpeed event) { if (event.block.blockMaterial == Material.wood) { if (!ForgeHooks.canToolHarvestBlock(event.block, event.metadata, event.entityPlayer.getCurrentEquippedItem())) event.newSpeed = 0f; } } ...which makes it so that you can't harvest wood without proper tools. This is working perfectly in Eclipse, but does not after reobfuscating and using it on a universal forged Minecraft. I'm aware that "f", "setRequiresTool" gets reobfuscated to something that Minecraft can't read. Anyone has an idea how to transport the source code to something properly reobfuscated and useable in Minecraft?
June 29, 201312 yr wait, sorry, are you asking how to get the appropriate obfuscated names or how to find out if mc's running in an obfuscated environment?
June 29, 201312 yr Hey folks, I'm having this code... Method m = ReflectionHelper.findMethod(Material.class, Material.wood, new String[] {"f", "setRequiresTool"}); try { m.invoke(Material.wood); } catch (Throwable t) { t.printStackTrace(); } public void breakSpeed(PlayerEvent.BreakSpeed event) { if (event.block.blockMaterial == Material.wood) { if (!ForgeHooks.canToolHarvestBlock(event.block, event.metadata, event.entityPlayer.getCurrentEquippedItem())) event.newSpeed = 0f; } } ...which makes it so that you can't harvest wood without proper tools. This is working perfectly in Eclipse, but does not after reobfuscating and using it on a universal forged Minecraft. I'm aware that "f", "setRequiresTool" gets reobfuscated to something that Minecraft can't read. Anyone has an idea how to transport the source code to something properly reobfuscated and useable in Minecraft? Replace "f" with "func_76221_f". It's the SRG name of setRequiresTool. You can find it for methods under /mcp/conf/methods.csv and for fields under /mcp/conf/fields.csv 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.
June 30, 201312 yr Author Replace "f" with "func_76221_f". It's the SRG name of setRequiresTool. You can find it for methods under /mcp/conf/methods.csv and for fields under /mcp/conf/fields.csv Thank you very much. Works like a charm now. Could you answer another question then? I set up a new copper axe as tool, but when trying to chop wood with it (when including the code that prevents chopping wood with your bare hands only), the axe does not seem to get recognized as tool, but rather as normal weapon, or the wrong tool. Here's the code: Axe Code package MetallurgyRealism; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.EnumToolMaterial; import net.minecraft.item.ItemAxe; public class ToolAxeCopper extends ItemAxe{ public ToolAxeCopper(int i, EnumToolMaterial enumToolMaterial){ super(i, enumToolMaterial); setMaxStackSize(1); setCreativeTab(MetallurgyRealismModBase.MetallurgyRealismTab); } @Override public void registerIcons(IconRegister iconRegister) { itemIcon = iconRegister.registerIcon("MetallurgyRealism:axecopper"); } } Enum Code public static EnumToolMaterial CopperMaterial = EnumHelper.addToolMaterial("CopperMaterial", 3, 5, 15.0F, 1, 15); Register and ID code public static Item toolAxeCopper; int toolAxeCopperID = 6029; toolAxeCopper = new ToolAxeCopper(toolAxeCopperID, CopperMaterial).setUnlocalizedName("axecopper"); GameRegistry.registerItem(toolAxeCopper, "ToolAxeCopper"); LanguageRegistry.addName(toolAxeCopper, "Copper Axe");
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.