-
Posts
5 -
Joined
-
Last visited
-
Days Won
1
Posts posted by myWitch
-
-
Thank you very much for your attention, finally it's working! I'll tell you what was wrong, maybe someone will need it. I started with deep debug of these lines:
ResourceLocation loc = new ResourceLocation(Reference.MOD_ID,"t1.nbt");Template template = templatemanager.getTemplate(minecraftserver, loc);
And I've found that now minecraft simply adds ".nbt", no need to put it here in a file name! So, file extension was doubles and I've got no structure as a result.
-
ResourceLocation loc = new ResourceLocation(Reference.MOD_ID,"structures/t1.nbt");
- if I change this code to the one below - it's also not working, I tried indeed ((
ResourceLocation loc = new ResourceLocation(Reference.MOD_ID,"t1.nbt");
-
1 hour ago, JimiIT92 said:
The reason could be that you are searching for this resource
new ResourceLocation(Reference.MOD_ID,"structures/test2.nbt")
This will actually search for the file in structures/structures/test2.nbt, wich i believe doesn't exist. So you should just type the name of the structure in your structures folder (if is not in a sub folder). Searching for this resource instead will mostly solve your issue. That was my bad that i didn't specified earlier and i'm sorry for this. Let me know if it works after this change
new ResourceLocation(Reference.MOD_ID,"test2.nbt")
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); } }
-
On 5/13/2017 at 4:34 PM, Acrogenous said:
Forgive me for opening up an old topic, but does this work anymore?
I have recently been designing a mod (for 1.10.2) that requires structures, and came across this (very good) solution I used basically the exact same code as Jimil (except i replaced the func_ with getTemplate) and I know my structure is working as I can load it from a structure block, I have it print out the contents of template and player location and resource location, it doesn't give me any errors, it just doesn't load. can anyone here help me?
I have the same problem now, and nothing is generated in the world (on test item right click), no metter do I use get or getTemplate functions, maybe someone can help? I tried everything... Here is my code:
if (!worldIn.isRemote) { WorldServer worldserver = (WorldServer) worldIn; MinecraftServer minecraftserver = worldIn.getMinecraftServer(); TemplateManager templatemanager = worldserver.getStructureTemplateManager(); Template template = templatemanager.get(minecraftserver, new ResourceLocation(Reference.MOD_ID,"structures/test2.nbt")); Utils.getLogger().info("=======1======="+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); template.addBlocksToWorld(worldIn, pos.add(0, 1, 0), placementsettings); Utils.getLogger().info("========2======="+template); } }
Console gives me this result for loggers:
=======1=======net.minecraft.world.gen.structure.template.Template@1bca1033
========2=======net.minecraft.world.gen.structure.template.Template@1bca1033
[1.10.2] Spawning structures using Structure Blocks files
in Modder Support
Posted
Here I'll show the final code that definitly works for me: