use of org.apollo.net.codec.game.GamePacketBuilder in project apollo by apollo-rsps.
the class ClearRegionMessageEncoder method encode.
@Override
public GamePacket encode(ClearRegionMessage message) {
GamePacketBuilder builder = new GamePacketBuilder(40);
Position player = message.getPlayerPosition(), region = message.getRegionPosition();
builder.put(DataType.BYTE, DataTransformation.SUBTRACT, region.getLocalY(player));
builder.put(DataType.BYTE, DataTransformation.NEGATE, region.getLocalX(player));
return builder.toGamePacket();
}
use of org.apollo.net.codec.game.GamePacketBuilder in project apollo by apollo-rsps.
the class DisplayTabInterfaceMessageEncoder method encode.
@Override
public GamePacket encode(DisplayTabInterfaceMessage message) {
GamePacketBuilder builder = new GamePacketBuilder(252);
builder.put(DataType.BYTE, DataTransformation.NEGATE, message.getTab());
return builder.toGamePacket();
}
use of org.apollo.net.codec.game.GamePacketBuilder in project apollo by apollo-rsps.
the class ConfigMessageEncoder method encode.
@Override
public GamePacket encode(ConfigMessage message) {
GamePacketBuilder builder;
int value = message.getValue();
if (value > Byte.MIN_VALUE && value < Byte.MAX_VALUE) {
builder = new GamePacketBuilder(182);
builder.put(DataType.SHORT, DataTransformation.ADD, message.getId());
builder.put(DataType.BYTE, DataTransformation.SUBTRACT, value & 0xFF);
} else {
builder = new GamePacketBuilder(115);
builder.put(DataType.INT, DataOrder.INVERSED_MIDDLE, value);
builder.put(DataType.SHORT, DataOrder.LITTLE, message.getId());
}
return builder.toGamePacket();
}
use of org.apollo.net.codec.game.GamePacketBuilder in project apollo by apollo-rsps.
the class DisplayCrossbonesMessageEncoder method encode.
@Override
public GamePacket encode(DisplayCrossbonesMessage message) {
GamePacketBuilder builder = new GamePacketBuilder(233);
builder.put(DataType.BYTE, message.isDisplayed() ? 1 : 0);
return builder.toGamePacket();
}
use of org.apollo.net.codec.game.GamePacketBuilder in project apollo by apollo-rsps.
the class RemoveObjectMessageEncoder method encode.
@Override
public GamePacket encode(RemoveObjectMessage message) {
GamePacketBuilder builder = new GamePacketBuilder(101);
builder.put(DataType.BYTE, DataTransformation.NEGATE, message.getType() << 2 | message.getOrientation());
builder.put(DataType.BYTE, message.getPositionOffset());
return builder.toGamePacket();
}
Aggregations