@Override public ByteMessage write(Player player) { ByteMessage msg = ByteMessage.message(248); msg.putShort(interfaceId, ByteTransform.A); msg.putShort(overlayInterfaceId); return msg; }
@Override public ByteMessage write(Player player) { ByteMessage msg = ByteMessage.message(34, MessageType.VARIABLE_SHORT); msg.putShort(id); msg.put(index); msg.putShort(item.getId() + 1); if (item.getAmount() > 254) { msg.put(255); msg.putShort(item.getAmount()); } else { msg.put(item.getAmount()); } return msg; }
@Override public Event read(Player player, GameMessage msg) throws Exception { int opcode = msg.getOpcode(); int size = msg.getSize(); ByteMessage payload = msg.getPayload(); if (opcode == 248) { // Minimap click. size -= 14; player.interruptAction(); } else if (opcode == 164) { // Yellow <x> click. player.interruptAction(); } else if (opcode == 98) { // Red <x> click. // impl } int pathSize = (size - 5) / 2; int[][] path = new int[pathSize][2]; int x = payload.getShort(false, ByteTransform.A, ByteOrder.LITTLE); for (int i = 0; i < pathSize; i++) { path[i][0] = payload.get(); path[i][1] = payload.get(); } int y = payload.getShort(false, ByteOrder.LITTLE); boolean running = payload.get(false, ByteTransform.S) == 1; WalkingQueue walkingQueue = player.getWalkingQueue(); walkingQueue.setRunningPath(running); walkingQueue.clear(); Step[] steps = new Step[pathSize + 1]; walkingQueue.addFirst(steps[0] = new Step(x, y)); for (int i = 0; i < pathSize; i++) { walkingQueue.add(steps[i + 1] = new Step(path[i][0] + x, path[i][1] + y)); } return new WalkingEvent(steps, running); }
@Override public void write(Player mob, ByteMessage msg) { msg.putShort(mob.getGraphic().getId(), ByteOrder.LITTLE); msg.putInt(mob.getGraphic().getHeight() << 16 | mob.getGraphic().getDelay() & 0xFFFF); }
@Override public ByteMessage write(Player player) { ByteMessage msg = ByteMessage.message(164); msg.putShort(id, ByteOrder.LITTLE); return msg; }