com.nukkitx.protocol.bedrock.packet.InventoryTransactionPacket Java Examples

The following examples show how to use com.nukkitx.protocol.bedrock.packet.InventoryTransactionPacket. 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: InventoryTransactionSerializer_v354.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 #2
Source File: InventoryTransactionSerializer_v354.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, InventoryTransactionPacket packet) {
    Type transactionType = Type.values()[VarInts.readUnsignedInt(buffer)];
    packet.setTransactionType(transactionType);

    BedrockUtils.readArray(buffer, packet.getActions(), BedrockUtils::readInventoryAction);

    switch (transactionType) {
        case ITEM_USE:
            packet.setActionType(VarInts.readUnsignedInt(buffer));
            packet.setBlockPosition(BedrockUtils.readBlockPosition(buffer));
            packet.setFace(VarInts.readInt(buffer));
            packet.setHotbarSlot(VarInts.readInt(buffer));
            packet.setItemInHand(BedrockUtils.readItemData(buffer));
            packet.setPlayerPosition(BedrockUtils.readVector3f(buffer));
            packet.setClickPosition(BedrockUtils.readVector3f(buffer));
            packet.setBlockRuntimeId(VarInts.readUnsignedInt(buffer));
            break;
        case ITEM_USE_ON_ENTITY:
            packet.setRuntimeEntityId(VarInts.readUnsignedInt(buffer));
            packet.setActionType(VarInts.readUnsignedInt(buffer));
            packet.setHotbarSlot(VarInts.readInt(buffer));
            packet.setItemInHand(BedrockUtils.readItemData(buffer));
            packet.setPlayerPosition(BedrockUtils.readVector3f(buffer));
            packet.setClickPosition(BedrockUtils.readVector3f(buffer));
            break;
        case ITEM_RELEASE:
            packet.setActionType(VarInts.readUnsignedInt(buffer));
            packet.setHotbarSlot(VarInts.readInt(buffer));
            packet.setItemInHand(BedrockUtils.readItemData(buffer));
            packet.setHeadPosition(BedrockUtils.readVector3f(buffer));
    }
}
 
Example #3
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 #4
Source File: InventoryTransactionSerializer_v388.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, InventoryTransactionPacket packet) {
    Type transactionType = Type.values()[VarInts.readUnsignedInt(buffer)];
    packet.setTransactionType(transactionType);

    BedrockUtils.readArray(buffer, packet.getActions(), BedrockUtils::readInventoryAction);

    switch (transactionType) {
        case ITEM_USE:
            packet.setActionType(VarInts.readUnsignedInt(buffer));
            packet.setBlockPosition(BedrockUtils.readBlockPosition(buffer));
            packet.setFace(VarInts.readInt(buffer));
            packet.setHotbarSlot(VarInts.readInt(buffer));
            packet.setItemInHand(BedrockUtils.readItemData(buffer));
            packet.setPlayerPosition(BedrockUtils.readVector3f(buffer));
            packet.setClickPosition(BedrockUtils.readVector3f(buffer));
            packet.setBlockRuntimeId(VarInts.readUnsignedInt(buffer));
            break;
        case ITEM_USE_ON_ENTITY:
            packet.setRuntimeEntityId(VarInts.readUnsignedInt(buffer));
            packet.setActionType(VarInts.readUnsignedInt(buffer));
            packet.setHotbarSlot(VarInts.readInt(buffer));
            packet.setItemInHand(BedrockUtils.readItemData(buffer));
            packet.setPlayerPosition(BedrockUtils.readVector3f(buffer));
            packet.setClickPosition(BedrockUtils.readVector3f(buffer));
            break;
        case ITEM_RELEASE:
            packet.setActionType(VarInts.readUnsignedInt(buffer));
            packet.setHotbarSlot(VarInts.readInt(buffer));
            packet.setItemInHand(BedrockUtils.readItemData(buffer));
            packet.setHeadPosition(BedrockUtils.readVector3f(buffer));
    }
}
 
Example #5
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 #6
Source File: InventoryTransactionSerializer_v340.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, InventoryTransactionPacket packet) {
    Type transactionType = Type.values()[VarInts.readUnsignedInt(buffer)];
    packet.setTransactionType(transactionType);

    BedrockUtils.readArray(buffer, packet.getActions(), BedrockUtils::readInventoryAction);

    switch (transactionType) {
        case ITEM_USE:
            packet.setActionType(VarInts.readUnsignedInt(buffer));
            packet.setBlockPosition(BedrockUtils.readBlockPosition(buffer));
            packet.setFace(VarInts.readInt(buffer));
            packet.setHotbarSlot(VarInts.readInt(buffer));
            packet.setItemInHand(BedrockUtils.readItemData(buffer));
            packet.setPlayerPosition(BedrockUtils.readVector3f(buffer));
            packet.setClickPosition(BedrockUtils.readVector3f(buffer));
            packet.setBlockRuntimeId(VarInts.readUnsignedInt(buffer));
            break;
        case ITEM_USE_ON_ENTITY:
            packet.setRuntimeEntityId(VarInts.readUnsignedInt(buffer));
            packet.setActionType(VarInts.readUnsignedInt(buffer));
            packet.setHotbarSlot(VarInts.readInt(buffer));
            packet.setItemInHand(BedrockUtils.readItemData(buffer));
            packet.setPlayerPosition(BedrockUtils.readVector3f(buffer));
            packet.setClickPosition(BedrockUtils.readVector3f(buffer));
            break;
        case ITEM_RELEASE:
            packet.setActionType(VarInts.readUnsignedInt(buffer));
            packet.setHotbarSlot(VarInts.readInt(buffer));
            packet.setItemInHand(BedrockUtils.readItemData(buffer));
            packet.setHeadPosition(BedrockUtils.readVector3f(buffer));
    }
}
 
Example #7
Source File: InventoryTransactionSerializer_v313.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 #8
Source File: InventoryTransactionSerializer_v313.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, InventoryTransactionPacket packet) {
    Type transactionType = Type.values()[VarInts.readUnsignedInt(buffer)];
    packet.setTransactionType(transactionType);

    BedrockUtils.readArray(buffer, packet.getActions(), BedrockUtils::readInventoryAction);

    switch (transactionType) {
        case ITEM_USE:
            packet.setActionType(VarInts.readUnsignedInt(buffer));
            packet.setBlockPosition(BedrockUtils.readBlockPosition(buffer));
            packet.setFace(VarInts.readInt(buffer));
            packet.setHotbarSlot(VarInts.readInt(buffer));
            packet.setItemInHand(BedrockUtils.readItemData(buffer));
            packet.setPlayerPosition(BedrockUtils.readVector3f(buffer));
            packet.setClickPosition(BedrockUtils.readVector3f(buffer));
            break;
        case ITEM_USE_ON_ENTITY:
            packet.setRuntimeEntityId(VarInts.readUnsignedInt(buffer));
            packet.setActionType(VarInts.readUnsignedInt(buffer));
            packet.setHotbarSlot(VarInts.readInt(buffer));
            packet.setItemInHand(BedrockUtils.readItemData(buffer));
            packet.setPlayerPosition(BedrockUtils.readVector3f(buffer));
            packet.setClickPosition(BedrockUtils.readVector3f(buffer));
            break;
        case ITEM_RELEASE:
            packet.setActionType(VarInts.readUnsignedInt(buffer));
            packet.setHotbarSlot(VarInts.readInt(buffer));
            packet.setItemInHand(BedrockUtils.readItemData(buffer));
            packet.setHeadPosition(BedrockUtils.readVector3f(buffer));
    }
}
 
Example #9
Source File: InventoryTransactionSerializer_v361.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 #10
Source File: InventoryTransactionSerializer_v361.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, InventoryTransactionPacket packet) {
    Type transactionType = Type.values()[VarInts.readUnsignedInt(buffer)];
    packet.setTransactionType(transactionType);

    BedrockUtils.readArray(buffer, packet.getActions(), BedrockUtils::readInventoryAction);

    switch (transactionType) {
        case ITEM_USE:
            packet.setActionType(VarInts.readUnsignedInt(buffer));
            packet.setBlockPosition(BedrockUtils.readBlockPosition(buffer));
            packet.setFace(VarInts.readInt(buffer));
            packet.setHotbarSlot(VarInts.readInt(buffer));
            packet.setItemInHand(BedrockUtils.readItemData(buffer));
            packet.setPlayerPosition(BedrockUtils.readVector3f(buffer));
            packet.setClickPosition(BedrockUtils.readVector3f(buffer));
            packet.setBlockRuntimeId(VarInts.readUnsignedInt(buffer));
            break;
        case ITEM_USE_ON_ENTITY:
            packet.setRuntimeEntityId(VarInts.readUnsignedInt(buffer));
            packet.setActionType(VarInts.readUnsignedInt(buffer));
            packet.setHotbarSlot(VarInts.readInt(buffer));
            packet.setItemInHand(BedrockUtils.readItemData(buffer));
            packet.setPlayerPosition(BedrockUtils.readVector3f(buffer));
            packet.setClickPosition(BedrockUtils.readVector3f(buffer));
            break;
        case ITEM_RELEASE:
            packet.setActionType(VarInts.readUnsignedInt(buffer));
            packet.setHotbarSlot(VarInts.readInt(buffer));
            packet.setItemInHand(BedrockUtils.readItemData(buffer));
            packet.setHeadPosition(BedrockUtils.readVector3f(buffer));
    }
}
 
Example #11
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 #12
Source File: InventoryTransactionSerializer_v332.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, InventoryTransactionPacket packet) {
    Type transactionType = Type.values()[VarInts.readUnsignedInt(buffer)];
    packet.setTransactionType(transactionType);

    BedrockUtils.readArray(buffer, packet.getActions(), BedrockUtils::readInventoryAction);

    switch (transactionType) {
        case ITEM_USE:
            packet.setActionType(VarInts.readUnsignedInt(buffer));
            packet.setBlockPosition(BedrockUtils.readBlockPosition(buffer));
            packet.setFace(VarInts.readInt(buffer));
            packet.setHotbarSlot(VarInts.readInt(buffer));
            packet.setItemInHand(BedrockUtils.readItemData(buffer));
            packet.setPlayerPosition(BedrockUtils.readVector3f(buffer));
            packet.setClickPosition(BedrockUtils.readVector3f(buffer));
            break;
        case ITEM_USE_ON_ENTITY:
            packet.setRuntimeEntityId(VarInts.readUnsignedInt(buffer));
            packet.setActionType(VarInts.readUnsignedInt(buffer));
            packet.setHotbarSlot(VarInts.readInt(buffer));
            packet.setItemInHand(BedrockUtils.readItemData(buffer));
            packet.setPlayerPosition(BedrockUtils.readVector3f(buffer));
            packet.setClickPosition(BedrockUtils.readVector3f(buffer));
            break;
        case ITEM_RELEASE:
            packet.setActionType(VarInts.readUnsignedInt(buffer));
            packet.setHotbarSlot(VarInts.readInt(buffer));
            packet.setItemInHand(BedrockUtils.readItemData(buffer));
            packet.setHeadPosition(BedrockUtils.readVector3f(buffer));
    }
}
 
Example #13
Source File: InventoryTransactionSerializer_v291.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 #14
Source File: InventoryTransactionSerializer_v291.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, InventoryTransactionPacket packet) {
    Type transactionType = Type.values()[VarInts.readUnsignedInt(buffer)];
    packet.setTransactionType(transactionType);

    BedrockUtils.readArray(buffer, packet.getActions(), BedrockUtils::readInventoryAction);

    switch (transactionType) {
        case ITEM_USE:
            packet.setActionType(VarInts.readUnsignedInt(buffer));
            packet.setBlockPosition(BedrockUtils.readBlockPosition(buffer));
            packet.setFace(VarInts.readInt(buffer));
            packet.setHotbarSlot(VarInts.readInt(buffer));
            packet.setItemInHand(BedrockUtils.readItemData(buffer));
            packet.setPlayerPosition(BedrockUtils.readVector3f(buffer));
            packet.setClickPosition(BedrockUtils.readVector3f(buffer));
            break;
        case ITEM_USE_ON_ENTITY:
            packet.setRuntimeEntityId(VarInts.readUnsignedInt(buffer));
            packet.setActionType(VarInts.readUnsignedInt(buffer));
            packet.setHotbarSlot(VarInts.readInt(buffer));
            packet.setItemInHand(BedrockUtils.readItemData(buffer));
            packet.setPlayerPosition(BedrockUtils.readVector3f(buffer));
            packet.setClickPosition(BedrockUtils.readVector3f(buffer));
            break;
        case ITEM_RELEASE:
            packet.setActionType(VarInts.readUnsignedInt(buffer));
            packet.setHotbarSlot(VarInts.readInt(buffer));
            packet.setItemInHand(BedrockUtils.readItemData(buffer));
            packet.setHeadPosition(BedrockUtils.readVector3f(buffer));
    }
}