Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** Object **/
- public void readValues(Buffer stream) { int flag = -1;
- do {
- int type = stream.readUnsignedByte();
- if (type == 0)
- break;
- if (type == 1) {
- int len = stream.readUnsignedByte();
- if (len > 0) {
- if (modelIds == null || lowMemory) {
- modelTypes = new int[len];
- modelIds = new int[len];
- for (int k1 = 0; k1 < len; k1++) {
- modelIds[k1] = stream.readUShort();
- modelTypes[k1] = stream.readUnsignedByte();
- }
- } else {
- stream.currentPosition += len * 3;
- }
- }
- } else if (type == 2)
- name = stream.readString();
- else if (type == 3)
- description = stream.readString();
- else if (type == 5) {
- int len = stream.readUnsignedByte();
- if (len > 0) {
- if (modelIds == null || lowMemory) {
- modelTypes = null;
- modelIds = new int[len];
- for (int l1 = 0; l1 < len; l1++)
- modelIds[l1] = stream.readUShort();
- } else {
- stream.currentPosition += len * 2;
- }
- }
- } else if (type == 14)
- objectSizeX = stream.readUnsignedByte();
- else if (type == 15)
- objectSizeY = stream.readUnsignedByte();
- else if (type == 17)
- solid = false;
- else if (type == 18)
- impenetrable = false;
- else if (type == 19)
- isInteractive = (stream.readUnsignedByte() == 1);
- else if (type == 21)
- contouredGround = true;
- else if (type == 22)
- delayShading = false;
- else if (type == 23)
- occludes = true;
- else if (type == 24) {
- animation = stream.readUShort();
- if (animation == 65535)
- animation = -1;
- } else if (type == 28)
- decorDisplacement = stream.readUnsignedByte();
- else if (type == 29)
- ambientLighting = stream.readSignedByte();
- else if (type == 39)
- lightDiffusion = stream.readSignedByte() ;
- else if (type >= 30 && type < 35) {
- if (interactions == null)
- interactions = new String[5];
- interactions[type - 30] = stream.readString();
- if (interactions[type - 30].equalsIgnoreCase("hidden"))
- interactions[type - 30] = null;
- } else if (type == 40) {
- int i1 = stream.readUnsignedByte();
- modifiedModelColors = new int[i1];
- originalModelColors = new int[i1];
- for (int i2 = 0; i2 < i1; i2++) {
- modifiedModelColors[i2] = stream.readUShort();
- originalModelColors[i2] = stream.readUShort();
- }
- } else if (type == 41) {
- int j2 = stream.readUnsignedByte();
- modifiedTexture = new short[j2];
- originalTexture = new short[j2];
- for (int k = 0; k < j2; k++) {
- modifiedTexture[k] = (short) stream.readUShort();
- originalTexture[k] = (short) stream.readUShort();
- }
- }
- else if (type == 62)
- inverted = true;
- else if (type == 64)
- castsShadow = false;
- else if (type == 65)
- scaleX = stream.readUShort();
- else if (type == 66)
- scaleY = stream.readUShort();
- else if (type == 67)
- scaleZ = stream.readUShort();
- else if (type == 68)
- mapscene = stream.readUShort();
- else if (type == 69)
- surroundings = stream.readUnsignedByte();
- else if (type == 70)
- translateX = stream.readShort();
- else if (type == 71)
- translateY = stream.readShort();
- else if (type == 72)
- translateZ = stream.readShort();
- else if (type == 73)
- obstructsGround = true;
- else if (type == 74)
- hollow = true;
- else if (type == 75)
- supportItems = stream.readUnsignedByte();
- else if (type == 78) {
- ambientsound = stream.readUShort(); // ambient sound id
- stream.readUnsignedByte();
- } else if (type == 79) {
- stream.readUShort();
- stream.readUShort();
- stream.readUnsignedByte();
- int len = stream.readUnsignedByte();
- for (int i = 0; i < len; i++) {
- stream.readUShort();
- }
- } else if (type == 81) {
- stream.readUnsignedByte();
- } else if (type == 60) {
- minimapFunction = stream.readUShort();
- } else if (type == 77 || type == 92) {
- varp = stream.readUShort();
- if (varp == 0xFFFF) {
- varp = -1;
- }
- varbit = stream.readUShort();
- if (varbit == 0xFFFF) {
- varbit = -1;
- }
- int value = -1;
- if (type == 92) {
- value = stream.readUShort();
- if (value == 0xFFFF) {
- value = -1;
- }
- }
- int len = stream.readUnsignedByte();
- morphisms = new int[len + 2];
- for (int i = 0; i <= len; ++i) {
- morphisms[i] = stream.readUShort();
- if (morphisms[i] == 0xFFFF) {
- morphisms[i] = -1;
- }
- }
- morphisms[len + 1] = value;
- }
- } while (true);
- if (flag == -1 && name != "null" && name != null) {
- isInteractive = modelIds != null
- && (modelTypes == null || modelTypes[0] == 10);
- if (interactions != null)
- isInteractive = true;
- }
- if (hollow) {
- solid = false;
- impenetrable = false;
- }
- if (supportItems == -1)
- supportItems = solid ? 1 : 0;
- }
- /** NPC **/
- public void readValues(Buffer stream) {
- do {
- int opCode = stream.readUnsignedByte();
- if (opCode == 0)
- return;
- if (opCode == 1) {
- int j = stream.readUnsignedByte();
- modelId = new int[j];
- for (int j1 = 0; j1 < j; j1++)
- modelId[j1] = stream.readUShort();
- } else if (opCode == 2)
- name = stream.readString();
- else if (opCode == 3)
- description = stream.readBytes();
- else if (opCode == 12)
- size = stream.readSignedByte();
- else if (opCode == 13)
- standAnim = stream.readUShort();
- else if (opCode == 14)
- walkAnim = stream.readUShort();
- else if (opCode == 17) {
- walkAnim = stream.readUShort();
- turn180AnimIndex = stream.readUShort();
- turn90CWAnimIndex = stream.readUShort();
- turn90CCWAnimIndex = stream.readUShort();
- } else if (opCode >= 30 && opCode < 40) {
- if (actions == null)
- actions = new String[5];
- actions[opCode - 30] = stream.readString();
- if (actions[opCode - 30].equalsIgnoreCase("hidden"))
- actions[opCode - 30] = null;
- } else if (opCode == 40) {
- int colours = stream.readUnsignedByte();
- recolourOriginal = new int[colours];
- recolourTarget = new int[colours];
- for (int k1 = 0; k1 < colours; k1++) {
- recolourOriginal[k1] = stream.readUShort();
- recolourTarget[k1] = stream.readUShort();
- }
- } else if (opCode == 60) {
- int additionalModelLen = stream.readUnsignedByte();
- additionalModels = new int[additionalModelLen];
- for (int l1 = 0; l1 < additionalModelLen; l1++)
- additionalModels[l1] = stream.readUShort();
- } else if (opCode == 90)
- stream.readUShort();
- else if (opCode == 91)
- stream.readUShort();
- else if (opCode == 92)
- stream.readUShort();
- else if (opCode == 93)
- drawMinimapDot = false;
- else if (opCode == 95)
- combatLevel = stream.readUShort();
- else if (opCode == 97)
- scaleXZ = stream.readUShort();
- else if (opCode == 98)
- scaleY = stream.readUShort();
- else if (opCode == 99)
- priorityRender = true;
- else if (opCode == 100)
- lightModifier = stream.readSignedByte();
- else if (opCode == 101)
- shadowModifier = stream.readSignedByte() * 5;
- else if (opCode == 102)
- headIcon = stream.readUShort();
- else if (opCode == 103)
- degreesToTurn = stream.readUShort();
- else if (opCode == 106) {
- varBitID = stream.readUShort();
- if (varBitID == 65535)
- varBitID = -1;
- settingId = stream.readUShort();
- if (settingId == 65535)
- settingId = -1;
- int value = -1;
- if (opCode == 118) {
- value = stream.readUShort();
- }
- int childCount = stream.readUnsignedByte();
- childrenIDs = new int[childCount + 2];
- for (int i2 = 0; i2 <= childCount; i2++) {
- childrenIDs[i2] = stream.readUShort();
- if (childrenIDs[i2] == 65535)
- childrenIDs[i2] = -1;
- }
- childrenIDs[childCount + 1] = value;
- } else if (opCode == 109)
- clickable = false;
- else if (opCode == 107 || opCode == 111) {
- aBoolean84 = false;
- } else {
- System.out.println(String.format("npc def invalid opcode: %d", opCode));
- }
- } while (true);
- }
- /** Items **/
- public void readValues(Buffer buffer) {
- do {
- 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)
- model_zoom = buffer.readUShort();
- else if (opCode == 5)
- rotation_y = buffer.readUShort();
- else if (opCode == 6)
- rotation_x = buffer.readUShort();
- else if (opCode == 7) {
- translate_x = buffer.readUShort();
- if (translate_x > 32767)
- translate_x -= 0x10000;
- } else if (opCode == 8) {
- translate_yz = buffer.readUShort();
- if (translate_yz > 32767)
- translate_yz -= 0x10000;
- } else if (opCode == 10)
- buffer.readUShort();
- else if (opCode == 11)
- stackable = true;
- else if (opCode == 12) {
- value = buffer.readInt();
- } else if (opCode == 16)
- is_members_only = true;
- else if (opCode == 23) {
- equipped_model_male_1 = buffer.readUShort();
- equipped_model_male_translation_y = buffer.readSignedByte();
- } else if (opCode == 24)
- equipped_model_male_2 = buffer.readUShort();
- else if (opCode == 25) {
- equipped_model_female_1 = buffer.readUShort();
- equipped_model_female_translation_y = buffer.readSignedByte();
- } else if (opCode == 26)
- equipped_model_female_2 = buffer.readUShort();
- else if (opCode >= 30 && opCode < 35) {
- if (groundActions == null)
- groundActions = new String[5];
- groundActions[opCode - 30] = buffer.readString();
- if (groundActions[opCode - 30].equalsIgnoreCase("hidden"))
- groundActions[opCode - 30] = null;
- } else if (opCode >= 35 && opCode < 40) {
- if (actions == null)
- actions = new String[5];
- actions[opCode - 35] = buffer.readString();
- } else if (opCode == 40) {
- int j = buffer.readUnsignedByte();
- original_model_colours = new int[j];
- modified_model_colours = new int[j];
- for (int k = 0; k < j; k++) {
- modified_model_colours[k] = buffer.readUShort();
- original_model_colours[k] = buffer.readUShort();
- }
- } else if (opCode == 41) {
- int j = buffer.readUnsignedByte();
- textureToReplace = new int[j];
- textureToReplaceWith = new int[j];
- for (int k = 0; k < j; k++) {
- textureToReplace[k] = buffer.readUShort();
- textureToReplaceWith[k] = buffer.readUShort();
- }
- } else if (opCode == 78)
- equipped_model_male_3 = buffer.readUShort();
- else if (opCode == 42)
- shiftClickIndex = buffer.readUShort();
- else if (opCode == 65)
- searchable = true;
- else if (opCode == 79)
- equipped_model_female_3 = buffer.readUShort();
- else if (opCode == 90)
- equipped_model_male_dialogue_1 = buffer.readUShort();
- else if (opCode == 91)
- equipped_model_female_dialogue_1 = buffer.readUShort();
- else if (opCode == 92)
- equipped_model_male_dialogue_2 = buffer.readUShort();
- else if (opCode == 93)
- equipped_model_female_dialogue_2 = buffer.readUShort();
- else if (opCode == 95)
- rotation_z = 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)
- model_scale_x = buffer.readUShort();
- else if (opCode == 111)
- model_scale_y = buffer.readUShort();
- else if (opCode == 112)
- model_scale_z = buffer.readUShort();
- else if (opCode == 113)
- ambient = buffer.readSignedByte();
- else if (opCode == 114)
- contrast = buffer.readSignedByte();
- else if (opCode == 115)
- team = buffer.readUnsignedByte();
- else if (opCode == 139) {
- unnoted_item_id = buffer.readUShort(); // un-noted id
- } else if (opCode == 140) {
- noted_item_id = buffer.readUShort(); // noted id
- } else if (opCode == 148) {
- placeHolderId = buffer.readUShort(); // placeholder id
- } else if (opCode == 149) {
- placeHolderTemplate = buffer.readUShort(); // placeholder template
- }
- } while (true);
- }
- /** Animation **/
- private void decode(Buffer buffer) {
- while(true) {
- final int opcode = buffer.readUByte();
- if (opcode == 0) {
- break;
- } else if (opcode == 1) {
- frameCount = buffer.readUShort();
- primaryFrames = new int[frameCount];
- secondaryFrames = new int[frameCount];
- durations = new int[frameCount];
- for (int i = 0; i < frameCount; i++) {
- durations[i] = buffer.readUShort();
- }
- for (int i = 0; i < frameCount; i++) {
- primaryFrames[i] = buffer.readUShort();
- secondaryFrames[i] = -1;
- }
- for (int i = 0; i < frameCount; i++) {
- primaryFrames[i] += buffer.readUShort() << 16;
- }
- } else if (opcode == 2) {
- loopOffset = buffer.readUShort();
- } else if (opcode == 3) {
- int len = buffer.readUByte();
- interleaveOrder = new int[len + 1];
- for (int i = 0; i < len; i++) {
- interleaveOrder[i] = buffer.readUByte();
- }
- interleaveOrder[len] = 9999999;
- } else if (opcode == 4) {
- stretches = true;
- } else if (opcode == 5) {
- forcedPriority = buffer.readUByte();
- } else if (opcode == 6) {
- playerOffhand = buffer.readUShort();
- } else if (opcode == 7) {
- playerMainhand = buffer.readUShort();
- } else if (opcode == 8) {
- maximumLoops = buffer.readUByte();
- } else if (opcode == 9) {
- animatingPrecedence = buffer.readUByte();
- } else if (opcode == 10) {
- priority = buffer.readUByte();
- } else if (opcode == 11) {
- replayMode = buffer.readUByte();
- } else if (opcode == 12) {
- int len = buffer.readUByte();
- for (int i = 0; i < len; i++) {
- buffer.readUShort();
- }
- for (int i = 0; i < len; i++) {
- buffer.readUShort();
- }
- } else if (opcode == 13) {
- int len = buffer.readUByte();
- for (int i = 0; i < len; i++) {
- buffer.readTriByte();
- }
- }
- }
- if (frameCount == 0) {
- frameCount = 1;
- primaryFrames = new int[1];
- primaryFrames[0] = -1;
- secondaryFrames = new int[1];
- secondaryFrames[0] = -1;
- durations = new int[1];
- durations[0] = -1;
- }
- if (animatingPrecedence == -1) {
- animatingPrecedence = (interleaveOrder == null) ? 0 : 2;
- }
- if (priority == -1) {
- priority = (interleaveOrder == null) ? 0 : 2;
- }
- }
- /**
- * Dumps animations
- */
- private void decode(Buffer buffer) {
- while(true) {
- final int opcode = buffer.readUByte();
- if (opcode == 0) {
- break;
- } else if (opcode == 1) {
- frameCount = buffer.readUShort();
- primaryFrames = new int[frameCount];
- secondaryFrames = new int[frameCount];
- durations = new int[frameCount];
- for (int i = 0; i < frameCount; i++) {
- durations[i] = buffer.readUShort();
- }
- for (int i = 0; i < frameCount; i++) {
- primaryFrames[i] = buffer.readUShort();
- secondaryFrames[i] = -1;
- }
- for (int i = 0; i < frameCount; i++) {
- primaryFrames[i] += buffer.readUShort() << 16;
- }
- } else if (opcode == 2) {
- loopOffset = buffer.readUShort();
- } else if (opcode == 3) {
- int len = buffer.readUByte();
- interleaveOrder = new int[len + 1];
- for (int i = 0; i < len; i++) {
- interleaveOrder[i] = buffer.readUByte();
- }
- interleaveOrder[len] = 9999999;
- } else if (opcode == 4) {
- stretches = true;
- } else if (opcode == 5) {
- forcedPriority = buffer.readUByte();
- } else if (opcode == 6) {
- playerOffhand = buffer.readUShort();
- } else if (opcode == 7) {
- playerMainhand = buffer.readUShort();
- } else if (opcode == 8) {
- maximumLoops = buffer.readUByte();
- } else if (opcode == 9) {
- animatingPrecedence = buffer.readUByte();
- } else if (opcode == 10) {
- priority = buffer.readUByte();
- } else if (opcode == 11) {
- replayMode = buffer.readUByte();
- } else if (opcode == 12) {
- int len = buffer.readUByte();
- for (int i = 0; i < len; i++) {
- buffer.readUShort();
- }
- for (int i = 0; i < len; i++) {
- buffer.readUShort();
- }
- } else if (opcode == 13) {
- int len = buffer.readUByte();
- for (int i = 0; i < len; i++) {
- buffer.readTriByte();
- }
- }
- }
- if (frameCount == 0) {
- frameCount = 1;
- primaryFrames = new int[1];
- primaryFrames[0] = -1;
- secondaryFrames = new int[1];
- secondaryFrames[0] = -1;
- durations = new int[1];
- durations[0] = -1;
- }
- if (animatingPrecedence == -1) {
- animatingPrecedence = (interleaveOrder == null) ? 0 : 2;
- }
- if (priority == -1) {
- priority = (interleaveOrder == null) ? 0 : 2;
- }
- }
- /*Floor / Underlay (Zion)*
- private void readValuesUnderlay(ByteBuffer buffer) {
- for (;;) {
- int opcode = buffer.get();
- if (opcode == 0) {
- break;
- } else if (opcode == 1) {
- rgb = ((buffer.get() & 0xff) << 16) + ((buffer.get() & 0xff) << 8) + (buffer.get() & 0xff);
- } else {
- System.out.println("Error unrecognised underlay code: " + opcode);
- }
- }
- }
- private void readValuesOverlay(ByteBuffer buffer) {
- for (;;) {
- int opcode = buffer.get();
- if (opcode == 0) {
- break;
- } else if (opcode == 1) {
- rgb = ((buffer.get() & 0xff) << 16) + ((buffer.get() & 0xff) << 8) + (buffer.get() & 0xff);
- } else if (opcode == 2) {
- texture = buffer.get() & 0xff;
- } else if (opcode == 5) {
- occlude = false;
- } else if (opcode == 7) {
- anotherRgb = ((buffer.get() & 0xff) << 16) + ((buffer.get() & 0xff) << 8) + (buffer.get() & 0xff);
- } else {
- System.out.println("Error unrecognised overlay code: " + opcode);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement