From c04246c7dae1bc31feb92045616c34e336ce8582 Mon Sep 17 00:00:00 2001 From: AutumnVN Date: Sun, 17 Mar 2024 08:27:32 +0700 Subject: [PATCH] death coord --- src/client/java/autumnvn/autumn/Options.java | 3 +++ .../java/autumnvn/autumn/SettingsScreen.java | 1 + .../autumn/mixin/client/DeathScreenMixin.java | 26 +++++++++++++++++++ .../resources/autumn.client.mixins.json | 1 + 4 files changed, 31 insertions(+) create mode 100644 src/client/java/autumnvn/autumn/mixin/client/DeathScreenMixin.java diff --git a/src/client/java/autumnvn/autumn/Options.java b/src/client/java/autumnvn/autumn/Options.java index 7b82a30..5949e35 100644 --- a/src/client/java/autumnvn/autumn/Options.java +++ b/src/client/java/autumnvn/autumn/Options.java @@ -26,6 +26,7 @@ public class Options { public SimpleOption ignorePlayer; public SimpleOption betterChat; public SimpleOption betterNametag; + public SimpleOption deathCoord; public SimpleOption fullBright; public SimpleOption horseSwim; public SimpleOption infoHud; @@ -54,6 +55,8 @@ public Options() { options.put("betterChat", betterChat); betterNametag = SimpleOption.ofBoolean("Better Nametag", value -> Tooltip.of(Text.of("Add health & gamemode to nametag, make nametag always visible & show targeted entity nametag")), true); options.put("betterNametag", betterNametag); + deathCoord = SimpleOption.ofBoolean("Death Coord", value -> Tooltip.of(Text.of("Show death coordinates in chat")), true); + options.put("deathCoord", deathCoord); fullBright = SimpleOption.ofBoolean("Full Bright", value -> Tooltip.of(Text.of("No more darkness")), true); options.put("fullBright", fullBright); horseSwim = SimpleOption.ofBoolean("Horse Swim", value -> Tooltip.of(Text.of("Make riding horse swim in water")), true); diff --git a/src/client/java/autumnvn/autumn/SettingsScreen.java b/src/client/java/autumnvn/autumn/SettingsScreen.java index 5974fde..251ea5d 100644 --- a/src/client/java/autumnvn/autumn/SettingsScreen.java +++ b/src/client/java/autumnvn/autumn/SettingsScreen.java @@ -15,6 +15,7 @@ public class SettingsScreen extends Screen { AutumnClient.options.ignorePlayer, AutumnClient.options.betterChat, AutumnClient.options.betterNametag, + AutumnClient.options.deathCoord, AutumnClient.options.fullBright, AutumnClient.options.horseSwim, AutumnClient.options.infoHud, diff --git a/src/client/java/autumnvn/autumn/mixin/client/DeathScreenMixin.java b/src/client/java/autumnvn/autumn/mixin/client/DeathScreenMixin.java new file mode 100644 index 0000000..fcd80ca --- /dev/null +++ b/src/client/java/autumnvn/autumn/mixin/client/DeathScreenMixin.java @@ -0,0 +1,26 @@ +package autumnvn.autumn.mixin.client; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import autumnvn.autumn.AutumnClient; +import net.minecraft.client.gui.screen.DeathScreen; +import net.minecraft.text.Text; + +@Mixin(DeathScreen.class) +public class DeathScreenMixin { + + // DeathCoord + @Inject(method = "init", at = @At("HEAD")) + private void init(CallbackInfo ci) { + if (AutumnClient.options.deathCoord.getValue()) { + AutumnClient.client.player.sendMessage(Text.of(String.format("You died at §a%d %d %d §rin §a%s", + AutumnClient.client.player.getBlockX(), + AutumnClient.client.player.getBlockY(), + AutumnClient.client.player.getBlockZ(), + AutumnClient.client.world.getRegistryKey().getValue().toString().split(":")[1]))); + } + } + +} diff --git a/src/client/resources/autumn.client.mixins.json b/src/client/resources/autumn.client.mixins.json index d58dc7e..756fca4 100644 --- a/src/client/resources/autumn.client.mixins.json +++ b/src/client/resources/autumn.client.mixins.json @@ -9,6 +9,7 @@ "ChatHudMixin", "ClientPlayerInteractionManagerMixin", "ClientPlayNetworkHandlerMixin", + "DeathScreenMixin", "EntityMixin", "EntityRendererMixin", "FishingBobberEntityRendererMixin",