WolfyScript / WolfyUtils-Spigot

The WolfyUtilities implementation for the Spigot platform
10 stars 4 forks source link

CustomItem shrink methods #31

Closed WolfyScript closed 2 years ago

WolfyScript commented 2 years ago

These new shrink methods are going to replace the previous remove with a more concise behaviour, like instead of manipulating the passed in ItemStack and relying on that side-effect, it returns the replaced/manipulated stack. Additionally it allows you to combine the custom replacement and durability cost, while before you could only use one at a time. If the item breaks due to the durability cost it is now replaced by the vanilla or custom replacement.

You can also provide your own function that handles replacements of stackable stacks. Like dropping the remains that do not fit in the inventory. There is a method with the default behaviour, that you can use too. See CustomItem#shrink(ItemStack, int, boolean, BiFunction<CustomItem, ItemStack, ItemStack>) and CustomItem#shrink(ItemStack, int, boolean, Inventory, Player, Location)