Class HeldItemSwaps
java.lang.Object
net.ixdarklord.coolcatcore.api.client.item.HeldItemSwaps
When the item in a player's hand is shown being put away and taken out again. Vanilla plays that swap whenever the
held stack changes in any way but a few (durability, for one), so data a mod keeps on a held item (a mark, a
charge, a page) makes the item dip out of view and back each time it changes. Here a mod says which changes are
quiet: the stack shown simply becomes the new one, in place.
HeldItemSwaps.quiet("mymod_charge"); // changes to these NBT keys alone
HeldItemSwaps.register((shown, next) -> shown.is(MyItems.WAND) // or any test of the old and new stacks
&& next.is(MyItems.WAND));
Changes to a mod's attachments (net.ixdarklord.coolcatcore.api.attachment) are quiet already, unless the
attachment was built with swapAnimation().
Client only; call it while the client sets up.-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisQuiet(net.minecraft.world.item.ItemStack shown, net.minecraft.world.item.ItemStack next) Whether going from the stack shown to the one now held is quiet: the new one simply takes its place.static voidChanges to these keys of a stack's NBT alone don't play the swap.static voidregister(HeldItemSwaps.SwapFilter filter) A test of the stack shown and the one now held: when it says they are the same item, no swap plays.static booleansameIgnoring(net.minecraft.world.item.ItemStack shown, net.minecraft.world.item.ItemStack next, Predicate<String> ignored) The same item and count, and the same NBT but for the keys ignored.
-
Method Details
-
quiet
Changes to these keys of a stack's NBT alone don't play the swap. -
register
A test of the stack shown and the one now held: when it says they are the same item, no swap plays. -
isQuiet
public static boolean isQuiet(net.minecraft.world.item.ItemStack shown, net.minecraft.world.item.ItemStack next) Whether going from the stack shown to the one now held is quiet: the new one simply takes its place. -
sameIgnoring
public static boolean sameIgnoring(net.minecraft.world.item.ItemStack shown, net.minecraft.world.item.ItemStack next, Predicate<String> ignored) The same item and count, and the same NBT but for the keys ignored.
-