Litematica (Forge)

Litematica (Forge)

336k Downloads

Option to export the schematic placements is a .mcfunction full of setblock commands.

JasonTable opened this issue ยท 3 comments

commented

Is your feature request related to a problem? Please describe.
My problem is not really related to the mod itself. There is a situation where i want to automate placing a structure using a datapack. Minecraft vanilla doesn't have a way to place structure block NBT structures with commands. So I need to use setblock commands.

Describe the solution you'd like
There can be an option to convert the schematic into a .mcfunction file. where it takes the schematic placements and exports them into setblock commands. I think this should probably be easy to implement since there is already a "paste" option that uses setblock. all it has to do is put the setblock commands in a file instead of sending it to the server.

Describe alternatives you've considered
One alternative for users is to create a personal test server and make/get a plugin that logs all the /setblock commands to a file. then run the mod's paste feature and once it's done, copy the log file from the server and that can be the mcfunction file.

Additional context
the .mcfuntion files are part of the minecraft datapack feature. they are a list of commands separated by line breaks and get ran all at once when the function is executed.
They can have up to 65,536 commands in a function so if this feature is implemented, it would have to split them into parts if there are too many blocks / commands. More info about them is available here https://minecraft.gamepedia.com/Function_(Java_Edition)

commented

I recently downloaded this mod again and saw that this feature was added. So I came by to say thanks! I will close the issue as I think it's resolved. I made use of this feature on a vanilla server to spawn structures with datapacks and rcon and It's wonderful.

commented

So my server actually does not have to be vanilla. It is a papermc server and i have worldedit. but last i checked, mcfunction files could only have vanilla commands in them. structures on my server will be placed in a separate custom dimension in a grid of 64 by 255 by 64. the nbt files for minecraft go up to 48 by 48 by 48 which might actually be big enough. if the height is greater than 48, i can split the structure. so i think i will try what you said.

Actually, before i post this reply, i remembered that litematica can convert structures into vanilla NBT files and they can be bigger than the 48 by 48 by 48 limit in the structure blocks. i wanted to see if structure blocks could still load them. So i converted a schematic that was bigger than the limit and copied it into a minecraft world's structure folder and loaded it with a structure block, and it actually worked. it acts a bit weird with them. but it works.

Maybe there could be a confirmation box that says something like "This schematic will be converted into X commands split into Y function files. Do you want to proceed?" You're right it might be best to implement this feature after the "sub-division" feature is implemented.

commented

For any kind of larger schematics these functions/files would become massive... It would at the very least need to implement the planned sub-division of the schematic to take advantage of /fill commands as well.

Can you give more context to your use case? Does the server have to be vanilla? Couldn't you instead use a /setblock to place the structure block with the proper NBT, and then another /setblock to activate it by placing a redstone block next to it? (This should work... right?)