mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-10-05 02:17:55 +02:00
Mask location for brushes
This commit is contained in:
parent
102468c2fd
commit
9d7a5e4344
@ -15,6 +15,7 @@ import com.sk89q.worldedit.event.platform.CommandEvent;
|
||||
import com.sk89q.worldedit.extension.platform.CommandManager;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
|
||||
public class CommandBrush implements Brush {
|
||||
|
||||
@ -47,7 +48,7 @@ public class CommandBrush implements Brush {
|
||||
}
|
||||
FawePlayer<Object> fp = FawePlayer.wrap(player);
|
||||
fp.setSelection(selector);
|
||||
PlayerWrapper wePlayer = new SilentPlayerWrapper(new LocationMaskedPlayerWrapper(player, position));
|
||||
PlayerWrapper wePlayer = new SilentPlayerWrapper(new LocationMaskedPlayerWrapper(player, new Location(player.getExtent(), position)));
|
||||
String[] cmds = replaced.split(";");
|
||||
for (String cmd : cmds) {
|
||||
CommandEvent event = new CommandEvent(wePlayer, cmd);
|
||||
|
@ -7,9 +7,9 @@ import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
|
||||
public class LocationMaskedPlayerWrapper extends PlayerWrapper {
|
||||
private Vector position;
|
||||
private Location position;
|
||||
|
||||
public LocationMaskedPlayerWrapper(Player parent, Vector position) {
|
||||
public LocationMaskedPlayerWrapper(Player parent, Location position) {
|
||||
super(parent);
|
||||
this.position = position;
|
||||
}
|
||||
@ -28,16 +28,16 @@ public class LocationMaskedPlayerWrapper extends PlayerWrapper {
|
||||
|
||||
@Override
|
||||
public WorldVector getPosition() {
|
||||
return new WorldVector((LocalWorld) getWorld(), position);
|
||||
return new WorldVector((LocalWorld) position.getExtent(), position.toVector());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return new Location(getWorld(), position);
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(Vector pos, float pitch, float yaw) {
|
||||
this.position = pos;
|
||||
this.position = new Location(position.getExtent(), pos, pitch, yaw);
|
||||
}
|
||||
}
|
||||
|
@ -265,7 +265,7 @@ public final class CommandManager {
|
||||
if (fp == null) {
|
||||
throw new IllegalArgumentException("FAWE doesn't support: " + actor);
|
||||
}
|
||||
locals.put(Actor.class, actor instanceof Player ? (actor = new LocationMaskedPlayerWrapper((Player) actor, ((Player) actor).getPosition())) : actor);
|
||||
locals.put(Actor.class, actor instanceof Player ? (actor = new LocationMaskedPlayerWrapper((Player) actor, ((Player) actor).getLocation())) : actor);
|
||||
final Actor finalActor = actor;
|
||||
if (!fp.runAction(new Runnable() {
|
||||
@Override
|
||||
|
@ -24,6 +24,7 @@ import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
import com.boydti.fawe.object.pattern.PatternTraverser;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.wrappers.LocationMaskedPlayerWrapper;
|
||||
import com.boydti.fawe.wrappers.PlayerWrapper;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
@ -348,7 +349,7 @@ public class PlatformManager {
|
||||
|
||||
// At this time, only handle interaction from players
|
||||
if (actor instanceof Player) {
|
||||
final Player player = PlayerWrapper.wrap((Player) actor);
|
||||
final Player player = new LocationMaskedPlayerWrapper(PlayerWrapper.wrap((Player) actor), ((Player) actor).getLocation());
|
||||
final LocalSession session = worldEdit.getSessionManager().get(actor);
|
||||
|
||||
if (event.getType() == Interaction.HIT) {
|
||||
@ -420,12 +421,12 @@ public class PlatformManager {
|
||||
if (tool != null && tool instanceof BlockTool) {
|
||||
if (tool.canUse(player)) {
|
||||
FawePlayer<?> fp = FawePlayer.wrap(player);
|
||||
fp.runAction(new Runnable() {
|
||||
fp.runAsyncIfFree(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
reset((BlockTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location);
|
||||
}
|
||||
}, true, true);
|
||||
});
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user