public interface IStructureElement<T>
IStructureDefinition. It
represents what a particular element can be and how this particular element should be autoplaced.| Modifier and Type | Interface and Description |
|---|---|
static class |
IStructureElement.BlocksToPlace |
static class |
IStructureElement.PlaceResult |
| Modifier and Type | Method and Description |
|---|---|
boolean |
check(T t,
World world,
int x,
int y,
int z) |
default IStructureElement.BlocksToPlace |
getBlocksToPlace(T t,
World world,
int x,
int y,
int z,
ItemStack trigger,
AutoPlaceEnvironment env)
A simplified version of survivalPlaceBlock.
|
default int |
getStepA() |
default int |
getStepB() |
default int |
getStepC() |
default boolean |
isNavigating() |
default IStructureElementNoPlacement<T> |
noPlacement()
Forget the messed up class dependency graph for now.
|
boolean |
placeBlock(T t,
World world,
int x,
int y,
int z,
ItemStack trigger) |
default boolean |
resetA() |
default boolean |
resetB() |
default boolean |
resetC() |
boolean |
spawnHint(T t,
World world,
int x,
int y,
int z,
ItemStack trigger) |
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 given
IItemSource. |
default IStructureElement.PlaceResult |
survivalPlaceBlock(T t,
World world,
int x,
int y,
int z,
ItemStack trigger,
IItemSource s,
EntityPlayerMP actor,
Consumer<IChatComponent> chatter)
Deprecated.
caller should call the non deprecated overload. implementor for reusable
IStructureElement
should still implement this. implementor for private implementations can freely ignore this as long
as you know the caller will not call this overload. |
@Deprecated default IStructureElement.PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor, Consumer<IChatComponent> chatter)
IStructureElement
should still implement this. implementor for private implementations can freely ignore this as long
as you know the caller will not call this overload.
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.
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.@Nullable default IStructureElement.BlocksToPlace getBlocksToPlace(T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env)
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 THE
survivalPlaceBlock(Object, World, int, int, int, ItemStack, AutoPlaceEnvironment) TO PROVIDE A
SIDEEFFECT FREE IStructureElement.PlaceResult.SKIP.
It should be noticed that this filter is only advisory and the actual
survivalPlaceBlock(Object, World, int, int, int, ItemStack, AutoPlaceEnvironment) or
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 legacy
IStructureElement that just didn't implement this API.
trigger - trigger itemenv - autoplacing environmentsurvivalPlaceBlock(Object, World, int, int, int, ItemStack, AutoPlaceEnvironment)default IStructureElement.PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env)
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.
The default implementation provided will
IStructureElement.BlocksToPlace via
getBlocksToPlace(Object, World, int, int, int, ItemStack, AutoPlaceEnvironment). If not null
check(Object, World, int, int, int). If this returns true, IStructureElement.PlaceResult.SKIP
will be returned without further action.IStructureElement.BlocksToPlace retrieved earlier and passed in IItemSource to determine an item to
placeStructureUtility#survivalPlaceBlock(ItemStack, NBTMode, NBTTagCompound, boolean, World, int, int, int, IItemSource, EntityPlayer, Consumer)survivalPlaceBlock(Object, World, int, int, int, ItemStack, IItemSource, EntityPlayerMP, Consumer) if
env.getActor() contains an EntityPlayerMPIStructureElement.PlaceResult.SKIPcheck(Object, World, int, int, int) is not side effect free, or is not idempotent. E.g. the
check(Object, World, int, int, int) will add current coord to a List. 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.trigger - trigger itemenv - autoplacing environmentdefault IStructureElementNoPlacement<T> noPlacement()
default int getStepA()
default int getStepB()
default int getStepC()
default boolean resetA()
default boolean resetB()
default boolean resetC()
default boolean isNavigating()