Interface IStructureElement<T>
-
- All Known Subinterfaces:
IStructureElementChain<T>,IStructureElementCheckOnly<T>,IStructureElementDeferred<T>,IStructureElementNoPlacement<T>
public interface IStructureElement<T>Use StructureUtility to instantiate. These are the building blocks for yourIStructureDefinition. It represents what a particular element can be and how this particular element should be autoplaced.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classIStructureElement.BlocksToPlacestatic classIStructureElement.PlaceResult
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description booleancheck(T t, World world, int x, int y, int z)default booleancouldBeValid(T t, World world, int x, int y, int z, ItemStack trigger)Pure (stateless and side effect free) function to test if current block could be valid.default IStructureElement.BlocksToPlacegetBlocksToPlace(T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env)A simplified version of survivalPlaceBlock.default java.util.List<java.lang.String>getDescription()Returns a human-readable description of what block(s) this element accepts.default intgetStepA()default intgetStepB()default intgetStepC()default booleanisNavigating()default IStructureElementNoPlacement<T>noPlacement()Forget the messed up class dependency graph for now.booleanplaceBlock(T t, World world, int x, int y, int z, ItemStack trigger)default booleanresetA()default booleanresetB()default booleanresetC()booleanspawnHint(T t, World world, int x, int y, int z, ItemStack trigger)default IStructureElement.PlaceResultsurvivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env)Try place the block by taking resource from givenIItemSource.default IStructureElement.PlaceResultsurvivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor, java.util.function.Consumer<IChatComponent> chatter)Deprecated.caller should call the non deprecated overload.
-
-
-
Method Detail
-
couldBeValid
default boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger)
Pure (stateless and side effect free) function to test if current block could be valid. Used to give user hints about incorrectly placed blocks given a controller and trigger item. If couldBeValid(...) == false for a set of channels, with those same tiers, check(...) == false. Not required, defaults to true which is always safe but won't give the user error hints.
-
getDescription
@Nullable default java.util.List<java.lang.String> getDescription()
Returns a human-readable description of what block(s) this element accepts. Used for diagnostic messages when structure checks fail (e.g. "expected Input Bus at (1, 2, 3)").Unlike
getBlocksToPlace(T, net.minecraft.world.World, int, int, int, net.minecraft.item.ItemStack, com.gtnewhorizon.structurelib.structure.AutoPlaceEnvironment), which returns the full set of concrete block variants for autoplacing (e.g. every tier of Input Bus), this method returns category-level descriptions suitable for display to the player (e.g. just "Input Bus"). It also requires no parameters, no world, trigger item, or environment, making it usable in contexts where those are unavailable.Implementations should return lang keys (e.g.
"tile.blockGlass.name") rather than pre-translated display names. The caller is responsible for translating these keys on the client side viaStatCollector.translateToLocal(). If a key has no matching translation,translateToLocalreturns the input string unchanged, so pre-translated fallback strings also work.- Returns:
- a list of accepted block descriptions as lang keys (or display names as fallback), or null if no description is available
-
survivalPlaceBlock
@Deprecated default IStructureElement.PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor, java.util.function.Consumer<IChatComponent> chatter)
Deprecated.caller should call the non deprecated overload. implementor for reusableIStructureElementshould still implement this. implementor for private implementations can freely ignore this as long as you know the caller will not call this overload.Try place the block by taking resource from given IItemSource.You might want to use
StructureUtility.survivalPlaceBlock(Block, int, World, int, int, int, IItemSource, net.minecraft.entity.player.EntityPlayer)or its overloads to implement this.- Parameters:
trigger- trigger items- drain resources from this placeactor- source of action. for very critical errors you can also just send the error messages here, bypassing any filter that chatter might have.chatter- send error messages here. Caller will choose an appropriate way to forward it to player if the other fallbacks also fails.
-
getBlocksToPlace
@Nullable default IStructureElement.BlocksToPlace getBlocksToPlace(T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env)
A simplified version of survivalPlaceBlock. Return null if not implemented.BY OVERRIDING THIS TO NULL, YOU ACKNOWLEDGE THAT THE
check(Object, World, int, int, int)OF THIS CLASS IS SIDE EFFECT FREE AND CAN HAVE ITS CHECK CALLED WITHOUT BREAKING ANYTHING. OTHERWISE OVERRIDE THEsurvivalPlaceBlock(Object, World, int, int, int, ItemStack, AutoPlaceEnvironment)TO PROVIDE A SIDEEFFECT FREEIStructureElement.PlaceResult.SKIP.It should be noticed that this filter is only advisory and the actual
survivalPlaceBlock(Object, World, int, int, int, ItemStack, AutoPlaceEnvironment)orcheck(Object, World, int, int, int)are free to reject/accept/place blocks not contained in this list, e.g. when the element can be placed anywhere in the structure, but no more than 3 overall; when the structure element cannot know all blocks it will accept at the time of calling; when this is backed by a legacyIStructureElementthat just didn't implement this API.- Parameters:
trigger- trigger itemenv- autoplacing environment- Returns:
- null if not implemented, otherwise an instance describing what kind of blocks will be placed by
survivalPlaceBlock(Object, World, int, int, int, ItemStack, AutoPlaceEnvironment)
-
survivalPlaceBlock
default IStructureElement.PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env)
Try place the block by taking resource from givenIItemSource.You might want to use
StructureUtility.survivalPlaceBlock(Block, int, World, int, int, int, IItemSource, net.minecraft.entity.player.EntityPlayer)or its overloads to implement this.The default implementation provided will
- Get
IStructureElement.BlocksToPlaceviagetBlocksToPlace(Object, World, int, int, int, ItemStack, AutoPlaceEnvironment). If not null- call
check(Object, World, int, int, int). If this returnstrue,IStructureElement.PlaceResult.SKIPwill be returned without further action. - Use the
IStructureElement.BlocksToPlaceretrieved earlier and passed inIItemSourceto determine an item to place - Hand over control to
StructureUtility.survivalPlaceBlock(ItemStack, NBTMode, NBTTagCompound, boolean, World, int, int, int, IItemSource, EntityPlayer, Consumer)
- call
- Call legacy
survivalPlaceBlock(Object, World, int, int, int, ItemStack, IItemSource, EntityPlayerMP, Consumer)ifenv.getActor()contains anEntityPlayerMP - Emit warning under debug mode (or throw exception under panic mode), then return
IStructureElement.PlaceResult.SKIP
check(Object, World, int, int, int)is not side effect free, or is not idempotent. E.g. thecheck(Object, World, int, int, int)will add current coord to aList. As this method might be invoked at a location that is already accepted, this will cause the machine to have multiple of this coord in its list.- Parameters:
trigger- trigger itemenv- autoplacing environment
- Get
-
noPlacement
default IStructureElementNoPlacement<T> noPlacement()
Forget the messed up class dependency graph for now. this is just so convenient.
-
getStepA
default int getStepA()
-
getStepB
default int getStepB()
-
getStepC
default int getStepC()
-
resetA
default boolean resetA()
-
resetB
default boolean resetB()
-
resetC
default boolean resetC()
-
isNavigating
default boolean isNavigating()
-
-