nothing spawns from structures

Started by Stapy_BFDI on

Topic category: Help with Minecraft modding (Java Edition)

Joined Feb 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
nothing spawns from structures

I can't get my structure to load, I've did a lot of code correctly but whenever I load in the world, No structures spawn even when the structure spawning is enabled. I tried testCilent but it wouldn't work. Can anyone help?

 

 

 

 

 

package net.mcreator.bfb.world.structure;

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.BlockPos;
import net.minecraft.util.Rotation;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Mirror;

import net.mcreator.bfb.BfbModElements;

import java.util.Random;

@BfbModElements.ModElement.Tag
public class GelatinsSteakhouseStructure extends BfbModElements.ModElement {
    public GelatinsSteakhouseStructure(BfbModElements instance) {
        super(instance, 188);
    }

    @Override
    public void init(FMLCommonSetupEvent event) {
        Feature<NoFeatureConfig> feature = new Feature<NoFeatureConfig>(NoFeatureConfig::deserialize) {
            @Override
            public boolean place(IWorld world, ChunkGenerator generator, Random random, BlockPos pos, NoFeatureConfig config) {
                int ci = (pos.getX() >> 4) << 4;
                int ck = (pos.getZ() >> 4) << 4;
                DimensionType dimensionType = world.getDimension().getType();
                boolean dimensionCriteria = false;
                if (dimensionType == DimensionType.OVERWORLD)
                    dimensionCriteria = true;
                if (!dimensionCriteria)
                    return false;
                if ((random.nextInt(1000000) + 1) <= 2000) {
                    int count = random.nextInt(1) + 1;
                    for (int a = 0; a < count; a++) {
                        int i = ci + random.nextInt(16);
                        int k = ck + random.nextInt(16);
                        int j = world.getHeight(Heightmap.Type.WORLD_SURFACE_WG, i, k);
                        j -= 1;
                        Rotation rotation = Rotation.values()[random.nextInt(3)];
                        Mirror mirror = Mirror.values()[random.nextInt(2)];
                        BlockPos spawnTo = new BlockPos(i + 0, j + 0, k + 0);
                        int x = spawnTo.getX();
                        int y = spawnTo.getY();
                        int z = spawnTo.getZ();
                        Template template = ((ServerWorld) world.getWorld()).getSaveHandler().getStructureTemplateManager()
                                .getTemplateDefaulted(new ResourceLocation("bfb", "gelatinssteakhouse"));
                        if (template == null)
                            return false;
                        template.addBlocksToWorld(world, spawnTo, new PlacementSettings().setRotation(rotation).setRandom(random).setMirror(mirror)
                                .addProcessor(BlockIgnoreStructureProcessor.STRUCTURE_BLOCK).setChunk(null).setIgnoreEntities(false));
                    }
                }
                return true;
            }
        };
        for (Biome biome : ForgeRegistries.BIOMES.getValues()) {
            biome.addFeature(GenerationStage.Decoration.SURFACE_STRUCTURES, feature.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG)
                    .withPlacement(Placement.NOPE.configure(IPlacementConfig.NO_PLACEMENT_CONFIG)));
        }
    }
}

Joined Feb 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
i already figured it out…
Wed, 03/24/2021 - 16:09

i already figured it out. Thanks for responding!