Merge branch '1.16.5' of gitlab.com:jeseibel/minecraft-lod-mod into

1.16.5

# Conflicts:
#	src/main/java/com/seibel/lod/wrappers/MinecraftWrapper.java
This commit is contained in:
James Seibel
2021-09-16 19:05:05 -05:00
8 changed files with 215 additions and 208 deletions
@@ -18,6 +18,8 @@
package com.seibel.lod.builders;
import java.awt.Color;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -33,13 +35,13 @@ import com.seibel.lod.wrappers.MinecraftWrapper;
import net.minecraft.block.*;
import net.minecraft.block.material.MaterialColor;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.DimensionType;
import net.minecraft.world.IWorld;
import net.minecraft.world.LightType;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.ChunkSection;
import net.minecraft.world.chunk.IChunk;
@@ -60,6 +62,7 @@ public class LodBuilder
public static final int CHUNK_DATA_WIDTH = LodUtil.CHUNK_WIDTH;
public static final int CHUNK_SECTION_HEIGHT = CHUNK_DATA_WIDTH;
public static final Heightmap.Type DEFAULT_HEIGHTMAP = Heightmap.Type.WORLD_SURFACE_WG;
public static final ConcurrentMap<Block, Integer> colorMap = new ConcurrentHashMap<>();
/**
* If no blocks are found in the area in determineBottomPointForArea return this
@@ -286,7 +289,7 @@ public class LodBuilder
yAbs = height - 1;
// We search light on above air block
color = generateLodColor(chunk, config, xRel, yAbs, zRel);
color = generateLodColor(chunk, config, xRel, yAbs, zRel, blockPos);
depth = determineBottomPointFrom(chunk, config, xRel, zRel, yAbs, blockPos);
blockPos.set(xAbs, yAbs + 1, zAbs);
light = getLightValue(chunk, blockPos);
@@ -420,7 +423,7 @@ public class LodBuilder
yAbs = height - 1;
// We search light on above air block
color = generateLodColor(chunk, config, xRel, yAbs, zRel);
color = generateLodColor(chunk, config, xRel, yAbs, zRel, blockPos);
depth = determineBottomPoint(chunk, config, xRel, zRel, blockPos);
blockPos.set(xAbs, yAbs + 1, zAbs);
@@ -508,7 +511,7 @@ public class LodBuilder
* Generate the color for the given chunk using biome water color, foliage
* color, and grass color.
*/
private int generateLodColor(IChunk chunk, LodBuilderConfig config, int xRel, int yAbs, int zRel)
private int generateLodColor(IChunk chunk, LodBuilderConfig config, int xRel, int yAbs, int zRel, BlockPos.Mutable blockPos)
{
ChunkSection[] chunkSections = chunk.getSections();
int colorInt = 0;
@@ -524,17 +527,16 @@ public class LodBuilder
int yRel = Math.floorMod(yAbs, CHUNK_SECTION_HEIGHT);
if (chunkSections[sectionIndex] != null)
{
BlockState blockState = chunkSections[sectionIndex].getBlockState(xRel, yRel, zRel);
// the bit shift is equivalent to dividing by 4
Biome biome = chunk.getBiomes().getNoiseBiome(xRel >> 2, yAbs >> 2, zRel >> 2);
colorInt = getColorForBlock(xRel, zRel, blockState, biome);
blockPos.set(chunk.getPos().getMinBlockX() + xRel, sectionIndex * CHUNK_DATA_WIDTH + yRel, chunk.getPos().getMinBlockZ() + zRel);
//colorInt = getColorTextureForBlock(blockState, blockPos);
colorInt = getColorForBlock(chunk, blockPos);
}
if (colorInt == 0 && yAbs > 0)
{
//invisible case
colorInt = generateLodColor(chunk, config, xRel, yAbs - 1, zRel);
colorInt = generateLodColor(chunk, config, xRel, yAbs - 1, zRel, blockPos);
}
}
return colorInt;
@@ -559,13 +561,79 @@ public class LodBuilder
return light;
}
private int getColorTextureForBlock(BlockState blockState, BlockPos blockPos)
{
if (colorMap.containsKey(blockState.getBlock()))
return colorMap.get(blockState.getBlock());
World world = MinecraftWrapper.INSTANCE.getPlayer().level;
TextureAtlasSprite texture = MinecraftWrapper.INSTANCE.getModelManager().getBlockModelShaper().getTexture(blockState, world, blockPos);
int count = 0;
int alpha = 0;
int red = 0;
int green = 0;
int blue = 0;
;
int color = 0;
for (int k = 0; k < texture.getFrameCount(); k++)
{
for (int i = 0; i < texture.getHeight(); i++)
{
for (int j = 0; j < texture.getWidth(); j++)
{
if (texture.isTransparent(k, i, j))
{
if (blockState.getBlock() instanceof LeavesBlock)
color = 0;
else
continue;
} else
{
color = texture.getPixelRGBA(k, i, j);
}
count++;
alpha += ColorUtil.getAlpha(color);
red += ColorUtil.getBlue(color);
green += ColorUtil.getGreen(color);
blue += ColorUtil.getRed(color);
}
}
}
if (count == 0)
{
color = 0;
} else
{
alpha /= count;
red /= count;
green /= count;
blue /= count;
color = ColorUtil.rgbToInt(alpha, red, green, blue);
}
colorMap.put(blockState.getBlock(), color);
return color;
}
/**
* Returns a color int for the given block.
*/
private int getColorForBlock(int x, int z, BlockState blockState, Biome biome)
private int getColorForBlock(IChunk chunk, BlockPos blockPos)
{
int xRel = blockPos.getX() - chunk.getPos().getMinBlockX();
int zRel = blockPos.getZ() - chunk.getPos().getMinBlockZ();
int x = blockPos.getX();
int y = blockPos.getY();
int z = blockPos.getZ();
Biome biome = chunk.getBiomes().getNoiseBiome(xRel >> 2, y >> 2, zRel >> 2);
int brightness;
int red = 0;
int green = 0;
int blue = 0;
BlockState blockState = chunk.getBlockState(blockPos);
int colorInt = 0;
// block special cases
if (blockState == Blocks.AIR.defaultBlockState()
|| blockState == Blocks.CAVE_AIR.defaultBlockState()
@@ -574,9 +642,6 @@ public class LodBuilder
Color tmp = LodUtil.intToColor(biome.getGrassColor(x, z));
tmp = tmp.darker();
colorInt = LodUtil.colorToInt(tmp);
} else if (blockState == Blocks.STONE.defaultBlockState())
{
colorInt = LodUtil.STONE_COLOR_INT;
} else if (blockState == Blocks.NETHERRACK.defaultBlockState())
{
colorInt = LodUtil.NETHERRACK_COLOR_INT;
@@ -587,63 +652,47 @@ public class LodBuilder
{
colorInt = LodUtil.CRIMSON_NYLIUM_COLOR_INT;
} else if (blockState == Blocks.WEEPING_VINES.defaultBlockState()
|| blockState == Blocks.WEEPING_VINES_PLANT.defaultBlockState()
|| blockState == Blocks.WEEPING_VINES_PLANT.defaultBlockState()
|| blockState == Blocks.CRIMSON_FUNGUS.defaultBlockState()
|| blockState == Blocks.CRIMSON_ROOTS.defaultBlockState())
{
colorInt = Blocks.NETHER_WART_BLOCK.defaultMaterialColor().col;
} else if (blockState == Blocks.TWISTING_VINES.defaultBlockState()
|| blockState == Blocks.TWISTING_VINES_PLANT.defaultBlockState()
|| blockState == Blocks.CRIMSON_FUNGUS.defaultBlockState()
|| blockState == Blocks.CRIMSON_ROOTS.defaultBlockState())
} else if (blockState.getBlock().equals(Blocks.TWISTING_VINES)
|| blockState.equals(Blocks.TWISTING_VINES_PLANT)
|| blockState == Blocks.WARPED_ROOTS.defaultBlockState()
|| blockState == Blocks.WARPED_FUNGUS.defaultBlockState())
{
colorInt = Blocks.WARPED_WART_BLOCK.defaultMaterialColor().col;
} else if (blockState == Blocks.BEDROCK.defaultBlockState())
{
colorInt = getColorForBiome(x, z, biome);
} else if (blockState == Blocks.MYCELIUM.defaultBlockState())
{
colorInt = LodUtil.MYCELIUM_COLOR_INT;
} else if (blockState == Blocks.SOUL_TORCH.defaultBlockState()
|| blockState == Blocks.SOUL_WALL_TORCH.defaultBlockState())
{
colorInt = Blocks.WARPED_PLANKS.defaultMaterialColor().col;
} else if (blockState == Blocks.TORCH.defaultBlockState()
|| blockState == Blocks.WALL_TORCH.defaultBlockState())
{
colorInt = Blocks.OAK_PLANKS.defaultMaterialColor().col;
} else if (blockState == Blocks.REDSTONE_TORCH.defaultBlockState()
|| blockState == Blocks.REDSTONE_WALL_TORCH.defaultBlockState())
{
colorInt = Blocks.CRIMSON_PLANKS.defaultMaterialColor().col;
colorInt = Blocks.WARPED_NYLIUM.defaultMaterialColor().col;
}
// plant life
else if (blockState.getBlock() instanceof LeavesBlock || blockState.getBlock() == Blocks.VINE)
{
Color leafColor = LodUtil.intToColor(biome.getFoliageColor()).darker();
leafColor = leafColor.darker();
colorInt = LodUtil.colorToInt(leafColor);
brightness = getColorTextureForBlock(blockState, blockPos);
colorInt = ColorUtil.changeBrightnessValue(biome.getFoliageColor(), brightness);
} else if ((blockState.getBlock() instanceof GrassBlock || blockState.getBlock() instanceof AbstractPlantBlock
|| blockState.getBlock() instanceof BushBlock || blockState.getBlock() instanceof IGrowable)
&& !(blockState.getBlock() == Blocks.BROWN_MUSHROOM || blockState.getBlock() == Blocks.RED_MUSHROOM))
{
Color plantColor = LodUtil.intToColor(biome.getGrassColor(x, z));
plantColor = plantColor.darker();
colorInt = LodUtil.colorToInt(plantColor);
brightness = getColorTextureForBlock(blockState, blockPos);
//colorInt = ColorUtil.changeBrightnessValue(biome.getGrassColor(x, z), brightness);
colorInt = ColorUtil.applySaturationAndBrightnessMultipliers(biome.getGrassColor(x, z),1f,0.65f);
}
// water
else if (blockState.getBlock() == Blocks.WATER)
{
colorInt = biome.getWaterColor();
brightness = getColorTextureForBlock(blockState, blockPos);
//colorInt = ColorUtil.changeBrightnessValue(biome.getWaterColor(), brightness);
colorInt = ColorUtil.applySaturationAndBrightnessMultipliers(biome.getWaterColor(),1f,0.75f);
}
// everything else
else
{
colorInt = blockState.getBlock().defaultMaterialColor().col;
colorInt = getColorTextureForBlock(blockState, blockPos);
//colorInt = blockState.materialColor.col;
//colorInt = blockState.getBlock().defaultMaterialColor().col;
}
return colorInt;
@@ -751,26 +800,4 @@ public class LodBuilder
return false;
}
private boolean isLayerValidLodPoint(ChunkSection[] chunkSections, int sectionIndex, int y, int x, int z)
{
if (chunkSections[sectionIndex] == null)
{
// this section doesn't have any blocks,
// it is not a valid section
return false;
} else
{
if (chunkSections[sectionIndex].getBlockState(x, y, z) != null
&& chunkSections[sectionIndex].getBlockState(x, y, z).getBlock() != Blocks.AIR
&& chunkSections[sectionIndex].getBlockState(x, y, z).getBlock() != Blocks.CAVE_AIR
&& chunkSections[sectionIndex].getBlockState(x, y, z).getBlock() != Blocks.BARRIER)
{
return true;
}
}
return false;
}
}
@@ -17,11 +17,7 @@
*/
package com.seibel.lod.handlers;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.concurrent.ExecutorService;
@@ -57,7 +53,7 @@ public class LodDimensionFileHandler
/**
* .txt
*/
private static final String FILE_EXTENSION = ".txt";
private static final String FILE_EXTENSION = ".dat";
/**
* detail-#
*/
@@ -79,11 +75,6 @@ public class LodDimensionFileHandler
*/
public static final int LOD_SAVE_FILE_VERSION = 6;
/**
* This is the string written before the file version
*/
private static final String LOD_FILE_VERSION_PREFIX = "lod_save_file_version";
/**
* Allow saving asynchronously, but never try to save multiple regions
* at a time
@@ -140,66 +131,50 @@ public class LodDimensionFileHandler
// return anything
continue;
}
String data = "";
BufferedReader bufferedReader = new BufferedReader(new FileReader(f));
data = bufferedReader.readLine();
int fileVersion = -1;
byte data[] = {0};
long dataSize = f.length();
dataSize -= 1;
if (dataSize > 0) {
try (InputStream inputStream = new BufferedInputStream(new FileInputStream(f))) {
int fileVersion = -1;
fileVersion = inputStream.read();
// check if this file can be read by this file handler
if (fileVersion < LOD_SAVE_FILE_VERSION) {
// the file we are reading is an older version,
// close the reader and delete the file.
inputStream.close();
f.delete();
ClientProxy.LOGGER.info("Outdated LOD region file for region: (" + regionX + "," + regionZ + ") version found: " + fileVersion +
", version requested: " + LOD_SAVE_FILE_VERSION +
" File was been deleted.");
if (data != null && !data.isEmpty())
{
// try to get the file version
try
{
fileVersion = Integer.parseInt(data.substring(data.indexOf(' ')).trim());
} catch (NumberFormatException | StringIndexOutOfBoundsException e)
{
// this file doesn't have a version
// keep the version as -1
fileVersion = -1;
break;
} else if (fileVersion > LOD_SAVE_FILE_VERSION) {
// the file we are reading is a newer version,
// close the reader and ignore the file, we don't
// want to accidently delete anything the user may want.
inputStream.close();
ClientProxy.LOGGER.info("Newer LOD region file for region: (" + regionX + "," + regionZ + ") version found: " + fileVersion +
", version requested: " + LOD_SAVE_FILE_VERSION +
" this region will not be written to in order to protect the newer file.");
break;
}
// this file is a readable version, begin reading the file
data = new byte[(int) dataSize];
inputStream.read(data);
inputStream.close();
} catch (IOException ex) {
ex.printStackTrace();
}
// check if this file can be read by this file handler
if (fileVersion < LOD_SAVE_FILE_VERSION)
{
// the file we are reading is an older version,
// close the reader and delete the file.
bufferedReader.close();
f.delete();
ClientProxy.LOGGER.info("Outdated LOD region file for region: (" + regionX + "," + regionZ + ") version found: " + fileVersion +
", version requested: " + LOD_SAVE_FILE_VERSION +
" File was been deleted.");
break;
} else if (fileVersion > LOD_SAVE_FILE_VERSION)
{
// the file we are reading is a newer version,
// close the reader and ignore the file, we don't
// want to accidently delete anything the user may want.
bufferedReader.close();
ClientProxy.LOGGER.info("Newer LOD region file for region: (" + regionX + "," + regionZ + ") version found: " + fileVersion +
", version requested: " + LOD_SAVE_FILE_VERSION +
" this region will not be written to in order to protect the newer file.");
break;
}
} else
{
// there is no data in this file
bufferedReader.close();
break;
}
// this file is a readable version, begin reading the file
data = bufferedReader.readLine();
bufferedReader.close();
switch (region.getLodQualityMode()){
default:
case HEIGHTMAP:
region.addLevel(new SingleLevelContainer(data));
break;
case MULTI_LOD:
region.addLevel(new VerticalLevelContainer(data));
//region.addLevel(new VerticalLevelContainer(data));
break;
}
//region.addLevel(new SingleLevelContainer(data));
@@ -293,25 +268,13 @@ public class LodDimensionFileHandler
// is the correct version.
// (to make sure we don't overwrite a newer
// version file if it exists)
BufferedReader br = new BufferedReader(new FileReader(oldFile));
String s = br.readLine();
int fileVersion = LOD_SAVE_FILE_VERSION;
if (s != null && !s.isEmpty())
{
// try to get the file version
try
{
fileVersion = Integer.parseInt(s.substring(s.indexOf(' ')).trim());
} catch (NumberFormatException | StringIndexOutOfBoundsException e)
{
// this file doesn't have a correctly formated version
// just overwrite the file
}
try (InputStream inputStream = new BufferedInputStream(new FileInputStream(oldFile))) {
fileVersion = inputStream.read();
inputStream.close();
} catch (IOException ex) {
ex.printStackTrace();
}
br.close();
// check if this file can be written to by the file handler
if (fileVersion <= LOD_SAVE_FILE_VERSION)
{
@@ -327,17 +290,20 @@ public class LodDimensionFileHandler
// the old file is good, now create a new save file
File newFile = new File(fileName + TMP_FILE_EXTENSION);
FileWriter fw = new FileWriter(newFile);
try (OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(newFile));) {
// add the version of this file
fw.write(LOD_FILE_VERSION_PREFIX + " " + LOD_SAVE_FILE_VERSION + "\n");
// add the version of this file
outputStream.write(LOD_SAVE_FILE_VERSION);
// add each LodChunk to the file
fw.write(region.getLevel(detailLevel).toDataString());
fw.close();
// add each LodChunk to the file
outputStream.write(region.getLevel(detailLevel).toDataString());
outputStream.close();
// overwrite the old file with the new one
Files.move(newFile.toPath(), oldFile.toPath(), StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING);
// overwrite the old file with the new one
Files.move(newFile.toPath(), oldFile.toPath(), StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING);
}catch (IOException ex) {
ex.printStackTrace();
}
} catch (Exception e)
{
ClientProxy.LOGGER.error("LOD file write error. Unable to write to [" + fileName + "] error [" + e.getMessage() + "]: ");
@@ -370,10 +336,10 @@ public class LodDimensionFileHandler
// or
// ".\Super Flat\data"
return dimensionDataSaveFolder.getCanonicalPath() + File.separatorChar +
lodQualityMode + File.separatorChar +
generationMode.toString() + File.separatorChar +
DETAIL_FOLDER_NAME_PREFIX + detailLevel + File.separatorChar +
FILE_NAME_PREFIX + "." + regionX + "." + regionZ + FILE_EXTENSION;
lodQualityMode + File.separatorChar +
generationMode.toString() + File.separatorChar +
DETAIL_FOLDER_NAME_PREFIX + detailLevel + File.separatorChar +
FILE_NAME_PREFIX + "." + regionX + "." + regionZ + FILE_EXTENSION;
} catch (IOException | SecurityException e)
{
ClientProxy.LOGGER.warn("Unable to get the filename for the region [" + regionX + ", " + regionZ + "], error: [" + e.getMessage() + "], stacktrace: ");
@@ -1,11 +1,5 @@
package com.seibel.lod.objects;
import com.seibel.lod.util.LevelPosUtil;
import com.seibel.lod.util.LodUtil;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
public interface LevelContainer
{
public static final char VERTICAL_DATA_DELIMITER = '\t';
@@ -74,5 +68,5 @@ public interface LevelContainer
* This will give the data to save in the file
* @return data as a String
*/
public String toDataString();
public byte[] toDataString();
}
@@ -1,8 +1,7 @@
package com.seibel.lod.objects;
import com.seibel.lod.builders.LodBuilder;
import com.seibel.lod.enums.DistanceGenerationMode;
import com.seibel.lod.util.*;
import java.util.Arrays;
public class SingleLevelContainer implements LevelContainer
{
@@ -57,17 +56,13 @@ public class SingleLevelContainer implements LevelContainer
return new SingleLevelContainer((byte) (getDetailLevel() - 1));
}
public SingleLevelContainer(String inputString)
public SingleLevelContainer(byte inputData[])
{
int tempIndex;
int shift = 0;
int index = 0;
int digit;
char currentChar;
long newData;
currentChar = inputString.charAt(index);
digit = Character.digit(currentChar,16);
detailLevel = (byte) digit;
detailLevel = inputData[index];
index++;
size = (int) Math.pow(2, LodUtil.REGION_DETAIL_LEVEL - detailLevel);
this.data = new long[size][size];
for (int x = 0; x < size; x++)
@@ -75,21 +70,17 @@ public class SingleLevelContainer implements LevelContainer
for (int z = 0; z < size; z++)
{
newData = 0;
for(tempIndex = 0; tempIndex < 16; tempIndex++)
{
if(index+tempIndex >= inputString.length())
break;
currentChar = inputString.charAt(index+tempIndex);
if(currentChar == DATA_DELIMITER){
break;
}
shift = (15-tempIndex)*4;
digit = Character.digit(currentChar,16);
newData += ((((long) digit & 0xf)) << shift);
}
newData = newData >>> (shift);
if(inputData[index] == 0)
index++;
else if(index + 7 >= inputData.length)
break;
else {
for (tempIndex = 0; tempIndex < 8; tempIndex++)
newData += (((long) inputData[index + tempIndex]) & 0xff) << (8 * tempIndex);
index = index + 8;
}
data[x][z] = newData;
index = index + tempIndex;
}
}
}
@@ -125,22 +116,28 @@ public class SingleLevelContainer implements LevelContainer
return DataPointUtil.doesItExist(getSingleData(posX, posZ));
}
public String toDataString()
public byte[] toDataString()
{
StringBuilder stringBuilder = new StringBuilder();
int size = (int) Math.pow(2, LodUtil.REGION_DETAIL_LEVEL - detailLevel);
stringBuilder.append(detailLevel);
stringBuilder.append(DATA_DELIMITER);
int index = 0;
int tempIndex;
byte[] tempData = new byte[1 + (size * size * 8)];
tempData[index] = detailLevel;
index++;
for (int x = 0; x < size; x++)
{
for (int z = 0; z < size; z++)
{
//Converting the dataToHex
stringBuilder.append(Long.toHexString(data[x][z]));
stringBuilder.append(DATA_DELIMITER);
if(data[x][z] == 0){
tempData[index] = 0;
index++;
} else {
for (tempIndex = 0; tempIndex < 8; tempIndex++)
tempData[index + tempIndex] = (byte) (data[x][z] >>> (8 * tempIndex));
index += 8;
}
}
}
return stringBuilder.toString();
return Arrays.copyOfRange(tempData, 0, index);
}
@Override
@@ -114,9 +114,10 @@ public class VerticalLevelContainer implements LevelContainer
addData(data,posX,posZ);
}
public String toDataString()
public byte[] toDataString()
{
return toString();
byte[] temp = {};
return temp;
}
@Override
@@ -575,10 +575,13 @@ public class LodRenderer
float sunBrightness = lodDimension.dimension.hasSkyLight() ? mc.getSkyDarken(partialTicks) : 0.2f;
sunBrightness = playerHasNightVision ? 1.0f : sunBrightness;
float gammaMultiplyer = (float) mc.getOptions().gamma - 0.5f;
float lightStrength = ((sunBrightness / 2f) - 0.2f) + (gammaMultiplyer * 0.3f);
float gamma = (float) mc.getOptions().gamma - 0.0f;
float dayEffect = (sunBrightness - 0.2f) * 1.25f;
float lightStrength = (gamma * 0.34f - 0.01f) * (1.0f - dayEffect) + dayEffect - 0.20f; //gamma * 0.2980392157f + 0.1647058824f
float blueLightStrength = (gamma * 0.44f + 0.12f) * (1.0f - dayEffect) + dayEffect - 0.20f; //gamma * 0.4235294118f + 0.2784313725f
float lightAmbient[] = {lightStrength, lightStrength, blueLightStrength, 1.0f};
float lightAmbient[] = {lightStrength, lightStrength, lightStrength, 1.0f};
// can be used for debugging
// if (partialTicks < 0.005)
@@ -79,4 +79,17 @@ public class ColorUtil
hsv[1],
brightness).getRGB();
}
/**
* Edit the given color as a HSV (Hue Saturation Value) color.
*/
public static int changeBrightnessValue(int color, int brightnessColor)
{
float[] hsv = Color.RGBtoHSB(getRed(color), getGreen(color), getBlue(color), null);
float brightness = Color.RGBtoHSB(getRed(brightnessColor), getGreen(brightnessColor), getBlue(brightnessColor), null)[2];
return Color.getHSBColor(
hsv[0], // hue
hsv[1],
brightness).getRGB();
}
}
@@ -15,6 +15,7 @@ import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.texture.NativeImage;
import net.minecraft.client.renderer.model.ModelManager;
import net.minecraft.entity.Entity;
import net.minecraft.profiler.IProfiler;
import net.minecraft.server.integrated.IntegratedServer;
@@ -45,9 +46,9 @@ public class MinecraftWrapper
//=======================//
// non-minecraft methods //
//=======================//
//================//
// helper methods //
//================//
/**
* This should be called at the beginning of every frame to
@@ -165,7 +166,12 @@ public class MinecraftWrapper
{
return mc.options;
}
public ModelManager getModelManager()
{
return mc.getModelManager();
}
/** Measured in chunks */
public int getRenderDistance()
{