The issues you're encountering are due to changes in the Minecraft API, particularly in how StructurePoolElement and StructureTemplatePool are handled.
Step 1: Fix StructurePoolElement Build Method
The build() method has been removed, and you can directly use StructurePoolElement with a LegacySinglePoolElement:
List<StructurePoolElement> customElements = List.of(
LegacySinglePoolElement.single(new ResourceLocation(ModConstants.MOD_ID, "village/plains/marloe_house_1").toString())
.projection(StructureTemplatePool.Projection.RIGID)
.weight(5)
.build(),
LegacySinglePoolElement.single(new ResourceLocation(ModConstants.MOD_ID, "village/plains/marloe_house_2").toString())
.projection(StructureTemplatePool.Projection.RIGID)
.weight(3)
.build()
);
Step 2: Fix StructureTemplatePool Projection Method
The getProjection() method does not exist. You can directly use StructureTemplatePool.Projection.RIGID when creating the pool:
// 3. Create a new pool that replaces the vanilla one
StructureTemplatePool modifiedPool = new StructureTemplatePool(
poolLocation, // Use the same location to override
originalPool.getFallback(), // Keep vanilla fallback
customElements, // Use your custom elements
StructureTemplatePool.Projection.RIGID // Keep vanilla projection
);
Step 3: Fix StructurePoolRegistry
The StructurePoolRegistry class has been removed. You can directly register the pool using BuiltInRegistries:
// 4. Register the modified pool to replace the vanilla one
BuiltInRegistries.STRUCTURE_POOL.register(poolLocation, modifiedPool);
Step 4: Fix BuiltInRegistries.STRUCTURE_POOL_ELEMENT
The STRUCTURE_POOL_ELEMENT registry is not needed. You can directly cast the originalPool to StructureTemplatePool:
// 1. Get the vanilla plains village houses pool
ResourceLocation poolLocation = new ResourceLocation("minecraft:village/plains/houses");
StructureTemplatePool originalPool = (StructureTemplatePool) BuiltInRegistries.STRUCTURE_POOL.get(poolLocation);
Updated Code
Here is the updated code:
package net.mattias.marloevillages.registry;
import net.mattias.marloevillages.MarloeVillages;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.levelgen.structure.pools.LegacySinglePoolElement;
import net.minecraft.world.level.levelgen.structure.pools.StructurePoolElement;
import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool;
import net.mattias.marloevillages.util.ModConstants;
import java.util.List;
public class ModStructurePools {
public static void register() {
modifyPlainsVillage();
}
private static void modifyPlainsVillage() {
// 1. Get the vanilla plains village houses pool
ResourceLocation poolLocation = new ResourceLocation("minecraft:village/plains/houses");
StructureTemplatePool originalPool = (StructureTemplatePool) BuiltInRegistries.STRUCTURE_POOL.get(poolLocation);
if (originalPool == null) {
MarloeVillages.LOGGER.error("Vanilla plains village pool not found!");
return;
}
// 2. Define your custom structure elements (use your mod's namespace)
List<StructurePoolElement> customElements = List.of(
LegacySinglePoolElement.single(new ResourceLocation(ModConstants.MOD_ID, "village/plains/marloe_house_1").toString())
.projection(StructureTemplatePool.Projection.RIGID)
.weight(5)
.build(),
LegacySinglePoolElement.single(new ResourceLocation(ModConstants.MOD_ID, "village/plains/marloe_house_2").toString())
.projection(StructureTemplatePool.Projection.RIGID)
.weight(3)
.build()
);
// 3. Create a new pool that replaces the vanilla one
StructureTemplatePool modifiedPool = new StructureTemplatePool(
poolLocation, // Use the same location to override
originalPool.getFallback(), // Keep vanilla fallback
customElements, // Use your custom elements
StructureTemplatePool.Projection.RIGID // Keep vanilla projection
);
// 4. Register the modified pool to replace the vanilla one
BuiltInRegistries.STRUCTURE_POOL.register(poolLocation, modifiedPool);
MarloeVillages.LOGGER.info("Replaced vanilla plains village pool with custom structures!");
}
}