mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-12 04:38:35 +00:00
Allow copy/pasting biomes.
Copy takes a -b flag to copy biomes. Paste takes a -b flag to paste biomes (if available). This allows flexibility to create/load schematics with/without biomes (when schematic biome support is added). Also added a -m mask flag to paste to set a source mask, and a -e flag to skip pasting entities if they are loaded.
This commit is contained in:
@ -25,6 +25,9 @@ import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.transform.BlockTransformExtent;
|
||||
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.MaskIntersection;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
@ -39,8 +42,12 @@ public class PasteBuilder {
|
||||
private final Transform transform;
|
||||
private final Extent targetExtent;
|
||||
|
||||
private Mask sourceMask = Masks.alwaysTrue();
|
||||
|
||||
private BlockVector3 to = BlockVector3.ZERO;
|
||||
private boolean ignoreAirBlocks;
|
||||
private boolean copyEntities = true; // default because it used to be this way
|
||||
private boolean copyBiomes;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
@ -67,6 +74,19 @@ public class PasteBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a custom mask of blocks to ignore from the source.
|
||||
* This provides a more flexible alternative to {@link #ignoreAirBlocks(boolean)}, for example
|
||||
* one might want to ignore structure void if copying a Minecraft Structure, etc.
|
||||
*
|
||||
* @param sourceMask
|
||||
* @return this builder instance
|
||||
*/
|
||||
public PasteBuilder maskSource(Mask sourceMask) {
|
||||
this.sourceMask = sourceMask;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether air blocks in the source are skipped over when pasting.
|
||||
*
|
||||
@ -77,6 +97,29 @@ public class PasteBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether the copy should include source entities.
|
||||
* Note that this is true by default for legacy reasons.
|
||||
*
|
||||
* @param copyEntities
|
||||
* @return this builder instance
|
||||
*/
|
||||
public PasteBuilder copyEntities(boolean copyEntities) {
|
||||
this.copyEntities = copyEntities;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether the copy should include source biomes (if available).
|
||||
*
|
||||
* @param copyBiomes
|
||||
* @return this builder instance
|
||||
*/
|
||||
public PasteBuilder copyBiomes(boolean copyBiomes) {
|
||||
this.copyBiomes = copyBiomes;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the operation.
|
||||
*
|
||||
@ -87,8 +130,13 @@ public class PasteBuilder {
|
||||
ForwardExtentCopy copy = new ForwardExtentCopy(extent, clipboard.getRegion(), clipboard.getOrigin(), targetExtent, to);
|
||||
copy.setTransform(transform);
|
||||
if (ignoreAirBlocks) {
|
||||
copy.setSourceMask(new ExistingBlockMask(clipboard));
|
||||
copy.setSourceMask(sourceMask == Masks.alwaysTrue() ? new ExistingBlockMask(clipboard)
|
||||
: new MaskIntersection(sourceMask, new ExistingBlockMask(clipboard)));
|
||||
} else {
|
||||
copy.setSourceMask(sourceMask);
|
||||
}
|
||||
copy.setCopyingEntities(copyEntities);
|
||||
copy.setCopyingBiomes(copyBiomes && clipboard.hasBiomes());
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user