Jump to content
Existing user? Sign In

Sign In



Sign Up

Packing 179 data/readvalues.


Alching

Recommended Posts

I'm packing 179 data into Ascend. I know how to pack the data but I'm completely clueless when it comes to readvalues, if anyone can help me fix those I'd greatly apprecaite it!

My discord is : a n d y#3230

Edited by A n d y
Link to comment
Share on other sites

  • 2 months later...
Guest bobby

Here a list of the ReadValue's for 179 Data pack



Animation Read Value's

 

import java.util.Arrays;

public final class Animation {

	public static void unpackConfig(StreamLoader archive) {
		Buffer buffer = new Buffer(archive.getDataForName("seq.dat"));

		final int length = buffer.readUShort();

		if (animations == null) {
			animations = new Animation[length];
		}

		for (int i = 0; i < length; i++) {
			if (animations[i] == null) {
				animations[i] = new Animation();
			}

			animations[i].decode(buffer);
		}
	}


	public int method258(int i) {
		int j = durations[i];
		if (j == 0) {
			Frame class36 = Frame.method531(primaryFrames[i] );
			if (class36 != null)
				j = durations[i] = class36.anInt636;
		}
		if (j == 0)
			j = 1;
		return j;
	}

	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;
				}

//				for (int i = 0; i < frameCount; i++) { // walking works but godswords break
//					primaryFrames[i] = buffer.readInt();
//					secondaryFrames[i] = -1;
//				}

//                for (int i = 0; i < frameCount; i++) { // walking breaks godswords work
//                    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) {
				maxLoops = buffer.readUByte();
			} else if (opcode == 9) {
				animatingPrecedence = buffer.readUByte();
			} else if (opcode == 10) {
				walkingPrecedence = 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.read24Int();
				}
			}
		}

		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 (walkingPrecedence == -1) {
			walkingPrecedence = (interleaveOrder == null) ? 0 : 2;
		}
	}

	private Animation() {
		animatingPrecedence = -1; //Stops character from moving
		walkingPrecedence = -1;
		replayMode = 1;
	}

	public static Animation animations[];
	public int frameCount;
	public int primaryFrames[];
	public int secondaryFrames[];
	public int[] durations;
	public int loopOffset = -1;
	public int interleaveOrder[];
	public boolean stretches;
	public int forcedPriority = 5;
	public int playerOffhand = -1;
	public int playerMainhand = -1;
	public int maxLoops = 99;
	public int animatingPrecedence;
	public int walkingPrecedence;
	public int replayMode;

}

Buffer Read value's

 

package io.battlerune;

import java.math.BigInteger;

public final class Buffer extends Cacheable {

	public static Buffer create() {
		synchronized (nodeList) {
			Buffer stream = null;
			if (anInt1412 > 0) {
				anInt1412--;
				stream = (Buffer) nodeList.popHead();
			}
			if (stream != null) {
				stream.currentOffset = 0;
				return stream;
			}
		}
		Buffer stream_1 = new Buffer();
		stream_1.currentOffset = 0;
		stream_1.buffer = new byte[5000];
		return stream_1;
	}

	public String readStringNew() {
		int i = currentOffset;
		while (buffer[currentOffset++] != 0)
			;
		return new String(buffer, i, currentOffset - i - 1);
	}

	public int readShort2() {
		currentOffset += 2;
		int i = ((buffer[currentOffset - 2] & 0xff) << 8) + (buffer[currentOffset - 1] & 0xff);
		if (i > 60000)
			i = -65535 + i;
		return i;

	}

	final int v(int i) {
		currentOffset += 3;
		return (0xff & buffer[currentOffset - 3] << 16) + (0xff & buffer[currentOffset - 2] << 8) + (0xff & buffer[currentOffset - 1]);
	}

	private Buffer() {
	}

	public Buffer(byte abyte0[]) {
		buffer = abyte0;
		currentOffset = 0;
	}

	public int readUSmart2() {
		int baseVal = 0;
		int lastVal = 0;
		while ((lastVal = method422()) == 32767) {
			baseVal += 32767;
		}
		return baseVal + lastVal;
	}

	public String readNewString() {
		int i = currentOffset;
		while (buffer[currentOffset++] != 0)
			;
		return new String(buffer, i, currentOffset - i - 1);
	}

	public void writeOpcode(int i) {
		// System.out.println("Frame: " + i);
		buffer[currentOffset++] = (byte) (i + encryption.getNextKey());
	}

	public void writeByte(int i) {
		buffer[currentOffset++] = (byte) i;
	}

	public void writeShort(int i) {
		buffer[currentOffset++] = (byte) (i >> 8);
		buffer[currentOffset++] = (byte) i;
	}

	public void writeDWordBigEndian(int i) {
		buffer[currentOffset++] = (byte) (i >> 16);
		buffer[currentOffset++] = (byte) (i >> 8);
		buffer[currentOffset++] = (byte) i;
	}

	public void writeDWord(int i) {
		buffer[currentOffset++] = (byte) (i >> 24);
		buffer[currentOffset++] = (byte) (i >> 16);
		buffer[currentOffset++] = (byte) (i >> 8);
		buffer[currentOffset++] = (byte) i;
	}

	public void method403(int j) {
		buffer[currentOffset++] = (byte) j;
		buffer[currentOffset++] = (byte) (j >> 8);
		buffer[currentOffset++] = (byte) (j >> 16);
		buffer[currentOffset++] = (byte) (j >> 24);
	}

	public void writeQWord(long l) {
		try {
			buffer[currentOffset++] = (byte) (int) (l >> 56);
			buffer[currentOffset++] = (byte) (int) (l >> 48);
			buffer[currentOffset++] = (byte) (int) (l >> 40);
			buffer[currentOffset++] = (byte) (int) (l >> 32);
			buffer[currentOffset++] = (byte) (int) (l >> 24);
			buffer[currentOffset++] = (byte) (int) (l >> 16);
			buffer[currentOffset++] = (byte) (int) (l >> 8);
			buffer[currentOffset++] = (byte) (int) l;
		} catch (RuntimeException runtimeexception) {
			Utility.reporterror("14395, " + 5 + ", " + l + ", " + runtimeexception.toString());
			throw new RuntimeException();
		}
	}

	public void writeString(String s) {
		// s.getBytes(0, s.length(), buffer, currentOffset); //deprecated
		System.arraycopy(s.getBytes(), 0, buffer, currentOffset, s.length());
		currentOffset += s.length();
		buffer[currentOffset++] = 10;
	}

	public void writeBytes(byte abyte0[], int i, int j) {
		for (int k = j; k < j + i; k++)
			buffer[currentOffset++] = abyte0[k];
	}

	public void writeBytes(int i) {
		buffer[currentOffset - i - 1] = (byte) i;
	}

	public int readUByte() {
		return buffer[currentOffset++] & 0xff;
	}

	public byte readSignedByte() {
		return buffer[currentOffset++];
	}

	public int readUShort() {
		currentOffset += 2;
		return ((buffer[currentOffset - 2] & 0xff) << 8) + (buffer[currentOffset - 1] & 0xff);
	}

	public int readSignedWord() {
		currentOffset += 2;
		int i = ((buffer[currentOffset - 2] & 0xff) << 8) + (buffer[currentOffset - 1] & 0xff);
		if (i > 32767)
			i -= 0x10000;
		return i;
	}

	public int read24Int() {
		currentOffset += 3;
		return ((buffer[currentOffset - 3] & 0xff) << 16) + ((buffer[currentOffset - 2] & 0xff) << 8) + (buffer[currentOffset - 1] & 0xff);
	}

	public int readInt() {
		currentOffset += 4;
		return ((buffer[currentOffset - 4] & 0xff) << 24) + ((buffer[currentOffset - 3] & 0xff) << 16) + ((buffer[currentOffset - 2] & 0xff) << 8) + (buffer[currentOffset - 1] & 0xff);
	}

	public long readLong() {
		long l = (long) readInt() & 0xffffffffL;
		long l1 = (long) readInt() & 0xffffffffL;
		return (l << 32) + l1;
	}

	public String readString() {
		int i = currentOffset;
		while (buffer[currentOffset++] != 10)
			;
		return new String(buffer, i, currentOffset - i - 1);
	}

	public byte[] readBytes() {
		int i = currentOffset;
		while (buffer[currentOffset++] != 10)
			;
		byte abyte0[] = new byte[currentOffset - i - 1];
		System.arraycopy(buffer, i, abyte0, i - i, currentOffset - 1 - i);
		return abyte0;
	}

	public void readBytes(int i, int j, byte abyte0[]) {
		for (int l = j; l < j + i; l++)
			abyte0[l] = buffer[currentOffset++];
	}

	public void initBitAccess() {
		bitPosition = currentOffset * 8;
	}

	public int readBits(int i) {
		int k = bitPosition >> 3;
		int l = 8 - (bitPosition & 7);
		int i1 = 0;
		bitPosition += i;
		for (; i > l; l = 8) {
			i1 += (buffer[k++] & anIntArray1409[l]) << i - l;
			i -= l;
		}
		if (i == l)
			i1 += buffer[k] & anIntArray1409[l];
		else
			i1 += buffer[k] >> l - i & anIntArray1409[i];
		return i1;
	}

	public void finishBitAccess() {
		currentOffset = (bitPosition + 7) / 8;
	}

	public int method421() {
		int i = buffer[currentOffset] & 0xff;
		if (i < 128)
			return readUByte() - 64;
		else
			return readUShort() - 49152;
	}

	public int method422() {
		int i = buffer[currentOffset] & 0xff;
		if (i < 128)
			return readUByte();
		else
			return readUShort() - 32768;
	}

	public void encodeRSA(BigInteger exponent, BigInteger modulus) {
		int i = currentOffset;
		currentOffset = 0;
		byte abyte0[] = new byte[i];
		readBytes(i, 0, abyte0);

		byte rsa[] = abyte0;

		if (Configuration.ENABLE_RSA) {
			rsa = new BigInteger(abyte0).modPow(exponent, modulus).toByteArray();
		}
		currentOffset = 0;
		writeByte(rsa.length);
		writeBytes(rsa, rsa.length, 0);
	}

	public void writeNegatedByte(int i) {
		buffer[currentOffset++] = (byte) (-i);
	}

	public void method425(int j) {
		buffer[currentOffset++] = (byte) (128 - j);
	}

	public int readUByteA() {
		return buffer[currentOffset++] - 128 & 0xff;
	}

	public int readNegUByte() {
		return -buffer[currentOffset++] & 0xff;
	}

	public int readUByteS() {
		return 128 - buffer[currentOffset++] & 0xff;
	}

	public byte method429() {
		return (byte) (-buffer[currentOffset++]);
	}

	public byte method430() {
		return (byte) (128 - buffer[currentOffset++]);
	}

	public void writeLEShort(int i) {
		buffer[currentOffset++] = (byte) i;
		buffer[currentOffset++] = (byte) (i >> 8);
	}

	public void writeShortA(int j) {
		buffer[currentOffset++] = (byte) (j >> 8);
		buffer[currentOffset++] = (byte) (j + 128);
	}

	public void writeLEShortA(int j) {
		buffer[currentOffset++] = (byte) (j + 128);
		buffer[currentOffset++] = (byte) (j >> 8);
	}

	public int readLEUShort() {
		currentOffset += 2;
		return ((buffer[currentOffset - 1] & 0xff) << 8) + (buffer[currentOffset - 2] & 0xff);
	}

	public int readUShortA() {
		currentOffset += 2;
		return ((buffer[currentOffset - 2] & 0xff) << 8) + (buffer[currentOffset - 1] - 128 & 0xff);
	}

	public int readLEUShortA() {
		currentOffset += 2;
		return ((buffer[currentOffset - 1] & 0xff) << 8) + (buffer[currentOffset - 2] - 128 & 0xff);
	}

	public int readLEShort() {
		currentOffset += 2;
		int j = ((buffer[currentOffset - 1] & 0xff) << 8) + (buffer[currentOffset - 2] & 0xff);
		if (j > 32767)
			j -= 0x10000;
		return j;
	}

	public int method438() {
		currentOffset += 2;
		int j = ((buffer[currentOffset - 1] & 0xff) << 8) + (buffer[currentOffset - 2] - 128 & 0xff);
		if (j > 32767)
			j -= 0x10000;
		return j;
	}

	public int method439() {
		currentOffset += 4;
		return ((buffer[currentOffset - 2] & 0xff) << 24) + ((buffer[currentOffset - 1] & 0xff) << 16) + ((buffer[currentOffset - 4] & 0xff) << 8) + (buffer[currentOffset - 3] & 0xff);
	}

	public int method440() {
		currentOffset += 4;
		return ((buffer[currentOffset - 3] & 0xff) << 24) + ((buffer[currentOffset - 4] & 0xff) << 16) + ((buffer[currentOffset - 1] & 0xff) << 8) + (buffer[currentOffset - 2] & 0xff);
	}

	public void method441(int i, byte abyte0[], int j) {
		for (int k = (i + j) - 1; k >= i; k--)
			buffer[currentOffset++] = (byte) (abyte0[k] + 128);

	}

	public void readReverseData(int i, int j, byte abyte0[]) {
		for (int k = (j + i) - 1; k >= j; k--)
			abyte0[k] = buffer[currentOffset++];

	}

	public byte buffer[];
	public int currentOffset;
	public int bitPosition;
	private static final int[] anIntArray1409 = {0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 0x1ffff, 0x3ffff, 0x7ffff, 0xfffff, 0x1fffff, 0x3fffff, 0x7fffff, 0xffffff, 0x1ffffff, 0x3ffffff, 0x7ffffff, 0xfffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff, -1};
	public ISAACRandomGen encryption;
	private static int anInt1412;
	private static final Deque nodeList = new Deque();
}

FloorDefinition's Read value's


import java.nio.ByteBuffer;
import java.util.logging.Logger;

public class FloorDefinition {

	/**
	 * The single logger for this class.
	 */
	private static final Logger LOGGER = Logger.getLogger(ItemDefinition.class.getName());

	public static FloorDefinition[] overlays;
	public static FloorDefinition[] underlays;

	public int texture;
	public int rgb;
	public boolean occlude;
	public int anotherRgb;

	public int hue;
	public int saturation;
	public int lumiance;

	public int anotherHue;
	public int anotherSaturation;
	public int anotherLuminance;

	public int blendHue;
	public int blendHueMultiplier;
	public int hslToRgb;

	private FloorDefinition() {
		texture = -1;
		occlude = true;
	}

	public static void unpackConfig(StreamLoader streamLoader) {
		ByteBuffer buffer = ByteBuffer.wrap(streamLoader.getDataForName("flo.dat"));
		int underlayAmount = buffer.getShort();
		underlays = new FloorDefinition[underlayAmount];

		System.out.println(String.format("Loaded: %d underlays", underlayAmount));

		for (int i = 0; i < underlayAmount; i++) {
			if (underlays[i] == null) {
				underlays[i] = new FloorDefinition();
			}
			underlays[i].readValuesUnderlay(buffer);
			underlays[i].generateHsl(true);
		}
		int overlayAmount = buffer.getShort();

		System.out.println(String.format("Loaded: %d overlays", overlayAmount));

		overlays = new FloorDefinition[overlayAmount];
		for (int i = 0; i < overlayAmount; i++) {
			if (overlays[i] == null) {
				overlays[i] = new FloorDefinition();
			}
			overlays[i].readValuesOverlay(buffer);
			overlays[i].generateHsl(false);
		}
	}

	private void generateHsl(boolean isUnderlay) {
		if (anotherRgb != -1) {
			rgbToHsl(anotherRgb);
			anotherHue = hue;
			anotherSaturation = saturation;
			anotherLuminance = lumiance;
		}
		int color = isUnderlay && Settings.SNOW ? 0xFFFFFF : rgb;
		rgbToHsl(color);
	}

	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);
			}
		}
	}

	private void rgbToHsl(int rgb) {
		double r = (rgb >> 16 & 0xff) / 256.0;
		double g = (rgb >> 8 & 0xff) / 256.0;
		double b = (rgb & 0xff) / 256.0;
		double min = r;
		if (g < min) {
			min = g;
		}
		if (b < min) {
			min = b;
		}
		double max = r;
		if (g > max) {
			max = g;
		}
		if (b > max) {
			max = b;
		}
		double h = 0.0;
		double s = 0.0;
		double l = (min + max) / 2.0;
		if (min != max) {
			if (l < 0.5) {
				s = (max - min) / (max + min);
			}
			if (l >= 0.5) {
				s = (max - min) / (2.0 - max - min);
			}
			if (r == max) {
				h = (g - b) / (max - min);
			} else if (g == max) {
				h = 2.0 + (b - r) / (max - min);
			} else if (b == max) {
				h = 4.0 + (r - g) / (max - min);
			}
		}
		h /= 6.0;
		hue = (int) (h * 256.0);
		saturation = (int) (s * 256.0);
		lumiance = (int) (l * 256.0);
		if (saturation < 0) {
			saturation = 0;
		} else if (saturation > 255) {
			saturation = 255;
		}
		if (lumiance < 0) {
			lumiance = 0;
		} else if (lumiance > 255) {
			lumiance = 255;
		}
		if (l > 0.5) {
			blendHueMultiplier = (int) ((1.0 - l) * s * 512.0);
		} else {
			blendHueMultiplier = (int) (l * s * 512.0);
		}
		if (blendHueMultiplier < 1) {
			blendHueMultiplier = 1;
		}
		blendHue = (int) (h * blendHueMultiplier);
		hslToRgb = hslToRgb(hue, saturation, lumiance);
	}

	private final static int hslToRgb(int h, int s, int l) {
		if (l > 179) {
			s /= 2;
		}
		if (l > 192) {
			s /= 2;
		}
		if (l > 217) {
			s /= 2;
		}
		if (l > 243) {
			s /= 2;
		}
		return (h / 4 << 10) + (s / 32 << 7) + l / 2;
	}
}


Graphic Read Value's

 


public final class Graphic {

	public static void unpackConfig(StreamLoader archive) {
		Buffer buffer = new Buffer(archive.getDataForName("spotanim.dat"));
		int length = buffer.readUShort();

		System.out.println(String.format("Loaded: %d gfx", length));

		if (cache == null) {
			cache = new Graphic[length];
		}

		for (int i = 0; i < length; i++) {
			if (cache[i] == null) {
				cache[i] = new Graphic();
			}
			cache[i].id = i;
			cache[i].decode(buffer);
		}

		if (buffer.currentOffset != buffer.buffer.length) {
			System.out.println("gfx mismatch! " + buffer.currentOffset + " " + buffer.buffer.length);
		}
	}

	private void decode(Buffer buffer) {
		while(true) {
			final int opcode = buffer.readUByte();

			if (opcode == 0) {
				return;
			} else if (opcode == 1) {
				modelId = buffer.readUShort();
			} else if (opcode == 2) {
				animationId = buffer.readUShort();

				if (Animation.animations != null) {
                    aAnimation_407 = Animation.animations[animationId];
                }
			} else if (opcode == 4) {
				resizeX = buffer.readUShort();
			} else if (opcode == 5) {
				resizeY = buffer.readUShort();
			} else if (opcode == 6) {
				rotation = buffer.readUShort();
			} else if (opcode == 7) {
				ambience = buffer.readUByte();
			} else if (opcode == 8) {
				contrast = buffer.readUByte();
			} else if (opcode == 40) {
				int len = buffer.readUByte();
				colorToFind = new int[len];
				colorToReplace = new int[len];
				for (int i = 0; i < len; i++) {
					colorToFind[i] = buffer.readUShort();
					colorToReplace[i] = buffer.readUShort();
				}
			} else if (opcode == 41) { // re-texture
				int len = buffer.readUByte();

				for (int i = 0; i < len; i++) {
					buffer.readUShort();
					buffer.readUShort();
				}
			} else {
				System.out.println("gfx invalid opcode: " + opcode);
			}
		}
	}

	public Model getModel() {
		Model model = (Model) aMRUNodes_415.get(id);
		if (model != null)
			return model;
		model = Model.getModel(modelId);
		if (model == null)
			return null;
		for (int i = 0; i < 6; i++)
			if (colorToFind[0] != 0)
				model.recolor(colorToFind[i], colorToReplace[i]);

		aMRUNodes_415.put(model, id);
		return model;
	}

	private Graphic() {
		animationId = -1;
		colorToFind = new int[6];
		colorToReplace = new int[6];
		resizeX = 128;
		resizeY = 128;
	}

	public static Graphic cache[];
	private int id;
	public int modelId;
	private int animationId;
	public Animation aAnimation_407;
	private int[] colorToFind;
	private int[] colorToReplace;
	public int resizeX;
	public int resizeY;
	public int rotation;
	public int ambience;
	public int contrast;
	public static Cache aMRUNodes_415 = new Cache(30);

}

IdentityKit Read value's

 


public final class IdentityKit {

	public static int length;
	public static IdentityKit kits[];
	public int bodyPartId = -1;
	private int[] bodyModels;
	private final int[] originalColors = new int[6];
	private final int[] replacementColors = new int[6];
	private final int[] headModels = {-1, -1, -1, -1, -1};
	public boolean validStyle;

	private IdentityKit() {
	}

	public static void init(StreamLoader archive) {
		Buffer buffer = new Buffer(archive.getDataForName("idk.dat"));
		length = buffer.readUShort();

		System.out.println(String.format("Loaded: %d identity kits", length));

		if (kits == null) {
			kits = new IdentityKit[length];
		}

		for (int index = 0; index < length; index++) {
			if (kits[index] == null) {
				kits[index] = new IdentityKit();
			}

			IdentityKit kit = kits[index];
			kit.decode(buffer);
			kit.originalColors[0] = 55232;
			kit.replacementColors[0] = 6798;
		}
	}

	private void decode(Buffer buffer) {
		while(true) {
			final int opcode = buffer.readUByte();

			if (opcode == 0) {
				break;
			}

			if (opcode == 1) {
				bodyPartId = buffer.readUByte();
			} else if (opcode == 2) {
				final int length = buffer.readUByte();
				bodyModels = new int[length];
				for (int i = 0; i < length; i++) {
					bodyModels[i] = buffer.readUShort();
				}
			} else if (opcode == 3) {
				validStyle = true;
			} else if (opcode >= 40 && opcode < 50) {
				originalColors[opcode - 40] = buffer.readUShort();
			} else if (opcode >= 50 && opcode < 60) {
				replacementColors[opcode - 50] = buffer.readUShort();
			} else if (opcode >= 60 && opcode < 70) {
				headModels[opcode - 60] = buffer.readUShort();
			} else {
				System.out.println("Error unrecognised config code: " + opcode);
			}
		}
	}

	public boolean bodyLoaded() {
		if (bodyModels == null) {
			return true;
		}
		boolean ready = true;
		for (int part = 0; part < bodyModels.length; part++) {
			if (!Model.isCached(bodyModels[part]))
				ready = false;
		}
		return ready;
	}

	public Model method538() {
		if (bodyModels == null) {
			return null;
		}

		Model models[] = new Model[bodyModels.length];

		for (int i = 0; i < bodyModels.length; i++) {
			models[i] = Model.getModel(bodyModels[i]);
		}

		Model model;
		if (models.length == 1) {
			model = models[0];
		} else {
			model = new Model(models.length, models);
		}

		for (int part = 0; part < 6; part++) {
			if (originalColors[part] == 0) {
				break;
			}
			model.recolor(originalColors[part], replacementColors[part]);
		}

		return model;
	}

	public boolean headLoaded() {
		boolean ready = true;
		for (int i = 0; i < 5; i++) {
			if (headModels[i] != -1 && !Model.isCached(headModels[i]))
				ready = false;
		}
		return ready;
	}

	public Model headModel() {
		Model models[] = new Model[5];
		int count = 0;
		for (int i = 0; i < 5; i++) {
			if (headModels[i] != -1) {
				models[count++] = Model.getModel(headModels[i]);
			}
		}

		Model model = new Model(count, models);
		for (int i = 0; i < 6; i++) {
			if (originalColors[i] == 0) {
				break;
			}
			model.recolor(originalColors[i], replacementColors[i]);
		}

		return model;
	}

}

ItemDefinition Read value's

 

package io.battlerune;

public final class ItemDefinition {

    public static void nullLoader() {
        mruNodes2 = null;
        mruNodes1 = null;
        offsets = null;
        cache = null;
        dataBuf = null;
    }

    public boolean method192(int j) {
        int k = primaryMaleHeadPiece;
        int l = secondaryMaleHeadPiece;
        if (j == 1) {
            k = primaryFemaleHeadPiece;
            l = secondaryFemaleHeadPiece;
        }
        if (k == -1)
            return true;
        boolean flag = true;
        if (!Model.isCached(k))
            flag = false;
        if (l != -1 && !Model.isCached(l))
            flag = false;
        return flag;
    }

    public static void dumpList() {
        /*JsonArray array = new JsonArray();

        for (int index = 0; index < totalItems; index++) {
            try {
                ItemDefinition definition = lookup(index);

                if (definition.name == null || definition.name.equals("null") || definition.name.isEmpty())
                    continue;

                JsonObject object = new JsonObject();
                array.add(object);

                object.addProperty("id", definition.id);
                object.addProperty("name", definition.name);
                object.addProperty("examine", definition.description);

                if (definition.stackable) {
                    object.addProperty("stackable", true);
                }
                if (definition.itemActions != null) {
                    for (int idx = 0; idx < definition.itemActions.length; idx++) {
                        String action = definition.itemActions[idx];
                        if (action != null) {
                            if (action.contains("Wear") || action.contains("Wield")) {
                                object.addProperty("equipable", true);
                            }
                            if (action.contains("Destroy")) {
                                object.addProperty("destroyable", true);
                            }
                        }
                    }
                }
                if (definition.certTemplateID == -1 && definition.certID != -1) {
                    object.addProperty("noted-id", definition.certID);
                }
                if (definition.certTemplateID != -1 && definition.certID != definition.id) {
                    object.addProperty("unnoted-id", definition.certID);
                }
                if (definition.value > 1) {
                    object.addProperty("base-value", definition.value);
                }
                if (definition.itemActions != null) {
                    for (int idx = 0; idx < definition.itemActions.length; idx++) {
                        String action = definition.itemActions[idx];
                        if (action != null) {
                            if (action.contains("Wield")) {
                                object.addProperty("equipment-type", "WEAPON");
                            }
                            break;
                        }
                    }
                }

            } catch (Exception e) {
                System.out.println(index);
                e.printStackTrace();
            }
        }

        try {
            Files.write(Paths.get("./item_dump.json"), new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create().toJson(array).getBytes());
        } catch (IOException e) {
            e.printStackTrace();
        }*/
    }

    public static void init(StreamLoader archive) {
        dataBuf = new Buffer(archive.getDataForName("obj.dat"));
        Buffer metaBuf = new Buffer(archive.getDataForName("obj.idx"));
        totalItems = metaBuf.readUShort();

        System.out.println(String.format("Loaded: %d items", totalItems));

        offsets = new int[totalItems];
        int offset = 2;
        for (int i = 0; i < totalItems; i++) {
            offsets[i] = offset;
            offset += metaBuf.readUShort();
        }

        cache = new ItemDefinition[10];

        for (int i = 0; i < 10; i++) {
            cache[i] = new ItemDefinition();
        }

    }

    Model method194(int j) {
        int k = primaryMaleHeadPiece;
        int l = secondaryMaleHeadPiece;
        if (j == 1) {
            k = primaryFemaleHeadPiece;
            l = secondaryFemaleHeadPiece;
        }
        if (k == -1)
            return null;
        Model model = Model.getModel(k);
        if (l != -1) {
            Model model_1 = Model.getModel(l);
            Model aclass30_sub2_sub4_sub6s[] = {model, model_1};
            model = new Model(2, aclass30_sub2_sub4_sub6s);
        }
        if (modifiedModelColors != null) {
            for (int i1 = 0; i1 < modifiedModelColors.length; i1++)
                model.recolor(modifiedModelColors[i1], originalModelColors[i1]);

        }
        return model;
    }

    public boolean method195(int j) {
        int k = primaryMaleModel;
        int l = secondaryMaleModel;
        int i1 = tertiaryMaleEquipmentModel;
        if (j == 1) {
            k = primaryFemaleModel;
            l = secondaryFemaleModel;
            i1 = tertiaryFemaleEquipmentModel;
        }
        if (k == -1)
            return true;
        boolean flag = true;
        if (!Model.isCached(k))
            flag = false;
        if (l != -1 && !Model.isCached(l))
            flag = false;
        if (i1 != -1 && !Model.isCached(i1))
            flag = false;
        return flag;
    }

    Model method196(int i) {
        int j = primaryMaleModel;
        int k = secondaryMaleModel;
        int l = tertiaryMaleEquipmentModel;
        if (i == 1) {
            j = primaryFemaleModel;
            k = secondaryFemaleModel;
            l = tertiaryFemaleEquipmentModel;
        }
        if (j == -1)
            return null;
        Model model = Model.getModel(j);
        if (k != -1)
            if (l != -1) {
                Model model_1 = Model.getModel(k);
                Model model_3 = Model.getModel(l);
                Model aclass30_sub2_sub4_sub6_1s[] = {model, model_1, model_3};
                model = new Model(3, aclass30_sub2_sub4_sub6_1s);
            } else {
                Model model_2 = Model.getModel(k);
                Model aclass30_sub2_sub4_sub6s[] = {model, model_2};
                model = new Model(2, aclass30_sub2_sub4_sub6s);
            }
        if (i == 0 && maleTranslation != 0)
            model.method475(0, maleTranslation, 0);
        if (i == 1 && femaleTranslation != 0)
            model.method475(0, femaleTranslation, 0);
        if (modifiedModelColors != null) {
            for (int i1 = 0; i1 < modifiedModelColors.length; i1++)
                model.recolor(modifiedModelColors[i1], originalModelColors[i1]);

        }
        return model;
    }

    private void setDefaults() {
        modelId = 0;
        name = "null";
        description = "";
        modifiedModelColors = null;
        originalModelColors = null;
        spriteScale = 2000;
        spritePitch = 0;
        spriteCameraRoll = 0;
        spriteCameraYaw = 0;
        spriteTranslateX = 0;
        spriteTranslateY = 0;
        stackable = false;
        value = 1;
        membersObject = false;
        groundActions = new String[]{null, null, "Take", null, null};;
        itemActions = new String[]{null, null, null, null, "Drop"};
        primaryMaleModel = -1;
        secondaryMaleModel = -1;
        maleTranslation = 0;
        primaryFemaleModel = -1;
        secondaryFemaleModel = -1;
        femaleTranslation = 0;
        tertiaryMaleEquipmentModel = -1;
        tertiaryFemaleEquipmentModel = -1;
        primaryMaleHeadPiece = -1;
        secondaryMaleHeadPiece = -1;
        primaryFemaleHeadPiece = -1;
        secondaryFemaleHeadPiece = -1;
        stackIds = null;
        stackAmounts = null;
        certID = -1;
        certTemplateID = -1;
        groundScaleX = 128;
        groundScaleY = 128;
        groundScaleZ = 128;
        ambience = 0;
        diffusion = 0;
        team = 0;
    }

    public static ItemDefinition lookup(int id) {
        for (int i = 0; i < 10; i++) {
            if (cache[i].id == id) {
                return cache[i];
            }
        }

        cacheIndex = (cacheIndex + 1) % 10;
        ItemDefinition itemDef = cache[cacheIndex];
        dataBuf.currentOffset = offsets[id];
        itemDef.id = id;
        itemDef.setDefaults();
        itemDef.decode(dataBuf);

        switch(id) {

        }

        if (itemDef.certTemplateID != -1) {
            itemDef.toNote();
        }
        return itemDef;
    }

    private void toNote() {
        ItemDefinition noted = lookup(certTemplateID);
        modelId = noted.modelId;
        spriteScale = noted.spriteScale;
        spritePitch = noted.spritePitch;
        spriteCameraRoll = noted.spriteCameraRoll;

        spriteCameraYaw = noted.spriteCameraYaw;
        spriteTranslateX = noted.spriteTranslateX;
        spriteTranslateY = noted.spriteTranslateY;
        modifiedModelColors = noted.modifiedModelColors;
        originalModelColors = noted.originalModelColors;
        ItemDefinition unnoted = lookup(certID);

        if (unnoted == null || unnoted.name == null) {
            return;
        }

        name = unnoted.name;
        membersObject = unnoted.membersObject;
        value = unnoted.value;
        String aOrAn = "a";
        char vowelChar = unnoted.name.charAt(0);
        if (vowelChar == 'A' || vowelChar == 'E' || vowelChar == 'I' || vowelChar == 'O' || vowelChar == 'U') {
            aOrAn = "an";
        }

        description = "Swap this note at any bank for " + aOrAn + " " + unnoted.name + ".";
        stackable = true;
    }

    public static Sprite getSprite(int item, int amount, int k) {
        if (k == 0) {
            Sprite sprite = (Sprite) mruNodes1.get(item);
            if (sprite != null && sprite.resizeHeight != amount && sprite.resizeHeight != -1) {

                sprite.unlink();
                sprite = null;
            }
            if (sprite != null)
                return sprite;
        }
        ItemDefinition itemDef = lookup(item);
        if (itemDef.stackIds == null)
            amount = -1;
        if (amount > 1) {
            int i1 = -1;
            for (int j1 = 0; j1 < 10; j1++)
                if (amount >= itemDef.stackAmounts[j1] && itemDef.stackAmounts[j1] != 0)
                    i1 = itemDef.stackIds[j1];

            if (i1 != -1)
                itemDef = lookup(i1);
        }
        Model model = itemDef.method201(1);
        if (model == null)
            return null;
        Sprite sprite = null;
        if (itemDef.certTemplateID != -1) {
            sprite = getSprite(itemDef.certID, 10, -1);
            if (sprite == null)
                return null;
        }
        Sprite enabledSprite = new Sprite(32, 32);
        int k1 = Rasterizer.textureInt1;
        int l1 = Rasterizer.textureInt2;
        int ai[] = Rasterizer.anIntArray1472;
        int ai1[] = Raster.pixels;
        int i2 = Raster.width;
        int j2 = Raster.height;
        int k2 = Raster.topX;
        int l2 = Raster.bottomX;
        int i3 = Raster.topY;
        int j3 = Raster.bottomY;
        Rasterizer.aBoolean1464 = false;
        Raster.initDrawingArea(enabledSprite.raster, 32, 32);
        Raster.fillRectangle(0, 0, 32, 32, 0);
        Rasterizer.method364();
        int k3 = itemDef.spriteScale;
        if (k == -1)
            k3 = (int) ((double) k3 * 1.5D);
        if (k > 0)
            k3 = (int) ((double) k3 * 1.04D);
        int l3 = Rasterizer.anIntArray1470[itemDef.spritePitch] * k3 >> 16;
        int i4 = Rasterizer.anIntArray1471[itemDef.spritePitch] * k3 >> 16;
        model.method482(itemDef.spriteCameraRoll, itemDef.spriteCameraYaw, itemDef.spritePitch, itemDef.spriteTranslateX, l3 + model.modelHeight / 2 + itemDef.spriteTranslateY, i4 + itemDef.spriteTranslateY);
        for (int i5 = 31; i5 >= 0; i5--) {
            for (int j4 = 31; j4 >= 0; j4--)
                if (enabledSprite.raster[i5 + j4 * 32] == 0)
                    if (i5 > 0 && enabledSprite.raster[(i5 - 1) + j4 * 32] > 1)
                        enabledSprite.raster[i5 + j4 * 32] = 1;
                    else if (j4 > 0 && enabledSprite.raster[i5 + (j4 - 1) * 32] > 1)
                        enabledSprite.raster[i5 + j4 * 32] = 1;
                    else if (i5 < 31 && enabledSprite.raster[i5 + 1 + j4 * 32] > 1)
                        enabledSprite.raster[i5 + j4 * 32] = 1;
                    else if (j4 < 31 && enabledSprite.raster[i5 + (j4 + 1) * 32] > 1)
                        enabledSprite.raster[i5 + j4 * 32] = 1;

        }

        if (k > 0) {
            for (int j5 = 31; j5 >= 0; j5--) {
                for (int k4 = 31; k4 >= 0; k4--)
                    if (enabledSprite.raster[j5 + k4 * 32] == 0)
                        if (j5 > 0 && enabledSprite.raster[(j5 - 1) + k4 * 32] == 1)
                            enabledSprite.raster[j5 + k4 * 32] = k;
                        else if (k4 > 0 && enabledSprite.raster[j5 + (k4 - 1) * 32] == 1)
                            enabledSprite.raster[j5 + k4 * 32] = k;
                        else if (j5 < 31 && enabledSprite.raster[j5 + 1 + k4 * 32] == 1)
                            enabledSprite.raster[j5 + k4 * 32] = k;
                        else if (k4 < 31 && enabledSprite.raster[j5 + (k4 + 1) * 32] == 1)
                            enabledSprite.raster[j5 + k4 * 32] = k;

            }

        } else if (k == 0) {
            for (int k5 = 31; k5 >= 0; k5--) {
                for (int l4 = 31; l4 >= 0; l4--)
                    if (enabledSprite.raster[k5 + l4 * 32] == 0 && k5 > 0 && l4 > 0 && enabledSprite.raster[(k5 - 1) + (l4 - 1) * 32] > 0)
                        enabledSprite.raster[k5 + l4 * 32] = 0x302020;

            }

        }
        if (itemDef.certTemplateID != -1) {
            int l5 = sprite.resizeWidth;
            int j6 = sprite.resizeHeight;
            sprite.resizeWidth = 32;
            sprite.resizeHeight = 32;
            sprite.drawSprite(0, 0);
            sprite.resizeWidth = l5;
            sprite.resizeHeight = j6;
        }
        if (k == 0)
            mruNodes1.put(enabledSprite, item);
        Raster.initDrawingArea(ai1, i2, j2);
        Raster.setDrawingArea(k2, i3, l2, j3);
        Rasterizer.textureInt1 = k1;
        Rasterizer.textureInt2 = l1;
        Rasterizer.anIntArray1472 = ai;
        Rasterizer.aBoolean1464 = true;
        if (itemDef.stackable)
            enabledSprite.resizeWidth = 33;
        else
            enabledSprite.resizeWidth = 32;
        enabledSprite.resizeHeight = amount;
        return enabledSprite;
    }

    public static Sprite getSprite(int item, int amount, int k, int zoom) {
        if (k == 0) {
            Sprite sprite = (Sprite) mruNodes1.get(item);
            if (sprite != null && sprite.resizeHeight != amount && sprite.resizeHeight != -1) {

                sprite.unlink();
                sprite = null;
            }
            if (sprite != null)
                return sprite;
        }
        ItemDefinition itemDef = lookup(item);
        if (itemDef.stackIds == null)
            amount = -1;
        if (amount > 1) {
            int i1 = -1;
            for (int j1 = 0; j1 < 10; j1++)
                if (amount >= itemDef.stackAmounts[j1] && itemDef.stackAmounts[j1] != 0)
                    i1 = itemDef.stackIds[j1];

            if (i1 != -1)
                itemDef = lookup(i1);
        }
        Model model = itemDef.method201(1);
        if (model == null)
            return null;
        Sprite sprite = null;
        if (itemDef.certTemplateID != -1) {
            sprite = getSprite(itemDef.certID, 10, -1);
            if (sprite == null)
                return null;
        }
        Sprite enabledSprite = new Sprite(32, 32);
        int k1 = Rasterizer.textureInt1;
        int l1 = Rasterizer.textureInt2;
        int ai[] = Rasterizer.anIntArray1472;
        int ai1[] = Raster.pixels;
        int i2 = Raster.width;
        int j2 = Raster.height;
        int k2 = Raster.topX;
        int l2 = Raster.bottomX;
        int i3 = Raster.topY;
        int j3 = Raster.bottomY;
        Rasterizer.aBoolean1464 = false;
        Raster.initDrawingArea(enabledSprite.raster, 32, 32);
        Raster.fillRectangle(0, 0, 32, 32, 0);
        Rasterizer.method364();
        int k3 = itemDef.spriteScale;
        if (k == -1)
            k3 = (int) ((double) k3 * 1.5D);
        if (k > 0)
            k3 = (int) ((double) k3 * 1.04D);
        int l3 = Rasterizer.anIntArray1470[itemDef.spritePitch] * k3 >> 16;
        int i4 = Rasterizer.anIntArray1471[itemDef.spritePitch] * k3 >> 16;
        model.method482(itemDef.spriteCameraRoll, itemDef.spriteCameraYaw, itemDef.spritePitch, itemDef.spriteTranslateX, l3 + model.modelHeight / 2 + itemDef.spriteTranslateY, i4 + itemDef.spriteTranslateY);
        for (int i5 = 31; i5 >= 0; i5--) {
            for (int j4 = 31; j4 >= 0; j4--)
                if (enabledSprite.raster[i5 + j4 * 32] == 0)
                    if (i5 > 0 && enabledSprite.raster[(i5 - 1) + j4 * 32] > 1)
                        enabledSprite.raster[i5 + j4 * 32] = 1;
                    else if (j4 > 0 && enabledSprite.raster[i5 + (j4 - 1) * 32] > 1)
                        enabledSprite.raster[i5 + j4 * 32] = 1;
                    else if (i5 < 31 && enabledSprite.raster[i5 + 1 + j4 * 32] > 1)
                        enabledSprite.raster[i5 + j4 * 32] = 1;
                    else if (j4 < 31 && enabledSprite.raster[i5 + (j4 + 1) * 32] > 1)
                        enabledSprite.raster[i5 + j4 * 32] = 1;

        }

        if (k > 0) {
            for (int j5 = 31; j5 >= 0; j5--) {
                for (int k4 = 31; k4 >= 0; k4--)
                    if (enabledSprite.raster[j5 + k4 * 32] == 0)
                        if (j5 > 0 && enabledSprite.raster[(j5 - 1) + k4 * 32] == 1)
                            enabledSprite.raster[j5 + k4 * 32] = k;
                        else if (k4 > 0 && enabledSprite.raster[j5 + (k4 - 1) * 32] == 1)
                            enabledSprite.raster[j5 + k4 * 32] = k;
                        else if (j5 < 31 && enabledSprite.raster[j5 + 1 + k4 * 32] == 1)
                            enabledSprite.raster[j5 + k4 * 32] = k;
                        else if (k4 < 31 && enabledSprite.raster[j5 + (k4 + 1) * 32] == 1)
                            enabledSprite.raster[j5 + k4 * 32] = k;

            }

        } else if (k == 0) {
            for (int k5 = 31; k5 >= 0; k5--) {
                for (int l4 = 31; l4 >= 0; l4--)
                    if (enabledSprite.raster[k5 + l4 * 32] == 0 && k5 > 0 && l4 > 0 && enabledSprite.raster[(k5 - 1) + (l4 - 1) * 32] > 0)
                        enabledSprite.raster[k5 + l4 * 32] = 0x302020;

            }

        }
        if (itemDef.certTemplateID != -1) {
            int l5 = sprite.resizeWidth;
            int j6 = sprite.resizeHeight;
            sprite.resizeWidth = 32;
            sprite.resizeHeight = 32;
            sprite.drawSprite(0, 0);
            sprite.resizeWidth = l5;
            sprite.resizeHeight = j6;
        }
        if (k == 0)
            mruNodes1.put(enabledSprite, item);
        Raster.initDrawingArea(ai1, i2, j2);
        Raster.setDrawingArea(k2, i3, l2, j3);
        Rasterizer.textureInt1 = k1;
        Rasterizer.textureInt2 = l1;
        Rasterizer.anIntArray1472 = ai;
        Rasterizer.aBoolean1464 = true;
        if (itemDef.stackable)
            enabledSprite.resizeWidth = 33;
        else
            enabledSprite.resizeWidth = 32;
        enabledSprite.resizeHeight = amount;
        return enabledSprite;
    }

    public Model method201(int i) {
        if (stackIds != null && i > 1) {
            int j = -1;
            for (int k = 0; k < 10; k++)
                if (i >= stackAmounts[k] && stackAmounts[k] != 0)
                    j = stackIds[k];

            if (j != -1)
                return lookup(j).method201(1);
        }
        Model model = (Model) mruNodes2.get(id);
        if (model != null)
            return model;
        model = Model.getModel(modelId);
        if (model == null)
            return null;
        if (groundScaleX != 128 || groundScaleY != 128 || groundScaleZ != 128)
            model.method478(groundScaleX, groundScaleZ, groundScaleY);
        if (modifiedModelColors != null) {
            for (int l = 0; l < modifiedModelColors.length; l++)
                model.recolor(modifiedModelColors[l], originalModelColors[l]);

        }
        model.light(64 + ambience, 768 + diffusion, -50, -10, -50, true);
        model.aBoolean1659 = true;
        mruNodes2.put(model, id);
        return model;
    }

    public Model method202(int i) {
        if (stackIds != null && i > 1) {
            int j = -1;
            for (int k = 0; k < 10; k++)
                if (i >= stackAmounts[k] && stackAmounts[k] != 0)
                    j = stackIds[k];

            if (j != -1)
                return lookup(j).method202(1);
        }
        Model model = Model.getModel(modelId);
        if (model == null)
            return null;
        if (modifiedModelColors != null) {
            for (int l = 0; l < modifiedModelColors.length; l++)
                model.recolor(modifiedModelColors[l], originalModelColors[l]);

        }
        return model;
    }

    private void decode(Buffer buffer) {
        while(true){
            int opcode = buffer.readUByte();

            if (opcode == 0) {
                return;
            } else if (opcode == 1) {
                modelId = buffer.readUShort();
            } else if (opcode == 2) {
                name = buffer.readString();
            } else if (opcode == 4) {
                spriteScale = buffer.readUShort();
            } else if (opcode == 5) {
                spritePitch = buffer.readUShort();
            } else if (opcode == 6) {
                spriteCameraRoll = buffer.readUShort();
            } else if (opcode == 7) {
                spriteTranslateX = buffer.readUShort();
                if (spriteTranslateX > 32767) {
                    spriteTranslateX -= 0x10000;
                }
            } else if (opcode == 8) {
                spriteTranslateY = buffer.readUShort();
                if (spriteTranslateY > 32767) {
                    spriteTranslateY -= 0x10000;
                }
            } else if (opcode == 11) {
                stackable = true;
            } else if (opcode == 12) {
                value = buffer.readInt();
            } else if (opcode == 16) {
                membersObject = true;
            } else if (opcode == 23) {
                primaryMaleModel = buffer.readUShort();
                maleTranslation = buffer.readSignedByte();
            } else if (opcode == 24) {
                secondaryMaleModel = buffer.readUShort();
            } else if (opcode == 25) {
                primaryFemaleModel = buffer.readUShort();
                femaleTranslation = buffer.readSignedByte();
            } else if (opcode == 26) {
                secondaryFemaleModel = 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 (itemActions == null) {
                    itemActions = new String[5];
                }

                itemActions[opcode - 35] = buffer.readString();
            } else if (opcode == 40) {
                int len = buffer.readUByte();
                originalModelColors = new int[len];
                modifiedModelColors = new int[len];
                for (int i = 0; i < len; i++) {
                    originalModelColors[i] = buffer.readUShort();
                    modifiedModelColors[i] = buffer.readUShort();
                }
            } else if (opcode == 41) {
                int len = buffer.readUByte();
                originalTexture = new short[len];
                modifiedTexture = new short[len];
                for (int i = 0; i < len; i++) {
                    originalTexture[i] = (short) buffer.readUShort();
                    modifiedTexture[i] = (short) buffer.readUShort();
                }
            } else if (opcode == 42) {
                shiftClickIndex = buffer.readUByte();
            } else if (opcode == 65) {
                searchable = true;
            }  else if (opcode == 78) {
                tertiaryMaleEquipmentModel = buffer.readUShort();
            } else if (opcode == 79) {
                tertiaryFemaleEquipmentModel = buffer.readUShort();
            } else if (opcode == 90) {
                primaryMaleHeadPiece = buffer.readUShort();
            } else if (opcode == 91) {
                primaryFemaleHeadPiece = buffer.readUShort();
            } else if (opcode == 92) {
                secondaryMaleHeadPiece = buffer.readUShort();
            } else if (opcode == 93) {
                secondaryFemaleHeadPiece = buffer.readUShort();
            } else if (opcode == 95) {
                spriteCameraYaw = buffer.readUShort();
            } else if (opcode == 97) {
                certID = buffer.readUShort();
            } else if (opcode == 98) {
                certTemplateID = buffer.readUShort();
            } else if (opcode >= 100 && opcode < 110) {
                if (stackIds == null) {
                    stackIds = new int[10];
                    stackAmounts = new int[10];
                }
                stackIds[opcode - 100] = buffer.readUShort();
                stackAmounts[opcode - 100] = buffer.readUShort();
            } else if (opcode == 110) {
                groundScaleX = buffer.readUShort();
            } else if (opcode == 111) {
                groundScaleY = buffer.readUShort();
            } else if (opcode == 112) {
                groundScaleZ = buffer.readUShort();
            } else if (opcode == 113) {
                ambience = buffer.readSignedByte();
            } else if (opcode == 114) {
                diffusion = buffer.readSignedByte();
            } else if (opcode == 115) {
                team = buffer.readUByte();
            } else if (opcode == 139) {
                unnotedId = buffer.readUShort(); // un-noted id
            } else if (opcode == 140) {
                notedId = buffer.readUShort(); // noted id
            } else if (opcode == 148) {
                buffer.readUShort(); // placeholder id
            } else if (opcode == 149) {
                buffer.readUShort(); // placeholder template
            }
        }
    }

    private ItemDefinition() {
        id = -1;
    }

    private byte femaleTranslation;
    private byte maleTranslation;
    public int id;// anInt157
    public int team;
    public int value;// anInt155
    public int certID;
    public int modelId;// dropModel
    public int primaryMaleHeadPiece;
    public int primaryFemaleModel;// femWieldModel
    public int spriteCameraYaw;// modelPositionUp
    public int secondaryFemaleModel;// femArmModel
    public int primaryFemaleHeadPiece;
    public int secondaryMaleModel;// maleArmModel
    public int primaryMaleModel;// maleWieldModel
    public int spriteScale;
    public int spriteTranslateX;
    public int spriteTranslateY;//
    public int certTemplateID;
    public int unnotedId = -1;
    public int notedId = -1;
    public int spriteCameraRoll;// modelRotateRight
    public int spritePitch;// modelRotateUp
    public static int totalItems;
    public int[] stackIds;// modelStack
    public int[] stackAmounts;// itemAmount
    public int[] modifiedModelColors;// newModelColor
    public int[] originalModelColors;
    public short[] modifiedTexture;
    public short[] originalTexture;
    private int ambience;
    private int tertiaryFemaleEquipmentModel;
    private int secondaryMaleHeadPiece;
    private int diffusion;
    private int tertiaryMaleEquipmentModel;
    private int groundScaleZ;
    private int groundScaleY;
    private int groundScaleX;
    private int secondaryFemaleHeadPiece;
    private int shiftClickIndex = -2;
    private boolean stockMarket;
    public boolean searchable;
    private static int cacheIndex;
    private static int[] offsets;
    public boolean stackable;// itemStackable
    public boolean membersObject;// aBoolean161
    public static boolean isMembers = true;
    public String name;// itemName
    public String description;// itemExamine
    public String itemActions[];// itemMenuOption
    public String groundActions[];
    private static Buffer dataBuf;
    private static ItemDefinition[] cache;
    public static Cache mruNodes1 = new Cache(100);
    public static Cache mruNodes2 = new Cache(50);
}

 NpcDefinition Read Value's

 


public final class NpcDefinition {

    public static void unpackConfig(StreamLoader archive) {
        buffer = new Buffer(archive.getDataForName("npc.dat"));
        Buffer metaBuf = new Buffer(archive.getDataForName("npc.idx"));
        int totalNPCs = metaBuf.readUShort();

        System.out.println(String.format("Loaded: %d npcs", totalNPCs));

        offsets = new int[totalNPCs];
        int metaOffset = 2;
        for (int i = 0; i < totalNPCs; i++) {
            offsets[i] = metaOffset;
            metaOffset += metaBuf.readUShort();
        }

        cache = new NpcDefinition[20];

        for (int i = 0; i < 20; i++) {
            cache[i] = new NpcDefinition();
        }

       // ClassFieldPrinter printer = new ClassFieldPrinter();

//        try(PrintWriter writer = new PrintWriter(new File("npc_fields.txt"))) {
//            for (int i = 0; i < totalNPCs; i++) {
//                NpcDefinition def = lookup(i);
//                if (def == null || def.name == null) {
//                    continue;
//                }
//                try {
//                    printer.printFields(def, "", true);
//                } catch (Exception ex) {
//                    ex.printStackTrace();
//                    continue;
//                }
//
//            }
//            writer.print(printer.getBuilder().toString());
//        } catch (FileNotFoundException e) {
//            e.printStackTrace();
//        }

    }

    public static NpcDefinition lookup(int id) {
        for (int i = 0; i < 20; i++) {
            if (cache[i].interfaceType == (long) id) {
                return cache[i];
            }
        }

        anInt56 = (anInt56 + 1) % 20;
        NpcDefinition entityDef = cache[anInt56] = new NpcDefinition();
        buffer.currentOffset = offsets[id];
        entityDef.interfaceType = id;
        entityDef.decode(buffer);
        return entityDef;
    }

    public Model method160() {
        if (morphisms != null) {
            NpcDefinition entityDef = morph();
            if (entityDef == null)
                return null;
            else
                return entityDef.method160();
        }
        if (additionalModels == null)
            return null;
        boolean flag1 = false;
        for (int i = 0; i < additionalModels.length; i++)
            if (!Model.isCached(additionalModels[i]))
                flag1 = true;

        if (flag1)
            return null;
        Model aclass30_sub2_sub4_sub6s[] = new Model[additionalModels.length];
        for (int j = 0; j < additionalModels.length; j++)
            aclass30_sub2_sub4_sub6s[j] = Model.getModel(additionalModels[j]);

        Model model;
        if (aclass30_sub2_sub4_sub6s.length == 1)
            model = aclass30_sub2_sub4_sub6s[0];
        else
            model = new Model(aclass30_sub2_sub4_sub6s.length, aclass30_sub2_sub4_sub6s);
        if (recolorOriginal != null) {
            for (int k = 0; k < recolorOriginal.length; k++)
                model.recolor(recolorOriginal[k], recolorTarget[k]);

        }
        return model;
    }

    public Model getAnimatedModel(int primaryFrame, int secondaryFrame, int interleaveOrder[]) {
        if (morphisms != null) {
            NpcDefinition definition = morph();
            if (definition == null)
                return null;
            else
                return definition.getAnimatedModel(primaryFrame, secondaryFrame, interleaveOrder);
        }
        Model model = (Model) modelCache.get(interfaceType);
        if (model == null) {
            boolean flag = false;
            for (int index = 0; index < modelId.length; index++)
                if (!Model.isCached(modelId[index]))
                    flag = true;
            if (flag) {
                return null;
            }
            Model models[] = new Model[modelId.length];
            for (int index = 0; index < modelId.length; index++)
                models[index] = Model.getModel(modelId[index]);

            if (models.length == 1)
                model = models[0];
            else
                model = new Model(models.length, models);
            if (recolorOriginal != null) {
                for (int index = 0; index < recolorOriginal.length; index++)
                    model.recolor(recolorOriginal[index], recolorTarget[index]);

            }
            model.skin();
            model.light(64 + lightModifier, 850 + shadowModifier, -30, -50, -30, true);
            modelCache.put(model, interfaceType);
        }
        Model model_1 = Model.EMPTY_MODEL;
        model_1.method464(model, Frame.method532(secondaryFrame) & Frame.method532(primaryFrame));
        if (secondaryFrame != -1 && primaryFrame != -1)
            model_1.method471(interleaveOrder, primaryFrame, secondaryFrame);
        else if (secondaryFrame != -1)
            model_1.method470(secondaryFrame);
        if (scaleXZ != 128 || scaleY != 128)
            model_1.method478(scaleXZ, scaleXZ, scaleY);
        model_1.method466();
        model_1.anIntArrayArray1658 = null;
        model_1.anIntArrayArray1657 = null;
        if (size == 1)
            model_1.aBoolean1659 = true;
        return model_1;
    }

    public NpcDefinition morph() {
        int j = -1;
        if (varbit != -1) {
            Varbit varBit = Varbit.cache[varbit];
            int k = varBit.configId;
            int l = varBit.lsb;
            int i1 = varBit.msb;
            int j1 = Client.BIT_MASKS[i1 - l];
            j = clientInstance.settings[k] >> l & j1;
        } else if (varp != -1)
            j = clientInstance.settings[varp];
        if (j < 0 || j >= morphisms.length || morphisms[j] == -1)
            return null;
        else
            return lookup(morphisms[j]);
    }

    public static void clear() {
        modelCache = null;
        offsets = null;
        cache = null;
        buffer = null;
    }

    Model method164(int j, int currAnim, int nextAnim, int currCycle, int nextCycle, int ai[]) {
        if (morphisms != null) {
            final NpcDefinition type = morph();
            if (type == null) {
                return null;
            } else {
                return type.method164(j, currAnim, nextAnim, currCycle, nextCycle, ai);
            }
        }
        Model model = (Model) modelCache.get(interfaceType);
        if (model == null) {
            boolean flag = false;
            for (int i1 = 0; i1 < modelId.length; i1++) {
                if (!Model.isCached(modelId[i1])) {
                    flag = true;
                }
            }
            if (flag) {
                return null;
            }
            final Model[] parts = new Model[modelId.length];
            for (int j1 = 0; j1 < modelId.length; j1++) {
                parts[j1] = Model.getModel(modelId[j1]);
            }
            if (parts.length == 1) {
                model = parts[0];
            } else {
                model = new Model(parts.length, parts);
            }
            if (recolorOriginal != null) {
                for (int k1 = 0; k1 < recolorOriginal.length; k1++) {
                    model.recolor(recolorOriginal[k1], recolorTarget[k1]);
                }
            }
            model.skin();
            if (Settings.CUSTOM_LIGHTING) {
                model.light(84, 1000, -90, -580, -90, true);
            } else {
                model.light(64 + lightModifier, 850 + shadowModifier, -30, -50, -30, true);
            }
            modelCache.put(model, interfaceType);
        }
        final Model model_1 = Model.EMPTY_MODEL;
        model_1.method464(model, Frame.method532(currAnim) & Frame.method532(j));
        if (currAnim != -1 && j != -1) {
            model_1.method471(ai, j, currAnim);
        } else if (currAnim != -1) {
            if (Settings.TWEENING) {
                model_1.interpolateFrames(currAnim, nextAnim, nextCycle, currCycle);
            } else {
                model_1.method470(currAnim);
            }
        }
        if (scaleXZ != 128 || scaleY != 128) {
            model_1.method478(scaleXZ, scaleY, scaleXZ);
        }
        model_1.method466();
        model_1.anIntArrayArray1658 = null;
        model_1.anIntArrayArray1657 = null;
        if (size == 1) {
            model_1.aBoolean1659 = true;
        }
        return model_1;
    }

    public void decode(Buffer buffer) {
        while(true) {
            int opcode = buffer.readUByte();
            if (opcode == 0) {
                return;
            } else if (opcode == 1) {
                int len = buffer.readUByte();
                modelId = new int[len];
                for (int i = 0; i < len; i++) {
                    modelId[i] = buffer.readUShort();
                }
            } else if (opcode == 2) {
                name = buffer.readString();
            } else if (opcode == 12) {
                size = buffer.readUByte();
            } else if (opcode == 13) {
                standingAnimation = buffer.readUShort();
            } else if (opcode == 14) {
                walkingAnimation = buffer.readUShort();
            } else if (opcode == 15) {
                buffer.readUShort();
            } else if (opcode == 16) {
                buffer.readUShort();
            } else if (opcode == 17) {
                walkingAnimation = buffer.readUShort();
                halfTurnAnimation = buffer.readUShort();
                quarterClockwiseTurnAnimation = buffer.readUShort();
                quarterAnticlockwiseTurnAnimation = buffer.readUShort();
                if (halfTurnAnimation == 65535) {
                    halfTurnAnimation = walkingAnimation;
                }
                if (quarterClockwiseTurnAnimation == 65535) {
                    quarterClockwiseTurnAnimation = walkingAnimation;
                }
                if (quarterAnticlockwiseTurnAnimation == 65535) {
                    quarterAnticlockwiseTurnAnimation = walkingAnimation;
                }
            } else if (opcode >= 30 && opcode < 35) {
                if (actions == null) {
                    actions = new String[5];
                }

                actions[opcode - 30] = buffer.readString();

                if (actions[opcode - 30].equalsIgnoreCase("Hidden")) {
                    actions[opcode - 30] = null;
                }
            } else if (opcode == 40) {
                int len = buffer.readUByte();
                recolorOriginal = new int[len];
                recolorTarget = new int[len];
                for (int i = 0; i < len; i++) {
                    recolorOriginal[i] = buffer.readUShort();
                    recolorTarget[i] = buffer.readUShort();
                }

            } else if (opcode == 41) {
                int len = buffer.readUByte();

                for (int i = 0; i < len; i++) {
                    buffer.readUShort(); // textures
                    buffer.readUShort();
                }
            } else if (opcode == 60) {
                int len = buffer.readUByte();
                additionalModels = new int[len];
                for (int i = 0; i < len; i++) {
                    additionalModels[i] = buffer.readUShort();
                }
            } else if (opcode == 93) {
                aBoolean87 = 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)
                aBoolean93 = 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)
                rotation = buffer.readUShort();
            else if (opcode == 106 || opcode == 118) {
                varbit = buffer.readUShort();

                if (varbit == 65535) {
                    varbit = -1;
                }

                varp = buffer.readUShort();

                if (varp == 65535) {
                    varp = -1;
                }

                int value = -1;

                if (opcode == 118) {
                    value = buffer.readUShort();
                }

                int len = buffer.readUByte();
                morphisms = new int[len + 2];
                for (int i = 0; i <= len; i++) {
                    morphisms[i] = buffer.readUShort();
                    if (morphisms[i] == 65535) {
                        morphisms[i] = -1;
                    }
                }
                morphisms[len + 1] = value;
            } else if (opcode == 109) {
                aBoolean84 = false;
            } else if (opcode == 107 || opcode == 111) {

            } else {
                System.out.println(String.format("npc def invalid opcode: %d", opcode));
            }
        }
    }

    public NpcDefinition() {
        quarterAnticlockwiseTurnAnimation = -1;
        varbit = -1;
        halfTurnAnimation = -1;
        varp = -1;
        combatLevel = -1;
        anInt64 = 1834;
        walkingAnimation = -1;
        size = 1;
        headIcon = -1;
        standingAnimation = -1;
        interfaceType = -1L;
        rotation = 32;
        quarterClockwiseTurnAnimation = -1;
        aBoolean84 = true;
        scaleY = 128;
        aBoolean87 = true;
        scaleXZ = 128;
        aBoolean93 = false;
    }

    public int quarterAnticlockwiseTurnAnimation;
    public static int anInt56;
    public int varbit;
    public int halfTurnAnimation;
    public int varp;
    public static Buffer buffer;
    public int combatLevel;
    public final int anInt64;
    public String name;
    public String actions[];
    public int walkingAnimation;
    public int size;
    public int[] recolorTarget;
    public static int[] offsets;
    public int[] additionalModels;
    public int headIcon;
    public int[] recolorOriginal;
    public int standingAnimation;
    public long interfaceType;
    public int rotation;
    public static NpcDefinition[] cache;
    public static Client clientInstance;
    public int quarterClockwiseTurnAnimation;
    public boolean aBoolean84;
    public int lightModifier;
    public int scaleY;
    public boolean aBoolean87;
    public int morphisms[];
    public byte description[];
    public int scaleXZ;
    public int shadowModifier;
    public boolean aBoolean93;
    public int[] modelId;
    public int interfaceZoom = 0;
    public static Cache modelCache = new Cache(30);

}

ObjectDefinition Read Value's

 


public final class ObjectDefinition {

	public static void unpackConfig(StreamLoader archive) {
		dataBuf = new Buffer(archive.getDataForName("loc.dat"));
		Buffer metaBuf = new Buffer(archive.getDataForName("loc.idx"));
		int totalObjects = metaBuf.readUShort();

		System.out.println(String.format("Loaded: %d objects", totalObjects));

		offsets = new int[totalObjects];

		int metaOffset = 2;
		for (int i = 0; i < totalObjects; i++) {
			offsets[i] = metaOffset;
			metaOffset += metaBuf.readUShort();
		}

		cache = new ObjectDefinition[20];

		for (int index = 0; index < 20; index++) {
			cache[index] = new ObjectDefinition();
		}

//		ClassFieldPrinter printer = new ClassFieldPrinter();
//        printer.setDefaultObject(new ObjectDefinition());
//
//		try(PrintWriter writer = new PrintWriter(new File("obj_fields.txt"))) {
//			for (int i = 0; i < totalObjects; i++) {
//				ObjectDefinition def = forID(i);
//				if (def == null) {
//					continue;
//				}
//
//				try {
//					printer.printFields(def);
//				} catch (Exception ex) {
//					ex.printStackTrace();
//				}
//
//			}
//            writer.print(printer.getBuilder());
//		} catch (FileNotFoundException e) {
//			e.printStackTrace();
//		}

	}

	static ObjectDefinition lookup(int i) {
		if (i > offsets.length)
			i = offsets.length - 1;
		for (int j = 0; j < 20; j++)
			if (cache[j].type == i)
				return cache[j];
		cacheIndex = (cacheIndex + 1) % 20;
	    /* Seers village fix */
		if (i == 25913)
			i = 15552;
		if (i == 25916 || i == 25926)
			i = 15553;
		if (i == 25917)
			i = 15554;
		ObjectDefinition def = cache[cacheIndex];
		dataBuf.currentOffset = offsets[i];
		def.type = i;
		def.setDefaults();
		def.decode(dataBuf);
		return def;
	}

	public void setDefaults() {
		modelIds = null;
		modelTypes = null;
		description = null;
		modifiedModelColors = null;
		originalModelColors = null;
		originalTexture = null;
		modifiedTexture = null;
		width = 1;
		length = 1;
		solid = true;
		impenetrable = true;
		interactive = false;
		contouredGround = false;
		nonFlatShading = false;
		modelClipped = false;
		animation = -1;
		decorDisplacement = 16;
		ambientLighting = 0;
		contrast = 0;
		actions = null;
		mapIcon = -1;
		mapscene = -1;
		inverted = false;
		castsShadow = true;
		scaleX = 128;
		scaleY = 128;
		scaleZ = 128;
		surroundings = 0;
		translateX = 0;
		translateY = 0;
		translateZ = 0;
		obstructsGround = false;
		removeClipping = false;
		supportItems = -1;
		varbit = -1;
		varp = -1;
		morphisms = null;
	}

	public void method574(ResourceProvider provider) {
		if (modelIds == null)
			return;
		for (int j = 0; j < modelIds.length; j++) {
			System.out.println(modelIds[j] & 0xffff);
			provider.method560(modelIds[j] & 0xffff, 0);
		}
	}

	public static void nullLoader() {
		mruNodes1 = null;
		mruNodes2 = null;
		offsets = null;
		cache = null;
		dataBuf = null;
	}

	public boolean method577(int i) {
		Model model = (Model) mruNodes2.get(type);
		if (modelTypes == null) {
			if (modelIds == null)
				return true;
			if (i != 10)
				return true;
			boolean flag1 = true;
			for (int k = 0; k < modelIds.length; k++)
				flag1 &= Model.isCached(modelIds[k] & 0xffff);
			return flag1;
		}
		for (int j = 0; j < modelTypes.length; j++)
			if (modelTypes[j] == i)
				return Model.isCached(modelIds[j] & 0xffff);
		return true;
	}

	public Model method578(int i, int j, int k, int l, int i1, int j1, int k1) {
		Model model = method581(i, k1, j);
		if (model == null)
			return null;
		if (contouredGround || nonFlatShading)
			model = new Model(contouredGround, nonFlatShading, model);
		if (contouredGround) {
			int l1 = (k + l + i1 + j1) / 4;
			for (int i2 = 0; i2 < model.anInt1626; i2++) {
				int j2 = model.anIntArray1627[i2];
				int k2 = model.anIntArray1629[i2];
				int l2 = k + ((l - k) * (j2 + 64)) / 128;
				int i3 = j1 + ((i1 - j1) * (j2 + 64)) / 128;
				int j3 = l2 + ((i3 - l2) * (k2 + 64)) / 128;
				model.anIntArray1628[i2] += j3 - l1;
			}
			model.method467();
		}
		return model;
	}

	public boolean method579() {
		if (modelIds == null)
			return true;
		boolean flag1 = true;
		for (int i = 0; i < modelIds.length; i++)
			flag1 &= Model.isCached(modelIds[i] & 0xffff);
		return flag1;
	}

	public ObjectDefinition method580() {
		int i = -1;
		if (varbit != -1) {
			Varbit varBit = Varbit.cache[varbit];
			int j = varBit.configId;
			int k = varBit.lsb;
			int l = varBit.msb;
			int i1 = Client.BIT_MASKS[l - k];
			i = clientInstance.settings[j] >> k & i1;
		} else if (varp != -1)
			i = clientInstance.settings[varp];

		int var;

		if (i >= 0 && i < morphisms.length) {
			var = morphisms[i];
		} else {
			var = morphisms[morphisms.length - 1];
		}

		return var != -1 ? lookup(var) : null;
	}

	public Model method581(int j, int k, int l) {
		Model model = null;
		long l1;
		if (modelTypes == null) {
			if (j != 10)
				return null;
			l1 = (long) ((type << 8) + l) + ((long) (k + 1) << 32);
			Model model_1 = (Model) mruNodes2.get(l1);
			if (model_1 != null)
				return model_1;
			if (modelIds == null)
				return null;
			boolean flag1 = inverted ^ (l > 3);
			int k1 = modelIds.length;
			for (int i2 = 0; i2 < k1; i2++) {
				int l2 = modelIds[i2];
				if (flag1)
					l2 += 0x10000;
				model = (Model) mruNodes1.get(l2);
				if (model == null) {
					model = Model.getModel(l2 & 0xffff);
					if (model == null)
						return null;
					if (flag1)
						model.method477();
					mruNodes1.put(model, l2);
				}
				if (k1 > 1)
					aModelArray741s[i2] = model;
			}

			if (k1 > 1)
				model = new Model(k1, aModelArray741s);
		} else {
			int i1 = -1;
			for (int j1 = 0; j1 < modelTypes.length; j1++) {
				if (modelTypes[j1] != j)
					continue;
				i1 = j1;
				break;
			}

			if (i1 == -1)
				return null;
			l1 = (long) ((type << 8) + (i1 << 3) + l) + ((long) (k + 1) << 32);
			Model model_2 = (Model) mruNodes2.get(l1);
			if (model_2 != null)
				return model_2;
			int j2 = modelIds[i1];
			boolean flag3 = inverted ^ (l > 3);
			if (flag3)
				j2 += 0x10000;
			model = (Model) mruNodes1.get(j2);
			if (model == null) {
				model = Model.getModel(j2 & 0xffff);
				if (model == null)
					return null;
				if (flag3)
					model.method477();
				mruNodes1.put(model, j2);
			}
		}
		boolean flag;
		flag = scaleX != 128 || scaleY != 128 || scaleZ != 128;
		boolean flag2;
		flag2 = translateX != 0 || translateY != 0 || translateZ != 0;
		Model model_3 = new Model(modifiedModelColors == null, Frame.method532(k), l == 0 && k == -1 && !flag && !flag2, modifiedTexture == null, model);
		if (k != -1) {
			model_3.skin();
			model_3.method470(k);
			model_3.anIntArrayArray1658 = null;
			model_3.anIntArrayArray1657 = null;
		}
		while (l-- > 0)
			model_3.method473();
		if (modifiedModelColors != null) {
			for (int k2 = 0; k2 < modifiedModelColors.length; k2++)
				model_3.recolor(modifiedModelColors[k2], originalModelColors[k2]);

		}
		if (modifiedTexture != null) {
			for (int k2 = 0; k2 < modifiedTexture.length; k2++)
				model_3.retexture(modifiedTexture[k2], originalTexture[k2]);

		}
		if (flag)
			model_3.method478(scaleX, scaleZ, scaleY);
		if (flag2)
			model_3.method475(translateX, translateY, translateZ);

		if (Settings.CUSTOM_LIGHTING) {
			model_3.light(84, 1500, -90, -280, -70, !nonFlatShading);
		} else {
			model_3.light(64 + ambientLighting, 768 + contrast * 5, -50, -10, -50, !nonFlatShading);
		}
		if (supportItems == 1)
			model_3.anInt1654 = model_3.modelHeight;
		mruNodes2.put(model_3, l1);
		return model_3;
	}

	public void decode(Buffer buffer) {
		while(true) {
			int opcode = buffer.readUByte();

			if (opcode == 0) {
				break;
			} else if (opcode == 1) {
				int len = buffer.readUByte();
				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.readUByte();
						}
					} else {
						buffer.currentOffset += len * 3;
					}
				}
			} else if (opcode == 2) {
				name = buffer.readString();
			} else if (opcode == 5) {
				int len = buffer.readUByte();
				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.currentOffset += len * 2;
					}
				}
			} else if (opcode == 14) {
				width = buffer.readUByte();
			} else if (opcode == 15) {
				length = buffer.readUByte();
			} else if (opcode == 17) {
				solid = false;
			} else if (opcode == 18) {
				impenetrable = false;
			} else if (opcode == 19) {
				interactive = (buffer.readUByte() == 1);
			} else if (opcode == 21) {
				contouredGround = true;
			} else if (opcode == 22) {
				nonFlatShading = true;
			} else if (opcode == 23) {
				modelClipped = true;
			} else if (opcode == 24) {
				animation = buffer.readUShort();
				if (animation == 0xFFFF) {
					animation = -1;
				}
			} else if (opcode == 27) {
				clipType = 1;
			} else if (opcode == 28) {
				decorDisplacement = buffer.readUByte();
			} else if (opcode == 29) {
				ambientLighting = buffer.readSignedByte();
			} else if (opcode == 39) {
				contrast = buffer.readSignedByte() * 25;
			} else if (opcode >= 30 && opcode < 35) {
				if (actions == null) {
					actions = new String[5];
				}
				actions[opcode - 30] = buffer.readString();
				if (actions[opcode - 30].equalsIgnoreCase("Hidden")) {
					actions[opcode - 30] = null;
				}
			} else if (opcode == 40) {
				int len = buffer.readUByte();
				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.readUByte();
				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 == 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.readUByte();
			} else if (opcode == 70) {
				translateX = buffer.readUShort();
			} else if (opcode == 71) {
				translateY = buffer.readUShort();
			} else if (opcode == 72) {
				translateZ = buffer.readUShort();
			} else if (opcode == 73) {
				obstructsGround = true;
			} else if (opcode == 74) {
				removeClipping = true;
			} else if (opcode == 75) {
				supportItems = buffer.readUByte();
			} else if (opcode == 78) {
				buffer.readUShort(); // ambient sound id
				buffer.readUByte();
			} else if (opcode == 79) {
				buffer.readUShort();
				buffer.readUShort();
				buffer.readUByte();
				int len = buffer.readUByte();

				for (int i = 0; i < len; i++) {
					buffer.readUShort();
				}
			} else if (opcode == 81) {
				buffer.readUByte();
			} else if (opcode == 82) {
				mapIcon = buffer.readUShort();

				if (mapIcon == 0xFFFF) {
					mapIcon = -1;
				}
			} else if (opcode == 77 || opcode == 92) {
				varp = buffer.readUShort();

				if (varp == 0xFFFF) {
					varp = -1;
				}

				varbit = buffer.readUShort();

				if (varbit == 0xFFFF) {
					varbit = -1;
				}

				int value = -1;

				if (opcode == 92) {
                    value = buffer.readUShort();

                    if (value == 0xFFFF) {
                        value = -1;
                    }
                }

				int len = buffer.readUByte();

				morphisms = new int[len + 2];
				for (int i = 0; i <= len; ++i) {
					morphisms[i] = buffer.readUShort();
					if (morphisms[i] == 0xFFFF) {
						morphisms[i] = -1;
					}
				}
				morphisms[len + 1] = value;
			} else {
				System.out.println("invalid opcode: " + opcode);
			}

		}

		if (name != null && !name.equals("null")) {
			interactive = modelIds != null && (modelTypes == null || modelTypes[0] == 10);
			if (actions != null)
				interactive = true;
		}

		if (removeClipping) {
			solid = false;
			impenetrable = false;
		}

		if (supportItems == -1) {
			supportItems = solid ? 1 : 0;
		}
	}

	public ObjectDefinition() {
		type = -1;
	}

	private short[] originalTexture;
	private short[] modifiedTexture;
	public boolean obstructsGround;
	public byte ambientLighting;
	public int translateX;
	public String name;
	public int scaleZ;
	public static final Model[] aModelArray741s = new Model[4];
	public int contrast;
	public int width;
	public int translateY;
	public int mapIcon;
	public int[] originalModelColors;
	public int scaleX;
	public int varp;
	public boolean inverted;
	public static boolean lowMem;
	public static Buffer dataBuf;
	public int type;
	public static int[] offsets;
	public boolean impenetrable;
	public int mapscene;
	public int morphisms[];
	public int supportItems;
	public int length;
	public boolean contouredGround;
	public boolean modelClipped;
	public static Client clientInstance;
	public boolean removeClipping;
	public boolean solid;
	public int surroundings;
	public boolean nonFlatShading;
	public static int cacheIndex;
	public int scaleY;
	public int[] modelIds;
	public int varbit;
	public int decorDisplacement;
	public int[] modelTypes;
	public byte description[];
	public boolean interactive;
	public boolean castsShadow;
	public static Cache mruNodes2 = new Cache(30);
	public int animation;
	public static ObjectDefinition[] cache;
	public int translateZ;
	public int[] modifiedModelColors;
	public static Cache mruNodes1 = new Cache(500);
	public String[] actions;
	int clipType = 2;
}

VarBit Read Value's

 


public final class Varbit {

	public static void unpackConfig(StreamLoader archive) {
		final Buffer buffer = new Buffer(archive.getDataForName("varbit.dat"));
		final int len = buffer.readUShort();

		if (cache == null) {
			cache = new Varbit[len];
		}

		System.out.println(String.format("Loaded: %d varbits", len));

		for (int i = 0; i < len; i++) {
			if (cache[i] == null) {
				cache[i] = new Varbit();
			}

			cache[i].decode(buffer);

			if (cache[i].aBoolean651) {
				Varp.varps[cache[i].configId].aBoolean713 = true;
			}
		}

		if (buffer.currentOffset != buffer.buffer.length) {
			System.out.println("varbit mismatch! " + buffer.currentOffset + " " + buffer.buffer.length);
		}
	}

	private void decode(Buffer buffer) {
		int opcode = buffer.readUByte();

		if (opcode == 0) {
			return;
		} else if (opcode == 1) {
			configId = buffer.readUShort();
			lsb = buffer.readUByte();
			msb = buffer.readUByte();
		} else {
			System.out.println(opcode);
		}
	}

	private Varbit() {
		aBoolean651 = false;
	}

	public static Varbit cache[];
	public int configId;
	public int lsb;
	public int msb;
	private boolean aBoolean651;
}

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Contact

[email protected]

astra.security

What is a RSPS?

A RSPS, also known as RuneScape private server, is an online game based on RuneScape, and controlled by independent individuals.

Popular RSPS Servers

Runewild Ikov RedemptionRSPS

Disclaimer

Runesuite is not affiliated with runescape, jagex in any way & exists solely for educational purposes.

×
×
  • Create New...