Schematics wont spawn at all. Code reveals that no blocks are being placed

Status
Works as designed
Type
Product/platform
MCreator/Windows
Priority
Normal
Issue description

I am making a mod focused on exploration, but none of the structures are working at all. I think it has something to do with the new format for importing structures. I took a schematic file and turned it into a .nbt file in order to import it into mcreator. Once imported, everything is fine until I spend 3 hours searching for any of the 8 structures that should be spawning in and not finding any of them. It is not a case of "hey make the spawnrates higher." I can tell you this because I looked at the code. The spawn rates were sticking. The problem is that none of the blocks in the structures are generating. There is nothing about block placements. Anyone else know of a solution or a way to get nbt files without using a converter of some sorts?

Here is the entire code:

package mod.mcreator;

import net.minecraft.world.gen.structure.template.Template;
import net.minecraft.world.gen.structure.template.PlacementSettings;
import net.minecraft.world.WorldServer;
import net.minecraft.world.World;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.Rotation;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Mirror;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.Block;

import java.util.Random;

public class mcreator_diamondMuseum extends testenvironmentmod.ModElement {

    @Override
    public void generateSurface(World world, Random random, int i2, int k2) {
        if ((random.nextInt(1000000) + 1) <= 7000) {
            int i = i2 + random.nextInt(16) + 8;
            int k = k2 + random.nextInt(16) + 8;
            int height = 255;
            while (height > 0) {
                if (!world.isAirBlock(new BlockPos(i, height, k)))
                    break;
                height--;
            }
            int j = height - 1;
            if (world.isRemote)
                return;
            Template template = ((WorldServer) world).getStructureTemplateManager().getTemplate(world.getMinecraftServer(),
                    new ResourceLocation("testenvironmentmod", "diamondmuseum"));
            if (template == null)
                return;
            BlockPos spawnTo = new BlockPos(i, j, k);
            IBlockState iblockstate = world.getBlockState(spawnTo);
            world.notifyBlockUpdate(spawnTo, iblockstate, iblockstate, 3);
            template.addBlocksToWorldChunk(world, spawnTo,
                    new PlacementSettings().setRotation(Rotation.NONE).setMirror(Mirror.NONE).setChunk((ChunkPos) null)
                            .setReplacedBlock((Block) null).setIgnoreStructureBlock(false).setIgnoreEntities(false));
        }
    }
}
 

Issue comments

The spawning code is right here:

template.addBlocksToWorldChunk(world, spawnTo,
                    new PlacementSettings().setRotation(Rotation.NONE).setMirror(Mirror.NONE).setChunk((ChunkPos) null)
                            .setReplacedBlock((Block) null).setIgnoreStructureBlock(false).setIgnoreEntities(false));

This code now loads structure from the resources folder from the .nbt file and generates it.

You have been warned that .schematic format is outdated. I suggest you to take this route:

  • Create new 1.12.2 world
  • Use worldedit to place the schematic in your world
  • Open the world in Minecraft and use the structure block to export your structure in .nbt format. Check Minecraft Wiki on examples on how to use structure block
  • Import .nbt structure in MCreator and select it as the structure


Donate to MCreator

By donating to developers you can speed up development, as with more resources, we can dedicate more time to MCreator. It is a free project made by developers working on it in their free time.