|
| 1 | +package com.rappytv.deathfinder.v1_20_5; |
| 2 | + |
| 3 | +import com.rappytv.deathfinder.DeathFinderAddon; |
| 4 | +import com.rappytv.deathfinder.events.DeathEvent; |
| 5 | +import com.rappytv.deathfinder.util.Location; |
| 6 | +import net.labymod.api.Laby; |
| 7 | +import net.minecraft.client.gui.screens.DeathScreen; |
| 8 | +import net.minecraft.client.gui.screens.Screen; |
| 9 | +import net.minecraft.client.player.LocalPlayer; |
| 10 | +import net.minecraft.network.chat.Component; |
| 11 | +import org.spongepowered.asm.mixin.Mixin; |
| 12 | +import org.spongepowered.asm.mixin.injection.At; |
| 13 | +import org.spongepowered.asm.mixin.injection.Inject; |
| 14 | +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
| 15 | + |
| 16 | +@Mixin(DeathScreen.class) |
| 17 | +public class DeathScreenMixin extends Screen { |
| 18 | + |
| 19 | + protected DeathScreenMixin(Component title) { |
| 20 | + super(title); |
| 21 | + } |
| 22 | + |
| 23 | + @Inject(method = "init", at = @At("TAIL")) |
| 24 | + public void onDeathScreen(CallbackInfo ci) { |
| 25 | + if(this.minecraft == null || this.minecraft.player == null) return; |
| 26 | + |
| 27 | + LocalPlayer player = this.minecraft.player; |
| 28 | + Location deathLocation = new Location(player.getX(), player.getY(), player.getZ()); |
| 29 | + |
| 30 | + if(DeathFinderAddon.get().configuration().saveRotation().get()) { |
| 31 | + deathLocation.setYaw(player.getYRot()); |
| 32 | + deathLocation.setPitch(player.getXRot()); |
| 33 | + } |
| 34 | + if(deathLocation.equals(DeathFinderAddon.getDeathLocation())) return; |
| 35 | + |
| 36 | + Laby.fireEvent(new DeathEvent(deathLocation)); |
| 37 | + } |
| 38 | +} |
0 commit comments