if (slot == oldSlot) {
// ignore
return;
}
PlayerItemHeldEvent event = new PlayerItemHeldEvent(player, oldSlot, slot);
EventFactory.callEvent(event);
if (!event.isCancelled()) {
player.getInventory().setRawHeldItemSlot(slot);
} else {
// sends a packet to switch back to the previous held slot
player.getInventory().setHeldItemSlot(oldSlot);
}