geforkt von Mirrors/FastAsyncWorldEdit
Cleaned a class
Dieser Commit ist enthalten in:
Ursprung
699783ba72
Commit
7ae8d567f3
@ -29,6 +29,7 @@ import javax.imageio.ImageIO;
|
|||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -47,7 +48,9 @@ public class TextureUtil implements TextureHolder{
|
|||||||
}
|
}
|
||||||
HashSet<BlockType> blocks = new HashSet<>();
|
HashSet<BlockType> blocks = new HashSet<>();
|
||||||
for (int typeId = 0; typeId < ids.length; typeId++) {
|
for (int typeId = 0; typeId < ids.length; typeId++) {
|
||||||
if (ids[typeId]) blocks.add(BlockTypes.get(typeId));
|
if (ids[typeId]) {
|
||||||
|
blocks.add(BlockTypes.get(typeId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return fromBlocks(blocks);
|
return fromBlocks(blocks);
|
||||||
}
|
}
|
||||||
@ -65,13 +68,14 @@ public class TextureUtil implements TextureHolder{
|
|||||||
for (int typeId : tu.getValidBlockIds()) {
|
for (int typeId : tu.getValidBlockIds()) {
|
||||||
BlockType block = BlockTypes.get(typeId);
|
BlockType block = BlockTypes.get(typeId);
|
||||||
pattern.setBlock(block.getDefaultState());
|
pattern.setBlock(block.getDefaultState());
|
||||||
if (mask.test(BlockVector3.ZERO)) blocks.add(block);
|
if (mask.test(BlockVector3.ZERO)) {
|
||||||
|
blocks.add(block);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return fromBlocks(blocks);
|
return fromBlocks(blocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public TextureUtil getTextureUtil() {
|
||||||
public TextureUtil getTextureUtil() {
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,16 +107,19 @@ public class TextureUtil implements TextureHolder{
|
|||||||
private BiomeColor[] biomes = new BiomeColor[] {
|
private BiomeColor[] biomes = new BiomeColor[] {
|
||||||
// ID Name Temperature, rainfall, grass, foliage colors
|
// ID Name Temperature, rainfall, grass, foliage colors
|
||||||
// - note: the colors here are just placeholders, they are computed in the program
|
// - note: the colors here are just placeholders, they are computed in the program
|
||||||
new BiomeColor(0, "Ocean", 0.5f, 0.5f, 0x92BD59, 0x77AB2F), // default values of temp and rain
|
new BiomeColor(0, "Ocean", 0.5f, 0.5f, 0x92BD59, 0x77AB2F),
|
||||||
|
// default values of temp and rain
|
||||||
new BiomeColor(1, "Plains", 0.8f, 0.4f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(1, "Plains", 0.8f, 0.4f, 0x92BD59, 0x77AB2F),
|
||||||
new BiomeColor(2, "Desert", 2.0f, 0.0f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(2, "Desert", 2.0f, 0.0f, 0x92BD59, 0x77AB2F),
|
||||||
new BiomeColor(3, "Extreme Hills", 0.2f, 0.3f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(3, "Extreme Hills", 0.2f, 0.3f, 0x92BD59, 0x77AB2F),
|
||||||
new BiomeColor(4, "Forest", 0.7f, 0.8f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(4, "Forest", 0.7f, 0.8f, 0x92BD59, 0x77AB2F),
|
||||||
new BiomeColor(5, "Taiga", 0.25f, 0.8f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(5, "Taiga", 0.25f, 0.8f, 0x92BD59, 0x77AB2F),
|
||||||
new BiomeColor(6, "Swampland", 0.8f, 0.9f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(6, "Swampland", 0.8f, 0.9f, 0x92BD59, 0x77AB2F),
|
||||||
new BiomeColor(7, "River", 0.5f, 0.5f, 0x92BD59, 0x77AB2F), // default values of temp and rain
|
new BiomeColor(7, "River", 0.5f, 0.5f, 0x92BD59, 0x77AB2F),
|
||||||
|
// default values of temp and rain
|
||||||
new BiomeColor(8, "Nether", 2.0f, 0.0f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(8, "Nether", 2.0f, 0.0f, 0x92BD59, 0x77AB2F),
|
||||||
new BiomeColor(9, "End", 0.5f, 0.5f, 0x92BD59, 0x77AB2F), // default values of temp and rain
|
new BiomeColor(9, "End", 0.5f, 0.5f, 0x92BD59, 0x77AB2F),
|
||||||
|
// default values of temp and rain
|
||||||
new BiomeColor(10, "Frozen Ocean", 0.0f, 0.5f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(10, "Frozen Ocean", 0.0f, 0.5f, 0x92BD59, 0x77AB2F),
|
||||||
new BiomeColor(11, "Frozen River", 0.0f, 0.5f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(11, "Frozen River", 0.0f, 0.5f, 0x92BD59, 0x77AB2F),
|
||||||
new BiomeColor(12, "Ice Plains", 0.0f, 0.5f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(12, "Ice Plains", 0.0f, 0.5f, 0x92BD59, 0x77AB2F),
|
||||||
@ -230,7 +237,8 @@ public class TextureUtil implements TextureHolder{
|
|||||||
new BiomeColor(124, "Unknown Biome", 0.8f, 0.4f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(124, "Unknown Biome", 0.8f, 0.4f, 0x92BD59, 0x77AB2F),
|
||||||
new BiomeColor(125, "Unknown Biome", 0.8f, 0.4f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(125, "Unknown Biome", 0.8f, 0.4f, 0x92BD59, 0x77AB2F),
|
||||||
new BiomeColor(126, "Unknown Biome", 0.8f, 0.4f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(126, "Unknown Biome", 0.8f, 0.4f, 0x92BD59, 0x77AB2F),
|
||||||
new BiomeColor(127, "The Void", 0.5f, 0.5f, 0x92BD59, 0x77AB2F), // default values of temp and rain; also, no height differences
|
new BiomeColor(127, "The Void", 0.5f, 0.5f, 0x92BD59, 0x77AB2F),
|
||||||
|
// default values of temp and rain; also, no height differences
|
||||||
new BiomeColor(128, "Unknown Biome", 0.8f, 0.4f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(128, "Unknown Biome", 0.8f, 0.4f, 0x92BD59, 0x77AB2F),
|
||||||
new BiomeColor(129, "Sunflower Plains", 0.8f, 0.4f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(129, "Sunflower Plains", 0.8f, 0.4f, 0x92BD59, 0x77AB2F),
|
||||||
new BiomeColor(130, "Desert M", 2.0f, 0.0f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(130, "Desert M", 2.0f, 0.0f, 0x92BD59, 0x77AB2F),
|
||||||
@ -263,7 +271,8 @@ public class TextureUtil implements TextureHolder{
|
|||||||
new BiomeColor(157, "Roofed Forest M", 0.7f, 0.8f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(157, "Roofed Forest M", 0.7f, 0.8f, 0x92BD59, 0x77AB2F),
|
||||||
new BiomeColor(158, "Cold Taiga M", -0.5f, 0.4f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(158, "Cold Taiga M", -0.5f, 0.4f, 0x92BD59, 0x77AB2F),
|
||||||
new BiomeColor(159, "Unknown Biome", 0.8f, 0.4f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(159, "Unknown Biome", 0.8f, 0.4f, 0x92BD59, 0x77AB2F),
|
||||||
new BiomeColor(160, "Mega Spruce Taiga", 0.25f, 0.8f, 0x92BD59, 0x77AB2F), // special exception, temperature not 0.3
|
new BiomeColor(160, "Mega Spruce Taiga", 0.25f, 0.8f, 0x92BD59, 0x77AB2F),
|
||||||
|
// special exception, temperature not 0.3
|
||||||
new BiomeColor(161, "Mega Spruce Taiga Hills", 0.25f, 0.8f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(161, "Mega Spruce Taiga Hills", 0.25f, 0.8f, 0x92BD59, 0x77AB2F),
|
||||||
new BiomeColor(162, "Extreme Hills+ M", 0.2f, 0.3f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(162, "Extreme Hills+ M", 0.2f, 0.3f, 0x92BD59, 0x77AB2F),
|
||||||
new BiomeColor(163, "Savanna M", 1.1f, 0.0f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(163, "Savanna M", 1.1f, 0.0f, 0x92BD59, 0x77AB2F),
|
||||||
@ -358,8 +367,7 @@ public class TextureUtil implements TextureHolder{
|
|||||||
new BiomeColor(252, "Unknown Biome", 0.8f, 0.4f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(252, "Unknown Biome", 0.8f, 0.4f, 0x92BD59, 0x77AB2F),
|
||||||
new BiomeColor(253, "Unknown Biome", 0.8f, 0.4f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(253, "Unknown Biome", 0.8f, 0.4f, 0x92BD59, 0x77AB2F),
|
||||||
new BiomeColor(254, "Unknown Biome", 0.8f, 0.4f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(254, "Unknown Biome", 0.8f, 0.4f, 0x92BD59, 0x77AB2F),
|
||||||
new BiomeColor(255, "Unknown Biome", 0.8f, 0.4f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(255, "Unknown Biome", 0.8f, 0.4f, 0x92BD59, 0x77AB2F),};
|
||||||
};
|
|
||||||
|
|
||||||
public TextureUtil() throws FileNotFoundException {
|
public TextureUtil() throws FileNotFoundException {
|
||||||
this(MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.TEXTURES));
|
this(MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.TEXTURES));
|
||||||
@ -368,7 +376,8 @@ public class TextureUtil implements TextureHolder{
|
|||||||
public TextureUtil(File folder) throws FileNotFoundException {
|
public TextureUtil(File folder) throws FileNotFoundException {
|
||||||
this.folder = folder;
|
this.folder = folder;
|
||||||
if (!folder.exists()) {
|
if (!folder.exists()) {
|
||||||
throw new FileNotFoundException("Please create a `FastAsyncWorldEdit/textures` folder with `.minecraft/versions` jar or mods in it.");
|
throw new FileNotFoundException(
|
||||||
|
"Please create a `FastAsyncWorldEdit/textures` folder with `.minecraft/versions` jar or mods in it.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -389,13 +398,17 @@ public class TextureUtil implements TextureHolder{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (min == Long.MAX_VALUE) return null;
|
if (min == Long.MAX_VALUE) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return BlockTypes.get(closest);
|
return BlockTypes.get(closest);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockType getNearestBlock(BlockType block) {
|
public BlockType getNearestBlock(BlockType block) {
|
||||||
int color = getColor(block);
|
int color = getColor(block);
|
||||||
if (color == 0) return null;
|
if (color == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return getNextNearestBlock(color);
|
return getNextNearestBlock(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,7 +429,9 @@ public class TextureUtil implements TextureHolder{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (min == Long.MAX_VALUE) return null;
|
if (min == Long.MAX_VALUE) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return BlockTypes.get(closest);
|
return BlockTypes.get(closest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -466,13 +481,15 @@ public class TextureUtil implements TextureHolder{
|
|||||||
return biomes[biome];
|
return biomes[biome];
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getIsBlockCloserThanBiome(int[] blockAndBiomeIdOutput, int color, int biomePriority) {
|
public boolean getIsBlockCloserThanBiome(int[] blockAndBiomeIdOutput, int color,
|
||||||
|
int biomePriority) {
|
||||||
BlockType block = getNearestBlock(color);
|
BlockType block = getNearestBlock(color);
|
||||||
TextureUtil.BiomeColor biome = getNearestBiome(color);
|
TextureUtil.BiomeColor biome = getNearestBiome(color);
|
||||||
int blockColor = getColor(block);
|
int blockColor = getColor(block);
|
||||||
blockAndBiomeIdOutput[0] = block.getInternalId();
|
blockAndBiomeIdOutput[0] = block.getInternalId();
|
||||||
blockAndBiomeIdOutput[1] = biome.id;
|
blockAndBiomeIdOutput[1] = biome.id;
|
||||||
if (colorDistance(biome.grassCombined, color) - biomePriority > colorDistance(blockColor, color)) {
|
if (colorDistance(biome.grassCombined, color) - biomePriority > colorDistance(blockColor,
|
||||||
|
color)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -513,8 +530,7 @@ public class TextureUtil implements TextureHolder{
|
|||||||
int red = (color >> 16) & 0xFF;
|
int red = (color >> 16) & 0xFF;
|
||||||
int green = (color >> 8) & 0xFF;
|
int green = (color >> 8) & 0xFF;
|
||||||
int blue = (color >> 0) & 0xFF;
|
int blue = (color >> 0) & 0xFF;
|
||||||
for (int i = 0; i < validBiomes.length; i++) {
|
for (BiomeColor biome : validBiomes) {
|
||||||
BiomeColor biome = validBiomes[i];
|
|
||||||
long distance = colorDistance(red, green, blue, biome.grassCombined);
|
long distance = colorDistance(red, green, blue, biome.grassCombined);
|
||||||
if (distance < min) {
|
if (distance < min) {
|
||||||
min = distance;
|
min = distance;
|
||||||
@ -560,22 +576,20 @@ public class TextureUtil implements TextureHolder{
|
|||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
if (folder.exists()) {
|
if (folder.exists()) {
|
||||||
// Get all the jar files
|
// Get all the jar files
|
||||||
File[] files = folder.listFiles(new FilenameFilter() {
|
File[] files = folder.listFiles((dir, name) -> name.endsWith(".jar"));
|
||||||
@Override
|
|
||||||
public boolean accept(File dir, String name) {
|
|
||||||
return name.endsWith(".jar");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
for (BlockType blockType : BlockTypes.values) {
|
for (BlockType blockType : BlockTypes.values) {
|
||||||
BlockMaterial material = blockType.getMaterial();
|
BlockMaterial material = blockType.getMaterial();
|
||||||
if (!material.isSolid() || !material.isFullCube()) continue;
|
if (!material.isSolid() || !material.isFullCube()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
int color = material.getMapColor();
|
int color = material.getMapColor();
|
||||||
if (color != 0) {
|
if (color != 0) {
|
||||||
colorMap.put((int) blockType.getInternalId(), (Integer) color);
|
colorMap.put(blockType.getInternalId(), (Integer) color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (files.length == 0) {
|
if (files.length == 0) {
|
||||||
Fawe.debug("Please create a `FastAsyncWorldEdit/textures` folder with `.minecraft/versions/1.13.jar` jar or mods in it. If the file exists, please make sure the server has read access to the directory");
|
Fawe.debug(
|
||||||
|
"Please create a `FastAsyncWorldEdit/textures` folder with `.minecraft/versions/1.13.jar` jar or mods in it. If the file exists, please make sure the server has read access to the directory");
|
||||||
} else {
|
} else {
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
ZipFile zipFile = new ZipFile(file);
|
ZipFile zipFile = new ZipFile(file);
|
||||||
@ -591,7 +605,8 @@ public class TextureUtil implements TextureHolder{
|
|||||||
String name = entry.getName();
|
String name = entry.getName();
|
||||||
Path path = Paths.get(name);
|
Path path = Paths.get(name);
|
||||||
if (path.startsWith("assets" + File.separator)) {
|
if (path.startsWith("assets" + File.separator)) {
|
||||||
String[] split = path.toString().split(Pattern.quote(File.separator));
|
String[] split =
|
||||||
|
path.toString().split(Pattern.quote(File.separator));
|
||||||
if (split.length > 1) {
|
if (split.length > 1) {
|
||||||
String modId = split[1];
|
String modId = split[1];
|
||||||
mods.add(modId);
|
mods.add(modId);
|
||||||
@ -607,7 +622,9 @@ public class TextureUtil implements TextureHolder{
|
|||||||
}.getType();
|
}.getType();
|
||||||
|
|
||||||
for (BlockType blockType : BlockTypes.values) {
|
for (BlockType blockType : BlockTypes.values) {
|
||||||
if (!blockType.getMaterial().isFullCube()) continue;
|
if (!blockType.getMaterial().isFullCube()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
int combined = blockType.getInternalId();
|
int combined = blockType.getInternalId();
|
||||||
String id = blockType.getId();
|
String id = blockType.getId();
|
||||||
String[] split = id.split(":", 2);
|
String[] split = id.split(":", 2);
|
||||||
@ -625,25 +642,34 @@ public class TextureUtil implements TextureHolder{
|
|||||||
|
|
||||||
String textureFileName;
|
String textureFileName;
|
||||||
try (InputStream is = zipFile.getInputStream(entry)) {
|
try (InputStream is = zipFile.getInputStream(entry)) {
|
||||||
JsonReader reader = new JsonReader(new InputStreamReader(is, "UTF-8"));
|
JsonReader reader = new JsonReader(
|
||||||
|
new InputStreamReader(is, StandardCharsets.UTF_8));
|
||||||
Map<String, Object> root = gson.fromJson(reader, typeToken);
|
Map<String, Object> root = gson.fromJson(reader, typeToken);
|
||||||
Map<String, Object> textures = (Map) root.get("textures");
|
Map<String, Object> textures = (Map) root.get("textures");
|
||||||
|
|
||||||
if (textures == null) continue;
|
if (textures == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
Set<String> models = new HashSet<>();
|
Set<String> models = new HashSet<>();
|
||||||
// Get models
|
// Get models
|
||||||
for (Map.Entry<String, Object> stringObjectEntry : textures.entrySet()) {
|
for (Map.Entry<String, Object> stringObjectEntry : textures
|
||||||
|
.entrySet()) {
|
||||||
Object value = stringObjectEntry.getValue();
|
Object value = stringObjectEntry.getValue();
|
||||||
if (value instanceof String) {
|
if (value instanceof String) {
|
||||||
models.add((String) value);
|
models.add((String) value);
|
||||||
} else if (value instanceof Map) {
|
} else if (value instanceof Map) {
|
||||||
value = ((Map) value).get("model");
|
value = ((Map) value).get("model");
|
||||||
if (value != null) models.add((String) value);
|
if (value != null) {
|
||||||
|
models.add((String) value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (models.size() != 1) continue;
|
}
|
||||||
|
if (models.size() != 1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
textureFileName = String.format(texturesDir, nameSpace, models.iterator().next());
|
textureFileName =
|
||||||
|
String.format(texturesDir, nameSpace, models.iterator().next());
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferedImage image = readImage(zipFile, textureFileName);
|
BufferedImage image = readImage(zipFile, textureFileName);
|
||||||
@ -653,14 +679,15 @@ public class TextureUtil implements TextureHolder{
|
|||||||
}
|
}
|
||||||
int color = ImageUtil.getColor(image);
|
int color = ImageUtil.getColor(image);
|
||||||
long distance = getDistance(image, color);
|
long distance = getDistance(image, color);
|
||||||
distanceMap.put((int) combined, (Long) distance);
|
distanceMap.put(combined, (Long) distance);
|
||||||
colorMap.put((int) combined, (Integer) color);
|
colorMap.put(combined, (Integer) color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Integer grass = null;
|
Integer grass = null;
|
||||||
{
|
{
|
||||||
String grassFileName = String.format(texturesDir, "minecraft", "grass_block_top");
|
String grassFileName =
|
||||||
|
String.format(texturesDir, "minecraft", "grass_block_top");
|
||||||
BufferedImage image = readImage(zipFile, grassFileName);
|
BufferedImage image = readImage(zipFile, grassFileName);
|
||||||
if (image != null) {
|
if (image != null) {
|
||||||
grass = ImageUtil.getColor(image);
|
grass = ImageUtil.getColor(image);
|
||||||
@ -668,15 +695,17 @@ public class TextureUtil implements TextureHolder{
|
|||||||
}
|
}
|
||||||
if (grass != null) {
|
if (grass != null) {
|
||||||
// assets\minecraft\textures\colormap
|
// assets\minecraft\textures\colormap
|
||||||
ZipEntry grassEntry = getEntry(zipFile, "assets/minecraft/textures/colormap/grass_block.png");
|
ZipEntry grassEntry = getEntry(zipFile,
|
||||||
|
"assets/minecraft/textures/colormap/grass_block.png");
|
||||||
if (grassEntry != null) {
|
if (grassEntry != null) {
|
||||||
try (InputStream is = zipFile.getInputStream(grassEntry)) {
|
try (InputStream is = zipFile.getInputStream(grassEntry)) {
|
||||||
BufferedImage image = ImageIO.read(is);
|
BufferedImage image = ImageIO.read(is);
|
||||||
// Update biome colors
|
// Update biome colors
|
||||||
for (int i = 0; i < biomes.length; i++) {
|
for (BiomeColor biome : biomes) {
|
||||||
BiomeColor biome = biomes[i];
|
float adjTemp =
|
||||||
float adjTemp = MathMan.clamp(biome.temperature, 0.0f, 1.0f);
|
MathMan.clamp(biome.temperature, 0.0f, 1.0f);
|
||||||
float adjRainfall = MathMan.clamp(biome.rainfall, 0.0f, 1.0f) * adjTemp;
|
float adjRainfall =
|
||||||
|
MathMan.clamp(biome.rainfall, 0.0f, 1.0f) * adjTemp;
|
||||||
int x = (int) (255 - adjTemp * 255);
|
int x = (int) (255 - adjTemp * 255);
|
||||||
int z = (int) (255 - adjRainfall * 255);
|
int z = (int) (255 - adjRainfall * 255);
|
||||||
biome.grass = image.getRGB(x, z);
|
biome.grass = image.getRGB(x, z);
|
||||||
@ -686,8 +715,10 @@ public class TextureUtil implements TextureHolder{
|
|||||||
biomes[6].grass = 0;
|
biomes[6].grass = 0;
|
||||||
biomes[134].grass = 0;
|
biomes[134].grass = 0;
|
||||||
// roofed forest: averaged w/ 0x28340A
|
// roofed forest: averaged w/ 0x28340A
|
||||||
biomes[29].grass = multiplyColor(biomes[29].grass, 0x28340A + (255 << 24));
|
biomes[29].grass =
|
||||||
biomes[157].grass = multiplyColor(biomes[157].grass, 0x28340A + (255 << 24));
|
multiplyColor(biomes[29].grass, 0x28340A + (255 << 24));
|
||||||
|
biomes[157].grass =
|
||||||
|
multiplyColor(biomes[157].grass, 0x28340A + (255 << 24));
|
||||||
// mesa : 0x90814D
|
// mesa : 0x90814D
|
||||||
biomes[37].grass = 0x90814D + (255 << 24);
|
biomes[37].grass = 0x90814D + (255 << 24);
|
||||||
biomes[38].grass = 0x90814D + (255 << 24);
|
biomes[38].grass = 0x90814D + (255 << 24);
|
||||||
@ -696,10 +727,10 @@ public class TextureUtil implements TextureHolder{
|
|||||||
biomes[166].grass = 0x90814D + (255 << 24);
|
biomes[166].grass = 0x90814D + (255 << 24);
|
||||||
biomes[167].grass = 0x90814D + (255 << 24);
|
biomes[167].grass = 0x90814D + (255 << 24);
|
||||||
List<BiomeColor> valid = new ArrayList<>();
|
List<BiomeColor> valid = new ArrayList<>();
|
||||||
for (int i = 0; i < biomes.length; i++) {
|
for (BiomeColor biome : biomes) {
|
||||||
BiomeColor biome = biomes[i];
|
|
||||||
// biome.grass = multiplyColor(biome.grass, grass);
|
// biome.grass = multiplyColor(biome.grass, grass);
|
||||||
if (biome.grass != 0 && !biome.name.equalsIgnoreCase("Unknown Biome")) {
|
if (biome.grass != 0 && !biome.name
|
||||||
|
.equalsIgnoreCase("Unknown Biome")) {
|
||||||
valid.add(biome);
|
valid.add(biome);
|
||||||
}
|
}
|
||||||
biome.grassCombined = multiplyColor(grass, biome.grass);
|
biome.grassCombined = multiplyColor(grass, biome.grass);
|
||||||
@ -726,19 +757,23 @@ public class TextureUtil implements TextureHolder{
|
|||||||
BiomeColor c1 = uniqueColors.get(i);
|
BiomeColor c1 = uniqueColors.get(i);
|
||||||
BiomeColor c2 = uniqueColors.get(j);
|
BiomeColor c2 = uniqueColors.get(j);
|
||||||
BiomeColor c3 = uniqueColors.get(k);
|
BiomeColor c3 = uniqueColors.get(k);
|
||||||
int average = averageColor(c1.grass, c2.grass, c3.grass);
|
int average =
|
||||||
|
averageColor(c1.grass, c2.grass, c3.grass);
|
||||||
if (uniqueBiomesColors.add(average)) {
|
if (uniqueBiomesColors.add(average)) {
|
||||||
count++;
|
count++;
|
||||||
layerColors.add((long) average);
|
layerColors.add((long) average);
|
||||||
layerIds.add((long) ((c1.id) + (c2.id << 8) + (c3.id << 16)));
|
layerIds.add(
|
||||||
|
(long) ((c1.id) + (c2.id << 8) + (c3.id
|
||||||
|
<< 16)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
validMixBiomeColors = new int[layerColors.size()];
|
validMixBiomeColors = new int[layerColors.size()];
|
||||||
for (int i = 0; i < layerColors.size(); i++)
|
for (int i = 0; i < layerColors.size(); i++) {
|
||||||
validMixBiomeColors[i] = (int) layerColors.getLong(i);
|
validMixBiomeColors[i] = (int) layerColors.getLong(i);
|
||||||
|
}
|
||||||
validMixBiomeIds = layerIds.toLongArray();
|
validMixBiomeIds = layerIds.toLongArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -902,12 +937,14 @@ public class TextureUtil implements TextureHolder{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (min == Long.MAX_VALUE) return null;
|
if (min == Long.MAX_VALUE) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return BlockTypes.get(closest);
|
return BlockTypes.get(closest);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getFileName(String path) {
|
private String getFileName(String path) {
|
||||||
String[] split = path.toString().split("[/|\\\\]");
|
String[] split = path.split("[/|\\\\]");
|
||||||
String name = split[split.length - 1];
|
String name = split[split.length - 1];
|
||||||
int dot = name.indexOf('.');
|
int dot = name.indexOf('.');
|
||||||
if (dot != -1) {
|
if (dot != -1) {
|
||||||
@ -936,10 +973,12 @@ public class TextureUtil implements TextureHolder{
|
|||||||
int g = green1 - green2;
|
int g = green1 - green2;
|
||||||
int b = blue1 - blue2;
|
int b = blue1 - blue2;
|
||||||
int hd = hueDistance(red1, green1, blue1, red2, green2, 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 * 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) {
|
protected static int hueDistance(int red1, int green1, int blue1, int red2, int green2,
|
||||||
|
int blue2) {
|
||||||
int total1 = (red1 + green1 + blue1);
|
int total1 = (red1 + green1 + blue1);
|
||||||
int total2 = (red2 + green2 + blue2);
|
int total2 = (red2 + green2 + blue2);
|
||||||
if (total1 == 0 || total2 == 0) {
|
if (total1 == 0 || total2 == 0) {
|
||||||
@ -980,7 +1019,8 @@ public class TextureUtil implements TextureHolder{
|
|||||||
public int grassCombined;
|
public int grassCombined;
|
||||||
public int foliage;
|
public int foliage;
|
||||||
|
|
||||||
public BiomeColor(int id, String name, float temperature, float rainfall, int grass, int foliage) {
|
public BiomeColor(int id, String name, float temperature, float rainfall, int grass,
|
||||||
|
int foliage) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.temperature = temperature;
|
this.temperature = temperature;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren