Class Material

java.lang.Object
com.hypixel.hytale.builtin.buildertools.utils.Material

public final class Material extends Object
Represents a material that can be either a block type, a fluid, or empty.

This abstraction allows builder tools to handle blocks and fluids uniformly, reducing code duplication in commands and operations.

Materials can optionally include rotation information for blocks.

  • Field Details

    • EMPTY

      public static final Material EMPTY
      Empty material - represents clearing both block and fluid.
  • Method Details

    • block

      @Nonnull public static Material block(int blockId)
      Creates a material representing a block type.
      Parameters:
      blockId - the block type ID
      Returns:
      the material
    • block

      @Nonnull public static Material block(int blockId, int rotation)
      Creates a material representing a block type with rotation.
      Parameters:
      blockId - the block type ID
      rotation - the rotation tuple index
      Returns:
      the material
    • fluid

      @Nonnull public static Material fluid(int fluidId, byte fluidLevel)
      Creates a material representing a fluid.
      Parameters:
      fluidId - the fluid ID
      fluidLevel - the fluid level
      Returns:
      the material
    • full

      @Nonnull public static Material full(int blockId, int rotation, int support, int filler, @Nullable Holder<ChunkStore> holder)
    • full

      @Nonnull public static Material full(int blockId, int rotation, int support, int filler, @Nullable Holder<ChunkStore> holder, int fluidId, byte fluidLevel)
    • fromKey

      @Nullable public static Material fromKey(@Nonnull String key)
      Parses a material from a key string.

      Supports rotation syntax: "Rock_Stone|Yaw=90|Pitch=45"

      First checks if the key is a fluid-placing item (has PlaceFluidInteraction), then falls back to checking if it's a block type.

      Parameters:
      key - the material key (e.g., "Rock_Stone", "Rock_Stone|Yaw=90", "Fluid_Water", "empty")
      Returns:
      the material, or null if the key is invalid
    • isFluid

      public boolean isFluid()
      Returns:
      true if this material represents a fluid (not a block)
    • isBlock

      public boolean isBlock()
      Returns:
      true if this material represents a block (not a fluid)
    • isEmpty

      public boolean isEmpty()
      Returns:
      true if this material represents empty (clears both block and fluid)
    • getBlockId

      public int getBlockId()
      Returns:
      the block type ID, or EMPTY_ID if this is a fluid material
    • getFluidId

      public int getFluidId()
      Returns:
      the fluid ID, or EMPTY_ID if this is a block material
    • getFluidLevel

      public byte getFluidLevel()
      Returns:
      the fluid level, or 0 if this is a block material
    • getRotation

      public int getRotation()
      Returns:
      the rotation tuple index for this material
    • hasRotation

      public boolean hasRotation()
      Returns:
      true if this material has a non-default rotation
    • getSupport

      public int getSupport()
    • getFiller

      public int getFiller()
    • getHolder

      @Nullable public Holder<ChunkStore> getHolder()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • fromPattern

      @Nonnull public static Material fromPattern(@Nonnull BlockPattern pattern, @Nonnull Random random)
      Gets the next material from a BlockPattern.

      This checks if the pattern's block type corresponds to a fluid item and returns the appropriate Material. Rotation information from the pattern is preserved for blocks.

      Parameters:
      pattern - the block pattern to get material from
      random - the random instance for weighted selection
      Returns:
      the next material from the pattern