From 4d3865a03639eac0da60cd830ba4feee0bb53121 Mon Sep 17 00:00:00 2001 From: James Clarke Date: Sun, 3 Feb 2013 00:32:07 +0000 Subject: [PATCH] Fix players spawning above portals. Fixes BUKKIT-3542. Vanilla does not check for blocks in which the player could suffocate when changing dimension, so portals will happily spawn players in blocks when using a portal under certain circumstances. However, we currently check for these instances and move the player up until they will not suffocate. This means that players can sometimes be taken to above the target portal, making it seem as if a portal was not created. Instead, we now disable this suffocation check when moveToWorld is called from changeDimension, mirroring vanilla behavior more accurately. --- src/main/java/net/minecraft/server/PlayerList.java | 8 ++++---- .../java/org/bukkit/craftbukkit/entity/CraftPlayer.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java index 0ad5c43b89..c9810b4b3b 100644 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -322,10 +322,10 @@ public abstract class PlayerList { // CraftBukkit start public EntityPlayer moveToWorld(EntityPlayer entityplayer, int i, boolean flag) { - return this.moveToWorld(entityplayer, i, flag, null); + return this.moveToWorld(entityplayer, i, flag, null, true); } - public EntityPlayer moveToWorld(EntityPlayer entityplayer, int i, boolean flag, Location location) { + public EntityPlayer moveToWorld(EntityPlayer entityplayer, int i, boolean flag, Location location, boolean avoidSuffocation) { // CraftBukkit end entityplayer.p().getTracker().untrackPlayer(entityplayer); // entityplayer.p().getTracker().untrackEntity(entityplayer); // CraftBukkit @@ -378,7 +378,7 @@ public abstract class PlayerList { worldserver.chunkProviderServer.getChunkAt((int) entityplayer1.locX >> 4, (int) entityplayer1.locZ >> 4); - while (!worldserver.getCubes(entityplayer1, entityplayer1.boundingBox).isEmpty()) { + while (avoidSuffocation && !worldserver.getCubes(entityplayer1, entityplayer1.boundingBox).isEmpty()) { // CraftBukkit entityplayer1.setPosition(entityplayer1.locX, entityplayer1.locY + 1.0D, entityplayer1.locZ); } @@ -468,7 +468,7 @@ public abstract class PlayerList { exitWorld.s().adjustExit(entityplayer, exit, velocity); exitWorld.chunkProviderServer.forceChunkLoad = before; - this.moveToWorld(entityplayer, exitWorld.dimension, true, exit); + this.moveToWorld(entityplayer, exitWorld.dimension, true, exit, false); // Vanilla doesn't check for suffocation when handling portals, so neither should we if (entityplayer.motX != velocity.getX() || entityplayer.motY != velocity.getY() || entityplayer.motZ != velocity.getZ()) { entityplayer.getBukkitEntity().setVelocity(velocity); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index b6c7b1ce89..b0c23a06e3 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -389,7 +389,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (getHandle().activeContainer != getHandle().defaultContainer){ getHandle().closeInventory(); } - server.getHandle().moveToWorld(entity, toWorld.dimension, true, to); + server.getHandle().moveToWorld(entity, toWorld.dimension, true, to, true); } return true; }