How to allow structure to spawn on super flat world

Started by nicholashammond2004 on

Topic category: Help with MCreator software

Last seen on 19:05, 23. Jul 2020
Joined May 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to allow structure to spawn on super flat world

Although I know MCreator does not have an option to enable this, what would I have to add into the code for my custom structure to generate in a super flat world? I modified the code so that the structure spawns in all dimensions and biomes, however for some reason it will not spawn into super flat worlds. What do I have to insert so it will generate in flat worlds?

@BackroomsModElements.ModElement.Tag
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;
    }

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

            @Override
            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.addFeature(GenerationStage.Decoration.SURFACE_STRUCTURES,
                    Biome.createDecoratedFeature(feature, IFeatureConfig.NO_FEATURE_CONFIG, Placement.NOPE, IPlacementConfig.NO_PLACEMENT_CONFIG));
        }
    }
}