use of cn.nukkit.network.protocol.InventoryContentPacket in project Nukkit by Nukkit.
the class BaseInventory method sendContents.
@Override
public void sendContents(Player... players) {
InventoryContentPacket pk = new InventoryContentPacket();
pk.slots = new Item[this.getSize()];
for (int i = 0; i < this.getSize(); ++i) {
pk.slots[i] = this.getItem(i);
}
for (Player player : players) {
int id = player.getWindowId(this);
if (id == -1 || !player.spawned) {
this.close(player);
continue;
}
pk.inventoryId = id;
player.dataPacket(pk);
}
}
use of cn.nukkit.network.protocol.InventoryContentPacket in project Nukkit by Nukkit.
the class PlayerInventory method sendArmorContents.
public void sendArmorContents(Player[] players) {
Item[] armor = this.getArmorContents();
MobArmorEquipmentPacket pk = new MobArmorEquipmentPacket();
pk.eid = this.getHolder().getId();
pk.slots = armor;
pk.encode();
pk.isEncoded = true;
for (Player player : players) {
if (player.equals(this.getHolder())) {
InventoryContentPacket pk2 = new InventoryContentPacket();
pk2.inventoryId = InventoryContentPacket.SPECIAL_ARMOR;
pk2.slots = armor;
player.dataPacket(pk2);
} else {
player.dataPacket(pk);
}
}
}
use of cn.nukkit.network.protocol.InventoryContentPacket in project Nukkit by Nukkit.
the class PlayerInventory method sendCreativeContents.
public void sendCreativeContents() {
if (!(this.getHolder() instanceof Player)) {
return;
}
Player p = (Player) this.getHolder();
InventoryContentPacket pk = new InventoryContentPacket();
pk.inventoryId = ContainerIds.CREATIVE;
if (!p.isSpectator()) {
// fill it for all gamemodes except spectator
pk.slots = Item.getCreativeItems().stream().toArray(Item[]::new);
}
p.dataPacket(pk);
}
use of cn.nukkit.network.protocol.InventoryContentPacket in project Nukkit by Nukkit.
the class PlayerInventory method sendContents.
@Override
public void sendContents(Player[] players) {
InventoryContentPacket pk = new InventoryContentPacket();
pk.slots = new Item[this.getSize()];
for (int i = 0; i < this.getSize(); ++i) {
pk.slots[i] = this.getItem(i);
}
for (Player player : players) {
int id = player.getWindowId(this);
if (id == -1 || !player.spawned) {
this.close(player);
continue;
}
pk.inventoryId = id;
player.dataPacket(pk.clone());
}
}
Aggregations