mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 02:46:41 +00:00
Fix clipboards to allow proper heights by allowing extended CuboidRegion heights (#1624)
* Fix clipboards to allow proper heights by allowing extended CuboidRegion heights Fixes #1534 * Add @since * Fix javadoc comment Co-authored-by: Alex <mc.cache@web.de>
This commit is contained in:
@ -61,6 +61,7 @@ import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.ChangeSetExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
@ -263,8 +264,10 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
this.limit = builder.getLimit().copy();
|
||||
this.actor = builder.getActor();
|
||||
this.changeSet = builder.getChangeTask();
|
||||
this.minY = world.getMinY();
|
||||
this.maxY = world.getMaxY();
|
||||
this.minY = world != null ? world.getMinY() :
|
||||
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).versionMinY();
|
||||
this.maxY = world != null ? world.getMaxY() :
|
||||
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).versionMaxY();
|
||||
this.blockBag = builder.getBlockBag();
|
||||
this.history = changeSet != null;
|
||||
this.relighter = builder.getRelighter();
|
||||
|
@ -340,8 +340,7 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable, Fl
|
||||
copy.setTransform(transform);
|
||||
}
|
||||
copy.setCopyingBiomes(this.hasBiomes());
|
||||
if (extent instanceof EditSession) {
|
||||
EditSession editSession = (EditSession) extent;
|
||||
if (extent instanceof EditSession editSession) {
|
||||
Mask sourceMask = editSession.getSourceMask();
|
||||
if (sourceMask != null) {
|
||||
new MaskTraverser(sourceMask).reset(extent);
|
||||
@ -393,7 +392,7 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable, Fl
|
||||
continue;
|
||||
}
|
||||
if (pos.getY() < extent.getMinY()) {
|
||||
throw new RuntimeException("Y-Position cannot be less than 0!");
|
||||
throw new RuntimeException("Y-Position cannot be less than the extent's minimum Y!");
|
||||
}
|
||||
extent.setBlock(xx, yy, zz, block);
|
||||
}
|
||||
|
@ -85,6 +85,30 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
recalculate();
|
||||
}
|
||||
|
||||
//FAWE start - allow region to be created without clamping Y
|
||||
/**
|
||||
* Construct a new instance of this cuboid using two corners of the cuboid.
|
||||
*
|
||||
* @param world the world
|
||||
* @param pos1 the first position
|
||||
* @param pos2 the second position
|
||||
* @param clampY if the min/max Y of the region should be clamped to the world
|
||||
* @since TODO
|
||||
*/
|
||||
public CuboidRegion(World world, BlockVector3 pos1, BlockVector3 pos2, boolean clampY) {
|
||||
super(world);
|
||||
checkNotNull(pos1);
|
||||
checkNotNull(pos2);
|
||||
this.pos1 = pos1;
|
||||
this.pos2 = pos2;
|
||||
if (clampY) {
|
||||
recalculate();
|
||||
} else {
|
||||
recalculateNoClamp();
|
||||
}
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Get the first cuboid-defining corner.
|
||||
*
|
||||
@ -128,7 +152,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
}
|
||||
|
||||
/**
|
||||
* Clamps the cuboid according to boundaries of the world.
|
||||
* Sets the cached min and max x/y/z and clamps Y to world y min/max
|
||||
*/
|
||||
protected void recalculate() {
|
||||
if (pos1 == null || pos2 == null) {
|
||||
@ -144,6 +168,23 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
maxZ = Math.max(pos1.getZ(), pos2.getZ());
|
||||
}
|
||||
|
||||
//FAWE start - allow region to be created without clamping Y
|
||||
/**
|
||||
* Sets the cached min and max x/y/z
|
||||
*/
|
||||
protected void recalculateNoClamp() {
|
||||
if (pos1 == null || pos2 == null) {
|
||||
return;
|
||||
}
|
||||
minX = Math.min(pos1.getX(), pos2.getX());
|
||||
minY = Math.min(pos1.getY(), pos2.getY());
|
||||
minZ = Math.min(pos1.getZ(), pos2.getZ());
|
||||
maxX = Math.max(pos1.getX(), pos2.getX());
|
||||
maxY = Math.max(pos1.getY(), pos2.getY());
|
||||
maxZ = Math.max(pos1.getZ(), pos2.getZ());
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Get a region that contains the faces of this cuboid.
|
||||
*
|
||||
|
Reference in New Issue
Block a user