aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2024-11-10 20:07:35 +0800
committershedaniel <daniel@shedaniel.me>2024-11-10 20:08:06 +0800
commit7343b3cc169b52900c251eeab0e2baaeb82aaf45 (patch)
tree7379b1cda76d76bbe800870e10b726e2bdb8c4d5
parent2f2be7e3b8e5d99cf7a76ce51c13ad01be8ca309 (diff)
downloadRoughlyEnoughItems-7343b3cc169b52900c251eeab0e2baaeb82aaf45.tar.gz
RoughlyEnoughItems-7343b3cc169b52900c251eeab0e2baaeb82aaf45.tar.bz2
RoughlyEnoughItems-7343b3cc169b52900c251eeab0e2baaeb82aaf45.zip
Fix #1751
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/ArmorDyeRecipeFiller.java9
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/MapExtendingRecipeFiller.java40
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/TippedArrowRecipeFiller.java38
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/common/DefaultPlugin.java1
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/anvil/DefaultAnvilDisplay.java3
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/crafting/MapExtendingCraftingDisplay.java128
-rw-r--r--gradle.properties2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java7
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java3
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/hints/ImportantWarningsWidget.java132
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/common/entry/DeferringEntryTypeProviderImpl.java37
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/types/EmptyEntryDefinition.java2
-rwxr-xr-xruntime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json4
13 files changed, 330 insertions, 76 deletions
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/ArmorDyeRecipeFiller.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/ArmorDyeRecipeFiller.java
index 6f7a668d3..95b62a5fe 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/ArmorDyeRecipeFiller.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/ArmorDyeRecipeFiller.java
@@ -23,12 +23,13 @@
package me.shedaniel.rei.plugin.client.categories.crafting.filler;
-import me.shedaniel.rei.api.client.registry.entry.EntryRegistry;
import me.shedaniel.rei.api.common.display.Display;
import me.shedaniel.rei.api.common.entry.EntryIngredient;
import me.shedaniel.rei.api.common.entry.EntryStack;
import me.shedaniel.rei.api.common.util.EntryIngredients;
+import me.shedaniel.rei.api.common.util.EntryStacks;
import me.shedaniel.rei.plugin.common.displays.crafting.DefaultCustomShapelessDisplay;
+import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.tags.ItemTags;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.DyeItem;
@@ -43,7 +44,11 @@ public class ArmorDyeRecipeFiller implements CraftingRecipeFiller<ArmorDyeRecipe
@Override
public Collection<Display> apply(RecipeHolder<ArmorDyeRecipe> recipe) {
List<Display> displays = new ArrayList<>();
- List<EntryStack<?>> toDye = EntryRegistry.getInstance().getEntryStacks().filter(entry -> entry.getValueType() == ItemStack.class && entry.<ItemStack>castValue().is(ItemTags.DYEABLE)).toList();
+ List<EntryStack<?>> toDye = BuiltInRegistries.ITEM.stream()
+ .filter(item -> item.builtInRegistryHolder().is(ItemTags.DYEABLE))
+ .map(EntryStacks::of)
+ .<EntryStack<?>>map(EntryStack::cast)
+ .toList();
DyeColor[] colors = DyeColor.values();
for (EntryStack<?> armor : toDye) {
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/MapExtendingRecipeFiller.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/MapExtendingRecipeFiller.java
index 2b8d3d0bb..d336cc2f3 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/MapExtendingRecipeFiller.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/MapExtendingRecipeFiller.java
@@ -24,14 +24,7 @@
package me.shedaniel.rei.plugin.client.categories.crafting.filler;
import me.shedaniel.rei.api.common.display.Display;
-import me.shedaniel.rei.api.common.entry.EntryIngredient;
-import me.shedaniel.rei.api.common.entry.EntryStack;
-import me.shedaniel.rei.api.common.util.EntryIngredients;
-import me.shedaniel.rei.plugin.common.displays.crafting.DefaultCustomDisplay;
-import net.minecraft.ChatFormatting;
-import net.minecraft.client.resources.language.I18n;
-import net.minecraft.network.chat.Component;
-import net.minecraft.world.item.Items;
+import me.shedaniel.rei.plugin.common.displays.crafting.MapExtendingCraftingDisplay;
import net.minecraft.world.item.crafting.MapExtendingRecipe;
import net.minecraft.world.item.crafting.RecipeHolder;
@@ -46,19 +39,7 @@ public class MapExtendingRecipeFiller implements CraftingRecipeFiller<MapExtendi
List<Display> displays = new ArrayList<>();
for (int i = 0; i < 4; i++) {
- EntryIngredient[] inputs = new EntryIngredient[9];
- for (int j = 0; j < 9; j++) {
- if (j == 4) {
- inputs[j] = mapWith("X", i, 1);
- } else {
- inputs[j] = EntryIngredients.of(Items.PAPER);
- }
- }
-
- displays.add(new DefaultCustomDisplay(
- List.of(inputs),
- List.of(mapWith("X", i + 1, 1)),
- Optional.of(recipe.id().location())));
+ displays.add(new MapExtendingCraftingDisplay(i, Optional.of(recipe.id().location())));
}
return displays;
@@ -68,21 +49,4 @@ public class MapExtendingRecipeFiller implements CraftingRecipeFiller<MapExtendi
public Class<MapExtendingRecipe> getRecipeClass() {
return MapExtendingRecipe.class;
}
-
- public static EntryIngredient mapWith(String mapId, int scale, int count) {
- EntryIngredient stacks = EntryIngredients.of(Items.FILLED_MAP, count);
- String unknown = I18n.get("filled_map.unknown");
- for (EntryStack<?> stack : stacks) {
- stack.tooltipProcessor(($, tooltip) -> {
- tooltip.entries().removeIf(entry -> entry.isText() && entry.getAsText().getString().equals(unknown));
- return tooltip;
- });
- stack.tooltip(
- Component.translatable("filled_map.id", mapId).withStyle(ChatFormatting.GRAY),
- Component.translatable("filled_map.scale", (1 << scale)).withStyle(ChatFormatting.GRAY),
- Component.translatable("filled_map.level", scale, 4).withStyle(ChatFormatting.GRAY)
- );
- }
- return stacks;
- }
}
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/TippedArrowRecipeFiller.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/TippedArrowRecipeFiller.java
index 91b94b0e8..d8118ddaa 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/TippedArrowRecipeFiller.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/TippedArrowRecipeFiller.java
@@ -23,13 +23,16 @@
package me.shedaniel.rei.plugin.client.categories.crafting.filler;
-import me.shedaniel.rei.api.client.registry.entry.EntryRegistry;
import me.shedaniel.rei.api.common.display.Display;
+import me.shedaniel.rei.api.common.display.basic.BasicDisplay;
import me.shedaniel.rei.api.common.entry.EntryIngredient;
import me.shedaniel.rei.api.common.util.EntryIngredients;
import me.shedaniel.rei.api.common.util.EntryStacks;
import me.shedaniel.rei.plugin.common.displays.crafting.DefaultCustomDisplay;
+import net.minecraft.core.Registry;
+import net.minecraft.core.RegistryAccess;
import net.minecraft.core.component.DataComponents;
+import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
@@ -46,21 +49,24 @@ public class TippedArrowRecipeFiller implements CraftingRecipeFiller<TippedArrow
Set<ResourceLocation> registeredPotions = new HashSet<>();
List<Display> displays = new ArrayList<>();
- EntryRegistry.getInstance().getEntryStacks().filter(entry -> entry.getValueType() == ItemStack.class && entry.<ItemStack>castValue().getItem() == Items.LINGERING_POTION).forEach(entry -> {
- ItemStack itemStack = (ItemStack) entry.getValue();
- PotionContents potion = itemStack.get(DataComponents.POTION_CONTENTS);
- if (potion.potion().isPresent() && potion.potion().get().unwrapKey().isPresent() && registeredPotions.add(potion.potion().get().unwrapKey().get().location())) {
- List<EntryIngredient> input = new ArrayList<>();
- for (int i = 0; i < 4; i++)
- input.add(arrowStack);
- input.add(EntryIngredients.of(itemStack));
- for (int i = 0; i < 4; i++)
- input.add(arrowStack);
- ItemStack outputStack = new ItemStack(Items.TIPPED_ARROW, 8);
- outputStack.set(DataComponents.POTION_CONTENTS, potion);
- displays.add(new DefaultCustomDisplay(input, List.of(EntryIngredients.of(outputStack)), Optional.of(recipe.id().location())));
- }
- });
+ RegistryAccess registryAccess = BasicDisplay.registryAccess();
+ BasicDisplay.registryAccess().lookup(Registries.POTION).stream()
+ .flatMap(Registry::listElements)
+ .map(reference -> PotionContents.createItemStack(Items.LINGERING_POTION, reference))
+ .forEach(itemStack -> {
+ PotionContents potion = itemStack.get(DataComponents.POTION_CONTENTS);
+ if (potion.potion().isPresent() && potion.potion().get().unwrapKey().isPresent() && registeredPotions.add(potion.potion().get().unwrapKey().get().location())) {
+ List<EntryIngredient> input = new ArrayList<>();
+ for (int i = 0; i < 4; i++)
+ input.add(arrowStack);
+ input.add(EntryIngredients.of(itemStack));
+ for (int i = 0; i < 4; i++)
+ input.add(arrowStack);
+ ItemStack outputStack = new ItemStack(Items.TIPPED_ARROW, 8);
+ outputStack.set(DataComponents.POTION_CONTENTS, potion);
+ displays.add(new DefaultCustomDisplay(input, List.of(EntryIngredients.of(outputStack)), Optional.of(recipe.id().location())));
+ }
+ });
return displays;
}
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/DefaultPlugin.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/DefaultPlugin.java
index 5a4a84ce1..ceed9d1b4 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/DefaultPlugin.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/DefaultPlugin.java
@@ -152,6 +152,7 @@ public class DefaultPlugin implements BuiltinPlugin, REICommonPlugin {
registry.register(id("default/crafting/custom"), DefaultCustomDisplay.SERIALIZER);
registry.register(id("default/crafting/custom_shaped"), DefaultCustomShapedDisplay.SERIALIZER);
registry.register(id("default/crafting/custom_shapeless"), DefaultCustomShapelessDisplay.SERIALIZER);
+ registry.register(id("extension/crafting/map_extending"), MapExtendingCraftingDisplay.SERIALIZER);
registry.register(id("default/smelting"), DefaultSmeltingDisplay.SERIALIZER);
registry.register(id("default/smoking"), DefaultSmokingDisplay.SERIALIZER);
registry.register(id("default/blasting"), DefaultBlastingDisplay.SERIALIZER);
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/anvil/DefaultAnvilDisplay.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/anvil/DefaultAnvilDisplay.java
index 581eb042c..d6c7e7459 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/anvil/DefaultAnvilDisplay.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/anvil/DefaultAnvilDisplay.java
@@ -32,6 +32,8 @@ import me.shedaniel.rei.api.common.display.basic.BasicDisplay;
import me.shedaniel.rei.api.common.entry.EntryIngredient;
import me.shedaniel.rei.api.common.util.EntryIngredients;
import me.shedaniel.rei.plugin.common.BuiltinPlugin;
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.Environment;
import net.minecraft.client.Minecraft;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.codec.ByteBufCodecs;
@@ -108,6 +110,7 @@ public class DefaultAnvilDisplay extends BasicDisplay {
@ApiStatus.Experimental
@ApiStatus.Internal
+ @Environment(EnvType.CLIENT)
public static Optional<Pair<ItemStack, Integer>> calculateOutput(ItemStack left, ItemStack right) {
try {
if (Minecraft.getInstance().player == null) return Optional.empty();
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/crafting/MapExtendingCraftingDisplay.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/crafting/MapExtendingCraftingDisplay.java
new file mode 100644
index 000000000..b40c27f88
--- /dev/null
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/crafting/MapExtendingCraftingDisplay.java
@@ -0,0 +1,128 @@
+/*
+ * 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.plugin.common.displays.crafting;
+
+import com.mojang.serialization.Codec;
+import com.mojang.serialization.codecs.RecordCodecBuilder;
+import dev.architectury.platform.Platform;
+import dev.architectury.utils.Env;
+import me.shedaniel.rei.api.common.display.Display;
+import me.shedaniel.rei.api.common.display.DisplaySerializer;
+import me.shedaniel.rei.api.common.entry.EntryIngredient;
+import me.shedaniel.rei.api.common.entry.EntryStack;
+import me.shedaniel.rei.api.common.util.EntryIngredients;
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.Environment;
+import net.minecraft.ChatFormatting;
+import net.minecraft.client.resources.language.I18n;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.codec.ByteBufCodecs;
+import net.minecraft.network.codec.StreamCodec;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.world.item.Items;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.List;
+import java.util.Optional;
+
+public class MapExtendingCraftingDisplay extends DefaultCraftingDisplay {
+ public static final DisplaySerializer<MapExtendingCraftingDisplay> SERIALIZER = DisplaySerializer.of(
+ RecordCodecBuilder.mapCodec(instance -> instance.group(
+ Codec.INT.fieldOf("i").forGetter(d -> d.i),
+ ResourceLocation.CODEC.optionalFieldOf("location").forGetter(MapExtendingCraftingDisplay::getDisplayLocation)
+ ).apply(instance, MapExtendingCraftingDisplay::new)),
+ StreamCodec.composite(
+ ByteBufCodecs.INT,
+ d -> d.i,
+ ByteBufCodecs.optional(ResourceLocation.STREAM_CODEC),
+ MapExtendingCraftingDisplay::getDisplayLocation,
+ MapExtendingCraftingDisplay::new
+ ));
+
+ private final int i;
+
+ public MapExtendingCraftingDisplay(int i, Optional<ResourceLocation> id) {
+ super(getInputs(i), List.of(mapWith("X", i + 1, 1)), id);
+ this.i = i;
+ }
+
+ private static List<EntryIngredient> getInputs(int i) {
+ EntryIngredient[] inputs = new EntryIngredient[9];
+ for (int j = 0; j < 9; j++) {
+ if (j == 4) {
+ inputs[j] = mapWith("X", i, 1);
+ } else {
+ inputs[j] = EntryIngredients.of(Items.PAPER);
+ }
+ }
+ return List.of(inputs);
+ }
+
+ @Override
+ @Nullable
+ public DisplaySerializer<? extends Display> getSerializer() {
+ return SERIALIZER;
+ }
+
+ public static EntryIngredient mapWith(String mapId, int scale, int count) {
+ if (Platform.getEnvironment() == Env.CLIENT) {
+ return mapWithClient(mapId, scale, count);
+ } else {
+ return EntryIngredients.of(Items.FILLED_MAP, count);
+ }
+ }
+
+ @Environment(EnvType.CLIENT)
+ public static EntryIngredient mapWithClient(String mapId, int scale, int count) {
+ EntryIngredient stacks = EntryIngredients.of(Items.FILLED_MAP, count);
+ String unknown = I18n.get("filled_map.unknown");
+ for (EntryStack<?> stack : stacks) {
+ stack.tooltipProcessor(($, tooltip) -> {
+ tooltip.entries().removeIf(entry -> entry.isText() && entry.getAsText().getString().equals(unknown));
+ return tooltip;
+ });
+ stack.tooltip(
+ Component.translatable("filled_map.id", mapId).withStyle(ChatFormatting.GRAY),
+ Component.translatable("filled_map.scale", (1 << scale)).withStyle(ChatFormatting.GRAY),
+ Component.translatable("filled_map.level", scale, 4).withStyle(ChatFormatting.GRAY)
+ );
+ }
+ return stacks;
+ }
+
+ @Override
+ public boolean isShapeless() {
+ return false;
+ }
+
+ @Override
+ public int getWidth() {
+ return 3;
+ }
+
+ @Override
+ public int getHeight() {
+ return 3;
+ }
+}
diff --git a/gradle.properties b/gradle.properties
index a1d905fae..4c76c39f9 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,7 +1,7 @@
org.gradle.jvmargs=-Xmx6G
base_version=17.0
unstable=false
-supported_version=1.21.2
+supported_version=1.21.2/3
minecraft_version=1.21.2
platforms=fabric,neoforge
forge_version=49.1.10
diff --git a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java
index 0e771ac4b..8a31cb95a 100644
--- a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java
+++ b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java
@@ -24,11 +24,13 @@
package me.shedaniel.rei;
import com.google.common.collect.ImmutableList;
+import dev.architectury.event.events.common.LifecycleEvent;
import dev.architectury.platform.Mod;
import dev.architectury.platform.Platform;
import dev.architectury.registry.ReloadListenerRegistry;
import dev.architectury.utils.Env;
import dev.architectury.utils.EnvExecutor;
+import dev.architectury.utils.GameInstance;
import me.shedaniel.rei.api.common.entry.type.EntryType;
import me.shedaniel.rei.api.common.plugins.REICommonPlugin;
import me.shedaniel.rei.impl.Internals;
@@ -147,9 +149,12 @@ public class RoughlyEnoughItemsCore {
RoughlyEnoughItemsNetwork.onInitialize();
if (Platform.getEnvironment() == Env.SERVER) {
- MutableLong lastReload = new MutableLong(-1);
+ LifecycleEvent.SERVER_STARTED.register(server -> {
+ ReloadManagerImpl.reloadPlugins(null, ReloadInterruptionContext.ofNever());
+ });
ReloadListenerRegistry.register(PackType.SERVER_DATA, (preparationBarrier, resourceManager, executor, executor2) -> {
return preparationBarrier.wait(Unit.INSTANCE).thenRunAsync(() -> {
+ if (GameInstance.getServer() == null) return;
ReloadManagerImpl.reloadPlugins(null, ReloadInterruptionContext.ofNever());
}, executor2);
});
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java
index 8b85d4255..0c081340e 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java
@@ -51,6 +51,7 @@ import me.shedaniel.rei.api.common.plugins.PluginManager;
import me.shedaniel.rei.impl.client.REIRuntimeImpl;
import me.shedaniel.rei.impl.client.gui.craftable.CraftableFilter;
import me.shedaniel.rei.impl.client.gui.dragging.CurrentDraggingStack;
+import me.shedaniel.rei.impl.client.gui.hints.ImportantWarningsWidget;
import me.shedaniel.rei.impl.client.gui.modules.MenuAccess;
import me.shedaniel.rei.impl.client.gui.modules.MenuHolder;
import me.shedaniel.rei.impl.client.gui.widget.*;
@@ -187,6 +188,8 @@ public abstract class ScreenOverlayImpl extends ScreenOverlay {
this.widgets.add(draggingStack);
this.widgets.add(InternalWidgets.wrapLateRenderable(hintsWidget));
this.hintsWidget.init();
+
+ this.widgets.add(InternalWidgets.wrapLateRenderable(new ImportantWarningsWidget()));
}
private Rectangle getSearchFieldArea() {
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/hints/ImportantWarningsWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/hints/ImportantWarningsWidget.java
new file mode 100644
index 000000000..66daf5c3f
--- /dev/null
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/hints/ImportantWarningsWidget.java
@@ -0,0 +1,132 @@
+/*
+ * 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.hints;
+
+import me.shedaniel.math.Rectangle;
+import me.shedaniel.rei.RoughlyEnoughItemsCoreClient;
+import me.shedaniel.rei.api.client.ClientHelper;
+import me.shedaniel.rei.api.client.gui.config.DisplayPanelLocation;
+import me.shedaniel.rei.api.client.gui.widgets.WidgetWithBounds;
+import me.shedaniel.rei.api.client.gui.widgets.Widgets;
+import me.shedaniel.rei.api.client.registry.entry.EntryRegistry;
+import me.shedaniel.rei.api.client.registry.screen.ScreenRegistry;
+import me.shedaniel.rei.impl.common.entry.type.EntryRegistryImpl;
+import me.shedaniel.rei.impl.common.entry.type.EntryRegistryListener;
+import me.shedaniel.rei.impl.common.util.InstanceHelper;
+import net.minecraft.ChatFormatting;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiGraphics;
+import net.minecraft.client.gui.components.events.GuiEventListener;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.MutableComponent;
+
+import java.util.List;
+
+public class ImportantWarningsWidget extends WidgetWithBounds {
+ private static final EntryRegistryListener LISTENER = new EntryRegistryListener() {
+ };
+ private static String prevId = "";
+ private static boolean dirty = false;
+ private boolean visible;
+ private final Rectangle bounds;
+ private final Rectangle buttonBounds = new Rectangle();
+ private List<Component> texts;
+
+ public ImportantWarningsWidget() {
+ if (((EntryRegistryImpl) EntryRegistry.getInstance()).listeners.add(LISTENER)) {
+ String newId = Minecraft.getInstance().hasSingleplayerServer() ?
+ "integrated:" + Minecraft.getInstance().getSingleplayerServer().getWorldData().getLevelName()
+ : InstanceHelper.connectionFromClient() != null ? "server:" + InstanceHelper.connectionFromClient().getId()
+ : "null";
+ if (!newId.equals(prevId)) {
+ prevId = newId;
+ dirty = true;
+ }
+ dirty = dirty && !ClientHelper.getInstance().canUseMovePackets();
+ }
+
+ this.visible = dirty;
+ this.texts = List.of(
+ Component.translatable("text.rei.recipes.not.full.title").withStyle(ChatFormatting.RED),
+ Component.translatable("text.rei.recipes.not.full.desc", Component.translatable("text.rei.recipes.not.full.desc.command").withStyle(ChatFormatting.AQUA, ChatFormatting.UNDERLINE)).withStyle(ChatFormatting.GRAY)
+ );
+ this.bounds = ScreenRegistry.getInstance().getOverlayBounds(DisplayPanelLocation.LEFT, Minecraft.getInstance().screen);
+ this.bounds.setBounds(this.bounds.x + 10, this.bounds.y + 10, this.bounds.width - 20, this.bounds.height - 20);
+ int heightRequired = -5;
+ for (Component text : texts) {
+ heightRequired += Minecraft.getInstance().font.wordWrapHeight(text, this.bounds.width * 2) / 2;
+ heightRequired += 5;
+ }
+ this.bounds.height = Math.min(heightRequired + 20, this.bounds.height);
+ }
+
+ @Override
+ public Rectangle getBounds() {
+ return bounds;
+ }
+
+ @Override
+ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
+ if (!visible)
+ return;
+ graphics.pose().pushPose();
+ graphics.pose().translate(0, 0, 900);
+ graphics.fill(bounds.x - 5, bounds.y - 5, bounds.getMaxX() + 5, bounds.getMaxY() + 5, 0x90111111);
+ int y = bounds.y;
+ for (Component text : texts) {
+ graphics.pose().pushPose();
+ graphics.pose().translate(bounds.x, y, 0);
+ graphics.pose().scale(0.5f, 0.5f, 1);
+ graphics.drawWordWrap(Minecraft.getInstance().font, text, 0, 0, bounds.width * 2, -1);
+ y += Minecraft.getInstance().font.wordWrapHeight(text, bounds.width * 2) / 2 + 5;
+ graphics.pose().popPose();
+ }
+
+ MutableComponent okayText = Component.translatable("text.rei.recipes.not.full.button.okay");
+ graphics.pose().pushPose();
+ graphics.pose().translate(bounds.x + bounds.width / 2 - Minecraft.getInstance().font.width(okayText) * 0.75 / 2, bounds.getMaxY() - 9, 0);
+ graphics.pose().scale(0.75f, 0.75f, 1);
+ this.buttonBounds.setBounds(bounds.x, bounds.getMaxY() - 20, bounds.width, 20);
+ graphics.drawString(Minecraft.getInstance().font, okayText, 0, 0,
+ buttonBounds.contains(mouseX, mouseY) ? 0xfffff8de : 0xAAFFFFFF);
+ graphics.pose().popPose();
+ graphics.pose().popPose();
+ }
+
+ @Override
+ public boolean mouseClicked(double mouseX, double mouseY, int button) {
+ if (this.visible && button == 0 && buttonBounds.contains(mouseX, mouseY)) {
+ dirty = false;
+ this.visible = false;
+ Widgets.produceClickSound();
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public List<? extends GuiEventListener> children() {
+ return List.of();
+ }
+}
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/DeferringEntryTypeProviderImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/DeferringEntryTypeProviderImpl.java
index 20f6171ff..f53ee9dc3 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/DeferringEntryTypeProviderImpl.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/DeferringEntryTypeProviderImpl.java
@@ -84,24 +84,27 @@ public enum DeferringEntryTypeProviderImpl implements Function<ResourceLocation,
@Environment(EnvType.CLIENT)
public EntryType<Renderer> renderingType(ResourceLocation id) {
+ @Environment(EnvType.CLIENT)
+ class RenderType implements EntryType<Renderer> {
+ private final int hashCode = id.hashCode();
+
+ @Override
+ public ResourceLocation getId() {
+ return id;
+ }
+
+ @Override
+ public EntryDefinition<Renderer> getDefinition() {
+ return RenderingEntryDefinition.RENDERING;
+ }
+
+ @Override
+ public int hashCode() {
+ return hashCode;
+ }
+ }
if (render == null) {
- int hashCode = id.hashCode();
- render = new EntryType<>() {
- @Override
- public ResourceLocation getId() {
- return id;
- }
-
- @Override
- public EntryDefinition<Renderer> getDefinition() {
- return RenderingEntryDefinition.RENDERING;
- }
-
- @Override
- public int hashCode() {
- return hashCode;
- }
- };
+ render = new RenderType();
}
return render;
}
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/types/EmptyEntryDefinition.java b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/types/EmptyEntryDefinition.java
index 0f1dcfacb..5a67a2bd9 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/types/EmptyEntryDefinition.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/types/EmptyEntryDefinition.java
@@ -39,7 +39,7 @@ import org.jetbrains.annotations.Nullable;
@ApiStatus.Internal
public class EmptyEntryDefinition {
- public static final EntryDefinition<Unit> EMPTY = new BuiltinEntryDefinition<>(Unit.class, BuiltinEntryTypes.EMPTY, true, () -> Unit.INSTANCE, () -> () -> new EmptyRenderer());
+ public static final EntryDefinition<Unit> EMPTY = new BuiltinEntryDefinition<>(Unit.class, BuiltinEntryTypes.EMPTY, true, () -> Unit.INSTANCE, () -> EmptyRenderer::new);
@Environment(EnvType.CLIENT)
public static class EmptyRenderer implements EntryRenderer<Unit> {
diff --git a/runtime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json b/runtime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json
index af68baab0..d6c807650 100755
--- a/runtime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json
+++ b/runtime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json
@@ -21,6 +21,10 @@
"text.rei.caching.search.step": "Step %d/%d (%s%%):",
"text.rei.searching": "REI searching results...",
"text.rei.searching.step": "This is slower on the first search.\nProgress: %s%%",
+ "text.rei.recipes.not.full.title": "Partial Recipes Data Warning",
+ "text.rei.recipes.not.full.desc": "REI does not have access to all recipes data!\nHere's what you can do:\n• If you are on a vanilla server and have operator permissions, running %s will unlock some recipes.\n• If you are on a modded server, ask the server owner to install REI on the server.",
+ "text.rei.recipes.not.full.desc.command": "/recipe give @p *",
+ "text.rei.recipes.not.full.button.okay": "Okay, I understand!",
"text.rei.config.menu.dark_theme": "Dark Theme",
"text.rei.config.menu.reduced_motion": "Reduced Motion",
"text.rei.config.menu.craftable_filter": "Craftable Filter",