From 5401ecc9a8a64f6631503e9553c2ec26bbce7a99 Mon Sep 17 00:00:00 2001 From: Patbox <39821509+Patbox@users.noreply.github.com> Date: Thu, 18 Apr 2024 22:29:28 +0200 Subject: [PATCH] Finish up the 1.20.5 update --- .github/workflows/build.yml | 2 +- .github/workflows/release.yml | 2 +- gradle.properties | 8 +- .../elements/AnimatedGuiElementBuilder.java | 83 +++++++++++++- .../sgui/api/elements/BookElementBuilder.java | 12 ++- .../sgui/api/elements/GuiElementBuilder.java | 102 ++++++++++++++++-- .../eu/pb4/sgui/api/gui/SlotGuiInterface.java | 2 +- .../java/eu/pb4/sgui/testmod/SGuiTest.java | 12 ++- .../java/eu/pb4/sgui/testmod/SnakeGui.java | 30 +++--- 9 files changed, 216 insertions(+), 37 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 53280d0..81dd0ea 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ jobs: matrix: # Use these Java versions java: [ - 17 # Latest version + 21 # Latest version ] # and run on both Linux and Windows os: [ubuntu-20.04, windows-latest] diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c3f7917..a695ae2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,7 +24,7 @@ jobs: - name: Set up JDK uses: actions/setup-java@v1 with: - java-version: 17 + java-version: 21 - name: Grant execute permission for gradlew run: chmod +x gradlew diff --git a/gradle.properties b/gradle.properties index 0a36e27..fe33a03 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,12 +3,12 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/versions.html -minecraft_version=24w13a -yarn_mappings=24w13a+build.2 -loader_version=0.15.7 +minecraft_version=1.20.5-rc1 +yarn_mappings=1.20.5-rc1+build.1 +loader_version=0.15.10 #Fabric api -fabric_version=0.96.12+1.20.5 +fabric_version=0.97.3+1.20.5 # Mod Properties diff --git a/src/main/java/eu/pb4/sgui/api/elements/AnimatedGuiElementBuilder.java b/src/main/java/eu/pb4/sgui/api/elements/AnimatedGuiElementBuilder.java index 3049b54..3b43aa5 100644 --- a/src/main/java/eu/pb4/sgui/api/elements/AnimatedGuiElementBuilder.java +++ b/src/main/java/eu/pb4/sgui/api/elements/AnimatedGuiElementBuilder.java @@ -4,6 +4,7 @@ import com.mojang.authlib.minecraft.MinecraftProfileTextures; import com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.PropertyMap; +import net.minecraft.component.DataComponentType; import net.minecraft.component.DataComponentTypes; import net.minecraft.component.type.CustomModelDataComponent; import net.minecraft.component.type.LoreComponent; @@ -15,6 +16,7 @@ import net.minecraft.item.Items; import net.minecraft.server.MinecraftServer; import net.minecraft.text.Text; +import net.minecraft.util.Rarity; import net.minecraft.util.Unit; import org.jetbrains.annotations.Nullable; @@ -98,7 +100,18 @@ public AnimatedGuiElementBuilder setItem(Item item) { * @return this element builder */ public AnimatedGuiElementBuilder setName(Text name) { - this.itemStack.set(DataComponentTypes.CUSTOM_NAME, name.copy()); + this.itemStack.set(DataComponentTypes.ITEM_NAME, name.copy()); + return this; + } + + /** + * Sets the rarity of the element. + * + * @param rarity to use + * @return this element builder + */ + public AnimatedGuiElementBuilder setRarity(Rarity rarity) { + this.itemStack.set(DataComponentTypes.RARITY, rarity); return this; } @@ -113,6 +126,17 @@ public AnimatedGuiElementBuilder setCount(int count) { return this; } + /** + * Sets the max number of items in the element. + * + * @param count the number of items + * @return this element builder + */ + public AnimatedGuiElementBuilder setMaxCount(int count) { + this.itemStack.set(DataComponentTypes.MAX_STACK_SIZE, count); + return this; + } + /** * Sets the lore lines of the element. * @@ -148,12 +172,53 @@ public AnimatedGuiElementBuilder setDamage(int damage) { } /** - * Hides all Tooltips added through this builder from the element display + * Set the max damage of the element. + * + * @param damage the amount of durability the item is missing + * @return this element builder + */ + public AnimatedGuiElementBuilder setMaxDamage(int damage) { + this.itemStack.set(DataComponentTypes.MAX_DAMAGE, damage); + return this; + } + + /** + * Disables all default components on an item. + * @return this element builder + */ + public AnimatedGuiElementBuilder noDefaults() { + for (var x : this.itemStack.getItem().getComponents()) { + if (this.itemStack.get(x.type()) == x.value()) { + this.itemStack.set(x.type(), null); + } + } + return this; + } + + @Nullable + public T getComponent(DataComponentType type) { + return this.itemStack.get(type); + } + + public AnimatedGuiElementBuilder setComponent(DataComponentType type, @Nullable T value) { + this.itemStack.set(type, value); + return this; + } + + /** + * Hides all component-item related tooltip added by item's or non name/lore components. * * @return this element builder */ - public AnimatedGuiElementBuilder hideFlags() { - // TODO 1.20.5 + public AnimatedGuiElementBuilder hideDefaultTooltip() { + this.itemStack.apply(DataComponentTypes.TRIM, null, comp -> comp != null ? comp.withShowInTooltip(false) : null); + this.itemStack.apply(DataComponentTypes.UNBREAKABLE, null, comp -> comp != null ? comp.withShowInTooltip(false) : null); + this.itemStack.apply(DataComponentTypes.ENCHANTMENTS, null, comp -> comp != null ? comp.withShowInTooltip(false) : null); + this.itemStack.apply(DataComponentTypes.STORED_ENCHANTMENTS, null, comp -> comp != null ? comp.withShowInTooltip(false) : null); + this.itemStack.apply(DataComponentTypes.ATTRIBUTE_MODIFIERS, null, comp -> comp != null ? comp.withShowInTooltip(false) : null); + this.itemStack.apply(DataComponentTypes.DYED_COLOR, null, comp -> comp != null ? comp.withShowInTooltip(false) : null); + this.itemStack.apply(DataComponentTypes.CAN_BREAK, null, comp -> comp != null ? comp.withShowInTooltip(false) : null); + this.itemStack.apply(DataComponentTypes.CAN_PLACE_ON, null, comp -> comp != null ? comp.withShowInTooltip(false) : null); this.itemStack.set(DataComponentTypes.HIDE_ADDITIONAL_TOOLTIP, Unit.INSTANCE); return this; } @@ -180,6 +245,16 @@ public AnimatedGuiElementBuilder glow() { return this; } + /** + * Sets the element to have an enchantment glint. + * + * @return this element builder + */ + public AnimatedGuiElementBuilder glow(boolean value) { + this.itemStack.set(DataComponentTypes.ENCHANTMENT_GLINT_OVERRIDE, value); + return this; + } + /** * Sets the custom model data of the element. * diff --git a/src/main/java/eu/pb4/sgui/api/elements/BookElementBuilder.java b/src/main/java/eu/pb4/sgui/api/elements/BookElementBuilder.java index 7fcd9d9..2a89a33 100644 --- a/src/main/java/eu/pb4/sgui/api/elements/BookElementBuilder.java +++ b/src/main/java/eu/pb4/sgui/api/elements/BookElementBuilder.java @@ -73,7 +73,11 @@ public BookElementBuilder addPage(Text... lines) { } public BookElementBuilder addPage(Text text) { - this.getOrCreatePages().add(NbtString.of(Text.Serialization.toJsonString(text))); + this.itemStack.apply(DataComponentTypes.WRITTEN_BOOK_CONTENT, DEFAULT_WRITTEN_COMPONENT, original -> { + List> updatedPages = new LinkedList<>(original.pages()); + updatedPages.add(RawFilteredPair.of(text)); + return new WrittenBookContentComponent(original.title(), original.author(), original.generation(), updatedPages, original.resolved()); + }); return this; } @@ -101,7 +105,11 @@ public BookElementBuilder setPage(int index, Text... lines) { } public BookElementBuilder setPage(int index, Text text) { - this.getOrCreatePages().set(index, NbtString.of(Text.Serialization.toJsonString(text))); + this.itemStack.apply(DataComponentTypes.WRITTEN_BOOK_CONTENT, DEFAULT_WRITTEN_COMPONENT, original -> { + List> updatedPages = new LinkedList<>(original.pages()); + updatedPages.set(index, RawFilteredPair.of(text)); + return new WrittenBookContentComponent(original.title(), original.author(), original.generation(), updatedPages, original.resolved()); + }); return this; } diff --git a/src/main/java/eu/pb4/sgui/api/elements/GuiElementBuilder.java b/src/main/java/eu/pb4/sgui/api/elements/GuiElementBuilder.java index 9a29ce3..8e2da46 100644 --- a/src/main/java/eu/pb4/sgui/api/elements/GuiElementBuilder.java +++ b/src/main/java/eu/pb4/sgui/api/elements/GuiElementBuilder.java @@ -4,6 +4,7 @@ import com.mojang.authlib.minecraft.MinecraftProfileTextures; import com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.PropertyMap; +import net.minecraft.component.DataComponentType; import net.minecraft.component.DataComponentTypes; import net.minecraft.component.type.CustomModelDataComponent; import net.minecraft.component.type.LoreComponent; @@ -15,6 +16,7 @@ import net.minecraft.item.Items; import net.minecraft.server.MinecraftServer; import net.minecraft.text.Text; +import net.minecraft.util.Rarity; import net.minecraft.util.Unit; import org.jetbrains.annotations.Nullable; @@ -28,8 +30,8 @@ * * @see GuiElementBuilderInterface */ -@SuppressWarnings({"unused"}) -public class GuiElementBuilder implements GuiElementBuilderInterface { +@SuppressWarnings({"unused", "rawtypes"}) +public class GuiElementBuilder implements GuiElementBuilderInterface { protected ItemStack itemStack = new ItemStack(Items.STONE); protected GuiElement.ClickCallback callback = GuiElementInterface.EMPTY_CALLBACK; @@ -101,7 +103,18 @@ public GuiElementBuilder setItem(Item item) { * @return this element builder */ public GuiElementBuilder setName(Text name) { - this.itemStack.set(DataComponentTypes.CUSTOM_NAME, name.copy()); + this.itemStack.set(DataComponentTypes.ITEM_NAME, name.copy()); + return this; + } + + /** + * Sets the rarity of the element. + * + * @param rarity to use + * @return this element builder + */ + public GuiElementBuilder setRarity(Rarity rarity) { + this.itemStack.set(DataComponentTypes.RARITY, rarity); return this; } @@ -116,6 +129,18 @@ public GuiElementBuilder setCount(int count) { return this; } + + /** + * Sets the max number of items in the element. + * + * @param count the number of items + * @return this element builder + */ + public GuiElementBuilder setMaxCount(int count) { + this.itemStack.set(DataComponentTypes.MAX_STACK_SIZE, count); + return this; + } + /** * Sets the lore lines of the element. * @@ -151,16 +176,66 @@ public GuiElementBuilder setDamage(int damage) { } /** - * Hides all Tooltips added through this builder from the element display + * Set the max damage of the element. * + * @param damage the amount of durability the item is missing * @return this element builder */ - public GuiElementBuilder hideFlags() { - // TODO 1.20.5 + public GuiElementBuilder setMaxDamage(int damage) { + this.itemStack.set(DataComponentTypes.MAX_DAMAGE, damage); + return this; + } + + /** + * Disables all default components on an item. + * @return this element builder + */ + public GuiElementBuilder noDefaults() { + for (var x : this.itemStack.getItem().getComponents()) { + if (this.itemStack.get(x.type()) == x.value()) { + this.itemStack.set(x.type(), null); + } + } + return this; + } + + @Nullable + public T getComponent(DataComponentType type) { + return this.itemStack.get(type); + } + + public GuiElementBuilder setComponent(DataComponentType type, @Nullable T value) { + this.itemStack.set(type, value); + return this; + } + + /** + * Hides all component-item related tooltip added by item's or non name/lore components. + * + * @return this element builder + */ + public GuiElementBuilder hideDefaultTooltip() { + this.itemStack.apply(DataComponentTypes.TRIM, null, comp -> comp != null ? comp.withShowInTooltip(false) : null); + this.itemStack.apply(DataComponentTypes.UNBREAKABLE, null, comp -> comp != null ? comp.withShowInTooltip(false) : null); + this.itemStack.apply(DataComponentTypes.ENCHANTMENTS, null, comp -> comp != null ? comp.withShowInTooltip(false) : null); + this.itemStack.apply(DataComponentTypes.STORED_ENCHANTMENTS, null, comp -> comp != null ? comp.withShowInTooltip(false) : null); + this.itemStack.apply(DataComponentTypes.ATTRIBUTE_MODIFIERS, null, comp -> comp != null ? comp.withShowInTooltip(false) : null); + this.itemStack.apply(DataComponentTypes.DYED_COLOR, null, comp -> comp != null ? comp.withShowInTooltip(false) : null); + this.itemStack.apply(DataComponentTypes.CAN_BREAK, null, comp -> comp != null ? comp.withShowInTooltip(false) : null); + this.itemStack.apply(DataComponentTypes.CAN_PLACE_ON, null, comp -> comp != null ? comp.withShowInTooltip(false) : null); this.itemStack.set(DataComponentTypes.HIDE_ADDITIONAL_TOOLTIP, Unit.INSTANCE); return this; } + /** + * Hides tooltip completely, making it never show + * @return this element builder + */ + public GuiElementBuilder hideTooltip() { + this.itemStack.set(DataComponentTypes.HIDE_TOOLTIP, Unit.INSTANCE); + return this; + } + /** * Give the element the specified enchantment. * @@ -183,6 +258,16 @@ public GuiElementBuilder glow() { return this; } + /** + * Sets the element to have an enchantment glint. + * + * @return this element builder + */ + public GuiElementBuilder glow(boolean value) { + this.itemStack.set(DataComponentTypes.ENCHANTMENT_GLINT_OVERRIDE, value); + return this; + } + /** * Sets the custom model data of the element. * @@ -287,4 +372,9 @@ public ItemStack asStack() { public GuiElement build() { return new GuiElement(this.itemStack, this.callback); } + + @Deprecated(forRemoval = true) + public GuiElementBuilder hideFlags() { + return this.hideDefaultTooltip(); + } } diff --git a/src/main/java/eu/pb4/sgui/api/gui/SlotGuiInterface.java b/src/main/java/eu/pb4/sgui/api/gui/SlotGuiInterface.java index b78bf6d..b271116 100644 --- a/src/main/java/eu/pb4/sgui/api/gui/SlotGuiInterface.java +++ b/src/main/java/eu/pb4/sgui/api/gui/SlotGuiInterface.java @@ -123,7 +123,7 @@ default boolean insertItem(ItemStack stack, int startIndex, int endIndex, boolea slot = this.getSlotRedirectOrPlayer(i); if (slot != null && slot.canInsert(stack)) { itemStack = slot.getStack(); - if (!itemStack.isEmpty() && ItemStack.canCombine(stack, itemStack)) { + if (!itemStack.isEmpty() && ItemStack.areItemsAndComponentsEqual(stack, itemStack)) { int j = itemStack.getCount() + stack.getCount(); if (j <= stack.getMaxCount()) { stack.setCount(0); diff --git a/src/testmod/java/eu/pb4/sgui/testmod/SGuiTest.java b/src/testmod/java/eu/pb4/sgui/testmod/SGuiTest.java index 72d9a4d..07a6a69 100644 --- a/src/testmod/java/eu/pb4/sgui/testmod/SGuiTest.java +++ b/src/testmod/java/eu/pb4/sgui/testmod/SGuiTest.java @@ -60,7 +60,7 @@ public boolean onClick(int index, ClickType type, SlotActionType action, GuiElem @Override public void onTick() { - this.setSlot(0, new GuiElementBuilder(Items.ARROW).setCount((int) (player.getServerWorld().getTime() % 127))); + this.setSlot(0, new GuiElementBuilder(Items.ARROW).setCount((int) (player.getServerWorld().getTime() % 99999)).setMaxCount(99999)); super.onTick(); } @@ -71,7 +71,7 @@ public boolean canPlayerClose() { }; gui.setTitle(Text.literal("Nice")); - gui.setSlot(0, new GuiElementBuilder(Items.ARROW).setCount(100)); + gui.setSlot(0, new GuiElementBuilder(Items.ARROW).setCount(2000).setMaxDamage(99999)); gui.setSlot(1, new AnimatedGuiElement(new ItemStack[]{ Items.NETHERITE_PICKAXE.getDefaultStack(), Items.DIAMOND_PICKAXE.getDefaultStack(), @@ -86,8 +86,8 @@ public boolean canPlayerClose() { .setItem(Items.NETHERITE_AXE).setDamage(150).saveItemStack() .setItem(Items.DIAMOND_AXE).setDamage(150).unbreakable().saveItemStack() .setItem(Items.GOLDEN_AXE).glow().saveItemStack() - .setItem(Items.IRON_AXE).enchant(Enchantments.AQUA_AFFINITY, 1).hideFlags().saveItemStack() - .setItem(Items.STONE_AXE).saveItemStack() + .setItem(Items.IRON_AXE).enchant(Enchantments.AQUA_AFFINITY, 1).hideDefaultTooltip().saveItemStack() + .setItem(Items.STONE_AXE).noDefaults().saveItemStack() .setItem(Items.WOODEN_AXE).saveItemStack() .setInterval(10).setRandom(true) ); @@ -120,12 +120,14 @@ public boolean canPlayerClose() { .setStyle(Style.EMPTY.withItalic(false).withBold(true))) .addLoreLine(Text.literal("Some lore")) .addLoreLine(Text.literal("More lore").formatted(Formatting.RED)) + .hideTooltip() .setCount(3) .setCallback((index, clickType, actionType) -> gui.close()) ); gui.setSlot(8, new GuiElementBuilder() .setItem(Items.TNT) + .hideDefaultTooltip() .glow() .setName(Text.literal("Test :)") .setStyle(Style.EMPTY.withItalic(false).withBold(true))) @@ -533,7 +535,7 @@ public boolean onSelectedSlotChange(int slot) { .setItem(Items.NETHERITE_AXE).setDamage(150).saveItemStack() .setItem(Items.DIAMOND_AXE).setDamage(150).unbreakable().saveItemStack() .setItem(Items.GOLDEN_AXE).glow().saveItemStack() - .setItem(Items.IRON_AXE).enchant(Enchantments.AQUA_AFFINITY, 1).hideFlags().saveItemStack() + .setItem(Items.IRON_AXE).enchant(Enchantments.AQUA_AFFINITY, 1).saveItemStack() .setItem(Items.STONE_AXE).saveItemStack() .setItem(Items.WOODEN_AXE).saveItemStack() .setInterval(10).setRandom(true) diff --git a/src/testmod/java/eu/pb4/sgui/testmod/SnakeGui.java b/src/testmod/java/eu/pb4/sgui/testmod/SnakeGui.java index e6c98da..1812ca7 100644 --- a/src/testmod/java/eu/pb4/sgui/testmod/SnakeGui.java +++ b/src/testmod/java/eu/pb4/sgui/testmod/SnakeGui.java @@ -10,6 +10,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.nbt.StringNbtReader; +import net.minecraft.registry.RegistryKeys; import net.minecraft.screen.ScreenHandlerType; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; @@ -29,19 +30,7 @@ static ItemStack create(BannerPatternsComponent component) { return stack; } - - static final ItemStack[] NUMBERS = new ItemStack[]{ - create(new BannerPatternsComponent.Builder().add(BannerPatterns.STRIPE_BOTTOM, DyeColor.WHITE).add(BannerPatterns.STRIPE_LEFT, DyeColor.WHITE).add(BannerPatterns.STRIPE_TOP, DyeColor.WHITE).add(BannerPatterns.STRIPE_RIGHT, DyeColor.WHITE).add(BannerPatterns.STRIPE_DOWNLEFT, DyeColor.WHITE).add(BannerPatterns.BORDER, DyeColor.GRAY).build()), - create(new BannerPatternsComponent.Builder().add(BannerPatterns.STRIPE_CENTER, DyeColor.WHITE).add(BannerPatterns.SQUARE_TOP_LEFT, DyeColor.WHITE).add(BannerPatterns.CURLY_BORDER, DyeColor.GRAY).add(BannerPatterns.STRIPE_BOTTOM, DyeColor.WHITE).add(BannerPatterns.BORDER, DyeColor.GRAY).build()), - create(new BannerPatternsComponent.Builder().add(BannerPatterns.STRIPE_TOP, DyeColor.WHITE).add(BannerPatterns.RHOMBUS, DyeColor.GRAY).add(BannerPatterns.STRIPE_BOTTOM, DyeColor.WHITE).add(BannerPatterns.STRIPE_DOWNLEFT, DyeColor.WHITE).add(BannerPatterns.BORDER, DyeColor.GRAY).build()), - create(new BannerPatternsComponent.Builder().add(BannerPatterns.STRIPE_BOTTOM, DyeColor.WHITE).add(BannerPatterns.STRIPE_MIDDLE, DyeColor.WHITE).add(BannerPatterns.STRIPE_TOP, DyeColor.WHITE).add(BannerPatterns.CURLY_BORDER, DyeColor.GRAY).add(BannerPatterns.STRIPE_RIGHT, DyeColor.WHITE).add(BannerPatterns.BORDER, DyeColor.GRAY).build()), - create(new BannerPatternsComponent.Builder().add(BannerPatterns.STRIPE_LEFT, DyeColor.WHITE).add(BannerPatterns.HALF_HORIZONTAL_BOTTOM, DyeColor.GRAY).add(BannerPatterns.STRIPE_RIGHT, DyeColor.WHITE).add(BannerPatterns.STRIPE_MIDDLE, DyeColor.WHITE).add(BannerPatterns.BORDER, DyeColor.GRAY).build()), - create(new BannerPatternsComponent.Builder().add(BannerPatterns.STRIPE_BOTTOM, DyeColor.WHITE).add(BannerPatterns.RHOMBUS, DyeColor.GRAY).add(BannerPatterns.STRIPE_TOP, DyeColor.WHITE).add(BannerPatterns.STRIPE_DOWNRIGHT, DyeColor.WHITE).add(BannerPatterns.BORDER, DyeColor.GRAY).build()), - create(new BannerPatternsComponent.Builder().add(BannerPatterns.STRIPE_BOTTOM, DyeColor.WHITE).add(BannerPatterns.STRIPE_RIGHT, DyeColor.WHITE).add(BannerPatterns.HALF_HORIZONTAL, DyeColor.GRAY).add(BannerPatterns.STRIPE_MIDDLE, DyeColor.WHITE).add(BannerPatterns.STRIPE_TOP, DyeColor.WHITE).add(BannerPatterns.STRIPE_LEFT, DyeColor.WHITE).add(BannerPatterns.BORDER, DyeColor.GRAY).build()), - create(new BannerPatternsComponent.Builder().add(BannerPatterns.STRIPE_DOWNLEFT, DyeColor.WHITE).add(BannerPatterns.STRIPE_TOP, DyeColor.WHITE).add(BannerPatterns.BORDER, DyeColor.GRAY).build()), - create(new BannerPatternsComponent.Builder().add(BannerPatterns.STRIPE_DOWNLEFT, DyeColor.WHITE).add(BannerPatterns.STRIPE_TOP, DyeColor.WHITE).add(BannerPatterns.BORDER, DyeColor.GRAY).build()), - create(new BannerPatternsComponent.Builder().add(BannerPatterns.STRIPE_LEFT, DyeColor.WHITE).add(BannerPatterns.HALF_HORIZONTAL_BOTTOM, DyeColor.GRAY).add(BannerPatterns.STRIPE_MIDDLE, DyeColor.WHITE).add(BannerPatterns.STRIPE_TOP, DyeColor.WHITE).add(BannerPatterns.STRIPE_RIGHT, DyeColor.WHITE).add(BannerPatterns.STRIPE_BOTTOM, DyeColor.WHITE).add(BannerPatterns.BORDER, DyeColor.GRAY).build()), - }; + final ItemStack[] NUMBERS; final Layer gameplayLayer; final Layer scoreLayer; @@ -65,6 +54,21 @@ static ItemStack create(BannerPatternsComponent component) { public SnakeGui(ServerPlayerEntity player) { super(ScreenHandlerType.GENERIC_9X6, player, true); this.setTitle(Text.literal("SGui Snake")); + + var reg = player.getRegistryManager().get(RegistryKeys.BANNER_PATTERN); + + NUMBERS = new ItemStack[]{ + create(new BannerPatternsComponent.Builder().add(reg.getEntry(BannerPatterns.STRIPE_BOTTOM).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.STRIPE_LEFT).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.STRIPE_TOP).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.STRIPE_RIGHT).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.STRIPE_DOWNLEFT).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.BORDER).orElseThrow(), DyeColor.GRAY).build()), + create(new BannerPatternsComponent.Builder().add(reg.getEntry(BannerPatterns.STRIPE_CENTER).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.SQUARE_TOP_LEFT).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.CURLY_BORDER).orElseThrow(), DyeColor.GRAY).add(reg.getEntry(BannerPatterns.STRIPE_BOTTOM).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.BORDER).orElseThrow(), DyeColor.GRAY).build()), + create(new BannerPatternsComponent.Builder().add(reg.getEntry(BannerPatterns.STRIPE_TOP).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.RHOMBUS).orElseThrow(), DyeColor.GRAY).add(reg.getEntry(BannerPatterns.STRIPE_BOTTOM).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.STRIPE_DOWNLEFT).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.BORDER).orElseThrow(), DyeColor.GRAY).build()), + create(new BannerPatternsComponent.Builder().add(reg.getEntry(BannerPatterns.STRIPE_BOTTOM).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.STRIPE_MIDDLE).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.STRIPE_TOP).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.CURLY_BORDER).orElseThrow(), DyeColor.GRAY).add(reg.getEntry(BannerPatterns.STRIPE_RIGHT).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.BORDER).orElseThrow(), DyeColor.GRAY).build()), + create(new BannerPatternsComponent.Builder().add(reg.getEntry(BannerPatterns.STRIPE_LEFT).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.HALF_HORIZONTAL_BOTTOM).orElseThrow(), DyeColor.GRAY).add(reg.getEntry(BannerPatterns.STRIPE_RIGHT).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.STRIPE_MIDDLE).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.BORDER).orElseThrow(), DyeColor.GRAY).build()), + create(new BannerPatternsComponent.Builder().add(reg.getEntry(BannerPatterns.STRIPE_BOTTOM).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.RHOMBUS).orElseThrow(), DyeColor.GRAY).add(reg.getEntry(BannerPatterns.STRIPE_TOP).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.STRIPE_DOWNRIGHT).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.BORDER).orElseThrow(), DyeColor.GRAY).build()), + create(new BannerPatternsComponent.Builder().add(reg.getEntry(BannerPatterns.STRIPE_BOTTOM).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.STRIPE_RIGHT).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.HALF_HORIZONTAL).orElseThrow(), DyeColor.GRAY).add(reg.getEntry(BannerPatterns.STRIPE_MIDDLE).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.STRIPE_TOP).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.STRIPE_LEFT).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.BORDER).orElseThrow(), DyeColor.GRAY).build()), + create(new BannerPatternsComponent.Builder().add(reg.getEntry(BannerPatterns.STRIPE_DOWNLEFT).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.STRIPE_TOP).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.BORDER).orElseThrow(), DyeColor.GRAY).build()), + create(new BannerPatternsComponent.Builder().add(reg.getEntry(BannerPatterns.STRIPE_DOWNLEFT).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.STRIPE_TOP).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.BORDER).orElseThrow(), DyeColor.GRAY).build()), + create(new BannerPatternsComponent.Builder().add(reg.getEntry(BannerPatterns.STRIPE_LEFT).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.HALF_HORIZONTAL_BOTTOM).orElseThrow(), DyeColor.GRAY).add(reg.getEntry(BannerPatterns.STRIPE_MIDDLE).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.STRIPE_TOP).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.STRIPE_RIGHT).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.STRIPE_BOTTOM).orElseThrow(), DyeColor.WHITE).add(reg.getEntry(BannerPatterns.BORDER).orElseThrow(), DyeColor.GRAY).build()), + }; Layer controller = new Layer(3, 3); this.controller = controller;