diff options
Diffstat (limited to 'runtime')
51 files changed, 2911 insertions, 342 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsInitializer.java b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsInitializer.java index 97f53c08d..5b56c0739 100644 --- a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsInitializer.java +++ b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsInitializer.java @@ -27,13 +27,19 @@ import dev.architectury.injectables.annotations.ExpectPlatform; import net.fabricmc.api.EnvType; import java.lang.invoke.MethodHandles; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; public class RoughlyEnoughItemsInitializer { + public static final String COMPATIBLE_MC_VERSION = "1.18"; + public static void onInitialize() { RoughlyEnoughItemsState.env = isClient() ? EnvType.CLIENT : EnvType.SERVER; RoughlyEnoughItemsState.isDev = isDev(); + + if (getMinecraftVersion().startsWith("1.") && !getMinecraftVersion().startsWith(COMPATIBLE_MC_VERSION)) { + RoughlyEnoughItemsState.error("Your current REI version (for " + COMPATIBLE_MC_VERSION + ") is not compatible with your current Minecraft version (" + getMinecraftVersion() + ")."); + } + checkMods(); if (RoughlyEnoughItemsState.getErrors().isEmpty()) { @@ -95,4 +101,9 @@ public class RoughlyEnoughItemsInitializer { public static void checkMods() { throw new AssertionError(); } + + @ExpectPlatform + public static String getMinecraftVersion() { + 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 6705f1fc0..89568931a 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 @@ -256,11 +256,14 @@ public class ClientHelperImpl implements ClientHelper { if (ConfigObject.getInstance().getRecipeScreenType() == DisplayScreenType.COMPOSITE) { screen = new CompositeDisplayViewingScreen(map, builder.getPreferredOpenedCategory()); } else if (ConfigObject.getInstance().getRecipeScreenType() == DisplayScreenType.UNSET) { - screen = new UncertainDisplayViewingScreen(REIRuntime.getInstance().getPreviousScreen(), DisplayScreenType.UNSET, true, original -> { - ConfigObject.getInstance().setRecipeScreenType(original ? DisplayScreenType.ORIGINAL : DisplayScreenType.COMPOSITE); - ConfigManager.getInstance().saveConfig(); - openView(builder); - }); + ConfigObject.getInstance().setRecipeScreenType(DisplayScreenType.ORIGINAL); + ConfigManager.getInstance().saveConfig(); + return openView(builder); +// screen = new UncertainDisplayViewingScreen(REIRuntime.getInstance().getPreviousScreen(), DisplayScreenType.UNSET, true, original -> { +// ConfigObject.getInstance().setRecipeScreenType(original ? DisplayScreenType.ORIGINAL : DisplayScreenType.COMPOSITE); +// ConfigManager.getInstance().saveConfig(); +// openView(builder); +// }); } else { screen = new DefaultDisplayViewingScreen(map, builder.getPreferredOpenedCategory()); } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/REIRuntimeImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/REIRuntimeImpl.java index 9351303cb..792c66586 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/REIRuntimeImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/REIRuntimeImpl.java @@ -26,6 +26,7 @@ package me.shedaniel.rei.impl.client; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; import com.mojang.blaze3d.platform.Window; +import com.mojang.blaze3d.systems.RenderSystem; import dev.architectury.event.EventResult; import dev.architectury.event.events.client.ClientGuiEvent; import dev.architectury.event.events.client.ClientTickEvent; @@ -43,6 +44,7 @@ import me.shedaniel.rei.api.client.registry.screen.ScreenRegistry; import me.shedaniel.rei.api.common.registry.ReloadStage; import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl; import me.shedaniel.rei.impl.client.gui.hints.HintProvider; +import me.shedaniel.rei.impl.client.gui.widget.CachedEntryListRender; import me.shedaniel.rei.impl.client.gui.widget.search.OverlaySearchField; import me.shedaniel.rei.impl.client.search.argument.Argument; import net.fabricmc.api.EnvType; @@ -240,6 +242,11 @@ public class REIRuntimeImpl implements REIRuntime { Argument.SEARCH_CACHE.clear(); getOverlay().ifPresent(ScreenOverlay::queueReloadOverlay); lastDisplayScreen.clear(); + if (!RenderSystem.isOnRenderThread()) { + RenderSystem.recordRenderCall(CachedEntryListRender::refresh); + } else { + CachedEntryListRender.refresh(); + } } @Override 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 9357313c5..485b90271 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 @@ -51,6 +51,7 @@ import me.shedaniel.rei.api.client.REIRuntime; import me.shedaniel.rei.api.client.config.ConfigManager; import me.shedaniel.rei.api.client.config.entry.EntryStackProvider; import me.shedaniel.rei.api.client.favorites.FavoriteEntry; +import me.shedaniel.rei.api.client.gui.config.CheatingMode; import me.shedaniel.rei.api.client.gui.config.DisplayScreenType; import me.shedaniel.rei.api.client.gui.config.SyntaxHighlightingMode; import me.shedaniel.rei.api.client.overlay.ScreenOverlay; @@ -79,7 +80,6 @@ import net.minecraft.nbt.TagParser; import net.minecraft.network.chat.*; import net.minecraft.util.Mth; import net.minecraft.world.InteractionResult; -import org.apache.commons.lang3.mutable.MutableLong; import org.jetbrains.annotations.ApiStatus; import java.util.*; @@ -135,6 +135,21 @@ public class ConfigManagerImpl implements ConfigManager { } private static Jankson buildJankson(Jankson.Builder builder) { + // CheatingMode + builder.registerSerializer(CheatingMode.class, (value, marshaller) -> { + if (value == CheatingMode.WHEN_CREATIVE) { + return new JsonPrimitive("WHEN_CREATIVE"); + } else { + return new JsonPrimitive(value == CheatingMode.ON); + } + }); + builder.registerDeserializer(Boolean.class, CheatingMode.class, (value, unmarshaller) -> { + return value ? CheatingMode.ON : CheatingMode.OFF; + }); + builder.registerDeserializer(String.class, CheatingMode.class, (value, unmarshaller) -> { + return CheatingMode.valueOf(value.toUpperCase(Locale.ROOT)); + }); + // InputConstants.Key builder.registerSerializer(InputConstants.Key.class, (value, marshaller) -> { return new JsonPrimitive(value.getName()); @@ -355,7 +370,6 @@ public class ConfigManagerImpl implements ConfigManager { ((GlobalizedClothConfigScreen) screen).listWidget.children().add(0, (AbstractConfigEntry) feedbackEntry); ((GlobalizedClothConfigScreen) screen).listWidget.children().add(0, (AbstractConfigEntry) new EmptyEntry(4)); ScreenHooks.addRenderableWidget(screen, new Button(screen.width - 104, 4, 100, 20, new TranslatableComponent("text.rei.credits"), button -> { - MutableLong current = new MutableLong(0); CreditsScreen creditsScreen = new CreditsScreen(screen); Minecraft.getInstance().setScreen(creditsScreen); })); 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 4fe37ff72..76c7e269c 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 @@ -38,7 +38,9 @@ import me.shedaniel.rei.api.client.gui.config.*; import me.shedaniel.rei.impl.client.entry.filtering.FilteringRule; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.minecraft.client.Minecraft; import net.minecraft.util.Mth; +import net.minecraft.world.level.GameType; import org.jetbrains.annotations.ApiStatus; import java.lang.annotation.ElementType; @@ -73,12 +75,18 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { @Override public boolean isCheating() { - return basics.cheating; + return basics.cheating == CheatingMode.ON || (basics.cheating == CheatingMode.WHEN_CREATIVE && Minecraft.getInstance().gameMode != null + && Minecraft.getInstance().gameMode.getPlayerMode() == GameType.CREATIVE); } @Override public void setCheating(boolean cheating) { - basics.cheating = cheating; + basics.cheating = cheating ? CheatingMode.ON : CheatingMode.OFF; + } + + @Override + public CheatingMode getCheatingMode() { + return basics.cheating; } @Override @@ -182,6 +190,11 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { } @Override + public String getTimeCommand() { + return advanced.commands.timeCommand; + } + + @Override public int getMaxRecipePerPage() { return advanced.layout.maxRecipesPerPage; } @@ -255,6 +268,15 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { } @Override + public boolean doesCacheEntryRendering() { + return advanced.miscellaneous.cachingFastEntryRendering; + } + + public void setDoesCacheEntryRendering(boolean doesCacheEntryRendering) { + advanced.miscellaneous.cachingFastEntryRendering = doesCacheEntryRendering; + } + + @Override public boolean doDebugRenderTimeRequired() { return advanced.layout.debugRenderTimeRequired; } @@ -265,6 +287,11 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { } @Override + public FavoriteAddWidgetMode getFavoriteAddWidgetMode() { + return advanced.layout.favoriteAddWidgetMode; + } + + @Override public ModifierKeyCode getFavoriteKeyCode() { return basics.keyBindings.favoriteKeybind == null ? ModifierKeyCode.unknown() : basics.keyBindings.favoriteKeybind; } @@ -433,6 +460,11 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { } @Override + public boolean isFocusModeZoomed() { + return appearance.isFocusModeZoomed; + } + + @Override public SearchMode getTooltipSearchMode() { return advanced.search.tooltipSearch; } @@ -489,7 +521,7 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { public static class Basics { @ConfigEntry.Gui.Excluded public List<FavoriteEntry> favorites = new ArrayList<>(); - @Comment("Declares whether cheating mode is on.") private boolean cheating = false; + @Comment("Declares whether cheating mode is on.") @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) private CheatingMode cheating = CheatingMode.OFF; private boolean favoritesEnabled = true; @ConfigEntry.Gui.CollapsibleObject(startExpanded = true) private KeyBindings keyBindings = new KeyBindings(); @@ -542,6 +574,7 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { @UsePercentage(min = 0.1, max = 1.0, prefix = "Limit: ") private double favoritesHorizontalEntriesBoundaries = 1.0; private int favoritesHorizontalEntriesBoundariesColumns = 50; @UseSpecialSearchFilterSyntaxHighlightingScreen private SyntaxHighlightingMode syntaxHighlightingMode = SyntaxHighlightingMode.COLORFUL; + private boolean isFocusModeZoomed = false; } public static class Functionality { @@ -549,7 +582,8 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { @Comment("Declares whether mob effects should be on the left side instead of the right side.") private boolean leftSideMobEffects = false; @Comment("Declares whether subsets is enabled.") private boolean isSubsetsEnabled = false; private boolean allowInventoryHighlighting = true; - @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) private ItemCheatingMode itemCheatingMode = ItemCheatingMode.REI_LIKE; + @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) + private ItemCheatingMode itemCheatingMode = ItemCheatingMode.REI_LIKE; } public static class Advanced { @@ -585,6 +619,8 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { private int maxRecipesPageHeight = 300; @Comment("Declares whether entry rendering time should be debugged.") private boolean debugRenderTimeRequired = false; @Comment("Merges displays with equal contents under 1 display.") private boolean mergeDisplayUnderOne = true; + @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) + private FavoriteAddWidgetMode favoriteAddWidgetMode = FavoriteAddWidgetMode.ALWAYS_VISIBLE; } public static class Accessibility { @@ -616,12 +652,15 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { @Comment("Declares the command used to change gamemode.") private String gamemodeCommand = "/gamemode {gamemode}"; @Comment("Declares the command used in servers to cheat items.") private String giveCommand = "/give {player_name} {item_identifier}{nbt} {count}"; @Comment("Declares the command used to change weather.") private String weatherCommand = "/weather {weather}"; + @Comment("Declares the command used to change time.") private String timeCommand = "/time set {time}"; } public static class Miscellaneous { @Comment("Declares whether arrows in containers should be clickable.") private boolean clickableRecipeArrows = true; private boolean registerRecipesInAnotherThread = true; private boolean newFastEntryRendering = true; + @ConfigEntry.Gui.PrefixText + private boolean cachingFastEntryRendering = false; } public static class Filtering { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringScreen.java index 2ea8b127a..5fcd5790e 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringScreen.java @@ -30,8 +30,7 @@ import com.mojang.blaze3d.vertex.*; import com.mojang.math.Matrix4f; import me.shedaniel.clothconfig2.ClothConfigInitializer; import me.shedaniel.clothconfig2.api.ScissorsHandler; -import me.shedaniel.clothconfig2.api.ScrollingContainer; -import me.shedaniel.clothconfig2.gui.widget.DynamicNewSmoothScrollingEntryListWidget; +import me.shedaniel.clothconfig2.api.scroll.ScrollingContainer; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.math.impl.PointHelper; @@ -80,7 +79,7 @@ public class FilteringScreen extends Screen { } @Override - public int getScrollBarX() { + public int getScrollBarX(int maxX) { return width - 7; } }; @@ -130,7 +129,7 @@ public class FilteringScreen extends Screen { for (int i = 0; i < entryStacks.size(); i++) { EntryStack<?> stack = entryStacks.get(i); EntryListEntry entry = entries.get(i); - entry.getBounds().y = (int) (entry.backupY - scrolling.scrollAmount); + entry.getBounds().y = entry.backupY - scrolling.scrollAmountInt(); if (entry.isSelected() && !entry.isFiltered()) { filteringEntry.configFiltered.add(stack); filteringEntry.edited = true; @@ -145,7 +144,7 @@ public class FilteringScreen extends Screen { for (int i = 0; i < entryStacks.size(); i++) { EntryStack<?> stack = entryStacks.get(i); EntryListEntry entry = entries.get(i); - entry.getBounds().y = (int) (entry.backupY - scrolling.scrollAmount); + entry.getBounds().y = entry.backupY - scrolling.scrollAmountInt(); if (entry.isSelected() && filteringEntry.configFiltered.remove(stack)) { filteringEntry.edited = true; entry.dirty = true; @@ -219,14 +218,14 @@ public class FilteringScreen extends Screen { ScissorsHandler.INSTANCE.scissor(bounds); for (EntryListEntry entry : entries) entry.clearStacks(); - int skip = Math.max(0, Mth.floor(scrolling.scrollAmount / (float) entrySize())); + int skip = Math.max(0, Mth.floor(scrolling.scrollAmount() / (float) entrySize())); int nextIndex = skip * innerBounds.width / entrySize(); int i = nextIndex; BatchedEntryRendererManager manager = new BatchedEntryRendererManager(); for (; i < entryStacks.size(); i++) { EntryStack<?> stack = entryStacks.get(i); EntryListEntry entry = entries.get(nextIndex); - entry.getBounds().y = (int) (entry.backupY - scrolling.scrollAmount); + entry.getBounds().y = entry.backupY - scrolling.scrollAmountInt(); if (entry.getBounds().y > bounds.getMaxY()) break; entry.entry(stack); @@ -281,13 +280,13 @@ public class FilteringScreen extends Screen { Point p = secondPoint; if (p == null) { p = PointHelper.ofMouse(); - p.translate(0, (int) scrolling.scrollAmount); + p.translate(0, scrolling.scrollAmountInt()); } int left = Math.min(p.x, selectionPoint.x); int top = Math.min(p.y, selectionPoint.y); int right = Math.max(p.x, selectionPoint.x); int bottom = Math.max(p.y, selectionPoint.y); - selectionCache = new Rectangle(left, (int) (top - scrolling.scrollAmount), right - left, bottom - top); + selectionCache = new Rectangle(left, top - scrolling.scrollAmountInt(), right - left, bottom - top); return; } selectionCache = new Rectangle(0, 0, 0, 0); @@ -301,13 +300,6 @@ public class FilteringScreen extends Screen { } private void updatePosition(float delta) { - if (ConfigObject.getInstance().doesSnapToRows() && scrolling.scrollTarget >= 0 && scrolling.scrollTarget <= scrolling.getMaxScroll()) { - double nearestRow = Math.round(scrolling.scrollTarget / (double) entrySize()) * (double) entrySize(); - if (!DynamicNewSmoothScrollingEntryListWidget.Precision.almostEquals(scrolling.scrollTarget, nearestRow, DynamicNewSmoothScrollingEntryListWidget.Precision.FLOAT_EPSILON)) - scrolling.scrollTarget += (nearestRow - scrolling.scrollTarget) * Math.min(delta / 2.0, 1.0); - else - scrolling.scrollTarget = nearestRow; - } scrolling.updatePosition(delta); } @@ -377,7 +369,7 @@ public class FilteringScreen extends Screen { return true; } if (int_1 == 0) { - this.selectionPoint = new Point(double_1, double_2 + scrolling.scrollAmount); + this.selectionPoint = new Point(double_1, double_2 + scrolling.scrollAmount()); this.secondPoint = null; return true; } @@ -388,7 +380,7 @@ public class FilteringScreen extends Screen { @Override public boolean mouseReleased(double mouseX, double mouseY, int button) { if (selectionPoint != null && button == 0 && secondPoint == null) { - this.secondPoint = new Point(mouseX, mouseY + scrolling.scrollAmount); + this.secondPoint = new Point(mouseX, mouseY + scrolling.scrollAmount()); if (secondPoint.equals(selectionPoint)) { secondPoint.translate(1, 1); } 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/Favo |
