Interface IStructureHandler

All Superinterfaces:
IPlacementContext
All Known Implementing Classes:
AbstractStructureHandler, CreativeStructureHandler

public interface IStructureHandler extends IPlacementContext
A handler for structures. Handlers hold necessary and specific information about the entity/block/etc that is executing the placement.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    If the handler allows to replace or requires to mine the block first.
    default void
    consume(List<net.minecraft.world.item.ItemStack> requiredItems)
    Consume the items from the handler inventory if existent.
    net.minecraft.world.item.ItemStack
    The item being held by the handler
    @Nullable net.minecraftforge.items.IItemHandler
    Get the inventory of the handler.
    int
    How many blocks are checked max per call.
    Get the md5 value.
    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.
    Getter for the placement settings.
    net.minecraft.world.level.block.state.BlockState
    getSolidBlockForPos(net.minecraft.core.BlockPos worldPos)
    Deprecated, for removal: This API element is subject to removal in a future version.
    net.minecraft.world.level.block.state.BlockState
    getSolidBlockForPos(net.minecraft.core.BlockPos worldPos, @Nullable Function<net.minecraft.core.BlockPos,net.minecraft.world.level.block.state.BlockState> virtualBlocks)
    Get the solid worldgen block for given pos while using data from handler.
    int
    How many steps are executed on per call.
    default net.minecraft.core.BlockPos
    getStructurePosFromWorld(net.minecraft.core.BlockPos worldPos)
    Get the position in the blueprint translated from world pos.
    net.minecraft.world.level.Level
    Get the world from the handler.
    boolean
    Check if the handler has a valid blueprint.
    boolean
    hasRequiredItems(List<net.minecraft.world.item.ItemStack> requiredItems)
    Check if the handler has the required items for an action.
    default boolean
    isCorrectMD5(String otherMD5)
    Compare the md5 from the structure with an other md5 hash.
    boolean
    If creative placement (Free placement without inventory).
    boolean
    Check if the handler is ready.
    boolean
    isStackFree(@Nullable net.minecraft.world.item.ItemStack stack)
    Check if the stack is free for this handler.
    default void
    Possible on complete hooks after placement.
    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.
    boolean
    replaceWithSolidBlock(net.minecraft.world.level.block.state.BlockState blockState)
    Check if this block is considered solid for the solid placerholder blocks.
    void
    Set the blueprint.
    void
    setMd5(String calculatedMD5)
    Set the md5 value.
    boolean
    shouldBlocksBeConsideredEqual(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.block.state.BlockState state1)
    Deprecated.
    void
    triggerEntitySuccess(net.minecraft.core.BlockPos pos, List<net.minecraft.world.item.ItemStack> requiredRes, boolean placement)
    Trigger entity success.
    void
    triggerSuccess(net.minecraft.core.BlockPos pos, List<net.minecraft.world.item.ItemStack> requiredRes, boolean placement)
    Trigger success AFTER placement of block.

    Methods inherited from interface com.ldtteam.structurize.placement.IPlacementContext

    fancyPlacement, getBluePrint, getCenterPos, getRotationMirror
  • Method Details

    • setBlueprint

      void setBlueprint(Blueprint blueprint)
      Set the blueprint.
      Parameters:
      blueprint - the blueprint to set.
    • setMd5

      void setMd5(String calculatedMD5)
      Set the md5 value.
      Parameters:
      calculatedMD5 - the calculated md5.
    • getMd5

      String getMd5()
      Get the md5 value.
      Returns:
      the md5.
    • isCorrectMD5

      default boolean isCorrectMD5(String otherMD5)
      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
    • getWorld

      net.minecraft.world.level.Level getWorld()
      Get the world from the handler.
      Returns:
      the world.
    • getSettings

      PlacementSettings getSettings()
      Getter for the placement settings.
      Returns:
      the settings object.
    • getInventory

      @Nullable @Nullable net.minecraftforge.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.
    • shouldBlocksBeConsideredEqual

      @Deprecated boolean shouldBlocksBeConsideredEqual(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.block.state.BlockState state1)
      Deprecated.
      Special equal condition check.
      Parameters:
      state - the first state.
      state1 - the second state.
      Returns:
      true if considered equal and block should be skipped.
    • hasRequiredItems

      boolean hasRequiredItems(List<net.minecraft.world.item.ItemStack> requiredItems)
      Check if the handler has the required items for an action.
      Parameters:
      requiredItems - the list of items.
      Returns:
      true if so.
    • consume

      default void consume(List<net.minecraft.world.item.ItemStack> requiredItems)
      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

      @Deprecated(forRemoval=true, since="1.18.2") net.minecraft.world.level.block.state.BlockState getSolidBlockForPos(net.minecraft.core.BlockPos worldPos)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the right solid block for the substitution block.
      Parameters:
      worldPos - the world pos.
      Returns:
      the right block (classically biome dependent).
    • getSolidBlockForPos

      net.minecraft.world.level.block.state.BlockState getSolidBlockForPos(net.minecraft.core.BlockPos worldPos, @Nullable @Nullable Function<net.minecraft.core.BlockPos,net.minecraft.world.level.block.state.BlockState> virtualBlocks)
      Get the solid worldgen block for given pos while using data from handler.
      Specified by:
      getSolidBlockForPos in interface IPlacementContext
      Parameters:
      worldPos - the world pos.
      virtualBlocks - if null use level instead for getting surrounding block states, fnc may should return null if virtual block is not available
      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.