mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-12-01 07:03:52 +01:00
Various
Fix random 1000ms brush delay Fix brush perform location not using snapshot location Add fall command Add getlight debug command Fix relight NPE
This commit is contained in:
parent
efc0de27d4
commit
50ba6427a2
@ -52,7 +52,7 @@ public enum BBC {
|
||||
TRANSFORM_DISABLED("Global transform disabled", "WorldEdit.General"),
|
||||
TRANSFORM("Global transform set", "WorldEdit.General"),
|
||||
|
||||
COMMAND_COPY("%s0 blocks were copied", "WorldEdit.Copy"),
|
||||
COMMAND_COPY("%s0 blocks were copied (Note: lazycopy is faster)", "WorldEdit.Copy"),
|
||||
COMMAND_CUT("%s0 blocks were cut", "WorldEdit.Cut"),
|
||||
COMMAND_PASTE("The clipboard has been pasted at %s0", "WorldEdit.Paste"),
|
||||
COMMAND_ROTATE("The clipboard has been rotated", "WorldEdit.Rotate"),
|
||||
|
@ -138,7 +138,10 @@ public class NMSRelighter {
|
||||
@Override
|
||||
public void run(Object value) {
|
||||
for (Map.Entry<FaweChunk, int[]> entry : fcs.entrySet()) {
|
||||
queue.setHeightMap(entry.getKey(), entry.getValue());
|
||||
FaweChunk chunk = entry.getKey();
|
||||
if (queue.isChunkLoaded(chunk.getX(), chunk.getZ())) {
|
||||
queue.setHeightMap(chunk, entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1,9 +1,7 @@
|
||||
package com.boydti.fawe.object;
|
||||
|
||||
public class IntegerTrio {
|
||||
public final int z;
|
||||
public final int x;
|
||||
public final int y;
|
||||
public int x,y,z;
|
||||
|
||||
public IntegerTrio(int x, int y, int z) {
|
||||
this.x = x;
|
||||
@ -11,13 +9,41 @@ public class IntegerTrio {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public IntegerTrio(IntegerTrio node) {
|
||||
this.x = node.x;
|
||||
this.y = node.y;
|
||||
this.z = node.z;
|
||||
}
|
||||
|
||||
public IntegerTrio() {}
|
||||
|
||||
public final void set(int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public final void set(IntegerTrio node) {
|
||||
this.x = node.x;
|
||||
this.y = node.y;
|
||||
this.z = node.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 13;
|
||||
hash = hash * 13 + x;
|
||||
hash = hash * 13 + y;
|
||||
hash = hash * 13 + z;
|
||||
return hash;
|
||||
public final int hashCode() {
|
||||
return (x ^ (z << 12)) ^ (y << 24);
|
||||
}
|
||||
|
||||
public final int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public final int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public final int getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -27,13 +53,7 @@ public class IntegerTrio {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (obj instanceof IntegerTrio) {
|
||||
IntegerTrio other = (IntegerTrio) obj;
|
||||
return other.x == x && other.z == z && other.y == y;
|
||||
}
|
||||
return false;
|
||||
IntegerTrio other = (IntegerTrio) obj;
|
||||
return other.x == x && other.z == z && other.y == y;
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +59,9 @@ public abstract class FaweChangeSet implements ChangeSet {
|
||||
@Override
|
||||
public void run() {
|
||||
waiting.decrementAndGet();
|
||||
synchronized (lock) {
|
||||
lock.notifyAll();
|
||||
}
|
||||
flush();
|
||||
}
|
||||
});
|
||||
|
@ -1,8 +1,6 @@
|
||||
package com.boydti.fawe.wrappers;
|
||||
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldVector;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.internal.LocalWorldAdapter;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
@ -38,6 +36,10 @@ public class LocationMaskedPlayerWrapper extends PlayerWrapper {
|
||||
return WorldVector.toBlockPoint(pos.getWorld(), pos.getX(), pos.getY() - 1, pos.getZ());
|
||||
}
|
||||
|
||||
public void setPosition(Location position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldVector getPosition() {
|
||||
LocalWorld world;
|
||||
|
@ -4,24 +4,17 @@ import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.RunnableVal;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.EditSessionFactory;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.PlayerDirection;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.WorldVector;
|
||||
import com.sk89q.worldedit.WorldVectorFace;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockType;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extension.platform.AbstractPlayerActor;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||
import com.sk89q.worldedit.session.SessionKey;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.TargetBlock;
|
||||
import com.sk89q.worldedit.util.auth.AuthorizationException;
|
||||
import com.sk89q.worldedit.world.AbstractWorld;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
@ -29,7 +22,7 @@ import java.io.File;
|
||||
import java.util.UUID;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class PlayerWrapper implements Player {
|
||||
public class PlayerWrapper extends AbstractPlayerActor {
|
||||
private final Player parent;
|
||||
|
||||
public PlayerWrapper(Player parent) {
|
||||
@ -57,11 +50,6 @@ public class PlayerWrapper implements Player {
|
||||
return parent.isHoldingPickAxe();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerDirection getCardinalDirection(int yawOffset) {
|
||||
return parent.getCardinalDirection(yawOffset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemInHand() {
|
||||
return parent.getItemInHand();
|
||||
@ -222,22 +210,13 @@ public class PlayerWrapper implements Player {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldVector getBlockIn() {
|
||||
return parent.getBlockIn();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldVector getBlockOn() {
|
||||
return parent.getBlockOn();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldVector getBlockTrace(final int range, final boolean useLastBlock) {
|
||||
return TaskManager.IMP.sync(new RunnableVal<WorldVector>() {
|
||||
@Override
|
||||
public void run(WorldVector value) {
|
||||
this.value = parent.getBlockTrace(range, useLastBlock);
|
||||
TargetBlock tb = new TargetBlock(PlayerWrapper.this, range, 0.2D);
|
||||
this.value = useLastBlock?tb.getAnyTargetBlock():tb.getTargetBlock();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -247,22 +226,19 @@ public class PlayerWrapper implements Player {
|
||||
return TaskManager.IMP.sync(new RunnableVal<WorldVectorFace>() {
|
||||
@Override
|
||||
public void run(WorldVectorFace value) {
|
||||
this.value = parent.getBlockTraceFace(range, useLastBlock);
|
||||
TargetBlock tb = new TargetBlock(PlayerWrapper.this, range, 0.2D);
|
||||
this.value = useLastBlock?tb.getAnyTargetBlockFace():tb.getTargetBlockFace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldVector getBlockTrace(int range) {
|
||||
return getBlockTrace(range, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldVector getSolidBlockTrace(final int range) {
|
||||
return TaskManager.IMP.sync(new RunnableVal<WorldVector>() {
|
||||
@Override
|
||||
public void run(WorldVector value) {
|
||||
this.value = parent.getSolidBlockTrace(range);
|
||||
TargetBlock tb = new TargetBlock(PlayerWrapper.this, range, 0.2D);
|
||||
this.value = tb.getSolidTargetBlock();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -295,7 +271,47 @@ public class PlayerWrapper implements Player {
|
||||
return TaskManager.IMP.sync(new RunnableVal<Boolean>() {
|
||||
@Override
|
||||
public void run(Boolean value) {
|
||||
this.value = parent.passThroughForwardWall(range);
|
||||
int searchDist = 0;
|
||||
TargetBlock hitBlox = new TargetBlock(PlayerWrapper.this, range, 0.2D);
|
||||
LocalWorld world = PlayerWrapper.this.getPosition().getWorld();
|
||||
boolean firstBlock = true;
|
||||
int freeToFind = 2;
|
||||
boolean inFree = false;
|
||||
|
||||
while(true) {
|
||||
BlockWorldVector block;
|
||||
while((block = hitBlox.getNextBlock()) != null) {
|
||||
boolean free = BlockType.canPassThrough(world.getBlock(block));
|
||||
if(firstBlock) {
|
||||
firstBlock = false;
|
||||
if(!free) {
|
||||
--freeToFind;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
++searchDist;
|
||||
if(searchDist > 20) {
|
||||
this.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if(inFree != free && free) {
|
||||
--freeToFind;
|
||||
}
|
||||
|
||||
if(freeToFind == 0) {
|
||||
PlayerWrapper.this.setOnGround(block);
|
||||
this.value = true;
|
||||
return;
|
||||
}
|
||||
|
||||
inFree = free;
|
||||
}
|
||||
|
||||
this.value = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -305,11 +321,6 @@ public class PlayerWrapper implements Player {
|
||||
parent.setPosition(pos, pitch, yaw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(Vector pos) {
|
||||
parent.setPosition(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public BaseEntity getState() {
|
||||
@ -321,11 +332,6 @@ public class PlayerWrapper implements Player {
|
||||
return parent.getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Extent getExtent() {
|
||||
return parent.getExtent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove() {
|
||||
return parent.remove();
|
||||
|
@ -1302,6 +1302,35 @@ public class EditSession extends AbstractWorld implements HasFaweQueue {
|
||||
return this.countBlock(region, ids);
|
||||
}
|
||||
|
||||
public int fall(final Region region, boolean fullHeight, BaseBlock replace) {
|
||||
FlatRegion flat = asFlatRegion(region);
|
||||
int startPerformY = region.getMinimumPoint().getBlockY();
|
||||
int startCheckY = fullHeight ? 0 : startPerformY;
|
||||
int endY = region.getMaximumPoint().getBlockY();
|
||||
for (BlockVector pos : flat) {
|
||||
int x = (int) pos.x;
|
||||
int z = (int) pos.z;
|
||||
int freeSpot = startCheckY;
|
||||
for (int y = startCheckY; y <= endY; y++) {
|
||||
if (y < startPerformY) {
|
||||
if (getLazyBlock(x, y, z) != EditSession.nullBlock) {
|
||||
freeSpot = y + 1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
BaseBlock block = getLazyBlock(x, y, z);
|
||||
if (block != EditSession.nullBlock) {
|
||||
if (freeSpot != y) {
|
||||
setBlock(x, freeSpot, z, block);
|
||||
setBlock(x, y, z, replace);
|
||||
}
|
||||
freeSpot++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.changes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills an area recursively in the X/Z directions.
|
||||
*
|
||||
|
@ -113,6 +113,20 @@ public class RegionCommands {
|
||||
BBC.FIX_LIGHTING_SELECTION.send(fp, count);
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/getlighting" },
|
||||
desc = "Get the light at a position",
|
||||
min = 0,
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.light.fix")
|
||||
public void getlighting(Player player, EditSession editSession) throws WorldEditException {
|
||||
FawePlayer fp = FawePlayer.wrap(player);
|
||||
final FaweLocation loc = fp.getLocation();
|
||||
FaweQueue queue = SetQueue.IMP.getNewQueue(loc.world, true, false);
|
||||
fp.sendMessage("Light: " + queue.getEmmittedLight(loc.x, loc.y, loc.z) + " | " + queue.getSkyLight(loc.x, loc.y, loc.z));
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/removelight", "/removelighting" },
|
||||
desc = "Removing lighting in a selection",
|
||||
@ -395,6 +409,28 @@ public class RegionCommands {
|
||||
BBC.VISITOR_BLOCK.send(player, affected);
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/fall" },
|
||||
usage = "[replace]",
|
||||
flags = "m",
|
||||
desc = "Have the blocks in the selection fall",
|
||||
help =
|
||||
"Make the blocks in the selection fall\n" +
|
||||
"The -m flag will only fall within the vertical selection.",
|
||||
min = 0,
|
||||
max = 2
|
||||
)
|
||||
@CommandPermissions("worldedit.region.fall")
|
||||
@Logging(ORIENTATION_REGION)
|
||||
public void fall(Player player, EditSession editSession, LocalSession session,
|
||||
@Selection Region region,
|
||||
@Optional("air") BaseBlock replace,
|
||||
@Switch('m') boolean notFullHeight) throws WorldEditException {
|
||||
|
||||
int affected = editSession.fall(region, !notFullHeight, replace);
|
||||
BBC.VISITOR_BLOCK.send(player, affected);
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/stack" },
|
||||
usage = "[count] [direction]",
|
||||
|
@ -421,12 +421,12 @@ public class PlatformManager {
|
||||
if (tool != null && tool instanceof BlockTool) {
|
||||
if (tool.canUse(player)) {
|
||||
FawePlayer<?> fp = FawePlayer.wrap(player);
|
||||
fp.runAsyncIfFree(new Runnable() {
|
||||
fp.runAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
reset((BlockTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location);
|
||||
}
|
||||
});
|
||||
}, true, true);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -519,12 +519,12 @@ public class PlatformManager {
|
||||
if (tool != null && tool instanceof TraceTool) {
|
||||
if (tool.canUse(player)) {
|
||||
FawePlayer<?> fp = FawePlayer.wrap(player);
|
||||
fp.runAsyncIfFree(new Runnable() {
|
||||
fp.runAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
reset((TraceTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session);
|
||||
}
|
||||
});
|
||||
}, true, true);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
@ -154,13 +154,13 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
|
||||
public Node() {}
|
||||
|
||||
private final void set(int x, int y, int z) {
|
||||
public final void set(int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
private final void set(Node node) {
|
||||
public final void set(Node node) {
|
||||
this.x = node.x;
|
||||
this.y = node.y;
|
||||
this.z = node.z;
|
||||
@ -171,15 +171,15 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
return (x ^ (z << 12)) ^ (y << 24);
|
||||
}
|
||||
|
||||
private final int getX() {
|
||||
public final int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
private final int getY() {
|
||||
public final int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
private final int getZ() {
|
||||
public final int getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user