Class CustomBlock.Advanced

java.lang.Object
dev.lone.itemsadder.api.CustomBlock.Advanced
Enclosing class:
CustomBlock

public static class CustomBlock.Advanced extends Object
Advanced helpers for editing ItemsAdder custom block region data directly.
  • Constructor Details

    • Advanced

      public Advanced()
  • Method Details

    • getInCustomRegion

      @Nullable public static @Nullable String getInCustomRegion(Location location)
      Gets the custom block namespaced id stored in region data at a location.
      Parameters:
      location - the location to check.
      Returns:
      the custom block namespaced id, or null if none is stored.
    • placeInCustomRegion

      public static void placeInCustomRegion(@NotNull @NotNull CustomBlock customBlock, Location location)
      Stores a custom block in region data without placing the vanilla block state.
      Parameters:
      customBlock - the custom block to store.
      location - the location to write.
    • placeInCustomRegion

      public static boolean placeInCustomRegion(String namespacedId, Location location)
      Stores a custom block in region data without placing the vanilla block state.
      Parameters:
      namespacedId - the custom block namespaced id.
      location - the location to write.
      Returns:
      true if the custom block exists and was stored.
    • removeFromCustomRegion

      public static boolean removeFromCustomRegion(Location location)
      Removes custom block region data at a location.
      Parameters:
      location - the location to clear.
      Returns:
      true if custom block data existed and was removed.
    • deleteAllCustomBlocksInChunk

      public static void deleteAllCustomBlocksInChunk(Chunk chunk)
      Deletes all custom block data stored for a chunk.
      Parameters:
      chunk - the chunk to clear.
    • deleteAllCustomBlocksInChunk

      public static void deleteAllCustomBlocksInChunk(Chunk chunk, boolean removeVanillaBlock, boolean sendChunkPacket)
      Deletes all custom block data stored for a chunk.
      Parameters:
      chunk - the chunk to clear.
      removeVanillaBlock - true to also remove the vanilla blocks.
      sendChunkPacket - true to refresh the chunk for players after removal.
    • getAllBlocksLocationsList

      @Nullable public static @Nullable List<Location> getAllBlocksLocationsList(Chunk chunk)
      Gets all custom block locations stored in a chunk.
      Parameters:
      chunk - the chunk to read.
      Returns:
      the custom block locations, or null if the region is not available.
    • getAllBlocksLocations

      @Nullable public static @Nullable Map<Location,String> getAllBlocksLocations(Chunk chunk)
      Gets all custom block locations and namespaced ids stored in a chunk.
      Parameters:
      chunk - the chunk to read.
      Returns:
      a map of locations to custom block namespaced ids, or null if the region is not available.
    • runActionOnBlocks

      public static void runActionOnBlocks(Chunk chunk, BiConsumer<String,Location> action)
      Runs an action for each custom block stored in a chunk.
      Parameters:
      chunk - the chunk to read.
      action - receives the namespaced id and location of each stored custom block.