Added some element comments to ArbitraryShape.

This commit is contained in:
TomyLobo 2011-11-24 04:06:14 +01:00
parent dfb729d5f1
commit d69b04caf5

View File

@ -23,6 +23,12 @@ import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.patterns.Pattern; import com.sk89q.worldedit.patterns.Pattern;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
/**
* Generates solid and hollow shapes according to materials returned by the
* {@link #getMaterial} method.
*
* @author TomyLobo
*/
public abstract class ArbitraryShape { public abstract class ArbitraryShape {
private final Region extent; private final Region extent;
private int cacheSizeX; private int cacheSizeX;
@ -63,6 +69,15 @@ public abstract class ArbitraryShape {
*/ */
private final short[] cache; private final short[] cache;
/**
* Override this function to specify the shape to generate.
*
* @param x
* @param y
* @param z
* @param defaultMaterial The material returned by the pattern for the current block.
* @return material to place or null to not place anything.
*/
protected abstract BaseBlock getMaterial(int x, int y, int z, BaseBlock defaultMaterial); protected abstract BaseBlock getMaterial(int x, int y, int z, BaseBlock defaultMaterial);
private BaseBlock getMaterialCached(int x, int y, int z, Pattern pattern) { private BaseBlock getMaterialCached(int x, int y, int z, Pattern pattern) {
@ -118,6 +133,15 @@ public abstract class ArbitraryShape {
} }
} }
/**
* Generates the shape.
*
* @param editSession
* @param pattern The pattern to generate default materials from.
* @param hollow Specifies whether to generate a hollow shape.
* @return number of affected blocks.
* @throws MaxChangedBlocksException
*/
public int generate(EditSession editSession, Pattern pattern, boolean hollow) throws MaxChangedBlocksException { public int generate(EditSession editSession, Pattern pattern, boolean hollow) throws MaxChangedBlocksException {
int affected = 0; int affected = 0;