Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (โ‹ฎ) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I want to make a custom Structure for my minecraft mod. I have been able to register other world features (flowers in my case) without any problems, but registering this structure isn't working. In the locate command, my structure is displayed as "minecraft:labyrinth" instead of with my modid. I put a breakpoint where the structure-start of my labyrinth is initialized (init method), but it doesn't seem to be called.

ย 

This is my code for registering:

@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public class WorldGenRegistry {

    public static Feature<NoFeatureConfig> ENERGY_FLOWER;
    public static Structure<LabyrinthConfig> LABYRINTH;

    @SubscribeEvent
    public static void registerFeatures(RegistryEvent.Register<Feature<?>> event) {
        IForgeRegistry<Feature<?>> registry = event.getRegistry();

        ENERGY_FLOWER = registerFeature(new EnergyFlowersFeature(NoFeatureConfig::deserialize), "energy_flowers");
        LABYRINTH = registerStructure(new LabyrinthStructure(LabyrinthConfig::deserialize), "labyrinth");

        registry.registerAll(
                ENERGY_FLOWER,
                LABYRINTH
        );
    }

    private static <T extends IFeatureConfig> Feature<T> registerFeature(Feature<T> feature, String registryName) {
        feature.setRegistryName(registryName);
        return feature;
    }

    private static <T extends IFeatureConfig> Structure<T> registerStructure(Structure<T> structure, String registryName) {
        structure.setRegistryName(registryName);
        return structure;
    }

}

And my labyrinth structure:

public class LabyrinthStructure extends Structure<LabyrinthConfig> {

    public LabyrinthStructure(Function<Dynamic<?>, ? extends LabyrinthConfig> deserializer) {
        super(deserializer);
    }

    @Override
    public boolean hasStartAt(ChunkGenerator<?> generator, Random random, int chunkX, int chunkZ) {
        ChunkPos pos = this.getStartPositionForPosition(generator, random, chunkX, chunkZ, 0, 0);
        if (chunkX == pos.x && chunkZ == pos.z) {
            Biome biome = generator.getBiomeProvider().getBiome(new BlockPos((chunkX << 4) + 9, 0, (chunkZ << 4) + 9));
            return generator.hasStructure(biome, WorldGenRegistry.LABYRINTH);
        } else {
            return false;
        }
    }

    @Override
    public IStartFactory getStartFactory() {
        return Start::new;
    }

    @Override
    public String getStructureName() {
        return "Labyrinth";
    }

    @Override
    public int getSize() {
        return 8; //TODO what is this?
    }

    public static class Start extends MarginedStructureStart {

        public Start(Structure<?> structure, int chunkPosX, int chunkPosZ, Biome biome, MutableBoundingBox bounds, int reference, long seed) {
            super(structure, chunkPosX, chunkPosZ, biome, bounds, reference, seed);
        }

        @Override
        public void init(ChunkGenerator<?> generator, TemplateManager templateManagerIn, int chunkX, int chunkZ, Biome biomeIn) {
            LabyrinthConfig config = generator.getStructureConfig(biomeIn, WorldGenRegistry.LABYRINTH);
            BlockPos pos = new BlockPos(chunkX * 16, 0, chunkZ * 16);

            System.out.println("GENERATE LABYRINTh"); //breakpoint here

            //TODO: VillagePieces.func_214838_a(generator, templateManagerIn, pos, this.components, this.rand, config);
            this.recalculateStructureSize();
        }

    }

}

ย 

I doubt anything is wrong with the LabyrinthConfig, so I'm not posting it unless requested.

Any help is greatly appreciated!

Cause it's string by default not ResourceLocation
ย 

    private static <T extends IFeatureConfig> Structure<T> registerStructure(Structure<T> structure, String registryName) {
        structure.setRegistryName(registryName);
        return structure;
    }

You need to add your modid to (registryName).ย 
Also it seems that Structure registry is somehow... changed. Look at "Structures" file and Structures field in "Feature" file.ย 

Edited by Krevik

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions โ†’ Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.