hello i'm trying to load some OSRS maps on my 634 maps but i cant get the objects working. for the OSRS maps
my objectDef class
Code:
import java.io.FileWriter;
public final class ObjectDef {
public static ObjectDef forID(int i) {
for(int j = 0; j < 20; j++)
if(cache[j].type == i)
return cache[j];
if (i > streamIndices.length)
return forIDOSRS(i);
cacheIndex = (cacheIndex + 1) % 20;
ObjectDef objectDef = cache[cacheIndex];
try {
stream.currentOffset = streamIndices[i];
} catch(Exception e) {}
objectDef.type = i;
objectDef.setDefaults();
objectDef.readValues(stream);
//farming fix
/*case 8388:
if(i == 8389) {
if(i == 8390) {
if(i == 8391) {
if(i == 7847) {
if(i == 8150) {
if(i == 8151) {
if(i == 8152) {
if(i == 8153) {
if(i == 8552) {
if(i == 8553) {
if(i == 8550) {
if(i == 8551) {
if(i == 7848) {
if(i == 7849) {
if(i == 7850) {
if(i == 8556) {
if(i == 8557) {
if(i == 8554) {
if(i == 8555) {*/
if(i == 10284) {//barrow chest
if (objectDef.name == null || objectDef.name.equalsIgnoreCase("null"))
objectDef.name = "";
objectDef.hasActions = true;
}
//end farming
//dungeoneering fix
if(i == 48312) {
objectDef.offsetH = 60;
objectDef.hasActions = false;
}
if(i == 48282) {
objectDef.hasActions = false;
}
//end
if (i == 36972) {
objectDef.hasActions = true;
objectDef.actions = new String[5];
objectDef.actions[0] = "Pray-at";
objectDef.actions[1] = "Change-pray";
}
if(i == 23735) {
objectDef.anInt781 = 0;
}
if(i == 31299) {
objectDef.anInt781 = 0;
}
if(i == 57226) {
objectDef.offsetH = 240;
objectDef.hasActions = false;
}
if(i == 26970) {
objectDef.name = "Grand exchange booth";
objectDef.hasActions = true;
objectDef.actions = new String[5];
objectDef.actions[0] = "Open";
}
if(i == 2732) {
objectDef.actions = new String[5];
objectDef.actions[1] = "Add-Logs";
}
if(i == 22721) {
objectDef.hasActions = true;
objectDef.actions = new String[5];
objectDef.actions[0] = "Smelt";
}
if(i == 7837) {
objectDef.hasActions = true;
objectDef.actions = new String[5];
}
if (objectDef.type == i && objectDef.originalModelColors == null) {
objectDef.originalModelColors = new int[1];
objectDef.modifiedModelColors = new int[1];
objectDef.originalModelColors[0] = 0;
objectDef.modifiedModelColors[0] = 1;
}
if (Config.debugModels) {
if (objectDef.name == null || objectDef.name.equalsIgnoreCase("null"))
objectDef.name = "";
objectDef.hasActions = true;
} else if (objectDef.name == null || objectDef.name.equalsIgnoreCase("null"))
objectDef.hasActions = false;
return objectDef;
}
public static ObjectDef forIDOSRS(int i) {
for(int j = 0; j < 20; j++)
if(cache[j].type == i)
return cache[j];
cacheIndex = (cacheIndex + 1) % 20;
ObjectDef objectDef = cache[cacheIndex];
stream2.currentOffset = streamIndices2[i];
objectDef.type = i;
objectDef.setDefaults();
try {
objectDef.readValuesOSRS(stream);
} catch (Exception e) {
e.printStackTrace();
}
return objectDef;
}
private void setDefaults() {
anIntArray773 = null;
anIntArray776 = null;
name = null;
description = null;
modifiedModelColors = null;
originalModelColors = null;
anInt744 = 1;
anInt761 = 1;
aBoolean767 = true;
aBoolean757 = true;
hasActions = false;
aBoolean762 = false;
aBoolean769 = false;
aBoolean764 = false;
anInt781 = -1;
anInt775 = 16;
actions = null;
anInt746 = -1;
anInt758 = -1;
aBoolean751 = false;
aBoolean779 = true;
modelSizeX = 128;
modelSizeH = 128;
modelSizeY = 128;
anInt768 = 0;
offsetX = 0;
offsetH = 0;
offsetY = 0;
aBoolean736 = false;
isSolidObject = false;
anInt760 = -1;
anInt774 = -1;
anInt749 = -1;
childrenIDs = null;
}
public void method574(OnDemandFetcher class42_sub1) {
if (anIntArray773 == null)
return;
for (int j = 0; j < anIntArray773.length; j++)
class42_sub1.method560(anIntArray773[j] & 0xffff, 0);
}
public static void nullLoader() {
mruNodes1 = null;
mruNodes2 = null;
streamIndices = null;
cache = null;
stream = null;
}
public static void unpackConfig(StreamLoader streamLoader) {
stream = new Stream(streamLoader.getDataForName("667loc.dat"));
Stream stream = new Stream(streamLoader.getDataForName("667loc.idx"));
stream2 = new Stream(FileOperations.ReadFile(Signlink.findcachedir() + "Data/locOSRS.dat"));
Stream stream2 = new Stream(FileOperations.ReadFile(Signlink.findcachedir() + "Data/locOSRS.idx"));
int totalObjects = stream.readUnsignedWord();//667
int totalObjects2 = stream2.readUnsignedWord();//osrs
System.out.println("667 Object Amount: " + totalObjects);
System.out.println("OSRS Object Amount: " + totalObjects2);
streamIndices = new int[totalObjects];
int i = 2;
for (int j = 0; j < totalObjects; j++) {
streamIndices[j] = i;
i += stream.readUnsignedWord();
}
totalObjects = totalObjects2;
streamIndices2 = new int[totalObjects];
i = 2;
for (int j = 0; j < totalObjects; j++) {
streamIndices2[j] = i;
i += stream2.readUnsignedWord();
}
cache = new ObjectDef[20];
for (int k = 0; k < 20; k++)
cache[k] = new ObjectDef();
}
public boolean method577(int i) {
if (anIntArray776 == null) {
if (anIntArray773 == null)
return true;
if (i != 10)
return true;
boolean flag1 = true;
for (int k = 0; k < anIntArray773.length; k++)
flag1 &= Model.method463(anIntArray773[k] & 0xffff);
return flag1;
}
for (int j = 0; j < anIntArray776.length; j++)
if (anIntArray776[j] == i)
return Model.method463(anIntArray773[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 (aBoolean762 || aBoolean769)
model = new Model(aBoolean762, aBoolean769, model);
if (aBoolean762) {
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 (anIntArray773 == null)
return true;
boolean flag1 = true;
for (int i = 0; i < anIntArray773.length; i++)
flag1 &= Model.method463(anIntArray773[i] & 0xffff);
return flag1;
}
public ObjectDef method580() {
int i = -1;
if (anInt774 != -1) {
VarBit varBit = VarBit.cache[anInt774];
int j = varBit.configId;
int k = varBit.leastSignificantBit;
int l = varBit.mostSignificantBit;
int i1 = Client.anIntArray1232[l - k];
i = clientInstance.variousSettings[j] >> k & i1;
} else if (anInt749 != -1)
i = clientInstance.variousSettings[anInt749];
if (i < 0 || i >= childrenIDs.length || childrenIDs[i] == -1)
return null;
else
return forID(childrenIDs[i]);
}
private Model method581(int j, int k, int l) {
Model model = null;
long l1;
if (anIntArray776 == null) {
if (j != 10)
return null;
l1 = (long) ((type << 8) + l) + ((long) (k + 1) << 32);
Model model_1 = (Model) mruNodes2.insertFromCache(l1);
if (model_1 != null)
return model_1;
if (anIntArray773 == null)
return null;
boolean flag1 = aBoolean751 ^ (l > 3);
int k1 = anIntArray773.length;
for (int i2 = 0; i2 < k1; i2++) {
int l2 = anIntArray773[i2];
if (flag1)
l2 += 0x10000;
model = (Model) mruNodes1.insertFromCache(l2);
if (model == null) {
model = Model.method462(l2 & 0xffff);
if (model == null)
return null;
if (flag1)
model.method477();
mruNodes1.removeFromCache(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 < anIntArray776.length; j1++) {
if (anIntArray776[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.insertFromCache(l1);
if (model_2 != null)
return model_2;
int j2 = anIntArray773[i1];
boolean flag3 = aBoolean751 ^ (l > 3);
if (flag3)
j2 += 0x10000;
model = (Model) mruNodes1.insertFromCache(j2);
if (model == null) {
model = Model.method462(j2 & 0xffff);
if (model == null)
return null;
if (flag3)
model.method477();
mruNodes1.removeFromCache(model, j2);
}
}
boolean flag;
flag = modelSizeX != 128 || modelSizeH != 128 || modelSizeY != 128;
boolean flag2;
flag2 = offsetX != 0 || offsetH != 0 || offsetY != 0;
Model model_3 = new Model(modifiedModelColors == null,
Class36.method532(k), l == 0 && k == -1 && !flag && !flag2, model);
if (k != -1) {
model_3.method469();
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.method476(modifiedModelColors[k2],
originalModelColors[k2]);
}
if (flag)
model_3.method478(modelSizeX, modelSizeY, modelSizeH);
if (flag2)
model_3.method475(offsetX, offsetH, offsetY);
model_3.method479(74, 1000, -90, -580, -90, !aBoolean769);
if (anInt760 == 1)
model_3.anInt1654 = model_3.modelHeight;
mruNodes2.removeFromCache(model_3, l1);
return model_3;
}
private void readValues(Stream stream) {
int i = -1;
label0: do {
int opcode;
do {
opcode = stream.readUnsignedByte();
if (opcode == 0)
break label0;
if (opcode == 1) {
int k = stream.readUnsignedByte();
if (k > 0)
if (anIntArray773 == null || lowMem) {
anIntArray776 = new int[k];
anIntArray773 = new int[k];
for (int k1 = 0; k1 < k; k1++) {
anIntArray773[k1] = stream.readUnsignedWord();
anIntArray776[k1] = stream.readUnsignedByte();
}
} else {
stream.currentOffset += k * 3;
}
} else if (opcode == 2)
name = stream.readString();
else if (opcode == 3)
description = stream.readBytes();
else if (opcode == 5) {
int l = stream.readUnsignedByte();
if (l > 0)
if (anIntArray773 == null || lowMem) {
anIntArray776 = null;
anIntArray773 = new int[l];
for (int l1 = 0; l1 < l; l1++)
anIntArray773[l1] = stream.readUnsignedWord();
} else {
stream.currentOffset += l * 2;
}
} else if (opcode == 14)
anInt744 = stream.readUnsignedByte();
else if (opcode == 15)
anInt761 = stream.readUnsignedByte();
else if (opcode == 17)
aBoolean767 = false;
else if (opcode == 18)
aBoolean757 = false;
else if (opcode == 19) {
i = stream.readUnsignedByte();
if(i == 1)
hasActions = true;
} else if (opcode == 21)
aBoolean762 = true;
else if (opcode == 22)
aBoolean769 = false;
else if (opcode == 23)
aBoolean764 = true;
else if (opcode == 24) {
anInt781 = stream.readUnsignedWord();
if (anInt781 == 65535)
anInt781 = -1;
} else if (opcode == 28)
anInt775 = stream.readUnsignedByte();
else if (opcode == 29)
stream.readSignedByte();
else if (opcode == 39)
stream.readSignedByte();
else if (opcode >= 30 && opcode < 39) {
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 i1 = stream.readUnsignedByte();
modifiedModelColors = new int[i1];
originalModelColors = new int[i1];
for (int i2 = 0; i2 < i1; i2++) {
modifiedModelColors[i2] = stream.readUnsignedWord();
originalModelColors[i2] = stream.readUnsignedWord();
}
} else if (opcode == 60)
anInt746 = stream.readUnsignedWord();
else if (opcode == 62)
aBoolean751 = true;
else if (opcode == 64)
aBoolean779 = false;
else if (opcode == 65)
modelSizeX = stream.readUnsignedWord();
else if (opcode == 66)
modelSizeH = stream.readUnsignedWord();
else if (opcode == 67)
modelSizeY = stream.readUnsignedWord();
else if (opcode == 68)
anInt758 = stream.readUnsignedWord();
else if (opcode == 69)
anInt768 = stream.readUnsignedByte();
else if (opcode == 70)
offsetX = stream.readSignedWord();
else if (opcode == 71)
offsetH = stream.readSignedWord();
else if (opcode == 72)
offsetY = stream.readSignedWord();
else if (opcode == 73)
aBoolean736 = true;
else if (opcode == 74) {
isSolidObject = true;
} else {
if (opcode != 75)
continue;
anInt760 = stream.readUnsignedByte();
}
continue label0;
} while (opcode != 77);
anInt774 = stream.readUnsignedWord();
if (anInt774 == 65535)
anInt774 = -1;
anInt749 = stream.readUnsignedWord();
if (anInt749 == 65535)
anInt749 = -1;
int j1 = stream.readUnsignedByte();
childrenIDs = new int[j1 + 1];
for (int j2 = 0; j2 <= j1; j2++) {
childrenIDs[j2] = stream.readUnsignedWord();
if (childrenIDs[j2] == 65535)
childrenIDs[j2] = -1;
}
} while (true);
if (i == -1) {
hasActions = anIntArray773 != null
&& (anIntArray776 == null || anIntArray776[0] == 10);
if (actions != null)
hasActions = true;
}
if (isSolidObject) {
aBoolean767 = false;
aBoolean757 = false;
}
if (anInt760 == -1)
anInt760 = aBoolean767 ? 1 : 0;
}
private void readValuesOSRS(Stream stream) {
int flag = -1;
do {
int type = stream.readUnsignedByte();
if (type == 0)
break;
if (type == 1) {
int len = stream.readUnsignedByte();
if (len > 0) {
if (anIntArray773 == null || lowMem) {
anIntArray776 = new int[len];
anIntArray773 = new int[len];
for (int k1 = 0; k1 < len; k1++) {
anIntArray773[k1] = stream.readUnsignedWord();
anIntArray776[k1] = stream.readUnsignedByte();
}
} else {
stream.currentOffset += len * 3;
}
}
} else if (type == 2)
name = stream.readString();
else if (type == 3)
description = stream.readBytes();
else if (type == 5) {
int len = stream.readUnsignedByte();
if (len > 0) {
if (anIntArray773 == null || lowMem) {
anIntArray776 = null;
anIntArray773 = new int[len];
for (int l1 = 0; l1 < len; l1++)
anIntArray773[l1] = stream.readUnsignedWord();
} else {
stream.currentOffset += len * 2;
}
}
} else if (type == 14)
anInt744 = stream.readUnsignedByte();
else if (type == 15)
anInt761 = stream.readUnsignedByte();
else if (type == 17)
aBoolean767 = false;
else if (type == 18)
aBoolean757 = false;
else if (type == 19)
hasActions = (stream.readUnsignedByte() == 1);
else if (type == 21)
aBoolean762 = true;
else if (type == 22)
aBoolean769 = false;
else if (type == 23)
aBoolean764 = true;
else if (type == 24) {
anInt781 = stream.readUnsignedWord();
if (anInt781 == 65535)
anInt781 = -1;
} else if (type == 28)
anInt775 = stream.readUnsignedByte();
else if (type == 29)
stream.readSignedByte();
else if (type == 39)
stream.readSignedByte();
else if (type >= 30 && type < 39) {
if (actions == null)
actions = new String[5];
actions[type - 30] = stream.readString();
if (actions[type - 30].equalsIgnoreCase("hidden"))
actions[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.readUnsignedWord();
originalModelColors[i2] = stream.readUnsignedWord();
}
} 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.readUnsignedWord();
originalTexture[k] = (short) stream.readUnsignedWord();
}
} else if (type == 60)
anInt746 = stream.readUnsignedWord();
else if (type == 62)
aBoolean751 = true;
else if (type == 64)
aBoolean779 = false;
else if (type == 65)
modelSizeX = stream.readUnsignedWord();
else if (type == 66)
modelSizeH = stream.readUnsignedWord();
else if (type == 67)
modelSizeY = stream.readUnsignedWord();
else if (type == 68)
anInt758 = stream.readUnsignedWord();
else if (type == 69)
anInt768 = stream.readUnsignedByte();
else if (type == 70)
offsetX = stream.readSignedWord();
else if (type == 71)
offsetH = stream.readSignedWord();
else if (type == 72)
offsetY = stream.readSignedWord();
else if (type == 73)
aBoolean736 = true;
else if (type == 74)
isSolidObject = true;
else if (type == 75)
anInt760 = stream.readUnsignedByte();
else if (type == 77) {
anInt774 = stream.readUnsignedWord();
if (anInt774 == 65535)
anInt774 = -1;
anInt749 = stream.readUnsignedWord();
if (anInt749 == 65535)
anInt749 = -1;
int j1 = stream.readUnsignedByte();
childrenIDs = new int[j1 + 1];
for (int j2 = 0; j2 <= j1; j2++) {
childrenIDs[j2] = stream.readUnsignedWord();
if (childrenIDs[j2] == 65535)
childrenIDs[j2] = -1;
}
}
} while (true);
if (flag == -1 && name != "null" && name != null) {
hasActions = anIntArray773 != null
&& (anIntArray776 == null || anIntArray776[0] == 10);
if (actions != null)
hasActions = true;
}
if (isSolidObject) {
aBoolean767 = false;
aBoolean757 = false;
}
if (anInt760 == -1)
anInt760 = aBoolean767 ? 1 : 0;
}
private short[] originalTexture;
private short[] modifiedTexture;
public static void ObjectDump(StreamLoader streamLoader) {
stream = new Stream(streamLoader.getDataForName("667loc.dat"));
Stream stream2 = new Stream(streamLoader.getDataForName("667loc.idx"));
int totalObjects = stream2.readUnsignedWord();
try {
FileWriter fw = new FileWriter(System.getProperty("user.home")+"/Desktop/Object Dump.txt");
for(int i = 0; i < totalObjects; i++) {
ObjectDef ed = ObjectDef.forID(i);
fw.write("case "+i+":");
fw.write(System.getProperty("line.separator"));
fw.write("objectDef.name = \""+ed.name+"\";");
fw.write(System.getProperty("line.separator"));
fw.write("objectDef.description = \""+ed.description+"\";");
fw.write(System.getProperty("line.separator"));
fw.write("objectDef.offsetH = \""+ed.offsetH+"\";");
fw.write(System.getProperty("line.separator"));
if(ed.actions != null) {
fw.write("objectDef.actions = new String["+ed.actions.length+"];");
fw.write(System.getProperty("line.separator"));
for(int range = 0; range < ed.actions.length; range++) {
if(ed.actions[range] != null) {
fw.write("objectDef.actions["+range+"] = \""+ed.actions[range]+"\";");
fw.write(System.getProperty("line.separator"));
}
}
}
if(ed.anIntArray773 != null) {
fw.write("objectDef.models = new int["+ed.anIntArray773.length+"];");
fw.write(System.getProperty("line.separator"));
for(int range = 0; range < ed.anIntArray773.length; range++) {
fw.write("objectDef.models["+range+"] = "+ed.anIntArray773[range]+";");
fw.write(System.getProperty("line.separator"));
}
}
fw.write("break;");
fw.write(System.getProperty("line.separator"));
fw.write(System.getProperty("line.separator"));
}
fw.close();
System.out.println("object Dump Finished.");
System.out.println("Total objects: " + totalObjects);
} catch(Exception e) {
e.printStackTrace();
}
}
private ObjectDef() {
type = -1;
}
public boolean aBoolean736;
private int offsetX;
public String name;
private int modelSizeY;
private static final Model[] aModelArray741s = new Model[4];
public int anInt744;
private int offsetH;
public int anInt746;
private int[] originalModelColors;
private int modelSizeX;
public int anInt749;
private boolean aBoolean751;
public static boolean lowMem;
private static Stream stream;
private static Stream stream2;
public int type;
private static int[] streamIndices;
private static int[] streamIndices2;
public boolean aBoolean757;
public int anInt758;
public int childrenIDs[];
private int anInt760;
public int anInt761;
public boolean aBoolean762;
public boolean aBoolean764;
public static Client clientInstance;
private boolean isSolidObject;
public boolean aBoolean767;
public int anInt768;
private boolean aBoolean769;
private static int cacheIndex;
private int modelSizeH;
public int[] anIntArray773;
public int anInt774;
public int anInt775;
public int[] anIntArray776;
public byte description[];
public boolean hasActions;
public boolean aBoolean779;
public static MRUNodes mruNodes2 = new MRUNodes(30);
public int anInt781;
private static ObjectDef[] cache;
private int offsetY;
private int[] modifiedModelColors;
public static MRUNodes mruNodes1 = new MRUNodes(500);
public String actions[];
}