mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-09-16 04:28:16 +00:00
50ab8ad5c7
* Feature/main/propagate diff annotations (#1187) * 25% done * More work * More work * 50% * More work * 75% * 100% & cleanup * Update adapters * Squish squash, applesauce commit275ba9bd84
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Date: Sat Jul 17 01:10:20 2021 +0200 Update dependency com.comphenix.protocol:ProtocolLib to v4.7.0 (#1173) Co-authored-by: Renovate Bot <bot@renovateapp.com> commit9fd8984804
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Date: Sat Jul 17 01:09:29 2021 +0200 Update dependency org.checkerframework:checker-qual to v3.16.0 (#1184) Co-authored-by: Renovate Bot <bot@renovateapp.com> commit861fb45e5c
Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 19:07:02 2021 +0100 Fix #1075 commit420c45a29a
Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 18:48:21 2021 +0100 Entity removal should be on the main thread as we're just passing through rather than doing chunk operations - Fixes #1164 - Not working: butcher/remove history commit4d4db7dcd0
Author: SirYwell <hannesgreule@outlook.de> Date: Fri Jul 16 17:52:44 2021 +0200 Make sure leaves category is loaded for heightmaps (fixes #1176) commitc98f6e4f37
Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 10:44:52 2021 +0100 Do not allow generation commands to generate outside selection commit2485f5eccc
Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 10:43:15 2021 +0100 EditSession needs to override some Extent methods to ensure block changes are correctly set through the various extents Fixes #1152 commitd9418ec8ae
Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 09:52:44 2021 +0100 Undo part of41073bb1a0
Fixes #1178 * Update Upstream fb1fb84 Fixed typo and grammar * We don't support custom heights yet * Casing inconsistency * Address a few comments * Address comments * Don't refactor to AP classpath * Document annotation style * Refactoring & shade cleanup * Address a few comments * More work * Resolve comments not being resolved yet * Feature/main/propagate diff annotations (#1187) (#1194) * Remove beta package, fix history packages, move classes out of object package * Resolve comments not being resolved yet * Remove beta package, fix history packages, move classes out of object package Co-authored-by: NotMyFault <mc.cache@web.de> * brushes should be under brush * More refactoring - Filters/processors should be in the same place and are related to extents - Transforms are in `extent.transform` in upstream * Move history classes under history * Update adapters Co-authored-by: dordsor21 <dordsor21@gmail.com>
185 lines
6.0 KiB
Java
185 lines
6.0 KiB
Java
/*
|
|
* WorldEdit, a Minecraft world manipulation toolkit
|
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
|
* Copyright (C) WorldEdit team and contributors
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
package com.sk89q.worldedit.session;
|
|
|
|
import com.fastasyncworldedit.core.util.MaskTraverser;
|
|
import com.sk89q.worldedit.EditSession;
|
|
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.RegionFunction;
|
|
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;
|
|
import com.sk89q.worldedit.math.transform.Transform;
|
|
|
|
import static com.google.common.base.Preconditions.checkNotNull;
|
|
|
|
/**
|
|
* Builds an operation to paste the contents of a clipboard.
|
|
*/
|
|
public class PasteBuilder {
|
|
|
|
private final Clipboard clipboard;
|
|
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;
|
|
private RegionFunction canApply;
|
|
|
|
/**
|
|
* Create a new instance.
|
|
*
|
|
* @param holder the clipboard holder
|
|
* @param targetExtent an extent
|
|
*/
|
|
PasteBuilder(ClipboardHolder holder, Extent targetExtent) {
|
|
checkNotNull(holder);
|
|
checkNotNull(targetExtent);
|
|
this.clipboard = holder.getClipboard();
|
|
this.transform = holder.getTransform();
|
|
this.targetExtent = targetExtent;
|
|
}
|
|
|
|
/**
|
|
* Set the target location.
|
|
*
|
|
* @param to the target location
|
|
* @return this builder instance
|
|
*/
|
|
public PasteBuilder to(BlockVector3 to) {
|
|
this.to = to;
|
|
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 the mask for the source
|
|
* @return this builder instance
|
|
*/
|
|
public PasteBuilder maskSource(Mask sourceMask) {
|
|
if (sourceMask == null) {
|
|
this.sourceMask = Masks.alwaysTrue();
|
|
return this;
|
|
}
|
|
this.sourceMask = sourceMask;
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Set whether air blocks in the source are skipped over when pasting.
|
|
*
|
|
* @return this builder instance
|
|
*/
|
|
public PasteBuilder ignoreAirBlocks(boolean ignoreAirBlocks) {
|
|
this.ignoreAirBlocks = ignoreAirBlocks;
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Set whether the copy should include source entities.
|
|
* Note that this is true by default for legacy reasons.
|
|
*
|
|
* @param copyEntities if entities should be copied
|
|
* @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 if biomes should be copied
|
|
* @return this builder instance
|
|
*/
|
|
public PasteBuilder copyBiomes(boolean copyBiomes) {
|
|
this.copyBiomes = copyBiomes;
|
|
return this;
|
|
}
|
|
|
|
//FAWE start
|
|
public PasteBuilder filter(RegionFunction function) {
|
|
this.canApply = function;
|
|
return this;
|
|
}
|
|
//FAWE end
|
|
|
|
/**
|
|
* Build the operation.
|
|
*
|
|
* @return the operation
|
|
*/
|
|
public Operation build() {
|
|
//FAWE start
|
|
Extent extent = clipboard;
|
|
if (!transform.isIdentity()) {
|
|
extent = new BlockTransformExtent(extent, transform);
|
|
}
|
|
//FAWE end
|
|
ForwardExtentCopy copy = new ForwardExtentCopy(extent, clipboard.getRegion(), clipboard.getOrigin(), targetExtent, to);
|
|
copy.setTransform(transform);
|
|
|
|
//FAWE start
|
|
copy.setCopyingEntities(copyEntities);
|
|
copy.setCopyingBiomes(copyBiomes && clipboard.hasBiomes());
|
|
if (this.canApply != null) {
|
|
copy.setFilterFunction(this.canApply);
|
|
}
|
|
//FAWE end
|
|
if (ignoreAirBlocks) {
|
|
//FAWE start - respect clipboard
|
|
sourceMask = MaskIntersection.of(sourceMask, new ExistingBlockMask(clipboard));
|
|
}
|
|
if (targetExtent instanceof EditSession) {
|
|
Mask esSourceMask = ((EditSession) targetExtent).getSourceMask();
|
|
if (esSourceMask == Masks.alwaysFalse()) {
|
|
return null;
|
|
}
|
|
if (esSourceMask != null) {
|
|
new MaskTraverser(esSourceMask).reset(extent);
|
|
((EditSession) targetExtent).setSourceMask(null);
|
|
sourceMask = MaskIntersection.of(sourceMask, esSourceMask);
|
|
}
|
|
}
|
|
//FAWE end
|
|
if (sourceMask != null && sourceMask != Masks.alwaysTrue()) {
|
|
copy.setSourceMask(sourceMask);
|
|
}
|
|
copy.setCopyingEntities(copyEntities);
|
|
copy.setCopyingBiomes(copyBiomes && clipboard.hasBiomes());
|
|
return copy;
|
|
}
|
|
|
|
}
|