Class CustomBlock

java.lang.Object
dev.lone.itemsadder.api.CustomStack
dev.lone.itemsadder.api.CustomBlock

public class CustomBlock extends CustomStack
Wrapper for a custom block item and, when available, its placed block.
  • Method Details

    • getNamespacedIdsInRegistry

      public static Set<String> getNamespacedIdsInRegistry()
      Gets all custom block namespaced ids currently registered.
      Returns:
      the registered custom block namespaced ids.
    • isInRegistry

      public static boolean isInRegistry(String namespacedId)
      Checks if a custom block is registered.
      Parameters:
      namespacedId - the custom block namespaced id.
      Returns:
      true if the custom block exists in the registry.
    • getInstance

      @Nullable public static @Nullable CustomBlock getInstance(String namespacedID)
      Gets a clone of the custom block item declared in the ItemsAdder registry.
      Parameters:
      namespacedID - the custom block namespaced id.
      Returns:
      the custom block wrapper, or null if it does not exist.
    • byItemStack

      @Nullable public static @Nullable CustomBlock byItemStack(ItemStack itemStack)
      Gets a custom block wrapper from an item stack.
      Parameters:
      itemStack - the item stack to read.
      Returns:
      the custom block wrapper, or null if the item is not a custom block.
    • place

      @Nullable public static @Nullable CustomBlock place(String namespacedId, Location location)
      Places a custom block in the world.
      Parameters:
      namespacedId - the custom block namespaced id.
      location - the location where the block will be placed.
      Returns:
      the placed custom block wrapper, or null if the block does not exist.
    • byAlreadyPlaced

      @Nullable public static @Nullable CustomBlock byAlreadyPlaced(Block block)
      Gets the custom block wrapper for an already placed block.
      Parameters:
      block - the block to check.
      Returns:
      the custom block wrapper, or null if the block is not a custom block.
    • remove

      public static boolean remove(Location location)
      Removes a custom block from the world and from ItemsAdder region data.
      Parameters:
      location - the custom block location.
      Returns:
      true if a custom block was removed.
    • generateBlockData

      @Deprecated @Nullable public @Nullable BlockData generateBlockData()
      Deprecated.
      use getBaseBlockData() instead.
      Generates the base block data used by this custom block.
      Returns:
      the base block data, or null if not available.
    • getBaseBlockData

      @Nullable public @Nullable BlockData getBaseBlockData()
      Gets the base block data used by this custom block.
      Returns:
      the base block data, or null if not available.
    • getBaseBlockData

      @Nullable public static @Nullable BlockData getBaseBlockData(String namespacedID)
      Gets the base block data used by a registered custom block.
      Parameters:
      namespacedID - the custom block namespaced id.
      Returns:
      the base block data, or null if the block does not exist.
    • getBlock

      @Nullable public @Nullable Block getBlock()
      Gets the placed Bukkit block associated with this wrapper.
      Returns:
      the Bukkit block, or null if this wrapper is not placed.
    • isPlaced

      public boolean isPlaced()
      Checks if this wrapper is associated with a placed block.
      Returns:
      true if this custom block is placed.
    • place

      public CustomBlock place(Location location)
      Places this custom block in the world.
      Parameters:
      location - the location where the block will be placed.
      Returns:
      this wrapper.
    • remove

      public boolean remove()
      Removes this custom block from the world.
      Returns:
      true if the custom block was removed.
    • playBreakEffect

      public boolean playBreakEffect()
      Plays the configured break particles and sound for this block.
      Returns:
      true if the effect was played.
    • playBreakEffect

      public static boolean playBreakEffect(Block bukkitBlock)
      Plays the configured break particles and sound for a placed custom block.
      Parameters:
      bukkitBlock - the placed custom block.
      Returns:
      true if the effect was played.
    • playBreakSound

      public boolean playBreakSound()
      Plays the configured break sound for this block.
      Returns:
      true if the sound was played.
    • playBreakSound

      public static boolean playBreakSound(Block bukkitBlock)
      Plays the configured break sound for a placed custom block.
      Parameters:
      bukkitBlock - the placed custom block.
      Returns:
      true if the sound was played.
    • playBreakParticles

      public boolean playBreakParticles()
      Plays the configured break particles for this block.
      Returns:
      true if the particles were played.
    • playBreakParticles

      public static boolean playBreakParticles(Block bukkitBlock)
      Plays the configured break particles for a placed custom block.
      Parameters:
      bukkitBlock - the placed custom block.
      Returns:
      true if the particles were played.
    • playPlaceSound

      public boolean playPlaceSound()
      Plays the configured place sound for this block.
      Returns:
      true if the sound was played.
    • playPlaceSound

      public static boolean playPlaceSound(Block bukkitBlock)
      Plays the configured place sound for a placed custom block.
      Parameters:
      bukkitBlock - the placed custom block.
      Returns:
      true if the sound was played.
    • getLoot

      public List<ItemStack> getLoot(boolean includeSelfBlock)
      Gets the loot generated by this custom block.
      Parameters:
      includeSelfBlock - true to include the block item itself when configured.
      Returns:
      the generated loot.
    • getLoot

      public List<ItemStack> getLoot()
      Gets the loot generated by this custom block using the default options.
      Returns:
      the generated loot.
    • getLoot

      public List<ItemStack> getLoot(@Nullable @Nullable ItemStack tool, boolean includeSelfBlock)
      Gets the loot generated by this custom block.
      Parameters:
      tool - the tool used to break the block, or null.
      includeSelfBlock - true to include the block item itself when configured.
      Returns:
      the generated loot.
    • getLoot

      public static List<ItemStack> getLoot(Block bukkitBlock, @Nullable @Nullable ItemStack tool, boolean includeSelfBlock)
      Gets the loot generated by a placed custom block.
      Parameters:
      bukkitBlock - the placed custom block.
      tool - the tool used to break the block, or null.
      includeSelfBlock - true to include the block item itself when configured.
      Returns:
      the generated loot, or an empty list if the block is not custom.
    • getOriginalLightLevel

      public int getOriginalLightLevel()
      Gets the light level configured for this custom block.
      Returns:
      the configured light level.
    • setCurrentLightLevel

      public void setCurrentLightLevel(int level)
      Sets the current light level emitted by this custom block.
      Parameters:
      level - the new light level.