Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Spawn Custom Structures [1.16.5]


Recommended Posts

Ok maybe i found out how can i spawn the struct, but i don't know how to get the CompoundNBT from the ResourcceLocation of the file.
Can someone help?

Link to post
Share on other sites

Ok, i finally make it work
I leave it the code for everyone that need something like this.

 

public static void readStructure(ResourceLocation res, World world, BlockPos pos) {
        if (world instanceof ServerWorld) {
            ServerWorld server = (ServerWorld) world;
            TemplateManager templateManager = server.getStructureManager();
            Template template = templateManager.get(res);
            if (template != null) {
                template.placeInWorld(server, pos, new PlacementSettings().setRandom(server.random), server.random);
                System.out.println("Template loaded");
            } else {
                System.out.println("Template " + res + " does not exist");
            }
        }
    }

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
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.



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.