mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-05 20:36:42 +00:00
Added non-cuboid support for //walls and //outline.
This commit is contained in:
@ -34,7 +34,7 @@ import com.sk89q.worldedit.regions.Region;
|
||||
* @author TomyLobo
|
||||
*/
|
||||
public abstract class ArbitraryShape {
|
||||
private final Region extent;
|
||||
protected final Region extent;
|
||||
private int cacheOffsetX;
|
||||
private int cacheOffsetY;
|
||||
private int cacheOffsetZ;
|
||||
@ -148,6 +148,20 @@ public abstract class ArbitraryShape {
|
||||
* @throws MaxChangedBlocksException
|
||||
*/
|
||||
public int generate(EditSession editSession, Pattern pattern, boolean hollow) throws MaxChangedBlocksException {
|
||||
return generate(editSession, pattern, hollow, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the shape.
|
||||
*
|
||||
* @param editSession The EditSession to use.
|
||||
* @param pattern The pattern to generate default materials from.
|
||||
* @param hollow Specifies whether to generate a hollow shape.
|
||||
* @param flat If hollow mode is enabled, disregard blocks above/below
|
||||
* @return number of affected blocks.
|
||||
* @throws MaxChangedBlocksException
|
||||
*/
|
||||
public int generate(EditSession editSession, Pattern pattern, boolean hollow, boolean flat) throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
|
||||
for (BlockVector position : getExtent()) {
|
||||
@ -179,14 +193,6 @@ public abstract class ArbitraryShape {
|
||||
draw = true;
|
||||
break;
|
||||
}
|
||||
if (!isInsideCached(x, y + 1, z, pattern)) {
|
||||
draw = true;
|
||||
break;
|
||||
}
|
||||
if (!isInsideCached(x, y - 1, z, pattern)) {
|
||||
draw = true;
|
||||
break;
|
||||
}
|
||||
if (!isInsideCached(x, y, z + 1, pattern)) {
|
||||
draw = true;
|
||||
break;
|
||||
@ -195,6 +201,19 @@ public abstract class ArbitraryShape {
|
||||
draw = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (flat) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!isInsideCached(x, y + 1, z, pattern)) {
|
||||
draw = true;
|
||||
break;
|
||||
}
|
||||
if (!isInsideCached(x, y - 1, z, pattern)) {
|
||||
draw = true;
|
||||
break;
|
||||
}
|
||||
} while (false);
|
||||
|
||||
if (!draw) {
|
||||
|
27
src/main/java/com/sk89q/worldedit/shape/RegionShape.java
Normal file
27
src/main/java/com/sk89q/worldedit/shape/RegionShape.java
Normal file
@ -0,0 +1,27 @@
|
||||
package com.sk89q.worldedit.shape;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.shape.ArbitraryShape;
|
||||
|
||||
/**
|
||||
* Generates solid and hollow shapes according to materials returned by the
|
||||
* {@link #getMaterial} method.
|
||||
*
|
||||
* @author TomyLobo
|
||||
*/
|
||||
public class RegionShape extends ArbitraryShape {
|
||||
public RegionShape(Region extent) {
|
||||
super(extent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BaseBlock getMaterial(int x, int y, int z, BaseBlock defaultMaterial) {
|
||||
if (!this.extent.contains(new Vector(x, y, z))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return defaultMaterial;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user