percyqaz / UltimateInventory

Minecraft server plugin to streamline inventory management - Supports PaperMC and SpigotMC
https://www.spigotmc.org/resources/ultimate-inventory-1-19-1-20.109298/
MIT License
9 stars 2 forks source link

Support opening anvils from the inventory #5

Closed percyqaz closed 9 months ago

percyqaz commented 1 year ago

This would be a new feature that can work on both Spigot and PaperMC

Original considerations from #3:

@percyqaz:

Anvils could receive random damage as you've pointed out. Adding damage to the anvil while it's in the inventory sounds simple but is actually about the same difficulty as the main feature of opening and editing shulker boxes (I have to think about what happens when it's a stack of anvils, or if you move the slot the anvil is in while using it, for example)


Things required to add this feature as originally described, where the anvil can take damage:

  • Only allow opening 1 anvil and not a stack of anvils in your hand
  • Lock anvils in place once open the same way shulker boxes are locked
  • Add code to prevent moving locked anvil by any inventory interaction
  • Simulate vanilla probability (12%) of taking damage, and apply to the stack whenever the user crafts something*
  • Close the anvil if the item breaks completely

*this is the part I'm particularly not sure about, because it means I have to detect an anvil craft event specifcally when the player is using a "virtual" anvil and not one in the world

Basically the code for this could be a bit of a mess, but I will sleep on it and maybe if it gets requested by more people I can add it

If I'm doing this I'm doing it ignoring anvil durability

percyqaz commented 9 months ago

Done, ignoring anvil durability mechanics Because it ignores durability this feature is off by default and you have to turn it on in the config