Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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?

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?

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.

  • 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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.