Class PaperItemBehavior

java.lang.Object
net.momirealms.craftengine.core.item.behavior.ItemBehavior
fr.robie.machineengine.api.paper.PaperItemBehavior

public abstract class PaperItemBehavior extends net.momirealms.craftengine.core.item.behavior.ItemBehavior
A CraftEngine item behavior written with Bukkit types (D32): right-clicks with the item in the main hand arrive as one use(Use), whether on a block or in the air, and useOnEntity(Player, ItemStack, Entity) on an entity. Return true when the click was handled: it is then cancelled, as a listener would.

CraftEngine calls these on the player's thread. A click on a vanilla block that opens something (a chest, a furnace) reaches the item only while the player sneaks; a click on a machine reaches it only when the behavior is also a MachineTool.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    A right-click with the item.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected boolean
    use(@NotNull PaperItemBehavior.Use use)
     
    final net.momirealms.craftengine.core.entity.player.InteractionResult
    use(net.momirealms.craftengine.core.world.World world, @Nullable net.momirealms.craftengine.core.entity.player.Player player, net.momirealms.craftengine.core.entity.player.InteractionHand hand)
     
    final net.momirealms.craftengine.core.entity.player.InteractionResult
    useOnBlock(net.momirealms.craftengine.core.world.context.UseOnContext context)
     
    final net.momirealms.craftengine.core.entity.player.InteractionResult
    useOnEntity(net.momirealms.craftengine.core.world.context.InteractEntityContext context)
     
    protected boolean
    useOnEntity(@NotNull org.bukkit.entity.Player player, @NotNull org.bukkit.inventory.ItemStack item, @NotNull org.bukkit.entity.Entity target)
     

    Methods inherited from class net.momirealms.craftengine.core.item.behavior.ItemBehavior

    getFirst, let, onBreakBlock

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PaperItemBehavior

      public PaperItemBehavior()
  • Method Details

    • use

      protected boolean use(@NotNull @NotNull PaperItemBehavior.Use use)
      Returns:
      whether the click was handled (it is cancelled)
    • useOnEntity

      protected boolean useOnEntity(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull org.bukkit.inventory.ItemStack item, @NotNull @NotNull org.bukkit.entity.Entity target)
      Returns:
      whether the click was handled (it is cancelled)
    • useOnBlock

      public final net.momirealms.craftengine.core.entity.player.InteractionResult useOnBlock(net.momirealms.craftengine.core.world.context.UseOnContext context)
      Overrides:
      useOnBlock in class net.momirealms.craftengine.core.item.behavior.ItemBehavior
    • use

      public final net.momirealms.craftengine.core.entity.player.InteractionResult use(net.momirealms.craftengine.core.world.World world, @Nullable net.momirealms.craftengine.core.entity.player.Player player, net.momirealms.craftengine.core.entity.player.InteractionHand hand)
      Overrides:
      use in class net.momirealms.craftengine.core.item.behavior.ItemBehavior
    • useOnEntity

      public final net.momirealms.craftengine.core.entity.player.InteractionResult useOnEntity(net.momirealms.craftengine.core.world.context.InteractEntityContext context)
      Overrides:
      useOnEntity in class net.momirealms.craftengine.core.item.behavior.ItemBehavior