aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2022-06-28 03:20:16 +0800
committershedaniel <daniel@shedaniel.me>2022-06-28 03:21:12 +0800
commitad4340ec49d11f7a440a6cef911e6f963fe8402f (patch)
treed4a17da1da9bb1c68373bacbb840f179949cbd8d
parentc5f2df8e240a8a960f6e1540fdbf9984e8dce856 (diff)
downloadRoughlyEnoughItems-ad4340ec49d11f7a440a6cef911e6f963fe8402f.tar.gz
RoughlyEnoughItems-ad4340ec49d11f7a440a6cef911e6f963fe8402f.tar.bz2
RoughlyEnoughItems-ad4340ec49d11f7a440a6cef911e6f963fe8402f.zip
Fix compile issues
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/tag/TagNodes.java22
-rw-r--r--fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinTagBuilder.java91
-rw-r--r--fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinTagLoader.java62
-rw-r--r--fabric/src/main/resources/rei.mixins.json1
-rw-r--r--fabric/src/main/resources/roughlyenoughitems.accessWidener10
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java4
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/config/addon/ConfigAddonsScreen.java7
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ConfigAddonsEntry.java6
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/AutoCraftingEvaluator.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryWidget.java5
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/CollapsedEntriesTooltip.java3
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/EntryListStackEntry.java17
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayEntry.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/transfer/MissingStacksTooltip.java8
14 files changed, 95 insertions, 145 deletions
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/tag/TagNodes.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/tag/TagNodes.java
index 76b6adbcc..9877363b2 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/tag/TagNodes.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/tag/TagNodes.java
@@ -32,6 +32,7 @@ import dev.architectury.utils.EnvExecutor;
import io.netty.buffer.Unpooled;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
+import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.Minecraft;
@@ -42,7 +43,6 @@ import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
-import net.minecraft.tags.Tag;
import net.minecraft.tags.TagKey;
import org.jetbrains.annotations.ApiStatus;
@@ -58,10 +58,28 @@ public class TagNodes {
public static final Map<String, ResourceKey<? extends Registry<?>>> TAG_DIR_MAP = new HashMap<>();
public static final ThreadLocal<String> CURRENT_TAG_DIR = new ThreadLocal<>();
- public static final Map<String, Map<Tag<?>, RawTagData>> RAW_TAG_DATA_MAP = new ConcurrentHashMap<>();
+ public static final Map<String, Map<CollectionWrapper<?>, RawTagData>> RAW_TAG_DATA_MAP = new ConcurrentHashMap<>();
public static final Map<ResourceKey<? extends Registry<?>>, Map<ResourceLocation, TagData>> TAG_DATA_MAP = new HashMap<>();
public static Map<ResourceKey<? extends Registry<?>>, Consumer<Consumer<DataResult<Map<ResourceLocation, TagData>>>>> requestedTags = new HashMap<>();
+ public static class CollectionWrapper<T> {
+ private final Collection<T> collection;
+
+ public CollectionWrapper(Collection<T> collection) {
+ this.collection = collection;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return obj instanceof CollectionWrapper && ((CollectionWrapper) obj).collection == collection;
+ }
+
+ @Override
+ public int hashCode() {
+ return System.identityHashCode(collection);
+ }
+ }
+
public record RawTagData(List<ResourceLocation> otherElements, List<ResourceLocation> otherTags) {
}
diff --git a/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinTagBuilder.java b/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinTagBuilder.java
deleted file mode 100644
index 169a0df0f..000000000
--- a/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinTagBuilder.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * This file is licensed under the MIT License, part of Roughly Enough Items.
- * Copyright (c) 2018, 2019, 2020, 2021, 2022 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.mixin.fabric;
-
-import com.mojang.datafixers.util.Either;
-import me.shedaniel.rei.plugin.common.displays.tag.TagNodes;
-import net.minecraft.core.Registry;
-import net.minecraft.resources.ResourceKey;
-import net.minecraft.resources.ResourceLocation;
-import net.minecraft.tags.Tag;
-import net.minecraft.tags.TagBuilder;
-import net.minecraft.tags.TagEntry;
-import org.spongepowered.asm.mixin.Final;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.Shadow;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Inject;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Function;
-
-@Mixin(TagBuilder.class)
-public class MixinTagBuilder<T> {
- @Shadow @Final private List<TagEntry> entries;
-
- @Inject(method = "build", at = @At("RETURN"))
- private void load(Function<ResourceLocation, Tag<T>> tagResolver, Function<ResourceLocation, T> valueResolver, CallbackInfoReturnable<Either<Collection<Tag.BuilderEntry>, Tag<T>>> cir) {
- Tag<T> tag = cir.getReturnValue().right().orElse(null);
- if (tag != null) {
- String currentTagDirectory = TagNodes.CURRENT_TAG_DIR.get();
- if (currentTagDirectory == null) return;
- ResourceKey<? extends Registry<?>> resourceKey = TagNodes.TAG_DIR_MAP.get(currentTagDirectory);
- if (resourceKey == null) return;
- Map<Tag<?>, TagNodes.RawTagData> dataMap = TagNodes.RAW_TAG_DATA_MAP.get(currentTagDirectory);
- if (dataMap == null) return;
- List<ResourceLocation> otherElements = new ArrayList<>();
- List<ResourceLocation> otherTags = new ArrayList<>();
-
- for (Tag.BuilderEntry builderEntry : this.entries) {
- if (builderEntry.entry() instanceof Tag.OptionalTagEntry tagEntry) {
- Tag<T> apply = tagResolver.apply(tagEntry.id);
- if (apply != null) {
- otherTags.add(tagEntry.id);
- }
- } else if (builderEntry.entry() instanceof Tag.TagEntry tagEntry) {
- Tag<T> apply = tagResolver.apply(tagEntry.id);
- if (apply != null) {
- otherTags.add(tagEntry.id);
- }
- } else if (builderEntry.entry() instanceof Tag.OptionalElementEntry tagEntry) {
- T apply = valueResolver.apply(tagEntry.id);
- if (apply != null) {
- otherElements.add(tagEntry.id);
- }
- } else if (builderEntry.entry() instanceof Tag.ElementEntry tagEntry) {
- T apply = valueResolver.apply(tagEntry.id);
- if (apply != null) {
- otherElements.add(tagEntry.id);
- }
- }
- }
-
- dataMap.put(tag, new TagNodes.RawTagData(otherElements, otherTags));
- }
- }
-}
diff --git a/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinTagLoader.java b/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinTagLoader.java
index 493361c56..c866f7ea5 100644
--- a/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinTagLoader.java
+++ b/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinTagLoader.java
@@ -25,17 +25,20 @@ package me.shedaniel.rei.mixin.fabric;
import com.google.common.base.Stopwatch;
import com.google.common.collect.BiMap;
+import com.google.common.collect.Comparators;
import com.google.common.collect.HashBiMap;
+import com.mojang.datafixers.util.Either;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
+import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
+import it.unimi.dsi.fastutil.objects.Reference2ObjectMaps;
+import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
import me.shedaniel.rei.RoughlyEnoughItemsCore;
-import me.shedaniel.rei.plugin.common.displays.tag.TagNode;
import me.shedaniel.rei.plugin.common.displays.tag.TagNodes;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
-import net.minecraft.tags.Tag;
-import net.minecraft.tags.TagKey;
+import net.minecraft.tags.TagEntry;
import net.minecraft.tags.TagLoader;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
@@ -50,15 +53,18 @@ import java.util.*;
public class MixinTagLoader<T> {
@Shadow @Final private String directory;
- @Inject(method = "build", at = @At("HEAD"))
- private void load(Map<ResourceLocation, Tag.Builder> map, CallbackInfoReturnable<Map<ResourceLocation, Tag<T>>> cir) {
+ @Inject(method = "build(Ljava/util/Map;)Ljava/util/Map;", at = @At("HEAD"))
+ private void load(Map<ResourceLocation, TagLoader.EntryWithSource> map, CallbackInfoReturnable<Map<ResourceLocation, Collection<T>>> cir) {
TagNodes.RAW_TAG_DATA_MAP.put(directory, new HashMap<>());
TagNodes.CURRENT_TAG_DIR.set(directory);
}
- @Inject(method = "build", at = @At("RETURN"))
- private void loadPost(Map<ResourceLocation, Tag.Builder> map, CallbackInfoReturnable<Map<ResourceLocation, Tag<T>>> cir) {
- HashBiMap<ResourceLocation, Tag<T>> biMap = HashBiMap.create(cir.getReturnValue());
+ @Inject(method = "build(Ljava/util/Map;)Ljava/util/Map;", at = @At("RETURN"))
+ private void loadPost(Map<ResourceLocation, TagLoader.EntryWithSource> map, CallbackInfoReturnable<Map<ResourceLocation, Collection<T>>> cir) {
+ Map<TagNodes.CollectionWrapper<T>, ResourceLocation> inverseMap = new HashMap<>(cir.getReturnValue().size());
+ for (Map.Entry<ResourceLocation, Collection<T>> entry : cir.getReturnValue().entrySet()) {
+ inverseMap.put(new TagNodes.CollectionWrapper<>(entry.getValue()), entry.getKey());
+ }
ResourceKey<? extends Registry<?>> resourceKey = TagNodes.TAG_DIR_MAP.get(directory);
if (resourceKey == null) return;
TagNodes.TAG_DATA_MAP.put(resourceKey, new HashMap<>());
@@ -66,18 +72,18 @@ public class MixinTagLoader<T> {
Registry<T> registry = ((Registry<Registry<T>>) Registry.REGISTRY).get((ResourceKey<Registry<T>>) resourceKey);
Stopwatch stopwatch = Stopwatch.createStarted();
- Iterator<Map.Entry<Tag<?>, TagNodes.RawTagData>> entryIterator = TagNodes.RAW_TAG_DATA_MAP.getOrDefault(directory, Collections.emptyMap())
+ Iterator<Map.Entry<TagNodes.CollectionWrapper<?>, TagNodes.RawTagData>> entryIterator = TagNodes.RAW_TAG_DATA_MAP.getOrDefault(directory, Reference2ObjectMaps.emptyMap())
.entrySet().iterator();
if (!entryIterator.hasNext()) return;
while (entryIterator.hasNext()) {
- Map.Entry<Tag<?>, TagNodes.RawTagData> entry = entryIterator.next();
- Tag<?> tag = entry.getKey();
+ Map.Entry<TagNodes.CollectionWrapper<?>, TagNodes.RawTagData> entry = entryIterator.next();
+ TagNodes.CollectionWrapper<?> tag = entry.getKey();
entryIterator.remove();
if (registry != null) {
- ResourceLocation tagLoc = biMap.inverse().get(tag);
+ ResourceLocation tagLoc = inverseMap.get(tag);
if (tagLoc != null) {
TagNodes.RawTagData rawTagData = entry.getValue();
@@ -95,4 +101,36 @@ public class MixinTagLoader<T> {
RoughlyEnoughItemsCore.LOGGER.info("Processed %d tags in %s for %s", tagDataMap.size(), stopwatch.stop(), resourceKey.location());
}
+
+ @Inject(method = "build(Lnet/minecraft/tags/TagEntry$Lookup;Ljava/util/List;)Lcom/mojang/datafixers/util/Either;", at = @At("RETURN"))
+ private void load(TagEntry.Lookup<T> lookup, List<TagLoader.EntryWithSource> entries, CallbackInfoReturnable<Either<Collection<TagLoader.EntryWithSource>, Collection<T>>> cir) {
+ Collection<T> tag = cir.getReturnValue().right().orElse(null);
+ if (tag != null) {
+ String currentTagDirectory = TagNodes.CURRENT_TAG_DIR.get();
+ if (currentTagDirectory == null) return;
+ ResourceKey<? extends Registry<?>> resourceKey = TagNodes.TAG_DIR_MAP.get(currentTagDirectory);
+ if (resourceKey == null) return;
+ Map<TagNodes.CollectionWrapper<?>, TagNodes.RawTagData> dataMap = TagNodes.RAW_TAG_DATA_MAP.get(currentTagDirectory);
+ if (dataMap == null) return;
+ List<ResourceLocation> otherElements = new ArrayList<>();
+ List<ResourceLocation> otherTags = new ArrayList<>();
+
+ for (TagLoader.EntryWithSource builderEntry : entries) {
+ TagEntry entry = builderEntry.entry();
+ if (entry.tag) {
+ Collection<T> apply = lookup.tag(entry.id);
+ if (apply != null) {
+ otherTags.add(entry.id);
+ }
+ } else {
+ T apply = lookup.element(entry.id);
+ if (apply != null) {
+ otherElements.add(entry.id);
+ }
+ }
+ }
+
+ dataMap.put(new TagNodes.CollectionWrapper<>(tag), new TagNodes.RawTagData(otherElements, otherTags));
+ }
+ }
}
diff --git a/fabric/src/main/resources/rei.mixins.json b/fabric/src/main/resources/rei.mixins.json
index 7d240b971..17048486a 100644
--- a/fabric/src/main/resources/rei.mixins.json
+++ b/fabric/src/main/resources/rei.mixins.json
@@ -11,7 +11,6 @@
],
"mixins": [
"MixinPacketEncoder",
- "MixinTagBuilder",
"MixinTagLoader",
"MixinTagManager"
],
diff --git a/fabric/src/main/resources/roughlyenoughitems.accessWidener b/fabric/src/main/resources/roughlyenoughitems.accessWidener
index 0d86d79a6..48fa4cc1b 100644
--- a/fabric/src/main/resources/roughlyenoughitems.accessWidener
+++ b/fabric/src/main/resources/roughlyenoughitems.accessWidener
@@ -36,11 +36,5 @@ accessible method net/minecraft/client/gui/screens/Screen
accessible method net/minecraft/client/gui/screens/Screen addWidget (Lnet/minecraft/client/gui/components/events/GuiEventListener;)Lnet/minecraft/client/gui/components/events/GuiEventListener;
accessible method net/minecraft/client/gui/screens/Screen renderTooltipInternal (Lcom/mojang/blaze3d/vertex/PoseStack;Ljava/util/List;II)V
accessible method net/minecraft/client/renderer/RenderType create (Ljava/lang/String;Lcom/mojang/blaze3d/vertex/VertexFormat;Lcom/mojang/blaze3d/vertex/VertexFormat$Mode;ILnet/minecraft/client/renderer/RenderType$CompositeState;)Lnet/minecraft/client/renderer/RenderType$CompositeRenderType;
-accessible class net/minecraft/tags/Tag$OptionalTagEntry
-accessible field net/minecraft/tags/Tag$OptionalTagEntry id Lnet/minecraft/resources/ResourceLocation;
-accessible class net/minecraft/tags/Tag$TagEntry
-accessible field net/minecraft/tags/Tag$TagEntry id Lnet/minecraft/resources/ResourceLocation;
-accessible class net/minecraft/tags/Tag$OptionalElementEntry
-accessible field net/minecraft/tags/Tag$OptionalElementEntry id Lnet/minecraft/resources/ResourceLocation;
-accessible class net/minecraft/tags/Tag$ElementEntry
-accessible field net/minecraft/tags/Tag$ElementEntry id Lnet/minecraft/resources/ResourceLocation; \ No newline at end of file
+accessible field net/minecraft/tags/TagEntry tag Z
+accessible field net/minecraft/tags/TagEntry id Lnet/minecraft/resources/ResourceLocation; \ No newline at end of file
diff --git a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java
index 328914480..9258e3a08 100644
--- a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java
+++ b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java
@@ -101,7 +101,7 @@ public class RoughlyEnoughItemsNetwork {
NetworkManager.registerReceiver(NetworkManager.c2s(), CREATE_ITEMS_HOTBAR_PACKET, Collections.singletonList(new SplitPacketTransformer()), (buf, context) -> {
ServerPlayer player = (ServerPlayer) context.getPlayer();
if (player.getServer().getProfilePermissions(player.getGameProfile()) < player.getServer().getOperatorUserPermissionLevel()) {
- player.displayClientMessage(new TranslatableComponent("text.rei.no_permission_cheat").withStyle(ChatFormatting.RED), false);
+ player.displayClientMessage(Component.translatable("text.rei.no_permission_cheat").withStyle(ChatFormatting.RED), false);
return;
}
ItemStack stack = buf.readItem();
@@ -112,7 +112,7 @@ public class RoughlyEnoughItemsNetwork {
menu.broadcastChanges();
NetworkManager.sendToPlayer(player, RoughlyEnoughItemsNetwork.CREATE_ITEMS_MESSAGE_PACKET, new FriendlyByteBuf(Unpooled.buffer()).writeItem(stack.copy()).writeUtf(player.getScoreboardName(), 32767));
} else {
- player.displayClientMessage(new TranslatableComponent("text.rei.failed_cheat_items"), false);
+ player.displayClientMessage(Component.translatable("text.rei.failed_cheat_items"), false);
}
});
NetworkManager.registerReceiver(NetworkManager.c2s(), MOVE_ITEMS_PACKET, Collections.singletonList(new SplitPacketTransformer()), (packetByteBuf, context) -> {
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 0773483e9..c04120eea 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
@@ -36,13 +36,10 @@ 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.network.chat.TextComponent;
-import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation;
import java.util.Collections;
import java.util.List;
-import java.util.Objects;
import static me.shedaniel.rei.impl.client.gui.screen.DefaultDisplayViewingScreen.CHEST_GUI_TEXTURE;
@@ -51,7 +48,7 @@ public class ConfigAddonsScreen extends Screen {
private final Screen parent;
public ConfigAddonsScreen(Screen parent) {
- super(new TranslatableComponent("text.rei.addons"));
+ super(Component.translatable("text.rei.addons"));
this.parent = parent;
}
@@ -59,7 +56,7 @@ public class ConfigAddonsScreen extends Screen {
public void init() {
super.init();
{
- Component backText = new TextComponent("↩ ").append(new TranslatableComponent("gui.back"));
+ Component backText = Component.literal("↩ ").append(Component.translatable("gui.back"));
addRenderableWidget(new Button(4, 4, Minecraft.getInstance().font.width(backText) + 10, 20, backText, button -> {
minecraft.setScreen(parent);
}));
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ConfigAddonsEntry.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ConfigAddonsEntry.java
index 017201a14..b3aeca310 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ConfigAddonsEntry.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ConfigAddonsEntry.java
@@ -35,7 +35,7 @@ import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.narration.NarratableEntry;
-import net.minecraft.network.chat.TranslatableComponent;
+import net.minecraft.network.chat.Component;
import net.minecraft.util.Unit;
import org.jetbrains.annotations.ApiStatus;
@@ -54,8 +54,8 @@ public class ConfigAddonsEntry extends AbstractConfigListEntry<Unit> {
super(NarratorChatListener.NO_TITLE, false);
this.width = width;
this.buttonWidget.setMessage(REIRuntime.getInstance().getPreviousContainerScreen() != null && Minecraft.getInstance().getConnection() != null
- && Minecraft.getInstance().getConnection().getRecipeManager() != null ? new TranslatableComponent("text.rei.addons")
- : new TranslatableComponent("config.roughlyenoughitems.filteredEntries.loadWorldFirst"));
+ && Minecraft.getInstance().getConnection().getRecipeManager() != null ? Component.translatable("text.rei.addons")
+ : Component.translatable("config.roughlyenoughitems.filteredEntries.loadWorldFirst"));
}
@Override
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/AutoCraftingEvaluator.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/AutoCraftingEvaluator.java
index 6254f1d1a..117a9a7f4 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/AutoCraftingEvaluator.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/AutoCraftingEvaluator.java
@@ -175,7 +175,7 @@ public class AutoCraftingEvaluator {
}
}
} else {
- errorTooltip.add(Tooltip.entry(Component.translatable(new TranslatableComponent("error.rei.multi.errors").withStyle(ChatFormatting.RED))));
+ errorTooltip.add(Tooltip.entry(Component.translatable("error.rei.multi.errors").withStyle(ChatFormatting.RED)));
for (Tooltip.Entry tooltipFilled : tooltipsFilled) {
if (tooltipFilled.isText()) {
MutableComponent colored = Component.literal("- ").withStyle(ChatFormatting.RED)
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryWidget.java
index 227b2f958..50b2c5276 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryWidget.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryWidget.java
@@ -63,7 +63,6 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
-import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
import net.minecraft.network.chat.Component;
@@ -405,7 +404,7 @@ public class EntryWidget extends Slot implements DraggableStackProviderWidget {
}
protected void queueTooltip(PoseStack matrices, int mouseX, int mouseY, float delta) {
- Tooltip tooltip = getCurrentTooltip(TooltipContext.ofMouse().getPoint());
+ Tooltip tooltip = getCurrentTooltip(TooltipContext.ofMouse());
if (tooltip != null) {
tooltip.queue();
}
@@ -436,7 +435,7 @@ public class EntryWidget extends Slot implements DraggableStackProviderWidget {
if (exists) {
tooltip.add(Component.translatable("text.auto_craft.move_items.tooltip").withStyle(ChatFormatting.YELLOW));
- tooltip.add((ClientTooltipComponent) displayTooltipComponent.get());
+ tooltip.add(displayTooltipComponent.get());
}
}
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/CollapsedEntriesTooltip.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/CollapsedEntriesTooltip.java
index 44d848b8e..e3f5f036f 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/CollapsedEntriesTooltip.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/CollapsedEntriesTooltip.java
@@ -34,7 +34,6 @@ import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.network.chat.Component;
-import net.minecraft.network.chat.TextComponent;
import net.minecraft.util.Mth;
import net.minecraft.world.inventory.tooltip.TooltipComponent;
@@ -75,7 +74,7 @@ public class CollapsedEntriesTooltip implements ClientTooltipComponent, TooltipC
if (i / w > 3 - 1) {
poses.translate(0, 0, 200);
MultiBufferSource.BufferSource source = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder());
- Component text = new TextComponent("+" + (stack.getIngredient().size() - w * 3 + 1)).withStyle(ChatFormatting.GRAY);
+ Component text = Component.literal("+" + (stack.getIngredient().size() - w * 3 + 1)).withStyle(ChatFormatting.GRAY);
font.drawInBatch(text, x1 + entrySize / 2 - font.width(text) / 2, y1 + entrySize / 2 - 1, -1, true, poses.last().pose(), source, false, 0, 15728880);
source.endBatch();
break;
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/EntryListStackEntry.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/EntryListStackEntry.java
index 31b03aca1..26a75fbed 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/EntryListStackEntry.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/EntryListStackEntry.java
@@ -26,22 +26,21 @@ package me.shedaniel.rei.impl.client.gui.widget.entrylist;
import com.mojang.blaze3d.vertex.PoseStack;
import me.shedaniel.clothconfig2.api.animator.NumberAnimator;
import me.shedaniel.clothconfig2.api.animator.ValueAnimator;
-import me.shedaniel.math.FloatingPoint;
import me.shedaniel.math.FloatingRectangle;
import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
import me.shedaniel.math.impl.PointHelper;
import me.shedaniel.rei.api.client.ClientHelper;
import me.shedaniel.rei.api.client.gui.widgets.Tooltip;
+import me.shedaniel.rei.api.client.gui.widgets.TooltipContext;
import me.shedaniel.rei.api.client.gui.widgets.Widgets;
import me.shedaniel.rei.api.common.entry.EntryStack;
import me.shedaniel.rei.impl.client.gui.widget.CachedEntryListRender;
import me.shedaniel.rei.impl.client.gui.widget.DisplayedEntryWidget;
import me.shedaniel.rei.impl.common.entry.type.collapsed.CollapsedStack;
import net.minecraft.ChatFormatting;
-import net.minecraft.network.chat.TranslatableComponent;
+import net.minecraft.network.chat.Component;
import net.minecraft.util.Mth;
-import net.minecraft.world.inventory.tooltip.TooltipComponent;
import org.jetbrains.annotations.Nullable;
import java.util.List;
@@ -177,21 +176,21 @@ public class EntryListStackEntry extends DisplayedEntryWidget {
@Override
@Nullable
- public Tooltip getCurrentTooltip(Point point) {
+ public Tooltip getCurrentTooltip(TooltipContext context) {
if (this.collapsedStack != null) {
if (!this.collapsedStack.isExpanded()) {
- Tooltip tooltip = Tooltip.create(point, new TranslatableComponent("text.rei.collapsed.entry", collapsedStack.getName()));
- tooltip.add((TooltipComponent) new CollapsedEntriesTooltip(collapsedStack));
- tooltip.add(new TranslatableComponent("text.rei.collapsed.entry.hint.expand", collapsedStack.getName(), collapsedStack.getIngredient().size())
+ Tooltip tooltip = Tooltip.create(context.getPoint(), Component.translatable("text.rei.collapsed.entry", collapsedStack.getName()));
+ tooltip.add(new CollapsedEntriesTooltip(collapsedStack));
+ tooltip.add(Component.translatable("text.rei.collapsed.entry.hint.expand", collapsedStack.getName(), collapsedStack.getIngredient().size())
.withStyle(ChatFormatting.GRAY, ChatFormatting.ITALIC));
ClientHelper.getInstance().appendModIdToTooltips(tooltip, collapsedStack.getModId());
return tooltip;
}
}
- Tooltip tooltip = super.getCurrentTooltip(point);
+ Tooltip tooltip = super.getCurrentTooltip(context);
if (tooltip != null && this.collapsedStack != null) {
- tooltip.entries().add(Mth.clamp(tooltip.entries().size() - 1, 0, tooltip.entries().size() - 1), Tooltip.entry(new TranslatableComponent("text.rei.collapsed.entry.hint.collapse", collapsedStack.getName(), collapsedStack.getIngredient().size())
+ tooltip.entries().add(Mth.clamp(tooltip.entries().size() - 1, 0, tooltip.entries().size() - 1), Tooltip.entry(Component.translatable("text.rei.collapsed.entry.hint.collapse", collapsedStack.getName(), collapsedStack.getIngredient().size())
.withStyle(ChatFormatting.GRAY, ChatFormatting.ITALIC)));
}
return tooltip;
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayEntry.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayEntry.java
index f0cb0c0ff..98cbbfc06 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayEntry.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayEntry.java
@@ -70,7 +70,7 @@ public class DisplayEntry extends WidgetWithBounds {
this.bounds.setAs(initialBounds.getFloatingBounds());
this.plusButton = Widgets.createButton(new Rectangle(initialBounds.getMaxX() - 16, initialBounds.getMaxY() - 16, 10, 10), Component.literal("+"));
} else {
- this.plusButton = Widgets.createButton(new Rectangle(-1000, -1000, 10, 10), new TextComponent("+"));
+ this.plusButton = Widgets.createButton(new Rectangle(-1000, -1000, 10, 10), Component.literal("+"));
}
}
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/transfer/MissingStacksTooltip.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/transfer/MissingStacksTooltip.java
index 1a6868104..a01ef9151 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/transfer/MissingStacksTooltip.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/transfer/MissingStacksTooltip.java
@@ -37,8 +37,6 @@ import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.network.chat.Component;
-import net.minecraft.network.chat.TextComponent;
-import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.util.Mth;
import net.minecraft.world.inventory.tooltip.TooltipComponent;
@@ -67,7 +65,7 @@ public class MissingStacksTooltip implements ClientTooltipComponent, TooltipComp
int w = Math.max(1, MAX_WIDTH / entrySize);
int size = stacks.size();
int width = Math.min(size, w) * entrySize;
- width = Math.max(width, font.width(new TranslatableComponent("text.rei.missing")));
+ width = Math.max(width, font.width(Component.translatable("text.rei.missing")));
return width;
}
@@ -84,7 +82,7 @@ public class MissingStacksTooltip implements ClientTooltipComponent, TooltipComp
i++;
if (i / w > 5) {
MultiBufferSource.BufferSource source = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder());
- Component text = new TextComponent("+" + (stacks.size() - w * 6 + 1)).withStyle(ChatFormatting.GRAY);
+ Component text = Component.literal("+" + (stacks.size() - w * 6 + 1)).withStyle(ChatFormatting.GRAY);
font.drawInBatch(text, x1 + entrySize / 2 - font.width(text) / 2, y1 + entrySize / 2 - 1, -1, true, poses.last().pose(), source, false, 0, 15728880);
source.endBatch();
break;
@@ -101,7 +99,7 @@ public class MissingStacksTooltip implements ClientTooltipComponent, TooltipComp
@Override
public void renderText(Font font, int x, int y, Matrix4f pose, MultiBufferSource.BufferSource buffers) {
- font.drawInBatch(new TranslatableComponent("text.rei.missing").withStyle(ChatFormatting.GRAY),
+ font.drawInBatch(Component.translatable("text.rei.missing").withStyle(ChatFormatting.GRAY),
x, y + 2,