Skip to content

Commit

Permalink
Fix cross-dimension waypoints beacon rendering position
Browse files Browse the repository at this point in the history
  • Loading branch information
rfresh2 committed Jul 13, 2023
1 parent 9ce064b commit 3091d25
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import xaero.common.XaeroMinimapSession;
import xaero.common.minimap.render.MinimapRendererHelper;
import xaero.common.minimap.waypoints.Waypoint;
import xaero.common.minimap.waypoints.WaypointsManager;
Expand Down Expand Up @@ -97,16 +98,18 @@ public double redirectDimensionDivision(final WaypointsManager waypointsManager,
}

@Override
public void renderWaypointBeacons(final MatrixStack matrixStack, final float tickDelta) {
public void renderWaypointBeacons(final XaeroMinimapSession minimapSession, final MatrixStack matrixStack, final float tickDelta) {
if (!XaeroPlusSettingRegistry.waypointBeacons.getValue()) return;
beaconWaypoints.forEach(w -> renderWaypointBeacon(w, tickDelta, matrixStack));
final WaypointsManager waypointsManager = minimapSession.getWaypointsManager();
double dimDiv = redirectDimensionDivision(waypointsManager, waypointsManager.getCurrentContainerID());
beaconWaypoints.forEach(w -> renderWaypointBeacon(w, dimDiv, tickDelta, matrixStack));
}

public void renderWaypointBeacon(final Waypoint waypoint, float tickDelta, MatrixStack matrixStack) {
public void renderWaypointBeacon(final Waypoint waypoint, final double dimDiv, float tickDelta, MatrixStack matrixStack) {
final MinecraftClient mc = MinecraftClient.getInstance();
if (mc.world == null || mc.player == null) return;
final Vec3d playerVec = mc.player.getPos();
Vec3d waypointVec = new Vec3d(waypoint.getX(), playerVec.y, waypoint.getZ());
Vec3d waypointVec = new Vec3d(waypoint.getX(dimDiv), playerVec.y, waypoint.getZ(dimDiv));
final double xzDistance = playerVec.distanceTo(waypointVec);
if (xzDistance < (int) XaeroPlusSettingRegistry.waypointBeaconDistanceMin.getValue()) return;
final int farScale = (int) XaeroPlusSettingRegistry.waypointBeaconScaleMin.getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ public void renderBlockEntitiesInject(final MatrixStack matrixStack, final float
final XaeroMinimapSession minimapSession = XaeroMinimapSession.getCurrentSession();
if (minimapSession == null) return;
WaypointsIngameRenderer waypointsIngameRenderer = minimapSession.getModMain().getInterfaces().getMinimapInterface().getWaypointsIngameRenderer();
((CustomWaypointsIngameRenderer) waypointsIngameRenderer).renderWaypointBeacons(matrixStack, tickDelta);
((CustomWaypointsIngameRenderer) waypointsIngameRenderer).renderWaypointBeacons(minimapSession, matrixStack, tickDelta);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package xaeroplus.util;

import net.minecraft.client.util.math.MatrixStack;
import xaero.common.XaeroMinimapSession;

public interface CustomWaypointsIngameRenderer {
void renderWaypointBeacons(final MatrixStack matrixStack, final float tickDelta);
void renderWaypointBeacons(final XaeroMinimapSession minimapSession, final MatrixStack matrixStack, final float tickDelta);
}

0 comments on commit 3091d25

Please sign in to comment.