use of com.nukkitx.protocol.bedrock.data.inventory.ItemData in project Geyser by GeyserMC.
the class ChestInventoryUpdater method updateInventory.
@Override
public void updateInventory(InventoryTranslator translator, GeyserSession session, Inventory inventory) {
super.updateInventory(translator, session, inventory);
List<ItemData> bedrockItems = new ArrayList<>(paddedSize);
for (int i = 0; i < paddedSize; i++) {
if (i < translator.size) {
bedrockItems.add(inventory.getItem(i).getItemData(session));
} else {
bedrockItems.add(UNUSUABLE_SPACE_BLOCK.apply(session.getUpstream().getProtocolVersion()));
}
}
InventoryContentPacket contentPacket = new InventoryContentPacket();
contentPacket.setContainerId(inventory.getId());
contentPacket.setContents(bedrockItems);
session.sendUpstreamPacket(contentPacket);
}
use of com.nukkitx.protocol.bedrock.data.inventory.ItemData in project Geyser by GeyserMC.
the class ContainerInventoryUpdater method updateInventory.
@Override
public void updateInventory(InventoryTranslator translator, GeyserSession session, Inventory inventory) {
super.updateInventory(translator, session, inventory);
ItemData[] bedrockItems = new ItemData[translator.size];
for (int i = 0; i < bedrockItems.length; i++) {
bedrockItems[translator.javaSlotToBedrock(i)] = inventory.getItem(i).getItemData(session);
}
InventoryContentPacket contentPacket = new InventoryContentPacket();
contentPacket.setContainerId(inventory.getId());
contentPacket.setContents(Arrays.asList(bedrockItems));
session.sendUpstreamPacket(contentPacket);
}
use of com.nukkitx.protocol.bedrock.data.inventory.ItemData in project Geyser by GeyserMC.
the class HorseInventoryUpdater method updateInventory.
@Override
public void updateInventory(InventoryTranslator translator, GeyserSession session, Inventory inventory) {
super.updateInventory(translator, session, inventory);
ItemData[] bedrockItems = new ItemData[translator.size];
for (int i = 0; i < bedrockItems.length; i++) {
bedrockItems[translator.javaSlotToBedrock(i)] = inventory.getItem(i).getItemData(session);
}
InventoryContentPacket contentPacket = new InventoryContentPacket();
contentPacket.setContainerId(inventory.getId());
contentPacket.setContents(Arrays.asList(bedrockItems));
session.sendUpstreamPacket(contentPacket);
}
use of com.nukkitx.protocol.bedrock.data.inventory.ItemData in project Geyser by GeyserMC.
the class InventoryUpdater method updateInventory.
public void updateInventory(InventoryTranslator translator, GeyserSession session, Inventory inventory) {
ItemData[] bedrockItems = new ItemData[36];
for (int i = 0; i < 36; i++) {
final int offset = i < 9 ? 27 : -9;
bedrockItems[i] = inventory.getItem(translator.size + i + offset).getItemData(session);
}
InventoryContentPacket contentPacket = new InventoryContentPacket();
contentPacket.setContainerId(ContainerId.INVENTORY);
contentPacket.setContents(Arrays.asList(bedrockItems));
session.sendUpstreamPacket(contentPacket);
}
use of com.nukkitx.protocol.bedrock.data.inventory.ItemData in project Protocol by CloudburstMC.
the class BedrockPacketHelper_v431 method readInventoryActions.
@Override
public boolean readInventoryActions(ByteBuf buffer, BedrockSession session, List<InventoryActionData> actions) {
this.readArray(buffer, actions, session, (buf, helper, aSession) -> {
InventorySource source = helper.readSource(buf);
int slot = VarInts.readUnsignedInt(buf);
ItemData fromItem = helper.readItem(buf, aSession);
ItemData toItem = helper.readItem(buf, aSession);
return new InventoryActionData(source, slot, fromItem, toItem);
});
return false;
}
Aggregations