Update block interact event, and add some clarifying Javadocs on what blockItemUse method does (#102)

This commit is contained in:
GreatWyrm 2024-01-05 23:15:28 -08:00 committed by Matt Worzala
parent 2d5fa3a7c7
commit dfe892aa1a

View File

@ -19,6 +19,7 @@ public class PlayerBlockInteractEvent implements PlayerInstanceEvent, BlockEvent
private final Player.Hand hand;
private final Block block;
private final Point blockPosition;
private final Point cursorPosition;
private final BlockFace blockFace;
/**
@ -36,6 +37,7 @@ public class PlayerBlockInteractEvent implements PlayerInstanceEvent, BlockEvent
this.hand = hand;
this.block = block;
this.blockPosition = blockPosition;
this.cursorPosition = cursorPosition;
this.blockFace = blockFace;
}
@ -48,6 +50,11 @@ public class PlayerBlockInteractEvent implements PlayerInstanceEvent, BlockEvent
return blocksItemUse;
}
/**
* Sets the blocking item use state of this event
* Note: If this is true, then no {@link PlayerUseItemOnBlockEvent} will be fired.
* @param blocks - true to block item interactions, false to not block
*/
public void setBlockingItemUse(boolean blocks) {
this.blocksItemUse = blocks;
}
@ -66,6 +73,12 @@ public class PlayerBlockInteractEvent implements PlayerInstanceEvent, BlockEvent
return blockPosition;
}
/**
* Gets the cursor position of the interacted block
* @return the cursor position of the interaction
*/
public @NotNull Point getCursorPosition() { return cursorPosition; }
/**
* Gets the hand used for the interaction.
*