Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-25 02:20:07 +01:00
Added support for type/data to //generate.
Dieser Commit ist enthalten in:
Ursprung
8a83f7f70e
Commit
478d6f6e54
@ -28,6 +28,7 @@ import com.sk89q.worldedit.*;
|
|||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.expression.Expression;
|
import com.sk89q.worldedit.expression.Expression;
|
||||||
import com.sk89q.worldedit.expression.ExpressionException;
|
import com.sk89q.worldedit.expression.ExpressionException;
|
||||||
|
import com.sk89q.worldedit.expression.runtime.LValue;
|
||||||
import com.sk89q.worldedit.patterns.Pattern;
|
import com.sk89q.worldedit.patterns.Pattern;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.util.TreeGenerator;
|
import com.sk89q.worldedit.util.TreeGenerator;
|
||||||
@ -304,7 +305,7 @@ public class GenerationCommands {
|
|||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "/generate", "/gen", "/g" },
|
aliases = { "/generate", "/gen", "/g" },
|
||||||
usage = "<block> <equation>",
|
usage = "<block> <expression>",
|
||||||
desc = "Generates a shape according to a formula. -h for hollow, -r for raw coordinates, -o for unscaled, but offset from placement",
|
desc = "Generates a shape according to a formula. -h for hollow, -r for raw coordinates, -o for unscaled, but offset from placement",
|
||||||
flags = "hro",
|
flags = "hro",
|
||||||
min = 1,
|
min = 1,
|
||||||
@ -321,13 +322,16 @@ public class GenerationCommands {
|
|||||||
|
|
||||||
final Expression expression;
|
final Expression expression;
|
||||||
try {
|
try {
|
||||||
expression = Expression.compile(args.getJoinedStrings(1), "x", "y", "z");
|
expression = Expression.compile(args.getJoinedStrings(1), "x", "y", "z", "type", "data");
|
||||||
expression.optimize();
|
expression.optimize();
|
||||||
} catch (ExpressionException e) {
|
} catch (ExpressionException e) {
|
||||||
player.printError(e.getMessage());
|
player.printError(e.getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final LValue typeVariable = (LValue) expression.getVariable("type");
|
||||||
|
final LValue dataVariable = (LValue) expression.getVariable("data");
|
||||||
|
|
||||||
final ArbitraryShape shape;
|
final ArbitraryShape shape;
|
||||||
|
|
||||||
if (args.hasFlag('r')) {
|
if (args.hasFlag('r')) {
|
||||||
@ -335,7 +339,14 @@ public class GenerationCommands {
|
|||||||
@Override
|
@Override
|
||||||
protected BaseBlock getMaterial(int x, int y, int z, BaseBlock defaultMaterial) {
|
protected BaseBlock getMaterial(int x, int y, int z, BaseBlock defaultMaterial) {
|
||||||
try {
|
try {
|
||||||
return expression.evaluate(x, y, z) > 0 ? defaultMaterial : null;
|
typeVariable.assign(defaultMaterial.getType());
|
||||||
|
dataVariable.assign(defaultMaterial.getData());
|
||||||
|
|
||||||
|
if (expression.evaluate(x, y, z) <= 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new BaseBlock((int)typeVariable.getValue(), (int)dataVariable.getValue());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
@ -353,7 +364,14 @@ public class GenerationCommands {
|
|||||||
@Override
|
@Override
|
||||||
protected BaseBlock getMaterial(int x, int y, int z, BaseBlock defaultMaterial) {
|
protected BaseBlock getMaterial(int x, int y, int z, BaseBlock defaultMaterial) {
|
||||||
try {
|
try {
|
||||||
return expression.evaluate(x - placementX, y - placementY, z - placementZ) > 0 ? defaultMaterial : null;
|
typeVariable.assign(defaultMaterial.getType());
|
||||||
|
dataVariable.assign(defaultMaterial.getData());
|
||||||
|
|
||||||
|
if (expression.evaluate(x - placementX, y - placementY, z - placementZ) <= 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new BaseBlock((int)typeVariable.getValue(), (int)dataVariable.getValue());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
@ -371,7 +389,14 @@ public class GenerationCommands {
|
|||||||
final Vector scaled = new Vector(x, y, z).subtract(center).divide(stretch);
|
final Vector scaled = new Vector(x, y, z).subtract(center).divide(stretch);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return expression.evaluate(scaled.getX(), scaled.getY(), scaled.getZ()) > 0 ? defaultMaterial : null;
|
typeVariable.assign(defaultMaterial.getType());
|
||||||
|
dataVariable.assign(defaultMaterial.getData());
|
||||||
|
|
||||||
|
if (expression.evaluate(scaled.getX(), scaled.getY(), scaled.getZ()) <= 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new BaseBlock((int)typeVariable.getValue(), (int)dataVariable.getValue());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren