Search in sources :

Example 6 with PEInventorySlot

use of org.dragonet.inventory.PEInventorySlot in project Dragonet-Legacy by DragonetMC.

the class DragonetSession method sendInventory.

public void sendInventory() {
    if (this.getPlayer() == null) {
        return;
    }
    if (this.getPlayer().getGameMode().equals(GameMode.CREATIVE)) {
        return;
    }
    WindowItemsPacket pkItems = new WindowItemsPacket();
    pkItems.windowID = PEWindowConstantID.PLAYER_INVENTORY;
    pkItems.slots = new PEInventorySlot[InventoryType.SlotSize.PLAYER];
    pkItems.hotbar = new int[9];
    for (int i = 9; i <= 35; i++) {
        if (this.getPlayer().getInventory().getContents()[i] != null) {
            pkItems.slots[i - 9] = new PEInventorySlot((short) (this.getPlayer().getInventory().getContents()[i].getTypeId() & 0xFFFF), (byte) (this.getPlayer().getInventory().getContents()[i].getAmount() & 0xFF), this.getPlayer().getInventory().getContents()[i].getDurability());
        } else {
            pkItems.slots[i - 9] = new PEInventorySlot();
        }
    }
    for (int i = 0; i <= 8; i++) {
        if (this.getPlayer().getInventory().getContents()[i] != null) {
            pkItems.slots[i + 27] = new PEInventorySlot((short) (this.getPlayer().getInventory().getContents()[i].getTypeId() & 0xFFFF), (byte) (this.getPlayer().getInventory().getContents()[i].getAmount() & 0xFF), this.getPlayer().getInventory().getContents()[i].getDurability());
        } else {
            pkItems.slots[i + 27] = new PEInventorySlot();
        }
    }
    for (int i = 0; i <= 8; i++) {
        pkItems.hotbar[i] = 44 - 8 + i;
    }
    this.send(pkItems);
}
Also used : WindowItemsPacket(org.dragonet.net.packet.minecraft.WindowItemsPacket) PEInventorySlot(org.dragonet.inventory.PEInventorySlot)

Aggregations

PEInventorySlot (org.dragonet.inventory.PEInventorySlot)6 PEPacket (org.dragonet.net.packet.minecraft.PEPacket)3 PlayerEquipmentPacket (org.dragonet.net.packet.minecraft.PlayerEquipmentPacket)2 WindowItemsPacket (org.dragonet.net.packet.minecraft.WindowItemsPacket)2 Message (com.flowpowered.networking.Message)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 BlockPlacementHandler (net.glowstone.net.handler.play.player.BlockPlacementHandler)1 SpawnObjectMessage (net.glowstone.net.message.play.entity.SpawnObjectMessage)1 BlockPlacementMessage (net.glowstone.net.message.play.player.BlockPlacementMessage)1 PlayerSwingArmMessage (net.glowstone.net.message.play.player.PlayerSwingArmMessage)1 Player (org.bukkit.entity.Player)1 ItemStack (org.bukkit.inventory.ItemStack)1 AddItemEntityPacket (org.dragonet.net.packet.minecraft.AddItemEntityPacket)1 UpdateBlockPacket (org.dragonet.net.packet.minecraft.UpdateBlockPacket)1 UseItemPacket (org.dragonet.net.packet.minecraft.UseItemPacket)1 PEBinaryWriter (org.dragonet.utilities.io.PEBinaryWriter)1