Closed MatArtz closed 6 years ago
Sleep animation got weird in minecraft, it requires a bed in some specific position relative to the player entity to play correctly.
Could anyone help me to realize this or it's too difficult?
The client actually checks that a bed is nearby these days. You have to put a bed nearby and be in night to get the animation to play.
Try this plugin: https://www.spigotmc.org/resources/nunpcdestinations-create-living-npcs-1-8-3-1-11.13863/
It comes with an addon animation plugin that allows you to set locations and have NPCs sleep at them, it's also got fishing, fishing and keeping the fish in inventory, opening chests and opening chests then emptying all the items into it.
I submitted a PR to fix this issue (and basically any other sleeping issues): https://github.com/CitizensDev/Citizens2/pull/2029
public static NPC spawnNPC(Location loc, String Skin, String Name) { NPC npc = CitizensAPI.getNPCRegistry().createNPC(EntityType.PLAYER, Name); npc.data().setPersistent(NPC.PLAYER_SKIN_UUID_METADATA, Skin); npc.data().setPersistent(NPC.PLAYER_SKIN_USE_LATEST, false); npc.spawn(loc);
return npc; }
NPC npc = spawnNPC(p.getLocation(), p.getName(), CubeLife.getRoleName(p, false, true)); PlayerAnimation.SLEEP.play((Player)npc.getEntity());