use of org.apollo.net.codec.game.GamePacketBuilder in project apollo by apollo-rsps.
the class NpcSynchronizationMessageEncoder method encode.
@Override
public GamePacket encode(NpcSynchronizationMessage message) {
GamePacketBuilder builder = new GamePacketBuilder(71, PacketType.VARIABLE_SHORT);
builder.switchToBitAccess();
GamePacketBuilder blockBuilder = new GamePacketBuilder();
builder.putBits(8, message.getLocalNpcCount());
for (SynchronizationSegment segment : message.getSegments()) {
SegmentType type = segment.getType();
if (type == SegmentType.REMOVE_MOB) {
putRemoveNpcUpdate(builder);
} else if (type == SegmentType.ADD_MOB) {
putAddNpcUpdate((AddNpcSegment) segment, message, builder);
putBlocks(segment, blockBuilder);
} else {
putMovementUpdate(segment, message, builder);
putBlocks(segment, blockBuilder);
}
}
if (blockBuilder.getLength() > 0) {
builder.putBits(14, 16383);
builder.switchToByteAccess();
builder.putRawBuilder(blockBuilder);
} else {
builder.switchToByteAccess();
}
return builder.toGamePacket();
}
use of org.apollo.net.codec.game.GamePacketBuilder in project apollo by apollo-rsps.
the class OpenDialogueOverlayMessageEncoder method encode.
@Override
public GamePacket encode(OpenDialogueOverlayMessage message) {
GamePacketBuilder builder = new GamePacketBuilder(158);
builder.put(DataType.SHORT, DataOrder.LITTLE, message.getInterfaceId());
return builder.toGamePacket();
}
use of org.apollo.net.codec.game.GamePacketBuilder in project apollo by apollo-rsps.
the class OpenInterfaceSidebarMessageEncoder method encode.
@Override
public GamePacket encode(OpenInterfaceSidebarMessage message) {
GamePacketBuilder builder = new GamePacketBuilder(128);
builder.put(DataType.SHORT, DataTransformation.ADD, message.getInterfaceId());
builder.put(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD, message.getSidebarId());
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(88);
builder.put(DataType.BYTE, DataTransformation.SUBTRACT, message.getPositionOffset());
builder.put(DataType.BYTE, DataTransformation.SUBTRACT, message.getType() << 2 | message.getOrientation());
return builder.toGamePacket();
}
use of org.apollo.net.codec.game.GamePacketBuilder in project apollo by apollo-rsps.
the class SendFriendMessageEncoder method encode.
@Override
public GamePacket encode(SendFriendMessage message) {
GamePacketBuilder builder = new GamePacketBuilder(78);
builder.put(DataType.LONG, NameUtil.encodeBase37(message.getUsername()));
builder.put(DataType.BYTE, message.getWorld());
return builder.toGamePacket();
}
Aggregations