hunger.setEating(true, currentSlot);
return;
}
if (clickedFace == BlockFace.THIS) {
// Right clicked air with an item.
PlayerInteractBlockEvent event = Spout.getEventManager().callEvent(new PlayerInteractBlockEvent(player, null, null, clickedFace, Action.RIGHT_CLICK));
// May have been changed by the event
holding = currentSlot.get();
holdingMat = holding == null ? null : holding.getMaterial();
if (holdingMat != null) {
holdingMat.onInteract(player, Action.RIGHT_CLICK);
}
} else {
// TODO: Validate the x/y/z coordinates of the message to check if it is in range of the player
// This is an anti-hack requirement (else hackers can load far-away chunks and crash the server)
// Get clicked block and validated face against it was placed
final Block clickedBlock = world.getBlock(message.getX(), message.getY(), message.getZ());
final BlockMaterial clickedMaterial = clickedBlock.getMaterial();
// Perform interaction event
PlayerInteractBlockEvent interactEvent = Spout.getEventManager().callEvent(new PlayerInteractBlockEvent(player, clickedBlock, clickedBlock.getPosition(), clickedFace, Action.RIGHT_CLICK));
// May have been changed by the event
holding = currentSlot.get();
holdingMat = holding == null ? null : holding.getMaterial();
// check if the interaction was cancelled by the event
if (interactEvent.isCancelled()) {
refreshClient(player, clickedBlock, clickedFace, rm);
return;
}
if (holdingMat != null) {
holdingMat.onInteract(player, clickedBlock, Action.RIGHT_CLICK, clickedFace);