use of net.minecraft.network.protocol.game.ClientboundContainerClosePacket in project SpongeCommon by SpongePowered.
the class CloseMenuTransaction method postProcessEvent.
@Override
public void postProcessEvent(final PhaseContext<@NonNull ?> context, final InteractContainerEvent event) {
if (!this.clientSource) {
// Server closed send packet to client
this.player.connection.send(new ClientboundContainerClosePacket(this.player.containerMenu.containerId));
}
// Finish closing container
this.player.containerMenu = this.player.inventoryMenu;
// And restore cursor if needed
PacketPhaseUtil.handleCursorRestore(this.player, event.cursorTransaction());
if (event instanceof ChangeInventoryEvent) {
PacketPhaseUtil.handleSlotRestore(this.player, this.menu, ((ChangeInventoryEvent) event).transactions(), event.isCancelled());
}
// prevent double capture
this.player.inventoryMenu.broadcastChanges();
}
Aggregations