A tribute to Jesse
This commit is contained in:
MattBDev
2019-09-20 21:52:35 -04:00
parent 68c8fca672
commit 8b96cdc9a5
121 changed files with 1196 additions and 1130 deletions

View File

@ -33,10 +33,6 @@ dependencies {
"annotationProcessor"("com.google.auto.value:auto-value:${Versions.AUTO_VALUE}")
"compile"("co.aikar:fastutil-lite:1.0")
"compile"("com.github.luben:zstd-jni:1.4.3-1")
//"compile"("com.mojang:datafixerupper:1.0.20")
"compileOnly"("com.github.intellectualsites.plotsquared:PlotSquared-API:latest") {
isTransitive = false
}
"compileOnly"("net.fabiozumbi12:redprotect:1.9.6")
}

View File

@ -4,7 +4,6 @@ import com.boydti.fawe.beta.implementation.QueueHandler;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.brush.visualization.VisualQueue;
import com.boydti.fawe.regions.general.plot.PlotSquaredFeature;
import com.boydti.fawe.util.CachedTextureUtil;
import com.boydti.fawe.util.CleanTextureUtil;
import com.boydti.fawe.util.FaweTimer;
@ -186,7 +185,6 @@ public class Fawe {
transformParser = new DefaultTransformParser(getWorldEdit());
visualQueue = new VisualQueue(3);
WEManager.IMP.managers.addAll(Fawe.this.IMP.getMaskManagers());
WEManager.IMP.managers.add(new PlotSquaredFeature());
Fawe.debug("Plugin 'PlotSquared' found. Using it now.");
} catch (Throwable ignored) {}
try {

View File

@ -24,6 +24,7 @@ public interface IChunkSet extends IBlocks, OutputExtent {
boolean isEmpty();
@Override
boolean setTile(int x, int y, int z, CompoundTag tile);
void setEntity(CompoundTag tag);

View File

@ -104,7 +104,7 @@ public class CFICommands {
desc = "Start CFI with a height map as a base"
)
@CommandPermissions("worldedit.anvil.cfi")
public void heightmap(Player fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "yscale", desc = "double", def = "1") double yscale) {
public void heightmap(Player player, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "yscale", desc = "double", def = "1") double yscale) {
if (yscale != 0) {
int[] raw = ((DataBufferInt) image.load().getRaster().getDataBuffer()).getData();
int[] table = IntStream.range(0, 256).map(i -> Math.min(255, (int) (i * yscale)))
@ -118,7 +118,7 @@ public class CFICommands {
}
}
HeightMapMCAGenerator generator = new HeightMapMCAGenerator(image.load(), getFolder(generateName()));
setup(generator, fp);
setup(generator, player);
}
@Command(
@ -126,9 +126,9 @@ public class CFICommands {
desc = "Start CFI with an empty map as a base"
)
@CommandPermissions("worldedit.anvil.cfi")
public void heightMap(Player fp, int width, int length) {
public void heightMap(Player player, int width, int length) {
HeightMapMCAGenerator generator = new HeightMapMCAGenerator(width, length, getFolder(generateName()));
setup(generator, fp);
setup(generator, player);
}
private String generateName() {
@ -136,13 +136,13 @@ public class CFICommands {
return df.format(new Date());
}
private void setup(HeightMapMCAGenerator generator, Player fp) {
CFISettings settings = getSettings(fp).remove();
generator.setPacketViewer(fp);
private void setup(HeightMapMCAGenerator generator, Player player) {
CFISettings settings = getSettings(player).remove();
generator.setPacketViewer(player);
settings.setGenerator(generator).bind();
generator.setImageViewer(Fawe.imp().getImageViewer(fp));
generator.setImageViewer(Fawe.imp().getImageViewer(player));
generator.update();
mainMenu(fp);
mainMenu(player);
}
@Command(
@ -172,9 +172,9 @@ public class CFICommands {
desc = "Cancel creation"
)
@CommandPermissions("worldedit.anvil.cfi")
public void cancel(Player fp) {
getSettings(fp).remove();
fp.print("Cancelled!");
public void cancel(Player player) {
getSettings(player).remove();
player.print("Cancelled!");
}
@Command(
@ -238,8 +238,8 @@ public class CFICommands {
desc = "Set the floor and main block"
)
@CommandPermissions("worldedit.anvil.cfi")
public void column(Player fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
public void column(Player player, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
HeightMapMCAGenerator gen = assertSettings(player).getGenerator();
if (image != null) {
gen.setColumn(load(image), patternArg, !disableWhiteOnly);
} else if (maskOpt != null) {
@ -247,9 +247,9 @@ public class CFICommands {
} else {
gen.setColumn(patternArg);
}
fp.print("Set column!");
assertSettings(fp).resetComponent();
component(fp);
player.print("Set column!");
assertSettings(player).resetComponent();
component(player);
}
@Command(
@ -257,15 +257,15 @@ public class CFICommands {
desc = "Set the floor (default: grass)"
)
@CommandPermissions("worldedit.anvil.cfi")
public void floorCmd(Player fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
floor(fp, patternArg, image, maskOpt, disableWhiteOnly);
fp.print("Set floor!");
assertSettings(fp).resetComponent();
component(fp);
public void floorCmd(Player player, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
floor(player, patternArg, image, maskOpt, disableWhiteOnly);
player.print("Set floor!");
assertSettings(player).resetComponent();
component(player);
}
private void floor(Player fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) {
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
private void floor(Player player, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) {
HeightMapMCAGenerator gen = assertSettings(player).getGenerator();
if (image != null) {
gen.setFloor(load(image), patternArg, !disableWhiteOnly);
} else if (maskOpt != null) {
@ -280,15 +280,15 @@ public class CFICommands {
desc = "Set the main block (default: stone)"
)
@CommandPermissions("worldedit.anvil.cfi")
public void mainCmd(Player fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
main(fp, patternArg, image, maskOpt, disableWhiteOnly);
fp.print("Set main!");
assertSettings(fp).resetComponent();
component(fp);
public void mainCmd(Player player, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
main(player, patternArg, image, maskOpt, disableWhiteOnly);
player.print("Set main!");
assertSettings(player).resetComponent();
component(player);
}
public void main(Player fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
public void main(Player player, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
HeightMapMCAGenerator gen = assertSettings(player).getGenerator();
if (image != null) {
gen.setMain(load(image), patternArg, !disableWhiteOnly);
} else if (maskOpt != null) {
@ -306,8 +306,8 @@ public class CFICommands {
"e.g. Tallgrass"
)
@CommandPermissions("worldedit.anvil.cfi")
public void overlay(Player fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
public void overlay(Player player, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
HeightMapMCAGenerator gen = assertSettings(player).getGenerator();
if (image != null) {
gen.setOverlay(load(image), patternArg, !disableWhiteOnly);
} else if (maskOpt != null) {
@ -315,8 +315,8 @@ public class CFICommands {
} else {
gen.setOverlay(patternArg);
}
fp.print("Set overlay!");
component(fp);
player.print("Set overlay!");
component(player);
}
@Command(
@ -328,14 +328,14 @@ public class CFICommands {
" - A good value for radius and iterations would be 1 8."
)
@CommandPermissions("worldedit.anvil.cfi")
public void smoothCmd(Player fp, int radius, int iterations, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
smooth(fp, radius, iterations, image, maskOpt, disableWhiteOnly);
assertSettings(fp).resetComponent();
component(fp);
public void smoothCmd(Player player, int radius, int iterations, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
smooth(player, radius, iterations, image, maskOpt, disableWhiteOnly);
assertSettings(player).resetComponent();
component(player);
}
private void smooth(Player fp, int radius, int iterations, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
private void smooth(Player player, int radius, int iterations, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
HeightMapMCAGenerator gen = assertSettings(player).getGenerator();
if (image != null) {
gen.smooth(load(image), !disableWhiteOnly, radius, iterations);
} else {
@ -348,14 +348,14 @@ public class CFICommands {
desc = "Create some snow"
)
@CommandPermissions("worldedit.anvil.cfi")
public void snow(Player fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
floor(fp, BlockTypes.SNOW.getDefaultState().with(PropertyKey.LAYERS, 7), image, maskOpt, disableWhiteOnly);
main(fp, BlockTypes.SNOW_BLOCK, image, maskOpt, disableWhiteOnly);
smooth(fp, 1, 8, image, maskOpt, disableWhiteOnly);
fp.print(TextComponent.of("Added snow!"));
assertSettings(fp).resetComponent();
component(fp);
public void snow(Player player, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
HeightMapMCAGenerator gen = assertSettings(player).getGenerator();
floor(player, BlockTypes.SNOW.getDefaultState().with(PropertyKey.LAYERS, 7), image, maskOpt, disableWhiteOnly);
main(player, BlockTypes.SNOW_BLOCK, image, maskOpt, disableWhiteOnly);
smooth(player, 1, 8, image, maskOpt, disableWhiteOnly);
player.print(TextComponent.of("Added snow!"));
assertSettings(player).resetComponent();
component(player);
}
@Command(

View File

@ -1,16 +1,13 @@
package com.boydti.fawe.object.brush;
import com.google.common.collect.Maps;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.command.tool.brush.Brush;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.Arrays;
import java.util.Map;
public class BlendBall implements Brush {
@ -38,8 +35,8 @@ public class BlendBall implements Brush {
}
int z0 = z + tz;
int highest = 1;
BlockStateHolder currentState = editSession.getBlock(x0, y0, z0);
BlockStateHolder highestState = currentState;
BlockState currentState = editSession.getBlock(x0, y0, z0);
BlockState highestState = currentState;
Arrays.fill(frequency, 0);
boolean tie = false;
for (int ox = -1; ox <= 1; ox++) {
@ -48,13 +45,9 @@ public class BlendBall implements Brush {
if (oy + y0 < 0 || oy + y0 > maxY) {
continue;
}
BlockStateHolder state = editSession.getBlock(x0 + ox, y0 + oy, z0 + oz);
BlockState state = editSession.getBlock(x0 + ox, y0 + oy, z0 + oz);
Integer count = frequency[state.getInternalBlockTypeId()];
if (count == null) {
count = 1;
} else {
count++;
}
count++;
if (count > highest) {
highest = count;
highestState = state;

View File

@ -67,9 +67,9 @@ public class BlobBrush implements Brush {
.rotateY(ThreadLocalRandom.current().nextInt(360))
.rotateZ(ThreadLocalRandom.current().nextInt(360));
double manScaleX = (1.25 + seedX * 0.5);
double manScaleY = (1.25 + seedY * 0.5);
double manScaleZ = (1.25 + seedZ * 0.5);
double manScaleX = 1.25 + seedX * 0.5;
double manScaleY = 1.25 + seedY * 0.5;
double manScaleZ = 1.25 + seedZ * 0.5;
MutableVector3 mutable = new MutableVector3();
double roughness = 1 - sphericity;
@ -103,4 +103,4 @@ public class BlobBrush implements Brush {
}
}
}
}
}

View File

@ -5,7 +5,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.object.brush.scroll.ScrollAction;
import com.boydti.fawe.object.extent.ResettableExtent;
import com.sk89q.minecraft.util.commands.CommandException;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.tool.BrushTool;
@ -42,10 +41,10 @@ public class BrushSettings {
private final Map<SettingType, Object> constructor = new ConcurrentHashMap<>();
private Brush brush = null;
private Mask mask = null;
private Mask sourceMask = null;
private ResettableExtent transform = null;
private Brush brush;
private Mask mask;
private Mask sourceMask;
private ResettableExtent transform;
private Pattern material;
private Expression size = new Expression(1);
private Set<String> permissions;
@ -57,7 +56,7 @@ public class BrushSettings {
this.constructor.put(SettingType.PERMISSIONS, permissions);
}
public static BrushSettings get(BrushTool tool, Player player, LocalSession session, Map<String, Object> settings) throws CommandException, InputParseException {
public static BrushSettings get(BrushTool tool, Player player, LocalSession session, Map<String, Object> settings) throws InputParseException {
PlatformCommandManager manager = PlatformCommandManager.getInstance();
String constructor = (String) settings.get(SettingType.BRUSH.name());
if (constructor == null) {

View File

@ -31,7 +31,7 @@ public class CatenaryBrush implements Brush, ResettableTool {
@Override
public void build(EditSession editSession, BlockVector3 pos2, final Pattern pattern, double size) throws MaxChangedBlocksException {
boolean visual = (editSession.getExtent() instanceof VisualExtent);
boolean visual = editSession.getExtent() instanceof VisualExtent;
if (pos1 == null || pos2.equals(pos1)) {
if (!visual) {
pos1 = pos2;
@ -64,9 +64,8 @@ public class CatenaryBrush implements Brush, ResettableTool {
if (!select) {
pos1 = null;
return;
} else {
pos1 = pos2;
}
pos1 = pos2;
}
}
@ -87,7 +86,7 @@ public class CatenaryBrush implements Brush, ResettableTool {
double a = 0.00001;
for (;g < a * Math.sinh(dh/(2 * a)); a *= 1.00001);
double vertX = (dh-a*Math.log((curveLen + dy)/(curveLen - dy)))/2.0;
double z = (dh/2)/a;
double z = (dh / 2) / a;
double oY = (dy - curveLen * (Math.cosh(z) / Math.sinh(z))) / 2;
double vertY = a * 1 + oY;
return pos1.add(pos2.subtract(pos1).multiply(vertX / dh).add(0, vertY, 0)).round().toBlockPoint();

View File

@ -9,23 +9,23 @@ import com.sk89q.worldedit.command.tool.brush.Brush;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.util.Direction;
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.BlockTypes;
import java.util.Arrays;
import java.util.function.Function;
import java.util.stream.Stream;
public class ErodeBrush implements Brush {
private static final BlockVector3[] FACES_TO_CHECK = Direction.valuesOf(Direction.Flag.CARDINAL).stream().map(direction -> direction.toBlockVector()).toArray(size -> new BlockVector3[size]);
private static final BlockVector3[] FACES_TO_CHECK = Direction.valuesOf(Direction.Flag.CARDINAL).stream().map(Direction::toBlockVector).toArray(BlockVector3[]::new);
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
this.erosion(editSession, 2, 1, 5, 1, position, size);
this.erosion(editSession, 2, 1, 5, position, size);
}
public void erosion(final EditSession es, int erodeFaces, int erodeRec, int fillFaces, int fillRec, BlockVector3 target, double size) {
void erosion(EditSession es, int erodeFaces, int erodeRec, int fillFaces,
BlockVector3 target, double size) {
int brushSize = (int) size + 1;
int brushSizeSquared = (int) (size * size);
int dimension = brushSize * 2 + 1;
@ -42,7 +42,7 @@ public class ErodeBrush implements Brush {
int y0 = y + by;
for (int z = -brushSize; z <= brushSize; z++) {
int z0 = z + bz;
BlockStateHolder state = es.getBlock(x0, y0, z0);
BlockState state = es.getBlock(x0, y0, z0);
buffer1.setBlock(x, y, z, state);
buffer2.setBlock(x, y, z, state);
}
@ -55,7 +55,7 @@ public class ErodeBrush implements Brush {
swap++;
}
for (int i = 0; i < fillRec; ++i) {
for (int i = 0; i < 1; ++i) {
fillIteration(brushSize, brushSizeSquared, fillFaces, swap % 2 == 0 ? buffer1 : buffer2, swap % 2 == 1 ? buffer1 : buffer2);
swap++;
}
@ -69,7 +69,8 @@ public class ErodeBrush implements Brush {
}, true);
}
public void fillIteration(int brushSize, int brushSizeSquared, int fillFaces, FaweClipboard current, FaweClipboard target) {
private void fillIteration(int brushSize, int brushSizeSquared, int fillFaces,
FaweClipboard current, FaweClipboard target) {
int[] frequency = null;
for (int x = -brushSize; x <= brushSize; x++) {
int x2 = x * x;
@ -81,20 +82,20 @@ public class ErodeBrush implements Brush {
if (cube >= brushSizeSquared) {
continue;
}
BlockStateHolder state = current.getBlock(x, y, z);
BaseBlock state = current.getBlock(x, y, z);
if (state.getBlockType().getMaterial().isMovementBlocker()) {
continue;
}
int total = 0;
int highest = 1;
BlockStateHolder highestState = state;
BaseBlock highestState = state;
if (frequency == null) {
frequency = new int[BlockTypes.size()];
} else {
Arrays.fill(frequency, 0);
}
for (BlockVector3 offs : FACES_TO_CHECK) {
BlockStateHolder next = current.getBlock(x + offs.getBlockX(), y + offs.getBlockY(), z + offs.getBlockZ());
BaseBlock next = current.getBlock(x + offs.getBlockX(), y + offs.getBlockY(), z + offs.getBlockZ());
if (!next.getBlockType().getMaterial().isMovementBlocker()) {
continue;
}
@ -113,7 +114,8 @@ public class ErodeBrush implements Brush {
}
}
public void erosionIteration(int brushSize, int brushSizeSquared, int erodeFaces, FaweClipboard current, FaweClipboard target) {
private void erosionIteration(int brushSize, int brushSizeSquared, int erodeFaces,
FaweClipboard current, FaweClipboard target) {
int[] frequency = null;
for (int x = -brushSize; x <= brushSize; x++) {
int x2 = x * x;
@ -125,20 +127,20 @@ public class ErodeBrush implements Brush {
if (cube >= brushSizeSquared) {
continue;
}
BlockStateHolder state = current.getBlock(x, y, z);
BaseBlock state = current.getBlock(x, y, z);
if (!state.getBlockType().getMaterial().isMovementBlocker()) {
continue;
}
int total = 0;
int highest = 1;
BlockStateHolder highestState = state;
BaseBlock highestState = state;
if (frequency == null) {
frequency = new int[BlockTypes.size()];
} else {
Arrays.fill(frequency, 0);
}
for (BlockVector3 offs : FACES_TO_CHECK) {
BlockStateHolder next = current.getBlock(x + offs.getBlockX(), y + offs.getBlockY(), z + offs.getBlockZ());
BaseBlock next = current.getBlock(x + offs.getBlockX(), y + offs.getBlockY(), z + offs.getBlockZ());
if (next.getBlockType().getMaterial().isMovementBlocker()) {
continue;
}

View File

@ -47,7 +47,7 @@ public class InspectBrush extends BrushTool implements DoubleActionTraceTool {
}
public Vector3 getTarget(Player player, boolean adjacent) {
int range = this.range > -1 ? getRange() : DEFAULT_RANGE;
int range = this.range > -1 ? getRange() : MAX_RANGE;
if (adjacent) {
Location face = player.getBlockTraceFace(range, true);
return face.add(face.getDirection());

View File

@ -1,7 +1,5 @@
package com.boydti.fawe.object.brush;
import com.boydti.fawe.beta.FilterBlock;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.object.collection.BlockVectorSet;
import com.boydti.fawe.object.mask.AdjacentAnyMask;
import com.boydti.fawe.object.mask.RadiusMask;
@ -9,8 +7,6 @@ import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.command.tool.brush.Brush;
import com.sk89q.worldedit.function.mask.BlockMask;
import com.sk89q.worldedit.function.mask.BlockTypeMask;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.SolidBlockMask;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.pattern.Pattern;
@ -21,7 +17,6 @@ import com.sk89q.worldedit.math.MutableBlockVector3;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.Arrays;
public class LayerBrush implements Brush {
@ -44,32 +39,29 @@ public class LayerBrush implements Brush {
visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS));
Operations.completeBlindly(visitor);
BlockVectorSet visited = visitor.getVisited();
visitor = new RecursiveVisitor(new Mask() {
@Override
public boolean test(BlockVector3 pos) {
int depth = visitor.getDepth() + 1;
if (depth > 1) {
boolean found = false;
BlockState previous = layers[depth - 1];
BlockState previous2 = layers[depth - 2];
for (BlockVector3 dir : BreadthFirstSearch.DEFAULT_DIRECTIONS) {
mutable.setComponents(pos.getBlockX() + dir.getBlockX(), pos.getBlockY() + dir.getBlockY(), pos.getBlockZ() + dir.getBlockZ());
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);
if (visitor.isVisited(mutable) && editSession.getBlock(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous2) {
found = true;
break;
} else {
return false;
}
visitor = new RecursiveVisitor(pos -> {
int depth = visitor.getDepth() + 1;
if (depth > 1) {
boolean found = false;
BlockState previous = layers[depth - 1];
BlockState previous2 = layers[depth - 2];
for (BlockVector3 dir : BreadthFirstSearch.DEFAULT_DIRECTIONS) {
mutable.setComponents(pos.getBlockX() + dir.getBlockX(), pos.getBlockY() + dir.getBlockY(), pos.getBlockZ() + dir.getBlockZ());
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);
if (visitor.isVisited(mutable) && editSession.getBlock(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous2) {
found = true;
break;
} else {
return false;
}
}
if (!found) {
return false;
}
}
return !adjacent.test(pos);
if (!found) {
return false;
}
}
return !adjacent.test(pos);
}, pos -> {
int depth = visitor.getDepth();
BlockStateHolder currentPattern = layers[depth];

View File

@ -20,8 +20,8 @@ public class LineBrush implements Brush, ResettableTool {
}
@Override
public void build(EditSession editSession, BlockVector3 position, final Pattern pattern, double size) throws MaxChangedBlocksException {
boolean visual = (editSession.getExtent() instanceof VisualExtent);
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
boolean visual = editSession.getExtent() instanceof VisualExtent;
if (pos1 == null) {
if (!visual) {
pos1 = position;
@ -34,7 +34,6 @@ public class LineBrush implements Brush, ResettableTool {
BBC.BRUSH_LINE_SECONDARY.send(editSession.getPlayer());
if (!select) {
pos1 = null;
return;
} else {
pos1 = position;
}

View File

@ -8,6 +8,6 @@ import com.sk89q.worldedit.math.BlockVector3;
public class RaiseBrush extends ErodeBrush {
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
this.erosion(editSession, 6, 0, 1, 1, position, size);
this.erosion(editSession, 6, 0, 1, position, size);
}
}
}

View File

@ -4,7 +4,6 @@ import com.boydti.fawe.object.mask.RadiusMask;
import com.boydti.fawe.object.visitor.DFSRecursiveVisitor;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.command.tool.brush.Brush;
import com.sk89q.worldedit.function.block.BlockReplace;
import com.sk89q.worldedit.function.mask.Mask;
@ -24,7 +23,7 @@ public class RecurseBrush implements Brush {
}
@Override
public void build(final EditSession editSession, final BlockVector3 position, Pattern to, double size) throws MaxChangedBlocksException {
public void build(EditSession editSession, BlockVector3 position, Pattern to, double size) throws MaxChangedBlocksException {
Mask mask = editSession.getMask();
if (mask == null) {
mask = Masks.alwaysTrue();
@ -35,7 +34,7 @@ public class RecurseBrush implements Brush {
return;
}
final BlockReplace replace = new BlockReplace(editSession, to);
editSession.setMask((Mask) null);
editSession.setMask(null);
final int maxY = editSession.getMaxY();
if (dfs) {
final Mask radMask = new RadiusMask(0, (int) size);
@ -43,7 +42,7 @@ public class RecurseBrush implements Brush {
@Override
public boolean isVisitable(BlockVector3 from, BlockVector3 to) {
int y = to.getBlockY();
return y >= y && y < maxY && radMask.test(to) && super.isVisitable(from, to);
return y < maxY && radMask.test(to) && super.isVisitable(from, to);
}
};
visitor.visit(position);
@ -53,7 +52,7 @@ public class RecurseBrush implements Brush {
@Override
public boolean isVisitable(BlockVector3 from, BlockVector3 to) {
int y = to.getBlockY();
return y >= y && y < maxY && super.isVisitable(from, to);
return y < maxY && super.isVisitable(from, to);
}
};
visitor.visit(position);

View File

@ -17,7 +17,6 @@ public class ScatterOverlayBrush extends ScatterBrush {
int y = pt.getBlockY();
int z = pt.getBlockZ();
BlockVector3 dir = getDirection(pt);
// dir.setComponents(x + dir.getBlockX(), y + dir.getBlockY(), z + dir.getBlockZ());
editSession.setBlock(x + dir.getBlockX(), y + dir.getBlockY(), z + dir.getBlockZ(), p);
}
}
}

View File

@ -1,15 +0,0 @@
package com.boydti.fawe.object.brush;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.command.tool.brush.Brush;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
public class SpikeBrush implements Brush {
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
}
}

View File

@ -5,13 +5,11 @@ import com.boydti.fawe.object.mask.SurfaceMask;
import com.boydti.fawe.object.pattern.BiomePattern;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.function.mask.SolidBlockMask;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.visitor.BreadthFirstSearch;
import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
import com.sk89q.worldedit.math.BlockVector3;
import java.util.Arrays;
import java.util.concurrent.ThreadLocalRandom;
@ -32,8 +30,8 @@ public class SplatterBrush extends ScatterBrush {
Pattern tmp;
try {
tmp = p.apply(position);
} catch (BiomePattern.BiomePatternException ignore) {
tmp = ignore.getPattern();
} catch (BiomePattern.BiomePatternException e) {
tmp = e.getPattern();
}
finalPattern = tmp;
} else {
@ -44,7 +42,8 @@ public class SplatterBrush extends ScatterBrush {
RecursiveVisitor visitor = new RecursiveVisitor(vector -> {
double dist = vector.distanceSq(position);
if (dist < size2 && !placed.contains(vector) && (ThreadLocalRandom.current().nextInt(5) < 2) && surface.test(vector)) {
if (dist < size2 && !placed.contains(vector) && ThreadLocalRandom.current().nextInt(5) < 2
&& surface.test(vector)) {
placed.add(vector);
return true;
}

View File

@ -28,12 +28,10 @@ public class SplineBrush implements Brush, ResettableTool {
private ArrayList<ArrayList<BlockVector3>> positionSets;
private int numSplines;
private final LocalSession session;
private final Player player;
private BlockVector3 position;
public SplineBrush(Player player, LocalSession session) {
this.session = session;
this.player = player;
this.positionSets = new ArrayList<>();
}

View File

@ -16,9 +16,12 @@ import java.util.ArrayList;
import java.util.List;
public class SurfaceSpline implements Brush {
final double tension, bias, continuity, quality;
private final double tension;
private final double bias;
private final double continuity;
private final double quality;
public SurfaceSpline(final double tension, final double bias, final double continuity, final double quality) {
public SurfaceSpline(double tension, double bias, double continuity, double quality) {
this.tension = tension;
this.bias = bias;
this.continuity = continuity;
@ -43,7 +46,7 @@ public class SurfaceSpline implements Brush {
final List<Node> nodes = new ArrayList<>(path.size());
final KochanekBartelsInterpolation interpol = new KochanekBartelsInterpolation();
for (final BlockVector3 nodevector : path) {
for (BlockVector3 nodevector : path) {
final Node n = new Node(nodevector.toVector3());
n.setTension(tension);
n.setBias(bias);
@ -72,13 +75,13 @@ public class SurfaceSpline implements Brush {
}
}
if (radius != 0) {
double radius2 = (radius * radius);
double radius2 = radius * radius;
LocalBlockVectorSet newSet = new LocalBlockVectorSet();
final int ceilrad = (int) Math.ceil(radius);
for (final BlockVector3 v : vset) {
for (BlockVector3 v : vset) {
final int tipx = v.getBlockX(), tipy = v.getBlockY(), tipz = v.getBlockZ();
for (int loopx = tipx - ceilrad; loopx <= (tipx + ceilrad); loopx++) {
for (int loopz = tipz - ceilrad; loopz <= (tipz + ceilrad); loopz++) {
for (int loopx = tipx - ceilrad; loopx <= tipx + ceilrad; loopx++) {
for (int loopz = tipz - ceilrad; loopz <= tipz + ceilrad; loopz++) {
if (MathMan.hypot2(loopx - tipx, 0, loopz - tipz) <= radius2) {
int y = editSession.getNearestSurfaceTerrainBlock(loopx, loopz, v.getBlockY(), 0, maxY);
if (y == -1) continue;

View File

@ -139,23 +139,23 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
enttFile.delete();
}
public void undo(Player fp, Region[] regions) {
EditSession session = toEditSession(fp, regions);
public void undo(Player player, Region[] regions) {
EditSession session = toEditSession(player, regions);
session.undo(session);
deleteFiles();
}
public void undo(Player fp) {
undo(fp, null);
public void undo(Player player) {
undo(player, null);
}
public void redo(Player fp, Region[] regions) {
EditSession session = toEditSession(fp, regions);
public void redo(Player player, Region[] regions) {
EditSession session = toEditSession(player, regions);
session.redo(session);
}
public void redo(Player fp) {
undo(fp, null);
public void redo(Player player) {
undo(player, null);
}
public UUID getUUID() {

View File

@ -140,8 +140,7 @@ public final class MemBlockSet extends BlockSet {
@Override
public int size() {
int size = 0;
for (int X = 0;X < rows.length; X++) {
IRow nullRowX = rows[X];
for (IRow nullRowX : rows) {
if (nullRowX instanceof RowX) {
RowX rowx = (RowX) nullRowX;
for (int Z = 0; Z < rowx.rows.length; Z++) {
@ -238,8 +237,7 @@ public final class MemBlockSet extends BlockSet {
@Override
public int size() {
int size = 0;
for (int X = 0;X < rows.length; X++) {
IRow nullRowX = rows[X];
for (IRow nullRowX : rows) {
if (nullRowX instanceof RowX) {
RowX rowx = (RowX) nullRowX;
for (int Z = 0; Z < rowx.rows.length; Z++) {
@ -286,18 +284,20 @@ public final class MemBlockSet extends BlockSet {
int maxY = 15;
int maxy = 16;
int by = Integer.MAX_VALUE;
for (int X = 0; X < rows.length; X++) {
IRow nullRowX = rows[X];
if (!(nullRowX instanceof RowX)) continue;
for (IRow nullRowX : rows) {
if (!(nullRowX instanceof RowX))
continue;
RowX rowx = (RowX) nullRowX;
for (int Z = 0; Z < rowx.rows.length; Z++) {
IRow nullRowZ = rowx.rows[Z];
if (!(nullRowZ instanceof RowZ)) continue;
if (!(nullRowZ instanceof RowZ))
continue;
RowZ rowz = (RowZ) nullRowZ;
outer:
for (int Y = 0; Y <= maxY; Y++) {
IRow nullRowY = rowz.rows[Y];
if (!(nullRowY instanceof RowY)) continue;
if (!(nullRowY instanceof RowY))
continue;
RowY rowY = (RowY) nullRowY;
int localMaxy = Y == maxY ? maxy : 15;
for (int y = 0, i = 0; y < localMaxy; y++) {
@ -312,7 +312,8 @@ public final class MemBlockSet extends BlockSet {
maxy = y;
}
by = (Y << 4) + y;
if (by == 0) return 0;
if (by == 0)
return 0;
break outer;
}
}
@ -328,18 +329,20 @@ public final class MemBlockSet extends BlockSet {
int maxY = 0;
int maxy = 0;
int by = Integer.MIN_VALUE;
for (int X = 0; X < rows.length; X++) {
IRow nullRowX = rows[X];
if (!(nullRowX instanceof RowX)) continue;
for (IRow nullRowX : rows) {
if (!(nullRowX instanceof RowX))
continue;
RowX rowx = (RowX) nullRowX;
for (int Z = 0; Z < rowx.rows.length; Z++) {
IRow nullRowZ = rowx.rows[Z];
if (!(nullRowZ instanceof RowZ)) continue;
if (!(nullRowZ instanceof RowZ))
continue;
RowZ rowz = (RowZ) nullRowZ;
outer:
for (int Y = 15; Y >= maxY; Y--) {
IRow nullRowY = rowz.rows[Y];
if (!(nullRowY instanceof RowY)) continue;
if (!(nullRowY instanceof RowY))
continue;
RowY rowY = (RowY) nullRowY;
int localMaxy = Y == maxY ? maxy : 0;
for (int y = 15, i = 63; y >= localMaxy; y--) {
@ -354,7 +357,8 @@ public final class MemBlockSet extends BlockSet {
maxy = y + 1;
}
by = (Y << 4) + y;
if (by == FaweCache.IMP.WORLD_MAX_Y) return FaweCache.IMP.WORLD_MAX_Y;
if (by == FaweCache.IMP.WORLD_MAX_Y)
return FaweCache.IMP.WORLD_MAX_Y;
break outer;
}
}
@ -425,9 +429,7 @@ public final class MemBlockSet extends BlockSet {
IRow nullRowY = rowz.rows[Y];
if (!(nullRowY instanceof RowY)) continue;
RowY rowY = (RowY) nullRowY;
for (long value : rowY.bits) {
or |= value;
}
or |= Arrays.stream(rowY.bits).reduce(0, (a, b) -> a | b);
or = (or & 0xFFFF) | ((or >> 16) & 0xFFFF) | ((or >> 32) & 0xFFFF) | ((or >> 48) & 0xFFFF);
if (highestBit(or) == 15) return tx + 15;
}
@ -444,14 +446,15 @@ public final class MemBlockSet extends BlockSet {
int maxChunkZ = rows.length - 1;
int maxz = 16;
int bz = Integer.MAX_VALUE;
for (int X = 0; X < rows.length; X++) {
IRow nullRowX = rows[X];
if (!(nullRowX instanceof RowX)) continue;
for (IRow nullRowX : rows) {
if (!(nullRowX instanceof RowX))
continue;
RowX rowx = (RowX) nullRowX;
outer:
for (int Z = 0; Z <= maxChunkZ; Z++) {
IRow nullRowZ = rowx.rows[Z];
if (!(nullRowZ instanceof RowZ)) continue;
if (!(nullRowZ instanceof RowZ))
continue;
RowZ rowz = (RowZ) nullRowZ;
if (Z != maxChunkZ) {
maxChunkZ = Z;
@ -459,7 +462,8 @@ public final class MemBlockSet extends BlockSet {
}
for (int Y = 0; Y < rowz.rows.length; Y++) {
IRow nullRowY = rowz.rows[Y];
if (!(nullRowY instanceof RowY)) continue;
if (!(nullRowY instanceof RowY))
continue;
RowY rowY = (RowY) nullRowY;
for (int y = 0, i1 = 0; y < 16; y++, i1 += 4) {
for (int z = 0, i = i1; z < maxz; z += 4, i++) {
@ -500,9 +504,7 @@ public final class MemBlockSet extends BlockSet {
IRow nullRowY = rowz.rows[Y];
if (!(nullRowY instanceof RowY)) continue;
RowY rowY = (RowY) nullRowY;
for (long value : rowY.bits) {
or |= value;
}
or |= Arrays.stream(rowY.bits).reduce(0, (a, b) -> a | b);
or = (or & 0xFFFF) | ((or >> 16) & 0xFFFF) | ((or >> 32) & 0xFFFF) | ((or >> 48) & 0xFFFF);
if (lowestBit(or) == 0) return bx;
}
@ -566,7 +568,6 @@ public final class MemBlockSet extends BlockSet {
private int bx, by, bz, zz, yy;
private RowX rowX;
private RowZ rowZ;
private RowY rowY;
private long[] bits;
private int bitsIndex = 0;
private int yIndex = 0;
@ -618,7 +619,7 @@ public final class MemBlockSet extends BlockSet {
by = yIndex << 4;
IRow nullRowY = rowZ.rows[yIndex++];
if (nullRowY instanceof RowY) {
rowY = (RowY) nullRowY;
RowY rowY = (RowY) nullRowY;
bits = rowY.bits;
return true;
}
@ -656,9 +657,7 @@ public final class MemBlockSet extends BlockSet {
public BlockVector3 next() {
final long lowBit = Long.lowestOneBit(bitBuffer);
final int bitIndex = Long.bitCount(lowBit-1);
{
mutable.setComponents((bx) + (bitIndex & 15), yy, (zz) + (bitIndex));
}
mutable.setComponents((bx) + (bitIndex & 15), yy, (zz) + (bitIndex));
bitBuffer = bitBuffer ^ lowBit;
nextLong();
return mutable;
@ -674,20 +673,23 @@ public final class MemBlockSet extends BlockSet {
@Override
public boolean isEmpty() {
for (int X = 0; X < rows.length; X++) {
IRow nullRowX = rows[X];
if (!(nullRowX instanceof RowX)) continue;
for (IRow nullRowX : rows) {
if (!(nullRowX instanceof RowX))
continue;
RowX rowx = (RowX) nullRowX;
for (int Z = 0; Z < rowx.rows.length; Z++) {
IRow nullRowZ = rowx.rows[Z];
if (!(nullRowZ instanceof RowZ)) continue;
if (!(nullRowZ instanceof RowZ))
continue;
RowZ rowz = (RowZ) nullRowZ;
for (int Y = 0; Y < 16; Y++) {
IRow nullRowY = rowz.rows[Y];
if (!(nullRowY instanceof RowY)) continue;
if (!(nullRowY instanceof RowY))
continue;
RowY rowY = (RowY) nullRowY;
for (long bit : rowY.bits) {
if (bit != 0) return true;
if (bit != 0)
return true;
}
}
}
@ -704,13 +706,14 @@ public final class MemBlockSet extends BlockSet {
long total = 0;
long lastBit = 0;
int lastCount = 0;
for (int x = 0; x < rows.length; x++) {
IRow nullRowX = rows[x];
if (!(nullRowX instanceof RowX)) continue;
for (IRow nullRowX : rows) {
if (!(nullRowX instanceof RowX))
continue;
RowX rowx = (RowX) nullRowX;
for (int z = 0; z < rowx.rows.length; z++) {
IRow nullRowZ = rowx.rows[z];
if (!(nullRowZ instanceof RowZ)) continue;
if (!(nullRowZ instanceof RowZ))
continue;
RowZ rowz = (RowZ) nullRowZ;
for (int y = 0; y < 16; y++) {
IRow nullRowY = rowz.rows[y];
@ -755,7 +758,8 @@ public final class MemBlockSet extends BlockSet {
remove(rows, x, y, z);
return false;
}
default void clear(IRow[] rows, int x, int y, int z) { return; }
default void clear(IRow[] rows, int x, int y, int z) {
}
}
public static final class NullRowX implements IRow {

View File

@ -1,6 +1,5 @@
package com.boydti.fawe.object.extent;
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.PassthroughExtent;
@ -30,7 +29,7 @@ public class ExtentHeightCacher extends PassthroughExtent {
int rx = x - cacheBotX + 16;
int rz = z - cacheBotZ + 16;
int index;
if (((rx & 0xFF) != rx || (rz & 0xFF) != rz)) {
if ((rx & 0xFF) != rx || (rz & 0xFF) != rz) {
cacheBotX = x - 16;
cacheBotZ = z - 16;
lastY = y;

View File

@ -1,12 +1,9 @@
package com.boydti.fawe.object.extent;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.util.WEManager;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.Extent;
@ -15,9 +12,10 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
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.BlockTypes;
import java.util.Collection;
import javax.annotation.Nullable;
@ -41,12 +39,7 @@ public abstract class FaweRegionExtent extends ResettableExtent {
public abstract Collection<Region> getRegions();
public boolean isGlobal() {
for (Region region : getRegions()) {
if (region.isGlobal()) {
return true;
}
}
return false;
return getRegions().stream().anyMatch(Region::isGlobal);
}
@Override

View File

@ -30,12 +30,12 @@ public class OffsetExtent extends ResettableExtent {
}
@Override
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block) throws WorldEditException {
return getExtent().setBlock(location.getBlockX() + dx, location.getBlockY() + dy, location.getBlockZ() + dz, block);
}
@Override
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
return getExtent().setBlock(x + dx, y + dy, z + dz, block);
}

View File

@ -51,13 +51,13 @@ public class TransformExtent extends BlockTransformExtent {
if (min == null) {
min = pos;
}
mutable1.mutX(((pos.getX() - min.getX())));
mutable1.mutY(((pos.getY() - min.getY())));
mutable1.mutZ(((pos.getZ() - min.getZ())));
mutable1.mutX(pos.getX() - min.getX());
mutable1.mutY(pos.getY() - min.getY());
mutable1.mutZ(pos.getZ() - min.getZ());
Vector3 tmp = getTransform().apply(mutable1);
mutable2.mutX((tmp.getX() + min.getX()));
mutable2.mutY((tmp.getY() + min.getY()));
mutable2.mutZ((tmp.getZ() + min.getZ()));
mutable2.mutX(tmp.getX() + min.getX());
mutable2.mutY(tmp.getY() + min.getY());
mutable2.mutZ(tmp.getZ() + min.getZ());
return mutable2;
}
@ -65,13 +65,13 @@ public class TransformExtent extends BlockTransformExtent {
if (min == null) {
min = BlockVector3.at(x, y, z);
}
mutable1.mutX(((x - min.getX())));
mutable1.mutY(((y - min.getY())));
mutable1.mutZ(((z - min.getZ())));
mutable1.mutX(x - min.getX());
mutable1.mutY(y - min.getY());
mutable1.mutZ(z - min.getZ());
Vector3 tmp = getTransform().apply(mutable1);
mutable2.mutX((tmp.getX() + min.getX()));
mutable2.mutY((tmp.getY() + min.getY()));
mutable2.mutZ((tmp.getZ() + min.getZ()));
mutable2.mutX(tmp.getX() + min.getX());
mutable2.mutY(tmp.getY() + min.getY());
mutable2.mutZ(tmp.getZ() + min.getZ());
return tmp.toBlockPoint();
}
@ -93,13 +93,13 @@ public class TransformExtent extends BlockTransformExtent {
}
@Override
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
return super.setBlock(getPos(x, y, z), transformInverse(block));
}
@Override
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException {
return super.setBlock(getPos(location), transformInverse(block));
}

View File

@ -1,11 +0,0 @@
package com.boydti.fawe.object.mask;
import com.sk89q.worldedit.function.mask.AbstractMask;
import com.sk89q.worldedit.math.BlockVector3;
public class AdjacentAnyMask2 extends AbstractMask {
@Override
public boolean test(BlockVector3 vector) {
return false;
}
}

View File

@ -1,21 +0,0 @@
package com.boydti.fawe.object.number;
public final class MutableLong {
private long value;
public final void increment() {
value++;
}
public void set(long value) {
this.value = value;
}
public long get() {
return value;
}
public void add(long amount) {
this.value += amount;
}
}

View File

@ -23,9 +23,9 @@ public class RelativePattern extends AbstractPattern implements ResettablePatter
if (origin == null) {
origin = pos;
}
mutable.mutX((pos.getX() - origin.getX()));
mutable.mutY((pos.getY() - origin.getY()));
mutable.mutZ((pos.getZ() - origin.getZ()));
mutable.mutX(pos.getX() - origin.getX());
mutable.mutY(pos.getY() - origin.getY());
mutable.mutZ(pos.getZ() - origin.getZ());
return pattern.apply(mutable);
}
@ -34,9 +34,9 @@ public class RelativePattern extends AbstractPattern implements ResettablePatter
if (origin == null) {
origin = set;
}
mutable.mutX((set.getX() - origin.getX()));
mutable.mutY((set.getY() - origin.getY()));
mutable.mutZ((set.getZ() - origin.getZ()));
mutable.mutX(set.getX() - origin.getX());
mutable.mutY(set.getY() - origin.getY());
mutable.mutZ(set.getZ() - origin.getZ());
return pattern.apply(extent, get, mutable);
}

View File

@ -1,9 +1,10 @@
package com.boydti.fawe.object.random;
public interface SimpleRandom {
public double nextDouble(int x, int y, int z);
public default int nextInt(int x, int y, int z, int len) {
double nextDouble(int x, int y, int z);
default int nextInt(int x, int y, int z, int len) {
double val = nextDouble(x, y, z);
return (int) (val * len);
}

View File

@ -3,19 +3,16 @@ package com.boydti.fawe.object.random;
import java.util.SplittableRandom;
public class TrueRandom implements SimpleRandom {
private final SplittableRandom r;
public TrueRandom() {
this.r = new SplittableRandom();
}
private final SplittableRandom random = new SplittableRandom();
@Override
public double nextDouble(int x, int y, int z) {
return r.nextDouble();
return random.nextDouble();
}
@Override
public int nextInt(int x, int y, int z, int len) {
return r.nextInt(len);
return random.nextInt(len);
}
}

View File

@ -35,7 +35,8 @@ public class Triangle {
radius[1] = RADIUS;
radius[2] = RADIUS;
this.normalVec = pos2.subtract(pos1).cross(pos3.subtract(pos1)).normalize();
this.b = Math.max(Math.max(this.normalVec.dot(pos1), this.normalVec.dot(pos2)), this.normalVec.dot(pos3));
this.b = Math.max(Math.max(this.normalVec.dot(pos1), this.normalVec.dot(pos2)),
this.normalVec.dot(pos3));
}
public boolean above(BlockVector3 pt) {
@ -45,9 +46,14 @@ public class Triangle {
public Edge getEdge(int index) {
if (index == this.verts.length - 1) {
return new Edge(Vector3.at(this.verts[index][0], this.verts[index][1],this.verts[index][2]), Vector3.at(this.verts[0][0], this.verts[0][1], this.verts[0][2]));
return new Edge(
Vector3.at(this.verts[index][0], this.verts[index][1], this.verts[index][2]),
Vector3.at(this.verts[0][0], this.verts[0][1], this.verts[0][2]));
} else {
return new Edge(Vector3.at(this.verts[index][0], this.verts[index][1],this.verts[index][2]), Vector3.at(this.verts[index + 1][0], this.verts[index + 1][1], this.verts[index + 1][2]));
return new Edge(
Vector3.at(this.verts[index][0], this.verts[index][1], this.verts[index][2]),
Vector3.at(this.verts[index + 1][0], this.verts[index + 1][1],
this.verts[index + 1][2]));
}
}
@ -80,7 +86,7 @@ public class Triangle {
}
private double dot(double[] v1, double[] v2) {
return (v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2]);
return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2];
}
@ -175,8 +181,8 @@ public class Triangle {
}
private boolean overlaps(double boxcenter[], double boxhalfsize[], double triverts[][]) {
double min, max, p0, p1, p2, rad, fex, fey, fez;
private boolean overlaps(double[] boxcenter, double[] boxhalfsize, double[][] triverts) {
double min, max, fex, fey, fez;
sub(v0, triverts[0], boxcenter);
sub(v1, triverts[1], boxcenter);
sub(v2, triverts[2], boxcenter);
@ -188,48 +194,71 @@ public class Triangle {
fey = Math.abs(e0[1]);
fez = Math.abs(e0[2]);
if (!axisTestX01(e0[2], e0[1], fez, fey)) return false;
if (!axisTestY02(e0[2], e0[0], fez, fex)) return false;
if (!axisTestZ12(e0[1], e0[0], fey, fex)) return false;
if (!axisTestX01(e0[2], e0[1], fez, fey)) {
return false;
}
if (!axisTestY02(e0[2], e0[0], fez, fex)) {
return false;
}
if (!axisTestZ12(e0[1], e0[0], fey, fex)) {
return false;
}
fex = Math.abs(e1[0]);
fey = Math.abs(e1[1]);
fez = Math.abs(e1[2]);
if (!axisTestX01(e1[2], e1[1], fez, fey)) return false;
if (!axisTestY02(e1[2], e1[0], fez, fex)) return false;
if (!axisTestZ0(e1[1], e1[0], fey, fex)) return false;
if (!axisTestX01(e1[2], e1[1], fez, fey)) {
return false;
}
if (!axisTestY02(e1[2], e1[0], fez, fex)) {
return false;
}
if (!axisTestZ0(e1[1], e1[0], fey, fex)) {
return false;
}
fex = Math.abs(e2[0]);
fey = Math.abs(e2[1]);
fez = Math.abs(e2[2]);
if (!axisTestX2(e2[2], e2[1], fez, fey)) return false;
if (!axisTestY1(e2[2], e2[0], fez, fex)) return false;
if (!axisTestZ12(e2[1], e2[0], fey, fex)) return false;
if (!axisTestX2(e2[2], e2[1], fez, fey)) {
return false;
}
if (!axisTestY1(e2[2], e2[0], fez, fex)) {
return false;
}
if (!axisTestZ12(e2[1], e2[0], fey, fex)) {
return false;
}
max = MathMan.max(v0[0], v1[0], v2[0]);
min = MathMan.min(v0[0], v1[0], v2[0]);
if (min > boxhalfsize[0] || max < -boxhalfsize[0]) return false;
if (min > boxhalfsize[0] || max < -boxhalfsize[0]) {
return false;
}
max = MathMan.max(v0[1], v1[1], v2[1]);
min = MathMan.min(v0[1], v1[1], v2[1]);
if (min > boxhalfsize[1] || max < -boxhalfsize[1]) return false;
if (min > boxhalfsize[1] || max < -boxhalfsize[1]) {
return false;
}
max = MathMan.max(v0[2], v1[2], v2[2]);
min = MathMan.min(v0[2], v1[2], v2[2]);
if (min > boxhalfsize[2] || max < -boxhalfsize[2]) return false;
if (min > boxhalfsize[2] || max < -boxhalfsize[2]) {
return false;
}
cross(normal, e0, e1);
return (planeBoxOverlap(normal, v0, boxhalfsize));
return planeBoxOverlap(normal, v0, boxhalfsize);
}
private boolean planeBoxOverlap(double normal[], double vert[], double maxbox[]) {
private boolean planeBoxOverlap(double[] normal, double[] vert, double[] maxbox) {
for (int q = 0; q <= 2; q++) {
double v = vert[q];
if (normal[q] > 0.0f) {
@ -240,8 +269,9 @@ public class Triangle {
vmax[q] = -maxbox[q] - v;
}
}
if (dot(normal, vmin) > 0.0f) return false;
if (dot(normal, vmax) >= 0.0f) return true;
return false;
if (dot(normal, vmin) > 0.0f) {
return false;
}
return dot(normal, vmax) >= 0.0f;
}
}

View File

@ -19,6 +19,8 @@
package com.boydti.fawe.object.regions.selector;
import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.object.regions.PolyhedralRegion;
import com.boydti.fawe.object.regions.Triangle;
import com.sk89q.worldedit.IncompleteRegionException;
@ -32,13 +34,14 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionSelector;
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
import com.sk89q.worldedit.world.World;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Creates a {@code PolyhedralRegion} from a user's selections.
*/
@ -51,7 +54,7 @@ public class PolyhedralRegionSelector implements RegionSelector, CUIRegion {
* Create a new selector with a {@code null} world.
*/
public PolyhedralRegionSelector() {
this((World) null);
this(null);
}
/**

View File

@ -1,48 +0,0 @@
package com.boydti.fawe.regions;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.AbstractRegion;
import com.sk89q.worldedit.regions.RegionOperationException;
import com.sk89q.worldedit.world.World;
public abstract class SimpleRegion extends AbstractRegion {
private final BlockVector3 max;
private final BlockVector3 min;
public SimpleRegion(World world, BlockVector3 min, BlockVector3 max) {
super(world);
this.min = min;
this.max = max;
}
@Override
public BlockVector3 getMinimumPoint() {
return min;
}
@Override
public BlockVector3 getMaximumPoint() {
return max;
}
@Override
public void expand(BlockVector3... changes) throws RegionOperationException {
throw new UnsupportedOperationException("Region is immutable");
}
@Override
public void contract(BlockVector3... changes) throws RegionOperationException {
throw new UnsupportedOperationException("Region is immutable");
}
@Override
public boolean contains(BlockVector3 p) {
return contains(p.getBlockX(), p.getBlockY(), p.getBlockZ());
}
@Override
public abstract boolean contains(int x, int y, int z);
@Override
public abstract boolean contains(int x, int z);
}

View File

@ -1,7 +1,8 @@
package com.boydti.fawe.regions.general;
public interface RegionFilter {
public boolean containsRegion(int mcaX, int mcaZ);
public boolean containsChunk(int chunkX, int chunkZ);
}
boolean containsRegion(int mcaX, int mcaZ);
boolean containsChunk(int chunkX, int chunkZ);
}

View File

@ -1,50 +0,0 @@
package com.boydti.fawe.regions.general.plot;
import com.github.intellectualsites.plotsquared.commands.Command;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.commands.CommandCategory;
import com.github.intellectualsites.plotsquared.plot.commands.MainCommand;
import com.github.intellectualsites.plotsquared.plot.commands.RequiredType;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea;
import com.sk89q.worldedit.WorldEdit;
import java.util.concurrent.CompletableFuture;
@CommandDeclaration(
command = "cfi",
permission = "plots.createfromimage",
aliases = {"createfromheightmap", "createfromimage", "cfhm"},
category = CommandCategory.APPEARANCE,
requiredType = RequiredType.NONE,
description = "Generate a world from an image heightmap: [More info](https://goo.gl/friFbV)",
usage = "/plots cfi [url or dimensions]"
)
public class CFIRedirect extends Command {
private final WorldEdit we;
public CFIRedirect() {
super(MainCommand.getInstance(), true);
this.we = WorldEdit.getInstance();
}
@Override
public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
checkTrue(args.length >= 1, Captions.COMMAND_SYNTAX, getUsage());
final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT);
checkTrue(plot.isOwner(player.getUUID()), Captions.NOW_OWNER);
checkTrue(plot.getRunning() == 0, Captions.WAIT_FOR_TIMER);
final PlotArea area = plot.getArea();
if (area instanceof SinglePlotArea) {
player.sendMessage("The command has been changed to: //cfi");
} else {
player.sendMessage("Must have the `worlds` component enabled in the PlotSquared config.yml");
return CompletableFuture.completedFuture(false);
}
return CompletableFuture.completedFuture(true);
}
}

View File

@ -1,103 +0,0 @@
package com.boydti.fawe.regions.general.plot;
import com.boydti.fawe.util.EditSessionBuilder;
import com.boydti.fawe.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.object.ChunkLoc;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.World;
import java.util.concurrent.CompletableFuture;
public class FaweChunkManager extends ChunkManager {
private ChunkManager parent;
public FaweChunkManager(ChunkManager parent) {
this.parent = parent;
}
@Override
public int[] countEntities(Plot plot) {
return parent.countEntities(plot);
}
@Override
public CompletableFuture loadChunk(String world, ChunkLoc loc, boolean force) {
return parent.loadChunk(world, loc, force);
}
@Override
public void unloadChunk(String world, ChunkLoc loc, boolean save) {
parent.unloadChunk(world, loc, save);
}
@Override
public void clearAllEntities(Location pos1, Location pos2) {
parent.clearAllEntities(pos1, pos2);
}
@Override
public void swap(final Location pos1, final Location pos2, final Location pos3, final Location pos4, final Runnable whenDone) {
TaskManager.IMP.async(() -> {
synchronized (FaweChunkManager.class) {
EditSession sessionA = new EditSessionBuilder(pos1.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
EditSession sessionB = new EditSessionBuilder(pos3.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
CuboidRegion regionA = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ()));
CuboidRegion regionB = new CuboidRegion(BlockVector3.at(pos3.getX(), pos3.getY(), pos3.getZ()), BlockVector3.at(pos4.getX(), pos4.getY(), pos4.getZ()));
ForwardExtentCopy copyA = new ForwardExtentCopy(sessionA, regionA, sessionB, regionB.getMinimumPoint());
ForwardExtentCopy copyB = new ForwardExtentCopy(sessionB, regionB, sessionA, regionA.getMinimumPoint());
try {
Operations.completeLegacy(copyA);
Operations.completeLegacy(copyB);
sessionA.flushQueue();
sessionB.flushQueue();
} catch (MaxChangedBlocksException e) {
e.printStackTrace();
}
TaskManager.IMP.task(whenDone);
}
});
}
@Override
public boolean copyRegion(final Location pos1, final Location pos2, final Location pos3, final Runnable whenDone) {
TaskManager.IMP.async(() -> {
synchronized (FaweChunkManager.class) {
EditSession from = new EditSessionBuilder(pos1.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
EditSession to = new EditSessionBuilder(pos3.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
CuboidRegion region = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ()));
ForwardExtentCopy copy = new ForwardExtentCopy(from, region, to, BlockVector3.at(pos3.getX(), pos3.getY(), pos3.getZ()));
try {
Operations.completeLegacy(copy);
to.flushQueue();
} catch (MaxChangedBlocksException e) {
e.printStackTrace();
}
}
TaskManager.IMP.task(whenDone);
});
return true;
}
@Override
public boolean regenerateRegion(final Location pos1, final Location pos2, boolean ignore, final Runnable whenDone) {
TaskManager.IMP.async(() -> {
synchronized (FaweChunkManager.class) {
EditSession editSession = new EditSessionBuilder(pos1.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
World world = editSession.getWorld();
CuboidRegion region = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ()));
world.regenerate(region, editSession);
editSession.flushQueue();
TaskManager.IMP.task(whenDone);
}
});
return true;
}
}

View File

@ -1,142 +0,0 @@
package com.boydti.fawe.regions.general.plot;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IQueueExtent;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.WorldEdit;
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.BiomeTypes;
import com.sk89q.worldedit.world.biome.Biomes;
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.LegacyMapper;
import java.util.Collection;
// TODO FIXME
public class FaweLocalBlockQueue extends LocalBlockQueue {
public final IQueueExtent IMP;
private final LegacyMapper legacyMapper;
private final World world;
public FaweLocalBlockQueue(String worldName) {
super(worldName);
this.world = FaweAPI.getWorld(worldName);
IMP = Fawe.get().getQueueHandler().getQueue(world);
legacyMapper = LegacyMapper.getInstance();
}
@Override
public boolean next() {
if (!IMP.isEmpty()) {
IMP.flush();
}
return false;
}
@Override
public void startSet(boolean parallel) {
Fawe.get().getQueueHandler().startSet(parallel);
}
@Override
public void endSet(boolean parallel) {
Fawe.get().getQueueHandler().endSet(parallel);
}
@Override
public int size() {
return IMP.isEmpty() ? 0 : 1;
}
@Override
public void optimize() {
}
@Override
public void setModified(long l) {
}
@Override
public long getModified() {
return IMP.size();
}
@Override
public boolean setBlock(final int x, final int y, final int z, final PlotBlock id) {
return setBlock(x, y, z, legacyMapper.getBaseBlockFromPlotBlock(id));
}
@Override
public boolean setBlock(final int x, final int y, final int z, final BaseBlock id) {
return IMP.setBlock(x, y, z, id);
}
@Override
public PlotBlock getBlock(int x, int y, int z) {
BlockState block = IMP.getBlock(x, y, z);
return PlotBlock.get(block.toBaseBlock());
}
private BiomeType biome;
private String lastBiome;
private BiomeRegistry reg;
@Override
public boolean setBiome(int x, int z, String biome) {
if (!StringMan.isEqual(biome, lastBiome)) {
if (reg == null) {
reg = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.USER_COMMANDS).getRegistries().getBiomeRegistry();
}
Collection<BiomeType> biomes = BiomeTypes.values();
lastBiome = biome;
this.biome = Biomes.findBiomeByName(biomes, biome, reg);
}
return IMP.setBiome(x, 0, z, this.biome);
}
@Override
public String getWorld() {
return world.getId();
}
@Override
public void flush() {
IMP.flush();
}
@Override
public boolean enqueue() {
boolean val = super.enqueue();
IMP.enableQueue();
return val;
}
@Override
public void refreshChunk(int x, int z) {
world.sendChunk(x, z, 0);
}
@Override
public void fixChunkLighting(int x, int z) {
}
@Override
public void regenChunk(int x, int z) {
IMP.regenerateChunk(x, z, null, null);
}
@Override
public boolean setTile(int x, int y, int z, CompoundTag tag) {
IMP.setTile(x, y, z, (com.sk89q.jnbt.CompoundTag) FaweCache.IMP.asTag(tag));
return true;
}
}

View File

@ -1,131 +0,0 @@
package com.boydti.fawe.regions.general.plot;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.object.clipboard.ReadOnlyClipboard;
import com.boydti.fawe.object.io.PGZIPOutputStream;
import com.boydti.fawe.util.EditSessionBuilder;
import com.boydti.fawe.util.IOUtil;
import com.boydti.fawe.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.CompressedCompoundTag;
import com.sk89q.jnbt.CompressedSchematicTag;
import com.sk89q.jnbt.NBTOutputStream;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.SpongeSchematicWriter;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URL;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import net.jpountz.lz4.LZ4BlockInputStream;
public class FaweSchematicHandler extends SchematicHandler {
@Override
public boolean restoreTile(LocalBlockQueue queue, CompoundTag compoundTag, int x, int y, int z) {
if (queue instanceof FaweLocalBlockQueue) {
queue.setTile(x, y, z, compoundTag);
return true;
}
return false;
}
@Override
public void getCompoundTag(final String world, final Set<RegionWrapper> regions, final RunnableVal<CompoundTag> whenDone) {
TaskManager.IMP.async(() -> {
Location[] corners = MainUtil.getCorners(world, regions);
Location pos1 = corners[0];
Location pos2 = corners[1];
final CuboidRegion region = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ()));
final EditSession editSession = new EditSessionBuilder(world).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
final int mx = pos1.getX();
final int my = pos1.getY();
final int mz = pos1.getZ();
ReadOnlyClipboard clipboard = ReadOnlyClipboard.of(editSession, region);
Clipboard holder = new BlockArrayClipboard(region, clipboard);
CompressedSchematicTag tag = new CompressedSchematicTag(holder);
whenDone.run(tag);
});
}
@Override
public boolean save(CompoundTag tag, String path) {
if (tag == null) {
PlotSquared.debug("&cCannot save empty tag");
return false;
}
try {
File tmp = MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), path);
tmp.getParentFile().mkdirs();
if (tag instanceof CompressedCompoundTag) {
CompressedCompoundTag cTag = (CompressedCompoundTag) tag;
if (cTag instanceof CompressedSchematicTag) {
Clipboard clipboard = (Clipboard) cTag.getSource();
try (OutputStream stream = new FileOutputStream(tmp); NBTOutputStream output = new NBTOutputStream(new BufferedOutputStream(new PGZIPOutputStream(stream)))) {
new SpongeSchematicWriter(output).write(clipboard);
}
} else {
try (OutputStream stream = new FileOutputStream(tmp); BufferedOutputStream output = new BufferedOutputStream(new PGZIPOutputStream(stream))) {
LZ4BlockInputStream is = cTag.adapt(cTag.getSource());
IOUtil.copy(is, stream);
}
}
} else {
try (OutputStream stream = new FileOutputStream(tmp); NBTOutputStream output = new NBTOutputStream(new PGZIPOutputStream(stream))) {
Map<String, Tag> map = tag.getValue();
output.writeNamedTag("Schematic", map.getOrDefault("Schematic", tag));
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
return false;
}
return true;
}
@Override
public void upload(final CompoundTag tag, final UUID uuid, final String file, final RunnableVal<URL> whenDone) {
if (tag == null) {
PlotSquared.debug("&cCannot save empty tag");
com.github.intellectualsites.plotsquared.plot.util.TaskManager.runTask(whenDone);
return;
}
MainUtil.upload(uuid, file, "schematic", new RunnableVal<OutputStream>() {
@Override
public void run(OutputStream output) {
try {
try (PGZIPOutputStream gzip = new PGZIPOutputStream(output)) {
CompoundTag weTag = (CompoundTag) FaweCache.IMP.asTag(tag);
try (NBTOutputStream nos = new NBTOutputStream(gzip)) {
Map<String, Tag> map = weTag.getValue();
nos.writeNamedTag("Schematic", map.getOrDefault("Schematic", weTag));
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}, whenDone);
}
}

View File

@ -1,57 +0,0 @@
package com.boydti.fawe.regions.general.plot;
import com.boydti.fawe.util.TaskManager;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.commands.CommandCategory;
import com.github.intellectualsites.plotsquared.plot.commands.RequiredType;
import com.github.intellectualsites.plotsquared.plot.commands.SubCommand;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
@CommandDeclaration(
command = "trimchunks",
permission = "plots.admin",
description = "Delete unmodified portions of your plotworld",
requiredType = RequiredType.PLAYER,
category = CommandCategory.ADMINISTRATION)
public class FaweTrim extends SubCommand {
private boolean ran = false;
@Override
public boolean onCommand(final PlotPlayer plotPlayer, final String[] strings) {
if (ran) {
plotPlayer.sendMessage("Already running!");
return false;
}
if (strings.length != 2) {
plotPlayer.sendMessage("First make a backup of your world called <world-copy> then stand in the middle of an empty plot");
plotPlayer.sendMessage("use /plot trimall <world> <boolean-delete-unowned>");
return false;
}
if (!WorldUtil.IMP.isWorld(strings[0])) {
Captions.NOT_VALID_PLOT_WORLD.send(plotPlayer, strings[0]);
return false;
}
ran = true;
TaskManager.IMP.async(new Runnable() {
@Override
public void run() {
try {
// TODO NOT IMPLEMENTED
// PlotTrim trim = new PlotTrim(plotPlayer, plotPlayer.getPlotAreaAbs(), strings[0], Boolean.parseBoolean(strings[1]));
// Location loc = plotPlayer.getLocation();
// trim.setChunk(loc.getX() >> 4, loc.getZ() >> 4);
// trim.run();
// plotPlayer.sendMessage("Done!");
} catch (Throwable e) {
e.printStackTrace();
}
ran = false;
}
});
return true;
}
}

View File

@ -1,341 +0,0 @@
package com.boydti.fawe.regions.general.plot;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.commands.CommandCategory;
import com.github.intellectualsites.plotsquared.plot.commands.RequiredType;
@CommandDeclaration(
command = "moveto512",
permission = "plots.moveto512",
category = CommandCategory.DEBUG,
requiredType = RequiredType.CONSOLE,
description = "Move plots to a 512 sized region",
usage = "/plots moveto512 [world]"
)
// TODO FIXME
public class MoveTo512 /*extends Command*/ {
// public MoveTo512() {
// super(MainCommand.getInstance(), true);
// }
//
// private MCAChunk emptyPlot(MCAChunk chunk, HybridPlotWorld hpw) {
// int maxLayer = (hpw.PLOT_HEIGHT) >> 4;
// for (int i = maxLayer + 1; i < chunk.ids.length; i++) {
// chunk.ids[i] = null;
// chunk.data[i] = null;
// }
// for (int layer = 0; layer <= maxLayer; layer++) {
// byte[] ids = chunk.ids[layer];
// if (ids == null) {
// ids = chunk.ids[layer] = new byte[4096];
// chunk.data[layer] = new byte[2048];
// chunk.skyLight[layer] = new byte[2048];
// chunk.blockLight[layer] = new byte[2048];
// } else {
// Arrays.fill(ids, (byte) 0);
// Arrays.fill(chunk.data[layer], (byte) 0);
// Arrays.fill(chunk.skyLight[layer], (byte) 0);
// Arrays.fill(chunk.blockLight[layer], (byte) 0);
// }
// if (layer == maxLayer) {
// int yMax = hpw.PLOT_HEIGHT & 15;
// for (int y = yMax + 1; y < 15; y++) {
// Arrays.fill(chunk.skyLight[layer], y << 7, (y << 7) + 128, (byte) 255);
// }
// if (layer == 0) {
// Arrays.fill(ids, 0, 256, (byte) 7);
// for (int y = 1; y < yMax; y++) {
// int y8 = y << 8;
// Arrays.fill(ids, y8, y8 + 256, (byte) 3);
// }
// } else {
// for (int y = 0; y < yMax; y++) {
// int y8 = y << 8;
// Arrays.fill(ids, y8, y8 + 256, (byte) 3);
// }
// }
// int yMax15 = yMax & 15;
// int yMax158 = yMax15 << 8;
// Arrays.fill(ids, yMax158, yMax158 + 256, (byte) 2);
// if (yMax != 15) {
// Arrays.fill(ids, yMax158 + 256, 4096, (byte) 0);
// }
// } else if (layer == 0){
// Arrays.fill(ids, 256, 4096, (byte) 3);
// Arrays.fill(ids, 0, 256, (byte) 7);
// } else {
// Arrays.fill(ids, (byte) 3);
// }
// }
// return chunk;
// }
//
// private MCAChunk emptyRoad(MCAChunk chunk, HybridPlotWorld hpw) {
// int maxLayer = (hpw.ROAD_HEIGHT) >> 4;
// for (int i = maxLayer + 1; i < chunk.ids.length; i++) {
// chunk.ids[i] = null;
// chunk.data[i] = null;
// }
// for (int layer = 0; layer <= maxLayer; layer++) {
// byte[] ids = chunk.ids[layer];
// if (ids == null) {
// ids = chunk.ids[layer] = new byte[4096];
// chunk.data[layer] = new byte[2048];
// chunk.skyLight[layer] = new byte[2048];
// chunk.blockLight[layer] = new byte[2048];
// } else {
// Arrays.fill(ids, (byte) 0);
// Arrays.fill(chunk.data[layer], (byte) 0);
// Arrays.fill(chunk.skyLight[layer], (byte) 0);
// Arrays.fill(chunk.blockLight[layer], (byte) 0);
// }
// if (layer == maxLayer) {
// int yMax = hpw.ROAD_HEIGHT & 15;
// for (int y = yMax + 1; y < 15; y++) {
// Arrays.fill(chunk.skyLight[layer], y << 7, (y << 7) + 128, (byte) 255);
// }
// if (layer == 0) {
// Arrays.fill(ids, 0, 256, (byte) 7);
// for (int y = 1; y <= yMax; y++) {
// int y8 = y << 8;
// Arrays.fill(ids, y8, y8 + 256, (byte) hpw.ROAD_BLOCK.id);
// }
// } else {
// for (int y = 0; y <= yMax; y++) {
// int y8 = y << 8;
// Arrays.fill(ids, y8, y8 + 256, (byte) hpw.ROAD_BLOCK.id);
// }
// }
// if (yMax != 15) {
// int yMax15 = yMax & 15;
// int yMax158 = yMax15 << 8;
// Arrays.fill(ids, yMax158 + 256, 4096, (byte) 0);
// }
// } else if (layer == 0){
// Arrays.fill(ids, 256, 4096, (byte) hpw.ROAD_BLOCK.id);
// Arrays.fill(ids, 0, 256, (byte) 7);
// } else {
// Arrays.fill(ids, (byte) hpw.ROAD_BLOCK.id);
// }
// }
// return chunk;
// }
// @Override
// public void execute(PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
// checkTrue(args.length == 1, Captions.COMMAND_SYNTAX, getUsage());
// PlotArea area = player.getPlotAreaAbs();
// check(area, Captions.COMMAND_SYNTAX, getUsage());
// checkTrue(area instanceof HybridPlotWorld, Captions.NOT_VALID_HYBRID_PLOT_WORLD);
//
// WorldUtil.IMP.saveWorld(area.worldname);
//
// IQueueExtent defaultQueue = SetQueue.IMP.getNewQueue(area.worldname, true, false);
// MCAQueue queueFrom = new MCAQueue(area.worldname, defaultQueue.getSaveFolder(), defaultQueue.hasSky());
//
// String world = args[0];
// File folder = new File(PS.imp().getWorldContainer(), world + File.separator + "region");
// checkTrue(!folder.exists(), Captions.SETUP_WORLD_TAKEN, world);
//
// HybridPlotWorld hpw = (HybridPlotWorld) area;
// int minRoad = 7;
// int pLen = Math.min(hpw.PLOT_WIDTH, 512 - minRoad);
// int roadWidth = 512 - pLen;
// int roadPosLower;
// if ((roadWidth & 1) == 0) {
// roadPosLower = (short) (Math.floor(roadWidth / 2) - 1);
// } else {
// roadPosLower = (short) Math.floor(roadWidth / 2);
// }
// int roadPosUpper = 512 - roadWidth + roadPosLower + 1;
//
// final ThreadLocal<boolean[]> roadCache = new ThreadLocal<boolean[]>() {
// @Override
// protected boolean[] initialValue() {
// return new boolean[64];
// }
// };
//
// MCAChunk reference = new MCAChunk(null, 0, 0);
// {
// reference.fillCuboid(0, 15, 0, 0, 0, 15, 7, (byte) 0);
// reference.fillCuboid(0, 15, 1, hpw.PLOT_HEIGHT - 1, 0, 15, 3, (byte) 0);
// reference.fillCuboid(0, 15, hpw.PLOT_HEIGHT, hpw.PLOT_HEIGHT, 0, 15, 2, (byte) 0);
// }
//
// Map<PlotId, Plot> rawPlots = area.getPlotsRaw();
// ArrayList<Plot> plots = new ArrayList(rawPlots.values());
// int size = plots.size();
//
// PlotId nextId = new PlotId(0, 0);
//
// long start = System.currentTimeMillis();
//
// int percent = 0;
// for (Plot plot : plots) {
// Fawe.debug(((percent += 100) / size) + "% complete!");
//
// Location bot = plot.getBottomAbs();
// Location top = plot.getTopAbs();
//
// int oX = roadPosLower - bot.getX() + 1;
// int oZ = roadPosLower - bot.getZ() + 1;
//
// { // Move
// PlotId id = plot.getId();
// Fawe.debug("Moving " + plot.getId() + " to " + nextId);
// id.x = nextId.x;
// id.y = nextId.y;
// id.recalculateHash();
// }
//
// MCAWriter writer = new MCAWriter(512, 512, folder) {
//
// @Override
// public boolean shouldWrite(int chunkX, int chunkZ) {
// int bx = chunkX << 4;
// int bz = chunkZ << 4;
// int tx = bx + 15;
// int tz = bz + 15;
// return !(tx < roadPosLower || tz < roadPosLower || bx > roadPosUpper || bz > roadPosUpper);
// }
//
// @Override
// public MCAChunk write(MCAChunk newChunk, int bx, int tx, int bz, int tz) {
// Arrays.fill(newChunk.biomes, (byte) 4);
// if (!newChunk.tiles.isEmpty()) newChunk.tiles.clear();
// if (tx < roadPosLower || tz < roadPosLower || bx > roadPosUpper || bz > roadPosUpper) {
// return emptyRoad(newChunk, hpw);
// } else {
// boolean partRoad = (bx <= roadPosLower || bz <= roadPosLower || tx >= roadPosUpper || tz >= roadPosUpper);
//
// boolean changed = false;
// emptyPlot(newChunk, hpw);
//
// int obx = bx - oX;
// int obz = bz - oZ;
// int otx = tx - oX;
// int otz = tz - oZ;
// int otherBCX = (obx) >> 4;
// int otherBCZ = (obz) >> 4;
// int otherTCX = (otx) >> 4;
// int otherTCZ = (otz) >> 4;
// int cx = newChunk.getX();
// int cz = newChunk.getZ();
// int cbx = (cx << 4) - oX;
// int cbz = (cz << 4) - oZ;
//
// for (int otherCZ = otherBCZ; otherCZ <= otherTCZ; otherCZ++) {
// for (int otherCX = otherBCX; otherCX <= otherTCX; otherCX++) {
// FaweChunk chunk;
// synchronized (queueFrom) {
// chunk = queueFrom.getFaweChunk(otherCX, otherCZ);
// }
// if (!(chunk instanceof NullFaweChunk)) {
// changed = true;
// MCAChunk other = (MCAChunk) chunk;
// int ocbx = otherCX << 4;
// int ocbz = otherCZ << 4;
// int octx = ocbx + 15;
// int octz = ocbz + 15;
// int offsetY = 0;
// int minX = obx > ocbx ? (obx - ocbx) & 15 : 0;
// int maxX = otx < octx ? (otx - ocbx) : 15;
// int minZ = obz > ocbz ? (obz - ocbz) & 15 : 0;
// int maxZ = otz < octz ? (otz - ocbz) : 15;
// int offsetX = ocbx - cbx;
// int offsetZ = ocbz - cbz;
// newChunk.copyFrom(other, minX, maxX, 0, 255, minZ, maxZ, offsetX, offsetY, offsetZ);
// }
// }
// }
// if (!changed || reference.idsEqual(newChunk, false)) {
// return null;
// }
// if (partRoad) {
// boolean[] rwp = roadCache.get();
// for (short i = 0; i < 16; i++) {
// int vx = bx + i;
// int vz = bz + i;
// rwp[i] = vx < roadPosLower || vx > roadPosUpper;
// rwp[i + 32] = vx == roadPosLower || vx == roadPosUpper;
// rwp[i + 16] = vz < roadPosLower || vz > roadPosUpper;
// rwp[i + 48] = vz == roadPosLower || vz == roadPosUpper;
// }
// for (int z = 0; z < 16; z++) {
// final boolean rwpz16 = rwp[z + 16];
// final boolean rwpz48 = rwp[z + 48];
// for (int x = 0; x < 16; x++) {
// if (rwpz16 || rwp[x]) {
// for (int y = 1; y <= hpw.ROAD_HEIGHT; y++) {
// newChunk.setBlock(x, y, z, hpw.ROAD_BLOCK.id, hpw.ROAD_BLOCK.data);
// }
// for (int y = hpw.ROAD_HEIGHT + 1; y < 256; y++) {
// newChunk.setBlock(x, y, z, 0, 0);
// }
// } else if (rwpz48 || rwp[x + 32]) {
// for (int y = 1; y <= hpw.WALL_HEIGHT; y++) {
// newChunk.setBlock(x, y, z, hpw.WALL_FILLING.id, hpw.WALL_FILLING.data);
// }
// for (int y = hpw.WALL_HEIGHT + 2; y < 256; y++) {
// newChunk.setBlock(x, y, z, 0, 0);
// }
// newChunk.setBlock(x, hpw.WALL_HEIGHT + 1, z, hpw.CLAIMED_WALL_BLOCK.id, hpw.CLAIMED_WALL_BLOCK.data);
// }
// }
// }
// }
// }
// return newChunk;
// }
// };
// writer.setMCAOffset(nextId.x - 1, nextId.y - 1);
// try {
// writer.generate();
// System.gc();
// } catch (IOException e) {
// e.printStackTrace();
// return;
// }
// queueFrom.clear();
// nextId = nextId.getNextId(1);
// }
// Fawe.debug("Anvil copy completed in " + ((System.currentTimeMillis() - start) / 1000d) + "s");
// Fawe.debug("Updating database, please wait...");
// rawPlots.clear();
// for (Plot plot : plots) {
// rawPlots.put(plot.getId(), plot);
// DBFunc.movePlot(plot, plot);
// }
// SQLManager db = (SQLManager) DBFunc.dbManager;
// db.addNotifyTask(new Runnable() {
// @Override
// public void run() {
// Fawe.debug("Instructions");
// Fawe.debug(" - Stop the server");
// Fawe.debug(" - Rename the folder for the new world to the current world");
// Fawe.debug(" - Change the plot size to " + pLen);
// Fawe.debug(" - Change the road size to " + roadWidth);
// Fawe.debug(" - Start the server");
// }
// });
//
// ConfigurationSection section = PS.get().worlds.getConfigurationSection("worlds." + world);
// if (section == null) section = PS.get().worlds.createSection("worlds." + world);
// area.saveConfiguration(section);
// section.set("plot.size", pLen);
// section.set("road.width", roadWidth);
// try {
// PS.get().worlds.save(PS.get().worldsFile);
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// final SetupObject object = new SetupObject();
// object.world = world;
// object.plotManager = PS.imp().getPluginName();
// object.setupGenerator = PS.imp().getPluginName();
// String created = SetupUtils.manager.setupWorld(object);
// }
}

View File

@ -1,28 +0,0 @@
package com.boydti.fawe.regions.general.plot;
import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.regions.general.CuboidRegionFilter;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.sk89q.worldedit.math.BlockVector2;
import java.util.ArrayList;
public class PlotRegionFilter extends CuboidRegionFilter {
private final PlotArea area;
public PlotRegionFilter(PlotArea area) {
checkNotNull(area);
this.area = area;
}
@Override
public void calculateRegions() {
ArrayList<Plot> plots = new ArrayList<>(area.getPlots());
for (Plot plot : plots) {
Location bottom = plot.getCorners()[0];
Location top = plot.getCorners()[1];
add(BlockVector2.at(bottom.getX(), bottom.getZ()), BlockVector2.at(top.getX(), top.getZ()));
}
}
}

View File

@ -1,100 +0,0 @@
package com.boydti.fawe.regions.general.plot;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.util.EditSessionBuilder;
import com.boydti.fawe.util.TaskManager;
import com.github.intellectualsites.plotsquared.commands.Command;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.commands.CommandCategory;
import com.github.intellectualsites.plotsquared.plot.commands.MainCommand;
import com.github.intellectualsites.plotsquared.plot.commands.RequiredType;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
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.registry.BiomeRegistry;
import java.util.Collection;
import java.util.HashSet;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ThreadLocalRandom;
@CommandDeclaration(
command = "generatebiome",
permission = "plots.generatebiome",
category = CommandCategory.APPEARANCE,
requiredType = RequiredType.NONE,
description = "Generate a biome in your plot",
aliases = {"bg", "gb"},
usage = "/plots generatebiome <biome>"
)
public class PlotSetBiome extends Command {
public PlotSetBiome() {
super(MainCommand.getInstance(), true);
}
@Override
public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT);
checkTrue(plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.admin.command.generatebiome"), Captions.NO_PLOT_PERMS);
if (plot.getRunning() != 0) {
Captions.WAIT_FOR_TIMER.send(player);
return null;
}
checkTrue(args.length == 1, Captions.COMMAND_SYNTAX, getUsage());
final HashSet<RegionWrapper> regions = plot.getRegions();
BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
Collection<BiomeType> knownBiomes = BiomeTypes.values();
final BiomeType biome = Biomes.findBiomeByName(knownBiomes, args[0], biomeRegistry);
if (biome == null) {
String biomes = StringMan.join(WorldUtil.IMP.getBiomeList(), Captions.BLOCK_LIST_SEPARATOR.toString());
Captions.NEED_BIOME.send(player);
MainUtil.sendMessage(player, Captions.SUBCOMMAND_SET_OPTIONS_HEADER.toString() + biomes);
return CompletableFuture.completedFuture(false);
}
confirm.run(this, new Runnable() {
@Override
public void run() {
if (plot.getRunning() != 0) {
Captions.WAIT_FOR_TIMER.send(player);
return;
}
plot.addRunning();
TaskManager.IMP.async(new Runnable() {
@Override
public void run() {
EditSession session = new EditSessionBuilder(plot.getArea().worldname)
.autoQueue(false)
.checkMemory(false)
.allowedRegionsEverywhere()
.player(Fawe.imp().wrap(player.getName()))
.limitUnlimited()
.build();
long seed = ThreadLocalRandom.current().nextLong();
for (RegionWrapper region : regions) {
CuboidRegion cuboid = new CuboidRegion(BlockVector3.at(region.minX, 0, region.minZ), BlockVector3.at(region.maxX, 256, region.maxZ));
session.regenerate(cuboid, biome, seed);
}
session.flushQueue();
plot.removeRunning();
}
});
}
}, null);
return CompletableFuture.completedFuture(true);
}
}

View File

@ -1,169 +0,0 @@
package com.boydti.fawe.regions.general.plot;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.regions.FaweMask;
import com.boydti.fawe.regions.FaweMaskManager;
import com.boydti.fawe.regions.SimpleRegion;
import com.boydti.fawe.regions.general.RegionFilter;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.commands.MainCommand;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.generator.HybridPlotManager;
import com.github.intellectualsites.plotsquared.plot.listener.WEManager;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper;
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.block.QueueProvider;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region;
import java.util.HashSet;
import java.util.UUID;
public class PlotSquaredFeature extends FaweMaskManager {
public PlotSquaredFeature() {
super("PlotSquared");
Fawe.debug("Optimizing PlotSquared");
setupBlockQueue();
setupSchematicHandler();
setupChunkManager();
if (Settings.PLATFORM.equalsIgnoreCase("bukkit")) {
new FaweTrim();
}
if (MainCommand.getInstance().getCommand("generatebiome") == null) {
new PlotSetBiome();
}
// TODO: revisit this later on
/*
try {
if (Settings.Enabled_Components.WORLDS) {
new ReplaceAll();
}
} catch (Throwable e) {
Fawe.debug("You need to update PlotSquared to access the CFI and REPLACEALL commands");
}
*/
}
public static String getName(UUID uuid) {
return UUIDHandler.getName(uuid);
}
private void setupBlockQueue() {
try {
// If it's going to fail, throw an error now rather than later
QueueProvider provider = QueueProvider.of(FaweLocalBlockQueue.class, null);
GlobalBlockQueue.IMP.setProvider(provider);
HybridPlotManager.REGENERATIVE_CLEAR = false;
Fawe.debug(" - QueueProvider: " + FaweLocalBlockQueue.class);
Fawe.debug(" - HybridPlotManager.REGENERATIVE_CLEAR: " + HybridPlotManager.REGENERATIVE_CLEAR);
} catch (Throwable e) {
Fawe.debug("Please update PlotSquared: http://ci.athion.net/job/PlotSquared/");
}
}
private void setupChunkManager() {
try {
ChunkManager.manager = new FaweChunkManager(ChunkManager.manager);
Fawe.debug(" - ChunkManager: " + ChunkManager.manager);
} catch (Throwable e) {
Fawe.debug("Please update PlotSquared: http://ci.athion.net/job/PlotSquared/");
}
}
private void setupSchematicHandler() {
try {
SchematicHandler.manager = new FaweSchematicHandler();
Fawe.debug(" - SchematicHandler: " + SchematicHandler.manager);
} catch (Throwable e) {
Fawe.debug("Please update PlotSquared: http://ci.athion.net/job/PlotSquared/");
}
}
public boolean isAllowed(com.sk89q.worldedit.entity.Player player, Plot plot, MaskType type) {
if (plot == null) {
return false;
}
UUID uid = player.getUniqueId();
return !Flags.NO_WORLDEDIT.isTrue(plot) && ((plot.isOwner(uid) || (type == MaskType.MEMBER && (plot.getTrusted().contains(uid) || plot.getTrusted().contains(DBFunc.EVERYONE) || ((plot.getMembers().contains(uid) || plot.getMembers().contains(DBFunc.EVERYONE)) && player.hasPermission("fawe.plotsquared.member"))))) || player.hasPermission("fawe.plotsquared.admin"));
}
@Override
public FaweMask getMask(Player fp, MaskType type) {
final PlotPlayer pp = PlotPlayer.wrap(fp);
final HashSet<RegionWrapper> regions;
Plot plot = pp.getCurrentPlot();
if (isAllowed(fp, plot, type)) {
regions = plot.getRegions();
} else {
plot = null;
regions = WEManager.getMask(pp);
if (regions.size() == 1) {
RegionWrapper region = regions.iterator().next();
if (region.minX == Integer.MIN_VALUE && region.maxX == Integer.MAX_VALUE) {
regions.clear();
}
}
}
if (regions.size() == 0) {
return null;
}
PlotArea area = pp.getApplicablePlotArea();
int min = area != null ? area.MIN_BUILD_HEIGHT : 0;
int max = area != null ? Math.min(255, area.MAX_BUILD_HEIGHT) : 255;
final HashSet<com.boydti.fawe.object.RegionWrapper> faweRegions = new HashSet<>();
for (final RegionWrapper current : regions) {
faweRegions.add(new com.boydti.fawe.object.RegionWrapper(current.minX, current.maxX, min, max, current.minZ, current.maxZ));
}
final RegionWrapper region = regions.iterator().next();
final BlockVector3 pos1 = BlockVector3.at(region.minX, min, region.minZ);
final BlockVector3 pos2 = BlockVector3.at(region.maxX, max, region.maxZ);
final Plot finalPlot = plot;
if (Settings.Done.RESTRICT_BUILDING && Flags.DONE.isSet(finalPlot) || regions.isEmpty()) {
return null;
}
Region maskedRegion;
if (regions.size() == 1) {
maskedRegion = new CuboidRegion(pos1, pos2);
} else {
maskedRegion = new SimpleRegion(FaweAPI.getWorld(area.worldname), pos1, pos2) {
@Override
public boolean contains(int x, int y, int z) {
return WEManager.maskContains(regions, x, y, z);
}
@Override
public boolean contains(int x, int z) {
return WEManager.maskContains(regions, x, z);
}
};
}
return new FaweMask(maskedRegion) {
@Override
public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) {
if (Settings.Done.RESTRICT_BUILDING && Flags.DONE.isSet(finalPlot)) {
return false;
}
return isAllowed(player, finalPlot, type);
}
};
}
@Override
public RegionFilter getFilter(String world) {
PlotArea area = PlotSquared.get().getPlotArea(world, null);
if (area != null) return new PlotRegionFilter(area);
return null;
}
}

View File

@ -1,75 +0,0 @@
/*
package com.boydti.fawe.regions.general.plot;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.util.StringMan;
import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.wrappers.FakePlayer;
import com.github.intellectualsites.plotsquared.commands.Command;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.commands.CommandCategory;
import com.github.intellectualsites.plotsquared.plot.commands.MainCommand;
import com.github.intellectualsites.plotsquared.plot.commands.RequiredType;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea;
import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
import com.sk89q.worldedit.event.platform.CommandEvent;
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
@CommandDeclaration(
command = "replaceall",
permission = "plots.replaceall",
category = CommandCategory.APPEARANCE,
requiredType = RequiredType.NONE,
description = "Replace all block in the plot",
usage = "/plots replaceall <from> <to>"
)
public class ReplaceAll extends Command {
public ReplaceAll() {
super(MainCommand.getInstance(), true);
}
@Override
public void execute(final PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
checkTrue(args.length >= 1, Captions.COMMAND_SYNTAX, getUsage());
final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT);
checkTrue(plot.isOwner(player.getUUID()), Captions.NOW_OWNER);
checkTrue(plot.getRunning() == 0, Captions.WAIT_FOR_TIMER);
final PlotArea area = plot.getArea();
if (area instanceof SinglePlotArea) {
plot.addRunning();
FawePlayer<Object> fp = FawePlayer.wrap(player.getName());
Captions.TASK_START.send(player);
TaskManager.IMP.async(() -> fp.runAction(() -> {
String worldName = plot.getWorldName();
TaskManager.IMP.sync(new RunnableVal<Object>() {
@Override
public void run(Object value) {
SetupUtils.manager.unload(worldName, true);
}
});
FakePlayer actor = FakePlayer.getConsole();
String cmd = "/replaceallpattern " + worldName + " " + StringMan.join(args, " ");
CommandEvent event = new CommandEvent(actor, cmd);
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event);
TaskManager.IMP.sync(new RunnableVal<Object>() {
@Override
public void run(Object value) {
plot.teleportPlayer(player);
}
});
plot.removeRunning();
}, true, false));
} else {
player.sendMessage("Must have the `worlds` component enabled in the PlotSquared config.yml");
return;
}
}
}
*/

View File

@ -372,8 +372,8 @@ public class LocalSession implements TextureHolder {
public void remember(EditSession editSession) {
checkNotNull(editSession);
Player fp = editSession.getPlayer();
int limit = fp == null ? Integer.MAX_VALUE : fp.getLimit().MAX_HISTORY;
Player player = editSession.getPlayer();
int limit = player == null ? Integer.MAX_VALUE : player.getLimit().MAX_HISTORY;
remember(editSession, true, limit);
}
@ -507,7 +507,6 @@ public class LocalSession implements TextureHolder {
*/
public EditSession undo(@Nullable BlockBag newBlockBag, Actor actor) {
checkNotNull(actor);
//TODO This method needs to be modified to use actors instead of FAWEPlayer
loadSessionHistoryFromDisk(actor.getUniqueId(), ((Player) actor).getWorldForEditing());
if (getHistoryNegativeIndex() < history.size()) {
FaweChangeSet changeSet = getChangeSet(history.get(getHistoryIndex()));
@ -544,7 +543,6 @@ public class LocalSession implements TextureHolder {
*/
public EditSession redo(@Nullable BlockBag newBlockBag, Actor actor) {
checkNotNull(actor);
//TODO This method needs to be modified to use actors instead of FAWEPlayer
loadSessionHistoryFromDisk(actor.getUniqueId(), ((Player)actor).getWorldForEditing());
if (getHistoryNegativeIndex() > 0) {
setDirty();
@ -622,16 +620,12 @@ public class LocalSession implements TextureHolder {
*/
public RegionSelector getRegionSelector(World world) {
checkNotNull(world);
try {
if (selector.getWorld() == null || !selector.getWorld().equals(world)) {
selector.setWorld(world);
selector.clear();
if (hasWorldOverride() && !world.equals(getWorldOverride())) {
setWorldOverride(null);
}
}
} catch (Throwable ignore) {
if (selector.getWorld() == null || !selector.getWorld().equals(world)) {
selector.setWorld(world);
selector.clear();
if (hasWorldOverride() && !world.equals(getWorldOverride())) {
setWorldOverride(null);
}
}
return selector;
}
@ -1044,6 +1038,7 @@ public class LocalSession implements TextureHolder {
} else if (type.getId().equalsIgnoreCase(config.navigationWand)) {
throw new InvalidToolBindException(type, "Already used for the navigation wand");
}
Tool previous;
if (player != null && (tool instanceof BrushTool || tool == null) && Settings.IMP.EXPERIMENTAL.PERSISTENT_BRUSHES && item.getNativeItem() != null) {
previous = BrushCache.getCachedTool(item);
@ -1350,23 +1345,25 @@ public class LocalSession implements TextureHolder {
*/
public EditSession createEditSession(Actor actor) {
checkNotNull(actor);
BlockBag blockBag = null;
if (actor.isPlayer() && actor instanceof Player) {
blockBag = getBlockBag((Player) actor);
}
World world = null;
if (hasWorldOverride()) {
world = getWorldOverride();
} else if (actor instanceof Locatable && ((Locatable) actor).getExtent() instanceof World) {
world = (World) ((Locatable) actor).getExtent();
}
EditSessionBuilder builder = new EditSessionBuilder(world);
if (actor.isPlayer() && actor instanceof Player) builder.player((Player) actor);
builder.blockBag(blockBag);
builder.fastmode(fastMode);
// Create an edit session
EditSession editSession = builder.build();
EditSession editSession;
EditSessionBuilder builder = new EditSessionBuilder(world);
if (actor.isPlayer() && actor instanceof Player) {
BlockBag blockBag = getBlockBag((Player) actor);
builder.player((Player) actor);
builder.blockBag(blockBag);
}
builder.fastmode(fastMode);
editSession = builder.build();
if (mask != null) {
editSession.setMask(mask);

View File

@ -41,7 +41,6 @@ import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.internal.annotation.Direction;
import com.sk89q.worldedit.internal.command.CommandRegistrationHandler;
import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.internal.expression.runtime.Constant;
import com.sk89q.worldedit.regions.factory.RegionFactory;
import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.util.formatting.text.TextComponent;

View File

@ -132,7 +132,6 @@ import org.enginehub.piston.annotation.param.Arg;
import org.enginehub.piston.annotation.param.ArgFlag;
import org.enginehub.piston.annotation.param.Switch;
import org.enginehub.piston.inject.InjectedValueAccess;
import org.enginehub.piston.inject.Key;
/**
* Commands to set brush shape.
@ -162,9 +161,9 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.blendball")
public void blendBallBrush(Player player, LocalSession session,
@Arg(desc = "The radius to sample for blending", def = "5")
Expression radius, InjectedValueAccess context) throws WorldEditException {
Expression radius) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
set(session, context, new BlendBall()).setSize(radius);
set(player, session, new BlendBall()).setSize(radius);
}
@Command(
@ -174,9 +173,9 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.erode")
public void erodeBrush(Player player, LocalSession session,
@Arg(desc = "The radius for eroding", def = "5")
Expression radius, InjectedValueAccess context) throws WorldEditException {
Expression radius) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
set(session, context, new ErodeBrush()).setSize(radius);
set(player, session, new ErodeBrush()).setSize(radius);
}
@Command(
@ -186,9 +185,9 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.pull")
public void pullBrush(Player player, LocalSession session,
@Arg(desc = "The radius to sample for blending", def = "5")
Expression radius, InjectedValueAccess context) throws WorldEditException {
Expression radius) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
set(session, context, new RaiseBrush()).setSize(radius);
set(player, session, new RaiseBrush()).setSize(radius);
}
@Command(
@ -196,11 +195,12 @@ public class BrushCommands {
desc = "Creates a circle which revolves around your facing direction"
)
@CommandPermissions("worldedit.brush.sphere")
public void circleBrush(Player player, EditSession editSession, LocalSession session, Pattern fill,
public void circleBrush(Player player, EditSession editSession, LocalSession session,
Pattern fill,
@Arg(desc = "The radius to sample for blending", def = "5")
Expression radius, InjectedValueAccess context) throws WorldEditException {
Expression radius) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
set(session, context, new CircleBrush(player)).setSize(radius).setFill(fill);
set(player, session, new CircleBrush(player)).setSize(radius).setFill(fill);
}
@Command(
@ -211,14 +211,14 @@ public class BrushCommands {
"Note: Set a mask to recurse along specific blocks"
)
@CommandPermissions("worldedit.brush.recursive")
public void recursiveBrush(Player player, LocalSession session, EditSession editSession, Pattern fill,
public void recursiveBrush(Player player, LocalSession session, EditSession editSession,
Pattern fill,
@Arg(desc = "The radius to sample for blending", def = "5")
Expression radius,
@Switch(name = 'd', desc = "Apply in depth first order")
boolean depthFirst,
InjectedValueAccess context) throws WorldEditException {
boolean depthFirst) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
set(session, context, new RecurseBrush(depthFirst))
set(player, session, new RecurseBrush(depthFirst))
.setSize(radius).setFill(fill).setMask(new IdMask(editSession));
}
@ -236,9 +236,9 @@ public class BrushCommands {
@Switch(name = 's', desc = "Selects the clicked point after drawing")
boolean select,
@Switch(name = 'f', desc = "Create a flat line")
boolean flat, InjectedValueAccess context) throws WorldEditException {
boolean flat) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
set(session, context, new LineBrush(shell, select, flat)).setSize(radius).setFill(fill);
set(player, session, new LineBrush(shell, select, flat)).setSize(radius).setFill(fill);
}
@Command(
@ -252,13 +252,14 @@ public class BrushCommands {
"Tutorial: https://www.planetminecraft.com/blog/fawe-tutorial/"
)
@CommandPermissions("worldedit.brush.spline")
public void splineBrush(Player player, EditSession editSession, LocalSession session, Pattern fill,
public void splineBrush(Player player, EditSession editSession, LocalSession session,
Pattern fill,
@Arg(desc = "The radius to sample for blending", def = "25")
Expression radius, InjectedValueAccess context) throws WorldEditException {
Expression radius) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
player.print(BBC.BRUSH_SPLINE.format(radius));
set(session, context,
new SplineBrush(player, session))
set(player, session,
new SplineBrush(player, session))
.setSize(radius)
.setFill(fill);
}
@ -272,9 +273,10 @@ public class BrushCommands {
"Set [copies] to a value > 0 if you want to have your selection pasted a limited amount of times equally spaced on the curve"
)
@CommandPermissions("worldedit.brush.sweep")
public void sweepBrush(Player player, LocalSession session, @Arg(name = "copies", desc = "int", def = "-1") int copies, InjectedValueAccess context) throws WorldEditException {
public void sweepBrush(Player player, LocalSession session,
@Arg(name = "copies", desc = "int", def = "-1") int copies) throws WorldEditException {
player.print(BBC.BRUSH_SPLINE.s());
set(session, context, new SweepBrush(copies));
set(player, session, new SweepBrush(copies));
}
@Command(
@ -283,7 +285,8 @@ public class BrushCommands {
desc = "Create a hanging line between two points"
)
@CommandPermissions("worldedit.brush.spline")
public void catenaryBrush(LocalSession session, Pattern fill, @Arg(def = "1.2", desc = "Length of wire compared to distance between points") @Range(min = 1) double lengthFactor,
public void catenaryBrush(Player player, LocalSession session, Pattern fill,
@Arg(def = "1.2", desc = "Length of wire compared to distance between points") @Range(min = 1) double lengthFactor,
@Arg(desc = "The radius to sample for blending", def = "0")
Expression radius,
@Switch(name = 'h', desc = "Create only a shell")
@ -291,12 +294,11 @@ public class BrushCommands {
@Switch(name = 's', desc = "Select the clicked point after drawing")
boolean select,
@Switch(name = 'd', desc = "sags the catenary toward the facing direction")
boolean facingDirection,
InjectedValueAccess context) throws WorldEditException {
boolean facingDirection) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
Brush brush = new CatenaryBrush(shell, select, facingDirection, lengthFactor);
set(session, context,
new CatenaryBrush(shell, select, facingDirection, lengthFactor))
set(player, session,
new CatenaryBrush(shell, select, facingDirection, lengthFactor))
.setSize(radius)
.setFill(fill);
}
@ -311,11 +313,14 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.surfacespline") // 0, 0, 0, 10, 0,
public void surfaceSpline(Player player, LocalSession session, Pattern fill,
@Arg(desc = "The radius to sample for blending", def = "0")
Expression radius, @Arg(name = "tension", desc = "double", def = "0") double tension, @Arg(name = "bias", desc = "double", def = "0") double bias, @Arg(name = "continuity", desc = "double", def = "0") double continuity, @Arg(name = "quality", desc = "double", def = "10") double quality, InjectedValueAccess context) throws WorldEditException {
Expression radius, @Arg(name = "tension", desc = "double", def = "0") double tension,
@Arg(name = "bias", desc = "double", def = "0") double bias,
@Arg(name = "continuity", desc = "double", def = "0") double continuity,
@Arg(name = "quality", desc = "double", def = "10") double quality) throws WorldEditException {
player.print(BBC.BRUSH_SPLINE.format(radius));
worldEdit.checkMaxBrushRadius(radius);
set(session, context,
new SurfaceSpline(tension, bias, continuity, quality))
set(player, session,
new SurfaceSpline(tension, bias, continuity, quality))
.setSize(radius)
.setFill(fill);
}
@ -326,11 +331,19 @@ public class BrushCommands {
desc = "Creates a distorted sphere"
)
@CommandPermissions("worldedit.brush.rock")
public void blobBrush(LocalSession session, Pattern fill, @Arg(name = "radius", desc = "Vector3", def = "10") Vector3 radius, @Arg(name = "sphericity", desc = "double", def = "100") double sphericity, @Arg(name = "frequency", desc = "double", def = "30") double frequency, @Arg(name = "amplitude", desc = "double", def = "50") double amplitude, InjectedValueAccess context) throws WorldEditException {
public void blobBrush(Player player, LocalSession session, Pattern fill,
@Arg(name = "radius", desc = "Vector3", def = "10")
Vector3 radius,
@Arg(name = "sphericity", desc = "double", def = "100")
double sphericity,
@Arg(name = "frequency", desc = "double", def = "30")
double frequency,
@Arg(name = "amplitude", desc = "double", def = "50")
double amplitude) throws WorldEditException {
double max = MathMan.max(radius.getX(), radius.getY(), radius.getZ());
worldEdit.checkMaxBrushRadius(max);
Brush brush = new BlobBrush(radius.divide(max), frequency / 100, amplitude / 100, sphericity / 100);
set(session, context, brush).setSize(max).setFill(fill);
set(player, session, brush).setSize(max).setFill(fill);
}
@Command(
@ -347,7 +360,7 @@ public class BrushCommands {
@Switch(name = 'h', desc = "Create hollow spheres instead")
boolean hollow,
@Switch(name = 'f', desc = "Create falling spheres instead")
boolean falling, InjectedValueAccess context) throws WorldEditException {
boolean falling) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
Brush brush;
if (hollow) {
@ -369,10 +382,7 @@ public class BrushCommands {
}
}
set(session, context,
brush)
.setSize(radius)
.setFill(pattern);
set(player, session, brush).setSize(radius).setFill(pattern);
}
@Command(
@ -383,13 +393,14 @@ public class BrushCommands {
"Pic: https://i.imgur.com/2xKsZf2.png"
)
@CommandPermissions("worldedit.brush.shatter")
public void shatterBrush(Player player, EditSession editSession, LocalSession session, Pattern fill,
public void shatterBrush(Player player, EditSession editSession, LocalSession session,
Pattern fill,
@Arg(desc = "The radius to sample for blending", def = "10")
Expression radius,
@Arg(desc = "Lines", def = "10") int count, InjectedValueAccess context) throws WorldEditException {
Expression radius,
@Arg(desc = "Lines", def = "10") int count) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
set(session, context,
new ShatterBrush(count))
set(player, session,
new ShatterBrush(count))
.setSize(radius)
.setFill(fill)
.setMask(new ExistingBlockMask(editSession));
@ -402,13 +413,12 @@ public class BrushCommands {
)
@CommandPermissions("worldedit.brush.stencil")
public void stencilBrush(Player player, LocalSession session, Pattern fill,
@Arg(name = "radius", desc = "Expression", def = "5") Expression radius,
@Arg(name = "image", desc = "String", def = "") String image,
@Arg(def = "0", desc = "rotation") @Range(min = 0, max = 360) int rotation,
@Arg(name = "yscale", desc = "double", def = "1") double yscale,
@Switch(name = 'w', desc = "Apply at maximum saturation") boolean onlyWhite,
@Switch(name = 'r', desc = "Apply random rotation") boolean randomRotate,
InjectedValueAccess context) throws WorldEditException, FileNotFoundException {
@Arg(name = "radius", desc = "Expression", def = "5") Expression radius,
@Arg(name = "image", desc = "String", def = "") String image,
@Arg(def = "0", desc = "rotation") @Range(min = 0, max = 360) int rotation,
@Arg(name = "yscale", desc = "double", def = "1") double yscale,
@Switch(name = 'w', desc = "Apply at maximum saturation") boolean onlyWhite,
@Switch(name = 'r', desc = "Apply random rotation") boolean randomRotate) throws WorldEditException, FileNotFoundException {
worldEdit.checkMaxBrushRadius(radius);
InputStream stream = getHeightmapStream(image);
HeightBrush brush;
@ -420,8 +430,8 @@ public class BrushCommands {
if (randomRotate) {
brush.setRandomRotate(true);
}
set(session, context,
brush)
set(player, session,
brush)
.setSize(radius)
.setFill(fill);
}
@ -432,12 +442,16 @@ public class BrushCommands {
desc = "Use a height map to paint a surface",
descFooter = "Use a height map to paint any surface.\n")
@CommandPermissions("worldedit.brush.stencil")
public void imageBrush(LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius,
ProvideBindings.ImageUri imageUri,
@Arg(def = "1", desc = "scale height") @Range(min = Double.MIN_NORMAL) double yscale,
@Switch(name = 'a', desc = "Use image Alpha") boolean alpha,
@Switch(name = 'f', desc = "Blend the image with existing terrain") boolean fadeOut,
InjectedValueAccess context) throws WorldEditException, IOException {
public void imageBrush(Player player, LocalSession session,
@Arg(name = "radius", desc = "Expression", def = "5")
Expression radius,
ProvideBindings.ImageUri imageUri,
@Arg(def = "1", desc = "scale height") @Range(min = Double.MIN_NORMAL)
double yscale,
@Switch(name = 'a', desc = "Use image Alpha")
boolean alpha,
@Switch(name = 'f', desc = "Blend the image with existing terrain")
boolean fadeOut) throws WorldEditException, IOException {
BufferedImage image = imageUri.load();
worldEdit.checkMaxBrushRadius(radius);
if (yscale != 1) {
@ -449,9 +463,7 @@ public class BrushCommands {
alpha = true;
}
ImageBrush brush = new ImageBrush(image, session, alpha);
set(session, context,
brush)
.setSize(radius);
set(player, session, brush).setSize(radius);
}
@Command(
@ -463,12 +475,11 @@ public class BrushCommands {
"The -r flag will apply random rotation"
)
@CommandPermissions("worldedit.brush.surface")
public void surfaceBrush(LocalSession session, Pattern fill,
public void surfaceBrush(Player player, LocalSession session, Pattern fill,
@Arg(name = "radius", desc = "Expression", def = "5")
Expression radius,
InjectedValueAccess context) throws WorldEditException {
Expression radius) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
set(session, context, new SurfaceSphereBrush()).setFill(fill).setSize(radius);
set(player, session, new SurfaceSphereBrush()).setFill(fill).setSize(radius);
}
@Command(
@ -478,7 +489,11 @@ public class BrushCommands {
"Video: https://youtu.be/RPZIaTbqoZw?t=34s"
)
@CommandPermissions("worldedit.brush.scatter")
public void scatterBrush(LocalSession session, Pattern fill, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "points", desc = "double", def = "5") double pointsOpt, @Arg(name = "distance", desc = "double", def = "1") double distanceOpt, @Switch(name = 'o', desc = "Overlay the block") boolean overlay, InjectedValueAccess context) throws WorldEditException {
public void scatterBrush(Player player, LocalSession session, Pattern fill,
@Arg(name = "radius", desc = "Expression", def = "5") Expression radius,
@Arg(name = "points", desc = "double", def = "5") double pointsOpt,
@Arg(name = "distance", desc = "double", def = "1") double distanceOpt,
@Switch(name = 'o', desc = "Overlay the block") boolean overlay) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
Brush brush;
if (overlay) {
@ -486,10 +501,7 @@ public class BrushCommands {
} else {
brush = new ScatterBrush((int) pointsOpt, (int) distanceOpt);
}
set(session, context,
brush)
.setSize(radius)
.setFill(fill);
set(player, session, brush).setSize(radius).setFill(fill);
}
@Command(
@ -498,7 +510,11 @@ public class BrushCommands {
desc = "Scatter a schematic on a surface"
)
@CommandPermissions("worldedit.brush.populateschematic")
public void scatterSchemBrush(Player player, LocalSession session, Mask mask, @Arg(name = "clipboard", desc = "Clipboard uri") String clipboardStr, @Arg(name = "radius", desc = "Expression", def = "30") Expression radius, @Arg(name = "density", desc = "double", def = "50") double density, @Switch(name = 'r', desc = "Apply random rotation") boolean rotate, InjectedValueAccess context) throws WorldEditException {
public void scatterSchemBrush(Player player, LocalSession session, Mask mask,
@Arg(name = "clipboard", desc = "Clipboard uri") String clipboardStr,
@Arg(name = "radius", desc = "Expression", def = "30") Expression radius,
@Arg(name = "density", desc = "double", def = "50") double density,
@Switch(name = 'r', desc = "Apply random rotation") boolean rotate) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
try {
MultiClipboardHolder clipboards = ClipboardFormats.loadAllFromInput(player, clipboardStr, null, true);
@ -512,8 +528,8 @@ public class BrushCommands {
return;
}
set(session, context,
new PopulateSchem(mask, holders, (int) density, rotate)).setSize(radius);
set(player, session,
new PopulateSchem(mask, holders, (int) density, rotate)).setSize(radius);
} catch (IOException e) {
throw new RuntimeException(e);
}
@ -527,9 +543,10 @@ public class BrushCommands {
"Pic: https://i.imgur.com/XV0vYoX.png"
)
@CommandPermissions("worldedit.brush.layer")
public void surfaceLayer(LocalSession session, @Arg(name = "radius", desc = "Expression") Expression radius, List<BlockState> blockLayers, InjectedValueAccess context) throws WorldEditException {
public void surfaceLayer(Player player, LocalSession session,
@Arg(name = "radius", desc = "Expression") Expression radius, List<BlockState> blockLayers) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
set(session, context, new LayerBrush(blockLayers.toArray(new BlockState[0]))).setSize(radius);
set(player, session, new LayerBrush(blockLayers.toArray(new BlockState[0]))).setSize(radius);
}
@Command(
@ -541,9 +558,13 @@ public class BrushCommands {
"Note: The seeds define how many splotches there are, recursion defines how large, solid defines whether the pattern is applied per seed, else per block."
)
@CommandPermissions("worldedit.brush.splatter")
public void splatterBrush(LocalSession session, Pattern fill, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "points", desc = "double", def = "1") double pointsOpt, @Arg(name = "recursion", desc = "double", def = "5") double recursion, @Arg(name = "solid", desc = "boolean", def = "true") boolean solid, InjectedValueAccess context) throws WorldEditException {
public void splatterBrush(Player player, LocalSession session, Pattern fill,
@Arg(name = "radius", desc = "Expression", def = "5") Expression radius,
@Arg(name = "points", desc = "double", def = "1") double pointsOpt,
@Arg(name = "recursion", desc = "double", def = "5") double recursion,
@Arg(name = "solid", desc = "boolean", def = "true") boolean solid) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
set(session, context, new SplatterBrush((int) pointsOpt, (int) recursion, solid)).setSize(radius).setFill(fill);
set(player, session, new SplatterBrush((int) pointsOpt, (int) recursion, solid)).setSize(radius).setFill(fill);
}
@Command(
@ -557,10 +578,12 @@ public class BrushCommands {
" - Placeholders: {x}, {y}, {z}, {world}, {size}"
)
@CommandPermissions("worldedit.brush.scattercommand")
public void scatterCommandBrush(Player player, EditSession editSession, LocalSession session, @Arg(name = "radius", desc = "Expression") Expression radius, double points, double distance, List<String> commandStr, InjectedValueAccess context) throws WorldEditException {
public void scatterCommandBrush(Player player, EditSession editSession, LocalSession session,
@Arg(name = "radius", desc = "Expression") Expression radius, double points,
double distance, List<String> commandStr) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
set(session, context,
new ScatterCommand((int) points, (int) distance, StringMan.join(commandStr, " ")))
set(player, session,
new ScatterCommand((int) points, (int) distance, StringMan.join(commandStr, " ")))
.setSize(radius);
}
@ -578,19 +601,17 @@ public class BrushCommands {
@Arg(desc = "The height of the cylinder", def = "1")
int height,
@Switch(name = 'h', desc = "Create hollow cylinders instead")
boolean hollow,
InjectedValueAccess context) throws WorldEditException {
boolean hollow) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(height);
BrushSettings settings;
if (hollow) {
settings = set(session, context, new HollowCylinderBrush(height));
settings = set(player, session, new HollowCylinderBrush(height));
} else {
settings = set(session, context, new CylinderBrush(height));
settings = set(player, session, new CylinderBrush(height));
}
settings.setSize(radius)
.setFill(pattern);
settings.setSize(radius).setFill(pattern);
}
@Command(
@ -603,20 +624,20 @@ public class BrushCommands {
)
@Deprecated
@CommandPermissions("worldedit.brush.clipboard")
public void clipboardBrush(Player player,LocalSession session,
@Switch(name = 'a', desc = "Don't paste air from the clipboard")
boolean ignoreAir,
@Switch(name = 'o', desc = "Paste starting at the target location, instead of centering on it")
boolean usingOrigin,
@Switch(name = 'e', desc = "Skip paste entities if available")
boolean skipEntities,
@Switch(name = 'b', desc = "Paste biomes if available")
boolean pasteBiomes,
@ArgFlag(name = 'm', desc = "Skip blocks matching this mask in the clipboard", def = "")
@ClipboardMask
Mask sourceMask,
InjectedValueAccess context) throws WorldEditException {
public void clipboardBrush(Player player, LocalSession session,
@Switch(name = 'a', desc = "Don't paste air from the clipboard")
boolean ignoreAir,
@Switch(name = 'o', desc = "Paste starting at the target location, instead of centering on it")
boolean usingOrigin,
@Switch(name = 'e', desc = "Skip paste entities if available")
boolean skipEntities,
@Switch(name = 'b', desc = "Paste biomes if available")
boolean pasteBiomes,
@ArgFlag(name = 'm', desc = "Skip blocks matching this mask in the clipboard", def = "")
@ClipboardMask
Mask sourceMask) throws WorldEditException {
ClipboardHolder holder = session.getClipboard();
Clipboard clipboard = holder.getClipboard();
ClipboardHolder newHolder = new ClipboardHolder(clipboard);
newHolder.setTransform(holder.getTransform());
@ -627,7 +648,8 @@ public class BrushCommands {
worldEdit.checkMaxBrushRadius(size.getBlockY() / 2D - 1);
worldEdit.checkMaxBrushRadius(size.getBlockZ() / 2D - 1);
set(session, context, new ClipboardBrush(newHolder, ignoreAir, usingOrigin, !skipEntities, pasteBiomes, sourceMask));
set(player, session,
new ClipboardBrush(newHolder, ignoreAir, usingOrigin, !skipEntities, pasteBiomes, sourceMask));
}
@Command(
@ -637,19 +659,19 @@ public class BrushCommands {
)
@CommandPermissions("worldedit.brush.smooth")
public void smoothBrush(Player player, LocalSession session, EditSession editSession,
@Arg(desc = "The radius to sample for softening", def = "2")
Expression radius,
@Arg(desc = "The number of iterations to perform", def = "4")
int iterations,
@Arg(desc = "The mask of blocks to use for the heightmap", def = "")
Mask maskOpt, InjectedValueAccess context) throws WorldEditException {
@Arg(desc = "The radius to sample for softening", def = "2")
Expression radius,
@Arg(desc = "The number of iterations to perform", def = "4")
int iterations,
@Arg(desc = "The mask of blocks to use for the heightmap", def = "")
Mask maskOpt) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
FaweLimit limit = Settings.IMP.getLimit(player);
iterations = Math.min(limit.MAX_ITERATIONS, iterations);
set(session, context,
new SmoothBrush(iterations, maskOpt))
set(player, session,
new SmoothBrush(iterations, maskOpt))
.setSize(radius);
}
@ -660,16 +682,14 @@ public class BrushCommands {
)
@CommandPermissions("worldedit.brush.ex")
public void extinguishBrush(Player player, LocalSession session, EditSession editSession,
@Arg(desc = "The radius to extinguish", def = "5")
Expression radius,
InjectedValueAccess context) throws WorldEditException {
@Arg(desc = "The radius to extinguish", def = "5")
Expression radius) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
Pattern fill = BlockTypes.AIR.getDefaultState();
set(session, context,
new SphereBrush())
set(player, session,
new SphereBrush())
.setSize(radius)
.setFill(fill)
.setFill(BlockTypes.AIR.getDefaultState())
.setMask(new SingleBlockTypeMask(editSession, BlockTypes.FIRE));
}
@ -681,15 +701,12 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.gravity")
public void gravityBrush(Player player, LocalSession session,
@Arg(desc = "The radius to apply gravity in", def = "5")
Expression radius,
Expression radius,
@Switch(name = 'h', desc = "Affect blocks starting at max Y, rather than the target location Y + radius")
boolean fromMaxY,
InjectedValueAccess context) throws WorldEditException {
boolean fromMaxY) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
set(session, context,
new GravityBrush(fromMaxY))
.setSize(radius);
set(player, session, new GravityBrush(fromMaxY)).setSize(radius);
}
@Command(
@ -705,7 +722,7 @@ public class BrushCommands {
)
@CommandPermissions("worldedit.brush.height")
public void heightBrush(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "image", desc = "String", def = "") String image, @Arg(def = "0", desc = "rotation") @Range(min = 0, max = 360) int rotation, @Arg(name = "yscale", desc = "double", def = "1") double yscale, @Switch(name = 'r', desc = "TODO") boolean randomRotate, @Switch(name = 'l', desc = "TODO") boolean layers, @Switch(name = 's', desc = "TODO") boolean dontSmooth, InjectedValueAccess context) throws WorldEditException, FileNotFoundException {
terrainBrush(player, session, radius, image, rotation, yscale, false, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CONE, context);
terrainBrush(player, session, radius, image, rotation, yscale, false, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CONE);
}
@Command(
@ -730,7 +747,7 @@ public class BrushCommands {
boolean layers,
@Switch(name = 's', desc = "Disables smoothing")
boolean dontSmooth, InjectedValueAccess context) throws WorldEditException, FileNotFoundException {
terrainBrush(player, session, radius, image, rotation, yscale, true, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CYLINDER, context);
terrainBrush(player, session, radius, image, rotation, yscale, true, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CYLINDER);
}
@Command(
@ -746,10 +763,13 @@ public class BrushCommands {
boolean layers,
@Switch(name = 's', desc = "Disables smoothing")
boolean dontSmooth, InjectedValueAccess context) throws WorldEditException, FileNotFoundException {
terrainBrush(player, session, radius, image, rotation, yscale, true, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CONE, context);
terrainBrush(player, session, radius, image, rotation, yscale, true, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CONE);
}
private void terrainBrush(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression") Expression radius, String image, int rotation, double yscale, boolean flat, boolean randomRotate, boolean layers, boolean smooth, Shape shape, InjectedValueAccess context) throws WorldEditException, FileNotFoundException {
private void terrainBrush(Player player, LocalSession session,
@Arg(name = "radius", desc = "Expression") Expression radius, String image, int rotation,
double yscale, boolean flat, boolean randomRotate, boolean layers, boolean smooth,
Shape shape) throws WorldEditException, FileNotFoundException {
worldEdit.checkMaxBrushRadius(radius);
InputStream stream = getHeightmapStream(image);
HeightBrush brush;
@ -769,7 +789,7 @@ public class BrushCommands {
if (randomRotate) {
brush.setRandomRotate(true);
}
set(session, context,
set(player, session,
brush)
.setSize(radius);
}
@ -794,12 +814,15 @@ public class BrushCommands {
"Video: https://www.youtube.com/watch?v=RPZIaTbqoZw"
)
@CommandPermissions("worldedit.brush.copy")
public void copy(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Switch(name = 'r', desc = "Apply random rotation on paste") boolean randomRotate, @Switch(name = 'a', desc = "Apply auto view based rotation on paste") boolean autoRotate, InjectedValueAccess context) throws WorldEditException {
public void copy(Player player, LocalSession session,
@Arg(name = "radius", desc = "Expression", def = "5") Expression radius,
@Switch(name = 'r', desc = "Apply random rotation on paste") boolean randomRotate,
@Switch(name = 'a', desc = "Apply auto view based rotation on paste") boolean autoRotate) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
player.print(BBC.BRUSH_COPY.format(radius));
set(session, context,
new CopyPastaBrush(player, session, randomRotate, autoRotate))
set(player, session,
new CopyPastaBrush(player, session, randomRotate, autoRotate))
.setSize(radius);
}
@ -812,11 +835,13 @@ public class BrushCommands {
" - Placeholders: {x}, {y}, {z}, {world}, {size}"
)
@CommandPermissions("worldedit.brush.command")
public void command(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression") Expression radius, @Arg(desc = "Command to run") List<String> input, InjectedValueAccess context) throws WorldEditException {
public void command(Player player, LocalSession session,
@Arg(name = "radius", desc = "Expression") Expression radius,
@Arg(desc = "Command to run") List<String> input) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
String cmd = StringMan.join(input, " ");
set(session, context,
new CommandBrush(cmd))
set(player, session,
new CommandBrush(cmd))
.setSize(radius);
}
@ -826,25 +851,25 @@ public class BrushCommands {
desc = "Butcher brush, kills mobs within a radius"
)
@CommandPermissions("worldedit.brush.butcher")
public void butcherBrush(Player player, LocalSession session, InjectedValueAccess context,
@Arg(desc = "Radius to kill mobs in", def = "5")
Expression radius,
@Switch(name = 'p', desc = "Also kill pets")
boolean killPets,
@Switch(name = 'n', desc = "Also kill NPCs")
boolean killNpcs,
@Switch(name = 'g', desc = "Also kill golems")
boolean killGolems,
@Switch(name = 'a', desc = "Also kill animals")
boolean killAnimals,
@Switch(name = 'b', desc = "Also kill ambient mobs")
boolean killAmbient,
@Switch(name = 't', desc = "Also kill mobs with name tags")
boolean killWithName,
@Switch(name = 'f', desc = "Also kill all friendly mobs (Applies the flags `-abgnpt`)")
boolean killFriendly,
@Switch(name = 'r', desc = "Also destroy armor stands")
boolean killArmorStands) throws WorldEditException {
public void butcherBrush(Player player, LocalSession session,
@Arg(desc = "Radius to kill mobs in", def = "5")
Expression radius,
@Switch(name = 'p', desc = "Also kill pets")
boolean killPets,
@Switch(name = 'n', desc = "Also kill NPCs")
boolean killNpcs,
@Switch(name = 'g', desc = "Also kill golems")
boolean killGolems,
@Switch(name = 'a', desc = "Also kill animals")
boolean killAnimals,
@Switch(name = 'b', desc = "Also kill ambient mobs")
boolean killAmbient,
@Switch(name = 't', desc = "Also kill mobs with name tags")
boolean killWithName,
@Switch(name = 'f', desc = "Also kill all friendly mobs (Applies the flags `-abgnpt`)")
boolean killFriendly,
@Switch(name = 'r', desc = "Also destroy armor stands")
boolean killArmorStands) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
CreatureButcher flags = new CreatureButcher(player);
@ -857,7 +882,7 @@ public class BrushCommands {
flags.or(CreatureButcher.Flags.TAGGED , killWithName, "worldedit.butcher.tagged");
flags.or(CreatureButcher.Flags.ARMOR_STAND , killArmorStands, "worldedit.butcher.armorstands");
set(session, context, new ButcherBrush(flags)).setSize(radius);
set(player, session, new ButcherBrush(flags)).setSize(radius);
}
public BrushSettings process(CommandLocals locals, BrushSettings settings) throws WorldEditException {
@ -873,11 +898,10 @@ public class BrushCommands {
return null;
}
public BrushSettings set(LocalSession session, InjectedValueAccess context, Brush brush) throws InvalidToolBindException {
Player plr = context.injectedValue(Key.of(Player.class))
.orElseThrow(() -> new IllegalStateException("No player"));
public BrushSettings set(Player player, LocalSession session,
Brush brush) throws InvalidToolBindException {
BrushSettings bs = new BrushSettings();
BrushTool tool = session.getBrushTool(plr, false);
BrushTool tool = session.getBrushTool(player, false);
if (tool != null) {
BrushSettings currentContext = tool.getContext();
if (currentContext != null) {
@ -896,14 +920,14 @@ public class BrushCommands {
)
@CommandPermissions("worldedit.brush.forest")
public void forest(Player player, LocalSession localSession,
@Arg(desc = "The shape of the region")
RegionFactory shape,
@Arg(desc = "The size of the brush", def = "5")
Expression radius,
@Arg(desc = "The density of the brush", def = "20")
double density,
@Arg(desc = "The type of tree to use")
TreeGenerator.TreeType type) throws WorldEditException, EvaluationException {
@Arg(desc = "The shape of the region")
RegionFactory shape,
@Arg(desc = "The size of the brush", def = "5")
Expression radius,
@Arg(desc = "The density of the brush", def = "20")
double density,
@Arg(desc = "The type of tree to use")
TreeGenerator.TreeType type) throws WorldEditException, EvaluationException {
setOperationBasedBrush(player, localSession, radius,
new Paint(new TreeGeneratorFactory(type), density / 100), shape, "worldedit.brush.forest");
}
@ -931,7 +955,7 @@ public class BrushCommands {
@Arg(desc = "The shape of the region")
RegionFactory shape,
@Arg(desc = "The size of the brush", def = "5")
Expression radius) throws WorldEditException, EvaluationException {
Expression radius) throws WorldEditException, EvaluationException {
setOperationBasedBrush(player, localSession, radius,
new Deform("y+=1"), shape, "worldedit.brush.lower");
}

View File

@ -47,6 +47,7 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World;
import java.io.File;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
import org.enginehub.piston.annotation.Command;
@ -93,45 +94,51 @@ public class HistoryCommands {
return;
}
File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY);
if (!folder.exists()) {
return;
}
for (File worldFolder : folder.listFiles()) {
if (!worldFolder.isDirectory()) {
continue;
}
String worldName = worldFolder.getName();
World world = FaweAPI.getWorld(worldName);
if (world != null) {
for (File userFolder : worldFolder.listFiles()) {
if (!userFolder.isDirectory()) {
continue;
}
String userUUID = userFolder.getName();
try {
UUID uuid = UUID.fromString(userUUID);
for (File historyFile : userFolder.listFiles()) {
String name = historyFile.getName();
if (!name.endsWith(".bd")) {
if (folder.exists()) {
for (File worldFolder : Objects.requireNonNull(folder.listFiles())) {
if (worldFolder != null && worldFolder.isDirectory()) {
String worldName = worldFolder.getName();
World world = FaweAPI.getWorld(worldName);
if (world != null) {
for (File userFolder : worldFolder.listFiles()) {
if (!userFolder.isDirectory()) {
continue;
}
RollbackOptimizedHistory rollback = new RollbackOptimizedHistory(world, uuid, Integer.parseInt(name.substring(0, name.length() - 3)));
DiskStorageHistory.DiskStorageSummary summary = rollback.summarize(RegionWrapper.GLOBAL(), false);
if (summary != null) {
rollback.setDimensions(BlockVector3.at(summary.minX, 0, summary.minZ), BlockVector3.at(summary.maxX, 255, summary.maxZ));
rollback.setTime(historyFile.lastModified());
RollbackDatabase db = DBHandler.IMP.getDatabase(world);
db.logEdit(rollback);
player.print("Logging: " + historyFile);
String userUUID = userFolder.getName();
try {
UUID uuid = UUID.fromString(userUUID);
for (File historyFile : userFolder.listFiles()) {
String name = historyFile.getName();
if (!name.endsWith(".bd")) {
continue;
}
RollbackOptimizedHistory rollback = new RollbackOptimizedHistory(
world, uuid,
Integer.parseInt(
name.substring(0, name.length() - 3)));
DiskStorageHistory.DiskStorageSummary summary = rollback
.summarize(RegionWrapper.GLOBAL(), false);
if (summary != null) {
rollback.setDimensions(
BlockVector3.at(summary.minX, 0, summary.minZ),
BlockVector3
.at(summary.maxX, 255, summary.maxZ));
rollback.setTime(historyFile.lastModified());
RollbackDatabase db = DBHandler.IMP
.getDatabase(world);
db.logEdit(rollback);
player.print("Logging: " + historyFile);
}
}
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
}
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
}
}
player.print("Done import!");
}
player.print("Done import!");
return;
}
String toParse = user.substring(1);

View File

@ -110,6 +110,9 @@ public class FactoryConverter<T> implements ArgumentConverter<T> {
parserContext.setWorld((World) extent);
}
parserContext.setExtent(new RequestExtent());
} else if (session.hasWorldOverride()) {
parserContext.setWorld(session.getWorldOverride());
parserContext.setExtent(new RequestExtent());
}
parserContext.setSession(session);
parserContext.setRestricted(true);

View File

@ -30,7 +30,7 @@ import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BaseBlock;
/**
* A mode that replaces one block.
@ -55,7 +55,7 @@ public class BlockReplacer implements DoubleActionBlockTool {
try (EditSession editSession = session.createEditSession(player)) {
try {
BlockVector3 position = clicked.toVector().toBlockPoint();
editSession.setBlock(position, pattern.apply(position));
editSession.setBlock(position, pattern);
} catch (MaxChangedBlocksException ignored) {
} finally {
session.remember(editSession);
@ -72,8 +72,7 @@ public class BlockReplacer implements DoubleActionBlockTool {
@Override
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
EditSession editSession = session.createEditSession(player);
BlockState targetBlock = editSession.getBlock(clicked.toVector().toBlockPoint());
BaseBlock targetBlock = player.getWorld().getFullBlock(clicked.toVector().toBlockPoint());
if (targetBlock != null) {
pattern = targetBlock;

View File

@ -91,7 +91,6 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
}
protected static int MAX_RANGE = 500;
protected static int DEFAULT_RANGE = 240;
protected int range = -1;
private VisualMode visualMode = VisualMode.NONE;
private TargetMode targetMode = TargetMode.TARGET_BLOCK_RANGE;
@ -178,7 +177,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
if (targetMode != TargetMode.TARGET_BLOCK_RANGE) {
map.put("target", targetMode);
}
if (range != -1 && range != DEFAULT_RANGE) {
if (range != -1 && range != MAX_RANGE) {
map.put("range", range);
}
if (targetOffset != 0) {
@ -312,7 +311,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
* @return the mask used to stop block traces
*/
public @Nullable Mask getTraceMask() {
return traceMask;
return this.traceMask;
}
/**
@ -409,7 +408,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
* @return the range of the brush in blocks
*/
public int getRange() {
return (range < 0) ? DEFAULT_RANGE : Math.min(range, MAX_RANGE);
return (range < 0) ? MAX_RANGE : Math.min(range, MAX_RANGE);
}
/**
@ -418,16 +417,12 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
* @param range the range of the brush in blocks
*/
public void setRange(int range) {
if (range == DEFAULT_RANGE) {
this.range = -1;
} else {
this.range = range;
}
this.range = range;
}
@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
return act(BrushAction.PRIMARY, server, config, player, session);
return act(BrushAction.PRIMARY, player, session);
}
public BlockVector3 getPosition(EditSession editSession, Player player) {
@ -481,7 +476,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
});
}
public boolean act(BrushAction action, Platform server, LocalConfiguration config, Player player, LocalSession session) {
public boolean act(BrushAction action, Player player, LocalSession session) {
switch (action) {
case PRIMARY:
setContext(primary);
@ -499,14 +494,14 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
return false;
}
try (EditSession editSession = session.createEditSession(player)) {
BlockVector3 target = getPosition(editSession, player);
Location target = player.getBlockTrace(getRange(), true, traceMask);
if (target == null) {
editSession.cancel();
BBC.NO_BLOCK.send(player);
player.print(BBC.NO_BLOCK.s());
return true;
}
BlockBag bag = editSession.getBlockBag();
BlockBag bag = session.getBlockBag(player);
Request.request().setEditSession(editSession);
Mask mask = current.getMask();
@ -536,7 +531,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
new PatternTraverser(current).reset(editSession);
double size = current.getSize();
WorldEdit.getInstance().checkMaxBrushRadius(size);
brush.build(editSession, target, current.getMaterial(), size);
brush.build(editSession, target.toBlockPoint(), current.getMaterial(), size);
} catch (MaxChangedBlocksException e) {
player.printError("Max blocks change limit reached.");
} finally {
@ -554,7 +549,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
@Override
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
return act(BrushAction.SECONDARY, server, config, player, session);
return act(BrushAction.SECONDARY, player, session);
}
@ -627,8 +622,8 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
return false;
}
public void queueVisualization(Player fp) {
Fawe.get().getVisualQueue().queue(fp);
public void queueVisualization(Player player) {
Fawe.get().getVisualQueue().queue(player);
}
@Deprecated

View File

@ -27,42 +27,42 @@ import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.util.Location;
public class NavigationWand implements DoubleActionTraceTool {
@Override
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
if (!player.hasPermission("worldedit.navigation.jumpto.tool")) {
return false;
}
final int maxDist = config.navigationWandMaxDistance;
if (maxDist <= 0) {
return false;
}
Location pos = player.getSolidBlockTrace(maxDist);
if (pos != null) {
player.findFreePosition(pos);
} else {
player.printError("No block in sight (or too far)!");
}
return true;
}
@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
if (!player.hasPermission("worldedit.navigation.thru.tool")) {
return false;
}
final int maxDist = config.navigationWandMaxDistance;
if (maxDist <= 0) {
return false;
@Override
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
if (!player.hasPermission("worldedit.navigation.jumpto.tool")) {
return false;
}
final int maxDist = config.navigationWandMaxDistance;
if (maxDist <= 0) {
return false;
}
Location pos = player.getSolidBlockTrace(maxDist);
if (pos != null) {
player.findFreePosition(pos);
} else {
player.printError("No block in sight (or too far)!");
}
return true;
}
if (!player.passThroughForwardWall(Math.max(1, maxDist - 10))) {
player.printError("Nothing to pass through (or too far)!");
}
return true;
}
@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
if (!player.hasPermission("worldedit.navigation.thru.tool")) {
return false;
}
final int maxDist = config.navigationWandMaxDistance;
if (maxDist <= 0) {
return false;
}
@Override
public boolean canUse(Actor actor) {
return true; // skip check here - checked separately for primary/secondary
}
if (!player.passThroughForwardWall(Math.max(1, maxDist - 10))) {
player.printError("Nothing to pass through (or too far)!");
}
return true;
}
@Override
public boolean canUse(Actor actor) {
return true; // skip check here - checked separately for primary/secondary
}
}

View File

@ -55,7 +55,7 @@ public class QueryTool implements BlockTool {
builder.append(TextComponent.of("@" + clicked.toVector().toBlockPoint() + ": ", TextColor.BLUE));
builder.append(TextComponent.of(block.getBlockType().getName(), TextColor.YELLOW));
builder.append(TextComponent.of(" (" + block + ") ", TextColor.GRAY)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Block state"))));
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Block state"))));
/*
final OptionalInt internalId = BlockStateIdAccess.getBlockStateId(block.toImmutableState());
if (internalId.isPresent()) {
@ -64,8 +64,8 @@ public class QueryTool implements BlockTool {
}
*/
builder.append(TextComponent.of(" (" + world.getBlockLightLevel(blockPoint) + "/"
+ world.getBlockLightLevel(blockPoint.add(0, 1, 0)) + ")", TextColor.WHITE)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Block Light/Light Above"))));
+ world.getBlockLightLevel(blockPoint.add(0, 1, 0)) + ")", TextColor.WHITE)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Block Light/Light Above"))));
player.print(builder.build());

View File

@ -20,11 +20,9 @@
package com.sk89q.worldedit.command.tool;
import com.boydti.fawe.object.mask.IdMask;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Platform;
@ -37,8 +35,6 @@ import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.Set;
/**
* A pickaxe mode that recursively finds adjacent blocks within range of
* an initial block and of the same type.

View File

@ -34,8 +34,8 @@ public class SelectionWand implements DoubleActionBlockTool {
@Override
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
RegionSelector selector = session.getRegionSelector(player.getWorld());
BlockVector3 blockPoint = clicked.toVector().toBlockPoint();
if (selector.selectPrimary(blockPoint, ActorSelectorLimits.forActor(player))) {
selector.explainPrimarySelection(player, session, blockPoint);
}
@ -46,6 +46,7 @@ public class SelectionWand implements DoubleActionBlockTool {
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
RegionSelector selector = session.getRegionSelector(player.getWorld());
BlockVector3 blockPoint = clicked.toVector().toBlockPoint();
if (selector.selectSecondary(blockPoint, ActorSelectorLimits.forActor(player))) {
selector.explainSecondarySelection(player, session, blockPoint);
}

View File

@ -64,10 +64,10 @@ public class TreePlanter implements BlockTool {
}
if (!successful) {
BBC.TOOL_TREE_ERROR_BLOCK.send(player);
player.printError(BBC.TOOL_TREE_ERROR_BLOCK.s());
}
} catch (MaxChangedBlocksException e) {
BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES.send(player);
player.printError(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES.s());
} finally {
session.remember(editSession);
}

View File

@ -21,7 +21,6 @@ package com.sk89q.worldedit.command.tool.brush;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.function.pattern.BlockPattern;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockTypes;

View File

@ -21,7 +21,6 @@ package com.sk89q.worldedit.command.tool.brush;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.function.pattern.BlockPattern;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockTypes;

View File

@ -19,6 +19,9 @@
package com.sk89q.worldedit.command.util;
import static org.enginehub.piston.converter.SuggestionHelper.byPrefix;
import static org.enginehub.piston.converter.SuggestionHelper.limitByPrefix;
import com.sk89q.worldedit.registry.Keyed;
import com.sk89q.worldedit.registry.NamespacedRegistry;
import com.sk89q.worldedit.registry.Registry;
@ -26,7 +29,6 @@ import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.world.block.BlockCategory;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
@ -37,9 +39,6 @@ import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.enginehub.piston.converter.SuggestionHelper.byPrefix;
import static org.enginehub.piston.converter.SuggestionHelper.limitByPrefix;
/**
* Internal class for generating common command suggestions.
*/
@ -140,12 +139,12 @@ public final class SuggestionHelper {
public static <V extends Keyed> Stream<String> getRegistrySuggestions(Registry<V> registry, String input) {
if (registry instanceof NamespacedRegistry) {
return getNamespacedRegistrySuggestions(((NamespacedRegistry<?>) registry), input);
return getNamespacedRegistrySuggestions(((NamespacedRegistry<V>) registry), input);
}
return limitByPrefix(registry.keySet().stream(), input).stream();
}
public static <V extends Keyed> Stream<String> getNamespacedRegistrySuggestions(NamespacedRegistry<?> registry, String input) {
public static <V extends Keyed> Stream<String> getNamespacedRegistrySuggestions(NamespacedRegistry<V> registry, String input) {
if (input.isEmpty() || input.equals(":")) {
final Set<String> namespaces = registry.getKnownNamespaces();
if (namespaces.size() == 1) {

View File

@ -60,7 +60,9 @@ import com.sk89q.worldedit.world.block.FuzzyBlockState;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@ -73,10 +75,10 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
super(worldEdit);
}
private static BlockState getBlockInHand(Actor actor, HandSide handSide) throws InputParseException {
private static BaseBlock getBlockInHand(Actor actor, HandSide handSide) throws InputParseException {
if (actor instanceof Player) {
try {
return ((Player) actor).getBlockInHand(handSide).toImmutableState();
return ((Player) actor).getBlockInHand(handSide);
} catch (NotABlockException e) {
throw new InputParseException("You're not holding a block!");
} catch (WorldEditException e) {
@ -111,6 +113,8 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
}
}
private static String[] EMPTY_STRING_ARRAY = {};
/**
* Backwards compatibility for wool colours in block syntax.
*
@ -163,7 +167,9 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
}
private BaseBlock parseLogic(String input, ParserContext context) throws InputParseException {
String[] blockAndExtraData = input.trim().split("\\|", 2);
BlockType blockType = null;
Map<Property<?>, Object> blockStates = new HashMap<>();
String[] blockAndExtraData = input.trim().split("\\|");
blockAndExtraData[0] = woolMapper(blockAndExtraData[0]);
BlockState state = null;
@ -171,8 +177,10 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
// Legacy matcher
if (context.isTryingLegacy()) {
try {
String[] split = blockAndExtraData[0].split(":");
if (split.length == 1) {
String[] split = blockAndExtraData[0].split(":", 2);
if (split.length == 0) {
throw new InputParseException("Invalid colon.");
} else if (split.length == 1) {
state = LegacyMapper.getInstance().getBlockFromLegacy(Integer.parseInt(split[0]));
} else if (MathMan.isInteger(split[0])) {
int id = Integer.parseInt(split[0]);
@ -191,7 +199,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
state = LegacyMapper.getInstance().getBlockFromLegacy(type.getLegacyCombinedId() >> 4, data);
}
}
} catch (NumberFormatException e) {
} catch (NumberFormatException ignored) {
}
}
@ -204,58 +212,83 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
typeString = blockAndExtraData[0];
} else {
typeString = blockAndExtraData[0].substring(0, stateStart);
if (stateStart + 1 >= blockAndExtraData[0].length()) {
throw new InputParseException("Invalid format. Hanging bracket @ " + stateStart + ".");
}
int stateEnd = blockAndExtraData[0].lastIndexOf(']');
if (stateEnd < 0) {
throw new InputParseException("Invalid format. Unclosed property.");
}
stateString = blockAndExtraData[0].substring(stateStart + 1, blockAndExtraData[0].length() - 1);
}
if (typeString.isEmpty()) {
throw new InputParseException("Invalid format");
}
// PosX
if (typeString.matches("pos[0-9]+")) {
String[] stateProperties = EMPTY_STRING_ARRAY;
if (stateString != null) {
stateProperties = stateString.split(",");
}
if ("hand".equalsIgnoreCase(typeString)) {
// Get the block type from the item in the user's hand.
final BaseBlock blockInHand = getBlockInHand(context.requireActor(), HandSide.MAIN_HAND);
if (blockInHand.getClass() != BaseBlock.class) {
return blockInHand;
}
blockType = blockInHand.getBlockType();
blockStates.putAll(blockInHand.getStates());
} else if ("offhand".equalsIgnoreCase(typeString)) {
// Get the block type from the item in the user's off hand.
final BaseBlock blockInHand = getBlockInHand(context.requireActor(), HandSide.OFF_HAND);
if (blockInHand.getClass() != BaseBlock.class) {
return blockInHand;
}
blockType = blockInHand.getBlockType();
blockStates.putAll(blockInHand.getStates());
} else if (typeString.matches("pos[0-9]+")) {
int index = Integer.parseInt(typeString.replaceAll("[a-z]+", ""));
// Get the block type from the "primary position"
final World world = context.requireWorld();
final BlockVector3 primaryPosition;
try {
primaryPosition = context.requireSession().getRegionSelector(world).getVertices().get(index - 1);
primaryPosition = context.requireSession().getRegionSelector(world).getPrimaryPosition();
} catch (IncompleteRegionException e) {
throw new InputParseException("Your selection is not complete.");
}
state = world.getBlock(primaryPosition);
final BlockState blockInHand = world.getBlock(primaryPosition);
blockType = blockInHand.getBlockType();
blockStates.putAll(blockInHand.getStates());
} else if (typeString.matches("slot[0-9]+")) {
int slot = Integer.parseInt(typeString.substring(4)) - 1;
Actor actor = context.requireActor();
if (!(actor instanceof Player)) {
throw new InputParseException("The user is not a player!");
}
Player player = (Player) actor;
BlockBag bag = player.getInventoryBlockBag();
if (true) {
throw new InputParseException("Unsupported!");
}
SlottableBlockBag slottable = (SlottableBlockBag) bag;
BaseItem item = slottable.getItem(slot);
if (!item.getType().hasBlockType()) {
throw new InputParseException("You're not holding a block!");
}
state = item.getType().getBlockType().getDefaultState();
nbt = item.getNbtData();
} else {
if ("hand".equalsIgnoreCase(typeString)) {
// Get the block type from the item in the user's hand.
state = getBlockInHand(context.requireActor(), HandSide.MAIN_HAND);
} else if ("offhand".equalsIgnoreCase(typeString)) {
// Get the block type from the item in the user's off hand.
state = getBlockInHand(context.requireActor(), HandSide.OFF_HAND);
} else if (typeString.matches("slot[0-9]+")) {
int slot = Integer.parseInt(typeString.substring(4)) - 1;
Actor actor = context.requireActor();
if (!(actor instanceof Player)) {
throw new InputParseException("The user is not a player!");
}
Player player = (Player) actor;
BlockBag bag = player.getInventoryBlockBag();
if (bag == null || !(bag instanceof SlottableBlockBag)) {
throw new InputParseException("Unsupported!");
}
SlottableBlockBag slottable = (SlottableBlockBag) bag;
BaseItem item = slottable.getItem(slot);
BlockType type = BlockTypes.parse(typeString.toLowerCase(Locale.ROOT));
if (!item.getType().hasBlockType()) {
throw new InputParseException("You're not holding a block!");
}
state = item.getType().getBlockType().getDefaultState();
nbt = item.getNbtData();
} else {
BlockType type = BlockTypes.parse(typeString.toLowerCase(Locale.ROOT));
if (type != null) {
state = type.getDefaultState();
}
if (state == null) {
throw new NoMatchException("Does not match a valid block type: '" + input + "'");
}
if (type != null) {
state = type.getDefaultState();
}
if (state == null) {
throw new NoMatchException(
"Does not match a valid block type: '" + input + "'");
}
}
if (nbt == null) nbt = state.getNbtData();

View File

@ -26,7 +26,6 @@ import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.mask.BlockCategoryMask;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.internal.registry.InputParser;
import com.sk89q.worldedit.session.request.RequestExtent;
import com.sk89q.worldedit.world.block.BlockCategory;
import java.util.Locale;

View File

@ -26,7 +26,6 @@ import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.mask.BlockMask;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.internal.registry.InputParser;
import com.sk89q.worldedit.session.request.RequestExtent;
import com.sk89q.worldedit.world.block.BaseBlock;
import java.util.Set;

View File

@ -24,8 +24,6 @@ import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.MutableBlockVector2;
import com.sk89q.worldedit.math.MutableBlockVector3;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockStateHolder;
@ -52,16 +50,12 @@ public interface OutputExtent {
* @param block block to set
* @return true if the block was successfully set (return value may not be accurate)
* @throws WorldEditException thrown on an error
* @deprecated Use {@link #setBlock(int, int, int, BlockStateHolder)}
* @deprecated It is recommended that you use {@link #setBlock(int, int, int, BlockStateHolder)} in FAWE
*/
@Deprecated
default <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 position, T block) throws WorldEditException {
return setBlock(position.getX(), position.getY(), position.getZ(), block);
}
<T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 position, T block) throws WorldEditException;
default <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
return setBlock(MutableBlockVector3.get(x, y, z), block);
}
<T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException;
boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException;
@ -72,13 +66,9 @@ public interface OutputExtent {
* @param biome the biome to set to
* @return true if the biome was successfully set (return value may not be accurate)
*/
default boolean setBiome(BlockVector2 position, BiomeType biome) {
return setBiome(position.getX(), 0, position.getBlockZ(), biome);
}
boolean setBiome(BlockVector2 position, BiomeType biome);
default boolean setBiome(int x, int y, int z, BiomeType biome) {
return setBiome(MutableBlockVector2.get(x, z), biome);
}
boolean setBiome(int x, int y, int z, BiomeType biome);
/**
* Return an {@link Operation} that should be called to tie up loose ends

View File

@ -175,6 +175,7 @@ public class PassthroughExtent extends AbstractDelegateExtent {
return getExtent().getBlockDistributionWithData(region);
}
@Override
@Nullable
public Operation commit() {
return getExtent().commit();
@ -271,6 +272,7 @@ public class PassthroughExtent extends AbstractDelegateExtent {
return getExtent().setBlock(position, block);
}
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
return getExtent().setBlock(x, y, z, block);
}
@ -285,6 +287,7 @@ public class PassthroughExtent extends AbstractDelegateExtent {
return getExtent().setBiome(position, biome);
}
@Override
public boolean setBiome(int x, int y, int z, BiomeType biome) {
return getExtent().setBiome(x, y, z, biome);
}

View File

@ -25,16 +25,20 @@ import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.Mask2D;
import com.sk89q.worldedit.function.mask.Masks;
import com.sk89q.worldedit.function.pattern.BiomePattern;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.AbstractRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionOperationException;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
@ -46,12 +50,16 @@ import java.util.Map;
* <p>This buffer will not attempt to return results from the buffer when
* accessor methods (such as {@link #getBlock(BlockVector3)}) are called.</p>
*/
public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pattern {
public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pattern, BiomePattern {
private final Map<BlockVector3, BaseBlock> buffer = new LinkedHashMap<>();
private final Map<BlockVector2, BiomeType> biomeBuffer = new LinkedHashMap<>();
private final Mask mask;
private final Mask2D biomeMask;
private BlockVector3 min = null;
private BlockVector2 min2d = null;
private BlockVector3 max = null;
private BlockVector2 max2d = null;
/**
* Create a new extent buffer that will buffer every change.
@ -79,6 +87,8 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
checkNotNull(delegate);
checkNotNull(mask);
this.mask = mask;
Mask2D bmask = mask.toMask2D();
this.biomeMask = bmask == null ? Masks.alwaysTrue2D() : bmask;
}
@Override
@ -105,6 +115,54 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
}
}
@Override
public boolean setBiome(BlockVector2 position, BiomeType biome) {
// Update minimum
if (min2d == null) {
min2d = position;
} else {
min2d = min2d.getMinimum(position);
}
// Update maximum
if (max2d == null) {
max2d = position;
} else {
max2d = max2d.getMaximum(position);
}
if (biomeMask.test(position)) {
biomeBuffer.put(position, biome);
return true;
} else {
return getExtent().setBiome(position, biome);
}
}
@Override
public boolean setBiome(int x, int y, int z, BiomeType biome) {
// Update minimum
if (min2d == null) {
min2d = BlockVector2.at(x, z);
} else {
min2d = min2d.getMinimum(BlockVector2.at(x,z));
}
// Update maximum
if (max2d == null) {
max2d = BlockVector2.at(x,z);
} else {
max2d = max2d.getMaximum(BlockVector2.at(x,z));
}
if (biomeMask.test(BlockVector2.at(x,z))) {
biomeBuffer.put(BlockVector2.at(x,z), biome);
return true;
} else {
return getExtent().setBiome(x, y, z, biome);
} }
@Override
public BaseBlock apply(BlockVector3 pos) {
BaseBlock block = buffer.get(pos);
@ -115,6 +173,16 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
}
}
@Override
public BiomeType apply(BlockVector2 pos) {
BiomeType biome = biomeBuffer.get(pos);
if (biome != null) {
return biome;
} else {
return BiomeTypes.OCEAN;
}
}
/**
* Return a region representation of this buffer.
*
@ -151,6 +219,10 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
public Iterator<BlockVector3> iterator() {
return buffer.keySet().iterator();
}
public Iterable<BlockVector2> asFlatRegion() {
return biomeBuffer.keySet();
}
};
}
}

View File

@ -216,6 +216,7 @@ public class BlockArrayClipboard implements Clipboard, Closeable {
return false;
}
@Override
public boolean setTile(int x, int y, int z, CompoundTag tag) {
x -= mx;
y -= my;

View File

@ -19,10 +19,27 @@
package com.sk89q.worldedit.extent.transform;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.util.Direction.ASCENDING_EAST;
import static com.sk89q.worldedit.util.Direction.ASCENDING_NORTH;
import static com.sk89q.worldedit.util.Direction.ASCENDING_SOUTH;
import static com.sk89q.worldedit.util.Direction.ASCENDING_WEST;
import static com.sk89q.worldedit.util.Direction.DOWN;
import static com.sk89q.worldedit.util.Direction.EAST;
import static com.sk89q.worldedit.util.Direction.Flag;
import static com.sk89q.worldedit.util.Direction.NORTH;
import static com.sk89q.worldedit.util.Direction.NORTHEAST;
import static com.sk89q.worldedit.util.Direction.NORTHWEST;
import static com.sk89q.worldedit.util.Direction.SOUTH;
import static com.sk89q.worldedit.util.Direction.SOUTHEAST;
import static com.sk89q.worldedit.util.Direction.SOUTHWEST;
import static com.sk89q.worldedit.util.Direction.UP;
import static com.sk89q.worldedit.util.Direction.WEST;
import static com.sk89q.worldedit.util.Direction.findClosest;
import static com.sk89q.worldedit.util.Direction.values;
import com.boydti.fawe.object.extent.ResettableExtent;
import com.boydti.fawe.util.ReflectionUtils;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.jnbt.ByteTag;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.Tag;
@ -38,21 +55,19 @@ import com.sk89q.worldedit.registry.state.DirectionalProperty;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.registry.state.PropertyKey;
import com.sk89q.worldedit.util.Direction;
import static com.sk89q.worldedit.util.Direction.*;
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 com.sk89q.worldedit.world.block.BlockTypes;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import javax.annotation.Nullable;
import org.jetbrains.annotations.NotNull;
/**
* Transforms blocks themselves (but not their position) according to a
@ -87,11 +102,8 @@ public class BlockTransformExtent extends ResettableExtent {
private static long combine(Direction... directions) {
long mask = 0;
for (Direction dir : directions) {
mask = mask | (1L << dir.ordinal());
}
return mask;
return Arrays.stream(directions).mapToLong(dir -> (1L << dir.ordinal()))
.reduce(0, (a, b) -> a | b);
}
private static long[] adapt(Direction... dirs) {
@ -497,7 +509,7 @@ public class BlockTransformExtent extends ResettableExtent {
}
@Override
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
return super.setBlock(x, y, z, transformInverse(block));
}
}

View File

@ -23,11 +23,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.math.BlockVector3;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
/**
* Executes several region functions in order.
@ -49,7 +47,7 @@ public class CombinedRegionFunction implements RegionFunction {
*/
public CombinedRegionFunction(Collection<RegionFunction> functions) {
checkNotNull(functions);
this.functions = functions.toArray(new RegionFunction[functions.size()]);
this.functions = functions.toArray(new RegionFunction[0]);
}
/**
@ -84,7 +82,7 @@ public class CombinedRegionFunction implements RegionFunction {
checkNotNull(functions);
ArrayList<RegionFunction> functionsList = new ArrayList<>(Arrays.asList(this.functions));
functionsList.addAll(functions);
this.functions = functionsList.toArray(new RegionFunction[functionsList.size()]);
this.functions = functionsList.toArray(new RegionFunction[0]);
}
/**
@ -105,4 +103,4 @@ public class CombinedRegionFunction implements RegionFunction {
return ret;
}
}
}

View File

@ -35,4 +35,5 @@ public interface RegionFunction {
* @throws WorldEditException thrown on an error
*/
boolean apply(BlockVector3 position) throws WorldEditException;
}

View File

@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.FlatRegionFunction;
import com.sk89q.worldedit.function.pattern.BiomePattern;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.world.biome.BiomeType;
@ -33,7 +34,7 @@ import com.sk89q.worldedit.world.biome.BiomeType;
public class BiomeReplace implements FlatRegionFunction {
private final Extent extent;
private BiomeType biome;
private BiomePattern biome;
/**
* Create a new instance.
@ -42,15 +43,25 @@ public class BiomeReplace implements FlatRegionFunction {
* @param biome a biome
*/
public BiomeReplace(Extent extent, BiomeType biome) {
this(extent, (BiomePattern) biome);
}
/**
* Create a new instance.
*
* @param extent the extent to apply this function to
* @param pattern the biome pattern to set
*/
public BiomeReplace(Extent extent, BiomePattern pattern) {
checkNotNull(extent);
checkNotNull(biome);
checkNotNull(pattern);
this.extent = extent;
this.biome = biome;
this.biome = pattern;
}
@Override
public boolean apply(BlockVector2 position) throws WorldEditException {
return extent.setBiome(position, biome);
return extent.setBiome(position, biome.apply(position));
}
}

View File

@ -50,7 +50,7 @@ public class BlockReplace implements RegionFunction {
@Override
public boolean apply(BlockVector3 position) throws WorldEditException {
return pattern.apply(extent, position, position);
return extent.setBlock(position, pattern.apply(position));
}
}

View File

@ -80,7 +80,14 @@ public class Naturalizer implements LayerFunction {
}
private boolean naturalize(BlockVector3 position, int depth) throws WorldEditException {
return editSession.setBlock(position, getTargetBlock(depth));
BlockState block = editSession.getBlock(position);
BlockState targetBlock = getTargetBlock(depth);
if (block.equalsFuzzy(targetBlock)) {
return false;
}
return editSession.setBlock(position, targetBlock);
}
@Override

View File

@ -157,10 +157,10 @@ public class ExtentEntityCopy implements EntityFunction {
BlockVector3 newLeash = transform.apply(tilePosition.subtract(from)).add(to).toBlockPoint();
return new BaseEntity(state.getType(), tag.createBuilder()
.put("Leash", leashCompound.createBuilder()
.putInt("X", newLeash.getBlockX())
.putInt("Y", newLeash.getBlockY())
.putInt("Z", newLeash.getBlockZ())
.build()
.putInt("X", newLeash.getBlockX())
.putInt("Y", newLeash.getBlockY())
.putInt("Z", newLeash.getBlockZ())
.build()
).build());
}
}

View File

@ -53,7 +53,7 @@ public class ForestGenerator implements RegionFunction {
BlockState block = editSession.getBlock(position);
BlockType t = block.getBlockType();
if (t == BlockTypes.GRASS_BLOCK || t == BlockTypes.DIRT) {
if (t == BlockTypes.GRASS_BLOCK || t == BlockTypes.DIRT || t == BlockTypes.PODZOL || t == BlockTypes.COARSE_DIRT) {
return treeType.generate(editSession, position.add(0, 1, 0));
} else if (t.getMaterial().isReplacedDuringPlacement()) {
// since the implementation's tree generators generally don't generate in non-air spots,

View File

@ -69,6 +69,7 @@ public class BlockMask extends ABlockMask {
@Deprecated
public BlockMask(Extent extent, Collection<BaseBlock> blocks) {
this(extent);
checkNotNull(blocks);
add(blocks);
}
@ -149,9 +150,8 @@ public class BlockMask extends ABlockMask {
*/
@Deprecated
public void add(Collection<BaseBlock> blocks) {
for (BaseBlock block : blocks) {
add(block.toBlockState());
}
checkNotNull(blocks);
blocks.forEach(baseBlock -> add(baseBlock.toBlockState()));
}
/**
@ -235,7 +235,7 @@ public class BlockMask extends ABlockMask {
setType = type;
setStates += all.size();
setState = type.getDefaultState();
} else if (hasAny) {
} else {
for (BlockState state : all) {
if (test(state)) {
setStates++;
@ -244,8 +244,6 @@ public class BlockMask extends ABlockMask {
unsetState = state;
}
}
} else {
unsetType = type;
}
}
}
@ -269,11 +267,7 @@ public class BlockMask extends ABlockMask {
}
if (setTypes == totalTypes - 1) {
if (unsetType != null) {
return new InverseSingleBlockTypeMask(getExtent(), unsetType);
} else {
throw new IllegalArgumentException("unsetType cannot be null when passed to InverseSingleBlockTypeMask");
}
throw new IllegalArgumentException("unsetType cannot be null when passed to InverseSingleBlockTypeMask");
}
return null;

View File

@ -55,4 +55,5 @@ public class BoundedHeightMask extends AbstractMask {
public Mask2D toMask2D() {
return null;
}
}

View File

@ -40,7 +40,7 @@ public class ExistingBlockMask extends AbstractExtentMask {
@Override
public boolean test(BlockVector3 vector) {
return !vector.getBlock(getExtent()).getMaterial().isAir();
return !getExtent().getBlock(vector).getBlockType().getMaterial().isAir();
}
@Nullable

View File

@ -38,17 +38,6 @@ public interface Mask {
*/
boolean test(BlockVector3 vector);
default Filter toFilter(Runnable run) {
return new Filter() {
@Override
public void applyBlock(FilterBlock block) {
if (test(block)) {
run.run();
}
}
};
}
default <T extends Filter> DelegateFilter<T> toFilter(T filter) {
return new DelegateFilter<T>(filter) {
@Override

View File

@ -37,7 +37,6 @@ import java.util.Set;
import java.util.function.Function;
import javax.annotation.Nullable;
/**
* Combines several masks and requires that all masks return true
* when a certain position is tested. It serves as a logical AND operation
@ -223,6 +222,10 @@ public class MaskIntersection extends AbstractMask {
@Override
public boolean test(BlockVector3 vector) {
if (masksArray.length == 0) {
return false;
}
for (Mask mask : masksArray) {
if (!mask.test(vector)) {
return false;

View File

@ -21,7 +21,6 @@ package com.sk89q.worldedit.function.mask;
import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.beta.FilterBlock;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
@ -32,8 +31,8 @@ import javax.annotation.Nullable;
*/
public final class Masks {
protected static final AlwaysTrue ALWAYS_TRUE = new AlwaysTrue();
protected static final AlwaysFalse ALWAYS_FALSE = new AlwaysFalse();
static final AlwaysTrue ALWAYS_TRUE = new AlwaysTrue();
static final AlwaysFalse ALWAYS_FALSE = new AlwaysFalse();
private Masks() {
}

View File

@ -21,7 +21,6 @@ package com.sk89q.worldedit.function.mask;
import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.beta.FilterBlock;
import com.sk89q.worldedit.math.BlockVector3;
import javax.annotation.Nullable;

View File

@ -70,4 +70,5 @@ public class RegionMask extends AbstractMask {
public Mask2D toMask2D() {
return null;
}
}

View File

@ -66,16 +66,15 @@ public class ChangeSetExecutor implements Operation {
@Override
public Operation resume(RunContext run) throws WorldEditException {
Change change = iterator.next();
if (type == Type.UNDO) {
while (iterator.hasNext()) {
while (iterator.hasNext()) {
Change change = iterator.next();
if (type == Type.UNDO) {
change.undo(context);
}
} else {
while (iterator.hasNext()) {
} else {
change.redo(context);
}
}
return null;
}

View File

@ -0,0 +1,37 @@
/*
* 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.function.pattern;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.world.biome.BiomeType;
/**
* Returns a {@link BiomeType} for a given position.
*/
public interface BiomePattern {
/**
* Return a {@link BiomeType} for the given position.
*
* @param position the position
* @return a block
*/
BiomeType apply(BlockVector2 position);
}

View File

@ -67,4 +67,5 @@ public class BlockPattern extends AbstractPattern {
public BaseBlock apply(BlockVector3 position) {
return block;
}
}

View File

@ -21,6 +21,7 @@ package com.sk89q.worldedit.function.pattern;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.registry.state.PropertyKey;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
@ -64,9 +65,10 @@ public class WaterloggedRemover extends AbstractExtentPattern {
@Override
public BaseBlock apply(BlockVector3 position) {
BaseBlock block = getExtent().getFullBlock(position);
BlockState newState = remap[block.getOrdinal()];
if (newState != null) {
return newState.toBaseBlock(block.getNbtData());
@SuppressWarnings("unchecked")
Property<Object> prop = (Property<Object>) remap[block.getOrdinal()].getBlockType().getPropertyMap().getOrDefault("waterlogged", null);
if (prop != null) {
return block.with(prop, false);
}
return BlockTypes.AIR.getDefaultState().toBaseBlock();
}

View File

@ -78,9 +78,9 @@ public abstract class BreadthFirstSearch implements Operation {
}
private final RegionFunction function;
private BlockVectorSet queue = new BlockVectorSet();
private BlockVectorSet visited = new BlockVectorSet();
private BlockVector3[] directions;
private BlockVectorSet visited;
private BlockVectorSet queue;
private int affected = 0;
private int currentDepth = 0;
private final int maxDepth;
@ -98,8 +98,6 @@ public abstract class BreadthFirstSearch implements Operation {
public BreadthFirstSearch(RegionFunction function, int maxDepth) {
checkNotNull(function);
this.queue = new BlockVectorSet();
this.visited = new BlockVectorSet();
this.function = function;
this.directions = DEFAULT_DIRECTIONS;
this.maxDepth = maxDepth;
@ -121,6 +119,8 @@ public abstract class BreadthFirstSearch implements Operation {
* unit vectors. An example of a valid direction is
* {@code BlockVector3.at(1, 0, 1)}.</p>
*
* <p>The list of directions can be cleared.</p>
*
* @return the list of directions
*/
public Collection<BlockVector3> getDirections() {
@ -260,6 +260,7 @@ public abstract class BreadthFirstSearch implements Operation {
tmp.clear();
tempQueue = tmp;
}
return null;
}

View File

@ -70,6 +70,7 @@ public class FlatRegionVisitor implements Operation {
affected++;
}
}
return null;
}

View File

@ -20,14 +20,12 @@
package com.sk89q.worldedit.function.visitor;
import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.RunContext;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import java.util.List;
/**
@ -42,17 +40,12 @@ public class RegionVisitor implements Operation {
public int affected = 0;
public final Iterable<? extends BlockVector3> iterable;
/**
* Deprecated in favor of the other constructors which will preload chunks during iteration
*
* @param region
* @param function
*/
@Deprecated
public RegionVisitor(Region region, RegionFunction function) {
this((Iterable<BlockVector3>) region, function);
}
@Deprecated
public RegionVisitor(Iterable<BlockVector3> iterable, RegionFunction function) {
this.region = iterable instanceof Region ? (Region) iterable : null;
this.function = function;
@ -75,6 +68,7 @@ public class RegionVisitor implements Operation {
affected++;
}
}
return null;
}

View File

@ -46,7 +46,7 @@ public class CommandRegistrationHandler {
.listeners(callListeners);
if (registration instanceof CommandPermissionsConditionGenerator.Registration) {
((CommandPermissionsConditionGenerator.Registration) registration).commandPermissionsConditionGenerator(
PERM_GEN
PERM_GEN
);
}
if (registration instanceof CommandQueuedConditionGenerator.Registration) {

View File

@ -85,6 +85,7 @@ public class WorldEditExceptionConverter extends ExceptionConverterHelper {
public void convert(MissingWorldException e) throws CommandException {
throw newCommandException("You need to provide a world (Try //world)", e);
}
@ExceptionMatch
public void convert(UnknownItemException e) throws CommandException {
throw newCommandException("Block name '" + e.getID() + "' was not recognized.", e);

View File

@ -86,7 +86,6 @@ public class Expression {
.build());
private final Map<String, RValue> variables = new HashMap<>();
private final String[] variableNames;
private Variable[] variableArray;
private RValue root;
private final Functions functions = new Functions();
@ -97,7 +96,6 @@ public class Expression {
}
public Expression(double constant) {
variableNames = null;
root = new Constant(0, constant);
}
@ -106,7 +104,6 @@ public class Expression {
}
private Expression(List<Token> tokens, String... variableNames) throws ExpressionException {
this.variableNames = variableNames;
variables.put("e", new Constant(-1, Math.E));
variables.put("pi", new Constant(-1, Math.PI));
@ -115,12 +112,11 @@ public class Expression {
variableArray = new Variable[variableNames.length];
for (int i = 0; i < variableNames.length; i++) {
String variableName = variableNames[i];
if (variables.containsKey(variableName)) {
throw new ExpressionException(-1, "Tried to overwrite identifier '" + variableName + "'");
if (variables.containsKey(variableNames[i])) {
throw new ExpressionException(-1, "Tried to overwrite identifier '" + variableNames[i] + "'");
}
Variable var = new Variable(0);
variables.put(variableName, var);
variables.put(variableNames[i], var);
variableArray[i] = var;
}
@ -139,14 +135,7 @@ public class Expression {
return evaluateTimeout(WorldEdit.getInstance().getConfiguration().calculationTimeout, values);
}
public double evaluateTimeout(int timeout, double x, double y) throws EvaluationException {
if (root instanceof Constant) return root.getValue();
variableArray[0].value = x;
variableArray[1].value = y;
return evaluateFinal(timeout);
}
public double evaluateTimeout(int timeout, double x, double y, double z) throws EvaluationException {
private double evaluateTimeout(int timeout, double x, double y, double z) throws EvaluationException {
if (root instanceof Constant) return root.getValue();
variableArray[0].value = x;
variableArray[1].value = y;
@ -156,8 +145,8 @@ public class Expression {
public double evaluateTimeout(int timeout, double... values) throws EvaluationException {
if (root instanceof Constant) return root.getValue();
for (int i = 0; i < values.length; i++) {
Variable var = variableArray[i];
for (int i = 0; i < values.length; ++i) {
final Variable var = variableArray[i];
var.value = values[i];
}
return evaluateFinal(timeout);
@ -167,7 +156,7 @@ public class Expression {
if (root instanceof Constant) {
return root.getValue();
}
for (int i = 0; i < values.length; i++) {
for (int i = 0; i < values.length; ++i) {
Variable var = variableArray[i];
var.value = values[i];
}

View File

@ -38,4 +38,4 @@ public class ReturnException extends EvaluationException {
return value;
}
}
}

View File

@ -19,6 +19,8 @@
package com.sk89q.worldedit.internal.util;
import static com.google.common.base.Preconditions.checkArgument;
import java.util.Objects;
/**
@ -31,7 +33,7 @@ public final class Substring {
* a Substring.
*/
public static Substring from(String original, int start) {
return wrap(original.substring(start), start, original.length());
return new Substring(original.substring(start), start, original.length());
}
/**
@ -39,13 +41,15 @@ public final class Substring {
* a Substring.
*/
public static Substring from(String original, int start, int end) {
return wrap(original.substring(start, end), start, end);
return new Substring(original.substring(start, end), start, end);
}
/**
* Wrap the given parameters into a Substring instance.
*/
public static Substring wrap(String substring, int start, int end) {
checkArgument(0 <= start, "Start must be greater than or equal to zero");
checkArgument(start <= end, "End must be greater than or equal to start");
return new Substring(substring, start, end);
}

View File

@ -98,7 +98,6 @@ public abstract class BlockVector3 {
// thread-safe initialization idiom
private static final class YzxOrderComparator {
private static final Comparator<BlockVector3> YZX_ORDER =
Comparator.comparingInt(BlockVector3::getY)
.thenComparingInt(BlockVector3::getZ)
@ -151,38 +150,6 @@ public abstract class BlockVector3 {
return BlockVector3.at(getX(), getY(), getZ());
}
// /**
// * Get the BlockVector3 to the north<br>
// * Normal use you would use north(this),
// * To avoid constructing a new Vector, pass e.g. north(some MutableBlockVector3)
// * There is no gaurantee it will use this provided vector
// * @param orDefault the vector to use as the result<br>
// * @return BlockVector3
// */
// public BlockVector3 north(BlockVector3 orDefault) {
// return orDefault.setComponents(getX(), getY(), getZ() - 1);
// }
//
// public BlockVector3 east(BlockVector3 orDefault) {
// return orDefault.setComponents(getX() + 1, getY(), getZ());
// }
//
// public BlockVector3 south(BlockVector3 orDefault) {
// return orDefault.setComponents(getX(), getY(), getZ() + 1);
// }
//
// public BlockVector3 west(BlockVector3 orDefault) {
// return orDefault.setComponents(getX() - 1, getY(), getZ());
// }
//
// public BlockVector3 up(BlockVector3 orDefault) {
// return orDefault.setComponents(getX(), getY() + 1, getZ());
// }
//
// public BlockVector3 down(BlockVector3 orDefault) {
// return orDefault.setComponents(getX(), getY() - 1, getZ());
// }
public long toLongPackedForm() {
checkLongPackable(this);
return (getX() & BITS_26) | ((getZ() & BITS_26) << 26) | (((getY() & (long) BITS_12) << (26 + 26)));
@ -289,7 +256,8 @@ public abstract class BlockVector3 {
}
/**
* Add a list of vectors to this vector and return the result as a new vector.
* Add a list of vectors to this vector and return the
* result as a new vector.
*
* @param others an array of vectors
* @return a new vector
@ -307,7 +275,8 @@ public abstract class BlockVector3 {
}
/**
* Subtract another vector from this vector and return the result as a new vector.
* Subtract another vector from this vector and return the result
* as a new vector.
*
* @param other the other vector
* @return a new vector
@ -317,7 +286,8 @@ public abstract class BlockVector3 {
}
/**
* Subtract another vector from this vector and return the result as a new vector.
* Subtract another vector from this vector and return the result
* as a new vector.
*
* @param x the value to subtract
* @param y the value to subtract
@ -329,7 +299,8 @@ public abstract class BlockVector3 {
}
/**
* Subtract a list of vectors from this vector and return the result as a new vector.
* Subtract a list of vectors from this vector and return the result
* as a new vector.
*
* @param others an array of vectors
* @return a new vector
@ -514,7 +485,8 @@ public abstract class BlockVector3 {
}
/**
* Get the normalized vector, which is the vector divided by its length, as a new vector.
* Get the normalized vector, which is the vector divided by its
* length, as a new vector.
*
* @return a new vector
*/
@ -613,7 +585,8 @@ public abstract class BlockVector3 {
}
/**
* Returns a vector with the absolute values of the components of this vector.
* Returns a vector with the absolute values of the components of
* this vector.
*
* @return a new vector
*/
@ -624,16 +597,15 @@ public abstract class BlockVector3 {
/**
* Perform a 2D transformation on this vector and return a new one.
*
* @param angle in degrees
* @param aboutX about which x coordinate to rotate
* @param aboutZ about which z coordinate to rotate
* @param angle in degrees
* @param aboutX about which x coordinate to rotate
* @param aboutZ about which z coordinate to rotate
* @param translateX what to add after rotation
* @param translateZ what to add after rotation
* @return a new vector
* @see AffineTransform another method to transform vectors
*/
public BlockVector3 transform2D(double angle, double aboutX, double aboutZ, double translateX,
double translateZ) {
public BlockVector3 transform2D(double angle, double aboutX, double aboutZ, double translateX, double translateZ) {
angle = Math.toRadians(angle);
double x = this.getX() - aboutX;
double z = this.getZ() - aboutZ;
@ -691,9 +663,9 @@ public abstract class BlockVector3 {
*/
public BlockVector3 getMinimum(BlockVector3 v2) {
return new BlockVector3Imp(
Math.min(getX(), v2.getX()),
Math.min(getY(), v2.getY()),
Math.min(getZ(), v2.getZ())
Math.min(getX(), v2.getX()),
Math.min(getY(), v2.getY()),
Math.min(getZ(), v2.getZ())
);
}
@ -705,9 +677,9 @@ public abstract class BlockVector3 {
*/
public BlockVector3 getMaximum(BlockVector3 v2) {
return new BlockVector3Imp(
Math.max(getX(), v2.getX()),
Math.max(getY(), v2.getY()),
Math.max(getZ(), v2.getZ())
Math.max(getX(), v2.getX()),
Math.max(getY(), v2.getY()),
Math.max(getZ(), v2.getZ())
);
}
@ -788,7 +760,8 @@ public abstract class BlockVector3 {
return false;
}
return equals((BlockVector3) obj);
BlockVector3 other = (BlockVector3) obj;
return other.getX() == this.getX() && other.getY() == this.getY() && other.getZ() == this.getZ();
}
public final boolean equals(BlockVector3 other) {

View File

@ -31,8 +31,8 @@ import java.util.List;
/**
* A Kochanek-Bartels interpolation; continuous in the 2nd derivative.
*
* <p>Supports Node#tension tension, Node#bias bias and
* Node#continuity continuity parameters per {@link Node}.</p>
* <p>Supports {@link Node#tension tension}, {@link Node#bias bias} and
* {@link Node#continuity continuity} parameters per {@link Node}.</p>
*/
public class KochanekBartelsInterpolation implements Interpolation {

View File

@ -120,6 +120,7 @@ public abstract class AbstractRegion extends AbstractSet<BlockVector3> implement
(max.getY() - min.getY() + 1) *
(max.getZ() - min.getZ() + 1);
}
/**
* Get X-size.
*

View File

@ -412,6 +412,11 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
return x >= this.minX && x <= this.maxX && z >= this.minZ && z <= this.maxZ;
}
@Override
public boolean contains(BlockVector3 position) {
return contains(position.getX(), position.getY(), position.getZ());
}
@Override
public Iterator<BlockVector3> iterator() {
if (Settings.IMP.HISTORY.COMPRESSION_LEVEL >= 9 || useOldIterator) {

View File

@ -35,7 +35,6 @@ import com.sk89q.worldedit.math.geom.Polygons;
import com.sk89q.worldedit.regions.iterator.FlatRegion3DIterator;
import com.sk89q.worldedit.regions.iterator.FlatRegionIterator;
import com.sk89q.worldedit.world.World;
import java.util.Iterator;
import java.util.List;
@ -327,6 +326,11 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
return dx * dx + dz * dz <= 1;
}
@Override
public boolean contains(BlockVector3 position) {
return contains(position.getX(), position.getY(), position.getZ());
}
/**
* Sets the height of the cylinder to fit the specified Y.
*
@ -411,7 +415,8 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
}
@Override
public void filter(final IChunk chunk, final Filter filter, final ChunkFilterBlock block, final IChunkGet get, final IChunkSet set) {
public void filter(final IChunk chunk, final Filter filter, final ChunkFilterBlock block,
final IChunkGet get, final IChunkSet set) {
int bcx = chunk.getX() >> 4;
int bcz = chunk.getZ() >> 4;
int tcx = bcx + 15;

View File

@ -104,7 +104,7 @@ public class EllipsoidRegion extends AbstractRegion {
@Override
public int getHeight() {
return Math.max((int) (2 * radius.getY()), 256);
return (int) (2 * radius.getY());
}
@Override
@ -246,6 +246,11 @@ public class EllipsoidRegion extends AbstractRegion {
return cxd + cyd + czd <= 1;
}
@Override
public boolean contains(BlockVector3 position) {
return position.subtract(center).toVector3().divide(radius).lengthSq() <= 1;
}
@Override
public boolean contains(int x, int z) {
int cx = x - center.getBlockX();

Some files were not shown because too many files have changed in this diff Show More