Posted September 24, 20196 yr 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!
September 27, 20196 yr 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 September 27, 20196 yr 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.