Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (โ‹ฎ) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

myWitch

Members
  • Joined

  • Last visited

  1. Here I'll show the final code that definitly works for me: //spawn structure if (!worldIn.isRemote) { WorldServer worldserver = (WorldServer) worldIn; MinecraftServer minecraftserver = worldIn.getMinecraftServer(); TemplateManager templatemanager = worldserver.getStructureTemplateManager(); ResourceLocation loc = new ResourceLocation(Reference.MOD_ID,"t1"); Template template = templatemanager.getTemplate(minecraftserver, loc); 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, placementsettings); Utils.getLogger().info("========2======="+pos); } }
  2. 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.
  3. 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");
  4. 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); } }
  5. myWitch changed their profile photo
  6. 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

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions โ†’ Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.