Class BlockUtil

java.lang.Object
com.ardorcraft.util.BlockUtil

public final class BlockUtil extends Object
Main class to use for setting up properties for all block types.
  • Constructor Details

    • BlockUtil

      public BlockUtil(int textureWidth, int textureHeight, int subTextureSize)
  • Method Details

    • setIsLocalLightSource

      public void setIsLocalLightSource(int blockId, boolean value)
      Set if this block should emit light
      Parameters:
      blockId - the identifier of the block
      value - the value of the block
    • setBlockMapping

      public void setBlockMapping(int blockId, int x, int y)
      Setup texture tiles to use for this block
      Parameters:
      blockId - the identifier of the block
      x - the x value
      y - the y value
    • setBlockMapping

      public void setBlockMapping(int blockId, int xTop, int yTop, int xSide, int ySide, int xBottom, int yBottom)
      Setup texture tiles to use for this block
      Parameters:
      blockId - the identifier of the block
      xTop - the x top value
      yTop - the y top value
      xSide - the x side value
      ySide - the y side value
      xBottom - the x bottom value
      yBottom - the y bottom value
    • setBlockMapping

      public void setBlockMapping(int blockId, int xTop, int yTop, int xFront, int yFront, int xBack, int yBack, int xLeft, int yLeft, int xRight, int yRight, int xBottom, int yBottom)
      Setup texture tiles to use for this block
      Parameters:
      blockId - the identifier of the block
      xTop - the x top value
      yTop - the y top value
      xFront - the x front value
      yFront - the y front value
      xBack - the x back value
      yBack - the y back value
      xLeft - the x left value
      yLeft - the y left value
      xRight - the x right value
      yRight - the y right value
      xBottom - the x bottom value
      yBottom - the y bottom value
    • setBlockMapping

      public void setBlockMapping(int blockId, BlockSide side, int x, int y)
      Setup texture tiles to use for this block
      Parameters:
      blockId - the identifier of the block
      side - the side of the block
      x - the x value
      y - the y value
    • setBlockType

      public void setBlockType(int blockId, BlockType type)
      Set if this block is see-through or not (if not, then hidden surface removal can be done)
      Parameters:
      blockId - the identifier of the block
      type - the type of the block
    • getBlockType

      public BlockType getBlockType(int blockId)
    • isLocalLight

      public boolean isLocalLight(int block)
    • getBlockTextureCoord

      public ReadOnlyVector2 getBlockTextureCoord(int blockId, BlockSide blockSide)
      Get start coordinates for a specific side of a block.
      Parameters:
      blockId - the identifier of the block
      blockSide - the side of the block
      Returns:
      the start coordinates for a specific side of a block
    • getOffsetWidth

      public float getOffsetWidth()
      Get offset to fix the artifact issue of texture bleeding.
      Returns:
      the offset width to fix the artifact issue of texture bleeding
    • getOffsetHeight

      public float getOffsetHeight()
      Get offset to fix the artifact issue of texture bleeding.
      Returns:
      the offset height to fix the artifact issue of texture bleeding
    • getTileWidth

      public float getTileWidth()
      Get the width of each tile in the texture atlas.
      Returns:
      the width of each tile in the texture atlas
    • getTileHeight

      public float getTileHeight()
      Get the height of each tile in the texture atlas.
      Returns:
      the height of each tile in the texture atlas
    • setGeometryProducer

      public void setGeometryProducer(int blockId, GeometryProducer handler)
      Set the geometry producer to use for this block id.
      Parameters:
      blockId - the identifier of the block
      handler - the geometry producer to use for this identifier of block
    • getGeometryProducer

      public GeometryProducer getGeometryProducer(int blockId)
    • setIsCollidable

      public void setIsCollidable(int blockId, boolean value)
      Set if the block should be collidable.
      Parameters:
      blockId - the identifier of the block
      value - true if the block should be collidable
    • getIsCollidable

      public boolean getIsCollidable(int blockId)
    • setIsPickable

      public void setIsPickable(int blockId, boolean value)
      Set if the block should be pickable.
      Parameters:
      blockId - the identifier of the block
      value - true if the block should be pickable
    • getIsPickable

      public boolean getIsPickable(int blockId)
    • setIsSemiTransparent

      public void setIsSemiTransparent(int blockId, boolean value)
      Set if the block is semi-transparent like water and should not generate sides when next to itself.
      Parameters:
      blockId - the identifier of the block
      value - true if the block is semi-transparent like water and should not generate sides when next to itself
    • getIsSemiTransparent

      public boolean getIsSemiTransparent(int blockId)