Fix setPosition

This commit is contained in:
Jesse Boyd 2019-04-06 05:51:18 +11:00
parent 0afae082c2
commit 501992dd20
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
2 changed files with 13 additions and 2 deletions

View File

@ -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));
}

View File

@ -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;
}