Thread: Elvarg V3.2 Updating data to 207.4 and fixing modelLoader

Results 1 to 2 of 2
  1. #1 Elvarg V3.2 Updating data to 207.4 and fixing modelLoader 
    Registered Member Fozzey's Avatar
    Join Date
    Jan 2014
    Posts
    33
    Thanks given
    8
    Thanks received
    1
    Rep Power
    11
    Im getting this error on a constant loop. I have added a modelLoader class and adjusted it all to link with my model class. I have added the new Model(int modelId) into my model.java, i have added all the readvalues to the correct classes objdef, itemdef and npcdef. I have updated the collisionmap, I have added the readSmart() and the readUnsignedIntSmartShortCompat(). I have loaded 207.4 data, loc.dat, npc.dat, obj.dat etc. and i made sure i did the mapIndex BOTH client/Server side aswell as loc.dat and loc.idx. I have repacked the cache index1,2,4 that came with the 207.4 data. As i said above i get this error down below and i can log into the game and i can move but all graphics are just not there, so no minimap, world, npc etc. I am also getting opcode error messages server side which is also pasted below. Im not sure where to go with this info. I believe i haven't missed anything in the snippets above. I followed the guide posted by Mark.

    I updated the client stack with the debug info.

    Spoiler for Client stack:
    Code:
    java.lang.ArrayIndexOutOfBoundsException: Index 205 out of bounds for length 204
    	at com.runescape.io.Buffer.readUnsignedByte(Buffer.java:147)
    	at com.runescape.entity.model.ModelLoader.decodeType2(ModelLoader.java:515)
    	at com.runescape.entity.model.Model.<init>(Model.java:107)
    	at com.runescape.entity.model.Model.getModel(Model.java:656)
    	at com.runescape.cache.def.ItemDefinition.getModel(ItemDefinition.java:579)
    	at com.runescape.cache.def.ItemDefinition.getSprite(ItemDefinition.java:266)
    	at com.runescape.Client.drawInterface(Client.java:10863)
    	at com.runescape.Client.drawTabArea(Client.java:4143)
    	at com.runescape.Client.drawGameScreen(Client.java:10618)
    	at com.runescape.Client.processDrawing(Client.java:12052)
    	at com.runescape.GameApplet.run(GameApplet.java:219)
    	at com.runescape.Client.run(Client.java:7283)
    	at java.base/java.lang.Thread.run(Thread.java:831)


    Spoiler for Server stack:
    Code:
    Sept 24, 2022 8:15:11 PM com.elvarg.game.definition.loader.DefinitionLoader run
    INFO: Loaded definitions for: ./data/definitions/object_spawns.json. It took 199 milliseconds.
    Sept 24, 2022 8:15:11 PM com.elvarg.game.definition.loader.DefinitionLoader run
    INFO: Loaded definitions for: ./data/definitions/items.json. It took 251 milliseconds.
    Sept 24, 2022 8:15:11 PM com.elvarg.game.definition.loader.DefinitionLoader run
    INFO: Loaded definitions for: ./data/definitions/shops.json. It took 8 milliseconds.
    Sept 24, 2022 8:15:11 PM com.elvarg.game.definition.loader.DefinitionLoader run
    INFO: Loaded definitions for: ./data/definitions/npc_defs.json. It took 56 milliseconds.
    Sept 24, 2022 8:15:11 PM com.elvarg.game.definition.loader.DefinitionLoader run
    INFO: Loaded definitions for: ./data/definitions/npc_drops.json. It took 36 milliseconds.
    Sept 24, 2022 8:15:11 PM com.elvarg.game.definition.loader.DefinitionLoader run
    INFO: Loaded definitions for: ./data/definitions/npc_spawns.json. It took 62 milliseconds.
    invalid opcode: 61
    invalid opcode: 3
    invalid opcode: 129
    invalid opcode: 61
    invalid opcode: 6
    invalid opcode: 148
    invalid opcode: 61
    invalid opcode: 6
    invalid opcode: 148
    invalid opcode: 61
    invalid opcode: 6
    invalid opcode: 148
    invalid opcode: 61
    invalid opcode: 3
    invalid opcode: 192
    Sept 24, 2022 8:15:11 PM com.elvarg.game.definition.loader.DefinitionLoader run
    INFO: Loaded definitions for: ./data/definitions/global_presets.json. It took 30 milliseconds.
    Sept 24, 2022 8:15:12 PM com.elvarg.Server main
    INFO: RuneScape is now online!
    invalid opcode: 61
    invalid opcode: 3
    invalid opcode: 4
    invalid opcode: 61
    invalid opcode: 3
    invalid opcode: 192
    invalid opcode: 61
    invalid opcode: 61
    invalid opcode: 6
    invalid opcode: 148
    invalid opcode: 61
    invalid opcode: 6
    invalid opcode: 148
    invalid opcode: 61
    invalid opcode: 6
    invalid opcode: 148
    invalid opcode: 61
    invalid opcode: 3
    invalid opcode: 192
    invalid opcode: 61
    invalid opcode: 61
    invalid opcode: 61
    invalid opcode: 61
    invalid opcode: 61
    invalid opcode: 61
    invalid opcode: 61
    [World] Registering player - [username, host] : [Florrey, 127.0.0.1]
    invalid opcode: 61
    invalid opcode: 61
    invalid opcode: 61
    invalid opcode: 61
    invalid opcode: 61
    invalid opcode: 61
    invalid opcode: 3
    invalid opcode: 129
    [World] Deregistering player - [username, host] : [Florrey, 127.0.0.1]


    Spoiler for model.java:
    Code:
        private Model(int modelId) {
            byte[] is = modelHeader[modelId].aByteArray368;
            if (is[is.length - 1] == -3 && is[is.length - 2] == -1) {
                ModelLoader.decodeType3(this, is);
            } else if (is[is.length - 1] == -2 && is[is.length - 2] == -1) {
                ModelLoader.decodeType2(this, is);
            } else if (is[is.length - 1] == -1 && is[is.length - 2] == -1) {
                ModelLoader.decodeType1(this, is);
            } else {
                ModelLoader.decodeOldFormat(this, is);
            }
    
        }


    Spoiler for modelLoader.java:
    Code:
    package com.runescape.entity.model;
    import com.runescape.io.Buffer;
    
        public class ModelLoader {
    
            public static void decodeType3(Model def, byte[] var1)
            {
                Buffer var2 = new Buffer(var1);
                Buffer var3 = new Buffer(var1);
                Buffer var4 = new Buffer(var1);
                Buffer var5 = new Buffer(var1);
                Buffer var6 = new Buffer(var1);
                Buffer var7 = new Buffer(var1);
                Buffer var8 = new Buffer(var1);
                var2.setOffset(var1.length - 26);
                int var9 = var2.readUShort();
                int var10 = var2.readUShort();
                int var11 = var2.readUnsignedByte();
                int var12 = var2.readUnsignedByte();
                int var13 = var2.readUnsignedByte();
                int var14 = var2.readUnsignedByte();
                int var15 = var2.readUnsignedByte();
                int var16 = var2.readUnsignedByte();
                int var17 = var2.readUnsignedByte();
                int var18 = var2.readUnsignedByte();
                int var19 = var2.readUShort();
                int var20 = var2.readUShort();
                int var21 = var2.readUShort();
                int var22 = var2.readUShort();
                int var23 = var2.readUShort();
                int var24 = var2.readUShort();
                int var25 = 0;
                int var26 = 0;
                int var27 = 0;
                int var28;
    
    
                if (var11 > 0)
                {
                    def.texture_type = new byte[var11];
                    var2.setOffset(0);
    
                    for (var28 = 0; var28 < var11; ++var28)
                    {
                        byte var29 = def.texture_type[var28] = var2.readByteS();
                        if (var29 == 0)
                        {
                            ++var25;
                        }
    
                        if (var29 >= 1 && var29 <= 3)
                        {
                            ++var26;
                        }
    
                        if (var29 == 2)
                        {
                            ++var27;
                        }
                    }
                }
    
                var28 = var11 + var9;
                int var58 = var28;
                if (var12 == 1)
                {
                    var28 += var10;
                }
    
                int var30 = var28;
                var28 += var10;
                int var31 = var28;
                if (var13 == 255)
                {
                    var28 += var10;
                }
    
                int var32 = var28;
                if (var15 == 1)
                {
                    var28 += var10;
                }
    
                int var33 = var28;
                var28 += var24;
                int var34 = var28;
                if (var14 == 1)
                {
                    var28 += var10;
                }
    
                int var35 = var28;
                var28 += var22;
                int var36 = var28;
                if (var16 == 1)
                {
                    var28 += var10 * 2;
                }
    
                int var37 = var28;
                var28 += var23;
                int var38 = var28;
                var28 += var10 * 2;
                int var39 = var28;
                var28 += var19;
                int var40 = var28;
                var28 += var20;
                int var41 = var28;
                var28 += var21;
                int var42 = var28;
                var28 += var25 * 6;
                int var43 = var28;
                var28 += var26 * 6;
                int var44 = var28;
                var28 += var26 * 6;
                int var45 = var28;
                var28 += var26 * 2;
                int var46 = var28;
                var28 += var26;
                int var47 = var28;
                var28 = var28 + var26 * 2 + var27 * 2;
    
    
                def.numVertices = var9;
                def.numTriangles = var10;
                def.numberOfTexturesFaces = var11;
                def.vertexX = new int[var9];
                def.vertexY = new int[var9];
                def.vertexZ = new int[var9];
                def.facePointA = new int[var10];
                def.facePointB = new int[var10];
                def.facePointC = new int[var10];
                if (var17 == 1)
                {
                    def.vertexVSkin = new int[var9];
                }
    
                if (var12 == 1)
                {
                    def.faceDrawType = new int[var10];
                }
    
                if (var13 == 255)
                {
                    def.face_render_priorities = new byte[var10];
                }
                else
                {
                    def.face_priority = (byte) var13;
                }
    
                if (var14 == 1)
                {
                    def.face_alpha = new int[var10];
                }
    
                if (var15 == 1)
                {
                    def.triangleTSkin = new int[var10];
                }
    
                if (var16 == 1)
                {
                    def.materials = new short[var10];
                }
    
                if (var16 == 1 && var11 > 0)
                {
                    def.texture_type = new byte[var10];
                }
    
                if (var18 == 1)
                {
                    def.animayaGroups = new int[var9][];
                    def.animayaScales = new int[var9][];
                }
    
                def.triangleColours = new short[var10];
                if (var11 > 0)
                {
                    def.textures_face_a = new short[var11];
                    def.textures_face_b = new short[var11];
                    def.textures_face_c = new short[var11];
                }
    
                var2.setOffset(var11);
                var3.setOffset(var39);
                var4.setOffset(var40);
                var5.setOffset(var41);
                var6.setOffset(var33);
                int var48 = 0;
                int var49 = 0;
                int var50 = 0;
    
                int var51;
                int var52;
                int var53;
                int var54;
                int var55;
                for (var51 = 0; var51 < var9; ++var51)
                {
                    var52 = var2.readUnsignedByte();
                    var53 = 0;
                    if ((var52 & 1) != 0)
                    {
                        var53 = var3.readSmart();
                    }
    
                    var54 = 0;
                    if ((var52 & 2) != 0)
                    {
                        var54 = var4.readSmart();
                    }
    
                    var55 = 0;
                    if ((var52 & 4) != 0)
                    {
                        var55 = var5.readSmart();
                    }
    
                    def.vertexX[var51] = var48 + var53;
                    def.vertexY[var51] = var49 + var54;
                    def.vertexZ[var51] = var50 + var55;
                    var48 = def.vertexX[var51];
                    var49 = def.vertexY[var51];
                    var50 = def.vertexZ[var51];
                    if (var17 == 1)
                    {
                        def.vertexVSkin[var51] = var6.readUnsignedByte();
                    }
                }
    
                if (var18 == 1)
                {
                    for (var51 = 0; var51 < var9; ++var51)
                    {
                        var52 = var6.readUnsignedByte();
                        def.animayaGroups[var51] = new int[var52];
                        def.animayaScales[var51] = new int[var52];
    
                        for (var53 = 0; var53 < var52; ++var53)
                        {
                            def.animayaGroups[var51][var53] = var6.readUnsignedByte();
                            def.animayaScales[var51][var53] = var6.readUnsignedByte();
                        }
                    }
                }
    
                var2.setOffset(var38);
                var3.setOffset(var58);
                var4.setOffset(var31);
                var5.setOffset(var34);
                var6.setOffset(var32);
                var7.setOffset(var36);
                var8.setOffset(var37);
    
                for (var51 = 0; var51 < var10; ++var51)
                {
                    def.triangleColours[var51] = (short) var2.readUShort();
                    if (var12 == 1)
                    {
                        def.faceDrawType[var51] = var3.readByteS();
                    }
    
                    if (var13 == 255)
                    {
                        def.face_render_priorities[var51] = var4.readByteS();
                    }
    
                    if (var14 == 1)
                    {
                        def.face_alpha[var51] = var5.readByteS();
                        if (def.face_alpha[var51] < 0) {
                            def.face_alpha[var51] = (256 + def.face_alpha[var51]);
                        }
                    }
    
                    if (var15 == 1)
                    {
                        def.triangleTSkin[var51] = var6.readUnsignedByte();
                    }
    
                    if (var16 == 1)
                    {
                        def.materials[var51] = (short) (var7.readUShort() - 1);
                    }
    
                    if (def.texture != null && def.materials[var51] != -1)
                    {
                        def.texture[var51] = (byte) (var8.readUnsignedByte() - 1);
                    }
                }
    
                var2.setOffset(var35);
                var3.setOffset(var30);
                var51 = 0;
                var52 = 0;
                var53 = 0;
                var54 = 0;
    
                int var56;
                for (var55 = 0; var55 < var10; ++var55)
                {
                    var56 = var3.readUnsignedByte();
                    if (var56 == 1)
                    {
                        var51 = var2.readSmart() + var54;
                        var52 = var2.readSmart() + var51;
                        var53 = var2.readSmart() + var52;
                        var54 = var53;
                        def.facePointA[var55] = var51;
                        def.facePointB[var55] = var52;
                        def.facePointC[var55] = var53;
                    }
    
                    if (var56 == 2)
                    {
                        var52 = var53;
                        var53 = var2.readSmart() + var54;
                        var54 = var53;
                        def.facePointA[var55] = var51;
                        def.facePointB[var55] = var52;
                        def.facePointC[var55] = var53;
                    }
    
                    if (var56 == 3)
                    {
                        var51 = var53;
                        var53 = var2.readSmart() + var54;
                        var54 = var53;
                        def.facePointA[var55] = var51;
                        def.facePointB[var55] = var52;
                        def.facePointC[var55] = var53;
                    }
    
                    if (var56 == 4)
                    {
                        int var57 = var51;
                        var51 = var52;
                        var52 = var57;
                        var53 = var2.readSmart() + var54;
                        var54 = var53;
                        def.facePointA[var55] = var51;
                        def.facePointB[var55] = var57;
                        def.facePointC[var55] = var53;
                    }
                }
    
                var2.setOffset(var42);
                var3.setOffset(var43);
                var4.setOffset(var44);
                var5.setOffset(var45);
                var6.setOffset(var46);
                var7.setOffset(var47);
    
                for (var55 = 0; var55 < var11; ++var55)
                {
                    var56 = def.texture_type[var55] & 255;
                    if (var56 == 0)
                    {
                        def.textures_face_a[var55] = (short) var2.readUShort();
                        def.textures_face_b[var55] = (short) var2.readUShort();
                        def.textures_face_c[var55] = (short) var2.readUShort();
                    }
                }
    
                var2.setOffset(var28);
                var55 = var2.readUnsignedByte();
                if (var55 != 0)
                {
                    var2.readUShort();
                    var2.readUShort();
                    var2.readUShort();
                    var2.readInt();
                }
    
            }
    
            public static void decodeType2(Model def, byte[] var1)
            {
                boolean var2 = false;
                boolean var3 = false;
                Buffer var4 = new Buffer(var1);
                Buffer var5 = new Buffer(var1);
                Buffer var6 = new Buffer(var1);
                Buffer var7 = new Buffer(var1);
                Buffer var8 = new Buffer(var1);
                var4.setOffset(var1.length - 23);
                int var9 = var4.readUShort();
                int var10 = var4.readUShort();
                int var11 = var4.readUnsignedByte();
                int var12 = var4.readUnsignedByte();
                int var13 = var4.readUnsignedByte();
                int var14 = var4.readUnsignedByte();
                int var15 = var4.readUnsignedByte();
                int var16 = var4.readUnsignedByte();
                int var17 = var4.readUnsignedByte();
                int var18 = var4.readUShort();
                int var19 = var4.readUShort();
                int var20 = var4.readUShort();
                int var21 = var4.readUShort();
                int var22 = var4.readUShort();
                byte var23 = 0;
                int var24 = var23 + var9;
                int var25 = var24;
                var24 += var10;
                int var26 = var24;
                if (var13 == 255)
                {
                    var24 += var10;
                }
    
                int var27 = var24;
                if (var15 == 1)
                {
                    var24 += var10;
                }
    
                int var28 = var24;
                if (var12 == 1)
                {
                    var24 += var10;
                }
    
                int var29 = var24;
                var24 += var22;
                int var30 = var24;
                if (var14 == 1)
                {
                    var24 += var10;
                }
    
                int var31 = var24;
                var24 += var21;
                int var32 = var24;
                var24 += var10 * 2;
                int var33 = var24;
                var24 += var11 * 6;
                int var34 = var24;
                var24 += var18;
                int var35 = var24;
                var24 += var19;
                int var10000 = var24 + var20;
                def.numVertices = var9;
                def.numTriangles = var10;
                def.numberOfTexturesFaces = var11;
                def.vertexX = new int[var9];
                def.vertexY = new int[var9];
                def.vertexZ = new int[var9];
                def.facePointA = new int[var10];
                def.facePointB = new int[var10];
                def.facePointC = new int[var10];
                if (var11 > 0)
                {
                    def.texture_type = new byte[var11];
                    def.textures_face_a = new short[var11];
                    def.textures_face_b = new short[var11];
                    def.textures_face_c = new short[var11];
                }
    
                if (var16 == 1)
                {
                    def.vertexVSkin = new int[var9];
                }
    
                if (var12 == 1)
                {
                    def.faceDrawType = new int[var10];
                    def.texture_type = new byte[var10];
                    def.materials = new short[var10];
                }
    
                if (var13 == 255)
                {
                    def.face_render_priorities = new byte[var10];
                }
                else
                {
                    def.face_priority = (byte) var13;
                }
    
                if (var14 == 1)
                {
                    def.face_alpha = new int[var10];
                }
    
                if (var15 == 1)
                {
                    def.triangleTSkin = new int[var10];
                }
    
                if (var17 == 1)
                {
                    def.animayaGroups = new int[var9][];
                    def.animayaScales = new int[var9][];
                }
    
                def.triangleColours = new short[var10];
                var4.setOffset(var23);
                var5.setOffset(var34);
                var6.setOffset(var35);
                var7.setOffset(var24);
                var8.setOffset(var29);
                int var37 = 0;
                int var38 = 0;
                int var39 = 0;
    
                int var40;
                int var41;
                int var42;
                int var43;
                int var44;
                for (var40 = 0; var40 < var9; ++var40)
                {
                    var41 = var4.readUnsignedByte();
                    var42 = 0;
                    if ((var41 & 1) != 0)
                    {
                        var42 = var5.readSmart();
                    }
    
                    var43 = 0;
                    if ((var41 & 2) != 0)
                    {
                        var43 = var6.readSmart();
                    }
    
                    var44 = 0;
                    if ((var41 & 4) != 0)
                    {
                        var44 = var7.readSmart();
                    }
    
                    def.vertexX[var40] = var37 + var42;
                    def.vertexY[var40] = var38 + var43;
                    def.vertexZ[var40] = var39 + var44;
                    var37 = def.vertexX[var40];
                    var38 = def.vertexY[var40];
                    var39 = def.vertexZ[var40];
                    if (var16 == 1)
                    {
                        def.vertexVSkin[var40] = var8.readUnsignedByte();
                    }
                }
    
                if (var17 == 1)
                {
                    for (var40 = 0; var40 < var9; ++var40)
                    {
                        var41 = var8.readUnsignedByte();
                        def.animayaGroups[var40] = new int[var41];
                        def.animayaScales[var40] = new int[var41];
    
                        for (var42 = 0; var42 < var41; ++var42)
                        {
                            def.animayaGroups[var40][var42] = var8.readUnsignedByte();
                            def.animayaScales[var40][var42] = var8.readUnsignedByte();
                        }
                    }
                }
    
                var4.setOffset(var32);
                var5.setOffset(var28);
                var6.setOffset(var26);
                var7.setOffset(var30);
                var8.setOffset(var27);
    
                for (var40 = 0; var40 < var10; ++var40)
                {
                    def.triangleColours[var40] = (short) var4.readUShort();
                    if (var12 == 1)
                    {
                        var41 = var5.readUnsignedByte();
                        if ((var41 & 1) == 1)
                        {
                            def.faceDrawType[var40] = 1;
                            var2 = true;
                        }
                        else
                        {
                            def.faceDrawType[var40] = 0;
                        }
    
                        if ((var41 & 2) == 2)
                        {
                            def.texture[var40] = (byte) (var41 >> 2);
                            def.materials[var40] = def.triangleColours[var40];
                            def.triangleColours[var40] = 127;
                            if (def.materials[var40] != -1)
                            {
                                var3 = true;
                            }
                        }
                        else
                        {
                            def.texture[var40] = -1;
                            def.materials[var40] = -1;
                        }
                    }
    
                    if (var13 == 255)
                    {
                        def.face_render_priorities[var40] = var6.readByteS();
                    }
    
                    if (var14 == 1)
                    {
                        def.face_alpha[var40] = var7.readByteS();
                        if (def.face_alpha[var40] < 0) {
                            def.face_alpha[var40] = (256 + def.face_alpha[var40]);
                        }
                    }
    
                    if (var15 == 1)
                    {
                        def.triangleTSkin[var40] = var8.readUnsignedByte();
                    }
                }
    
                var4.setOffset(var31);
                var5.setOffset(var25);
                var40 = 0;
                var41 = 0;
                var42 = 0;
                var43 = 0;
    
                int var45;
                int var46;
                for (var44 = 0; var44 < var10; ++var44)
                {
                    var45 = var5.readUnsignedByte();
                    if (var45 == 1)
                    {
                        var40 = var4.readSmart() + var43;
                        var41 = var4.readSmart() + var40;
                        var42 = var4.readSmart() + var41;
                        var43 = var42;
                        def.facePointA[var44] = var40;
                        def.facePointB[var44] = var41;
                        def.facePointC[var44] = var42;
                    }
    
                    if (var45 == 2)
                    {
                        var41 = var42;
                        var42 = var4.readSmart() + var43;
                        var43 = var42;
                        def.facePointA[var44] = var40;
                        def.facePointB[var44] = var41;
                        def.facePointC[var44] = var42;
                    }
    
                    if (var45 == 3)
                    {
                        var40 = var42;
                        var42 = var4.readSmart() + var43;
                        var43 = var42;
                        def.facePointA[var44] = var40;
                        def.facePointB[var44] = var41;
                        def.facePointC[var44] = var42;
                    }
    
                    if (var45 == 4)
                    {
                        var46 = var40;
                        var40 = var41;
                        var41 = var46;
                        var42 = var4.readSmart() + var43;
                        var43 = var42;
                        def.facePointA[var44] = var40;
                        def.facePointB[var44] = var46;
                        def.facePointC[var44] = var42;
                    }
                }
    
                var4.setOffset(var33);
    
                for (var44 = 0; var44 < var11; ++var44)
                {
                    def.texture_type[var44] = 0;
                    def.textures_face_a[var44] = (short) var4.readUShort();
                    def.textures_face_b[var44] = (short) var4.readUShort();
                    def.textures_face_c[var44] = (short) var4.readUShort();
                }
    
                if (def.texture != null)
                {
                    boolean var47 = false;
    
                    for (var45 = 0; var45 < var10; ++var45)
                    {
                        var46 = def.texture[var45] & 255;
                        if (var46 != 255)
                        {
                            if (def.facePointA[var45] == (def.textures_face_a[var46] & '\uffff') && def.facePointB[var45] == (def.textures_face_b[var46] & '\uffff') && def.facePointC[var45] == (def.textures_face_c[var46] & '\uffff'))
                            {
                                def.texture[var45] = -1;
                            }
                            else
                            {
                                var47 = true;
                            }
                        }
                    }
    
                    if (!var47)
                    {
                        def.texture = null;
                    }
                }
    
                if (!var3)
                {
                    def.materials = null;
                }
    
                if (!var2)
                {
                    def.faceDrawType = null;
                }
    
            }
    
            public static void decodeType1(Model def, byte[] var1)
            {
                Buffer var2 = new Buffer(var1);
                Buffer var3 = new Buffer(var1);
                Buffer var4 = new Buffer(var1);
                Buffer var5 = new Buffer(var1);
                Buffer var6 = new Buffer(var1);
                Buffer var7 = new Buffer(var1);
                Buffer var8 = new Buffer(var1);
                var2.setOffset(var1.length - 23);
                int var9 = var2.readUShort();
                int var10 = var2.readUShort();
                int var11 = var2.readUnsignedByte();
                int var12 = var2.readUnsignedByte();
                int var13 = var2.readUnsignedByte();
                int var14 = var2.readUnsignedByte();
                int var15 = var2.readUnsignedByte();
                int var16 = var2.readUnsignedByte();
                int var17 = var2.readUnsignedByte();
                int var18 = var2.readUShort();
                int var19 = var2.readUShort();
                int var20 = var2.readUShort();
                int var21 = var2.readUShort();
                int var22 = var2.readUShort();
                int var23 = 0;
                int var24 = 0;
                int var25 = 0;
                int var26;
                if (var11 > 0)
                {
                    def.texture_type = new byte[var11];
                    var2.setOffset(0);
    
                    for (var26 = 0; var26 < var11; ++var26)
                    {
                        byte var27 = def.texture_type[var26] = var2.readByteS();
                        if (var27 == 0)
                        {
                            ++var23;
                        }
    
                        if (var27 >= 1 && var27 <= 3)
                        {
                            ++var24;
                        }
    
                        if (var27 == 2)
                        {
                            ++var25;
                        }
                    }
                }
    
                var26 = var11 + var9;
                int var56 = var26;
                if (var12 == 1)
                {
                    var26 += var10;
                }
    
                int var28 = var26;
                var26 += var10;
                int var29 = var26;
                if (var13 == 255)
                {
                    var26 += var10;
                }
    
                int var30 = var26;
                if (var15 == 1)
                {
                    var26 += var10;
                }
    
                int var31 = var26;
                if (var17 == 1)
                {
                    var26 += var9;
                }
    
                int var32 = var26;
                if (var14 == 1)
                {
                    var26 += var10;
                }
    
                int var33 = var26;
                var26 += var21;
                int var34 = var26;
                if (var16 == 1)
                {
                    var26 += var10 * 2;
                }
    
                int var35 = var26;
                var26 += var22;
                int var36 = var26;
                var26 += var10 * 2;
                int var37 = var26;
                var26 += var18;
                int var38 = var26;
                var26 += var19;
                int var39 = var26;
                var26 += var20;
                int var40 = var26;
                var26 += var23 * 6;
                int var41 = var26;
                var26 += var24 * 6;
                int var42 = var26;
                var26 += var24 * 6;
                int var43 = var26;
                var26 += var24 * 2;
                int var44 = var26;
                var26 += var24;
                int var45 = var26;
                var26 = var26 + var24 * 2 + var25 * 2;
                def.numVertices = var9;
                def.numTriangles = var10;
                def.numberOfTexturesFaces = var11;
                def.vertexX = new int[var9];
                def.vertexY = new int[var9];
                def.vertexZ = new int[var9];
                def.facePointA = new int[var10];
                def.facePointB = new int[var10];
                def.facePointC = new int[var10];
                if (var17 == 1)
                {
                    def.vertexVSkin = new int[var9];
                }
    
                if (var12 == 1)
                {
                    def.faceDrawType = new int[var10];
    
                }
    
                if (var13 == 255)
                {
                    def.face_render_priorities = new byte[var10];
                }
                else
                {
                    def.face_priority = (byte) var13;
                }
    
                if (var14 == 1)
                {
                    def.face_alpha = new int[var10];
                }
    
                if (var15 == 1)
                {
                    def.triangleTSkin = new int[var10];
                }
    
                if (var16 == 1)
                {
                    def.materials = new short[var10];
                }
    
                if (var16 == 1 && var11 > 0)
                {
                    def.texture_type = new byte[var10];
                }
    
                def.triangleColours = new short[var10];
                if (var11 > 0)
                {
                    def.textures_face_a = new short[var11];
                    def.textures_face_b = new short[var11];
                    def.textures_face_c = new short[var11];
                }
    
                var2.setOffset(var11);
                var3.setOffset(var37);
                var4.setOffset(var38);
                var5.setOffset(var39);
                var6.setOffset(var31);
                int var46 = 0;
                int var47 = 0;
                int var48 = 0;
    
                int var49;
                int var50;
                int var51;
                int var52;
                int var53;
                for (var49 = 0; var49 < var9; ++var49)
                {
                    var50 = var2.readUnsignedByte();
                    var51 = 0;
                    if ((var50 & 1) != 0)
                    {
                        var51 = var3.readSmart();
                    }
    
                    var52 = 0;
                    if ((var50 & 2) != 0)
                    {
                        var52 = var4.readSmart();
                    }
    
                    var53 = 0;
                    if ((var50 & 4) != 0)
                    {
                        var53 = var5.readSmart();
                    }
    
                    def.vertexX[var49] = var46 + var51;
                    def.vertexY[var49] = var47 + var52;
                    def.vertexZ[var49] = var48 + var53;
                    var46 = def.vertexX[var49];
                    var47 = def.vertexY[var49];
                    var48 = def.vertexZ[var49];
                    if (var17 == 1)
                    {
                        def.vertexVSkin[var49] = var6.readUnsignedByte();
                    }
                }
    
                var2.setOffset(var36);
                var3.setOffset(var56);
                var4.setOffset(var29);
                var5.setOffset(var32);
                var6.setOffset(var30);
                var7.setOffset(var34);
                var8.setOffset(var35);
    
                for (var49 = 0; var49 < var10; ++var49)
                {
                    def.triangleColours[var49] = (short) var2.readUShort();
                    if (var12 == 1)
                    {
                        def.faceDrawType[var49] = var3.readByteS();
                    }
    
                    if (var13 == 255)
                    {
                        def.face_render_priorities[var49] = var4.readByteS();
                    }
    
                    if (var14 == 1)
                    {
                        def.face_alpha[var49] = var5.readByteS();
                        if (def.face_alpha[var49] < 0) {
                            def.face_alpha[var49] = (256 + def.face_alpha[var40]);
                        }
                    }
    
                    if (var15 == 1)
                    {
                        def.triangleTSkin[var49] = var6.readUnsignedByte();
                    }
    
                    if (var16 == 1)
                    {
                        def.materials[var49] = (short) (var7.readUShort() - 1);
                    }
    
                    if (def.texture != null && def.materials[var49] != -1)
                    {
                        def.texture[var49] = (byte) (var8.readUnsignedByte() - 1);
                    }
                }
    
                var2.setOffset(var33);
                var3.setOffset(var28);
                var49 = 0;
                var50 = 0;
                var51 = 0;
                var52 = 0;
    
                int var54;
                for (var53 = 0; var53 < var10; ++var53)
                {
                    var54 = var3.readUnsignedByte();
                    if (var54 == 1)
                    {
                        var49 = var2.readSmart() + var52;
                        var50 = var2.readSmart() + var49;
                        var51 = var2.readSmart() + var50;
                        var52 = var51;
                        def.facePointA[var53] = var49;
                        def.facePointB[var53] = var50;
                        def.facePointC[var53] = var51;
                    }
    
                    if (var54 == 2)
                    {
                        var50 = var51;
                        var51 = var2.readSmart() + var52;
                        var52 = var51;
                        def.facePointA[var53] = var49;
                        def.facePointB[var53] = var50;
                        def.facePointC[var53] = var51;
                    }
    
                    if (var54 == 3)
                    {
                        var49 = var51;
                        var51 = var2.readSmart() + var52;
                        var52 = var51;
                        def.facePointA[var53] = var49;
                        def.facePointB[var53] = var50;
                        def.facePointC[var53] = var51;
                    }
    
                    if (var54 == 4)
                    {
                        int var55 = var49;
                        var49 = var50;
                        var50 = var55;
                        var51 = var2.readSmart() + var52;
                        var52 = var51;
                        def.facePointA[var53] = var49;
                        def.facePointB[var53] = var55;
                        def.facePointC[var53] = var51;
                    }
                }
    
                var2.setOffset(var40);
                var3.setOffset(var41);
                var4.setOffset(var42);
                var5.setOffset(var43);
                var6.setOffset(var44);
                var7.setOffset(var45);
    
                for (var53 = 0; var53 < var11; ++var53)
                {
                    var54 = def.texture_type[var53] & 255;
                    if (var54 == 0)
                    {
                        def.textures_face_a[var53] = (short) var2.readUShort();
                        def.textures_face_b[var53] = (short) var2.readUShort();
                        def.textures_face_c[var53] = (short) var2.readUShort();
                    }
                }
    
                var2.setOffset(var26);
                var53 = var2.readUnsignedByte();
                if (var53 != 0)
                {
                    var2.readUShort();
                    var2.readUShort();
                    var2.readUShort();
                    var2.readInt();
                }
    
            }
    
            public static void decodeOldFormat(Model def, byte[] var1)
            {
                boolean var2 = false;
                boolean var3 = false;
                Buffer var4 = new Buffer(var1);
                Buffer var5 = new Buffer(var1);
                Buffer var6 = new Buffer(var1);
                Buffer var7 = new Buffer(var1);
                Buffer var8 = new Buffer(var1);
                var4.setOffset(var1.length - 18);
                int var9 = var4.readUShort();
                int var10 = var4.readUShort();
                int var11 = var4.readUnsignedByte();
                int var12 = var4.readUnsignedByte();
                int var13 = var4.readUnsignedByte();
                int var14 = var4.readUnsignedByte();
                int var15 = var4.readUnsignedByte();
                int var16 = var4.readUnsignedByte();
                int var17 = var4.readUShort();
                int var18 = var4.readUShort();
                int var19 = var4.readUShort();
                int var20 = var4.readUShort();
                byte var21 = 0;
                int var22 = var21 + var9;
                int var23 = var22;
                var22 += var10;
                int var24 = var22;
                if (var13 == 255)
                {
                    var22 += var10;
                }
    
                int var25 = var22;
                if (var15 == 1)
                {
                    var22 += var10;
                }
    
                int var26 = var22;
                if (var12 == 1)
                {
                    var22 += var10;
                }
    
                int var27 = var22;
                if (var16 == 1)
                {
                    var22 += var9;
                }
    
                int var28 = var22;
                if (var14 == 1)
                {
                    var22 += var10;
                }
    
                int var29 = var22;
                var22 += var20;
                int var30 = var22;
                var22 += var10 * 2;
                int var31 = var22;
                var22 += var11 * 6;
                int var32 = var22;
                var22 += var17;
                int var33 = var22;
                var22 += var18;
                int var10000 = var22 + var19;
                def.numVertices = var9;
                def.numTriangles = var10;
                def.numberOfTexturesFaces = var11;
                def.vertexX = new int[var9];
                def.vertexY = new int[var9];
                def.vertexZ = new int[var9];
                def.facePointA = new int[var10];
                def.facePointB = new int[var10];
                def.facePointC = new int[var10];
                if (var11 > 0)
                {
                    def.texture_type = new byte[var11];
                    def.textures_face_a = new short[var11];
                    def.textures_face_b = new short[var11];
                    def.textures_face_c = new short[var11];
                }
    
                if (var16 == 1)
                {
                    def.vertexVSkin = new int[var9];
                }
    
                if (var12 == 1)
                {
                    def.faceDrawType = new int[var10];
                    def.texture_type = new byte[var10];
                    def.materials = new short[var10];
    
                }
    
                if (var13 == 255)
                {
                    def.face_render_priorities = new byte[var10];
                }
                else
                {
                    def.face_priority = (byte) var13;
                }
    
                if (var14 == 1)
                {
                    def.face_alpha = new int[var10];
                }
    
                if (var15 == 1)
                {
                    def.triangleTSkin = new int[var10];
                }
    
                def.triangleColours = new short[var10];
                var4.setOffset(var21);
                var5.setOffset(var32);
                var6.setOffset(var33);
                var7.setOffset(var22);
                var8.setOffset(var27);
                int var35 = 0;
                int var36 = 0;
                int var37 = 0;
    
                int var38;
                int var39;
                int var40;
                int var41;
                int var42;
                for (var38 = 0; var38 < var9; ++var38)
                {
                    var39 = var4.readUnsignedByte();
                    var40 = 0;
                    if ((var39 & 1) != 0)
                    {
                        var40 = var5.readSmart();
                    }
    
                    var41 = 0;
                    if ((var39 & 2) != 0)
                    {
                        var41 = var6.readSmart();
                    }
    
                    var42 = 0;
                    if ((var39 & 4) != 0)
                    {
                        var42 = var7.readSmart();
                    }
    
                    def.vertexX[var38] = var35 + var40;
                    def.vertexY[var38] = var36 + var41;
                    def.vertexZ[var38] = var37 + var42;
                    var35 = def.vertexX[var38];
                    var36 = def.vertexY[var38];
                    var37 = def.vertexZ[var38];
                    if (var16 == 1)
                    {
                        def.vertexVSkin[var38] = var8.readUnsignedByte();
                    }
                }
    
                var4.setOffset(var30);
                var5.setOffset(var26);
                var6.setOffset(var24);
                var7.setOffset(var28);
                var8.setOffset(var25);
    
                for (var38 = 0; var38 < var10; ++var38)
                {
                    def.triangleColours[var38] = (short) var4.readUShort();
                    if (var12 == 1)
                    {
                        var39 = var5.readUnsignedByte();
                        if ((var39 & 1) == 1)
                        {
                            def.faceDrawType[var38] = 1;
                            var2 = true;
                        }
                        else
                        {
                            def.faceDrawType[var38] = 0;
                        }
    
                        if ((var39 & 2) == 2)
                        {
                            def.texture[var38] = (byte) (var39 >> 2);
                            def.materials[var38] = def.triangleColours[var38];
                            def.triangleColours[var38] = 127;
                            if (def.materials[var38] != -1)
                            {
                                var3 = true;
                            }
                        }
                        else
                        {
                            def.texture[var38] = -1;
                            def.materials[var38] = -1;
                        }
                    }
    
                    if (var13 == 255)
                    {
                        def.face_render_priorities[var38] = var6.readByteS();
                    }
    
                    if (var14 == 1)
                    {
                        def.face_alpha[var38] = var7.readByteS();
                        if (def.face_alpha[var38] < 0) {
                            def.face_alpha[var38] = (256 + def.face_alpha[var38]);
                        }
                    }
    
                    if (var15 == 1)
                    {
                        def.triangleTSkin[var38] = var8.readUnsignedByte();
                    }
                }
    
                var4.setOffset(var29);
                var5.setOffset(var23);
                var38 = 0;
                var39 = 0;
                var40 = 0;
                var41 = 0;
    
                int var43;
                int var44;
                for (var42 = 0; var42 < var10; ++var42)
                {
                    var43 = var5.readUnsignedByte();
                    if (var43 == 1)
                    {
                        var38 = var4.readSmart() + var41;
                        var39 = var4.readSmart() + var38;
                        var40 = var4.readSmart() + var39;
                        var41 = var40;
                        def.facePointA[var42] = var38;
                        def.facePointB[var42] = var39;
                        def.facePointC[var42] = var40;
                    }
    
                    if (var43 == 2)
                    {
                        var39 = var40;
                        var40 = var4.readSmart() + var41;
                        var41 = var40;
                        def.facePointA[var42] = var38;
                        def.facePointB[var42] = var39;
                        def.facePointC[var42] = var40;
                    }
    
                    if (var43 == 3)
                    {
                        var38 = var40;
                        var40 = var4.readSmart() + var41;
                        var41 = var40;
                        def.facePointA[var42] = var38;
                        def.facePointB[var42] = var39;
                        def.facePointC[var42] = var40;
                    }
    
                    if (var43 == 4)
                    {
                        var44 = var38;
                        var38 = var39;
                        var39 = var44;
                        var40 = var4.readSmart() + var41;
                        var41 = var40;
                        def.facePointA[var42] = var38;
                        def.facePointB[var42] = var44;
                        def.facePointC[var42] = var40;
                    }
                }
    
                var4.setOffset(var31);
                for (var42 = 0; var42 < var11; ++var42)
                {
                    def.texture_type[var42] = 0;
                    def.textures_face_a[var42] = (short) var4.readUShort();
                    def.textures_face_b[var42] = (short) var4.readUShort();
                    def.textures_face_c[var42] = (short) var4.readUShort();
                }
    
                if (def.texture != null)
                {
                    boolean var45 = false;
    
                    for (var43 = 0; var43 < var10; ++var43)
                    {
                        var44 = def.texture[var43] & 255;
                        if (var44 != 255)
                        {
                            if (def.facePointA[var43] == (def.textures_face_a[var44] & '\uffff') && def.facePointB[var43] == (def.textures_face_b[var44] & '\uffff') && def.facePointC[var43] == (def.textures_face_c[var44] & '\uffff'))
                            {
                                def.texture[var43] = -1;
                            }
                            else
                            {
                                var45 = true;
                            }
                        }
                    }
    
                    if (!var45)
                    {
                        def.texture = null;
                    }
                }
    
                if (!var3)
                {
                    def.materials = null;
                }
    
                if (!var2)
                {
                    def.faceDrawType = null;
                }
    
            }
    
    }


    Spoiler for readvalues:
    Code:
    objDef
    
        private void readValues(Buffer buffer) {
            while (true) {
                int opcode = buffer.readUnsignedByte();
                if (opcode == 0)
                    break;
                if (opcode == 1) {
                    int len = buffer.readUnsignedByte();
                    if (len > 0) {
                        if (modelIds == null) {
                            modelTypes = new int[len];
                            modelIds = new int[len];
    
                            for (int i = 0; i < len; i++) {
                                modelIds[i] = buffer.readUShort();
                                modelTypes[i] = buffer.readUnsignedByte();
                            }
                        } else {
                            buffer.currentPosition += len * 3;
                        }
                    }
                } else if (opcode == 2)
                    name = buffer.readString();
                else if (opcode == 3)
                    description = buffer.readString();
                else if (opcode == 5) {
                    int len = buffer.readUnsignedByte();
                    if (len > 0) {
                        if (modelIds == null) {
                            modelTypes = null;
                            modelIds = new int[len];
    
                            for (int i = 0; i < len; i++) {
                                modelIds[i] = buffer.readUShort();
                            }
                        } else {
                            buffer.currentPosition += len * 3;
                        }
                    }
                } else if (opcode == 14)
                    objectSizeX = buffer.readUnsignedByte();
                else if (opcode == 15)
                    objectSizeY = buffer.readUnsignedByte();
                else if (opcode == 17) {
                    solid = false;
                    impenetrable = false;
                } else if (opcode == 18)
                    impenetrable = false;
                else if (opcode == 19)
                    isInteractive = (buffer.readUnsignedByte() == 1);
                else if (opcode == 21)
                    contouredGround = true;
                else if (opcode == 22)
                    delayShading = true;
                else if (opcode == 23)
                    occludes = true;
                else if (opcode == 24) { // Object Animations
                    animation = buffer.readUShort();
                    if (animation == 65535)
                        animation = -1;
                } else if (opcode == 28)
                    decorDisplacement = buffer.readUnsignedByte();
                else if (opcode == 29)
                    ambientLighting = buffer.readSignedByte();
                else if (opcode == 39)
                    lightDiffusion = buffer.readSignedByte();
                else if (opcode >= 30 && opcode < 35) {
                    if (interactions == null)
                        interactions = new String[10];
                    interactions[opcode - 30] = buffer.readString();
                    if (interactions[opcode - 30].equalsIgnoreCase("hidden"))
                        interactions[opcode - 30] = null;
                } else if (opcode == 40) {
                    int len = buffer.readUnsignedByte();
                    modifiedModelColors = new int[len];
                    originalModelColors = new int[len];
                    for (int i = 0; i < len; i++) {
                        modifiedModelColors[i] = buffer.readUShort();
                        originalModelColors[i] = buffer.readUShort();
                    }
                } else if (opcode == 41) {
                    int len = buffer.readUnsignedByte();
                    modifiedTexture = new short[len];
                    originalTexture = new short[len];
                    for (int i = 0; i < len; i++) {
                        modifiedTexture[i] = (short) buffer.readUShort();
                        originalTexture[i] = (short) buffer.readUShort();
                    }
                } else if (opcode == 61) {
                    category = buffer.readUShort();
                } else if (opcode == 62)
                    inverted = true;
                else if (opcode == 64)
                    castsShadow = false;
                else if (opcode == 65)
                    scaleX = buffer.readUShort();
                else if (opcode == 66)
                    scaleY = buffer.readUShort();
                else if (opcode == 67)
                    scaleZ = buffer.readUShort();
                else if (opcode == 68)
                    mapscene = buffer.readUShort();
                else if (opcode == 69)
                    surroundings = buffer.readUnsignedByte();
                else if (opcode == 70)
                    translateX = buffer.readShort();
                else if (opcode == 71)
                    translateY = buffer.readShort();
                else if (opcode == 72)
                    translateZ = buffer.readShort();
                else if (opcode == 73)
                    obstructsGround = true;
                else if (opcode == 74)
                    hollow = true;
                else if (opcode == 75)
                    supportItems = buffer.readUnsignedByte();
                else if (opcode == 77 || opcode == 92) {
                    varbit = buffer.readUShort();
    
                    if (varp == 0xFFFF) {
                        varp = -1;
                    }
    
                    varp = buffer.readUShort();
    
                    if (varbit == 0xFFFF) {
                        varbit = -1;
                    }
    
                    int value = -1;
    
                    if (opcode == 92) {
                        value = buffer.readUShort();
    
                        if (value == 0xFFFF) {
                            value = -1;
                        }
                    }
    
                    int len = buffer.readUnsignedByte();
    
                    childrenIDs = new int[len + 2];
                    for (int i = 0; i <= len; ++i) {
                        childrenIDs[i] = buffer.readUShort();
                        if (childrenIDs[i] == 0xFFFF) {
                            childrenIDs[i] = -1;
                        }
                    }
                    childrenIDs[len + 1] = value;
                } else if (opcode == 78) {
                    ambientSoundId = buffer.readUShort();
                    anInt2083 = buffer.readUnsignedByte();
                } else if (opcode == 79) {
                    anInt2112 = buffer.readUShort();
                    anInt2113 = buffer.readUShort();
                    anInt2083 = buffer.readUShort();
    
                    int length = buffer.readUnsignedByte();
                    int[] anims = new int[length];
    
                    for (int index = 0; index < length; ++index) {
                        anims[index] = buffer.readUShort();
                    }
                    ambientSoundIds = anims;
                } else if (opcode == 81) {
                    contouredGround = buffer.readUnsignedByte() == 1;
                } else if (opcode == 82) {
                    minimapFunction = buffer.readUShort();//AreaType
                } else if (opcode == 89) {
                    randomAnimStart = false;
                } else if (opcode == 249) {
                    int length = buffer.readUnsignedByte();
    
                    Map<Integer, Object> params = new HashMap<>(length);
                    for (int i = 0; i < length; i++) {
                        boolean isString = buffer.readUnsignedByte() == 1;
                        int key = buffer.read24Int();
                        Object value;
    
                        if (isString) {
                            value = buffer.readString();
                            System.out.println(value);
                        } else {
                            value = buffer.readInt();
                        }
    
                        params.put(key, value);
                    }
    
                    this.params = params;
                } else {
                    //System.err.printf("Error unrecognised {Objects} opcode: %d%n%n", opcode);
                }
            }
            post();
        }
    
        private void post() {
        }
    Code:
    npcDEF
    
    public void readValues(Buffer buffer) {
    
    		while (true) {
    			int opcode = buffer.readUnsignedByte();
    			if (opcode == 0)
    				return;
    			if (opcode == 1) {
    				int j = buffer.readUnsignedByte();
    				modelId = new int[j];
    				for (int j1 = 0; j1 < j; j1++) {
    					modelId[j1] = buffer.readUShort();
    				}
    			} else if (opcode == 2)
    				name = buffer.readString();
    			else if (opcode == 3)
    				description = buffer.readBytes();
    			else if (opcode == 12)
    				size = buffer.readSignedByte();
    			else if (opcode == 13)
    				standAnim = buffer.readUShort();
    			else if (opcode == 14)
    				walkAnim = buffer.readUShort();
    			else if (opcode == 15) {
    				rotateLeftAnimation = buffer.readUShort();
    			} else if (opcode == 16) {
    				rotateRightAnimation = buffer.readUShort();
    			} else if (opcode == 17) {
    				walkAnim = buffer.readUShort();
    				turn180AnimIndex = buffer.readUShort();
    				turn90CWAnimIndex = buffer.readUShort();
    				turn90CCWAnimIndex = buffer.readUShort();
    				if (turn180AnimIndex == 65535) {
    					turn180AnimIndex = -1;
    				}
    				if (turn90CWAnimIndex == 65535) {
    					turn90CWAnimIndex = -1;
    				}
    				if (turn90CCWAnimIndex == 65535) {
    					turn90CCWAnimIndex = -1;
    				}
    			} else if (opcode == 18) {
    				category = buffer.readUShort();
    			} else if (opcode >= 30 && opcode < 40) {
    				if (actions == null)
    					actions = new String[10];
    				actions[opcode - 30] = buffer.readString();
    				if (actions[opcode - 30].equalsIgnoreCase("hidden"))
    					actions[opcode - 30] = null;
    			} else if (opcode == 40) {
    				int k = buffer.readUnsignedByte();
    				recolourOriginal = new int[k];
    				recolourTarget = new int[k];
    				for (int k1 = 0; k1 < k; k1++) {
    					recolourOriginal[k1] = buffer.readUShort();
    					recolourTarget[k1] = buffer.readUShort();
    				}
    			} else if (opcode == 41) {
    				int length = buffer.readUnsignedByte();
    				src_texture = new short[length];
    				dst_texture = new short[length];
    				for (int index = 0; index < length; index++) {
    					src_texture[index] = (short) buffer.readUShort();
    					dst_texture[index] = (short) buffer.readUShort();
    				}
    
    			} else if (opcode == 60) {
    				int l = buffer.readUnsignedByte();
    				aditionalModels = new int[l];
    				for (int l1 = 0; l1 < l; l1++) {
    					aditionalModels[l1] = buffer.readUShort();
    				}
    			} else if (opcode == 93)
    				drawMinimapDot = false;
    			else if (opcode == 95)
    				combatLevel = buffer.readUShort();
    			else if (opcode == 97)
    				scaleXZ = buffer.readUShort();
    			else if (opcode == 98)
    				scaleY = buffer.readUShort();
    			else if (opcode == 99)
    				priorityRender = true;
    			else if (opcode == 100)
    				lightModifier = buffer.readSignedByte();
    			else if (opcode == 101)
    				shadowModifier = buffer.readSignedByte();
    			else if (opcode == 102)
    				headIcon = buffer.readUShort();
    			else if (opcode == 103)
    				degreesToTurn = buffer.readUShort();
    			else if (opcode == 109) {
    				rotationFlag = false;
    			} else if (opcode == 111) {
    				isPet = true;
    			} else if (opcode == 106 || opcode == 118) {
    				varBitID = buffer.readUShort();
    				if (varBitID == 65535)
    					varBitID = -1;
    				settingId = buffer.readUShort();
    				if (settingId == 65535)
    					settingId = -1;
    
    				int var3 = -1;
    				if (opcode == 118) {
    					var3 = buffer.readUShort();
    				}
    				int i1 = buffer.readUnsignedByte();
    				childrenIDs = new int[i1 + 2];
    				for (int i2 = 0; i2 <= i1; i2++) {
    					childrenIDs[i2] = buffer.readUShort();
    					if (childrenIDs[i2] == 65535)
    						childrenIDs[i2] = -1;
    				}
    				childrenIDs[i1 + 1] = var3;
    
    			} else if (opcode == 107)
    				clickable = false;
    			else if (opcode == 249) {
    				int length = buffer.readUnsignedByte();
    
    				params = new HashMap<>(length);
    
    				for (int i = 0; i < length; i++) {
    					boolean isString = buffer.readUnsignedByte() == 1;
    					int key = buffer.read24Int();
    					Object value;
    
    					if (isString) {
    						value = buffer.readString();
    					} else {
    						value = buffer.readInt();
    					}
    
    					params.put(key, value);
    				}
    			} else {
    				System.err.printf("Error unrecognised {NPC} opcode: %d%n%n", opcode);
    				continue;
    			}
    		}
    	}
    Code:
    itemDEF
    
    public void readValues(Buffer buffer) {
            while (true) {
                int opcode = buffer.readUnsignedByte();
                if (opcode == 0)
                    return;
                if (opcode == 1)
                    inventory_model = buffer.readUShort();
                else if (opcode == 2)
                    name = buffer.readString();
                else if (opcode == 3)
                    description = buffer.readString();
                else if (opcode == 4)
                    zoom2d = buffer.readUShort();
                else if (opcode == 5)
                    xan2d = buffer.readUShort();
                else if (opcode == 6)
                    yan2d = buffer.readUShort();
                else if (opcode == 7) {
                    xOffset2d = buffer.readUShort();
                    if (xOffset2d > 32767)
                        xOffset2d -= 0x10000;
                } else if (opcode == 8) {
                    yOffset2d = buffer.readUShort();
                    if (yOffset2d > 32767)
                        yOffset2d -= 0x10000;
                } else if (opcode == 11)
                    stackable = true;
                else if (opcode == 12)
                    value = buffer.readInt();
                else if (opcode == 16)
                    membership_required = true;
                else if (opcode == 23) {
                    male_equip_main = buffer.readUShort();
                    male_equip_translate_y = buffer.readSignedByte();
                } else if (opcode == 24)
                    male_equip_attachment = buffer.readUShort();
                else if (opcode == 25) {
                    female_equip_main = buffer.readUShort();
                    female_equip_attachment = buffer.readSignedByte();
                } else if (opcode == 26)
                    female_equip_attachment = buffer.readUShort();
                else if (opcode >= 30 && opcode < 35) {
                    if (scene_actions == null)
                        scene_actions = new String[5];
                    scene_actions[opcode - 30] = buffer.readString();
                    if (scene_actions[opcode - 30].equalsIgnoreCase("hidden"))
                        scene_actions[opcode - 30] = null;
                } else if (opcode >= 35 && opcode < 40) {
                    if (widget_actions == null)
                        widget_actions = new String[5];
                    widget_actions[opcode - 35] = buffer.readString();
                } else if (opcode == 40) {
                    int length = buffer.readUnsignedByte();
                    src_color = new int[length];
                    dst_color = new int[length];
                    for (int index = 0; index < length; index++) {
                        dst_color[index] = buffer.readUShort();
                        src_color[index] = buffer.readUShort();
                    }
                } else if (opcode == 41) {
                    int length = buffer.readUnsignedByte();
                    src_texture = new short[length];
                    dst_texture = new short[length];
                    for (int index = 0; index < length; index++) {
                        src_texture[index] = (short) buffer.readUShort();
                        dst_texture[index] = (short) buffer.readUShort();
                    }
                } else if (opcode == 42) {
                    shiftClickIndex = buffer.readUnsignedByte();
                } else if (opcode == 65) {
                    tradeable = true;
                } else if (opcode == 78)
                    male_equip_emblem = buffer.readUShort();
                else if (opcode == 79)
                    female_equip_emblem = buffer.readUShort();
                else if (opcode == 90)
                    male_dialogue_head = buffer.readUShort();
                else if (opcode == 91)
                    female_dialogue_head = buffer.readUShort();
                else if (opcode == 92)
                    male_dialogue_headgear = buffer.readUShort();
                else if (opcode == 93)
                    female_dialogue_headgear = buffer.readUShort();
                else if (opcode == 94)
                    category = buffer.readUShort();
                else if (opcode == 95)
                    zan2d = buffer.readUShort();
                else if (opcode == 97)
                    unnoted_item_id = buffer.readUShort();
                else if (opcode == 98)
                    noted_item_id = buffer.readUShort();
                else if (opcode >= 100 && opcode < 110) {
                    if (stack_variant_id == null) {
                        stack_variant_id = new int[10];
                        stack_variant_size = new int[10];
                    }
                    stack_variant_id[opcode - 100] = buffer.readUShort();
                    stack_variant_size[opcode - 100] = buffer.readUShort();
                } else if (opcode == 110)
                    resizeX = buffer.readUShort();
                else if (opcode == 111)
                    resizeY = buffer.readUShort();
                else if (opcode == 112)
                    resizeZ = buffer.readUShort();
                else if (opcode == 113)
                    ambient = buffer.readSignedByte();
                else if (opcode == 114)
                    contrast = buffer.readSignedByte() * 5;
                else if (opcode == 115)
                    team_id = buffer.readUnsignedByte();
                else if (opcode == 139)
                    bought_id = buffer.readUShort();
                else if (opcode == 140)
                    bought_template_id = buffer.readUShort();
                else if (opcode == 148)
                    placeholder_id = buffer.readUShort();
                else if (opcode == 149) {
                    placeholder_template_id = buffer.readUShort();
                } else if (opcode == 249) {
                    int length = buffer.readUnsignedByte();
    
                    params = new HashMap<>(length);
    
                    for (int i = 0; i < length; i++) {
                        boolean isString = buffer.readUnsignedByte() == 1;
                        int key = buffer.read24Int();
                        Object value;
    
                        if (isString) {
                            value = buffer.readString();
                        } else {
                            value = buffer.readInt();
                        }
    
                        params.put(key, value);
                    }
                } else {
                    System.err.printf("Error unrecognised {Items} opcode: %d%n%n", opcode);
                }
            }
        }


    Spoiler for collisionMap.java:

    Code:
        
    
    
    public void load(int block_x, CollisionMap[] map, int block_y, SceneGraph scene, byte[] data) {
            load:
            {
                Buffer buffer = new Buffer(data);
                int object_id = -1;
                do {
                    int id_offset = buffer.readUnsignedIntSmartShortCompat();
                    if (id_offset == 0)
                        break load;
    
                    object_id += id_offset;
                    int pos = 0;
                    do {
                        int pos_offset = buffer.readUSmart();
                        if (pos_offset == 0)
                            break;
    
                        pos += pos_offset - 1;
                        int tile_y = pos & 0x3F;
                        int tile_x = pos >> 6 & 0x3F;
                        int plane = pos >> 12 & 0x3;
                        int hash = buffer.readUnsignedByte();
                        int type = hash >> 2;
                        int orientation = hash & 3;
                        int x = tile_x + block_x;
                        int y = tile_y + block_y;
                        if (x > 0 && y > 0 && x < 103 && y < 103 && plane >= 0 && plane < 4) {
                            int marking_plane = plane;
                            if ((tile_flags[1][x][y] & 2) == 2)
                                marking_plane--;
    
                            CollisionMap collision = null;
                            if (marking_plane >= 0/* && marking_plane < 4*/)//added for higher revisions
                                collision = map[marking_plane];
    
                            render(y, scene, collision, type, plane, x, object_id, orientation);
                        }
                    } while (true);
                } while (true);
            }
        }
    
        private void render(int y, SceneGraph scene, CollisionMap collision, int type, int plane, int x, int object_id, int orientation) {
        }


    Spoiler for buffer.java:
    Code:
        public int readUnsignedIntSmartShortCompat() {
            int var1 = 0;
    
            int var2;
            for (var2 = this.readUSmart(); var2 == 32767; var2 = this.readUSmart()) {
                var1 += 32767;
            }
    
            var1 += var2;
            return var1;
        }
    
    public int readUSmart() {
            int peek = payload[currentPosition] & 0xFF;
            return peek < 128 ? this.readUnsignedByte() : this.readUShort() - 0x8000;
        }
    
        public void encodeRSA(BigInteger exponent, BigInteger modulus) {
            int length = currentPosition;
            currentPosition = 0;
            byte buffer[] = new byte[length];
            readBytes(length, 0, buffer);
    
            byte rsa[] = buffer;
    
            if (Configuration.ENABLE_RSA) {
                rsa = new BigInteger(buffer).modPow(exponent, modulus)
                        .toByteArray();
            }
    
            currentPosition = 0;
            writeByte(rsa.length);
            writeBytes(rsa, rsa.length, 0);
        }


    Spoiler for Image:
    Attached image
    Reply With Quote  
     

  2. #2  
    Extreme Donator
    Elvarg V3.2 Updating data to 207.4 and fixing modelLoader Market Banned


    Mark_'s Avatar
    Join Date
    Jul 2020
    Posts
    157
    Thanks given
    99
    Thanks received
    161
    Discord
    View profile
    Rep Power
    294
    Quote Originally Posted by Fozzey View Post
    Im getting this error on a constant loop. I have added a modelLoader class and adjusted it all to link with my model class. I have added the new Model(int modelId) into my model.java, i have added all the readvalues to the correct classes objdef, itemdef and npcdef. I have updated the collisionmap, I have added the readSmart() and the readUnsignedIntSmartShortCompat(). I have loaded 207.4 data, loc.dat, npc.dat, obj.dat etc. and i made sure i did the mapIndex BOTH client/Server side aswell as loc.dat and loc.idx. I have repacked the cache index1,2,4 that came with the 207.4 data. As i said above i get this error down below and i can log into the game and i can move but all graphics are just not there, so no minimap, world, npc etc. I am also getting opcode error messages server side which is also pasted below. Im not sure where to go with this info. I believe i haven't missed anything in the snippets above. I followed the guide posted by Mark.

    Spoiler for Client stack:
    Code:
    java.lang.ArrayIndexOutOfBoundsException
    java.lang.ArrayIndexOutOfBoundsException
    java.lang.ArrayIndexOutOfBoundsException
    java.lang.ArrayIndexOutOfBoundsException
    java.lang.ArrayIndexOutOfBoundsException
    java.lang.ArrayIndexOutOfBoundsException
    java.lang.ArrayIndexOutOfBoundsException
    java.lang.ArrayIndexOutOfBoundsException
    java.lang.ArrayIndexOutOfBoundsException
    java.lang.ArrayIndexOutOfBoundsException
    java.lang.ArrayIndexOutOfBoundsException
    java.lang.ArrayIndexOutOfBoundsException
    java.lang.ArrayIndexOutOfBoundsException
    java.lang.ArrayIndexOutOfBoundsException
    java.lang.ArrayIndexOutOfBoundsException
    java.lang.ArrayIndexOutOfBoundsException
    java.lang.ArrayIndexOutOfBoundsException
    java.lang.ArrayIndexOutOfBoundsException
    java.lang.ArrayIndexOutOfBoundsException
    java.lang.ArrayIndexOutOfBoundsException
    java.lang.ArrayIndexOutOfBoundsException
    java.lang.ArrayIndexOutOfBoundsException
    java.lang.ArrayIndexOutOfBoundsException
    java.lang.ArrayIndexOutOfBoundsException
    java.lang.ArrayIndexOutOfBoundsException


    Spoiler for Server stack:
    Code:
    Sept 24, 2022 8:15:11 PM com.elvarg.game.definition.loader.DefinitionLoader run
    INFO: Loaded definitions for: ./data/definitions/object_spawns.json. It took 199 milliseconds.
    Sept 24, 2022 8:15:11 PM com.elvarg.game.definition.loader.DefinitionLoader run
    INFO: Loaded definitions for: ./data/definitions/items.json. It took 251 milliseconds.
    Sept 24, 2022 8:15:11 PM com.elvarg.game.definition.loader.DefinitionLoader run
    INFO: Loaded definitions for: ./data/definitions/shops.json. It took 8 milliseconds.
    Sept 24, 2022 8:15:11 PM com.elvarg.game.definition.loader.DefinitionLoader run
    INFO: Loaded definitions for: ./data/definitions/npc_defs.json. It took 56 milliseconds.
    Sept 24, 2022 8:15:11 PM com.elvarg.game.definition.loader.DefinitionLoader run
    INFO: Loaded definitions for: ./data/definitions/npc_drops.json. It took 36 milliseconds.
    Sept 24, 2022 8:15:11 PM com.elvarg.game.definition.loader.DefinitionLoader run
    INFO: Loaded definitions for: ./data/definitions/npc_spawns.json. It took 62 milliseconds.
    invalid opcode: 61
    invalid opcode: 3
    invalid opcode: 129
    invalid opcode: 61
    invalid opcode: 6
    invalid opcode: 148
    invalid opcode: 61
    invalid opcode: 6
    invalid opcode: 148
    invalid opcode: 61
    invalid opcode: 6
    invalid opcode: 148
    invalid opcode: 61
    invalid opcode: 3
    invalid opcode: 192
    Sept 24, 2022 8:15:11 PM com.elvarg.game.definition.loader.DefinitionLoader run
    INFO: Loaded definitions for: ./data/definitions/global_presets.json. It took 30 milliseconds.
    Sept 24, 2022 8:15:12 PM com.elvarg.Server main
    INFO: RuneScape is now online!
    invalid opcode: 61
    invalid opcode: 3
    invalid opcode: 4
    invalid opcode: 61
    invalid opcode: 3
    invalid opcode: 192
    invalid opcode: 61
    invalid opcode: 61
    invalid opcode: 6
    invalid opcode: 148
    invalid opcode: 61
    invalid opcode: 6
    invalid opcode: 148
    invalid opcode: 61
    invalid opcode: 6
    invalid opcode: 148
    invalid opcode: 61
    invalid opcode: 3
    invalid opcode: 192
    invalid opcode: 61
    invalid opcode: 61
    invalid opcode: 61
    invalid opcode: 61
    invalid opcode: 61
    invalid opcode: 61
    invalid opcode: 61
    [World] Registering player - [username, host] : [Florrey, 127.0.0.1]
    invalid opcode: 61
    invalid opcode: 61
    invalid opcode: 61
    invalid opcode: 61
    invalid opcode: 61
    invalid opcode: 61
    invalid opcode: 3
    invalid opcode: 129
    [World] Deregistering player - [username, host] : [Florrey, 127.0.0.1]


    Spoiler for model.java:
    Code:
        private Model(int modelId) {
            byte[] is = modelHeader[modelId].aByteArray368;
            if (is[is.length - 1] == -3 && is[is.length - 2] == -1) {
                ModelLoader.decodeType3(this, is);
            } else if (is[is.length - 1] == -2 && is[is.length - 2] == -1) {
                ModelLoader.decodeType2(this, is);
            } else if (is[is.length - 1] == -1 && is[is.length - 2] == -1) {
                ModelLoader.decodeType1(this, is);
            } else {
                ModelLoader.decodeOldFormat(this, is);
            }
    
        }


    Spoiler for modelLoader.java:
    Code:
    package com.runescape.entity.model;
    import com.runescape.io.Buffer;
    
        public class ModelLoader {
    
            public static void decodeType3(Model def, byte[] var1)
            {
                Buffer var2 = new Buffer(var1);
                Buffer var3 = new Buffer(var1);
                Buffer var4 = new Buffer(var1);
                Buffer var5 = new Buffer(var1);
                Buffer var6 = new Buffer(var1);
                Buffer var7 = new Buffer(var1);
                Buffer var8 = new Buffer(var1);
                var2.setOffset(var1.length - 26);
                int var9 = var2.readUShort();
                int var10 = var2.readUShort();
                int var11 = var2.readUnsignedByte();
                int var12 = var2.readUnsignedByte();
                int var13 = var2.readUnsignedByte();
                int var14 = var2.readUnsignedByte();
                int var15 = var2.readUnsignedByte();
                int var16 = var2.readUnsignedByte();
                int var17 = var2.readUnsignedByte();
                int var18 = var2.readUnsignedByte();
                int var19 = var2.readUShort();
                int var20 = var2.readUShort();
                int var21 = var2.readUShort();
                int var22 = var2.readUShort();
                int var23 = var2.readUShort();
                int var24 = var2.readUShort();
                int var25 = 0;
                int var26 = 0;
                int var27 = 0;
                int var28;
    
    
                if (var11 > 0)
                {
                    def.texture_type = new byte[var11];
                    var2.setOffset(0);
    
                    for (var28 = 0; var28 < var11; ++var28)
                    {
                        byte var29 = def.texture_type[var28] = var2.readByteS();
                        if (var29 == 0)
                        {
                            ++var25;
                        }
    
                        if (var29 >= 1 && var29 <= 3)
                        {
                            ++var26;
                        }
    
                        if (var29 == 2)
                        {
                            ++var27;
                        }
                    }
                }
    
                var28 = var11 + var9;
                int var58 = var28;
                if (var12 == 1)
                {
                    var28 += var10;
                }
    
                int var30 = var28;
                var28 += var10;
                int var31 = var28;
                if (var13 == 255)
                {
                    var28 += var10;
                }
    
                int var32 = var28;
                if (var15 == 1)
                {
                    var28 += var10;
                }
    
                int var33 = var28;
                var28 += var24;
                int var34 = var28;
                if (var14 == 1)
                {
                    var28 += var10;
                }
    
                int var35 = var28;
                var28 += var22;
                int var36 = var28;
                if (var16 == 1)
                {
                    var28 += var10 * 2;
                }
    
                int var37 = var28;
                var28 += var23;
                int var38 = var28;
                var28 += var10 * 2;
                int var39 = var28;
                var28 += var19;
                int var40 = var28;
                var28 += var20;
                int var41 = var28;
                var28 += var21;
                int var42 = var28;
                var28 += var25 * 6;
                int var43 = var28;
                var28 += var26 * 6;
                int var44 = var28;
                var28 += var26 * 6;
                int var45 = var28;
                var28 += var26 * 2;
                int var46 = var28;
                var28 += var26;
                int var47 = var28;
                var28 = var28 + var26 * 2 + var27 * 2;
    
    
                def.numVertices = var9;
                def.numTriangles = var10;
                def.numberOfTexturesFaces = var11;
                def.vertexX = new int[var9];
                def.vertexY = new int[var9];
                def.vertexZ = new int[var9];
                def.facePointA = new int[var10];
                def.facePointB = new int[var10];
                def.facePointC = new int[var10];
                if (var17 == 1)
                {
                    def.vertexVSkin = new int[var9];
                }
    
                if (var12 == 1)
                {
                    def.faceDrawType = new int[var10];
                }
    
                if (var13 == 255)
                {
                    def.face_render_priorities = new byte[var10];
                }
                else
                {
                    def.face_priority = (byte) var13;
                }
    
                if (var14 == 1)
                {
                    def.face_alpha = new int[var10];
                }
    
                if (var15 == 1)
                {
                    def.triangleTSkin = new int[var10];
                }
    
                if (var16 == 1)
                {
                    def.materials = new short[var10];
                }
    
                if (var16 == 1 && var11 > 0)
                {
                    def.texture_type = new byte[var10];
                }
    
                if (var18 == 1)
                {
                    def.animayaGroups = new int[var9][];
                    def.animayaScales = new int[var9][];
                }
    
                def.triangleColours = new short[var10];
                if (var11 > 0)
                {
                    def.textures_face_a = new short[var11];
                    def.textures_face_b = new short[var11];
                    def.textures_face_c = new short[var11];
                }
    
                var2.setOffset(var11);
                var3.setOffset(var39);
                var4.setOffset(var40);
                var5.setOffset(var41);
                var6.setOffset(var33);
                int var48 = 0;
                int var49 = 0;
                int var50 = 0;
    
                int var51;
                int var52;
                int var53;
                int var54;
                int var55;
                for (var51 = 0; var51 < var9; ++var51)
                {
                    var52 = var2.readUnsignedByte();
                    var53 = 0;
                    if ((var52 & 1) != 0)
                    {
                        var53 = var3.readSmart();
                    }
    
                    var54 = 0;
                    if ((var52 & 2) != 0)
                    {
                        var54 = var4.readSmart();
                    }
    
                    var55 = 0;
                    if ((var52 & 4) != 0)
                    {
                        var55 = var5.readSmart();
                    }
    
                    def.vertexX[var51] = var48 + var53;
                    def.vertexY[var51] = var49 + var54;
                    def.vertexZ[var51] = var50 + var55;
                    var48 = def.vertexX[var51];
                    var49 = def.vertexY[var51];
                    var50 = def.vertexZ[var51];
                    if (var17 == 1)
                    {
                        def.vertexVSkin[var51] = var6.readUnsignedByte();
                    }
                }
    
                if (var18 == 1)
                {
                    for (var51 = 0; var51 < var9; ++var51)
                    {
                        var52 = var6.readUnsignedByte();
                        def.animayaGroups[var51] = new int[var52];
                        def.animayaScales[var51] = new int[var52];
    
                        for (var53 = 0; var53 < var52; ++var53)
                        {
                            def.animayaGroups[var51][var53] = var6.readUnsignedByte();
                            def.animayaScales[var51][var53] = var6.readUnsignedByte();
                        }
                    }
                }
    
                var2.setOffset(var38);
                var3.setOffset(var58);
                var4.setOffset(var31);
                var5.setOffset(var34);
                var6.setOffset(var32);
                var7.setOffset(var36);
                var8.setOffset(var37);
    
                for (var51 = 0; var51 < var10; ++var51)
                {
                    def.triangleColours[var51] = (short) var2.readUShort();
                    if (var12 == 1)
                    {
                        def.faceDrawType[var51] = var3.readByteS();
                    }
    
                    if (var13 == 255)
                    {
                        def.face_render_priorities[var51] = var4.readByteS();
                    }
    
                    if (var14 == 1)
                    {
                        def.face_alpha[var51] = var5.readByteS();
                        if (def.face_alpha[var51] < 0) {
                            def.face_alpha[var51] = (256 + def.face_alpha[var51]);
                        }
                    }
    
                    if (var15 == 1)
                    {
                        def.triangleTSkin[var51] = var6.readUnsignedByte();
                    }
    
                    if (var16 == 1)
                    {
                        def.materials[var51] = (short) (var7.readUShort() - 1);
                    }
    
                    if (def.texture != null && def.materials[var51] != -1)
                    {
                        def.texture[var51] = (byte) (var8.readUnsignedByte() - 1);
                    }
                }
    
                var2.setOffset(var35);
                var3.setOffset(var30);
                var51 = 0;
                var52 = 0;
                var53 = 0;
                var54 = 0;
    
                int var56;
                for (var55 = 0; var55 < var10; ++var55)
                {
                    var56 = var3.readUnsignedByte();
                    if (var56 == 1)
                    {
                        var51 = var2.readSmart() + var54;
                        var52 = var2.readSmart() + var51;
                        var53 = var2.readSmart() + var52;
                        var54 = var53;
                        def.facePointA[var55] = var51;
                        def.facePointB[var55] = var52;
                        def.facePointC[var55] = var53;
                    }
    
                    if (var56 == 2)
                    {
                        var52 = var53;
                        var53 = var2.readSmart() + var54;
                        var54 = var53;
                        def.facePointA[var55] = var51;
                        def.facePointB[var55] = var52;
                        def.facePointC[var55] = var53;
                    }
    
                    if (var56 == 3)
                    {
                        var51 = var53;
                        var53 = var2.readSmart() + var54;
                        var54 = var53;
                        def.facePointA[var55] = var51;
                        def.facePointB[var55] = var52;
                        def.facePointC[var55] = var53;
                    }
    
                    if (var56 == 4)
                    {
                        int var57 = var51;
                        var51 = var52;
                        var52 = var57;
                        var53 = var2.readSmart() + var54;
                        var54 = var53;
                        def.facePointA[var55] = var51;
                        def.facePointB[var55] = var57;
                        def.facePointC[var55] = var53;
                    }
                }
    
                var2.setOffset(var42);
                var3.setOffset(var43);
                var4.setOffset(var44);
                var5.setOffset(var45);
                var6.setOffset(var46);
                var7.setOffset(var47);
    
                for (var55 = 0; var55 < var11; ++var55)
                {
                    var56 = def.texture_type[var55] & 255;
                    if (var56 == 0)
                    {
                        def.textures_face_a[var55] = (short) var2.readUShort();
                        def.textures_face_b[var55] = (short) var2.readUShort();
                        def.textures_face_c[var55] = (short) var2.readUShort();
                    }
                }
    
                var2.setOffset(var28);
                var55 = var2.readUnsignedByte();
                if (var55 != 0)
                {
                    var2.readUShort();
                    var2.readUShort();
                    var2.readUShort();
                    var2.readInt();
                }
    
            }
    
            public static void decodeType2(Model def, byte[] var1)
            {
                boolean var2 = false;
                boolean var3 = false;
                Buffer var4 = new Buffer(var1);
                Buffer var5 = new Buffer(var1);
                Buffer var6 = new Buffer(var1);
                Buffer var7 = new Buffer(var1);
                Buffer var8 = new Buffer(var1);
                var4.setOffset(var1.length - 23);
                int var9 = var4.readUShort();
                int var10 = var4.readUShort();
                int var11 = var4.readUnsignedByte();
                int var12 = var4.readUnsignedByte();
                int var13 = var4.readUnsignedByte();
                int var14 = var4.readUnsignedByte();
                int var15 = var4.readUnsignedByte();
                int var16 = var4.readUnsignedByte();
                int var17 = var4.readUnsignedByte();
                int var18 = var4.readUShort();
                int var19 = var4.readUShort();
                int var20 = var4.readUShort();
                int var21 = var4.readUShort();
                int var22 = var4.readUShort();
                byte var23 = 0;
                int var24 = var23 + var9;
                int var25 = var24;
                var24 += var10;
                int var26 = var24;
                if (var13 == 255)
                {
                    var24 += var10;
                }
    
                int var27 = var24;
                if (var15 == 1)
                {
                    var24 += var10;
                }
    
                int var28 = var24;
                if (var12 == 1)
                {
                    var24 += var10;
                }
    
                int var29 = var24;
                var24 += var22;
                int var30 = var24;
                if (var14 == 1)
                {
                    var24 += var10;
                }
    
                int var31 = var24;
                var24 += var21;
                int var32 = var24;
                var24 += var10 * 2;
                int var33 = var24;
                var24 += var11 * 6;
                int var34 = var24;
                var24 += var18;
                int var35 = var24;
                var24 += var19;
                int var10000 = var24 + var20;
                def.numVertices = var9;
                def.numTriangles = var10;
                def.numberOfTexturesFaces = var11;
                def.vertexX = new int[var9];
                def.vertexY = new int[var9];
                def.vertexZ = new int[var9];
                def.facePointA = new int[var10];
                def.facePointB = new int[var10];
                def.facePointC = new int[var10];
                if (var11 > 0)
                {
                    def.texture_type = new byte[var11];
                    def.textures_face_a = new short[var11];
                    def.textures_face_b = new short[var11];
                    def.textures_face_c = new short[var11];
                }
    
                if (var16 == 1)
                {
                    def.vertexVSkin = new int[var9];
                }
    
                if (var12 == 1)
                {
                    def.faceDrawType = new int[var10];
                    def.texture_type = new byte[var10];
                    def.materials = new short[var10];
                }
    
                if (var13 == 255)
                {
                    def.face_render_priorities = new byte[var10];
                }
                else
                {
                    def.face_priority = (byte) var13;
                }
    
                if (var14 == 1)
                {
                    def.face_alpha = new int[var10];
                }
    
                if (var15 == 1)
                {
                    def.triangleTSkin = new int[var10];
                }
    
                if (var17 == 1)
                {
                    def.animayaGroups = new int[var9][];
                    def.animayaScales = new int[var9][];
                }
    
                def.triangleColours = new short[var10];
                var4.setOffset(var23);
                var5.setOffset(var34);
                var6.setOffset(var35);
                var7.setOffset(var24);
                var8.setOffset(var29);
                int var37 = 0;
                int var38 = 0;
                int var39 = 0;
    
                int var40;
                int var41;
                int var42;
                int var43;
                int var44;
                for (var40 = 0; var40 < var9; ++var40)
                {
                    var41 = var4.readUnsignedByte();
                    var42 = 0;
                    if ((var41 & 1) != 0)
                    {
                        var42 = var5.readSmart();
                    }
    
                    var43 = 0;
                    if ((var41 & 2) != 0)
                    {
                        var43 = var6.readSmart();
                    }
    
                    var44 = 0;
                    if ((var41 & 4) != 0)
                    {
                        var44 = var7.readSmart();
                    }
    
                    def.vertexX[var40] = var37 + var42;
                    def.vertexY[var40] = var38 + var43;
                    def.vertexZ[var40] = var39 + var44;
                    var37 = def.vertexX[var40];
                    var38 = def.vertexY[var40];
                    var39 = def.vertexZ[var40];
                    if (var16 == 1)
                    {
                        def.vertexVSkin[var40] = var8.readUnsignedByte();
                    }
                }
    
                if (var17 == 1)
                {
                    for (var40 = 0; var40 < var9; ++var40)
                    {
                        var41 = var8.readUnsignedByte();
                        def.animayaGroups[var40] = new int[var41];
                        def.animayaScales[var40] = new int[var41];
    
                        for (var42 = 0; var42 < var41; ++var42)
                        {
                            def.animayaGroups[var40][var42] = var8.readUnsignedByte();
                            def.animayaScales[var40][var42] = var8.readUnsignedByte();
                        }
                    }
                }
    
                var4.setOffset(var32);
                var5.setOffset(var28);
                var6.setOffset(var26);
                var7.setOffset(var30);
                var8.setOffset(var27);
    
                for (var40 = 0; var40 < var10; ++var40)
                {
                    def.triangleColours[var40] = (short) var4.readUShort();
                    if (var12 == 1)
                    {
                        var41 = var5.readUnsignedByte();
                        if ((var41 & 1) == 1)
                        {
                            def.faceDrawType[var40] = 1;
                            var2 = true;
                        }
                        else
                        {
                            def.faceDrawType[var40] = 0;
                        }
    
                        if ((var41 & 2) == 2)
                        {
                            def.texture[var40] = (byte) (var41 >> 2);
                            def.materials[var40] = def.triangleColours[var40];
                            def.triangleColours[var40] = 127;
                            if (def.materials[var40] != -1)
                            {
                                var3 = true;
                            }
                        }
                        else
                        {
                            def.texture[var40] = -1;
                            def.materials[var40] = -1;
                        }
                    }
    
                    if (var13 == 255)
                    {
                        def.face_render_priorities[var40] = var6.readByteS();
                    }
    
                    if (var14 == 1)
                    {
                        def.face_alpha[var40] = var7.readByteS();
                        if (def.face_alpha[var40] < 0) {
                            def.face_alpha[var40] = (256 + def.face_alpha[var40]);
                        }
                    }
    
                    if (var15 == 1)
                    {
                        def.triangleTSkin[var40] = var8.readUnsignedByte();
                    }
                }
    
                var4.setOffset(var31);
                var5.setOffset(var25);
                var40 = 0;
                var41 = 0;
                var42 = 0;
                var43 = 0;
    
                int var45;
                int var46;
                for (var44 = 0; var44 < var10; ++var44)
                {
                    var45 = var5.readUnsignedByte();
                    if (var45 == 1)
                    {
                        var40 = var4.readSmart() + var43;
                        var41 = var4.readSmart() + var40;
                        var42 = var4.readSmart() + var41;
                        var43 = var42;
                        def.facePointA[var44] = var40;
                        def.facePointB[var44] = var41;
                        def.facePointC[var44] = var42;
                    }
    
                    if (var45 == 2)
                    {
                        var41 = var42;
                        var42 = var4.readSmart() + var43;
                        var43 = var42;
                        def.facePointA[var44] = var40;
                        def.facePointB[var44] = var41;
                        def.facePointC[var44] = var42;
                    }
    
                    if (var45 == 3)
                    {
                        var40 = var42;
                        var42 = var4.readSmart() + var43;
                        var43 = var42;
                        def.facePointA[var44] = var40;
                        def.facePointB[var44] = var41;
                        def.facePointC[var44] = var42;
                    }
    
                    if (var45 == 4)
                    {
                        var46 = var40;
                        var40 = var41;
                        var41 = var46;
                        var42 = var4.readSmart() + var43;
                        var43 = var42;
                        def.facePointA[var44] = var40;
                        def.facePointB[var44] = var46;
                        def.facePointC[var44] = var42;
                    }
                }
    
                var4.setOffset(var33);
    
                for (var44 = 0; var44 < var11; ++var44)
                {
                    def.texture_type[var44] = 0;
                    def.textures_face_a[var44] = (short) var4.readUShort();
                    def.textures_face_b[var44] = (short) var4.readUShort();
                    def.textures_face_c[var44] = (short) var4.readUShort();
                }
    
                if (def.texture != null)
                {
                    boolean var47 = false;
    
                    for (var45 = 0; var45 < var10; ++var45)
                    {
                        var46 = def.texture[var45] & 255;
                        if (var46 != 255)
                        {
                            if (def.facePointA[var45] == (def.textures_face_a[var46] & '\uffff') && def.facePointB[var45] == (def.textures_face_b[var46] & '\uffff') && def.facePointC[var45] == (def.textures_face_c[var46] & '\uffff'))
                            {
                                def.texture[var45] = -1;
                            }
                            else
                            {
                                var47 = true;
                            }
                        }
                    }
    
                    if (!var47)
                    {
                        def.texture = null;
                    }
                }
    
                if (!var3)
                {
                    def.materials = null;
                }
    
                if (!var2)
                {
                    def.faceDrawType = null;
                }
    
            }
    
            public static void decodeType1(Model def, byte[] var1)
            {
                Buffer var2 = new Buffer(var1);
                Buffer var3 = new Buffer(var1);
                Buffer var4 = new Buffer(var1);
                Buffer var5 = new Buffer(var1);
                Buffer var6 = new Buffer(var1);
                Buffer var7 = new Buffer(var1);
                Buffer var8 = new Buffer(var1);
                var2.setOffset(var1.length - 23);
                int var9 = var2.readUShort();
                int var10 = var2.readUShort();
                int var11 = var2.readUnsignedByte();
                int var12 = var2.readUnsignedByte();
                int var13 = var2.readUnsignedByte();
                int var14 = var2.readUnsignedByte();
                int var15 = var2.readUnsignedByte();
                int var16 = var2.readUnsignedByte();
                int var17 = var2.readUnsignedByte();
                int var18 = var2.readUShort();
                int var19 = var2.readUShort();
                int var20 = var2.readUShort();
                int var21 = var2.readUShort();
                int var22 = var2.readUShort();
                int var23 = 0;
                int var24 = 0;
                int var25 = 0;
                int var26;
                if (var11 > 0)
                {
                    def.texture_type = new byte[var11];
                    var2.setOffset(0);
    
                    for (var26 = 0; var26 < var11; ++var26)
                    {
                        byte var27 = def.texture_type[var26] = var2.readByteS();
                        if (var27 == 0)
                        {
                            ++var23;
                        }
    
                        if (var27 >= 1 && var27 <= 3)
                        {
                            ++var24;
                        }
    
                        if (var27 == 2)
                        {
                            ++var25;
                        }
                    }
                }
    
                var26 = var11 + var9;
                int var56 = var26;
                if (var12 == 1)
                {
                    var26 += var10;
                }
    
                int var28 = var26;
                var26 += var10;
                int var29 = var26;
                if (var13 == 255)
                {
                    var26 += var10;
                }
    
                int var30 = var26;
                if (var15 == 1)
                {
                    var26 += var10;
                }
    
                int var31 = var26;
                if (var17 == 1)
                {
                    var26 += var9;
                }
    
                int var32 = var26;
                if (var14 == 1)
                {
                    var26 += var10;
                }
    
                int var33 = var26;
                var26 += var21;
                int var34 = var26;
                if (var16 == 1)
                {
                    var26 += var10 * 2;
                }
    
                int var35 = var26;
                var26 += var22;
                int var36 = var26;
                var26 += var10 * 2;
                int var37 = var26;
                var26 += var18;
                int var38 = var26;
                var26 += var19;
                int var39 = var26;
                var26 += var20;
                int var40 = var26;
                var26 += var23 * 6;
                int var41 = var26;
                var26 += var24 * 6;
                int var42 = var26;
                var26 += var24 * 6;
                int var43 = var26;
                var26 += var24 * 2;
                int var44 = var26;
                var26 += var24;
                int var45 = var26;
                var26 = var26 + var24 * 2 + var25 * 2;
                def.numVertices = var9;
                def.numTriangles = var10;
                def.numberOfTexturesFaces = var11;
                def.vertexX = new int[var9];
                def.vertexY = new int[var9];
                def.vertexZ = new int[var9];
                def.facePointA = new int[var10];
                def.facePointB = new int[var10];
                def.facePointC = new int[var10];
                if (var17 == 1)
                {
                    def.vertexVSkin = new int[var9];
                }
    
                if (var12 == 1)
                {
                    def.faceDrawType = new int[var10];
    
                }
    
                if (var13 == 255)
                {
                    def.face_render_priorities = new byte[var10];
                }
                else
                {
                    def.face_priority = (byte) var13;
                }
    
                if (var14 == 1)
                {
                    def.face_alpha = new int[var10];
                }
    
                if (var15 == 1)
                {
                    def.triangleTSkin = new int[var10];
                }
    
                if (var16 == 1)
                {
                    def.materials = new short[var10];
                }
    
                if (var16 == 1 && var11 > 0)
                {
                    def.texture_type = new byte[var10];
                }
    
                def.triangleColours = new short[var10];
                if (var11 > 0)
                {
                    def.textures_face_a = new short[var11];
                    def.textures_face_b = new short[var11];
                    def.textures_face_c = new short[var11];
                }
    
                var2.setOffset(var11);
                var3.setOffset(var37);
                var4.setOffset(var38);
                var5.setOffset(var39);
                var6.setOffset(var31);
                int var46 = 0;
                int var47 = 0;
                int var48 = 0;
    
                int var49;
                int var50;
                int var51;
                int var52;
                int var53;
                for (var49 = 0; var49 < var9; ++var49)
                {
                    var50 = var2.readUnsignedByte();
                    var51 = 0;
                    if ((var50 & 1) != 0)
                    {
                        var51 = var3.readSmart();
                    }
    
                    var52 = 0;
                    if ((var50 & 2) != 0)
                    {
                        var52 = var4.readSmart();
                    }
    
                    var53 = 0;
                    if ((var50 & 4) != 0)
                    {
                        var53 = var5.readSmart();
                    }
    
                    def.vertexX[var49] = var46 + var51;
                    def.vertexY[var49] = var47 + var52;
                    def.vertexZ[var49] = var48 + var53;
                    var46 = def.vertexX[var49];
                    var47 = def.vertexY[var49];
                    var48 = def.vertexZ[var49];
                    if (var17 == 1)
                    {
                        def.vertexVSkin[var49] = var6.readUnsignedByte();
                    }
                }
    
                var2.setOffset(var36);
                var3.setOffset(var56);
                var4.setOffset(var29);
                var5.setOffset(var32);
                var6.setOffset(var30);
                var7.setOffset(var34);
                var8.setOffset(var35);
    
                for (var49 = 0; var49 < var10; ++var49)
                {
                    def.triangleColours[var49] = (short) var2.readUShort();
                    if (var12 == 1)
                    {
                        def.faceDrawType[var49] = var3.readByteS();
                    }
    
                    if (var13 == 255)
                    {
                        def.face_render_priorities[var49] = var4.readByteS();
                    }
    
                    if (var14 == 1)
                    {
                        def.face_alpha[var49] = var5.readByteS();
                        if (def.face_alpha[var49] < 0) {
                            def.face_alpha[var49] = (256 + def.face_alpha[var40]);
                        }
                    }
    
                    if (var15 == 1)
                    {
                        def.triangleTSkin[var49] = var6.readUnsignedByte();
                    }
    
                    if (var16 == 1)
                    {
                        def.materials[var49] = (short) (var7.readUShort() - 1);
                    }
    
                    if (def.texture != null && def.materials[var49] != -1)
                    {
                        def.texture[var49] = (byte) (var8.readUnsignedByte() - 1);
                    }
                }
    
                var2.setOffset(var33);
                var3.setOffset(var28);
                var49 = 0;
                var50 = 0;
                var51 = 0;
                var52 = 0;
    
                int var54;
                for (var53 = 0; var53 < var10; ++var53)
                {
                    var54 = var3.readUnsignedByte();
                    if (var54 == 1)
                    {
                        var49 = var2.readSmart() + var52;
                        var50 = var2.readSmart() + var49;
                        var51 = var2.readSmart() + var50;
                        var52 = var51;
                        def.facePointA[var53] = var49;
                        def.facePointB[var53] = var50;
                        def.facePointC[var53] = var51;
                    }
    
                    if (var54 == 2)
                    {
                        var50 = var51;
                        var51 = var2.readSmart() + var52;
                        var52 = var51;
                        def.facePointA[var53] = var49;
                        def.facePointB[var53] = var50;
                        def.facePointC[var53] = var51;
                    }
    
                    if (var54 == 3)
                    {
                        var49 = var51;
                        var51 = var2.readSmart() + var52;
                        var52 = var51;
                        def.facePointA[var53] = var49;
                        def.facePointB[var53] = var50;
                        def.facePointC[var53] = var51;
                    }
    
                    if (var54 == 4)
                    {
                        int var55 = var49;
                        var49 = var50;
                        var50 = var55;
                        var51 = var2.readSmart() + var52;
                        var52 = var51;
                        def.facePointA[var53] = var49;
                        def.facePointB[var53] = var55;
                        def.facePointC[var53] = var51;
                    }
                }
    
                var2.setOffset(var40);
                var3.setOffset(var41);
                var4.setOffset(var42);
                var5.setOffset(var43);
                var6.setOffset(var44);
                var7.setOffset(var45);
    
                for (var53 = 0; var53 < var11; ++var53)
                {
                    var54 = def.texture_type[var53] & 255;
                    if (var54 == 0)
                    {
                        def.textures_face_a[var53] = (short) var2.readUShort();
                        def.textures_face_b[var53] = (short) var2.readUShort();
                        def.textures_face_c[var53] = (short) var2.readUShort();
                    }
                }
    
                var2.setOffset(var26);
                var53 = var2.readUnsignedByte();
                if (var53 != 0)
                {
                    var2.readUShort();
                    var2.readUShort();
                    var2.readUShort();
                    var2.readInt();
                }
    
            }
    
            public static void decodeOldFormat(Model def, byte[] var1)
            {
                boolean var2 = false;
                boolean var3 = false;
                Buffer var4 = new Buffer(var1);
                Buffer var5 = new Buffer(var1);
                Buffer var6 = new Buffer(var1);
                Buffer var7 = new Buffer(var1);
                Buffer var8 = new Buffer(var1);
                var4.setOffset(var1.length - 18);
                int var9 = var4.readUShort();
                int var10 = var4.readUShort();
                int var11 = var4.readUnsignedByte();
                int var12 = var4.readUnsignedByte();
                int var13 = var4.readUnsignedByte();
                int var14 = var4.readUnsignedByte();
                int var15 = var4.readUnsignedByte();
                int var16 = var4.readUnsignedByte();
                int var17 = var4.readUShort();
                int var18 = var4.readUShort();
                int var19 = var4.readUShort();
                int var20 = var4.readUShort();
                byte var21 = 0;
                int var22 = var21 + var9;
                int var23 = var22;
                var22 += var10;
                int var24 = var22;
                if (var13 == 255)
                {
                    var22 += var10;
                }
    
                int var25 = var22;
                if (var15 == 1)
                {
                    var22 += var10;
                }
    
                int var26 = var22;
                if (var12 == 1)
                {
                    var22 += var10;
                }
    
                int var27 = var22;
                if (var16 == 1)
                {
                    var22 += var9;
                }
    
                int var28 = var22;
                if (var14 == 1)
                {
                    var22 += var10;
                }
    
                int var29 = var22;
                var22 += var20;
                int var30 = var22;
                var22 += var10 * 2;
                int var31 = var22;
                var22 += var11 * 6;
                int var32 = var22;
                var22 += var17;
                int var33 = var22;
                var22 += var18;
                int var10000 = var22 + var19;
                def.numVertices = var9;
                def.numTriangles = var10;
                def.numberOfTexturesFaces = var11;
                def.vertexX = new int[var9];
                def.vertexY = new int[var9];
                def.vertexZ = new int[var9];
                def.facePointA = new int[var10];
                def.facePointB = new int[var10];
                def.facePointC = new int[var10];
                if (var11 > 0)
                {
                    def.texture_type = new byte[var11];
                    def.textures_face_a = new short[var11];
                    def.textures_face_b = new short[var11];
                    def.textures_face_c = new short[var11];
                }
    
                if (var16 == 1)
                {
                    def.vertexVSkin = new int[var9];
                }
    
                if (var12 == 1)
                {
                    def.faceDrawType = new int[var10];
                    def.texture_type = new byte[var10];
                    def.materials = new short[var10];
    
                }
    
                if (var13 == 255)
                {
                    def.face_render_priorities = new byte[var10];
                }
                else
                {
                    def.face_priority = (byte) var13;
                }
    
                if (var14 == 1)
                {
                    def.face_alpha = new int[var10];
                }
    
                if (var15 == 1)
                {
                    def.triangleTSkin = new int[var10];
                }
    
                def.triangleColours = new short[var10];
                var4.setOffset(var21);
                var5.setOffset(var32);
                var6.setOffset(var33);
                var7.setOffset(var22);
                var8.setOffset(var27);
                int var35 = 0;
                int var36 = 0;
                int var37 = 0;
    
                int var38;
                int var39;
                int var40;
                int var41;
                int var42;
                for (var38 = 0; var38 < var9; ++var38)
                {
                    var39 = var4.readUnsignedByte();
                    var40 = 0;
                    if ((var39 & 1) != 0)
                    {
                        var40 = var5.readSmart();
                    }
    
                    var41 = 0;
                    if ((var39 & 2) != 0)
                    {
                        var41 = var6.readSmart();
                    }
    
                    var42 = 0;
                    if ((var39 & 4) != 0)
                    {
                        var42 = var7.readSmart();
                    }
    
                    def.vertexX[var38] = var35 + var40;
                    def.vertexY[var38] = var36 + var41;
                    def.vertexZ[var38] = var37 + var42;
                    var35 = def.vertexX[var38];
                    var36 = def.vertexY[var38];
                    var37 = def.vertexZ[var38];
                    if (var16 == 1)
                    {
                        def.vertexVSkin[var38] = var8.readUnsignedByte();
                    }
                }
    
                var4.setOffset(var30);
                var5.setOffset(var26);
                var6.setOffset(var24);
                var7.setOffset(var28);
                var8.setOffset(var25);
    
                for (var38 = 0; var38 < var10; ++var38)
                {
                    def.triangleColours[var38] = (short) var4.readUShort();
                    if (var12 == 1)
                    {
                        var39 = var5.readUnsignedByte();
                        if ((var39 & 1) == 1)
                        {
                            def.faceDrawType[var38] = 1;
                            var2 = true;
                        }
                        else
                        {
                            def.faceDrawType[var38] = 0;
                        }
    
                        if ((var39 & 2) == 2)
                        {
                            def.texture[var38] = (byte) (var39 >> 2);
                            def.materials[var38] = def.triangleColours[var38];
                            def.triangleColours[var38] = 127;
                            if (def.materials[var38] != -1)
                            {
                                var3 = true;
                            }
                        }
                        else
                        {
                            def.texture[var38] = -1;
                            def.materials[var38] = -1;
                        }
                    }
    
                    if (var13 == 255)
                    {
                        def.face_render_priorities[var38] = var6.readByteS();
                    }
    
                    if (var14 == 1)
                    {
                        def.face_alpha[var38] = var7.readByteS();
                        if (def.face_alpha[var38] < 0) {
                            def.face_alpha[var38] = (256 + def.face_alpha[var38]);
                        }
                    }
    
                    if (var15 == 1)
                    {
                        def.triangleTSkin[var38] = var8.readUnsignedByte();
                    }
                }
    
                var4.setOffset(var29);
                var5.setOffset(var23);
                var38 = 0;
                var39 = 0;
                var40 = 0;
                var41 = 0;
    
                int var43;
                int var44;
                for (var42 = 0; var42 < var10; ++var42)
                {
                    var43 = var5.readUnsignedByte();
                    if (var43 == 1)
                    {
                        var38 = var4.readSmart() + var41;
                        var39 = var4.readSmart() + var38;
                        var40 = var4.readSmart() + var39;
                        var41 = var40;
                        def.facePointA[var42] = var38;
                        def.facePointB[var42] = var39;
                        def.facePointC[var42] = var40;
                    }
    
                    if (var43 == 2)
                    {
                        var39 = var40;
                        var40 = var4.readSmart() + var41;
                        var41 = var40;
                        def.facePointA[var42] = var38;
                        def.facePointB[var42] = var39;
                        def.facePointC[var42] = var40;
                    }
    
                    if (var43 == 3)
                    {
                        var38 = var40;
                        var40 = var4.readSmart() + var41;
                        var41 = var40;
                        def.facePointA[var42] = var38;
                        def.facePointB[var42] = var39;
                        def.facePointC[var42] = var40;
                    }
    
                    if (var43 == 4)
                    {
                        var44 = var38;
                        var38 = var39;
                        var39 = var44;
                        var40 = var4.readSmart() + var41;
                        var41 = var40;
                        def.facePointA[var42] = var38;
                        def.facePointB[var42] = var44;
                        def.facePointC[var42] = var40;
                    }
                }
    
                var4.setOffset(var31);
                for (var42 = 0; var42 < var11; ++var42)
                {
                    def.texture_type[var42] = 0;
                    def.textures_face_a[var42] = (short) var4.readUShort();
                    def.textures_face_b[var42] = (short) var4.readUShort();
                    def.textures_face_c[var42] = (short) var4.readUShort();
                }
    
                if (def.texture != null)
                {
                    boolean var45 = false;
    
                    for (var43 = 0; var43 < var10; ++var43)
                    {
                        var44 = def.texture[var43] & 255;
                        if (var44 != 255)
                        {
                            if (def.facePointA[var43] == (def.textures_face_a[var44] & '\uffff') && def.facePointB[var43] == (def.textures_face_b[var44] & '\uffff') && def.facePointC[var43] == (def.textures_face_c[var44] & '\uffff'))
                            {
                                def.texture[var43] = -1;
                            }
                            else
                            {
                                var45 = true;
                            }
                        }
                    }
    
                    if (!var45)
                    {
                        def.texture = null;
                    }
                }
    
                if (!var3)
                {
                    def.materials = null;
                }
    
                if (!var2)
                {
                    def.faceDrawType = null;
                }
    
            }
    
    }


    Spoiler for readvalues:
    Code:
    objDef
    
        private void readValues(Buffer buffer) {
            while (true) {
                int opcode = buffer.readUnsignedByte();
                if (opcode == 0)
                    break;
                if (opcode == 1) {
                    int len = buffer.readUnsignedByte();
                    if (len > 0) {
                        if (modelIds == null) {
                            modelTypes = new int[len];
                            modelIds = new int[len];
    
                            for (int i = 0; i < len; i++) {
                                modelIds[i] = buffer.readUShort();
                                modelTypes[i] = buffer.readUnsignedByte();
                            }
                        } else {
                            buffer.currentPosition += len * 3;
                        }
                    }
                } else if (opcode == 2)
                    name = buffer.readString();
                else if (opcode == 3)
                    description = buffer.readString();
                else if (opcode == 5) {
                    int len = buffer.readUnsignedByte();
                    if (len > 0) {
                        if (modelIds == null) {
                            modelTypes = null;
                            modelIds = new int[len];
    
                            for (int i = 0; i < len; i++) {
                                modelIds[i] = buffer.readUShort();
                            }
                        } else {
                            buffer.currentPosition += len * 3;
                        }
                    }
                } else if (opcode == 14)
                    objectSizeX = buffer.readUnsignedByte();
                else if (opcode == 15)
                    objectSizeY = buffer.readUnsignedByte();
                else if (opcode == 17) {
                    solid = false;
                    impenetrable = false;
                } else if (opcode == 18)
                    impenetrable = false;
                else if (opcode == 19)
                    isInteractive = (buffer.readUnsignedByte() == 1);
                else if (opcode == 21)
                    contouredGround = true;
                else if (opcode == 22)
                    delayShading = true;
                else if (opcode == 23)
                    occludes = true;
                else if (opcode == 24) { // Object Animations
                    animation = buffer.readUShort();
                    if (animation == 65535)
                        animation = -1;
                } else if (opcode == 28)
                    decorDisplacement = buffer.readUnsignedByte();
                else if (opcode == 29)
                    ambientLighting = buffer.readSignedByte();
                else if (opcode == 39)
                    lightDiffusion = buffer.readSignedByte();
                else if (opcode >= 30 && opcode < 35) {
                    if (interactions == null)
                        interactions = new String[10];
                    interactions[opcode - 30] = buffer.readString();
                    if (interactions[opcode - 30].equalsIgnoreCase("hidden"))
                        interactions[opcode - 30] = null;
                } else if (opcode == 40) {
                    int len = buffer.readUnsignedByte();
                    modifiedModelColors = new int[len];
                    originalModelColors = new int[len];
                    for (int i = 0; i < len; i++) {
                        modifiedModelColors[i] = buffer.readUShort();
                        originalModelColors[i] = buffer.readUShort();
                    }
                } else if (opcode == 41) {
                    int len = buffer.readUnsignedByte();
                    modifiedTexture = new short[len];
                    originalTexture = new short[len];
                    for (int i = 0; i < len; i++) {
                        modifiedTexture[i] = (short) buffer.readUShort();
                        originalTexture[i] = (short) buffer.readUShort();
                    }
                } else if (opcode == 61) {
                    category = buffer.readUShort();
                } else if (opcode == 62)
                    inverted = true;
                else if (opcode == 64)
                    castsShadow = false;
                else if (opcode == 65)
                    scaleX = buffer.readUShort();
                else if (opcode == 66)
                    scaleY = buffer.readUShort();
                else if (opcode == 67)
                    scaleZ = buffer.readUShort();
                else if (opcode == 68)
                    mapscene = buffer.readUShort();
                else if (opcode == 69)
                    surroundings = buffer.readUnsignedByte();
                else if (opcode == 70)
                    translateX = buffer.readShort();
                else if (opcode == 71)
                    translateY = buffer.readShort();
                else if (opcode == 72)
                    translateZ = buffer.readShort();
                else if (opcode == 73)
                    obstructsGround = true;
                else if (opcode == 74)
                    hollow = true;
                else if (opcode == 75)
                    supportItems = buffer.readUnsignedByte();
                else if (opcode == 77 || opcode == 92) {
                    varbit = buffer.readUShort();
    
                    if (varp == 0xFFFF) {
                        varp = -1;
                    }
    
                    varp = buffer.readUShort();
    
                    if (varbit == 0xFFFF) {
                        varbit = -1;
                    }
    
                    int value = -1;
    
                    if (opcode == 92) {
                        value = buffer.readUShort();
    
                        if (value == 0xFFFF) {
                            value = -1;
                        }
                    }
    
                    int len = buffer.readUnsignedByte();
    
                    childrenIDs = new int[len + 2];
                    for (int i = 0; i <= len; ++i) {
                        childrenIDs[i] = buffer.readUShort();
                        if (childrenIDs[i] == 0xFFFF) {
                            childrenIDs[i] = -1;
                        }
                    }
                    childrenIDs[len + 1] = value;
                } else if (opcode == 78) {
                    ambientSoundId = buffer.readUShort();
                    anInt2083 = buffer.readUnsignedByte();
                } else if (opcode == 79) {
                    anInt2112 = buffer.readUShort();
                    anInt2113 = buffer.readUShort();
                    anInt2083 = buffer.readUShort();
    
                    int length = buffer.readUnsignedByte();
                    int[] anims = new int[length];
    
                    for (int index = 0; index < length; ++index) {
                        anims[index] = buffer.readUShort();
                    }
                    ambientSoundIds = anims;
                } else if (opcode == 81) {
                    contouredGround = buffer.readUnsignedByte() == 1;
                } else if (opcode == 82) {
                    minimapFunction = buffer.readUShort();//AreaType
                } else if (opcode == 89) {
                    randomAnimStart = false;
                } else if (opcode == 249) {
                    int length = buffer.readUnsignedByte();
    
                    Map<Integer, Object> params = new HashMap<>(length);
                    for (int i = 0; i < length; i++) {
                        boolean isString = buffer.readUnsignedByte() == 1;
                        int key = buffer.read24Int();
                        Object value;
    
                        if (isString) {
                            value = buffer.readString();
                            System.out.println(value);
                        } else {
                            value = buffer.readInt();
                        }
    
                        params.put(key, value);
                    }
    
                    this.params = params;
                } else {
                    //System.err.printf("Error unrecognised {Objects} opcode: %d%n%n", opcode);
                }
            }
            post();
        }
    
        private void post() {
        }
    Code:
    npcDEF
    
    public void readValues(Buffer buffer) {
    
    		while (true) {
    			int opcode = buffer.readUnsignedByte();
    			if (opcode == 0)
    				return;
    			if (opcode == 1) {
    				int j = buffer.readUnsignedByte();
    				modelId = new int[j];
    				for (int j1 = 0; j1 < j; j1++) {
    					modelId[j1] = buffer.readUShort();
    				}
    			} else if (opcode == 2)
    				name = buffer.readString();
    			else if (opcode == 3)
    				description = buffer.readBytes();
    			else if (opcode == 12)
    				size = buffer.readSignedByte();
    			else if (opcode == 13)
    				standAnim = buffer.readUShort();
    			else if (opcode == 14)
    				walkAnim = buffer.readUShort();
    			else if (opcode == 15) {
    				rotateLeftAnimation = buffer.readUShort();
    			} else if (opcode == 16) {
    				rotateRightAnimation = buffer.readUShort();
    			} else if (opcode == 17) {
    				walkAnim = buffer.readUShort();
    				turn180AnimIndex = buffer.readUShort();
    				turn90CWAnimIndex = buffer.readUShort();
    				turn90CCWAnimIndex = buffer.readUShort();
    				if (turn180AnimIndex == 65535) {
    					turn180AnimIndex = -1;
    				}
    				if (turn90CWAnimIndex == 65535) {
    					turn90CWAnimIndex = -1;
    				}
    				if (turn90CCWAnimIndex == 65535) {
    					turn90CCWAnimIndex = -1;
    				}
    			} else if (opcode == 18) {
    				category = buffer.readUShort();
    			} else if (opcode >= 30 && opcode < 40) {
    				if (actions == null)
    					actions = new String[10];
    				actions[opcode - 30] = buffer.readString();
    				if (actions[opcode - 30].equalsIgnoreCase("hidden"))
    					actions[opcode - 30] = null;
    			} else if (opcode == 40) {
    				int k = buffer.readUnsignedByte();
    				recolourOriginal = new int[k];
    				recolourTarget = new int[k];
    				for (int k1 = 0; k1 < k; k1++) {
    					recolourOriginal[k1] = buffer.readUShort();
    					recolourTarget[k1] = buffer.readUShort();
    				}
    			} else if (opcode == 41) {
    				int length = buffer.readUnsignedByte();
    				src_texture = new short[length];
    				dst_texture = new short[length];
    				for (int index = 0; index < length; index++) {
    					src_texture[index] = (short) buffer.readUShort();
    					dst_texture[index] = (short) buffer.readUShort();
    				}
    
    			} else if (opcode == 60) {
    				int l = buffer.readUnsignedByte();
    				aditionalModels = new int[l];
    				for (int l1 = 0; l1 < l; l1++) {
    					aditionalModels[l1] = buffer.readUShort();
    				}
    			} else if (opcode == 93)
    				drawMinimapDot = false;
    			else if (opcode == 95)
    				combatLevel = buffer.readUShort();
    			else if (opcode == 97)
    				scaleXZ = buffer.readUShort();
    			else if (opcode == 98)
    				scaleY = buffer.readUShort();
    			else if (opcode == 99)
    				priorityRender = true;
    			else if (opcode == 100)
    				lightModifier = buffer.readSignedByte();
    			else if (opcode == 101)
    				shadowModifier = buffer.readSignedByte();
    			else if (opcode == 102)
    				headIcon = buffer.readUShort();
    			else if (opcode == 103)
    				degreesToTurn = buffer.readUShort();
    			else if (opcode == 109) {
    				rotationFlag = false;
    			} else if (opcode == 111) {
    				isPet = true;
    			} else if (opcode == 106 || opcode == 118) {
    				varBitID = buffer.readUShort();
    				if (varBitID == 65535)
    					varBitID = -1;
    				settingId = buffer.readUShort();
    				if (settingId == 65535)
    					settingId = -1;
    
    				int var3 = -1;
    				if (opcode == 118) {
    					var3 = buffer.readUShort();
    				}
    				int i1 = buffer.readUnsignedByte();
    				childrenIDs = new int[i1 + 2];
    				for (int i2 = 0; i2 <= i1; i2++) {
    					childrenIDs[i2] = buffer.readUShort();
    					if (childrenIDs[i2] == 65535)
    						childrenIDs[i2] = -1;
    				}
    				childrenIDs[i1 + 1] = var3;
    
    			} else if (opcode == 107)
    				clickable = false;
    			else if (opcode == 249) {
    				int length = buffer.readUnsignedByte();
    
    				params = new HashMap<>(length);
    
    				for (int i = 0; i < length; i++) {
    					boolean isString = buffer.readUnsignedByte() == 1;
    					int key = buffer.read24Int();
    					Object value;
    
    					if (isString) {
    						value = buffer.readString();
    					} else {
    						value = buffer.readInt();
    					}
    
    					params.put(key, value);
    				}
    			} else {
    				System.err.printf("Error unrecognised {NPC} opcode: %d%n%n", opcode);
    				continue;
    			}
    		}
    	}
    Code:
    itemDEF
    
    public void readValues(Buffer buffer) {
            while (true) {
                int opcode = buffer.readUnsignedByte();
                if (opcode == 0)
                    return;
                if (opcode == 1)
                    inventory_model = buffer.readUShort();
                else if (opcode == 2)
                    name = buffer.readString();
                else if (opcode == 3)
                    description = buffer.readString();
                else if (opcode == 4)
                    zoom2d = buffer.readUShort();
                else if (opcode == 5)
                    xan2d = buffer.readUShort();
                else if (opcode == 6)
                    yan2d = buffer.readUShort();
                else if (opcode == 7) {
                    xOffset2d = buffer.readUShort();
                    if (xOffset2d > 32767)
                        xOffset2d -= 0x10000;
                } else if (opcode == 8) {
                    yOffset2d = buffer.readUShort();
                    if (yOffset2d > 32767)
                        yOffset2d -= 0x10000;
                } else if (opcode == 11)
                    stackable = true;
                else if (opcode == 12)
                    value = buffer.readInt();
                else if (opcode == 16)
                    membership_required = true;
                else if (opcode == 23) {
                    male_equip_main = buffer.readUShort();
                    male_equip_translate_y = buffer.readSignedByte();
                } else if (opcode == 24)
                    male_equip_attachment = buffer.readUShort();
                else if (opcode == 25) {
                    female_equip_main = buffer.readUShort();
                    female_equip_attachment = buffer.readSignedByte();
                } else if (opcode == 26)
                    female_equip_attachment = buffer.readUShort();
                else if (opcode >= 30 && opcode < 35) {
                    if (scene_actions == null)
                        scene_actions = new String[5];
                    scene_actions[opcode - 30] = buffer.readString();
                    if (scene_actions[opcode - 30].equalsIgnoreCase("hidden"))
                        scene_actions[opcode - 30] = null;
                } else if (opcode >= 35 && opcode < 40) {
                    if (widget_actions == null)
                        widget_actions = new String[5];
                    widget_actions[opcode - 35] = buffer.readString();
                } else if (opcode == 40) {
                    int length = buffer.readUnsignedByte();
                    src_color = new int[length];
                    dst_color = new int[length];
                    for (int index = 0; index < length; index++) {
                        dst_color[index] = buffer.readUShort();
                        src_color[index] = buffer.readUShort();
                    }
                } else if (opcode == 41) {
                    int length = buffer.readUnsignedByte();
                    src_texture = new short[length];
                    dst_texture = new short[length];
                    for (int index = 0; index < length; index++) {
                        src_texture[index] = (short) buffer.readUShort();
                        dst_texture[index] = (short) buffer.readUShort();
                    }
                } else if (opcode == 42) {
                    shiftClickIndex = buffer.readUnsignedByte();
                } else if (opcode == 65) {
                    tradeable = true;
                } else if (opcode == 78)
                    male_equip_emblem = buffer.readUShort();
                else if (opcode == 79)
                    female_equip_emblem = buffer.readUShort();
                else if (opcode == 90)
                    male_dialogue_head = buffer.readUShort();
                else if (opcode == 91)
                    female_dialogue_head = buffer.readUShort();
                else if (opcode == 92)
                    male_dialogue_headgear = buffer.readUShort();
                else if (opcode == 93)
                    female_dialogue_headgear = buffer.readUShort();
                else if (opcode == 94)
                    category = buffer.readUShort();
                else if (opcode == 95)
                    zan2d = buffer.readUShort();
                else if (opcode == 97)
                    unnoted_item_id = buffer.readUShort();
                else if (opcode == 98)
                    noted_item_id = buffer.readUShort();
                else if (opcode >= 100 && opcode < 110) {
                    if (stack_variant_id == null) {
                        stack_variant_id = new int[10];
                        stack_variant_size = new int[10];
                    }
                    stack_variant_id[opcode - 100] = buffer.readUShort();
                    stack_variant_size[opcode - 100] = buffer.readUShort();
                } else if (opcode == 110)
                    resizeX = buffer.readUShort();
                else if (opcode == 111)
                    resizeY = buffer.readUShort();
                else if (opcode == 112)
                    resizeZ = buffer.readUShort();
                else if (opcode == 113)
                    ambient = buffer.readSignedByte();
                else if (opcode == 114)
                    contrast = buffer.readSignedByte() * 5;
                else if (opcode == 115)
                    team_id = buffer.readUnsignedByte();
                else if (opcode == 139)
                    bought_id = buffer.readUShort();
                else if (opcode == 140)
                    bought_template_id = buffer.readUShort();
                else if (opcode == 148)
                    placeholder_id = buffer.readUShort();
                else if (opcode == 149) {
                    placeholder_template_id = buffer.readUShort();
                } else if (opcode == 249) {
                    int length = buffer.readUnsignedByte();
    
                    params = new HashMap<>(length);
    
                    for (int i = 0; i < length; i++) {
                        boolean isString = buffer.readUnsignedByte() == 1;
                        int key = buffer.read24Int();
                        Object value;
    
                        if (isString) {
                            value = buffer.readString();
                        } else {
                            value = buffer.readInt();
                        }
    
                        params.put(key, value);
                    }
                } else {
                    System.err.printf("Error unrecognised {Items} opcode: %d%n%n", opcode);
                }
            }
        }


    Spoiler for collisionMap.java:

    Code:
        
    
    
    public void load(int block_x, CollisionMap[] map, int block_y, SceneGraph scene, byte[] data) {
            load:
            {
                Buffer buffer = new Buffer(data);
                int object_id = -1;
                do {
                    int id_offset = buffer.readUnsignedIntSmartShortCompat();
                    if (id_offset == 0)
                        break load;
    
                    object_id += id_offset;
                    int pos = 0;
                    do {
                        int pos_offset = buffer.readUSmart();
                        if (pos_offset == 0)
                            break;
    
                        pos += pos_offset - 1;
                        int tile_y = pos & 0x3F;
                        int tile_x = pos >> 6 & 0x3F;
                        int plane = pos >> 12 & 0x3;
                        int hash = buffer.readUnsignedByte();
                        int type = hash >> 2;
                        int orientation = hash & 3;
                        int x = tile_x + block_x;
                        int y = tile_y + block_y;
                        if (x > 0 && y > 0 && x < 103 && y < 103 && plane >= 0 && plane < 4) {
                            int marking_plane = plane;
                            if ((tile_flags[1][x][y] & 2) == 2)
                                marking_plane--;
    
                            CollisionMap collision = null;
                            if (marking_plane >= 0/* && marking_plane < 4*/)//added for higher revisions
                                collision = map[marking_plane];
    
                            render(y, scene, collision, type, plane, x, object_id, orientation);
                        }
                    } while (true);
                } while (true);
            }
        }
    
        private void render(int y, SceneGraph scene, CollisionMap collision, int type, int plane, int x, int object_id, int orientation) {
        }


    Spoiler for buffer.java:
    Code:
        public int readUnsignedIntSmartShortCompat() {
            int var1 = 0;
    
            int var2;
            for (var2 = this.readUSmart(); var2 == 32767; var2 = this.readUSmart()) {
                var1 += 32767;
            }
    
            var1 += var2;
            return var1;
        }
    
    public int readUSmart() {
            int peek = payload[currentPosition] & 0xFF;
            return peek < 128 ? this.readUnsignedByte() : this.readUShort() - 0x8000;
        }
    
        public void encodeRSA(BigInteger exponent, BigInteger modulus) {
            int length = currentPosition;
            currentPosition = 0;
            byte buffer[] = new byte[length];
            readBytes(length, 0, buffer);
    
            byte rsa[] = buffer;
    
            if (Configuration.ENABLE_RSA) {
                rsa = new BigInteger(buffer).modPow(exponent, modulus)
                        .toByteArray();
            }
    
            currentPosition = 0;
            writeByte(rsa.length);
            writeBytes(rsa, rsa.length, 0);
        }


    Spoiler for Image:
    Attached image
    The server you are missing opcodes when u read the data as for the client stacks u probs have errors being suppressed somewhere so them client errors dont rlly help us. add me on discord and ill help u out, or run the client on debug and it will break where it happens
    Attached image
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 0
    Last Post: 03-26-2019, 01:41 AM
  2. Updating Vencillo to 118 data
    By Audi in forum Help
    Replies: 0
    Last Post: 08-06-2016, 02:38 AM
  3. need people to find dupes and fix them.
    By Jarrodv2 in forum Buying
    Replies: 0
    Last Post: 07-03-2014, 11:44 PM
  4. Replies: 41
    Last Post: 09-25-2013, 08:50 PM
  5. How to edit shops and fix trade glitch
    By codyorr4 in forum Help
    Replies: 1
    Last Post: 06-23-2013, 11:39 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •