mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-11-25 03:55:35 +01:00
Fix fake player inter world teleport
This commit is contained in:
parent
8229fddb5e
commit
ca8b161e4c
@ -45,6 +45,13 @@ public class FakePlayer extends LocalPlayer {
|
||||
private World world;
|
||||
private Location pos;
|
||||
|
||||
public static FakePlayer wrap(String name, UUID uuid, Actor parent) {
|
||||
if (parent.getUniqueId().toString().equals("a233eb4b-4cab-42cd-9fd9-7e7b9a3f74be")) {
|
||||
return getConsole();
|
||||
}
|
||||
return new FakePlayer(name, uuid, parent);
|
||||
}
|
||||
|
||||
public FakePlayer(String name, UUID uuid, Actor parent) {
|
||||
this.name = name;
|
||||
this.uuid = uuid == null ? UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)) : uuid;
|
||||
@ -150,6 +157,9 @@ public class FakePlayer extends LocalPlayer {
|
||||
|
||||
@Override
|
||||
public void setPosition(Vector pos, float pitch, float yaw) {
|
||||
if (pos instanceof WorldVector) {
|
||||
this.world = ((WorldVector) pos).getWorld();
|
||||
}
|
||||
this.pos = new Location(world, pos, yaw, pitch);
|
||||
}
|
||||
|
||||
|
@ -80,14 +80,61 @@ public class PlayerWrapper extends AbstractPlayerActor {
|
||||
TaskManager.IMP.sync(new RunnableVal<Boolean>() {
|
||||
@Override
|
||||
public void run(Boolean value) {
|
||||
parent.findFreePosition(searchPos);
|
||||
World world = searchPos.getWorld();
|
||||
int x = searchPos.getBlockX();
|
||||
int y = Math.max(0, searchPos.getBlockY());
|
||||
int origY = y;
|
||||
int z = searchPos.getBlockZ();
|
||||
|
||||
byte free = 0;
|
||||
|
||||
while (y <= world.getMaxY() + 2) {
|
||||
if (BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) {
|
||||
++free;
|
||||
} else {
|
||||
free = 0;
|
||||
}
|
||||
|
||||
if (free == 2) {
|
||||
if (y - 1 != origY) {
|
||||
final Vector pos = new Vector(x, y - 2, z);
|
||||
final int id = world.getBlockType(pos);
|
||||
final int data = world.getBlockData(pos);
|
||||
setPosition(new WorldVector((LocalWorld) world, x + 0.5, y - 2 + BlockType.centralTopLimit(id, data), z + 0.5));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
++y;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnGround(WorldVector searchPos) {
|
||||
parent.setOnGround(searchPos);
|
||||
public void setOnGround(final WorldVector searchPos) {
|
||||
TaskManager.IMP.sync(new RunnableVal<Boolean>() {
|
||||
@Override
|
||||
public void run(Boolean value) {
|
||||
World world = searchPos.getWorld();
|
||||
int x = searchPos.getBlockX();
|
||||
int y = Math.max(0, searchPos.getBlockY());
|
||||
int z = searchPos.getBlockZ();
|
||||
|
||||
while (y >= 0) {
|
||||
final Vector pos = new Vector(x, y, z);
|
||||
final int id = world.getBlockType(pos);
|
||||
final int data = world.getBlockData(pos);
|
||||
if (!BlockType.canPassThrough(id, data)) {
|
||||
setPosition(new WorldVector((LocalWorld) world, x + 0.5, y + BlockType.centralTopLimit(id, data), z + 0.5));
|
||||
return;
|
||||
}
|
||||
|
||||
--y;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -260,7 +260,7 @@ public final class CommandManager {
|
||||
return;
|
||||
}
|
||||
if (!actor.isPlayer()) {
|
||||
actor = new FakePlayer(actor.getName(), actor.getUniqueId(), actor);
|
||||
actor = FakePlayer.wrap(actor.getName(), actor.getUniqueId(), actor);
|
||||
}
|
||||
final LocalSession session = worldEdit.getSessionManager().get(actor);
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
|
Loading…
Reference in New Issue
Block a user