Java Code Examples for com.nukkitx.protocol.bedrock.packet.InventorySlotPacket#setSlot()
The following examples show how to use
com.nukkitx.protocol.bedrock.packet.InventorySlotPacket#setSlot() .
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: PlayerInventoryTranslator.java From Geyser with MIT License | 6 votes |
/** * Update the crafting grid for the player to hide/show the barriers in the creative inventory * @param session Session of the player * @param inventory Inventory of the player */ public static void updateCraftingGrid(GeyserSession session, Inventory inventory) { // Crafting grid for (int i = 1; i < 5; i++) { InventorySlotPacket slotPacket = new InventorySlotPacket(); slotPacket.setContainerId(ContainerId.CURSOR); slotPacket.setSlot(i + 27); if (session.getGameMode() == GameMode.CREATIVE) { slotPacket.setItem(UNUSUABLE_CRAFTING_SPACE_BLOCK); }else{ slotPacket.setItem(ItemTranslator.translateToBedrock(session, inventory.getItem(i))); } session.sendUpstreamPacket(slotPacket); } }
Example 2
Source File: PlayerInventoryTranslator.java From Geyser with MIT License | 5 votes |
@Override public void updateSlot(GeyserSession session, Inventory inventory, int slot) { if (slot >= 1 && slot <= 44) { InventorySlotPacket slotPacket = new InventorySlotPacket(); if (slot >= 9) { slotPacket.setContainerId(ContainerId.INVENTORY); if (slot >= 36) { slotPacket.setSlot(slot - 36); } else { slotPacket.setSlot(slot); } } else if (slot >= 5) { slotPacket.setContainerId(ContainerId.ARMOR); slotPacket.setSlot(slot - 5); } else { slotPacket.setContainerId(ContainerId.CURSOR); slotPacket.setSlot(slot + 27); } slotPacket.setItem(ItemTranslator.translateToBedrock(session, inventory.getItem(slot))); session.sendUpstreamPacket(slotPacket); } else if (slot == 45) { InventoryContentPacket offhandPacket = new InventoryContentPacket(); offhandPacket.setContainerId(ContainerId.OFFHAND); offhandPacket.setContents(new ItemData[]{ItemTranslator.translateToBedrock(session, inventory.getItem(slot))}); session.sendUpstreamPacket(offhandPacket); } }
Example 3
Source File: InventoryUpdater.java From Geyser with MIT License | 5 votes |
public boolean updateSlot(InventoryTranslator translator, GeyserSession session, Inventory inventory, int javaSlot) { if (javaSlot >= translator.size) { InventorySlotPacket slotPacket = new InventorySlotPacket(); slotPacket.setContainerId(ContainerId.INVENTORY); slotPacket.setSlot(translator.javaSlotToBedrock(javaSlot)); slotPacket.setItem(ItemTranslator.translateToBedrock(session, inventory.getItem(javaSlot))); session.sendUpstreamPacket(slotPacket); return true; } return false; }
Example 4
Source File: ContainerInventoryUpdater.java From Geyser with MIT License | 5 votes |
@Override public boolean updateSlot(InventoryTranslator translator, GeyserSession session, Inventory inventory, int javaSlot) { if (super.updateSlot(translator, session, inventory, javaSlot)) return true; InventorySlotPacket slotPacket = new InventorySlotPacket(); slotPacket.setContainerId(inventory.getId()); slotPacket.setSlot(translator.javaSlotToBedrock(javaSlot)); slotPacket.setItem(ItemTranslator.translateToBedrock(session, inventory.getItem(javaSlot))); session.sendUpstreamPacket(slotPacket); return true; }
Example 5
Source File: ChestInventoryUpdater.java From Geyser with MIT License | 5 votes |
@Override public boolean updateSlot(InventoryTranslator translator, GeyserSession session, Inventory inventory, int javaSlot) { if (super.updateSlot(translator, session, inventory, javaSlot)) return true; InventorySlotPacket slotPacket = new InventorySlotPacket(); slotPacket.setContainerId(inventory.getId()); slotPacket.setSlot(translator.javaSlotToBedrock(javaSlot)); slotPacket.setItem(ItemTranslator.translateToBedrock(session, inventory.getItem(javaSlot))); session.sendUpstreamPacket(slotPacket); return true; }
Example 6
Source File: CursorInventoryUpdater.java From Geyser with MIT License | 5 votes |
@Override public void updateInventory(InventoryTranslator translator, GeyserSession session, Inventory inventory) { super.updateInventory(translator, session, inventory); for (int i = 0; i < translator.size; i++) { final int bedrockSlot = translator.javaSlotToBedrock(i); if (bedrockSlot == 50) continue; InventorySlotPacket slotPacket = new InventorySlotPacket(); slotPacket.setContainerId(ContainerId.CURSOR); slotPacket.setSlot(bedrockSlot); slotPacket.setItem(ItemTranslator.translateToBedrock(session, inventory.getItem(i))); session.sendUpstreamPacket(slotPacket); } }
Example 7
Source File: CursorInventoryUpdater.java From Geyser with MIT License | 5 votes |
@Override public boolean updateSlot(InventoryTranslator translator, GeyserSession session, Inventory inventory, int javaSlot) { if (super.updateSlot(translator, session, inventory, javaSlot)) return true; InventorySlotPacket slotPacket = new InventorySlotPacket(); slotPacket.setContainerId(ContainerId.CURSOR); slotPacket.setSlot(translator.javaSlotToBedrock(javaSlot)); slotPacket.setItem(ItemTranslator.translateToBedrock(session, inventory.getItem(javaSlot))); session.sendUpstreamPacket(slotPacket); return true; }
Example 8
Source File: InventoryUtils.java From Geyser with MIT License | 5 votes |
public static void updateCursor(GeyserSession session) { InventorySlotPacket cursorPacket = new InventorySlotPacket(); cursorPacket.setContainerId(ContainerId.CURSOR); cursorPacket.setSlot(0); cursorPacket.setItem(ItemTranslator.translateToBedrock(session, session.getInventory().getCursor())); session.sendUpstreamPacket(cursorPacket); }
Example 9
Source File: InventorySlotSerializer_v354.java From Protocol with Apache License 2.0 | 4 votes |
@Override public void deserialize(ByteBuf buffer, InventorySlotPacket packet) { packet.setContainerId(VarInts.readUnsignedInt(buffer)); packet.setSlot(VarInts.readUnsignedInt(buffer)); packet.setItem(BedrockUtils.readItemData(buffer)); }
Example 10
Source File: InventorySlotSerializer_v388.java From Protocol with Apache License 2.0 | 4 votes |
@Override public void deserialize(ByteBuf buffer, InventorySlotPacket packet) { packet.setContainerId(VarInts.readUnsignedInt(buffer)); packet.setSlot(VarInts.readUnsignedInt(buffer)); packet.setItem(BedrockUtils.readItemData(buffer)); }
Example 11
Source File: InventorySlotSerializer_v340.java From Protocol with Apache License 2.0 | 4 votes |
@Override public void deserialize(ByteBuf buffer, InventorySlotPacket packet) { packet.setContainerId(VarInts.readUnsignedInt(buffer)); packet.setSlot(VarInts.readUnsignedInt(buffer)); packet.setItem(BedrockUtils.readItemData(buffer)); }
Example 12
Source File: InventorySlotSerializer_v313.java From Protocol with Apache License 2.0 | 4 votes |
@Override public void deserialize(ByteBuf buffer, InventorySlotPacket packet) { packet.setContainerId(VarInts.readUnsignedInt(buffer)); packet.setSlot(VarInts.readUnsignedInt(buffer)); packet.setItem(BedrockUtils.readItemData(buffer)); }
Example 13
Source File: InventorySlotSerializer_v361.java From Protocol with Apache License 2.0 | 4 votes |
@Override public void deserialize(ByteBuf buffer, InventorySlotPacket packet) { packet.setContainerId(VarInts.readUnsignedInt(buffer)); packet.setSlot(VarInts.readUnsignedInt(buffer)); packet.setItem(BedrockUtils.readItemData(buffer)); }
Example 14
Source File: InventorySlotSerializer_v332.java From Protocol with Apache License 2.0 | 4 votes |
@Override public void deserialize(ByteBuf buffer, InventorySlotPacket packet) { packet.setContainerId(VarInts.readUnsignedInt(buffer)); packet.setSlot(VarInts.readUnsignedInt(buffer)); packet.setItem(BedrockUtils.readItemData(buffer)); }
Example 15
Source File: InventorySlotSerializer_v291.java From Protocol with Apache License 2.0 | 4 votes |
@Override public void deserialize(ByteBuf buffer, InventorySlotPacket packet) { packet.setContainerId(VarInts.readUnsignedInt(buffer)); packet.setSlot(VarInts.readUnsignedInt(buffer)); packet.setItem(BedrockUtils.readItemData(buffer)); }