T - Type of the context object. Usually this will be the multiblock controller.public interface IStructureDefinition<T>
You will construct this definition once per multi, either at class load or at first call to your variant of
getStructureDefinition(). You can use a ClassValue<IStructureDefinition<?>> if you
have a template for subclass. You can also use defer() or its overloads for
simpler cases, but it is slightly less performant as it will allocate new objects on each structure check, whereas
ClassValue will allocate once and cache it onwards.
IStructureDefinition is constructed using builder()
Builder has two main methods:
addShape() is a 2d string array describing the layout of structure. You can optionally use
`StructureUtility#transpose()` to transpose the array to make the structure look nicer in source code.
addElement(). It takes a char identifier (mapped to a char in any of
addShape()
calls) and a IStructureElement.
| Modifier and Type | Method and Description |
|---|---|
default boolean |
build(T object,
ItemStack trigger,
String piece,
World world,
ExtendedFacing extendedFacing,
int basePositionX,
int basePositionY,
int basePositionZ,
int basePositionA,
int basePositionB,
int basePositionC)
Build the multi in creative mode on a best-effort basis.
|
static <T> StructureDefinition.Builder<T> |
builder()
Create a new instance of builder.
|
default boolean |
buildOrHints(T object,
ItemStack trigger,
String piece,
World world,
ExtendedFacing extendedFacing,
int basePositionX,
int basePositionY,
int basePositionZ,
int basePositionA,
int basePositionB,
int basePositionC,
boolean hintsOnly)
|
default boolean |
check(T object,
String piece,
World world,
ExtendedFacing extendedFacing,
int basePositionX,
int basePositionY,
int basePositionZ,
int basePositionA,
int basePositionB,
int basePositionC,
boolean forceCheckAllBlocks)
Run a structure check.
|
IStructureElement<T>[] |
getStructureFor(String name)
Used internally
|
default boolean |
hints(T object,
ItemStack trigger,
String piece,
World world,
ExtendedFacing extendedFacing,
int basePositionX,
int basePositionY,
int basePositionZ,
int basePositionA,
int basePositionB,
int basePositionC)
Spawn hint particles.
|
boolean |
isContainedInStructure(String name,
int offsetA,
int offsetB,
int offsetC) |
static <T> boolean |
iterate(T object,
ItemStack trigger,
IStructureElement<T>[] elements,
World world,
ExtendedFacing extendedFacing,
int basePositionX,
int basePositionY,
int basePositionZ,
int basePositionA,
int basePositionB,
int basePositionC,
boolean hintsOnly,
Boolean checkBlocksIfNotNullForceCheckAllIfTrue)
Low level utility.
|
default int |
survivalBuild(T object,
ItemStack trigger,
String piece,
World world,
ExtendedFacing extendedFacing,
int basePositionX,
int basePositionY,
int basePositionZ,
int basePositionA,
int basePositionB,
int basePositionC,
int elementBudget,
IItemSource source,
EntityPlayerMP actor,
boolean check)
Deprecated.
|
default int |
survivalBuild(T object,
ItemStack trigger,
String piece,
World world,
ExtendedFacing extendedFacing,
int basePositionX,
int basePositionY,
int basePositionZ,
int basePositionA,
int basePositionB,
int basePositionC,
int elementBudget,
ISurvivalBuildEnvironment env,
boolean check)
Cause a survival build.
|
IStructureElement<T>[] getStructureFor(String name)
Might, but is not required, to throw NoSuchElementException if the given structure piece is not
found.
name - same name as for other methods hereNoSuchElementException - if the given structure piece is not found and the moon phase perfectly
matchesboolean isContainedInStructure(String name, int offsetA, int offsetB, int offsetC)
default boolean check(T object, String piece, World world, ExtendedFacing extendedFacing, int basePositionX, int basePositionY, int basePositionZ, int basePositionA, int basePositionB, int basePositionC, boolean forceCheckAllBlocks)
object - context object. usually multiblock controller.piece - the structure piece's string identifier.world - the world object this check takes place in.extendedFacing - the current structure's orientation.basePositionX - X location of the structurebasePositionY - Y location of the structurebasePositionZ - Z location of the structurebasePositionA - see class javadocbasePositionB - see class javadocbasePositionC - see class javadocforceCheckAllBlocks - check all location even if chunk not currently loaded.default boolean hints(T object, ItemStack trigger, String piece, World world, ExtendedFacing extendedFacing, int basePositionX, int basePositionY, int basePositionZ, int basePositionA, int basePositionB, int basePositionC)
object - context object. usually multiblock controller.piece - the structure piece's string identifier.world - the world object this check takes place in.extendedFacing - the current structure's orientation.basePositionX - X location of the structurebasePositionY - Y location of the structurebasePositionZ - Z location of the structurebasePositionA - see class javadocbasePositionB - see class javadocbasePositionC - see class javadocdefault boolean build(T object, ItemStack trigger, String piece, World world, ExtendedFacing extendedFacing, int basePositionX, int basePositionY, int basePositionZ, int basePositionA, int basePositionB, int basePositionC)
object - context object. usually multiblock controller.trigger - The trigger item that contains channel data.piece - the structure piece's string identifier.world - the world object this check takes place in.extendedFacing - the current structure's orientation.basePositionX - X location of the structurebasePositionY - Y location of the structurebasePositionZ - Z location of the structurebasePositionA - see class javadocbasePositionB - see class javadocbasePositionC - see class javadocdefault boolean buildOrHints(T object, ItemStack trigger, String piece, World world, ExtendedFacing extendedFacing, int basePositionX, int basePositionY, int basePositionZ, int basePositionA, int basePositionB, int basePositionC, boolean hintsOnly)
build(Object, ItemStack, String, World, ExtendedFacing, int, int, int, int, int, int) if
hintsOnly, call
hints(Object, ItemStack, String, World, ExtendedFacing, int, int, int, int, int, int) otherwise.object - context object. usually multiblock controller.trigger - The trigger item that contains channel data.piece - the structure piece's string identifier.world - the world object this check takes place in.extendedFacing - the current structure's orientation.basePositionX - X location of the structurebasePositionY - Y location of the structurebasePositionZ - Z location of the structurebasePositionA - see class javadocbasePositionB - see class javadocbasePositionC - see class javadochintsOnly - whether to spawn hints or do creative build.hints(Object, ItemStack, String, World, ExtendedFacing, int, int, int, int, int, int),
build(Object, ItemStack, String, World, ExtendedFacing, int, int, int, int, int, int)@Deprecated default int survivalBuild(T object, ItemStack trigger, String piece, World world, ExtendedFacing extendedFacing, int basePositionX, int basePositionY, int basePositionZ, int basePositionA, int basePositionB, int basePositionC, int elementBudget, IItemSource source, EntityPlayerMP actor, boolean check)
object - context object. usually multiblock controller.trigger - The trigger item that contains channel data.piece - the structure piece's string identifier.world - the world object this check takes place in.extendedFacing - the current structure's orientation.basePositionX - X location of the structurebasePositionY - Y location of the structurebasePositionZ - Z location of the structurebasePositionA - see class javadocbasePositionB - see class javadocbasePositionC - see class javadocelementBudget - build up to this many elementssource - from where to drain resourceactor - source of actioncheck - whether IStructureElement.check(Object, World, int, int, int) should be called if
anything would be placed. use with caution. if in doubt, call
check(Object, String, World, ExtendedFacing, int, int, int, int, int, int, boolean)
after this call and set this parameter to falsebuild(Object, ItemStack, String, World, ExtendedFacing, int, int, int, int, int, int)default int survivalBuild(T object, ItemStack trigger, String piece, World world, ExtendedFacing extendedFacing, int basePositionX, int basePositionY, int basePositionZ, int basePositionA, int basePositionB, int basePositionC, int elementBudget, ISurvivalBuildEnvironment env, boolean check)
object - context object. usually multiblock controller.trigger - The trigger item that contains channel data.piece - the structure piece's string identifier.world - the world object this check takes place in.extendedFacing - the current structure's orientation.basePositionX - X location of the structurebasePositionY - Y location of the structurebasePositionZ - Z location of the structurebasePositionA - see class javadocbasePositionB - see class javadocbasePositionC - see class javadocelementBudget - build up to this many elementsenv - build environment.check - whether IStructureElement.check(Object, World, int, int, int) should be called if
anything would be placed. use with caution. if in doubt, call
check(Object, String, World, ExtendedFacing, int, int, int, int, int, int, boolean)
after this call and set this parameter to falsebuild(Object, ItemStack, String, World, ExtendedFacing, int, int, int, int, int, int)static <T> boolean iterate(T object,
ItemStack trigger,
IStructureElement<T>[] elements,
World world,
ExtendedFacing extendedFacing,
int basePositionX,
int basePositionY,
int basePositionZ,
int basePositionA,
int basePositionB,
int basePositionC,
boolean hintsOnly,
Boolean checkBlocksIfNotNullForceCheckAllIfTrue)
T - type of context object.object - context object. usually multiblock controller.trigger - The trigger item that contains channel data.elements - the structure pieceworld - the world object this check takes place in.extendedFacing - the current structure's orientation.basePositionX - X location of the structurebasePositionY - Y location of the structurebasePositionZ - Z location of the structurebasePositionA - see class javadocbasePositionB - see class javadocbasePositionC - see class javadochintsOnly - whether to spawn hints or do creative build. no effect if
checkBlocksIfNotNullForceCheckAllIfTrue is not null.checkBlocksIfNotNullForceCheckAllIfTrue - creative build or spawn hints if null. Force check not loaded
chunk if true. Check only loaded chunk is false.static <T> StructureDefinition.Builder<T> builder()
T - type of context object