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)
These new
shrink
methods are going to replace the previousremove
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>)
andCustomItem#shrink(ItemStack, int, boolean, Inventory, Player, Location)