diff options
26 files changed, 271 insertions, 97 deletions
diff --git a/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinTagLoader.java b/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinTagLoader.java index f317661b0..00f95c32f 100644 --- a/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinTagLoader.java +++ b/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinTagLoader.java @@ -28,8 +28,8 @@ import com.mojang.datafixers.util.Either; import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntList; import it.unimi.dsi.fastutil.objects.Reference2ObjectMaps; -import me.shedaniel.rei.RoughlyEnoughItemsCore; import me.shedaniel.rei.api.common.util.CollectionUtils; +import me.shedaniel.rei.impl.common.InternalLogger; import me.shedaniel.rei.plugin.common.displays.tag.TagNodes; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceKey; @@ -96,7 +96,7 @@ public class MixinTagLoader<T> { } } - RoughlyEnoughItemsCore.LOGGER.info("Processed %d tags in %s for %s", tagDataMap.size(), stopwatch.stop(), resourceKey.location()); + InternalLogger.getInstance().debug("Processed %d tags in %s for %s", tagDataMap.size(), stopwatch.stop(), resourceKey.location()); } @Inject(method = "build(Lnet/minecraft/tags/TagEntry$Lookup;Ljava/util/List;)Lcom/mojang/datafixers/util/Either;", at = @At("RETURN")) diff --git a/forge/src/main/java/me/shedaniel/rei/mixin/forge/MixinTagLoader.java b/forge/src/main/java/me/shedaniel/rei/mixin/forge/MixinTagLoader.java index cb622841e..b48ddc175 100644 --- a/forge/src/main/java/me/shedaniel/rei/mixin/forge/MixinTagLoader.java +++ b/forge/src/main/java/me/shedaniel/rei/mixin/forge/MixinTagLoader.java @@ -28,8 +28,8 @@ import com.mojang.datafixers.util.Either; import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntList; import it.unimi.dsi.fastutil.objects.Reference2ObjectMaps; -import me.shedaniel.rei.RoughlyEnoughItemsCore; import me.shedaniel.rei.api.common.util.CollectionUtils; +import me.shedaniel.rei.impl.common.InternalLogger; import me.shedaniel.rei.plugin.common.displays.tag.TagNodes; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceKey; @@ -96,7 +96,7 @@ public class MixinTagLoader<T> { } } - RoughlyEnoughItemsCore.LOGGER.info("Processed %d tags in %s for %s", tagDataMap.size(), stopwatch.stop(), resourceKey.location()); + InternalLogger.getInstance().debug("Processed %d tags in %s for %s", tagDataMap.size(), stopwatch.stop(), resourceKey.location()); } @Inject(method = "build(Lnet/minecraft/tags/TagEntry$Lookup;Ljava/util/List;)Lcom/mojang/datafixers/util/Either;", at = @At("RETURN")) diff --git a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java index 8546ddb3e..5555acda0 100644 --- a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java +++ b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java @@ -29,11 +29,7 @@ import dev.architectury.registry.ReloadListenerRegistry; import dev.architectury.utils.Env; import dev.architectury.utils.EnvExecutor; import me.shedaniel.cloth.clothconfig.shadowed.blue.endless.jankson.annotation.Nullable; -import me.shedaniel.rei.api.common.entry.comparison.FluidComparatorRegistry; -import me.shedaniel.rei.api.common.entry.comparison.ItemComparatorRegistry; import me.shedaniel.rei.api.common.entry.type.EntryType; -import me.shedaniel.rei.api.common.entry.type.EntryTypeRegistry; -import me.shedaniel.rei.api.common.fluid.FluidSupportProvider; import me.shedaniel.rei.api.common.plugins.PluginManager; import me.shedaniel.rei.api.common.plugins.PluginView; import me.shedaniel.rei.api.common.plugins.REIPlugin; @@ -88,6 +84,7 @@ public class RoughlyEnoughItemsCore { } public static void attachCommonInternals() { + Internals.attachInstanceSupplier(LOGGER, "logger"); CategoryIdentifierImpl.attach(); Internals.attachInstance((Function<ResourceLocation, EntryType<?>>) DeferringEntryTypeProviderImpl.INSTANCE, "entryTypeDeferred"); Internals.attachInstance(EntryStackProviderImpl.INSTANCE, Internals.EntryStackProvider.class); @@ -96,16 +93,6 @@ public class RoughlyEnoughItemsCore { Internals.attachInstanceSupplier(new PluginManagerImpl<>( REIPlugin.class, UnaryOperator.identity(), - usedTime -> { - RoughlyEnoughItemsCore.LOGGER.info("Reloaded Plugin Manager [%s] with %d entry types, %d item comparators, %d fluid comparators and %d fluid support providers in %dms.", - REIPlugin.class.getSimpleName(), - EntryTypeRegistry.getInstance().values().size(), - ItemComparatorRegistry.getInstance().comparatorSize(), - FluidComparatorRegistry.getInstance().comparatorSize(), - FluidSupportProvider.getInstance().size(), - usedTime - ); - }, new EntryTypeRegistryImpl(), new EntrySettingsAdapterRegistryImpl(), new RecipeManagerContextImpl<>(RecipeManagerContextImpl.supplier()), @@ -116,15 +103,7 @@ public class RoughlyEnoughItemsCore { Internals.attachInstanceSupplier(new PluginManagerImpl<>( REIServerPlugin.class, view -> view.then(PluginView.getInstance()), - usedTime -> { - RoughlyEnoughItemsCore.LOGGER.info("Reloaded Plugin Manager [%s] with %d menu infos in %dms.", - REIServerPlugin.class.getSimpleName(), - MenuInfoRegistry.getInstance().infoSize(), - usedTime - ); - }, new MenuInfoRegistryImpl()), "serverPluginManager"); - Internals.attachInstanceSupplier(LOGGER, "logger"); } public static void _reloadPlugins(@Nullable ReloadStage stage) { diff --git a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java index 4c01ce177..89ff17233 100644 --- a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java +++ b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java @@ -44,9 +44,6 @@ import me.shedaniel.rei.api.client.gui.widgets.TooltipContext; import me.shedaniel.rei.api.client.overlay.ScreenOverlay; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.client.registry.category.CategoryRegistry; -import me.shedaniel.rei.api.client.registry.display.DisplayCategory; -import me.shedaniel.rei.api.client.registry.display.DisplayRegistry; -import me.shedaniel.rei.api.client.registry.entry.EntryRegistry; import me.shedaniel.rei.api.client.registry.screen.ClickArea; import me.shedaniel.rei.api.client.registry.screen.OverlayDecider; import me.shedaniel.rei.api.client.registry.screen.ScreenRegistry; @@ -77,6 +74,7 @@ import me.shedaniel.rei.impl.client.search.method.InputMethodRegistryImpl; import me.shedaniel.rei.impl.client.subsets.SubsetsRegistryImpl; import me.shedaniel.rei.impl.client.transfer.TransferHandlerRegistryImpl; import me.shedaniel.rei.impl.client.view.ViewsImpl; +import me.shedaniel.rei.impl.common.InternalLogger; import me.shedaniel.rei.impl.common.entry.type.EntryRegistryImpl; import me.shedaniel.rei.impl.common.entry.type.collapsed.CollapsibleEntryRegistryImpl; import me.shedaniel.rei.impl.common.entry.type.types.EmptyEntryDefinition; @@ -117,7 +115,6 @@ import java.util.function.BiFunction; import java.util.function.BooleanSupplier; import java.util.function.Function; import java.util.function.Supplier; -import java.util.stream.Collectors; import java.util.stream.Stream; @Environment(EnvType.CLIENT) @@ -128,7 +125,7 @@ public class RoughlyEnoughItemsCoreClient { Thread thread = new Thread(task, "REI-ReloadPlugins"); thread.setDaemon(true); thread.setUncaughtExceptionHandler(($, exception) -> { - RoughlyEnoughItemsCore.LOGGER.throwException(exception); + InternalLogger.getInstance().throwException(exception); }); return thread; }); @@ -207,22 +204,6 @@ public class RoughlyEnoughItemsCoreClient { ClientInternals.attachInstanceSupplier(new PluginManagerImpl<>( REIClientPlugin.class, view -> view.then(PluginView.getInstance()), - usedTime -> { - RoughlyEnoughItemsCore.LOGGER.info("Reloaded Plugin Manager [%s] with %d entries, %d displays, %d display visibility predicates, %d categories (%s), %d exclusion zones and %d overlay deciders in %dms.", - REIClientPlugin.class.getSimpleName(), - EntryRegistry.getInstance().size(), - DisplayRegistry.getInstance().displaySize(), - DisplayRegistry.getInstance().getVisibilityPredicates().size(), - CategoryRegistry.getInstance().size(), - CategoryRegistry.getInstance().stream() - .map(CategoryRegistry.CategoryConfiguration::getCategory) - .map(DisplayCategory::getTitle) - .map(Component::getString).collect(Collectors.joining(", ")), - ScreenRegistry.getInstance().exclusionZones().getZonesCount(), - ScreenRegistry.getInstance().getDeciders().size(), - usedTime - ); - }, new EntryRendererRegistryImpl(), new ViewsImpl(), new InputMethodRegistryImpl(), @@ -338,7 +319,7 @@ public class RoughlyEnoughItemsCoreClient { } } - RoughlyEnoughItemsCore.LOGGER.error("Detected missing stage: END! This is possibly due to issues during client recipe reload! REI will force a reload of the recipes now!"); + InternalLogger.getInstance().error("Detected missing stage: END! This is possibly due to issues during client recipe reload! REI will force a reload of the recipes now!"); reloadPlugins(endReload, ReloadStage.END); } @@ -471,7 +452,7 @@ public class RoughlyEnoughItemsCoreClient { public static void reloadPlugins(MutableLong lastReload, @Nullable ReloadStage start) { if (lastReload != null) { if (lastReload.getValue() > 0 && System.currentTimeMillis() - lastReload.getValue() <= 5000) { - RoughlyEnoughItemsCore.LOGGER.warn("Suppressing Reload Plugins of stage " + start); + InternalLogger.getInstance().warn("Suppressing Reload Plugins of stage " + start); return; } lastReload.setValue(System.currentTimeMillis()); 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 64f3a186c..6dae2f38a 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 @@ -67,6 +67,7 @@ import me.shedaniel.rei.impl.client.entry.filtering.rules.ManualFilteringRule; import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl; import me.shedaniel.rei.impl.client.gui.credits.CreditsScreen; import me.shedaniel.rei.impl.client.gui.performance.entry.PerformanceEntry; +import me.shedaniel.rei.impl.common.InternalLogger; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.ChatFormatting; @@ -135,7 +136,7 @@ public class ConfigManagerImpl implements ConfigManager { } , (field) -> field.getType() == List.class, ConfigObjectImpl.UseFilteringScreen.class); saveConfig(); - RoughlyEnoughItemsCore.LOGGER.info("Config loaded."); + InternalLogger.getInstance().info("Config loaded"); } private static Jankson buildJankson(Jankson.Builder builder) { @@ -302,6 +303,7 @@ public class ConfigManagerImpl implements ConfigManager { return InteractionResult.PASS; }); AutoConfig.getConfigHolder(ConfigObjectImpl.class).save(); + InternalLogger.getInstance().debug("Config saved"); } @Override diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/addon/ConfigAddonRegistryImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/addon/ConfigAddonRegistryImpl.java index 859c6a867..6124cb83c 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/addon/ConfigAddonRegistryImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/addon/ConfigAddonRegistryImpl.java @@ -26,6 +26,7 @@ package me.shedaniel.rei.impl.client.config.addon; import me.shedaniel.rei.api.client.config.addon.ConfigAddon; import me.shedaniel.rei.api.client.config.addon.ConfigAddonRegistry; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; +import me.shedaniel.rei.impl.common.InternalLogger; import java.util.ArrayList; import java.util.List; @@ -39,8 +40,14 @@ public class ConfigAddonRegistryImpl implements ConfigAddonRegistry { } @Override + public void endReload() { + InternalLogger.getInstance().debug("Registered %d config addons", this.addons.size()); + } + + @Override public void register(ConfigAddon addon) { this.addons.add(addon); + InternalLogger.getInstance().debug("Added config addon: %s [%s]", addon, addon.getName().getString()); } @Override 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 47996d9d3..fbd5f3330 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 @@ -36,6 +36,7 @@ import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.common.registry.ReloadStage; import me.shedaniel.rei.api.common.util.CollectionUtils; import me.shedaniel.rei.impl.client.config.ConfigManagerImpl; +import me.shedaniel.rei.impl.common.InternalLogger; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import org.apache.commons.lang3.mutable.MutableLong; @@ -67,6 +68,7 @@ public class FavoriteEntryTypeRegistryImpl implements FavoriteEntryType.Registry @Override public void register(ResourceLocation id, FavoriteEntryType<?> type) { this.registry.put(id, type); + InternalLogger.getInstance().debug("Added favorite entry type [%s]: %s", id, type); } @Override @@ -97,6 +99,7 @@ public class FavoriteEntryTypeRegistryImpl implements FavoriteEntryType.Registry @Override public <A extends FavoriteEntry> void registerSystemFavorites(SystemFavoriteEntryProvider<A> provider) { this.systemFavorites.add(Triple.of(provider, new MutableLong(-1), new ArrayList<>())); + InternalLogger.getInstance().debug("Added system favorites: %s", provider); } public List<Triple<SystemFavoriteEntryProvider<?>, MutableLong, List<FavoriteEntry>>> getSystemProviders() { @@ -119,6 +122,8 @@ public class FavoriteEntryTypeRegistryImpl implements FavoriteEntryType.Registry ConfigManager.getInstance().saveConfig(); } + + InternalLogger.getInstance().debug("Registered %d favorite entry types", registry.size()); } private static class SectionImpl implements FavoriteEntryType.Section { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CachedEntryListRender.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CachedEntryListRender.java index 905aba9b2..60c7b98ce 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CachedEntryListRender.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CachedEntryListRender.java @@ -36,13 +36,13 @@ import it.unimi.dsi.fastutil.longs.Long2LongMap; import it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap; import me.shedaniel.clothconfig2.api.LazyResettable; import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.RoughlyEnoughItemsCore; import me.shedaniel.rei.api.client.config.ConfigObject; import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer; import me.shedaniel.rei.api.client.registry.entry.EntryRegistry; import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes; import me.shedaniel.rei.api.common.util.EntryStacks; +import me.shedaniel.rei.impl.common.InternalLogger; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.RenderStateShard; @@ -88,7 +88,7 @@ public class CachedEntryListRender { public static void refresh() { if (ConfigObject.getInstance().doesCacheEntryRendering()) { - RoughlyEnoughItemsCore.LOGGER.info("Refreshing cached entry list texture..."); + InternalLogger.getInstance().info("Refreshing cached entry list texture..."); } if (cachedTextureLocation != null) { Minecraft.getInstance().getTextureManager().release(cachedTextureLocation); @@ -139,7 +139,7 @@ public class CachedEntryListRender { int width = side * RESOLUTION; int height = side * RESOLUTION; - RoughlyEnoughItemsCore.LOGGER.info("Preparing cached texture with size %sx%s for %sx%s entries", width, height, side, side); + InternalLogger.getInstance().info("Preparing cached texture with size %sx%s for %sx%s entries", width, height, side, side); hash = new Long2LongOpenHashMap(list.size() + 10); Minecraft minecraft = Minecraft.getInstance(); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/EntryListSearchManager.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/EntryListSearchManager.java index 2aee122fe..a03865208 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/EntryListSearchManager.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/EntryListSearchManager.java @@ -26,7 +26,6 @@ package me.shedaniel.rei.impl.client.gui.widget.entrylist; import com.google.common.base.Stopwatch; import it.unimi.dsi.fastutil.longs.LongOpenHashSet; import it.unimi.dsi.fastutil.longs.LongSet; -import me.shedaniel.rei.RoughlyEnoughItemsCore; import me.shedaniel.rei.api.client.config.ConfigManager; import me.shedaniel.rei.api.client.config.ConfigObject; import me.shedaniel.rei.api.client.gui.config.EntryPanelOrdering; @@ -37,11 +36,13 @@ import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes; import me.shedaniel.rei.api.common.util.EntryStacks; import me.shedaniel.rei.impl.client.search.AsyncSearchManager; +import me.shedaniel.rei.impl.common.InternalLogger; import me.shedaniel.rei.impl.common.entry.type.collapsed.CollapsedStack; import me.shedaniel.rei.impl.common.entry.type.collapsed.CollapsibleEntryRegistryImpl; import net.minecraft.client.Minecraft; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.ItemStack; +import org.apache.logging.log4j.Level; import org.jetbrains.annotations.Nullable; import java.util.*; @@ -79,9 +80,7 @@ public class EntryListSearchManager { searchManager.getAsync(list -> { List</*EntryStack<?> | CollapsedStack*/ Object> finalList = collapse(copyAndOrder(list)); - if (ConfigObject.getInstance().doDebugSearchTimeRequired()) { - RoughlyEnoughItemsCore.LOGGER.info("Search Used: %s", stopwatch.stop().toString()); - } + InternalLogger.getInstance().log(ConfigObject.getInstance().doDebugSearchTimeRequired() ? Level.INFO : Level.TRACE, "Search Used: %s", stopwatch.stop().toString()); Minecraft.getInstance().executeBlocking(() -> { update.accept(finalList); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/category/CategoryRegistryImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/category/CategoryRegistryImpl.java index ee784a849..5ab3f59a7 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/category/CategoryRegistryImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/category/CategoryRegistryImpl.java @@ -25,7 +25,6 @@ package me.shedaniel.rei.impl.client.registry.category; import com.google.common.base.MoreObjects; import dev.architectury.event.EventResult; -import me.shedaniel.rei.RoughlyEnoughItemsCore; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.client.registry.category.ButtonArea; import me.shedaniel.rei.api.client.registry.category.CategoryRegistry; @@ -36,10 +35,12 @@ import me.shedaniel.rei.api.client.registry.display.DisplayCategoryView; import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.display.Display; import me.shedaniel.rei.api.common.entry.EntryIngredient; +import me.shedaniel.rei.impl.common.InternalLogger; import org.jetbrains.annotations.ApiStatus; import java.util.*; import java.util.function.Consumer; +import java.util.stream.Collectors; @ApiStatus.Internal public class CategoryRegistryImpl implements CategoryRegistry { @@ -55,6 +56,15 @@ public class CategoryRegistryImpl implements CategoryRegistry { @Override public void startReload() { this.categories.clear(); + this.listeners.clear(); + this.visibilityPredicates.clear(); + } + + @Override + public void endReload() { + InternalLogger.getInstance().debug("Registered %d categories: %s", this.categories.size(), + this.categories.values().stream().map(configuration -> configuration.getCategory().getTitle().getString()) + .collect(Collectors.joining(", "))); } @Override @@ -70,6 +80,8 @@ public class CategoryRegistryImpl implements CategoryRegistry { listener.accept(configuration); } } + + InternalLogger.getInstance().debug("Added category [%s]: %s", category.getCategoryIdentifier(), category.getTitle().getString()); } @Override @@ -106,6 +118,7 @@ public class CategoryRegistryImpl implements CategoryRegistry { public void registerVisibilityPredicate(CategoryVisibilityPredicate predicate) { visibilityPredicates.add(predicate); visibilityPredicates.sort(Comparator.reverseOrder()); + InternalLogger.getInstance().debug("Added category visibility predicate: %s [%.2f priority]", predicate, predicate.getPriority()); } @Override @@ -117,7 +130,7 @@ public class CategoryRegistryImpl implements CategoryRegistry { return result.isEmpty() || result.isTrue(); } } catch (Throwable throwable) { - RoughlyEnoughItemsCore.LOGGER.error("Failed to check if the category is visible!", throwable); + InternalLogger.getInstance().error("Failed to check if the category is visible!", throwable); } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/display/DisplayRegistryImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/display/DisplayRegistryImpl.java index af84abe0f..bd29f9142 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/display/DisplayRegistryImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/display/DisplayRegistryImpl.java @@ -28,7 +28,6 @@ import com.google.common.collect.ForwardingMap; import com.google.common.collect.ForwardingMapEntry; import com.google.common.collect.Iterators; import dev.architectury.event.EventResult; -import me.shedaniel.rei.RoughlyEnoughItemsCore; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.client.registry.category.CategoryRegistry; import me.shedaniel.rei.api.client.registry.display.DisplayCategory; @@ -40,6 +39,7 @@ import me.shedaniel.rei.api.client.registry.display.visibility.DisplayVisibility import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.display.Display; import me.shedaniel.rei.api.common.plugins.PluginManager; +import me.shedaniel.rei.impl.common.InternalLogger; import me.shedaniel.rei.impl.common.registry.RecipeManagerContextImpl; import net.minecraft.world.item.crafting.Recipe; import org.apache.commons.lang3.mutable.MutableInt; @@ -155,7 +155,7 @@ public class DisplayRegistryImpl extends RecipeManagerContextImpl<REIClientPlugi if (!PluginManager.areAnyReloading()) { if (lastAddWarning != null) { if (lastAddWarning.getValue() > 0 && System.currentTimeMillis() - lastAddWarning.getValue() > 5000) { - RoughlyEnoughItemsCore.LOGGER.warn("Detected runtime DisplayRegistry modification, this can be extremely dangerous!"); + InternalLogger.getInstance().warn("Detected runtime DisplayRegistry modification, this can be extremely dangerous!"); } lastAddWarning.setValue(System.currentTimeMillis()); } @@ -179,12 +179,14 @@ public class DisplayRegistryImpl extends RecipeManagerContextImpl<REIClientPlugi @Override public <A extends Display> void registerGlobalDisplayGenerator(DynamicDisplayGenerator<A> generator) { globalDisplayGenerators.add(generator); + InternalLogger.getInstance().debug("Added global display generator: %s", generator); } @Override public <A extends Display> void registerDisplayGenerator(CategoryIdentifier<A> categoryId, DynamicDisplayGenerator<A> generator) { displayGenerators.computeIfAbsent(categoryId, location -> new ArrayList<>()) .add(generator); + InternalLogger.getInstance().debug("Added display generator for category [%s]: %s", categoryId, generator); } @Override @@ -201,6 +203,7 @@ public class DisplayRegistryImpl extends RecipeManagerContextImpl<REIClientPlugi public void registerVisibilityPredicate(DisplayVisibilityPredicate predicate) { visibilityPredicates.add(predicate); visibilityPredicates.sort(Comparator.reverseOrder()); + InternalLogger.getInstance().debug("Added display visibility predicate: %s [%.2f priority]", predicate, predicate.getPriority()); } @Override @@ -214,7 +217,7 @@ public class DisplayRegistryImpl extends RecipeManagerContextImpl<REIClientPlugi return result.isEmpty() || result.isTrue(); } } catch (Throwable throwable) { - RoughlyEnoughItemsCore.LOGGER.error("Failed to check if the display is visible!", throwable); + InternalLogger.getInstance().error("Failed to check if the display is visible!", throwable); } } @@ -234,11 +237,13 @@ public class DisplayRegistryImpl extends RecipeManagerContextImpl<REIClientPlugi @Override public <T, D extends Display> void registerFiller(Class<T> typeClass, BiPredicate<? extends T, DisplayAdditionReasons> predicate, Function<? extends T, D> filler) { fillers.add(new DisplayFiller<>((o, s) -> typeClass.isInstance(o) && ((BiPredicate<Object, DisplayAdditionReasons>) predicate).test(o, s), (Function<Object, D>) filler)); + InternalLogger.getInstance().debug("Added display filter: %s for %s", filler, typeClass.getName()); } @Override public <D extends Display> void registerFiller(Predicate<?> predicate, Function<?, D> filler) { fillers.add(new DisplayFiller<>((o, s) -> ((Predicate<Object>) predicate).test(o), (Function<Object, D>) filler)); + InternalLogger.getInstance().debug("Added display filter: %s", filler); } @Override @@ -263,9 +268,11 @@ public class DisplayRegistryImpl extends RecipeManagerContextImpl<REIClientPlugi for (CategoryIdentifier<?> identifier : displays.keySet()) { if (CategoryRegistry.getInstance().tryGet(identifier).isEmpty()) { - RoughlyEnoughItemsCore.LOGGER.throwException(new IllegalStateException("Displays registered for unknown registry: " + identifier)); + InternalLogger.getInstance().error("Found displays registered for unknown registry", new IllegalStateException(identifier.toString())); } } + + InternalLogger.getInstance().debug("Registered %d displays", displayCount.getValue()); } @Override @@ -307,7 +314,7 @@ public class DisplayRegistryImpl extends RecipeManagerContextImpl<REIClientPlugi return displaysBase.get(display); } - private static record DisplayFiller<D extends Display>( + private record DisplayFiller<D extends Display>( BiPredicate<Object, DisplayAdditionReasons> predicate, Function<Object, D> mappingFunction diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/screen/ExclusionZonesImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/screen/ExclusionZonesImpl.java index 26f7b6773..85b8090f1 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/screen/ExclusionZonesImpl.java +++ b/ |
