fix some more compilation issues

This commit is contained in:
Jesse Boyd 2019-07-22 19:05:14 +10:00
parent 55196cec6d
commit 4d8cf04be1
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
38 changed files with 241 additions and 855 deletions

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.beta; package com.boydti.fawe.beta;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
@ -25,6 +26,22 @@ public interface IDelegateChunk<U extends IChunk> extends IChunk {
return root; return root;
} }
@Override
default IQueueExtent getQueue() {
return getParent().getQueue();
}
@Override
default CompoundTag getTag(int x, int y, int z) {
return getParent().getTag(x, y, z);
}
@Override
default boolean hasSection(int layer) {
return getParent().hasSection(layer);
}
@Override @Override
default void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block) { default void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block) {
getParent().flood(flood, mask, block); getParent().flood(flood, mask, block);

View File

@ -121,4 +121,10 @@ public interface IQueueExtent extends Flushable, Trimable, Extent {
void flush(); void flush();
ChunkFilterBlock initFilterBlock(); ChunkFilterBlock initFilterBlock();
int size();
boolean isEmpty();
void sendChunk(int chunkX, int chunkZ);
} }

View File

@ -216,9 +216,9 @@ public abstract class QueueHandler implements Trimable, Runnable {
public abstract IQueueExtent create(); public abstract IQueueExtent create();
public abstract void startSet(boolean value); public abstract void startSet(boolean parallel);
public abstract void endSet(boolean value); public abstract void endSet(boolean parallel);
public IQueueExtent getQueue(final World world) { public IQueueExtent getQueue(final World world) {
final IQueueExtent queue = queuePool.get(); final IQueueExtent queue = queuePool.get();

View File

@ -85,6 +85,16 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent {
CHUNK_POOL.add(chunk); CHUNK_POOL.add(chunk);
} }
@Override
public int size() {
return chunks.size() + submissions.size();
}
@Override
public boolean isEmpty() {
return chunks.isEmpty() && submissions.isEmpty();
}
@Override @Override
public <T extends Future<T>> T submit(final IChunk<T> chunk) { public <T extends Future<T>> T submit(final IChunk<T> chunk) {
if (lastChunk == chunk) { if (lastChunk == chunk) {

View File

@ -2,6 +2,7 @@ package com.boydti.fawe.beta.implementation.holder;
import com.boydti.fawe.beta.IChunk; import com.boydti.fawe.beta.IChunk;
import com.boydti.fawe.beta.IQueueExtent; import com.boydti.fawe.beta.IQueueExtent;
import com.sk89q.jnbt.CompoundTag;
import java.lang.ref.Reference; import java.lang.ref.Reference;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;

View File

@ -8,6 +8,7 @@ import com.boydti.fawe.object.*;
import com.boydti.fawe.object.changeset.DiskStorageHistory; import com.boydti.fawe.object.changeset.DiskStorageHistory;
import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.TaskManager;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
@ -17,6 +18,8 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
public class Rollback extends FaweCommand { public class Rollback extends FaweCommand {
@ -106,22 +109,14 @@ public class Rollback extends FaweCommand {
BBC.COMMAND_SYNTAX.send(player, "/frb info u:<uuid> r:<radius> t:<time>"); BBC.COMMAND_SYNTAX.send(player, "/frb info u:<uuid> r:<radius> t:<time>");
return false; return false;
} }
final Runnable task = new Runnable() { for (DiskStorageHistory edit : edits) {
@Override
public void run() {
if (edits.size() == 0) {
player.sendMessage("Rollback complete!");
return;
}
DiskStorageHistory edit = edits.remove(0);
player.sendMessage("&d" + edit.getBDFile()); player.sendMessage("&d" + edit.getBDFile());
EditSession session = edit.toEditSession(null); EditSession session = edit.toEditSession(null);
session.undo(session); session.undo(session);
edit.deleteFiles(); edit.deleteFiles();
session.getQueue().addNotifyTask(this); session.flushQueue();
} }
}; player.sendMessage("Rollback complete!");
task.run();
} }
return true; return true;
} }

View File

@ -50,10 +50,10 @@ public class Commands {
} }
public static class TranslatedCommand implements Command { public static class TranslatedCommand implements Command {
private final String name;
private final String[] aliases; private final String[] aliases;
private final String usage;
private final String desc; private final String desc;
private final String help; private final String descFooter;
private final Command command; private final Command command;
public TranslatedCommand(String clazz, Command command) { public TranslatedCommand(String clazz, Command command) {
@ -70,10 +70,10 @@ public class Commands {
} }
HashMap<String, Object> options = new HashMap<>(); HashMap<String, Object> options = new HashMap<>();
options.put("name", command.name());
options.put("aliases", new ArrayList<>(Arrays.asList(command.aliases()))); options.put("aliases", new ArrayList<>(Arrays.asList(command.aliases())));
options.put("usage", command.usage()); options.put("help", command.desc());
options.put("desc", command.desc()); options.put("desc", command.descFooter());
options.put("help", command.help());
for (Map.Entry<String, Object> entry : options.entrySet()) { for (Map.Entry<String, Object> entry : options.entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
if (!commands.contains(key)) { if (!commands.contains(key)) {
@ -88,10 +88,10 @@ public class Commands {
e.printStackTrace(); e.printStackTrace();
} }
} }
this.name = commands.getString("name");
this.aliases = commands.getStringList("aliases").toArray(new String[0]); this.aliases = commands.getStringList("aliases").toArray(new String[0]);
this.usage = commands.getString("usage"); this.desc = commands.getString("help");
this.desc = commands.getString("desc"); this.descFooter = commands.getString("desc");
this.help = commands.getString("help");
this.command = command; this.command = command;
} }
@ -101,13 +101,13 @@ public class Commands {
} }
@Override @Override
public String[] aliases() { public String name() {
return aliases; return name;
} }
@Override @Override
public String usage() { public String[] aliases() {
return usage; return aliases;
} }
@Override @Override
@ -116,33 +116,8 @@ public class Commands {
} }
@Override @Override
public int min() { public String descFooter() {
return this.command.min(); return descFooter;
}
@Override
public int max() {
return this.command.max();
}
@Override
public String flags() {
return this.command.flags();
}
@Override
public String help() {
return help;
}
@Override
public boolean anyFlags() {
return this.command.anyFlags();
}
@Override
public boolean queued() {
return this.command.queued();
} }
} }
} }

View File

@ -150,7 +150,7 @@ public abstract class FawePlayer<T> extends Metadatable {
Runnable newTask = () -> PlatformCommandManager.getInstance().handleCommandTask(() -> { Runnable newTask = () -> PlatformCommandManager.getInstance().handleCommandTask(() -> {
task.run(); task.run();
return null; return null;
}, context, getPlayer(), getSession(), event); }, context, getSession(), event);
setMeta("cmdConfirm", newTask); setMeta("cmdConfirm", newTask);
} }

View File

@ -32,7 +32,7 @@ public class CommandBrush implements Brush {
String replaced = command.replace("{x}", position.getBlockX() + "") String replaced = command.replace("{x}", position.getBlockX() + "")
.replace("{y}", Integer.toString(position.getBlockY())) .replace("{y}", Integer.toString(position.getBlockY()))
.replace("{z}", Integer.toString(position.getBlockZ())) .replace("{z}", Integer.toString(position.getBlockZ()))
.replace("{world}", editSession.getQueue().getWorldName()) .replace("{world}", editSession.getWorld().getName())
.replace("{size}", Integer.toString(radius)); .replace("{size}", Integer.toString(radius));
FawePlayer fp = editSession.getPlayer(); FawePlayer fp = editSession.getPlayer();

View File

@ -79,7 +79,7 @@ public class CopyPastaBrush implements Brush, ResettableTool {
}; };
// Add origin // Add origin
mask.test(position); mask.test(position);
RecursiveVisitor visitor = new RecursiveVisitor(mask, new NullRegionFunction(), (int) size, editSession); RecursiveVisitor visitor = new RecursiveVisitor(mask, new NullRegionFunction(), (int) size);
visitor.visit(position); visitor.visit(position);
Operations.completeBlindly(visitor); Operations.completeBlindly(visitor);
// Build the clipboard // Build the clipboard

View File

@ -127,7 +127,7 @@ public class ImageBrush implements Brush {
} }
return false; return false;
} }
}, vector -> true, Integer.MAX_VALUE, editSession); }, vector -> true, Integer.MAX_VALUE);
visitor.setDirections(Arrays.asList(visitor.DIAGONAL_DIRECTIONS)); visitor.setDirections(Arrays.asList(visitor.DIAGONAL_DIRECTIONS));
visitor.visit(position); visitor.visit(position);
Operations.completeBlindly(visitor); Operations.completeBlindly(visitor);

View File

@ -36,7 +36,6 @@ public class LayerBrush implements Brush {
@Override @Override
public void build(EditSession editSession, BlockVector3 position, Pattern ignore, double size) throws MaxChangedBlocksException { public void build(EditSession editSession, BlockVector3 position, Pattern ignore, double size) throws MaxChangedBlocksException {
final IQueueExtent queue = editSession.getQueue();
final AdjacentAnyMask adjacent = new AdjacentAnyMask(new BlockMask(editSession).add(BlockTypes.AIR, BlockTypes.CAVE_AIR, BlockTypes.VOID_AIR)); final AdjacentAnyMask adjacent = new AdjacentAnyMask(new BlockMask(editSession).add(BlockTypes.AIR, BlockTypes.CAVE_AIR, BlockTypes.VOID_AIR));
final SolidBlockMask solid = new SolidBlockMask(editSession); final SolidBlockMask solid = new SolidBlockMask(editSession);
final RadiusMask radius = new RadiusMask(0, (int) size); final RadiusMask radius = new RadiusMask(0, (int) size);
@ -51,13 +50,13 @@ public class LayerBrush implements Brush {
int depth = visitor.getDepth() + 1; int depth = visitor.getDepth() + 1;
if (depth > 1) { if (depth > 1) {
boolean found = false; boolean found = false;
int previous = layers[depth - 1].getInternalId(); BlockState previous = layers[depth - 1];
int previous2 = layers[depth - 2].getInternalId(); BlockState previous2 = layers[depth - 2];
for (BlockVector3 dir : BreadthFirstSearch.DEFAULT_DIRECTIONS) { for (BlockVector3 dir : BreadthFirstSearch.DEFAULT_DIRECTIONS) {
mutable.setComponents(pos.getBlockX() + dir.getBlockX(), pos.getBlockY() + dir.getBlockY(), pos.getBlockZ() + dir.getBlockZ()); mutable.setComponents(pos.getBlockX() + dir.getBlockX(), pos.getBlockY() + dir.getBlockY(), pos.getBlockZ() + dir.getBlockZ());
if (visitor.isVisited(mutable) && queue.getCachedCombinedId4Data(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous) { if (visitor.isVisited(mutable) && editSession.getBlock(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous) {
mutable.setComponents(pos.getBlockX() + dir.getBlockX() * 2, pos.getBlockY() + dir.getBlockY() * 2, pos.getBlockZ() + dir.getBlockZ() * 2); mutable.setComponents(pos.getBlockX() + dir.getBlockX() * 2, pos.getBlockY() + dir.getBlockY() * 2, pos.getBlockZ() + dir.getBlockZ() * 2);
if (visitor.isVisited(mutable) && queue.getCachedCombinedId4Data(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous2) { if (visitor.isVisited(mutable) && editSession.getBlock(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous2) {
found = true; found = true;
break; break;
} else { } else {
@ -74,8 +73,8 @@ public class LayerBrush implements Brush {
}, pos -> { }, pos -> {
int depth = visitor.getDepth(); int depth = visitor.getDepth();
BlockStateHolder currentPattern = layers[depth]; BlockStateHolder currentPattern = layers[depth];
return editSession.setBlock(pos, currentPattern); return currentPattern.apply(editSession, pos, pos);
}, layers.length - 1, editSession); }, layers.length - 1);
for (BlockVector3 pos : visited) { for (BlockVector3 pos : visited) {
visitor.visit(pos); visitor.visit(pos);
} }

View File

@ -49,7 +49,7 @@ public class RecurseBrush implements Brush {
visitor.visit(position); visitor.visit(position);
Operations.completeBlindly(visitor); Operations.completeBlindly(visitor);
} else { } else {
RecursiveVisitor visitor = new RecursiveVisitor(mask, replace, radius, editSession) { RecursiveVisitor visitor = new RecursiveVisitor(mask, replace, radius) {
@Override @Override
public boolean isVisitable(BlockVector3 from, BlockVector3 to) { public boolean isVisitable(BlockVector3 from, BlockVector3 to) {
int y = to.getBlockY(); int y = to.getBlockY();

View File

@ -51,7 +51,7 @@ public class SplatterBrush extends ScatterBrush {
return true; return true;
} }
return false; return false;
}, vector -> editSession.setBlock(vector, finalPattern), recursion, editSession); }, vector -> editSession.setBlock(vector, finalPattern), recursion);
visitor.setMaxBranch(2); visitor.setMaxBranch(2);
visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS)); visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS));
visitor.visit(position); visitor.visit(position);

View File

@ -93,7 +93,7 @@ public class StencilBrush extends HeightBrush {
} }
return false; return false;
} }
}, vector -> true, Integer.MAX_VALUE, editSession); }, vector -> true, Integer.MAX_VALUE);
visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS)); visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS));
visitor.visit(position); visitor.visit(position);
Operations.completeBlindly(visitor); Operations.completeBlindly(visitor);

View File

@ -23,7 +23,6 @@ public abstract class ScrollAction implements ScrollTool {
parserContext.setActor(player); parserContext.setActor(player);
parserContext.setWorld(player.getWorld()); parserContext.setWorld(player.getWorld());
parserContext.setSession(session); parserContext.setSession(session);
final LocalConfiguration config = WorldEdit.getInstance().getConfiguration();
String[] split = arguments.split(" "); String[] split = arguments.split(" ");
switch (split[0].toLowerCase()) { switch (split[0].toLowerCase()) {
case "none": case "none":

View File

@ -6,7 +6,6 @@ import com.boydti.fawe.object.FaweInputStream;
import com.boydti.fawe.object.FaweOutputStream; import com.boydti.fawe.object.FaweOutputStream;
import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.Metadatable; import com.boydti.fawe.object.Metadatable;
import com.boydti.fawe.object.RunnableVal2;
import com.boydti.fawe.object.brush.visualization.VirtualWorld; import com.boydti.fawe.object.brush.visualization.VirtualWorld;
import com.boydti.fawe.object.change.StreamChange; import com.boydti.fawe.object.change.StreamChange;
import com.boydti.fawe.object.changeset.CFIChangeSet; import com.boydti.fawe.object.changeset.CFIChangeSet;
@ -20,17 +19,14 @@ import com.boydti.fawe.object.schematic.Schematic;
import com.boydti.fawe.util.CachedTextureUtil; import com.boydti.fawe.util.CachedTextureUtil;
import com.boydti.fawe.util.RandomTextureUtil; import com.boydti.fawe.util.RandomTextureUtil;
import com.boydti.fawe.util.ReflectionUtils; import com.boydti.fawe.util.ReflectionUtils;
import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.util.TextureUtil; import com.boydti.fawe.util.TextureUtil;
import com.boydti.fawe.util.image.Drawable; import com.boydti.fawe.util.image.Drawable;
import com.boydti.fawe.util.image.ImageViewer; import com.boydti.fawe.util.image.ImageViewer;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.Operation;
@ -47,7 +43,6 @@ import com.sk89q.worldedit.registry.state.PropertyKey;
import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes; import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.block.BlockID; import com.sk89q.worldedit.world.block.BlockID;
@ -62,9 +57,8 @@ import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.nio.file.Path;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
@ -816,9 +810,10 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
// } // }
// } // }
@Nullable
@Override @Override
public File getSaveFolder() { public Path getStoragePath() {
return getFolder(); return getFolder().toPath();
} }
@Override @Override
@ -845,20 +840,13 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
e.printStackTrace(); e.printStackTrace();
} }
} }
clear();
return null; return null;
} }
@Override
public void clear() {
this.editSession = null;
}
@Override @Override
public void close(boolean update) { public void close(boolean update) {
clear();
if (chunkOffset != null && player != null && update) { if (chunkOffset != null && player != null && update) {
IQueueExtent packetQueue = SetQueue.IMP.getNewQueue(player.getWorld(), true, false); IQueueExtent packetQueue = Fawe.get().getQueueHandler().getQueue(player.getWorld());
int lenCX = (getWidth() + 15) >> 4; int lenCX = (getWidth() + 15) >> 4;
int lenCZ = (getLength() + 15) >> 4; int lenCZ = (getLength() + 15) >> 4;
@ -897,7 +885,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
return BiomeTypes.get(biomes.getByte(index)); return BiomeTypes.get(biomes.getByte(index));
} }
@Override // @Override
public int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException { public int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException {
int index = z * getWidth() + x; int index = z * getWidth() + x;
if (y < 0) return 0; if (y < 0) return 0;
@ -1023,7 +1011,9 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
} }
public BufferedImage draw() { public BufferedImage draw() {
return new HeightMapMCADrawer(this).draw(); // TODO NOT IMPLEMENTED
// return new HeightMapMCADrawer(this).draw();
return null;
} }
public void setBiomePriority(int value) { public void setBiomePriority(int value) {

View File

@ -1,13 +1,9 @@
package com.boydti.fawe.object.change; package com.boydti.fawe.object.change;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.object.HasIQueueExtent;
import com.boydti.fawe.util.ExtentTraverser;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.history.UndoContext; import com.sk89q.worldedit.history.UndoContext;
import com.sk89q.worldedit.history.change.Change; import com.sk89q.worldedit.history.change.Change;
import com.sk89q.worldedit.world.block.BlockState;
public class MutableBlockChange implements Change { public class MutableBlockChange implements Change {
@ -34,22 +30,7 @@ public class MutableBlockChange implements Change {
create(context); create(context);
} }
private IQueueExtent queue;
private boolean checkedQueue;
public void create(UndoContext context) { public void create(UndoContext context) {
if (queue != null) { context.getExtent().setBlock(x, y, z, BlockState.getFromOrdinal(combinedId));
queue.setBlock(x, y, z, combinedId);
}
if (!checkedQueue) {
checkedQueue = true;
Extent extent = context.getExtent();
ExtentTraverser found = new ExtentTraverser(extent).find(HasIQueueExtent.class);
if (found != null) {
(queue = ((HasIQueueExtent) found.get()).getQueue()).setBlock(x, y, z, combinedId);
} else {
Fawe.debug("FAWE does not support: " + extent + " for " + getClass() + " (bug Empire92)");
}
}
} }
} }

View File

@ -92,7 +92,7 @@ public class WorldCopyClipboard extends ReadOnlyClipboard {
} }
task.run(x, y, z, block); task.run(x, y, z, block);
return true; return true;
}, extent instanceof EditSession ? (EditSession) extent : null); });
Operations.completeBlindly(visitor); Operations.completeBlindly(visitor);
} else { } else {
CuboidRegion cuboidEquivalent = new CuboidRegion(region.getMinimumPoint(), region.getMaximumPoint()); CuboidRegion cuboidEquivalent = new CuboidRegion(region.getMinimumPoint(), region.getMaximumPoint());
@ -118,7 +118,7 @@ public class WorldCopyClipboard extends ReadOnlyClipboard {
return true; return true;
} }
}, extent instanceof EditSession ? (EditSession) extent : null); });
Operations.completeBlindly(visitor); Operations.completeBlindly(visitor);
} }
} else { } else {

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.regions.general.plot; package com.boydti.fawe.regions.general.plot;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IQueueExtent; import com.boydti.fawe.beta.IQueueExtent;
@ -9,10 +10,12 @@ import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes; import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.biome.Biomes; import com.sk89q.worldedit.world.biome.Biomes;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.registry.BiomeRegistry; import com.sk89q.worldedit.world.registry.BiomeRegistry;
import com.sk89q.worldedit.world.registry.LegacyMapper; import com.sk89q.worldedit.world.registry.LegacyMapper;
@ -24,45 +27,47 @@ public class FaweLocalBlockQueue extends LocalBlockQueue {
public final IQueueExtent IMP; public final IQueueExtent IMP;
private final LegacyMapper legacyMapper; private final LegacyMapper legacyMapper;
public FaweLocalBlockQueue(String world) { public FaweLocalBlockQueue(String worldName) {
super(world); super(worldName);
IMP = SetQueue.IMP.getNewQueue(FaweAPI.getWorld(world), true, false); World world = FaweAPI.getWorld(worldName);
IMP = Fawe.get().getQueueHandler().getQueue(world);
legacyMapper = LegacyMapper.getInstance(); legacyMapper = LegacyMapper.getInstance();
} }
@Override @Override
public boolean next() { public boolean next() {
return IMP.size() > 0; if (!IMP.isEmpty()) {
IMP.flush();
}
return false;
} }
@Override @Override
public void startSet(boolean parallel) { public void startSet(boolean parallel) {
IMP.startSet(parallel); Fawe.get().getQueueHandler().startSet(parallel);
} }
@Override @Override
public void endSet(boolean parallel) { public void endSet(boolean parallel) {
IMP.endSet(parallel); Fawe.get().getQueueHandler().endSet(parallel);
} }
@Override @Override
public int size() { public int size() {
return IMP.size(); return IMP.isEmpty() ? 0 : 1;
} }
@Override @Override
public void optimize() { public void optimize() {
IMP.optimize();
} }
@Override @Override
public void setModified(long l) { public void setModified(long l) {
IMP.setModified(l);
} }
@Override @Override
public long getModified() { public long getModified() {
return IMP.getModified(); return IMP.size();
} }
@Override @Override
@ -77,9 +82,8 @@ public class FaweLocalBlockQueue extends LocalBlockQueue {
@Override @Override
public PlotBlock getBlock(int x, int y, int z) { public PlotBlock getBlock(int x, int y, int z) {
int combined = IMP.getCombinedId4Data(x, y, z); BlockState block = IMP.getBlock(x, y, z);
com.sk89q.worldedit.world.block.BlockState state = com.sk89q.worldedit.world.block.BlockState.getFromInternalId(combined); return PlotBlock.get(block.toBaseBlock());
return PlotBlock.get(state.getInternalBlockTypeId(), state.getInternalPropertiesId());
} }
private BiomeType biome; private BiomeType biome;
@ -96,12 +100,12 @@ public class FaweLocalBlockQueue extends LocalBlockQueue {
lastBiome = biome; lastBiome = biome;
this.biome = Biomes.findBiomeByName(biomes, biome, reg); this.biome = Biomes.findBiomeByName(biomes, biome, reg);
} }
return IMP.setBiome(x, z, this.biome); return IMP.setBiome(x, 0, z, this.biome);
} }
@Override @Override
public String getWorld() { public String getWorld() {
return IMP.getWorldName(); return IMP.getWorld().getName();
} }
@Override @Override
@ -112,12 +116,12 @@ public class FaweLocalBlockQueue extends LocalBlockQueue {
@Override @Override
public void enqueue() { public void enqueue() {
super.enqueue(); super.enqueue();
IMP.enqueue(); IMP.enableQueue();
} }
@Override @Override
public void refreshChunk(int x, int z) { public void refreshChunk(int x, int z) {
IMP.sendChunk(IMP.getFaweChunk(x, z)); IMP.sendChunk(x, z);
} }
@Override @Override
@ -126,7 +130,7 @@ public class FaweLocalBlockQueue extends LocalBlockQueue {
@Override @Override
public void regenChunk(int x, int z) { public void regenChunk(int x, int z) {
IMP.regenerateChunk(x, z); IMP.regenerateChunk(x, z, null, null);
} }
@Override @Override

View File

@ -1,12 +1,10 @@
package com.boydti.fawe.regions.general.plot; package com.boydti.fawe.regions.general.plot;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.object.clipboard.ReadOnlyClipboard; import com.boydti.fawe.object.clipboard.ReadOnlyClipboard;
import com.boydti.fawe.object.io.PGZIPOutputStream; import com.boydti.fawe.object.io.PGZIPOutputStream;
import com.boydti.fawe.util.EditSessionBuilder; import com.boydti.fawe.util.EditSessionBuilder;
import com.boydti.fawe.util.IOUtil; import com.boydti.fawe.util.IOUtil;
import com.boydti.fawe.util.SetQueue;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
@ -29,7 +27,6 @@ import com.sk89q.worldedit.regions.CuboidRegion;
import net.jpountz.lz4.LZ4BlockInputStream; import net.jpountz.lz4.LZ4BlockInputStream;
import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
import java.io.DataInputStream;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@ -47,9 +44,6 @@ public class FaweSchematicHandler extends SchematicHandler {
queue.setTile(x, y, z, compoundTag); queue.setTile(x, y, z, compoundTag);
return true; return true;
} }
IQueueExtent IQueueExtent = SetQueue.IMP.getNewQueue(((FaweLocalBlockQueue) queue).IMP.getWEWorld(), true, false);
IQueueExtent.setTile(x, y, z, (CompoundTag) FaweCache.asTag(compoundTag));
IQueueExtent.flush();
return false; return false;
} }

View File

@ -61,7 +61,11 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
} }
// Don't delete // Don't delete
public NBTOutputStream(DataOutput os) throws IOException { public NBTOutputStream(DataOutput os) {
this.os = os;
}
public NBTOutputStream(DataOutputStream os) {
this.os = os; this.os = os;
} }

View File

@ -11,7 +11,11 @@ import com.boydti.fawe.object.extent.ResettableExtent;
import com.boydti.fawe.object.io.PGZIPOutputStream; import com.boydti.fawe.object.io.PGZIPOutputStream;
import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.StringMan;
import com.google.common.collect.Iterables;
import com.sk89q.worldedit.command.argument.Arguments;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.internal.command.CommandArgParser;
import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.inject.InjectedValueAccess; import org.enginehub.piston.inject.InjectedValueAccess;
@ -44,6 +48,7 @@ import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.nio.file.FileSystems; import java.nio.file.FileSystems;
import java.util.List;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
/** /**
@ -194,12 +199,12 @@ public class BrushOptionsCommands {
descFooter = "Set the right click brush" descFooter = "Set the right click brush"
) )
@CommandPermissions("worldedit.brush.primary") @CommandPermissions("worldedit.brush.primary")
public void primary(Player player, LocalSession session, InjectedValueAccess args) public void primary(Player player, LocalSession session,
throws WorldEditException { @Arg(desc = "The brush command", variable = true) List<String> command) throws WorldEditException {
BaseItem item = player.getItemInHand(HandSide.MAIN_HAND); BaseItem item = player.getItemInHand(HandSide.MAIN_HAND);
BrushTool tool = session.getBrushTool(player, false); BrushTool tool = session.getBrushTool(player, false);
session.setTool(item, null, player); session.setTool(item, null, player);
String cmd = "brush " + args.getJoinedStrings(0); String cmd = "brush " + StringMan.join(command, " ");
CommandEvent event = new CommandEvent(player, cmd); CommandEvent event = new CommandEvent(player, cmd);
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event); PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event);
BrushTool newTool = session.getBrushTool(item, player, false); BrushTool newTool = session.getBrushTool(item, player, false);
@ -214,12 +219,13 @@ public class BrushOptionsCommands {
descFooter = "Set the left click brush" descFooter = "Set the left click brush"
) )
@CommandPermissions("worldedit.brush.secondary") @CommandPermissions("worldedit.brush.secondary")
public void secondary(Player player, LocalSession session, InjectedValueAccess args) public void secondary(Player player, LocalSession session,
@Arg(desc = "The brush command", variable = true) List<String> command)
throws WorldEditException { throws WorldEditException {
BaseItem item = player.getItemInHand(HandSide.MAIN_HAND); BaseItem item = player.getItemInHand(HandSide.MAIN_HAND);
BrushTool tool = session.getBrushTool(player, false); BrushTool tool = session.getBrushTool(player, false);
session.setTool(item, null, player); session.setTool(item, null, player);
String cmd = "brush " + args.getJoinedStrings(0); String cmd = "brush " + StringMan.join(command, " ");
CommandEvent event = new CommandEvent(player, cmd); CommandEvent event = new CommandEvent(player, cmd);
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event); PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event);
BrushTool newTool = session.getBrushTool(item, player, false); BrushTool newTool = session.getBrushTool(item, player, false);
@ -276,21 +282,14 @@ public class BrushOptionsCommands {
desc = "Set the targeting mask" desc = "Set the targeting mask"
) )
@CommandPermissions("worldedit.brush.targetmask") @CommandPermissions("worldedit.brush.targetmask")
public void targetMask(Player player, EditSession editSession, LocalSession session, public void targetMask(Player player, EditSession editSession, LocalSession session, Mask mask) throws WorldEditException {
InjectedValueAccess context) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false); BrushTool tool = session.getBrushTool(player, false);
if (tool == null) { if (tool == null) {
BBC.BRUSH_NONE.send(player); BBC.BRUSH_NONE.send(player);
return; return;
} }
ParserContext parserContext = new ParserContext();
parserContext.setActor(player);
parserContext.setWorld(player.getWorld());
parserContext.setSession(session);
parserContext.setExtent(editSession);
Mask mask = worldEdit.getMaskFactory().parseFromInput(context.getJoinedStrings(0), parserContext);
tool.setTraceMask(mask); tool.setTraceMask(mask);
BBC.BRUSH_TARGET_MASK_SET.send(player, context.getJoinedStrings(0)); BBC.BRUSH_TARGET_MASK_SET.send(player, mask.toString());
} }
@Command( @Command(
@ -319,14 +318,17 @@ public class BrushOptionsCommands {
@Switch(name = 'h', desc = "TODO") @Switch(name = 'h', desc = "TODO")
boolean offHand, boolean offHand,
@Arg(desc="Target Modes") @Arg(desc="Target Modes")
String modes, InjectedValueAccess args) throws WorldEditException { String modes,
@Arg(desc = "The scroll action", variable = true)
List<String> command) throws WorldEditException {
// TODO NOT IMPLEMENTED Convert ScrollAction to an argument converter
BrushTool bt = session.getBrushTool(player, false); BrushTool bt = session.getBrushTool(player, false);
if (bt == null) { if (bt == null) {
BBC.BRUSH_NONE.send(player); BBC.BRUSH_NONE.send(player);
return; return;
} }
BrushSettings settings = offHand ? bt.getOffHand() : bt.getContext(); BrushSettings settings = offHand ? bt.getOffHand() : bt.getContext();
ScrollAction action = ScrollAction.fromArguments(bt, player, session, args.getJoinedStrings(0), true); ScrollAction action = ScrollAction.fromArguments(bt, player, session, StringMan.join(command, " "), true);
settings.setScrollAction(action); settings.setScrollAction(action);
if (modes.equalsIgnoreCase("none")) { if (modes.equalsIgnoreCase("none")) {
BBC.BRUSH_SCROLL_ACTION_UNSET.send(player); BBC.BRUSH_SCROLL_ACTION_UNSET.send(player);
@ -345,26 +347,25 @@ public class BrushOptionsCommands {
@CommandPermissions({"worldedit.brush.options.mask", "worldedit.mask.brush"}) @CommandPermissions({"worldedit.brush.options.mask", "worldedit.mask.brush"})
public void mask(Player player, LocalSession session, EditSession editSession, public void mask(Player player, LocalSession session, EditSession editSession,
@Switch(name = 'h', desc = "TODO") @Switch(name = 'h', desc = "TODO")
boolean offHand, InjectedValueAccess context) boolean offHand,
@Arg(desc = "The destination mask", def = "")
Mask mask,
Arguments arguments)
throws WorldEditException { throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false); BrushTool tool = session.getBrushTool(player, false);
if (tool == null) { if (tool == null) {
player.print(BBC.BRUSH_NONE.f()); player.print(BBC.BRUSH_NONE.f());
return; return;
} }
if (context.argsLength() == 0) { if (mask == null) {
BBC.BRUSH_MASK_DISABLED.send(player); BBC.BRUSH_MASK_DISABLED.send(player);
tool.setMask(null); tool.setMask(null);
return; return;
} }
ParserContext parserContext = new ParserContext();
parserContext.setActor(player);
parserContext.setWorld(player.getWorld());
parserContext.setSession(session);
parserContext.setExtent(editSession);
Mask mask = worldEdit.getMaskFactory().parseFromInput(context.getJoinedStrings(0), parserContext);
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext(); BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
settings.addSetting(BrushSettings.SettingType.MASK, context.getString(context.argsLength() - 1)); String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
System.out.println(lastArg + " TODO check this is not the whole command");
settings.addSetting(BrushSettings.SettingType.MASK, lastArg);
settings.setMask(mask); settings.setMask(mask);
tool.update(); tool.update();
BBC.BRUSH_MASK.send(player); BBC.BRUSH_MASK.send(player);
@ -378,29 +379,24 @@ public class BrushOptionsCommands {
) )
@CommandPermissions({"worldedit.brush.options.mask", "worldedit.mask.brush"}) @CommandPermissions({"worldedit.brush.options.mask", "worldedit.mask.brush"})
public void smask(Player player, LocalSession session, EditSession editSession, public void smask(Player player, LocalSession session, EditSession editSession,
@Arg(desc = "The destination mask", def = "")
Mask mask,
@Switch(name = 'h', desc = "TODO") @Switch(name = 'h', desc = "TODO")
boolean offHand, boolean offHand,
InjectedValueAccess context) throws WorldEditException { Arguments arguments) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false); BrushTool tool = session.getBrushTool(player, false);
if (tool == null) { if (tool == null) {
player.print(BBC.BRUSH_NONE.f()); player.print(BBC.BRUSH_NONE.f());
return; return;
} }
if (context.argsLength() == 0) { if (mask == null) {
BBC.BRUSH_SOURCE_MASK_DISABLED.send(player); BBC.BRUSH_SOURCE_MASK_DISABLED.send(player);
tool.setSourceMask(null); tool.setSourceMask(null);
return; return;
} }
ParserContext parserContext = new ParserContext();
parserContext.setActor(player);
parserContext.setWorld(player.getWorld());
parserContext.setSession(session);
parserContext.setExtent(editSession);
Mask mask = worldEdit.getMaskFactory()
.parseFromInput(context.getJoinedStrings(0), parserContext);
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext(); BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
settings.addSetting(BrushSettings.SettingType.SOURCE_MASK, String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
context.getString(context.argsLength() - 1)); settings.addSetting(BrushSettings.SettingType.SOURCE_MASK, lastArg);
settings.setSourceMask(mask); settings.setSourceMask(mask);
tool.update(); tool.update();
BBC.BRUSH_SOURCE_MASK.send(player); BBC.BRUSH_SOURCE_MASK.send(player);
@ -412,27 +408,23 @@ public class BrushOptionsCommands {
) )
@CommandPermissions({"worldedit.brush.options.transform", "worldedit.transform.brush"}) @CommandPermissions({"worldedit.brush.options.transform", "worldedit.transform.brush"})
public void transform(Player player, LocalSession session, EditSession editSession, public void transform(Player player, LocalSession session, EditSession editSession,
@Arg(desc = "The transform", def = "") ResettableExtent transform,
@Switch(name = 'h', desc = "TODO") @Switch(name = 'h', desc = "TODO")
boolean offHand, boolean offHand,
InjectedValueAccess context) throws WorldEditException { Arguments arguments) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false); BrushTool tool = session.getBrushTool(player, false);
if (tool == null) { if (tool == null) {
player.print(BBC.BRUSH_NONE.f()); player.print(BBC.BRUSH_NONE.f());
return; return;
} }
if (context.argsLength() == 0) { if (transform == null) {
BBC.BRUSH_TRANSFORM_DISABLED.send(player); BBC.BRUSH_TRANSFORM_DISABLED.send(player);
tool.setTransform(null); tool.setTransform(null);
return; return;
} }
ParserContext parserContext = new ParserContext();
parserContext.setActor(player);
parserContext.setWorld(player.getWorld());
parserContext.setSession(session);
parserContext.setExtent(editSession);
ResettableExtent transform = Fawe.get().getTransformParser().parseFromInput(context.getJoinedStrings(0), parserContext);
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext(); BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
settings.addSetting(BrushSettings.SettingType.TRANSFORM, context.getString(context.argsLength() - 1)); String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
settings.addSetting(BrushSettings.SettingType.TRANSFORM, lastArg);
settings.setTransform(transform); settings.setTransform(transform);
tool.update(); tool.update();
BBC.BRUSH_TRANSFORM.send(player); BBC.BRUSH_TRANSFORM.send(player);
@ -445,23 +437,24 @@ public class BrushOptionsCommands {
) )
@CommandPermissions("worldedit.brush.options.material") @CommandPermissions("worldedit.brush.options.material")
public void material(Player player, EditSession editSession, LocalSession session, public void material(Player player, EditSession editSession, LocalSession session,
Pattern pattern, @Arg(desc = "brush material pattern", def = "") Pattern pattern,
@Switch(name = 'h', desc = "TODO") @Switch(name = 'h', desc = "TODO")
boolean offHand, boolean offHand,
InjectedValueAccess context) throws WorldEditException { Arguments arguments) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false); BrushTool tool = session.getBrushTool(player, false);
if (tool == null) { if (tool == null) {
player.print(BBC.BRUSH_NONE.f()); player.print(BBC.BRUSH_NONE.f());
return; return;
} }
if (context.argsLength() == 0) { if (pattern == null) {
BBC.BRUSH_TRANSFORM_DISABLED.send(player); BBC.BRUSH_MATERIAL.send(player);
tool.setFill(null); tool.setFill(null);
return; return;
} }
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext(); BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
settings.setFill(pattern); settings.setFill(pattern);
settings.addSetting(BrushSettings.SettingType.FILL, context.getString(context.argsLength() - 1)); String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
settings.addSetting(BrushSettings.SettingType.FILL, lastArg);
tool.update(); tool.update();
BBC.BRUSH_MATERIAL.send(player); BBC.BRUSH_MATERIAL.send(player);
} }

View File

@ -27,7 +27,9 @@ import com.boydti.fawe.util.CachedTextureUtil;
import com.boydti.fawe.util.CleanTextureUtil; import com.boydti.fawe.util.CleanTextureUtil;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.RandomTextureUtil; import com.boydti.fawe.util.RandomTextureUtil;
import com.boydti.fawe.util.StringMan;
import com.boydti.fawe.util.TextureUtil; import com.boydti.fawe.util.TextureUtil;
import com.sk89q.worldedit.extension.input.InputParseException;
import org.enginehub.piston.inject.InjectedValueAccess; import org.enginehub.piston.inject.InjectedValueAccess;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalConfiguration;
@ -297,26 +299,28 @@ public class GeneralCommands {
desc = "Set the global mask" desc = "Set the global mask"
) )
@CommandPermissions("worldedit.global-texture") @CommandPermissions("worldedit.global-texture")
public void gtexture(FawePlayer player, LocalSession session, EditSession editSession, @Arg(name = "context", desc = "InjectedValueAccess", def = "") InjectedValueAccess context) throws WorldEditException, FileNotFoundException, ParameterException { public void gtexture(FawePlayer player, LocalSession session, EditSession editSession, @Arg(name = "context", desc = "InjectedValueAccess", def = "") List<String> arguments) throws WorldEditException, FileNotFoundException {
if (context == null || context.argsLength() == 0) { // gtexture <randomize> <min=0> <max=100>
// TODO NOT IMPLEMENTED convert this to an ArgumentConverter
if (arguments.isEmpty()) {
session.setTextureUtil(null); session.setTextureUtil(null);
BBC.TEXTURE_DISABLED.send(player); BBC.TEXTURE_DISABLED.send(player);
} else { } else {
String arg = context.getString(0); String arg = arguments.get(0);
String argLower = arg.toLowerCase(); String argLower = arg.toLowerCase();
TextureUtil util = Fawe.get().getTextureUtil(); TextureUtil util = Fawe.get().getTextureUtil();
int randomIndex = 1; int randomIndex = 1;
boolean checkRandomization = true; boolean checkRandomization = true;
if (context.argsLength() >= 2 && MathMan.isInteger(context.getString(0)) && MathMan.isInteger(context.getString(1))) { if (arguments.size() >= 2 && MathMan.isInteger(arguments.get(0)) && MathMan.isInteger(arguments.get(1))) {
// complexity // complexity
int min = Integer.parseInt(context.getString(0)); int min = Integer.parseInt(arguments.get(0));
int max = Integer.parseInt(context.getString(1)); int max = Integer.parseInt(arguments.get(1));
if (min < 0 || max > 100) throw new ParameterException("Complexity must be in the range 0-100"); if (min < 0 || max > 100) throw new InputParseException("Complexity must be in the range 0-100");
if (min != 0 || max != 100) util = new CleanTextureUtil(util, min, max); if (min != 0 || max != 100) util = new CleanTextureUtil(util, min, max);
randomIndex = 2; randomIndex = 2;
} else if (context.argsLength() == 1 && argLower.equals("true") || argLower.equals("false")) { } else if (arguments.size() == 1 && argLower.equals("true") || argLower.equals("false")) {
if (argLower.equals("true")) util = new RandomTextureUtil(util); if (argLower.equals("true")) util = new RandomTextureUtil(util);
checkRandomization = false; checkRandomization = false;
} else { } else {
@ -337,14 +341,14 @@ public class GeneralCommands {
} }
} }
if (checkRandomization) { if (checkRandomization) {
if (context.argsLength() > randomIndex) { if (arguments.size() > randomIndex) {
boolean random = Boolean.parseBoolean(context.getString(randomIndex)); boolean random = Boolean.parseBoolean(arguments.get(randomIndex));
if (random) util = new RandomTextureUtil(util); if (random) util = new RandomTextureUtil(util);
} }
} }
if (!(util instanceof CachedTextureUtil)) util = new CachedTextureUtil(util); if (!(util instanceof CachedTextureUtil)) util = new CachedTextureUtil(util);
session.setTextureUtil(util); session.setTextureUtil(util);
BBC.TEXTURE_SET.send(player, context.getJoinedStrings(0)); BBC.TEXTURE_SET.send(player, StringMan.join(arguments, " "));
} }
} }

View File

@ -19,28 +19,11 @@
package com.sk89q.worldedit.command; package com.sk89q.worldedit.command;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.command.util.Logging.LogMode.ALL;
import static com.sk89q.worldedit.command.util.Logging.LogMode.ORIENTATION_REGION;
import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION;
import static com.sk89q.worldedit.internal.command.CommandUtil.checkCommandArgument;
import static com.sk89q.worldedit.regions.Regions.asFlatRegion;
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.beta.filters.DistrFilter;
import com.boydti.fawe.beta.filters.SetFilter;
import com.boydti.fawe.beta.implementation.QueueHandler;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.object.visitor.Fast2DIterator;
import com.boydti.fawe.util.MathMan;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
@ -50,7 +33,6 @@ import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.command.util.Logging; import com.sk89q.worldedit.command.util.Logging;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.function.GroundFunction; import com.sk89q.worldedit.function.GroundFunction;
import com.sk89q.worldedit.function.generator.FloraGenerator; import com.sk89q.worldedit.function.generator.FloraGenerator;
import com.sk89q.worldedit.function.mask.ExistingBlockMask; import com.sk89q.worldedit.function.mask.ExistingBlockMask;
@ -78,23 +60,27 @@ import com.sk89q.worldedit.regions.RegionOperationException;
import com.sk89q.worldedit.regions.Regions; import com.sk89q.worldedit.regions.Regions;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.TreeGenerator.TreeType; import com.sk89q.worldedit.util.TreeGenerator.TreeType;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.biome.Biomes;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.registry.BiomeRegistry;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg; import org.enginehub.piston.annotation.param.Arg;
import org.enginehub.piston.annotation.param.Switch; import org.enginehub.piston.annotation.param.Switch;
import org.enginehub.piston.inject.InjectedValueAccess; import org.enginehub.piston.inject.InjectedValueAccess;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.command.util.Logging.LogMode.ALL;
import static com.sk89q.worldedit.command.util.Logging.LogMode.ORIENTATION_REGION;
import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION;
import static com.sk89q.worldedit.internal.command.CommandUtil.checkCommandArgument;
import static com.sk89q.worldedit.regions.Regions.asFlatRegion;
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
/** /**
* Commands that operate on regions. * Commands that operate on regions.
*/ */
@ -113,39 +99,6 @@ public class RegionCommands extends MethodCommands {
this.worldEdit = worldEdit; this.worldEdit = worldEdit;
} }
@Command(
name = "debugtest",
desc = "debugtest"
)
@CommandPermissions("fawe.admin.debug")
public void debugtest(Player player, @Selection Region region) throws WorldEditException {
QueueHandler queueHandler = Fawe.get().getQueueHandler();
World world = player.getWorld();
DistrFilter filter = new DistrFilter();
long start = System.currentTimeMillis();
queueHandler.apply(world, region, filter);
long diff = System.currentTimeMillis() - start;
System.out.println(diff);
}
@Command(
name = "db2",
desc = "db2"
)
@CommandPermissions("fawe.admin.debug")
public void db2(Player player, @Selection Region region, String blockStr) throws WorldEditException {
QueueHandler queueHandler = Fawe.get().getQueueHandler();
World world = player.getWorld();
BlockState block = BlockState.get(blockStr);
SetFilter filter = new SetFilter(block);
long start = System.currentTimeMillis();
queueHandler.apply(world, region, filter);
long diff = System.currentTimeMillis() - start;
System.out.println(diff);
}
@Command( @Command(
name = "/fixlighting", name = "/fixlighting",
desc = "Get the light at a position" desc = "Get the light at a position"
@ -366,7 +319,7 @@ public class RegionCommands extends MethodCommands {
BlockVector3 max = region.getMaximumPoint(); BlockVector3 max = region.getMaximumPoint();
int maxY = max.getBlockY(); int maxY = max.getBlockY();
Iterable<BlockVector2> flat = Regions.asFlatRegion(region).asFlatRegion(); Iterable<BlockVector2> flat = Regions.asFlatRegion(region).asFlatRegion();
Iterator<BlockVector2> iter = new Fast2DIterator(flat, editSession).iterator(); Iterator<BlockVector2> iter = flat.iterator();
int y = 0; int y = 0;
int affected = 0; int affected = 0;
while (iter.hasNext()) { while (iter.hasNext()) {

View File

@ -1,68 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.command.composition;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.minecraft.util.commands.CommandException;
import com.sk89q.minecraft.util.commands.CommandLocals;
import com.sk89q.worldedit.command.argument.RegionFunctionParser;
import com.sk89q.worldedit.function.Contextual;
import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.function.factory.Apply;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.util.command.argument.CommandArgs;
import com.sk89q.worldedit.util.command.composition.CommandExecutor;
import com.sk89q.worldedit.util.command.composition.SimpleCommand;
public class ApplyCommand extends SimpleCommand<Contextual<? extends Operation>> {
private final CommandExecutor<Contextual<? extends RegionFunction>> functionParser;
private final String description;
public ApplyCommand() {
this(new RegionFunctionParser(), "Applies a function to every block");
}
public ApplyCommand(CommandExecutor<Contextual<? extends RegionFunction>> functionParser, String description) {
checkNotNull(functionParser, "functionParser");
checkNotNull(description, "description");
this.functionParser = functionParser;
this.description = description;
addParameter(functionParser);
}
@Override
public Apply call(CommandArgs args, CommandLocals locals) throws CommandException {
Contextual<? extends RegionFunction> function = functionParser.call(args, locals);
return new Apply(function);
}
@Override
public String getDescription() {
return description;
}
@Override
protected boolean testPermission0(CommandLocals locals) {
return true;
}
}

View File

@ -1,84 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.command.composition;
import com.sk89q.minecraft.util.commands.CommandException;
import com.sk89q.minecraft.util.commands.CommandLocals;
import com.sk89q.minecraft.util.commands.WrappedCommandException;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.argument.BooleanFlag;
import com.sk89q.worldedit.command.argument.StringParser;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.function.Contextual;
import com.sk89q.worldedit.function.factory.Deform;
import com.sk89q.worldedit.function.factory.Deform.Mode;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.util.command.argument.CommandArgs;
import com.sk89q.worldedit.util.command.composition.FlagParser.Flag;
import com.sk89q.worldedit.util.command.composition.FlagParser.FlagData;
import com.sk89q.worldedit.util.command.composition.SimpleCommand;
public class DeformCommand extends SimpleCommand<Contextual<? extends Operation>> {
private final Flag<Boolean> rawCoordsFlag = addFlag('r', new BooleanFlag("Raw coords mode"));
private final Flag<Boolean> offsetFlag = addFlag('o', new BooleanFlag("Offset mode"));
private final StringParser expressionParser = addParameter(new StringParser("expression", "Expression to apply", "y-=0.2"));
@Override
public Deform call(CommandArgs args, CommandLocals locals) throws CommandException {
FlagData flagData = getFlagParser().call(args, locals);
String expression = expressionParser.call(args, locals);
boolean rawCoords = rawCoordsFlag.get(flagData, false);
boolean offset = offsetFlag.get(flagData, false);
Deform deform = new Deform(expression);
if (rawCoords) {
deform.setMode(Mode.RAW_COORD);
} else if (offset) {
deform.setMode(Mode.OFFSET);
Player player = (Player) locals.get(Actor.class);
LocalSession session = WorldEdit.getInstance().getSessionManager().get(locals.get(Actor.class));
try {
deform.setOffset(session.getPlacementPosition(player).toVector3());
} catch (IncompleteRegionException e) {
throw new WrappedCommandException(e);
}
} else {
deform.setMode(Mode.UNIT_CUBE);
}
return deform;
}
@Override
public String getDescription() {
return "Apply math expression to area";
}
@Override
protected boolean testPermission0(CommandLocals locals) {
return true;
}
}

View File

@ -1,64 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.command.composition;
import com.sk89q.minecraft.util.commands.CommandException;
import com.sk89q.minecraft.util.commands.CommandLocals;
import com.sk89q.worldedit.command.argument.NumberParser;
import com.sk89q.worldedit.command.argument.RegionFunctionParser;
import com.sk89q.worldedit.function.Contextual;
import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.function.factory.Paint;
import com.sk89q.worldedit.util.command.argument.CommandArgs;
import com.sk89q.worldedit.util.command.composition.CommandExecutor;
import com.sk89q.worldedit.util.command.composition.SimpleCommand;
public class PaintCommand extends SimpleCommand<Paint> {
private final NumberParser densityCommand = addParameter(new NumberParser("density", "0-100", "20"));
private final CommandExecutor<? extends Contextual<? extends RegionFunction>> functionParser;
public PaintCommand() {
this(new RegionFunctionParser());
}
public PaintCommand(CommandExecutor<? extends Contextual<? extends RegionFunction>> functionParser) {
this.functionParser = functionParser;
addParameter(functionParser);
}
@Override
public Paint call(CommandArgs args, CommandLocals locals) throws CommandException {
double density = densityCommand.call(args, locals).doubleValue() / 100.0;
Contextual<? extends RegionFunction> function = functionParser.call(args, locals);
return new Paint(function, density);
}
@Override
public String getDescription() {
return "Applies a function to surfaces";
}
@Override
protected boolean testPermission0(CommandLocals locals) {
return true;
}
}

View File

@ -1,102 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.command.composition;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.minecraft.util.commands.CommandException;
import com.sk89q.minecraft.util.commands.CommandLocals;
import com.sk89q.worldedit.command.util.CommandPermissionsException;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.MaxBrushRadiusException;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.argument.NumberParser;
import com.sk89q.worldedit.command.argument.RegionFactoryParser;
import com.sk89q.worldedit.command.tool.BrushTool;
import com.sk89q.worldedit.command.tool.InvalidToolBindException;
import com.sk89q.worldedit.command.tool.brush.OperationFactoryBrush;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.function.Contextual;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.regions.factory.RegionFactory;
import com.sk89q.worldedit.util.command.argument.CommandArgs;
import com.sk89q.worldedit.util.command.composition.CommandExecutor;
import com.sk89q.worldedit.util.command.composition.SimpleCommand;
public class ShapedBrushCommand extends SimpleCommand<Object> {
private final CommandExecutor<? extends Contextual<? extends Operation>> delegate;
private final String permission;
private final RegionFactoryParser regionFactoryParser = addParameter(new RegionFactoryParser());
private final NumberParser radiusCommand = addParameter(new NumberParser("size", "The size of the brush", "5"));
public ShapedBrushCommand(CommandExecutor<? extends Contextual<? extends Operation>> delegate, String permission) {
checkNotNull(delegate, "delegate");
this.permission = permission;
this.delegate = delegate;
addParameter(delegate);
}
@Override
public Object call(CommandArgs args, CommandLocals locals) throws CommandException {
if (!testPermission(locals)) {
throw new CommandPermissionsException();
}
RegionFactory regionFactory = regionFactoryParser.call(args, locals);
int radius = radiusCommand.call(args, locals).intValue();
Contextual<? extends Operation> factory = delegate.call(args, locals);
Player player = (Player) locals.get(Actor.class);
LocalSession session = WorldEdit.getInstance().getSessionManager().get(player);
try {
WorldEdit.getInstance().checkMaxBrushRadius(radius);
BrushTool tool = session.getBrushTool(player);
tool.setSize(radius);
tool.setFill(null);
tool.setBrush(new OperationFactoryBrush(factory, regionFactory, session), permission);
} catch (MaxBrushRadiusException | InvalidToolBindException e) {
WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().getExceptionConverter().convert(e);
}
player.print("Set brush to " + factory);
return true;
}
@Override
public String getDescription() {
return delegate.getDescription();
}
@Override
public boolean testPermission0(CommandLocals locals) {
Actor sender = locals.get(Actor.class);
if (sender == null) {
throw new RuntimeException("Uh oh! No 'Actor' specified so that we can check permissions");
} else {
return sender.hasPermission(permission);
}
}
}

View File

@ -76,7 +76,7 @@ public class FloodFillTool implements BlockTool {
try { try {
Mask mask = initialType.toMask(editSession); Mask mask = initialType.toMask(editSession);
BlockReplace function = new BlockReplace(editSession, pattern); BlockReplace function = new BlockReplace(editSession, pattern);
RecursiveVisitor visitor = new RecursiveVisitor(mask, function, range, editSession.getQueue()); RecursiveVisitor visitor = new RecursiveVisitor(mask, function, range);
visitor.visit(origin); visitor.visit(origin);
Operations.completeLegacy(visitor); Operations.completeLegacy(visitor);
} catch (MaxChangedBlocksException e) { } catch (MaxChangedBlocksException e) {

View File

@ -78,7 +78,7 @@ public class RecursivePickaxe implements BlockTool {
final int radius = (int) range; final int radius = (int) range;
final BlockReplace replace = new BlockReplace(editSession, (BlockTypes.AIR.getDefaultState())); final BlockReplace replace = new BlockReplace(editSession, (BlockTypes.AIR.getDefaultState()));
editSession.setMask(null); editSession.setMask(null);
RecursiveVisitor visitor = new RecursiveVisitor(new IdMask(editSession), replace, radius, editSession); RecursiveVisitor visitor = new RecursiveVisitor(new IdMask(editSession), replace, radius);
visitor.visit(pos); visitor.visit(pos);
Operations.completeBlindly(visitor); Operations.completeBlindly(visitor);

View File

@ -30,6 +30,7 @@ import com.sk89q.worldedit.extent.buffer.ForgetfulExtentBuffer;
import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.OperationQueue; import com.sk89q.worldedit.function.operation.OperationQueue;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
@ -116,6 +117,11 @@ public class AbstractDelegateExtent implements Extent, LightingExtent {
} }
} }
@Override
public World getWorld() {
return getExtent().getWorld();
}
/* /*
Bounds Bounds
*/ */

View File

@ -52,6 +52,7 @@ import com.sk89q.worldedit.registry.state.PropertyGroup;
import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.util.Countable; import com.sk89q.worldedit.util.Countable;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
@ -496,24 +497,12 @@ public interface Extent extends InputExtent, OutputExtent {
checkNotNull(block); checkNotNull(block);
boolean hasNbt = block instanceof BaseBlock && ((BaseBlock)block).hasNbtData(); boolean hasNbt = block instanceof BaseBlock && ((BaseBlock)block).hasNbtData();
if (canBypassAll(region, false, true) && !hasNbt) { int changes = 0;
return changes = queue.setBlocks((CuboidRegion) region, block.getInternalId()); for (BlockVector3 pos : region) {
} if (setBlock(pos, block)) {
try {
if (hasExtraExtents()) {
RegionVisitor visitor = new RegionVisitor(region, new BlockReplace(getExtent(), (block)), this);
Operations.completeBlindly(visitor);
this.changes += visitor.getAffected();
} else {
for (BlockVector3 blockVector3 : region) {
if (getExtent().setBlock(blockVector3, block)) {
changes++; changes++;
} }
} }
}
} catch (final WorldEditException e) {
throw new RuntimeException("Unexpected exception", e);
}
return changes; return changes;
} }
@ -534,10 +523,13 @@ public interface Extent extends InputExtent, OutputExtent {
if (pattern instanceof BlockStateHolder) { if (pattern instanceof BlockStateHolder) {
return setBlocks(region, (BlockStateHolder) pattern); return setBlocks(region, (BlockStateHolder) pattern);
} }
BlockReplace replace = new BlockReplace(this, pattern); int count = 0;
RegionVisitor visitor = new RegionVisitor(region, replace, queue instanceof MappedIQueueExtent ? (MappedIQueueExtent) queue : null); for (BlockVector3 pos : region) {
Operations.completeBlindly(visitor); if (pattern.apply(this, pos, pos)) {
return this.changes = visitor.getAffected(); count++;
}
}
return count;
} }
/** /**
@ -616,9 +608,20 @@ public interface Extent extends InputExtent, OutputExtent {
} }
default int setBlocks(final Set<BlockVector3> vset, final Pattern pattern) { default int setBlocks(final Set<BlockVector3> vset, final Pattern pattern) {
RegionVisitor visitor = new RegionVisitor(vset, new BlockReplace(getExtent(), pattern)); if (vset instanceof Region) {
Operations.completeBlindly(visitor); return setBlocks((Region) vset, pattern);
return 0; }
int count = 0;
for (BlockVector3 pos : vset) {
if (pattern.apply(this, pos, pos)) {
count++;
}
}
return count;
}
default World getWorld() {
return null;
} }
} }

View File

@ -1,177 +0,0 @@
package com.sk89q.worldedit.extent;
import com.boydti.fawe.jnbt.anvil.generator.GenBase;
import com.boydti.fawe.jnbt.anvil.generator.Resource;
import com.boydti.fawe.object.extent.LightingExtent;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.OperationQueue;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.util.Countable;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import javax.annotation.Nullable;
import java.util.List;
public class PassthroughExtent extends AbstractDelegateExtent {
private final Extent extent;
public PassthroughExtent(Extent parent) {
super(parent);
this.extent = parent;
}
@Override
public List<? extends Entity> getEntities(Region region) {
return extent.getEntities(region);
}
@Override
public List<? extends Entity> getEntities() {
return extent.getEntities();
}
@Override
@Nullable
public Entity createEntity(Location location, BaseEntity entity) {
return extent.createEntity(location, entity);
}
@Override
public int getHighestTerrainBlock(int x, int z, int minY, int maxY) {
return extent.getHighestTerrainBlock(x, z, minY, maxY);
}
@Override
public int getHighestTerrainBlock(int x, int z, int minY, int maxY, Mask filter) {
return extent.getHighestTerrainBlock(x, z, minY, maxY, filter);
}
@Override
public int getNearestSurfaceLayer(int x, int z, int y, int minY, int maxY) {
return extent.getNearestSurfaceLayer(x, z, y, minY, maxY);
}
@Override
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, boolean ignoreAir) {
return extent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, ignoreAir);
}
@Override
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY) {
return extent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY);
}
@Override
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax) {
return extent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax);
}
@Override
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, Mask mask) {
return extent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, mask);
}
@Override
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, boolean ignoreAir) {
return extent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, ignoreAir);
}
@Override
public void addCaves(Region region) throws WorldEditException {
extent.addCaves(region);
}
@Override
public void generate(Region region, GenBase gen) throws WorldEditException {
extent.generate(region, gen);
}
@Override
public void addSchems(Region region, Mask mask, List<ClipboardHolder> clipboards, int rarity, boolean rotate) throws WorldEditException {
extent.addSchems(region, mask, clipboards, rarity, rotate);
}
@Override
public void spawnResource(Region region, Resource gen, int rarity, int frequency) throws WorldEditException {
extent.spawnResource(region, gen, rarity, frequency);
}
@Override
public boolean contains(BlockVector3 pt) {
return extent.contains(pt);
}
@Override
public void addOre(Region region, Mask mask, Pattern material, int size, int frequency, int rarity, int minY, int maxY) throws WorldEditException {
extent.addOre(region, mask, material, size, frequency, rarity, minY, maxY);
}
@Override
public void addOres(Region region, Mask mask) throws WorldEditException {
extent.addOres(region, mask);
}
@Override
public List<Countable<BlockType>> getBlockDistribution(Region region) {
return extent.getBlockDistribution(region);
}
@Override
public List<Countable<BlockState>> getBlockDistributionWithData(Region region) {
return extent.getBlockDistributionWithData(region);
}
@Override
public BlockArrayClipboard lazyCopy(Region region) {
return extent.lazyCopy(region);
}
@Override
public BlockState getBlock(BlockVector3 position) {
return extent.getBlock(position);
}
@Override
public BlockType getBlockType(BlockVector3 position) {
return extent.getBlockType(position);
}
@Override
public BaseBlock getFullBlock(BlockVector3 position) {
return extent.getFullBlock(position);
}
@Override
public BiomeType getBiome(BlockVector2 position) {
return extent.getBiome(position);
}
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 position, T block) throws WorldEditException {
return extent.setBlock(position, block);
}
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
return extent.setBlock(x, y, z, block);
}
@Override
public boolean setBiome(BlockVector2 position, BiomeType biome) {
return extent.setBiome(position, biome);
}
}

View File

@ -53,7 +53,7 @@ import java.util.UUID;
* Stores block data as a multi-dimensional array of {@link BlockState}s and * Stores block data as a multi-dimensional array of {@link BlockState}s and
* other data as lists or maps. * other data as lists or maps.
*/ */
public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable { public class BlockArrayClipboard implements Clipboard, Closeable {
private Region region; private Region region;
private BlockVector3 origin; private BlockVector3 origin;
@ -260,29 +260,4 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable
public Operation commit() { public Operation commit() {
return null; return null;
} }
@Override
public int getLight(int x, int y, int z) {
return getBlockLight(x, y, z);
}
@Override
public int getSkyLight(int x, int y, int z) {
return 0;
}
@Override
public int getBlockLight(int x, int y, int z) {
return getBrightness(x, y, z);
}
@Override
public int getOpacity(int x, int y, int z) {
return getBlock(x, y, z).getBlockType().getMaterial().getLightOpacity();
}
@Override
public int getBrightness(int x, int y, int z) {
return getBlock(x, y, z).getBlockType().getMaterial().getLightValue();
}
} }

View File

@ -22,7 +22,6 @@ package com.sk89q.worldedit.function.operation;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.example.MappedIQueueExtent;
import com.boydti.fawe.beta.IQueueExtent; import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.object.extent.BlockTranslateExtent; import com.boydti.fawe.object.extent.BlockTranslateExtent;
import com.boydti.fawe.object.extent.PositionTransformExtent; import com.boydti.fawe.object.extent.PositionTransformExtent;
@ -277,14 +276,6 @@ public class ForwardExtentCopy implements Operation {
if (currentTransform == null) { if (currentTransform == null) {
currentTransform = transform; currentTransform = transform;
} }
IQueueExtent queue;
if (source instanceof EditSession) {
queue = ((EditSession) source).getQueue();
} else if (destination instanceof EditSession) {
queue = ((EditSession) destination).getQueue();
} else {
queue = null;
}
Extent finalDest = destination; Extent finalDest = destination;
BlockVector3 translation = to.subtract(from); BlockVector3 translation = to.subtract(from);
@ -368,7 +359,7 @@ public class ForwardExtentCopy implements Operation {
if (copyingBiomes && (!(source instanceof BlockArrayClipboard) || ((BlockArrayClipboard) source).IMP.hasBiomes())) { if (copyingBiomes && (!(source instanceof BlockArrayClipboard) || ((BlockArrayClipboard) source).IMP.hasBiomes())) {
copy = CombinedRegionFunction.combine(copy, new BiomeCopy(source, finalDest)); copy = CombinedRegionFunction.combine(copy, new BiomeCopy(source, finalDest));
} }
blockCopy = new RegionVisitor(region, copy, queue instanceof MappedIQueueExtent ? (MappedIQueueExtent) queue : null); blockCopy = new RegionVisitor(region, copy);
} }
List<? extends Entity> entities; List<? extends Entity> entities;

View File

@ -20,12 +20,6 @@
package com.sk89q.worldedit.function.visitor; package com.sk89q.worldedit.function.visitor;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.example.MappedIQueueExtent;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.object.HasIQueueExtent;
import com.boydti.fawe.object.visitor.Fast2DIterator;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.FlatRegionFunction; import com.sk89q.worldedit.function.FlatRegionFunction;
import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.Operation;
@ -35,13 +29,14 @@ import com.sk89q.worldedit.regions.FlatRegion;
import java.util.List; import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Applies region functions to columns in a {@link FlatRegion}. * Applies region functions to columns in a {@link FlatRegion}.
*/ */
public class FlatRegionVisitor implements Operation { public class FlatRegionVisitor implements Operation {
private final FlatRegionFunction function; private final FlatRegionFunction function;
private MappedIQueueExtent queue;
private int affected = 0; private int affected = 0;
private final Iterable<BlockVector2> iterator; private final Iterable<BlockVector2> iterator;
@ -59,15 +54,6 @@ public class FlatRegionVisitor implements Operation {
this.iterator = flatRegion.asFlatRegion(); this.iterator = flatRegion.asFlatRegion();
} }
public FlatRegionVisitor(final FlatRegion flatRegion, final FlatRegionFunction function, HasIQueueExtent hasIQueueExtent) {
checkNotNull(flatRegion);
checkNotNull(function);
this.function = function;
this.iterator = flatRegion.asFlatRegion();
IQueueExtent queue = hasIQueueExtent.getQueue();
this.queue = (MappedIQueueExtent) (queue instanceof MappedIQueueExtent ? queue : null);
}
/** /**
* Get the number of affected objects. * Get the number of affected objects.
* *
@ -79,20 +65,11 @@ public class FlatRegionVisitor implements Operation {
@Override @Override
public Operation resume(RunContext run) throws WorldEditException { public Operation resume(RunContext run) throws WorldEditException {
if (queue != null) {
for (BlockVector2 pt : new Fast2DIterator(iterator, queue)) {
if (function.apply(pt)) {
affected++;
}
}
} else {
for (BlockVector2 pt : this.iterator) { for (BlockVector2 pt : this.iterator) {
if (function.apply(pt)) { if (function.apply(pt)) {
affected++; affected++;
} }
} }
}
return null; return null;
} }

View File

@ -277,4 +277,8 @@ public interface World extends Extent {
return true; return true;
} }
@Override
default World getWorld() {
return this;
}
} }