use of org.apollo.net.codec.game.GamePacketReader in project apollo by apollo-rsps.
the class ButtonMessageDecoder method decode.
@Override
public ButtonMessage decode(GamePacket packet) {
GamePacketReader reader = new GamePacketReader(packet);
int interfaceId = (int) reader.getUnsigned(DataType.SHORT);
return new ButtonMessage(interfaceId);
}
use of org.apollo.net.codec.game.GamePacketReader in project apollo by apollo-rsps.
the class TakeTileItemMessageDecoder method decode.
@Override
public TakeTileItemMessage decode(GamePacket packet) {
GamePacketReader reader = new GamePacketReader(packet);
int y = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE);
int id = (int) reader.getUnsigned(DataType.SHORT);
int x = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE);
return new TakeTileItemMessage(id, new Position(x, y));
}
use of org.apollo.net.codec.game.GamePacketReader in project apollo by apollo-rsps.
the class ThirdObjectActionMessageDecoder method decode.
@Override
public ObjectActionMessage decode(GamePacket packet) {
GamePacketReader reader = new GamePacketReader(packet);
int x = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE);
int y = (int) reader.getUnsigned(DataType.SHORT);
int id = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD);
return new ObjectActionMessage(3, id, new Position(x, y));
}
use of org.apollo.net.codec.game.GamePacketReader in project apollo by apollo-rsps.
the class WalkMessageDecoder method decode.
@Override
public WalkMessage decode(GamePacket packet) {
GamePacketReader reader = new GamePacketReader(packet);
int length = packet.getLength();
if (packet.getOpcode() == 248) {
// strip off anti-cheat data
length -= 14;
}
int steps = (length - 5) / 2;
int[][] path = new int[steps][2];
int x = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD);
for (int i = 0; i < steps; i++) {
path[i][0] = (int) reader.getSigned(DataType.BYTE);
path[i][1] = (int) reader.getSigned(DataType.BYTE);
}
int y = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE);
boolean run = reader.getUnsigned(DataType.BYTE, DataTransformation.NEGATE) == 1;
Position[] positions = new Position[steps + 1];
positions[0] = new Position(x, y);
for (int i = 0; i < steps; i++) {
positions[i + 1] = new Position(path[i][0] + x, path[i][1] + y);
}
return new WalkMessage(positions, run);
}
use of org.apollo.net.codec.game.GamePacketReader in project apollo by apollo-rsps.
the class SecondItemActionMessageDecoder method decode.
@Override
public ItemActionMessage decode(GamePacket packet) {
GamePacketReader reader = new GamePacketReader(packet);
int interfaceId = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD);
int id = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD);
int slot = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE);
return new ItemActionMessage(2, interfaceId, id, slot);
}
Aggregations