Roundaround / mc-fabric-stackables

MIT License
4 stars 0 forks source link

[Bug] Enchanted Book Duplication in Anvils #16

Closed WisteriaSp closed 10 months ago

WisteriaSp commented 1 year ago

Enchanted books can be duplicated when combining them in the anvil gui. While this normally wouldn't be a problem in vanilla survival due to the "too expensive" mechanic, it does cause a lot of issues when using mods that remove that mechanic or the xp cost from anvil usage. This occurs on both 1.3.1 and 1.4.0. The only mods I'm running are Fabrication, Stackables, Mod Menu, and Fabric Api. This issue can be reproduced without Fabrication by using creative mode to combine the books.

Dupe: https://streamable.com/dk55ic

Arturequis commented 1 year ago

Can you fix it for 1.19.4 too?

tesseract-two commented 1 year ago

I can reproduce this with any stackable items, by renaming them.

Setup: Minecraft 1.20.2 No Telemetry 1.7.0 Stackables 1.4.0

Steps to reproduce:

  1. Get a stack of items and try to rename them at a anvil
  2. It fails, so add another number/letter and try again (Without removing the stack from the anvil!)
  3. Unlimited items!
ekimekim commented 10 months ago

Can confirm I'm also seeing this on Minecraft 1.20.1, Stackables 1.3.1. Attempting to rename any stack of more than 1 item will give you a stack of the renamed item, as well as a stack one smaller of the original item.

The culprit seems to be the anvil handling code introduced in https://github.com/Roundaround/mc-fabric-stackables/commit/e4693a52c06ac07400bda6a31bea95a9552927e0 to fix #9. Specifically it always decrements the existing stack by 1 even if a whole stack was meant to be consumed. I don't know enough about minecraft modding to suggest a proper fix, but one idea may be to only apply this to the second slot, not both slots, as only the first slot is used when renaming (this could still cause problems if trying to combine a stack of enchanted books with another enchanted book, but that seems like a more niche case). My usage of the mod doesn't allow enchanted book stacking anyway, so I may attempt to just remove the anvil mixin.

UPDATE: I had some trouble building a custom version so instead we've decided to revert to 1.3.0 (and disable suspicious stew and enchanted book stacking).

Roundaround commented 10 months ago

Duplicate of #21

Moving any further discussion there because there are lots of individual issues I need to fix about anvils