diff --git a/core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCAGenerator.java b/core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCAGenerator.java index adafc6dd..d94f21dd 100644 --- a/core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCAGenerator.java +++ b/core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCAGenerator.java @@ -275,18 +275,18 @@ public class HeightMapMCAGenerator extends MCAWriter implements Extent { BaseBlock block = textureUtil.getNearestBlock(color); TextureUtil.BiomeColor biome = textureUtil.getNearestBiome(color); int blockColor = textureUtil.getColor(block); - if (textureUtil.colorDistance(biome.grass, color) < textureUtil.colorDistance(blockColor, color)) { + if (textureUtil.colorDistance(biome.grass, color) <= textureUtil.colorDistance(blockColor, color)) { byte biomeByte = (byte) biome.id; biomes[index] = biomeByte; if (yBiome && x > 0 && x < widthIndex) { - setBiomeIfZero(index+ 1, biomeByte); - setBiomeIfZero(index- 1, biomeByte); - setBiomeIfZero(index+ getWidth(), biomeByte); - setBiomeIfZero(index+ getWidth() + 1, biomeByte); - setBiomeIfZero(index+ getWidth() - 1, biomeByte); - setBiomeIfZero(index- getWidth(), biomeByte); - setBiomeIfZero(index- getWidth() + 1, biomeByte); - setBiomeIfZero(index- getWidth() - 1, biomeByte); + setBiomeIfZero(index + 1, biomeByte); + setBiomeIfZero(index - 1, biomeByte); + setBiomeIfZero(index + getWidth(), biomeByte); + setBiomeIfZero(index + getWidth() + 1, biomeByte); + setBiomeIfZero(index + getWidth() - 1, biomeByte); + setBiomeIfZero(index - getWidth(), biomeByte); + setBiomeIfZero(index - getWidth() + 1, biomeByte); + setBiomeIfZero(index - getWidth() - 1, biomeByte); } } else { char combined = (char) block.getCombined(); diff --git a/core/src/main/java/com/boydti/fawe/util/CleanTextureUtil.java b/core/src/main/java/com/boydti/fawe/util/CleanTextureUtil.java index d9e44e88..9c5b5d69 100644 --- a/core/src/main/java/com/boydti/fawe/util/CleanTextureUtil.java +++ b/core/src/main/java/com/boydti/fawe/util/CleanTextureUtil.java @@ -11,6 +11,7 @@ public class CleanTextureUtil extends TextureUtil { long max = parent.distances[maxIndex]; int num = maxIndex - minIndex + 1; + this.validBiomes = parent.validBiomes; this.blockColors = parent.blockColors; this.blockDistance = parent.blockDistance; this.distances = Arrays.copyOfRange(parent.blockDistance, minIndex, maxIndex + 1); diff --git a/core/src/main/java/com/boydti/fawe/util/DelegateTextureUtil.java b/core/src/main/java/com/boydti/fawe/util/DelegateTextureUtil.java index cb1ed5eb..dc90ea90 100644 --- a/core/src/main/java/com/boydti/fawe/util/DelegateTextureUtil.java +++ b/core/src/main/java/com/boydti/fawe/util/DelegateTextureUtil.java @@ -9,6 +9,10 @@ import org.json.simple.parser.ParseException; public class DelegateTextureUtil extends TextureUtil { private final TextureUtil parent; + public static void main(String[] args) throws Throwable { + TextureUtil.main(args); + } + public DelegateTextureUtil(TextureUtil parent) { super(parent.getFolder()); this.parent = parent; @@ -39,6 +43,16 @@ public class DelegateTextureUtil extends TextureUtil { return parent.getColor(block); } + @Override + public BiomeColor getBiome(int biome) { + return parent.getBiome(biome); + } + + @Override + public BiomeColor getNearestBiome(int color) { + return parent.getNearestBiome(color); + } + @Override public File getFolder() { return parent.getFolder(); @@ -49,11 +63,21 @@ public class DelegateTextureUtil extends TextureUtil { return parent.combineTransparency(top, bottom); } + @Override + public void calculateLayerArrays() { + parent.calculateLayerArrays(); + } + @Override public void loadModTextures() throws IOException, ParseException { parent.loadModTextures(); } + @Override + public int multiply(int c1, int c2) { + return parent.multiply(c1, c2); + } + @Override public BaseBlock getNearestBlock(BaseBlock block, boolean darker) { return parent.getNearestBlock(block, darker); @@ -79,8 +103,17 @@ public class DelegateTextureUtil extends TextureUtil { return parent.colorDistance(red1, green1, blue1, c2); } + public static int hueDistance(int red1, int green1, int blue1, int red2, int green2, int blue2) { + return TextureUtil.hueDistance(red1, green1, blue1, red2, green2, blue2); + } + @Override public int getColor(BufferedImage image) { return parent.getColor(image); } + + @Override + public long getDistance(BufferedImage image, int c1) { + return parent.getDistance(image, c1); + } } diff --git a/core/src/main/java/com/boydti/fawe/util/FilteredTextureUtil.java b/core/src/main/java/com/boydti/fawe/util/FilteredTextureUtil.java index f9a293fa..fd89de8e 100644 --- a/core/src/main/java/com/boydti/fawe/util/FilteredTextureUtil.java +++ b/core/src/main/java/com/boydti/fawe/util/FilteredTextureUtil.java @@ -7,6 +7,7 @@ import java.util.Set; public class FilteredTextureUtil extends TextureUtil { public FilteredTextureUtil(TextureUtil parent, Set blocks) { super(parent.getFolder()); + this.validBiomes = parent.validBiomes; this.blockColors = parent.blockColors; this.blockDistance = parent.blockDistance; this.distances = parent.distances; diff --git a/core/src/main/java/com/boydti/fawe/util/TextureUtil.java b/core/src/main/java/com/boydti/fawe/util/TextureUtil.java index eaf2d437..581975f8 100644 --- a/core/src/main/java/com/boydti/fawe/util/TextureUtil.java +++ b/core/src/main/java/com/boydti/fawe/util/TextureUtil.java @@ -52,7 +52,7 @@ public class TextureUtil { /** * https://github.com/erich666/Mineways/blob/master/Win/biomes.cpp */ - private BiomeColor[] validBiomes; + protected BiomeColor[] validBiomes; private BiomeColor[] biomes = new BiomeColor[] { // ID Name Temperature, rainfall, grass, foliage colors // - note: the colors here are just placeholders, they are computed in the program @@ -823,7 +823,7 @@ public class TextureUtil { int g = green1 - green2; int b = blue1 - blue2; int hd = hueDistance(red1, green1, blue1, red2, green2, blue2); - return (((512 + rmean) * r * r) >> 8) + 4 * g * g + (((767 - rmean) * b * b) >> 8) + (hd); + return (((512 + rmean) * r * r) >> 8) + 4 * g * g + (((767 - rmean) * b * b) >> 8) + (hd * hd); } protected static int hueDistance(int red1, int green1, int blue1, int red2, int green2, int blue2) {