aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky/skyblocker/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/utils')
-rw-r--r--src/main/java/de/hysky/skyblocker/utils/ItemUtils.java14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java b/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java
index ea861a88..fa04acf8 100644
--- a/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java
+++ b/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java
@@ -44,6 +44,7 @@ public class ItemUtils {
/**
* Gets the {@code ExtraAttributes} NBT tag from the item stack.
+ *
* @param stack the item stack to get the {@code ExtraAttributes} NBT tag from
* @return an optional containing the {@code ExtraAttributes} NBT tag of the item stack
*/
@@ -53,16 +54,18 @@ public class ItemUtils {
/**
* Gets the {@code ExtraAttributes} NBT tag from the item stack.
+ *
* @param stack the item stack to get the {@code ExtraAttributes} NBT tag from
* @return the {@code ExtraAttributes} NBT tag of the item stack, or null if the item stack is null or does not have an {@code ExtraAttributes} NBT tag
*/
@Nullable
public static NbtCompound getExtraAttributes(@NotNull ItemStack stack) {
- return getExtraAttributesOptional(stack).orElse(null);
+ return stack.getSubNbt(EXTRA_ATTRIBUTES);
}
/**
* Gets the internal name of the item stack from the {@code ExtraAttributes} NBT tag.
+ *
* @param stack the item stack to get the internal name from
* @return an optional containing the internal name of the item stack
*/
@@ -72,15 +75,18 @@ public class ItemUtils {
/**
* Gets the internal name of the item stack from the {@code ExtraAttributes} NBT tag.
+ *
* @param stack the item stack to get the internal name from
* @return the internal name of the item stack, or an empty string if the item stack is null or does not have an internal name
*/
public static String getItemId(@NotNull ItemStack stack) {
- return getItemIdOptional(stack).orElse("");
+ NbtCompound extraAttributes = getExtraAttributes(stack);
+ return extraAttributes != null ? extraAttributes.getString(ID) : "";
}
/**
* Gets the UUID of the item stack from the {@code ExtraAttributes} NBT tag.
+ *
* @param stack the item stack to get the UUID from
* @return an optional containing the UUID of the item stack
*/
@@ -90,11 +96,13 @@ public class ItemUtils {
/**
* Gets the UUID of the item stack from the {@code ExtraAttributes} NBT tag.
+ *
* @param stack the item stack to get the UUID from
* @return the UUID of the item stack, or null if the item stack is null or does not have a UUID
*/
public static String getItemUuid(@NotNull ItemStack stack) {
- return getItemUuidOptional(stack).orElse("");
+ NbtCompound extraAttributes = getExtraAttributes(stack);
+ return extraAttributes != null ? extraAttributes.getString(UUID) : "";
}
@Nullable