diff options
15 files changed, 209 insertions, 65 deletions
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigManager.java b/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigManager.java index db6baac9d..9bc243750 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigManager.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigManager.java @@ -75,5 +75,4 @@ public interface ConfigManager extends Reloadable<REIClientPlugin> { Screen getConfigScreen(Screen parent); ConfigObject getConfig(); - } diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/DelegateWidget.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/DelegateWidget.java index fdda2dea6..6275f438d 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/DelegateWidget.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/DelegateWidget.java @@ -85,4 +85,9 @@ public class DelegateWidget extends WidgetWithBounds { public boolean containsMouse(double mouseX, double mouseY) { return widget.containsMouse(mouseX, mouseY); } + + @Override + public boolean isDragging() { + return true; + } } diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widgets.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widgets.java index fea6292e3..0ac417634 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widgets.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widgets.java @@ -26,6 +26,7 @@ package me.shedaniel.rei.api.client.gui.widgets; import com.google.common.collect.AbstractIterator; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.math.Matrix4f; +import com.mojang.math.Vector4f; import me.shedaniel.math.Dimension; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; @@ -94,9 +95,46 @@ public final class Widgets { public void render(PoseStack poseStack, int i, int j, float f) { poseStack.pushPose(); poseStack.last().pose().multiply(translate.get()); - super.render(poseStack, i, j, f); + Vector4f mouse = transformMouse(i, j); + super.render(poseStack, (int) mouse.x(), (int) mouse.y(), f); poseStack.popPose(); } + + private Vector4f transformMouse(double mouseX, double mouseY) { + Vector4f mouse = new Vector4f((float) mouseX, (float) mouseY, 0, 1); + mouse.transform(translate.get()); + return mouse; + } + + @Override + public boolean containsMouse(double mouseX, double mouseY) { + Vector4f mouse = transformMouse(mouseX, mouseY); + return super.containsMouse(mouse.x(), mouse.y()); + } + + @Override + public boolean mouseClicked(double d, double e, int i) { + Vector4f mouse = transformMouse(d, e); + return super.mouseClicked(mouse.x(), mouse.y(), i); + } + + @Override + public boolean mouseReleased(double d, double e, int i) { + Vector4f mouse = transformMouse(d, e); + return super.mouseReleased(mouse.x(), mouse.y(), i); + } + + @Override + public boolean mouseDragged(double d, double e, int i, double f, double g) { + Vector4f mouse = transformMouse(d, e); + return super.mouseDragged(mouse.x(), mouse.y(), i, f, g); + } + + @Override + public boolean mouseScrolled(double d, double e, double f) { + Vector4f mouse = transformMouse(d, e); + return super.mouseScrolled(mouse.x(), mouse.y(), f); + } } private static class VanillaWrappedWidget extends Widget { @@ -134,7 +172,12 @@ public final class Widgets { ((ContainerEventHandler) element).setFocused(guiEventListener); } } - + + @Override + public boolean isDragging() { + return true; + } + @Override public boolean containsMouse(double mouseX, double mouseY) { return element.isMouseOver(mouseX, mouseY); diff --git a/fabric/src/main/java/me/shedaniel/rei/fabric/RoughlyEnoughItemsInitializerImpl.java b/fabric/src/main/java/me/shedaniel/rei/fabric/RoughlyEnoughItemsInitializerImpl.java new file mode 100644 index 000000000..3e06c8898 --- /dev/null +++ b/fabric/src/main/java/me/shedaniel/rei/fabric/RoughlyEnoughItemsInitializerImpl.java @@ -0,0 +1,72 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 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.fabric; + +import com.google.common.collect.ImmutableSet; +import me.shedaniel.rei.RoughlyEnoughItemsState; +import net.fabricmc.api.EnvType; +import net.fabricmc.loader.api.FabricLoader; +import net.fabricmc.loader.api.SemanticVersion; +import net.fabricmc.loader.api.VersionParsingException; + +public class RoughlyEnoughItemsInitializerImpl { + public static boolean isClient() { + return FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT; + } + + public static void checkMods() { + ImmutableSet<String> requiredModules = isClient() ? + ImmutableSet.<String>builder() + .add("fabric-api-base") + .add("fabric-resource-loader-v0") + .add("fabric-networking-v0") + .add("fabric-lifecycle-events-v1") + .add("fabric-rendering-fluids-v1") + .build() : + ImmutableSet.<String>builder() + .add("fabric-api-base") + .add("fabric-resource-loader-v0") + .add("fabric-networking-v0") + .add("fabric-lifecycle-events-v1") + .build(); + for (String module : requiredModules) { + boolean moduleLoaded = FabricLoader.getInstance().isModLoaded(module); + if (!moduleLoaded) { + RoughlyEnoughItemsState.error("Fabric API is not installed!", "https://www.curseforge.com/minecraft/mc-mods/fabric-api/files/all"); + break; + } + } + if (isClient()) { + try { + if (!FabricLoader.getInstance().isModLoaded("cloth-config2")) { + RoughlyEnoughItemsState.error("Cloth Config is not installed!", "https://www.curseforge.com/minecraft/mc-mods/cloth-config/files/all"); + } else if (SemanticVersion.parse(FabricLoader.getInstance().getModContainer("cloth-config2").get().getMetadata().getVersion().getFriendlyString()).compareTo(SemanticVersion.parse("4.10.9")) < 0) { + RoughlyEnoughItemsState.error("Your Cloth Config version is too old!", "https://www.curseforge.com/minecraft/mc-mods/cloth-config/files/all"); + } + } catch (VersionParsingException e) { + e.printStackTrace(); + } + } + } +} diff --git a/forge/src/main/java/me/shedaniel/rei/forge/PluginDetectorImpl.java b/forge/src/main/java/me/shedaniel/rei/forge/PluginDetectorImpl.java index 437a05e22..40bc41a49 100644 --- a/forge/src/main/java/me/shedaniel/rei/forge/PluginDetectorImpl.java +++ b/forge/src/main/java/me/shedaniel/rei/forge/PluginDetectorImpl.java @@ -23,6 +23,7 @@ package me.shedaniel.rei.forge; +import me.shedaniel.architectury.platform.forge.EventBuses; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.common.plugins.PluginManager; import me.shedaniel.rei.api.common.plugins.PluginView; @@ -35,6 +36,7 @@ import me.shedaniel.rei.plugin.client.DefaultClientRuntimePlugin; import me.shedaniel.rei.plugin.common.DefaultPlugin; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import java.util.ArrayList; import java.util.List; @@ -50,6 +52,7 @@ public class PluginDetectorImpl { } public static void detectCommonPlugins() { + EventBuses.registerModEventBus("roughlyenoughitems", FMLJavaModLoadingContext.get().getModEventBus()); RoughlyEnoughItemsForge.<REIPlugin, me.shedaniel.rei.api.common.plugins.REIPlugin<?>>scanAnnotation(REIPlugin.class, me.shedaniel.rei.api.common.plugins.REIPlugin.class::isAssignableFrom, (modId, plugin) -> { ((PluginView) PluginManager.getInstance()).registerPlugin(plugin); }); diff --git a/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsForge.java b/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsForge.java index c3430c559..7f035c134 100644 --- a/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsForge.java +++ b/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsForge.java @@ -24,13 +24,11 @@ package me.shedaniel.rei.forge; import com.google.common.collect.Lists; -import me.shedaniel.architectury.platform.forge.EventBuses; import me.shedaniel.rei.RoughlyEnoughItemsInitializer; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.forgespi.language.IModInfo; import net.minecraftforge.forgespi.language.ModFileScanData; import org.apache.commons.lang3.tuple.ImmutablePair; @@ -51,7 +49,6 @@ public class RoughlyEnoughItemsForge { public static final Logger LOGGER = LogManager.getFormatterLogger("REI"); public RoughlyEnoughItemsForge() { - EventBuses.registerModEventBus("roughlyenoughitems", FMLJavaModLoadingContext.get().getModEventBus()); RoughlyEnoughItemsInitializer.onInitialize(); DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> RoughlyEnoughItemsInitializer::onInitializeClient); } diff --git a/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsInitializerImpl.java b/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsInitializerImpl.java new file mode 100644 index 000000000..b6ce353b2 --- /dev/null +++ b/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsInitializerImpl.java @@ -0,0 +1,43 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 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.forge; + +import me.shedaniel.rei.RoughlyEnoughItemsState; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.fml.ModList; +import net.minecraftforge.fml.loading.FMLEnvironment; + +public class RoughlyEnoughItemsInitializerImpl { + public static boolean isClient() { + return FMLEnvironment.dist == Dist.CLIENT; + } + + public static void checkMods() { + if (isClient()) { + if (!ModList.get().isLoaded("cloth-config")) { + RoughlyEnoughItemsState.error("Cloth Config is not installed!", "https://www.curseforge.com/minecraft/mc-mods/cloth-config/files/all"); + } + } + } +} diff --git a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsInitializer.java b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsInitializer.java index a75362eb6..0eb41f2ce 100644 --- a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsInitializer.java +++ b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsInitializer.java @@ -23,21 +23,14 @@ package me.shedaniel.rei; -import com.google.common.collect.ImmutableSet; -import me.shedaniel.architectury.platform.Platform; -import net.fabricmc.api.EnvType; +import me.shedaniel.architectury.annotations.ExpectPlatform; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; public class RoughlyEnoughItemsInitializer { public static void onInitialize() { - if (Platform.isFabric()) { - checkRequiredFabricModules(); - } - if (Platform.getEnv() == EnvType.CLIENT) { - checkClothConfig(); - } + checkMods(); if (RoughlyEnoughItemsState.getErrors().isEmpty()) { initializeEntryPoint(false, "me.shedaniel.rei.RoughlyEnoughItemsCore"); @@ -61,7 +54,7 @@ public class RoughlyEnoughItemsInitializer { Object instance = name.getConstructor().newInstance(); Method method = null; if (client) { - if (Platform.getEnv() == EnvType.CLIENT) { + if (isClient()) { try { method = name.getDeclaredMethod("onInitializeClient"); } catch (NoSuchMethodException ignored) { @@ -84,43 +77,13 @@ public class RoughlyEnoughItemsInitializer { } } - public static void checkRequiredFabricModules() { - ImmutableSet<String> requiredModules = Platform.getEnv() == EnvType.CLIENT ? - ImmutableSet.<String>builder() - .add("fabric-api-base") - .add("fabric-resource-loader-v0") - .add("fabric-networking-v0") - .add("fabric-lifecycle-events-v1") - .add("fabric-rendering-fluids-v1") - .build() : - ImmutableSet.<String>builder() - .add("fabric-api-base") - .add("fabric-resource-loader-v0") - .add("fabric-networking-v0") - .add("fabric-lifecycle-events-v1") - .build(); - for (String module : requiredModules) { - boolean moduleLoaded = Platform.isModLoaded(module); - if (!moduleLoaded) { - RoughlyEnoughItemsState.error("Fabric API is not installed!", "https://www.curseforge.com/minecraft/mc-mods/fabric-api/files/all"); - break; - } - } + @ExpectPlatform + public static boolean isClient() { + throw new AssertionError(); } - public static void checkClothConfig() { - if (!Platform.isModLoaded(Platform.isFabric() ? "cloth-config2" : "cloth-config")) { - RoughlyEnoughItemsState.error("Cloth Config is not installed!", "https://www.curseforge.com/minecraft/mc-mods/cloth-config/files/all"); - } - /*try { - if (!Platform.isModLoaded("cloth-config2")) { - RoughlyEnoughItemsState.error("Cloth Config is not installed!", "https://www.curseforge.com/minecraft/mc-mods/cloth-config/files/all"); - } else if (SemanticVersion.parse(Platform.getMod("cloth-config2").getVersion()).compareTo(SemanticVersion.parse("4.10.9")) < 0) { - RoughlyEnoughItemsState.error("Your Cloth Config version is too old!", "https://www.curseforge.com/minecraft/mc-mods/cloth-config/files/all"); - } - } catch (VersionParsingException e) { - RoughlyEnoughItemsState.error("Failed to parse Cloth Config version: " + e.getMessage()); - e.printStackTrace(); - }*/ + @ExpectPlatform + public static void checkMods() { + throw new AssertionError(); } }
\ No newline at end of file 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 0c18217cb..9590c62a7 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 @@ -69,7 +69,8 @@ import java.util.stream.Collectors; @ApiStatus.Internal @Environment(EnvType.CLIENT) public class ClientHelperImpl implements ClientHelper { - @ApiStatus.Internal public final LazyLoadedValue<Boolean> isYog = new LazyLoadedValue<>(() -> { + @ApiStatus.Internal + public final LazyLoadedValue<Boolean> isYog = new LazyLoadedValue<>(() -> { try { if (Minecraft.getInstance().getUser().getGameProfile().getId().equals(UUID.fromString("f9546389-9415-4358-9c29-2c26b25bff5b"))) return true; @@ -77,7 +78,8 @@ public class ClientHelperImpl implements ClientHelper { } return false; }); - @ApiStatus.Internal public final LazyLoadedValue<Boolean> isAprilFools = new LazyLoadedValue<>(() -> { + @ApiStatus.Internal + public final LazyLoadedValue<Boolean> isAprilFools = new LazyLoadedValue<>(() -> { try { LocalDateTime now = LocalDateTime.now(); return now.getMonthValue() == 4 && now.getDayOfMonth() == 1; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java index 3a27369d6..25315cca1 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java @@ -386,6 +386,10 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { return Platform.isForge() && advanced.jeiCompatibilityLayer; } + public void setJEICompatibilityLayerEnabled(boolean value) { + advanced.jeiCompatibilityLayer = value; + } + @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD}) @interface DontApplyFieldName {} diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ReloadPluginsEntry.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ReloadPluginsEntry.java index 27a6554df..81c652c97 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ReloadPluginsEntry.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ReloadPluginsEntry.java @@ -35,6 +35,7 @@ import net.minecraft.client.gui.chat.NarratorChatListener; 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.screens.Screen; import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.util.Unit; import org.jetbrains.annotations.ApiStatus; @@ -49,7 +50,8 @@ public class ReloadPluginsEntry extends AbstractConfigListEntry<Unit> { @Override public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { if (PluginManager.areAnyPluginsReloading()) { - Minecraft.getInstance().setScreen(new ConfigReloadingScreen(Minecraft.getInstance().screen)); + Screen screen = Minecraft.getInstance().screen; + Minecraft.getInstance().setScreen(new ConfigReloadingScreen(() -> Minecraft.getInstance().setScreen(screen))); } else { super.render(matrices, mouseX, mouseY, delta); } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/ConfigReloadingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/ConfigReloadingScreen.java index c74f1e928..eb39fbe74 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/ConfigReloadingScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/ConfigReloadingScreen.java @@ -33,10 +33,9 @@ import org.jetbrains.annotations.ApiStatus; @ApiStatus.Internal public class ConfigReloadingScreen extends Screen { + private Runnable parent; - private Screen parent; - - public ConfigReloadingScreen(Screen parent) { + public ConfigReloadingScreen(Runnable parent) { super(NarratorChatListener.NO_TITLE); this.parent = parent; } @@ -50,7 +49,7 @@ public class ConfigReloadingScreen extends Screen { public void render(PoseStack matrices, int int_1, int int_2, float float_1) { this.renderDirtBackground(0); if (!PluginManager.areAnyPluginsReloading()) { - minecraft.setScreen(parent); + parent.run(); } drawCenteredString(matrices, this.font, I18n.get("text.rei.config.is.reloading"), this.width / 2, this.height / 2 - 50, 16777215); String string_3; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/UncertainDisplayViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/UncertainDisplayViewingScreen.java index 31ebbf260..6c1fa75ee 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/UncertainDisplayViewingScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/UncertainDisplayViewingScreen.java @@ -33,8 +33,10 @@ import me.shedaniel.clothconfig2.gui.widget.DynamicNewSmoothScrollingEntryListWi import me.shedaniel.clothconfig2.impl.EasingMethod; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.RoughlyEnoughItemsCore; import me.shedaniel.rei.api.client.ClientHelper; import me.shedaniel.rei.api.client.REIHelper; +import me.shedaniel.rei.api.client.config.ConfigManager; import me.shedaniel.rei.api.client.gui.config.DisplayScreenType; import me.shedaniel.rei.api.client.gui.widgets.Button; import me.shedaniel.rei.api.client.gui.widgets.Widget; @@ -43,6 +45,7 @@ import me.shedaniel.rei.api.client.gui.widgets.Widgets; import me.shedaniel.rei.api.common.util.Animator; import me.shedaniel.rei.api.common.util.ImmutableTextComponent; import me.shedaniel.rei.impl.ClientInternals; +import me.shedaniel.rei.impl.client.config.ConfigManagerImpl; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.chat.NarratorChatListener; @@ -57,7 +60,6 @@ import net.minecraft.util.FormattedCharSequence; import net.minecraft.util.Mth; import org.jetbrains.annotations.ApiStatus; -import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; @@ -80,6 +82,7 @@ public class UncertainDisplayViewingScreen extends Screen { private boolean showTips; private Animator scroll = new Animator(); private List<String> allModsUsingJEI = null; + private boolean jeiEnabled = false; public UncertainDisplayViewingScreen(Screen parent, DisplayScreenType type, boolean showTips, BooleanConsumer callback) { super(ImmutableTextComponent.EMPTY); @@ -139,6 +142,11 @@ public class UncertainDisplayViewingScreen extends Screen { .onClick(button -> { if (scroll.target() == 0 && allModsUsingJEI != null) { scroll.setTo(200, 450); + } else if (allModsUsingJEI != null && jeiEnabled) { + ConfigManagerImpl.getInstance().getConfig().setJEICompatibilityLayerEnabled(jeiEnabled); + ConfigManager.getInstance().saveConfig(); + RoughlyEnoughItemsCore.reloadPlugins(null); + Minecraft.getInstance().setScreen(new ConfigReloadingScreen(() -> callback.accept(original))); } else { callback.accept(original); } @@ -150,7 +158,7 @@ public class UncertainDisplayViewingScreen extends Screen { this.widgets.add(slider = transformScroll(Widgets.wrapVanillaWidget(new AbstractSliderButton(width / 2 - 100, height * 2 - 64, 200, 20, new TranslatableComponent("text.rei.jei_compat.false"), 0) { @Override protected void updateMessage() { - setMessage(new TranslatableComponent("text.rei.jei_compat." + (value == 1f))); + setMessage(new TranslatableComponent("text.rei.jei_compat." + (jeiEnabled = value == 1f))); } @Override @@ -259,7 +267,7 @@ public class UncertainDisplayViewingScreen extends Screen { this.bounds = new Rectangle(x - 4 + 16, y - 4, 176 + 8, 120 + 8); } - @Override + @Override public Rectangle getBounds() { return bounds; } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/FavoritesListWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/FavoritesListWidget.java index e5284e6ab..d6f45de76 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/FavoritesListWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/FavoritesListWidget.java @@ -55,6 +55,7 @@ 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.WidgetWithBounds; import me.shedaniel.rei.api.client.util.ClientEntryStacks; +import me.shedaniel.rei.api.common.entry.EntrySerializer; import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.util.Animator; import me.shedaniel.rei.api.common.util.CollectionUtils; @@ -212,7 +213,10 @@ public class FavoritesListWidget extends WidgetWithBounds implements DraggableSt @Override public Optional<Acceptor> visitDraggedStack(DraggableStack stack) { if (innerBounds.contains(PointHelper.ofMouse())) { - return Optional.of(this::acceptDraggedStack); + EntrySerializer<?> serializer = stack.getStack().getDefinition().getSerializer(); + if (stack instanceof FavoriteDraggableStack || (serializer.supportReading() && serializer.supportSaving())) { + return Optional.of(this::acceptDraggedStack); + } } return Optional.empty(); } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/types/BuiltinEntryDefinition.java b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/types/BuiltinEntryDefinition.java index 4cb06a9ea..2df769391 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/types/BuiltinEntryDefinition.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/types/BuiltinEntryDefinition.java @@ -122,12 +122,12 @@ public class BuiltinEntryDefinition<T> implements EntryDefinition<T>, EntrySeria @Override public boolean supportReading() { - return true; + return empty; } @Override public boolean supportSaving() { - return true; + return empty; } @Override |
