diff options
| author | shedaniel <daniel@shedaniel.me> | 2021-03-28 01:44:38 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2021-03-28 01:44:38 +0800 |
| commit | c80c345c4fa3def0536bcecbc2223f202af79415 (patch) | |
| tree | 26208cfd201227070b546f5f12d260c9c6db9775 /runtime/src/main/java/me/shedaniel | |
| parent | b11c3866aada638f0ad758ced4068c71e620ce23 (diff) | |
| download | RoughlyEnoughItems-c80c345c4fa3def0536bcecbc2223f202af79415.tar.gz RoughlyEnoughItems-c80c345c4fa3def0536bcecbc2223f202af79415.tar.bz2 RoughlyEnoughItems-c80c345c4fa3def0536bcecbc2223f202af79415.zip | |
Complete custom favorites
Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'runtime/src/main/java/me/shedaniel')
17 files changed, 332 insertions, 225 deletions
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.entrySet()) { - to.add(entry.getKey(), entry.getValue()); + return getUnwrapped().save(tag); } - return to; - } + return tag.merge(toJson.get()); + } + @Override public boolean isSame(FavoriteEntry other) { return getUnwrapped().isSame(other.getUnwrapped()); } }, "delegateFavoriteEntry"); - ClientInternals.attachInstance((Function<JsonObject, FavoriteEntry>) (object) -> { - String type = GsonHelper.getAsString(object, FavoriteEntry.TYPE_KEY); - switch (type) { - case "stack": - case "item": - case "fluid": - case "empty": - return FavoriteEntry.fromEntryStack(EntryStack.readFromJson(object)); - default: - ResourceLocation id = new ResourceLocation(type); - return Objects.requireNonNull(Objects.requireNonNull(FavoriteEntryType.registry().get(id)).fromJson(object)); - } + ClientInternals.attachInstance((Function<CompoundTag, FavoriteEntry>) (object) -> { + String type = object.getString(FavoriteEntry.TYPE_KEY); + ResourceLocation id = new ResourceLocation(type); + return Objects.requireNonNull(Objects.requireNonNull(FavoriteEntryType.registry().get(id)).read(object)); }, "favoriteEntryFromJson"); ClientInternals.attachInstance((BiFunction<@Nullable Point, Collection<Component>, Tooltip>) QueuedTooltip::create, "tooltipProvider"); ClientInternals.attachInstance((Function<@Nullable Boolean, ClickArea.Result>) successful -> new ClickArea.Result() { private List<CategoryIdentifier<?>> categories = Lists.newArrayList(); - + @Override public ClickArea.Result category(CategoryIdentifier<?> category) { this.categories.add(category); return this; } - + @Override public boolean isSuccessful() { return successful; } - + @Override public Stream<CategoryIdentifier<?>> getCategories() { return categories.stream(); } }, "clickAreaHandlerResult"); + 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"); } @ApiStatus.Internal @@ -479,7 +464,7 @@ public class RoughlyEnoughItemsCore { if (shouldReturn(screen)) return InteractionResult.PASS; resetFocused(screen); - if (REIHelper.getInstance().isOverlayVisible() && REIHelper.getInstance().getOverlay().get().mouseClicked(mouseX, mouseY, button)) { + if (REIHelper.getInstance().getOverlay().get().mouseClicked(mouseX, mouseY, button)) { if (button == 0) { screen.setDragging(true); } 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 64700c4cd..0c18217cb 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 @@ -330,7 +330,8 @@ public class ClientHelperImpl implements ClientHelper { } @Override - public @Nullable CategoryIdentifier<?> getPreferredOpenedCategory() { + @Nullable + public CategoryIdentifier<?> getPreferredOpenedCategory() { return this.preferredOpenedCategory; } @@ -414,9 +415,10 @@ public class ClientHelperImpl implements ClientHelper { this.preferredOpenedCategory = category; return this; } - + @Override - public @Nullable CategoryIdentifier<?> getPreferredOpenedCategory() { + @Nullable + public CategoryIdentifier<?> getPreferredOpenedCategory() { return this.preferredOpenedCategory; } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigManagerImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigManagerImpl.java index 4ce4c30f6..6a9feabe9 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigManagerImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigManagerImpl.java @@ -26,9 +26,9 @@ package me.shedaniel.rei.impl.client.config; import com.google.common.collect.Lists; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import com.google.gson.JsonElement; import com.mojang.blaze3d.platform.InputConstants; import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.math.Matrix4f; import me.shedaniel.architectury.hooks.ScreenHooks; import me.shedaniel.architectury.platform.Platform; @@ -42,7 +42,7 @@ import me.shedaniel.cloth.clothconfig.shadowed.blue.endless.jankson.Jankson; import me.shedaniel.cloth.clothconfig.shadowed.blue.endless.jankson.JsonNull; import me.shedaniel.cloth.clothconfig.shadowed.blue.endless.jankson.JsonObject; import me.shedaniel.cloth.clothconfig.shadowed.blue.endless.jankson.JsonPrimitive; -import me.shedaniel.cloth.clothconfig.shadowed.blue.endless.jankson.api.SyntaxError; +import me.shedaniel.cloth.clothconfig.shadowed.blue.endless.jankson.api.DeserializationException; import me.shedaniel.clothconfig2.api.ConfigEntryBuilder; import me.shedaniel.clothconfig2.api.Modifier; import me.shedaniel.clothconfig2.api.ModifierKeyCode; @@ -76,6 +76,7 @@ import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.resources.language.I18n; import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.Tag; import net.minecraft.nbt.TagParser; import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.Component; @@ -99,60 +100,13 @@ import static me.shedaniel.autoconfig.util.Utils.setUnsafely; @ApiStatus.Internal @Environment(EnvType.CLIENT) public class ConfigManagerImpl implements ConfigManager { - private boolean craftableOnly; + private boolean craftableOnly = false; private final Gson gson = new GsonBuilder().create(); private ConfigObjectImpl object; public ConfigManagerImpl() { - this.craftableOnly = false; Jankson jankson = Jankson.builder().build(); - AutoConfig.register(ConfigObjectImpl.class, (definition, configClass) -> new JanksonConfigSerializer<>(definition, configClass, Jankson.builder().registerPrimitiveTypeAdapter(InputConstants.Key.class, it -> { - return it instanceof String ? InputConstants.getKey((String) it) : null; - }).registerSerializer(InputConstants.Key.class, (it, marshaller) -> new JsonPrimitive(it.getName())).registerTypeAdapter(ModifierKeyCode.class, o -> { - String code = ((JsonPrimitive) o.get("keyCode")).asString(); - if (code.endsWith(".unknown")) return ModifierKeyCode.unknown(); - InputConstants.Key keyCode = InputConstants.getKey(code); - Modifier modifier = Modifier.of(((Number) ((JsonPrimitive) o.get("modifier")).getValue()).shortValue()); - return ModifierKeyCode.of(keyCode, modifier); - }).registerSerializer(ModifierKeyCode.class, (keyCode, marshaller) -> { - JsonObject object = new JsonObject(); - object.put("keyCode", new JsonPrimitive(keyCode.getKeyCode().getName())); - object.put("modifier", new JsonPrimitive(keyCode.getModifier().getValue())); - return object; - }).registerSerializer(EntryStack.class, (stack, marshaller) -> { - try { - return jankson.load(gson.toJson(stack.toJson())); - } catch (SyntaxError syntaxError) { - syntaxError.printStackTrace(); - return JsonNull.INSTANCE; - } - }).registerPrimitiveTypeAdapter(EntryStack.class, it -> { - return it instanceof String ? EntryStack.readFromJson(gson.fromJson((String) it, JsonElement.class)) : null; - }).registerTypeAdapter(EntryStack.class, it -> { - return EntryStack.readFromJson(gson.fromJson(it.toString(), JsonElement.class)); - }).registerSerializer(FavoriteEntry.class, (favoriteEntry, marshaller) -> { - try { - return jankson.load(favoriteEntry.toJson(new com.google.gson.JsonObject()).toString()); - } catch (SyntaxError syntaxError) { - syntaxError.printStackTrace(); - return JsonNull.INSTANCE; - } - }).registerTypeAdapter(FavoriteEntry.class, it -> { - com.google.gson.JsonObject object = gson.fromJson(it.toString(), com.google.gson.JsonObject.class); - return FavoriteEntry.delegate(() -> FavoriteEntry.fromJson(object), () -> object); - }).registerPrimitiveTypeAdapter(FavoriteEntry.class, it -> { - com.google.gson.JsonObject object = gson.fromJson(it.toString(), com.google.gson.JsonObject.class); - return FavoriteEntry.delegate(() -> FavoriteEntry.fromJson(object), () -> object); - }).registerSerializer(FilteringRule.class, (rule, marshaller) -> { - return new JsonPrimitive(FilteringRule.toTag(rule, new CompoundTag()).toString()); - }).registerPrimitiveTypeAdapter(FilteringRule.class, it -> { - try { - return it instanceof String ? FilteringRule.fromTag(TagParser.parseTag((String) it)) : null; - } catch (Exception e) { - e.printStackTrace(); - return null; - } - }).build())); + AutoConfig.register(ConfigObjectImpl.class, (definition, configClass) -> new JanksonConfigSerializer<>(definition, configClass, buildJankson(Jankson.builder()))); GuiRegistry guiRegistry = AutoConfig.getGuiRegistry(ConfigObjectImpl.class); guiRegistry.registerPredicateProvider((i13n, field, config, defaults, guiProvider) -> { if (field.isAnnotationPresent(ConfigEntry.Gui.Excluded.class)) @@ -183,6 +137,127 @@ public class ConfigManagerImpl implements ConfigManager { RoughlyEnoughItemsCore.LOGGER.info("Config loaded."); } + private static Jankson buildJankson(Jankson.Builder builder) { + // InputConstants.Key + builder.registerSerializer(InputConstants.Key.class, (value, marshaller) -> { + return new JsonPrimitive(value.getName()); + }); + builder.registerDeserializer(String.class, InputConstants.Key.class, (value, marshaller) -> { + return InputConstants.getKey(value); + }); + + // ModifierKeyCode + builder.registerSerializer(ModifierKeyCode.class, (value, marshaller) -> { + JsonObject object = new JsonObject(); + object.put("keyCode", new JsonPrimitive(value.getKeyCode().getName())); + object.put("modifier", new JsonPrimitive(value.getModifier().getValue())); + return object; + }); + builder.registerDeserializer(JsonObject.class, ModifierKeyCode.class, (value, marshaller) -> { + String code = value.get(String.class, "keyCode"); + if (code.endsWith(".unknown")) { + return ModifierKeyCode.unknown(); + } else { + InputConstants.Key keyCode = InputConstants.getKey(code); + Modifier modifier = Modifier.of(value.getShort("modifier", (short) 0)); + return ModifierKeyCode.of(keyCode, modifier); + } + }); + + // Tag + builder.registerSerializer(Tag.class, (value, marshaller) -> { + return marshaller.serialize(value.toString()); + }); + builder.registerDeserializer(String.class, Tag.class, (value, marshaller) -> { + try { + return TagParser.parseTag(value); + } catch (CommandSyntaxException e) { + throw new DeserializationException(e); + } + }); + + // EntryStack + builder.registerSerializer(EntryStack.class, (stack, marshaller) -> { + try { + return marshaller.serialize(stack.save()); + } catch (Exception e) { + e.printStackTrace(); + return JsonNull.INSTANCE; + } + }); + builder.registerDeserializer(Tag.class, EntryStack.class, (value, marshaller) -> { + try { + return EntryStack.read((CompoundTag) value); + } catch (Exception e) { + e.printStackTrace(); + return EntryStack.empty(); + } + }); + builder.registerDeserializer(String.class, EntryStack.class, (value, marshaller) -> { + try { + return EntryStack.read(TagParser.parseTag(value)); + } catch (Exception e) { + e.printStackTrace(); + return EntryStack.empty(); + } + }); + + // FilteringRule + builder.registerSerializer(FilteringRule.class, (value, marshaller) -> { + try { + return marshaller.serialize(FilteringRule.save(value, new CompoundTag())); + } catch (Exception e) { + e.printStackTrace(); + return JsonNull.INSTANCE; + } + }); + builder.registerDeserializer(Tag.class, FilteringRule.class, (value, marshaller) -> { + try { + return FilteringRule.read((CompoundTag) value); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + }); + builder.registerDeserializer(String.class, FilteringRule.class, (value, marshaller) -> { + try { + return FilteringRule.read(TagParser.parseTag(value)); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + }); + + // FavoriteEntry + builder.registerSerializer(FavoriteEntry.class, (value, marshaller) -> { + try { + return marshaller.serialize(value.save(new CompoundTag())); + } catch (Exception e) { + e.printStackTrace(); + return JsonNull.INSTANCE; + } + }); + builder.registerDeserializer(Tag.class, FavoriteEntry.class, (value, marshaller) -> { + try { + return FavoriteEntry.delegate(() -> FavoriteEntry.read((CompoundTag) value), () -> (CompoundTag) value); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + }); + builder.registerDeserializer(String.class, FavoriteEntry.class, (value, marshaller) -> { + try { + CompoundTag tag = TagParser.parseTag(value); + return FavoriteEntry.delegate(() -> FavoriteEntry.read(tag), () -> tag); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + }); + + return builder.build(); + } + @Override public void startReload() { } @@ -193,8 +268,9 @@ public class ConfigManagerImpl implements ConfigManager { @Override public void saveConfig() { - if (getConfig().getFavoriteEntries() != null) + if (getConfig().getFavoriteEntries() != null) { getConfig().getFavoriteEntries().removeIf(Objects::isNull); + } if (getConfig().getFilteredStacks() != null) { getConfig().getFilteredStacks().removeIf(EntryStack::isEmpty); List<EntryStack<?>> normalizedFilteredStacks = CollectionUtils.map(getConfig().getFilteredStacks(), EntryStack::normalize); @@ -204,11 +280,11 @@ public class ConfigManagerImpl implements ConfigManager { if (getConfig().getFilteringRules().stream().noneMatch(filteringRule -> filteringRule instanceof ManualFilteringRule)) { getConfig().getFilteringRules().add(new ManualFilteringRule()); } - AutoConfig.getConfigHolder(ConfigObjectImpl.class).save(); AutoConfig.getConfigHolder(ConfigObjectImpl.class).registerLoadListener((configHolder, configObject) -> { object = configObject; return InteractionResult.PASS; }); + AutoConfig.getConfigHolder(ConfigObjectImpl.class).save(); } @Override diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/FilteringRule.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/FilteringRule.java index a5098779a..dd8cd6340 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/FilteringRule.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/FilteringRule.java @@ -56,17 +56,17 @@ public interface FilteringRule<T extends FilteringRule<?>> { return registry; } - static CompoundTag toTag(FilteringRule<?> rule, CompoundTag tag) { + static CompoundTag save(FilteringRule<?> rule, CompoundTag tag) { tag.putString("id", REGISTRY.getKey(rule).toString()); - tag.put("rule", rule.toTag(new CompoundTag())); + tag.put("rule", rule.save(new CompoundTag())); return tag; } - static FilteringRule<?> fromTag(CompoundTag tag) { + static FilteringRule<?> read(CompoundTag tag) { return REGISTRY.get(ResourceLocation.tryParse(tag.getString("id"))).createFromTag(tag.getCompound("rule")); } - CompoundTag toTag(CompoundTag tag); + CompoundTag save(CompoundTag tag); T createFromTag(CompoundTag tag); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/rules/ManualFilteringRule.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/rules/ManualFilteringRule.java index 5bcd19e2c..d5a2cfde3 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/rules/ManualFilteringRule.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/rules/ManualFilteringRule.java @@ -41,7 +41,7 @@ import java.util.stream.Collectors; public class ManualFilteringRule extends AbstractFilteringRule<ManualFilteringRule> { @Override - public CompoundTag toTag(CompoundTag tag) { + public CompoundTag save(CompoundTag tag) { return tag; } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/rules/SearchFilteringRule.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/rules/SearchFilteringRule.java index 3113cc79c..eeb494cea 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/rules/SearchFilteringRule.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/rules/SearchFilteringRule.java @@ -65,7 +65,7 @@ public class SearchFilteringRule extends AbstractFilteringRule<SearchFilteringRu } @Override - public CompoundTag toTag(CompoundTag tag) { + public CompoundTag save(CompoundTag tag) { tag.putString("filter", filter.getFilter()); tag.putBoolean("show", show); return tag; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/type/types/RenderingEntryDefinition.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/type/types/RenderingEntryDefinition.java index d04a86e14..e8dfa574f 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/type/types/RenderingEntryDefinition.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/type/types/RenderingEntryDefinition.java @@ -67,7 +67,8 @@ public class RenderingEntryDefinition { } @Override - public @Nullable Tooltip getTooltip(EntryStack<Renderer> entry, Point mouse) { + @Nullable + public Tooltip getTooltip(EntryStack<Renderer> entry, Point mouse) { return entry.getValue().getTooltip(mouse); } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/favorites/FavoriteEntryTypeRegistryImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/favorites/FavoriteEntryTypeRegistryImpl.java index 759ff2ab9..41c308588 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/favorites/FavoriteEntryTypeRegistryImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/favorites/FavoriteEntryTypeRegistryImpl.java @@ -60,7 +60,8 @@ public class FavoriteEntryTypeRegistryImpl implements FavoriteEntryType.Registry } @Override - public @Nullable ResourceLocation getId(FavoriteEntryType<?> type) { + @Nullable + public ResourceLocation getId(FavoriteEntryType<?> type) { return this.registry.inverse().get(type); } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ContainerScreenOverlay.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ContainerScreenOverlay.java index 68d9a7782..ef88474a0 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ContainerScreenOverlay.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ContainerScreenOverlay.java @@ -23,7 +23,6 @@ package me.shedaniel.rei.impl.client.gui; -import com.google.common.collect.AbstractIterator; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; @@ -44,7 +43,10 @@ import me.shedaniel.rei.api.client.gui.config.SearchFieldLocation; import me.shedaniel.rei.api.client.gui.drag.DraggableStackProvider; import me.shedaniel.rei.api.client.gui.drag.DraggableStackVisitor; import me.shedaniel.rei.api.client.gui.drag.DraggingContext; -import me.shedaniel.rei.api.client.gui.widgets.*; +import me.shedaniel.rei.api.client.gui.widgets.Button; +import me.shedaniel.rei.api.client.gui.widgets.Tooltip; +import me.shedaniel.rei.api.client.gui.widgets.Widget; +import me.shedaniel.rei.api.client.gui.widgets.Widgets; import me.shedaniel.rei.api.client.registry.category.CategoryRegistry; import me.shedaniel.rei.api.client.registry.screen.ClickArea; import me.shedaniel.rei.api.client.registry.screen.OverlayDecider; @@ -70,7 +72,6 @@ import me.shedaniel.rei.impl.client.gui.widget.search.OverlaySearchField; import me.shedaniel.rei.impl.common.util.Weather; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.chat.NarratorChatListener; -import net.minecraft.client.gui.components.events.ContainerEventHandler; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; @@ -109,6 +110,7 @@ public class ContainerScreenOverlay extends REIOverlay { private Rectangle bounds; private Window window; |
