mirror of
https://github.com/Oth3r/Sit.git
synced 2025-09-20 00:13:21 +02:00
fixed sit while seated causing sit entities to not be removed for the player
This commit is contained in:
parent
4db3062a62
commit
2e1ae46d77
2 changed files with 22 additions and 8 deletions
|
@ -84,6 +84,26 @@ public class Logic {
|
||||||
Utl.Entity.remove(entity);
|
Utl.Entity.remove(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* spawns a sit entity for the player, they HAVE TO BE in the spawn list
|
||||||
|
*/
|
||||||
|
public static void spawnEntity(ServerPlayerEntity player) {
|
||||||
|
// return if not in the list
|
||||||
|
if (Data.getSpawnList().get(player) == null) return;
|
||||||
|
|
||||||
|
// if the player is already sitting on a sit entity, remove it before spawning a new one
|
||||||
|
if (FileData.getSitEntity(player) != null) Logic.removeEntity(player);
|
||||||
|
// get the new entity
|
||||||
|
DisplayEntity.TextDisplayEntity sitEntity = Data.getSpawnList().get(player);
|
||||||
|
// spawn and ride the entity
|
||||||
|
player.getServerWorld().spawnEntity(sitEntity);
|
||||||
|
player.startRiding(sitEntity);
|
||||||
|
// add the entity to the list
|
||||||
|
FileData.addSitEntity(player, sitEntity);
|
||||||
|
// remove the entity from the spawn list
|
||||||
|
Data.removeSpawnList(player);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checks if the player should still be sitting, e.g. the block was destroyed ect.
|
* checks if the player should still be sitting, e.g. the block was destroyed ect.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -51,16 +51,10 @@ public class LoopManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// spawn entities for everyone in the spawn list
|
||||||
HashMap<ServerPlayerEntity, DisplayEntity.TextDisplayEntity> spawnList = Data.getSpawnList();
|
HashMap<ServerPlayerEntity, DisplayEntity.TextDisplayEntity> spawnList = Data.getSpawnList();
|
||||||
for (ServerPlayerEntity player : spawnList.keySet()) {
|
for (ServerPlayerEntity player : spawnList.keySet()) {
|
||||||
DisplayEntity.TextDisplayEntity sitEntity = spawnList.get(player);
|
Logic.spawnEntity(player);
|
||||||
|
|
||||||
player.getServerWorld().spawnEntity(sitEntity);
|
|
||||||
player.startRiding(sitEntity);
|
|
||||||
// add the entity to the list
|
|
||||||
FileData.addSitEntity(player, sitEntity);
|
|
||||||
// remove the entity from the list
|
|
||||||
Data.removeSpawnList(player);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue