mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-05 20:36:42 +00:00
Fixes #255 compass exceptipn
This commit is contained in:
@ -17,16 +17,16 @@ import com.sk89q.worldedit.util.TargetBlock;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
public class PlayerWrapper extends PlayerProxy {
|
||||
public PlayerWrapper(Player parent) {
|
||||
public class AsyncPlayer extends PlayerProxy {
|
||||
public AsyncPlayer(Player parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
public static PlayerWrapper wrap(Player parent) {
|
||||
if (parent instanceof PlayerWrapper) {
|
||||
return (PlayerWrapper) parent;
|
||||
public static AsyncPlayer wrap(Player parent) {
|
||||
if (parent instanceof AsyncPlayer) {
|
||||
return (AsyncPlayer) parent;
|
||||
}
|
||||
return new PlayerWrapper(parent);
|
||||
return new AsyncPlayer(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -162,23 +162,23 @@ public class PlayerWrapper extends PlayerProxy {
|
||||
} catch (RuntimeException e) {
|
||||
caught = e;
|
||||
}
|
||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@Override
|
||||
public void run(Object value) {
|
||||
setPosition(Vector3.at(x + 0.5, y, z + 0.5));
|
||||
}
|
||||
});
|
||||
setPosition(Vector3.at(x + 0.5, y, z + 0.5));
|
||||
if (caught != null) {
|
||||
throw caught;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(Vector3 pos, float pitch, float yaw) {
|
||||
Fawe.get().getQueueHandler().sync(() -> super.setPosition(pos, pitch, yaw));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getBlockTrace(int range, boolean useLastBlock) {
|
||||
return TaskManager.IMP.sync(new RunnableVal<Location>() {
|
||||
@Override
|
||||
public void run(Location value) {
|
||||
TargetBlock tb = new TargetBlock(PlayerWrapper.this, range, 0.2D);
|
||||
TargetBlock tb = new TargetBlock(AsyncPlayer.this, range, 0.2D);
|
||||
this.value = useLastBlock ? tb.getAnyTargetBlock() : tb.getTargetBlock();
|
||||
}
|
||||
});
|
||||
@ -189,7 +189,7 @@ public class PlayerWrapper extends PlayerProxy {
|
||||
return TaskManager.IMP.sync(new RunnableVal<Location>() {
|
||||
@Override
|
||||
public void run(Location value) {
|
||||
TargetBlock tb = new TargetBlock(PlayerWrapper.this, range, 0.2D);
|
||||
TargetBlock tb = new TargetBlock(AsyncPlayer.this, range, 0.2D);
|
||||
this.value = useLastBlock ? tb.getAnyTargetBlockFace() : tb.getTargetBlockFace();
|
||||
}
|
||||
});
|
||||
@ -200,7 +200,7 @@ public class PlayerWrapper extends PlayerProxy {
|
||||
return TaskManager.IMP.sync(new RunnableVal<Location>() {
|
||||
@Override
|
||||
public void run(Location value) {
|
||||
TargetBlock tb = new TargetBlock(PlayerWrapper.this, range, 0.2D);
|
||||
TargetBlock tb = new TargetBlock(AsyncPlayer.this, range, 0.2D);
|
||||
this.value = tb.getSolidTargetBlock();
|
||||
}
|
||||
});
|
||||
@ -215,7 +215,7 @@ public class PlayerWrapper extends PlayerProxy {
|
||||
public boolean passThroughForwardWall(int range) {
|
||||
return TaskManager.IMP.sync(() -> {
|
||||
int searchDist = 0;
|
||||
TargetBlock hitBlox = new TargetBlock(PlayerWrapper.this, range, 0.2);
|
||||
TargetBlock hitBlox = new TargetBlock(AsyncPlayer.this, range, 0.2);
|
||||
Extent world = getLocation().getExtent();
|
||||
Location block;
|
||||
boolean firstBlock = true;
|
@ -1,10 +1,19 @@
|
||||
package com.boydti.fawe.wrappers;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.object.RunnableVal;
|
||||
import com.boydti.fawe.util.EditSessionBuilder;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
public class LocationMaskedPlayerWrapper extends PlayerWrapper {
|
||||
public class LocationMaskedPlayerWrapper extends AsyncPlayer {
|
||||
private final boolean allowTeleport;
|
||||
private Location position;
|
||||
|
||||
@ -23,11 +32,101 @@ public class LocationMaskedPlayerWrapper extends PlayerWrapper {
|
||||
return position;
|
||||
}
|
||||
|
||||
private void update() {
|
||||
this.position = super.getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(Vector3 pos, float pitch, float yaw) {
|
||||
this.position = new Location(position.getExtent(), pos, pitch, yaw);
|
||||
if (allowTeleport) {
|
||||
super.setPosition(pos, pitch, yaw);
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void findFreePosition(Location searchPos) {
|
||||
if (allowTeleport) {
|
||||
super.setPosition(searchPos);
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnGround(Location searchPos) {
|
||||
if (allowTeleport) {
|
||||
super.setPosition(searchPos);
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void findFreePosition() {
|
||||
if (allowTeleport) {
|
||||
super.findFreePosition();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ascendLevel() {
|
||||
if (allowTeleport) {
|
||||
super.ascendLevel();
|
||||
update();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean descendLevel() {
|
||||
if (allowTeleport) {
|
||||
super.descendLevel();
|
||||
update();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ascendToCeiling(int clearance) {
|
||||
if (allowTeleport) {
|
||||
super.ascendToCeiling(clearance);
|
||||
update();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ascendToCeiling(int clearance, boolean alwaysGlass) {
|
||||
if (allowTeleport) {
|
||||
super.ascendToCeiling(clearance, alwaysGlass);
|
||||
update();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ascendUpwards(int distance) {
|
||||
if (allowTeleport) {
|
||||
super.ascendUpwards(distance);
|
||||
update();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ascendUpwards(int distance, boolean alwaysGlass) {
|
||||
if (allowTeleport) {
|
||||
super.ascendUpwards(distance, alwaysGlass);
|
||||
update();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void floatAt(int x, int y, int z, boolean alwaysGlass) {
|
||||
if (allowTeleport) {
|
||||
super.floatAt(x, y, z, alwaysGlass);
|
||||
update();
|
||||
}
|
||||
}
|
||||
}
|
@ -3,12 +3,10 @@ package com.boydti.fawe.wrappers;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* Avoids printing any messages
|
||||
*/
|
||||
public class SilentPlayerWrapper extends PlayerWrapper {
|
||||
public class SilentPlayerWrapper extends AsyncPlayer {
|
||||
public SilentPlayerWrapper(Player parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
Reference in New Issue
Block a user