Interface IStructureDefinition<T>
-
- Type Parameters:
T- Type of the context object. Usually this will be the multiblock controller.
- All Known Implementing Classes:
StructureDefinition
public interface IStructureDefinition<T>This is the structure definition of your multi. You will have one of these for each multi.Cache the instances of this class
You will construct this definition once per multi, either at class load or at first call to your variant of
getStructureDefinition(). You can use aClassValue<IStructureDefinition<?>>if you have a template for subclass. You can also usedefer()or its overloads for simpler cases, but it is slightly less performant as it will allocate new objects on each structure check, whereasClassValuewill allocate once and cache it onwards.Constructing
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 ofaddShape()calls) and aIStructureElement.
Position A, B and C
Imagine you stand in front of the controller, with controller facing towards you not rotated or flipped.- The "A" position would be the number of blocks on the left side of the controller, not counting controller itself.
- The "B" position would be the number of blocks on the top side of the controller, not counting controller itself.
- The "C" position would be the number of blocks between you and controller, not counting controller itself.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description default booleanbuild(T object, ItemStack trigger, java.lang.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 booleanbuildOrHints(T object, ItemStack trigger, java.lang.String piece, World world, ExtendedFacing extendedFacing, int basePositionX, int basePositionY, int basePositionZ, int basePositionA, int basePositionB, int basePositionC, boolean hintsOnly)default booleancheck(T object, java.lang.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(java.lang.String name)Used internallydefault booleanhints(T object, ItemStack trigger, java.lang.String piece, World world, ExtendedFacing extendedFacing, int basePositionX, int basePositionY, int basePositionZ, int basePositionA, int basePositionB, int basePositionC)Spawn hint particles.booleanisContainedInStructure(java.lang.String name, int offsetA, int offsetB, int offsetC)default voiditerate(java.lang.String piece, World world, ExtendedFacing extendedFacing, int basePositionX, int basePositionY, int basePositionZ, int basePositionA, int basePositionB, int basePositionC, IStructureWalker<T> predicate)static <T> booleaniterate(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, java.lang.Boolean checkBlocksIfNotNullForceCheckAllIfTrue)Low level utility.default intsurvivalBuild(T object, ItemStack trigger, java.lang.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 intsurvivalBuild(T object, ItemStack trigger, java.lang.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.
-
-
-
Method Detail
-
getStructureFor
IStructureElement<T>[] getStructureFor(java.lang.String name)
Used internallyMight, but is not required, to throw
NoSuchElementExceptionif the given structure piece is not found.- Parameters:
name- same name as for other methods here- Returns:
- the array of elements to process
- Throws:
java.util.NoSuchElementException- if the given structure piece is not found and the moon phase perfectly matches
-
isContainedInStructure
boolean isContainedInStructure(java.lang.String name, int offsetA, int offsetB, int offsetC)
-
check
default boolean check(T object, java.lang.String piece, World world, ExtendedFacing extendedFacing, int basePositionX, int basePositionY, int basePositionZ, int basePositionA, int basePositionB, int basePositionC, boolean forceCheckAllBlocks)
Run a structure check.- Parameters:
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.- Returns:
- true if successful, false otherwise
-
hints
default boolean hints(T object, ItemStack trigger, java.lang.String piece, World world, ExtendedFacing extendedFacing, int basePositionX, int basePositionY, int basePositionZ, int basePositionA, int basePositionB, int basePositionC)
Spawn hint particles. Should not be called on server side.- Parameters:
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 javadoc- Returns:
- true if successful, false otherwise
-
build
default boolean build(T object, ItemStack trigger, java.lang.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. Does not guarantee the structure is correct after a successful call.- Parameters:
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 javadoc- Returns:
- true if sucessful, false otherwise
-
buildOrHints
default boolean buildOrHints(T object, ItemStack trigger, java.lang.String piece, World world, ExtendedFacing extendedFacing, int basePositionX, int basePositionY, int basePositionZ, int basePositionA, int basePositionB, int basePositionC, boolean hintsOnly)
Callbuild(Object, ItemStack, String, World, ExtendedFacing, int, int, int, int, int, int)ifhintsOnly, callhints(Object, ItemStack, String, World, ExtendedFacing, int, int, int, int, int, int)otherwise.- Parameters:
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.- Returns:
- true if sucessful, false otherwise
- See Also:
hints(Object, ItemStack, String, World, ExtendedFacing, int, int, int, int, int, int),build(Object, ItemStack, String, World, ExtendedFacing, int, int, int, int, int, int)
-
survivalBuild
@Deprecated default int survivalBuild(T object, ItemStack trigger, java.lang.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.Cause a survival build.- Parameters:
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- whetherIStructureElement.check(Object, World, int, int, int)should be called if anything would be placed. use with caution. if in doubt, callcheck(Object, String, World, ExtendedFacing, int, int, int, int, int, int, boolean)after this call and set this parameter to false- Returns:
- number of elements built, or -1 if structure done
- See Also:
build(Object, ItemStack, String, World, ExtendedFacing, int, int, int, int, int, int)
-
survivalBuild
default int survivalBuild(T object, ItemStack trigger, java.lang.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.- Parameters:
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- whetherIStructureElement.check(Object, World, int, int, int)should be called if anything would be placed. use with caution. if in doubt, callcheck(Object, String, World, ExtendedFacing, int, int, int, int, int, int, boolean)after this call and set this parameter to false- Returns:
- number of elements built, or -1 if structure done
- See Also:
build(Object, ItemStack, String, World, ExtendedFacing, int, int, int, int, int, int)
-
iterate
default void iterate(java.lang.String piece, World world, ExtendedFacing extendedFacing, int basePositionX, int basePositionY, int basePositionZ, int basePositionA, int basePositionB, int basePositionC, IStructureWalker<T> predicate)
-
iterate
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, java.lang.Boolean checkBlocksIfNotNullForceCheckAllIfTrue)Low level utility.- Type Parameters:
T- type of context object.- Parameters:
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 ifcheckBlocksIfNotNullForceCheckAllIfTrueis not null.checkBlocksIfNotNullForceCheckAllIfTrue- creative build or spawn hints if null. Force check not loaded chunk if true. Check only loaded chunk is false.- Returns:
- true if iteration completed successfully.
-
builder
static <T> StructureDefinition.Builder<T> builder()
Create a new instance of builder.- Type Parameters:
T- type of context object
-
-