diff --git a/src/main/java/net/PeytonPlayz585/shadow/Config.java b/src/main/java/net/PeytonPlayz585/shadow/Config.java index dffa9ae..c221b67 100644 --- a/src/main/java/net/PeytonPlayz585/shadow/Config.java +++ b/src/main/java/net/PeytonPlayz585/shadow/Config.java @@ -304,6 +304,18 @@ public class Config { public static boolean isCustomItems() { return gameSettings.ofCustomItems; } + + public static boolean isSwampColors() { + return gameSettings.ofSwampColors; + } + + public static boolean isSmoothBiomes() { + return gameSettings.ofSmoothBiomes; + } + + public static boolean isCustomColors() { + return gameSettings.ofCustomColors; + } public static int limit(int p_limit_0_, int p_limit_1_, int p_limit_2_) { return p_limit_0_ < p_limit_1_ ? p_limit_1_ : (p_limit_0_ > p_limit_2_ ? p_limit_2_ : p_limit_0_); @@ -629,4 +641,13 @@ public class Config { public static void warn(String s, Throwable t) { LOGGER.warn("[Shadow Client] " + s, t); } + + public static int intHash(int p_intHash_0_) { + p_intHash_0_ = p_intHash_0_ ^ 61 ^ p_intHash_0_ >> 16; + p_intHash_0_ = p_intHash_0_ + (p_intHash_0_ << 3); + p_intHash_0_ = p_intHash_0_ ^ p_intHash_0_ >> 4; + p_intHash_0_ = p_intHash_0_ * 668265261; + p_intHash_0_ = p_intHash_0_ ^ p_intHash_0_ >> 15; + return p_intHash_0_; + } } diff --git a/src/main/java/net/PeytonPlayz585/shadow/CustomColorFader.java b/src/main/java/net/PeytonPlayz585/shadow/CustomColorFader.java new file mode 100644 index 0000000..b96a8ae --- /dev/null +++ b/src/main/java/net/PeytonPlayz585/shadow/CustomColorFader.java @@ -0,0 +1,39 @@ +package net.PeytonPlayz585.shadow; + +import net.minecraft.util.Vec3; + +public class CustomColorFader { + private Vec3 color = null; + private long timeUpdate = System.currentTimeMillis(); + + public Vec3 getColor(double x, double y, double z) { + if (this.color == null) { + this.color = new Vec3(x, y, z); + return this.color; + } else { + long i = System.currentTimeMillis(); + long j = i - this.timeUpdate; + + if (j == 0L) { + return this.color; + } else { + this.timeUpdate = i; + + if (Math.abs(x - this.color.xCoord) < 0.004D && Math.abs(y - this.color.yCoord) < 0.004D && Math.abs(z - this.color.zCoord) < 0.004D) { + return this.color; + } else { + double d0 = (double) j * 0.001D; + d0 = Config.limit(d0, 0.0D, 1.0D); + double d1 = x - this.color.xCoord; + double d2 = y - this.color.yCoord; + double d3 = z - this.color.zCoord; + double d4 = this.color.xCoord + d1 * d0; + double d5 = this.color.yCoord + d2 * d0; + double d6 = this.color.zCoord + d3 * d0; + this.color = new Vec3(d4, d5, d6); + return this.color; + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/shadow/CustomColormap.java b/src/main/java/net/PeytonPlayz585/shadow/CustomColormap.java new file mode 100644 index 0000000..304b2e1 --- /dev/null +++ b/src/main/java/net/PeytonPlayz585/shadow/CustomColormap.java @@ -0,0 +1,468 @@ +package net.PeytonPlayz585.shadow; + +import java.io.IOException; +import java.io.InputStream; +import java.util.HashSet; +import java.util.Properties; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import net.lax1dude.eaglercraft.v1_8.opengl.ImageData; +import net.minecraft.block.Block; +import net.minecraft.block.state.BlockStateBase; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.renderer.texture.TextureUtil; +import net.minecraft.util.BlockPos; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.biome.BiomeGenBase; + +public class CustomColormap implements CustomColors.IColorizer { + public String name = null; + public String basePath = null; + private int format = -1; + private MatchBlock[] matchBlocks = null; + private String source = null; + private int color = -1; + private int yVariance = 0; + private int yOffset = 0; + private int width = 0; + private int height = 0; + private int[] colors = null; + private float[][] colorsRgb = (float[][]) null; + private static final int FORMAT_UNKNOWN = -1; + private static final int FORMAT_VANILLA = 0; + private static final int FORMAT_GRID = 1; + private static final int FORMAT_FIXED = 2; + public static final String FORMAT_VANILLA_STRING = "vanilla"; + public static final String FORMAT_GRID_STRING = "grid"; + public static final String FORMAT_FIXED_STRING = "fixed"; + public static final String[] FORMAT_STRINGS = new String[] { + "vanilla", + "grid", + "fixed" + }; + public static final String KEY_FORMAT = "format"; + public static final String KEY_BLOCKS = "blocks"; + public static final String KEY_SOURCE = "source"; + public static final String KEY_COLOR = "color"; + public static final String KEY_Y_VARIANCE = "yVariance"; + public static final String KEY_Y_OFFSET = "yOffset"; + + public CustomColormap(Properties props, String path, int width, int height, String formatDefault) { + ConnectedParser connectedparser = new ConnectedParser("Colormap"); + this.name = connectedparser.parseName(path); + this.basePath = connectedparser.parseBasePath(path); + this.format = this.parseFormat(props.getProperty("format", formatDefault)); + this.matchBlocks = connectedparser.parseMatchBlocks(props.getProperty("blocks")); + this.source = parseTexture(props.getProperty("source"), path, this.basePath); + this.color = ConnectedParser.parseColor(props.getProperty("color"), -1); + this.yVariance = connectedparser.parseInt(props.getProperty("yVariance"), 0); + this.yOffset = connectedparser.parseInt(props.getProperty("yOffset"), 0); + this.width = width; + this.height = height; + } + + private int parseFormat(String str) { + if (str == null) { + return 0; + } else { + str = str.trim(); + + if (str.equals("vanilla")) { + return 0; + } else if (str.equals("grid")) { + return 1; + } else if (str.equals("fixed")) { + return 2; + } else { + warn("Unknown format: " + str); + return -1; + } + } + } + + public boolean isValid(String path) { + if (this.format != 0 && this.format != 1) { + if (this.format != 2) { + return false; + } + + if (this.color < 0) { + this.color = 16777215; + } + } else { + if (this.source == null) { + warn("Source not defined: " + path); + return false; + } + + this.readColors(); + + if (this.colors == null) { + return false; + } + + if (this.color < 0) { + if (this.format == 0) { + this.color = this.getColor(127, 127); + } + + if (this.format == 1) { + this.color = this.getColorGrid(BiomeGenBase.plains, new BlockPos(0, 64, 0)); + } + } + } + + return true; + } + + public boolean isValidMatchBlocks(String path) { + if (this.matchBlocks == null) { + this.matchBlocks = this.detectMatchBlocks(); + + if (this.matchBlocks == null) { + warn("Match blocks not defined: " + path); + return false; + } + } + + return true; + } + + private MatchBlock[] detectMatchBlocks() { + Block block = Block.getBlockFromName(this.name); + + if (block != null) { + return new MatchBlock[] { + new MatchBlock(Block.getIdFromBlock(block)) + }; + } else { + Pattern pattern = Pattern.compile("^block([0-9]+).*$"); + Matcher matcher = pattern.matcher(this.name); + + if (matcher.matches()) { + String s = matcher.group(1); + int i = Config.parseInt(s, -1); + + if (i >= 0) { + return new MatchBlock[] { + new MatchBlock(i) + }; + } + } + + ConnectedParser connectedparser = new ConnectedParser("Colormap"); + MatchBlock[] amatchblock = connectedparser.parseMatchBlock(this.name); + return amatchblock != null ? amatchblock : null; + } + } + + private void readColors() { + try { + this.colors = null; + + if (this.source == null) { + return; + } + + String s = this.source + ".png"; + ResourceLocation resourcelocation = new ResourceLocation(s); + InputStream inputstream = Config.getResourceStream(resourcelocation); + + if (inputstream == null) { + return; + } + + ImageData bufferedimage = TextureUtil.readBufferedImage(inputstream); + + if (bufferedimage == null) { + return; + } + + int i = bufferedimage.width; + int j = bufferedimage.height; + boolean flag = this.width < 0 || this.width == i; + boolean flag1 = this.height < 0 || this.height == j; + + if (!flag || !flag1) { + dbg("Non-standard palette size: " + i + "x" + j + ", should be: " + this.width + "x" + this.height + ", path: " + s); + } + + this.width = i; + this.height = j; + + if (this.width <= 0 || this.height <= 0) { + warn("Invalid palette size: " + i + "x" + j + ", path: " + s); + return; + } + + this.colors = new int[i * j]; + bufferedimage.getRGB(0, 0, i, j, this.colors, 0, i); + } catch (IOException ioexception) { + ioexception.printStackTrace(); + } + } + + private static void dbg(String str) { + Config.dbg("CustomColors: " + str); + } + + private static void warn(String str) { + Config.warn("CustomColors: " + str); + } + + private static String parseTexture(String texStr, String path, String basePath) { + if (texStr != null) { + texStr = texStr.trim(); + String s1 = ".png"; + + if (texStr.endsWith(s1)) { + texStr = texStr.substring(0, texStr.length() - s1.length()); + } + + texStr = fixTextureName(texStr, basePath); + return texStr; + } else { + String s = path; + int i = path.lastIndexOf(47); + + if (i >= 0) { + s = path.substring(i + 1); + } + + int j = s.lastIndexOf(46); + + if (j >= 0) { + s = s.substring(0, j); + } + + s = fixTextureName(s, basePath); + return s; + } + } + + private static String fixTextureName(String iconName, String basePath) { + iconName = TextureUtils.fixResourcePath(iconName, basePath); + + if (!iconName.startsWith(basePath) && !iconName.startsWith("textures/") && !iconName.startsWith("mcpatcher/")) { + iconName = basePath + "/" + iconName; + } + + if (iconName.endsWith(".png")) { + iconName = iconName.substring(0, iconName.length() - 4); + } + + String s = "textures/blocks/"; + + if (iconName.startsWith(s)) { + iconName = iconName.substring(s.length()); + } + + if (iconName.startsWith("/")) { + iconName = iconName.substring(1); + } + + return iconName; + } + + public boolean matchesBlock(BlockStateBase blockState) { + return Matches.block(blockState, this.matchBlocks); + } + + public int getColorRandom() { + if (this.format == 2) { + return this.color; + } else { + int i = CustomColors.random.nextInt(this.colors.length); + return this.colors[i]; + } + } + + public int getColor(int index) { + index = Config.limit(index, 0, this.colors.length - 1); + return this.colors[index] & 16777215; + } + + public int getColor(int cx, int cy) { + cx = Config.limit(cx, 0, this.width - 1); + cy = Config.limit(cy, 0, this.height - 1); + return this.colors[cy * this.width + cx] & 16777215; + } + + public float[][] getColorsRgb() { + if (this.colorsRgb == null) { + this.colorsRgb = toRgb(this.colors); + } + + return this.colorsRgb; + } + + public int getColor(IBlockState blockState, IBlockAccess blockAccess, BlockPos blockPos) { + return this.getColor(blockAccess, blockPos); + } + + public int getColor(IBlockAccess blockAccess, BlockPos blockPos) { + BiomeGenBase biomegenbase = CustomColors.getColorBiome(blockAccess, blockPos); + return this.getColor(biomegenbase, blockPos); + } + + public boolean isColorConstant() { + return this.format == 2; + } + + public int getColor(BiomeGenBase biome, BlockPos blockPos) { + return this.format == 0 ? this.getColorVanilla(biome, blockPos) : (this.format == 1 ? this.getColorGrid(biome, blockPos) : this.color); + } + + public int getColorSmooth(IBlockAccess blockAccess, double x, double y, double z, int radius) { + if (this.format == 2) { + return this.color; + } else { + int i = MathHelper.floor_double(x); + int j = MathHelper.floor_double(y); + int k = MathHelper.floor_double(z); + int l = 0; + int i1 = 0; + int j1 = 0; + int k1 = 0; + BlockPosM blockposm = new BlockPosM(0, 0, 0); + + for (int l1 = i - radius; l1 <= i + radius; ++l1) { + for (int i2 = k - radius; i2 <= k + radius; ++i2) { + blockposm.setXyz(l1, j, i2); + int j2 = this.getColor((IBlockAccess) blockAccess, blockposm); + l += j2 >> 16 & 255; + i1 += j2 >> 8 & 255; + j1 += j2 & 255; + ++k1; + } + } + + int k2 = l / k1; + int l2 = i1 / k1; + int i3 = j1 / k1; + return k2 << 16 | l2 << 8 | i3; + } + } + + private int getColorVanilla(BiomeGenBase biome, BlockPos blockPos) { + double d0 = (double) MathHelper.clamp_float(biome.getFloatTemperature(blockPos), 0.0F, 1.0F); + double d1 = (double) MathHelper.clamp_float(biome.getFloatRainfall(), 0.0F, 1.0F); + d1 = d1 * d0; + int i = (int)((1.0D - d0) * (double)(this.width - 1)); + int j = (int)((1.0D - d1) * (double)(this.height - 1)); + return this.getColor(i, j); + } + + private int getColorGrid(BiomeGenBase biome, BlockPos blockPos) { + int i = biome.biomeID; + int j = blockPos.getY() - this.yOffset; + + if (this.yVariance > 0) { + int k = blockPos.getX() << 16 + blockPos.getZ(); + int l = Config.intHash(k); + int i1 = this.yVariance * 2 + 1; + int j1 = (l & 255) % i1 - this.yVariance; + j += j1; + } + + return this.getColor(i, j); + } + + public int getLength() { + return this.format == 2 ? 1 : this.colors.length; + } + + public int getWidth() { + return this.width; + } + + public int getHeight() { + return this.height; + } + + private static float[][] toRgb(int[] cols) { + float[][] afloat = new float[cols.length][3]; + + for (int i = 0; i < cols.length; ++i) { + int j = cols[i]; + float f = (float)(j >> 16 & 255) / 255.0F; + float f1 = (float)(j >> 8 & 255) / 255.0F; + float f2 = (float)(j & 255) / 255.0F; + float[] afloat1 = afloat[i]; + afloat1[0] = f; + afloat1[1] = f1; + afloat1[2] = f2; + } + + return afloat; + } + + public void addMatchBlock(MatchBlock mb) { + if (this.matchBlocks == null) { + this.matchBlocks = new MatchBlock[0]; + } + + this.matchBlocks = (MatchBlock[])((MatchBlock[]) Config.addObjectToArray(this.matchBlocks, mb)); + } + + public void addMatchBlock(int blockId, int metadata) { + MatchBlock matchblock = this.getMatchBlock(blockId); + + if (matchblock != null) { + if (metadata >= 0) { + matchblock.addMetadata(metadata); + } + } else { + this.addMatchBlock(new MatchBlock(blockId, metadata)); + } + } + + private MatchBlock getMatchBlock(int blockId) { + if (this.matchBlocks == null) { + return null; + } else { + for (int i = 0; i < this.matchBlocks.length; ++i) { + MatchBlock matchblock = this.matchBlocks[i]; + + if (matchblock.getBlockId() == blockId) { + return matchblock; + } + } + + return null; + } + } + + public int[] getMatchBlockIds() { + if (this.matchBlocks == null) { + return null; + } else { + Set set = new HashSet(); + + for (int i = 0; i < this.matchBlocks.length; ++i) { + MatchBlock matchblock = this.matchBlocks[i]; + + if (matchblock.getBlockId() >= 0) { + set.add(Integer.valueOf(matchblock.getBlockId())); + } + } + + Integer[] ainteger = (Integer[])((Integer[]) set.toArray(new Integer[set.size()])); + int[] aint = new int[ainteger.length]; + + for (int j = 0; j < ainteger.length; ++j) { + aint[j] = ainteger[j].intValue(); + } + + return aint; + } + } + + public String toString() { + return "" + this.basePath + "/" + this.name + ", blocks: " + Config.arrayToString((Object[]) this.matchBlocks) + ", source: " + this.source; + } +} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/shadow/CustomColors.java b/src/main/java/net/PeytonPlayz585/shadow/CustomColors.java new file mode 100644 index 0000000..0c32c64 --- /dev/null +++ b/src/main/java/net/PeytonPlayz585/shadow/CustomColors.java @@ -0,0 +1,1461 @@ +package net.PeytonPlayz585.shadow; + +import java.awt.image.BufferedImage; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Random; +import java.util.Set; +import javax.imageio.ImageIO; + +import net.PeytonPlayz585.shadow.apache.ImmutablePair; +import net.PeytonPlayz585.shadow.apache.Pair; +import net.minecraft.block.Block; +import net.minecraft.block.BlockRedstoneWire; +import net.minecraft.block.BlockStem; +import net.minecraft.block.material.MapColor; +import net.minecraft.block.material.Material; +import net.minecraft.block.state.BlockStateBase; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.item.EnumDyeColor; +import net.minecraft.item.Item; +import net.minecraft.item.ItemMonsterPlacer; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.util.BlockPos; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Vec3; +import net.minecraft.world.ColorizerFoliage; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; + +public class CustomColors { + private static String paletteFormatDefault = "vanilla"; + private static CustomColormap waterColors = null; + private static CustomColormap foliagePineColors = null; + private static CustomColormap foliageBirchColors = null; + private static CustomColormap swampFoliageColors = null; + private static CustomColormap swampGrassColors = null; + private static CustomColormap[] colorsBlockColormaps = null; + private static CustomColormap[][] blockColormaps = (CustomColormap[][]) null; + private static CustomColormap skyColors = null; + private static CustomColorFader skyColorFader = new CustomColorFader(); + private static CustomColormap fogColors = null; + private static CustomColorFader fogColorFader = new CustomColorFader(); + private static CustomColormap underwaterColors = null; + private static CustomColorFader underwaterColorFader = new CustomColorFader(); + private static CustomColormap underlavaColors = null; + private static CustomColorFader underlavaColorFader = new CustomColorFader(); + private static LightMapPack[] lightMapPacks = null; + private static int lightmapMinDimensionId = 0; + private static CustomColormap redstoneColors = null; + private static CustomColormap xpOrbColors = null; + private static int xpOrbTime = -1; + private static CustomColormap durabilityColors = null; + private static CustomColormap stemColors = null; + private static CustomColormap stemMelonColors = null; + private static CustomColormap stemPumpkinColors = null; + private static CustomColormap myceliumParticleColors = null; + private static boolean useDefaultGrassFoliageColors = true; + private static int particleWaterColor = -1; + private static int particlePortalColor = -1; + private static int lilyPadColor = -1; + private static int expBarTextColor = -1; + private static int bossTextColor = -1; + private static int signTextColor = -1; + private static Vec3 fogColorNether = null; + private static Vec3 fogColorEnd = null; + private static Vec3 skyColorEnd = null; + private static int[] spawnEggPrimaryColors = null; + private static int[] spawnEggSecondaryColors = null; + private static float[][] wolfCollarColors = (float[][]) null; + private static float[][] sheepColors = (float[][]) null; + private static int[] textColors = null; + private static int[] mapColorsOriginal = null; + private static int[] potionColors = null; + private static final IBlockState BLOCK_STATE_DIRT = Blocks.dirt.getDefaultState(); + private static final IBlockState BLOCK_STATE_WATER = Blocks.water.getDefaultState(); + public static Random random = new Random(); + private static final CustomColors.IColorizer COLORIZER_GRASS = new CustomColors.IColorizer() { + public int getColor(IBlockState blockState, IBlockAccess blockAccess, BlockPos blockPos) { + BiomeGenBase biomegenbase = CustomColors.getColorBiome(blockAccess, blockPos); + return CustomColors.swampGrassColors != null && biomegenbase == BiomeGenBase.swampland ? CustomColors.swampGrassColors.getColor(biomegenbase, blockPos) : biomegenbase.getGrassColorAtPos(blockPos); + } + public boolean isColorConstant() { + return false; + } + }; + private static final CustomColors.IColorizer COLORIZER_FOLIAGE = new CustomColors.IColorizer() { + public int getColor(IBlockState blockState, IBlockAccess blockAccess, BlockPos blockPos) { + BiomeGenBase biomegenbase = CustomColors.getColorBiome(blockAccess, blockPos); + return CustomColors.swampFoliageColors != null && biomegenbase == BiomeGenBase.swampland ? CustomColors.swampFoliageColors.getColor(biomegenbase, blockPos) : biomegenbase.getFoliageColorAtPos(blockPos); + } + public boolean isColorConstant() { + return false; + } + }; + private static final CustomColors.IColorizer COLORIZER_FOLIAGE_PINE = new CustomColors.IColorizer() { + public int getColor(IBlockState blockState, IBlockAccess blockAccess, BlockPos blockPos) { + return CustomColors.foliagePineColors != null ? CustomColors.foliagePineColors.getColor(blockAccess, blockPos) : ColorizerFoliage.getFoliageColorPine(); + } + public boolean isColorConstant() { + return CustomColors.foliagePineColors == null; + } + }; + private static final CustomColors.IColorizer COLORIZER_FOLIAGE_BIRCH = new CustomColors.IColorizer() { + public int getColor(IBlockState blockState, IBlockAccess blockAccess, BlockPos blockPos) { + return CustomColors.foliageBirchColors != null ? CustomColors.foliageBirchColors.getColor(blockAccess, blockPos) : ColorizerFoliage.getFoliageColorBirch(); + } + public boolean isColorConstant() { + return CustomColors.foliageBirchColors == null; + } + }; + private static final CustomColors.IColorizer COLORIZER_WATER = new CustomColors.IColorizer() { + public int getColor(IBlockState blockState, IBlockAccess blockAccess, BlockPos blockPos) { + BiomeGenBase biomegenbase = CustomColors.getColorBiome(blockAccess, blockPos); + return CustomColors.waterColors != null ? CustomColors.waterColors.getColor(biomegenbase, blockPos) : biomegenbase.waterColorMultiplier; + } + public boolean isColorConstant() { + return false; + } + }; + + public static void update() { + paletteFormatDefault = "vanilla"; + waterColors = null; + foliageBirchColors = null; + foliagePineColors = null; + swampGrassColors = null; + swampFoliageColors = null; + skyColors = null; + fogColors = null; + underwaterColors = null; + underlavaColors = null; + redstoneColors = null; + xpOrbColors = null; + xpOrbTime = -1; + durabilityColors = null; + stemColors = null; + myceliumParticleColors = null; + lightMapPacks = null; + particleWaterColor = -1; + particlePortalColor = -1; + lilyPadColor = -1; + expBarTextColor = -1; + bossTextColor = -1; + signTextColor = -1; + fogColorNether = null; + fogColorEnd = null; + skyColorEnd = null; + colorsBlockColormaps = null; + blockColormaps = (CustomColormap[][]) null; + useDefaultGrassFoliageColors = true; + spawnEggPrimaryColors = null; + spawnEggSecondaryColors = null; + wolfCollarColors = (float[][]) null; + sheepColors = (float[][]) null; + textColors = null; + setMapColors(mapColorsOriginal); + potionColors = null; + paletteFormatDefault = getValidProperty("mcpatcher/color.properties", "palette.format", CustomColormap.FORMAT_STRINGS, "vanilla"); + String s = "mcpatcher/colormap/"; + String[] astring = new String[] { + "water.png", + "watercolorX.png" + }; + waterColors = getCustomColors(s, astring, 256, 256); + updateUseDefaultGrassFoliageColors(); + + if (Config.isCustomColors()) { + String[] astring1 = new String[] { + "pine.png", + "pinecolor.png" + }; + foliagePineColors = getCustomColors(s, astring1, 256, 256); + String[] astring2 = new String[] { + "birch.png", + "birchcolor.png" + }; + foliageBirchColors = getCustomColors(s, astring2, 256, 256); + String[] astring3 = new String[] { + "swampgrass.png", + "swampgrasscolor.png" + }; + swampGrassColors = getCustomColors(s, astring3, 256, 256); + String[] astring4 = new String[] { + "swampfoliage.png", + "swampfoliagecolor.png" + }; + swampFoliageColors = getCustomColors(s, astring4, 256, 256); + String[] astring5 = new String[] { + "sky0.png", + "skycolor0.png" + }; + skyColors = getCustomColors(s, astring5, 256, 256); + String[] astring6 = new String[] { + "fog0.png", + "fogcolor0.png" + }; + fogColors = getCustomColors(s, astring6, 256, 256); + String[] astring7 = new String[] { + "underwater.png", + "underwatercolor.png" + }; + underwaterColors = getCustomColors(s, astring7, 256, 256); + String[] astring8 = new String[] { + "underlava.png", + "underlavacolor.png" + }; + underlavaColors = getCustomColors(s, astring8, 256, 256); + String[] astring9 = new String[] { + "redstone.png", + "redstonecolor.png" + }; + redstoneColors = getCustomColors(s, astring9, 16, 1); + xpOrbColors = getCustomColors(s + "xporb.png", -1, -1); + durabilityColors = getCustomColors(s + "durability.png", -1, -1); + String[] astring10 = new String[] { + "stem.png", + "stemcolor.png" + }; + stemColors = getCustomColors(s, astring10, 8, 1); + stemPumpkinColors = getCustomColors(s + "pumpkinstem.png", 8, 1); + stemMelonColors = getCustomColors(s + "melonstem.png", 8, 1); + String[] astring11 = new String[] { + "myceliumparticle.png", + "myceliumparticlecolor.png" + }; + myceliumParticleColors = getCustomColors(s, astring11, -1, -1); + Pair < LightMapPack[], Integer > pair = parseLightMapPacks(); + lightMapPacks = (LightMapPack[]) pair.getLeft(); + lightmapMinDimensionId = ((Integer) pair.getRight()).intValue(); + readColorProperties("mcpatcher/color.properties"); + blockColormaps = readBlockColormaps(new String[] { + s + "custom/", s + "blocks/" + }, colorsBlockColormaps, 256, 256); + updateUseDefaultGrassFoliageColors(); + } + } + + private static String getValidProperty(String fileName, String key, String[] validValues, String valDef) { + try { + ResourceLocation resourcelocation = new ResourceLocation(fileName); + InputStream inputstream = Config.getResourceStream(resourcelocation); + + if (inputstream == null) { + return valDef; + } else { + Properties properties = new PropertiesOrdered(); + properties.load(inputstream); + inputstream.close(); + String s = properties.getProperty(key); + + if (s == null) { + return valDef; + } else { + List < String > list = Arrays. < String > asList(validValues); + + if (!list.contains(s)) { + warn("Invalid value: " + key + "=" + s); + warn("Expected values: " + Config.arrayToString((Object[]) validValues)); + return valDef; + } else { + dbg("" + key + "=" + s); + return s; + } + } + } + } catch (FileNotFoundException var9) { + return valDef; + } catch (IOException ioexception) { + ioexception.printStackTrace(); + return valDef; + } + } + + private static Pair < LightMapPack[], Integer > parseLightMapPacks() { + String s = "mcpatcher/lightmap/world"; + String s1 = ".png"; + String[] astring = ResUtils.collectFiles(s, s1); + Map < Integer, String > map = new HashMap(); + + for (int i = 0; i < astring.length; ++i) { + String s2 = astring[i]; + String s3 = StrUtils.removePrefixSuffix(s2, s, s1); + int j = Config.parseInt(s3, Integer.MIN_VALUE); + + if (j == Integer.MIN_VALUE) { + warn("Invalid dimension ID: " + s3 + ", path: " + s2); + } else { + map.put(Integer.valueOf(j), s2); + } + } + + Set < Integer > set = map.keySet(); + Integer[] ainteger = (Integer[]) set.toArray(new Integer[set.size()]); + Arrays.sort((Object[]) ainteger); + + if (ainteger.length <= 0) { + return new ImmutablePair((Object) null, Integer.valueOf(0)); + } else { + int j1 = ainteger[0].intValue(); + int k1 = ainteger[ainteger.length - 1].intValue(); + int k = k1 - j1 + 1; + CustomColormap[] acustomcolormap = new CustomColormap[k]; + + for (int l = 0; l < ainteger.length; ++l) { + Integer integer = ainteger[l]; + String s4 = (String) map.get(integer); + CustomColormap customcolormap = getCustomColors(s4, -1, -1); + + if (customcolormap != null) { + if (customcolormap.getWidth() < 16) { + warn("Invalid lightmap width: " + customcolormap.getWidth() + ", path: " + s4); + } else { + int i1 = integer.intValue() - j1; + acustomcolormap[i1] = customcolormap; + } + } + } + + LightMapPack[] alightmappack = new LightMapPack[acustomcolormap.length]; + + for (int l1 = 0; l1 < acustomcolormap.length; ++l1) { + CustomColormap customcolormap3 = acustomcolormap[l1]; + + if (customcolormap3 != null) { + String s5 = customcolormap3.name; + String s6 = customcolormap3.basePath; + CustomColormap customcolormap1 = getCustomColors(s6 + "/" + s5 + "_rain.png", -1, -1); + CustomColormap customcolormap2 = getCustomColors(s6 + "/" + s5 + "_thunder.png", -1, -1); + LightMap lightmap = new LightMap(customcolormap3); + LightMap lightmap1 = customcolormap1 != null ? new LightMap(customcolormap1) : null; + LightMap lightmap2 = customcolormap2 != null ? new LightMap(customcolormap2) : null; + LightMapPack lightmappack = new LightMapPack(lightmap, lightmap1, lightmap2); + alightmappack[l1] = lightmappack; + } + } + + return new ImmutablePair(alightmappack, Integer.valueOf(j1)); + } + } + + private static int getTextureHeight(String path, int defHeight) { + try { + InputStream inputstream = Config.getResourceStream(new ResourceLocation(path)); + + if (inputstream == null) { + return defHeight; + } else { + BufferedImage bufferedimage = ImageIO.read(inputstream); + inputstream.close(); + return bufferedimage == null ? defHeight : bufferedimage.getHeight(); + } + } catch (IOException var4) { + return defHeight; + } + } + + private static void readColorProperties(String fileName) { + try { + ResourceLocation resourcelocation = new ResourceLocation(fileName); + InputStream inputstream = Config.getResourceStream(resourcelocation); + + if (inputstream == null) { + return; + } + + dbg("Loading " + fileName); + Properties properties = new PropertiesOrdered(); + properties.load(inputstream); + inputstream.close(); + particleWaterColor = readColor(properties, new String[] { + "particle.water", + "drop.water" + }); + particlePortalColor = readColor(properties, "particle.portal"); + lilyPadColor = readColor(properties, "lilypad"); + expBarTextColor = readColor(properties, "text.xpbar"); + bossTextColor = readColor(properties, "text.boss"); + signTextColor = readColor(properties, "text.sign"); + fogColorNether = readColorVec3(properties, "fog.nether"); + fogColorEnd = readColorVec3(properties, "fog.end"); + skyColorEnd = readColorVec3(properties, "sky.end"); + colorsBlockColormaps = readCustomColormaps(properties, fileName); + spawnEggPrimaryColors = readSpawnEggColors(properties, fileName, "egg.shell.", "Spawn egg shell"); + spawnEggSecondaryColors = readSpawnEggColors(properties, fileName, "egg.spots.", "Spawn egg spot"); + wolfCollarColors = readDyeColors(properties, fileName, "collar.", "Wolf collar"); + sheepColors = readDyeColors(properties, fileName, "sheep.", "Sheep"); + textColors = readTextColors(properties, fileName, "text.code.", "Text"); + int[] aint = readMapColors(properties, fileName, "map.", "Map"); + + if (aint != null) { + if (mapColorsOriginal == null) { + mapColorsOriginal = getMapColors(); + } + + setMapColors(aint); + } + + potionColors = readPotionColors(properties, fileName, "potion.", "Potion"); + xpOrbTime = Config.parseInt(properties.getProperty("xporb.time"), -1); + } catch (FileNotFoundException var5) { + return; + } catch (IOException ioexception) { + ioexception.printStackTrace(); + } + } + + private static CustomColormap[] readCustomColormaps(Properties props, String fileName) { + List list = new ArrayList(); + String s = "palette.block."; + Map map = new HashMap(); + + for (Object e: props.keySet()) { + String s1 = (String) e; + String s2 = props.getProperty(s1); + + if (s1.startsWith(s)) { + map.put(s1, s2); + } + } + + String[] astring = (String[])((String[]) map.keySet().toArray(new String[map.size()])); + + for (int j = 0; j < astring.length; ++j) { + String s6 = astring[j]; + String s3 = props.getProperty(s6); + dbg("Block palette: " + s6 + " = " + s3); + String s4 = s6.substring(s.length()); + String s5 = TextureUtils.getBasePath(fileName); + s4 = TextureUtils.fixResourcePath(s4, s5); + CustomColormap customcolormap = getCustomColors(s4, 256, 256); + + if (customcolormap == null) { + warn("Colormap not found: " + s4); + } else { + ConnectedParser connectedparser = new ConnectedParser("CustomColors"); + MatchBlock[] amatchblock = connectedparser.parseMatchBlocks(s3); + + if (amatchblock != null && amatchblock.length > 0) { + for (int i = 0; i < amatchblock.length; ++i) { + MatchBlock matchblock = amatchblock[i]; + customcolormap.addMatchBlock(matchblock); + } + + list.add(customcolormap); + } else { + warn("Invalid match blocks: " + s3); + } + } + } + + if (list.size() <= 0) { + return null; + } else { + CustomColormap[] acustomcolormap = (CustomColormap[])((CustomColormap[]) list.toArray(new CustomColormap[list.size()])); + return acustomcolormap; + } + } + + private static CustomColormap[][] readBlockColormaps(String[] basePaths, CustomColormap[] basePalettes, int width, int height) { + String[] astring = ResUtils.collectFiles(basePaths, new String[] { + ".properties" + }); + Arrays.sort((Object[]) astring); + List list = new ArrayList(); + + for (int i = 0; i < astring.length; ++i) { + String s = astring[i]; + dbg("Block colormap: " + s); + + try { + ResourceLocation resourcelocation = new ResourceLocation("minecraft", s); + InputStream inputstream = Config.getResourceStream(resourcelocation); + + if (inputstream == null) { + warn("File not found: " + s); + } else { + Properties properties = new PropertiesOrdered(); + properties.load(inputstream); + inputstream.close(); + CustomColormap customcolormap = new CustomColormap(properties, s, width, height, paletteFormatDefault); + + if (customcolormap.isValid(s) && customcolormap.isValidMatchBlocks(s)) { + addToBlockList(customcolormap, list); + } + } + } catch (FileNotFoundException var12) { + warn("File not found: " + s); + } catch (Exception exception) { + exception.printStackTrace(); + } + } + + if (basePalettes != null) { + for (int j = 0; j < basePalettes.length; ++j) { + CustomColormap customcolormap1 = basePalettes[j]; + addToBlockList(customcolormap1, list); + } + } + + if (list.size() <= 0) { + return (CustomColormap[][]) null; + } else { + CustomColormap[][] acustomcolormap = blockListToArray(list); + return acustomcolormap; + } + } + + private static void addToBlockList(CustomColormap cm, List blockList) { + int[] aint = cm.getMatchBlockIds(); + + if (aint != null && aint.length > 0) { + for (int i = 0; i < aint.length; ++i) { + int j = aint[i]; + + if (j < 0) { + warn("Invalid block ID: " + j); + } else { + addToList(cm, blockList, j); + } + } + } else { + warn("No match blocks: " + Config.arrayToString(aint)); + } + } + + private static void addToList(CustomColormap cm, List list, int id) { + while (id >= list.size()) { + list.add(null); + } + + List list1 = (List) list.get(id); + + if (list1 == null) { + list1 = new ArrayList(); + list.set(id, list1); + } + + list1.add(cm); + } + + private static CustomColormap[][] blockListToArray(List list) { + CustomColormap[][] acustomcolormap = new CustomColormap[list.size()][]; + + for (int i = 0; i < list.size(); ++i) { + List list1 = (List) list.get(i); + + if (list1 != null) { + CustomColormap[] acustomcolormap1 = (CustomColormap[])((CustomColormap[]) list1.toArray(new CustomColormap[list1.size()])); + acustomcolormap[i] = acustomcolormap1; + } + } + + return acustomcolormap; + } + + private static int readColor(Properties props, String[] names) { + for (int i = 0; i < names.length; ++i) { + String s = names[i]; + int j = readColor(props, s); + + if (j >= 0) { + return j; + } + } + + return -1; + } + + private static int readColor(Properties props, String name) { + String s = props.getProperty(name); + + if (s == null) { + return -1; + } else { + s = s.trim(); + int i = parseColor(s); + + if (i < 0) { + warn("Invalid color: " + name + " = " + s); + return i; + } else { + dbg(name + " = " + s); + return i; + } + } + } + + private static int parseColor(String str) { + if (str == null) { + return -1; + } else { + str = str.trim(); + + try { + int i = Integer.parseInt(str, 16) & 16777215; + return i; + } catch (NumberFormatException var2) { + return -1; + } + } + } + + private static Vec3 readColorVec3(Properties props, String name) { + int i = readColor(props, name); + + if (i < 0) { + return null; + } else { + int j = i >> 16 & 255; + int k = i >> 8 & 255; + int l = i & 255; + float f = (float) j / 255.0F; + float f1 = (float) k / 255.0F; + float f2 = (float) l / 255.0F; + return new Vec3((double) f, (double) f1, (double) f2); + } + } + + private static CustomColormap getCustomColors(String basePath, String[] paths, int width, int height) { + for (int i = 0; i < paths.length; ++i) { + String s = paths[i]; + s = basePath + s; + CustomColormap customcolormap = getCustomColors(s, width, height); + + if (customcolormap != null) { + return customcolormap; + } + } + + return null; + } + + public static CustomColormap getCustomColors(String pathImage, int width, int height) { + try { + ResourceLocation resourcelocation = new ResourceLocation(pathImage); + + if (!Config.hasResource(resourcelocation)) { + return null; + } else { + dbg("Colormap " + pathImage); + Properties properties = new PropertiesOrdered(); + String s = StrUtils.replaceSuffix(pathImage, ".png", ".properties"); + ResourceLocation resourcelocation1 = new ResourceLocation(s); + + if (Config.hasResource(resourcelocation1)) { + InputStream inputstream = Config.getResourceStream(resourcelocation1); + properties.load(inputstream); + inputstream.close(); + dbg("Colormap properties: " + s); + } else { + properties.put("format", paletteFormatDefault); + properties.put("source", pathImage); + s = pathImage; + } + + CustomColormap customcolormap = new CustomColormap(properties, s, width, height, paletteFormatDefault); + return !customcolormap.isValid(s) ? null : customcolormap; + } + } catch (Exception exception) { + exception.printStackTrace(); + return null; + } + } + + public static void updateUseDefaultGrassFoliageColors() { + useDefaultGrassFoliageColors = foliageBirchColors == null && foliagePineColors == null && swampGrassColors == null && swampFoliageColors == null && Config.isSwampColors() && Config.isSmoothBiomes(); + } + + public static int getColorMultiplier(BakedQuad quad, IBlockState blockState, IBlockAccess blockAccess, BlockPos blockPos, RenderEnv renderEnv) { + Block block = blockState.getBlock(); + IBlockState iblockstate = renderEnv.getBlockState(); + + if (blockColormaps != null) { + if (!quad.hasTintIndex()) { + if (block == Blocks.grass) { + iblockstate = BLOCK_STATE_DIRT; + } + + if (block == Blocks.redstone_wire) { + return -1; + } + } + + if (block == Blocks.double_plant && renderEnv.getMetadata() >= 8) { + blockPos = blockPos.down(); + iblockstate = blockAccess.getBlockState(blockPos); + } + + CustomColormap customcolormap = getBlockColormap(iblockstate); + + if (customcolormap != null) { + if (Config.isSmoothBiomes() && !customcolormap.isColorConstant()) { + return getSmoothColorMultiplier(blockState, blockAccess, blockPos, customcolormap, renderEnv.getColorizerBlockPosM()); + } + + return customcolormap.getColor(blockAccess, blockPos); + } + } + + if (!quad.hasTintIndex()) { + return -1; + } else if (block == Blocks.waterlily) { + return getLilypadColorMultiplier(blockAccess, blockPos); + } else if (block == Blocks.redstone_wire) { + return getRedstoneColor(renderEnv.getBlockState()); + } else if (block instanceof BlockStem) { + return getStemColorMultiplier(block, blockAccess, blockPos, renderEnv); + } else if (useDefaultGrassFoliageColors) { + return -1; + } else { + int i = renderEnv.getMetadata(); + CustomColors.IColorizer customcolors$icolorizer; + + if (block != Blocks.grass && block != Blocks.tallgrass && block != Blocks.double_plant) { + if (block == Blocks.double_plant) { + customcolors$icolorizer = COLORIZER_GRASS; + + if (i >= 8) { + blockPos = blockPos.down(); + } + } else if (block == Blocks.leaves) { + switch (i & 3) { + case 0: + customcolors$icolorizer = COLORIZER_FOLIAGE; + break; + + case 1: + customcolors$icolorizer = COLORIZER_FOLIAGE_PINE; + break; + + case 2: + customcolors$icolorizer = COLORIZER_FOLIAGE_BIRCH; + break; + + default: + customcolors$icolorizer = COLORIZER_FOLIAGE; + } + } else if (block == Blocks.leaves2) { + customcolors$icolorizer = COLORIZER_FOLIAGE; + } else { + if (block != Blocks.vine) { + return -1; + } + + customcolors$icolorizer = COLORIZER_FOLIAGE; + } + } else { + customcolors$icolorizer = COLORIZER_GRASS; + } + + return Config.isSmoothBiomes() && !customcolors$icolorizer.isColorConstant() ? getSmoothColorMultiplier(blockState, blockAccess, blockPos, customcolors$icolorizer, renderEnv.getColorizerBlockPosM()) : customcolors$icolorizer.getColor(iblockstate, blockAccess, blockPos); + } + } + + protected static BiomeGenBase getColorBiome(IBlockAccess blockAccess, BlockPos blockPos) { + BiomeGenBase biomegenbase = blockAccess.getBiomeGenForCoords(blockPos); + + if (biomegenbase == BiomeGenBase.swampland && !Config.isSwampColors()) { + biomegenbase = BiomeGenBase.plains; + } + + return biomegenbase; + } + + private static CustomColormap getBlockColormap(IBlockState blockState) { + if (blockColormaps == null) { + return null; + } else if (!(blockState instanceof BlockStateBase)) { + return null; + } else { + BlockStateBase blockstatebase = (BlockStateBase) blockState; + int i = blockstatebase.getBlockId(); + + if (i >= 0 && i < blockColormaps.length) { + CustomColormap[] acustomcolormap = blockColormaps[i]; + + if (acustomcolormap == null) { + return null; + } else { + for (int j = 0; j < acustomcolormap.length; ++j) { + CustomColormap customcolormap = acustomcolormap[j]; + + if (customcolormap.matchesBlock(blockstatebase)) { + return customcolormap; + } + } + + return null; + } + } else { + return null; + } + } + } + + private static int getSmoothColorMultiplier(IBlockState blockState, IBlockAccess blockAccess, BlockPos blockPos, CustomColors.IColorizer colorizer, BlockPosM blockPosM) { + int i = 0; + int j = 0; + int k = 0; + int l = blockPos.getX(); + int i1 = blockPos.getY(); + int j1 = blockPos.getZ(); + BlockPosM blockposm = blockPosM; + + for (int k1 = l - 1; k1 <= l + 1; ++k1) { + for (int l1 = j1 - 1; l1 <= j1 + 1; ++l1) { + blockposm.setXyz(k1, i1, l1); + int i2 = colorizer.getColor(blockState, blockAccess, blockposm); + i += i2 >> 16 & 255; + j += i2 >> 8 & 255; + k += i2 & 255; + } + } + + int j2 = i / 9; + int k2 = j / 9; + int l2 = k / 9; + return j2 << 16 | k2 << 8 | l2; + } + + public static int getFluidColor(IBlockAccess blockAccess, IBlockState blockState, BlockPos blockPos, RenderEnv renderEnv) { + Block block = blockState.getBlock(); + CustomColors.IColorizer customcolors$icolorizer = getBlockColormap(blockState); + + if (customcolors$icolorizer == null && blockState.getBlock().getMaterial() == Material.water) { + customcolors$icolorizer = COLORIZER_WATER; + } + + return customcolors$icolorizer == null ? block.colorMultiplier(blockAccess, blockPos, 0) : (Config.isSmoothBiomes() && !customcolors$icolorizer.isColorConstant() ? getSmoothColorMultiplier(blockState, blockAccess, blockPos, customcolors$icolorizer, renderEnv.getColorizerBlockPosM()) : customcolors$icolorizer.getColor(blockState, blockAccess, blockPos)); + } + + public static void updatePortalFX(EntityFX fx) { + if (particlePortalColor >= 0) { + int i = particlePortalColor; + int j = i >> 16 & 255; + int k = i >> 8 & 255; + int l = i & 255; + float f = (float) j / 255.0F; + float f1 = (float) k / 255.0F; + float f2 = (float) l / 255.0F; + fx.setRBGColorF(f, f1, f2); + } + } + + public static void updateMyceliumFX(EntityFX fx) { + if (myceliumParticleColors != null) { + int i = myceliumParticleColors.getColorRandom(); + int j = i >> 16 & 255; + int k = i >> 8 & 255; + int l = i & 255; + float f = (float) j / 255.0F; + float f1 = (float) k / 255.0F; + float f2 = (float) l / 255.0F; + fx.setRBGColorF(f, f1, f2); + } + } + + private static int getRedstoneColor(IBlockState blockState) { + if (redstoneColors == null) { + return -1; + } else { + int i = getRedstoneLevel(blockState, 15); + int j = redstoneColors.getColor(i); + return j; + } + } + + public static void updateReddustFX(EntityFX fx, IBlockAccess blockAccess, double x, double y, double z) { + if (redstoneColors != null) { + IBlockState iblockstate = blockAccess.getBlockState(new BlockPos(x, y, z)); + int i = getRedstoneLevel(iblockstate, 15); + int j = redstoneColors.getColor(i); + int k = j >> 16 & 255; + int l = j >> 8 & 255; + int i1 = j & 255; + float f = (float) k / 255.0F; + float f1 = (float) l / 255.0F; + float f2 = (float) i1 / 255.0F; + fx.setRBGColorF(f, f1, f2); + } + } + + private static int getRedstoneLevel(IBlockState state, int def) { + Block block = state.getBlock(); + + if (!(block instanceof BlockRedstoneWire)) { + return def; + } else { + Object object = state.getValue(BlockRedstoneWire.POWER); + + if (!(object instanceof Integer)) { + return def; + } else { + Integer integer = (Integer) object; + return integer.intValue(); + } + } + } + + public static float getXpOrbTimer(float timer) { + if (xpOrbTime <= 0) { + return timer; + } else { + float f = 628.0F / (float) xpOrbTime; + return timer * f; + } + } + + public static int getXpOrbColor(float timer) { + if (xpOrbColors == null) { + return -1; + } else { + int i = (int) Math.round((double)((MathHelper.sin(timer) + 1.0F) * (float)(xpOrbColors.getLength() - 1)) / 2.0D); + int j = xpOrbColors.getColor(i); + return j; + } + } + + public static int getDurabilityColor(int dur255) { + if (durabilityColors == null) { + return -1; + } else { + int i = dur255 * durabilityColors.getLength() / 255; + int j = durabilityColors.getColor(i); + return j; + } + } + + public static void updateWaterFX(EntityFX fx, IBlockAccess blockAccess, double x, double y, double z, RenderEnv renderEnv) { + if (waterColors != null || blockColormaps != null || particleWaterColor >= 0) { + BlockPos blockpos = new BlockPos(x, y, z); + renderEnv.reset(BLOCK_STATE_WATER, blockpos); + int i = getFluidColor(blockAccess, BLOCK_STATE_WATER, blockpos, renderEnv); + int j = i >> 16 & 255; + int k = i >> 8 & 255; + int l = i & 255; + float f = (float) j / 255.0F; + float f1 = (float) k / 255.0F; + float f2 = (float) l / 255.0F; + + if (particleWaterColor >= 0) { + int i1 = particleWaterColor >> 16 & 255; + int j1 = particleWaterColor >> 8 & 255; + int k1 = particleWaterColor & 255; + f *= (float) i1 / 255.0F; + f1 *= (float) j1 / 255.0F; + f2 *= (float) k1 / 255.0F; + } + + fx.setRBGColorF(f, f1, f2); + } + } + + private static int getLilypadColorMultiplier(IBlockAccess blockAccess, BlockPos blockPos) { + return lilyPadColor < 0 ? Blocks.waterlily.colorMultiplier(blockAccess, blockPos) : lilyPadColor; + } + + private static Vec3 getFogColorNether(Vec3 col) { + return fogColorNether == null ? col : fogColorNether; + } + + private static Vec3 getFogColorEnd(Vec3 col) { + return fogColorEnd == null ? col : fogColorEnd; + } + + private static Vec3 getSkyColorEnd(Vec3 col) { + return skyColorEnd == null ? col : skyColorEnd; + } + + public static Vec3 getSkyColor(Vec3 skyColor3d, IBlockAccess blockAccess, double x, double y, double z) { + if (skyColors == null) { + return skyColor3d; + } else { + int i = skyColors.getColorSmooth(blockAccess, x, y, z, 3); + int j = i >> 16 & 255; + int k = i >> 8 & 255; + int l = i & 255; + float f = (float) j / 255.0F; + float f1 = (float) k / 255.0F; + float f2 = (float) l / 255.0F; + float f3 = (float) skyColor3d.xCoord / 0.5F; + float f4 = (float) skyColor3d.yCoord / 0.66275F; + float f5 = (float) skyColor3d.zCoord; + f = f * f3; + f1 = f1 * f4; + f2 = f2 * f5; + Vec3 vec3 = skyColorFader.getColor((double) f, (double) f1, (double) f2); + return vec3; + } + } + + private static Vec3 getFogColor(Vec3 fogColor3d, IBlockAccess blockAccess, double x, double y, double z) { + if (fogColors == null) { + return fogColor3d; + } else { + int i = fogColors.getColorSmooth(blockAccess, x, y, z, 3); + int j = i >> 16 & 255; + int k = i >> 8 & 255; + int l = i & 255; + float f = (float) j / 255.0F; + float f1 = (float) k / 255.0F; + float f2 = (float) l / 255.0F; + float f3 = (float) fogColor3d.xCoord / 0.753F; + float f4 = (float) fogColor3d.yCoord / 0.8471F; + float f5 = (float) fogColor3d.zCoord; + f = f * f3; + f1 = f1 * f4; + f2 = f2 * f5; + Vec3 vec3 = fogColorFader.getColor((double) f, (double) f1, (double) f2); + return vec3; + } + } + + public static Vec3 getUnderwaterColor(IBlockAccess blockAccess, double x, double y, double z) { + return getUnderFluidColor(blockAccess, x, y, z, underwaterColors, underwaterColorFader); + } + + public static Vec3 getUnderlavaColor(IBlockAccess blockAccess, double x, double y, double z) { + return getUnderFluidColor(blockAccess, x, y, z, underlavaColors, underlavaColorFader); + } + + public static Vec3 getUnderFluidColor(IBlockAccess blockAccess, double x, double y, double z, CustomColormap underFluidColors, CustomColorFader underFluidColorFader) { + if (underFluidColors == null) { + return null; + } else { + int i = underFluidColors.getColorSmooth(blockAccess, x, y, z, 3); + int j = i >> 16 & 255; + int k = i >> 8 & 255; + int l = i & 255; + float f = (float) j / 255.0F; + float f1 = (float) k / 255.0F; + float f2 = (float) l / 255.0F; + Vec3 vec3 = underFluidColorFader.getColor((double) f, (double) f1, (double) f2); + return vec3; + } + } + + private static int getStemColorMultiplier(Block blockStem, IBlockAccess blockAccess, BlockPos blockPos, RenderEnv renderEnv) { + CustomColormap customcolormap = stemColors; + + if (blockStem == Blocks.pumpkin_stem && stemPumpkinColors != null) { + customcolormap = stemPumpkinColors; + } + + if (blockStem == Blocks.melon_stem && stemMelonColors != null) { + customcolormap = stemMelonColors; + } + + if (customcolormap == null) { + return -1; + } else { + int i = renderEnv.getMetadata(); + return customcolormap.getColor(i); + } + } + + public static boolean updateLightmap(World world, float torchFlickerX, int[] lmColors, boolean nightvision, float partialTicks) { + if (world == null) { + return false; + } else if (lightMapPacks == null) { + return false; + } else { + int i = world.provider.getDimensionId(); + int j = i - lightmapMinDimensionId; + + if (j >= 0 && j < lightMapPacks.length) { + LightMapPack lightmappack = lightMapPacks[j]; + return lightmappack == null ? false : lightmappack.updateLightmap(world, torchFlickerX, lmColors, nightvision, partialTicks); + } else { + return false; + } + } + } + + public static Vec3 getWorldFogColor(Vec3 fogVec, World world, Entity renderViewEntity, float partialTicks) { + int i = world.provider.getDimensionId(); + + switch (i) { + case -1: + fogVec = getFogColorNether(fogVec); + break; + + case 0: + Minecraft minecraft = Minecraft.getMinecraft(); + fogVec = getFogColor(fogVec, minecraft.theWorld, renderViewEntity.posX, renderViewEntity.posY + 1.0D, renderViewEntity.posZ); + break; + + case 1: + fogVec = getFogColorEnd(fogVec); + } + + return fogVec; + } + + public static Vec3 getWorldSkyColor(Vec3 skyVec, World world, Entity renderViewEntity, float partialTicks) { + int i = world.provider.getDimensionId(); + + switch (i) { + case 0: + Minecraft minecraft = Minecraft.getMinecraft(); + skyVec = getSkyColor(skyVec, minecraft.theWorld, renderViewEntity.posX, renderViewEntity.posY + 1.0D, renderViewEntity.posZ); + break; + + case 1: + skyVec = getSkyColorEnd(skyVec); + } + + return skyVec; + } + + private static int[] readSpawnEggColors(Properties props, String fileName, String prefix, String logName) { + List < Integer > list = new ArrayList(); + Set set = props.keySet(); + int i = 0; + + for (Object e: set) { + String s = (String) e; + String s1 = props.getProperty(s); + + if (s.startsWith(prefix)) { + String s2 = StrUtils.removePrefix(s, prefix); + int j = EntityUtils.getEntityIdByName(s2); + + if (j < 0) { + warn("Invalid spawn egg name: " + s); + } else { + int k = parseColor(s1); + + if (k < 0) { + warn("Invalid spawn egg color: " + s + " = " + s1); + } else { + while (((List) list).size() <= j) { + list.add(Integer.valueOf(-1)); + } + + list.set(j, Integer.valueOf(k)); + ++i; + } + } + } + } + + if (i <= 0) { + return null; + } else { + dbg(logName + " colors: " + i); + int[] aint = new int[list.size()]; + + for (int l = 0; l < aint.length; ++l) { + aint[l] = ((Integer) list.get(l)).intValue(); + } + + return aint; + } + } + + private static int getSpawnEggColor(ItemMonsterPlacer item, ItemStack itemStack, int layer, int color) { + int i = itemStack.getMetadata(); + int[] aint = layer == 0 ? spawnEggPrimaryColors : spawnEggSecondaryColors; + + if (aint == null) { + return color; + } else if (i >= 0 && i < aint.length) { + int j = aint[i]; + return j < 0 ? color : j; + } else { + return color; + } + } + + public static int getColorFromItemStack(ItemStack itemStack, int layer, int color) { + if (itemStack == null) { + return color; + } else { + Item item = itemStack.getItem(); + return item == null ? color : (item instanceof ItemMonsterPlacer ? getSpawnEggColor((ItemMonsterPlacer) item, itemStack, layer, color) : color); + } + } + + private static float[][] readDyeColors(Properties props, String fileName, String prefix, String logName) { + EnumDyeColor[] aenumdyecolor = EnumDyeColor.values(); + Map < String, EnumDyeColor > map = new HashMap(); + + for (int i = 0; i < aenumdyecolor.length; ++i) { + EnumDyeColor enumdyecolor = aenumdyecolor[i]; + map.put(enumdyecolor.getName(), enumdyecolor); + } + + float[][] afloat1 = new float[aenumdyecolor.length][]; + int k = 0; + + for (Object e: props.keySet()) { + String s = (String) e; + String s1 = props.getProperty(s); + + if (s.startsWith(prefix)) { + String s2 = StrUtils.removePrefix(s, prefix); + + if (s2.equals("lightBlue")) { + s2 = "light_blue"; + } + + EnumDyeColor enumdyecolor1 = (EnumDyeColor) map.get(s2); + int j = parseColor(s1); + + if (enumdyecolor1 != null && j >= 0) { + float[] afloat = new float[] { + (float)(j >> 16 & 255) / 255.0F, (float)(j >> 8 & 255) / 255.0F, (float)(j & 255) / 255.0F + }; + afloat1[enumdyecolor1.ordinal()] = afloat; + ++k; + } else { + warn("Invalid color: " + s + " = " + s1); + } + } + } + + if (k <= 0) { + return (float[][]) null; + } else { + dbg(logName + " colors: " + k); + return afloat1; + } + } + + private static float[] getDyeColors(EnumDyeColor dye, float[][] dyeColors, float[] colors) { + if (dyeColors == null) { + return colors; + } else if (dye == null) { + return colors; + } else { + float[] afloat = dyeColors[dye.ordinal()]; + return afloat == null ? colors : afloat; + } + } + + public static float[] getWolfCollarColors(EnumDyeColor dye, float[] colors) { + return getDyeColors(dye, wolfCollarColors, colors); + } + + public static float[] getSheepColors(EnumDyeColor dye, float[] colors) { + return getDyeColors(dye, sheepColors, colors); + } + + private static int[] readTextColors(Properties props, String fileName, String prefix, String logName) { + int[] aint = new int[32]; + Arrays.fill((int[]) aint, (int) - 1); + int i = 0; + + for (Object e: props.keySet()) { + String s = (String) e; + String s1 = props.getProperty(s); + + if (s.startsWith(prefix)) { + String s2 = StrUtils.removePrefix(s, prefix); + int j = Config.parseInt(s2, -1); + int k = parseColor(s1); + + if (j >= 0 && j < aint.length && k >= 0) { + aint[j] = k; + ++i; + } else { + warn("Invalid color: " + s + " = " + s1); + } + } + } + + if (i <= 0) { + return null; + } else { + dbg(logName + " colors: " + i); + return aint; + } + } + + public static int getTextColor(int index, int color) { + if (textColors == null) { + return color; + } else if (index >= 0 && index < textColors.length) { + int i = textColors[index]; + return i < 0 ? color : i; + } else { + return color; + } + } + + private static int[] readMapColors(Properties props, String fileName, String prefix, String logName) { + int[] aint = new int[MapColor.mapColorArray.length]; + Arrays.fill((int[]) aint, (int) - 1); + int i = 0; + + for (Object o: props.keySet()) { + String s = (String) o; + String s1 = props.getProperty(s); + + if (s.startsWith(prefix)) { + String s2 = StrUtils.removePrefix(s, prefix); + int j = getMapColorIndex(s2); + int k = parseColor(s1); + + if (j >= 0 && j < aint.length && k >= 0) { + aint[j] = k; + ++i; + } else { + warn("Invalid color: " + s + " = " + s1); + } + } + } + + if (i <= 0) { + return null; + } else { + dbg(logName + " colors: " + i); + return aint; + } + } + + private static int[] readPotionColors(Properties props, String fileName, String prefix, String logName) { + int[] aint = new int[Potion.potionTypes.length]; + Arrays.fill((int[]) aint, (int) - 1); + int i = 0; + + for (Object e: props.keySet()) { + String s = (String) e; + String s1 = props.getProperty(s); + + if (s.startsWith(prefix)) { + int j = getPotionId(s); + int k = parseColor(s1); + + if (j >= 0 && j < aint.length && k >= 0) { + aint[j] = k; + ++i; + } else { + warn("Invalid color: " + s + " = " + s1); + } + } + } + + if (i <= 0) { + return null; + } else { + dbg(logName + " colors: " + i); + return aint; + } + } + + private static int getPotionId(String name) { + if (name.equals("potion.water")) { + return 0; + } else { + Potion[] apotion = Potion.potionTypes; + + for (int i = 0; i < apotion.length; ++i) { + Potion potion = apotion[i]; + + if (potion != null && potion.getName().equals(name)) { + return potion.getId(); + } + } + + return -1; + } + } + + public static int getPotionColor(int potionId, int color) { + if (potionColors == null) { + return color; + } else if (potionId >= 0 && potionId < potionColors.length) { + int i = potionColors[potionId]; + return i < 0 ? color : i; + } else { + return color; + } + } + + private static int getMapColorIndex(String name) { + return name == null ? -1 : (name.equals("air") ? MapColor.airColor.colorIndex : (name.equals("grass") ? MapColor.grassColor.colorIndex : (name.equals("sand") ? MapColor.sandColor.colorIndex : (name.equals("cloth") ? MapColor.clothColor.colorIndex : (name.equals("tnt") ? MapColor.tntColor.colorIndex : (name.equals("ice") ? MapColor.iceColor.colorIndex : (name.equals("iron") ? MapColor.ironColor.colorIndex : (name.equals("foliage") ? MapColor.foliageColor.colorIndex : (name.equals("clay") ? MapColor.clayColor.colorIndex : (name.equals("dirt") ? MapColor.dirtColor.colorIndex : (name.equals("stone") ? MapColor.stoneColor.colorIndex : (name.equals("water") ? MapColor.waterColor.colorIndex : (name.equals("wood") ? MapColor.woodColor.colorIndex : (name.equals("quartz") ? MapColor.quartzColor.colorIndex : (name.equals("gold") ? MapColor.goldColor.colorIndex : (name.equals("diamond") ? MapColor.diamondColor.colorIndex : (name.equals("lapis") ? MapColor.lapisColor.colorIndex : (name.equals("emerald") ? MapColor.emeraldColor.colorIndex : (name.equals("podzol") ? MapColor.obsidianColor.colorIndex : (name.equals("netherrack") ? MapColor.netherrackColor.colorIndex : (!name.equals("snow") && !name.equals("white") ? (!name.equals("adobe") && !name.equals("orange") ? (name.equals("magenta") ? MapColor.magentaColor.colorIndex : (!name.equals("light_blue") && !name.equals("lightBlue") ? (name.equals("yellow") ? MapColor.yellowColor.colorIndex : (name.equals("lime") ? MapColor.limeColor.colorIndex : (name.equals("pink") ? MapColor.pinkColor.colorIndex : (name.equals("gray") ? MapColor.grayColor.colorIndex : (name.equals("silver") ? MapColor.silverColor.colorIndex : (name.equals("cyan") ? MapColor.cyanColor.colorIndex : (name.equals("purple") ? MapColor.purpleColor.colorIndex : (name.equals("blue") ? MapColor.blueColor.colorIndex : (name.equals("brown") ? MapColor.brownColor.colorIndex : (name.equals("green") ? MapColor.greenColor.colorIndex : (name.equals("red") ? MapColor.redColor.colorIndex : (name.equals("black") ? MapColor.blackColor.colorIndex : -1)))))))))))) : MapColor.lightBlueColor.colorIndex)) : MapColor.adobeColor.colorIndex) : MapColor.snowColor.colorIndex))))))))))))))))))))); + } + + private static int[] getMapColors() { + MapColor[] amapcolor = MapColor.mapColorArray; + int[] aint = new int[amapcolor.length]; + Arrays.fill((int[]) aint, (int) - 1); + + for (int i = 0; i < amapcolor.length && i < aint.length; ++i) { + MapColor mapcolor = amapcolor[i]; + + if (mapcolor != null) { + aint[i] = mapcolor.colorValue; + } + } + + return aint; + } + + private static void setMapColors(int[] colors) { + if (colors != null) { + MapColor[] amapcolor = MapColor.mapColorArray; + boolean flag = false; + + for (int i = 0; i < amapcolor.length && i < colors.length; ++i) { + MapColor mapcolor = amapcolor[i]; + + if (mapcolor != null) { + int j = colors[i]; + + if (j >= 0 && mapcolor.colorValue != j) { + mapcolor.colorValue = j; + flag = true; + } + } + } + + if (flag) { + Minecraft.getMinecraft().getTextureManager().reloadBannerTextures(); + } + } + } + + private static void dbg(String str) { + Config.dbg("CustomColors: " + str); + } + + private static void warn(String str) { + Config.warn("CustomColors: " + str); + } + + public static int getExpBarTextColor(int color) { + return expBarTextColor < 0 ? color : expBarTextColor; + } + + public static int getBossTextColor(int color) { + return bossTextColor < 0 ? color : bossTextColor; + } + + public static int getSignTextColor(int color) { + return signTextColor < 0 ? color : signTextColor; + } + + public interface IColorizer { + int getColor(IBlockState var1, IBlockAccess var2, BlockPos var3); + + boolean isColorConstant(); + } +} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/shadow/EntityUtils.java b/src/main/java/net/PeytonPlayz585/shadow/EntityUtils.java new file mode 100644 index 0000000..cc6e168 --- /dev/null +++ b/src/main/java/net/PeytonPlayz585/shadow/EntityUtils.java @@ -0,0 +1,59 @@ +package net.PeytonPlayz585.shadow; + +import java.util.HashMap; +import java.util.Map; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityList; + +public class EntityUtils { + private static final Map < Class, Integer > mapIdByClass = new HashMap(); + private static final Map < String, Integer > mapIdByName = new HashMap(); + private static final Map < String, Class > mapClassByName = new HashMap(); + + public static int getEntityIdByClass(Entity entity) { + return entity == null ? -1 : getEntityIdByClass(entity.getClass()); + } + + public static int getEntityIdByClass(Class cls) { + Integer integer = (Integer) mapIdByClass.get(cls); + return integer == null ? -1 : integer.intValue(); + } + + public static int getEntityIdByName(String name) { + Integer integer = (Integer) mapIdByName.get(name); + return integer == null ? -1 : integer.intValue(); + } + + public static Class getEntityClassByName(String name) { + Class oclass = (Class) mapClassByName.get(name); + return oclass; + } + + static { + for (int i = 0; i < 1000; ++i) { + Class oclass = EntityList.getClassFromID(i); + + if (oclass != null) { + String s = EntityList.getStringFromID(i); + + if (s != null) { + if (mapIdByClass.containsKey(oclass)) { + Config.warn("Duplicate entity class: " + oclass + ", id1: " + mapIdByClass.get(oclass) + ", id2: " + i); + } + + if (mapIdByName.containsKey(s)) { + Config.warn("Duplicate entity name: " + s + ", id1: " + mapIdByName.get(s) + ", id2: " + i); + } + + if (mapClassByName.containsKey(s)) { + Config.warn("Duplicate entity name: " + s + ", class1: " + mapClassByName.get(s) + ", class2: " + oclass); + } + + mapIdByClass.put(oclass, Integer.valueOf(i)); + mapIdByName.put(s, Integer.valueOf(i)); + mapClassByName.put(s, oclass); + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/shadow/GuiQualitySettingsOF.java b/src/main/java/net/PeytonPlayz585/shadow/GuiQualitySettingsOF.java index 566a4eb..ffce4d5 100644 --- a/src/main/java/net/PeytonPlayz585/shadow/GuiQualitySettingsOF.java +++ b/src/main/java/net/PeytonPlayz585/shadow/GuiQualitySettingsOF.java @@ -11,8 +11,7 @@ public class GuiQualitySettingsOF extends GuiScreen { private GuiScreen prevScreen; protected String title; private GameSettings settings; - private static GameSettings.Options[] enumOptions = new GameSettings.Options[] {GameSettings.Options.MIPMAP_LEVELS, GameSettings.Options.MIPMAP_TYPE, GameSettings.Options.AF_LEVEL, GameSettings.Options.FXAA, GameSettings.Options.CLEAR_WATER, GameSettings.Options.BETTER_GRASS, GameSettings.Options.BETTER_SNOW, GameSettings.Options.CUSTOM_FONTS, GameSettings.Options.CUSTOM_SKY, GameSettings.Options.CUSTOM_ITEMS, GameSettings.Options.DYNAMIC_LIGHTS}; - //private static GameSettings.Options[] enumOptions = new GameSettings.Options[] {GameSettings.Options.MIPMAP_LEVELS, GameSettings.Options.MIPMAP_TYPE, GameSettings.Options.AF_LEVEL, GameSettings.Options.AA_LEVEL, GameSettings.Options.CLEAR_WATER, GameSettings.Options.RANDOM_MOBS, GameSettings.Options.BETTER_GRASS, GameSettings.Options.BETTER_SNOW, GameSettings.Options.CUSTOM_FONTS, GameSettings.Options.CUSTOM_COLORS, GameSettings.Options.SWAMP_COLORS, GameSettings.Options.SMOOTH_BIOMES, GameSettings.Options.CONNECTED_TEXTURES, GameSettings.Options.NATURAL_TEXTURES, GameSettings.Options.CUSTOM_SKY, GameSettings.Options.CUSTOM_ITEMS, GameSettings.Options.DYNAMIC_LIGHTS}; + private static GameSettings.Options[] enumOptions = new GameSettings.Options[] {GameSettings.Options.MIPMAP_LEVELS, GameSettings.Options.MIPMAP_TYPE, GameSettings.Options.AF_LEVEL, GameSettings.Options.FXAA, GameSettings.Options.CLEAR_WATER, GameSettings.Options.RANDOM_MOBS, GameSettings.Options.BETTER_GRASS, GameSettings.Options.BETTER_SNOW, GameSettings.Options.CUSTOM_FONTS, GameSettings.Options.CUSTOM_COLORS, GameSettings.Options.SWAMP_COLORS, GameSettings.Options.SMOOTH_BIOMES, /*GameSettings.Options.CONNECTED_TEXTURES, GameSettings.Options.NATURAL_TEXTURES,*/ GameSettings.Options.CUSTOM_SKY, GameSettings.Options.CUSTOM_ITEMS, GameSettings.Options.DYNAMIC_LIGHTS}; public GuiQualitySettingsOF(GuiScreen p_i53_1_, GameSettings p_i53_2_) { this.prevScreen = p_i53_1_; diff --git a/src/main/java/net/PeytonPlayz585/shadow/LightMap.java b/src/main/java/net/PeytonPlayz585/shadow/LightMap.java new file mode 100644 index 0000000..b59d71e --- /dev/null +++ b/src/main/java/net/PeytonPlayz585/shadow/LightMap.java @@ -0,0 +1,119 @@ +package net.PeytonPlayz585.shadow; + +import net.minecraft.world.World; + +public class LightMap { + private CustomColormap lightMapRgb = null; + private float[][] sunRgbs = new float[16][3]; + private float[][] torchRgbs = new float[16][3]; + + public LightMap(CustomColormap lightMapRgb) { + this.lightMapRgb = lightMapRgb; + } + + public CustomColormap getColormap() { + return this.lightMapRgb; + } + + public boolean updateLightmap(World world, float torchFlickerX, int[] lmColors, boolean nightvision) { + if (this.lightMapRgb == null) { + return false; + } else { + int i = this.lightMapRgb.getHeight(); + + if (nightvision && i < 64) { + return false; + } else { + int j = this.lightMapRgb.getWidth(); + + if (j < 16) { + warn("Invalid lightmap width: " + j); + this.lightMapRgb = null; + return false; + } else { + int k = 0; + + if (nightvision) { + k = j * 16 * 2; + } + + float f = 1.1666666F * (world.getSunBrightness(1.0F) - 0.2F); + + if (world.getLastLightningBolt() > 0) { + f = 1.0F; + } + + f = Config.limitTo1(f); + float f1 = f * (float)(j - 1); + float f2 = Config.limitTo1(torchFlickerX + 0.5F) * (float)(j - 1); + float f3 = Config.limitTo1(Config.getGameSettings().saturation); + boolean flag = f3 > 1.0E-4F; + float[][] afloat = this.lightMapRgb.getColorsRgb(); + this.getLightMapColumn(afloat, f1, k, j, this.sunRgbs); + this.getLightMapColumn(afloat, f2, k + 16 * j, j, this.torchRgbs); + float[] afloat1 = new float[3]; + + for (int l = 0; l < 16; ++l) { + for (int i1 = 0; i1 < 16; ++i1) { + for (int j1 = 0; j1 < 3; ++j1) { + float f4 = Config.limitTo1(this.sunRgbs[l][j1] + this.torchRgbs[i1][j1]); + + if (flag) { + float f5 = 1.0F - f4; + f5 = 1.0F - f5 * f5 * f5 * f5; + f4 = f3 * f5 + (1.0F - f3) * f4; + } + + afloat1[j1] = f4; + } + + int k1 = (int)(afloat1[0] * 255.0F); + int l1 = (int)(afloat1[1] * 255.0F); + int i2 = (int)(afloat1[2] * 255.0F); + lmColors[l * 16 + i1] = -16777216 | k1 << 16 | l1 << 8 | i2; + } + } + + return true; + } + } + } + } + + private void getLightMapColumn(float[][] origMap, float x, int offset, int width, float[][] colRgb) { + int i = (int) Math.floor((double) x); + int j = (int) Math.ceil((double) x); + + if (i == j) { + for (int i1 = 0; i1 < 16; ++i1) { + float[] afloat3 = origMap[offset + i1 * width + i]; + float[] afloat4 = colRgb[i1]; + + for (int j1 = 0; j1 < 3; ++j1) { + afloat4[j1] = afloat3[j1]; + } + } + } else { + float f = 1.0F - (x - (float) i); + float f1 = 1.0F - ((float) j - x); + + for (int k = 0; k < 16; ++k) { + float[] afloat = origMap[offset + k * width + i]; + float[] afloat1 = origMap[offset + k * width + j]; + float[] afloat2 = colRgb[k]; + + for (int l = 0; l < 3; ++l) { + afloat2[l] = afloat[l] * f + afloat1[l] * f1; + } + } + } + } + + private static void dbg(String str) { + Config.dbg("CustomColors: " + str); + } + + private static void warn(String str) { + Config.warn("CustomColors: " + str); + } +} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/shadow/LightMapPack.java b/src/main/java/net/PeytonPlayz585/shadow/LightMapPack.java new file mode 100644 index 0000000..5dac2c8 --- /dev/null +++ b/src/main/java/net/PeytonPlayz585/shadow/LightMapPack.java @@ -0,0 +1,136 @@ +package net.PeytonPlayz585.shadow; + +import net.minecraft.world.World; + +public class LightMapPack { + private LightMap lightMap; + private LightMap lightMapRain; + private LightMap lightMapThunder; + private int[] colorBuffer1 = new int[0]; + private int[] colorBuffer2 = new int[0]; + + public LightMapPack(LightMap lightMap, LightMap lightMapRain, LightMap lightMapThunder) { + if (lightMapRain != null || lightMapThunder != null) { + if (lightMapRain == null) { + lightMapRain = lightMap; + } + + if (lightMapThunder == null) { + lightMapThunder = lightMapRain; + } + } + + this.lightMap = lightMap; + this.lightMapRain = lightMapRain; + this.lightMapThunder = lightMapThunder; + } + + public boolean updateLightmap(World world, float torchFlickerX, int[] lmColors, boolean nightvision, float partialTicks) { + if (this.lightMapRain == null && this.lightMapThunder == null) { + return this.lightMap.updateLightmap(world, torchFlickerX, lmColors, nightvision); + } else { + int i = world.provider.getDimensionId(); + + if (i != 1 && i != -1) { + float f = world.getRainStrength(partialTicks); + float f1 = world.getThunderStrength(partialTicks); + float f2 = 1.0E-4F; + boolean flag = f > f2; + boolean flag1 = f1 > f2; + + if (!flag && !flag1) { + return this.lightMap.updateLightmap(world, torchFlickerX, lmColors, nightvision); + } else { + if (f > 0.0F) { + f1 /= f; + } + + float f3 = 1.0F - f; + float f4 = f - f1; + + if (this.colorBuffer1.length != lmColors.length) { + this.colorBuffer1 = new int[lmColors.length]; + this.colorBuffer2 = new int[lmColors.length]; + } + + int j = 0; + int[][] aint = new int[][] { + lmColors, + this.colorBuffer1, + this.colorBuffer2 + }; + float[] afloat = new float[3]; + + if (f3 > f2 && this.lightMap.updateLightmap(world, torchFlickerX, aint[j], nightvision)) { + afloat[j] = f3; + ++j; + } + + if (f4 > f2 && this.lightMapRain != null && this.lightMapRain.updateLightmap(world, torchFlickerX, aint[j], nightvision)) { + afloat[j] = f4; + ++j; + } + + if (f1 > f2 && this.lightMapThunder != null && this.lightMapThunder.updateLightmap(world, torchFlickerX, aint[j], nightvision)) { + afloat[j] = f1; + ++j; + } + + return j == 2 ? this.blend(aint[0], afloat[0], aint[1], afloat[1]) : (j == 3 ? this.blend(aint[0], afloat[0], aint[1], afloat[1], aint[2], afloat[2]) : true); + } + } else { + return this.lightMap.updateLightmap(world, torchFlickerX, lmColors, nightvision); + } + } + } + + private boolean blend(int[] cols0, float br0, int[] cols1, float br1) { + if (cols1.length != cols0.length) { + return false; + } else { + for (int i = 0; i < cols0.length; ++i) { + int j = cols0[i]; + int k = j >> 16 & 255; + int l = j >> 8 & 255; + int i1 = j & 255; + int j1 = cols1[i]; + int k1 = j1 >> 16 & 255; + int l1 = j1 >> 8 & 255; + int i2 = j1 & 255; + int j2 = (int)((float) k * br0 + (float) k1 * br1); + int k2 = (int)((float) l * br0 + (float) l1 * br1); + int l2 = (int)((float) i1 * br0 + (float) i2 * br1); + cols0[i] = -16777216 | j2 << 16 | k2 << 8 | l2; + } + + return true; + } + } + + private boolean blend(int[] cols0, float br0, int[] cols1, float br1, int[] cols2, float br2) { + if (cols1.length == cols0.length && cols2.length == cols0.length) { + for (int i = 0; i < cols0.length; ++i) { + int j = cols0[i]; + int k = j >> 16 & 255; + int l = j >> 8 & 255; + int i1 = j & 255; + int j1 = cols1[i]; + int k1 = j1 >> 16 & 255; + int l1 = j1 >> 8 & 255; + int i2 = j1 & 255; + int j2 = cols2[i]; + int k2 = j2 >> 16 & 255; + int l2 = j2 >> 8 & 255; + int i3 = j2 & 255; + int j3 = (int)((float) k * br0 + (float) k1 * br1 + (float) k2 * br2); + int k3 = (int)((float) l * br0 + (float) l1 * br1 + (float) l2 * br2); + int l3 = (int)((float) i1 * br0 + (float) i2 * br1 + (float) i3 * br2); + cols0[i] = -16777216 | j3 << 16 | k3 << 8 | l3; + } + + return true; + } else { + return false; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/shadow/RenderEnv.java b/src/main/java/net/PeytonPlayz585/shadow/RenderEnv.java index 47c5ed7..bf6e2ae 100644 --- a/src/main/java/net/PeytonPlayz585/shadow/RenderEnv.java +++ b/src/main/java/net/PeytonPlayz585/shadow/RenderEnv.java @@ -14,7 +14,6 @@ import net.minecraft.util.EnumFacing; import net.minecraft.world.IBlockAccess; public class RenderEnv { - private IBlockAccess blockAccess; private IBlockState blockState; private BlockPos blockPos; private GameSettings gameSettings; @@ -29,7 +28,6 @@ public class RenderEnv { private static ThreadLocal threadLocalInstance = new ThreadLocal(); private RenderEnv(IBlockAccess p_i94_1_, IBlockState p_i94_2_, BlockPos p_i94_3_) { - this.blockAccess = p_i94_1_; this.blockState = p_i94_2_; this.blockPos = p_i94_3_; this.gameSettings = Config.getGameSettings(); @@ -47,9 +45,19 @@ public class RenderEnv { return renderenv; } } + + public void reset(IBlockState blockStateIn, BlockPos blockPosIn) { + if (this.blockState != blockStateIn || this.blockPos != blockPosIn) { + this.blockState = blockStateIn; + this.blockPos = blockPosIn; + this.blockId = -1; + this.metadata = -1; + this.breakingAnimation = -1; + this.boundsFlags.clear(); + } + } private void reset(IBlockAccess p_reset_1_, IBlockState p_reset_2_, BlockPos p_reset_3_) { - this.blockAccess = p_reset_1_; this.blockState = p_reset_2_; this.blockPos = p_reset_3_; this.blockId = -1; diff --git a/src/main/java/net/PeytonPlayz585/shadow/apache/ImmutablePair.java b/src/main/java/net/PeytonPlayz585/shadow/apache/ImmutablePair.java new file mode 100644 index 0000000..010036c --- /dev/null +++ b/src/main/java/net/PeytonPlayz585/shadow/apache/ImmutablePair.java @@ -0,0 +1,214 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.PeytonPlayz585.shadow.apache; + +import java.util.Map; +import java.util.Objects; + +/** + * An immutable pair consisting of two {@link Object} elements. + * + *

Although the implementation is immutable, there is no restriction on the objects + * that may be stored. If mutable objects are stored in the pair, then the pair + * itself effectively becomes mutable.

+ * + *

#ThreadSafe# if both paired objects are thread-safe

+ * + * @param the left element type + * @param the right element type + * + * @since 3.0 + */ +public class ImmutablePair extends Pair { + + /** + * An empty array. + *

+ * Consider using {@link #emptyArray()} to avoid generics warnings. + *

+ * + * @since 3.10. + */ + public static final ImmutablePair[] EMPTY_ARRAY = {}; + + /** + * An immutable pair of nulls. + */ + // This is not defined with generics to avoid warnings in call sites. + @SuppressWarnings("rawtypes") + private static final ImmutablePair NULL = new ImmutablePair<>(null, null); + + /** Serialization version */ + private static final long serialVersionUID = 4954918890077093841L; + + /** + * Returns the empty array singleton that can be assigned without compiler warning. + * + * @param the left element type + * @param the right element type + * @return the empty array singleton that can be assigned without compiler warning. + * + * @since 3.10. + */ + @SuppressWarnings("unchecked") + public static ImmutablePair[] emptyArray() { + return (ImmutablePair[]) EMPTY_ARRAY; + } + + /** + * Creates an immutable pair of two objects inferring the generic types. + * + *

This factory allows the pair to be created using inference to + * obtain the generic types.

+ * + * @param the left element type + * @param the right element type + * @param left the left element, may be null + * @return a pair formed from the two parameters, not null + * @since 3.11 + */ + public static Pair left(final L left) { + return ImmutablePair.of(left, null); + } + + /** + * Returns an immutable pair of nulls. + * + * @param the left element of this pair. Value is {@code null}. + * @param the right element of this pair. Value is {@code null}. + * @return an immutable pair of nulls. + * @since 3.6 + */ + @SuppressWarnings("unchecked") + public static ImmutablePair nullPair() { + return NULL; + } + + /** + * Creates an immutable pair of two objects inferring the generic types. + * + *

This factory allows the pair to be created using inference to + * obtain the generic types.

+ * + * @param the left element type + * @param the right element type + * @param left the left element, may be null + * @param right the right element, may be null + * @return a pair formed from the two parameters, not null + */ + public static ImmutablePair of(final L left, final R right) { + return left != null || right != null ? new ImmutablePair<>(left, right) : nullPair(); + } + + /** + * Creates an immutable pair from a map entry. + * + *

This factory allows the pair to be created using inference to + * obtain the generic types.

+ * + * @param the left element type + * @param the right element type + * @param pair the existing map entry. + * @return a pair formed from the map entry + * @since 3.10 + */ + public static ImmutablePair of(final Map.Entry pair) { + return pair != null ? new ImmutablePair<>(pair.getKey(), pair.getValue()) : nullPair(); + } + + /** + * Creates an immutable pair of two non-null objects inferring the generic types. + * + *

This factory allows the pair to be created using inference to + * obtain the generic types.

+ * + * @param the left element type + * @param the right element type + * @param left the left element, may not be null + * @param right the right element, may not be null + * @return a pair formed from the two parameters, not null + * @throws NullPointerException if any input is null + * @since 3.13.0 + */ + public static ImmutablePair ofNonNull(final L left, final R right) { + return of(Objects.requireNonNull(left, "left"), Objects.requireNonNull(right, "right")); + } + + /** + * Creates an immutable pair of two objects inferring the generic types. + * + *

This factory allows the pair to be created using inference to + * obtain the generic types.

+ * + * @param the left element type + * @param the right element type + * @param right the right element, may be null + * @return a pair formed from the two parameters, not null + * @since 3.11 + */ + public static Pair right(final R right) { + return ImmutablePair.of(null, right); + } + + /** Left object */ + public final L left; + + /** Right object */ + public final R right; + + /** + * Create a new pair instance. + * + * @param left the left value, may be null + * @param right the right value, may be null + */ + public ImmutablePair(final L left, final R right) { + this.left = left; + this.right = right; + } + + /** + * {@inheritDoc} + */ + @Override + public L getLeft() { + return left; + } + + /** + * {@inheritDoc} + */ + @Override + public R getRight() { + return right; + } + + /** + * Throws {@link UnsupportedOperationException}. + * + *

This pair is immutable, so this operation is not supported.

+ * + * @param value the value to set + * @return never + * @throws UnsupportedOperationException as this operation is not supported + */ + @Override + public R setValue(final R value) { + throw new UnsupportedOperationException(); + } + +} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/shadow/apache/Pair.java b/src/main/java/net/PeytonPlayz585/shadow/apache/Pair.java new file mode 100644 index 0000000..938ab14 --- /dev/null +++ b/src/main/java/net/PeytonPlayz585/shadow/apache/Pair.java @@ -0,0 +1,247 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.PeytonPlayz585.shadow.apache; + +import java.io.Serializable; +import java.util.Map; +import java.util.Objects; + +import org.apache.commons.lang3.function.FailableBiConsumer; +import org.apache.commons.lang3.function.FailableBiFunction; + +/** + * A pair consisting of two elements. + * + *

This class is an abstract implementation defining the basic API. + * It refers to the elements as 'left' and 'right'. It also implements the + * {@code Map.Entry} interface where the key is 'left' and the value is 'right'.

+ * + *

Subclass implementations may be mutable or immutable. + * However, there is no restriction on the type of the stored objects that may be stored. + * If mutable objects are stored in the pair, then the pair itself effectively becomes mutable.

+ * + * @param the left element type + * @param the right element type + * + * @since 3.0 + */ +public abstract class Pair implements Map.Entry, Serializable { + + /** Serialization version */ + private static final long serialVersionUID = 4954918890077093841L; + + /** + * An empty array. + *

+ * Consider using {@link #emptyArray()} to avoid generics warnings. + *

+ * + * @since 3.10. + */ + public static final Pair[] EMPTY_ARRAY = {}; + + /** + * Returns the empty array singleton that can be assigned without compiler warning. + * + * @param the left element type + * @param the right element type + * @return the empty array singleton that can be assigned without compiler warning. + * + * @since 3.10. + */ + @SuppressWarnings("unchecked") + public static Pair[] emptyArray() { + return (Pair[]) EMPTY_ARRAY; + } + + /** + * Creates an immutable pair of two objects inferring the generic types. + * + *

This factory allows the pair to be created using inference to + * obtain the generic types.

+ * + * @param the left element type + * @param the right element type + * @param left the left element, may be null + * @param right the right element, may be null + * @return a pair formed from the two parameters, not null + */ + public static Pair of(final L left, final R right) { + return ImmutablePair.of(left, right); + } + + /** + * Creates an immutable pair from a map entry. + * + *

This factory allows the pair to be created using inference to + * obtain the generic types.

+ * + * @param the left element type + * @param the right element type + * @param pair the map entry. + * @return a pair formed from the map entry + * @since 3.10 + */ + public static Pair of(final Map.Entry pair) { + return ImmutablePair.of(pair); + } + + /** + * Creates an immutable pair of two non-null objects inferring the generic types. + * + *

This factory allows the pair to be created using inference to + * obtain the generic types.

+ * + * @param the left element type + * @param the right element type + * @param left the left element, may not be null + * @param right the right element, may not be null + * @return a pair formed from the two parameters, not null + * @throws NullPointerException if any input is null + * @since 3.13.0 + */ + public static Pair ofNonNull(final L left, final R right) { + return ImmutablePair.ofNonNull(left, right); + } + + /** + * Accepts this key and value as arguments to the given consumer. + * + * @param The kind of thrown exception or error. + * @param consumer the consumer to call. + * @throws E Thrown when the consumer fails. + * @since 3.13.0 + */ + public void accept(final FailableBiConsumer consumer) throws E { + consumer.accept(getKey(), getValue()); + } + + /** + * Applies this key and value as arguments to the given function. + * + * @param The function return type. + * @param The kind of thrown exception or error. + * @param function the consumer to call. + * @return the function's return value. + * @throws E Thrown when the consumer fails. + * @since 3.13.0 + */ + public V apply(final FailableBiFunction function) throws E { + return function.apply(getKey(), getValue()); + } + + /** + * Compares this pair to another based on the two elements. + * + * @param obj the object to compare to, null returns false + * @return true if the elements of the pair are equal + */ + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (obj instanceof Map.Entry) { + final Map.Entry other = (Map.Entry) obj; + return Objects.equals(getKey(), other.getKey()) + && Objects.equals(getValue(), other.getValue()); + } + return false; + } + + /** + * Gets the key from this pair. + * + *

This method implements the {@code Map.Entry} interface returning the + * left element as the key.

+ * + * @return the left element as the key, may be null + */ + @Override + public final L getKey() { + return getLeft(); + } + + /** + * Gets the left element from this pair. + * + *

When treated as a key-value pair, this is the key.

+ * + * @return the left element, may be null + */ + public abstract L getLeft(); + + /** + * Gets the right element from this pair. + * + *

When treated as a key-value pair, this is the value.

+ * + * @return the right element, may be null + */ + public abstract R getRight(); + + /** + * Gets the value from this pair. + * + *

This method implements the {@code Map.Entry} interface returning the + * right element as the value.

+ * + * @return the right element as the value, may be null + */ + @Override + public R getValue() { + return getRight(); + } + + /** + * Returns a suitable hash code. + * The hash code follows the definition in {@code Map.Entry}. + * + * @return the hash code + */ + @Override + public int hashCode() { + // see Map.Entry API specification + return Objects.hashCode(getKey()) ^ Objects.hashCode(getValue()); + } + + /** + * Returns a String representation of this pair using the format {@code ($left,$right)}. + * + * @return a string describing this object, not null + */ + @Override + public String toString() { + return "(" + getLeft() + ',' + getRight() + ')'; + } + + /** + * Formats the receiver using the given format. + * + *

This uses {@link java.util.Formattable} to perform the formatting. Two variables may + * be used to embed the left and right elements. Use {@code %1$s} for the left + * element (key) and {@code %2$s} for the right element (value). + * The default format used by {@code toString()} is {@code (%1$s,%2$s)}.

+ * + * @param format the format string, optionally containing {@code %1$s} and {@code %2$s}, not null + * @return the formatted string, not null + */ + public String toString(final String format) { + return String.format(format, getLeft(), getRight()); + } + +} \ No newline at end of file diff --git a/src/main/java/net/lax1dude/eaglercraft/v1_8/IOUtils.java b/src/main/java/net/lax1dude/eaglercraft/v1_8/IOUtils.java index d9a2fb4..94084bd 100644 --- a/src/main/java/net/lax1dude/eaglercraft/v1_8/IOUtils.java +++ b/src/main/java/net/lax1dude/eaglercraft/v1_8/IOUtils.java @@ -70,6 +70,25 @@ public class IOUtils { } } } + + public static String inputStreamToString(InputStream is, Charset c, boolean b1) throws IOException { + if(is instanceof EaglerInputStream) { + return new String(((EaglerInputStream)is).getAsArray(), c); + }else { + try { + StringBuilder b = new StringBuilder(); + BufferedReader rd = new BufferedReader(new InputStreamReader(is, c)); + String s; + while((s = rd.readLine()) != null) { + b.append(s).append('\n'); + } + return b.toString(); + } catch(Exception e) { + e.printStackTrace(); + return null; + } + } + } public static int readFully(InputStream is, byte[] out) throws IOException { int i = 0, j; diff --git a/src/main/java/net/minecraft/block/material/MapColor.java b/src/main/java/net/minecraft/block/material/MapColor.java index c7aebfd..e94963a 100644 --- a/src/main/java/net/minecraft/block/material/MapColor.java +++ b/src/main/java/net/minecraft/block/material/MapColor.java @@ -62,7 +62,7 @@ public class MapColor { public static final MapColor emeraldColor = new MapColor(33, '\ud93a'); public static final MapColor obsidianColor = new MapColor(34, 8476209); public static final MapColor netherrackColor = new MapColor(35, 7340544); - public final int colorValue; + public int colorValue; public final int colorIndex; private MapColor(int index, int color) { diff --git a/src/main/java/net/minecraft/client/renderer/texture/TextureManager.java b/src/main/java/net/minecraft/client/renderer/texture/TextureManager.java index ceded3c..ae74d86 100644 --- a/src/main/java/net/minecraft/client/renderer/texture/TextureManager.java +++ b/src/main/java/net/minecraft/client/renderer/texture/TextureManager.java @@ -3,6 +3,7 @@ package net.minecraft.client.renderer.texture; import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*; import java.io.IOException; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -162,4 +163,16 @@ public class TextureManager implements ITickable, IResourceManagerReloadListener } } + + public void reloadBannerTextures() { + for (Object entry0 : new HashSet(this.mapTextureObjects.entrySet())) { + Entry entry = (Entry) entry0; + ResourceLocation resourcelocation = (ResourceLocation)entry.getKey(); + ITextureObject itextureobject = (ITextureObject)entry.getValue(); + + if (itextureobject instanceof LayeredColorMaskTexture) { + this.loadTexture(resourcelocation, itextureobject); + } + } + } } \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/SimpleResource.java b/src/main/java/net/minecraft/client/resources/SimpleResource.java index 451f222..675d0c5 100644 --- a/src/main/java/net/minecraft/client/resources/SimpleResource.java +++ b/src/main/java/net/minecraft/client/resources/SimpleResource.java @@ -86,7 +86,12 @@ public class SimpleResource implements IResource { IMetadataSection imetadatasection = (IMetadataSection) this.mapMetadataSections.get(s); if (imetadatasection == null) { - imetadatasection = this.srMetadataSerializer.parseMetadataSection(s, this.mcmetaJson); + try { + imetadatasection = this.srMetadataSerializer.parseMetadataSection(s, this.mcmetaJson); + } catch(Exception e) { + //Temp fix, no frame time :( + imetadatasection = this.srMetadataSerializer.parseMetadataSection(s, new JSONObject("{\"animation\":{}}")); + } } return (T) imetadatasection; @@ -129,4 +134,4 @@ public class SimpleResource implements IResource { i = 31 * i + (this.srResourceLocation != null ? this.srResourceLocation.hashCode() : 0); return i; } -} \ No newline at end of file +} diff --git a/src/main/java/net/minecraft/client/resources/data/IMetadataSerializer.java b/src/main/java/net/minecraft/client/resources/data/IMetadataSerializer.java index 44c9303..1dfaa88 100644 --- a/src/main/java/net/minecraft/client/resources/data/IMetadataSerializer.java +++ b/src/main/java/net/minecraft/client/resources/data/IMetadataSerializer.java @@ -29,10 +29,8 @@ import net.minecraft.util.RegistrySimple; public class IMetadataSerializer { private final IRegistry> metadataSectionSerializerRegistry = new RegistrySimple(); - public void registerMetadataSectionType( - IMetadataSectionSerializer parIMetadataSectionSerializer, Class parClass1) { - this.metadataSectionSerializerRegistry.putObject(parIMetadataSectionSerializer.getSectionName(), - new IMetadataSerializer.Registration(parIMetadataSectionSerializer, parClass1)); + public void registerMetadataSectionType(IMetadataSectionSerializer parIMetadataSectionSerializer, Class parClass1) { + this.metadataSectionSerializerRegistry.putObject(parIMetadataSectionSerializer.getSectionName(), new IMetadataSerializer.Registration(parIMetadataSectionSerializer, parClass1)); } public T parseMetadataSection(String parString1, JSONObject parJsonObject) { diff --git a/src/main/java/net/minecraft/client/settings/GameSettings.java b/src/main/java/net/minecraft/client/settings/GameSettings.java index a64afda..e06adb5 100644 --- a/src/main/java/net/minecraft/client/settings/GameSettings.java +++ b/src/main/java/net/minecraft/client/settings/GameSettings.java @@ -18,6 +18,7 @@ import com.google.common.collect.Sets; import net.PeytonPlayz585.shadow.ClearWater; import net.PeytonPlayz585.shadow.Config; +import net.PeytonPlayz585.shadow.CustomColors; import net.PeytonPlayz585.shadow.CustomSky; import net.PeytonPlayz585.shadow.DynamicLights; import net.PeytonPlayz585.shadow.GuiYesNo; @@ -260,6 +261,9 @@ public class GameSettings { public boolean experimentalVisGraph = false; public boolean experimentalBufferQueue = false; public GuiScreen lastGuiScreen; + public boolean ofSwampColors = true; + public boolean ofSmoothBiomes = true; + public boolean ofCustomColors = true; public GameSettings(Minecraft mcIn) { this.keyBindings = (KeyBinding[]) ArrayUtils.addAll(new KeyBinding[] { this.keyBindAttack, this.keyBindUseItem, @@ -869,6 +873,24 @@ public class GameSettings { this.ofCustomItems = !this.ofCustomItems; this.mc.refreshResources(); } + + if (parOptions == GameSettings.Options.SWAMP_COLORS) { + this.ofSwampColors = !this.ofSwampColors; + CustomColors.updateUseDefaultGrassFoliageColors(); + this.mc.renderGlobal.loadRenderers(); + } + + if (parOptions == GameSettings.Options.SMOOTH_BIOMES) { + this.ofSmoothBiomes = !this.ofSmoothBiomes; + CustomColors.updateUseDefaultGrassFoliageColors(); + this.mc.renderGlobal.loadRenderers(); + } + + if (parOptions == GameSettings.Options.CUSTOM_COLORS) { + this.ofCustomColors = !this.ofCustomColors; + CustomColors.update(); + this.mc.renderGlobal.loadRenderers(); + } this.saveOptions(); } @@ -984,6 +1006,12 @@ public class GameSettings { return this.experimentalBufferQueue; case CUSTOM_ITEMS: return this.ofCustomItems; + case SWAMP_COLORS: + return this.ofSwampColors; + case SMOOTH_BIOMES: + return this.ofSmoothBiomes; + case CUSTOM_COLORS: + return this.ofCustomColors; default: return false; } @@ -1254,6 +1282,12 @@ public class GameSettings { return this.experimentalBufferQueue ? s + Lang.getOn() : s + Lang.getOff(); } else if (parOptions == GameSettings.Options.CUSTOM_ITEMS) { return this.ofCustomItems ? s + Lang.getOn() : s + Lang.getOff(); + } else if (parOptions == GameSettings.Options.SWAMP_COLORS) { + return this.ofSwampColors ? s + Lang.getOn() : s + Lang.getOff(); + } else if (parOptions == GameSettings.Options.SMOOTH_BIOMES) { + return this.ofSmoothBiomes ? s + Lang.getOn() : s + Lang.getOff(); + } else if (parOptions == GameSettings.Options.CUSTOM_COLORS) { + return this.ofCustomColors ? s + Lang.getOn() : s + Lang.getOff(); } else { return s; } @@ -1808,6 +1842,18 @@ public class GameSettings { if (astring[0].equals("ofCustomItems") && astring.length >= 2) { this.ofCustomItems = Boolean.valueOf(astring[1]).booleanValue(); } + + if (astring[0].equals("ofSwampColors") && astring.length >= 2) { + this.ofSwampColors = Boolean.valueOf(astring[1]).booleanValue(); + } + + if (astring[0].equals("ofSmoothBiomes") && astring.length >= 2) { + this.ofSmoothBiomes = Boolean.valueOf(astring[1]).booleanValue(); + } + + if (astring[0].equals("ofCustomColors") && astring.length >= 2) { + this.ofCustomColors = Boolean.valueOf(astring[1]).booleanValue(); + } Keyboard.setFunctionKeyModifier(keyBindFunction.getKeyCode()); @@ -1983,6 +2029,9 @@ public class GameSettings { printwriter.println("visGraph:" + this.experimentalVisGraph); printwriter.println("bufferQueue:" + this.experimentalBufferQueue); printwriter.println("ofCustomItems:" + this.ofCustomItems); + printwriter.println("ofSwampColors:" + this.ofSwampColors); + printwriter.println("ofSmoothBiomes:" + this.ofSmoothBiomes); + printwriter.println("ofCustomColors:" + this.ofCustomColors); for (KeyBinding keybinding : this.keyBindings) { printwriter.println("key_" + keybinding.getKeyDescription() + ":" + keybinding.getKeyCode()); @@ -2187,7 +2236,10 @@ public class GameSettings { CHUNK_BORDERS("Chunk Borders", false, false), VIS_GRAPH("Experimental VisGraph", false, false), BUFFER_QUEUE("Experimental Queuing", false, false), - CUSTOM_ITEMS("Custom Items", false, false); + CUSTOM_ITEMS("Custom Items", false, false), + SWAMP_COLORS("Swamp Colors", false, false), + SMOOTH_BIOMES("Smooth Biomes", false, false), + CUSTOM_COLORS("Custom Colors", false, false); private final boolean enumFloat; private final boolean enumBoolean;