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.

[1.10][Solved] Edit (or simulate editing) vMC tool materials

Featured Replies

Posted

Hello,

I'd like to change the values set in original vanilla tool materials.

...
        WOOD(0, 59, 2.0F, 0.0F, 15),
        STONE(1, 131, 4.0F, 1.0F, 5),
        IRON(2, 250, 6.0F, 2.0F, 14),
        DIAMOND(3, 1561, 8.0F, 3.0F, 10),
        GOLD(0, 32, 12.0F, 0.0F, 22);
...

(as seen in Item.ToolMaterial)

I'd like to edit maxUses, efficiency and enchantability.

I can edit maxUses afterwards with Item#setMaxDamage() so that's not a big problem, but the two others are not accessible.

With reflection on ItemTool.efficiencyOnProperMaterial I could change efficiency, but enchantability is a direct call to toolMaterial.getEnch..().

 

Only other option I can think of is creating new materials with EnumHelper, recreate all vanilla tools and use substitution, but even then if some mod (or myself if I forget) compares the material it won't work.

 

Is there any better way for this ?

  • Author

The values are taken from the material in the constructor of ItemTool. Except enchantability.

    protected ItemTool(float attackDamageIn, float attackSpeedIn, Item.ToolMaterial materialIn, Set<Block> effectiveBlocksIn)
    {
        <...>
        this.toolMaterial = materialIn;
        this.effectiveBlocks = effectiveBlocksIn;
        this.maxStackSize = 1;
        this.setMaxDamage(materialIn.getMaxUses());
        this.efficiencyOnProperMaterial = materialIn.getEfficiencyOnProperMaterial();
        this.damageVsEntity = attackDamageIn + materialIn.getDamageVsEntity();
        <...>
    }

 

The vanilla items are instanciated before preInit so it will already be too late.

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.