All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.nukkit.network.process.processor.PlayerHotbarProcessor Maven / Gradle / Ivy

package cn.nukkit.network.process.processor;

import cn.nukkit.PlayerHandle;
import cn.nukkit.network.process.DataPacketProcessor;
import cn.nukkit.network.protocol.PlayerHotbarPacket;
import cn.nukkit.network.protocol.ProtocolInfo;
import cn.nukkit.network.protocol.types.ContainerIds;
import org.jetbrains.annotations.NotNull;

public class PlayerHotbarProcessor extends DataPacketProcessor {
    @Override
    public void handle(@NotNull PlayerHandle playerHandle, @NotNull PlayerHotbarPacket pk) {
        if (pk.windowId != ContainerIds.INVENTORY) {
            return; //In PE this should never happen
        }
        playerHandle.player.getInventory().equipItem(pk.selectedHotbarSlot);
    }

    @Override
    public int getPacketId() {
        return ProtocolInfo.toNewProtocolID(ProtocolInfo.PLAYER_HOTBAR_PACKET);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy