Solved Schematic Exporting (Manually)

Discussion in 'Spigot Plugin Development' started by XZot1K, Jul 23, 2018.

  1. Afternoon, so I've been messing around with the concept of importing a schematic and exporting to a schematic file, but I'm having a little bit of trouble with the exporting portion. My original thoughts were to start at the minimum point of a selection for a player and increase the yY until it is no longer less than the maximum point and then of course nesting further loop within the Y loop to find x and z. So, I guess my question is what is the best way of going about doing this in terms of getting the Byte arrays to store into a schematic object listed below. My intention is not so much to save it to a file, but to at least temporarily snapshot the selection and move it. Hopefully, someone has dealt with this more than I have and can share some valuable information! :)
    Code (Java):
    package xzot1k.plugins.ec.core.utils.objects;

    public class Schematic
    {

        private byte[] blocks, data;
        private short width;
        private short length, height;

        public Schematic()
        {
            setBlocks(new byte[]{});
            setData(new byte[]{});
            setWidth((short) 0);
            setHeight((short) 0);
            setLength((short) 0);
        }

        public byte[] getBlocks()
        {
            return blocks;
        }

        public void setBlocks(byte[] blocks)
        {
            this.blocks = blocks;
        }

        public byte[] getData()
        {
            return data;
        }

        public void setData(byte[] data)
        {
            this.data = data;
        }

        public short getWidth()
        {
            return width;
        }

        public void setWidth(short width)
        {
            this.width = width;
        }

        public short getLength()
        {
            return length;
        }

        public void setLength(short length)
        {
            this.length = length;
        }

        public short getHeight()
        {
            return height;
        }

        public void setHeight(short height)
        {
            this.height = height;
        }
    }
     
    Please note the object above is just an example; however, I would like to store the information displayed!
     
  2. A couple years ago I made a plugin that worked with schematics and unfortunately I don't have the code I wrote to accomplish it. However, I would suggest looking at WorldEdit's code for schematics and play around with it to fit your needs. I found these files on WorldEdit's GitHub after a quick Google search. I hope it's some help to you. Good luck!

    Schematic related WorldEdit code:
    - SchematicWriter.java
    - SchematicReader.java
     
    • Winner Winner x 1
  3. Sweet that's actually exactly what I needed, I appreciate it sir!
     
    • Like Like x 1