From 5e8e73078e2a3e6fb1066b24c0df305564ef6ae0 Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Mon, 2 Sep 2024 16:40:41 -0700 Subject: [PATCH] cleanup --- .../CustomWaypointsIngameRenderer.java | 4 +- ...nMinimapElementOverMapRendererHandler.java | 4 +- .../mixin/client/MixinMinimapFBORenderer.java | 10 +-- .../mixin/client/MixinMinimapWriter.java | 8 +-- .../client/MixinRadarRenderProvider.java | 4 +- .../client/MixinWaypointsIngameRenderer.java | 68 +++++++++---------- .../mixin/client/mc/MixinWorldRenderer.java | 16 ++++- .../module/impl/BaritoneGoalSync.java | 4 +- 8 files changed, 58 insertions(+), 60 deletions(-) diff --git a/common/src/main/java/xaeroplus/feature/extensions/CustomWaypointsIngameRenderer.java b/common/src/main/java/xaeroplus/feature/extensions/CustomWaypointsIngameRenderer.java index 3ebd4536..37ecd0e6 100644 --- a/common/src/main/java/xaeroplus/feature/extensions/CustomWaypointsIngameRenderer.java +++ b/common/src/main/java/xaeroplus/feature/extensions/CustomWaypointsIngameRenderer.java @@ -1,8 +1,8 @@ package xaeroplus.feature.extensions; import com.mojang.blaze3d.vertex.PoseStack; -import xaero.common.XaeroMinimapSession; +import xaero.hud.minimap.module.MinimapSession; public interface CustomWaypointsIngameRenderer { - void renderWaypointBeacons(final XaeroMinimapSession minimapSession, final PoseStack matrixStack, final float tickDelta); + void renderWaypointBeacons(final MinimapSession minimapSession, final PoseStack matrixStack, final float tickDelta); } diff --git a/common/src/main/java/xaeroplus/mixin/client/MixinMinimapElementOverMapRendererHandler.java b/common/src/main/java/xaeroplus/mixin/client/MixinMinimapElementOverMapRendererHandler.java index af9f007e..918a63af 100644 --- a/common/src/main/java/xaeroplus/mixin/client/MixinMinimapElementOverMapRendererHandler.java +++ b/common/src/main/java/xaeroplus/mixin/client/MixinMinimapElementOverMapRendererHandler.java @@ -9,12 +9,12 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -import xaero.common.XaeroMinimapSession; import xaero.common.minimap.element.render.MinimapElementRenderer; import xaero.common.minimap.element.render.over.MinimapElementOverMapRendererHandler; import xaero.common.minimap.render.MinimapRendererHelper; import xaero.common.minimap.render.radar.element.RadarRenderContext; import xaero.common.minimap.render.radar.element.RadarRenderer; +import xaero.hud.HudSession; import xaeroplus.Globals; @Mixin(value = MinimapElementOverMapRendererHandler.class, remap = false) @@ -47,7 +47,7 @@ public boolean redirectRenderElement(final MinimapElementRenderer instance, final boolean cave, final float partialTicks) { if (instance instanceof RadarRenderer) { - ((RadarRenderContext) instance.getContext()).nameScale = XaeroMinimapSession.getCurrentSession().getModMain().getSettings().getDotNameScale(); + ((RadarRenderContext) instance.getContext()).nameScale = HudSession.getCurrentSession().getHudMod().getSettings().getDotNameScale(); return instance.renderElement(location, highlit, outOfBounds, drawContext, immediate, fontRenderer, framebuffer, minimapRendererHelper, renderEntity, entityPlayer, renderX, renderY, renderZ, elementIndex, optionalDepth, diff --git a/common/src/main/java/xaeroplus/mixin/client/MixinMinimapFBORenderer.java b/common/src/main/java/xaeroplus/mixin/client/MixinMinimapFBORenderer.java index dd2b9b7c..30080fd0 100644 --- a/common/src/main/java/xaeroplus/mixin/client/MixinMinimapFBORenderer.java +++ b/common/src/main/java/xaeroplus/mixin/client/MixinMinimapFBORenderer.java @@ -16,12 +16,10 @@ 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.CustomRenderTypes; import xaero.common.graphics.CustomVertexConsumers; import xaero.common.graphics.ImprovedFramebuffer; import xaero.common.graphics.shader.MinimapShaders; -import xaero.common.minimap.MinimapInterface; import xaero.common.minimap.MinimapProcessor; import xaero.common.minimap.render.MinimapFBORenderer; import xaero.common.minimap.render.MinimapRenderer; @@ -29,6 +27,8 @@ import xaero.common.minimap.waypoints.render.CompassRenderer; import xaero.common.minimap.waypoints.render.WaypointsGuiRenderer; import xaero.common.misc.OptimizedMath; +import xaero.hud.minimap.BuiltInHudModules; +import xaero.hud.minimap.Minimap; import xaero.hud.minimap.MinimapLogs; import xaero.hud.minimap.module.MinimapSession; import xaeroplus.Globals; @@ -46,8 +46,8 @@ public abstract class MixinMinimapFBORenderer extends MinimapRenderer implements @Shadow private boolean loadedFBO; - public MixinMinimapFBORenderer(final IXaeroMinimap modMain, final Minecraft mc, final WaypointsGuiRenderer waypointsGuiRenderer, final MinimapInterface minimapInterface, final CompassRenderer compassRenderer) { - super(modMain, mc, waypointsGuiRenderer, minimapInterface, compassRenderer); + public MixinMinimapFBORenderer(final IXaeroMinimap modMain, final Minecraft mc, final WaypointsGuiRenderer waypointsGuiRenderer, final Minimap minimap, final CompassRenderer compassRenderer) { + super(modMain, mc, waypointsGuiRenderer, minimap, compassRenderer); } @ModifyConstant(method = "loadFrameBuffer", constant = @Constant(intValue = 512)) @@ -57,7 +57,7 @@ public int overrideFrameBufferSize(int size) { @Override public void reloadMapFrameBuffers() { - if (!XaeroMinimapSession.getCurrentSession().getMinimapProcessor().canUseFrameBuffer()) { + if (!BuiltInHudModules.MINIMAP.getCurrentSession().getProcessor().canUseFrameBuffer()) { MinimapLogs.LOGGER.info("FBO mode not supported! Using minimap safe mode."); } else { if (this.scalingFramebuffer != null) diff --git a/common/src/main/java/xaeroplus/mixin/client/MixinMinimapWriter.java b/common/src/main/java/xaeroplus/mixin/client/MixinMinimapWriter.java index 61ea750c..85c92b43 100644 --- a/common/src/main/java/xaeroplus/mixin/client/MixinMinimapWriter.java +++ b/common/src/main/java/xaeroplus/mixin/client/MixinMinimapWriter.java @@ -1,21 +1,17 @@ package xaeroplus.mixin.client; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.Constant; import org.spongepowered.asm.mixin.injection.ModifyConstant; -import xaero.common.minimap.MinimapInterface; +import xaero.common.HudMod; import xaero.common.minimap.write.MinimapWriter; import xaeroplus.Globals; @Mixin(value = MinimapWriter.class, remap = false) public class MixinMinimapWriter { - - @Shadow private MinimapInterface minimapInterface; - @ModifyConstant(method = "getLoadSide", constant = @Constant(intValue = 9)) public int overrideLoadSide(final int constant) { - if (this.minimapInterface.usingFBO()) { + if (HudMod.INSTANCE.getMinimap().usingFBO()) { return constant * Globals.minimapScaleMultiplier; } else { return constant; diff --git a/common/src/main/java/xaeroplus/mixin/client/MixinRadarRenderProvider.java b/common/src/main/java/xaeroplus/mixin/client/MixinRadarRenderProvider.java index 4a7450c9..058d2e26 100644 --- a/common/src/main/java/xaeroplus/mixin/client/MixinRadarRenderProvider.java +++ b/common/src/main/java/xaeroplus/mixin/client/MixinRadarRenderProvider.java @@ -8,11 +8,11 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import xaero.common.XaeroMinimapSession; import xaero.common.minimap.radar.MinimapRadarList; import xaero.common.minimap.radar.category.setting.EntityRadarCategorySettings; import xaero.common.minimap.render.radar.element.RadarRenderContext; import xaero.common.minimap.render.radar.element.RadarRenderProvider; +import xaero.hud.HudSession; import xaeroplus.Globals; import xaeroplus.feature.extensions.IScreenRadarRenderContext; import xaeroplus.settings.XaeroPlusSettingRegistry; @@ -42,7 +42,7 @@ public void setupContextAndGetNextInject(final int location, final RadarRenderCo } if (!((IScreenRadarRenderContext) (Object) context).isWorldMap()) { - context.nameScale = XaeroMinimapSession.getCurrentSession().getModMain().getSettings().getDotNameScale() * Globals.minimapScaleMultiplier / Globals.minimapSizeMultiplier; + context.nameScale = HudSession.getCurrentSession().getHudMod().getSettings().getDotNameScale() * Globals.minimapScaleMultiplier / Globals.minimapSizeMultiplier; context.iconScale = this.currentList.getCategory().getSettingValue(EntityRadarCategorySettings.ICON_SCALE) * Globals.minimapScaleMultiplier / Globals.minimapSizeMultiplier; } } diff --git a/common/src/main/java/xaeroplus/mixin/client/MixinWaypointsIngameRenderer.java b/common/src/main/java/xaeroplus/mixin/client/MixinWaypointsIngameRenderer.java index 79a3e51b..3162fce5 100644 --- a/common/src/main/java/xaeroplus/mixin/client/MixinWaypointsIngameRenderer.java +++ b/common/src/main/java/xaeroplus/mixin/client/MixinWaypointsIngameRenderer.java @@ -28,14 +28,13 @@ import org.spongepowered.asm.mixin.injection.Inject; 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.BuiltInHudModules; import xaero.hud.minimap.module.MinimapSession; import xaeroplus.feature.extensions.CustomWaypointsIngameRenderer; import xaeroplus.settings.XaeroPlusSettingRegistry; @@ -56,34 +55,31 @@ public class MixinWaypointsIngameRenderer implements CustomWaypointsIngameRenderer { @Shadow private List sortingList; @Shadow private WaypointFilterParams filterParams; - List beaconWaypoints = new ArrayList<>(); - final Predicate beaconViewFilter = new Predicate() { - @Override - public boolean test(final Waypoint w) { - boolean deathpoints = filterParams.deathpoints; - if (!w.isDisabled() - && w.getVisibilityType() != 2 - && w.getVisibilityType() != 3 - && (w.getWaypointType() != 1 && w.getWaypointType() != 2 || deathpoints)) { - double offX = (double)w.getX(filterParams.dimDiv) - filterParams.cameraX + 0.5; - double offZ = (double)w.getZ(filterParams.dimDiv) - filterParams.cameraZ + 0.5; - double distanceScale = filterParams.dimensionScaleDistance ? Minecraft.getInstance().level.dimensionType().coordinateScale() : 1.0; - double unscaledDistance2D = Math.sqrt(offX * offX + offZ * offZ); - double distance2D = unscaledDistance2D * distanceScale; - double waypointsDistance = filterParams.waypointsDistance; - double waypointsDistanceMin = filterParams.waypointsDistanceMin; - return w.isOneoffDestination() - || ( - w.getWaypointType() == 1 - || w.isGlobal() - || w.isTemporary() && filterParams.temporaryWaypointsGlobal - || waypointsDistance == 0.0 - || !(distance2D > waypointsDistance) - ) - && (waypointsDistanceMin == 0.0 || !(unscaledDistance2D < waypointsDistanceMin)); - } else { - return false; - } + @Unique List beaconWaypoints = new ArrayList<>(); + @Unique final Predicate beaconViewFilter = (w) -> { + boolean deathpoints = filterParams.deathpoints; + if (!w.isDisabled() + && w.getVisibilityType() != 2 + && w.getVisibilityType() != 3 + && (w.getWaypointType() != 1 && w.getWaypointType() != 2 || deathpoints)) { + double offX = (double)w.getX(filterParams.dimDiv) - filterParams.cameraX + 0.5; + double offZ = (double)w.getZ(filterParams.dimDiv) - filterParams.cameraZ + 0.5; + double distanceScale = filterParams.dimensionScaleDistance ? Minecraft.getInstance().level.dimensionType().coordinateScale() : 1.0; + double unscaledDistance2D = Math.sqrt(offX * offX + offZ * offZ); + double distance2D = unscaledDistance2D * distanceScale; + double waypointsDistance = filterParams.waypointsDistance; + double waypointsDistanceMin = filterParams.waypointsDistanceMin; + return w.isOneoffDestination() + || ( + w.getWaypointType() == 1 + || w.isGlobal() + || w.isTemporary() && filterParams.temporaryWaypointsGlobal + || waypointsDistance == 0.0 + || !(distance2D > waypointsDistance) + ) + && (waypointsDistanceMin == 0.0 || !(unscaledDistance2D < waypointsDistanceMin)); + } else { + return false; } }; @@ -108,10 +104,8 @@ public void collectBeaconWaypointsList(final PoseStack matrixStack, final PoseSt } @Override - public void renderWaypointBeacons(final XaeroMinimapSession minimapSession, final PoseStack matrixStack, final float tickDelta) { - if (!XaeroPlusSettingRegistry.waypointBeacons.getValue()) return; - final WaypointsManager waypointsManager = minimapSession.getWaypointsManager(); - double dimDiv = waypointsManager.getDimensionDivision(waypointsManager.getCurrentContainerID()); + public void renderWaypointBeacons(final MinimapSession minimapSession, final PoseStack matrixStack, final float tickDelta) { + double dimDiv = minimapSession.getDimensionHelper().getDimensionDivision(minimapSession.getWorldManager().getCurrentWorld()); beaconWaypoints.forEach(w -> renderWaypointBeacon(w, dimDiv, tickDelta, matrixStack)); beaconWaypoints.clear(); } @@ -196,9 +190,9 @@ public long getEtaSecondsToReachWaypoint(Waypoint waypoint) { if (mc.level == null || mc.player == null) return 0; try { final Vec3 playerVec = mc.player.position(); - final WaypointsManager waypointsManager = XaeroMinimapSession.getCurrentSession().getWaypointsManager(); - double dimDiv = waypointsManager.getDimensionDivision(waypointsManager.getCurrentContainerID()); - int wpX = waypoint.getX(dimDiv); + MinimapSession minimapSession = BuiltInHudModules.MINIMAP.getCurrentSession(); + if (minimapSession == null) return 0; + double dimDiv = minimapSession.getDimensionHelper().getDimensionDivision(minimapSession.getWorldManager().getCurrentWorld()); int wpX = waypoint.getX(dimDiv); int wpZ = waypoint.getZ(dimDiv); double directionX = wpX - playerVec.x; double directionZ = wpZ - playerVec.z; diff --git a/common/src/main/java/xaeroplus/mixin/client/mc/MixinWorldRenderer.java b/common/src/main/java/xaeroplus/mixin/client/mc/MixinWorldRenderer.java index 1e72367b..54a608ca 100644 --- a/common/src/main/java/xaeroplus/mixin/client/mc/MixinWorldRenderer.java +++ b/common/src/main/java/xaeroplus/mixin/client/mc/MixinWorldRenderer.java @@ -10,10 +10,14 @@ 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.XaeroMinimapSession; +import xaero.common.HudMod; import xaero.common.minimap.waypoints.render.WaypointsIngameRenderer; +import xaero.hud.minimap.BuiltInHudModules; +import xaero.hud.minimap.Minimap; +import xaero.hud.minimap.module.MinimapSession; import xaeroplus.XaeroPlus; import xaeroplus.feature.extensions.CustomWaypointsIngameRenderer; +import xaeroplus.settings.XaeroPlusSettingRegistry; @Mixin(value = LevelRenderer.class) public class MixinWorldRenderer { @@ -21,10 +25,16 @@ public class MixinWorldRenderer { private int errorCount = 0; @Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/LevelRenderer;checkPoseStack(Lcom/mojang/blaze3d/vertex/PoseStack;)V", ordinal = 1, shift = At.Shift.AFTER)) public void renderBlockEntitiesInject(final PoseStack matrixStack, final float tickDelta, final long limitTime, final boolean renderBlockOutline, final Camera camera, final GameRenderer gameRenderer, final LightTexture lightmapTextureManager, final Matrix4f positionMatrix, final CallbackInfo ci) { - final XaeroMinimapSession minimapSession = XaeroMinimapSession.getCurrentSession(); + if (!XaeroPlusSettingRegistry.waypointBeacons.getValue()) return; + HudMod hudMod = HudMod.INSTANCE; + if (hudMod == null) return; + Minimap minimap = hudMod.getMinimap(); + if (minimap == null) return; + WaypointsIngameRenderer waypointsIngameRenderer = minimap.getWaypointsIngameRenderer(); + if (waypointsIngameRenderer == null) return; + MinimapSession minimapSession = BuiltInHudModules.MINIMAP.getCurrentSession(); if (minimapSession == null) return; try { - WaypointsIngameRenderer waypointsIngameRenderer = minimapSession.getModMain().getInterfaces().getMinimapInterface().getWaypointsIngameRenderer(); ((CustomWaypointsIngameRenderer) waypointsIngameRenderer).renderWaypointBeacons(minimapSession, matrixStack, tickDelta); } catch (final Exception e) { if (errorCount++ < 2) XaeroPlus.LOGGER.error("Error rendering waypoints", e); diff --git a/common/src/main/java/xaeroplus/module/impl/BaritoneGoalSync.java b/common/src/main/java/xaeroplus/module/impl/BaritoneGoalSync.java index 3a747f54..4e4a9489 100644 --- a/common/src/main/java/xaeroplus/module/impl/BaritoneGoalSync.java +++ b/common/src/main/java/xaeroplus/module/impl/BaritoneGoalSync.java @@ -5,7 +5,6 @@ import baritone.api.utils.interfaces.IGoalRenderPos; import net.lenni0451.lambdaevents.EventHandler; import net.minecraft.core.BlockPos; -import net.minecraft.resources.ResourceLocation; import xaero.common.minimap.waypoints.Waypoint; import xaero.common.misc.OptimizedMath; import xaero.hud.minimap.BuiltInHudModules; @@ -18,7 +17,6 @@ import xaeroplus.util.BaritoneHelper; public class BaritoneGoalSync extends Module { - final ResourceLocation XP = new ResourceLocation("xaeroplus"); @EventHandler public void onClientTickEvent(final ClientTickEvent.Post event) { @@ -47,7 +45,7 @@ public void onClientTickEvent(final ClientTickEvent.Post event) { return; } - // todo: this no longer has no idea about the baritone goal's dimension + // todo: this no longer has any 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());