Class TextureUtil

java.lang.Object
com.fastasyncworldedit.core.util.TextureUtil
All Implemented Interfaces:
TextureHolder
Direct Known Subclasses:
CleanTextureUtil, DelegateTextureUtil, FilteredTextureUtil

public class TextureUtil extends Object implements TextureHolder
  • Field Details

    • blockColors

      protected int[] blockColors
    • blockDistance

      protected long[] blockDistance
    • distances

      protected long[] distances
    • validColors

      protected int[] validColors
    • validBlockIds

      protected int[] validBlockIds
    • validLayerColors

      protected int[] validLayerColors
    • validLayerBlocks

      protected int[][] validLayerBlocks
    • validMixBiomeColors

      protected int[] validMixBiomeColors
    • validMixBiomeIds

      protected long[] validMixBiomeIds
    • validBiomes

      protected TextureUtil.BiomeColor[] validBiomes
      https://github.com/erich666/Mineways/blob/master/Win/biomes.cpp
  • Constructor Details

  • Method Details

    • fromClipboard

      public static TextureUtil fromClipboard(Clipboard clipboard) throws FileNotFoundException
      Throws:
      FileNotFoundException
    • fromBlocks

      public static TextureUtil fromBlocks(Set<BlockType> blocks) throws FileNotFoundException
      Throws:
      FileNotFoundException
    • fromMask

      public static TextureUtil fromMask(Mask mask) throws FileNotFoundException
      Throws:
      FileNotFoundException
    • hueDistance

      protected static int hueDistance(int red1, int green1, int blue1, int red2, int green2, int blue2)
    • colorDistance

      protected static long colorDistance(int c1, int c2)
    • multiplyColor

      public static int multiplyColor(int c1, int c2)
      Combine two colors by multipling
      Parameters:
      c1 - color 1
      c2 - color 2
      Returns:
      new color
    • averageColor

      public static int averageColor(int c1, int c2)
      Combine two colors by averaging
      Parameters:
      c1 - color 1
      c2 - color 2
      Returns:
      new color
    • averageColor

      public static int averageColor(int... colors)
      Combine multiple colors by multipling
      Parameters:
      colors - colors
      Returns:
      new color
    • combineTransparency

      public static int combineTransparency(int top, int bottom)
      Assumes the top layer is a transparent color and the bottom is opaque
    • getTextureUtil

      public TextureUtil getTextureUtil()
      Specified by:
      getTextureUtil in interface TextureHolder
    • getNearestBlock

      public BlockType getNearestBlock(int color)
      Get the block most closely matching a color based on the block's average color
      Parameters:
      color - color to match
      Returns:
      matching block
    • getNextNearestBlock

      public BlockType getNextNearestBlock(int color)
      Get the block most closely matching a color, without matching the color, based on the block's average color
      Parameters:
      color - color to match
      Returns:
      matching block
    • getNearestLayer

      public BlockType[] getNearestLayer(int color)
      Returns the block combined ids as an array.
    • getLighterBlock

      public BlockType getLighterBlock(BlockType block)
      Get the next lightest block
      Parameters:
      block - input block
      Returns:
      next lightest block
    • getDarkerBlock

      public BlockType getDarkerBlock(BlockType block)
      Get the next darkest block
      Parameters:
      block - input block
      Returns:
      next darkest block
    • getLighterBlock

      public BlockType getLighterBlock(int color)
      Get the next lightest block
      Parameters:
      color - input color
      Returns:
      next lightest block
    • getDarkerBlock

      public BlockType getDarkerBlock(int color)
      Get the next darkest block
      Parameters:
      color - input color
      Returns:
      next darkest block
    • getColor

      public int getColor(BlockType block)
      Get the integer representation of a block's RGBA color.
      Parameters:
      block - input block
      Returns:
      integer RGBA color
    • getColor

      public int getColor(BiomeType biome)
      Get the integer representation of a biomes's RGBA color when applied to grass.
      Parameters:
      biome - input biome
      Returns:
      integer RGBA color
    • getBiome

      public TextureUtil.BiomeColor getBiome(int biome)
      Get the TextureUtil.BiomeColor entry from a biome's ID
      Parameters:
      biome - biome id
      Returns:
      the TextureUtil.BiomeColor entry
    • getIsBlockCloserThanBiome

      protected boolean getIsBlockCloserThanBiome(char[] blockAndBiomeIdOutput, int color, int biomePriority)
    • getBiomeMix

      protected int getBiomeMix(int[] biomeIdsOutput, int color)
    • getNearestBiome

      public TextureUtil.BiomeColor getNearestBiome(int color)
      Get the biome most closely matching a color based on the block's average color
      Parameters:
      color - color to match
      Returns:
      matching block
    • getFolder

      protected File getFolder()
    • loadModTextures

      public void loadModTextures() throws IOException
      Throws:
      IOException
    • calculateLayerArrays

      protected void calculateLayerArrays()
    • getNearestBlock

      protected BlockType getNearestBlock(BlockType block, boolean darker)
    • getNearestBlock

      protected BlockType getNearestBlock(int color, boolean darker)
    • hasAlpha

      protected boolean hasAlpha(int color)
    • getValidBlockIds

      public int[] getValidBlockIds()