Okay boys, where the heck am I going wrong?
Client Sided NPC Bits:
Code:
private void updateNewNPCs(int i, JagexBuffer stream) {
while (stream.bitPosition + 21 < i * 8) {
int k = stream.readBits(12);
if (k == 4096)
break;
if (npcArray[k] == null)
npcArray[k] = new NPC();
NPC npc = npcArray[k];
npcIndices[npcCount++] = k;
npc.updateCycle = loopCycle;
int l = stream.readBits(5);
if (l > 15)
l -= 32;
int i1 = stream.readBits(5);
if (i1 > 15)
i1 -= 32;
int j1 = stream.readBits(1);
npc.desc = stream.readBits(12);
int k1 = stream.readBits(1);
if (k1 == 1)
entityIndices[entityCount++] = k;
NPCDef def = npc.desc();
npc.size = def.aByte68;
npc.anInt1504 = def.anInt79;
npc.walkSequence = def.anInt67;
npc.turn180Sequence = def.anInt58;
npc.turnRightSequence = def.anInt83;
npc.turnLeftSequence = def.anInt55;
npc.standSequence = def.anInt77;
npc.runAnimation = def.runAnimIndex;
npc.setPos(myPlayer.smallX[0] + i1, myPlayer.smallY[0] + l, j1 == 1);
}
stream.finishBitAccess();
}
Server sided NPC Bits
Code:
public static void addNewNpc(StreamBuffer.OutBuffer out, Player player, Npc npc) {
out.writeBits(12, npc.getIndex());
Position delta = Misc.delta(player.getPosition(), npc.getPosition());
out.writeBits(5, delta.getY());
out.writeBits(5, delta.getX());
out.writeBits(1, 0);
out.writeBits(12, npc.getNpcId());
out.writeBit(true);
}