Class StructurePlacerAPI
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic final classUsed to schedule the replacements -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected booleanprotected net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block>protected net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block>static final org.slf4j.Loggerprotected ActionOnBlockFindprotected ActionOnBlockFindprotected booleanprotected booleanprotected booleanprotected booleanprotected net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block> -
Constructor Summary
ConstructorsConstructorDescriptionStructurePlacerAPI(net.minecraft.world.level.WorldGenLevel world, net.minecraft.resources.ResourceLocation 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/structuresStructurePlacerAPI(net.minecraft.world.level.WorldGenLevel world, net.minecraft.resources.ResourceLocation 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/structuresStructurePlacerAPI(net.minecraft.world.level.WorldGenLevel world, net.minecraft.resources.ResourceLocation 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/structuresStructurePlacerAPI(net.minecraft.world.level.WorldGenLevel world, net.minecraft.resources.ResourceLocation 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/structuresStructurePlacerAPI(net.minecraft.world.level.WorldGenLevel world, net.minecraft.resources.ResourceLocation 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/structuresStructurePlacerAPI(net.minecraft.world.level.WorldGenLevel world, net.minecraft.resources.ResourceLocation 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/structuresStructurePlacerAPI(net.minecraft.world.level.WorldGenLevel world, net.minecraft.resources.ResourceLocation 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 TypeMethodDescriptionvoidactionOnBlocksPlacedByStructure(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 filevoidactionOnBlocksReplacedByStructure(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 filestatic net.minecraft.util.RandomSourcecreateRandom(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.ResourceLocation templateName) Returns the copy of a structure that you are going to be loading later, in order to get its size and other infostatic Optional<net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate>getTemplatePreview(net.minecraft.world.level.WorldGenLevel world, net.minecraft.resources.ResourceLocation templateName) Returns the copy of a structure that you are going to be loading later, in order to get its size and other infobooleanbooleanbooleanbooleanbooleanloadAndRestoreStructure(int restore_ticks) Use this method to load the structure into the world and spawn it.booleanloadAndRestoreStructureAnimated(int restore_ticks, int blocks_per_tick, boolean random) Use this method to load the structure into the world and spawn it.booleanUse this method to load the structure into the world and place it.static voidonServerTick(net.minecraftforge.event.TickEvent.ServerTickEvent event) static voidrunEveryTick(ServerTickRunnable action) Runs an action every tick and provides the tick count with an optional start delay.static voidrunLater(int delayTicks, ServerRunnable action) voidsetOnlyReplaceTaggedBlocks(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 blocksvoidsetPreventReplacementOfTaggedBlocks(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 tagvoidsetReplaceBarrier(boolean replaceBarrier) Weather or not this structure should replace the barrier blockvoidsetReplaceBedrock(boolean replaceBedrock) Sets weather or not this structure should replace the bedrockvoidsetTaggedBlocks(net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block> taggedBlocks) toString()
-
Field Details
-
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
-
onBlockReplacedByStructure
-
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.ResourceLocation 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 structuretemplateName- The identifier of the structure to place, likenew Identifier(MOD_ID, structure_name)blockPos- The position of the structuremirror- Use this to mirror the structure usingBlockMirror.#rotation- Use this to rotate the structure usingBlockRotation.#ignoreEntities- Set to true to block the spawning of entities saved in the structure fileintegrity- 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.ResourceLocation 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 structuretemplateName- The identifier of the structure to place, likenew Identifier(MOD_ID, structure_name)blockPos- The position of the structure
-
StructurePlacerAPI
public StructurePlacerAPI(net.minecraft.world.level.WorldGenLevel world, net.minecraft.resources.ResourceLocation 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 structuretemplateName- The identifier of the structure to place, likenew Identifier(MOD_ID, structure_name)blockPos- The position of the structureoffset- Use this to offset the placing of the structure.
-
StructurePlacerAPI
public StructurePlacerAPI(net.minecraft.world.level.WorldGenLevel world, net.minecraft.resources.ResourceLocation 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 structuretemplateName- The identifier of the structure to place, likenew Identifier(MOD_ID, structure_name)blockPos- The position of the structuremirror- Use this to mirror the structure usingBlockMirror.#
-
StructurePlacerAPI
public StructurePlacerAPI(net.minecraft.world.level.WorldGenLevel world, net.minecraft.resources.ResourceLocation 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 structuretemplateName- The identifier of the structure to place, likenew Identifier(MOD_ID, structure_name)blockPos- The position of the structurerotation- Use this to rotate the structure usingBlockRotation.#
-
StructurePlacerAPI
public StructurePlacerAPI(net.minecraft.world.level.WorldGenLevel world, net.minecraft.resources.ResourceLocation 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 structuretemplateName- The identifier of the structure to place, likenew Identifier(MOD_ID, structure_name)blockPos- The position of the structuremirror- Use this to mirror the structure usingBlockMirror.#rotation- Use this to rotate the structure usingBlockRotation.#
-
StructurePlacerAPI
public StructurePlacerAPI(net.minecraft.world.level.WorldGenLevel world, net.minecraft.resources.ResourceLocation 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 structuretemplateName- The identifier of the structure to place, likenew Identifier(MOD_ID, structure_name)blockPos- The position of the structureintegrity- 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.ResourceLocation 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.ResourceLocation 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)orloadAndRestoreStructureAnimated(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 useloadStructure()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 useloadStructure()insteadblocks_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 useloadAndRestoreStructure(int)insteadrandom- 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 fileFor 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 fileFor 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
-
onServerTick
public static void onServerTick(net.minecraftforge.event.TickEvent.ServerTickEvent event) -
runLater
-
runEveryTick
Runs an action every tick and provides the tick count with an optional start delay. If the action lambda returns a falls the task is stopepd -
toString
-