Bugfix /back on death
This commit is contained in:
parent
6ca46fc562
commit
c29bab20fd
1 changed files with 7 additions and 3 deletions
|
@ -2,8 +2,9 @@ package cc.reconnected.server.core;
|
||||||
|
|
||||||
import cc.reconnected.server.events.PlayerTeleport;
|
import cc.reconnected.server.events.PlayerTeleport;
|
||||||
import cc.reconnected.server.struct.ServerPosition;
|
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.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
||||||
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
@ -20,8 +21,11 @@ public class BackTracker {
|
||||||
lastPlayerPositions.put(player.getUuid(), origin);
|
lastPlayerPositions.put(player.getUuid(), origin);
|
||||||
});
|
});
|
||||||
|
|
||||||
ServerPlayerEvents.AFTER_RESPAWN.register((oldPlayer, newPlayer, alive) -> {
|
ServerLivingEntityEvents.AFTER_DEATH.register((entity, damageSource) -> {
|
||||||
lastPlayerPositions.put(oldPlayer.getUuid(), new ServerPosition(oldPlayer));
|
if (entity.isPlayer()) {
|
||||||
|
var player = (ServerPlayerEntity) entity;
|
||||||
|
lastPlayerPositions.put(entity.getUuid(), new ServerPosition(player));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue