public interface WPObject
extends java.io.Serializable, java.lang.Cloneable
This class uses the WorldPainter coordinate system (z is vertical).
Modifier and Type | Interface and Description |
---|---|
static interface |
WPObject.BlockVisitor |
Modifier and Type | Field and Description |
---|---|
static org.pepsoft.util.AttributeKey<java.lang.Integer> |
ATTRIBUTE_COLLISION_MODE
Collision mode.
|
static org.pepsoft.util.AttributeKey<java.lang.Boolean> |
ATTRIBUTE_CONNECT_BLOCKS
Whether certain connecting blocks such as fences, glass panes and iron bars should have their west, north, east
and south properties automatically set if there is a connecting block in that direction.
|
static org.pepsoft.util.AttributeKey<java.lang.Boolean> |
ATTRIBUTE_EXTEND_FOUNDATION
When set, the blocks on the lowest level of the object will be copied
downwards until they meet a solid block, if they end up being placed
floating in the air.
|
static org.pepsoft.util.AttributeKey<java.io.File> |
ATTRIBUTE_FILE |
static org.pepsoft.util.AttributeKey<java.lang.Integer> |
ATTRIBUTE_FREQUENCY |
static org.pepsoft.util.AttributeKey<java.lang.Integer> |
ATTRIBUTE_HEIGHT_MODE |
static org.pepsoft.util.AttributeKey<java.lang.Integer> |
ATTRIBUTE_LEAF_DECAY_MODE
Whether to change leaf blocks so that they do or do not decay.
|
static org.pepsoft.util.AttributeKey<java.lang.Boolean> |
ATTRIBUTE_MANAGE_WATERLOGGED
Whether the
Material.WATERLOGGED property of the blocks should be automatically managed (set if there is
already water where the blocks are placed and reset if the target location is dry) or exported as set in the
object. |
static org.pepsoft.util.AttributeKey<java.lang.Boolean> |
ATTRIBUTE_NEEDS_FOUNDATION |
static org.pepsoft.util.AttributeKey<javax.vecmath.Point3i> |
ATTRIBUTE_OFFSET |
static org.pepsoft.util.AttributeKey<java.lang.Boolean> |
ATTRIBUTE_RANDOM_MIRRORING_ONLY |
static org.pepsoft.util.AttributeKey<java.lang.Boolean> |
ATTRIBUTE_RANDOM_ROTATION
Random rotation and mirroring, for historical reasons.
|
static org.pepsoft.util.AttributeKey<java.lang.Boolean> |
ATTRIBUTE_RANDOM_ROTATION_ONLY |
static org.pepsoft.util.AttributeKey<int[]> |
ATTRIBUTE_REPLACE_WITH_AIR
Deprecated.
|
static org.pepsoft.util.AttributeKey<Material> |
ATTRIBUTE_REPLACE_WITH_AIR_MATERIAL
When set, describes a material which will be replaced with air blocks
when this object is rendered.
|
static org.pepsoft.util.AttributeKey<java.lang.Boolean> |
ATTRIBUTE_SPAWN_IN_LAVA |
static org.pepsoft.util.AttributeKey<java.lang.Boolean> |
ATTRIBUTE_SPAWN_IN_WATER |
static org.pepsoft.util.AttributeKey<java.lang.Boolean> |
ATTRIBUTE_SPAWN_ON_LAND |
static org.pepsoft.util.AttributeKey<java.lang.Boolean> |
ATTRIBUTE_SPAWN_ON_LAVA |
static org.pepsoft.util.AttributeKey<java.lang.Boolean> |
ATTRIBUTE_SPAWN_ON_WATER |
static org.pepsoft.util.AttributeKey<java.lang.Boolean> |
ATTRIBUTE_SPAWN_ON_WATER_NO_COLLIDE |
static org.pepsoft.util.AttributeKey<java.lang.Integer> |
ATTRIBUTE_UNDERGROUND_MODE
Underground rendering mode.
|
static org.pepsoft.util.AttributeKey<java.lang.Integer> |
ATTRIBUTE_VERTICAL_OFFSET |
static org.pepsoft.util.AttributeKey<java.lang.Integer> |
ATTRIBUTE_Y_VARIATION |
static int |
COLLISION_MODE_ALL |
static int |
COLLISION_MODE_NONE |
static int |
COLLISION_MODE_SOLID |
static int |
HEIGHT_MODE_FIXED |
static int |
HEIGHT_MODE_TERRAIN |
static int |
LEAF_DECAY_NO_CHANGE |
static int |
LEAF_DECAY_OFF |
static int |
LEAF_DECAY_ON |
Modifier and Type | Method and Description |
---|---|
WPObject |
clone()
Create a clone of the object.
|
default void |
dump()
Dumps the object to the console.
|
default java.util.Set<Material> |
getAllMaterials()
Return all unique materials contained in this object.
|
default <T extends java.io.Serializable> |
getAttribute(org.pepsoft.util.AttributeKey<T> key)
Convencience method for getting the value of an attribute stored in the
external metadata, if any.
|
java.util.Map<java.lang.String,java.io.Serializable> |
getAttributes()
Get a live view of the object metadata.
|
javax.vecmath.Point3i |
getDimensions()
Get the dimensions of the object.
|
java.util.List<Entity> |
getEntities()
Get any entities contained in the object.
|
boolean |
getMask(int x,
int y,
int z)
Determine whether a block should be placed at the specified relative coordinates.
|
Material |
getMaterial(int x,
int y,
int z)
Get the material to place at the specified relative coordinates.
|
java.lang.String |
getName()
Get the name of the object.
|
javax.vecmath.Point3i |
getOffset()
Get the offset to apply to this object when placing it.
|
java.util.List<TileEntity> |
getTileEntities()
Get any tile entities contained in the object.
|
default void |
guessConnectBlocks()
Will guess whether the
ATTRIBUTE_CONNECT_BLOCKS attribute should be set and if so set it. |
default void |
guessManageWaterlogged()
TODO only for formats with named blocks which could conceivable contain the waterlogged property
|
default javax.vecmath.Point3i |
guestimateOffset()
Guestimate an offset for the object.
|
default boolean |
hasAttribute(org.pepsoft.util.AttributeKey<?> attributeKey)
Determine whether the object contains a value for a particular attribute.
|
void |
prepareForExport(Dimension dimension)
Make preparations, if necessary, for exporting the object.
|
<T extends java.io.Serializable> |
setAttribute(org.pepsoft.util.AttributeKey<T> key,
T value)
Convenience method for setting the value of an attribute stored in the
external metadata, if any.
|
void |
setAttributes(java.util.Map<java.lang.String,java.io.Serializable> attributes)
Store external metadata about the object.
|
void |
setName(java.lang.String name)
Set the name of the object.
|
default boolean |
visitBlocks(WPObject.BlockVisitor visitor)
Visit all blocks in the object.
|
static final int COLLISION_MODE_ALL
static final int COLLISION_MODE_SOLID
static final int COLLISION_MODE_NONE
static final int LEAF_DECAY_NO_CHANGE
static final int LEAF_DECAY_ON
static final int LEAF_DECAY_OFF
static final int HEIGHT_MODE_TERRAIN
static final int HEIGHT_MODE_FIXED
static final org.pepsoft.util.AttributeKey<java.io.File> ATTRIBUTE_FILE
static final org.pepsoft.util.AttributeKey<javax.vecmath.Point3i> ATTRIBUTE_OFFSET
static final org.pepsoft.util.AttributeKey<java.lang.Boolean> ATTRIBUTE_RANDOM_ROTATION
ATTRIBUTE_RANDOM_ROTATION_ONLY
and ATTRIBUTE_RANDOM_MIRRORING_ONLY
for separate attributes. If one or both of those attributes are
set, this one must be set to false
, since otherwise it defaults to true
and will override the
separate attributes.static final org.pepsoft.util.AttributeKey<java.lang.Boolean> ATTRIBUTE_NEEDS_FOUNDATION
static final org.pepsoft.util.AttributeKey<java.lang.Boolean> ATTRIBUTE_SPAWN_IN_WATER
static final org.pepsoft.util.AttributeKey<java.lang.Boolean> ATTRIBUTE_SPAWN_IN_LAVA
static final org.pepsoft.util.AttributeKey<java.lang.Boolean> ATTRIBUTE_SPAWN_ON_LAND
static final org.pepsoft.util.AttributeKey<java.lang.Boolean> ATTRIBUTE_SPAWN_ON_WATER
static final org.pepsoft.util.AttributeKey<java.lang.Boolean> ATTRIBUTE_SPAWN_ON_LAVA
static final org.pepsoft.util.AttributeKey<java.lang.Integer> ATTRIBUTE_FREQUENCY
static final org.pepsoft.util.AttributeKey<java.lang.Boolean> ATTRIBUTE_SPAWN_ON_WATER_NO_COLLIDE
static final org.pepsoft.util.AttributeKey<java.lang.Integer> ATTRIBUTE_COLLISION_MODE
Value | Meaning |
---|---|
COLLISION_MODE_ALL | Will collide with (and therefore not render) any above ground block other than air |
COLLISION_MODE_SOLID | Will collide with (and therefore not render) any above ground solid block (i.e. not air, grass, water, flowers, leaves, etc.). Default value |
COLLISION_MODE_NONE | Will not collide with any above ground block (and therefore intersect any other object already there!) |
static final org.pepsoft.util.AttributeKey<java.lang.Integer> ATTRIBUTE_UNDERGROUND_MODE
Value | Meaning |
---|---|
COLLISION_MODE_ALL | Every underground block belonging to the object will be rendered (including air blocks), regardless of what is already there. Default value |
COLLISION_MODE_SOLID | Every solid (i.e. not air, grass, water, flowers, leaves, etc.) underground block belonging to the object will be rendered regardless of what is already there. Non-solid blocks will be rendered only if the existing block is air |
COLLISION_MODE_NONE | Underground blocks belonging to the object will only be rendered if the existing block is air |
static final org.pepsoft.util.AttributeKey<java.lang.Integer> ATTRIBUTE_LEAF_DECAY_MODE
Value | Meaning |
---|---|
LEAF_DECAY_NO_CHANGE | Leaf blocks are copied unchanged from the custom object. Default value |
LEAF_DECAY_ON | All leaf blocks are set to decay regardless of their setting in the custom object |
LEAF_DECAY_OFF | All leaf blocks are set to not decay regardless of their setting in the custom object |
@Deprecated static final org.pepsoft.util.AttributeKey<int[]> ATTRIBUTE_REPLACE_WITH_AIR
ATTRIBUTE_REPLACE_WITH_AIR_MATERIAL
static final org.pepsoft.util.AttributeKey<Material> ATTRIBUTE_REPLACE_WITH_AIR_MATERIAL
static final org.pepsoft.util.AttributeKey<java.lang.Boolean> ATTRIBUTE_EXTEND_FOUNDATION
static final org.pepsoft.util.AttributeKey<java.lang.Boolean> ATTRIBUTE_RANDOM_ROTATION_ONLY
static final org.pepsoft.util.AttributeKey<java.lang.Boolean> ATTRIBUTE_RANDOM_MIRRORING_ONLY
static final org.pepsoft.util.AttributeKey<java.lang.Integer> ATTRIBUTE_HEIGHT_MODE
static final org.pepsoft.util.AttributeKey<java.lang.Integer> ATTRIBUTE_VERTICAL_OFFSET
static final org.pepsoft.util.AttributeKey<java.lang.Integer> ATTRIBUTE_Y_VARIATION
static final org.pepsoft.util.AttributeKey<java.lang.Boolean> ATTRIBUTE_CONNECT_BLOCKS
false
.static final org.pepsoft.util.AttributeKey<java.lang.Boolean> ATTRIBUTE_MANAGE_WATERLOGGED
Material.WATERLOGGED
property of the blocks should be automatically managed (set if there is
already water where the blocks are placed and reset if the target location is dry) or exported as set in the
object.java.lang.String getName()
void setName(java.lang.String name)
name
- The new name of the object.javax.vecmath.Point3i getDimensions()
javax.vecmath.Point3i getOffset()
This is a convenience method which must return the same as invoking
getAttribute(ATTRIBUTE_OFFSET)
. See
getAttribute(AttributeKey)
and ATTRIBUTE_OFFSET
.
Material getMaterial(int x, int y, int z)
getMask(int, int, int)
returns true
. These coordinates are zero-based and must never be
negative.x
- The relative X coordinate.y
- The relative Y coordinate.z
- The relative Z coordinate.default java.util.Set<Material> getAllMaterials()
boolean getMask(int x, int y, int z)
x
- The relative X coordinate.y
- The relative Y coordinate.z
- The relative Z coordinate.true
if a block should be placed at the specified relative coordinates.java.util.List<Entity> getEntities()
null
.java.util.List<TileEntity> getTileEntities()
null
.void prepareForExport(Dimension dimension)
getMask(int, int, int)
or
getMaterial(int, int, int)
are invoked.dimension
- The dimension for which the object is being exported.java.util.Map<java.lang.String,java.io.Serializable> getAttributes()
null
.default boolean hasAttribute(org.pepsoft.util.AttributeKey<?> attributeKey)
attributeKey
- The attribute key to check.true
if a value is set for the specified attribute.default <T extends java.io.Serializable> T getAttribute(org.pepsoft.util.AttributeKey<T> key)
null
) if it is
not.T
- The type of the attribute.key
- The key of the attribute.void setAttributes(java.util.Map<java.lang.String,java.io.Serializable> attributes)
attributes
- The external metadata to store.<T extends java.io.Serializable> void setAttribute(org.pepsoft.util.AttributeKey<T> key, T value)
null
will
delete the attribute from the store. If the store becomes empty it is
deleted entirely.T
- The type of the attribute.key
- The key of the attribute to set or delete.value
- The value of the attribute to set, or null
to
delete it.WPObject clone()
default javax.vecmath.Point3i guestimateOffset()
null
will be returned.
Note that this method calls getDimensions()
and getMask(int, int, int)
, so they must return valid values.
default boolean visitBlocks(WPObject.BlockVisitor visitor)
visitor
- The visitor to invoke for each block. If the visitor
returns false
the operation is aborted.true
if all blocks were visited or
false
if the visitor returned false
at some
point.default void guessConnectBlocks()
ATTRIBUTE_CONNECT_BLOCKS
attribute should be set and if so set it. Should only be
called for custom object formats which have legacy, numerical block IDs, for which you might want to set that
property.default void guessManageWaterlogged()
default void dump()