From 08bd33a3ed979109e912064b0e2dd6959c2fb20f Mon Sep 17 00:00:00 2001 From: EvilSeph Date: Sat, 10 Mar 2012 00:36:11 -0500 Subject: [PATCH] Made entering an end portal from The End move the player to their bed spawn if it exists. Fixes BUKKIT-1061 --- .../net/minecraft/server/NetServerHandler.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/minecraft/server/NetServerHandler.java b/src/main/java/net/minecraft/server/NetServerHandler.java index 8c24d43f3d..356e000878 100644 --- a/src/main/java/net/minecraft/server/NetServerHandler.java +++ b/src/main/java/net/minecraft/server/NetServerHandler.java @@ -1093,11 +1093,19 @@ public class NetServerHandler extends NetHandler implements ICommandListener { public void a(Packet9Respawn packet9respawn) { if (this.player.viewingCredits) { // CraftBukkit start - CraftWorld cworld = (CraftWorld) this.server.getWorlds().get(0); - ChunkCoordinates chunkcoordinates = cworld.getHandle().getSpawn(); - Location toLocation = new Location(cworld, chunkcoordinates.x + 0.5, chunkcoordinates.y, chunkcoordinates.z + 0.5); - org.bukkit.craftbukkit.PortalTravelAgent pta = new org.bukkit.craftbukkit.PortalTravelAgent(); + Location toLocation; + + if (this.player.getBukkitEntity().getBedSpawnLocation() == null) { + CraftWorld cworld = (CraftWorld) this.server.getWorlds().get(0); + ChunkCoordinates chunkcoordinates = cworld.getHandle().getSpawn(); + toLocation = new Location(cworld, chunkcoordinates.x + 0.5, chunkcoordinates.y, chunkcoordinates.z + 0.5); + this.player.netServerHandler.sendPacket(new Packet70Bed(0, 0)); + } else { + toLocation = this.player.getBukkitEntity().getBedSpawnLocation(); + toLocation = new Location(toLocation.getWorld(), toLocation.getX() + 0.5, toLocation.getY(), toLocation.getZ() + 0.5); + } + PlayerPortalEvent event = new PlayerPortalEvent(this.player.getBukkitEntity(), this.player.getBukkitEntity().getLocation(), toLocation, pta, PlayerPortalEvent.TeleportCause.END_PORTAL); event.useTravelAgent(false);