|
| 1 | +package dev.dfonline.codeclient.mixin; |
| 2 | + |
| 3 | +import dev.dfonline.codeclient.CodeClient; |
| 4 | +import dev.dfonline.codeclient.location.Plot; |
| 5 | +import net.minecraft.client.gui.hud.debug.DebugHudLines; |
| 6 | +import net.minecraft.client.gui.hud.debug.PlayerPositionDebugHudEntry; |
| 7 | +import net.minecraft.util.Identifier; |
| 8 | +import net.minecraft.world.World; |
| 9 | +import net.minecraft.world.chunk.WorldChunk; |
| 10 | +import org.spongepowered.asm.mixin.Final; |
| 11 | +import org.spongepowered.asm.mixin.Mixin; |
| 12 | +import org.spongepowered.asm.mixin.Shadow; |
| 13 | +import org.spongepowered.asm.mixin.injection.At; |
| 14 | +import org.spongepowered.asm.mixin.injection.Inject; |
| 15 | +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
| 16 | + |
| 17 | +import java.util.List; |
| 18 | +import java.util.Locale; |
| 19 | + |
| 20 | +@Mixin(PlayerPositionDebugHudEntry.class) |
| 21 | +public class PlayerPosDebugMixin { |
| 22 | + @Shadow @Final public static Identifier SECTION_ID; |
| 23 | + |
| 24 | + @Inject(method = "render", at = @At("TAIL")) |
| 25 | + private void render(DebugHudLines lines, World world, WorldChunk clientChunk, WorldChunk chunk, CallbackInfo ci) { |
| 26 | + if (CodeClient.location instanceof Plot plot) { |
| 27 | + var plotLocation = CodeClient.MC.getCameraEntity().getEntityPos().subtract(plot.getPos()); |
| 28 | + String size = plot.getSize() == null ? "UNKNOWN" : plot.getSize().name(); |
| 29 | + lines.addLinesToSection(SECTION_ID, List.of(String.format( |
| 30 | + Locale.ROOT, |
| 31 | + "Plot: %.3f / %.5f / %.3f (%s)", |
| 32 | + plotLocation.getX(), |
| 33 | + plotLocation.getY(), |
| 34 | + plotLocation.getZ(), |
| 35 | + size |
| 36 | + ))); |
| 37 | + } |
| 38 | + } |
| 39 | +} |
0 commit comments