wip on 1.14

This commit is contained in:
Jesse Boyd
2019-07-09 17:18:51 +10:00
229 changed files with 9489 additions and 3025 deletions

View File

@ -128,7 +128,7 @@ public class ClipboardCommands extends MethodCommands {
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
FaweLimit limit = FawePlayer.wrap(player).getLimit();
if (volume >= limit.MAX_CHECKS) {
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
throw FaweException.MAX_CHECKS;
}
session.setClipboard(null);
final BlockVector3 origin = region.getMinimumPoint();
@ -168,7 +168,7 @@ public class ClipboardCommands extends MethodCommands {
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
FaweLimit limit = FawePlayer.wrap(player).getLimit();
if (volume >= limit.MAX_CHECKS) {
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
throw FaweException.MAX_CHECKS;
}
BlockVector3 pos = session.getPlacementPosition(player);
fp.checkConfirmationRegion(() -> {
@ -218,10 +218,10 @@ public class ClipboardCommands extends MethodCommands {
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
FaweLimit limit = FawePlayer.wrap(player).getLimit();
if (volume >= limit.MAX_CHECKS) {
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
throw FaweException.MAX_CHECKS;
}
if (volume >= limit.MAX_CHANGES) {
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES);
throw FaweException.MAX_CHANGES;
}
session.setClipboard(null);
final BlockVector3 origin = region.getMinimumPoint();
@ -258,10 +258,10 @@ public class ClipboardCommands extends MethodCommands {
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
FaweLimit limit = FawePlayer.wrap(player).getLimit();
if (volume >= limit.MAX_CHECKS) {
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
throw FaweException.MAX_CHECKS;
}
if (volume >= limit.MAX_CHANGES) {
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES);
throw FaweException.MAX_CHANGES;
}
BlockVector3 pos = session.getPlacementPosition(player);
fp.checkConfirmationRegion(() -> {
@ -497,7 +497,7 @@ public class ClipboardCommands extends MethodCommands {
if (holder instanceof URIClipboardHolder) uri = ((URIClipboardHolder) holder).getURI(clipboard);
PasteEvent event = new PasteEvent(player, clipboard, uri, editSession, to);
worldEdit.getEventBus().post(event);
if (event.isCancelled()) throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MANUAL);
if (event.isCancelled()) throw FaweException.MANUAL;
}
@Command(

View File

@ -235,7 +235,7 @@ public class PatternCommands extends MethodCommands {
min = 2,
max = 2
)
public Pattern iddatamask(Actor actor, LocalSession session, Extent extent, @Range(min = 0, max = 15) int bitmask, Pattern pattern) {
public Pattern iddatamask(Extent extent, @Range(min = 0, max = 15) int bitmask, Pattern pattern) {
return new IdDataMaskPattern(extent, pattern, bitmask);
}
@ -246,7 +246,7 @@ public class PatternCommands extends MethodCommands {
min = 1,
max = 1
)
public Pattern id(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
public Pattern id(Extent extent, Pattern pattern) {
return new IdPattern(extent, pattern);
}
@ -257,7 +257,7 @@ public class PatternCommands extends MethodCommands {
min = 1,
max = 1
)
public Pattern data(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
public Pattern data(Extent extent, Pattern pattern) {
return new DataPattern(extent, pattern);
}
@ -268,7 +268,7 @@ public class PatternCommands extends MethodCommands {
min = 1,
max = 1
)
public Pattern biome(Actor actor, LocalSession session, Extent extent, BiomeType biome) {
public Pattern biome(Extent extent, BiomeType biome) {
return new BiomePattern(extent, biome);
}
@ -279,7 +279,7 @@ public class PatternCommands extends MethodCommands {
min = 1,
max = 1
)
public Pattern relative(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
public Pattern relative(Pattern pattern) {
return new RelativePattern(pattern);
}
@ -292,7 +292,7 @@ public class PatternCommands extends MethodCommands {
min = 1,
max = 1
)
public Pattern nox(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
public Pattern nox(Pattern pattern) {
return new NoXPattern(pattern);
}
@ -303,7 +303,7 @@ public class PatternCommands extends MethodCommands {
min = 1,
max = 1
)
public Pattern noy(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
public Pattern noy(Pattern pattern) {
return new NoYPattern(pattern);
}
@ -314,7 +314,7 @@ public class PatternCommands extends MethodCommands {
min = 1,
max = 1
)
public Pattern noz(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
public Pattern noz(Pattern pattern) {
return new NoZPattern(pattern);
}
@ -325,9 +325,8 @@ public class PatternCommands extends MethodCommands {
min = 3,
max = 3
)
public Pattern mask(Actor actor, LocalSession session, Mask mask, Pattern pass, Pattern fail) {
PatternExtent extent = new PatternExtent(pass);
return new MaskedPattern(mask, extent, fail);
public Pattern mask(Mask mask, Pattern pass, @Optional Pattern fail) {
return new MaskedPattern(mask, pass, fail);
}
@Command(
@ -337,7 +336,7 @@ public class PatternCommands extends MethodCommands {
min = 4,
max = 4
)
public Pattern offset(Actor actor, LocalSession session, double x, double y, double z, Pattern pattern) {
public Pattern offset(double x, double y, double z, Pattern pattern) {
return new OffsetPattern(pattern, (int) x, (int) y, (int) z);
}
@ -348,7 +347,7 @@ public class PatternCommands extends MethodCommands {
min = 2,
max = 2
)
public Pattern surfacespread(Actor actor, LocalSession session, double distance, Pattern pattern) {
public Pattern surfacespread(double distance, Pattern pattern) {
return new SurfaceRandomOffsetPattern(pattern, (int) distance);
}
@ -359,7 +358,7 @@ public class PatternCommands extends MethodCommands {
min = 4,
max = 4
)
public Pattern solidspread(Actor actor, LocalSession session, double x, double y, double z, Pattern pattern) {
public Pattern solidspread(double x, double y, double z, Pattern pattern) {
return new SolidRandomOffsetPattern(pattern, (int) x, (int) y, (int) z);
}
@ -370,7 +369,7 @@ public class PatternCommands extends MethodCommands {
min = 4,
max = 4
)
public Pattern spread(Actor actor, LocalSession session, double x, double y, double z, Pattern pattern) {
public Pattern spread(double x, double y, double z, Pattern pattern) {
return new RandomOffsetPattern(pattern, (int) x, (int) y, (int) z);
}
@ -381,7 +380,7 @@ public class PatternCommands extends MethodCommands {
min = 1,
max = 1
)
public Pattern linear(Actor actor, LocalSession session, Pattern other) {
public Pattern linear(Pattern other) {
if (other instanceof RandomPattern) {
Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
return new LinearBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
@ -396,7 +395,7 @@ public class PatternCommands extends MethodCommands {
min = 1,
max = 1
)
public Pattern linear3d(Actor actor, LocalSession session, Pattern other) {
public Pattern linear3d(Pattern other) {
if (other instanceof RandomPattern) {
Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
return new Linear3DBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
@ -411,7 +410,7 @@ public class PatternCommands extends MethodCommands {
min = 1,
max = 1
)
public Pattern linear2d(Actor actor, LocalSession session, Pattern other) {
public Pattern linear2d(Pattern other) {
if (other instanceof RandomPattern) {
Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
return new Linear2DBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
@ -426,7 +425,7 @@ public class PatternCommands extends MethodCommands {
min = 1,
max = 1
)
public Pattern expression(Actor actor, LocalSession session, Extent extent, String input) throws ExpressionException {
public Pattern expression(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);

View File

@ -19,7 +19,12 @@
package com.sk89q.worldedit.command;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.beta.filters.SetFilter;
import com.boydti.fawe.beta.implementation.QueueHandler;
import com.boydti.fawe.beta.filters.CountFilter;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.example.NMSMappedFaweQueue;
import com.boydti.fawe.object.FaweLimit;
@ -45,6 +50,7 @@ import com.sk89q.worldedit.function.generator.FloraGenerator;
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.NoiseFilter2D;
import com.sk89q.worldedit.function.mask.SolidBlockMask;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.visitor.LayerVisitor;
@ -65,10 +71,14 @@ import com.sk89q.worldedit.util.command.binding.Range;
import com.sk89q.worldedit.util.command.binding.Switch;
import com.sk89q.worldedit.util.command.binding.Text;
import com.sk89q.worldedit.util.command.parametric.Optional;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.biome.Biomes;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.registry.BiomeRegistry;
import java.util.ArrayList;
@ -104,6 +114,43 @@ public class RegionCommands extends MethodCommands {
this.worldEdit = worldEdit;
}
@Command(
aliases = {"debugtest"},
usage = "",
desc = "debugtest",
help = "debugtest"
)
@CommandPermissions("fawe.admin.debug")
public void debugtest(Player player, @Selection Region region) throws WorldEditException {
QueueHandler queueHandler = Fawe.get().getQueueHandler();
World world = player.getWorld();
CountFilter filter = new CountFilter();
long start = System.currentTimeMillis();
queueHandler.apply(world, region, filter);
long diff = System.currentTimeMillis() - start;
System.out.println(diff);
}
@Command(
aliases = {"db2"},
usage = "",
desc = "db2",
help = "db2"
)
@CommandPermissions("fawe.admin.debug")
public void db2(Player player, @Selection Region region, String blockStr) throws WorldEditException {
QueueHandler queueHandler = Fawe.get().getQueueHandler();
World world = player.getWorld();
BlockState block = BlockState.get(blockStr);
SetFilter filter = new SetFilter(block);
long start = System.currentTimeMillis();
queueHandler.apply(world, region, filter);
long diff = System.currentTimeMillis() - start;
System.out.println(diff);
}
@Command(
aliases = {"/fixlighting"},
desc = "Get the light at a position",
@ -465,7 +512,7 @@ public class RegionCommands extends MethodCommands {
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
FaweLimit limit = FawePlayer.wrap(player).getLimit();
if (volume >= limit.MAX_CHECKS) {
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
throw FaweException.MAX_CHECKS;
}
player.checkConfirmationRegion(() -> {
try {
@ -733,7 +780,9 @@ public class RegionCommands extends MethodCommands {
help =
"Hollows out the object contained in this selection.\n" +
"Optionally fills the hollowed out part with the given block.\n" +
"Thickness is measured in manhattan distance.",
"Thickness is measured in manhattan distance.\n" +
"Flags:\n" +
" -m Mask, uses a mask to hollow",
min = 0,
max = 2
)
@ -743,9 +792,11 @@ public class RegionCommands extends MethodCommands {
@Selection Region region,
@Optional("0") @Range(min = 0) int thickness,
@Optional("air") Pattern pattern,
@Switch('m') Mask mask,
CommandContext context) throws WorldEditException {
Mask finalMask = mask == null ? new SolidBlockMask(editSession) : mask;
player.checkConfirmationRegion(() -> {
int affected = editSession.hollowOutRegion(region, thickness, pattern);
int affected = editSession.hollowOutRegion(region, thickness, pattern, finalMask);
BBC.VISITOR_BLOCK.send(player, affected);
}, getArguments(context), region, context);
}

View File

@ -24,6 +24,7 @@ import com.boydti.fawe.object.clipboard.URIClipboardHolder;
import com.boydti.fawe.object.mask.IdMask;
import com.boydti.fawe.object.regions.selector.FuzzyRegionSelector;
import com.boydti.fawe.object.regions.selector.PolyhedralRegionSelector;
import com.boydti.fawe.util.ExtentTraverser;
import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandException;
@ -694,7 +695,7 @@ public class SelectionCommands {
// TODO multi clipboard distribution
Clipboard clipboard = session.getClipboard().getClipboard();
region = clipboard.getRegion();
editSession.setExtent(new AbstractDelegateExtent(clipboard));
new ExtentTraverser<AbstractDelegateExtent>(editSession).setNext(new AbstractDelegateExtent(clipboard));
} else {
region = session.getSelection(player.getWorld());
}
@ -702,7 +703,7 @@ public class SelectionCommands {
distributionData = (List) editSession.getBlockDistributionWithData(region);
else
distributionData = (List) editSession.getBlockDistribution(region);
size = session.getSelection(player.getWorld()).getArea();
size = region.getArea();
if (distributionData.size() <= 0) {
player.printError("No blocks counted.");

View File

@ -21,6 +21,8 @@ package com.sk89q.worldedit.command;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.beta.implementation.QueueHandler;
import com.boydti.fawe.beta.implementation.WorldChunkCache;
import com.boydti.fawe.command.FaweParser;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Commands;
@ -67,6 +69,7 @@ import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.visitor.EntityVisitor;
import com.sk89q.worldedit.internal.annotation.Direction;
import com.sk89q.worldedit.internal.annotation.Selection;
import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.internal.expression.ExpressionException;
import com.sk89q.worldedit.internal.expression.runtime.EvaluationException;

View File

@ -68,7 +68,7 @@ public class AreaPickaxe implements BlockTool {
for (int x = ox - range; x <= ox + range; ++x) {
for (int z = oz - range; z <= oz + range; ++z) {
for (int y = oy + range; y >= oy - range; --y) {
if (editSession.getLazyBlock(x, y, z).getBlockType() != initialType) {
if (initialType.equals(editSession.getBlock(x, y, z))) {
continue;
}
editSession.setBlock(x, y, z, BlockTypes.AIR.getDefaultState());

View File

@ -634,15 +634,16 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
Brush brush = current.getBrush();
if (brush == null) return;
FawePlayer<Object> fp = FawePlayer.wrap(player);
EditSession editSession = new EditSessionBuilder(player.getWorld())
EditSessionBuilder builder = new EditSessionBuilder(player.getWorld())
.player(fp)
.allowedRegionsEverywhere()
.autoQueue(false)
.blockBag(null)
.changeSetNull()
.combineStages(false)
.build();
VisualExtent newVisualExtent = new VisualExtent(editSession.getExtent(), editSession.getQueue());
.combineStages(false);
EditSession editSession = builder.build();
VisualExtent newVisualExtent = new VisualExtent(builder.getExtent(), builder.getQueue());
BlockVector3 position = getPosition(editSession, player);
if (position != null) {
editSession.setExtent(newVisualExtent);

View File

@ -49,7 +49,7 @@ public class GravityBrush implements Brush {
for (int z = position.getBlockZ() + size; z > position.getBlockZ() - size; --z) {
int freeSpot = startCheckY;
for (int y = startCheckY; y <= endY; y++) {
BlockStateHolder block = editSession.getLazyBlock(x, y, z);
BlockStateHolder block = editSession.getBlock(x, y, z);
if (!block.getBlockType().getMaterial().isAir()) {
if (y != freeSpot) {
editSession.setBlock(x, y, z, BlockTypes.AIR.getDefaultState());