Jump to content

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


Recommended Posts

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 ?

Posted

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

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

Announcements



×
×
  • Create New...

Important Information

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