1.15.2 Bed spawn location

Discussion in 'Spigot Plugin Development' started by vildaberper, Feb 18, 2020.

  1. So I'm trying to update my plugin, which allows players to craft and use "sleeping bags". They will allow you to sleep during the night without setting your respawn point.

    Now that this vanilla mechanic is somewhat changed - is there a way to disable it through a plugin?

    Events fire in this order:
    Interact -> BedEnter -> "Respawn point set" -> BedLeave

    It seems to me like we need similar functionality in BedEnter as in BedLeave:
    setSpawnLocation(boolean setBedSpawn)
    shouldSetSpawnLocation()

    EDIT:
    For anyone interested, you can vote on the issue here: https://hub.spigotmc.org/jira/browse/SPIGOT-5599
     
    #1 vildaberper, Feb 18, 2020
    Last edited: Mar 1, 2020
  2. actual functionality aside, you can get the current spawn location when they enter the bed (as this is called before any changes are made), then in a task that runs a tick delayed, set the spawn location back to what it was.
     
  3. Yeah, this is my current approach. But I suspect that minecraft store the actual bed location and not respawnlocation, meaning:
    Location loc = ...;
    setBedSpawnLocation(loc);
    -- loc is not the same as getBedSpawnLocation()

    I could force it with setBedSpawnLocation(Location location, boolean force), but this is obviously not ideal since I assume it is no longer tied to a bed.