Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rfresh2 committed Sep 2, 2024
1 parent d6f9f94 commit 5e8e730
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 60 deletions.
Original file line number Diff line number Diff line change
@@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@
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;
import xaero.common.minimap.render.MinimapRendererHelper;
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;
Expand All @@ -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))
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -56,34 +55,31 @@
public class MixinWaypointsIngameRenderer implements CustomWaypointsIngameRenderer {
@Shadow private List<Waypoint> sortingList;
@Shadow private WaypointFilterParams filterParams;
List<Waypoint> beaconWaypoints = new ArrayList<>();
final Predicate<Waypoint> beaconViewFilter = new Predicate<Waypoint>() {
@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<Waypoint> beaconWaypoints = new ArrayList<>();
@Unique final Predicate<Waypoint> 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;
}
};

Expand All @@ -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();
}
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,31 @@
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 {

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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 5e8e730

Please sign in to comment.