Class CustomBlock

java.lang.Object
dev.piglin.piglinworldapi.block.CustomBlock

public abstract class CustomBlock extends Object
Your custom block. Extend this class to make a block.

How this works: There are mushrooms. Many mushrooms. 192 in total (3 types * 64=2^6 boolean fields in BlockState). Some of them are used (deprecated in Mushroom), some are not. You can override one mushroom to be your custom block. We'll take care of any mutations done to the mushroom block (or at least we try to do this)

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    CustomBlock​(Mushroom mushroom)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract boolean
    breakBlock​(org.bukkit.block.Block block, org.bukkit.inventory.ItemStack tool)
    Handle block break
    List<org.bukkit.block.Block>
     
    onInteract​(org.bukkit.event.player.PlayerInteractEvent event)
    Handle interaction at the block
    abstract void
    onLoad​(org.bukkit.block.Block block)
    Handle the block load (when the chunk is being loaded)
    abstract void
    onUnload​(org.bukkit.block.Block block)
    Handle the block unload (when the chunk is being unloaded)
    abstract boolean
    placeBlock​(org.bukkit.block.Block block)
    Handle block placement

    Methods inherited from class java.lang.Object

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

    • mushroom

      public final Mushroom mushroom
  • Constructor Details

    • CustomBlock

      public CustomBlock(Mushroom mushroom)
      Parameters:
      mushroom - The mushroom to use
  • Method Details

    • onInteract

      public abstract Optional<CustomGui> onInteract(org.bukkit.event.player.PlayerInteractEvent event)
      Handle interaction at the block
      Parameters:
      event - The event
      Returns:
      gui to open if any
    • breakBlock

      public abstract boolean breakBlock(org.bukkit.block.Block block, org.bukkit.inventory.ItemStack tool)
      Handle block break
      Parameters:
      block - The block
      tool - The tool
      Returns:
      true if the block should spawn as an item
    • placeBlock

      public abstract boolean placeBlock(org.bukkit.block.Block block)
      Handle block placement
      Parameters:
      block - The block
      Returns:
      false to cancel
    • onLoad

      public abstract void onLoad(org.bukkit.block.Block block)
      Handle the block load (when the chunk is being loaded)
      Parameters:
      block - The block
    • onUnload

      public abstract void onUnload(org.bukkit.block.Block block)
      Handle the block unload (when the chunk is being unloaded)
      Parameters:
      block - The block
    • getBlocks

      public List<org.bukkit.block.Block> getBlocks()
      Returns:
      Loaded blocks of this type