How to get the bed respawn point for a player?


#1

I found the RespawnLocationData in Javadoc,but I can’t get an instance of this type.

I placed a bed in the main world. The player is respawned nearby the bed.But player.get(RespawnLocationData.class) still return null.

So how do I get the location of the bed set by the player?


#2
Map<UUID, RespawnLocation> locations = player.get(Keys.RESPAWN_LOCATIONS).get();

The UUID is the worlds uniquie id


#3

Thank you for your reply.

But player.get(Keys.RESPAWN_LOCATIONS) still return null.Should I set value on my own?

EDIT: My Minecraft server version is 1.12.2 and the Sponge API version is 7.1.0.


#4

It should never return null, but Optional empty or a Optional value of Map. It maybe that it is not implemented. If it does actually return null then check that your player object isnt null itself


#5

This return an Optional object. I mean player.get(Keys.RESPAWN_LOCATIONS).isPresent() returns false.


#6

That probably means its not implemented yet. Put a issue on the spongeapi’s git page if there isnt one already.


#7

I found this issue.

It seems that RespawnLocationData is still not implemented correctly in the Sponge API 7.1.0 release.


#8

The Sponge team do a very good job at adding new API’s and fixing bugs, so it will hopfully be fixed soon enough. Just got to play the waiting game.


#9

A year has passed, this problem still not fixed, except nms i don’t know how to get bed location


#10

The Sponge team are mainly focusing on 1.14 sadly. Im yet to see a pull request that tackles the issue meaning it is no closer then it was before.

If your confortable with NMS, then by all means make the pull request and have your code in Sponge