Search in sources :

Example 1 with ClientboundSetCarriedItemPacket

use of net.minecraft.network.protocol.game.ClientboundSetCarriedItemPacket in project SpongeCommon by SpongePowered.

the class InventoryMixin_Bridge_Inventory method bridge$setSelectedItem.

@Override
public void bridge$setSelectedItem(int itemIndex, final boolean notify) {
    itemIndex = itemIndex % 9;
    if (notify && this.player instanceof ServerPlayer) {
        final ClientboundSetCarriedItemPacket packet = new ClientboundSetCarriedItemPacket(itemIndex);
        ((ServerPlayer) this.player).connection.send(packet);
    }
    this.selected = itemIndex;
}
Also used : ServerPlayer(net.minecraft.server.level.ServerPlayer) ClientboundSetCarriedItemPacket(net.minecraft.network.protocol.game.ClientboundSetCarriedItemPacket)

Example 2 with ClientboundSetCarriedItemPacket

use of net.minecraft.network.protocol.game.ClientboundSetCarriedItemPacket in project SpongeCommon by SpongePowered.

the class SetCarriedItemTransaction method restore.

@Override
public void restore(final PhaseContext<@NonNull ?> context, final ChangeInventoryEvent event) {
    this.player.connection.send(new ClientboundSetCarriedItemPacket(this.prevSlotId));
    this.player.inventory.selected = this.prevSlotId;
    this.handleEventResults(this.player, event);
}
Also used : ClientboundSetCarriedItemPacket(net.minecraft.network.protocol.game.ClientboundSetCarriedItemPacket)

Aggregations

ClientboundSetCarriedItemPacket (net.minecraft.network.protocol.game.ClientboundSetCarriedItemPacket)2 ServerPlayer (net.minecraft.server.level.ServerPlayer)1