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(MyComponents.CHARGE); // changes to these components 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 voidThe same for a component registered later: it is looked up only once stacks are compared, so a mod can call this while it sets up, before its components are registered (as they are then on NeoForge).static voidquiet(net.minecraft.core.component.DataComponentType<?>... types) Changes to these components alone, and to those that vanilla already ignores, 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.
-
Method Details
-
quiet
public static void quiet(net.minecraft.core.component.DataComponentType<?>... types) Changes to these components alone, and to those that vanilla already ignores, don't play the swap. -
quiet
public static void quiet(Supplier<? extends net.minecraft.core.component.DataComponentType<?>> type) The same for a component registered later: it is looked up only once stacks are compared, so a mod can call this while it sets up, before its components are registered (as they are then on NeoForge). -
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.
-