Jump to content

How to spawn structure in custom dimension which uses flat world presets

Nicholas Hammond

Recommended Posts

After various tests I found out that my structure spawner works on all dimensions and biomes except on flat worlds. My custom dimension uses a super flat world generator, therefore I believe it does not generate for this reason. Anyway to generate my structure?


EmptyRoomStructure code

package net.zorathekidlz.backrooms.gen.level0;

import net.minecraft.world.WorldType;
import net.minecraftforge.common.BiomeManager;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;

import net.minecraft.world.server.ServerWorld;
import net.minecraft.world.gen.placement.Placement;
import net.minecraft.world.gen.placement.IPlacementConfig;
import net.minecraft.world.gen.feature.template.Template;
import net.minecraft.world.gen.feature.template.PlacementSettings;
import net.minecraft.world.gen.feature.template.BlockIgnoreStructureProcessor;
import net.minecraft.world.gen.feature.NoFeatureConfig;
import net.minecraft.world.gen.feature.IFeatureConfig;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.Heightmap;
import net.minecraft.world.gen.GenerationStage;
import net.minecraft.world.gen.ChunkGenerator;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.IWorld;
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.zorathekidlz.backrooms.BackroomsModElements;
import net.zorathekidlz.backrooms.dimensions.level0.Level0ModDimension;

import java.util.Random;
import java.util.logging.Level;

public class EmptyRoomStructure extends BackroomsModElements.ModElement {
    public EmptyRoomStructure(BackroomsModElements instance) {
        super(instance, 23);

    private static boolean validSpawn(int x, int z){
        if(x % 32 == 0 && z % 32 != 0) {
            return true;
        } else return false;

    public void init(FMLCommonSetupEvent event) {
        Feature<NoFeatureConfig> feature = new Feature<NoFeatureConfig>(NoFeatureConfig::deserialize) {

            public boolean place(IWorld iworld, ChunkGenerator generator, Random random, BlockPos pos, NoFeatureConfig config) {
                int ci = pos.getX();
                int ck = pos.getZ();
                DimensionType dimensionType = iworld.getDimension().getType();
                boolean dimensionCriteria = false;
                if (dimensionType == Level0ModDimension.type)
                    dimensionCriteria = true;
                if (!dimensionCriteria)
                    return false;
                Template template = ((ServerWorld) iworld.getWorld()).getSaveHandler().getStructureTemplateManager()
                        .getTemplateDefaulted(new ResourceLocation("backrooms", "empty_room"));
                if (template == null){
                    return false;
                if (!validSpawn(ci, ck)){
                    return false;
                Rotation rotation = Rotation.NONE;
                Mirror mirror = Mirror.NONE;
                BlockPos spawnTo = new BlockPos(ci,  100, ck);
                template.addBlocksToWorldChunk(iworld, spawnTo, new PlacementSettings().setRotation(rotation).setRandom(random)
                        .setMirror(mirror).setChunk((ChunkPos) null).setIgnoreEntities(false));
                return true;
        for (Biome biome : ForgeRegistries.BIOMES.getValues()) {
                    Biome.createDecoratedFeature(feature, IFeatureConfig.NO_FEATURE_CONFIG, Placement.NOPE, IPlacementConfig.NO_PLACEMENT_CONFIG));


Level0ChunkGenerator code

package net.zorathekidlz.backrooms.dimensions.level0;

import com.google.common.collect.Maps;
import net.minecraft.block.Blocks;
import net.minecraft.world.IWorld;
import net.minecraft.world.biome.Biomes;
import net.minecraft.world.biome.provider.BiomeProvider;
import net.minecraft.world.gen.ChunkGeneratorType;
import net.minecraft.world.gen.FlatChunkGenerator;
import net.minecraft.world.gen.FlatGenerationSettings;
import net.minecraft.world.gen.FlatLayerInfo;
import net.zorathekidlz.backrooms.biomes.BackroomsLevel0Biome;
import net.zorathekidlz.backrooms.block.CielingtileBlock;
import net.zorathekidlz.backrooms.block.OldmoistcarpetBlock;
import net.zorathekidlz.backrooms.gen.level0.EmptyRoomStructure;

public class Level0ChunkGenerator extends FlatChunkGenerator {
    public Level0ChunkGenerator(IWorld world, BiomeProvider biome) {
        super(world, biome, Level0Settings());

    public static FlatGenerationSettings Level0Settings(){
        FlatGenerationSettings flatgenerationsettings = ChunkGeneratorType.FLAT.createSettings();
        flatgenerationsettings.setBiome(new BackroomsLevel0Biome.Level0Biome());
        flatgenerationsettings.getFlatLayers().add(new FlatLayerInfo(1, Blocks.BEDROCK));
        flatgenerationsettings.getFlatLayers().add(new FlatLayerInfo(1, OldmoistcarpetBlock.block));
        flatgenerationsettings.getFlatLayers().add(new FlatLayerInfo(4, Blocks.AIR));
        flatgenerationsettings.getFlatLayers().add(new FlatLayerInfo(1, CielingtileBlock.block));
        flatgenerationsettings.getFlatLayers().add(new FlatLayerInfo(1, Blocks.BEDROCK));
        return flatgenerationsettings;


Link to comment
Share on other sites

11 hours ago, Nicholas Hammond said:

I know it's frowned upon but I can't progress in my mod making until I solve this bug.

2 tips that will help your progress:


1: Stop using MCreator

2: Set up a github account, and put your project on there in a buildable form, and post the link in your support posts.


These are both likely reasons that you do not get as many responses to your questions as you would like, as you have been told multiple times on here to stop using MCreator, and to properly share your code as opposed to attachments to forum posts.


I'm not trying to be mean or tell you what to do, just making suggestions to try and help you progress with your mod better.

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.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.