Schematic API - Certain Blocks are null from schematic?

Discussion in 'Spigot Plugin Development' started by Twixellzz, Nov 16, 2017.

  1. Code (Text):
    public class SchematicUtils {
        private static File baseSchematicsFile;
        private static List<Schematic> allSchematics = new ArrayList<Schematic>();
        public static void initFile(File baseFile){
            baseSchematicsFile = baseFile;
        public static void initSchematics(){
            for(File schematicFile : baseSchematicsFile.listFiles()){
                    Schematic schematic = loadScheamtic(schematicFile);
                    if(schematic != null){
        public static List<Schematic> getAllSchematics(){
            return allSchematics;
        public static Schematic loadScheamtic(File file){
                    NBTInputStream nbtStream =  new NBTInputStream(new FileInputStream(file));
                    CompoundTag compound = (CompoundTag) nbtStream.readTag();
                    Map<String, Tag> tags = compound.getValue();
                    Short width = ((ShortTag) tags.get("Width")).getValue();
                    Short height = ((ShortTag) tags.get("Height")).getValue();
                    Short length = ((ShortTag) tags.get("Length")).getValue();
                    String materials = ((StringTag) tags.get("Materials")).getValue();
                    byte[] blocks = ((ByteArrayTag) tags.get("Blocks")).getValue();
                    byte[] data = ((ByteArrayTag) tags.get("Data")).getValue();
                    Schematic schematic = new Schematic(file.getName().replace(".schematic", ""), width, height, length, materials, blocks, data);
                    return schematic;
            } catch(Exception e){
                PortableBuildings.getInstance().getLogger().severe("Failed to load the schematic: " + file.getAbsolutePath());
            return null;
    When the schematic is loaded, stairs / barriers / fences and some certain blocks are null. How do I go about fixing this?
    #1 Twixellzz, Nov 16, 2017
    Last edited: Nov 16, 2017
  2. I would assume it would be a value in the byte array:
    Code (Text):
    byte[] data = ((ByteArrayTag) tags.get("Data")).getValue();
    each byte specifying an orientation.

    But im just assuming, I havent really messed around with Schematics or Schematic API's such as this one.

    And then you can set the block data to that using Block#setData()

    However setData is depricated, so I would look for another way of setting the data, but its worth giving it a try.

    Just do a quick debug by logging every data that gets read and check the values if when it reaches the stairs it changes for every orientation, you know that's what it is. Make a test schematic with stairs in different orientations.
    #2 vivabenfica4, Nov 16, 2017
    Last edited: Nov 16, 2017
  3. Thanks for the reply @vivabenfica4, unfortunately the stairs are null when the schematic is loaded. So the only way I can do it is, to check if the block is null when I'm pasting the schematic, and replacing it with stairs. It still keeps the block data (blockface) but does not know the material of the block for some reason.