Posted April 20, 20178 yr I used MCEdit and exported a building as .NBT and I was able to get BlockPos's as well the block using Block#getBlockFromName() but I have no idea how to get the BlockState properties. I know where they are stored but I don't know how to convert them to Block State. See the picture. For example at the first index in the Properties Compount Tag it has a property snowy: false. What I would use is Blocks.GRASS.getDefaultState().withProperty(BlockGrass.SNOWY, false) Searching the minecraft's source code I found some classes like IBlockStatePalette that I suspect they can transform this but I do not know how to use it Edited April 20, 20178 yr by GeorgeTsak
April 20, 20178 yr Unsure if this class exists in 1.9.4, but NBTUtil#func_190008_d takes an NBTTagCompound (which has an IBlockState serialized within it) and returns the proper IBlockState. You can see how vanilla MC makes use of this in Template#read. Also previously known as eAndPi. "Pi, is there a station coming up where we can board your train of thought?" -Kronnn Published Mods: Underworld Handy links: Vic_'s Forge events Own WIP Tutorials.
April 20, 20178 yr Author 7 hours ago, Matryoshika said: Unsure if this class exists in 1.9.4, but NBTUtil#func_190008_d takes an NBTTagCompound (which has an IBlockState serialized within it) and returns the proper IBlockState. You can see how vanilla MC makes use of this in Template#read. OK since func_190008_d does not exist,I used the Template#read method like this: public class NBTBuilding { NBTTagCompound nbtTagCompound; public NBTBuilding(String filename){ try { InputStream is = Schematic.class.getResourceAsStream("/assets/modname/schematics/" + filename + ".nbt"); this.nbtTagCompound = CompressedStreamTools.readCompressed(is); is.close(); } catch (Exception e){ FMLLog.warning("Error occurred while reading " + filename + ".nbt"); FMLLog.warning(String.valueOf(e)); } } public void createBuilding(World world, int x, int y, int z){ //System.out.println("Requested to create a building at " + x + ", " + y + ", " + z); Template template = ((WorldServer)(world)).getStructureTemplateManager().getTemplate(world.getMinecraftServer(), new ResourceLocation(ModName.MODID, "name")); template.read(nbtTagCompound); template.addBlocksToWorldChunk(world, new BlockPos(x, y, z), new PlacementSettings()); } } Well the structure generates in the correct shape however the blocks are messed up... Not a single block is correct. Eg instead of Stone it uses Lava. Checking here http://minecraft.gamepedia.com/Structure_block_file_format I see that my NBT file has the correct format. Any clue? Edited April 20, 20178 yr by GeorgeTsak Provide more info
April 20, 20178 yr Author Ok finally I got it. Aparrently the read method of Template does not work with the new Structure NBT of the 1.10+ So what I did was create a custom class copying the read code from 1.10. Now it works perfectly even if code is messed up a bit.
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.