Search in sources :

Example 91 with GamePacketBuilder

use of org.apollo.net.codec.game.GamePacketBuilder in project apollo by apollo-rsps.

the class UpdateSlottedItemsMessageEncoder method encode.

@Override
public GamePacket encode(UpdateSlottedItemsMessage message) {
    GamePacketBuilder builder = new GamePacketBuilder(34, PacketType.VARIABLE_SHORT);
    SlottedItem[] items = message.getSlottedItems();
    builder.put(DataType.SHORT, message.getInterfaceId());
    for (SlottedItem slottedItem : items) {
        builder.putSmart(slottedItem.getSlot());
        Item item = slottedItem.getItem();
        int id = item == null ? -1 : item.getId();
        int amount = item == null ? 0 : item.getAmount();
        builder.put(DataType.SHORT, id + 1);
        if (amount > 254) {
            builder.put(DataType.BYTE, 255);
            builder.put(DataType.INT, amount);
        } else {
            builder.put(DataType.BYTE, amount);
        }
    }
    return builder.toGamePacket();
}
Also used : SlottedItem(org.apollo.game.model.inv.SlottedItem) Item(org.apollo.game.model.Item) GamePacketBuilder(org.apollo.net.codec.game.GamePacketBuilder) SlottedItem(org.apollo.game.model.inv.SlottedItem)

Example 92 with GamePacketBuilder

use of org.apollo.net.codec.game.GamePacketBuilder in project apollo by apollo-rsps.

the class OpenOverlayMessageEncoder method encode.

@Override
public GamePacket encode(OpenOverlayMessage message) {
    GamePacketBuilder builder = new GamePacketBuilder(208);
    builder.put(DataType.SHORT, DataOrder.LITTLE, message.getOverlayId());
    return builder.toGamePacket();
}
Also used : GamePacketBuilder(org.apollo.net.codec.game.GamePacketBuilder)

Example 93 with GamePacketBuilder

use of org.apollo.net.codec.game.GamePacketBuilder in project apollo by apollo-rsps.

the class PrivacyOptionMessageEncoder method encode.

@Override
public GamePacket encode(final PrivacyOptionMessage message) {
    final GamePacketBuilder builder = new GamePacketBuilder(206);
    builder.put(DataType.BYTE, message.getChatPrivacy().toInteger(true));
    builder.put(DataType.BYTE, message.getFriendPrivacy().toInteger(true));
    builder.put(DataType.BYTE, message.getTradePrivacy().toInteger(true));
    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