Jump to content

Recommended Posts

Posted

I am creating a mod that has blocks that build structures, but I don't want to code in each of the positions for blocks by hand, so I want to use schematics. How would I start going about reading a schematic with forge?

Posted
23 minutes ago, Beethoven92 said:

You could look at how vanilla minecraft load its .nbt structure files

Alright. It seems it uses TemplateManager, and I have figured out how to get that, ang grab a Template using it, but how do I get the blocks from said template?

if (!world.isRemote) {
  TemplateManager manager = world.getServer().func_241755_D_().getStructureTemplateManager();
  Template template = manager.getTemplate(new ResourceLocation(ModBase.MODID, "schematics/small_house"));
}

 

Posted (edited)

It turns out using 

TemplateManager manager = world.getServer().func_241755_D_().getStructureTemplateManager();

crashes if its a singleplayer world, even with the !world.isRemote, so how else do I get the TemplateManager?

 

And I think to get the blocks I just do

BlockPos temp = new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ());
template.func_215386_a(temp, new PlacementSettings(), Blocks.ACACIA_WOOD, true);

 

Edited by NullDev
Posted (edited)
On 3/4/2021 at 3:22 AM, Beethoven92 said:

Please, post a link to your repository so we can see the whole code...

Sorry it took me so long, but here you go. I am trying to build it block by block from a tileentity. The code for the building is in the OneBlockBuilderTileEntityAbstract class. I currently have my own system implemented, but I'd prefer to use schematics, because those will be easier for complex structures.

https://github.com/AyliasTheCoder/OneBlockADayForge

Edited by NullDev
Forgot github link

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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