com.nukkitx.network.VarInts Java Examples

The following examples show how to use com.nukkitx.network.VarInts. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BedrockUtils.java    From Protocol with Apache License 2.0 6 votes vote down vote up
public static void writeInventorySource(ByteBuf buffer, InventorySource inventorySource) {
    Preconditions.checkNotNull(buffer, "buffer");
    Preconditions.checkNotNull(inventorySource, "inventorySource");

    VarInts.writeUnsignedInt(buffer, inventorySource.getType().id());

    switch (inventorySource.getType()) {
        case CONTAINER:
        case UNTRACKED_INTERACTION_UI:
        case NON_IMPLEMENTED_TODO:
            VarInts.writeInt(buffer, inventorySource.getContainerId());
            break;
        case WORLD_INTERACTION:
            VarInts.writeUnsignedInt(buffer, inventorySource.getFlag().ordinal());
            break;
    }
}
 
Example #2
Source File: AdventureSettingsSerializer_v291.java    From Protocol with Apache License 2.0 6 votes vote down vote up
@Override
public void serialize(ByteBuf buffer, AdventureSettingsPacket packet) {
    int flags1 = 0;
    int flags2 = 0;
    for (AdventureSettingsPacket.Flag flag : packet.getFlags()) {
        if (FLAGS_TO_BIT_1.containsKey(flag)) {
            flags1 |= FLAGS_TO_BIT_1.get(flag);
        } else if (FLAGS_TO_BIT_2.containsKey(flag)) {
            flags2 |= FLAGS_TO_BIT_2.get(flag);
        }
    }
    VarInts.writeUnsignedInt(buffer, flags1);
    VarInts.writeUnsignedInt(buffer, packet.getCommandPermission().ordinal());
    VarInts.writeUnsignedInt(buffer, flags2);
    VarInts.writeUnsignedInt(buffer, packet.getPlayerPermission().ordinal());
    VarInts.writeUnsignedInt(buffer, 0); // Useless
    buffer.writeLongLE(packet.getUniqueEntityId());
}
 
Example #3
Source File: AddPlayerSerializer_v291.java    From Protocol with Apache License 2.0 6 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, AddPlayerPacket packet) {
    packet.setUuid(BedrockUtils.readUuid(buffer));
    packet.setUsername(BedrockUtils.readString(buffer));
    packet.setUniqueEntityId(VarInts.readLong(buffer));
    packet.setRuntimeEntityId(VarInts.readUnsignedLong(buffer));
    packet.setPlatformChatId(BedrockUtils.readString(buffer));
    packet.setPosition(BedrockUtils.readVector3f(buffer));
    packet.setMotion(BedrockUtils.readVector3f(buffer));
    packet.setRotation(BedrockUtils.readVector3f(buffer));
    packet.setHand(BedrockUtils.readItemData(buffer));
    BedrockUtils.readEntityData(buffer, packet.getMetadata());
    AdventureSettingsSerializer_v291.INSTANCE.deserialize(buffer, packet.getAdventureSettings());
    BedrockUtils.readArray(buffer, packet.getEntityLinks(), BedrockUtils::readEntityLink);
    packet.setDeviceId(BedrockUtils.readString(buffer));
}
 
Example #4
Source File: BedrockUtils.java    From Protocol with Apache License 2.0 6 votes vote down vote up
public static void writeGameRule(ByteBuf buffer, GameRuleData gameRule) {
    Preconditions.checkNotNull(buffer, "buffer");
    Preconditions.checkNotNull(gameRule, "gameRule");

    Object value = gameRule.getValue();
    int type = GameRulesChangedSerializer_v340.RULE_TYPES.get(value.getClass());

    BedrockUtils.writeString(buffer, gameRule.getName());
    VarInts.writeUnsignedInt(buffer, type);

    switch (type) {
        case 1:
            buffer.writeBoolean((boolean) value);
            break;
        case 2:
            VarInts.writeUnsignedInt(buffer, (int) value);
            break;
        case 3:
            buffer.writeFloatLE((float) value);
            break;
    }
}
 
Example #5
Source File: PlayerListSerializer_v313.java    From Protocol with Apache License 2.0 6 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, PlayerListPacket packet) {
    PlayerListPacket.Action action = PlayerListPacket.Action.values()[buffer.readUnsignedByte()];
    packet.setAction(action);
    int length = VarInts.readUnsignedInt(buffer);

    for (int i = 0; i < length; i++) {
        Entry entry = new Entry(BedrockUtils.readUuid(buffer));

        if (action == PlayerListPacket.Action.ADD) {
            entry.setEntityId(VarInts.readLong(buffer));
            entry.setName(BedrockUtils.readString(buffer));
            String skinId = BedrockUtils.readString(buffer);
            ImageData skinData = ImageData.of(BedrockUtils.readByteArray(buffer));
            ImageData capeData = ImageData.of(64, 32, BedrockUtils.readByteArray(buffer));
            String geometryName = BedrockUtils.readString(buffer);
            String geometryData = BedrockUtils.readString(buffer);
            entry.setSkin(SerializedSkin.of(skinId, skinData, capeData, geometryName, geometryData, false));
            entry.setXuid(BedrockUtils.readString(buffer));
            entry.setPlatformChatId(BedrockUtils.readString(buffer));
        }
        packet.getEntries().add(entry);
    }
}
 
Example #6
Source File: BedrockUtils.java    From Protocol with Apache License 2.0 6 votes vote down vote up
public static void writeInventorySource(ByteBuf buffer, InventorySource inventorySource) {
    Preconditions.checkNotNull(buffer, "buffer");
    Preconditions.checkNotNull(inventorySource, "inventorySource");

    VarInts.writeUnsignedInt(buffer, inventorySource.getType().id());

    switch (inventorySource.getType()) {
        case CONTAINER:
        case UNTRACKED_INTERACTION_UI:
        case NON_IMPLEMENTED_TODO:
            VarInts.writeInt(buffer, inventorySource.getContainerId());
            break;
        case WORLD_INTERACTION:
            VarInts.writeUnsignedInt(buffer, inventorySource.getFlag().ordinal());
            break;
    }
}
 
Example #7
Source File: BedrockUtils.java    From Protocol with Apache License 2.0 6 votes vote down vote up
public static InventorySource readInventorySource(ByteBuf buffer) {
    Preconditions.checkNotNull(buffer, "buffer");

    InventorySource.Type type = InventorySource.Type.byId(VarInts.readUnsignedInt(buffer));

    switch (type) {
        case CONTAINER:
            int containerId = VarInts.readInt(buffer);
            return InventorySource.fromContainerWindowId(containerId);
        case GLOBAL:
            return InventorySource.fromGlobalInventory();
        case WORLD_INTERACTION:
            InventorySource.Flag flag = InventorySource.Flag.values()[VarInts.readUnsignedInt(buffer)];
            return InventorySource.fromWorldInteraction(flag);
        case CREATIVE:
            return InventorySource.fromCreativeInventory();
        case UNTRACKED_INTERACTION_UI:
            containerId = VarInts.readInt(buffer);
            return InventorySource.fromUntrackedInteractionUI(containerId);
        case NON_IMPLEMENTED_TODO:
            containerId = VarInts.readInt(buffer);
            return InventorySource.fromNonImplementedTodo(containerId);
        default:
            return InventorySource.fromInvalid();
    }
}
 
Example #8
Source File: BedrockUtils.java    From Protocol with Apache License 2.0 6 votes vote down vote up
public static GameRuleData<?> readGameRule(ByteBuf buffer) {
    Preconditions.checkNotNull(buffer, "buffer");

    String name = BedrockUtils.readString(buffer);
    int type = VarInts.readUnsignedInt(buffer);

    switch (type) {
        case 1:
            return new GameRuleData<>(name, buffer.readBoolean());
        case 2:
            return new GameRuleData<>(name, VarInts.readUnsignedInt(buffer));
        case 3:
            return new GameRuleData<>(name, buffer.readFloatLE());
    }
    throw new IllegalStateException("Invalid gamerule type received");
}
 
Example #9
Source File: BedrockUtils.java    From Protocol with Apache License 2.0 6 votes vote down vote up
public static InventorySource readInventorySource(ByteBuf buffer) {
    Preconditions.checkNotNull(buffer, "buffer");

    InventorySource.Type type = InventorySource.Type.byId(VarInts.readUnsignedInt(buffer));

    switch (type) {
        case CONTAINER:
            int containerId = VarInts.readInt(buffer);
            return InventorySource.fromContainerWindowId(containerId);
        case GLOBAL:
            return InventorySource.fromGlobalInventory();
        case WORLD_INTERACTION:
            InventorySource.Flag flag = InventorySource.Flag.values()[VarInts.readUnsignedInt(buffer)];
            return InventorySource.fromWorldInteraction(flag);
        case CREATIVE:
            return InventorySource.fromCreativeInventory();
        case UNTRACKED_INTERACTION_UI:
            containerId = VarInts.readInt(buffer);
            return InventorySource.fromUntrackedInteractionUI(containerId);
        case NON_IMPLEMENTED_TODO:
            containerId = VarInts.readInt(buffer);
            return InventorySource.fromNonImplementedTodo(containerId);
        default:
            return InventorySource.fromInvalid();
    }
}
 
Example #10
Source File: AddPaintingSerializer_v332.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, AddPaintingPacket packet) {
    packet.setUniqueEntityId(VarInts.readLong(buffer));
    packet.setRuntimeEntityId(VarInts.readUnsignedLong(buffer));
    packet.setPosition(BedrockUtils.readBlockPosition(buffer).toFloat());
    packet.setDirection(readInt(buffer));
    packet.setName(BedrockUtils.readString(buffer));
}
 
Example #11
Source File: BedrockUtils.java    From Protocol with Apache License 2.0 5 votes vote down vote up
public static void writeVector3i(ByteBuf buffer, Vector3i vector3i) {
    Preconditions.checkNotNull(buffer, "buffer");
    Preconditions.checkNotNull(vector3i, "vector3i");
    VarInts.writeInt(buffer, vector3i.getX());
    VarInts.writeInt(buffer, vector3i.getY());
    VarInts.writeInt(buffer, vector3i.getZ());
}
 
Example #12
Source File: InventoryTransactionSerializer_v388.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(ByteBuf buffer, InventoryTransactionPacket packet) {
    Type transactionType = packet.getTransactionType();
    VarInts.writeUnsignedInt(buffer, transactionType.ordinal());

    BedrockUtils.writeArray(buffer, packet.getActions(), BedrockUtils::writeInventoryAction);

    switch (transactionType) {
        case ITEM_USE:
            VarInts.writeUnsignedInt(buffer, packet.getActionType());
            BedrockUtils.writeBlockPosition(buffer, packet.getBlockPosition());
            VarInts.writeInt(buffer, packet.getFace());
            VarInts.writeInt(buffer, packet.getHotbarSlot());
            BedrockUtils.writeItemData(buffer, packet.getItemInHand());
            BedrockUtils.writeVector3f(buffer, packet.getPlayerPosition());
            BedrockUtils.writeVector3f(buffer, packet.getClickPosition());
            VarInts.writeUnsignedInt(buffer, packet.getBlockRuntimeId());
            break;
        case ITEM_USE_ON_ENTITY:
            VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId());
            VarInts.writeUnsignedInt(buffer, packet.getActionType());
            VarInts.writeInt(buffer, packet.getHotbarSlot());
            BedrockUtils.writeItemData(buffer, packet.getItemInHand());
            BedrockUtils.writeVector3f(buffer, packet.getPlayerPosition());
            BedrockUtils.writeVector3f(buffer, packet.getClickPosition());
            break;
        case ITEM_RELEASE:
            VarInts.writeUnsignedInt(buffer, packet.getActionType());
            VarInts.writeInt(buffer, packet.getHotbarSlot());
            BedrockUtils.writeItemData(buffer, packet.getItemInHand());
            BedrockUtils.writeVector3f(buffer, packet.getHeadPosition());
    }
}
 
Example #13
Source File: CraftingEventSerializer_v354.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, CraftingEventPacket packet) {
    packet.setWindowId(buffer.readByte());
    packet.setType(VarInts.readInt(buffer));
    packet.setUuid(BedrockUtils.readUuid(buffer));

    BedrockUtils.readArray(buffer, packet.getInputs(), BedrockUtils::readItemData);

    BedrockUtils.readArray(buffer, packet.getOutputs(), BedrockUtils::readItemData);
}
 
Example #14
Source File: MoveEntityAbsoluteSerializer_v291.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, MoveEntityAbsolutePacket packet) {
    packet.setRuntimeEntityId(VarInts.readUnsignedLong(buffer));
    int flags = buffer.readUnsignedByte();
    packet.setOnGround((flags & FLAG_ON_GROUND) != 0);
    packet.setTeleported((flags & FLAG_TELEPORTED) != 0);
    packet.setPosition(BedrockUtils.readVector3f(buffer));
    packet.setRotation(BedrockUtils.readByteRotation(buffer));
}
 
Example #15
Source File: AddEntitySerializer_v361.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(ByteBuf buffer, AddEntityPacket packet) {
    VarInts.writeLong(buffer, packet.getUniqueEntityId());
    VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId());
    BedrockUtils.writeString(buffer, packet.getIdentifier());
    BedrockUtils.writeVector3f(buffer, packet.getPosition());
    BedrockUtils.writeVector3f(buffer, packet.getMotion());
    BedrockUtils.writeVector3f(buffer, packet.getRotation());
    BedrockUtils.writeArray(buffer, packet.getAttributes(), BedrockUtils::writeEntityAttribute);
    BedrockUtils.writeEntityData(buffer, packet.getMetadata());
    BedrockUtils.writeArray(buffer, packet.getEntityLinks(), BedrockUtils::writeEntityLink);
}
 
Example #16
Source File: SetTitleSerializer_v332.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, SetTitlePacket packet) {
    packet.setType(SetTitlePacket.Type.values()[VarInts.readInt(buffer)]);
    packet.setText(BedrockUtils.readString(buffer));
    packet.setFadeInTime(VarInts.readInt(buffer));
    packet.setStayTime(VarInts.readInt(buffer));
    packet.setFadeOutTime(VarInts.readInt(buffer));
}
 
Example #17
Source File: InventoryTransactionSerializer_v340.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(ByteBuf buffer, InventoryTransactionPacket packet) {
    Type transactionType = packet.getTransactionType();
    VarInts.writeUnsignedInt(buffer, transactionType.ordinal());

    BedrockUtils.writeArray(buffer, packet.getActions(), BedrockUtils::writeInventoryAction);

    switch (transactionType) {
        case ITEM_USE:
            VarInts.writeUnsignedInt(buffer, packet.getActionType());
            BedrockUtils.writeBlockPosition(buffer, packet.getBlockPosition());
            VarInts.writeInt(buffer, packet.getFace());
            VarInts.writeInt(buffer, packet.getHotbarSlot());
            BedrockUtils.writeItemData(buffer, packet.getItemInHand());
            BedrockUtils.writeVector3f(buffer, packet.getPlayerPosition());
            BedrockUtils.writeVector3f(buffer, packet.getClickPosition());
            VarInts.writeUnsignedInt(buffer, packet.getBlockRuntimeId());
            break;
        case ITEM_USE_ON_ENTITY:
            VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId());
            VarInts.writeUnsignedInt(buffer, packet.getActionType());
            VarInts.writeInt(buffer, packet.getHotbarSlot());
            BedrockUtils.writeItemData(buffer, packet.getItemInHand());
            BedrockUtils.writeVector3f(buffer, packet.getPlayerPosition());
            BedrockUtils.writeVector3f(buffer, packet.getClickPosition());
            break;
        case ITEM_RELEASE:
            VarInts.writeUnsignedInt(buffer, packet.getActionType());
            VarInts.writeInt(buffer, packet.getHotbarSlot());
            BedrockUtils.writeItemData(buffer, packet.getItemInHand());
            BedrockUtils.writeVector3f(buffer, packet.getHeadPosition());
    }
}
 
Example #18
Source File: UpdateBlockSerializer_v313.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, UpdateBlockPacket packet) {
    packet.setBlockPosition(BedrockUtils.readBlockPosition(buffer));
    packet.setRuntimeId(VarInts.readUnsignedInt(buffer));
    int flagValue = VarInts.readUnsignedInt(buffer);
    Set<Flag> flags = packet.getFlags();
    for (Flag flag : Flag.values()) {
        if ((flagValue & (1 << flag.ordinal())) != 0) {
            flags.add(flag);
        }
    }
    packet.setDataLayer(VarInts.readUnsignedInt(buffer));
}
 
Example #19
Source File: BedrockUtils.java    From Protocol with Apache License 2.0 5 votes vote down vote up
public static Vector3i readBlockPosition(ByteBuf buffer) {
    Preconditions.checkNotNull(buffer, "buffer");
    int x = VarInts.readInt(buffer);
    int y = VarInts.readUnsignedInt(buffer);
    int z = VarInts.readInt(buffer);

    return Vector3i.from(x, y, z);
}
 
Example #20
Source File: SpawnParticleEffectSerializer_v388.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(ByteBuf buffer, SpawnParticleEffectPacket packet) {
    buffer.writeByte(packet.getDimensionId());
    VarInts.writeLong(buffer, packet.getUniqueEntityId());
    BedrockUtils.writeVector3f(buffer, packet.getPosition());
    BedrockUtils.writeString(buffer, packet.getIdentifier());
}
 
Example #21
Source File: AddEntitySerializer_v332.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, AddEntityPacket packet) {
    packet.setUniqueEntityId(VarInts.readLong(buffer));
    packet.setRuntimeEntityId(VarInts.readUnsignedLong(buffer));
    packet.setIdentifier(BedrockUtils.readString(buffer));
    packet.setPosition(BedrockUtils.readVector3f(buffer));
    packet.setMotion(BedrockUtils.readVector3f(buffer));
    packet.setRotation(BedrockUtils.readVector3f(buffer));
    BedrockUtils.readArray(buffer, packet.getAttributes(), BedrockUtils::readEntityAttribute);
    BedrockUtils.readEntityData(buffer, packet.getMetadata());
    BedrockUtils.readArray(buffer, packet.getEntityLinks(), BedrockUtils::readEntityLink);
}
 
Example #22
Source File: LevelSoundEvent1Serializer_v354.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, LevelSoundEvent1Packet packet) {
    packet.setSound(SOUNDS.get(VarInts.readInt(buffer)));
    packet.setPosition(BedrockUtils.readVector3f(buffer));
    packet.setExtraData(VarInts.readInt(buffer));
    packet.setPitch(VarInts.readInt(buffer));
    packet.setBabySound(buffer.readBoolean());
    packet.setRelativeVolumeDisabled(buffer.readBoolean());
}
 
Example #23
Source File: AddPaintingSerializer_v340.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, AddPaintingPacket packet) {
    packet.setUniqueEntityId(VarInts.readLong(buffer));
    packet.setRuntimeEntityId(VarInts.readUnsignedLong(buffer));
    packet.setPosition(BedrockUtils.readBlockPosition(buffer).toFloat());
    packet.setDirection(readInt(buffer));
    packet.setName(BedrockUtils.readString(buffer));
}
 
Example #24
Source File: BedrockUtils.java    From Protocol with Apache License 2.0 5 votes vote down vote up
public static void writeVector3i(ByteBuf buffer, Vector3i vector3i) {
    Preconditions.checkNotNull(buffer, "buffer");
    Preconditions.checkNotNull(vector3i, "vector3i");
    VarInts.writeInt(buffer, vector3i.getX());
    VarInts.writeInt(buffer, vector3i.getY());
    VarInts.writeInt(buffer, vector3i.getZ());
}
 
Example #25
Source File: PacketHeaderSerializer_v340.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, PacketHeader packet) {
    int header = VarInts.readUnsignedInt(buffer);
    packet.setPacketId(header & 0x3ff);
    packet.setSenderId((header >>> 10) & 3);
    packet.setClientId((header >>> 12) & 3);
}
 
Example #26
Source File: MobEquipmentSerializer_v340.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, MobEquipmentPacket packet) {
    packet.setRuntimeEntityId(VarInts.readUnsignedLong(buffer));
    packet.setItem(BedrockUtils.readItemData(buffer));
    packet.setInventorySlot(buffer.readUnsignedByte());
    packet.setHotbarSlot(buffer.readUnsignedByte());
    packet.setContainerId(buffer.readByte());
}
 
Example #27
Source File: BedrockUtils.java    From Protocol with Apache License 2.0 5 votes vote down vote up
public static void writeCommandEnumData(ByteBuf buffer, CommandEnumData enumData) {
    Preconditions.checkNotNull(buffer, "buffer");
    Preconditions.checkNotNull(enumData, "enumData");

    BedrockUtils.writeString(buffer, enumData.getName());

    String[] values = enumData.getValues();
    VarInts.writeUnsignedInt(buffer, values.length);
    for (String value : values) {
        BedrockUtils.writeString(buffer, value);
    }
}
 
Example #28
Source File: InventoryTransactionSerializer_v332.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(ByteBuf buffer, InventoryTransactionPacket packet) {
    Type transactionType = packet.getTransactionType();
    VarInts.writeUnsignedInt(buffer, transactionType.ordinal());

    BedrockUtils.writeArray(buffer, packet.getActions(), BedrockUtils::writeInventoryAction);

    switch (transactionType) {
        case ITEM_USE:
            VarInts.writeUnsignedInt(buffer, packet.getActionType());
            BedrockUtils.writeBlockPosition(buffer, packet.getBlockPosition());
            VarInts.writeInt(buffer, packet.getFace());
            VarInts.writeInt(buffer, packet.getHotbarSlot());
            BedrockUtils.writeItemData(buffer, packet.getItemInHand());
            BedrockUtils.writeVector3f(buffer, packet.getPlayerPosition());
            BedrockUtils.writeVector3f(buffer, packet.getClickPosition());
            break;
        case ITEM_USE_ON_ENTITY:
            VarInts.writeUnsignedLong(buffer, packet.getRuntimeEntityId());
            VarInts.writeUnsignedInt(buffer, packet.getActionType());
            VarInts.writeInt(buffer, packet.getHotbarSlot());
            BedrockUtils.writeItemData(buffer, packet.getItemInHand());
            BedrockUtils.writeVector3f(buffer, packet.getPlayerPosition());
            BedrockUtils.writeVector3f(buffer, packet.getClickPosition());
            break;
        case ITEM_RELEASE:
            VarInts.writeUnsignedInt(buffer, packet.getActionType());
            VarInts.writeInt(buffer, packet.getHotbarSlot());
            BedrockUtils.writeItemData(buffer, packet.getItemInHand());
            BedrockUtils.writeVector3f(buffer, packet.getHeadPosition());
    }
}
 
Example #29
Source File: FullChunkDataSerializer_v354.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(ByteBuf buffer, LevelChunkPacket packet) {
    VarInts.writeInt(buffer, packet.getChunkX());
    VarInts.writeInt(buffer, packet.getChunkZ());
    byte[] data = packet.getData();
    VarInts.writeUnsignedInt(buffer, data.length);
    buffer.writeBytes(data);
}
 
Example #30
Source File: LevelSoundEvent2Serializer_v361.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(ByteBuf buffer, LevelSoundEvent2Packet packet) {
    buffer.writeByte(SOUNDS.get(packet.getSound()));
    BedrockUtils.writeVector3f(buffer, packet.getPosition());
    VarInts.writeInt(buffer, packet.getExtraData());
    BedrockUtils.writeString(buffer, packet.getIdentifier());
    buffer.writeBoolean(packet.isBabySound());
    buffer.writeBoolean(packet.isRelativeVolumeDisabled());
}