diff options
25 files changed, 397 insertions, 336 deletions
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntry.java b/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntry.java index da68b4d39..9ca3b960e 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntry.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntry.java @@ -23,10 +23,10 @@ package me.shedaniel.rei.api.client.favorites; -import com.google.gson.JsonObject; import me.shedaniel.rei.api.client.gui.Renderer; import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.impl.ClientInternals; +import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.Nullable; @@ -40,12 +40,12 @@ public abstract class FavoriteEntry { public static final String TYPE_KEY = "type"; private final UUID uuid = UUID.randomUUID(); - public static FavoriteEntry delegate(Supplier<FavoriteEntry> supplier, @Nullable Supplier<JsonObject> toJson) { + public static FavoriteEntry delegate(Supplier<FavoriteEntry> supplier, @Nullable Supplier<CompoundTag> toJson) { return ClientInternals.delegateFavoriteEntry(supplier, toJson); } @Nullable - public static FavoriteEntry fromJson(JsonObject object) { + public static FavoriteEntry read(CompoundTag object) { return ClientInternals.favoriteEntryFromJson(object); } @@ -57,9 +57,9 @@ public abstract class FavoriteEntry { return entry == null || entry.isInvalid(); } - public JsonObject toJson(JsonObject object) { - object.addProperty(TYPE_KEY, getType().toString()); - return Objects.requireNonNull(Objects.requireNonNull(FavoriteEntryType.registry().get(getType())).toJson(this, object)); + public CompoundTag save(CompoundTag tag) { + tag.putString(TYPE_KEY, getType().toString()); + return Objects.requireNonNull(Objects.requireNonNull(FavoriteEntryType.registry().get(getType())).save(this, tag)); } public UUID getUuid() { @@ -94,7 +94,10 @@ public abstract class FavoriteEntry { @Override public int hashCode() { - return hashIgnoreAmount(); + int result = 1; + result = 31 * result + getType().hashCode(); + result = 31 * result + hashIgnoreAmount(); + return result; } public abstract boolean isSame(FavoriteEntry other); diff --git a/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntryType.java b/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntryType.java index c341581a9..b3e79bf4f 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntryType.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntryType.java @@ -23,11 +23,11 @@ package me.shedaniel.rei.api.client.favorites; -import com.google.gson.JsonObject; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.plugins.PluginManager; import me.shedaniel.rei.api.common.registry.Reloadable; +import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.ApiStatus; @@ -45,11 +45,11 @@ public interface FavoriteEntryType<T extends FavoriteEntry> { return PluginManager.getClientInstance().get(FavoriteEntryType.Registry.class); } - T fromJson(JsonObject object); + T read(CompoundTag object); T fromArgs(Object... args); - JsonObject toJson(T entry, JsonObject object); + CompoundTag save(T entry, CompoundTag tag); @ApiStatus.NonExtendable interface Registry extends Reloadable<REIClientPlugin> { diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/DisplayRenderer.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/DisplayRenderer.java index 29d3593bc..adfb9b087 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/DisplayRenderer.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/DisplayRenderer.java @@ -37,7 +37,8 @@ public abstract class DisplayRenderer extends AbstractRenderer { } @Override - public @Nullable Tooltip getTooltip(Point mouse) { + @Nullable + public Tooltip getTooltip(Point mouse) { return null; } } diff --git a/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryStack.java b/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryStack.java index ce7201d51..cd3defe83 100644 --- a/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryStack.java +++ b/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryStack.java @@ -23,10 +23,6 @@ package me.shedaniel.rei.api.common.entry; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.mojang.serialization.Dynamic; -import com.mojang.serialization.JsonOps; import me.shedaniel.math.Point; import me.shedaniel.rei.api.client.config.ConfigObject; import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer; @@ -41,11 +37,8 @@ import me.shedaniel.rei.impl.Internals; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.NbtOps; -import net.minecraft.nbt.TagParser; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.GsonHelper; import net.minecraft.util.Unit; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; @@ -69,38 +62,6 @@ public interface EntryStack<T> extends TextRepresentable, Renderer { return of(type.getDefinition(), value); } - @ApiStatus.Internal - static EntryStack<?> readFromJson(JsonElement jsonElement) { - try { - JsonObject obj = jsonElement.getAsJsonObject(); - EntryType<Object> type = EntryType.deferred(new ResourceLocation(GsonHelper.getAsString(obj, "type"))); - EntrySerializer<Object> serializer = type.getDefinition().getSerializer(); - if (serializer != null && serializer.supportReading()) { - Object o = serializer.read(TagParser.parseTag(obj.toString())); - return EntryStack.of(type, o); - } - } catch (Exception e) { - e.printStackTrace(); - } - return EntryStack.empty(); - } - - @ApiStatus.Internal - @Nullable - default JsonElement toJson() { - try { - EntrySerializer<T> serializer = getDefinition().getSerializer(); - if (serializer != null && serializer.supportSaving()) { - JsonObject object = Dynamic.convert(NbtOps.INSTANCE, JsonOps.INSTANCE, serializer.save(this, getValue())).getAsJsonObject(); - object.addProperty("type", getType().getId().toString()); - return object; - } - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - static EntryStack<?> read(CompoundTag tag) { EntryDefinition<?> definition = EntryTypeRegistry.getInstance().get(new ResourceLocation(tag.getString("type"))); EntrySerializer<?> serializer = definition.getSerializer(); diff --git a/api/src/main/java/me/shedaniel/rei/impl/ClientInternals.java b/api/src/main/java/me/shedaniel/rei/impl/ClientInternals.java index 1daaa568d..50e512c49 100644 --- a/api/src/main/java/me/shedaniel/rei/impl/ClientInternals.java +++ b/api/src/main/java/me/shedaniel/rei/impl/ClientInternals.java @@ -23,7 +23,6 @@ package me.shedaniel.rei.impl; -import com.google.gson.JsonObject; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.ClientHelper; @@ -37,6 +36,7 @@ import me.shedaniel.rei.api.client.view.ViewSearchBuilder; import me.shedaniel.rei.api.common.plugins.PluginManager; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.FormattedText; import net.minecraft.resources.ResourceLocation; @@ -57,8 +57,8 @@ public final class ClientInternals { private static Supplier<ViewSearchBuilder> viewSearchBuilder = ClientInternals::throwNotSetup; private static Supplier<PluginManager<REIClientPlugin>> clientPluginManager = ClientInternals::throwNotSetup; private static Supplier<EntryRenderer<?>> emptyEntryRenderer = ClientInternals::throwNotSetup; - private static BiFunction<Supplier<FavoriteEntry>, Supplier<JsonObject>, FavoriteEntry> delegateFavoriteEntry = (supplier, toJson) -> throwNotSetup(); - private static Function<JsonObject, FavoriteEntry> favoriteEntryFromJson = (object) -> throwNotSetup(); + private static BiFunction<Supplier<FavoriteEntry>, Supplier<CompoundTag>, FavoriteEntry> delegateFavoriteEntry = (supplier, toJson) -> throwNotSetup(); + private static Function<CompoundTag, FavoriteEntry> favoriteEntryFromJson = (object) -> throwNotSetup(); private static Function<Boolean, ClickArea.Result> clickAreaHandlerResult = (result) -> throwNotSetup(); private static BiFunction<@Nullable Point, Collection<Component>, Tooltip> tooltipProvider = (point, texts) -> throwNotSetup(); private static Supplier<List<String>> jeiCompatMods = ClientInternals::throwNotSetup; @@ -117,12 +117,12 @@ public final class ClientInternals { return tooltipProvider.apply(point, texts); } - public static FavoriteEntry delegateFavoriteEntry(Supplier<FavoriteEntry> supplier, Supplier<JsonObject> toJoin) { + public static FavoriteEntry delegateFavoriteEntry(Supplier<FavoriteEntry> supplier, Supplier<CompoundTag> toJoin) { return delegateFavoriteEntry.apply(supplier, toJoin); } - public static FavoriteEntry favoriteEntryFromJson(JsonObject object) { - return favoriteEntryFromJson.apply(object); + public static FavoriteEntry favoriteEntryFromJson(CompoundTag tag) { + return favoriteEntryFromJson.apply(tag); } public static <T> EntryRenderer<T> getEmptyEntryRenderer() { diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java index f9ab098e6..9be48eff1 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java @@ -23,8 +23,8 @@ package me.shedaniel.rei.plugin.client.favorites; -import com.google.gson.JsonObject; import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.math.Vector4f; import me.shedaniel.clothconfig2.api.ScissorsHandler; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; @@ -44,11 +44,11 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.resources.sounds.SimpleSoundInstance; +import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvents; -import net.minecraft.util.GsonHelper; import net.minecraft.world.level.GameType; import org.jetbrains.annotations.Nullable; @@ -81,14 +81,18 @@ public class GameModeFavoriteEntry extends FavoriteEntry { @Override public void render(PoseStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) { int color = bounds.contains(mouseX, mouseY) ? 0xFFEEEEEE : 0xFFAAAAAA; - fillGradient(matrices, bounds.getX(), bounds.getY(), bounds.getMaxX(), bounds.getY() + 1, color, color); - fillGradient(matrices, bounds.getX(), bounds.getMaxY() - 1, bounds.getMaxX(), bounds.getMaxY(), color, color); - fillGradient(matrices, bounds.getX(), bounds.getY(), bounds.getX() + 1, bounds.getMaxY(), color, color); - fillGradient(matrices, bounds.getMaxX() - 1, bounds.getY(), bounds.getMaxX(), bounds.getMaxY(), color, color); +// fillGradient(matrices, bounds.getX(), bounds.getY(), bounds.getMaxX(), bounds.getY() + 1, color, color); +// fillGradient(matrices, bounds.getX(), bounds.getMaxY() - 1, bounds.getMaxX(), bounds.getMaxY(), color, color); +// fillGradient(matrices, bounds.getX(), bounds.getY(), bounds.getX() + 1, bounds.getMaxY(), color, color); +// fillGradient(matrices, bounds.getMaxX() - 1, bounds.getY(), bounds.getMaxX(), bounds.getMaxY(), color, color); if (bounds.width > 4 && bounds.height > 4) { if (gameMode == null) { updateAnimator(delta); - notSetScissorArea.setBounds(bounds.x + 2, bounds.y + 2, bounds.width - 4, bounds.height - 4); + Vector4f vector4f = new Vector4f(bounds.x + 2, bounds.y + 2, 0, 1.0F); + vector4f.transform(matrices.last().pose()); + Vector4f vector4f2 = new Vector4f(bounds.getMaxX() - 2, bounds.getMaxY() - 2, 0, 1.0F); + vector4f2.transform(matrices.last().pose()); + notSetScissorArea.setBounds((int) vector4f.x(), (int) vector4f.y(), (int) vector4f2.x() - (int) vector4f.x(), (int) vector4f2.y() - (int) vector4f.y()); ScissorsHandler.INSTANCE.scissor(notSetScissorArea); int offset = Math.round(notSetOffset.floatValue() * bounds.getHeight()); for (int i = 0; i <= 3; i++) { @@ -120,7 +124,7 @@ public class GameModeFavoriteEntry extends FavoriteEntry { private void renderGameModeText(PoseStack matrices, GameType type, int centerX, int centerY, int color) { Component s = new TranslatableComponent("text.rei.short_gamemode." + type.getName()); Font font = Minecraft.getInstance().font; - font.draw(matrices, s, centerX - font.width(s) / 2f + 1, centerY - 3.5f, color); + font.draw(matrices, s, centerX - font.width(s) / 2f + 0.5f, centerY - 3.5f, color); } @Override @@ -194,10 +198,10 @@ public class GameModeFavoriteEntry extends FavoriteEntry { public enum Type implements FavoriteEntryType<GameModeFavoriteEntry> { INSTANCE; - + @Override - public GameModeFavoriteEntry fromJson(JsonObject object) { - String stringValue = GsonHelper.getAsString(object, KEY); + public GameModeFavoriteEntry read(CompoundTag object) { + String stringValue = object.getString(KEY); GameType type = stringValue.equals("NOT_SET") ? null : GameType.valueOf(stringValue); return new GameModeFavoriteEntry(type); } @@ -206,11 +210,11 @@ public class GameModeFavoriteEntry extends FavoriteEntry { public GameModeFavoriteEntry fromArgs(Object... args) { return new GameModeFavoriteEntry((GameType) args[0]); } - + @Override - public JsonObject toJson(GameModeFavoriteEntry entry, JsonObject object) { - object.addProperty(KEY, entry.gameMode == null ? "NOT_SET" : entry.gameMode.name()); - return object; + public CompoundTag save(GameModeFavoriteEntry entry, CompoundTag tag) { + tag.putString(KEY, entry.gameMode == null ? "NOT_SET" : entry.gameMode.name()); + return tag; } } diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java index 31b0db5fb..acd9e6a69 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java @@ -23,10 +23,9 @@ package me.shedaniel.rei.plugin.client.favorites; -import com.google.gson.JsonObject; -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.*; -import com.mojang.math.Matrix4f; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.math.Vector4f; +import me.shedaniel.clothconfig2.api.ScissorsHandler; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.REIHelper; @@ -42,13 +41,12 @@ import me.shedaniel.rei.api.common.util.CollectionUtils; import net.minecraft.Util; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.components.events.GuiEventListener; -import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.resources.language.I18n; import net.minecraft.client.resources.sounds.SimpleSoundInstance; +import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvents; -import net.minecraft.util.GsonHelper; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; @@ -59,7 +57,7 @@ public class WeatherFavoriteEntry extends FavoriteEntry { public static final ResourceLocation ID = new ResourceLocation("roughlyenoughitems", "weather"); public static final String TRANSLATION_KEY = "favorite.section.weather"; private static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/recipecontainer.png"); - public static final String KEY = "type"; + public static final String KEY = "weather"; @Nullable private final Weather weather; @@ -86,19 +84,27 @@ public class WeatherFavoriteEntry extends FavoriteEntry { if (weather == null) { matrices.pushPose(); updateAnimator(delta); - notSetScissorArea.setBounds(bounds.x, bounds.y, bounds.width, bounds.height); -// ScissorsHandler.INSTANCE.scissor(notSetScissorArea); + Vector4f vector4f = new Vector4f(bounds.x, bounds.y, 0, 1.0F); + vector4f.transform(matrices.last().pose()); + Vector4f vector4f2 = new Vector4f(bounds.getMaxX(), bounds.getMaxY(), 0, 1.0F); + vector4f2.transform(matrices.last().pose()); + notSetScissorArea.setBounds((int) vector4f.x(), (int) vector4f.y(), (int) vector4f2.x() - (int) vector4f.x(), (int) vector4f2.y() - (int) vector4f.y()); + ScissorsHandler.INSTANCE.scissor(notSetScissorArea); int offset = Math.round(notSetOffset.floatValue() * bounds.getHeight()); for (int i = 0; i <= 2; i++) { Weather type = Weather.byId(i); renderWeatherIcon(matrices, type, bounds.getCenterX(), bounds.getCenterY() + bounds.getHeight() * i - offset, color); } -// ScissorsHandler.INSTANCE.removeLastScissor(); + ScissorsHandler.INSTANCE.removeLastScissor(); matrices.popPose(); } else { renderWeatherIcon(matrices, weather, bounds.getCenterX(), bounds.getCenterY(), color); } } +// fillGradient(matrices, bounds.getX(), bounds.getY(), bounds.getMaxX(), bounds.getY() + 1, color, color); +// fillGradient(matrices, bounds.getX(), bounds.getMaxY() - 1, bounds.getMaxX(), bounds.getMaxY(), color, color); +// fillGradient(matrices, bounds.getX(), bounds.getY(), bounds.getX() + 1, bounds.getMaxY(), color, color); +// fillGradient(matrices, bounds.getMaxX() - 1, bounds.getY(), bounds.getMaxX(), bounds.getMaxY(), color, color); } private void updateAnimator(float delta) { @@ -118,28 +124,7 @@ public class WeatherFavoriteEntry extends FavoriteEntry { private void renderWeatherIcon(PoseStack matrices, Weather type, int centerX, int centerY, int color) { Minecraft.getInstance().getTextureManager().bind(CHEST_GUI_TEXTURE); - Minecraft.getInstance().getTextureManager().bind(TextureAtlas.LOCATION_BLOCKS); - RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); - Matrix4f matrix = matrices.last().pose(); - float j = centerX - 6.5f; - float i = j + 14; - float k = centerY - 6.5f; - float l = k + 14; - float m = getZ(); - float f = type.getId() * 14 / 256f; - float g = f + 14 / 256f; - float h = 14 / 256f; - float n = h + 14 / 256f; - - BufferBuilder bufferBuilder = Tesselator.getInstance().getBuilder(); - bufferBuilder.begin(7, DefaultVertexFormat.POSITION_TEX); - bufferBuilder.vertex(matrix, i, l, m).uv(f, n).endVertex(); - bufferBuilder.vertex(matrix, j, l, m).uv(g, n).endVertex(); - bufferBuilder.vertex(matrix, j, k, m).uv(g, h).endVertex(); - bufferBuilder.vertex(matrix, i, k, m).uv(f, h).endVertex(); - bufferBuilder.end(); - RenderSystem.enableAlphaTest(); - BufferUploader.end(bufferBuilder); + blit(matrices, centerX - 7, centerY - 7, type.getId() * 14, 14, 14, 14, 256, 256); } @Override @@ -211,10 +196,10 @@ public class WeatherFavoriteEntry extends FavoriteEntry { public enum Type implements FavoriteEntryType<WeatherFavoriteEntry> { INSTANCE; - + @Override - public WeatherFavoriteEntry fromJson(JsonObject object) { - String stringValue = GsonHelper.getAsString(object, KEY); + public WeatherFavoriteEntry read(CompoundTag object) { + String stringValue = object.getString(KEY); Weather type = stringValue.equals("NOT_SET") ? null : Weather.valueOf(stringValue); return new WeatherFavoriteEntry(type); } @@ -223,11 +208,11 @@ public class WeatherFavoriteEntry extends FavoriteEntry { public WeatherFavoriteEntry fromArgs(Object... args) { return new WeatherFavoriteEntry((Weather) args[0]); } - + @Override - public JsonObject toJson(WeatherFavoriteEntry entry, JsonObject object) { - object.addProperty(KEY, entry.weather == null ? "NOT_SET" : entry.weather.name()); - return object; + public CompoundTag save(WeatherFavoriteEntry entry, CompoundTag tag) { + tag.putString(KEY, entry.weather == null ? "NOT_SET" : entry.weather.name()); + return tag; } } diff --git a/gradle.properties b/gradle.properties index 50c282545..657fd1fcc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ supported_version=1.16.2/3/4/5 minecraft_version=1.16.5 forge_version=36.0.43 fabricloader_version=0.11.1 -cloth_config_version=4.11.14 +cloth_config_version=4.11.17 modmenu_version=1.16.7 fabric_api=0.30.0+1.16 architectury_version=1.9.136 diff --git a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java index f82444644..3f7e762a7 100644 --- a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java +++ b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java @@ -24,15 +24,12 @@ package me.shedaniel.rei; import com.google.common.collect.Lists; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; import me.shedaniel.architectury.event.events.GuiEvent; import me.shedaniel.architectury.event.events.RecipeUpdateEvent; import me.shedaniel.architectury.event.events.client.ClientScreenInputEvent; import me.shedaniel.architectury.networking.NetworkManager; import me.shedaniel.architectury.platform.Platform; import me.shedaniel.architectury.utils.Env; -import me.shedaniel.architectury.utils.EnvExecutor; import me.shedaniel.math.Point; import me.shedaniel.rei.api.client.REIHelper; import me.shedaniel.rei.api.client.REIOverlay; @@ -102,10 +99,10 @@ import net.minecraft.client.gui.screens.recipebook.GhostRecipe; import net.minecraft.client.gui.screens.recipebook.RecipeBookComponent; import net.minecraft.client.gui.screens.recipebook.RecipeUpdateListener; import net.minecraft.client.resources.language.I18n; +import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TextComponent; import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.GsonHelper; import net.minecraft.util.Unit; import net.minecraft.world.InteractionResult; import net.minecraft.world.inventory.CraftingMenu; @@ -147,18 +144,6 @@ public class RoughlyEnoughItemsCore { public static void attachCommonInternals() { CategoryIdentifierImpl.attach(); - Internals.attachInstanceSupplier(new PluginManagerImpl<>( - REIPlugin.class, - UnaryOperator.identity(), - new EntryTypeRegistryImpl(), - new RecipeManagerContextImpl<>(RecipeManagerContextImpl.supplier()), - new ItemComparatorRegistryImpl(), - new DisplaySerializerRegistryImpl(), - new FluidSupportProviderImpl()), "commonPluginManager"); - Internals.attachInstanceSupplier(new PluginManagerImpl<>( - REIServerPlugin.class, - view -> view.then(PluginView.getInstance()), - new MenuInfoRegistryImpl()), "serverPluginManager"); Internals.attachInstance((Function<ResourceLocation, EntryType<?>>) new Function<ResourceLocation, EntryType<?>>() { ResourceLocation RENDERING_ID = new ResourceLocation("rendering"); private Map<ResourceLocation, EntryType<?>> typeCache = new ConcurrentHashMap<>(); @@ -222,35 +207,33 @@ public class RoughlyEnoughItemsCore { if (Objects.equals(definition.getType().getId(), BuiltinEntryTypes.EMPTY_ID)) { return empty().cast(); } - + return new TypedEntryStack<>(definition, value); } }, Internals.EntryStackProvider.class); Internals.attachInstance(new NbtHasherProviderImpl(), Internals.NbtHasherProvider.class); Internals.attachInstance(EntryIngredientImpl.provide(), Internals.EntryIngredientProvider.class); + Internals.attachInstanceSupplier(new PluginManagerImpl<>( + REIPlugin.class, + UnaryOperator.identity(), + new EntryTypeRegistryImpl(), + new RecipeManagerContextImpl<>(RecipeManagerContextImpl.supplier()), + new ItemComparatorRegistryImpl(), + new DisplaySerializerRegistryImpl(), + new FluidSupportProviderImpl()), "commonPluginManager"); + Internals.attachInstanceSupplier(new PluginManagerImpl<>( + REIServerPlugin.class, + view -> view.then(PluginView.getInstance()), + new MenuInfoRegistryImpl()), "serverPluginManager"); } @Environment(EnvType.CLIENT) public static void attachClientInternals() { - ClientInternals.attachInstanceSupplier(new PluginManagerImpl<>( - REIClientPlugin.class, - view -> view.then(PluginView.getInstance()), - new ViewsImpl(), - new SearchProviderImpl(), - new ConfigManagerImpl(), - new CategoryRegistryImpl(), - new DisplayRegistryImpl(), - new ScreenRegistryImpl(), - new EntryRegistryImpl(), - new FavoriteEntryTypeRegistryImpl(), - new SubsetsRegistryImpl(), - new TransferHandlerRegistryImpl(), - new REIHelperImpl()), "clientPluginManager"); InternalWidgets.attach(); ClientInternals.attachInstance((Supplier<EntryRenderer<?>>) () -> EmptyEntryDefinition.EmptyRenderer.INSTANCE, "emptyEntryRenderer"); - ClientInternals.attachInstance((BiFunction<Supplier<FavoriteEntry>, Supplier<JsonObject>, FavoriteEntry>) (supplier, toJson) -> new FavoriteEntry() { + ClientInternals.attachInstance((BiFunction<Supplier<FavoriteEntry>, Supplier<CompoundTag>, FavoriteEntry>) (supplier, toJson) -> new FavoriteEntry() { FavoriteEntry value = null; - + @Override public FavoriteEntry getUnwrapped() { if (this.value == null) { @@ -258,7 +241,7 @@ public class RoughlyEnoughItemsCore { } return Objects.requireNonNull(value).getUnwrapped(); } - + @Override public UUID getUuid() { return getUnwrapped().getUuid(); @@ -302,58 +285,60 @@ public class RoughlyEnoughItemsCore { public ResourceLocation getType() { return getUnwrapped().getType(); } - + @Override - public JsonObject toJson(JsonObject to) { + public CompoundTag save(CompoundTag tag) { if (toJson == null) { - return getUnwrapped().toJson(to); - } - - JsonObject object = toJson.get(); - for (Map.Entry<String, JsonElement> entry : object.en |
