Interface IStructureHandler
- All Known Implementing Classes:
AbstractStructureHandler,CreativeStructureHandler
public interface IStructureHandler
A handler for structures.
Handlers hold necessary and specific information about the entity/block/etc that is executing the placement.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanIf the handler allows to replace or requires to mine the block first.default voidConsume the items from the handler inventory if existent.booleanIf this is supposed to be fancy placement (player facing) or builder facing (complete).Get the bluerint from the handler.net.minecraft.world.item.ItemStackThe item being held by the handler@Nullable net.neoforged.neoforge.items.IItemHandlerGet the inventory of the handler.intHow many blocks are checked max per call.getMd5()Get the md5 value.default net.minecraft.core.BlockPosgetProgressPosInWorld(net.minecraft.core.BlockPos localPos) Get the position in the world translated from a local pos in the structure.Getter for the placement settings.net.minecraft.world.level.block.state.BlockStategetSolidBlockForPos(net.minecraft.core.BlockPos worldPos, Function<net.minecraft.core.BlockPos, @Nullable net.minecraft.world.level.block.state.BlockState> virtualBlocks) Get the solid worldgen block for given pos while using data from handler.intHow many steps are executed on per call.default net.minecraft.core.BlockPosgetStructurePosFromWorld(net.minecraft.core.BlockPos worldPos) Get the position in the blueprint translated from world pos.net.minecraft.world.level.LevelgetWorld()Get the world from the handler.net.minecraft.core.BlockPosGet the world position this is placed at.booleanCheck if the handler has a valid blueprint.booleanhasRequiredItems(List<net.minecraft.world.item.ItemStack> requiredItems) Check if the handler has the required items for an action.default booleanisCorrectMD5(String otherMD5) Compare the md5 from the structure with an other md5 hash.booleanIf creative placement (Free placement without inventory).booleanisReady()Check if the handler is ready.booleanisStackFree(@Nullable net.minecraft.world.item.ItemStack stack) Check if the stack is free for this handler.default voidPossible on complete hooks after placement.voidprePlacementLogic(net.minecraft.core.BlockPos worldPos, net.minecraft.world.level.block.state.BlockState blockState, List<net.minecraft.world.item.ItemStack> requiredItems) Execute pre placement logic if necessary.booleanreplaceWithSolidBlock(net.minecraft.world.level.block.state.BlockState blockState) Check if this block is considered solid for the solid placerholder blocks.voidsetBlueprint(Blueprint blueprint) Set the blueprint.voidSet the md5 value.booleanshouldBlocksBeConsideredEqual(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.block.state.BlockState state1) Special equal condition check.voidtriggerEntitySuccess(net.minecraft.core.BlockPos pos, List<net.minecraft.world.item.ItemStack> requiredRes, boolean placement) Trigger entity success.voidtriggerSuccess(net.minecraft.core.BlockPos pos, List<net.minecraft.world.item.ItemStack> requiredRes, boolean placement) Trigger success AFTER placement of block.
-
Method Details
-
setBlueprint
Set the blueprint.- Parameters:
blueprint- the blueprint to set.
-
setMd5
Set the md5 value.- Parameters:
calculatedMD5- the calculated md5.
-
getMd5
String getMd5()Get the md5 value.- Returns:
- the md5.
-
isCorrectMD5
Compare the md5 from the structure with an other md5 hash.- Parameters:
otherMD5- to compare with- Returns:
- whether the otherMD5 match, return false if md5 is null
-
getBluePrint
Blueprint getBluePrint()Get the bluerint from the handler.- Returns:
- the blueprint
-
getWorld
net.minecraft.world.level.Level getWorld()Get the world from the handler.- Returns:
- the world.
-
getWorldPos
net.minecraft.core.BlockPos getWorldPos()Get the world position this is placed at.- Returns:
- the position.
-
getRotationMirror
RotationMirror getRotationMirror()Getter for the placement settings.- Returns:
- the settings object.
-
getInventory
@Nullable @Nullable net.neoforged.neoforge.items.IItemHandler getInventory()Get the inventory of the handler.- Returns:
- the IItemhandler (may be null!).
-
triggerSuccess
void triggerSuccess(net.minecraft.core.BlockPos pos, List<net.minecraft.world.item.ItemStack> requiredRes, boolean placement) Trigger success AFTER placement of block.- Parameters:
pos- the pos it was placed at.requiredRes- the list of required res.placement- if through placement (true) or through equality (false).
-
triggerEntitySuccess
void triggerEntitySuccess(net.minecraft.core.BlockPos pos, List<net.minecraft.world.item.ItemStack> requiredRes, boolean placement) Trigger entity success.- Parameters:
pos- the position the entity was placed at.requiredRes- the list of required res.placement- if through placement (true) or through equality (false).
-
isCreative
boolean isCreative()If creative placement (Free placement without inventory).- Returns:
- true if so.
-
hasBluePrint
boolean hasBluePrint()Check if the handler has a valid blueprint.- Returns:
- true if so.
-
getStepsPerCall
int getStepsPerCall()How many steps are executed on per call.- Returns:
- the number of steps.
-
getMaxBlocksCheckedPerCall
int getMaxBlocksCheckedPerCall()How many blocks are checked max per call.- Returns:
- the max number.
-
isStackFree
boolean isStackFree(@Nullable @Nullable net.minecraft.world.item.ItemStack stack) Check if the stack is free for this handler.- Parameters:
stack- the stack to check.- Returns:
- true if so.
-
allowReplace
boolean allowReplace()If the handler allows to replace or requires to mine the block first.- Returns:
- true if so.
-
getHeldItem
net.minecraft.world.item.ItemStack getHeldItem()The item being held by the handler- Returns:
- the Item (could be empty).
-
replaceWithSolidBlock
boolean replaceWithSolidBlock(net.minecraft.world.level.block.state.BlockState blockState) Check if this block is considered solid for the solid placerholder blocks.- Parameters:
blockState- the blockState to check.- Returns:
- true if it should be replaced.
-
fancyPlacement
boolean fancyPlacement()If this is supposed to be fancy placement (player facing) or builder facing (complete).- Returns:
- true if fancy placement.
-
shouldBlocksBeConsideredEqual
boolean shouldBlocksBeConsideredEqual(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.block.state.BlockState state1) Special equal condition check.- Parameters:
state- the first state.state1- the second state.- Returns:
- true if considered equal and block should be skipped.
-
hasRequiredItems
Check if the handler has the required items for an action.- Parameters:
requiredItems- the list of items.- Returns:
- true if so.
-
consume
Consume the items from the handler inventory if existent.- Parameters:
requiredItems- the items to consume.
-
getProgressPosInWorld
default net.minecraft.core.BlockPos getProgressPosInWorld(net.minecraft.core.BlockPos localPos) Get the position in the world translated from a local pos in the structure.- Parameters:
localPos- the local structure pos.- Returns:
- the world pos.
-
getStructurePosFromWorld
default net.minecraft.core.BlockPos getStructurePosFromWorld(net.minecraft.core.BlockPos worldPos) Get the position in the blueprint translated from world pos.- Parameters:
worldPos- the world pos.- Returns:
- the structure pos.
-
prePlacementLogic
void prePlacementLogic(net.minecraft.core.BlockPos worldPos, net.minecraft.world.level.block.state.BlockState blockState, List<net.minecraft.world.item.ItemStack> requiredItems) Execute pre placement logic if necessary.- Parameters:
worldPos- the position the block si going to be placed.blockState- the blockstate to be placed.requiredItems- the list of required items.
-
getSolidBlockForPos
net.minecraft.world.level.block.state.BlockState getSolidBlockForPos(net.minecraft.core.BlockPos worldPos, Function<net.minecraft.core.BlockPos, @Nullable net.minecraft.world.level.block.state.BlockState> virtualBlocks) Get the solid worldgen block for given pos while using data from handler.- Parameters:
worldPos- the world pos.virtualBlocks- blueprint blocks, fnc may return null if virtual block is not available (then use level instead for getting surrounding block states), pos argument is using world coords- Returns:
- the solid worldgen block (classically biome dependent).
-
isReady
boolean isReady()Check if the handler is ready.- Returns:
- true if so.
-
onCompletion
default void onCompletion()Possible on complete hooks after placement.
-