JimilT92, thank you very much for your answer. I tried this too with no success ((( actually I tried tones of variants, including rewriting of addBlocksToWorld function... Here is the last variant that gives not null template, but nothing spawns, so I'm really stuck on it :((( I put this code right into onItemRightClick, but I think it doesn't matter if I put it somewhere as a separate function... Test file t1.nbt is in structures folder and I checked it by using structure block loading - it's good. You can also see some variants that I've tried in commented lines... If you can give me any ideas I would be realy happy )) It's the last thing to be solved for my mod.
if (!worldIn.isRemote) {
WorldServer worldserver = (WorldServer) worldIn;
MinecraftServer minecraftserver = worldIn.getMinecraftServer();
TemplateManager templatemanager = worldserver.getStructureTemplateManager();
ResourceLocation loc = new ResourceLocation(Reference.MOD_ID,"structures/t1.nbt");
Template template = templatemanager.getTemplate(minecraftserver, loc); //.get(minecraftserver, new ResourceLocation(Reference.MOD_ID,"t1.nbt"));
Utils.getLogger().info("=======0======="+template);
if (template != null) {
worldIn.notifyBlockUpdate(pos, iblockstate, iblockstate, 3);
PlacementSettings placementsettings = (new PlacementSettings()).setMirror(Mirror.NONE)
.setRotation(Rotation.NONE).setIgnoreEntities(false).setChunk((ChunkPos) null)
.setReplacedBlock((Block) null).setIgnoreStructureBlock(false);
Utils.getLogger().info("=======1======="+loc);
//template.addBlocksToWorld(worldIn, pos, new BlockRotationProcessor(pos, placementsettings), placementsettings, 1);
//template.addBlocksToWorld(worldIn, pos.add(0, 1, 0), placementsettings);
template.addBlocksToWorldChunk(worldIn, pos, placementsettings);
Utils.getLogger().info("========2======="+template);
}
}