From 00fc4238d399e93875eae8c25df834beeffba30a Mon Sep 17 00:00:00 2001 From: apple502j <33279053+apple502j@users.noreply.github.com> Date: Sun, 10 Mar 2024 16:42:55 +0900 Subject: [PATCH] Finish NBT -> components changes Breaking change: `FabricItem#allowNbtUpdateAnimation` was renamed to `allowComponentsUpdateAnimation`. --- .../item/client/HeldItemRendererMixin.java | 6 +++--- .../fabric/api/item/v1/FabricItem.java | 10 ++++----- .../fabric/test/item/UpdatingItem.java | 2 +- fabric-transfer-api-v1/README.md | 6 +++--- .../v1/fluid/CauldronFluidContent.java | 2 +- .../v1/fluid/base/EmptyItemFluidStorage.java | 10 ++++----- .../v1/fluid/base/FullItemFluidStorage.java | 6 +++--- .../fabric/api/transfer/v1/package-info.java | 6 +++--- .../transfer/v1/storage/TransferVariant.java | 2 +- .../base/SingleVariantItemStorage.java | 21 ++++++++++--------- .../transfer/unittests/FluidItemTests.java | 2 +- .../test/transfer/unittests/ItemTests.java | 4 ++-- .../SingleVariantItemStorageTests.java | 8 ++++--- 13 files changed, 44 insertions(+), 41 deletions(-) diff --git a/fabric-item-api-v1/src/client/java/net/fabricmc/fabric/mixin/item/client/HeldItemRendererMixin.java b/fabric-item-api-v1/src/client/java/net/fabricmc/fabric/mixin/item/client/HeldItemRendererMixin.java index 3f10a0e211..a6153406f6 100644 --- a/fabric-item-api-v1/src/client/java/net/fabricmc/fabric/mixin/item/client/HeldItemRendererMixin.java +++ b/fabric-item-api-v1/src/client/java/net/fabricmc/fabric/mixin/item/client/HeldItemRendererMixin.java @@ -31,7 +31,7 @@ import net.fabricmc.fabric.api.item.v1.FabricItem; /** - * Allow canceling the held item update animation if {@link FabricItem#allowNbtUpdateAnimation} returns false. + * Allow canceling the held item update animation if {@link FabricItem#allowComponentsUpdateAnimation} returns false. */ @Mixin(HeldItemRenderer.class) public class HeldItemRendererMixin { @@ -51,7 +51,7 @@ private void modifyProgressAnimation(CallbackInfo ci) { ItemStack newMainStack = client.player.getMainHandStack(); if (mainHand.getItem() == newMainStack.getItem()) { - if (!mainHand.getItem().allowNbtUpdateAnimation(client.player, Hand.MAIN_HAND, mainHand, newMainStack)) { + if (!mainHand.getItem().allowComponentsUpdateAnimation(client.player, Hand.MAIN_HAND, mainHand, newMainStack)) { mainHand = newMainStack; } } @@ -60,7 +60,7 @@ private void modifyProgressAnimation(CallbackInfo ci) { ItemStack newOffStack = client.player.getOffHandStack(); if (offHand.getItem() == newOffStack.getItem()) { - if (!offHand.getItem().allowNbtUpdateAnimation(client.player, Hand.OFF_HAND, offHand, newOffStack)) { + if (!offHand.getItem().allowComponentsUpdateAnimation(client.player, Hand.OFF_HAND, offHand, newOffStack)) { offHand = newOffStack; } } diff --git a/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/api/item/v1/FabricItem.java b/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/api/item/v1/FabricItem.java index 750c68003c..6cdc69de7d 100644 --- a/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/api/item/v1/FabricItem.java +++ b/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/api/item/v1/FabricItem.java @@ -42,8 +42,8 @@ */ public interface FabricItem { /** - * When the NBT of an item stack in the main hand or off hand changes, vanilla runs an "update animation". - * This function is called on the client side when the NBT or count of the stack has changed, but not the item, + * When the components of an item stack in the main hand or off hand changes, vanilla runs an "update animation". + * This function is called on the client side when the components or count of the stack has changed, but not the item, * and returning false cancels this animation. * * @param player the current player; this may be safely cast to {@link net.minecraft.client.network.ClientPlayerEntity} in client-only code @@ -52,13 +52,13 @@ public interface FabricItem { * @param newStack the new stack, also of this item * @return true to run the vanilla animation, false to cancel it. */ - default boolean allowNbtUpdateAnimation(PlayerEntity player, Hand hand, ItemStack oldStack, ItemStack newStack) { + default boolean allowComponentsUpdateAnimation(PlayerEntity player, Hand hand, ItemStack oldStack, ItemStack newStack) { return true; } /** - * When the NBT of the selected stack changes, block breaking progress is reset. - * This function is called when the NBT of the selected stack has changed, + * When the components of the selected stack changes, block breaking progress is reset. + * This function is called when the components of the selected stack has changed, * and returning true allows the block breaking progress to continue. * * @param player the player breaking the block diff --git a/fabric-item-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/UpdatingItem.java b/fabric-item-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/UpdatingItem.java index 54f4fe6e0e..e5683f656f 100644 --- a/fabric-item-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/UpdatingItem.java +++ b/fabric-item-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/UpdatingItem.java @@ -51,7 +51,7 @@ public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, } @Override - public boolean allowNbtUpdateAnimation(PlayerEntity player, Hand hand, ItemStack originalStack, ItemStack updatedStack) { + public boolean allowComponentsUpdateAnimation(PlayerEntity player, Hand hand, ItemStack originalStack, ItemStack updatedStack) { return allowUpdateAnimation; } diff --git a/fabric-transfer-api-v1/README.md b/fabric-transfer-api-v1/README.md index 0dd515eded..42186b22ca 100644 --- a/fabric-transfer-api-v1/README.md +++ b/fabric-transfer-api-v1/README.md @@ -23,7 +23,7 @@ and combine them with `CombinedStorage`. ## Fluid transfer A `Storage` is any object that can store fluids. It is just a `Storage`, where `T` is -[`FluidVariant`](src/main/java/net/fabricmc/fabric/api/transfer/v1/fluid/FluidVariant.java), the immutable combination of a `Fluid` and additional NBT data. +[`FluidVariant`](src/main/java/net/fabricmc/fabric/api/transfer/v1/fluid/FluidVariant.java), the immutable combination of a `Fluid` and additional components. Instances can be accessed through the API lookups defined in [`FluidStorage`](src/main/java/net/fabricmc/fabric/api/transfer/v1/fluid/FluidStorage.java). The unit for fluid transfer is 1/81000ths of a bucket, also known as _droplets_. @@ -31,8 +31,8 @@ The unit for fluid transfer is 1/81000ths of a bucket, also known as _droplets_. to work with droplets. Client-side [Fluid variant rendering](src/main/java/net/fabricmc/fabric/api/transfer/v1/client/fluid/FluidVariantRendering.java) will use regular fluid rendering by default, -ignoring the additional NBT data. -`Fluid`s that wish to render differently depending on the stored NBT data can register a +ignoring the additional components. +`Fluid`s that wish to render differently depending on the stored components can register a [`FluidVariantRenderHandler`](src/main/java/net/fabricmc/fabric/api/transfer/v1/client/fluid/FluidVariantRenderHandler.java). ## Item transfer diff --git a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/api/transfer/v1/fluid/CauldronFluidContent.java b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/api/transfer/v1/fluid/CauldronFluidContent.java index 157eee86ef..342a37b363 100644 --- a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/api/transfer/v1/fluid/CauldronFluidContent.java +++ b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/api/transfer/v1/fluid/CauldronFluidContent.java @@ -39,7 +39,7 @@ *

The {@code CauldronFluidContent} itself defines: *