diff --git a/eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/eco/proxy/v1_16_R3/FastItemStackUtils.java b/eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/eco/proxy/v1_16_R3/FastItemStackUtils.java index 4a97f331b..438f7489f 100644 --- a/eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/eco/proxy/v1_16_R3/FastItemStackUtils.java +++ b/eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/eco/proxy/v1_16_R3/FastItemStackUtils.java @@ -8,14 +8,15 @@ import java.lang.reflect.Field; public class FastItemStackUtils { - private static final Field field; + private static final Field FIELD; public static net.minecraft.server.v1_16_R3.ItemStack getNMSStack(@NotNull final ItemStack itemStack) { if (!(itemStack instanceof CraftItemStack)) { return CraftItemStack.asNMSCopy(itemStack); } else { try { - return (net.minecraft.server.v1_16_R3.ItemStack) field.get(itemStack); + net.minecraft.server.v1_16_R3.ItemStack nms = (net.minecraft.server.v1_16_R3.ItemStack) FIELD.get(itemStack); + return nms == null ? CraftItemStack.asNMSCopy(itemStack) : nms; } catch (ReflectiveOperationException e) { e.printStackTrace(); return null; @@ -37,6 +38,6 @@ public static net.minecraft.server.v1_16_R3.ItemStack getNMSStack(@NotNull final assert temp != null; Validate.notNull(temp, "Error occurred in initialization!"); - field = temp; + FIELD = temp; } } diff --git a/eco-core/core-nms/v1_17_R1/src/main/java/com/willfp/eco/proxy/v1_17_R1/FastItemStackUtils.java b/eco-core/core-nms/v1_17_R1/src/main/java/com/willfp/eco/proxy/v1_17_R1/FastItemStackUtils.java index 22eab2c6d..73ff85f47 100644 --- a/eco-core/core-nms/v1_17_R1/src/main/java/com/willfp/eco/proxy/v1_17_R1/FastItemStackUtils.java +++ b/eco-core/core-nms/v1_17_R1/src/main/java/com/willfp/eco/proxy/v1_17_R1/FastItemStackUtils.java @@ -10,14 +10,15 @@ @UtilityClass public class FastItemStackUtils { - private static final Field field; + private static final Field FIELD; public static net.minecraft.world.item.ItemStack getNMSStack(@NotNull final ItemStack itemStack) { if (!(itemStack instanceof CraftItemStack)) { return CraftItemStack.asNMSCopy(itemStack); } else { try { - return (net.minecraft.world.item.ItemStack) field.get(itemStack); + net.minecraft.world.item.ItemStack nms = (net.minecraft.world.item.ItemStack) FIELD.get(itemStack); + return nms == null ? CraftItemStack.asNMSCopy(itemStack) : nms; } catch (ReflectiveOperationException e) { e.printStackTrace(); return null; @@ -39,6 +40,6 @@ public static net.minecraft.world.item.ItemStack getNMSStack(@NotNull final Item assert temp != null; Validate.notNull(temp, "Error occurred in initialization!"); - field = temp; + FIELD = temp; } }