Search in sources :

Example 56 with GamePacketBuilder

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();
}
Also used : SegmentType(org.apollo.game.sync.seg.SegmentType) AddNpcSegment(org.apollo.game.sync.seg.AddNpcSegment) GamePacketBuilder(org.apollo.net.codec.game.GamePacketBuilder) SynchronizationSegment(org.apollo.game.sync.seg.SynchronizationSegment)

Example 57 with GamePacketBuilder

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();
}
Also used : GamePacketBuilder(org.apollo.net.codec.game.GamePacketBuilder)

Example 58 with GamePacketBuilder

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();
}
Also used : GamePacketBuilder(org.apollo.net.codec.game.GamePacketBuilder)

Example 59 with GamePacketBuilder

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();
}
Also used : GamePacketBuilder(org.apollo.net.codec.game.GamePacketBuilder)

Example 60 with GamePacketBuilder

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();
}
Also used : GamePacketBuilder(org.apollo.net.codec.game.GamePacketBuilder)

Aggregations

GamePacketBuilder (org.apollo.net.codec.game.GamePacketBuilder)93 Position (org.apollo.game.model.Position)9 Item (org.apollo.game.model.Item)6 HintIconMessage (org.apollo.game.message.impl.HintIconMessage)4 SegmentType (org.apollo.game.sync.seg.SegmentType)4 SynchronizationSegment (org.apollo.game.sync.seg.SynchronizationSegment)4 EquipmentDefinition (org.apollo.cache.def.EquipmentDefinition)2 GroupedRegionUpdateMessage (org.apollo.game.message.impl.GroupedRegionUpdateMessage)2 Type (org.apollo.game.message.impl.HintIconMessage.Type)2 MobHintIconMessage (org.apollo.game.message.impl.MobHintIconMessage)2 PositionHintIconMessage (org.apollo.game.message.impl.PositionHintIconMessage)2 RegionUpdateMessage (org.apollo.game.message.impl.RegionUpdateMessage)2 Appearance (org.apollo.game.model.Appearance)2 Skill (org.apollo.game.model.entity.Skill)2 Inventory (org.apollo.game.model.inv.Inventory)2 SlottedItem (org.apollo.game.model.inv.SlottedItem)2 AddNpcSegment (org.apollo.game.sync.seg.AddNpcSegment)2 AddPlayerSegment (org.apollo.game.sync.seg.AddPlayerSegment)2 GamePacket (org.apollo.net.codec.game.GamePacket)2 MessageEncoder (org.apollo.net.release.MessageEncoder)2