public class ModStructurePools {
public static void register() {
modifyPlainsVillage();
}
code
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_ELEMENT.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(
// Convert ResourceLocation to String for the "single" method
StructurePoolElement.single(new ResourceLocation(ModConstants.MOD_ID, "village/plains/marloe_house_1").toString())
.apply(StructureTemplatePool.Projection.RIGID)
.build(),
StructurePoolElement.single(new ResourceLocation(ModConstants.MOD_ID, "village/plains/marloe_house_2").toString())
.apply(StructureTemplatePool.Projection.RIGID)
.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
originalPool.getProjection() // Keep vanilla projection
);
// 4. Register the modified pool to replace the vanilla one
StructurePoolRegistry.register(poolLocation, modifiedPool);
MarloeVillages.LOGGER.info("Replaced vanilla plains village pool with custom structures!");
}
}
Cannot resolve method 'build' in 'SinglePoolElement'
Cannot resolve method 'build' in 'SinglePoolElement'
Cannot resolve method 'getProjection' in 'StructureTemplatePool'
Cannot resolve symbol 'StructurePoolRegistry'
Assistant
Here's an updated version that should resolve the compilation errors:
java
package net.mattias.marloevillages.registry;
import net.mattias.marloevillages.MarloeVillages;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
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 net.minecraft.core.Registry;
import java.util.ArrayList;
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 = 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 = new ArrayList<>(originalPool.getElements());
customElements.addAll(List.of(
// Use direct string references to your custom structures
StructurePoolElement.single(
ModConstants.MOD_ID + ":village/plains/marloe_house_1"
).apply(StructureTemplatePool.Projection.RIGID),
StructurePoolElement.single(
ModConstants.MOD_ID + ":village/plains/marloe_house_2"
).apply(StructureTemplatePool.Projection.RIGID)
));
// 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, // Combine original and custom elements
StructureTemplatePool.Projection.RIGID // Use a consistent projection
);
// 4. Register the modified pool
Registry.register(BuiltInRegistries.STRUCTURE_POOL, poolLocation, modifiedPool);
MarloeVillages.LOGGER.info("Modified plains village pool with custom structures!");
}
}