From c29bab20fd3f48e1de8068d315db2c704c1bb648 Mon Sep 17 00:00:00 2001 From: Alessandro Proto Date: Fri, 25 Oct 2024 13:12:16 +0200 Subject: [PATCH] Bugfix /back on death --- .../java/cc/reconnected/server/core/BackTracker.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/cc/reconnected/server/core/BackTracker.java b/src/main/java/cc/reconnected/server/core/BackTracker.java index 4681f18..9b9d69e 100644 --- a/src/main/java/cc/reconnected/server/core/BackTracker.java +++ b/src/main/java/cc/reconnected/server/core/BackTracker.java @@ -2,8 +2,9 @@ package cc.reconnected.server.core; import cc.reconnected.server.events.PlayerTeleport; import cc.reconnected.server.struct.ServerPosition; -import net.fabricmc.fabric.api.entity.event.v1.ServerPlayerEvents; +import net.fabricmc.fabric.api.entity.event.v1.ServerLivingEntityEvents; import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents; +import net.minecraft.server.network.ServerPlayerEntity; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; @@ -20,8 +21,11 @@ public class BackTracker { lastPlayerPositions.put(player.getUuid(), origin); }); - ServerPlayerEvents.AFTER_RESPAWN.register((oldPlayer, newPlayer, alive) -> { - lastPlayerPositions.put(oldPlayer.getUuid(), new ServerPosition(oldPlayer)); + ServerLivingEntityEvents.AFTER_DEATH.register((entity, damageSource) -> { + if (entity.isPlayer()) { + var player = (ServerPlayerEntity) entity; + lastPlayerPositions.put(entity.getUuid(), new ServerPosition(player)); + } }); } }