ByteBuffer is skipping loops?

Discussion in 'Plugin Development' started by Shadow_tingBRO, Apr 20, 2020.

Thread Status:
Not open for further replies.
  1. EDIT: Title should be 'File loading and save not working'

    I have a file, and I have written the correct data successfully, and now I want to retrieve it. (This is for saving a very small minecraft build without schematic format)
    There is one problem Im very confused with, when I read the data from the file I use a loop like this:
    Code:
    DataLength = buf.readInt();//amount of loops that should be done (this works)
            polys=new ArrayList<Polygon>();
            for(int i = 1; i <= DataLength; i++) {
                Polygon p = new Polygon();
                p.faces=new ArrayList<Short>();
                p.verts=new ArrayList<Float>();
                int faces = buf.readInt();
                int verts = buf.readInt();
                for(int x = 1; x <= faces; x++) {
                    short s = buf.readShort();
                    System.out.println(x+" "+s);
                    p.faces.add(s);
                }
                System.out.println("read faces");
                for(int x = 1; x <= verts; x++) {
                    float f = buf.readFloat();
                    System.out.println(x+" "+f);
                    p.verts.add(f);
                }
                System.out.println("read verts");
                polys.add(p);
            }
    
    But the problem is, Im getting different results from when the data was written,
    Here is the code + whats outputted when i save the data to the file (what should the data should be):
    https://pastebin.com/FiFXFRSc
    Here is the output from the code above:
    https://pastebin.com/A62kpvAj

    (By the way, im using data input and output streams)

    What am I doing wrong here?

    EDIT: I solved it, actually it WAS working, but I didn't read the actual log I posted as that was pasted from thje log file, the console wasnt writing each loop (Becuase it was too fast) and I realised the problem was somewhere else.
     
    Last edited: Apr 20, 2020
Thread Status:
Not open for further replies.

Share This Page