Posted May 5, 20214 yr Hi! I have a file .nbt that represents a struct. The question is, how can i spawn that struct in a particular BlockPos?
May 5, 20214 yr Author 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?
May 5, 20214 yr Author 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"); } } }
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.