Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Introduce XPConsumed property to PlayerItemMendEvent

Open ryantheleach opened this issue 2 years ago • 4 comments

Is your feature request related to a problem?

I've created a plugin that wants to be able to change the max durability of a given individual item stack (It emulates custom items with customModelData).

As a part of this, it emulates durability via tracking it's own property when the item is used, and updating the real damage as a 'display' value that is interpolated.

However mending throws a huge wrench into this, as a CarrotOnAStick only has 25 durability, so it is VERY cheap to repair with mending.

So expanding this out to, say, 2000 uses, you can get instant repairs of very expensive items.

Describe the solution you'd like.

I think the minimal patch to spigot, would be allowing paper plugins to set the value of k, or maybe this.durabilityToXP(j)

image

So, the event would expose both the repairAmount, as well as the XP remaining.

This would allow for people to change the 'scaling' rate of mending universally, making it more or less buffed/nerfed, or implement interesting mechanics.

For this reason, I think it's worthy on it's own right, than the alternative proposed below.

However, I foresee a problem though, on whether setting the RepairAmount would also mutate the XPRemaining for spigot compatibility.

So maybe it would need to be XPConsumed?

Or maybe it would need to be deprecated under paper, since setting the repairAmount would need to mutate both, and expose a replacement property that does not get changed whenever repairAmount is?

Anyway, I leave this to the implementer to consider.

Describe alternatives you've considered.

Exposing a general purpose durability event, that mending, item use and repair recipes would trigger.

However it's my belief that this could be painful to maintain / upkeep.

Other

No response

ryantheleach avatar Jan 11 '22 03:01 ryantheleach

Maybe can make a PR in upstream for this... but my question is how handle this... i mean if the "k" its exposed using the current value if the user change repairamount then in teory need update the "k" value or keep the event value...

maybe can be better add in Orb class a method for change the formule for durabilityToXP and xpToDurability in vanilla its 2.

Doc94 avatar Jan 11 '22 12:01 Doc94

Simply changing the formula does not cover my usecase. I specifically need the values to be asymmetric, per itemstack.

ryantheleach avatar Jan 11 '22 20:01 ryantheleach

@ryantheleach can you confirm that the changes made in the linked PR resolve your issue?

Machine-Maker avatar Jan 21 '22 17:01 Machine-Maker

@Machine-Maker This would very much solve our issue :) I'm looking forward to this being merged

oddlama avatar Aug 23 '22 10:08 oddlama