Skip to content

Broken tool head drops when tool damage is skipped due to custom behavior #138

Description

@MetaflameDragon

This has been previously posted as an issue under Toolsmith: Mario90900/Toolsmith#49

In brief: when a tool at 1 durability is used (or the damage amount would otherwise cause it to break), but Toolsmith's sharpness prevents the tool from taking durability damage, SmithingPlus still assumes that the tool is about to break and drops a broken tool head, effectively duplicating the tool head.


I read through the code on either side (see my comments on the other issue), and I feel like it may be more appropriate to fix the behavior in Smithing Plus.

Previously, Toolsmith used a prefix patch with a higher priority, and skipped further execution if a tinkered tool head didn't break, or a smithed tool took no durability damage. If tool sharpness was sufficiently high (or an RNG roll succeeded), and no durability damage was dealt, Smithing Plus code that checks for tool destruction was skipped.

Toolsmith has since moved the code from a patch to a method override, meaning that Smithing Plus' patch now runs before Toolsmith. This means that a broken tool head is dropped even if Toolsmith later decides to not decrement tool durability.

The reason I think this is a bug in Smithing Plus rather than Toolsmith is that Smithing Plus' ItemDamagePatches::Prefix_DamageItem assumes that durability < amount means that the tool will be destroyed. If the subsequent OnDamageItem code does not destroy the item for one reason or another, a broken tool head will have been dropped while the original item still exists. I think that this would cause the same bug to happen with any other mod that alters durability damage behavior.


I wanna see if I can give fixing it a shot. My idea is to use a postfix patch instead, or track the tool durability damage across a prefix & postfix and only dropping the tool head if it actually breaks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions