use of org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutWindowItems in project LanternServer by LanternPowered.
the class ClientContainer method init.
/**
* Initializes the container for the bounded {@link Player}.
*/
public void init() {
checkState(this.player != null);
populate();
final List<Message> messages = new ArrayList<>();
final Message message = createInitMessage();
if (message != null) {
messages.add(message);
}
final ItemStack[] items = new ItemStack[getSlotFlags().length];
for (int i = 0; i < items.length; i++) {
items[serverSlotIndexToClient(i)] = this.slots[i].getItem();
this.slots[i].dirtyState = 0;
}
// Send the inventory content
messages.add(new MessagePlayOutWindowItems(this.containerId, items));
// Send the cursor item if present
if (!this.cursor.getRaw().isEmpty()) {
messages.add(new MessagePlayOutSetWindowSlot(-1, -1, this.cursor.getItem()));
this.cursor.dirtyState = 0;
}
// Collect additional messages
collectInitMessages(messages);
// Stream the messages to the player
this.player.getConnection().send(messages);
}
Aggregations