Interface IStructureElementChain<T>
-
- All Superinterfaces:
IStructureElement<T>
public interface IStructureElementChain<T> extends IStructureElement<T>
Use StructureUtility to instantiate
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.gtnewhorizon.structurelib.structure.IStructureElement
IStructureElement.BlocksToPlace, IStructureElement.PlaceResult
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default 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.IStructureElement<T>[]fallbacks()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 booleanplaceBlock(T t, World world, int x, int y, int z, ItemStack trigger)default 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)Try place the block by taking resource from given IItemSource.-
Methods inherited from interface com.gtnewhorizon.structurelib.structure.IStructureElement
getStepA, getStepB, getStepC, isNavigating, noPlacement, resetA, resetB, resetC
-
-
-
-
Method Detail
-
fallbacks
IStructureElement<T>[] fallbacks()
-
check
default boolean check(T t, World world, int x, int y, int z)
- Specified by:
checkin interfaceIStructureElement<T>
-
couldBeValid
default boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger)
Description copied from interface:IStructureElementPure (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.- Specified by:
couldBeValidin interfaceIStructureElement<T>
-
spawnHint
default boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger)
- Specified by:
spawnHintin interfaceIStructureElement<T>
-
placeBlock
default boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger)
- Specified by:
placeBlockin interfaceIStructureElement<T>
-
getDescription
@Nullable default java.util.List<java.lang.String> getDescription()
Description copied from interface:IStructureElementReturns 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
IStructureElement.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.- Specified by:
getDescriptionin interfaceIStructureElement<T>- Returns:
- a list of accepted block descriptions as lang keys (or display names as fallback), or null if no description is available
-
getBlocksToPlace
@Nullable default IStructureElement.BlocksToPlace getBlocksToPlace(T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env)
Description copied from interface:IStructureElementA simplified version of survivalPlaceBlock. Return null if not implemented.BY OVERRIDING THIS TO NULL, YOU ACKNOWLEDGE THAT THE
IStructureElement.check(Object, World, int, int, int)OF THIS CLASS IS SIDE EFFECT FREE AND CAN HAVE ITS CHECK CALLED WITHOUT BREAKING ANYTHING. OTHERWISE OVERRIDE THEIStructureElement.survivalPlaceBlock(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
IStructureElement.survivalPlaceBlock(Object, World, int, int, int, ItemStack, AutoPlaceEnvironment)orIStructureElement.check(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.- Specified by:
getBlocksToPlacein interfaceIStructureElement<T>trigger- trigger itemenv- autoplacing environment- Returns:
- null if not implemented, otherwise an instance describing what kind of blocks will be placed by
IStructureElement.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, IItemSource s, EntityPlayerMP actor, java.util.function.Consumer<IChatComponent> chatter)
Description copied from interface:IStructureElementTry 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.- Specified by:
survivalPlaceBlockin interfaceIStructureElement<T>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.
-
survivalPlaceBlock
default IStructureElement.PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env)
Description copied from interface:IStructureElementTry 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.BlocksToPlaceviaIStructureElement.getBlocksToPlace(Object, World, int, int, int, ItemStack, AutoPlaceEnvironment). If not null- call
IStructureElement.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
IStructureElement.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
IStructureElement.check(Object, World, int, int, int)is not side effect free, or is not idempotent. E.g. theIStructureElement.check(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.- Specified by:
survivalPlaceBlockin interfaceIStructureElement<T>trigger- trigger itemenv- autoplacing environment
- Get
-
-