resolve conflicts

This commit is contained in:
Jesse Boyd
2019-07-18 16:56:57 +10:00
parent dd38cbe750
commit be8213d8ee
49 changed files with 1819 additions and 1722 deletions

View File

@ -38,6 +38,7 @@ import com.boydti.fawe.util.MaskTraverser;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
@ -91,6 +92,7 @@ import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/**
* Clipboard commands.
*/
@ -123,20 +125,24 @@ public class ClipboardCommands {
Mask mask, CommandContext context) throws WorldEditException {
BlockVector3 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint();
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;
}
fp.checkConfirmationRegion(() -> {
session.setClipboard(null);
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId());
session.setClipboard(new ClipboardHolder(clipboard));
clipboard.setOrigin(session.getPlacementPosition(player));
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
copy.setCopyingEntities(!skipEntities);
copy.setCopyingBiomes(copyBiomes);
Mask sourceMask = editSession.getSourceMask();
if (sourceMask != null) {
new MaskTraverser(sourceMask).reset(editSession);
@ -204,12 +210,13 @@ public class ClipboardCommands {
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);
ReadOnlyClipboard lazyClipboard = new WorldCutClipboard(editSession, region, !skipEntities, copyBiomes);
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, lazyClipboard);
clipboard.setOrigin(session.getPlacementPosition(player));
@ -221,6 +228,7 @@ public class ClipboardCommands {
name = "/cut",
desc = "Cut the selection to the clipboard",
descFooter = "WARNING: Cutting and pasting entities cannot be undone!"
)
@CommandPermissions("worldedit.clipboard.cut")
@Logging(REGION)
@ -237,21 +245,24 @@ public class ClipboardCommands {
CommandContext context) throws WorldEditException {
BlockVector3 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint();
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;
}
fp.checkConfirmationRegion(() -> {
session.setClipboard(null);
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId());
clipboard.setOrigin(session.getPlacementPosition(player));
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
copy.setSourceFunction(new BlockReplace(editSession, leavePattern));
copy.setCopyingEntities(!skipEntities);
copy.setCopyingEntities(copyEntities);
copy.setRemovingEntities(true);
copy.setCopyingBiomes(copyBiomes);
Mask sourceMask = editSession.getSourceMask();
@ -413,6 +424,7 @@ public class ClipboardCommands {
@Command(
name = "/paste",
desc = "Paste the clipboard's contents"
)
@CommandPermissions("worldedit.clipboard.paste")
@Logging(PLACEMENT)
@ -481,6 +493,7 @@ public class ClipboardCommands {
name = "/place",
desc = "Place the clipboard's contents without applying transformations (e.g. rotate)"
)
@CommandPermissions("worldedit.clipboard.place")
@Logging(PLACEMENT)
public void place(Player player, LocalSession session, final EditSession editSession,
@ -551,6 +564,7 @@ public class ClipboardCommands {
public void flip(Player player, LocalSession session,
@Arg(desc = "The direction to flip, defaults to look direction.", def = Direction.AIM)
@Direction BlockVector3 direction) throws WorldEditException {
ClipboardHolder holder = session.getClipboard();
AffineTransform transform = new AffineTransform();
transform = transform.scale(direction.abs().multiply(-2).add(1, 1, 1).toVector3());
@ -563,7 +577,7 @@ public class ClipboardCommands {
desc = "Clear your clipboard"
)
@CommandPermissions("worldedit.clipboard.clear")
public void clearClipboard(Player player, LocalSession session) throws WorldEditException {
public void clearClipboard(Player player, LocalSession session, EditSession editSession) throws WorldEditException {
session.setClipboard(null);
BBC.CLIPBOARD_CLEARED.send(player);
}

View File

@ -205,6 +205,7 @@ public class PatternCommands extends MethodCommands {
" - 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);
}
@ -213,6 +214,7 @@ public class PatternCommands extends MethodCommands {
desc = "Only change the block id"
)
public Pattern id(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
return new IdPattern(extent, pattern);
}
@ -221,6 +223,7 @@ public class PatternCommands extends MethodCommands {
desc = "Only change the block data"
)
public Pattern data(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
return new DataPattern(extent, pattern);
}
@ -230,6 +233,7 @@ public class PatternCommands extends MethodCommands {
desc = "Set the biome"
)
public Pattern biome(Actor actor, LocalSession session, Extent extent, BiomeType biome) {
return new BiomePattern(extent, biome);
}
@ -239,6 +243,7 @@ public class PatternCommands extends MethodCommands {
desc = "Offset the pattern to where you click"
)
public Pattern relative(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
return new RelativePattern(pattern);
}
@ -250,6 +255,7 @@ public class PatternCommands extends MethodCommands {
"Example: #!x[#!z[#~[#l3d[pattern]]]]"
)
public Pattern nox(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
return new NoXPattern(pattern);
}
@ -259,6 +265,7 @@ public class PatternCommands extends MethodCommands {
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);
}
@ -268,6 +275,7 @@ public class PatternCommands extends MethodCommands {
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);
}
@ -285,6 +293,7 @@ public class PatternCommands extends MethodCommands {
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);
}
@ -293,6 +302,7 @@ public class PatternCommands extends MethodCommands {
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);
}
@ -301,6 +311,7 @@ public class PatternCommands extends MethodCommands {
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);
}
@ -310,6 +321,7 @@ public class PatternCommands extends MethodCommands {
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);
}
@ -319,6 +331,7 @@ public class PatternCommands extends MethodCommands {
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()]));
@ -332,6 +345,7 @@ public class PatternCommands extends MethodCommands {
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()]));
@ -345,6 +359,7 @@ public class PatternCommands extends MethodCommands {
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()]));
@ -358,6 +373,7 @@ public class PatternCommands extends MethodCommands {
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);

View File

@ -29,7 +29,11 @@ import static com.sk89q.worldedit.regions.Regions.asFlatRegion;
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.beta.filters.SetFilter;
import com.boydti.fawe.beta.implementation.QueueHandler;
import com.boydti.fawe.beta.filters.DistrFilter;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.example.NMSMappedFaweQueue;
import com.boydti.fawe.object.FaweLimit;
@ -54,6 +58,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;
@ -76,9 +81,11 @@ import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
import com.sk89q.worldedit.util.command.binding.Range;
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.registry.BiomeRegistry;
import java.util.ArrayList;
@ -109,6 +116,43 @@ public class RegionCommands {
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();
DistrFilter filter = new DistrFilter();
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(
name = "/fixlighting",
desc = "Get the light at a position"
@ -417,7 +461,7 @@ public class RegionCommands {
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 {
@ -673,6 +717,7 @@ public class RegionCommands {
descFooter = "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."
)
@CommandPermissions("worldedit.region.hollow")
@Logging(REGION)
@ -682,9 +727,11 @@ public class RegionCommands {
int thickness,
@Arg(desc = "The pattern of blocks to replace the hollowed area with", def = "air")
Pattern pattern,
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

@ -31,6 +31,7 @@ import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
import com.boydti.fawe.object.clipboard.URIClipboardHolder;
import com.boydti.fawe.object.clipboard.remap.ClipboardRemapper;
import com.boydti.fawe.object.schematic.StructureFormat;
import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.chat.Message;
import com.sk89q.minecraft.util.commands.CommandContext;
@ -80,6 +81,7 @@ import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.regex.Pattern;
import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer;
@ -403,8 +405,8 @@ public class SchematicCommands {
}
if (new PlayerSaveClipboardEvent(player, clipboard, uri, f.toURI()).call()) {
try (ClipboardWriter writer = format.getWriter(fos)) {
if (writer instanceof StructureFormat) {
((StructureFormat) writer).write(target, player.getName());
if (writer instanceof MinecraftStructure) {
((MinecraftStructure) writer).write(target, player.getName());
} else {
writer.write(target);
}

View File

@ -27,6 +27,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.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
@ -490,7 +491,7 @@ public class SelectionCommands {
// TODO multi clipboard distribution
Clipboard clipboard = session.getClipboard().getClipboard(); // throws if missing
region = clipboard.getRegion();
editSession.setExtent(new AbstractDelegateExtent(clipboard));
new ExtentTraverser<AbstractDelegateExtent>(editSession).setNext(new AbstractDelegateExtent(clipboard));
} else {
region = session.getSelection(player.getWorld());
}
@ -499,6 +500,7 @@ public class SelectionCommands {
else
distribution = (List) editSession.getBlockDistribution(region);
if (distribution.isEmpty()) { // *Should* always be false
player.printError("No blocks counted.");
return;

View File

@ -22,6 +22,7 @@ package com.sk89q.worldedit.command;
import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.DelegateConsumer;
@ -60,6 +61,7 @@ import com.sk89q.worldedit.function.mask.Mask;
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.expression.Expression;
import com.sk89q.worldedit.internal.expression.ExpressionException;
import com.sk89q.worldedit.math.BlockVector3;

View File

@ -75,6 +75,7 @@ public class WorldEditCommands {
FaweVersion fVer = Fawe.get().getVersion();
String fVerStr = fVer == null ? "unknown" : "-" + fVer.build;
actor.print("FastAsyncWorldEdit" + fVerStr + " created by Empire92");
if (fVer != null) {
actor.printDebug("----------- Platforms -----------");
FaweVersion version = Fawe.get().getVersion();

View File

@ -48,6 +48,7 @@ import com.sk89q.minecraft.util.commands.CommandException;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.MaxBrushRadiusException;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
@ -643,15 +644,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

@ -24,6 +24,7 @@ import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
public class GravityBrush implements Brush {
@ -43,8 +44,8 @@ public class GravityBrush implements Brush {
for (int x = position.getBlockX() + size; x > position.getBlockX() - size; --x) {
for (int z = position.getBlockZ() + size; z > position.getBlockZ() - size; --z) {
int freeSpot = startCheckY;
for (int y = startCheckY; y <= endY; ++y) {
final BlockState block = editSession.getLazyBlock(x, y, z);
for (int y = startCheckY; y <= endY; y++) {
BlockStateHolder block = editSession.getBlock(x, y, z);
if (!block.getBlockType().getMaterial().isAir()) {
if (y != freeSpot) {
editSession.setBlock(x, y, z, BlockTypes.AIR.getDefaultState());