mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 17:47:32 +00:00
Add mount edge case handling for dismount scenarios
- Player logout: Dismount from NPC mount before logout to prevent orphaned mount state (ServerTickHandler) - Teleportation: Dismount before cross-dimension teleport to prevent mount being left behind in old dimension (NoppesUtilPlayer) - Dead rider: Validate rider is alive, dismount dead/invalid riders to prevent stuck mount state (NPCMountUtil) - Role disable: Dismount rider when mount role is disabled to prevent mounted player on non-mount NPC (RoleMount)
This commit is contained in:
4 files changed
+31
-2
No files matched your search
@@ -11,6 +11,7 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import noppes.npcs.client.AnalyticsTracking;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.controllers.data.action.ActionManager;
|
||||
|
||||
import java.net.InetAddress;
|
||||
@@ -68,6 +69,11 @@ public class ServerTickHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void playerLogout(PlayerEvent.PlayerLoggedOutEvent event) {
|
||||
// Dismount player from NPC mount before logout to prevent orphaned mount state
|
||||
if (event.player.ridingEntity instanceof EntityNPCInterface) {
|
||||
event.player.mountEntity(null);
|
||||
}
|
||||
|
||||
PlayerData playerData = PlayerData.get(event.player);
|
||||
if (playerData != null) {
|
||||
playerData.onLogout();
|
||||
|
||||
Reference in new issue
Block a user