Class PlayerInteractEvent.LeftClickBlock

Enclosing class:

public static class PlayerInteractEvent.LeftClickBlock extends PlayerInteractEvent
This event is fired when a player left clicks while targeting a block. This event controls which of net.minecraft.block.Block#onBlockClicked and/or the item harvesting methods will be called Canceling the event will cause none of the above noted methods to be called. There are various results to this event, see the getters below. Note that if the event is canceled and the player holds down left mouse, the event will continue to fire. This is due to how vanilla calls the left click handler methods. Also note that creative mode directly breaks the block without running any other logic. Therefore, in creative mode, setUseBlock(net.minecraftforge.eventbus.api.Event.Result) and setUseItem(net.minecraftforge.eventbus.api.Event.Result) have no effect.
  • Field Details

    • useBlock

      private net.minecraftforge.eventbus.api.Event.Result useBlock
    • useItem

      private net.minecraftforge.eventbus.api.Event.Result useItem
  • Constructor Details

  • Method Details

    • getUseBlock

      public net.minecraftforge.eventbus.api.Event.Result getUseBlock()
      If net.minecraft.block.Block#onBlockClicked should be called. Changing this has no effect in creative mode
    • getUseItem

      public net.minecraftforge.eventbus.api.Event.Result getUseItem()
      If the block should be attempted to be mined with the current item. Changing this has no effect in creative mode
    • setUseBlock

      public void setUseBlock(net.minecraftforge.eventbus.api.Event.Result triggerBlock)
    • setUseItem

      public void setUseItem(net.minecraftforge.eventbus.api.Event.Result triggerItem)
    • setCanceled

      public void setCanceled(boolean canceled)
      setCanceled in class net.minecraftforge.eventbus.api.Event