Jump to content

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


Recommended Posts


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 ?

Link to comment
Share on other sites

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.efficiencyOnProperMaterial = materialIn.getEfficiencyOnProperMaterial();
        this.damageVsEntity = attackDamageIn + materialIn.getDamageVsEntity();


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

Link to comment
Share on other sites

Well, then you override them there as well. Iterate the item registry and find all instances of


that use the


you want to change. Then you call


and set the


field using reflection. Enchantability will be read from the


every time and for


instances are constructed later than your scan you don't have to worry since they will read the new values from the



Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

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