mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 03:56:41 +00:00
commanding-pipeline diff
This commit is contained in:
@ -69,6 +69,7 @@ import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.command.argument.Arguments;
|
||||
import com.sk89q.worldedit.command.factory.TreeGeneratorFactory;
|
||||
import com.sk89q.worldedit.command.tool.BrushTool;
|
||||
import com.sk89q.worldedit.command.tool.InvalidToolBindException;
|
||||
@ -132,6 +133,7 @@ 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.
|
||||
@ -159,11 +161,11 @@ public class BrushCommands {
|
||||
"Pic: https://i.imgur.com/cNUQUkj.png -> https://i.imgur.com/hFOFsNf.png"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.blendball")
|
||||
public void blendBallBrush(Player player, LocalSession session,
|
||||
public void blendBallBrush(InjectedValueAccess context,
|
||||
@Arg(desc = "The radius to sample for blending", def = "5")
|
||||
Expression radius) throws WorldEditException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
set(player, session, new BlendBall()).setSize(radius);
|
||||
set(context, new BlendBall()).setSize(radius);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -171,11 +173,16 @@ public class BrushCommands {
|
||||
desc = "Erodes terrain"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.erode")
|
||||
public void erodeBrush(Player player, LocalSession session,
|
||||
public void erodeBrush(InjectedValueAccess context,
|
||||
@Arg(desc = "The radius for eroding", def = "5")
|
||||
Expression radius) throws WorldEditException {
|
||||
Expression radius,
|
||||
@Arg(desc = "erodeFaces", def = "6") int erodefaces,
|
||||
@Arg(desc = "erodeRec", def = "0") int erodeRec,
|
||||
@Arg(desc = "fillFaces", def = "1") int fillFaces,
|
||||
@Arg(desc = "fillRec", def = "1") int fillRec
|
||||
) throws WorldEditException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
set(player, session, new ErodeBrush()).setSize(radius);
|
||||
set(context, new ErodeBrush(erodefaces, erodeRec, fillFaces, fillRec)).setSize(radius);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -183,11 +190,16 @@ public class BrushCommands {
|
||||
desc = "Pull terrain towards you"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.pull")
|
||||
public void pullBrush(Player player, LocalSession session,
|
||||
public void pullBrush(InjectedValueAccess context,
|
||||
@Arg(desc = "The radius to sample for blending", def = "5")
|
||||
Expression radius) throws WorldEditException {
|
||||
Expression radius,
|
||||
@Arg(desc = "erodeFaces", def = "2") int erodefaces,
|
||||
@Arg(desc = "erodeRec", def = "1") int erodeRec,
|
||||
@Arg(desc = "fillFaces", def = "5") int fillFaces,
|
||||
@Arg(desc = "fillRec", def = "1") int fillRec
|
||||
) throws WorldEditException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
set(player, session, new RaiseBrush()).setSize(radius);
|
||||
set(context, new RaiseBrush(erodefaces, erodeRec, fillFaces, fillRec)).setSize(radius);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -195,12 +207,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,
|
||||
public void circleBrush(Player player, InjectedValueAccess context,
|
||||
Pattern fill,
|
||||
@Arg(desc = "The radius to sample for blending", def = "5")
|
||||
Expression radius) throws WorldEditException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
set(player, session, new CircleBrush(player)).setSize(radius).setFill(fill);
|
||||
set(context, new CircleBrush(player)).setSize(radius).setFill(fill);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -211,14 +223,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,
|
||||
public void recursiveBrush(InjectedValueAccess context, 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) throws WorldEditException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
set(player, session, new RecurseBrush(depthFirst))
|
||||
set(context, new RecurseBrush(depthFirst))
|
||||
.setSize(radius).setFill(fill).setMask(new IdMask(editSession));
|
||||
}
|
||||
|
||||
@ -228,7 +240,7 @@ public class BrushCommands {
|
||||
desc = "Create lines"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.line")
|
||||
public void lineBrush(Player player, LocalSession session, Pattern fill,
|
||||
public void lineBrush(InjectedValueAccess context, Pattern fill,
|
||||
@Arg(desc = "The radius to sample for blending", def = "0")
|
||||
Expression radius,
|
||||
@Switch(name = 'h', desc = "Create only a shell")
|
||||
@ -238,7 +250,7 @@ public class BrushCommands {
|
||||
@Switch(name = 'f', desc = "Create a flat line")
|
||||
boolean flat) throws WorldEditException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
set(player, session, new LineBrush(shell, select, flat)).setSize(radius).setFill(fill);
|
||||
set(context, new LineBrush(shell, select, flat)).setSize(radius).setFill(fill);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -252,14 +264,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,
|
||||
public void splineBrush(Player player, InjectedValueAccess context,
|
||||
Pattern fill,
|
||||
@Arg(desc = "The radius to sample for blending", def = "25")
|
||||
Expression radius) throws WorldEditException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
player.print(BBC.BRUSH_SPLINE.format(radius));
|
||||
set(player, session,
|
||||
new SplineBrush(player, session))
|
||||
set(context,
|
||||
new SplineBrush(player))
|
||||
.setSize(radius)
|
||||
.setFill(fill);
|
||||
}
|
||||
@ -273,10 +285,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,
|
||||
public void sweepBrush(Player player, InjectedValueAccess context,
|
||||
@Arg(name = "copies", desc = "int", def = "-1") int copies) throws WorldEditException {
|
||||
player.print(BBC.BRUSH_SPLINE.s());
|
||||
set(player, session, new SweepBrush(copies));
|
||||
set(context, new SweepBrush(copies));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -285,7 +297,7 @@ public class BrushCommands {
|
||||
desc = "Create a hanging line between two points"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.spline")
|
||||
public void catenaryBrush(Player player, LocalSession session, Pattern fill,
|
||||
public void catenaryBrush(InjectedValueAccess context, 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,
|
||||
@ -297,7 +309,7 @@ public class BrushCommands {
|
||||
boolean facingDirection) throws WorldEditException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
Brush brush = new CatenaryBrush(shell, select, facingDirection, lengthFactor);
|
||||
set(player, session,
|
||||
set(context,
|
||||
new CatenaryBrush(shell, select, facingDirection, lengthFactor))
|
||||
.setSize(radius)
|
||||
.setFill(fill);
|
||||
@ -311,7 +323,7 @@ public class BrushCommands {
|
||||
"Video: https://www.youtube.com/watch?v=zSN-2jJxXlM"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.surfacespline") // 0, 0, 0, 10, 0,
|
||||
public void surfaceSpline(Player player, LocalSession session, Pattern fill,
|
||||
public void surfaceSpline(Player player, InjectedValueAccess context, 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,
|
||||
@ -319,7 +331,7 @@ public class BrushCommands {
|
||||
@Arg(name = "quality", desc = "double", def = "10") double quality) throws WorldEditException {
|
||||
player.print(BBC.BRUSH_SPLINE.format(radius));
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
set(player, session,
|
||||
set(context,
|
||||
new SurfaceSpline(tension, bias, continuity, quality))
|
||||
.setSize(radius)
|
||||
.setFill(fill);
|
||||
@ -331,7 +343,7 @@ public class BrushCommands {
|
||||
desc = "Creates a distorted sphere"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.rock")
|
||||
public void blobBrush(Player player, LocalSession session, Pattern fill,
|
||||
public void blobBrush(InjectedValueAccess context, Pattern fill,
|
||||
@Arg(name = "radius", desc = "Vector3", def = "10")
|
||||
Vector3 radius,
|
||||
@Arg(name = "sphericity", desc = "double", def = "100")
|
||||
@ -343,7 +355,7 @@ public class BrushCommands {
|
||||
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(player, session, brush).setSize(max).setFill(fill);
|
||||
set(context, brush).setSize(max).setFill(fill);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -352,7 +364,7 @@ public class BrushCommands {
|
||||
desc = "Choose the sphere brush"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.sphere")
|
||||
public void sphereBrush(Player player, LocalSession session,
|
||||
public void sphereBrush(Player player, InjectedValueAccess context,
|
||||
@Arg(desc = "The pattern of blocks to set")
|
||||
Pattern pattern,
|
||||
@Arg(desc = "The radius of the sphere", def = "2")
|
||||
@ -382,7 +394,7 @@ public class BrushCommands {
|
||||
}
|
||||
|
||||
}
|
||||
set(player, session, brush).setSize(radius).setFill(pattern);
|
||||
set(context, brush).setSize(radius).setFill(pattern);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -393,13 +405,13 @@ public class BrushCommands {
|
||||
"Pic: https://i.imgur.com/2xKsZf2.png"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.shatter")
|
||||
public void shatterBrush(Player player, EditSession editSession, LocalSession session,
|
||||
public void shatterBrush(EditSession editSession, InjectedValueAccess context,
|
||||
Pattern fill,
|
||||
@Arg(desc = "The radius to sample for blending", def = "10")
|
||||
Expression radius,
|
||||
@Arg(desc = "Lines", def = "10") int count) throws WorldEditException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
set(player, session,
|
||||
set(context,
|
||||
new ShatterBrush(count))
|
||||
.setSize(radius)
|
||||
.setFill(fill)
|
||||
@ -412,7 +424,7 @@ public class BrushCommands {
|
||||
descFooter = "Use a height map to paint any surface.\n"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.stencil")
|
||||
public void stencilBrush(Player player, LocalSession session, Pattern fill,
|
||||
public void stencilBrush(LocalSession session, InjectedValueAccess context, 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,
|
||||
@ -430,7 +442,7 @@ public class BrushCommands {
|
||||
if (randomRotate) {
|
||||
brush.setRandomRotate(true);
|
||||
}
|
||||
set(player, session,
|
||||
set(context,
|
||||
brush)
|
||||
.setSize(radius)
|
||||
.setFill(fill);
|
||||
@ -442,7 +454,7 @@ 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(Player player, LocalSession session,
|
||||
public void imageBrush(LocalSession session, InjectedValueAccess context,
|
||||
@Arg(name = "radius", desc = "Expression", def = "5")
|
||||
Expression radius,
|
||||
ProvideBindings.ImageUri imageUri,
|
||||
@ -463,7 +475,7 @@ public class BrushCommands {
|
||||
alpha = true;
|
||||
}
|
||||
ImageBrush brush = new ImageBrush(image, session, alpha);
|
||||
set(player, session, brush).setSize(radius);
|
||||
set(context, brush).setSize(radius);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -475,11 +487,11 @@ public class BrushCommands {
|
||||
"The -r flag will apply random rotation"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.surface")
|
||||
public void surfaceBrush(Player player, LocalSession session, Pattern fill,
|
||||
public void surfaceBrush(InjectedValueAccess context, Pattern fill,
|
||||
@Arg(name = "radius", desc = "Expression", def = "5")
|
||||
Expression radius) throws WorldEditException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
set(player, session, new SurfaceSphereBrush()).setFill(fill).setSize(radius);
|
||||
set(context, new SurfaceSphereBrush()).setFill(fill).setSize(radius);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -489,7 +501,7 @@ public class BrushCommands {
|
||||
"Video: https://youtu.be/RPZIaTbqoZw?t=34s"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.scatter")
|
||||
public void scatterBrush(Player player, LocalSession session, Pattern fill,
|
||||
public void scatterBrush(InjectedValueAccess context, 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,
|
||||
@ -501,7 +513,7 @@ public class BrushCommands {
|
||||
} else {
|
||||
brush = new ScatterBrush((int) pointsOpt, (int) distanceOpt);
|
||||
}
|
||||
set(player, session, brush).setSize(radius).setFill(fill);
|
||||
set(context, brush).setSize(radius).setFill(fill);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -510,7 +522,7 @@ public class BrushCommands {
|
||||
desc = "Scatter a schematic on a surface"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.populateschematic")
|
||||
public void scatterSchemBrush(Player player, LocalSession session, Mask mask,
|
||||
public void scatterSchemBrush(Player player, InjectedValueAccess context, 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,
|
||||
@ -528,7 +540,7 @@ public class BrushCommands {
|
||||
return;
|
||||
}
|
||||
|
||||
set(player, session,
|
||||
set(context,
|
||||
new PopulateSchem(mask, holders, (int) density, rotate)).setSize(radius);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
@ -543,10 +555,10 @@ public class BrushCommands {
|
||||
"Pic: https://i.imgur.com/XV0vYoX.png"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.layer")
|
||||
public void surfaceLayer(Player player, LocalSession session,
|
||||
public void surfaceLayer(InjectedValueAccess context,
|
||||
@Arg(name = "radius", desc = "Expression") Expression radius, List<BlockState> blockLayers) throws WorldEditException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
set(player, session, new LayerBrush(blockLayers.toArray(new BlockState[0]))).setSize(radius);
|
||||
set(context, new LayerBrush(blockLayers.toArray(new BlockState[0]))).setSize(radius);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -558,13 +570,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(Player player, LocalSession session, Pattern fill,
|
||||
public void splatterBrush(InjectedValueAccess context, 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(player, session, new SplatterBrush((int) pointsOpt, (int) recursion, solid)).setSize(radius).setFill(fill);
|
||||
set(context, new SplatterBrush((int) pointsOpt, (int) recursion, solid)).setSize(radius).setFill(fill);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -578,11 +590,11 @@ public class BrushCommands {
|
||||
" - Placeholders: {x}, {y}, {z}, {world}, {size}"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.scattercommand")
|
||||
public void scatterCommandBrush(Player player, EditSession editSession, LocalSession session,
|
||||
public void scatterCommandBrush(Player player, InjectedValueAccess context,
|
||||
@Arg(name = "radius", desc = "Expression") Expression radius, double points,
|
||||
double distance, List<String> commandStr) throws WorldEditException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
set(player, session,
|
||||
set(context,
|
||||
new ScatterCommand((int) points, (int) distance, StringMan.join(commandStr, " ")))
|
||||
.setSize(radius);
|
||||
}
|
||||
@ -593,7 +605,7 @@ public class BrushCommands {
|
||||
desc = "Choose the cylinder brush"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.cylinder")
|
||||
public void cylinderBrush(Player player, LocalSession session,
|
||||
public void cylinderBrush(InjectedValueAccess context,
|
||||
@Arg(desc = "The pattern of blocks to set")
|
||||
Pattern pattern,
|
||||
@Arg(desc = "The radius of the cylinder", def = "2")
|
||||
@ -607,9 +619,9 @@ public class BrushCommands {
|
||||
|
||||
BrushSettings settings;
|
||||
if (hollow) {
|
||||
settings = set(player, session, new HollowCylinderBrush(height));
|
||||
settings = set(context, new HollowCylinderBrush(height));
|
||||
} else {
|
||||
settings = set(player, session, new CylinderBrush(height));
|
||||
settings = set(context, new CylinderBrush(height));
|
||||
}
|
||||
settings.setSize(radius).setFill(pattern);
|
||||
}
|
||||
@ -624,7 +636,7 @@ public class BrushCommands {
|
||||
)
|
||||
@Deprecated
|
||||
@CommandPermissions("worldedit.brush.clipboard")
|
||||
public void clipboardBrush(Player player, LocalSession session,
|
||||
public void clipboardBrush(LocalSession session, InjectedValueAccess context,
|
||||
@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")
|
||||
@ -648,7 +660,7 @@ public class BrushCommands {
|
||||
worldEdit.checkMaxBrushRadius(size.getBlockY() / 2D - 1);
|
||||
worldEdit.checkMaxBrushRadius(size.getBlockZ() / 2D - 1);
|
||||
|
||||
set(player, session,
|
||||
set(context,
|
||||
new ClipboardBrush(newHolder, ignoreAir, usingOrigin, !skipEntities, pasteBiomes, sourceMask));
|
||||
}
|
||||
|
||||
@ -658,7 +670,7 @@ public class BrushCommands {
|
||||
descFooter = "Example: '/brush smooth 2 4 grass_block,dirt,stone'"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.smooth")
|
||||
public void smoothBrush(Player player, LocalSession session, EditSession editSession,
|
||||
public void smoothBrush(Player player, InjectedValueAccess context, EditSession editSession,
|
||||
@Arg(desc = "The radius to sample for softening", def = "2")
|
||||
Expression radius,
|
||||
@Arg(desc = "The number of iterations to perform", def = "4")
|
||||
@ -670,7 +682,7 @@ public class BrushCommands {
|
||||
FaweLimit limit = Settings.IMP.getLimit(player);
|
||||
iterations = Math.min(limit.MAX_ITERATIONS, iterations);
|
||||
|
||||
set(player, session,
|
||||
set(context,
|
||||
new SmoothBrush(iterations, maskOpt))
|
||||
.setSize(radius);
|
||||
}
|
||||
@ -681,12 +693,12 @@ public class BrushCommands {
|
||||
desc = "Shortcut fire extinguisher brush"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.ex")
|
||||
public void extinguishBrush(Player player, LocalSession session, EditSession editSession,
|
||||
public void extinguishBrush(InjectedValueAccess context, EditSession editSession,
|
||||
@Arg(desc = "The radius to extinguish", def = "5")
|
||||
Expression radius) throws WorldEditException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
|
||||
set(player, session,
|
||||
set(context,
|
||||
new SphereBrush())
|
||||
.setSize(radius)
|
||||
.setFill(BlockTypes.AIR.getDefaultState())
|
||||
@ -699,14 +711,14 @@ public class BrushCommands {
|
||||
desc = "Gravity brush, simulates the effect of gravity"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.gravity")
|
||||
public void gravityBrush(Player player, LocalSession session,
|
||||
public void gravityBrush(InjectedValueAccess context,
|
||||
@Arg(desc = "The radius to apply gravity in", def = "5")
|
||||
Expression radius,
|
||||
@Switch(name = 'h', desc = "Affect blocks starting at max Y, rather than the target location Y + radius")
|
||||
boolean fromMaxY) throws WorldEditException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
|
||||
set(player, session, new GravityBrush(fromMaxY)).setSize(radius);
|
||||
set(context, new GravityBrush(fromMaxY)).setSize(radius);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -721,8 +733,8 @@ public class BrushCommands {
|
||||
"Snow Pic: https://i.imgur.com/Hrzn0I4.png"
|
||||
)
|
||||
@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);
|
||||
public void heightBrush(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(session, radius, image, rotation, yscale, false, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CONE, context);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -732,8 +744,8 @@ public class BrushCommands {
|
||||
descFooter = "This brush flattens terrain and creates cliffs."
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.height")
|
||||
public void cliffBrush(Player player, LocalSession session,
|
||||
@Arg(name = "radius", desc = "Expression", def = "5")
|
||||
public void cliffBrush(LocalSession session,
|
||||
@Arg(name = "radius", desc = "Expression", def = "5")
|
||||
Expression radius,
|
||||
@Arg(name = "image", desc = "String", def = "")
|
||||
String image,
|
||||
@ -747,7 +759,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);
|
||||
terrainBrush(session, radius, image, rotation, yscale, true, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CYLINDER, context);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -756,20 +768,20 @@ public class BrushCommands {
|
||||
desc = "This brush raises or lowers land towards the clicked point"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.height")
|
||||
public void flattenBrush(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") @Step(90) @Range(min = 0, max = 360) int rotation, @Arg(name = "yscale", desc = "double", def = "1") double yscale,
|
||||
public void flattenBrush(LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "image", desc = "String", def = "") String image, @Arg(def = "0", desc = "rotation") @Step(90) @Range(min = 0, max = 360) int rotation, @Arg(name = "yscale", desc = "double", def = "1") double yscale,
|
||||
@Switch(name = 'r', desc = "Enables random off-axis rotation")
|
||||
boolean randomRotate,
|
||||
@Switch(name = 'l', desc = "Will work on snow layers")
|
||||
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);
|
||||
terrainBrush(session, radius, image, rotation, yscale, true, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CONE, context);
|
||||
}
|
||||
|
||||
private void terrainBrush(Player player, LocalSession session,
|
||||
private void terrainBrush(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 {
|
||||
Shape shape, InjectedValueAccess context) throws WorldEditException, FileNotFoundException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
InputStream stream = getHeightmapStream(image);
|
||||
HeightBrush brush;
|
||||
@ -789,7 +801,7 @@ public class BrushCommands {
|
||||
if (randomRotate) {
|
||||
brush.setRandomRotate(true);
|
||||
}
|
||||
set(player, session,
|
||||
set(context,
|
||||
brush)
|
||||
.setSize(radius);
|
||||
}
|
||||
@ -814,14 +826,14 @@ public class BrushCommands {
|
||||
"Video: https://www.youtube.com/watch?v=RPZIaTbqoZw"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.copy")
|
||||
public void copy(Player player, LocalSession session,
|
||||
public void copy(Player player, LocalSession session, InjectedValueAccess context,
|
||||
@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(player, session,
|
||||
set(context,
|
||||
new CopyPastaBrush(player, session, randomRotate, autoRotate))
|
||||
.setSize(radius);
|
||||
}
|
||||
@ -835,12 +847,12 @@ public class BrushCommands {
|
||||
" - Placeholders: {x}, {y}, {z}, {world}, {size}"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.command")
|
||||
public void command(Player player, LocalSession session,
|
||||
public void command(InjectedValueAccess context,
|
||||
@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(player, session,
|
||||
set(context,
|
||||
new CommandBrush(cmd))
|
||||
.setSize(radius);
|
||||
}
|
||||
@ -851,7 +863,7 @@ public class BrushCommands {
|
||||
desc = "Butcher brush, kills mobs within a radius"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.butcher")
|
||||
public void butcherBrush(Player player, LocalSession session,
|
||||
public void butcherBrush(Player player,
|
||||
@Arg(desc = "Radius to kill mobs in", def = "5")
|
||||
Expression radius,
|
||||
@Switch(name = 'p', desc = "Also kill pets")
|
||||
@ -869,7 +881,8 @@ public class BrushCommands {
|
||||
@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 {
|
||||
boolean killArmorStands,
|
||||
InjectedValueAccess context) throws WorldEditException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
|
||||
CreatureButcher flags = new CreatureButcher(player);
|
||||
@ -882,24 +895,25 @@ public class BrushCommands {
|
||||
flags.or(CreatureButcher.Flags.TAGGED , killWithName, "worldedit.butcher.tagged");
|
||||
flags.or(CreatureButcher.Flags.ARMOR_STAND , killArmorStands, "worldedit.butcher.armorstands");
|
||||
|
||||
set(player, session, new ButcherBrush(flags)).setSize(radius);
|
||||
set(context, new ButcherBrush(flags)).setSize(radius);
|
||||
}
|
||||
|
||||
public BrushSettings process(CommandLocals locals, BrushSettings settings) throws WorldEditException {
|
||||
Actor actor = locals.get(Actor.class);
|
||||
LocalSession session = worldEdit.getSessionManager().get(actor);
|
||||
session.setTool((Player) actor, null);
|
||||
BrushTool tool = session.getBrushTool((Player) actor);
|
||||
public BrushSettings process(Player player, Arguments arguments, BrushSettings settings) throws WorldEditException {
|
||||
LocalSession session = worldEdit.getSessionManager().get(player);
|
||||
session.setTool(player, null);
|
||||
BrushTool tool = session.getBrushTool(player);
|
||||
if (tool != null) {
|
||||
tool.setPrimary(settings);
|
||||
tool.setSecondary(settings);
|
||||
BBC.BRUSH_EQUIPPED.send(actor, ((String) locals.get("arguments")).split(" ")[1]);
|
||||
|
||||
BBC.BRUSH_EQUIPPED.send(player, arguments.get().split(" ")[1]);
|
||||
}
|
||||
return null;
|
||||
return settings;
|
||||
}
|
||||
|
||||
public BrushSettings set(Player player, LocalSession session,
|
||||
Brush brush) throws InvalidToolBindException {
|
||||
public BrushSettings set(InjectedValueAccess context, Brush brush) throws InvalidToolBindException {
|
||||
Player player = context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"));
|
||||
LocalSession session = player.getSession();
|
||||
BrushSettings bs = new BrushSettings();
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool != null) {
|
||||
@ -911,7 +925,17 @@ public class BrushCommands {
|
||||
}
|
||||
}
|
||||
}
|
||||
return bs;
|
||||
Arguments arguments = context.injectedValue(Key.of(Arguments.class)).orElse(null);
|
||||
if (arguments != null) {
|
||||
String args = arguments.get();
|
||||
bs.addSetting(BrushSettings.SettingType.BRUSH, args.substring(args.indexOf(' ') + 1));
|
||||
}
|
||||
CommandPermissions perms = context.injectedValue(Key.of(CommandPermissions.class)).orElse(null);
|
||||
if (perms != null) {
|
||||
bs.addPermissions(perms.value());
|
||||
}
|
||||
bs.setBrush(brush);
|
||||
return process(player, arguments, bs);
|
||||
}
|
||||
|
||||
@Command(
|
||||
|
@ -171,27 +171,16 @@ public class ChunkCommands {
|
||||
.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, "/stop"))));
|
||||
}
|
||||
|
||||
private static class ChunkListPaginationBox extends PaginationBox {
|
||||
private static class ChunkListPaginationBox extends PaginationBox.ListPaginationBox {
|
||||
//private final Region region;
|
||||
private final List<BlockVector2> chunks;
|
||||
|
||||
ChunkListPaginationBox(Region region) {
|
||||
super("Selected Chunks", "/listchunks -p %page%");
|
||||
// TODO make efficient/streamable/calculable implementations of this
|
||||
// for most region types, so we can just store the region and random-access get one page of chunks
|
||||
// (this is non-trivial for some types of selections...)
|
||||
//this.region = region.clone();
|
||||
this.chunks = new ArrayList<>(region.getChunks());
|
||||
super("Selected Chunks", "/listchunks -p %page%", region.getChunks());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getComponent(int number) {
|
||||
return TextComponent.of(chunks.get(number).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComponentsSize() {
|
||||
return chunks.size();
|
||||
return create(number);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -116,6 +116,7 @@ public class ClipboardCommands {
|
||||
|
||||
@Command(
|
||||
name = "/copy",
|
||||
aliases = "/cp",
|
||||
desc = "Copy the selection to the clipboard"
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.copy")
|
||||
@ -365,13 +366,7 @@ public class ClipboardCommands {
|
||||
ClipboardWriter writer = format.getWriter(baos);
|
||||
writer.write(target);
|
||||
baos.flush();
|
||||
String json = ImgurUtility
|
||||
.getImgurContent(ImgurUtility.CLIENT_ID, baos.toByteArray());
|
||||
Gson gson = new Gson();
|
||||
JsonObject obj = gson.fromJson(json, JsonObject.class);
|
||||
JsonObject data = obj.get("data").getAsJsonObject();
|
||||
String link = data.get("link").getAsString();
|
||||
url = new URL(link);
|
||||
url = ImgurUtility.uploadImage(baos.toByteArray());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
url = null;
|
||||
@ -434,6 +429,7 @@ public class ClipboardCommands {
|
||||
|
||||
@Command(
|
||||
name = "/paste",
|
||||
aliases = { "/p", "/pa" },
|
||||
desc = "Paste the clipboard's contents"
|
||||
|
||||
)
|
||||
|
@ -92,7 +92,7 @@ public class GenerationCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.caves")
|
||||
@Logging(PLACEMENT)
|
||||
public void caves(Player fp, LocalSession session, EditSession editSession, @Selection Region region,
|
||||
public void caves(Actor actor, LocalSession session, EditSession editSession, @Selection Region region,
|
||||
@Arg(name = "size", desc = "TODO", def = "8") int sizeOpt,
|
||||
@Arg(name = "frequency", desc = "TODO", def = "40") int frequencyOpt,
|
||||
@Arg(name = "rarity", desc = "TODO", def = "7") int rarityOpt,
|
||||
@ -103,10 +103,10 @@ public class GenerationCommands {
|
||||
@Arg(name = "pocketChance", desc = "TODO", def = "0") int pocketChanceOpt,
|
||||
@Arg(name = "pocketMin", desc = "TODO", def = "0") int pocketMinOpt,
|
||||
@Arg(name = "pocketMax", desc = "TODO", def = "3") int pocketMaxOpt, InjectedValueAccess context) throws WorldEditException {
|
||||
fp.checkConfirmationRegion(() -> {
|
||||
actor.checkConfirmationRegion(() -> {
|
||||
CavesGen gen = new CavesGen(sizeOpt, frequencyOpt, rarityOpt, minYOpt, maxYOpt, systemFrequencyOpt, individualRarityOpt, pocketChanceOpt, pocketMinOpt, pocketMaxOpt);
|
||||
editSession.generate(region, gen);
|
||||
BBC.VISITOR_BLOCK.send(fp, editSession.getBlockChangeCount());
|
||||
BBC.VISITOR_BLOCK.send(actor, editSession.getBlockChangeCount());
|
||||
}, "/caves", region, context);
|
||||
}
|
||||
|
||||
@ -117,10 +117,10 @@ public class GenerationCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.ore")
|
||||
@Logging(PLACEMENT)
|
||||
public void ores(Player fp, LocalSession session, EditSession editSession, @Selection Region region, Mask mask, InjectedValueAccess context) throws WorldEditException {
|
||||
fp.checkConfirmationRegion(() -> {
|
||||
public void ores(Actor actor, LocalSession session, EditSession editSession, @Selection Region region, Mask mask, InjectedValueAccess context) throws WorldEditException {
|
||||
actor.checkConfirmationRegion(() -> {
|
||||
editSession.addOres(region, mask);
|
||||
BBC.VISITOR_BLOCK.send(fp, editSession.getBlockChangeCount());
|
||||
BBC.VISITOR_BLOCK.send(actor, editSession.getBlockChangeCount());
|
||||
}, "/ores", region, context);
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ public class GenerationCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.image")
|
||||
@Logging(PLACEMENT)
|
||||
public void image(Player player, LocalSession session, EditSession editSession, String argStr, @Arg(name = "randomize", desc = "boolean", def = "true") boolean randomize,
|
||||
public void image(Actor actor, LocalSession session, EditSession editSession, String argStr, @Arg(name = "randomize", desc = "boolean", def = "true") boolean randomize,
|
||||
@Arg(desc = "TODO", def = "100") int threshold, @Arg(name = "dimensions", desc = "BlockVector2", def = "") BlockVector2 dimensions) throws WorldEditException, IOException {
|
||||
TextureUtil tu = Fawe.get().getCachedTextureUtil(randomize, 0, threshold);
|
||||
URL url = new URL(argStr);
|
||||
@ -142,7 +142,7 @@ public class GenerationCommands {
|
||||
image = ImageUtil.getScaledInstance(image, dimensions.getBlockX(), dimensions.getBlockZ(), RenderingHints.VALUE_INTERPOLATION_BILINEAR, false);
|
||||
}
|
||||
|
||||
BlockVector3 pos1 = player.getLocation().toBlockPoint();
|
||||
BlockVector3 pos1 = session.getPlacementPosition(actor);
|
||||
BlockVector3 pos2 = pos1.add(image.getWidth() - 1, 0, image.getHeight() - 1);
|
||||
CuboidRegion region = new CuboidRegion(pos1, pos2);
|
||||
int[] count = new int[1];
|
||||
@ -162,7 +162,7 @@ public class GenerationCommands {
|
||||
return false;
|
||||
});
|
||||
Operations.completeBlindly(visitor);
|
||||
BBC.VISITOR_BLOCK.send(player, editSession.getBlockChangeCount());
|
||||
BBC.VISITOR_BLOCK.send(actor, editSession.getBlockChangeCount());
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -171,10 +171,10 @@ public class GenerationCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.ore")
|
||||
@Logging(PLACEMENT)
|
||||
public void ore(Player fp, LocalSession session, EditSession editSession, @Selection Region region, Mask mask, Pattern material, @Arg(name="size", desc="Ore vein size") @Range(min = 0) int size, int freq, @Range(min = 0, max = 100) int rarity, @Range(min = 0, max = 255) int minY, @Range(min = 0, max = 255) int maxY, InjectedValueAccess context) throws WorldEditException {
|
||||
fp.checkConfirmationRegion(() -> {
|
||||
public void ore(Actor actor, LocalSession session, EditSession editSession, @Selection Region region, Mask mask, Pattern material, @Arg(name="size", desc="Ore vein size") @Range(min = 0) int size, int freq, @Range(min = 0, max = 100) int rarity, @Range(min = 0, max = 255) int minY, @Range(min = 0, max = 255) int maxY, InjectedValueAccess context) throws WorldEditException {
|
||||
actor.checkConfirmationRegion(() -> {
|
||||
editSession.addOre(region, mask, material, size, freq, rarity, minY, maxY);
|
||||
BBC.VISITOR_BLOCK.send(fp, editSession.getBlockChangeCount());
|
||||
BBC.VISITOR_BLOCK.send(actor, editSession.getBlockChangeCount());
|
||||
}, "/ore", region, context);
|
||||
}
|
||||
|
||||
@ -186,7 +186,7 @@ public class GenerationCommands {
|
||||
@Logging(PLACEMENT)
|
||||
public void hcyl(Actor actor, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The pattern of blocks to generate")
|
||||
Pattern pattern,
|
||||
Pattern pattern,
|
||||
BlockVector2 radius,
|
||||
@Arg(desc = "The height of the cylinder", def = "1")
|
||||
int height,
|
||||
@ -208,12 +208,12 @@ public class GenerationCommands {
|
||||
@Logging(PLACEMENT)
|
||||
public void cyl(Actor actor, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The pattern of blocks to generate")
|
||||
Pattern pattern,
|
||||
Pattern pattern,
|
||||
BlockVector2 radius,
|
||||
@Arg(desc = "The height of the cylinder", def = "1")
|
||||
int height,
|
||||
int height,
|
||||
@Switch(name = 'h', desc = "Make a hollow cylinder")
|
||||
boolean hollow, InjectedValueAccess context) throws WorldEditException {
|
||||
boolean hollow, InjectedValueAccess context) throws WorldEditException {
|
||||
double max = Math.max(radius.getBlockX(), radius.getBlockZ());
|
||||
worldEdit.checkMaxRadius(max);
|
||||
BlockVector3 pos = session.getPlacementPosition(actor);
|
||||
@ -260,9 +260,7 @@ public class GenerationCommands {
|
||||
BlockVector3 finalPos = raised ? pos.add(0, radii.getY(), 0) : pos;
|
||||
actor.checkConfirmationRadius(() -> {
|
||||
int affected = editSession.makeSphere(finalPos, pattern, radii.getX(), radii.getY(), radii.getZ(), !hollow);
|
||||
if (actor instanceof Player) {
|
||||
((Player) actor).findFreePosition();
|
||||
}
|
||||
if (actor instanceof Player) ((Player) actor).findFreePosition();
|
||||
BBC.VISITOR_BLOCK.send(actor, affected);
|
||||
}, "sphere", (int) max, context);
|
||||
}
|
||||
@ -274,16 +272,15 @@ public class GenerationCommands {
|
||||
@CommandPermissions("worldedit.generation.forest")
|
||||
@Logging(POSITION)
|
||||
public int forestGen(Actor actor, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The size of the forest, in blocks", def = "10")
|
||||
int size,
|
||||
@Arg(name = "size", desc = "The size of the forest, in blocks", def = "10")
|
||||
int sizeOpt,
|
||||
@Arg(desc = "The type of forest", def = "tree")
|
||||
TreeType type,
|
||||
@Arg(desc = "The density of the forest, between 0 and 100", def = "5")
|
||||
@Range(min = 0, max = 100) @Arg(desc = "The density of the forest, between 0 and 100", def = "5")
|
||||
double density) throws WorldEditException {
|
||||
checkCommandArgument(0 <= density && density <= 100, "Density must be between 0 and 100");
|
||||
worldEdit.checkMaxRadius(size);
|
||||
density /= 100;
|
||||
int affected = editSession.makeForest(session.getPlacementPosition(actor), size, density, type);
|
||||
int affected = editSession.makeForest(session.getPlacementPosition(actor), sizeOpt, density, type);
|
||||
actor.print(affected + " trees created.");
|
||||
return affected;
|
||||
}
|
||||
@ -295,14 +292,13 @@ public class GenerationCommands {
|
||||
@CommandPermissions("worldedit.generation.pumpkins")
|
||||
@Logging(POSITION)
|
||||
public int pumpkins(Actor actor, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The size of the patch", def = "10")
|
||||
int size,
|
||||
@Arg(name = "size", desc = "The size of the patch", def = "10")
|
||||
int sizeOpt,
|
||||
@Arg(desc = "//TODO", def = "10")
|
||||
int apothem,
|
||||
@Arg(desc = "//TODO ", def = "0.02")
|
||||
double density) throws WorldEditException {
|
||||
checkCommandArgument(0 <= density && density <= 100, "Density must be between 0 and 100");
|
||||
worldEdit.checkMaxRadius(size);
|
||||
int affected = editSession.makePumpkinPatches(session.getPlacementPosition(actor), apothem, density);
|
||||
BBC.COMMAND_PUMPKIN.send(actor, affected);
|
||||
return affected;
|
||||
@ -340,9 +336,7 @@ public class GenerationCommands {
|
||||
worldEdit.checkMaxRadius(size);
|
||||
actor.checkConfirmationRadius(() -> {
|
||||
int affected = editSession.makePyramid(pos, pattern, size, !hollow);
|
||||
if (actor instanceof Player) {
|
||||
((Player) actor).findFreePosition();
|
||||
}
|
||||
if (actor instanceof Player) ((Player) actor).findFreePosition();
|
||||
BBC.VISITOR_BLOCK.send(actor, affected);
|
||||
}, getArguments(context), size, context);
|
||||
}
|
||||
@ -403,9 +397,7 @@ public class GenerationCommands {
|
||||
actor.checkConfirmationRegion(() -> {
|
||||
try {
|
||||
final int affected = editSession.makeShape(region, zero, unit1, pattern, String.join(" ", expression), hollow, session.getTimeout());
|
||||
if (actor instanceof Player) {
|
||||
((Player) actor).findFreePosition();
|
||||
}
|
||||
if (actor instanceof Player) ((Player) actor).findFreePosition();
|
||||
BBC.VISITOR_BLOCK.send(actor, affected);
|
||||
} catch (ExpressionException e) {
|
||||
actor.printError(e.getMessage());
|
||||
|
@ -1,448 +1,448 @@
|
||||
//package com.sk89q.worldedit.command;
|
||||
//
|
||||
//import com.boydti.fawe.object.mask.AdjacentAnyMask;
|
||||
//import com.boydti.fawe.object.mask.AdjacentMask;
|
||||
//import com.boydti.fawe.object.mask.AngleMask;
|
||||
//import com.boydti.fawe.object.mask.BiomeMask;
|
||||
//import com.boydti.fawe.object.mask.BlockLightMask;
|
||||
//import com.boydti.fawe.object.mask.BrightnessMask;
|
||||
//import com.boydti.fawe.object.mask.DataMask;
|
||||
//import com.boydti.fawe.object.mask.ExtremaMask;
|
||||
//import com.boydti.fawe.object.mask.IdDataMask;
|
||||
//import com.boydti.fawe.object.mask.IdMask;
|
||||
//import com.boydti.fawe.object.mask.LightMask;
|
||||
//import com.boydti.fawe.object.mask.OpacityMask;
|
||||
//import com.boydti.fawe.object.mask.ROCAngleMask;
|
||||
//import com.boydti.fawe.object.mask.RadiusMask;
|
||||
//import com.boydti.fawe.object.mask.RandomMask;
|
||||
//import com.boydti.fawe.object.mask.SimplexMask;
|
||||
//import com.boydti.fawe.object.mask.SkyLightMask;
|
||||
//import com.boydti.fawe.object.mask.SurfaceMask;
|
||||
//import com.boydti.fawe.object.mask.WallMask;
|
||||
//import com.boydti.fawe.object.mask.XAxisMask;
|
||||
//import com.boydti.fawe.object.mask.YAxisMask;
|
||||
//import com.boydti.fawe.object.mask.ZAxisMask;
|
||||
//import com.sk89q.worldedit.IncompleteRegionException;
|
||||
//import com.sk89q.worldedit.LocalSession;
|
||||
//import com.sk89q.worldedit.WorldEdit;
|
||||
//import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
//import com.sk89q.worldedit.entity.Player;
|
||||
//import com.sk89q.worldedit.extent.Extent;
|
||||
//import com.sk89q.worldedit.function.mask.BlockMaskBuilder;
|
||||
//import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
||||
//import com.sk89q.worldedit.function.mask.ExpressionMask;
|
||||
//import com.sk89q.worldedit.function.mask.Mask;
|
||||
//import com.sk89q.worldedit.function.mask.MaskIntersection;
|
||||
//import com.sk89q.worldedit.function.mask.MaskUnion;
|
||||
//import com.sk89q.worldedit.function.mask.Masks;
|
||||
//import com.sk89q.worldedit.function.mask.OffsetMask;
|
||||
//import com.sk89q.worldedit.function.mask.RegionMask;
|
||||
//import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
||||
//import com.sk89q.worldedit.internal.expression.Expression;
|
||||
//import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
//import com.sk89q.worldedit.internal.expression.runtime.ExpressionEnvironment;
|
||||
//import com.sk89q.worldedit.math.BlockVector3;
|
||||
//import com.sk89q.worldedit.math.Vector3;
|
||||
//import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
|
||||
//import com.sk89q.worldedit.session.request.RequestSelection;
|
||||
//import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
//import org.enginehub.piston.annotation.Command;
|
||||
//import org.enginehub.piston.annotation.CommandContainer;
|
||||
//import org.enginehub.piston.annotation.param.Arg;
|
||||
//import org.enginehub.piston.annotation.param.Switch;
|
||||
//
|
||||
////@Command(aliases = {"masks"},
|
||||
//// desc = "Help for the various masks. [More Info](https://git.io/v9r4K)",
|
||||
//// descFooter = "Masks determine if a block can be placed\n" +
|
||||
//// " - Use [brackets] for arguments\n" +
|
||||
//// " - Use , to OR multiple\n" +
|
||||
//// " - Use & to AND multiple\n" +
|
||||
//// "e.g. >[stone,dirt],#light[0][5],$jungle\n" +
|
||||
//// "More Info: https://git.io/v9r4K"
|
||||
////)
|
||||
//@CommandContainer//(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
//public class MaskCommands {
|
||||
// private final WorldEdit worldEdit;
|
||||
//
|
||||
// public MaskCommands(WorldEdit worldEdit) {
|
||||
// this.worldEdit = worldEdit;
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#simplex",
|
||||
// desc = "Use simplex noise as the mask"
|
||||
// )
|
||||
// public Mask simplex(double scale, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
// scale = 1d / Math.max(1, scale);
|
||||
// minInt = (minInt - 50) / 50;
|
||||
// maxInt = (maxInt - 50) / 50;
|
||||
// return new SimplexMask(scale, minInt, maxInt);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#light",
|
||||
// desc = "Restrict to specific light levels"
|
||||
// )
|
||||
// public Mask light(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
// return new LightMask(extent, (int) minInt, (int) maxInt);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#false",
|
||||
// desc = "Always false"
|
||||
// )
|
||||
// public Mask falseMask(Extent extent) {
|
||||
// return Masks.alwaysFalse();
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#true",
|
||||
// desc = "Always true"
|
||||
// )
|
||||
// public Mask trueMask(Extent extent) {
|
||||
// return Masks.alwaysTrue();
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#skylight",
|
||||
// desc = "Restrict to specific sky light levels"
|
||||
// )
|
||||
// public Mask skylight(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
// return new SkyLightMask(extent, (int) minInt, (int) maxInt);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#blocklight",
|
||||
// aliases = {"#emittedlight"},
|
||||
// desc = "Restrict to specific block light levels"
|
||||
// )
|
||||
// public Mask blocklight(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
// return new BlockLightMask(extent, (int) minInt, (int) maxInt);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#opacity",
|
||||
// desc = "Restrict to specific opacity levels"
|
||||
// )
|
||||
// public Mask opacity(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
// return new OpacityMask(extent, (int) minInt, (int) maxInt);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#brightness",
|
||||
// desc = "Restrict to specific block brightness"
|
||||
// )
|
||||
// public Mask brightness(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
// return new BrightnessMask(extent, (int) minInt, (int) maxInt);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#offset",
|
||||
// desc = "Offset a mask"
|
||||
// )
|
||||
// public Mask offset(double x, double y, double z, Mask mask) {
|
||||
// return new OffsetMask(mask, BlockVector3.at(x, y, z));
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#haslight",
|
||||
// desc = "Restricts to blocks with light (sky or emitted)"
|
||||
// )
|
||||
// public Mask haslight(Extent extent) {
|
||||
// return new LightMask(extent, 1, Integer.MAX_VALUE);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#nolight",
|
||||
// desc = "Restrict to blocks without light (sky or emitted)"
|
||||
// )
|
||||
// public Mask nolight(Extent extent) {
|
||||
// return new LightMask(extent, 0, 0);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#existing",
|
||||
// desc = "If there is a non air block"
|
||||
// )
|
||||
// public Mask existing(Extent extent) {
|
||||
// return new ExistingBlockMask(extent);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#solid",
|
||||
// desc = "If there is a solid block"
|
||||
// )
|
||||
// public Mask solid(Extent extent) {
|
||||
// return new SolidBlockMask(extent);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#liquid",
|
||||
// desc = "If there is a solid block"
|
||||
// )
|
||||
// public Mask liquid(Extent extent) {
|
||||
// return new BlockMaskBuilder().addAll(b -> b.getMaterial().isLiquid()).build(extent);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#dregion",
|
||||
// aliases = {"#dselection", "#dsel"},
|
||||
// desc = "inside the player's selection"
|
||||
// )
|
||||
// public Mask dregion() {
|
||||
// return new RegionMask(new RequestSelection());
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#region",
|
||||
// aliases = {"#selection", "#sel"},
|
||||
// desc = "inside the provided selection"
|
||||
// )
|
||||
// public Mask selection(Player player, LocalSession session) throws IncompleteRegionException {
|
||||
// return new RegionMask(session.getSelection(player.getWorld()).clone());
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#xaxis",
|
||||
// desc = "Restrict to initial x axis"
|
||||
// )
|
||||
// public Mask xaxis() {
|
||||
// return new XAxisMask();
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#yaxis",
|
||||
// desc = "Restrict to initial y axis"
|
||||
// )
|
||||
// public Mask yaxis() {
|
||||
// return new YAxisMask();
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#zaxis",
|
||||
// desc = "Restrict to initial z axis"
|
||||
// )
|
||||
// public Mask zaxis() {
|
||||
// return new ZAxisMask();
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#id",
|
||||
// desc = "Restrict to initial id"
|
||||
// )
|
||||
// public Mask id(Extent extent) {
|
||||
// return new IdMask(extent);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#data",
|
||||
// desc = "Restrict to initial data"
|
||||
// )
|
||||
// public Mask data(Extent extent) {
|
||||
// return new DataMask(extent);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#iddata",
|
||||
// desc = "Restrict to initial block id and data"
|
||||
// )
|
||||
// public Mask iddata(Extent extent) {
|
||||
// return new IdDataMask(extent);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#air",
|
||||
// desc = "Restrict to types of air"
|
||||
// )
|
||||
// public Mask air(Extent extent) {
|
||||
// return new BlockMaskBuilder().addAll(b -> b.getMaterial().isAir()).build(extent);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#wall",
|
||||
// desc = "Restrict to walls (any block n,e,s,w of air)"
|
||||
// )
|
||||
// public Mask wall(Extent extent) {
|
||||
// Mask blockMask = air(extent);
|
||||
// return new MaskUnion(new ExistingBlockMask(extent), new WallMask(blockMask, 1, 8));
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#surface",
|
||||
// desc = "Restrict to surfaces (any solid block touching air)"
|
||||
// )
|
||||
// public Mask surface(Extent extent) {
|
||||
// return new SurfaceMask(extent);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "\\",
|
||||
// aliases = {"/", "#angle", "#\\", "#/"},
|
||||
// desc = "Restrict to specific terrain angle",
|
||||
// descFooter = "Restrict to specific terrain angle\n" +
|
||||
// "The -o flag will only overlay\n" +
|
||||
// "Example: /[0d][45d]\n" +
|
||||
// "Explanation: Allows any block where the adjacent block is between 0 and 45 degrees.\n" +
|
||||
// "Example: /[3][20]\n" +
|
||||
// "Explanation: Allows any block where the adjacent block is between 3 and 20 blocks below"
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import com.boydti.fawe.object.mask.AdjacentAnyMask;
|
||||
import com.boydti.fawe.object.mask.AdjacentMask;
|
||||
import com.boydti.fawe.object.mask.AngleMask;
|
||||
import com.boydti.fawe.object.mask.BiomeMask;
|
||||
import com.boydti.fawe.object.mask.BlockLightMask;
|
||||
import com.boydti.fawe.object.mask.BrightnessMask;
|
||||
import com.boydti.fawe.object.mask.DataMask;
|
||||
import com.boydti.fawe.object.mask.ExtremaMask;
|
||||
import com.boydti.fawe.object.mask.IdDataMask;
|
||||
import com.boydti.fawe.object.mask.IdMask;
|
||||
import com.boydti.fawe.object.mask.LightMask;
|
||||
import com.boydti.fawe.object.mask.OpacityMask;
|
||||
import com.boydti.fawe.object.mask.ROCAngleMask;
|
||||
import com.boydti.fawe.object.mask.RadiusMask;
|
||||
import com.boydti.fawe.object.mask.RandomMask;
|
||||
import com.boydti.fawe.object.mask.SimplexMask;
|
||||
import com.boydti.fawe.object.mask.SkyLightMask;
|
||||
import com.boydti.fawe.object.mask.SurfaceMask;
|
||||
import com.boydti.fawe.object.mask.WallMask;
|
||||
import com.boydti.fawe.object.mask.XAxisMask;
|
||||
import com.boydti.fawe.object.mask.YAxisMask;
|
||||
import com.boydti.fawe.object.mask.ZAxisMask;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.mask.BlockMaskBuilder;
|
||||
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
||||
import com.sk89q.worldedit.function.mask.ExpressionMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.MaskIntersection;
|
||||
import com.sk89q.worldedit.function.mask.MaskUnion;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.function.mask.OffsetMask;
|
||||
import com.sk89q.worldedit.function.mask.RegionMask;
|
||||
import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
||||
import com.sk89q.worldedit.internal.expression.Expression;
|
||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
import com.sk89q.worldedit.internal.expression.runtime.ExpressionEnvironment;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
|
||||
import com.sk89q.worldedit.session.request.RequestSelection;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
import org.enginehub.piston.annotation.param.Switch;
|
||||
|
||||
//@Command(aliases = {"masks"},
|
||||
// desc = "Help for the various masks. [More Info](https://git.io/v9r4K)",
|
||||
// descFooter = "Masks determine if a block can be placed\n" +
|
||||
// " - Use [brackets] for arguments\n" +
|
||||
// " - Use , to OR multiple\n" +
|
||||
// " - Use & to AND multiple\n" +
|
||||
// "e.g. >[stone,dirt],#light[0][5],$jungle\n" +
|
||||
// "More Info: https://git.io/v9r4K"
|
||||
//)
|
||||
// public Mask angle(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "1") int distanceOpt) throws ExpressionException {
|
||||
// double y1, y2;
|
||||
// boolean override;
|
||||
// if (maxStr.endsWith("d")) {
|
||||
// double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
|
||||
// double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
|
||||
// y1 = Math.tan(y1d * (Math.PI / 180));
|
||||
// y2 = Math.tan(y2d * (Math.PI / 180));
|
||||
// } else {
|
||||
// y1 = Expression.compile(minStr).evaluate();
|
||||
// y2 = Expression.compile(maxStr).evaluate();
|
||||
// }
|
||||
// return new AngleMask(extent, y1, y2, overlay, distanceOpt);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "(",
|
||||
// aliases = {")", "#roc", "#(", "#)"},
|
||||
// desc = "Restrict to near specific terrain slope rate of change",
|
||||
// descFooter = "Restrict to near specific terrain slope rate of change\n" +
|
||||
// "The -o flag will only overlay\n" +
|
||||
// "Example: ([0d][45d][5]\n" +
|
||||
// "Explanation: Restrict near where the angle changes between 0-45 degrees within 5 blocks\n" +
|
||||
// "Note: Use negatives for decreasing slope"
|
||||
//)
|
||||
// public Mask roc(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "4") int distanceOpt) throws ExpressionException {
|
||||
// double y1, y2;
|
||||
// boolean override;
|
||||
// if (maxStr.endsWith("d")) {
|
||||
// double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
|
||||
// double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
|
||||
// y1 = Math.tan(y1d * (Math.PI / 180));
|
||||
// y2 = Math.tan(y2d * (Math.PI / 180));
|
||||
// } else {
|
||||
// y1 = Expression.compile(minStr).evaluate();
|
||||
// y2 = Expression.compile(maxStr).evaluate();
|
||||
// }
|
||||
// return new ROCAngleMask(extent, y1, y2, overlay, distanceOpt);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "^",
|
||||
// aliases = {"#extrema", "#^"},
|
||||
// desc = "Restrict to near specific terrain extrema",
|
||||
// descFooter = "Restrict to near specific terrain extrema\n" +
|
||||
// "The -o flag will only overlay\n" +
|
||||
// "Example: ([0d][45d][5]\n" +
|
||||
// "Explanation: Restrict to near 45 degrees of local maxima\n" +
|
||||
// "Note: Use negatives for local minima"
|
||||
//)
|
||||
// public Mask extrema(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "4") int distanceOpt) throws ExpressionException {
|
||||
// double y1, y2;
|
||||
// boolean override;
|
||||
// if (maxStr.endsWith("d")) {
|
||||
// double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
|
||||
// double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
|
||||
// y1 = Math.tan(y1d * (Math.PI / 180));
|
||||
// y2 = Math.tan(y2d * (Math.PI / 180));
|
||||
// } else {
|
||||
// y1 = Expression.compile(minStr).evaluate();
|
||||
// y2 = Expression.compile(maxStr).evaluate();
|
||||
// }
|
||||
// return new ExtremaMask(extent, y1, y2, overlay, distanceOpt);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "{",
|
||||
// aliases = {"#{"},
|
||||
// desc = "Restricts blocks to within a specific radius range of the initial block"
|
||||
//)
|
||||
// public Mask radius(@Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) throws ExpressionException {
|
||||
// return new RadiusMask((int) minInt, (int) maxInt);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "|",
|
||||
// aliases = {"#|", "#side"},
|
||||
// desc = "sides with a specific number of other blocks"
|
||||
//)
|
||||
// public Mask wall(Mask mask, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) throws ExpressionException {
|
||||
// return new WallMask(mask, (int) minInt, (int) maxInt);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "~",
|
||||
// aliases = {"#~", "#adjacent"},
|
||||
// desc = "Adjacent to a specific number of other blocks"
|
||||
//)
|
||||
// public Mask adjacent(Mask mask, @Arg(name = "min", desc = "double", def = "-1") double min, @Arg(name = "max", desc = "double", def = "-1") double max) throws ExpressionException {
|
||||
// if (min == -1 && max == -1) {
|
||||
// min = 1;
|
||||
// max = 8;
|
||||
// } else if (max == -1) max = min;
|
||||
// if (max >= 8 && min == 1) {
|
||||
// return new AdjacentAnyMask(mask);
|
||||
// }
|
||||
// return new AdjacentMask(mask, (int) min, (int) max);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "<",
|
||||
// aliases = {"#<", "#below"},
|
||||
// desc = "below a specific block"
|
||||
//)
|
||||
// public Mask below(Mask mask) throws ExpressionException {
|
||||
// OffsetMask offsetMask = new OffsetMask(mask, BlockVector3.at(0, 1, 0));
|
||||
// return new MaskIntersection(offsetMask, Masks.negate(mask));
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = ">",
|
||||
// aliases = {"#>", "#above"},
|
||||
// desc = "above a specific block"
|
||||
//)
|
||||
// public Mask above(Mask mask) throws ExpressionException {
|
||||
// OffsetMask offsetMask = new OffsetMask(mask, BlockVector3.at(0, -1, 0));
|
||||
// return new MaskIntersection(offsetMask, Masks.negate(mask));
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "$",
|
||||
// aliases = {"#biome", "#$"},
|
||||
// desc = "in a specific biome",
|
||||
// descFooter = "in a specific biome. For a list of biomes use //biomelist"
|
||||
//)
|
||||
// public Mask biome(Extent extent, BiomeType biome) throws ExpressionException {
|
||||
// return new BiomeMask(extent, biome);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "%",
|
||||
// aliases = {"#%", "#percent"},
|
||||
// desc = "percentage chance"
|
||||
//)
|
||||
// public Mask random(double chance) throws ExpressionException {
|
||||
// chance = chance / 100;
|
||||
// return new RandomMask(chance);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "=",
|
||||
// aliases = {"#=", "#expression"},
|
||||
// desc = "expression mask"
|
||||
//)
|
||||
// public Mask expression(Extent extent, String input) throws ExpressionException {
|
||||
// Expression exp = Expression.compile(input, "x", "y", "z");
|
||||
// ExpressionEnvironment env = new WorldEditExpressionEnvironment(extent, Vector3.ONE, Vector3.ZERO);
|
||||
// exp.setEnvironment(env);
|
||||
// return new ExpressionMask(exp);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "!",
|
||||
// aliases = {"#not", "#negate", "#!"},
|
||||
// desc = "Negate another mask"
|
||||
//)
|
||||
// public Mask expression(Mask mask) throws ExpressionException {
|
||||
// return Masks.negate(mask);
|
||||
// }
|
||||
//}
|
||||
@CommandContainer//(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class MaskCommands {
|
||||
private final WorldEdit worldEdit;
|
||||
|
||||
public MaskCommands(WorldEdit worldEdit) {
|
||||
this.worldEdit = worldEdit;
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#simplex",
|
||||
desc = "Use simplex noise as the mask"
|
||||
)
|
||||
public Mask simplex(double scale, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
scale = 1d / Math.max(1, scale);
|
||||
minInt = (minInt - 50) / 50;
|
||||
maxInt = (maxInt - 50) / 50;
|
||||
return new SimplexMask(scale, minInt, maxInt);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#light",
|
||||
desc = "Restrict to specific light levels"
|
||||
)
|
||||
public Mask light(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
return new LightMask(extent, (int) minInt, (int) maxInt);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#false",
|
||||
desc = "Always false"
|
||||
)
|
||||
public Mask falseMask(Extent extent) {
|
||||
return Masks.alwaysFalse();
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#true",
|
||||
desc = "Always true"
|
||||
)
|
||||
public Mask trueMask(Extent extent) {
|
||||
return Masks.alwaysTrue();
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#skylight",
|
||||
desc = "Restrict to specific sky light levels"
|
||||
)
|
||||
public Mask skylight(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
return new SkyLightMask(extent, (int) minInt, (int) maxInt);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#blocklight",
|
||||
aliases = {"#emittedlight"},
|
||||
desc = "Restrict to specific block light levels"
|
||||
)
|
||||
public Mask blocklight(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
return new BlockLightMask(extent, (int) minInt, (int) maxInt);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#opacity",
|
||||
desc = "Restrict to specific opacity levels"
|
||||
)
|
||||
public Mask opacity(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
return new OpacityMask(extent, (int) minInt, (int) maxInt);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#brightness",
|
||||
desc = "Restrict to specific block brightness"
|
||||
)
|
||||
public Mask brightness(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
return new BrightnessMask(extent, (int) minInt, (int) maxInt);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#offset",
|
||||
desc = "Offset a mask"
|
||||
)
|
||||
public Mask offset(double x, double y, double z, Mask mask) {
|
||||
return new OffsetMask(mask, BlockVector3.at(x, y, z));
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#haslight",
|
||||
desc = "Restricts to blocks with light (sky or emitted)"
|
||||
)
|
||||
public Mask haslight(Extent extent) {
|
||||
return new LightMask(extent, 1, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#nolight",
|
||||
desc = "Restrict to blocks without light (sky or emitted)"
|
||||
)
|
||||
public Mask nolight(Extent extent) {
|
||||
return new LightMask(extent, 0, 0);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#existing",
|
||||
desc = "If there is a non air block"
|
||||
)
|
||||
public Mask existing(Extent extent) {
|
||||
return new ExistingBlockMask(extent);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#solid",
|
||||
desc = "If there is a solid block"
|
||||
)
|
||||
public Mask solid(Extent extent) {
|
||||
return new SolidBlockMask(extent);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#liquid",
|
||||
desc = "If there is a solid block"
|
||||
)
|
||||
public Mask liquid(Extent extent) {
|
||||
return new BlockMaskBuilder().addAll(b -> b.getMaterial().isLiquid()).build(extent);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#dregion",
|
||||
aliases = {"#dselection", "#dsel"},
|
||||
desc = "inside the player's selection"
|
||||
)
|
||||
public Mask dregion() {
|
||||
return new RegionMask(new RequestSelection());
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#region",
|
||||
aliases = {"#selection", "#sel"},
|
||||
desc = "inside the provided selection"
|
||||
)
|
||||
public Mask selection(Player player, LocalSession session) throws IncompleteRegionException {
|
||||
return new RegionMask(session.getSelection(player.getWorld()).clone());
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#xaxis",
|
||||
desc = "Restrict to initial x axis"
|
||||
)
|
||||
public Mask xaxis() {
|
||||
return new XAxisMask();
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#yaxis",
|
||||
desc = "Restrict to initial y axis"
|
||||
)
|
||||
public Mask yaxis() {
|
||||
return new YAxisMask();
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#zaxis",
|
||||
desc = "Restrict to initial z axis"
|
||||
)
|
||||
public Mask zaxis() {
|
||||
return new ZAxisMask();
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#id",
|
||||
desc = "Restrict to initial id"
|
||||
)
|
||||
public Mask id(Extent extent) {
|
||||
return new IdMask(extent);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#data",
|
||||
desc = "Restrict to initial data"
|
||||
)
|
||||
public Mask data(Extent extent) {
|
||||
return new DataMask(extent);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#iddata",
|
||||
desc = "Restrict to initial block id and data"
|
||||
)
|
||||
public Mask iddata(Extent extent) {
|
||||
return new IdDataMask(extent);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#air",
|
||||
desc = "Restrict to types of air"
|
||||
)
|
||||
public Mask air(Extent extent) {
|
||||
return new BlockMaskBuilder().addAll(b -> b.getMaterial().isAir()).build(extent);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#wall",
|
||||
desc = "Restrict to walls (any block n,e,s,w of air)"
|
||||
)
|
||||
public Mask wall(Extent extent) {
|
||||
Mask blockMask = air(extent);
|
||||
return new MaskUnion(new ExistingBlockMask(extent), new WallMask(blockMask, 1, 8));
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#surface",
|
||||
desc = "Restrict to surfaces (any solid block touching air)"
|
||||
)
|
||||
public Mask surface(Extent extent) {
|
||||
return new SurfaceMask(extent);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "\\",
|
||||
aliases = {"/", "#angle", "#\\", "#/"},
|
||||
desc = "Restrict to specific terrain angle",
|
||||
descFooter = "Restrict to specific terrain angle\n" +
|
||||
"The -o flag will only overlay\n" +
|
||||
"Example: /[0d][45d]\n" +
|
||||
"Explanation: Allows any block where the adjacent block is between 0 and 45 degrees.\n" +
|
||||
"Example: /[3][20]\n" +
|
||||
"Explanation: Allows any block where the adjacent block is between 3 and 20 blocks below"
|
||||
)
|
||||
public Mask angle(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "1") int distanceOpt) throws ExpressionException {
|
||||
double y1, y2;
|
||||
boolean override;
|
||||
if (maxStr.endsWith("d")) {
|
||||
double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
|
||||
double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
|
||||
y1 = Math.tan(y1d * (Math.PI / 180));
|
||||
y2 = Math.tan(y2d * (Math.PI / 180));
|
||||
} else {
|
||||
y1 = Expression.compile(minStr).evaluate();
|
||||
y2 = Expression.compile(maxStr).evaluate();
|
||||
}
|
||||
return new AngleMask(extent, y1, y2, overlay, distanceOpt);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "(",
|
||||
aliases = {")", "#roc", "#(", "#)"},
|
||||
desc = "Restrict to near specific terrain slope rate of change",
|
||||
descFooter = "Restrict to near specific terrain slope rate of change\n" +
|
||||
"The -o flag will only overlay\n" +
|
||||
"Example: ([0d][45d][5]\n" +
|
||||
"Explanation: Restrict near where the angle changes between 0-45 degrees within 5 blocks\n" +
|
||||
"Note: Use negatives for decreasing slope"
|
||||
)
|
||||
public Mask roc(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "4") int distanceOpt) throws ExpressionException {
|
||||
double y1, y2;
|
||||
boolean override;
|
||||
if (maxStr.endsWith("d")) {
|
||||
double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
|
||||
double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
|
||||
y1 = Math.tan(y1d * (Math.PI / 180));
|
||||
y2 = Math.tan(y2d * (Math.PI / 180));
|
||||
} else {
|
||||
y1 = Expression.compile(minStr).evaluate();
|
||||
y2 = Expression.compile(maxStr).evaluate();
|
||||
}
|
||||
return new ROCAngleMask(extent, y1, y2, overlay, distanceOpt);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "^",
|
||||
aliases = {"#extrema", "#^"},
|
||||
desc = "Restrict to near specific terrain extrema",
|
||||
descFooter = "Restrict to near specific terrain extrema\n" +
|
||||
"The -o flag will only overlay\n" +
|
||||
"Example: ([0d][45d][5]\n" +
|
||||
"Explanation: Restrict to near 45 degrees of local maxima\n" +
|
||||
"Note: Use negatives for local minima"
|
||||
)
|
||||
public Mask extrema(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "4") int distanceOpt) throws ExpressionException {
|
||||
double y1, y2;
|
||||
boolean override;
|
||||
if (maxStr.endsWith("d")) {
|
||||
double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
|
||||
double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
|
||||
y1 = Math.tan(y1d * (Math.PI / 180));
|
||||
y2 = Math.tan(y2d * (Math.PI / 180));
|
||||
} else {
|
||||
y1 = Expression.compile(minStr).evaluate();
|
||||
y2 = Expression.compile(maxStr).evaluate();
|
||||
}
|
||||
return new ExtremaMask(extent, y1, y2, overlay, distanceOpt);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "{",
|
||||
aliases = {"#{"},
|
||||
desc = "Restricts blocks to within a specific radius range of the initial block"
|
||||
)
|
||||
public Mask radius(@Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) throws ExpressionException {
|
||||
return new RadiusMask((int) minInt, (int) maxInt);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "|",
|
||||
aliases = {"#|", "#side"},
|
||||
desc = "sides with a specific number of other blocks"
|
||||
)
|
||||
public Mask wall(Mask mask, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) throws ExpressionException {
|
||||
return new WallMask(mask, (int) minInt, (int) maxInt);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "~",
|
||||
aliases = {"#~", "#adjacent"},
|
||||
desc = "Adjacent to a specific number of other blocks"
|
||||
)
|
||||
public Mask adjacent(Mask mask, @Arg(name = "min", desc = "double", def = "-1") double min, @Arg(name = "max", desc = "double", def = "-1") double max) throws ExpressionException {
|
||||
if (min == -1 && max == -1) {
|
||||
min = 1;
|
||||
max = 8;
|
||||
} else if (max == -1) max = min;
|
||||
if (max >= 8 && min == 1) {
|
||||
return new AdjacentAnyMask(mask);
|
||||
}
|
||||
return new AdjacentMask(mask, (int) min, (int) max);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "<",
|
||||
aliases = {"#<", "#below"},
|
||||
desc = "below a specific block"
|
||||
)
|
||||
public Mask below(Mask mask) throws ExpressionException {
|
||||
OffsetMask offsetMask = new OffsetMask(mask, BlockVector3.at(0, 1, 0));
|
||||
return new MaskIntersection(offsetMask, Masks.negate(mask));
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = ">",
|
||||
aliases = {"#>", "#above"},
|
||||
desc = "above a specific block"
|
||||
)
|
||||
public Mask above(Mask mask) throws ExpressionException {
|
||||
OffsetMask offsetMask = new OffsetMask(mask, BlockVector3.at(0, -1, 0));
|
||||
return new MaskIntersection(offsetMask, Masks.negate(mask));
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "$",
|
||||
aliases = {"#biome", "#$"},
|
||||
desc = "in a specific biome",
|
||||
descFooter = "in a specific biome. For a list of biomes use //biomelist"
|
||||
)
|
||||
public Mask biome(Extent extent, BiomeType biome) throws ExpressionException {
|
||||
return new BiomeMask(extent, biome);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "%",
|
||||
aliases = {"#%", "#percent"},
|
||||
desc = "percentage chance"
|
||||
)
|
||||
public Mask random(double chance) throws ExpressionException {
|
||||
chance = chance / 100;
|
||||
return new RandomMask(chance);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "=",
|
||||
aliases = {"#=", "#expression"},
|
||||
desc = "expression mask"
|
||||
)
|
||||
public Mask expression(Extent extent, String input) throws ExpressionException {
|
||||
Expression exp = Expression.compile(input, "x", "y", "z");
|
||||
ExpressionEnvironment env = new WorldEditExpressionEnvironment(extent, Vector3.ONE, Vector3.ZERO);
|
||||
exp.setEnvironment(env);
|
||||
return new ExpressionMask(exp);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "!",
|
||||
aliases = {"#not", "#negate", "#!"},
|
||||
desc = "Negate another mask"
|
||||
)
|
||||
public Mask expression(Mask mask) throws ExpressionException {
|
||||
return Masks.negate(mask);
|
||||
}
|
||||
}
|
||||
|
@ -1,403 +1,403 @@
|
||||
//package com.sk89q.worldedit.command;
|
||||
//
|
||||
//import com.boydti.fawe.object.DataAnglePattern;
|
||||
//import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
|
||||
//import com.boydti.fawe.object.collection.RandomCollection;
|
||||
//import com.boydti.fawe.object.pattern.AngleColorPattern;
|
||||
//import com.boydti.fawe.object.pattern.AverageColorPattern;
|
||||
//import com.boydti.fawe.object.pattern.BiomePattern;
|
||||
//import com.boydti.fawe.object.pattern.BufferedPattern;
|
||||
//import com.boydti.fawe.object.pattern.BufferedPattern2D;
|
||||
//import com.boydti.fawe.object.pattern.DataPattern;
|
||||
//import com.boydti.fawe.object.pattern.DesaturatePattern;
|
||||
//import com.boydti.fawe.object.pattern.ExistingPattern;
|
||||
//import com.boydti.fawe.object.pattern.ExpressionPattern;
|
||||
//import com.boydti.fawe.object.pattern.FullClipboardPattern;
|
||||
//import com.boydti.fawe.object.pattern.IdDataMaskPattern;
|
||||
//import com.boydti.fawe.object.pattern.IdPattern;
|
||||
//import com.boydti.fawe.object.pattern.Linear2DBlockPattern;
|
||||
//import com.boydti.fawe.object.pattern.Linear3DBlockPattern;
|
||||
//import com.boydti.fawe.object.pattern.LinearBlockPattern;
|
||||
//import com.boydti.fawe.object.pattern.MaskedPattern;
|
||||
//import com.boydti.fawe.object.pattern.NoXPattern;
|
||||
//import com.boydti.fawe.object.pattern.NoYPattern;
|
||||
//import com.boydti.fawe.object.pattern.NoZPattern;
|
||||
//import com.boydti.fawe.object.pattern.OffsetPattern;
|
||||
//import com.boydti.fawe.object.pattern.PropertyPattern;
|
||||
//import com.boydti.fawe.object.pattern.RandomFullClipboardPattern;
|
||||
//import com.boydti.fawe.object.pattern.RandomOffsetPattern;
|
||||
//import com.boydti.fawe.object.pattern.RelativePattern;
|
||||
//import com.boydti.fawe.object.pattern.SaturatePattern;
|
||||
//import com.boydti.fawe.object.pattern.ShadePattern;
|
||||
//import com.boydti.fawe.object.pattern.SolidRandomOffsetPattern;
|
||||
//import com.boydti.fawe.object.pattern.SurfaceRandomOffsetPattern;
|
||||
//import com.boydti.fawe.object.random.SimplexRandom;
|
||||
//import com.boydti.fawe.util.ColorUtil;
|
||||
//import com.boydti.fawe.util.TextureUtil;
|
||||
//import com.sk89q.worldedit.EmptyClipboardException;
|
||||
//import com.sk89q.worldedit.LocalSession;
|
||||
//import com.sk89q.worldedit.entity.Player;
|
||||
//import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
//import com.sk89q.worldedit.extension.platform.Actor;
|
||||
//import com.sk89q.worldedit.extent.Extent;
|
||||
//import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
//import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
||||
//import com.sk89q.worldedit.function.mask.Mask;
|
||||
//import com.sk89q.worldedit.function.pattern.ClipboardPattern;
|
||||
//import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
//import com.sk89q.worldedit.function.pattern.RandomPattern;
|
||||
//import com.sk89q.worldedit.internal.annotation.Range;
|
||||
//import com.sk89q.worldedit.internal.expression.Expression;
|
||||
//import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
//import com.sk89q.worldedit.math.Vector3;
|
||||
//import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
|
||||
//import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
//import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
//import java.awt.Color;
|
||||
//import java.io.IOException;
|
||||
//import java.util.Collections;
|
||||
//import java.util.List;
|
||||
//import java.util.Set;
|
||||
//import org.enginehub.piston.annotation.Command;
|
||||
//import org.enginehub.piston.annotation.CommandContainer;
|
||||
//import org.enginehub.piston.annotation.param.Arg;
|
||||
//
|
||||
////@Command(aliases = {"patterns"},
|
||||
//// desc = "Help for the various patterns. [More Info](https://git.io/vSPmA)",
|
||||
//// descFooter = "Patterns determine what blocks are placed\n" +
|
||||
//// " - Use [brackets] for arguments\n" +
|
||||
//// " - Use , to OR multiple\n" +
|
||||
//// "e.g. #surfacespread[10][#existing],andesite\n" +
|
||||
//// "More Info: https://git.io/vSPmA"
|
||||
////)
|
||||
//@CommandContainer//(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
//public class PatternCommands {
|
||||
//
|
||||
// @Command(
|
||||
// name = "#existing",
|
||||
// aliases = {"#*", "*", ".*"},
|
||||
// desc = "Use the block that is already there"
|
||||
// )
|
||||
// public Pattern existing(Extent extent, @Arg(name = "properties", desc = "String", def = "") String properties) { // TODO FIXME , @Arg(name = "properties", desc = "String", def = "") String properties
|
||||
// if (properties == null) return new ExistingPattern(extent);
|
||||
// return new PropertyPattern(extent).addRegex(".*[" + properties + "]");
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#clipboard",
|
||||
// aliases = {"#copy"},
|
||||
// desc = "Use the blocks in your clipboard as the pattern")
|
||||
// public Pattern clipboard(LocalSession session) throws EmptyClipboardException {
|
||||
// ClipboardHolder holder = session.getClipboard();
|
||||
// Clipboard clipboard = holder.getClipboard();
|
||||
// return new ClipboardPattern(clipboard);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#simplex",
|
||||
// desc = "Use simplex noise to randomize blocks. Tutorial: https://imgur.com/a/rwVAE"
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import com.boydti.fawe.object.DataAnglePattern;
|
||||
import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
|
||||
import com.boydti.fawe.object.collection.RandomCollection;
|
||||
import com.boydti.fawe.object.pattern.AngleColorPattern;
|
||||
import com.boydti.fawe.object.pattern.AverageColorPattern;
|
||||
import com.boydti.fawe.object.pattern.BiomePattern;
|
||||
import com.boydti.fawe.object.pattern.BufferedPattern;
|
||||
import com.boydti.fawe.object.pattern.BufferedPattern2D;
|
||||
import com.boydti.fawe.object.pattern.DataPattern;
|
||||
import com.boydti.fawe.object.pattern.DesaturatePattern;
|
||||
import com.boydti.fawe.object.pattern.ExistingPattern;
|
||||
import com.boydti.fawe.object.pattern.ExpressionPattern;
|
||||
import com.boydti.fawe.object.pattern.FullClipboardPattern;
|
||||
import com.boydti.fawe.object.pattern.IdDataMaskPattern;
|
||||
import com.boydti.fawe.object.pattern.IdPattern;
|
||||
import com.boydti.fawe.object.pattern.Linear2DBlockPattern;
|
||||
import com.boydti.fawe.object.pattern.Linear3DBlockPattern;
|
||||
import com.boydti.fawe.object.pattern.LinearBlockPattern;
|
||||
import com.boydti.fawe.object.pattern.MaskedPattern;
|
||||
import com.boydti.fawe.object.pattern.NoXPattern;
|
||||
import com.boydti.fawe.object.pattern.NoYPattern;
|
||||
import com.boydti.fawe.object.pattern.NoZPattern;
|
||||
import com.boydti.fawe.object.pattern.OffsetPattern;
|
||||
import com.boydti.fawe.object.pattern.PropertyPattern;
|
||||
import com.boydti.fawe.object.pattern.RandomFullClipboardPattern;
|
||||
import com.boydti.fawe.object.pattern.RandomOffsetPattern;
|
||||
import com.boydti.fawe.object.pattern.RelativePattern;
|
||||
import com.boydti.fawe.object.pattern.SaturatePattern;
|
||||
import com.boydti.fawe.object.pattern.ShadePattern;
|
||||
import com.boydti.fawe.object.pattern.SolidRandomOffsetPattern;
|
||||
import com.boydti.fawe.object.pattern.SurfaceRandomOffsetPattern;
|
||||
import com.boydti.fawe.object.random.SimplexRandom;
|
||||
import com.boydti.fawe.util.ColorUtil;
|
||||
import com.boydti.fawe.util.TextureUtil;
|
||||
import com.sk89q.worldedit.EmptyClipboardException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.pattern.ClipboardPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.RandomPattern;
|
||||
import com.sk89q.worldedit.internal.annotation.Range;
|
||||
import com.sk89q.worldedit.internal.expression.Expression;
|
||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import java.awt.Color;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
|
||||
//@Command(aliases = {"patterns"},
|
||||
// desc = "Help for the various patterns. [More Info](https://git.io/vSPmA)",
|
||||
// descFooter = "Patterns determine what blocks are placed\n" +
|
||||
// " - Use [brackets] for arguments\n" +
|
||||
// " - Use , to OR multiple\n" +
|
||||
// "e.g. #surfacespread[10][#existing],andesite\n" +
|
||||
// "More Info: https://git.io/vSPmA"
|
||||
//)
|
||||
// public Pattern simplex(@Arg(desc = "scale factor") double scale, Pattern other) {
|
||||
// if (other instanceof RandomPattern) {
|
||||
// scale = (1d / Math.max(1, scale));
|
||||
// RandomCollection<Pattern> collection = ((RandomPattern) other).getCollection();
|
||||
// collection.setRandom(new SimplexRandom(scale));
|
||||
// }
|
||||
// return other;
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#color",
|
||||
// desc = "Use the block closest to a specific color"
|
||||
//)
|
||||
// public Pattern color(TextureUtil textureUtil, String color) {
|
||||
// Color colorObj = ColorUtil.parseColor(color);
|
||||
// return textureUtil.getNearestBlock(colorObj.getRGB()).getDefaultState();
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#anglecolor",
|
||||
// desc = "A darker block based on the existing terrain angle"
|
||||
//)
|
||||
// public Pattern anglecolor(Extent extent, LocalSession session, @Arg(name = "randomize", desc = "boolean", def = "true") boolean randomize, @Arg(name = "maxcomplexity", desc = "double", def = "100") double maxComplexity, @Arg(name = "distance", desc = "int", def = "1") int distanceOpt) {
|
||||
// return new AngleColorPattern(extent, session, distanceOpt);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#angledata",
|
||||
// desc = "Block data based on the existing terrain angle"
|
||||
// )
|
||||
// public Pattern angledata(Extent extent, @Arg(name = "distance", desc = "int", def = "1") int distanceOpt) {
|
||||
// return new DataAnglePattern(extent, distanceOpt);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#saturate",
|
||||
// desc = "Saturate the existing block with a color"
|
||||
//)
|
||||
// public Pattern saturate(Extent extent, LocalSession session, String colorStr) {
|
||||
// Color color = ColorUtil.parseColor(colorStr);
|
||||
// return new SaturatePattern(extent, color.getRGB(), session);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#averagecolor",
|
||||
// desc = "Average between the existing block and a color"
|
||||
//)
|
||||
// public Pattern averagecolor(Extent extent, LocalSession session, String colorStr) {
|
||||
// Color color = ColorUtil.parseColor(colorStr);
|
||||
// return new AverageColorPattern(extent, color.getRGB(), session);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#desaturate",
|
||||
// desc = "Desaturated color of the existing block"
|
||||
//)
|
||||
// public Pattern desaturate(Extent extent, LocalSession session, @Arg(name = "percent", desc = "double", def = "100") double percent) {
|
||||
// return new DesaturatePattern(extent, percent / 100d, session);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#lighten",
|
||||
// desc = "Lighten the existing block"
|
||||
//)
|
||||
// public Pattern lighten(Extent extent, TextureUtil util) {
|
||||
// return new ShadePattern(extent, false, util);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#darken",
|
||||
// desc = "Darken the existing block"
|
||||
//)
|
||||
// public Pattern darken(Extent extent, TextureUtil util) {
|
||||
// return new ShadePattern(extent, true, util);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#fullcopy",
|
||||
// desc = "Places your full clipboard at each block"
|
||||
//)
|
||||
// public Pattern fullcopy(Player player, Extent extent, LocalSession session, @Arg(name = "location", desc = "String", def = "#copy") String location, @Arg(name = "rotate", desc = "boolean", def = "false") boolean rotate, @Arg(name = "flip", desc = "boolean", def = "false") boolean flip) throws EmptyClipboardException, InputParseException, IOException {
|
||||
// List<ClipboardHolder> clipboards;
|
||||
// switch (location.toLowerCase()) {
|
||||
// case "#copy":
|
||||
// case "#clipboard":
|
||||
// ClipboardHolder clipboard = session.getExistingClipboard();
|
||||
// if (clipboard == null) {
|
||||
// throw new InputParseException("To use #fullcopy, please first copy something to your clipboard");
|
||||
// }
|
||||
// if (!rotate && !flip) {
|
||||
// return new FullClipboardPattern(extent, clipboard.getClipboard());
|
||||
// }
|
||||
// clipboards = Collections.singletonList(clipboard);
|
||||
// break;
|
||||
// default:
|
||||
// MultiClipboardHolder multi = ClipboardFormats.loadAllFromInput(player, location, null, true);
|
||||
// clipboards = multi != null ? multi.getHolders() : null;
|
||||
// break;
|
||||
// }
|
||||
// if (clipboards == null) {
|
||||
// throw new InputParseException("#fullcopy:<source>");
|
||||
// }
|
||||
// return new RandomFullClipboardPattern(extent, clipboards, rotate, flip);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#buffer",
|
||||
// desc = "Only place a block once while a pattern is in use",
|
||||
// descFooter = "Only place a block once while a pattern is in use\n" +
|
||||
// "Use with a brush when you don't want to apply to the same spot twice"
|
||||
//)
|
||||
// public Pattern buffer(Actor actor, Pattern pattern) {
|
||||
// return new BufferedPattern(actor, pattern);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#buffer2d",
|
||||
// desc = "Only place a block once in a column while a pattern is in use"
|
||||
//)
|
||||
// public Pattern buffer2d(Actor actor, Pattern pattern) {
|
||||
// return new BufferedPattern2D(actor, pattern);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#iddatamask",
|
||||
// desc = "Use the pattern's id and the existing blocks data with the provided mask",
|
||||
// descFooter = "Use the pattern's id and the existing blocks data with the provided mask\n" +
|
||||
// " - Use to replace slabs or where the data values needs to be shifted instead of set"
|
||||
//)
|
||||
// public Pattern iddatamask(Actor actor, LocalSession session, Extent extent, @Range(min = 0, max = 15) int bitmask, Pattern pattern) {
|
||||
//
|
||||
// return new IdDataMaskPattern(extent, pattern, bitmask);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#id",
|
||||
// desc = "Only change the block id"
|
||||
//)
|
||||
// public Pattern id(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
|
||||
//
|
||||
// return new IdPattern(extent, pattern);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#data",
|
||||
// desc = "Only change the block data"
|
||||
//)
|
||||
// public Pattern data(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
|
||||
//
|
||||
// return new DataPattern(extent, pattern);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#biome",
|
||||
// aliases = {"$"},
|
||||
// desc = "Set the biome"
|
||||
//)
|
||||
// public Pattern biome(Actor actor, LocalSession session, Extent extent, BiomeType biome) {
|
||||
//
|
||||
// return new BiomePattern(extent, biome);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#relative",
|
||||
// aliases = {"#~", "#r", "#rel"},
|
||||
// desc = "Offset the pattern to where you click"
|
||||
//)
|
||||
// public Pattern relative(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
|
||||
//
|
||||
// return new RelativePattern(pattern);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#!x",
|
||||
// aliases = {"#nx", "#nox"},
|
||||
// desc = "The pattern will not be provided the x axis info",
|
||||
// descFooter = "The pattern will not be provided the z axis info.\n" +
|
||||
// "Example: #!x[#!z[#~[#l3d[pattern]]]]"
|
||||
//)
|
||||
// public Pattern nox(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
|
||||
//
|
||||
// return new NoXPattern(pattern);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#!y",
|
||||
// aliases = {"#ny", "#noy"},
|
||||
// desc = "The pattern will not be provided the y axis info"
|
||||
//)
|
||||
// public Pattern noy(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
|
||||
//
|
||||
// return new NoYPattern(pattern);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#!z",
|
||||
// aliases = {"#nz", "#noz"},
|
||||
// desc = "The pattern will not be provided the z axis info"
|
||||
//)
|
||||
// public Pattern noz(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
|
||||
//
|
||||
// return new NoZPattern(pattern);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#mask",
|
||||
// desc = "Apply a pattern depending on a mask"
|
||||
//)
|
||||
// public Pattern mask(Actor actor, LocalSession session, Mask mask, Pattern pass, Pattern fail) {
|
||||
// return new MaskedPattern(mask, pass, fail);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#offset",
|
||||
// desc = "Offset a pattern"
|
||||
//)
|
||||
// public Pattern offset(Actor actor, LocalSession session, double x, double y, double z, Pattern pattern) {
|
||||
//
|
||||
// return new OffsetPattern(pattern, (int) x, (int) y, (int) z);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#surfacespread",
|
||||
// desc = "Applies to only blocks on a surface. Selects a block from provided pattern with a given ranomized offset `[0, <distance>)`. e.g. Use `#existing` to randomly offset blocks in the world, or `#copy` to offset blocks in your clipboard"
|
||||
//)
|
||||
// public Pattern surfacespread(Actor actor, LocalSession session, double distance, Pattern pattern) {
|
||||
//
|
||||
// return new SurfaceRandomOffsetPattern(pattern, (int) distance);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#solidspread",
|
||||
// desc = "Randomly spread solid blocks"
|
||||
//)
|
||||
// public Pattern solidspread(Actor actor, LocalSession session, double x, double y, double z, Pattern pattern) {
|
||||
//
|
||||
// return new SolidRandomOffsetPattern(pattern, (int) x, (int) y, (int) z);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#spread",
|
||||
// aliases = {"#randomoffset"},
|
||||
// desc = "Randomly spread blocks"
|
||||
//)
|
||||
// public Pattern spread(Actor actor, LocalSession session, double x, double y, double z, Pattern pattern) {
|
||||
//
|
||||
// return new RandomOffsetPattern(pattern, (int) x, (int) y, (int) z);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#linear",
|
||||
// aliases = {"#l"},
|
||||
// desc = "Sequentially set blocks from a list of patterns"
|
||||
//)
|
||||
// public Pattern linear(Actor actor, LocalSession session, Pattern other) {
|
||||
//
|
||||
// if (other instanceof RandomPattern) {
|
||||
// Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
|
||||
// return new LinearBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
|
||||
// }
|
||||
// return other;
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#linear3d",
|
||||
// aliases = {"#l3d"},
|
||||
// desc = "Use the x,y,z coordinate to pick a block from the list"
|
||||
//)
|
||||
// public Pattern linear3d(Actor actor, LocalSession session, Pattern other) {
|
||||
//
|
||||
// if (other instanceof RandomPattern) {
|
||||
// Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
|
||||
// return new Linear3DBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
|
||||
// }
|
||||
// return other;
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#linear2d",
|
||||
// aliases = {"#l2d"},
|
||||
// desc = "Use the x,z coordinate to pick a block from the list"
|
||||
//)
|
||||
// public Pattern linear2d(Actor actor, LocalSession session, Pattern other) {
|
||||
//
|
||||
// if (other instanceof RandomPattern) {
|
||||
// Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
|
||||
// return new Linear2DBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
|
||||
// }
|
||||
// return other;
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "=",
|
||||
// aliases = {"#=", "#expression"},
|
||||
// desc = "Expression pattern: http://wiki.sk89q.com/wiki/WorldEdit/Expression_syntax"
|
||||
//)
|
||||
// public Pattern expression(Actor actor, LocalSession session, Extent extent, String input) throws ExpressionException {
|
||||
//
|
||||
// Expression exp = Expression.compile(input, "x", "y", "z");
|
||||
// WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment(extent, Vector3.ONE, Vector3.ZERO);
|
||||
// exp.setEnvironment(env);
|
||||
// return new ExpressionPattern(exp);
|
||||
// }
|
||||
//}
|
||||
@CommandContainer//(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class PatternCommands {
|
||||
|
||||
@Command(
|
||||
name = "#existing",
|
||||
aliases = {"#*", "*", ".*"},
|
||||
desc = "Use the block that is already there"
|
||||
)
|
||||
public Pattern existing(Extent extent, @Arg(name = "properties", desc = "String", def = "") String properties) { // TODO FIXME , @Arg(name = "properties", desc = "String", def = "") String properties
|
||||
if (properties == null) return new ExistingPattern(extent);
|
||||
return new PropertyPattern(extent).addRegex(".*[" + properties + "]");
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#clipboard",
|
||||
aliases = {"#copy"},
|
||||
desc = "Use the blocks in your clipboard as the pattern")
|
||||
public Pattern clipboard(LocalSession session) throws EmptyClipboardException {
|
||||
ClipboardHolder holder = session.getClipboard();
|
||||
Clipboard clipboard = holder.getClipboard();
|
||||
return new ClipboardPattern(clipboard);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#simplex",
|
||||
desc = "Use simplex noise to randomize blocks. Tutorial: https://imgur.com/a/rwVAE"
|
||||
)
|
||||
public Pattern simplex(@Arg(desc = "scale factor") double scale, @Arg(desc = "Pattern") Pattern other) {
|
||||
if (other instanceof RandomPattern) {
|
||||
scale = (1d / Math.max(1, scale));
|
||||
RandomCollection<Pattern> collection = ((RandomPattern) other).getCollection();
|
||||
collection.setRandom(new SimplexRandom(scale));
|
||||
}
|
||||
return other;
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#color",
|
||||
desc = "Use the block closest to a specific color"
|
||||
)
|
||||
public Pattern color(TextureUtil textureUtil, String color) {
|
||||
Color colorObj = ColorUtil.parseColor(color);
|
||||
return textureUtil.getNearestBlock(colorObj.getRGB()).getDefaultState();
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#anglecolor",
|
||||
desc = "A darker block based on the existing terrain angle"
|
||||
)
|
||||
public Pattern anglecolor(Extent extent, LocalSession session, @Arg(name = "distance", desc = "int", def = "1") int distanceOpt) {
|
||||
return new AngleColorPattern(extent, session, distanceOpt);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#angledata",
|
||||
desc = "Block data based on the existing terrain angle"
|
||||
)
|
||||
public Pattern angledata(Extent extent, @Arg(name = "distance", desc = "int", def = "1") int distanceOpt) {
|
||||
return new DataAnglePattern(extent, distanceOpt);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#saturate",
|
||||
desc = "Saturate the existing block with a color"
|
||||
)
|
||||
public Pattern saturate(Extent extent, LocalSession session, @Arg(desc = "Color code") String colorStr) {
|
||||
Color color = ColorUtil.parseColor(colorStr);
|
||||
return new SaturatePattern(extent, color.getRGB(), session);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#averagecolor",
|
||||
desc = "Average between the existing block and a color"
|
||||
)
|
||||
public Pattern averagecolor(Extent extent, LocalSession session, @Arg(desc = "Color code") String colorStr) {
|
||||
Color color = ColorUtil.parseColor(colorStr);
|
||||
return new AverageColorPattern(extent, color.getRGB(), session);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#desaturate",
|
||||
desc = "Desaturated color of the existing block"
|
||||
)
|
||||
public Pattern desaturate(Extent extent, LocalSession session, @Arg(name = "percent", desc = "double", def = "100") double percent) {
|
||||
return new DesaturatePattern(extent, percent / 100d, session);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#lighten",
|
||||
desc = "Lighten the existing block"
|
||||
)
|
||||
public Pattern lighten(Extent extent, TextureUtil util) {
|
||||
return new ShadePattern(extent, false, util);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#darken",
|
||||
desc = "Darken the existing block"
|
||||
)
|
||||
public Pattern darken(Extent extent, TextureUtil util) {
|
||||
return new ShadePattern(extent, true, util);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#fullcopy",
|
||||
desc = "Places your full clipboard at each block"
|
||||
)
|
||||
public Pattern fullcopy(Player player, Extent extent, LocalSession session, @Arg(name = "location", desc = "String", def = "#copy") String location, @Arg(name = "rotate", desc = "boolean", def = "false") boolean rotate, @Arg(name = "flip", desc = "boolean", def = "false") boolean flip) throws EmptyClipboardException, InputParseException, IOException {
|
||||
List<ClipboardHolder> clipboards;
|
||||
switch (location.toLowerCase()) {
|
||||
case "#copy":
|
||||
case "#clipboard":
|
||||
ClipboardHolder clipboard = session.getExistingClipboard();
|
||||
if (clipboard == null) {
|
||||
throw new InputParseException("To use #fullcopy, please first copy something to your clipboard");
|
||||
}
|
||||
if (!rotate && !flip) {
|
||||
return new FullClipboardPattern(extent, clipboard.getClipboard());
|
||||
}
|
||||
clipboards = Collections.singletonList(clipboard);
|
||||
break;
|
||||
default:
|
||||
MultiClipboardHolder multi = ClipboardFormats.loadAllFromInput(player, location, null, true);
|
||||
clipboards = multi != null ? multi.getHolders() : null;
|
||||
break;
|
||||
}
|
||||
if (clipboards == null) {
|
||||
throw new InputParseException("#fullcopy:<source>");
|
||||
}
|
||||
return new RandomFullClipboardPattern(extent, clipboards, rotate, flip);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#buffer",
|
||||
desc = "Only place a block once while a pattern is in use",
|
||||
descFooter = "Only place a block once while a pattern is in use\n" +
|
||||
"Use with a brush when you don't want to apply to the same spot twice"
|
||||
)
|
||||
public Pattern buffer(Actor actor, @Arg(desc = "Pattern")Pattern pattern) {
|
||||
return new BufferedPattern(actor, pattern);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#buffer2d",
|
||||
desc = "Only place a block once in a column while a pattern is in use"
|
||||
)
|
||||
public Pattern buffer2d(Actor actor, @Arg(desc = "Pattern")Pattern pattern) {
|
||||
return new BufferedPattern2D(actor, pattern);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#iddatamask",
|
||||
desc = "Use the pattern's id and the existing blocks data with the provided mask",
|
||||
descFooter = "Use the pattern's id and the existing blocks data with the provided mask\n" +
|
||||
" - Use to replace slabs or where the data values needs to be shifted instead of set"
|
||||
)
|
||||
public Pattern iddatamask(Extent extent, @Range(min = 0, max = 15) @Arg(desc = "bit mask") int bitmask, @Arg(desc = "Pattern")Pattern pattern) {
|
||||
|
||||
return new IdDataMaskPattern(extent, pattern, bitmask);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#id",
|
||||
desc = "Only change the block id"
|
||||
)
|
||||
public Pattern id(Extent extent, @Arg(desc = "Pattern")Pattern pattern) {
|
||||
|
||||
return new IdPattern(extent, pattern);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#data",
|
||||
desc = "Only change the block data"
|
||||
)
|
||||
public Pattern data(Extent extent, @Arg(desc = "Pattern")Pattern pattern) {
|
||||
|
||||
return new DataPattern(extent, pattern);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#biome",
|
||||
aliases = {"$"},
|
||||
desc = "Set the biome"
|
||||
)
|
||||
public Pattern biome(Extent extent, @Arg(desc = "Biome type") BiomeType biome) {
|
||||
|
||||
return new BiomePattern(extent, biome);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#relative",
|
||||
aliases = {"#~", "#r", "#rel"},
|
||||
desc = "Offset the pattern to where you click"
|
||||
)
|
||||
public Pattern relative(@Arg(desc = "Pattern")Pattern pattern) {
|
||||
|
||||
return new RelativePattern(pattern);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#!x",
|
||||
aliases = {"#nx", "#nox"},
|
||||
desc = "The pattern will not be provided the x axis info",
|
||||
descFooter = "The pattern will not be provided the z axis info.\n" +
|
||||
"Example: #!x[#!z[#~[#l3d[pattern]]]]"
|
||||
)
|
||||
public Pattern nox(@Arg(desc = "Pattern")Pattern pattern) {
|
||||
|
||||
return new NoXPattern(pattern);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#!y",
|
||||
aliases = {"#ny", "#noy"},
|
||||
desc = "The pattern will not be provided the y axis info"
|
||||
)
|
||||
public Pattern noy(@Arg(desc = "Pattern")Pattern pattern) {
|
||||
|
||||
return new NoYPattern(pattern);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#!z",
|
||||
aliases = {"#nz", "#noz"},
|
||||
desc = "The pattern will not be provided the z axis info"
|
||||
)
|
||||
public Pattern noz(@Arg(desc = "Pattern")Pattern pattern) {
|
||||
|
||||
return new NoZPattern(pattern);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#mask",
|
||||
desc = "Apply a pattern depending on a mask"
|
||||
)
|
||||
public Pattern mask(@Arg(desc = "Mask") Mask mask, @Arg(desc = "Pattern")Pattern pass, @Arg(desc = "Pattern")Pattern fail) {
|
||||
return new MaskedPattern(mask, pass, fail);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#offset",
|
||||
desc = "Offset a pattern"
|
||||
)
|
||||
public Pattern offset(@Arg(name = "x", desc = "x offset") double x, @Arg(name = "y", desc = "y offset") double y, @Arg(name = "z", desc = "z offset") double z, @Arg(desc = "Pattern")Pattern pattern) {
|
||||
|
||||
return new OffsetPattern(pattern, (int) x, (int) y, (int) z);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#surfacespread",
|
||||
desc = "Applies to only blocks on a surface. Selects a block from provided pattern with a given ranomized offset `[0, <distance>)`. e.g. Use `#existing` to randomly offset blocks in the world, or `#copy` to offset blocks in your clipboard"
|
||||
)
|
||||
public Pattern surfacespread(@Arg(desc = "spread distance (blocks)") double distance, @Arg(desc = "Pattern")Pattern pattern) {
|
||||
|
||||
return new SurfaceRandomOffsetPattern(pattern, (int) distance);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#solidspread",
|
||||
desc = "Randomly spread solid blocks"
|
||||
)
|
||||
public Pattern solidspread(@Arg(name = "x", desc = "x offset") double x, @Arg(name = "y", desc = "y offset") double y, @Arg(name = "z", desc = "z offset") double z, @Arg(desc = "Pattern")Pattern pattern) {
|
||||
|
||||
return new SolidRandomOffsetPattern(pattern, (int) x, (int) y, (int) z);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#spread",
|
||||
aliases = {"#randomoffset"},
|
||||
desc = "Randomly spread blocks"
|
||||
)
|
||||
public Pattern spread(@Arg(name = "x", desc = "x offset") double x, @Arg(name = "y", desc = "y offset") double y, @Arg(name = "z", desc = "z offset") double z, @Arg(desc = "Pattern")Pattern pattern) {
|
||||
|
||||
return new RandomOffsetPattern(pattern, (int) x, (int) y, (int) z);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#linear",
|
||||
aliases = {"#l"},
|
||||
desc = "Sequentially set blocks from a list of patterns"
|
||||
)
|
||||
public Pattern linear(@Arg(desc = "Pattern") Pattern other) {
|
||||
|
||||
if (other instanceof RandomPattern) {
|
||||
Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
|
||||
return new LinearBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
|
||||
}
|
||||
return other;
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#linear3d",
|
||||
aliases = {"#l3d"},
|
||||
desc = "Use the x,y,z coordinate to pick a block from the list"
|
||||
)
|
||||
public Pattern linear3d(@Arg(desc = "Pattern") Pattern other) {
|
||||
|
||||
if (other instanceof RandomPattern) {
|
||||
Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
|
||||
return new Linear3DBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
|
||||
}
|
||||
return other;
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#linear2d",
|
||||
aliases = {"#l2d"},
|
||||
desc = "Use the x,z coordinate to pick a block from the list"
|
||||
)
|
||||
public Pattern linear2d(@Arg(desc = "Pattern") Pattern other) {
|
||||
|
||||
if (other instanceof RandomPattern) {
|
||||
Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
|
||||
return new Linear2DBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
|
||||
}
|
||||
return other;
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "=",
|
||||
aliases = {"#=", "#expression"},
|
||||
desc = "Expression pattern: http://wiki.sk89q.com/wiki/WorldEdit/Expression_syntax"
|
||||
)
|
||||
public Pattern expression(Extent extent, @Arg(desc = "Expression") String input) throws ExpressionException {
|
||||
|
||||
Expression exp = Expression.compile(input, "x", "y", "z");
|
||||
WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment(extent, Vector3.ONE, Vector3.ZERO);
|
||||
exp.setEnvironment(env);
|
||||
return new ExpressionPattern(exp);
|
||||
}
|
||||
}
|
||||
|
@ -168,6 +168,7 @@ public class RegionCommands {
|
||||
|
||||
@Command(
|
||||
name = "/nbtinfo",
|
||||
aliases = "/nbt",
|
||||
desc = "View nbt info for a block"
|
||||
)
|
||||
@CommandPermissions("worldedit.nbtinfo")
|
||||
@ -266,7 +267,7 @@ public class RegionCommands {
|
||||
|
||||
@Command(
|
||||
name = "/replace",
|
||||
aliases = { "/re", "/rep" },
|
||||
aliases = { "/re", "/rep", "/r" },
|
||||
desc = "Replace all blocks in the selection with another"
|
||||
)
|
||||
@CommandPermissions("worldedit.region.replace")
|
||||
|
@ -98,6 +98,7 @@ public class SelectionCommands {
|
||||
|
||||
@Command(
|
||||
name = "/pos1",
|
||||
aliases = "/1",
|
||||
desc = "Set position 1"
|
||||
)
|
||||
@Logging(POSITION)
|
||||
@ -126,6 +127,7 @@ public class SelectionCommands {
|
||||
|
||||
@Command(
|
||||
name = "/pos2",
|
||||
aliases = "/2",
|
||||
desc = "Set position 2"
|
||||
)
|
||||
@Logging(POSITION)
|
||||
@ -261,6 +263,7 @@ public class SelectionCommands {
|
||||
@CommandPermissions("worldedit.wand")
|
||||
public void wand(Player player, LocalSession session,
|
||||
@Switch(name = 'n', desc = "Get a navigation wand") boolean navWand) throws WorldEditException {
|
||||
session.loadDefaults(player, true);
|
||||
String wandId = navWand ? session.getNavWandItem() : session.getWandItem();
|
||||
if (wandId == null) {
|
||||
wandId = navWand ? we.getConfiguration().navigationWand : we.getConfiguration().wandItem;
|
||||
@ -272,10 +275,10 @@ public class SelectionCommands {
|
||||
}
|
||||
player.giveItem(new BaseItemStack(itemType, 1));
|
||||
if (navWand) {
|
||||
session.setTool(itemType, new NavigationWand());
|
||||
session.setTool(itemType, NavigationWand.INSTANCE);
|
||||
player.print("Left click: jump to location; Right click: pass through walls");
|
||||
} else {
|
||||
session.setTool(itemType, new SelectionWand());
|
||||
session.setTool(itemType, SelectionWand.INSTANCE);
|
||||
player.print(BBC.SELECTION_WAND.s());
|
||||
}
|
||||
if (!player.hasPermission("fawe.tips"))
|
||||
|
@ -20,19 +20,29 @@
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.object.brush.BrushSettings;
|
||||
import com.boydti.fawe.object.brush.InspectBrush;
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.boydti.fawe.object.brush.TargetMode;
|
||||
import com.boydti.fawe.object.brush.scroll.ScrollAction;
|
||||
import com.boydti.fawe.object.brush.visualization.VisualMode;
|
||||
import com.boydti.fawe.object.extent.ResettableExtent;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.command.argument.Arguments;
|
||||
import com.sk89q.worldedit.command.tool.BlockDataCyler;
|
||||
import com.sk89q.worldedit.command.tool.BlockReplacer;
|
||||
import com.sk89q.worldedit.command.tool.BrushTool;
|
||||
import com.sk89q.worldedit.command.tool.DistanceWand;
|
||||
import com.sk89q.worldedit.command.tool.FloatingTreeRemover;
|
||||
import com.sk89q.worldedit.command.tool.FloodFillTool;
|
||||
import com.sk89q.worldedit.command.tool.InvalidToolBindException;
|
||||
import com.sk89q.worldedit.command.tool.LongRangeBuildTool;
|
||||
import com.sk89q.worldedit.command.tool.NavigationWand;
|
||||
import com.sk89q.worldedit.command.tool.QueryTool;
|
||||
@ -41,94 +51,25 @@ import com.sk89q.worldedit.command.tool.TreePlanter;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.event.platform.CommandEvent;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.internal.command.CommandRegistrationHandler;
|
||||
import com.sk89q.worldedit.internal.command.CommandUtil;
|
||||
import com.sk89q.worldedit.command.ToolCommandsRegistration;
|
||||
import com.sk89q.worldedit.internal.annotation.Range;
|
||||
import com.sk89q.worldedit.internal.command.CommandArgParser;
|
||||
import com.sk89q.worldedit.internal.expression.Expression;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import org.enginehub.piston.CommandManager;
|
||||
import org.enginehub.piston.CommandManagerService;
|
||||
import org.enginehub.piston.CommandMetadata;
|
||||
import org.enginehub.piston.CommandParameters;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
import org.enginehub.piston.part.SubCommandPart;
|
||||
import org.enginehub.piston.annotation.param.Switch;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class ToolCommands {
|
||||
|
||||
public static void register(CommandRegistrationHandler registration,
|
||||
CommandManager commandManager,
|
||||
CommandManagerService commandManagerService,
|
||||
WorldEdit worldEdit) {
|
||||
// Collect the tool commands
|
||||
CommandManager collect = commandManagerService.newCommandManager();
|
||||
|
||||
registration.register(
|
||||
collect,
|
||||
ToolCommandsRegistration.builder(),
|
||||
new ToolCommands(worldEdit)
|
||||
);
|
||||
|
||||
// Register deprecated global commands
|
||||
Set<org.enginehub.piston.Command> commands = collect.getAllCommands()
|
||||
.collect(Collectors.toSet());
|
||||
for (org.enginehub.piston.Command command : commands) {
|
||||
if (command.getAliases().contains("unbind")) {
|
||||
// Don't register new /tool unbind alias
|
||||
command = command.toBuilder().aliases(
|
||||
Collections2.filter(command.getAliases(), alias -> !"unbind".equals(alias))
|
||||
).build();
|
||||
}
|
||||
commandManager.register(CommandUtil.deprecate(
|
||||
command, "Global tool names cause conflicts " +
|
||||
"and will be removed in WorldEdit 8", ToolCommands::asNonGlobal
|
||||
));
|
||||
}
|
||||
|
||||
// Remove aliases with / in them, since it doesn't make sense for sub-commands.
|
||||
Set<org.enginehub.piston.Command> nonGlobalCommands = commands.stream()
|
||||
.map(command ->
|
||||
command.toBuilder().aliases(
|
||||
Collections2.filter(command.getAliases(), alias -> !alias.startsWith("/"))
|
||||
).build()
|
||||
)
|
||||
.collect(Collectors.toSet());
|
||||
commandManager.register("tool", command -> {
|
||||
command.addPart(SubCommandPart.builder(
|
||||
TranslatableComponent.of("tool"),
|
||||
TextComponent.of("The tool to bind")
|
||||
)
|
||||
.withCommands(nonGlobalCommands)
|
||||
.required()
|
||||
.build());
|
||||
command.description(TextComponent.of("Binds a tool to the item in your hand"));
|
||||
});
|
||||
}
|
||||
|
||||
private static String asNonGlobal(org.enginehub.piston.Command oldCommand,
|
||||
CommandParameters oldParameters) {
|
||||
String name = Optional.ofNullable(oldParameters.getMetadata())
|
||||
.map(CommandMetadata::getCalledName)
|
||||
.filter(n -> !n.startsWith("/"))
|
||||
.orElseGet(oldCommand::getName);
|
||||
return "/tool " + name;
|
||||
}
|
||||
|
||||
static void setToolNone(Player player, LocalSession session, String type)
|
||||
throws InvalidToolBindException {
|
||||
session.setTool(player.getItemInHand(HandSide.MAIN_HAND).getType(), null);
|
||||
player.print(type + " unbound from your current item.");
|
||||
}
|
||||
|
||||
private final WorldEdit we;
|
||||
|
||||
public ToolCommands(WorldEdit we) {
|
||||
@ -154,7 +95,7 @@ public class ToolCommands {
|
||||
public void selwand(Player player, LocalSession session) throws WorldEditException {
|
||||
|
||||
final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
|
||||
session.setTool(player, new SelectionWand());
|
||||
session.setTool(player, SelectionWand.INSTANCE);
|
||||
player.print("Selection wand bound to " + itemType.getName() + ".");
|
||||
}
|
||||
|
||||
@ -167,7 +108,7 @@ public class ToolCommands {
|
||||
public void navwand(Player player, LocalSession session) throws WorldEditException {
|
||||
|
||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
session.setTool(player, new NavigationWand());
|
||||
session.setTool(player, NavigationWand.INSTANCE);
|
||||
player.print("Navigation wand bound to " + itemStack.getType().getName() + ".");
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,6 @@ public class ToolUtilCommands {
|
||||
}
|
||||
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
|
||||
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
|
||||
System.out.println(lastArg + " TODO check this is not the whole command");
|
||||
settings.addSetting(BrushSettings.SettingType.MASK, lastArg);
|
||||
settings.setMask(maskOpt);
|
||||
tool.update();
|
||||
|
@ -1,104 +1,104 @@
|
||||
//package com.sk89q.worldedit.command;
|
||||
//
|
||||
//import com.boydti.fawe.object.extent.Linear3DTransform;
|
||||
//import com.boydti.fawe.object.extent.LinearTransform;
|
||||
//import com.boydti.fawe.object.extent.OffsetExtent;
|
||||
//import com.boydti.fawe.object.extent.PatternTransform;
|
||||
//import com.boydti.fawe.object.extent.RandomOffsetTransform;
|
||||
//import com.boydti.fawe.object.extent.RandomTransform;
|
||||
//import com.boydti.fawe.object.extent.ResettableExtent;
|
||||
//import com.boydti.fawe.object.extent.ScaleTransform;
|
||||
//import com.boydti.fawe.object.extent.TransformExtent;
|
||||
//import com.boydti.fawe.util.ExtentTraverser;
|
||||
//import com.sk89q.worldedit.LocalSession;
|
||||
//import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
//import com.sk89q.worldedit.entity.Player;
|
||||
//import com.sk89q.worldedit.extension.platform.Actor;
|
||||
//import com.sk89q.worldedit.extent.transform.BlockTransformExtent;
|
||||
//import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
//import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
//import java.util.Set;
|
||||
//import org.enginehub.piston.annotation.Command;
|
||||
//import org.enginehub.piston.annotation.CommandContainer;
|
||||
//import org.enginehub.piston.annotation.param.Arg;
|
||||
//
|
||||
//@CommandContainer//(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
//public class TransformCommands {
|
||||
//
|
||||
// @Command(
|
||||
// name = "#linear",
|
||||
// aliases = {"#l"},
|
||||
// desc = "Sequentially pick from a list of transform"
|
||||
// )
|
||||
// public ResettableExtent linear(Actor actor, LocalSession session, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
// if (other instanceof RandomTransform) {
|
||||
// Set<ResettableExtent> extents = ((RandomTransform) other).getExtents();
|
||||
// return new LinearTransform(extents.toArray(new ResettableExtent[0]));
|
||||
// }
|
||||
// return other;
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#linear3d",
|
||||
// aliases = {"#l3d"},
|
||||
// desc = "Use the x,y,z coordinate to pick a transform from the list"
|
||||
// )
|
||||
// public ResettableExtent linear3d(Actor actor, LocalSession session, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
// if (other instanceof RandomTransform) {
|
||||
// Set<ResettableExtent> extents = ((RandomTransform) other).getExtents();
|
||||
// return new Linear3DTransform(extents.toArray(new ResettableExtent[0]));
|
||||
// }
|
||||
// return other;
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#pattern",
|
||||
// desc = "Always use a specific pattern"
|
||||
// )
|
||||
// public ResettableExtent pattern(Actor actor, LocalSession session, Pattern pattern, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
// return new PatternTransform(other, pattern);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#offset",
|
||||
// desc = "Offset transform"
|
||||
// )
|
||||
// public ResettableExtent offset(Actor actor, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
// return new OffsetExtent(other, (int) x, (int) y, (int) z);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#spread",
|
||||
// aliases = {"#randomoffset"},
|
||||
// desc = "Random offset transform"
|
||||
//)
|
||||
// public ResettableExtent randomOffset(Actor actor, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
// return new RandomOffsetTransform(other, (int) x, (int) y, (int) z);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#scale",
|
||||
// desc = "All changes will be scaled"
|
||||
// )
|
||||
// public ResettableExtent scale(Actor actor, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
// return new ScaleTransform(other, x, y, z);
|
||||
// }
|
||||
//
|
||||
// @Command(
|
||||
// name = "#rotate",
|
||||
// desc = "All changes will be rotate around the initial position"
|
||||
// )
|
||||
// public ResettableExtent rotate(Player player, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
// ExtentTraverser<TransformExtent> traverser = new ExtentTraverser<>(other).find(TransformExtent.class);
|
||||
// BlockTransformExtent affine = traverser != null ? traverser.get() : null;
|
||||
// if (affine == null) {
|
||||
// other = affine = new TransformExtent(other);
|
||||
// }
|
||||
// AffineTransform transform = (AffineTransform) affine.getTransform();
|
||||
// transform = transform.rotateX(x);
|
||||
// transform = transform.rotateY(y);
|
||||
// transform = transform.rotateZ(z);
|
||||
// affine.setTransform(transform);
|
||||
// return other;
|
||||
// }
|
||||
//}
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import com.boydti.fawe.object.extent.Linear3DTransform;
|
||||
import com.boydti.fawe.object.extent.LinearTransform;
|
||||
import com.boydti.fawe.object.extent.OffsetExtent;
|
||||
import com.boydti.fawe.object.extent.PatternTransform;
|
||||
import com.boydti.fawe.object.extent.RandomOffsetTransform;
|
||||
import com.boydti.fawe.object.extent.RandomTransform;
|
||||
import com.boydti.fawe.object.extent.ResettableExtent;
|
||||
import com.boydti.fawe.object.extent.ScaleTransform;
|
||||
import com.boydti.fawe.object.extent.TransformExtent;
|
||||
import com.boydti.fawe.util.ExtentTraverser;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extent.transform.BlockTransformExtent;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import java.util.Set;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
|
||||
@CommandContainer//(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class TransformCommands {
|
||||
|
||||
@Command(
|
||||
name = "#linear",
|
||||
aliases = {"#l"},
|
||||
desc = "Sequentially pick from a list of transform"
|
||||
)
|
||||
public ResettableExtent linear(Actor actor, LocalSession session, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
if (other instanceof RandomTransform) {
|
||||
Set<ResettableExtent> extents = ((RandomTransform) other).getExtents();
|
||||
return new LinearTransform(extents.toArray(new ResettableExtent[0]));
|
||||
}
|
||||
return other;
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#linear3d",
|
||||
aliases = {"#l3d"},
|
||||
desc = "Use the x,y,z coordinate to pick a transform from the list"
|
||||
)
|
||||
public ResettableExtent linear3d(Actor actor, LocalSession session, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
if (other instanceof RandomTransform) {
|
||||
Set<ResettableExtent> extents = ((RandomTransform) other).getExtents();
|
||||
return new Linear3DTransform(extents.toArray(new ResettableExtent[0]));
|
||||
}
|
||||
return other;
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#pattern",
|
||||
desc = "Always use a specific pattern"
|
||||
)
|
||||
public ResettableExtent pattern(Actor actor, LocalSession session, Pattern pattern, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
return new PatternTransform(other, pattern);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#offset",
|
||||
desc = "Offset transform"
|
||||
)
|
||||
public ResettableExtent offset(Actor actor, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
return new OffsetExtent(other, (int) x, (int) y, (int) z);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#spread",
|
||||
aliases = {"#randomoffset"},
|
||||
desc = "Random offset transform"
|
||||
)
|
||||
public ResettableExtent randomOffset(Actor actor, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
return new RandomOffsetTransform(other, (int) x, (int) y, (int) z);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#scale",
|
||||
desc = "All changes will be scaled"
|
||||
)
|
||||
public ResettableExtent scale(Actor actor, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
return new ScaleTransform(other, x, y, z);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#rotate",
|
||||
desc = "All changes will be rotate around the initial position"
|
||||
)
|
||||
public ResettableExtent rotate(Player player, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||
ExtentTraverser<TransformExtent> traverser = new ExtentTraverser<>(other).find(TransformExtent.class);
|
||||
BlockTransformExtent affine = traverser != null ? traverser.get() : null;
|
||||
if (affine == null) {
|
||||
other = affine = new TransformExtent(other);
|
||||
}
|
||||
AffineTransform transform = (AffineTransform) affine.getTransform();
|
||||
transform = transform.rotateX(x);
|
||||
transform = transform.rotateY(y);
|
||||
transform = transform.rotateZ(z);
|
||||
affine.setTransform(transform);
|
||||
return other;
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.command.util.CommandQueued;
|
||||
import com.sk89q.worldedit.command.util.SkipQueue;
|
||||
import com.sk89q.worldedit.command.util.CreatureButcher;
|
||||
import com.sk89q.worldedit.command.util.EntityRemover;
|
||||
import com.sk89q.worldedit.command.util.Logging;
|
||||
@ -51,7 +51,6 @@ import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
||||
import com.sk89q.worldedit.function.EntityFunction;
|
||||
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
||||
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
@ -174,7 +173,7 @@ public class UtilityCommands {
|
||||
desc = "Cancel your current command"
|
||||
)
|
||||
@CommandPermissions("fawe.cancel")
|
||||
@CommandQueued(false)
|
||||
@SkipQueue
|
||||
public void cancel(Player fp) {
|
||||
int cancelled = fp.cancel(false);
|
||||
BBC.WORLDEDIT_CANCEL_COUNT.send(fp, cancelled);
|
||||
@ -523,7 +522,7 @@ public class UtilityCommands {
|
||||
int size = radius != null ? Math.max(1, radius) : defaultRadius;
|
||||
we.checkMaxRadius(size);
|
||||
|
||||
Mask mask = new BlockTypeMask(editSession, BlockTypes.FIRE);
|
||||
Mask mask = BlockTypes.FIRE.toMask();
|
||||
int affected = editSession.removeNear(session.getPlacementPosition(actor), mask, size);
|
||||
BBC.VISITOR_BLOCK.send(actor, affected);
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.command.util.CommandQueued;
|
||||
import com.sk89q.worldedit.command.util.SkipQueue;
|
||||
import com.sk89q.worldedit.command.util.CommandQueuedConditionGenerator;
|
||||
import com.sk89q.worldedit.command.util.PrintCommandHelp;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
@ -73,7 +73,7 @@ public class WorldEditCommands {
|
||||
aliases = { "ver" },
|
||||
desc = "Get WorldEdit/FAWE version"
|
||||
)
|
||||
@CommandQueued
|
||||
@SkipQueue
|
||||
public void version(Actor actor) {
|
||||
FaweVersion fVer = Fawe.get().getVersion();
|
||||
String fVerStr = fVer == null ? "unknown" : "-" + fVer.build;
|
||||
@ -128,7 +128,7 @@ public class WorldEditCommands {
|
||||
aliases = { "debugpaste" },
|
||||
desc = "Writes a report of latest.log, config.yml, message.yml https://athion.net/ISPaster/paste"
|
||||
)
|
||||
@CommandQueued
|
||||
@SkipQueue
|
||||
@CommandPermissions({"worldedit.report", "worldedit.debugpaste"})
|
||||
public void report(Actor actor) throws WorldEditException, IOException {
|
||||
BBC.DOWNLOAD_LINK.send(actor, IncendoPaster.debugPaste());
|
||||
@ -138,7 +138,7 @@ public class WorldEditCommands {
|
||||
name = "threads",
|
||||
desc = "Print all thread stacks"
|
||||
)
|
||||
@CommandQueued
|
||||
@SkipQueue
|
||||
@CommandPermissions("worldedit.threads")
|
||||
public void threads(Actor actor) throws WorldEditException {
|
||||
Map<Thread, StackTraceElement[]> stacks = Thread.getAllStackTraces();
|
||||
@ -188,7 +188,7 @@ public class WorldEditCommands {
|
||||
name = "help",
|
||||
desc = "Displays help for FAWE commands"
|
||||
)
|
||||
@CommandQueued
|
||||
@SkipQueue
|
||||
@CommandPermissions("worldedit.help")
|
||||
public void help(Actor actor,
|
||||
@Switch(name = 's', desc = "List sub-commands of the given command, if applicable")
|
||||
|
@ -91,6 +91,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
||||
}
|
||||
|
||||
protected static int MAX_RANGE = 500;
|
||||
protected static int DEFAULT_RANGE = 240; // 500 is laggy as the default
|
||||
protected int range = -1;
|
||||
private VisualMode visualMode = VisualMode.NONE;
|
||||
private TargetMode targetMode = TargetMode.TARGET_BLOCK_RANGE;
|
||||
@ -177,7 +178,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
||||
if (targetMode != TargetMode.TARGET_BLOCK_RANGE) {
|
||||
map.put("target", targetMode);
|
||||
}
|
||||
if (range != -1 && range != MAX_RANGE) {
|
||||
if (range != -1 && range != DEFAULT_RANGE) {
|
||||
map.put("range", range);
|
||||
}
|
||||
if (targetOffset != 0) {
|
||||
@ -408,7 +409,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
||||
* @return the range of the brush in blocks
|
||||
*/
|
||||
public int getRange() {
|
||||
return (range < 0) ? MAX_RANGE : Math.min(range, MAX_RANGE);
|
||||
return (range < 0) ? DEFAULT_RANGE : Math.min(range, MAX_RANGE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -74,8 +74,9 @@ public class DistanceWand extends BrushTool implements DoubleActionTraceTool {
|
||||
private Location getTarget(Player player) {
|
||||
Location target;
|
||||
Mask mask = getTraceMask();
|
||||
if (this.range > -1) {
|
||||
target = player.getBlockTrace(getRange(), true, mask);
|
||||
int range = getRange();
|
||||
if (range < MAX_RANGE) {
|
||||
target = player.getBlockTrace(range, true, mask);
|
||||
} else {
|
||||
target = player.getBlockTrace(MAX_RANGE, false, mask);
|
||||
}
|
||||
|
@ -26,30 +26,26 @@ import com.sk89q.worldedit.extension.platform.Actor;
|
||||
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;
|
||||
}
|
||||
public enum NavigationWand implements DoubleActionTraceTool {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
||||
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;
|
||||
@ -63,6 +59,6 @@ public class NavigationWand implements DoubleActionTraceTool {
|
||||
|
||||
@Override
|
||||
public boolean canUse(Actor actor) {
|
||||
return true; // skip check here - checked separately for primary/secondary
|
||||
return actor.hasPermission("worldedit.navigation.jumpto.tool"); // check should be here
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,8 @@ import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
|
||||
public class SelectionWand implements DoubleActionBlockTool {
|
||||
public enum SelectionWand implements DoubleActionBlockTool {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
|
||||
|
@ -34,4 +34,4 @@ public class SphereBrush implements Brush {
|
||||
}
|
||||
editSession.makeSphere(position, pattern, size, size, size, true);
|
||||
}
|
||||
}
|
||||
}
|
@ -7,14 +7,14 @@ import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
* Dummy class
|
||||
*/
|
||||
public class CommandQueuedCondition implements Command.Condition {
|
||||
private final boolean value;
|
||||
private final boolean isQueued;
|
||||
|
||||
public CommandQueuedCondition(boolean value) {
|
||||
this.value = value;
|
||||
public CommandQueuedCondition(boolean isQueued) {
|
||||
this.isQueued = isQueued;
|
||||
}
|
||||
|
||||
public boolean isQueued() {
|
||||
return value;
|
||||
return isQueued;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -17,10 +17,10 @@ public final class CommandQueuedConditionGenerator implements CommandConditionGe
|
||||
|
||||
@Override
|
||||
public Command.Condition generateCondition(Method commandMethod) {
|
||||
CommandQueued annotation = commandMethod.getAnnotation(CommandQueued.class);
|
||||
if (annotation == null) {
|
||||
SkipQueue skip = commandMethod.getAnnotation(SkipQueue.class);
|
||||
if (skip == null) {
|
||||
return Command.Condition.TRUE;
|
||||
}
|
||||
return new CommandQueuedCondition(annotation.value());
|
||||
return new CommandQueuedCondition(!skip.value());
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public class DelegateCommandManager implements CommandManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int execute(InjectedValueAccess context, List<String> args) {
|
||||
public Object execute(InjectedValueAccess context, List<String> args) {
|
||||
return parent.execute(context, args);
|
||||
}
|
||||
|
||||
|
@ -21,4 +21,4 @@ package com.sk89q.worldedit.command.util;
|
||||
|
||||
public enum HookMode {
|
||||
ACTIVE, INACTIVE
|
||||
}
|
||||
}
|
@ -24,6 +24,8 @@ import org.enginehub.piston.Command;
|
||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
import org.enginehub.piston.inject.Key;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
public class PermissionCondition implements Command.Condition {
|
||||
|
@ -10,6 +10,6 @@ import java.lang.annotation.RetentionPolicy;
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@CommandCondition(CommandQueuedConditionGenerator.class)
|
||||
public @interface CommandQueued {
|
||||
boolean value() default false;
|
||||
public @interface SkipQueue {
|
||||
boolean value() default true;
|
||||
}
|
Reference in New Issue
Block a user