Mmmm, then i have no clue why this is not working for you I'll post here an example of working class i'm using that spawns an obelisk in the world
public class WorldGenObelisk {
private int mirror;
private int rotation;
public WorldGenObelisk(BlockPos pos, World world) {
mirror = MW.rand.nextInt(Mirror.values().length);
rotation = MW.rand.nextInt(Rotation.values().length);
this.loadStructure(pos, world, "obelisk", true);
}
public void loadStructure(BlockPos pos, World world, String name, boolean check) {
boolean flag = false;
if (!world.isRemote) {
WorldServer worldserver = (WorldServer) world;
MinecraftServer minecraftserver = world.getMinecraftServer();
TemplateManager templatemanager = worldserver.getStructureTemplateManager();
ResourceLocation loc = new ResourceLocation(MW.MODID, name);
Template template = templatemanager.func_189942_b(minecraftserver, loc);
if (template != null) {
IBlockState iblockstate = world.getBlockState(pos);
world.notifyBlockUpdate(pos, iblockstate, iblockstate, 3);
flag = true;
if (check) {
for (int i = 0; i < template.getSize().getX(); i++) {
for (int j = 0; j < template.getSize().getZ(); j++) {
BlockPos down = pos.add(i, -1, j);
Block b = world.getBlockState(down).getBlock();
if (!b.equals(Blocks.SAND)) {
flag = false;
}
}
}
}
if (flag) {
PlacementSettings placementsettings = (new PlacementSettings()).setMirror(Mirror.values()[mirror])
.setRotation(Rotation.values()[rotation]).setIgnoreEntities(false).setChunk((ChunkPos) null)
.setReplacedBlock((Block) null).setIgnoreStructureBlock(true);
template.addBlocksToWorldChunk(world, pos.down(), placementsettings);
}
}
}
}
}
This class is called from the WorldGenMinable class, in the generateOverworld method (so where you put the code to spawn ores) by doing this
if (world.getBiomeGenForCoords(new BlockPos(x, 60, z)).equals(Biomes.DESERT) && random.nextInt(70) == 1) {
int randPosX = x + random.nextInt(35);
int randPosZ = z + random.nextInt(35);
int randPosY = 60 + random.nextInt(255 - 64);
BlockPos position = new BlockPos(randPosX, randPosY, randPosZ);
if (!(world.getBlockState(world.getTopSolidOrLiquidBlock(position)).getBlock().equals(Blocks.WATER)))
new WorldGenObelisk(world.getTopSolidOrLiquidBlock(position), world);
}
Notice that in the structure class it will also check if the spawn area is a valid area, you can remove that if you want. I hope this help, if not you can try looking at how Structure Blocks load structures and edit that code (since is exactly what i've done, maybe some small changes has been made but since is still 1.10.2 i don't think so)