From 501992dd2099aa48dd4c020ca159190a4b3bf11d Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sat, 6 Apr 2019 05:51:18 +1100 Subject: [PATCH] Fix setPosition --- .../java/com/sk89q/worldedit/bukkit/BukkitPlayer.java | 11 +++++++++++ .../extension/platform/AbstractPlayerActor.java | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java index 22e424821..2fc55ae0e 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java @@ -28,6 +28,7 @@ import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.extension.platform.AbstractPlayerActor; +import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.internal.cui.CUIEvent; import com.sk89q.worldedit.math.BlockVector3; @@ -162,6 +163,16 @@ public class BukkitPlayer extends AbstractPlayerActor { @Override public void setPosition(Vector3 pos, float pitch, float yaw) { + if (pos instanceof com.sk89q.worldedit.util.Location) { + com.sk89q.worldedit.util.Location loc = (com.sk89q.worldedit.util.Location) pos; + Extent extent = loc.getExtent(); + if (extent instanceof World) { + org.bukkit.World world = Bukkit.getWorld(((World) extent).getName()); + System.out.println("Teleport to world " + world); + player.teleport(new Location(world, pos.getX(), pos.getY(), + pos.getZ(), yaw, pitch)); + } + } player.teleport(new Location(player.getWorld(), pos.getX(), pos.getY(), pos.getZ(), yaw, pitch)); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java index 8992ac465..a3afeff70 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java @@ -118,7 +118,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { if (y - 1 != origY) { final BlockVector3 pos = BlockVector3.at(x, y - 2, z); final BlockStateHolder state = world.getBlock(pos); - setPosition(Vector3.at(x + 0.5, y - 2 + BlockTypeUtil.centralTopLimit(state), z + 0.5)); + setPosition(new Location(world, Vector3.at(x + 0.5, y - 2 + BlockTypeUtil.centralTopLimit(state), z + 0.5))); } return; @@ -139,7 +139,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { final BlockVector3 pos = BlockVector3.at(x, y, z); final BlockState id = world.getBlock(pos); if (id.getBlockType().getMaterial().isMovementBlocker()) { - setPosition(Vector3.at(x + 0.5, y + + BlockTypeUtil.centralTopLimit(id), z + 0.5)); + setPosition(new Location(world, Vector3.at(x + 0.5, y + + BlockTypeUtil.centralTopLimit(id), z + 0.5))); return; }