Well my Client doesn't wanna recieve streams that I am sending:
Code:
java.lang.ArrayIndexOutOfBoundsException: 52
at Stream.method526(Stream.java:311)
at Stream.method527(Stream.java:320)
at Player.updatePlayerApperance(Player.java:414)
at Client.method63(Client.java:10756)
at Client.method40(Client.java:8893)
at Client.method96(Client.java:13780)
at Client.method33(Client.java:8341)
at Client.method28(Client.java:6253)
at Client.method7(Client.java:11248)
at RSApplet.run(RSApplet.java:532)
at Client.run(Client.java:13948)
at java.lang.Thread.run(Unknown Source)
Client side method:
Code:
public void updatePlayerApperance(Stream stream, int i) {
stream.currentOffset = 0;
playerGender = stream.readUnsignedByte();
pkIcon = stream.readByte();
prayerIcon = stream.readByte();
aEntityDef_1757 = null;
anInt1766 = 0;
for (int j = 0; j < 12; j++) {
final int k = stream.readUnsignedByte();
if (k == 0) {
playerClothing[j] = 0;
continue;
}
final int i1 = stream.readUnsignedByte();
playerClothing[j] = (k << 8) + i1;
if (j == 0 && playerClothing[0] == 65535) {
aEntityDef_1757 = EntityDef.method364(stream.readUnsignedShort());
break;
}
if (playerClothing[j] >= 512
&& playerClothing[j] - 512 < ItemDef.anInt335) {
final int l1 = ItemDef.method212(playerClothing[j] - 512).anInt332;
if (l1 != 0) {
anInt1766 = l1;
}
}
}
for (int l = 0; l < 5; l++) {
int j1 = stream.readUnsignedByte();
if (j1 < 0 || j1 >= Client.anIntArrayArray1008[l].length) {
j1 = 0;
}
anIntArray1760[l] = j1;
}
super.anInt1634 = stream.readUnsignedShort();
if (super.anInt1634 == 65535) {
super.anInt1634 = -1;
}
super.anInt1635 = stream.readUnsignedShort();
if (super.anInt1635 == 65535) {
super.anInt1635 = -1;
}
super.anInt1619 = stream.readUnsignedShort();
if (super.anInt1619 == 65535) {
super.anInt1619 = -1;
}
super.anInt1620 = stream.readUnsignedShort();
if (super.anInt1620 == 65535) {
super.anInt1620 = -1;
}
super.anInt1621 = stream.readUnsignedShort();
if (super.anInt1621 == 65535) {
super.anInt1621 = -1;
}
super.anInt1622 = stream.readUnsignedShort();
if (super.anInt1622 == 65535) {
super.anInt1622 = -1;
}
super.anInt1629 = stream.readUnsignedShort();
if (super.anInt1629 == 65535) {
super.anInt1629 = -1;
}
aString1751 = TextClass.method303(TextClass.method300(stream
.method527(-149), 0), (byte) 7);
anInt1753 = stream.readUnsignedByte();
anInt1759 = stream.readUnsignedShort();
aBoolean1758 = true;
truePlayer = 0L;
final int k1 = playerClothing[5];
final int i2 = playerClothing[9];
if (i != 0) {
return;
}
playerClothing[5] = i2;
playerClothing[9] = k1;
for (int j2 = 0; j2 < 12; j2++) {
truePlayer <<= 4;
if (playerClothing[j2] >= 256) {
truePlayer += playerClothing[j2] - 256;
}
}
if (playerClothing[0] >= 256) {
truePlayer += playerClothing[0] - 256 >> 4;
}
if (playerClothing[1] >= 256) {
truePlayer += playerClothing[1] - 256 >> 8;
}
playerClothing[5] = k1;
playerClothing[9] = i2;
for (int k2 = 0; k2 < 5; k2++) {
truePlayer <<= 3;
truePlayer += anIntArray1760[k2];
}
truePlayer <<= 1;
truePlayer += playerGender;
}
my server side:
Code:
private static void appendAppearanceUpdate(Player p, StaticPacketBuilder updateBlock) {
StaticPacketBuilder playerProps = new StaticPacketBuilder().setBare(true);
Appearance app = p.getAppearance();
playerProps.addByte((byte) (app.getGender() & 0xFF));
playerProps.addByte((byte) p.getHeadIcons().getPkIcon());
playerProps.addByte((byte) p.getHeadIcons().getPrayerIcon());
for(int i = 0; i < 4; i ++) {
if(p.getEquipment().get(i) != null) {
playerProps.addShort(32768 + p.getEquipment().get(i).getId());
} else {
playerProps.addByte((byte) 0);
}
}
if(p.getEquipment().get(Equipment.SLOT_CHEST) != null) {
playerProps.addShort(32768 + p.getEquipment().get(Equipment.SLOT_CHEST).getId());
} else {
playerProps.addShort(0x100 + app.getLook(2));
}
if(p.getEquipment().get(Equipment.SLOT_SHIELD) != null) {
playerProps.addShort(32768 + p.getEquipment().get(Equipment.SLOT_SHIELD).getId());
} else {
playerProps.addByte((byte) 0);
}
Item chest = p.getEquipment().get(Equipment.SLOT_CHEST);
if(chest != null) {
if(!Equipment.isFullBody(chest.getDefinition())) {
playerProps.addShort(0x100 + app.getLook(3));
} else {
playerProps.addByte((byte) 0);
}
} else {
playerProps.addShort(0x100 + app.getLook(3));
}
if(p.getEquipment().get(Equipment.SLOT_LEGS) != null) {
playerProps.addShort(32768 + p.getEquipment().get(Equipment.SLOT_LEGS).getId());
} else {
playerProps.addShort(0x100 + app.getLook(5));
}
Item hat = p.getEquipment().get(Equipment.SLOT_HAT);
if(hat != null) {
if(!Equipment.isFullHat(hat.getDefinition()) && !Equipment.isFullMask(hat.getDefinition())) {
playerProps.addShort(0x100 + app.getLook(0));
} else {
playerProps.addByte((byte) 0);
}
} else {
playerProps.addShort(0x100 + app.getLook(0));
}
if(p.getEquipment().get(Equipment.SLOT_HANDS) != null) {
playerProps.addShort(32768 + p.getEquipment().get(Equipment.SLOT_HANDS).getDefinition().getEquipId());
} else {
playerProps.addShort(0x100 + app.getLook(4));
}
if(p.getEquipment().get(Equipment.SLOT_FEET) != null) {
playerProps.addShort(32768 + p.getEquipment().get(Equipment.SLOT_FEET).getDefinition().getEquipId());
} else {
playerProps.addShort(0x100 + app.getLook(6));
}
if(hat != null) {
if(!Equipment.isFullMask(hat.getDefinition())) {
playerProps.addShort(0x100 + app.getLook(1));
} else {
playerProps.addByte((byte) 0);
}
} else {
playerProps.addShort(0x100 + app.getLook(1));
}
for (int i = 0; i < 5; i ++) {
playerProps.addByte((byte) (app.getColour(i) * 0xFF));
}
//Animations
playerProps.addShort(0x333);
playerProps.addShort(0x334);
playerProps.addShort(0x335);
playerProps.addShort(0x336);
playerProps.addShort(0x337);
playerProps.addShort(0x338);
playerProps.addShort(0x339);
playerProps.addLong(Misc.stringToLong(
Misc.formatPlayerNameForProtocol(p.getUsername())));
playerProps.addByte((byte)p.getSkills().getCombatLevel());
playerProps.addShort(0);
updateBlock.addByte((byte) (playerProps.getLength() & 0xFF));
updateBlock.addBytes(playerProps.toPacket().getData(), 0, playerProps.getLength());
}
Yes I know animations are wrong.
And the error is happening on this line:
Code:
aString1751 = TextClass.method303(TextClass.method300(stream
.method527(-149), 0), (byte) 7);
I seriously got no idea, I put this in Client and Server section as I hope someone has had this before lulz and as a reference for others in the future.