diff --git a/src/main/java/com/gtnewhorizons/navigator/ClientProxy.java b/src/main/java/com/gtnewhorizons/navigator/ClientProxy.java index 596e858..9f627de 100644 --- a/src/main/java/com/gtnewhorizons/navigator/ClientProxy.java +++ b/src/main/java/com/gtnewhorizons/navigator/ClientProxy.java @@ -2,12 +2,7 @@ import com.gtnewhorizons.navigator.api.NavigatorApi; import com.gtnewhorizons.navigator.config.GeneralConfig; -import com.gtnewhorizons.navigator.impl.DirtyChunkButtonManager; import com.gtnewhorizons.navigator.impl.DirtyChunkLayerManager; -import com.gtnewhorizons.navigator.impl.journeymap.JMDirtyChunkRenderer; -import com.gtnewhorizons.navigator.impl.journeymap.JMDirtyChunkWaypointManager; -import com.gtnewhorizons.navigator.impl.xaero.XaeroDirtyChunkRenderer; -import com.gtnewhorizons.navigator.impl.xaero.XaeroDirtyChunkWaypointManager; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.common.event.FMLInitializationEvent; @@ -21,17 +16,7 @@ public void preInit(FMLPreInitializationEvent event) { super.preInit(event); ClientRegistry.registerKeyBinding(NavigatorApi.ACTION_KEY); if (GeneralConfig.enableDebugLayers) { - // Shared - NavigatorApi.registerLayerManager(DirtyChunkLayerManager.instance); - NavigatorApi.registerButtonManager(DirtyChunkButtonManager.instance); - - // Journeymap - NavigatorApi.registerLayerRenderer(JMDirtyChunkRenderer.instance); - NavigatorApi.registerWaypointManager(JMDirtyChunkWaypointManager.instance); - - // Xaero's maps - NavigatorApi.registerLayerRenderer(XaeroDirtyChunkRenderer.instance); - NavigatorApi.registerWaypointManager(XaeroDirtyChunkWaypointManager.instance); + NavigatorApi.registerLayerManager(DirtyChunkLayerManager.INSTANCE); } } diff --git a/src/main/java/com/gtnewhorizons/navigator/api/NavigatorApi.java b/src/main/java/com/gtnewhorizons/navigator/api/NavigatorApi.java index 29b6830..538c4e5 100644 --- a/src/main/java/com/gtnewhorizons/navigator/api/NavigatorApi.java +++ b/src/main/java/com/gtnewhorizons/navigator/api/NavigatorApi.java @@ -11,16 +11,12 @@ import org.lwjgl.input.Keyboard; import com.gtnewhorizons.navigator.Navigator; -import com.gtnewhorizons.navigator.api.journeymap.render.JMLayerRenderer; -import com.gtnewhorizons.navigator.api.journeymap.waypoints.JMWaypointManager; import com.gtnewhorizons.navigator.api.model.SupportedMods; import com.gtnewhorizons.navigator.api.model.buttons.ButtonManager; +import com.gtnewhorizons.navigator.api.model.layers.InteractableLayerManager; import com.gtnewhorizons.navigator.api.model.layers.LayerManager; import com.gtnewhorizons.navigator.api.model.layers.LayerRenderer; -import com.gtnewhorizons.navigator.api.model.waypoints.WaypointManager; import com.gtnewhorizons.navigator.api.util.Util; -import com.gtnewhorizons.navigator.api.xaero.renderers.XaeroLayerRenderer; -import com.gtnewhorizons.navigator.api.xaero.waypoints.XaeroWaypointManager; import com.gtnewhorizons.navigator.mixins.late.journeymap.FullscreenAccessor; import journeymap.client.render.map.GridRenderer; @@ -33,54 +29,48 @@ public final class NavigatorApi { Keyboard.KEY_DELETE, Navigator.MODNAME); - public static final List buttonManagers = new ArrayList<>(); public static final List layerManagers = new ArrayList<>(); - public static final List layerRenderers = new ArrayList<>(); - public static final List waypointManagers = new ArrayList<>(); - - /** - * @param buttonManager The {@link ButtonManager} to register - * Only one needs to be registered per layer regardless of how many mods are supported - */ - public static void registerButtonManager(ButtonManager buttonManager) { - buttonManagers.add(buttonManager); - } /** * @param layerManager The {@link LayerManager} to register. - * Only one needs to be registered per layer regardless of how many mods are supported */ public static void registerLayerManager(LayerManager layerManager) { layerManagers.add(layerManager); } - /** - * @param layerRenderer The LayerRenderer to register. - *

- * Should be an instance of {@link JMLayerRenderer} or {@link XaeroLayerRenderer} - * Both mods can be registered at the same time and will be handled accordingly - */ - public static void registerLayerRenderer(LayerRenderer layerRenderer) { - layerRenderers.add(layerRenderer); + public static List getActiveRenderersFor(SupportedMods mod) { + return layerManagers.stream() + .filter(LayerManager::isLayerActive) + .map(layerManager -> layerManager.getLayerRenderer(mod)) + .collect(Collectors.toList()); } - /** - * @param waypointManager The {@link WaypointManager} to register. - *

- * Should be an instance of {@link JMWaypointManager} or {@link XaeroWaypointManager} - * Both mods can be registered at the same time and will be handled accordingly - */ - public static void registerWaypointManager(WaypointManager waypointManager) { - waypointManagers.add(waypointManager); + public static List getEnabledLayers(SupportedMods mod) { + return layerManagers.stream() + .filter(layerManager -> layerManager.isEnabled(mod)) + .collect(Collectors.toList()); } - public static @Nullable LayerRenderer getActiveLayerFor(SupportedMods mod) { - return layerRenderers.stream() - .filter( - layerRenderer -> layerRenderer.isLayerActive() && layerRenderer.getLayerMod() - .equals(mod)) - .findFirst() - .orElse(null); + public static List getEnabledButtons(SupportedMods mod) { + return layerManagers.stream() + .filter(layerManager -> layerManager.isEnabled(mod)) + .map(LayerManager::getButtonManager) + .distinct() + .collect(Collectors.toList()); + } + + public static List getDistinctButtons() { + return layerManagers.stream() + .map(LayerManager::getButtonManager) + .distinct() + .collect(Collectors.toList()); + } + + public static List getInteractableLayers() { + return layerManagers.stream() + .filter(layerManager -> layerManager instanceof InteractableLayerManager) + .map(layerManager -> (InteractableLayerManager) layerManager) + .collect(Collectors.toList()); } public void openJourneyMapAt(@Nullable LayerManager layer, int blockX, int blockZ, int zoom) { @@ -96,18 +86,4 @@ public void openJourneyMapAt(@Nullable LayerManager layer, int blockX, int block public void openJourneyMapAt(@Nullable LayerManager layer, int blockX, int blockZ) { this.openJourneyMapAt(layer, blockX, blockZ, -1); } - - public static List getJourneyMapLayerRenderers() { - return layerRenderers.stream() - .filter(JMLayerRenderer.class::isInstance) - .map(JMLayerRenderer.class::cast) - .collect(Collectors.toList()); - } - - public static List getXaeroLayerRenderers() { - return layerRenderers.stream() - .filter(XaeroLayerRenderer.class::isInstance) - .map(XaeroLayerRenderer.class::cast) - .collect(Collectors.toList()); - } } diff --git a/src/main/java/com/gtnewhorizons/navigator/api/journeymap/render/JMInteractableLayerRenderer.java b/src/main/java/com/gtnewhorizons/navigator/api/journeymap/render/JMInteractableLayerRenderer.java index 5ab6d96..93940e1 100644 --- a/src/main/java/com/gtnewhorizons/navigator/api/journeymap/render/JMInteractableLayerRenderer.java +++ b/src/main/java/com/gtnewhorizons/navigator/api/journeymap/render/JMInteractableLayerRenderer.java @@ -8,16 +8,16 @@ import com.gtnewhorizons.navigator.api.NavigatorApi; import com.gtnewhorizons.navigator.api.journeymap.drawsteps.JMInteractableStep; import com.gtnewhorizons.navigator.api.journeymap.drawsteps.JMRenderStep; -import com.gtnewhorizons.navigator.api.model.layers.WaypointProviderManager; +import com.gtnewhorizons.navigator.api.model.layers.InteractableLayerManager; import com.gtnewhorizons.navigator.api.model.steps.RenderStep; import com.gtnewhorizons.navigator.api.util.Util; public abstract class JMInteractableLayerRenderer extends JMLayerRenderer { - protected final WaypointProviderManager manager; + protected InteractableLayerManager manager; protected JMInteractableStep hoveredDrawStep = null; - public JMInteractableLayerRenderer(WaypointProviderManager manager) { + public JMInteractableLayerRenderer(InteractableLayerManager manager) { super(manager); this.manager = manager; } diff --git a/src/main/java/com/gtnewhorizons/navigator/api/journeymap/waypoints/JMWaypointManager.java b/src/main/java/com/gtnewhorizons/navigator/api/journeymap/waypoints/JMWaypointManager.java index 8d9147e..74596d2 100644 --- a/src/main/java/com/gtnewhorizons/navigator/api/journeymap/waypoints/JMWaypointManager.java +++ b/src/main/java/com/gtnewhorizons/navigator/api/journeymap/waypoints/JMWaypointManager.java @@ -3,15 +3,15 @@ import java.awt.Color; import com.gtnewhorizons.navigator.api.model.SupportedMods; -import com.gtnewhorizons.navigator.api.model.layers.WaypointProviderManager; +import com.gtnewhorizons.navigator.api.model.layers.InteractableLayerManager; import com.gtnewhorizons.navigator.api.model.waypoints.Waypoint; import com.gtnewhorizons.navigator.api.model.waypoints.WaypointManager; -public abstract class JMWaypointManager extends WaypointManager { +public class JMWaypointManager extends WaypointManager { private journeymap.client.model.Waypoint jmWaypoint; - public JMWaypointManager(WaypointProviderManager layerManager) { + public JMWaypointManager(InteractableLayerManager layerManager) { super(layerManager, SupportedMods.JourneyMap); } diff --git a/src/main/java/com/gtnewhorizons/navigator/api/model/buttons/ButtonManager.java b/src/main/java/com/gtnewhorizons/navigator/api/model/buttons/ButtonManager.java index 003c86a..f5aca55 100644 --- a/src/main/java/com/gtnewhorizons/navigator/api/model/buttons/ButtonManager.java +++ b/src/main/java/com/gtnewhorizons/navigator/api/model/buttons/ButtonManager.java @@ -30,7 +30,8 @@ public boolean isActive() { } public void activate() { - NavigatorApi.buttonManagers.forEach(ButtonManager::deactivate); + NavigatorApi.getDistinctButtons() + .forEach(ButtonManager::deactivate); isActive = true; if (onToggle != null) { onToggle.accept(true); @@ -51,13 +52,4 @@ public void toggle() { activate(); } } - - /** - * Whether the button should be added to the GUI. - * - * @return true if the button should be added, false otherwise - */ - public boolean isEnabled(SupportedMods mod) { - return true; - } } diff --git a/src/main/java/com/gtnewhorizons/navigator/api/model/layers/WaypointProviderManager.java b/src/main/java/com/gtnewhorizons/navigator/api/model/layers/InteractableLayerManager.java similarity index 63% rename from src/main/java/com/gtnewhorizons/navigator/api/model/layers/WaypointProviderManager.java rename to src/main/java/com/gtnewhorizons/navigator/api/model/layers/InteractableLayerManager.java index b5f3751..ab40c54 100644 --- a/src/main/java/com/gtnewhorizons/navigator/api/model/layers/WaypointProviderManager.java +++ b/src/main/java/com/gtnewhorizons/navigator/api/model/layers/InteractableLayerManager.java @@ -5,21 +5,51 @@ import java.util.List; import java.util.Map; +import javax.annotation.Nullable; + import com.gtnewhorizons.navigator.api.model.SupportedMods; import com.gtnewhorizons.navigator.api.model.buttons.ButtonManager; import com.gtnewhorizons.navigator.api.model.locations.IWaypointAndLocationProvider; import com.gtnewhorizons.navigator.api.model.waypoints.Waypoint; import com.gtnewhorizons.navigator.api.model.waypoints.WaypointManager; -public abstract class WaypointProviderManager extends LayerManager { +public abstract class InteractableLayerManager extends LayerManager { private List visibleElements = new ArrayList<>(); private final Map waypointManagers = new EnumMap<>(SupportedMods.class); protected Waypoint activeWaypoint = null; - public WaypointProviderManager(ButtonManager buttonManager) { + public InteractableLayerManager(ButtonManager buttonManager) { super(buttonManager); + for (SupportedMods mod : SupportedMods.values()) { + WaypointManager waypointManager = addWaypointManager(this, mod); + if (waypointManager != null) { + waypointManagers.put(mod, waypointManager); + } + } + } + + /** + * @param manager This layer manager + * @param mod The mod to add the layer renderer for + * @return The layer renderer implementation for the mod or null if none + */ + protected abstract @Nullable LayerRenderer addLayerRenderer(InteractableLayerManager manager, SupportedMods mod); + + /** + * @param manager This layer manager + * @param mod The mod to add the waypoint manager for + * @return The waypoint manager implementation for the mod or null if none + */ + protected @Nullable WaypointManager addWaypointManager(InteractableLayerManager manager, SupportedMods mod) { + return null; + } + + @Nullable + @Override + protected final LayerRenderer addLayerRenderer(LayerManager manager, SupportedMods mod) { + return addLayerRenderer(this, mod); } public void setActiveWaypoint(Waypoint waypoint) { @@ -40,12 +70,7 @@ public boolean hasActiveWaypoint() { return activeWaypoint != null; } - public void registerWaypointManager(SupportedMods mod, WaypointManager waypointManager) { - if (!mod.isEnabled()) return; - waypointManagers.put(mod, waypointManager); - } - - public WaypointManager getWaypointManager(SupportedMods map) { + public @Nullable WaypointManager getWaypointManager(SupportedMods map) { return waypointManagers.get(map); } diff --git a/src/main/java/com/gtnewhorizons/navigator/api/model/layers/LayerManager.java b/src/main/java/com/gtnewhorizons/navigator/api/model/layers/LayerManager.java index 26ac8ac..b45932f 100644 --- a/src/main/java/com/gtnewhorizons/navigator/api/model/layers/LayerManager.java +++ b/src/main/java/com/gtnewhorizons/navigator/api/model/layers/LayerManager.java @@ -5,6 +5,8 @@ import java.util.List; import java.util.Map; +import javax.annotation.Nullable; + import com.gtnewhorizons.navigator.api.model.SupportedMods; import com.gtnewhorizons.navigator.api.model.buttons.ButtonManager; import com.gtnewhorizons.navigator.api.model.locations.ILocationProvider; @@ -15,7 +17,7 @@ public abstract class LayerManager { protected boolean forceRefresh = false; private List visibleElements = new ArrayList<>(); - protected Map layerRenderer = new EnumMap<>(SupportedMods.class); + protected final Map layerRenderer = new EnumMap<>(SupportedMods.class); private int miniMapWidth = 0; private int miniMapHeight = 0; private int fullscreenMapWidth = 0; @@ -24,8 +26,25 @@ public abstract class LayerManager { public LayerManager(ButtonManager buttonManager) { this.buttonManager = buttonManager; + for (SupportedMods mod : SupportedMods.values()) { + if (!mod.isEnabled() || !isEnabled(mod)) continue; + + LayerRenderer renderer = addLayerRenderer(this, mod); + if (renderer == null) continue; + layerRenderer.put(mod, renderer); + } } + /** + * @param manager This layer manager + * @param mod The mod to add the layer renderer for + * @return The layer renderer implementation for the mod or null if none + */ + protected abstract @Nullable LayerRenderer addLayerRenderer(LayerManager manager, SupportedMods mod); + + protected abstract List generateVisibleElements(int minBlockX, int minBlockZ, + int maxBlockX, int maxBlockZ); + public boolean isLayerActive() { return buttonManager.isActive(); } @@ -64,9 +83,6 @@ public final SupportedMods getOpenModGui() { return openModGui; } - protected abstract List generateVisibleElements(int minBlockX, int minBlockZ, - int maxBlockX, int maxBlockZ); - protected boolean needsRegenerateVisibleElements(int minBlockX, int minBlockZ, int maxBlockX, int maxBlockZ) { return true; } @@ -108,12 +124,21 @@ protected void checkAndUpdateElements(int minBlockX, int minBlockZ, int maxBlock } } - public void registerLayerRenderer(SupportedMods mod, LayerRenderer renderer) { - if (!mod.isEnabled()) return; - layerRenderer.put(mod, renderer); + public ButtonManager getButtonManager() { + return buttonManager; } public LayerRenderer getLayerRenderer(SupportedMods map) { return layerRenderer.get(map); } + + /** + * Whether the layer is enabled for the corresponding mod. + * + * @param mod the mod checking if it is enabled + * @return true if there is a layer implementation for the mod, false otherwise + */ + public boolean isEnabled(SupportedMods mod) { + return true; + } } diff --git a/src/main/java/com/gtnewhorizons/navigator/api/model/layers/LayerRenderer.java b/src/main/java/com/gtnewhorizons/navigator/api/model/layers/LayerRenderer.java index 130c805..bf75d80 100644 --- a/src/main/java/com/gtnewhorizons/navigator/api/model/layers/LayerRenderer.java +++ b/src/main/java/com/gtnewhorizons/navigator/api/model/layers/LayerRenderer.java @@ -15,7 +15,6 @@ public abstract class LayerRenderer { protected List renderSteps = new ArrayList<>(); public LayerRenderer(LayerManager manager, SupportedMods mod) { - manager.registerLayerRenderer(mod, this); this.mod = mod; this.manager = manager; } @@ -25,10 +24,6 @@ public LayerRenderer(LayerManager manager, SupportedMods mod) { protected abstract List generateRenderSteps( List visibleElements); - public final boolean isLayerActive() { - return manager.isLayerActive() && mod.isEnabled(); - } - public final SupportedMods getLayerMod() { return mod; } diff --git a/src/main/java/com/gtnewhorizons/navigator/api/model/waypoints/WaypointManager.java b/src/main/java/com/gtnewhorizons/navigator/api/model/waypoints/WaypointManager.java index fa6be86..13dc4a1 100644 --- a/src/main/java/com/gtnewhorizons/navigator/api/model/waypoints/WaypointManager.java +++ b/src/main/java/com/gtnewhorizons/navigator/api/model/waypoints/WaypointManager.java @@ -1,12 +1,16 @@ package com.gtnewhorizons.navigator.api.model.waypoints; import com.gtnewhorizons.navigator.api.model.SupportedMods; -import com.gtnewhorizons.navigator.api.model.layers.WaypointProviderManager; +import com.gtnewhorizons.navigator.api.model.layers.InteractableLayerManager; public abstract class WaypointManager { - public WaypointManager(WaypointProviderManager layerManager, SupportedMods map) { - layerManager.registerWaypointManager(map, this); + protected final InteractableLayerManager manager; + protected final SupportedMods mod; + + public WaypointManager(InteractableLayerManager layerManager, SupportedMods mod) { + this.manager = layerManager; + this.mod = mod; } public abstract void clearActiveWaypoint(); diff --git a/src/main/java/com/gtnewhorizons/navigator/api/xaero/renderers/XaeroInteractableLayerRenderer.java b/src/main/java/com/gtnewhorizons/navigator/api/xaero/renderers/XaeroInteractableLayerRenderer.java index aa1e0cf..8df75d1 100644 --- a/src/main/java/com/gtnewhorizons/navigator/api/xaero/renderers/XaeroInteractableLayerRenderer.java +++ b/src/main/java/com/gtnewhorizons/navigator/api/xaero/renderers/XaeroInteractableLayerRenderer.java @@ -6,20 +6,19 @@ import net.minecraft.client.gui.GuiScreen; import com.gtnewhorizons.navigator.api.NavigatorApi; -import com.gtnewhorizons.navigator.api.model.layers.WaypointProviderManager; +import com.gtnewhorizons.navigator.api.model.layers.InteractableLayerManager; import com.gtnewhorizons.navigator.api.util.Util; import com.gtnewhorizons.navigator.api.xaero.rendersteps.XaeroInteractableStep; import com.gtnewhorizons.navigator.api.xaero.rendersteps.XaeroRenderStep; public abstract class XaeroInteractableLayerRenderer extends XaeroLayerRenderer { - protected WaypointProviderManager manager; + protected InteractableLayerManager manager; protected XaeroInteractableStep hovered; - public XaeroInteractableLayerRenderer(WaypointProviderManager manager) { + public XaeroInteractableLayerRenderer(InteractableLayerManager manager) { super(manager); this.manager = manager; - hovered = null; } public void updateHovered(double mouseX, double mouseY, double scale) { diff --git a/src/main/java/com/gtnewhorizons/navigator/api/xaero/waypoints/XaeroWaypointManager.java b/src/main/java/com/gtnewhorizons/navigator/api/xaero/waypoints/XaeroWaypointManager.java index 51d110c..8443950 100644 --- a/src/main/java/com/gtnewhorizons/navigator/api/xaero/waypoints/XaeroWaypointManager.java +++ b/src/main/java/com/gtnewhorizons/navigator/api/xaero/waypoints/XaeroWaypointManager.java @@ -4,19 +4,19 @@ import com.gtnewhorizons.navigator.Navigator; import com.gtnewhorizons.navigator.api.model.SupportedMods; -import com.gtnewhorizons.navigator.api.model.layers.WaypointProviderManager; +import com.gtnewhorizons.navigator.api.model.layers.InteractableLayerManager; import com.gtnewhorizons.navigator.api.model.waypoints.Waypoint; import com.gtnewhorizons.navigator.api.model.waypoints.WaypointManager; import xaero.common.minimap.waypoints.WaypointsManager; -public abstract class XaeroWaypointManager extends WaypointManager { +public class XaeroWaypointManager extends WaypointManager { public static int lastId; protected final int waypointId; private WaypointWithDimension xWaypoint; - public XaeroWaypointManager(WaypointProviderManager layerManager) { + public XaeroWaypointManager(InteractableLayerManager layerManager) { super(layerManager, SupportedMods.XaeroMiniMap); waypointId = lastId++; } diff --git a/src/main/java/com/gtnewhorizons/navigator/impl/DirtyChunkLayerManager.java b/src/main/java/com/gtnewhorizons/navigator/impl/DirtyChunkLayerManager.java index 5c28a95..07e3ff6 100644 --- a/src/main/java/com/gtnewhorizons/navigator/impl/DirtyChunkLayerManager.java +++ b/src/main/java/com/gtnewhorizons/navigator/impl/DirtyChunkLayerManager.java @@ -3,22 +3,50 @@ import java.util.ArrayList; import java.util.List; +import javax.annotation.Nullable; + import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.server.MinecraftServer; import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; -import com.gtnewhorizons.navigator.api.model.layers.WaypointProviderManager; +import com.gtnewhorizons.navigator.api.journeymap.waypoints.JMWaypointManager; +import com.gtnewhorizons.navigator.api.model.SupportedMods; +import com.gtnewhorizons.navigator.api.model.layers.InteractableLayerManager; +import com.gtnewhorizons.navigator.api.model.layers.LayerRenderer; import com.gtnewhorizons.navigator.api.model.locations.IWaypointAndLocationProvider; +import com.gtnewhorizons.navigator.api.model.waypoints.WaypointManager; import com.gtnewhorizons.navigator.api.util.Util; +import com.gtnewhorizons.navigator.api.xaero.waypoints.XaeroWaypointManager; +import com.gtnewhorizons.navigator.impl.journeymap.JMDirtyChunkRenderer; +import com.gtnewhorizons.navigator.impl.xaero.XaeroDirtyChunkRenderer; -public class DirtyChunkLayerManager extends WaypointProviderManager { +public class DirtyChunkLayerManager extends InteractableLayerManager { - public static final DirtyChunkLayerManager instance = new DirtyChunkLayerManager(); + public static final DirtyChunkLayerManager INSTANCE = new DirtyChunkLayerManager(); public DirtyChunkLayerManager() { - super(DirtyChunkButtonManager.instance); + super(new DirtyChunkButtonManager()); + } + + @Override + protected @Nullable LayerRenderer addLayerRenderer(InteractableLayerManager manager, SupportedMods mod) { + return switch (mod) { + case XaeroWorldMap -> new XaeroDirtyChunkRenderer(manager); + case JourneyMap -> new JMDirtyChunkRenderer(manager); + default -> null; + }; + } + + @Nullable + @Override + protected WaypointManager addWaypointManager(InteractableLayerManager manager, SupportedMods mod) { + return switch (mod) { + case XaeroWorldMap -> new XaeroWaypointManager(manager); + case JourneyMap -> new JMWaypointManager(manager); + default -> null; + }; } @Override diff --git a/src/main/java/com/gtnewhorizons/navigator/impl/journeymap/JMDirtyChunkRenderer.java b/src/main/java/com/gtnewhorizons/navigator/impl/journeymap/JMDirtyChunkRenderer.java index 865a1cd..716970c 100644 --- a/src/main/java/com/gtnewhorizons/navigator/impl/journeymap/JMDirtyChunkRenderer.java +++ b/src/main/java/com/gtnewhorizons/navigator/impl/journeymap/JMDirtyChunkRenderer.java @@ -5,17 +5,15 @@ import com.gtnewhorizons.navigator.api.journeymap.drawsteps.JMRenderStep; import com.gtnewhorizons.navigator.api.journeymap.render.JMInteractableLayerRenderer; +import com.gtnewhorizons.navigator.api.model.layers.InteractableLayerManager; import com.gtnewhorizons.navigator.api.model.locations.ILocationProvider; import com.gtnewhorizons.navigator.api.model.steps.RenderStep; -import com.gtnewhorizons.navigator.impl.DirtyChunkLayerManager; import com.gtnewhorizons.navigator.impl.DirtyChunkLocation; public class JMDirtyChunkRenderer extends JMInteractableLayerRenderer { - public static final JMDirtyChunkRenderer instance = new JMDirtyChunkRenderer(); - - public JMDirtyChunkRenderer() { - super(DirtyChunkLayerManager.instance); + public JMDirtyChunkRenderer(InteractableLayerManager manager) { + super(manager); } @Override diff --git a/src/main/java/com/gtnewhorizons/navigator/impl/journeymap/JMDirtyChunkWaypointManager.java b/src/main/java/com/gtnewhorizons/navigator/impl/journeymap/JMDirtyChunkWaypointManager.java deleted file mode 100644 index b78a5e0..0000000 --- a/src/main/java/com/gtnewhorizons/navigator/impl/journeymap/JMDirtyChunkWaypointManager.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.gtnewhorizons.navigator.impl.journeymap; - -import com.gtnewhorizons.navigator.api.journeymap.waypoints.JMWaypointManager; -import com.gtnewhorizons.navigator.impl.DirtyChunkLayerManager; - -public class JMDirtyChunkWaypointManager extends JMWaypointManager { - - public static final JMDirtyChunkWaypointManager instance = new JMDirtyChunkWaypointManager(); - - public JMDirtyChunkWaypointManager() { - super(DirtyChunkLayerManager.instance); - } -} diff --git a/src/main/java/com/gtnewhorizons/navigator/impl/xaero/XaeroDirtyChunkRenderer.java b/src/main/java/com/gtnewhorizons/navigator/impl/xaero/XaeroDirtyChunkRenderer.java index c10cf70..248c091 100644 --- a/src/main/java/com/gtnewhorizons/navigator/impl/xaero/XaeroDirtyChunkRenderer.java +++ b/src/main/java/com/gtnewhorizons/navigator/impl/xaero/XaeroDirtyChunkRenderer.java @@ -3,17 +3,15 @@ import java.util.ArrayList; import java.util.List; +import com.gtnewhorizons.navigator.api.model.layers.InteractableLayerManager; import com.gtnewhorizons.navigator.api.model.locations.ILocationProvider; import com.gtnewhorizons.navigator.api.xaero.renderers.XaeroInteractableLayerRenderer; -import com.gtnewhorizons.navigator.impl.DirtyChunkLayerManager; import com.gtnewhorizons.navigator.impl.DirtyChunkLocation; public class XaeroDirtyChunkRenderer extends XaeroInteractableLayerRenderer { - public static final XaeroDirtyChunkRenderer instance = new XaeroDirtyChunkRenderer(); - - public XaeroDirtyChunkRenderer() { - super(DirtyChunkLayerManager.instance); + public XaeroDirtyChunkRenderer(InteractableLayerManager manager) { + super(manager); } @Override diff --git a/src/main/java/com/gtnewhorizons/navigator/impl/xaero/XaeroDirtyChunkWaypointManager.java b/src/main/java/com/gtnewhorizons/navigator/impl/xaero/XaeroDirtyChunkWaypointManager.java deleted file mode 100644 index 3249087..0000000 --- a/src/main/java/com/gtnewhorizons/navigator/impl/xaero/XaeroDirtyChunkWaypointManager.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.gtnewhorizons.navigator.impl.xaero; - -import com.gtnewhorizons.navigator.api.xaero.waypoints.XaeroWaypointManager; -import com.gtnewhorizons.navigator.impl.DirtyChunkLayerManager; - -public class XaeroDirtyChunkWaypointManager extends XaeroWaypointManager { - - public static final XaeroDirtyChunkWaypointManager instance = new XaeroDirtyChunkWaypointManager(); - - public XaeroDirtyChunkWaypointManager() { - super(DirtyChunkLayerManager.instance); - } -} diff --git a/src/main/java/com/gtnewhorizons/navigator/mixins/late/journeymap/FullscreenMixin.java b/src/main/java/com/gtnewhorizons/navigator/mixins/late/journeymap/FullscreenMixin.java index 3bce0fe..7f17c52 100644 --- a/src/main/java/com/gtnewhorizons/navigator/mixins/late/journeymap/FullscreenMixin.java +++ b/src/main/java/com/gtnewhorizons/navigator/mixins/late/journeymap/FullscreenMixin.java @@ -97,7 +97,8 @@ public FullscreenMixin() { @Inject(method = "*", at = @At("RETURN"), require = 1) private void navigator$init(CallbackInfo ci) { - NavigatorApi.layerManagers.forEach(LayerManager::forceRefresh); + NavigatorApi.getEnabledLayers(JourneyMap) + .forEach(LayerManager::forceRefresh); } @Shadow @@ -113,7 +114,8 @@ void drawMap() { @Inject(method = "*", at = @At("RETURN"), require = 1) private void navigator$onConstructed(CallbackInfo ci) { - NavigatorApi.layerManagers.forEach(layerManager -> layerManager.onGuiOpened(JourneyMap)); + NavigatorApi.getEnabledLayers(JourneyMap) + .forEach(layerManager -> layerManager.onGuiOpened(JourneyMap)); } @Inject( @@ -130,16 +132,16 @@ void drawMap() { final int centerBlockZ = (int) Math.round(gridRenderer.getCenterBlockZ()); final int widthBlocks = minecraft.displayWidth >> gridRenderer.getZoom(); final int heightBlocks = minecraft.displayHeight >> gridRenderer.getZoom(); - for (LayerManager layerManager : NavigatorApi.layerManagers) { + for (LayerManager layerManager : NavigatorApi.getEnabledLayers(JourneyMap)) { if (layerManager.isLayerActive()) { layerManager.recacheFullscreenMap(centerBlockX, centerBlockZ, widthBlocks, heightBlocks); } } - JMLayerRenderer activeLayer = (JMLayerRenderer) NavigatorApi.getActiveLayerFor(JourneyMap); - - if (activeLayer != null) { - gridRenderer.draw(activeLayer.getRenderSteps(), xOffset, yOffset, drawScale, fontScale, 0.0); + for (LayerRenderer layer : NavigatorApi.getActiveRenderersFor(JourneyMap)) { + if (layer instanceof JMLayerRenderer jmLayer) { + gridRenderer.draw(jmLayer.getRenderSteps(), xOffset, yOffset, drawScale, fontScale, 0.0); + } } } @@ -154,8 +156,7 @@ void drawMap() { final Theme theme = ThemeFileHandler.getCurrentTheme(); final ButtonList buttonList = new ButtonList(); - for (ButtonManager btnManager : NavigatorApi.buttonManagers) { - if (!btnManager.isEnabled(JourneyMap)) continue; + for (ButtonManager btnManager : NavigatorApi.getEnabledButtons(JourneyMap)) { String icon = btnManager.getIcon(JourneyMap, theme.name) .toString(); String trimmedIcon = icon.substring(0, icon.lastIndexOf(".")); @@ -200,11 +201,12 @@ public void drawScreen(int width, int height, float f) { final int scaledMouseX = (mx * mc.displayWidth) / this.width; final int scaledMouseY = (my * mc.displayHeight) / this.height; - LayerRenderer activeLayer = NavigatorApi.getActiveLayerFor(JourneyMap); - if (activeLayer instanceof JMInteractableLayerRenderer waypointProviderLayer) { - waypointProviderLayer.onMouseMove(scaledMouseX, scaledMouseY); - if (tooltip == null) { - tooltip = waypointProviderLayer.getTooltip(); + for (LayerRenderer layer : NavigatorApi.getActiveRenderersFor(JourneyMap)) { + if (layer instanceof JMInteractableLayerRenderer waypointProviderLayer) { + waypointProviderLayer.onMouseMove(scaledMouseX, scaledMouseY); + if (tooltip == null) { + tooltip = waypointProviderLayer.getTooltip(); + } } } @@ -216,8 +218,10 @@ public void drawScreen(int width, int height, float f) { drawHoveringText(tooltip, mx, my, getFontRenderer()); RenderHelper.disableStandardItemLighting(); } else { - if (activeLayer instanceof JMInteractableLayerRenderer waypointProviderLayer) { - waypointProviderLayer.drawCustomTooltip(getFontRenderer(), mx, my, this.width, this.height); + for (LayerRenderer layer : NavigatorApi.getActiveRenderersFor(JourneyMap)) { + if (layer instanceof JMInteractableLayerRenderer waypointProviderLayer) { + waypointProviderLayer.drawCustomTooltip(getFontRenderer(), mx, my, this.width, this.height); + } } } @@ -235,10 +239,11 @@ public void drawScreen(int width, int height, float f) { @Inject(method = "keyTyped", at = @At(value = "HEAD"), remap = true, require = 1, cancellable = true) private void navigator$onKeyPress(CallbackInfo ci, @Local(argsOnly = true) int keyCode) { if ((chat == null || chat.isHidden())) { - LayerRenderer layer = NavigatorApi.getActiveLayerFor(JourneyMap); - if (layer instanceof JMInteractableLayerRenderer waypointProvider) { - if (waypointProvider.onKeyPressed(keyCode)) { - ci.cancel(); + for (LayerRenderer layer : NavigatorApi.getActiveRenderersFor(JourneyMap)) { + if (layer instanceof JMInteractableLayerRenderer waypointProvider) { + if (waypointProvider.onKeyPressed(keyCode)) { + ci.cancel(); + } } } } @@ -246,7 +251,8 @@ public void drawScreen(int width, int height, float f) { @Inject(method = "onGuiClosed", at = @At("RETURN"), remap = true) private void navigator$onGuiClosed(CallbackInfo ci) { - NavigatorApi.layerManagers.forEach(layerManager -> layerManager.onGuiClosed(JourneyMap)); + NavigatorApi.getEnabledLayers(JourneyMap) + .forEach(layerManager -> layerManager.onGuiClosed(JourneyMap)); } @Override @@ -285,10 +291,10 @@ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) { if (mouseButton != 0) { return false; } - LayerRenderer layer = NavigatorApi.getActiveLayerFor(JourneyMap); - if (layer instanceof JMInteractableLayerRenderer wpLayerRender) { - wpLayerRender.onMouseMove(mouseX, mouseY); - return wpLayerRender.onMapClick(isDoubleClick, mouseX, mouseY, blockCoord.x, blockCoord.z); + for (LayerRenderer layer : NavigatorApi.getActiveRenderersFor(JourneyMap)) { + if (layer instanceof JMInteractableLayerRenderer waypointProviderLayer) { + return waypointProviderLayer.onMapClick(isDoubleClick, mouseX, mouseY, blockCoord.x, blockCoord.z); + } } return false; } diff --git a/src/main/java/com/gtnewhorizons/navigator/mixins/late/journeymap/MiniMapMixin.java b/src/main/java/com/gtnewhorizons/navigator/mixins/late/journeymap/MiniMapMixin.java index ca4577c..9f124ca 100644 --- a/src/main/java/com/gtnewhorizons/navigator/mixins/late/journeymap/MiniMapMixin.java +++ b/src/main/java/com/gtnewhorizons/navigator/mixins/late/journeymap/MiniMapMixin.java @@ -38,7 +38,7 @@ public abstract class MiniMapMixin { @Inject(method = "drawOnMapWaypoints", at = @At(value = "HEAD"), require = 1) private void navigator$onBeforeDrawWaypoints(double rotation, CallbackInfo ci) { - for (LayerManager layerManager : NavigatorApi.layerManagers) { + for (LayerManager layerManager : NavigatorApi.getEnabledLayers(JourneyMap)) { if (layerManager.isLayerActive()) { if (((DisplayVarsAccessor) dv).getShape() == Shape.Circle) { layerManager.recacheMiniMap( @@ -55,18 +55,17 @@ public abstract class MiniMapMixin { } } - LayerRenderer activeLayer = NavigatorApi.getActiveLayerFor(JourneyMap); - if (activeLayer == null) return; - - for (RenderStep renderStep : activeLayer.getRenderSteps()) { - if (renderStep instanceof DrawStep drawStep) { - drawStep.draw( - 0.0D, - 0.0D, - gridRenderer, - ((DisplayVarsAccessor) dv).getDrawScale(), - ((DisplayVarsAccessor) dv).getFontScale(), - rotation); + for (LayerRenderer layerRenderer : NavigatorApi.getActiveRenderersFor(JourneyMap)) { + for (RenderStep renderStep : layerRenderer.getRenderSteps()) { + if (renderStep instanceof DrawStep drawStep) { + drawStep.draw( + 0.0D, + 0.0D, + gridRenderer, + ((DisplayVarsAccessor) dv).getDrawScale(), + ((DisplayVarsAccessor) dv).getFontScale(), + rotation); + } } } } diff --git a/src/main/java/com/gtnewhorizons/navigator/mixins/late/journeymap/RenderWaypointBeaconMixin.java b/src/main/java/com/gtnewhorizons/navigator/mixins/late/journeymap/RenderWaypointBeaconMixin.java index 75fca97..f1c1b6f 100644 --- a/src/main/java/com/gtnewhorizons/navigator/mixins/late/journeymap/RenderWaypointBeaconMixin.java +++ b/src/main/java/com/gtnewhorizons/navigator/mixins/late/journeymap/RenderWaypointBeaconMixin.java @@ -1,5 +1,7 @@ package com.gtnewhorizons.navigator.mixins.late.journeymap; +import static com.gtnewhorizons.navigator.api.model.SupportedMods.JourneyMap; + import net.minecraft.client.Minecraft; import org.spongepowered.asm.mixin.Mixin; @@ -10,6 +12,7 @@ import com.gtnewhorizons.navigator.api.NavigatorApi; import com.gtnewhorizons.navigator.api.journeymap.waypoints.JMWaypointManager; +import com.gtnewhorizons.navigator.api.model.layers.InteractableLayerManager; import com.gtnewhorizons.navigator.api.model.waypoints.WaypointManager; import journeymap.client.model.Waypoint; @@ -34,8 +37,9 @@ static void doRender(Waypoint waypoint) { remap = false, require = 1) private static void navigator$onRenderAll(CallbackInfo ci) { - for (WaypointManager waypointManager : NavigatorApi.waypointManagers) { - if (waypointManager.hasWaypoint() && waypointManager instanceof JMWaypointManager jmWaypointManager) { + for (InteractableLayerManager layer : NavigatorApi.getInteractableLayers()) { + WaypointManager waypointManager = layer.getWaypointManager(JourneyMap); + if (waypointManager instanceof JMWaypointManager jmWaypointManager && waypointManager.hasWaypoint()) { final Waypoint waypoint = jmWaypointManager.getJmWaypoint(); if (waypoint.getDimensions() .contains(mc.thePlayer.dimension)) { diff --git a/src/main/java/com/gtnewhorizons/navigator/mixins/late/journeymap/WaypointManagerMixin.java b/src/main/java/com/gtnewhorizons/navigator/mixins/late/journeymap/WaypointManagerMixin.java index 1628113..e71f56b 100644 --- a/src/main/java/com/gtnewhorizons/navigator/mixins/late/journeymap/WaypointManagerMixin.java +++ b/src/main/java/com/gtnewhorizons/navigator/mixins/late/journeymap/WaypointManagerMixin.java @@ -6,8 +6,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import com.gtnewhorizons.navigator.api.NavigatorApi; +import com.gtnewhorizons.navigator.api.model.layers.InteractableLayerManager; import com.gtnewhorizons.navigator.api.model.layers.LayerManager; -import com.gtnewhorizons.navigator.api.model.layers.WaypointProviderManager; import journeymap.client.ui.waypoint.WaypointManager; @@ -18,7 +18,7 @@ public abstract class WaypointManagerMixin { private void navigator$onToggleAllWaypoints(boolean enable, CallbackInfoReturnable cir) { if (!enable) { for (LayerManager layer : NavigatorApi.layerManagers) { - if (layer instanceof WaypointProviderManager waypointProvider) { + if (layer instanceof InteractableLayerManager waypointProvider) { waypointProvider.clearActiveWaypoint(); } } diff --git a/src/main/java/com/gtnewhorizons/navigator/mixins/late/xaerosminimap/MinimapRendererMixin.java b/src/main/java/com/gtnewhorizons/navigator/mixins/late/xaerosminimap/MinimapRendererMixin.java index 94893f1..de24839 100644 --- a/src/main/java/com/gtnewhorizons/navigator/mixins/late/xaerosminimap/MinimapRendererMixin.java +++ b/src/main/java/com/gtnewhorizons/navigator/mixins/late/xaerosminimap/MinimapRendererMixin.java @@ -17,6 +17,7 @@ import com.gtnewhorizons.navigator.Navigator; import com.gtnewhorizons.navigator.api.NavigatorApi; import com.gtnewhorizons.navigator.api.model.layers.LayerManager; +import com.gtnewhorizons.navigator.api.model.layers.LayerRenderer; import com.gtnewhorizons.navigator.api.xaero.renderers.XaeroLayerRenderer; import com.gtnewhorizons.navigator.api.xaero.rendersteps.XaeroRenderStep; import com.llamalad7.mixinextras.sugar.Local; @@ -46,7 +47,7 @@ public abstract class MinimapRendererMixin { int width, int height, int scale, int size, float partial, CallbackInfo ci, @Local(name = "circleShape") boolean circleShape, @Local(name = "minimapFrameSize") int minimapFrameSize, @Local(name = "angle") double angle, @Local(name = "minimapScale") float minimapScale) { - for (LayerManager layerManager : NavigatorApi.layerManagers) { + for (LayerManager layerManager : NavigatorApi.getEnabledLayers(XaeroWorldMap)) { if (layerManager.isLayerActive()) { if (circleShape) { layerManager.recacheMiniMap((int) mc.thePlayer.posX, (int) mc.thePlayer.posZ, minimapFrameSize * 2); @@ -68,12 +69,12 @@ public abstract class MinimapRendererMixin { GL11.glScaled(mapZoom, mapZoom, 0); GL11.glStencilFunc(GL11.GL_EQUAL, 1, 1); - XaeroLayerRenderer activeLayer = (XaeroLayerRenderer) NavigatorApi.getActiveLayerFor(XaeroWorldMap); - if (activeLayer != null) { - for (XaeroRenderStep renderStep : activeLayer.getRenderSteps()) { + for (LayerRenderer layerRenderer : NavigatorApi.getActiveRenderersFor(XaeroWorldMap)) { + for (XaeroRenderStep renderStep : ((XaeroLayerRenderer) layerRenderer).getRenderSteps()) { renderStep.draw(null, minimap.mainPlayerX, minimap.mainPlayerZ, mapZoom); } } + GL11.glDisable(GL11.GL_STENCIL_TEST); GL11.glPopMatrix(); } diff --git a/src/main/java/com/gtnewhorizons/navigator/mixins/late/xaerosminimap/WaypointsIngameRendererMixin.java b/src/main/java/com/gtnewhorizons/navigator/mixins/late/xaerosminimap/WaypointsIngameRendererMixin.java index ea82441..72b7f07 100644 --- a/src/main/java/com/gtnewhorizons/navigator/mixins/late/xaerosminimap/WaypointsIngameRendererMixin.java +++ b/src/main/java/com/gtnewhorizons/navigator/mixins/late/xaerosminimap/WaypointsIngameRendererMixin.java @@ -10,6 +10,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import com.gtnewhorizons.navigator.api.NavigatorApi; +import com.gtnewhorizons.navigator.api.model.SupportedMods; +import com.gtnewhorizons.navigator.api.model.layers.InteractableLayerManager; import com.gtnewhorizons.navigator.api.model.waypoints.WaypointManager; import com.gtnewhorizons.navigator.api.xaero.waypoints.XaeroWaypointManager; @@ -31,7 +33,12 @@ public abstract class WaypointsIngameRendererMixin { opcode = Opcodes.GETSTATIC))) private void navigator$injectPreRenderCustomWaypoints(XaeroMinimapSession sets, float modCustomWaypoints, CallbackInfo ci) { - for (WaypointManager manager : NavigatorApi.waypointManagers) { + for (InteractableLayerManager layer : NavigatorApi.getInteractableLayers()) { + WaypointManager manager = layer.getWaypointManager(SupportedMods.XaeroMiniMap); + if (manager == null) { + manager = layer.getWaypointManager(SupportedMods.XaeroWorldMap); + } + if (manager instanceof XaeroWaypointManager xaeroManager) { if (xaeroManager.hasWaypoint()) { xaeroManager.getXWaypoint() diff --git a/src/main/java/com/gtnewhorizons/navigator/mixins/late/xaerosworldmap/GuiMapMixin.java b/src/main/java/com/gtnewhorizons/navigator/mixins/late/xaerosworldmap/GuiMapMixin.java index 3a73f67..3be9de3 100644 --- a/src/main/java/com/gtnewhorizons/navigator/mixins/late/xaerosworldmap/GuiMapMixin.java +++ b/src/main/java/com/gtnewhorizons/navigator/mixins/late/xaerosworldmap/GuiMapMixin.java @@ -73,7 +73,8 @@ protected GuiMapMixin(GuiScreen parent, GuiScreen escape) { @Inject(method = "", at = @At("RETURN")) private void navigator$injectConstruct(GuiScreen parent, GuiScreen escape, MapProcessor mapProcessor, Entity player, CallbackInfo ci) { - NavigatorApi.layerManagers.forEach(layerManager -> layerManager.onGuiOpened(XaeroWorldMap)); + NavigatorApi.getEnabledLayers(XaeroWorldMap) + .forEach(layerManager -> layerManager.onGuiOpened(XaeroWorldMap)); } @Inject( @@ -92,7 +93,7 @@ protected GuiMapMixin(GuiScreen parent, GuiScreen escape) { double mousePosX = (Misc.getMouseX(mc) - (double) mc.displayWidth / 2) / this.scale; double mousePosZ = (Misc.getMouseY(mc) - (double) mc.displayHeight / 2) / this.scale; - for (LayerRenderer layer : NavigatorApi.layerRenderers) { + for (LayerRenderer layer : NavigatorApi.getActiveRenderersFor(XaeroWorldMap)) { if (layer instanceof XaeroInteractableLayerRenderer interactableLayer) { interactableLayer.updateHovered(mousePosX, mousePosZ, scale); } @@ -104,21 +105,20 @@ protected GuiMapMixin(GuiScreen parent, GuiScreen escape) { at = @At(value = "INVOKE", target = "Lxaero/map/mods/SupportMods;minimap()Z", ordinal = 1, remap = false), remap = true) private void navigator$injectDraw(int scaledMouseX, int scaledMouseY, float partialTicks, CallbackInfo ci) { - for (LayerManager layerManager : NavigatorApi.layerManagers) { - if (layerManager.isLayerActive()) { - // +20s are to work around precision loss from casting to int and right-shifting - layerManager.recacheFullscreenMap( - (int) cameraX, - (int) cameraZ, - (int) (mc.displayWidth / scale) + 20, - (int) (mc.displayHeight / scale) + 20); - } + for (LayerManager layerManager : NavigatorApi.getEnabledLayers(XaeroWorldMap)) { + // +20s are to work around precision loss from casting to int and right-shifting + layerManager.recacheFullscreenMap( + (int) cameraX, + (int) cameraZ, + (int) (mc.displayWidth / scale) + 20, + (int) (mc.displayHeight / scale) + 20); } - XaeroLayerRenderer renderer = (XaeroLayerRenderer) NavigatorApi.getActiveLayerFor(XaeroWorldMap); - if (renderer != null) { - for (XaeroRenderStep step : renderer.getRenderSteps()) { - step.draw(this, cameraX, cameraZ, scale); + for (LayerRenderer layer : NavigatorApi.getActiveRenderersFor(XaeroWorldMap)) { + if (layer instanceof XaeroLayerRenderer xaeroLayerRenderer) { + for (XaeroRenderStep step : xaeroLayerRenderer.getRenderSteps()) { + step.draw(this, cameraX, cameraZ, scale); + } } } } @@ -132,26 +132,26 @@ protected GuiMapMixin(GuiScreen parent, GuiScreen escape) { shift = At.Shift.AFTER), remap = true) private void navigator$injectDrawTooltip(int scaledMouseX, int scaledMouseY, float partialTicks, CallbackInfo ci) { - LayerRenderer layer = NavigatorApi.getActiveLayerFor(XaeroWorldMap); - if (layer instanceof XaeroInteractableLayerRenderer interactableLayer) { - List tooltip = interactableLayer.getTooltip(); - if (!tooltip.isEmpty()) { - DrawUtils - .drawSimpleTooltip(this, tooltip, scaledMouseX + 16, scaledMouseY - 12, 0xFFFFFFFF, 0x86000000); - } else { - interactableLayer.drawCustomTooltip(this, scaledMouseX, scaledMouseY, scale, screenScale); + for (LayerRenderer layer : NavigatorApi.getActiveRenderersFor(XaeroWorldMap)) { + if (layer instanceof XaeroInteractableLayerRenderer interactableLayer) { + List tooltip = interactableLayer.getTooltip(); + if (!tooltip.isEmpty()) { + DrawUtils + .drawSimpleTooltip(this, tooltip, scaledMouseX + 16, scaledMouseY - 12, 0xFFFFFFFF, 0x86000000); + } else { + interactableLayer.drawCustomTooltip(this, scaledMouseX, scaledMouseY, scale, screenScale); + } } } } @Inject(method = "initGui", at = @At(value = "TAIL"), remap = true) private void navigator$injectInitButtons(CallbackInfo ci) { - List buttons = NavigatorApi.buttonManagers; + List buttons = NavigatorApi.getEnabledButtons(XaeroWorldMap); int numBtns = buttons.size(); int totalHeight = numBtns * 20; for (int i = 0; i < numBtns; i++) { ButtonManager btnManager = buttons.get(i); - if (!btnManager.isEnabled(XaeroWorldMap)) continue; SizedGuiTexturedButton button = new SizedGuiTexturedButton( 0, (height / 2 + totalHeight / 2) - 20 - 20 * i, @@ -172,10 +172,11 @@ protected GuiMapMixin(GuiScreen parent, GuiScreen escape) { ordinal = 1), cancellable = true) private void navigator$injectListenKeypress(boolean mouse, int code, CallbackInfoReturnable cir) { - LayerRenderer activeLayer = NavigatorApi.getActiveLayerFor(XaeroWorldMap); - if (activeLayer instanceof XaeroInteractableLayerRenderer interactableLayer - && interactableLayer.onKeyPressed(code)) { - cir.setReturnValue(true); + for (LayerRenderer layer : NavigatorApi.getActiveRenderersFor(XaeroWorldMap)) { + if (layer instanceof XaeroInteractableLayerRenderer interactableLayer + && interactableLayer.onKeyPressed(code)) { + cir.setReturnValue(true); + } } } @@ -189,16 +190,18 @@ protected GuiMapMixin(GuiScreen parent, GuiScreen escape) { navigator$oldMouseY = y; navigator$timeLastClick = isDoubleClick ? 0 : timestamp; - LayerRenderer layer = NavigatorApi.getActiveLayerFor(XaeroWorldMap); - if (layer instanceof XaeroInteractableLayerRenderer interactableLayer) { - interactableLayer.onMapClick(isDoubleClick, x, y, mouseBlockPosX, mouseBlockPosZ); + for (LayerRenderer layer : NavigatorApi.getActiveRenderersFor(XaeroWorldMap)) { + if (layer instanceof XaeroInteractableLayerRenderer interactableLayer) { + interactableLayer.onMapClick(isDoubleClick, x, y, mouseBlockPosX, mouseBlockPosZ); + } } } } @Inject(method = "onGuiClosed", at = @At("RETURN"), remap = true) private void navigator$onGuiClosed(CallbackInfo ci) { - NavigatorApi.layerManagers.forEach(layerManager -> layerManager.onGuiClosed(XaeroWorldMap)); + NavigatorApi.getEnabledLayers(XaeroWorldMap) + .forEach(layerManager -> layerManager.onGuiClosed(XaeroWorldMap)); } @Override