From 70a7e2528cc4757e324c99dc8b51f082a457d1db Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Fri, 14 Jun 2024 20:01:38 +0800 Subject: Fix dynamic registry usage and related tests --- .../utils/datafixer/ItemStackComponentizationFixerTest.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/test/java/de/hysky/skyblocker/utils/datafixer') diff --git a/src/test/java/de/hysky/skyblocker/utils/datafixer/ItemStackComponentizationFixerTest.java b/src/test/java/de/hysky/skyblocker/utils/datafixer/ItemStackComponentizationFixerTest.java index a151ae2f..2aca8f8e 100644 --- a/src/test/java/de/hysky/skyblocker/utils/datafixer/ItemStackComponentizationFixerTest.java +++ b/src/test/java/de/hysky/skyblocker/utils/datafixer/ItemStackComponentizationFixerTest.java @@ -17,19 +17,16 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.StringNbtReader; -import net.minecraft.registry.BuiltinRegistries; import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.RegistryWrapper.WrapperLookup; import net.minecraft.util.Util; public class ItemStackComponentizationFixerTest { - /*private final WrapperLookup LOOKUP = BuiltinRegistries.createWrapperLookup(); private final NbtCompound NBT = convertToNbt("{id:\"minecraft:diamond_sword\",Count:1,tag:{ExtraAttributes:{id:\"TEST\"}}}"); private final Gson GSON = new Gson(); private final ItemStack TEST_STACK = Util.make(new ItemStack(Items.DIAMOND_SWORD, 1), item -> { ItemEnchantmentsComponent.Builder builder = new ItemEnchantmentsComponent.Builder(ItemEnchantmentsComponent.DEFAULT); - builder.add(LOOKUP.getWrapperOrThrow(RegistryKeys.ENCHANTMENT).getOrThrow(Enchantments.SHARPNESS), 1); + builder.add(ItemStackComponentizationFixer.getRegistryLookup().getWrapperOrThrow(RegistryKeys.ENCHANTMENT).getOrThrow(Enchantments.SHARPNESS), 1); item.set(DataComponentTypes.ENCHANTMENTS, builder.build()); }); @@ -47,7 +44,7 @@ public class ItemStackComponentizationFixerTest { @Test void testDataFixer() { ItemStack fixedStack = ItemStackComponentizationFixer.fixUpItem(NBT); - JsonElement stackJson = ItemStack.CODEC.encodeStart(LOOKUP.getOps(JsonOps.INSTANCE), fixedStack).getOrThrow(); + JsonElement stackJson = ItemStack.CODEC.encodeStart(ItemStackComponentizationFixer.getRegistryLookup().getOps(JsonOps.INSTANCE), fixedStack).getOrThrow(); Assertions.assertEquals("{\"id\":\"minecraft:diamond_sword\",\"count\":1,\"components\":{\"minecraft:custom_data\":{\"ExtraAttributes\":{\"id\":\"TEST\"}}}}", GSON.toJson(stackJson)); } @@ -89,5 +86,5 @@ public class ItemStackComponentizationFixerTest { } catch (Exception e) { return new NbtCompound(); } - }*/ + } } -- cgit