From 52a6bf840ed665a2086ed37bbe0f99907d160350 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sat, 2 Mar 2024 03:09:05 +0900 Subject: Update to 24w09a --- .../rei/RoughlyEnoughItemsCoreClient.java | 6 +- .../shedaniel/rei/RoughlyEnoughItemsNetwork.java | 21 +++++-- .../rei/impl/client/ClientHelperImpl.java | 11 +++- .../client/config/addon/ConfigAddonsScreen.java | 13 ++-- .../config/entries/FilteringAddRuleScreen.java | 15 +++-- .../config/entries/FilteringCategoriesScreen.java | 15 +++-- .../config/entries/FilteringRuleOptionsScreen.java | 14 ++--- .../config/entries/FilteringRulesScreen.java | 15 +++-- .../client/config/entries/FilteringScreen.java | 8 ++- .../rei/impl/client/gui/InternalTextures.java | 2 + .../rei/impl/client/gui/RecipeDisplayExporter.java | 12 ++-- .../client/gui/credits/CreditsEntryListWidget.java | 9 ++- .../rei/impl/client/gui/credits/CreditsScreen.java | 9 ++- .../client/gui/error/ErrorsEntryListWidget.java | 3 +- .../rei/impl/client/gui/error/ErrorsScreen.java | 13 ++-- .../client/gui/performance/PerformanceScreen.java | 11 ++-- .../gui/screen/AbstractDisplayViewingScreen.java | 5 ++ .../client/gui/screen/ConfigReloadingScreen.java | 19 ++++-- .../SearchFilterSyntaxHighlightingScreen.java | 3 +- .../gui/screen/UncertainDisplayViewingScreen.java | 17 +++--- .../client/gui/screen/WarningAndErrorScreen.java | 6 +- .../gui/widget/BatchedEntryRendererManager.java | 1 + .../client/gui/widget/CachedEntryListRender.java | 12 ++-- .../impl/client/gui/widget/UpdatedListWidget.java | 69 ++++++++++++++++++++++ .../gui/widget/basewidgets/TextFieldWidget.java | 6 +- .../comparison/FluidComparatorRegistryImpl.java | 2 +- .../comparison/ItemComparatorRegistryImpl.java | 2 +- .../entry/comparison/NbtHasherProviderImpl.java | 64 ++++++++------------ .../rei/impl/common/transfer/InputSlotCrafter.java | 3 +- .../plugin/client/entry/ItemEntryDefinition.java | 40 ++++++------- .../shedaniel/rei/plugin/test/REITestPlugin.java | 11 ++-- 31 files changed, 263 insertions(+), 174 deletions(-) create mode 100644 runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/UpdatedListWidget.java (limited to 'runtime/src/main/java') diff --git a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java index 408227e16..37cb7814d 100644 --- a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java +++ b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java @@ -24,8 +24,6 @@ package me.shedaniel.rei; import com.google.common.collect.Lists; -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.serialization.DataResult; import dev.architectury.event.Event; import dev.architectury.event.EventFactory; @@ -247,7 +245,7 @@ public class RoughlyEnoughItemsCoreClient { Minecraft client = Minecraft.getInstance(); NetworkManager.registerReceiver(NetworkManager.s2c(), RoughlyEnoughItemsNetwork.CREATE_ITEMS_MESSAGE_PACKET, (buf, context) -> { - ItemStack stack = buf.readItem(); + ItemStack stack = buf.readJsonWithCodec(ItemStack.OPTIONAL_CODEC); String player = buf.readUtf(32767); if (client.player != null) { client.player.displayClientMessage(Component.literal(I18n.get("text.rei.cheat_items").replaceAll("\\{item_name}", EntryStacks.of(stack.copy()).asFormattedText().getString()).replaceAll("\\{item_count}", stack.copy().getCount() + "").replaceAll("\\{player_name}", player)), false); @@ -266,7 +264,7 @@ public class RoughlyEnoughItemsCoreClient { List list = Lists.newArrayList(); int count = buf.readInt(); for (int j = 0; j < count; j++) { - list.add(buf.readItem()); + list.add(buf.readJsonWithCodec(ItemStack.OPTIONAL_CODEC)); } input.add(list); } diff --git a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java index 58b4cd21a..3f536b53e 100644 --- a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java +++ b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java @@ -87,9 +87,12 @@ public class RoughlyEnoughItemsNetwork { player.displayClientMessage(Component.translatable("text.rei.no_permission_cheat").withStyle(ChatFormatting.RED), false); return; } - ItemStack stack = buf.readItem(); + ItemStack stack = buf.readJsonWithCodec(ItemStack.OPTIONAL_CODEC); if (player.getInventory().add(stack.copy())) { - NetworkManager.sendToPlayer(player, RoughlyEnoughItemsNetwork.CREATE_ITEMS_MESSAGE_PACKET, new FriendlyByteBuf(Unpooled.buffer()).writeItem(stack.copy()).writeUtf(player.getScoreboardName(), 32767)); + FriendlyByteBuf newBuf = new FriendlyByteBuf(Unpooled.buffer()); + newBuf.writeJsonWithCodec(ItemStack.OPTIONAL_CODEC, stack.copy()); + newBuf.writeUtf(player.getScoreboardName(), 32767); + NetworkManager.sendToPlayer(player, RoughlyEnoughItemsNetwork.CREATE_ITEMS_MESSAGE_PACKET, newBuf); } else { player.displayClientMessage(Component.translatable("text.rei.failed_cheat_items"), false); } @@ -102,7 +105,7 @@ public class RoughlyEnoughItemsNetwork { } AbstractContainerMenu menu = player.containerMenu; - ItemStack itemStack = buf.readItem(); + ItemStack itemStack = buf.readJsonWithCodec(ItemStack.OPTIONAL_CODEC); ItemStack stack = itemStack.copy(); if (!menu.getCarried().isEmpty() && ItemStack.isSameItemSameTags(menu.getCarried(), stack)) { stack.setCount(Mth.clamp(stack.getCount() + menu.getCarried().getCount(), 1, stack.getMaxStackSize())); @@ -111,7 +114,10 @@ public class RoughlyEnoughItemsNetwork { } menu.setCarried(stack.copy()); menu.broadcastChanges(); - NetworkManager.sendToPlayer(player, RoughlyEnoughItemsNetwork.CREATE_ITEMS_MESSAGE_PACKET, new FriendlyByteBuf(Unpooled.buffer()).writeItem(itemStack.copy()).writeUtf(player.getScoreboardName(), 32767)); + FriendlyByteBuf newBuf = new FriendlyByteBuf(Unpooled.buffer()); + newBuf.writeJsonWithCodec(ItemStack.OPTIONAL_CODEC, stack.copy()); + newBuf.writeUtf(player.getScoreboardName(), 32767); + NetworkManager.sendToPlayer(player, RoughlyEnoughItemsNetwork.CREATE_ITEMS_MESSAGE_PACKET, newBuf); }); NetworkManager.registerReceiver(NetworkManager.c2s(), CREATE_ITEMS_HOTBAR_PACKET, Collections.singletonList(new SplitPacketTransformer()), (buf, context) -> { ServerPlayer player = (ServerPlayer) context.getPlayer(); @@ -119,13 +125,16 @@ public class RoughlyEnoughItemsNetwork { player.displayClientMessage(Component.translatable("text.rei.no_permission_cheat").withStyle(ChatFormatting.RED), false); return; } - ItemStack stack = buf.readItem(); + ItemStack stack = buf.readJsonWithCodec(ItemStack.OPTIONAL_CODEC); int hotbarSlotId = buf.readVarInt(); if (hotbarSlotId >= 0 && hotbarSlotId < 9) { AbstractContainerMenu menu = player.containerMenu; player.getInventory().items.set(hotbarSlotId, stack.copy()); menu.broadcastChanges(); - NetworkManager.sendToPlayer(player, RoughlyEnoughItemsNetwork.CREATE_ITEMS_MESSAGE_PACKET, new FriendlyByteBuf(Unpooled.buffer()).writeItem(stack.copy()).writeUtf(player.getScoreboardName(), 32767)); + FriendlyByteBuf newBuf = new FriendlyByteBuf(Unpooled.buffer()); + newBuf.writeJsonWithCodec(ItemStack.OPTIONAL_CODEC, stack.copy()); + newBuf.writeUtf(player.getScoreboardName(), 32767); + NetworkManager.sendToPlayer(player, RoughlyEnoughItemsNetwork.CREATE_ITEMS_MESSAGE_PACKET, newBuf); } else { player.displayClientMessage(Component.translatable("text.rei.failed_cheat_items"), false); } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java index 9c185764e..0ebef6306 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java @@ -219,7 +219,9 @@ public class ClientHelperImpl implements ClientHelper { return false; } try { - NetworkManager.sendToServer(ConfigObject.getInstance().isGrabbingItems() ? RoughlyEnoughItemsNetwork.CREATE_ITEMS_GRAB_PACKET : RoughlyEnoughItemsNetwork.CREATE_ITEMS_PACKET, new FriendlyByteBuf(Unpooled.buffer()).writeItem(cheatedStack)); + FriendlyByteBuf newBuf = new FriendlyByteBuf(Unpooled.buffer()); + newBuf.writeJsonWithCodec(ItemStack.OPTIONAL_CODEC, cheatedStack); + NetworkManager.sendToServer(ConfigObject.getInstance().isGrabbingItems() ? RoughlyEnoughItemsNetwork.CREATE_ITEMS_GRAB_PACKET : RoughlyEnoughItemsNetwork.CREATE_ITEMS_PACKET, newBuf); return true; } catch (Exception exception) { return false; @@ -229,7 +231,7 @@ public class ClientHelperImpl implements ClientHelper { if (identifier == null) { return false; } - String tagMessage = cheatedStack.copy().getTag() != null && !cheatedStack.copy().getTag().isEmpty() ? cheatedStack.copy().getTag().getAsString() : ""; + String tagMessage = /* TODO 24w09a: cheatedStack.copy().getTag() != null && !cheatedStack.copy().getTag().isEmpty() ? cheatedStack.copy().getTag().getAsString() :*/ ""; String og = cheatedStack.getCount() == 1 ? ConfigObject.getInstance().getGiveCommand().replaceAll(" \\{count}", "") : ConfigObject.getInstance().getGiveCommand(); String madeUpCommand = og.replaceAll("\\{player_name}", Minecraft.getInstance().player.getScoreboardName()).replaceAll("\\{item_name}", identifier.getPath()).replaceAll("\\{item_identifier}", identifier.toString()).replaceAll("\\{nbt}", tagMessage).replaceAll("\\{count}", String.valueOf(cheatedStack.getCount())); if (madeUpCommand.length() > 256) { @@ -264,7 +266,10 @@ public class ClientHelperImpl implements ClientHelper { return false; } try { - NetworkManager.sendToServer(RoughlyEnoughItemsNetwork.CREATE_ITEMS_HOTBAR_PACKET, new FriendlyByteBuf(Unpooled.buffer()).writeItem(stack.getValue().copy()).writeVarInt(hotbarSlotId)); + FriendlyByteBuf newBuf = new FriendlyByteBuf(Unpooled.buffer()); + newBuf.writeJsonWithCodec(ItemStack.OPTIONAL_CODEC, stack.getValue().copy()); + newBuf.writeVarInt(hotbarSlotId); + NetworkManager.sendToServer(RoughlyEnoughItemsNetwork.CREATE_ITEMS_HOTBAR_PACKET, newBuf); return true; } catch (Exception exception) { return false; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/addon/ConfigAddonsScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/addon/ConfigAddonsScreen.java index 32ee7174d..fdbc3166e 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/addon/ConfigAddonsScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/addon/ConfigAddonsScreen.java @@ -23,10 +23,10 @@ package me.shedaniel.rei.impl.client.config.addon; -import me.shedaniel.clothconfig2.gui.widget.DynamicElementListWidget; import me.shedaniel.rei.api.client.config.addon.ConfigAddon; import me.shedaniel.rei.api.client.config.addon.ConfigAddonRegistry; import me.shedaniel.rei.impl.client.gui.InternalTextures; +import me.shedaniel.rei.impl.client.gui.widget.UpdatedListWidget; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ComponentPath; import net.minecraft.client.gui.GuiGraphics; @@ -38,7 +38,6 @@ import net.minecraft.client.gui.screens.Screen; import net.minecraft.locale.Language; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.FormattedText; -import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.Nullable; import java.util.Collections; @@ -63,7 +62,7 @@ public class ConfigAddonsScreen extends Screen { minecraft.setScreen(parent); }).bounds(4, 4, Minecraft.getInstance().font.width(backText) + 10, 20).build()); } - rulesList = addWidget(new AddonsList(minecraft, width, height, 30, height, BACKGROUND_LOCATION)); + rulesList = addWidget(new AddonsList(minecraft, width, height, 30, height)); ConfigAddonRegistryImpl addonRegistry = (ConfigAddonRegistryImpl) ConfigAddonRegistry.getInstance(); for (ConfigAddon addon : addonRegistry.getAddons()) { rulesList.addItem(new DefaultAddonEntry(parent, addon)); @@ -77,11 +76,11 @@ public class ConfigAddonsScreen extends Screen { graphics.drawString(this.font, this.title.getVisualOrderText(), (int) (this.width / 2.0F - this.font.width(this.title) / 2.0F), 12, -1); } - public static class AddonsList extends DynamicElementListWidget { + public static class AddonsList extends UpdatedListWidget { private boolean inFocus; - public AddonsList(Minecraft client, int width, int height, int top, int bottom, ResourceLocation backgroundLocation) { - super(client, width, height, top, bottom, backgroundLocation); + public AddonsList(Minecraft client, int width, int height, int top, int bottom) { + super(client, width, height, top, bottom); } @Override @@ -105,7 +104,7 @@ public class ConfigAddonsScreen extends Screen { } } - public static abstract class AddonEntry extends DynamicElementListWidget.ElementEntry { + public static abstract class AddonEntry extends UpdatedListWidget.ElementEntry { @Override public int getItemHeight() { return 26; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringAddRuleScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringAddRuleScreen.java index 46dd3aae5..2e3e40595 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringAddRuleScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringAddRuleScreen.java @@ -23,10 +23,10 @@ package me.shedaniel.rei.impl.client.config.entries; -import me.shedaniel.clothconfig2.gui.widget.DynamicElementListWidget; import me.shedaniel.rei.api.client.entry.filtering.FilteringRule; import me.shedaniel.rei.api.client.entry.filtering.FilteringRuleType; import me.shedaniel.rei.api.client.entry.filtering.FilteringRuleTypeRegistry; +import me.shedaniel.rei.impl.client.gui.widget.UpdatedListWidget; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; @@ -36,7 +36,6 @@ import net.minecraft.client.gui.screens.Screen; import net.minecraft.locale.Language; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.FormattedText; -import net.minecraft.resources.ResourceLocation; import java.util.Collections; import java.util.List; @@ -65,7 +64,7 @@ public class FilteringAddRuleScreen extends Screen { }, Supplier::get) { }); } - rulesList = addWidget(new RulesList(minecraft, width, height, 30, height, BACKGROUND_LOCATION)); + rulesList = addWidget(new RulesList(minecraft, width, height, 30, height)); for (FilteringRuleType rule : FilteringRuleTypeRegistry.getInstance()) { if (!rule.isSingular()) rulesList.addItem(new DefaultRuleEntry(parent, entry, rule.createNew(), null)); @@ -75,16 +74,16 @@ public class FilteringAddRuleScreen extends Screen { @Override public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { - this.rulesList.render(graphics, mouseX, mouseY, delta); super.render(graphics, mouseX, mouseY, delta); + this.rulesList.render(graphics, mouseX, mouseY, delta); graphics.drawString(this.font, this.title.getVisualOrderText(), (int) (this.width / 2.0F - this.font.width(this.title) / 2.0F), 12, -1); } - public static class RulesList extends DynamicElementListWidget { + public static class RulesList extends UpdatedListWidget { private boolean inFocus; - public RulesList(Minecraft client, int width, int height, int top, int bottom, ResourceLocation backgroundLocation) { - super(client, width, height, top, bottom, backgroundLocation); + public RulesList(Minecraft client, int width, int height, int top, int bottom) { + super(client, width, height, top, bottom); } @Override @@ -108,7 +107,7 @@ public class FilteringAddRuleScreen extends Screen { } } - public static abstract class RuleEntry extends DynamicElementListWidget.ElementEntry { + public static abstract class RuleEntry extends UpdatedListWidget.ElementEntry { private final FilteringRule rule; public RuleEntry(FilteringRule rule) { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringCategoriesScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringCategoriesScreen.java index 0c35ac197..2b30174e4 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringCategoriesScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringCategoriesScreen.java @@ -23,9 +23,9 @@ package me.shedaniel.rei.impl.client.config.entries; -import me.shedaniel.clothconfig2.gui.widget.DynamicElementListWidget; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.registry.category.CategoryRegistry; +import me.shedaniel.rei.impl.client.gui.widget.UpdatedListWidget; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; @@ -37,7 +37,6 @@ import net.minecraft.client.resources.sounds.SimpleSoundInstance; import net.minecraft.locale.Language; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.FormattedText; -import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvents; import java.util.Collections; @@ -64,7 +63,7 @@ public class FilteringCategoriesScreen extends Screen { this.parent = null; }, Supplier::get) {}); } - listWidget = addWidget(new ListWidget(minecraft, width, height, 30, height, BACKGROUND_LOCATION)); + listWidget = addWidget(new ListWidget(minecraft, width, height, 30, height)); for (CategoryRegistry.CategoryConfiguration configuration : CategoryRegistry.getInstance()) { listWidget.addItem(new DefaultListEntry(configuration)); } @@ -72,16 +71,16 @@ public class FilteringCategoriesScreen extends Screen { @Override public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { - this.listWidget.render(graphics, mouseX, mouseY, delta); super.render(graphics, mouseX, mouseY, delta); + this.listWidget.render(graphics, mouseX, mouseY, delta); graphics.drawString(this.font, this.title.getVisualOrderText(), (int) (this.width / 2.0F - this.font.width(this.title) / 2.0F), 12, -1); } - private static class ListWidget extends DynamicElementListWidget { + private static class ListWidget extends UpdatedListWidget { private boolean inFocus; - public ListWidget(Minecraft client, int width, int height, int top, int bottom, ResourceLocation backgroundLocation) { - super(client, width, height, top, bottom, backgroundLocation); + public ListWidget(Minecraft client, int width, int height, int top, int bottom) { + super(client, width, height, top, bottom); } @Override @@ -125,7 +124,7 @@ public class FilteringCategoriesScreen extends Screen { } } - private static abstract class ListEntry extends DynamicElementListWidget.ElementEntry { + private static abstract class ListEntry extends UpdatedListWidget.ElementEntry { @Override public int getItemHeight() { return 35; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringRuleOptionsScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringRuleOptionsScreen.java index fc91c1a04..9ba9ca8c5 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringRuleOptionsScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringRuleOptionsScreen.java @@ -24,9 +24,9 @@ package me.shedaniel.rei.impl.client.config.entries; import com.mojang.blaze3d.systems.RenderSystem; -import me.shedaniel.clothconfig2.gui.widget.DynamicElementListWidget; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.entry.filtering.FilteringRule; +import me.shedaniel.rei.impl.client.gui.widget.UpdatedListWidget; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ComponentPath; import net.minecraft.client.gui.GuiGraphics; @@ -76,7 +76,7 @@ public abstract class FilteringRuleOptionsScreen> ext }, Supplier::get) { }); } - rulesList = addWidget(new RulesList(minecraft, width, height, 30, height, BACKGROUND_LOCATION)); + rulesList = addWidget(new RulesList(minecraft, width, height, 30, height)); addEntries(ruleEntry -> rulesList.addItem(ruleEntry)); } @@ -96,14 +96,14 @@ public abstract class FilteringRuleOptionsScreen> ext @Override public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { - this.rulesList.render(graphics, mouseX, mouseY, delta); super.render(graphics, mouseX, mouseY, delta); + this.rulesList.render(graphics, mouseX, mouseY, delta); graphics.drawString(this.font, this.title.getVisualOrderText(), (int) (this.width / 2.0F - this.font.width(this.title) / 2.0F), 12, -1); } - public static class RulesList extends DynamicElementListWidget { - public RulesList(Minecraft client, int width, int height, int top, int bottom, ResourceLocation backgroundLocation) { - super(client, width, height, top, bottom, backgroundLocation); + public static class RulesList extends UpdatedListWidget { + public RulesList(Minecraft client, int width, int height, int top, int bottom) { + super(client, width, height, top, bottom); } @Override @@ -122,7 +122,7 @@ public abstract class FilteringRuleOptionsScreen> ext } } - public static abstract class RuleEntry extends DynamicElementListWidget.ElementEntry { + public static abstract class RuleEntry extends UpdatedListWidget.ElementEntry { private final FilteringRule rule; public RuleEntry(FilteringRule rule) { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringRulesScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringRulesScreen.java index 3321cb40f..dd8981641 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringRulesScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringRulesScreen.java @@ -24,7 +24,6 @@ package me.shedaniel.rei.impl.client.config.entries; import com.google.common.base.Suppliers; -import me.shedaniel.clothconfig2.gui.widget.DynamicElementListWidget; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.entry.filtering.FilteringRule; import me.shedaniel.rei.api.client.entry.filtering.FilteringRuleType; @@ -36,6 +35,7 @@ import me.shedaniel.rei.impl.client.entry.filtering.rules.ManualFilteringRule; import me.shedaniel.rei.impl.client.entry.filtering.rules.SearchFilteringRuleType; import me.shedaniel.rei.impl.client.gui.InternalTextures; import me.shedaniel.rei.impl.client.gui.widget.EntryWidget; +import me.shedaniel.rei.impl.client.gui.widget.UpdatedListWidget; import me.shedaniel.rei.impl.common.entry.type.FilteringLogic; import me.shedaniel.rei.impl.common.util.HashedEntryStackWrapper; import net.minecraft.client.Minecraft; @@ -48,7 +48,6 @@ import net.minecraft.client.resources.sounds.SimpleSoundInstance; import net.minecraft.locale.Language; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.FormattedText; -import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvents; import java.util.*; @@ -87,7 +86,7 @@ public class FilteringRulesScreen extends Screen { }, Supplier::get) { }); } - rulesList = addWidget(new RulesList(minecraft, width, height, 30, height, BACKGROUND_LOCATION)); + rulesList = addWidget(new RulesList(minecraft, width, height, 30, height)); for (int i = entry.rules.size() - 1; i >= 0; i--) { FilteringRule rule = entry.rules.get(i); if (rule instanceof ManualFilteringRule) @@ -102,16 +101,16 @@ public class FilteringRulesScreen extends Screen { @Override public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { - this.rulesList.render(graphics, mouseX, mouseY, delta); super.render(graphics, mouseX, mouseY, delta); + this.rulesList.render(graphics, mouseX, mouseY, delta); graphics.drawString(this.font, this.title.getVisualOrderText(), (int) (this.width / 2.0F - this.font.width(this.title) / 2.0F), 12, -1); } - public static class RulesList extends DynamicElementListWidget { + public static class RulesList extends UpdatedListWidget { private boolean inFocus; - public RulesList(Minecraft client, int width, int height, int top, int bottom, ResourceLocation backgroundLocation) { - super(client, width, height, top, bottom, backgroundLocation); + public RulesList(Minecraft client, int width, int height, int top, int bottom) { + super(client, width, height, top, bottom); } @Override @@ -150,7 +149,7 @@ public class FilteringRulesScreen extends Screen { } } - public static abstract class RuleEntry extends DynamicElementListWidget.ElementEntry { + public static abstract class RuleEntry extends UpdatedListWidget.ElementEntry { private final FilteringRule rule; public RuleEntry(FilteringRule rule) { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringScreen.java index 214d41257..9d826cfd2 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringScreen.java @@ -44,9 +44,11 @@ import me.shedaniel.rei.api.client.search.SearchFilter; import me.shedaniel.rei.api.client.search.SearchProvider; import me.shedaniel.rei.api.common.entry.EntrySerializer; import me.shedaniel.rei.api.common.entry.EntryStack; +import me.shedaniel.rei.impl.client.gui.InternalTextures; import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl; import me.shedaniel.rei.impl.client.gui.widget.BatchedEntryRendererManager; import me.shedaniel.rei.impl.client.gui.widget.EntryWidget; +import me.shedaniel.rei.impl.client.gui.widget.UpdatedListWidget; import me.shedaniel.rei.impl.client.gui.widget.search.OverlaySearchField; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; @@ -209,7 +211,7 @@ public class FilteringScreen extends Screen { protected void renderHoleBackground(GuiGraphics graphics, int y1, int y2, int tint, int alpha1, int alpha2) { Tesselator tesselator = Tesselator.getInstance(); BufferBuilder buffer = tesselator.getBuilder(); - RenderSystem.setShaderTexture(0, BACKGROUND_LOCATION); + RenderSystem.setShaderTexture(0, InternalTextures.LEGACY_DIRT); Matrix4f matrix = graphics.pose().last().pose(); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); float float_1 = 32.0F; @@ -224,10 +226,11 @@ public class FilteringScreen extends Screen { @Override public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { - renderHoleBackground(graphics, 0, height, 32, 255, 255); + super.render(graphics, mouseX, mouseY, delta); updateSelectionCache(); Rectangle bounds = getBounds(); tooltip = null; + UpdatedListWidget.renderAs(minecraft, width, height, bounds.y, height, graphics, delta); if (bounds.isEmpty()) return; ScissorsHandler.INSTANCE.scissor(bounds); @@ -273,7 +276,6 @@ public class FilteringScreen extends Screen { buffer.vertex(matrix, 0, bounds.y, 0.0F).uv(0.0F, 0.0F).color(0, 0, 0, 255).endVertex(); tesselator.end(); RenderSystem.disableBlend(); - renderHoleBackground(graphics, 0, bounds.y, 64, 255, 255); this.backButton.render(graphics, mouseX, mouseY, delta); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/InternalTextures.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/InternalTextures.java index 2d269b5ac..58636bb9e 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/InternalTextures.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/InternalTextures.java @@ -32,4 +32,6 @@ public class InternalTextures { public static final ResourceLocation ARROW_RIGHT_SMALL_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/arrow_right_small.png"); public static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/recipecontainer.png"); public static final ResourceLocation CHEST_GUI_TEXTURE_DARK = new ResourceLocation("roughlyenoughitems", "textures/gui/recipecontainer_dark.png"); + @Deprecated(forRemoval = true) + public static final ResourceLocation LEGACY_DIRT = new ResourceLocation("textures/block/dirt.png"); } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/RecipeDisplayExporter.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/RecipeDisplayExporter.java index eb589799f..ceb346dea 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/RecipeDisplayExporter.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/RecipeDisplayExporter.java @@ -29,7 +29,6 @@ import com.mojang.blaze3d.platform.Lighting; import com.mojang.blaze3d.platform.NativeImage; import com.mojang.blaze3d.platform.Window; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexSorting; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.gui.widgets.Widget; @@ -42,6 +41,7 @@ import net.minecraft.client.resources.language.I18n; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.ApiStatus; import org.joml.Matrix4f; +import org.joml.Matrix4fStack; import java.io.File; import java.io.IOException; @@ -87,10 +87,10 @@ public final class RecipeDisplayExporter { RenderSystem.clear(256, Minecraft.ON_OSX); Matrix4f matrix4f = new Matrix4f().setOrtho(0.0F, (float) ((double) window.getWidth() / window.getGuiScale()), (float) ((double) window.getHeight() / window.getGuiScale()), 0.0F, 1000.0F, 3000.0F); RenderSystem.setProjectionMatrix(matrix4f, VertexSorting.ORTHOGRAPHIC_Z); - PoseStack poseStack = RenderSystem.getModelViewStack(); - poseStack.pushPose(); - poseStack.setIdentity(); - poseStack.translate(0.0D, 0.0D, -2000.0D); + Matrix4fStack poseStack = RenderSystem.getModelViewStack(); + poseStack.pushMatrix(); + poseStack.identity(); + poseStack.translate(0.0F, 0.0F, -2000.0F); RenderSystem.applyModelViewMatrix(); Lighting.setupFor3DItems(); GuiGraphics graphics = new GuiGraphics(client, client.renderBuffers().bufferSource()); @@ -126,7 +126,7 @@ public final class RecipeDisplayExporter { renderTarget.destroyBuffers(); Minecraft.getInstance().levelRenderer.graphicsChanged(); Minecraft.getInstance().getMainRenderTarget().bindWrite(true); - poseStack.popPose(); + poseStack.popMatrix(); RenderSystem.applyModelViewMatrix(); } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/credits/CreditsEntryListWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/credits/CreditsEntryListWidget.java index e1048fc37..a38e17c3a 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/credits/CreditsEntryListWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/credits/CreditsEntryListWidget.java @@ -23,14 +23,13 @@ package me.shedaniel.rei.impl.client.gui.credits; -import me.shedaniel.clothconfig2.gui.widget.DynamicSmoothScrollingEntryListWidget; import me.shedaniel.rei.impl.client.gui.text.TextTransformations; +import me.shedaniel.rei.impl.client.gui.widget.UpdatedListWidget; import net.minecraft.ChatFormatting; import net.minecraft.Util; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.narration.NarratableEntry; -import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.resources.sounds.SimpleSoundInstance; import net.minecraft.network.chat.Component; import net.minecraft.sounds.SoundEvents; @@ -43,11 +42,11 @@ import java.util.Collections; import java.util.List; @ApiStatus.Internal -public class CreditsEntryListWidget extends DynamicSmoothScrollingEntryListWidget { +public class CreditsEntryListWidget extends UpdatedListWidget { private boolean inFocus; public CreditsEntryListWidget(Minecraft client, int width, int height, int startY, int endY) { - super(client, width, height, startY, endY, Screen.BACKGROUND_LOCATION); + super(client, width, height, startY, endY); } public void creditsClearEntries() { @@ -72,7 +71,7 @@ public class CreditsEntryListWidget extends DynamicSmoothScrollingEntryListWidge return width - 40; } - public static abstract class CreditsItem extends DynamicSmoothScrollingEntryListWidget.Entry { + public static abstract class CreditsItem extends UpdatedListWidget.Entry { @Override public List narratables() { return Collections.emptyList(); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/credits/CreditsScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/credits/CreditsScreen.java index b8bb723c3..6b1344675 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/credits/CreditsScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/credits/CreditsScreen.java @@ -153,10 +153,13 @@ public class CreditsScreen extends Screen { @Override public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { - this.renderDirtBackground(graphics); - this.entryListWidget.render(graphics, mouseX, mouseY, delta); - graphics.drawCenteredString(this.font, I18n.get("text.rei.credits"), this.width / 2, 16, 16777215); super.render(graphics, mouseX, mouseY, delta); + graphics.drawCenteredString(this.font, I18n.get("text.rei.credits"), this.width / 2, 16, 16777215); } + @Override + public void renderBackground(GuiGraphics graphics, int mouseX, int mouseY, float delta) { + super.renderBackground(graphics, mouseX, mouseY, delta); + this.entryListWidget.render(graphics, mouseX, mouseY, delta); + } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/error/ErrorsEntryListWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/error/ErrorsEntryListWidget.java index b90d83052..f0a48a26f 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/error/ErrorsEntryListWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/error/ErrorsEntryListWidget.java @@ -26,6 +26,7 @@ package me.shedaniel.rei.impl.client.gui.error; import com.mojang.blaze3d.platform.NativeImage; import me.shedaniel.clothconfig2.gui.widget.DynamicEntryListWidget; import me.shedaniel.clothconfig2.gui.widget.DynamicSmoothScrollingEntryListWidget; +import me.shedaniel.rei.impl.client.gui.InternalTextures; import net.minecraft.ChatFormatting; import net.minecraft.Util; import net.minecraft.client.Minecraft; @@ -59,7 +60,7 @@ public class ErrorsEntryListWidget extends DynamicSmoothScrollingEntryListWidget private boolean inFocus; public ErrorsEntryListWidget(Minecraft client, int width, int height, int startY, int endY) { - super(client, width, height, startY, endY, Screen.BACKGROUND_LOCATION); + super(client, width, height, startY, endY, InternalTextures.LEGACY_DIRT); } public void _clearItems() { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/error/ErrorsScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/error/ErrorsScreen.java index c61a18724..956d85b02 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/error/ErrorsScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/error/ErrorsScreen.java @@ -28,7 +28,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractButton; import net.minecraft.client.gui.components.Button; -import net.minecraft.client.gui.screens.GenericDirtMessageScreen; +import net.minecraft.client.gui.screens.GenericMessageScreen; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; import org.jetbrains.annotations.ApiStatus; @@ -91,7 +91,7 @@ public class ErrorsScreen extends Screen { this.minecraft.level.disconnect(); if (localServer) { - this.minecraft.disconnect(new GenericDirtMessageScreen(Component.translatable("menu.savingLevel"))); + this.minecraft.disconnect(new GenericMessageScreen(Component.translatable("menu.savingLevel"))); } else { this.minecraft.disconnect(); } @@ -108,10 +108,13 @@ public class ErrorsScreen extends Screen { @Override public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { - this.renderDirtBackground(graphics); - this.listWidget.render(graphics, mouseX, mouseY, delta); - graphics.drawCenteredString(this.font, getTitle(), this.width / 2, 16, 16777215); super.render(graphics, mouseX, mouseY, delta); + graphics.drawCenteredString(this.font, getTitle(), this.width / 2, 16, 16777215); } + @Override + public void renderBackground(GuiGraphics graphics, int mouseX, int mouseY, float delta) { + super.renderBackground(graphics, mouseX, mouseY, delta); + this.listWidget.render(graphics, mouseX, mouseY, delta); + } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/PerformanceScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/PerformanceScreen.java index ee463222d..01c69fe50 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/PerformanceScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/PerformanceScreen.java @@ -24,12 +24,12 @@ package me.shedaniel.rei.impl.client.gui.performance; import com.mojang.datafixers.util.Pair; -import me.shedaniel.clothconfig2.gui.widget.DynamicElementListWidget; import me.shedaniel.rei.RoughlyEnoughItemsCore; import me.shedaniel.rei.api.common.plugins.REIPlugin; import me.shedaniel.rei.api.common.plugins.REIPluginProvider; import me.shedaniel.rei.impl.client.gui.performance.entry.PerformanceEntryImpl; import me.shedaniel.rei.impl.client.gui.performance.entry.SubCategoryListEntry; +import me.shedaniel.rei.impl.client.gui.widget.UpdatedListWidget; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.Minecraft; @@ -185,17 +185,16 @@ public class PerformanceScreen extends Screen { @Override public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { - renderDirtBackground(graphics); + super.render(graphics, mouseX, mouseY, delta); list.render(graphics, mouseX, mouseY, delta); graphics.drawString(this.font, this.title.getVisualOrderText(), (int) (this.width / 2.0F - this.font.width(this.title) / 2.0F), 12, -1); - super.render(graphics, mouseX, mouseY, delta); } - public static abstract class PerformanceEntry extends DynamicElementListWidget.ElementEntry { + public static abstract class PerformanceEntry extends UpdatedListWidget.ElementEntry { } - private class PerformanceEntryListWidget extends DynamicElementListWidget { - public PerformanceEntryListWidget() {super(PerformanceScreen.this.minecraft, PerformanceScreen.this.width, PerformanceScreen.this.height, 30, PerformanceScreen.this.height, Screen.BACKGROUND_LOCATION);} + private class PerformanceEntryListWidget extends UpdatedListWidget { + public PerformanceEntryListWidget() {super(PerformanceScreen.this.minecraft, PerformanceScreen.this.width, PerformanceScreen.this.height, 30, PerformanceScreen.this.height);} @Override public int getItemWidth() { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java index c7ab8e3dc..da110b1bc 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java @@ -210,6 +210,11 @@ public abstract class AbstractDisplayViewingScreen extends Screen implements Dis selectCategory(categories.get(currentCategoryIndex).getCategoryIdentifier()); } + @Override + public void renderBackground(GuiGraphics guiGraphics, int i, int j, float f) { + this.renderTransparentBackground(guiGraphics); + } + protected void transformIngredientNotice(List setupDisplay, List> noticeStacks) { transformNotice(Slot.INPUT, setupDisplay, noticeStacks); } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/ConfigReloadingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/ConfigReloadingScreen.java index 2dbf02432..5e81fc28c 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/ConfigReloadingScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/ConfigReloadingScreen.java @@ -71,22 +71,31 @@ public class ConfigReloadingScreen extends Screen { @Override public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { - this.renderDirtBackground(graphics); if (!predicate.getAsBoolean()) { parent.run(); return; } - graphics.drawCenteredString(this.font, title, this.width / 2, this.height / 2 - 50, 0xffffff); + super.render(graphics, mouseX, mouseY, delta); String text = switch ((int) (Util.getMillis() / 300L % 4L)) { case 1, 3 -> "o O o"; case 2 -> "o o O"; default -> "O o o"; }; - graphics.drawCenteredString(this.font, text, this.width / 2, this.height / 2 - 50 + 9, 0x808080); Component subtitle = this.subtitle.get(); + int width = Math.max(font.width(text), font.width(title)), height = subtitle == null ? 18 : 27; + if (subtitle != null) width = Math.max(width, font.width(subtitle)); + int x = this.width / 2 - width / 2; + int k = x - 12; + int l = this.height / 2 - height / 2 - 12; + int m = width + 12 * 2; + int n = height + 12 * 2; + int o = this.isFocused() ? -1 : -6250336; + graphics.fill(k + 1, l, k + m, l + n, -16777216); + graphics.renderOutline(k, l, m, n, o); + graphics.drawCenteredString(this.font, title, this.width / 2, l + 12, 0xffffff); + graphics.drawCenteredString(this.font, text, this.width / 2, l + 12 + 9, 0x808080); if (subtitle != null) { - graphics.drawCenteredString(this.font, subtitle, this.width / 2, this.height / 2 - 50 + 9 + 9, 0x808080); + graphics.drawCenteredString(this.font, subtitle, this.width / 2, l + 12 + 9 + 9, 0x808080); } - super.render(graphics, mouseX, mouseY, delta); } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/SearchFilterSyntaxHighlightingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/SearchFilterSyntaxHighlightingScreen.java index 92d9b69e0..6a0be5926 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/SearchFilterSyntaxHighlightingScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/SearchFilterSyntaxHighlightingScreen.java @@ -28,6 +28,7 @@ import com.mojang.blaze3d.vertex.BufferBuilder; import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.Tesselator; import com.mojang.blaze3d.vertex.VertexFormat; +import me.shedaniel.rei.impl.client.gui.InternalTextures; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.renderer.GameRenderer; @@ -50,7 +51,7 @@ public class SearchFilterSyntaxHighlightingScreen extends Screen { protected void renderHoleBackground(GuiGraphics graphics, int y1, int y2, int tint, int alpha1, int alpha2) { Tesselator tesselator = Tesselator.getInstance(); BufferBuilder buffer = tesselator.getBuilder(); - RenderSystem.setShaderTexture(0, BACKGROUND_LOCATION); + RenderSystem.setShaderTexture(0, InternalTextures.LEGACY_DIRT); Matrix4f matrix = graphics.pose().last().pose(); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.setShader(GameRenderer::getPositionTexColorShader); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/UncertainDisplayViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/UncertainDisplayViewingScreen.java index 91b19e070..39e58e780 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/UncertainDisplayViewingScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/UncertainDisplayViewingScreen.java @@ -206,6 +206,9 @@ public class UncertainDisplayViewingScreen extends Screen { graphics.pose().popPose(); } } + int k = 10, l = 44, m = width - 20, n = height - l - 10 - 5; + graphics.fill( k + 1, l, k + m, l + n, -16777216); + graphics.renderOutline(k, l, m, n, -1); for (Widget widget : widgets) { widget.render(graphics, int_1, int_2, float_1); } @@ -213,12 +216,12 @@ public class UncertainDisplayViewingScreen extends Screen { graphics.pose().pushPose(); graphics.pose().translate(0, -(scroll.floatValue() / 200f * height), 0); updateFramePosition(float_1); - int x = (int) (width / 2 - 205 + (210 * frame)); + int x = (int) (width / 2 - 205 + (200 * frame)) + 10; int y = height / 2 - 112 / 2 - 10; - graphics.fillGradient(x - 2, y - 4, x - 6 + 208, y - 4 + 2, -1778384897, -1778384897); - graphics.fillGradient(x - 2, y - 4 + 126 - 2, x - 6 + 208, y - 4 + 126, -1778384897, -1778384897); + graphics.fillGradient(x - 2, y - 4, x - 6 + 208- 10, y - 4 + 2, -1778384897, -1778384897); + graphics.fillGradient(x - 2, y - 4 + 126 - 2, x - 6 + 208- 10, y - 4 + 126, -1778384897, -1778384897); graphics.fillGradient(x - 4, y - 4, x - 4 + 2, y - 4 + 126, -1778384897, -1778384897); - graphics.fillGradient(x - 4 + 208 - 2, y - 4, x - 4 + 208, y - 4 + 126, -1778384897, -1778384897); + graphics.fillGradient(x - 4 + 208 - 2 - 10, y - 4, x - 4 + 208 - 10, y - 4 + 126, -1778384897, -1778384897); graphics.pose().popPose(); } ScissorsHandler.INSTANCE.removeLastScissor(); @@ -227,11 +230,7 @@ public class UncertainDisplayViewingScreen extends Screen { @Override public void renderBackground(GuiGraphics graphics, int i, int j, float f) { - if (this.minecraft.level != null) { - super.renderBackground(graphics, i, j, f); - } else { - graphics.fillGradient(0, 0, this.width, this.height, -16777216, -16777216); - } + super.renderBackground(graphics, i, j, f); } private void updateFramePosition(float delta) { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/WarningAndErrorScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/WarningAndErrorScreen.java index 78821df17..50fc31e78 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/WarningAndErrorScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/WarningAndErrorScreen.java @@ -25,6 +25,7 @@ package me.shedaniel.rei.impl.client.gui.screen; import com.google.common.collect.ImmutableList; import me.shedaniel.rei.RoughlyEnoughItemsState; +import me.shedaniel.rei.impl.client.gui.InternalTextures; import me.shedaniel.rei.impl.client.gui.widget.DynamicErrorFreeEntryListWidget; import net.minecraft.ChatFormatting; import net.minecraft.Util; @@ -133,14 +134,13 @@ public class WarningAndErrorScreen extends Screen { @Override public void render(GuiGraphics graphics, int int_1, int int_2, float float_1) { - this.renderDirtBackground(graphics); + super.render(graphics, int_1, int_2, float_1); this.listWidget.render(graphics, int_1, int_2, float_1); if (RoughlyEnoughItemsState.getErrors().isEmpty()) { graphics.drawCenteredString(this.font, "Warnings during Roughly Enough Items' " + action, this.width / 2, 16, 16777215); } else { graphics.drawCenteredString(this.font, "Errors during Roughly Enough Items' " + action, this.width / 2, 16, 16777215); } - super.render(graphics, int_1, int_2, float_1); this.buttonExit.render(graphics, int_1, int_2, float_1); } @@ -149,7 +149,7 @@ public class WarningAndErrorScreen extends Screen { private int max = 80; public StringEntryListWidget(Minecraft client, int width, int height, int startY, int endY) { - super(client, width, height, startY, endY, Screen.BACKGROUND_LOCATION); + super(client, width, height, startY, endY, InternalTextures.LEGACY_DIRT); } public void creditsClearEntries() { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/BatchedEntryRendererManager.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/BatchedEntryRendererManager.java index 9eab1027e..c14ca5923 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/BatchedEntryRendererManager.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/BatchedEntryRendererManager.java @@ -26,6 +26,7 @@ package me.shedaniel.rei.impl.client.gui.widget; import com.google.common.collect.AbstractIterator; import com.google.common.collect.Iterables; import com.google.common.collect.Iterators; +import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CachedEntryListRender.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CachedEntryListRender.java index 45014b669..df4053cfd 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CachedEntryListRender.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CachedEntryListRender.java @@ -28,7 +28,6 @@ import com.mojang.blaze3d.platform.Lighting; import com.mojang.blaze3d.platform.NativeImage; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.DefaultVertexFormat; -import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexFormat; import com.mojang.blaze3d.vertex.VertexSorting; import dev.architectury.registry.ReloadListenerRegistry; @@ -54,6 +53,7 @@ import net.minecraft.server.packs.PackType; import net.minecraft.util.Unit; import org.jetbrains.annotations.Nullable; import org.joml.Matrix4f; +import org.joml.Matrix4fStack; import java.util.List; @@ -149,10 +149,10 @@ public class CachedEntryListRender { target.bindWrite(true); Matrix4f projectionMatrix = new Matrix4f().setOrtho(0.0F, width, height, 0.0F, 1000.0F, 3000.0F); RenderSystem.setProjectionMatrix(projectionMatrix, VertexSorting.ORTHOGRAPHIC_Z); - PoseStack modelViewStack = RenderSystem.getModelViewStack(); - modelViewStack.pushPose(); - modelViewStack.setIdentity(); - modelViewStack.translate(0.0D, 0.0D, -2000.0D); + Matrix4fStack modelViewStack = RenderSystem.getModelViewStack(); + modelViewStack.pushMatrix(); + modelViewStack.identity(); + modelViewStack.translate(0.0F, 0.0F, -2000.0F); RenderSystem.applyModelViewMatrix(); Lighting.setupFor3DItems(); @@ -182,7 +182,7 @@ public class CachedEntryListRender { Minecraft.getInstance().levelRenderer.graphicsChanged(); Minecraft.getInstance().getMainRenderTarget().bindWrite(true); - modelViewStack.popPose(); + modelViewStack.popMatrix(); RenderSystem.applyModelViewMatrix(); } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/UpdatedListWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/UpdatedListWidget.java new file mode 100644 index 000000000..b78d8dcba --- /dev/null +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/UpdatedListWidget.java @@ -0,0 +1,69 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.impl.client.gui.widget; + +import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.BufferBuilder; +import com.mojang.blaze3d.vertex.Tesselator; +import me.shedaniel.clothconfig2.gui.widget.DynamicElementListWidget; +import me.shedaniel.rei.impl.client.gui.InternalTextures; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.events.GuiEventListener; +import net.minecraft.resources.ResourceLocation; + +import java.util.List; + +public class UpdatedListWidget> extends DynamicElementListWidget { + public UpdatedListWidget(Minecraft client, int width, int height, int top, int bottom) { + super(client, width, height, top, bottom, InternalTextures.LEGACY_DIRT); + this.setRenderSelection(false); + } + + @Override + protected void renderHoleBackground(GuiGraphics graphics, int y1, int y2, int alpha1, int alpha2) { + } + + @Override + protected void renderBackBackground(GuiGraphics graphics, BufferBuilder buffer, Tesselator tessellator) { + RenderSystem.enableBlend(); + graphics.blit(new ResourceLocation("textures/gui/menu_list_background.png"), this.left, this.top, this.right, this.bottom, this.width, this.bottom - this.top, 32, 32); + RenderSystem.disableBlend(); + } + + @SuppressWarnings("rawtypes") + public static void renderAs(Minecraft minecraft, int width, int height, int top, int bottom, GuiGraphics graphics, float delta) { + new UpdatedListWidget(minecraft, width, height, top, bottom).render(graphics, -100, -100, delta); + } + + public static abstract class Entry> extends DynamicElementListWidget.ElementEntry { + @Override + public List children() { + return List.of(); + } + } + + public static abstract class ElementEntry> extends Entry { + } +} diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/TextFieldWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/TextFieldWidget.java index bdb4acfe4..aaaad5d3f 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/TextFieldWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/TextFieldWidget.java @@ -33,7 +33,6 @@ import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.gui.widgets.TextField; import me.shedaniel.rei.api.client.gui.widgets.Widget; import me.shedaniel.rei.api.client.gui.widgets.WidgetWithBounds; -import net.minecraft.SharedConstants; import net.minecraft.Util; import net.minecraft.client.gui.ComponentPath; import net.minecraft.client.gui.GuiGraphics; @@ -43,6 +42,7 @@ import net.minecraft.client.renderer.GameRenderer; import net.minecraft.network.chat.Style; import net.minecraft.util.FormattedCharSequence; import net.minecraft.util.Mth; +import net.minecraft.util.StringUtil; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; import org.joml.Matrix4f; @@ -55,7 +55,7 @@ import java.util.function.Predicate; @ApiStatus.Internal public class TextFieldWidget extends WidgetWithBounds implements TickableWidget, TextField { - public Function stripInvalid = SharedConstants::filterText; + public Function stripInvalid = StringUtil::filterText; protected int frame; protected boolean editable = true; protected int firstCharacterIndex; @@ -354,7 +354,7 @@ public class TextFieldWidget extends WidgetWithBounds implements TickableWidget, @Override public boolean charTyped(char character, int modifiers) { if (this.isVisible() && this.isFocused()) { - if (SharedConstants.isAllowedChatCharacter(character) && !( + if (StringUtil.isAllowedChatCharacter(character) && !( Screen.hasControlDown() && !Screen.hasShiftDown() && !Screen.hasAltDown() && ( character == 'a' || character == 'c' || character == 'v' ) diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/comparison/FluidComparatorRegistryImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/comparison/FluidComparatorRegistryImpl.java index 30a60219f..5209926ed 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/comparison/FluidComparatorRegistryImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/comparison/FluidComparatorRegistryImpl.java @@ -30,7 +30,7 @@ import me.shedaniel.rei.api.common.plugins.REIPlugin; import net.minecraft.world.level.material.Fluid; public class FluidComparatorRegistryImpl extends EntryComparatorRegistryImpl implements FluidComparatorRegistry { - private final EntryComparator fluidNbt = EntryComparator.fluidNbt(); + private final EntryComparator fluidNbt = EntryComparator.fluidComponents(); private final EntryComparator defaultComparator = (context, stack) -> { if (context.isExact()) { return fluidNbt.hash(context, stack); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/comparison/ItemComparatorRegistryImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/comparison/ItemComparatorRegistryImpl.java index 19c4d572f..97e79ac4d 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/comparison/ItemComparatorRegistryImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/comparison/ItemComparatorRegistryImpl.java @@ -30,7 +30,7 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; public class ItemComparatorRegistryImpl extends EntryComparatorRegistryImpl implements ItemComparatorRegistry { - private final EntryComparator itemNbt = EntryComparator.itemNbt(); + private final EntryComparator itemNbt = EntryComparator.itemComponents(); private final EntryComparator defaultComparator = (context, stack) -> { if (context.isExact()) { return itemNbt.hash(context, stack); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/comparison/NbtHasherProviderImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/comparison/NbtHasherProviderImpl.java index 2182322ac..d618f6fb5 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/comparison/NbtHasherProviderImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/comparison/NbtHasherProviderImpl.java @@ -24,75 +24,61 @@ package me.shedaniel.rei.impl.common.entry.comparison; import com.google.common.base.Predicates; +import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet; import me.shedaniel.rei.api.common.entry.comparison.ComparisonContext; import me.shedaniel.rei.api.common.entry.comparison.EntryComparator; import me.shedaniel.rei.impl.Internals; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.nbt.Tag; +import net.minecraft.core.component.DataComponentMap; +import net.minecraft.core.component.DataCompone