Class StructurePlacerAPI

java.lang.Object
me.emafire003.dev.structureplacerapi.StructurePlacerAPI

public class StructurePlacerAPI extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
     
    protected boolean
     
    protected net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block>
     
    final net.minecraft.core.BlockPos
     
    protected net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block>
     
    final boolean
     
    final float
     
    static final org.slf4j.Logger
     
    final net.minecraft.world.level.block.Mirror
     
    final net.minecraft.core.BlockPos
     
    aka check the block IN the structure
    aka check the block that is getting replced BY the structure
    protected boolean
     
    protected boolean
     
    protected boolean
     
    protected boolean
     
    final net.minecraft.world.level.block.Rotation
     
    net.minecraft.core.Vec3i
     
    protected net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block>
     
    final net.minecraft.resources.Identifier
     
    final net.minecraft.world.level.WorldGenLevel
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    StructurePlacerAPI(net.minecraft.world.level.WorldGenLevel world, net.minecraft.resources.Identifier templateName, net.minecraft.core.BlockPos blockPos)
    With this you can create placer object which will spawn a new structure from an nbt file located in /data/modid/structures
    StructurePlacerAPI(net.minecraft.world.level.WorldGenLevel world, net.minecraft.resources.Identifier templateName, net.minecraft.core.BlockPos blockPos, float integrity)
    With this you can create placer object which will spawn a new structure from an nbt file located in /data/modid/structures
    StructurePlacerAPI(net.minecraft.world.level.WorldGenLevel world, net.minecraft.resources.Identifier templateName, net.minecraft.core.BlockPos blockPos, net.minecraft.core.BlockPos offset)
    With this you can create placer object which will spawn a new structure from an nbt file located in /data/modid/structures
    StructurePlacerAPI(net.minecraft.world.level.WorldGenLevel world, net.minecraft.resources.Identifier templateName, net.minecraft.core.BlockPos blockPos, net.minecraft.world.level.block.Mirror mirror)
    With this you can create placer object which will spawn a new structure from an nbt file located in /data/modid/structures
    StructurePlacerAPI(net.minecraft.world.level.WorldGenLevel world, net.minecraft.resources.Identifier templateName, net.minecraft.core.BlockPos blockPos, net.minecraft.world.level.block.Mirror mirror, net.minecraft.world.level.block.Rotation rotation)
    With this you can create placer object which will spawn a new structure from an nbt file located in /data/modid/structures
    StructurePlacerAPI(net.minecraft.world.level.WorldGenLevel world, net.minecraft.resources.Identifier templateName, net.minecraft.core.BlockPos blockPos, net.minecraft.world.level.block.Mirror mirror, net.minecraft.world.level.block.Rotation rotation, boolean ignoreEntities, float integrity, net.minecraft.core.BlockPos offset)
    With this you can create placer object which will spawn a new structure from an nbt file located in /data/modid/structures
    StructurePlacerAPI(net.minecraft.world.level.WorldGenLevel world, net.minecraft.resources.Identifier templateName, net.minecraft.core.BlockPos blockPos, net.minecraft.world.level.block.Rotation rotation)
    With this you can create placer object which will spawn a new structure from an nbt file located in /data/modid/structures
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    actionOnBlocksPlacedByStructure(ActionOnBlockFind action, net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block> targets)
    Performs an action while placing a block with a tag, from the saved structure file.
    void
    actionOnBlocksReplacedByStructure(ActionOnBlockFind action, net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block> targets)
    Performs an action while a block with a tag in the world gets replaced by one from the structure file.
    static net.minecraft.util.RandomSource
    createRandom(long seed)
    This method creates a random seed for the integrity run-down effect.
    net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block>
     
    Optional<net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate>
    Returns an instance of the loaded structure.
    static Optional<net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate>
    getTemplatePreview(net.minecraft.server.level.ServerLevel world, net.minecraft.resources.Identifier templateName)
    Returns the copy of a structure that you are going to be loading later, in order to get its size and other info
    static Optional<net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate>
    getTemplatePreview(net.minecraft.world.level.WorldGenLevel world, net.minecraft.resources.Identifier templateName)
    Returns the copy of a structure that you are going to be loading later, in order to get its size and other info
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    boolean
    loadAndRestoreStructure(int restore_ticks)
    Use this method to load the structure into the world and spawn it.
    boolean
    loadAndRestoreStructureAnimated(int restore_ticks, int blocks_per_tick, boolean random)
    Use this method to load the structure into the world and spawn it.
    boolean
    Use this method to load the structure into the world and place it.
    void
    setOnlyReplaceTaggedBlocks(boolean onlyReplaceTaggedBlocks, net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block> tag)
    Sets weather or not this structure should only replace blocks with the provided tag, for example only replace air blocks
    void
    setPreventReplacementOfTaggedBlocks(boolean preventReplacementOfTaggedBlocks, net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block> tag)
    Allows to specify blocks which won't be replaced if they have the provided tag
    void
    setReplaceBarrier(boolean replaceBarrier)
    Weather or not this structure should replace the barrier block
    void
    setReplaceBedrock(boolean replaceBedrock)
    Sets weather or not this structure should replace the bedrock
    void
    setTaggedBlocks(net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block> taggedBlocks)
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • world

      public final net.minecraft.world.level.WorldGenLevel world
    • templateName

      public final net.minecraft.resources.Identifier templateName
    • blockPos

      public final net.minecraft.core.BlockPos blockPos
    • mirror

      public final net.minecraft.world.level.block.Mirror mirror
    • rotation

      public final net.minecraft.world.level.block.Rotation rotation
    • ignoreEntities

      public final boolean ignoreEntities
    • integrity

      public final float integrity
    • offset

      public final net.minecraft.core.BlockPos offset
    • size

      public net.minecraft.core.Vec3i size
    • replaceBedrock

      protected boolean replaceBedrock
    • replaceBarrier

      protected boolean replaceBarrier
    • onlyReplaceTaggedBlocks

      protected boolean onlyReplaceTaggedBlocks
    • preventReplacementOfTaggedBlocks

      protected boolean preventReplacementOfTaggedBlocks
    • taggedBlocks

      protected net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block> taggedBlocks
    • actOnBlockStructurePlacing

      protected boolean actOnBlockStructurePlacing
    • actOnBlockReplacedByStructure

      protected boolean actOnBlockReplacedByStructure
    • onBlockPlacingInStructure

      protected ActionOnBlockFind onBlockPlacingInStructure
      aka check the block IN the structure
    • onBlockReplacedByStructure

      protected ActionOnBlockFind onBlockReplacedByStructure
      aka check the block that is getting replced BY the structure
    • blockPlacedCheck

      protected net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block> blockPlacedCheck
    • blockReplacedCheck

      protected net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block> blockReplacedCheck
    • LOGGER

      public static final org.slf4j.Logger LOGGER
  • Constructor Details

    • StructurePlacerAPI

      public StructurePlacerAPI(net.minecraft.world.level.WorldGenLevel world, net.minecraft.resources.Identifier templateName, net.minecraft.core.BlockPos blockPos, net.minecraft.world.level.block.Mirror mirror, net.minecraft.world.level.block.Rotation rotation, boolean ignoreEntities, float integrity, net.minecraft.core.BlockPos offset)
      With this you can create placer object which will spawn a new structure from an nbt file located in /data/modid/structures
      Parameters:
      world - The StructureWorldAccess in which to place the structure
      templateName - The identifier of the structure to place, like new Identifier(MOD_ID, structure_name)
      blockPos - The position of the structure
      mirror - Use this to mirror the structure using BlockMirror.#
      rotation - Use this to rotate the structure using BlockRotation.#
      ignoreEntities - Set to true to block the spawning of entities saved in the structure file
      integrity - Set this to a value between 0f and 1f to remove some blocks from the placed structure. (All blocks = 1f)
      offset - Use this to offset the placing of the structure.
    • StructurePlacerAPI

      public StructurePlacerAPI(net.minecraft.world.level.WorldGenLevel world, net.minecraft.resources.Identifier templateName, net.minecraft.core.BlockPos blockPos)
      With this you can create placer object which will spawn a new structure from an nbt file located in /data/modid/structures
      Parameters:
      world - The StructureWorldAccess in which to place the structure
      templateName - The identifier of the structure to place, like new Identifier(MOD_ID, structure_name)
      blockPos - The position of the structure
    • StructurePlacerAPI

      public StructurePlacerAPI(net.minecraft.world.level.WorldGenLevel world, net.minecraft.resources.Identifier templateName, net.minecraft.core.BlockPos blockPos, net.minecraft.core.BlockPos offset)
      With this you can create placer object which will spawn a new structure from an nbt file located in /data/modid/structures
      Parameters:
      world - The StructureWorldAccess in which to place the structure
      templateName - The identifier of the structure to place, like new Identifier(MOD_ID, structure_name)
      blockPos - The position of the structure
      offset - Use this to offset the placing of the structure.
    • StructurePlacerAPI

      public StructurePlacerAPI(net.minecraft.world.level.WorldGenLevel world, net.minecraft.resources.Identifier templateName, net.minecraft.core.BlockPos blockPos, net.minecraft.world.level.block.Mirror mirror)
      With this you can create placer object which will spawn a new structure from an nbt file located in /data/modid/structures
      Parameters:
      world - The StructureWorldAccess in which to place the structure
      templateName - The identifier of the structure to place, like new Identifier(MOD_ID, structure_name)
      blockPos - The position of the structure
      mirror - Use this to mirror the structure using BlockMirror.#
    • StructurePlacerAPI

      public StructurePlacerAPI(net.minecraft.world.level.WorldGenLevel world, net.minecraft.resources.Identifier templateName, net.minecraft.core.BlockPos blockPos, net.minecraft.world.level.block.Rotation rotation)
      With this you can create placer object which will spawn a new structure from an nbt file located in /data/modid/structures
      Parameters:
      world - The StructureWorldAccess in which to place the structure
      templateName - The identifier of the structure to place, like new Identifier(MOD_ID, structure_name)
      blockPos - The position of the structure
      rotation - Use this to rotate the structure using BlockRotation.#
    • StructurePlacerAPI

      public StructurePlacerAPI(net.minecraft.world.level.WorldGenLevel world, net.minecraft.resources.Identifier templateName, net.minecraft.core.BlockPos blockPos, net.minecraft.world.level.block.Mirror mirror, net.minecraft.world.level.block.Rotation rotation)
      With this you can create placer object which will spawn a new structure from an nbt file located in /data/modid/structures
      Parameters:
      world - The StructureWorldAccess in which to place the structure
      templateName - The identifier of the structure to place, like new Identifier(MOD_ID, structure_name)
      blockPos - The position of the structure
      mirror - Use this to mirror the structure using BlockMirror.#
      rotation - Use this to rotate the structure using BlockRotation.#
    • StructurePlacerAPI

      public StructurePlacerAPI(net.minecraft.world.level.WorldGenLevel world, net.minecraft.resources.Identifier templateName, net.minecraft.core.BlockPos blockPos, float integrity)
      With this you can create placer object which will spawn a new structure from an nbt file located in /data/modid/structures
      Parameters:
      world - The StructureWorldAccess in which to place the structure
      templateName - The identifier of the structure to place, like new Identifier(MOD_ID, structure_name)
      blockPos - The position of the structure
      integrity - Set this to a value between 0f and 1f to remove some blocks from the placed structure. (All blocks = 1f)
  • Method Details

    • getTemplate

      public Optional<net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate> getTemplate()
      Returns an instance of the loaded structure. From this, you can get its size and other useful stuff
    • getTemplatePreview

      public static Optional<net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate> getTemplatePreview(net.minecraft.server.level.ServerLevel world, net.minecraft.resources.Identifier templateName)
      Returns the copy of a structure that you are going to be loading later, in order to get its size and other info
    • getTemplatePreview

      public static Optional<net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate> getTemplatePreview(net.minecraft.world.level.WorldGenLevel world, net.minecraft.resources.Identifier templateName)
      Returns the copy of a structure that you are going to be loading later, in order to get its size and other info
    • loadStructure

      public boolean loadStructure()
      Use this method to load the structure into the world and place it. You can check to see if the placing was successful.

      This method DOES NOT support regenerating the old terrain, use loadAndRestoreStructure(int) or loadAndRestoreStructureAnimated(int, int, boolean) instead if you want to do it. This method however consumes less resources.

    • loadAndRestoreStructure

      public boolean loadAndRestoreStructure(int restore_ticks)
      Use this method to load the structure into the world and spawn it. You can check to see if the placing was successful.

      It will also restore the blocks it replaced after restore_ticks Calling this function from the client only, will not regenerate the old terrain. And will probably cause other issues.

      Notice: Using this could lead to performance issues, especially with very large structures!

      Parameters:
      restore_ticks - Number of ticks (1 second = 20 ticks) after which the world would be restored. Setting this to -1 will prevent the structure from being restored so use loadStructure() instead
    • loadAndRestoreStructureAnimated

      public boolean loadAndRestoreStructureAnimated(int restore_ticks, int blocks_per_tick, boolean random)
      Use this method to load the structure into the world and spawn it. You can check to see if the placing was successful.

      It will also restore the blocks it replaced after restore_ticks with an animation

      Calling this function from the client only will not regenerate the old terrain. And will probably cause other issues.

      Notice: Using this could lead to performance issues, especially with very large structures!

      Parameters:
      restore_ticks - Number of ticks (1 second = 20 ticks) after which the blocks will begin to be restored Setting this to -1 will prevent the structure from being restored so use loadStructure() instead
      blocks_per_tick - How many blocks to restore per tick, the more, the faster the animation will go. Setting thi to -1 will cancel the animation so use loadAndRestoreStructure(int) instead
      random - Weather or not the blocks will be removed at random. If false, they will be removed from one corner to the other in sequence
    • createRandom

      public static net.minecraft.util.RandomSource createRandom(long seed)
      This method creates a random seed for the integrity run-down effect. No need to use it on your own, included during placement
    • isReplaceBedrock

      public boolean isReplaceBedrock()
    • setReplaceBedrock

      public void setReplaceBedrock(boolean replaceBedrock)
      Sets weather or not this structure should replace the bedrock
    • isReplaceBarrier

      public boolean isReplaceBarrier()
    • setReplaceBarrier

      public void setReplaceBarrier(boolean replaceBarrier)
      Weather or not this structure should replace the barrier block
    • isOnlyReplaceTaggedBlocks

      public boolean isOnlyReplaceTaggedBlocks()
    • setOnlyReplaceTaggedBlocks

      public void setOnlyReplaceTaggedBlocks(boolean onlyReplaceTaggedBlocks, net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block> tag)
      Sets weather or not this structure should only replace blocks with the provided tag, for example only replace air blocks
    • isPreventReplacementOfTaggedBlocks

      public boolean isPreventReplacementOfTaggedBlocks()
    • setPreventReplacementOfTaggedBlocks

      public void setPreventReplacementOfTaggedBlocks(boolean preventReplacementOfTaggedBlocks, net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block> tag)
      Allows to specify blocks which won't be replaced if they have the provided tag
    • getTaggedBlocks

      public net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block> getTaggedBlocks()
    • setTaggedBlocks

      public void setTaggedBlocks(net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block> taggedBlocks)
    • actionOnBlocksPlacedByStructure

      public void actionOnBlocksPlacedByStructure(ActionOnBlockFind action, net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block> targets)
      Performs an action while placing a block with a tag, from the saved structure file. You can return a different structureBlockInfo if you need to modify the block being placed. If you don't need this feature, return the given parameter.

      For example, a structure that has a fence inside of it will have an action that spawns a rabbit on top of it

    • actionOnBlocksReplacedByStructure

      public void actionOnBlocksReplacedByStructure(ActionOnBlockFind action, net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block> targets)
      Performs an action while a block with a tag in the world gets replaced by one from the structure file. You can return a different structureBlockInfo if you need to modify the block being placed. If you don't need this feature, return the given parameter.

      For example, in the world there is snow block that will be replaced by the structure, will have an action that spawn a snowgolem on top of it