Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

Untitled.png

Edited by GeorgeTsak

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.

  • 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 by GeorgeTsak
Provide more info

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

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.