[SPIGOT-1387] Bed spawning inconsistent with vanilla mechanics Created: 31/Dec/15 Updated: 03/Jan/17 Resolved: 03/Jan/17 |
|
Status: | Resolved |
Project: | Spigot |
Component/s: | None |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | Bug | Priority: | Minor |
Reporter: | chickeneer | Assignee: | Unassigned |
Resolution: | Done | Votes: | 0 |
Labels: | Beds |
Attachments: |
![]() |
Description |
Bed mechanics being reported relate to the respawn block found based on the bed a player has set after sleeping. First, is if the only valid spawnable blocks available around the bed (10 possible blocks around the bed) are in a Different chunk than the bed and that other chunk is unloaded; the find a respawn point method will return null and therefore fail. (this check is in BlockBed). This causes players to not respawn at their bed, even though there are available blocks for them to spawn at. Second is extremely minor but could be related. The order that the server picks for the player to respawn, goes in a different priority order check compared to vanilla minecraft. Note: This issue did not reproduce in Vanilla Single Player or the vanilla Minecraft 1.8.9 Server. Attached is a screenshot depicting a representation of the first issue. Where obsidian blocks represent the chunk which the bed is in. Non-obsidian is in a different chunk. |
Comments |
Comment by Daniel Ennis [ 31/Dec/15 ] |
chicken found the issue to be a CraftBukkit change where forceLoad which defaults to true in vanilla, was changed to false in CraftBukkit, for the WorldProviderServer. So getType() is not loading the nearby chunks, to fix this, follow suit for other boolean toggling operations and toggle the forceLoad boolean for getBed like so: diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java index 1dbd1eb..80a9f07 100644 --- a/src/main/java/net/minecraft/server/EntityHuman.java +++ b/src/main/java/net/minecraft/server/EntityHuman.java @@ -1272,7 +1272,16 @@ public abstract class EntityHuman extends EntityLiving { return this.world.getType(this.bx).getBlock() == Blocks.BED; } + // EMC start public static BlockPosition getBed(World world, BlockPosition blockposition, boolean flag) { + boolean before = ((WorldServer) world).chunkProviderServer.forceChunkLoad; + ((WorldServer) world).chunkProviderServer.forceChunkLoad = true; + final BlockPosition result = getBed0(world, blockposition, flag); + ((WorldServer) world).chunkProviderServer.forceChunkLoad = before; + return result; + } + private static BlockPosition getBed0(World world, BlockPosition blockposition, boolean flag) { + // EMC end ((ChunkProviderServer) world.chunkProvider).getChunkAt(blockposition.getX() >> 4, blockposition.getZ() >> 4); // CraftBukkit Block block = world.getType(blockposition).getBlock(); |