Jump to content

[1.8.9]Structures


captaincleric

Recommended Posts

I have a few questions about structures.

First, is there a decent schematic exporter for 1.8.9? I've tried MCEdit and mineways, but they both (possibly) produce garbled junk, that in no way resembles what I've created. It doesn't seem to handle stairs or slabs very well.

 

Second, why - if the schematics are alright, which I think they are - would it generate garbled junk?

Here's my generation code:

public static void PlaceStructure(Schematic structure, World world, BlockPos centre)
{
	int i = 0;
	if(structure == null)
		return;

	for(int x = centre.getX() - structure.width / 2; x < centre.getX() + structure.width / 2; x++)
	{
		for(int y = centre.getY() - 1; y < centre.getY() - 1 + structure.height; y++)
		{
			for(int z = centre.getZ() - structure.length / 2; z < centre.getZ() + structure.length / 2; z++)
			{
				Block currentBlock = Block.getBlockById(structure.blocks[i]);
				i += 1;
				if(currentBlock != Blocks.air)
				{
					world.setBlockState(new BlockPos(x, y, z), currentBlock.getDefaultState());
				}
			}
		}
 	}
}

 

And here's my Schematic class:

public class SchematicHandler
{
public Schematic get(String schematic)
{
        try 
        {
            InputStream is = this.getClass().getClassLoader().getResourceAsStream("assets/masterofmagic/schematics/" + schematic + ".schematic");
            NBTTagCompound nbtdata = CompressedStreamTools.readCompressed(is);
            short width = nbtdata.getShort("Width");
            short height = nbtdata.getShort("Height");
            short length = nbtdata.getShort("Length");

            byte[] blocks = nbtdata.getByteArray("Blocks");
            byte[] data = nbtdata.getByteArray("Data");


            System.out.println("schem size:" + width + " x " + height + " x " + length);
            NBTTagList tileentities = nbtdata.getTagList("TileEntities", 10);
            is.close();

            return new Schematic(tileentities, width, height, length, blocks, data);
        } 
        catch (Exception e) 
        {
            System.out.println("I can't load schematic, because " + e.toString());
            return null;
        }
    }

    public class Schematic
    {
        public  NBTTagList tileentities;
        public  short width;
        public  short height;
        public short length;
        public byte[] blocks;
        public byte[] data;
        public Schematic(NBTTagList tileentities, short width, short height, short length, byte[] blocks, byte[] data)
        {
            this.tileentities = tileentities;
            this.width = width;
            this.height = height;
            this.length = length;
            this.blocks = blocks;
            this.data = data;
        }
    }
}

 

Here's one I made earlier:

 

uLR1jww.jpg

 

Link to comment
Share on other sites

Do you have any mods installed, and are you using any modded blocks in your structure? The trouble with modded blocks is that they do not have set IDs - the integer IDs can and will be different between different worlds, so they are no longer a valid storage format without some sort of converter (e.g. a file storing the map of block IDs to block registry names used to create the structure).

Link to comment
Share on other sites

I found the problem.

The loops must go Y, Z, X, not X, Y, Z, for some reason. That's just the way schematics are constructed, apparently. Which apparently is how pre-1.4 Minecraft did its chunks.

 

Whoever did that is stupid.

 

EDIT TO PREVENT DOUBLE POSTING:

So my structure builds, now. The only problem I have is that the block metadata (I think) for the slabs and stairs are not set properly, so they are not the right type, or are oriented incorrectly, as appropriate.

Link to comment
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.
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...

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

Announcements



×
×
  • Create New...

Important Information

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