Skip to content

Commit

Permalink
hide custom subworld mm text when Prefer Waypoints enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
rfresh2 committed Sep 2, 2024
1 parent a922413 commit d6f9f94
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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<Void> original,
@Local(name = "currentWorld") MinimapWorld currentWorld) {
if (XaeroPlusSettingRegistry.owAutoWaypointDimension.getValue()) {
ResourceKey<Level> actualDimension = ChunkUtils.getActualDimension();
if (actualDimension == Level.NETHER && currentWorld.getDimId() == Level.OVERWORLD) return;
}
original.call(instance, lineWidth, text);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -95,7 +96,8 @@ public void preferOwWaypointsRemoveSubworldText(final MinimapSession session, fi
if (!XaeroPlusSettingRegistry.owAutoWaypointDimension.getValue()) return;
if (subWorldNameRef.get() == null) return;
ResourceKey<Level> actualDimension = ChunkUtils.getActualDimension();
if (actualDimension == NETHER) {
ResourceKey<Level> currentWpWorldDim = session.getWorldManager().getCurrentWorld().getDimId();
if (actualDimension == NETHER && currentWpWorldDim == OVERWORLD) {
subWorldNameRef.set(null);
}
}
Expand Down
1 change: 1 addition & 0 deletions common/src/main/resources/xaeroplus.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"AccessorWidgetScreenHandler",
"AccessorWorldMapModOptions",
"AccessorWorldMapScreenSwitchSettingEntry",
"MixinBuiltInInfoDisplays",
"MixinClientEvents",
"MixinCommonGuiSettings",
"MixinCommonInternet",
Expand Down

0 comments on commit d6f9f94

Please sign in to comment.