Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.14.4] [SOLVED] Structure Spawn


Recommended Posts

I am trying to make a structure that spawns in the world, I have registered the structure. When I run /locate command it gives me the coordinates but it just does not spawn in the world, there is nothing at the coordinates 


package com.budrunbun.lavalamp.worldgen;

import com.mojang.datafixers.Dynamic;
import net.minecraft.util.math.MutableBoundingBox;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.ChunkGenerator;
import net.minecraft.world.gen.feature.NoFeatureConfig;
import net.minecraft.world.gen.feature.structure.ScatteredStructure;
import net.minecraft.world.gen.feature.structure.Structure;
import net.minecraft.world.gen.feature.structure.StructureStart;
import net.minecraft.world.gen.feature.template.TemplateManager;

import javax.annotation.Nonnull;
import java.util.function.Function;

public class ShopStructure extends ScatteredStructure<NoFeatureConfig> {
    public ShopStructure(Function<Dynamic<?>, ? extends NoFeatureConfig> p_i51449_1_) {

    protected int getSeedModifier() {
        return 0;

    public IStartFactory getStartFactory() {
        return ShopStructure.Start::new;

    public String getStructureName() {
        return "Shop";

    public int getSize() {
        return 3;

    public static class Start extends StructureStart {
        public Start(Structure<?> p_i50289_1_, int p_i50289_2_, int p_i50289_3_, Biome p_i50289_4_, MutableBoundingBox p_i50289_5_, int p_i50289_6_, long p_i50289_7_) {
            super(p_i50289_1_, p_i50289_2_, p_i50289_3_, p_i50289_4_, p_i50289_5_, p_i50289_6_, p_i50289_7_);

        public void init(ChunkGenerator<?> generator, TemplateManager templateManagerIn, int chunkX, int chunkZ, @Nonnull Biome biomeIn) {
            ShopStructurePiece shopStructurePiece = new ShopStructurePiece(this.rand, chunkX * 16, chunkZ * 16);


package com.budrunbun.lavalamp.worldgen;

import net.minecraft.block.Blocks;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.MutableBoundingBox;
import net.minecraft.world.IWorld;
import net.minecraft.world.gen.feature.structure.IStructurePieceType;
import net.minecraft.world.gen.feature.structure.ScatteredStructurePiece;
import net.minecraft.world.gen.feature.template.TemplateManager;

import javax.annotation.Nonnull;
import java.util.Random;

public class ShopStructurePiece extends ScatteredStructurePiece {

    public static IStructurePieceType type = IStructurePieceType.register(ShopStructurePiece::new, "shop");

    public ShopStructurePiece(Random random, int x, int z) {
        super(type, random, x, 100, z, 100, 100, 100);

    public ShopStructurePiece(TemplateManager templateManager, CompoundNBT compoundNBT) {
        super(type, compoundNBT);

    public boolean addComponentParts(@Nonnull IWorld world, @Nonnull Random random, @Nonnull MutableBoundingBox structureBoundingBoxIn, @Nonnull ChunkPos pos) {

        this.fillWithBlocks(world, structureBoundingBoxIn, 0, 0, 0, this.width - 1, 100, this.depth - 1, Blocks.COBBLESTONE.getDefaultState(), Blocks.COBBLESTONE.getDefaultState(), false);

        return true;

Adding to biomes:

    private void setupCommon(final FMLCommonSetupEvent event) {
        for (Biome biome : ForgeRegistries.BIOMES) {
            biome.addStructure(ModFeatures.SHOP, NoFeatureConfig.NO_FEATURE_CONFIG);


Edited by BudRunBun
Link to comment
Share on other sites

You can focus on the defualt code about how to correctly add structure.

I will show you default desert_pyramid.

one is addStructure


another is addFeature

biomeIn.addFeature(GenerationStage.Decoration.SURFACE_STRUCTURES, Feature.DESERT_PYRAMID.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG).withPlacement(Placement.NOPE.configure(IPlacementConfig.NO_PLACEMENT_CONFIG)));

So what you need to do is add "addFeature" method.

I think addStructure means the biome can spawn the structure.

addFeature means the biome can show the structure.

  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • So I am coding a AFK mod which basically holds left click in servers (Skyblock). The problem is that once I tabbed out , the island sometimes restarts and I am warped to the community centre. I have coded so it automatically rejoin, but it doesn't hold left click anymore even I used the setKeyBindState method for keyBindAttack(I am tabbed out at this point). But after I went in the game window again, it somehow works again without me pressing left click. So is there any way that I can make setKeyBindState work after tabbing out and rejoining a server? P.S. I observed that after rejoining the server if I am tabbed out, my mouse cursor would somehow move to the centre of the game screen automatically so maybe some other code is affecting.
    • I'm struggling to find the correct methods and classes, and I cannot find the latest documentation for 1.18.1-39.0.59 for example if I need to get the current player dimension name, I found this post: But there is no such attribute names. After searching the mod source code of an public available repository I found that the method I need to call is obtained through player.level.dimension().location().getPath() and not from worldObj (as the post said) nor getName() or something easier to guess, this is pretty confusing. I use to code faster but this procedure of trial and error of guessing the attributes and methods is too slow, and can be solved with good docs. Do I have the wrong environment? or What is happening? Where can I find the correct latest documentation? At last I must say that I'm new into forge but not new into programming. Thank your for your attention, any help is appreciated.
    • I would recommend using the official format: https://minecraft.fandom.com/wiki/Raw_JSON_text_format#Java_Edition
    • Hello, I created a custom entity which shoots snowballs at the player and other mobs. Now I want it to look at the target while doing so --> rotating its head to it/at least rotate its body in the targets direction I tried to use this.lookAt(enitity) which doesnt seem to work. Spawning Particles doesnt work either public void tick() { this.attackTimer++; LivingEntity targetentity = this.snowmanCannon.getTarget(); this.snowmanCannon.setAttacking(true); Level level = this.snowmanCannon.level; this.snowmanCannon.getLookControl().setLookAt(targetentity); if(!this.snowmanCannon.hasLineOfSight(targetentity)) { } else if (this.attackTimer == 1) { this.snowmanCannon.setAttacking(true); Vec3 pos1 = this.snowmanCannon.getEyePosition().add(0,-0.5,0); Vec3 pos2 = targetentity.getEyePosition(); Vec3 dir = pos2.subtract(this.snowmanCannon.getEyePosition()); SnowmanCannonProjectile snowball = new SnowmanCannonProjectile(level, pos1.x, pos1.y, pos1.z); snowball.shoot(dir.x, dir.y, dir.z, 4.5F, 0.1F); this.snowmanCannon.playSound(SoundEvents.SNOW_GOLEM_SHOOT, 1.0F, 1.0F); level.addAlwaysVisibleParticle(ParticleTypes.EXPLOSION, pos1.x, pos1.y, pos1.z, 1d, 1d, 1d); level.addFreshEntity(snowball); } if (this.attackTimer == 3) { this.snowmanCannon.setAttacking(false); this.attackTimer = 0; } } Thank you for any help
  • Topics

  • Who's Online (See full list)

  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.