Class PlayerEvent.HarvestCheck

Enclosing class:
PlayerEvent

public static class PlayerEvent.HarvestCheck extends PlayerEvent
HarvestCheck is fired when a player attempts to harvest a block.

This event is fired whenever a player attempts to harvest a block in Player.hasCorrectToolForDrops(BlockState).

This event is fired via the EventHooks.doPlayerHarvestCheck(Player, BlockState, BlockGetter, BlockPos).

  • state contains the BlockState that is being checked for harvesting.
  • success contains the boolean value for whether the Block will be successfully harvested.
  • PlayerEvent.getEntity() contains the player that caused this event to occur.
This event is not cancellable, and is fired on the game event bus.
  • Field Details

    • state

      private final BlockState state
    • level

      private final BlockGetter level
    • pos

      private final BlockPos pos
    • success

      private boolean success
  • Constructor Details

  • Method Details

    • getTargetBlock

      public BlockState getTargetBlock()
    • getLevel

      public BlockGetter getLevel()
    • getPos

      public BlockPos getPos()
    • canHarvest

      public boolean canHarvest()
    • setCanHarvest

      public void setCanHarvest(boolean success)