From 09f8011b225f2d8a0615e4ec794cb5c5b1f14876 Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Sun, 1 Sep 2024 21:46:58 -0700 Subject: [PATCH 1/3] fix selection length when crossing pos/neg coords --- common/src/main/java/xaeroplus/mixin/client/MixinGuiMap.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/xaeroplus/mixin/client/MixinGuiMap.java b/common/src/main/java/xaeroplus/mixin/client/MixinGuiMap.java index fff71c4c..80fa1260 100644 --- a/common/src/main/java/xaeroplus/mixin/client/MixinGuiMap.java +++ b/common/src/main/java/xaeroplus/mixin/client/MixinGuiMap.java @@ -547,8 +547,8 @@ public void renderTileSelectionSize( ) { MapTileSelection selection = this.mapTileSelection; if (selection == null) return; - var sideLen = Math.abs(Math.abs(selection.getRight()) - Math.abs(selection.getLeft()))+1; - var heightLen = Math.abs(Math.abs(selection.getBottom()) - Math.abs(selection.getTop()))+1; + var sideLen = Math.abs(selection.getRight() - selection.getLeft())+1; + var heightLen = Math.abs(selection.getBottom() - selection.getTop())+1; if (sideLen <= 1 && heightLen <= 1) return; // todo: it'd be better if we could render this directly on the highlight // but we need a function for map -> screen coordinates translation From a922413e6d6ae2344ab2fa47edb66f47919cebbb Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Mon, 2 Sep 2024 15:19:55 -0700 Subject: [PATCH 2/3] MM24.4.0 --- .../extensions/IWaypointDimension.java | 9 -- .../mixin/client/AccessorWaypointSet.java | 16 +++ .../mixin/client/MixinGuiAddWaypoint.java | 44 ------- .../mixin/client/MixinGuiWaypoint.java | 29 ----- .../mixin/client/MixinGuiWaypoints.java | 33 +++--- .../mixin/client/MixinGuiWaypointsList.java | 13 +- .../mixin/client/MixinMinimapFBORenderer.java | 85 ++++---------- .../mixin/client/MixinMinimapModSettings.java | 55 ++++----- .../mixin/client/MixinMinimapRenderer.java | 32 ++--- .../client/MixinMinimapWorldStateUpdater.java | 59 ++++++++++ .../client/MixinSupportXaeroWorldmap.java | 16 +-- .../xaeroplus/mixin/client/MixinWaypoint.java | 23 ---- .../client/MixinWaypointSharingHandler.java | 9 +- .../client/MixinWaypointsIngameRenderer.java | 24 +++- .../mixin/client/MixinWaypointsManager.java | 102 ---------------- .../module/impl/BaritoneGoalSync.java | 111 ++++++------------ .../xaeroplus/module/impl/WaystoneSync.java | 92 ++++++--------- .../xaeroplus/util/DataFolderResolveUtil.java | 2 +- .../java/xaeroplus/util/WaypointsHelper.java | 18 --- .../src/main/resources/xaeroplus.mixins.json | 6 +- fabric/build.gradle.kts | 2 +- settings.gradle.kts | 6 +- 22 files changed, 283 insertions(+), 503 deletions(-) delete mode 100644 common/src/main/java/xaeroplus/feature/extensions/IWaypointDimension.java create mode 100644 common/src/main/java/xaeroplus/mixin/client/AccessorWaypointSet.java delete mode 100644 common/src/main/java/xaeroplus/mixin/client/MixinGuiAddWaypoint.java delete mode 100644 common/src/main/java/xaeroplus/mixin/client/MixinGuiWaypoint.java create mode 100644 common/src/main/java/xaeroplus/mixin/client/MixinMinimapWorldStateUpdater.java delete mode 100644 common/src/main/java/xaeroplus/mixin/client/MixinWaypoint.java delete mode 100644 common/src/main/java/xaeroplus/mixin/client/MixinWaypointsManager.java delete mode 100644 common/src/main/java/xaeroplus/util/WaypointsHelper.java diff --git a/common/src/main/java/xaeroplus/feature/extensions/IWaypointDimension.java b/common/src/main/java/xaeroplus/feature/extensions/IWaypointDimension.java deleted file mode 100644 index c7173b13..00000000 --- a/common/src/main/java/xaeroplus/feature/extensions/IWaypointDimension.java +++ /dev/null @@ -1,9 +0,0 @@ -package xaeroplus.feature.extensions; - -import net.minecraft.resources.ResourceKey; -import net.minecraft.world.level.Level; - -public interface IWaypointDimension { - ResourceKey getDimension(); - void setDimension(ResourceKey dimension); -} diff --git a/common/src/main/java/xaeroplus/mixin/client/AccessorWaypointSet.java b/common/src/main/java/xaeroplus/mixin/client/AccessorWaypointSet.java new file mode 100644 index 00000000..f73c7674 --- /dev/null +++ b/common/src/main/java/xaeroplus/mixin/client/AccessorWaypointSet.java @@ -0,0 +1,16 @@ +package xaeroplus.mixin.client; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; +import xaero.common.minimap.waypoints.Waypoint; +import xaero.hud.minimap.waypoint.set.WaypointSet; + +import java.util.List; + +@Mixin(value = WaypointSet.class, remap = false) +public interface AccessorWaypointSet { + // we could alternatively just cast the iterable getter back to list + // but doing an accessor should cause compile errors if the type ever changes from under us in future updates + @Accessor + List getList(); +} diff --git a/common/src/main/java/xaeroplus/mixin/client/MixinGuiAddWaypoint.java b/common/src/main/java/xaeroplus/mixin/client/MixinGuiAddWaypoint.java deleted file mode 100644 index 3ff7969f..00000000 --- a/common/src/main/java/xaeroplus/mixin/client/MixinGuiAddWaypoint.java +++ /dev/null @@ -1,44 +0,0 @@ -package xaeroplus.mixin.client; - -import com.llamalad7.mixinextras.sugar.Local; -import net.minecraft.client.gui.components.Button; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import xaero.common.gui.GuiAddWaypoint; -import xaero.common.minimap.waypoints.Waypoint; -import xaero.common.minimap.waypoints.WaypointWorld; -import xaeroplus.XaeroPlus; -import xaeroplus.feature.extensions.IWaypointDimension; - -import java.util.ArrayList; -import java.util.Arrays; - -@Mixin(value = GuiAddWaypoint.class, remap = true) -public class MixinGuiAddWaypoint { - - @Shadow(remap = false) private ArrayList waypointsEdited; - - - @Inject( - method = "lambda$init$3", - at = @At( - value = "INVOKE", - target = "Lxaero/common/IXaeroMinimap;getSettings()Lxaero/common/settings/ModSettings;", - ordinal = 1 - )) - public void addWaypointInject( - Button b, - final CallbackInfo ci, - @Local(name = "destinationWorld") WaypointWorld destinationWorld) { - try { - waypointsEdited.forEach(waypoint -> { - ((IWaypointDimension) waypoint).setDimension(destinationWorld.getDimId()); - }); - } catch (Throwable e) { - XaeroPlus.LOGGER.error("Failed setting waypoint dimension: {}", Arrays.toString(waypointsEdited.toArray()), e); - } - } -} diff --git a/common/src/main/java/xaeroplus/mixin/client/MixinGuiWaypoint.java b/common/src/main/java/xaeroplus/mixin/client/MixinGuiWaypoint.java deleted file mode 100644 index fa5d2839..00000000 --- a/common/src/main/java/xaeroplus/mixin/client/MixinGuiWaypoint.java +++ /dev/null @@ -1,29 +0,0 @@ -package xaeroplus.mixin.client; - -import net.minecraft.resources.ResourceKey; -import net.minecraft.world.level.Level; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import xaero.map.mods.gui.Waypoint; -import xaeroplus.feature.extensions.IWaypointDimension; - -@Mixin(value = Waypoint.class, remap = false) -public class MixinGuiWaypoint implements IWaypointDimension { - @Shadow - private Object original; - - @Override - public ResourceKey getDimension() { - if (original instanceof xaero.common.minimap.waypoints.Waypoint) { - return ((IWaypointDimension) original).getDimension(); - } - return Level.OVERWORLD; - } - - @Override - public void setDimension(final ResourceKey dimension) { - if (original instanceof xaero.common.minimap.waypoints.Waypoint) { - ((IWaypointDimension) original).setDimension(dimension); - } - } -} diff --git a/common/src/main/java/xaeroplus/mixin/client/MixinGuiWaypoints.java b/common/src/main/java/xaeroplus/mixin/client/MixinGuiWaypoints.java index d57fc37b..add8381e 100644 --- a/common/src/main/java/xaeroplus/mixin/client/MixinGuiWaypoints.java +++ b/common/src/main/java/xaeroplus/mixin/client/MixinGuiWaypoints.java @@ -21,30 +21,30 @@ import xaero.common.gui.MySmallButton; import xaero.common.gui.ScreenBase; import xaero.common.minimap.waypoints.Waypoint; -import xaero.common.minimap.waypoints.WaypointWorld; -import xaero.common.minimap.waypoints.WaypointsManager; import xaero.common.minimap.waypoints.WaypointsSort; import xaero.common.misc.KeySortableByOther; +import xaero.hud.minimap.module.MinimapSession; +import xaero.hud.minimap.world.MinimapWorld; import xaeroplus.settings.XaeroPlusSettingRegistry; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.concurrent.ConcurrentSkipListSet; @Mixin(value = GuiWaypoints.class, remap = false) public abstract class MixinGuiWaypoints extends ScreenBase { - - @Shadow - private WaypointWorld displayedWorld; - @Shadow - private ArrayList waypointsSorted; - @Shadow - private WaypointsManager waypointsManager; @Unique private EditBox searchField; @Unique private final int TOGGLE_ALL_ID = 69; @Unique private MySmallButton toggleAllButton; @Unique private String waypointsSearchFilter = ""; + @Shadow private MinimapWorld displayedWorld; + @Shadow private ArrayList waypointsSorted; + @Shadow protected abstract boolean isOneSelected(); + @Shadow private MinimapSession session; + @Shadow private ConcurrentSkipListSet selectedListSet; + protected MixinGuiWaypoints(final IXaeroMinimap modMain, final Screen parent, final Screen escape, final Component titleIn) { super(modMain, parent, escape, titleIn); } @@ -122,9 +122,6 @@ public void drawScreenInject(final GuiGraphics guiGraphics, final int mouseX, fi } } - @Shadow - protected abstract boolean isOneSelected(); - @Redirect(method = "updateButtons", at = @At(value = "INVOKE", target = "Lxaero/common/gui/GuiWaypoints;isOneSelected()Z")) public boolean shareButtonRedirect(final GuiWaypoints instance) { if (XaeroPlusSettingRegistry.disableWaypointSharing.getValue()) { @@ -133,11 +130,13 @@ public boolean shareButtonRedirect(final GuiWaypoints instance) { return isOneSelected(); } + @Unique private void updateSearch() { if (this.searchField.isFocused()) { String newValue = this.searchField.getValue(); if (!Objects.equal(this.waypointsSearchFilter, newValue)) { this.waypointsSearchFilter = this.searchField.getValue(); + selectedListSet.clear(); updateSortedList(); } } @@ -149,9 +148,9 @@ private void updateSearch() { */ @Overwrite private void updateSortedList() { - WaypointsSort sortType = this.displayedWorld.getContainer().getRootContainer().getSortType(); - ArrayList waypointsList = this.displayedWorld.getCurrentSet().getList(); - GuiWaypoints.distanceDivided = this.waypointsManager.getDimensionDivision(this.displayedWorld); + WaypointsSort sortType = this.displayedWorld.getContainer().getRoot().getSortType(); + Iterable waypointsList = this.displayedWorld.getCurrentWaypointSet().getWaypoints(); + GuiWaypoints.distanceDivided = this.session.getDimensionHelper().getDimensionDivision(this.displayedWorld); Camera camera = this.minecraft.gameRenderer.getMainCamera(); final List disabledWaypoints = new ArrayList<>(); @@ -167,11 +166,11 @@ private void updateSortedList() { disabledWaypoints.removeIf(waypoint -> !waypoint.getName().toLowerCase().contains(this.waypointsSearchFilter.toLowerCase())); } this.waypointsSorted = new ArrayList<>(); - this.waypointsSorted.addAll(sortWaypoints(enabledWaypoints, sortType, camera)); this.waypointsSorted.addAll(sortWaypoints(disabledWaypoints, sortType, camera)); } + @Unique private List sortWaypoints(final List waypointsList, WaypointsSort sortType, final Camera camera) { final ArrayList waypointsSorted = new ArrayList<>(); final ArrayList> sortableKeys = new ArrayList<>(); @@ -191,7 +190,7 @@ private List sortWaypoints(final List waypointsList, Waypoin for (KeySortableByOther k : sortableKeys) { waypointsSorted.add(k.getKey()); } - if (this.displayedWorld.getContainer().getRootContainer().isSortReversed()) { + if (this.displayedWorld.getContainer().getRoot().isSortReversed()) { Collections.reverse(waypointsSorted); } return waypointsSorted; diff --git a/common/src/main/java/xaeroplus/mixin/client/MixinGuiWaypointsList.java b/common/src/main/java/xaeroplus/mixin/client/MixinGuiWaypointsList.java index bcae33b0..6c837653 100644 --- a/common/src/main/java/xaeroplus/mixin/client/MixinGuiWaypointsList.java +++ b/common/src/main/java/xaeroplus/mixin/client/MixinGuiWaypointsList.java @@ -14,10 +14,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import xaero.common.gui.GuiWaypoints; import xaero.common.minimap.waypoints.Waypoint; +import xaero.hud.minimap.waypoint.set.WaypointSet; +import xaero.hud.minimap.world.MinimapWorld; import xaeroplus.settings.XaeroPlusSettingRegistry; import java.text.NumberFormat; -import java.util.ArrayList; @Mixin(targets = "xaero.common.gui.GuiWaypoints$List", remap = false) public abstract class MixinGuiWaypointsList { @@ -44,10 +45,14 @@ public void getWaypointCount(final CallbackInfoReturnable cir) { @Redirect(method = "getWaypoint", at = @At( value = "INVOKE", - target = "Lxaero/common/minimap/waypoints/WaypointSet;getList()Ljava/util/ArrayList;" + target = "Lxaero/hud/minimap/world/MinimapWorld;getCurrentWaypointSet()Lxaero/hud/minimap/waypoint/set/WaypointSet;" )) - public ArrayList getWaypointList(final xaero.common.minimap.waypoints.WaypointSet waypointSet) { - return ((AccessorGuiWaypoints) thisGuiWaypoints).getWaypointsSorted(); + public WaypointSet getWaypointList(final MinimapWorld instance) { + // todo: could be optimized to reduce unnecessary list allocs + WaypointSet currentWaypointSet = instance.getCurrentWaypointSet(); + var wpSet = WaypointSet.Builder.begin().setName(currentWaypointSet.getName()).build(); + wpSet.addAll(((AccessorGuiWaypoints) thisGuiWaypoints).getWaypointsSorted()); + return wpSet; } @Inject(method = "drawWaypointSlot", at = @At( diff --git a/common/src/main/java/xaeroplus/mixin/client/MixinMinimapFBORenderer.java b/common/src/main/java/xaeroplus/mixin/client/MixinMinimapFBORenderer.java index 2ceef7ed..dd2b9b7c 100644 --- a/common/src/main/java/xaeroplus/mixin/client/MixinMinimapFBORenderer.java +++ b/common/src/main/java/xaeroplus/mixin/client/MixinMinimapFBORenderer.java @@ -30,6 +30,7 @@ import xaero.common.minimap.waypoints.render.WaypointsGuiRenderer; import xaero.common.misc.OptimizedMath; import xaero.hud.minimap.MinimapLogs; +import xaero.hud.minimap.module.MinimapSession; import xaeroplus.Globals; import xaeroplus.feature.extensions.CustomMinimapFBORenderer; import xaeroplus.settings.XaeroPlusSettingRegistry; @@ -73,7 +74,7 @@ public void reloadMapFrameBuffers() { @ModifyArg(method = "renderChunks", at = @At( value = "INVOKE", - target = "Lxaero/common/minimap/render/MinimapFBORenderer;renderChunksToFBO(Lxaero/common/XaeroMinimapSession;Lnet/minecraft/client/gui/GuiGraphics;Lxaero/common/minimap/MinimapProcessor;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/entity/Entity;DDDDIIFFIZZZIDDZZLxaero/common/graphics/CustomVertexConsumers;)V" + target = "Lxaero/common/minimap/render/MinimapFBORenderer;renderChunksToFBO(Lxaero/hud/minimap/module/MinimapSession;Lnet/minecraft/client/gui/GuiGraphics;Lxaero/common/minimap/MinimapProcessor;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/entity/Entity;DDDDIIFFIZZZIDDZZLxaero/common/graphics/CustomVertexConsumers;)V" ), index = 10, remap = true) // $REMAP @@ -85,8 +86,8 @@ public int modifyViewW(final int viewW) { value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;pose()Lcom/mojang/blaze3d/vertex/PoseStack;" ), remap = true) - public void modifyScaledSize(final XaeroMinimapSession minimapSession, final GuiGraphics guiGraphics, final MinimapProcessor minimap, final Player player, final Entity renderEntity, final double playerX, final double playerZ, final double playerDimDiv, final double mapDimensionScale, final int bufferSize, final int viewW, final float sizeFix, final float partial, final int level, final boolean retryIfError, final boolean useWorldMap, final boolean lockedNorth, final int shape, final double ps, final double pc, final boolean cave, final boolean circle, final CustomVertexConsumers cvc, final CallbackInfo ci, - @Share("scaledSize") LocalIntRef scaledSize) { + public void modifyScaledSize(final MinimapSession minimapSession, final GuiGraphics guiGraphics, final MinimapProcessor minimap, final Player player, final Entity renderEntity, final double playerX, final double playerZ, final double playerDimDiv, final double mapDimensionScale, final int bufferSize, final int viewW, final float sizeFix, final float partial, final int level, final boolean retryIfError, final boolean useWorldMap, final boolean lockedNorth, final int shape, final double ps, final double pc, final boolean cave, final boolean circle, final CustomVertexConsumers cvc, final CallbackInfo ci, + @Share("scaledSize") LocalIntRef scaledSize) { int s = 256 * Globals.minimapScaleMultiplier * Globals.minimapSizeMultiplier; if (Globals.minimapSizeMultiplier > 1) { int f = (Globals.minimapSizeMultiplier - 1) * Globals.minimapScaleMultiplier; @@ -135,7 +136,7 @@ public float modifyChunkGridLineWidth(final float original) { target = "Lnet/minecraft/client/renderer/MultiBufferSource$BufferSource;endBatch()V", ordinal = 0 ), remap = true) - public void drawRenderDistanceSquare(final XaeroMinimapSession minimapSession, final GuiGraphics guiGraphics, final MinimapProcessor minimap, final Player player, final Entity renderEntity, final double playerX, final double playerZ, final double playerDimDiv, final double mapDimensionScale, final int bufferSize, final int viewW, final float sizeFix, final float partial, final int level, final boolean retryIfError, final boolean useWorldMap, final boolean lockedNorth, final int shape, final double ps, final double pc, final boolean cave, final boolean circle, final CustomVertexConsumers cvc, final CallbackInfo ci, + public void drawRenderDistanceSquare(final MinimapSession minimapSession, final GuiGraphics guiGraphics, final MinimapProcessor minimap, final Player player, final Entity renderEntity, final double playerX, final double playerZ, final double playerDimDiv, final double mapDimensionScale, final int bufferSize, final int viewW, final float sizeFix, final float partial, final int level, final boolean retryIfError, final boolean useWorldMap, final boolean lockedNorth, final int shape, final double ps, final double pc, final boolean cave, final boolean circle, final CustomVertexConsumers cvc, final CallbackInfo ci, @Local(name = "xFloored") int xFloored, @Local(name = "zFloored") int zFloored, @Local(name = "renderTypeBuffers") MultiBufferSource.BufferSource renderTypeBuffers, @@ -166,52 +167,24 @@ public void drawRenderDistanceSquare(final XaeroMinimapSession minimapSession, f PoseStack.Pose matrices = matrixStack.last(); helper.addColoredLineToExistingBuffer( - matrices, - lineBufferBuilder, - x0, - z0, - x1, - z0, - 1.0f, - 1.0f, - 0.0f, - 0.8f + matrices, lineBufferBuilder, + x0, z0, x1, z0, + 1.0f, 1.0f, 0.0f, 0.8f ); helper.addColoredLineToExistingBuffer( - matrices, - lineBufferBuilder, - x1, - z0, - x1, - z1, - 1.0f, - 1.0f, - 0.0f, - 0.8f + matrices, lineBufferBuilder, + x1, z0, x1, z1, + 1.0f, 1.0f, 0.0f, 0.8f ); helper.addColoredLineToExistingBuffer( - matrices, - lineBufferBuilder, - x1, - z1, - x0, - z1, - 1.0f, - 1.0f, - 0.0f, - 0.8f + matrices, lineBufferBuilder, + x1, z1, x0, z1, + 1.0f, 1.0f, 0.0f, 0.8f ); helper.addColoredLineToExistingBuffer( - matrices, - lineBufferBuilder, - x0, - z0, - x0, - z1, - 1.0f, - 1.0f, - 0.0f, - 0.8f + matrices, lineBufferBuilder, + x0, z0, x0, z1, + 1.0f, 1.0f, 0.0f, 0.8f ); } } @@ -241,7 +214,7 @@ public void correctPreRotationTranslationForSizeMult(final PoseStack instance, f target = "Lxaero/common/graphics/ImprovedFramebuffer;bindRead()V" ) ), remap = true) - public void correctPostRotationTranslationForSizeMult(final XaeroMinimapSession minimapSession, final GuiGraphics guiGraphics, final MinimapProcessor minimap, final Player player, final Entity renderEntity, final double playerX, final double playerZ, final double playerDimDiv, final double mapDimensionScale, final int bufferSize, final int viewW, final float sizeFix, final float partial, final int level, final boolean retryIfError, final boolean useWorldMap, final boolean lockedNorth, final int shape, final double ps, final double pc, final boolean cave, final boolean circle, final CustomVertexConsumers cvc, final CallbackInfo ci, + public void correctPostRotationTranslationForSizeMult(final MinimapSession minimapSession, final GuiGraphics guiGraphics, final MinimapProcessor minimap, final Player player, final Entity renderEntity, final double playerX, final double playerZ, final double playerDimDiv, final double mapDimensionScale, final int bufferSize, final int viewW, final float sizeFix, final float partial, final int level, final boolean retryIfError, final boolean useWorldMap, final boolean lockedNorth, final int shape, final double ps, final double pc, final boolean cave, final boolean circle, final CustomVertexConsumers cvc, final CallbackInfo ci, @Local(name = "halfWView") float halfWView, @Local(name = "shaderMatrixStack") PoseStack shaderMatrixStack) { float sizeMultTranslation = (halfWView / Globals.minimapSizeMultiplier) * (Globals.minimapSizeMultiplier - 1); @@ -262,7 +235,7 @@ public void redirectModelViewDraw(final MinimapRendererHelper instance, final Po value = "INVOKE", target = "Lxaero/common/graphics/renderer/multitexture/MultiTextureRenderTypeRendererProvider;draw(Lxaero/common/graphics/renderer/multitexture/MultiTextureRenderTypeRenderer;)V" )) - public void drawMinimapFeaturesCaveMode(final XaeroMinimapSession minimapSession, final GuiGraphics guiGraphics, final MinimapProcessor minimap, final Player player, final Entity renderEntity, final double playerX, final double playerZ, final double playerDimDiv, final double mapDimensionScale, final int bufferSize, final int viewW, final float sizeFix, final float partial, final int level, final boolean retryIfError, final boolean useWorldMap, final boolean lockedNorth, final int shape, final double ps, final double pc, final boolean cave, final boolean circle, final CustomVertexConsumers cvc, final CallbackInfo ci, + public void drawMinimapFeaturesCaveMode(final MinimapSession minimapSession, final GuiGraphics guiGraphics, final MinimapProcessor minimap, final Player player, final Entity renderEntity, final double playerX, final double playerZ, final double playerDimDiv, final double mapDimensionScale, final int bufferSize, final int viewW, final float sizeFix, final float partial, final int level, final boolean retryIfError, final boolean useWorldMap, final boolean lockedNorth, final int shape, final double ps, final double pc, final boolean cave, final boolean circle, final CustomVertexConsumers cvc, final CallbackInfo ci, @Local(name = "xFloored") int xFloored, @Local(name = "zFloored") int zFloored, @Local(name = "overlayBufferBuilder") VertexConsumer overlayBufferBuilder, @@ -271,7 +244,7 @@ public void drawMinimapFeaturesCaveMode(final XaeroMinimapSession minimapSession @Local(name = "maxX") int maxXRef, @Local(name = "minZ") int minZRef, @Local(name = "maxZ") int maxZRef - ) { + ) { int mapX = xFloored >> 4; int mapZ = zFloored >> 4; int chunkX = mapX >> 2; @@ -281,19 +254,11 @@ public void drawMinimapFeaturesCaveMode(final XaeroMinimapSession minimapSession int insideX = xFloored & 15; int insideZ = zFloored & 15; Globals.drawManager.drawMinimapFeatures( - minXRef, - maxXRef, - minZRef, - maxZRef, - chunkX, - chunkZ, - tileX, - tileZ, - insideX, - insideZ, - matrixStack, - overlayBufferBuilder, - helper + minXRef, maxXRef, minZRef, maxZRef, + chunkX, chunkZ, + tileX, tileZ, + insideX, insideZ, + matrixStack, overlayBufferBuilder, helper ); } } diff --git a/common/src/main/java/xaeroplus/mixin/client/MixinMinimapModSettings.java b/common/src/main/java/xaeroplus/mixin/client/MixinMinimapModSettings.java index f18bd87a..b270b941 100644 --- a/common/src/main/java/xaeroplus/mixin/client/MixinMinimapModSettings.java +++ b/common/src/main/java/xaeroplus/mixin/client/MixinMinimapModSettings.java @@ -1,5 +1,6 @@ package xaeroplus.mixin.client; +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.sugar.Local; import net.minecraft.client.KeyMapping; import org.spongepowered.asm.mixin.Mixin; @@ -8,22 +9,19 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import xaero.common.HudMod; import xaero.common.IXaeroMinimap; -import xaero.common.XaeroMinimapSession; -import xaero.common.minimap.waypoints.Waypoint; -import xaero.common.minimap.waypoints.WaypointWorld; import xaero.common.settings.ModOptions; import xaero.common.settings.ModSettings; -import xaero.hud.HudSession; +import xaero.hud.minimap.Minimap; import xaeroplus.Globals; -import xaeroplus.XaeroPlus; -import xaeroplus.feature.extensions.IWaypointDimension; import xaeroplus.settings.XaeroPlusModSettingsHooks; import xaeroplus.settings.XaeroPlusSettingRegistry; import xaeroplus.settings.XaeroPlusSettingsReflectionHax; import java.io.File; import java.io.IOException; +import java.nio.file.Path; import static xaeroplus.settings.XaeroPlusSettingsReflectionHax.ALL_MINIMAP_SETTINGS; @@ -47,29 +45,14 @@ private void init(CallbackInfo ci) { caveMaps = 0; } - @Inject(method = "getLockNorth", at = @At("HEAD"), cancellable = true) - public void getLockNorth(int mapSize, int shape, CallbackInfoReturnable cir) { - if (!XaeroPlusSettingRegistry.transparentMinimapBackground.getValue()) return; - // prevent lock north from being forced to true when minimap is square and greater than 180 size - XaeroMinimapSession minimapSession = XaeroMinimapSession.getCurrentSession(); - if (minimapSession == null) { - cir.setReturnValue(this.lockNorth); - } else { - cir.setReturnValue(this.lockNorth || !this.keepUnlockedWhenEnlarged && minimapSession.getMinimapProcessor().isEnlargedMap()); - } - } - - @Inject( - method = "checkWaypointsLine", - at = @At( - value = "INVOKE", - target = "Ljava/util/ArrayList;add(Ljava/lang/Object;)Z")) - public void createWaypointInject(final String[] args, final WaypointWorld wpw, final CallbackInfoReturnable cir, @Local Waypoint waypoint) { - try { - ((IWaypointDimension) waypoint).setDimension(wpw.getDimId()); - } catch (final Throwable e) { - XaeroPlus.LOGGER.error("Failed setting waypoint dimension: {}", waypoint, e); - } + @ModifyExpressionValue(method = "getLockNorth", at = @At( + value = "CONSTANT", + args = "intValue=180")) + public int allowNoNorthLockWithTransparentMM(final int original) { + if (XaeroPlusSettingRegistry.transparentMinimapBackground.getValue()) + // will make the if expression always return false + return Integer.MAX_VALUE; + else return original; } @Inject(method = "getMinimapSize", at = @At( @@ -77,9 +60,11 @@ public void createWaypointInject(final String[] args, final WaypointWorld wpw, f ), cancellable = true) public void modifyMinimapSize(final CallbackInfoReturnable cir) { try { - var session = HudSession.getCurrentSession(); - if (session == null) return; - if (session.getHudMod().getInterfaces().getMinimapInterface().usingFBO()) { + var hudMod = HudMod.INSTANCE; + if (hudMod == null) return; + Minimap minimap = hudMod.getMinimap(); + if (minimap == null) return; + if (minimap.usingFBO()) { cir.setReturnValue(cir.getReturnValue() * Globals.minimapSizeMultiplier); } } catch (final Exception e) { @@ -89,13 +74,13 @@ public void modifyMinimapSize(final CallbackInfoReturnable cir) { @Inject(method = "saveSettings", at = @At("RETURN")) - public void saveSettings(final CallbackInfo ci) throws IOException { + public void saveSettings(final CallbackInfo ci) { XaeroPlusModSettingsHooks.saveSettings(); } @Inject(method = "loadSettings", at = @At(value = "INVOKE", target = "Lxaero/common/settings/ModSettings;saveSettings()V")) - public void loadSettings(final CallbackInfo ci, @Local File mainConfigFile) throws IOException { - if (!mainConfigFile.exists()) { + public void loadSettings(final CallbackInfo ci, @Local(name = "mainConfigFile") Path mainConfigFile) throws IOException { + if (!mainConfigFile.toFile().exists()) { XaeroPlusModSettingsHooks.loadSettings(null, ALL_MINIMAP_SETTINGS.get()); } } diff --git a/common/src/main/java/xaeroplus/mixin/client/MixinMinimapRenderer.java b/common/src/main/java/xaeroplus/mixin/client/MixinMinimapRenderer.java index e642bc3e..84796579 100644 --- a/common/src/main/java/xaeroplus/mixin/client/MixinMinimapRenderer.java +++ b/common/src/main/java/xaeroplus/mixin/client/MixinMinimapRenderer.java @@ -11,7 +11,6 @@ import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import xaero.common.IXaeroMinimap; -import xaero.common.XaeroMinimapSession; import xaero.common.graphics.CustomVertexConsumers; import xaero.common.graphics.renderer.multitexture.MultiTextureRenderTypeRendererProvider; import xaero.common.minimap.MinimapProcessor; @@ -22,6 +21,7 @@ import xaero.common.minimap.render.MinimapRendererHelper; import xaero.common.settings.ModSettings; import xaero.hud.minimap.Minimap; +import xaero.hud.minimap.module.MinimapSession; import xaeroplus.Globals; import xaeroplus.feature.extensions.CustomMinimapFBORenderer; import xaeroplus.settings.XaeroPlusSettingRegistry; @@ -35,18 +35,18 @@ public class MixinMinimapRenderer { @Inject(method = "renderMinimap", at = @At("HEAD")) public void renderMinimap( - final XaeroMinimapSession minimapSession, - final GuiGraphics guiGraphics, - final MinimapProcessor minimap, - final int x, - final int y, - final int width, - final int height, - final double scale, - final int size, - final float partial, - final CustomVertexConsumers cvc, - final CallbackInfo ci + final MinimapSession minimapSession, + final GuiGraphics guiGraphics, + final MinimapProcessor minimap, + final int x, + final int y, + final int width, + final int height, + final double scale, + final int size, + final float partial, + final CustomVertexConsumers cvc, + final CallbackInfo ci ) { if (this.minimap.usingFBO() && Globals.shouldResetFBO) { Globals.minimapScaleMultiplier = (int) XaeroPlusSettingRegistry.minimapScaleMultiplierSetting.getValue(); @@ -65,7 +65,7 @@ public void renderMinimap( slice = @Slice( from = @At( value = "INVOKE", - target = "Lxaero/common/minimap/render/MinimapRenderer;renderChunks(Lxaero/common/XaeroMinimapSession;Lnet/minecraft/client/gui/GuiGraphics;Lxaero/common/minimap/MinimapProcessor;DDDDIIFFIZZIDDZZLxaero/common/settings/ModSettings;Lxaero/common/graphics/CustomVertexConsumers;)V" + target = "Lxaero/common/minimap/render/MinimapRenderer;renderChunks(Lxaero/hud/minimap/module/MinimapSession;Lnet/minecraft/client/gui/GuiGraphics;Lxaero/common/minimap/MinimapProcessor;DDDDIIFFIZZIDDZZLxaero/common/settings/ModSettings;Lxaero/common/graphics/CustomVertexConsumers;)V" ) ) ) @@ -86,7 +86,7 @@ public int modifyMinimapSizeConstantI(final int constant) { slice = @Slice( from = @At( value = "INVOKE", - target = "Lxaero/common/minimap/render/MinimapRenderer;renderChunks(Lxaero/common/XaeroMinimapSession;Lnet/minecraft/client/gui/GuiGraphics;Lxaero/common/minimap/MinimapProcessor;DDDDIIFFIZZIDDZZLxaero/common/settings/ModSettings;Lxaero/common/graphics/CustomVertexConsumers;)V" + target = "Lxaero/common/minimap/render/MinimapRenderer;renderChunks(Lxaero/hud/minimap/module/MinimapSession;Lnet/minecraft/client/gui/GuiGraphics;Lxaero/common/minimap/MinimapProcessor;DDDDIIFFIZZIDDZZLxaero/common/settings/ModSettings;Lxaero/common/graphics/CustomVertexConsumers;)V" ) ) ) @@ -107,7 +107,7 @@ public float modifyMinimapSizeConstantF(final float constant) { slice = @Slice( from = @At( value = "INVOKE", - target = "Lxaero/common/minimap/render/MinimapRenderer;renderChunks(Lxaero/common/XaeroMinimapSession;Lnet/minecraft/client/gui/GuiGraphics;Lxaero/common/minimap/MinimapProcessor;DDDDIIFFIZZIDDZZLxaero/common/settings/ModSettings;Lxaero/common/graphics/CustomVertexConsumers;)V" + target = "Lxaero/common/minimap/render/MinimapRenderer;renderChunks(Lxaero/hud/minimap/module/MinimapSession;Lnet/minecraft/client/gui/GuiGraphics;Lxaero/common/minimap/MinimapProcessor;DDDDIIFFIZZIDDZZLxaero/common/settings/ModSettings;Lxaero/common/graphics/CustomVertexConsumers;)V" ) ) ) diff --git a/common/src/main/java/xaeroplus/mixin/client/MixinMinimapWorldStateUpdater.java b/common/src/main/java/xaeroplus/mixin/client/MixinMinimapWorldStateUpdater.java new file mode 100644 index 00000000..36dac884 --- /dev/null +++ b/common/src/main/java/xaeroplus/mixin/client/MixinMinimapWorldStateUpdater.java @@ -0,0 +1,59 @@ +package xaeroplus.mixin.client; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.llamalad7.mixinextras.sugar.Local; +import net.minecraft.client.multiplayer.ClientPacketListener; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.Level; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import xaero.hud.minimap.module.MinimapSession; +import xaero.hud.minimap.world.state.MinimapWorldState; +import xaero.hud.minimap.world.state.MinimapWorldStateUpdater; +import xaero.hud.path.XaeroPath; +import xaeroplus.settings.XaeroPlusSettingRegistry; +import xaeroplus.util.ChunkUtils; +import xaeroplus.util.DataFolderResolveUtil; + +import static net.minecraft.world.level.Level.NETHER; +import static net.minecraft.world.level.Level.OVERWORLD; + +@Mixin(value = MinimapWorldStateUpdater.class, remap = false) +public abstract class MixinMinimapWorldStateUpdater { + + @Unique private ResourceKey currentDim = OVERWORLD; + + @WrapOperation(method = "update", at = @At( + value = "INVOKE", + target = "Lxaero/hud/minimap/world/state/MinimapWorldState;setAutoWorldPath(Lxaero/hud/path/XaeroPath;)V" + )) + public void preferOverworldWpSetCustomPathOnDimUpdate(final MinimapWorldState instance, final XaeroPath autoWorldPath, final Operation original, + @Local(argsOnly = true) MinimapSession session, + @Local(name = "oldAutoWorldPath") XaeroPath oldAutoWorldPath, + @Local(name = "potentialAutoWorldNode") String potentialAutoWorldNode) { + original.call(instance, autoWorldPath); + if (XaeroPlusSettingRegistry.owAutoWaypointDimension.getValue()) { + ResourceKey actualDimension = ChunkUtils.getActualDimension(); + if (actualDimension == NETHER && currentDim != actualDimension) { + XaeroPath overworldWpXaeroPath = session.getWorldState().getAutoRootContainerPath() + .resolve(session.getDimensionHelper().getDimensionDirectoryName(OVERWORLD)) + .resolve(potentialAutoWorldNode); // todo: probably not quite correct with all multiworld configs + session.getWorldState().setCustomWorldPath(overworldWpXaeroPath); + } + } + currentDim = ChunkUtils.getActualDimension(); + } + + @Inject(method = "getAutoRootContainerPath", at = @At("HEAD"), cancellable = true) + public void customDataFolderResolve(final int version, final ClientPacketListener connection, final MinimapSession session, final CallbackInfoReturnable cir) { + var customCir = new CallbackInfoReturnable("a", true); + DataFolderResolveUtil.resolveDataFolder(connection, customCir); + if (customCir.isCancelled()) { + cir.setReturnValue(XaeroPath.root(customCir.getReturnValue())); + } + } +} diff --git a/common/src/main/java/xaeroplus/mixin/client/MixinSupportXaeroWorldmap.java b/common/src/main/java/xaeroplus/mixin/client/MixinSupportXaeroWorldmap.java index 88c33abc..d01248b6 100644 --- a/common/src/main/java/xaeroplus/mixin/client/MixinSupportXaeroWorldmap.java +++ b/common/src/main/java/xaeroplus/mixin/client/MixinSupportXaeroWorldmap.java @@ -14,11 +14,11 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import xaero.common.XaeroMinimapSession; import xaero.common.graphics.renderer.multitexture.MultiTextureRenderTypeRenderer; import xaero.common.graphics.renderer.multitexture.MultiTextureRenderTypeRendererProvider; import xaero.common.minimap.render.MinimapRendererHelper; import xaero.common.mods.SupportXaeroWorldmap; +import xaero.hud.minimap.module.MinimapSession; import xaero.map.MapProcessor; import xaero.map.WorldMapSession; import xaero.map.region.MapTileChunk; @@ -32,13 +32,13 @@ public abstract class MixinSupportXaeroWorldmap { value = "INVOKE", target = "Lxaero/map/settings/ModSettings;getRegionCacheHashCode()I" ), remap = false) - public void overrideRegionRange(final XaeroMinimapSession minimapSession, final PoseStack matrixStack, final MinimapRendererHelper helper, final int xFloored, final int zFloored, final int minViewX, final int minViewZ, final int maxViewX, final int maxViewZ, final boolean zooming, final double zoom, final double mapDimensionScale, final VertexConsumer overlayBufferBuilder, final MultiTextureRenderTypeRendererProvider multiTextureRenderTypeRenderers, final CallbackInfo ci, - @Local(name = "mapX") int mapX, - @Local(name = "mapZ") int mapZ, - @Local(name = "minX") LocalIntRef minXRef, - @Local(name = "maxX") LocalIntRef maxXRef, - @Local(name = "minZ") LocalIntRef minZRef, - @Local(name = "maxZ") LocalIntRef maxZRef + public void overrideRegionRange(final MinimapSession minimapSession, final PoseStack matrixStack, final MinimapRendererHelper helper, final int xFloored, final int zFloored, final int minViewX, final int minViewZ, final int maxViewX, final int maxViewZ, final boolean zooming, final double zoom, final double mapDimensionScale, final VertexConsumer overlayBufferBuilder, final MultiTextureRenderTypeRendererProvider multiTextureRenderTypeRenderers, final CallbackInfo ci, + @Local(name = "mapX") int mapX, + @Local(name = "mapZ") int mapZ, + @Local(name = "minX") LocalIntRef minXRef, + @Local(name = "maxX") LocalIntRef maxXRef, + @Local(name = "minZ") LocalIntRef minZRef, + @Local(name = "maxZ") LocalIntRef maxZRef ) { final int scaledSize = Globals.minimapScaleMultiplier * 4; minXRef.set((mapX >> 2) - scaledSize); diff --git a/common/src/main/java/xaeroplus/mixin/client/MixinWaypoint.java b/common/src/main/java/xaeroplus/mixin/client/MixinWaypoint.java deleted file mode 100644 index 6197217c..00000000 --- a/common/src/main/java/xaeroplus/mixin/client/MixinWaypoint.java +++ /dev/null @@ -1,23 +0,0 @@ -package xaeroplus.mixin.client; - -import net.minecraft.resources.ResourceKey; -import net.minecraft.world.level.Level; -import org.spongepowered.asm.mixin.Mixin; -import xaero.common.minimap.waypoints.Waypoint; -import xaeroplus.feature.extensions.IWaypointDimension; - -@Mixin(value = Waypoint.class, remap = false) -public class MixinWaypoint implements IWaypointDimension { - - private ResourceKey dimension = null; - - @Override - public ResourceKey getDimension() { - return dimension; - } - - @Override - public void setDimension(ResourceKey dimension) { - this.dimension = dimension; - } -} diff --git a/common/src/main/java/xaeroplus/mixin/client/MixinWaypointSharingHandler.java b/common/src/main/java/xaeroplus/mixin/client/MixinWaypointSharingHandler.java index 5dd5d47f..01c65b1a 100644 --- a/common/src/main/java/xaeroplus/mixin/client/MixinWaypointSharingHandler.java +++ b/common/src/main/java/xaeroplus/mixin/client/MixinWaypointSharingHandler.java @@ -11,7 +11,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import xaero.common.minimap.waypoints.Waypoint; import xaero.common.minimap.waypoints.WaypointSharingHandler; -import xaero.common.minimap.waypoints.WaypointWorld; +import xaero.hud.minimap.world.MinimapWorld; import xaeroplus.settings.XaeroPlusSettingRegistry; @Mixin(value = WaypointSharingHandler.class, remap = false) @@ -19,8 +19,11 @@ public class MixinWaypointSharingHandler { @Shadow private Waypoint w; - @Inject(method = "shareWaypoint", at = @At("HEAD"), cancellable = true) - public void shareWaypoint(final Screen parent, final Waypoint w, final WaypointWorld wWorld, final CallbackInfo ci) { + @Inject(method = "shareWaypoint(Lnet/minecraft/client/gui/screens/Screen;Lxaero/common/minimap/waypoints/Waypoint;Lxaero/hud/minimap/world/MinimapWorld;)V", + at = @At("HEAD"), + cancellable = true, + remap = true) // $REMAP + public void shareWaypoint(final Screen parent, final Waypoint w, final MinimapWorld wWorld, final CallbackInfo ci) { if (XaeroPlusSettingRegistry.disableWaypointSharing.getValue()) { ci.cancel(); } diff --git a/common/src/main/java/xaeroplus/mixin/client/MixinWaypointsIngameRenderer.java b/common/src/main/java/xaeroplus/mixin/client/MixinWaypointsIngameRenderer.java index 67f78253..603fd7f2 100644 --- a/common/src/main/java/xaeroplus/mixin/client/MixinWaypointsIngameRenderer.java +++ b/common/src/main/java/xaeroplus/mixin/client/MixinWaypointsIngameRenderer.java @@ -1,6 +1,7 @@ package xaeroplus.mixin.client; import com.llamalad7.mixinextras.sugar.Local; +import com.llamalad7.mixinextras.sugar.ref.LocalRef; import com.mojang.blaze3d.vertex.BufferBuilder; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.Tesselator; @@ -13,7 +14,9 @@ import net.minecraft.client.renderer.blockentity.BeaconRenderer; import net.minecraft.client.renderer.culling.Frustum; import net.minecraft.client.renderer.entity.EntityRenderDispatcher; +import net.minecraft.resources.ResourceKey; import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.Level; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; import org.joml.Matrix4f; @@ -26,14 +29,17 @@ import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import xaero.common.XaeroMinimapSession; +import xaero.common.minimap.MinimapProcessor; import xaero.common.minimap.render.MinimapRendererHelper; import xaero.common.minimap.waypoints.Waypoint; import xaero.common.minimap.waypoints.WaypointsManager; import xaero.common.minimap.waypoints.render.WaypointFilterParams; import xaero.common.minimap.waypoints.render.WaypointsIngameRenderer; import xaero.common.settings.ModSettings; +import xaero.hud.minimap.module.MinimapSession; import xaeroplus.feature.extensions.CustomWaypointsIngameRenderer; import xaeroplus.settings.XaeroPlusSettingRegistry; +import xaeroplus.util.ChunkUtils; import xaeroplus.util.ColorHelper; import java.util.ArrayList; @@ -43,6 +49,7 @@ import java.util.stream.Collectors; import static net.minecraft.client.renderer.blockentity.BeaconRenderer.BEAM_LOCATION; +import static net.minecraft.world.level.Level.NETHER; @Mixin(value = WaypointsIngameRenderer.class, remap = false) public class MixinWaypointsIngameRenderer implements CustomWaypointsIngameRenderer { @@ -79,8 +86,22 @@ public boolean test(final Waypoint w) { } }; + @Inject(method = "render", at = @At( + value = "INVOKE", + target = "Lxaero/common/minimap/waypoints/render/WaypointDeleter;begin()V" + )) + public void preferOwWaypointsRemoveSubworldText(final MinimapSession session, final float partial, final MinimapProcessor minimap, final Matrix4f waypointsProjection, final Matrix4f worldModelView, final CallbackInfo ci, + @Local(name = "subworldName") LocalRef subWorldNameRef) { + if (!XaeroPlusSettingRegistry.owAutoWaypointDimension.getValue()) return; + if (subWorldNameRef.get() == null) return; + ResourceKey actualDimension = ChunkUtils.getActualDimension(); + if (actualDimension == NETHER) { + subWorldNameRef.set(null); + } + } + @Inject(method = "renderWaypointsIterator", at = @At("HEAD")) - public void injectRenderWaypoints(final PoseStack matrixStack, final PoseStack matrixStackOverlay, final MinimapRendererHelper helper, final Iterator iter, final double d3, final double d4, final double d5, final Entity entity, final BufferBuilder bufferbuilder, final Tesselator tessellator, final double dimDiv, final double actualEntityX, final double actualEntityY, final double actualEntityZ, final double smoothEntityY, final double fov, final int screenHeight, final float cameraAngleYaw, final float cameraAnglePitch, final Vector3f lookVector, final double clampDepth, final MultiBufferSource.BufferSource renderTypeBuffer, final VertexConsumer waypointBackgroundConsumer, final Font fontrenderer, final Matrix4f waypointsProjection, final int screenWidth, final boolean detailedDisplayAllowed, final double minDistance, final String subworldName, final CallbackInfo ci) { + public void collectBeaconWaypointsList(final PoseStack matrixStack, final PoseStack matrixStackOverlay, final MinimapRendererHelper helper, final Iterator iter, final double d3, final double d4, final double d5, final Entity entity, final BufferBuilder bufferbuilder, final Tesselator tessellator, final double dimDiv, final double actualEntityX, final double actualEntityY, final double actualEntityZ, final double smoothEntityY, final double fov, final int screenHeight, final float cameraAngleYaw, final float cameraAnglePitch, final Vector3f lookVector, final double clampDepth, final MultiBufferSource.BufferSource renderTypeBuffer, final VertexConsumer waypointBackgroundConsumer, final Font fontrenderer, final Matrix4f waypointsProjection, final int screenWidth, final boolean detailedDisplayAllowed, final double minDistance, final String subworldName, final CallbackInfo ci) { beaconWaypoints = sortingList.stream().filter(beaconViewFilter).sorted().collect(Collectors.toList()); } @@ -93,6 +114,7 @@ public void renderWaypointBeacons(final XaeroMinimapSession minimapSession, fina beaconWaypoints.clear(); } + @Unique public void renderWaypointBeacon(final Waypoint waypoint, final double dimDiv, float tickDelta, PoseStack matrixStack) { final Minecraft mc = Minecraft.getInstance(); if (mc.level == null || mc.player == null) return; diff --git a/common/src/main/java/xaeroplus/mixin/client/MixinWaypointsManager.java b/common/src/main/java/xaeroplus/mixin/client/MixinWaypointsManager.java deleted file mode 100644 index 544dd178..00000000 --- a/common/src/main/java/xaeroplus/mixin/client/MixinWaypointsManager.java +++ /dev/null @@ -1,102 +0,0 @@ -package xaeroplus.mixin.client; - -import com.llamalad7.mixinextras.sugar.Local; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screens.Screen; -import net.minecraft.client.multiplayer.ClientPacketListener; -import net.minecraft.resources.ResourceKey; -import net.minecraft.world.level.Level; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import xaero.common.minimap.waypoints.Waypoint; -import xaero.common.minimap.waypoints.WaypointWorld; -import xaero.common.minimap.waypoints.WaypointsManager; -import xaeroplus.Globals; -import xaeroplus.feature.extensions.IWaypointDimension; -import xaeroplus.settings.XaeroPlusSettingRegistry; -import xaeroplus.util.DataFolderResolveUtil; - -import static net.minecraft.world.level.Level.NETHER; -import static net.minecraft.world.level.Level.OVERWORLD; - -@Mixin(value = WaypointsManager.class, remap = false) -public abstract class MixinWaypointsManager { - @Unique Waypoint selected = null; - @Unique WaypointWorld displayedWorld = null; - @Shadow private Minecraft mc; - @Shadow private String mainContainerID; - @Shadow private String containerIDIgnoreCaseCache; - @Shadow public abstract String ignoreContainerCase(String potentialContainerID, String current); - @Shadow public abstract String getDimensionDirectoryName(ResourceKey dimKey); - - @Inject(method = "getMainContainer(ILnet/minecraft/client/multiplayer/ClientPacketListener;)Ljava/lang/String;", - at = @At("HEAD"), - cancellable = true, - remap = true) // $REMAP - private void getMainContainer(final int version, final ClientPacketListener connection, final CallbackInfoReturnable cir) { - DataFolderResolveUtil.resolveDataFolder(connection, cir); - } - - @Inject( - method = "teleportToWaypoint(Lxaero/common/minimap/waypoints/Waypoint;Lxaero/common/minimap/waypoints/WaypointWorld;Lnet/minecraft/client/gui/screens/Screen;Z)V", - at = @At("HEAD"), - remap = true) // $REMAP - public void teleportToWaypointHead(final Waypoint selected, final WaypointWorld displayedWorld, final Screen screen, final boolean respectHiddenCoords, final CallbackInfo ci) { - this.selected = selected; - this.displayedWorld = displayedWorld; - } - - @Redirect( - method = "teleportToWaypoint(Lxaero/common/minimap/waypoints/Waypoint;Lxaero/common/minimap/waypoints/WaypointWorld;Lnet/minecraft/client/gui/screens/Screen;Z)V", - at = @At( - value = "INVOKE", - target = "Lxaero/common/minimap/waypoints/WaypointsManager;getAutoWorld()Lxaero/common/minimap/waypoints/WaypointWorld;" - ), - remap = true) // $REMAP - public WaypointWorld getAutoWorldRedirect(final WaypointsManager instance) { - if (!XaeroPlusSettingRegistry.owAutoWaypointDimension.getValue()) return instance.getAutoWorld(); - ResourceKey waypointDimension = ((IWaypointDimension) selected).getDimension(); - if (waypointDimension != Globals.getCurrentDimensionId()) { - return null; - } else { - return instance.getAutoWorld(); - } - } - - @Inject(method = "getPotentialContainerID", at = @At("HEAD"), cancellable = true) - private void getPotentialContainerID(CallbackInfoReturnable cir) { - if (!XaeroPlusSettingRegistry.owAutoWaypointDimension.getValue()) return; - ResourceKey dimension = mc.level.dimension(); - if (dimension == OVERWORLD || dimension == NETHER) { - dimension = OVERWORLD; - } - cir.setReturnValue(this.ignoreContainerCase( - this.mainContainerID + "/" + this.getDimensionDirectoryName(dimension), this.containerIDIgnoreCaseCache) - ); - } - - - @Inject( - method = "createTemporaryWaypoints(Lxaero/common/minimap/waypoints/WaypointWorld;IIIZD)V", - at = @At( - value = "INVOKE", - target = "Lxaero/common/IXaeroMinimap;getSettings()Lxaero/common/settings/ModSettings;", - ordinal = 1 - )) - public void createTempWaypointInject(final WaypointWorld wpw, - final int x, - final int y, - final int z, - final boolean yIncluded, - final double dimScale, - final CallbackInfo ci, - @Local Waypoint waypoint) { - ((IWaypointDimension) waypoint).setDimension(wpw.getDimId()); - } -} diff --git a/common/src/main/java/xaeroplus/module/impl/BaritoneGoalSync.java b/common/src/main/java/xaeroplus/module/impl/BaritoneGoalSync.java index b072af63..3a747f54 100644 --- a/common/src/main/java/xaeroplus/module/impl/BaritoneGoalSync.java +++ b/common/src/main/java/xaeroplus/module/impl/BaritoneGoalSync.java @@ -5,100 +5,67 @@ import baritone.api.utils.interfaces.IGoalRenderPos; import net.lenni0451.lambdaevents.EventHandler; import net.minecraft.core.BlockPos; -import net.minecraft.resources.ResourceKey; -import net.minecraft.world.level.Level; -import xaero.common.XaeroMinimapSession; +import net.minecraft.resources.ResourceLocation; import xaero.common.minimap.waypoints.Waypoint; -import xaero.common.minimap.waypoints.WaypointSet; -import xaero.common.minimap.waypoints.WaypointWorld; -import xaero.common.minimap.waypoints.WaypointsManager; import xaero.common.misc.OptimizedMath; -import xaero.map.mods.SupportMods; -import xaeroplus.Globals; +import xaero.hud.minimap.BuiltInHudModules; +import xaero.hud.minimap.module.MinimapSession; +import xaero.hud.minimap.waypoint.set.WaypointSet; +import xaero.hud.minimap.world.MinimapWorld; import xaeroplus.event.ClientTickEvent; -import xaeroplus.feature.extensions.IWaypointDimension; import xaeroplus.module.Module; import xaeroplus.util.BaritoneGoalHelper; import xaeroplus.util.BaritoneHelper; -import xaeroplus.util.ChunkUtils; - -import java.util.List; -import java.util.Optional; - -import static net.minecraft.world.level.Level.NETHER; -import static net.minecraft.world.level.Level.OVERWORLD; public class BaritoneGoalSync extends Module { + final ResourceLocation XP = new ResourceLocation("xaeroplus"); @EventHandler public void onClientTickEvent(final ClientTickEvent.Post event) { if (!BaritoneHelper.isBaritonePresent()) return; - XaeroMinimapSession minimapSession = XaeroMinimapSession.getCurrentSession(); + MinimapSession minimapSession = BuiltInHudModules.MINIMAP.getCurrentSession(); if (minimapSession == null) return; - final WaypointsManager waypointsManager = minimapSession.getWaypointsManager(); - WaypointSet waypointSet = waypointsManager.getWaypoints(); - if (waypointSet == null) return; - WaypointWorld waypointWorld = waypointsManager.getCurrentWorld(); - if (waypointWorld == null) return; - final List waypoints = waypointSet.getList(); - Optional baritoneGoalWaypoint = waypoints.stream() - .filter(waypoint -> waypoint.getName().equals("Baritone Goal")) - .findFirst(); + MinimapWorld currentWorld = minimapSession.getWorldManager().getCurrentWorld(); + if (currentWorld == null) return; + WaypointSet currentWaypointSet = currentWorld.getCurrentWaypointSet(); + Waypoint currentBaritoneWp = null; + for (var wp : currentWaypointSet.getWaypoints()) { + if (wp.getName().equals("Baritone Goal")) { + currentBaritoneWp = wp; + break; + } + } + boolean baritoneWpExists = currentBaritoneWp != null; final Goal goal = BaritoneGoalHelper.getBaritoneGoal(); if (goal == null) { - baritoneGoalWaypoint.ifPresent(waypoint -> removeBaritoneGoalWaypoint(waypoints, waypoint)); + if (baritoneWpExists) currentWaypointSet.remove(currentBaritoneWp); return; } final BlockPos baritoneGoalBlockPos = getBaritoneGoalBlockPos(goal); if (baritoneGoalBlockPos == null) { - baritoneGoalWaypoint.ifPresent(waypoint -> removeBaritoneGoalWaypoint(waypoints, waypoint)); + if (baritoneWpExists) currentWaypointSet.remove(currentBaritoneWp); return; - }; - final double dimDiv = waypointsManager.getDimensionDivision(waypointWorld); - final int x = OptimizedMath.myFloor(baritoneGoalBlockPos.getX() * dimDiv); - final int z = OptimizedMath.myFloor(baritoneGoalBlockPos.getZ() * dimDiv); - if (baritoneGoalWaypoint.isPresent()) { - final Waypoint waypoint = baritoneGoalWaypoint.get(); - ResourceKey customDim = Globals.getCurrentDimensionId(); - ResourceKey actualDim = ChunkUtils.getActualDimension(); - double customDimDiv = 1.0; - if (customDim != actualDim) { - if (customDim == NETHER && actualDim == OVERWORLD) { - customDimDiv = 0.125; - } else if (customDim == OVERWORLD && actualDim == NETHER) { - customDimDiv = 8.0; - } - } - int expectedX = (int) (x * customDimDiv); - int expectedZ = (int) (z * customDimDiv); - if (waypoint.getX() != expectedX || - waypoint.getY() != baritoneGoalBlockPos.getY() || - waypoint.getZ() != expectedZ) { - waypoint.setX(expectedX); - waypoint.setY(baritoneGoalBlockPos.getY()); - waypoint.setZ(expectedZ); - SupportMods.xaeroMinimap.requestWaypointsRefresh(); - } - } else { - final Waypoint waypoint = new Waypoint( - x, - baritoneGoalBlockPos.getY(), - z, - "Baritone Goal", - "B", - 10, // green - 0, - true); - ((IWaypointDimension) waypoint).setDimension(waypointWorld.getDimId()); - waypoints.add(waypoint); - SupportMods.xaeroMinimap.requestWaypointsRefresh(); } - } - - private void removeBaritoneGoalWaypoint(List waypoints, Waypoint waypoint) { - if (waypoints.remove(waypoint)) { - SupportMods.xaeroMinimap.requestWaypointsRefresh(); + // todo: this no longer has no idea about the baritone goal's dimension + // so the dim div will be completely off if the player has a wp set of nether open in the ow and visa versa + final int x = OptimizedMath.myFloor(baritoneGoalBlockPos.getX()); + final int z = OptimizedMath.myFloor(baritoneGoalBlockPos.getZ()); + if (baritoneWpExists) { + currentBaritoneWp.setX(x); + currentBaritoneWp.setY(baritoneGoalBlockPos.getY()); + currentBaritoneWp.setZ(z); + } else { + final Waypoint waypoint = new Waypoint( + x, + baritoneGoalBlockPos.getY(), + z, + "Baritone Goal", + "B", + 10, // green + 0, + true); + currentWaypointSet.add(waypoint); } } diff --git a/common/src/main/java/xaeroplus/module/impl/WaystoneSync.java b/common/src/main/java/xaeroplus/module/impl/WaystoneSync.java index b2d8b79c..41feafa5 100644 --- a/common/src/main/java/xaeroplus/module/impl/WaystoneSync.java +++ b/common/src/main/java/xaeroplus/module/impl/WaystoneSync.java @@ -4,18 +4,21 @@ import net.lenni0451.lambdaevents.EventHandler; import net.minecraft.resources.ResourceKey; import net.minecraft.world.level.Level; -import xaero.common.XaeroMinimapSession; -import xaero.common.minimap.waypoints.*; -import xaero.map.mods.SupportMods; +import xaero.common.minimap.waypoints.Waypoint; +import xaero.hud.minimap.BuiltInHudModules; +import xaero.hud.minimap.module.MinimapSession; +import xaero.hud.minimap.waypoint.set.WaypointSet; +import xaero.hud.minimap.world.MinimapWorld; +import xaero.hud.minimap.world.MinimapWorldManager; +import xaero.hud.path.XaeroPath; import xaeroplus.XaeroPlus; import xaeroplus.event.ClientTickEvent; import xaeroplus.event.XaeroWorldChangeEvent; -import xaeroplus.feature.extensions.IWaypointDimension; +import xaeroplus.mixin.client.AccessorWaypointSet; import xaeroplus.module.Module; import xaeroplus.util.BlayWaystonesHelper; import xaeroplus.util.ColorHelper.WaystoneColor; import xaeroplus.util.FabricWaystonesHelper; -import xaeroplus.util.WaypointsHelper; import xaeroplus.util.WaystonesHelper; import java.util.*; @@ -79,32 +82,30 @@ public boolean syncBlayWaystones() { public boolean commonWaystoneSync(final List waystones) { try { - XaeroMinimapSession minimapSession = XaeroMinimapSession.getCurrentSession(); + MinimapSession minimapSession = BuiltInHudModules.MINIMAP.getCurrentSession(); if (minimapSession == null) return false; - final WaypointsManager waypointsManager = minimapSession.getWaypointsManager(); - WaypointSet waypointSet = waypointsManager.getWaypoints(); - if (waypointSet == null) return false; - final String currentContainerId = waypointsManager.getCurrentContainerID(); - if (waypointsManager.getCurrentWorld() == null) return false; + MinimapWorldManager worldManager = minimapSession.getWorldManager(); + if (worldManager == null) return false; + MinimapWorld currentWorld = worldManager.getCurrentWorld(); + if (currentWorld == null) return false; + Map waystoneToWaypointSet = waystones.stream() + .collect(Collectors.toMap((k1) -> k1, + (v1) -> getWaypointsList(v1, minimapSession), + (v1, v2) -> v1)); // iterate over ALL waypoint sets and lists and remove waystones // todo: this doesn't iterate over dims/set permutations where we have no waystones at all - // there isn't a great interface xaero provides to get all permutations unfortunately - this already has lots of hacks - final Map> waypointToWaypointsList = waystones.stream() - .collect(Collectors.toMap((k1) -> k1, - (v1) -> getWaypointsList(v1, waypointsManager, currentContainerId), - (v1, v2) -> v1)); - for (List waypointsList : new HashSet<>(waypointToWaypointsList.values())) { - waypointsList.removeIf(waypoint -> waypoint.isTemporary() && waypoint.getName().endsWith(" [Waystone]")); + for (var waypointSet : new HashSet<>(waystoneToWaypointSet.values())) { + List list = ((AccessorWaypointSet) waypointSet).getList(); + list.removeIf(waypoint -> waypoint.isTemporary() && waypoint.getName().endsWith(" [Waystone]")); } - for (Map.Entry> entry : waypointToWaypointsList.entrySet()) { + for (var entry : waystoneToWaypointSet.entrySet()) { try { waypointsListSync(entry.getKey(), entry.getValue()); } catch (final Exception e) { XaeroPlus.LOGGER.error("Error syncing waystone: {}", entry.getKey().name(), e); } } - SupportMods.xaeroMinimap.requestWaypointsRefresh(); return true; } catch (Exception e) { XaeroPlus.LOGGER.error("Error syncing waystones", e); @@ -112,7 +113,7 @@ public boolean commonWaystoneSync(final List waystones) { } } - private void waypointsListSync(final Waystone waystone, final List waypointsList) { + private void waypointsListSync(final Waystone waystone, final WaypointSet waypointsList) { Waypoint waystoneWp = new Waypoint( waystone.x(), waystone.y(), @@ -126,52 +127,37 @@ private void waypointsListSync(final Waystone waystone, final List way true ); waystoneWp.setVisibilityType(visibilityType); - ((IWaypointDimension) waystoneWp).setDimension(waystone.dimension()); waypointsList.add(waystoneWp); } - private List getWaypointsList(final Waystone waystone, - final WaypointsManager waypointsManager, - final String currentContainerId) { + private WaypointSet getWaypointsList(final Waystone waystone, final MinimapSession minimapSession) { final String waypointSetName = this.separateWaypointSet ? "Waystones" : "gui.xaero_default"; - final WaypointWorld waypointWorld = getWaypointWorldForWaystone(waystone, waypointsManager, currentContainerId); - WaypointSet waypointSet = waypointWorld.getSets().get(waypointSetName); + final MinimapWorld waypointWorld = getWaypointWorldForWaystone(waystone, minimapSession); + WaypointSet waypointSet = waypointWorld.getWaypointSet(waypointSetName); if (waypointSet == null) { - waypointWorld.getSets().put(waypointSetName, new WaypointSet(waypointSetName)); - waypointSet = waypointWorld.getSets().get(waypointSetName); + waypointSet = WaypointSet.Builder.begin().setName(waypointSetName).build(); + waypointWorld.addWaypointSet(waypointSet); } - return waypointSet.getList(); + return waypointSet; } - private WaypointWorld getWaypointWorldForWaystone(final Waystone waystone, - final WaypointsManager waypointsManager, - final String currentContainerId) { - final ResourceKey waystoneDimension = waystone.dimension(); - final String waystoneDimensionDirectoryName = waypointsManager.getDimensionDirectoryName(waystoneDimension); - final int waystoneDim = WaypointsHelper.getDimensionForWaypointWorldKey(waystoneDimensionDirectoryName); - final WaypointWorld currentWpWorld = waypointsManager.getCurrentWorld(); + private MinimapWorld getWaypointWorldForWaystone(final Waystone waystone, + MinimapSession minimapSession) { + ResourceKey waystoneDimension = waystone.dimension(); + String waystoneDimensionDirectoryName = minimapSession.getDimensionHelper().getDimensionDirectoryName(waystoneDimension); + MinimapWorld currentWpWorld = minimapSession.getWorldManager().getCurrentWorld(); if (currentWpWorld == null) { throw new RuntimeException("WaystoneSync: current waypoint world is null"); } if (currentWpWorld.getDimId() == waystoneDimension) { return currentWpWorld; } - final String worldContainerSuffix; - if (waystoneDim == Integer.MIN_VALUE) // non-vanilla dimensions - worldContainerSuffix = waystoneDimension.location().getNamespace() + "$" + waystoneDimension.location().getPath().replace("/", "%"); - else - // this is a crapshoot - // waypoint containers have no single naming scheme. this can change depending on the server, the world, and the dimension - worldContainerSuffix = String.valueOf(waystoneDim); - final WaypointWorldContainer waypointWorldContainer = waypointsManager.getWorldContainer(currentContainerId.substring( - 0, - currentContainerId.lastIndexOf(37) + 1) + worldContainerSuffix); - WaypointWorld crossDimWaypointWorld = waypointWorldContainer.worlds.get(currentWpWorld.getId()); - if (crossDimWaypointWorld == null) { - waypointWorldContainer.worlds.put(currentWpWorld.getId(), new WaypointWorld(waypointWorldContainer, currentWpWorld.getId(), waystoneDimension)); - crossDimWaypointWorld = waypointWorldContainer.worlds.get(currentWpWorld.getId()); - } - return crossDimWaypointWorld; + String waystoneWpWorldNode = minimapSession.getWorldStateUpdater().getPotentialWorldNode(waystoneDimension, true, minimapSession); + XaeroPath waystoneWpContainerPath = minimapSession.getWorldState() + .getAutoRootContainerPath() + .resolve(waystoneDimensionDirectoryName) + .resolve(waystoneWpWorldNode); + return minimapSession.getWorldManager().getWorld(waystoneWpContainerPath); } private int getWaystoneColor(Waystone waystone) { diff --git a/common/src/main/java/xaeroplus/util/DataFolderResolveUtil.java b/common/src/main/java/xaeroplus/util/DataFolderResolveUtil.java index fefdc434..2444e7ac 100644 --- a/common/src/main/java/xaeroplus/util/DataFolderResolveUtil.java +++ b/common/src/main/java/xaeroplus/util/DataFolderResolveUtil.java @@ -26,7 +26,7 @@ public static void resolveDataFolder(final ClientPacketListener connection, fina if (dataFolderResolutionMode == XaeroPlusSettingRegistry.DataFolderResolutionMode.SERVER_NAME) { if (nonNull(connection.getServerData())) { String serverName = connection.getServerData().name; - if (serverName.length() > 0) { + if (!serverName.isEmpty()) { // use common directories based on server list name instead of IP // good for proxies cir.setReturnValue(sanitizeDataFolderName("Multiplayer_" + serverName)); diff --git a/common/src/main/java/xaeroplus/util/WaypointsHelper.java b/common/src/main/java/xaeroplus/util/WaypointsHelper.java deleted file mode 100644 index 6973df26..00000000 --- a/common/src/main/java/xaeroplus/util/WaypointsHelper.java +++ /dev/null @@ -1,18 +0,0 @@ -package xaeroplus.util; - -public class WaypointsHelper { - public static int getDimensionForWaypointWorldKey(final String waypointWorldKey) { - String dimIdPart = waypointWorldKey.substring(waypointWorldKey.lastIndexOf(47) + 1).substring(4); - if (!dimIdPart.matches("-{0,1}[0-9]+")) { - return Integer.MIN_VALUE; - } else { - int dimId; - try { - dimId = Integer.parseInt(dimIdPart); - } catch (NumberFormatException var5) { - return Integer.MIN_VALUE; - } - return dimId; - } - } -} diff --git a/common/src/main/resources/xaeroplus.mixins.json b/common/src/main/resources/xaeroplus.mixins.json index 7d505ee4..91435ddf 100644 --- a/common/src/main/resources/xaeroplus.mixins.json +++ b/common/src/main/resources/xaeroplus.mixins.json @@ -11,6 +11,7 @@ "AccessorGuiWaypoints", "AccessorMinimapModOptions", "AccessorRightClickOption", + "AccessorWaypointSet", "AccessorWidgetScreenHandler", "AccessorWorldMapModOptions", "AccessorWorldMapScreenSwitchSettingEntry", @@ -20,14 +21,12 @@ "MixinControlsHandler", "MixinCrashHandler", "MixinDimensionHighlighterHandler", - "MixinGuiAddWaypoint", "MixinGuiEntityRadarSettings", "MixinGuiMap", "MixinGuiMinimapMain", "MixinGuiMinimapOverlaysSettings", "MixinGuiSettingsWorldMap", "MixinGuiUpdateAll", - "MixinGuiWaypoint", "MixinGuiWaypoints", "MixinGuiWaypointSettings", "MixinGuiWaypointsList", @@ -50,6 +49,7 @@ "MixinMinimapOption", "MixinMinimapRenderer", "MixinMinimapViewSettings", + "MixinMinimapWorldStateUpdater", "MixinMinimapWriter", "MixinMisc", "MixinModClientEvents", @@ -59,11 +59,9 @@ "MixinRadarRenderProvider", "MixinSupportXaeroMinimap", "MixinSupportXaeroWorldmap", - "MixinWaypoint", "MixinWaypointReader", "MixinWaypointSharingHandler", "MixinWaypointsIngameRenderer", - "MixinWaypointsManager", "MixinWidgetLoadingHandler", "MixinWorldDataReader", "MixinWorldMapGuiSettings", diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index 67ddd9e0..0402f9e3 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -40,7 +40,7 @@ dependencies { implementation(libs.sqlite) modImplementation(libs.worldmap.fabric) modImplementation(libs.minimap.fabric) - modCompileOnly(files("libs/baritone-api-fabric-1.20.1-elytra-beta-v1.jar")) + modImplementation(files("libs/baritone-api-fabric-1.20.1-elytra-beta-v1.jar")) modCompileOnly(files("libs/sodium-fabric-1.20.1-0.6.0-alpha.2.jar")) modImplementation(libs.waystones.fabric) modImplementation(libs.balm.fabric) diff --git a/settings.gradle.kts b/settings.gradle.kts index 7047fac1..2ab252aa 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -8,7 +8,7 @@ pluginManagement { } } gradle.extra.apply { - set("mod_version", "2.23") + set("mod_version", "2.23.1") set("maven_group", "xaeroplus") set("archives_base_name", "XaeroPlus") set("minecraft_version", "1.20.1") @@ -17,9 +17,9 @@ gradle.extra.apply { set("fabric_api_version", "0.92.2+1.20.1") set("forge_loader_version", "47.3.5") set("worldmap_version_fabric", "1.39.0") - set("minimap_version_fabric", "24.3.0") + set("minimap_version_fabric", "24.4.0") set("worldmap_version_forge", "1.39.0") - set("minimap_version_forge", "24.3.0") + set("minimap_version_forge", "24.4.0") } dependencyResolutionManagement { From d6f9f942de49dd5a77e8e285c986b684fbe06f2b Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Mon, 2 Sep 2024 15:54:28 -0700 Subject: [PATCH 3/3] hide custom subworld mm text when Prefer Waypoints enabled --- .../client/MixinBuiltInInfoDisplays.java | 30 +++++++++++++++++++ .../client/MixinWaypointsIngameRenderer.java | 4 ++- .../src/main/resources/xaeroplus.mixins.json | 1 + 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 common/src/main/java/xaeroplus/mixin/client/MixinBuiltInInfoDisplays.java diff --git a/common/src/main/java/xaeroplus/mixin/client/MixinBuiltInInfoDisplays.java b/common/src/main/java/xaeroplus/mixin/client/MixinBuiltInInfoDisplays.java new file mode 100644 index 00000000..452f6de1 --- /dev/null +++ b/common/src/main/java/xaeroplus/mixin/client/MixinBuiltInInfoDisplays.java @@ -0,0 +1,30 @@ +package xaeroplus.mixin.client; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.llamalad7.mixinextras.sugar.Local; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.Level; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import xaero.common.minimap.info.BuiltInInfoDisplays; +import xaero.common.minimap.info.render.compile.InfoDisplayCompiler; +import xaero.hud.minimap.world.MinimapWorld; +import xaeroplus.settings.XaeroPlusSettingRegistry; +import xaeroplus.util.ChunkUtils; + +@Mixin(value = BuiltInInfoDisplays.class, remap = false) +public class MixinBuiltInInfoDisplays { + + @WrapOperation(method = "lambda$static$13", at = @At( + value = "INVOKE", + target = "Lxaero/common/minimap/info/render/compile/InfoDisplayCompiler;addWords(ILjava/lang/String;)V")) + private static void hideAutoSubworldInfoWhenOwAutoWaypointsEnabled(final InfoDisplayCompiler instance, final int lineWidth, final String text, final Operation original, + @Local(name = "currentWorld") MinimapWorld currentWorld) { + if (XaeroPlusSettingRegistry.owAutoWaypointDimension.getValue()) { + ResourceKey actualDimension = ChunkUtils.getActualDimension(); + if (actualDimension == Level.NETHER && currentWorld.getDimId() == Level.OVERWORLD) return; + } + original.call(instance, lineWidth, text); + } +} diff --git a/common/src/main/java/xaeroplus/mixin/client/MixinWaypointsIngameRenderer.java b/common/src/main/java/xaeroplus/mixin/client/MixinWaypointsIngameRenderer.java index 603fd7f2..79a3e51b 100644 --- a/common/src/main/java/xaeroplus/mixin/client/MixinWaypointsIngameRenderer.java +++ b/common/src/main/java/xaeroplus/mixin/client/MixinWaypointsIngameRenderer.java @@ -50,6 +50,7 @@ import static net.minecraft.client.renderer.blockentity.BeaconRenderer.BEAM_LOCATION; import static net.minecraft.world.level.Level.NETHER; +import static net.minecraft.world.level.Level.OVERWORLD; @Mixin(value = WaypointsIngameRenderer.class, remap = false) public class MixinWaypointsIngameRenderer implements CustomWaypointsIngameRenderer { @@ -95,7 +96,8 @@ public void preferOwWaypointsRemoveSubworldText(final MinimapSession session, fi if (!XaeroPlusSettingRegistry.owAutoWaypointDimension.getValue()) return; if (subWorldNameRef.get() == null) return; ResourceKey actualDimension = ChunkUtils.getActualDimension(); - if (actualDimension == NETHER) { + ResourceKey currentWpWorldDim = session.getWorldManager().getCurrentWorld().getDimId(); + if (actualDimension == NETHER && currentWpWorldDim == OVERWORLD) { subWorldNameRef.set(null); } } diff --git a/common/src/main/resources/xaeroplus.mixins.json b/common/src/main/resources/xaeroplus.mixins.json index 91435ddf..80b0a222 100644 --- a/common/src/main/resources/xaeroplus.mixins.json +++ b/common/src/main/resources/xaeroplus.mixins.json @@ -15,6 +15,7 @@ "AccessorWidgetScreenHandler", "AccessorWorldMapModOptions", "AccessorWorldMapScreenSwitchSettingEntry", + "MixinBuiltInInfoDisplays", "MixinClientEvents", "MixinCommonGuiSettings", "MixinCommonInternet",