diff --git a/src/main/java/net/PeytonPlayz585/shadow/Config.java b/src/main/java/net/PeytonPlayz585/shadow/Config.java index c16afc2..a2b1c3d 100644 --- a/src/main/java/net/PeytonPlayz585/shadow/Config.java +++ b/src/main/java/net/PeytonPlayz585/shadow/Config.java @@ -22,6 +22,7 @@ import net.minecraft.client.resources.ResourcePackRepository; import net.minecraft.client.resources.model.ModelManager; import net.minecraft.client.settings.GameSettings; import net.minecraft.util.ResourceLocation; +import net.minecraft.client.resources.ResourcePackRepository.Entry; public class Config { @@ -233,6 +234,18 @@ public class Config { public static boolean isCustomFonts() { return Minecraft.getMinecraft().gameSettings.ofCustomFonts; } + + public static boolean isCustomColors() { + return Minecraft.getMinecraft().gameSettings.ofCustomColors; + } + + public static boolean isSwampColors() { + return Minecraft.getMinecraft().gameSettings.ofSwampColors; + } + + public static boolean isSmoothBiomes() { + return Minecraft.getMinecraft().gameSettings.ofSmoothBiomes; + } 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_); @@ -456,6 +469,23 @@ public class Config { return defaultResourcePackLazy; } + public static IResourcePack[] getResourcePacks() { + ResourcePackRepository resourcepackrepository = Minecraft.getMinecraft().getResourcePackRepository(); + List list = resourcepackrepository.getRepositoryEntries(); + List list1 = new ArrayList(); + + for (Object resourcepackrepository$entry : list) { + list1.add(((Entry) resourcepackrepository$entry).getResourcePack()); + } + + if (resourcepackrepository.getResourcePackInstance() != null) { + list1.add(resourcepackrepository.getResourcePackInstance()); + } + + IResourcePack[] airesourcepack = (IResourcePack[])((IResourcePack[])list1.toArray(new IResourcePack[list1.size()])); + return airesourcepack; + } + public static InputStream getResourceStream(ResourceLocation p_getResourceStream_0_) throws IOException { return getResourceStream(Minecraft.getMinecraft().getResourceManager(), p_getResourceStream_0_); } @@ -465,6 +495,15 @@ public class Config { return iresource == null ? null : iresource.getInputStream(); } + 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_; + } + public static boolean isShaders() { return Minecraft.getMinecraft().gameSettings.shaders; } @@ -506,6 +545,10 @@ public class Config { } } + public static boolean equals(Object p_equals_0_, Object p_equals_1_) { + return p_equals_0_ == p_equals_1_ ? true : (p_equals_0_ == null ? false : p_equals_0_.equals(p_equals_1_)); + } + public static boolean isDynamicLights() { return Minecraft.getMinecraft().gameSettings.ofDynamicLights != 3; } 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..c56e0c9 --- /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 p_getColor_1_, double p_getColor_3_, double p_getColor_5_) { + if (this.color == null) { + this.color = new Vec3(p_getColor_1_, p_getColor_3_, p_getColor_5_); + 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(p_getColor_1_ - this.color.xCoord) < 0.004D && Math.abs(p_getColor_3_ - this.color.yCoord) < 0.004D && Math.abs(p_getColor_5_ - 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 = p_getColor_1_ - this.color.xCoord; + double d2 = p_getColor_3_ - this.color.yCoord; + double d3 = p_getColor_5_ - 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..dac5fad --- /dev/null +++ b/src/main/java/net/PeytonPlayz585/shadow/CustomColormap.java @@ -0,0 +1,458 @@ +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.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 p_i33_1_, String p_i33_2_, int p_i33_3_, int p_i33_4_, String p_i33_5_) { + ConnectedParser connectedparser = new ConnectedParser("Colormap"); + this.name = connectedparser.parseName(p_i33_2_); + this.basePath = connectedparser.parseBasePath(p_i33_2_); + this.format = this.parseFormat(p_i33_1_.getProperty("format", p_i33_5_)); + this.matchBlocks = connectedparser.parseMatchBlocks(p_i33_1_.getProperty("blocks")); + this.source = parseTexture(p_i33_1_.getProperty("source"), p_i33_2_, this.basePath); + this.color = ConnectedParser.parseColor(p_i33_1_.getProperty("color"), -1); + this.yVariance = connectedparser.parseInt(p_i33_1_.getProperty("yVariance"), 0); + this.yOffset = connectedparser.parseInt(p_i33_1_.getProperty("yOffset"), 0); + this.width = p_i33_3_; + this.height = p_i33_4_; + } + + private int parseFormat(String p_parseFormat_1_) { + if (p_parseFormat_1_ == null) { + return 0; + } else if (p_parseFormat_1_.equals("vanilla")) { + return 0; + } else if (p_parseFormat_1_.equals("grid")) { + return 1; + } else if (p_parseFormat_1_.equals("fixed")) { + return 2; + } else { + warn("Unknown format: " + p_parseFormat_1_); + return -1; + } + } + + public boolean isValid(String p_isValid_1_) { + 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: " + p_isValid_1_); + 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 p_isValidMatchBlocks_1_) { + if (this.matchBlocks == null) { + this.matchBlocks = this.detectMatchBlocks(); + + if (this.matchBlocks == null) { + warn("Match blocks not defined: " + p_isValidMatchBlocks_1_); + 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 p_dbg_0_) { + Config.dbg("CustomColors: " + p_dbg_0_); + } + + private static void warn(String p_warn_0_) { + Config.warn("CustomColors: " + p_warn_0_); + } + + private static String parseTexture(String p_parseTexture_0_, String p_parseTexture_1_, String p_parseTexture_2_) { + if (p_parseTexture_0_ != null) { + String s1 = ".png"; + + if (p_parseTexture_0_.endsWith(s1)) { + p_parseTexture_0_ = p_parseTexture_0_.substring(0, p_parseTexture_0_.length() - s1.length()); + } + + p_parseTexture_0_ = fixTextureName(p_parseTexture_0_, p_parseTexture_2_); + return p_parseTexture_0_; + } else { + String s = p_parseTexture_1_; + int i = p_parseTexture_1_.lastIndexOf(47); + + if (i >= 0) { + s = p_parseTexture_1_.substring(i + 1); + } + + int j = s.lastIndexOf(46); + + if (j >= 0) { + s = s.substring(0, j); + } + + s = fixTextureName(s, p_parseTexture_2_); + return s; + } + } + + private static String fixTextureName(String p_fixTextureName_0_, String p_fixTextureName_1_) { + p_fixTextureName_0_ = TextureUtils.fixResourcePath(p_fixTextureName_0_, p_fixTextureName_1_); + + if (!p_fixTextureName_0_.startsWith(p_fixTextureName_1_) && !p_fixTextureName_0_.startsWith("textures/") && !p_fixTextureName_0_.startsWith("mcpatcher/")) { + p_fixTextureName_0_ = p_fixTextureName_1_ + "/" + p_fixTextureName_0_; + } + + if (p_fixTextureName_0_.endsWith(".png")) { + p_fixTextureName_0_ = p_fixTextureName_0_.substring(0, p_fixTextureName_0_.length() - 4); + } + + String s = "textures/blocks/"; + + if (p_fixTextureName_0_.startsWith(s)) { + p_fixTextureName_0_ = p_fixTextureName_0_.substring(s.length()); + } + + if (p_fixTextureName_0_.startsWith("/")) { + p_fixTextureName_0_ = p_fixTextureName_0_.substring(1); + } + + return p_fixTextureName_0_; + } + + public boolean matchesBlock(BlockStateBase p_matchesBlock_1_) { + return Matches.block(p_matchesBlock_1_, 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 p_getColor_1_) { + p_getColor_1_ = Config.limit(p_getColor_1_, 0, this.colors.length - 1); + return this.colors[p_getColor_1_] & 16777215; + } + + public int getColor(int p_getColor_1_, int p_getColor_2_) { + p_getColor_1_ = Config.limit(p_getColor_1_, 0, this.width - 1); + p_getColor_2_ = Config.limit(p_getColor_2_, 0, this.height - 1); + return this.colors[p_getColor_2_ * this.width + p_getColor_1_] & 16777215; + } + + public float[][] getColorsRgb() { + if (this.colorsRgb == null) { + this.colorsRgb = toRgb(this.colors); + } + + return this.colorsRgb; + } + + public int getColor(IBlockAccess p_getColor_1_, BlockPos p_getColor_2_) { + BiomeGenBase biomegenbase = CustomColors.getColorBiome(p_getColor_1_, p_getColor_2_); + return this.getColor(biomegenbase, p_getColor_2_); + } + + public boolean isColorConstant() { + return this.format == 2; + } + + public int getColor(BiomeGenBase p_getColor_1_, BlockPos p_getColor_2_) { + return this.format == 0 ? this.getColorVanilla(p_getColor_1_, p_getColor_2_) : (this.format == 1 ? this.getColorGrid(p_getColor_1_, p_getColor_2_) : this.color); + } + + public int getColorSmooth(IBlockAccess p_getColorSmooth_1_, double p_getColorSmooth_2_, double p_getColorSmooth_4_, double p_getColorSmooth_6_, int p_getColorSmooth_8_) { + if (this.format == 2) { + return this.color; + } else { + int i = MathHelper.floor_double(p_getColorSmooth_2_); + int j = MathHelper.floor_double(p_getColorSmooth_4_); + int k = MathHelper.floor_double(p_getColorSmooth_6_); + int l = 0; + int i1 = 0; + int j1 = 0; + int k1 = 0; + BlockPosM blockposm = new BlockPosM(0, 0, 0); + + for (int l1 = i - p_getColorSmooth_8_; l1 <= i + p_getColorSmooth_8_; ++l1) { + for (int i2 = k - p_getColorSmooth_8_; i2 <= k + p_getColorSmooth_8_; ++i2) { + blockposm.setXyz(l1, j, i2); + int j2 = this.getColor((IBlockAccess) p_getColorSmooth_1_, 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 p_getColorVanilla_1_, BlockPos p_getColorVanilla_2_) { + double d0 = (double) MathHelper.clamp_float(p_getColorVanilla_1_.getFloatTemperature(p_getColorVanilla_2_), 0.0F, 1.0F); + double d1 = (double) MathHelper.clamp_float(p_getColorVanilla_1_.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 p_getColorGrid_1_, BlockPos p_getColorGrid_2_) { + int i = p_getColorGrid_1_.biomeID; + int j = p_getColorGrid_2_.getY() - this.yOffset; + + if (this.yVariance > 0) { + int k = p_getColorGrid_2_.getX() << 16 + p_getColorGrid_2_.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[] p_toRgb_0_) { + float[][] afloat = new float[p_toRgb_0_.length][3]; + + for (int i = 0; i < p_toRgb_0_.length; ++i) { + int j = p_toRgb_0_[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 p_addMatchBlock_1_) { + if (this.matchBlocks == null) { + this.matchBlocks = new MatchBlock[0]; + } + + this.matchBlocks = (MatchBlock[])((MatchBlock[]) Config.addObjectToArray(this.matchBlocks, p_addMatchBlock_1_)); + } + + public void addMatchBlock(int p_addMatchBlock_1_, int p_addMatchBlock_2_) { + MatchBlock matchblock = this.getMatchBlock(p_addMatchBlock_1_); + + if (matchblock != null) { + if (p_addMatchBlock_2_ >= 0) { + matchblock.addMetadata(p_addMatchBlock_2_); + } + } else { + this.addMatchBlock(new MatchBlock(p_addMatchBlock_1_, p_addMatchBlock_2_)); + } + } + + private MatchBlock getMatchBlock(int p_getMatchBlock_1_) { + if (this.matchBlocks == null) { + return null; + } else { + for (int i = 0; i < this.matchBlocks.length; ++i) { + MatchBlock matchblock = this.matchBlocks[i]; + + if (matchblock.getBlockId() == p_getMatchBlock_1_) { + 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..6c6f9a3 --- /dev/null +++ b/src/main/java/net/PeytonPlayz585/shadow/CustomColors.java @@ -0,0 +1,1527 @@ +package net.PeytonPlayz585.shadow; + +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 net.PeytonPlayz585.shadow.apache.Pair; +import net.PeytonPlayz585.shadow.apache.ImmutablePair; + +import net.PeytonPlayz585.shadow.reflections.Reflector; +import net.lax1dude.eaglercraft.v1_8.opengl.ImageData; +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.multiplayer.WorldClient; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityList; +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.potion.PotionHelper; +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[] lightMapsColorsRgb = null; + private static int lightmapMinDimensionId = 0; + private static float[][] sunRgbs = new float[16][3]; + private static float[][] torchRgbs = new float[16][3]; + 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(IBlockAccess p_getColor_1_, BlockPos p_getColor_2_) { + BiomeGenBase biomegenbase = CustomColors.getColorBiome(p_getColor_1_, p_getColor_2_); + return CustomColors.swampGrassColors != null && biomegenbase == BiomeGenBase.swampland ? CustomColors.swampGrassColors.getColor(biomegenbase, p_getColor_2_) : biomegenbase.getGrassColorAtPos(p_getColor_2_); + } + public boolean isColorConstant() { + return false; + } + }; + private static final CustomColors.IColorizer COLORIZER_FOLIAGE = new CustomColors.IColorizer() { + public int getColor(IBlockAccess p_getColor_1_, BlockPos p_getColor_2_) { + BiomeGenBase biomegenbase = CustomColors.getColorBiome(p_getColor_1_, p_getColor_2_); + return CustomColors.swampFoliageColors != null && biomegenbase == BiomeGenBase.swampland ? CustomColors.swampFoliageColors.getColor(biomegenbase, p_getColor_2_) : biomegenbase.getFoliageColorAtPos(p_getColor_2_); + } + public boolean isColorConstant() { + return false; + } + }; + private static final CustomColors.IColorizer COLORIZER_FOLIAGE_PINE = new CustomColors.IColorizer() { + public int getColor(IBlockAccess p_getColor_1_, BlockPos p_getColor_2_) { + return CustomColors.foliagePineColors != null ? CustomColors.foliagePineColors.getColor(p_getColor_1_, p_getColor_2_) : ColorizerFoliage.getFoliageColorPine(); + } + public boolean isColorConstant() { + return CustomColors.foliagePineColors == null; + } + }; + private static final CustomColors.IColorizer COLORIZER_FOLIAGE_BIRCH = new CustomColors.IColorizer() { + public int getColor(IBlockAccess p_getColor_1_, BlockPos p_getColor_2_) { + return CustomColors.foliageBirchColors != null ? CustomColors.foliageBirchColors.getColor(p_getColor_1_, p_getColor_2_) : ColorizerFoliage.getFoliageColorBirch(); + } + public boolean isColorConstant() { + return CustomColors.foliageBirchColors == null; + } + }; + private static final CustomColors.IColorizer COLORIZER_WATER = new CustomColors.IColorizer() { + public int getColor(IBlockAccess p_getColor_1_, BlockPos p_getColor_2_) { + BiomeGenBase biomegenbase = CustomColors.getColorBiome(p_getColor_1_, p_getColor_2_); + return CustomColors.waterColors != null ? CustomColors.waterColors.getColor(biomegenbase, p_getColor_2_) : (Reflector.ForgeBiome_getWaterColorMultiplier.exists() ? Reflector.callInt(biomegenbase, Reflector.ForgeBiome_getWaterColorMultiplier, new Object[0]) : 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; + redstoneColors = null; + xpOrbColors = null; + xpOrbTime = -1; + durabilityColors = null; + stemColors = null; + myceliumParticleColors = null; + lightMapsColorsRgb = 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; + PotionHelper.clearPotionColorCache(); + 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[] { + "redstone.png", + "redstonecolor.png" + }; + redstoneColors = getCustomColors(s, astring8, 16, 1); + xpOrbColors = getCustomColors(s + "xporb.png", -1, -1); + durabilityColors = getCustomColors(s + "durability.png", -1, -1); + String[] astring9 = new String[] { + "stem.png", + "stemcolor.png" + }; + stemColors = getCustomColors(s, astring9, 8, 1); + stemPumpkinColors = getCustomColors(s + "pumpkinstem.png", 8, 1); + stemMelonColors = getCustomColors(s + "melonstem.png", 8, 1); + String[] astring10 = new String[] { + "myceliumparticle.png", + "myceliumparticlecolor.png" + }; + myceliumParticleColors = getCustomColors(s, astring10, -1, -1); + Pair < CustomColormap[], Integer > pair = parseLightmapsRgb(); + lightMapsColorsRgb = (CustomColormap[]) 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 p_getValidProperty_0_, String p_getValidProperty_1_, String[] p_getValidProperty_2_, String p_getValidProperty_3_) { + try { + ResourceLocation resourcelocation = new ResourceLocation(p_getValidProperty_0_); + InputStream inputstream = Config.getResourceStream(resourcelocation); + + if (inputstream == null) { + return p_getValidProperty_3_; + } else { + Properties properties = new Properties(); + properties.load(inputstream); + inputstream.close(); + String s = properties.getProperty(p_getValidProperty_1_); + + if (s == null) { + return p_getValidProperty_3_; + } else { + List < String > list = Arrays. < String > asList(p_getValidProperty_2_); + + if (!list.contains(s)) { + warn("Invalid value: " + p_getValidProperty_1_ + "=" + s); + warn("Expected values: " + Config.arrayToString((Object[]) p_getValidProperty_2_)); + return p_getValidProperty_3_; + } else { + dbg("" + p_getValidProperty_1_ + "=" + s); + return s; + } + } + } + } catch (FileNotFoundException var9) { + return p_getValidProperty_3_; + } catch (IOException ioexception) { + ioexception.printStackTrace(); + return p_getValidProperty_3_; + } + } + + private static Pair < CustomColormap[], Integer > parseLightmapsRgb() { + 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; + } + } + } + + return new ImmutablePair(acustomcolormap, Integer.valueOf(j1)); + } + } + + private static int getTextureHeight(String p_getTextureHeight_0_, int p_getTextureHeight_1_) { + try { + InputStream inputstream = Config.getResourceStream(new ResourceLocation(p_getTextureHeight_0_)); + + if (inputstream == null) { + return p_getTextureHeight_1_; + } else { + ImageData bufferedimage = ImageData.loadImageFile(inputstream); + inputstream.close(); + return bufferedimage == null ? p_getTextureHeight_1_ : bufferedimage.height; + } + } catch (IOException var4) { + return p_getTextureHeight_1_; + } + } + + private static void readColorProperties(String p_readColorProperties_0_) { + try { + ResourceLocation resourcelocation = new ResourceLocation(p_readColorProperties_0_); + InputStream inputstream = Config.getResourceStream(resourcelocation); + + if (inputstream == null) { + return; + } + + dbg("Loading " + p_readColorProperties_0_); + Properties properties = new Properties(); + 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, p_readColorProperties_0_); + spawnEggPrimaryColors = readSpawnEggColors(properties, p_readColorProperties_0_, "egg.shell.", "Spawn egg shell"); + spawnEggSecondaryColors = readSpawnEggColors(properties, p_readColorProperties_0_, "egg.spots.", "Spawn egg spot"); + wolfCollarColors = readDyeColors(properties, p_readColorProperties_0_, "collar.", "Wolf collar"); + sheepColors = readDyeColors(properties, p_readColorProperties_0_, "sheep.", "Sheep"); + textColors = readTextColors(properties, p_readColorProperties_0_, "text.code.", "Text"); + int[] aint = readMapColors(properties, p_readColorProperties_0_, "map.", "Map"); + + if (aint != null) { + if (mapColorsOriginal == null) { + mapColorsOriginal = getMapColors(); + } + + setMapColors(aint); + } + + potionColors = readPotionColors(properties, p_readColorProperties_0_, "potion.", "Potion"); + xpOrbTime = Config.parseInt(properties.getProperty("xporb.time"), -1); + } catch (FileNotFoundException var5) { + return; + } catch (IOException ioexception) { + ioexception.printStackTrace(); + } + } + + private static CustomColormap[] readCustomColormaps(Properties p_readCustomColormaps_0_, String p_readCustomColormaps_1_) { + List list = new ArrayList(); + String s = "palette.block."; + Map map = new HashMap(); + + for (Object s1: p_readCustomColormaps_0_.keySet()) { + String s2 = p_readCustomColormaps_0_.getProperty((String) s1); + + if (((String) 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 = p_readCustomColormaps_0_.getProperty(s6); + dbg("Block palette: " + s6 + " = " + s3); + String s4 = s6.substring(s.length()); + String s5 = TextureUtils.getBasePath(p_readCustomColormaps_1_); + 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[] p_readBlockColormaps_0_, CustomColormap[] p_readBlockColormaps_1_, int p_readBlockColormaps_2_, int p_readBlockColormaps_3_) { + String[] astring = ResUtils.collectFiles(p_readBlockColormaps_0_, 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 Properties(); + properties.load(inputstream); + CustomColormap customcolormap = new CustomColormap(properties, s, p_readBlockColormaps_2_, p_readBlockColormaps_3_, 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 (p_readBlockColormaps_1_ != null) { + for (int j = 0; j < p_readBlockColormaps_1_.length; ++j) { + CustomColormap customcolormap1 = p_readBlockColormaps_1_[j]; + addToBlockList(customcolormap1, list); + } + } + + if (list.size() <= 0) { + return (CustomColormap[][]) null; + } else { + CustomColormap[][] acustomcolormap = blockListToArray(list); + return acustomcolormap; + } + } + + private static void addToBlockList(CustomColormap p_addToBlockList_0_, List p_addToBlockList_1_) { + int[] aint = p_addToBlockList_0_.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(p_addToBlockList_0_, p_addToBlockList_1_, j); + } + } + } else { + warn("No match blocks: " + Config.arrayToString(aint)); + } + } + + private static void addToList(CustomColormap p_addToList_0_, List p_addToList_1_, int p_addToList_2_) { + while (p_addToList_2_ >= p_addToList_1_.size()) { + p_addToList_1_.add(null); + } + + List list = (List) p_addToList_1_.get(p_addToList_2_); + + if (list == null) { + list = new ArrayList(); + p_addToList_1_.set(p_addToList_2_, list); + } + + list.add(p_addToList_0_); + } + + private static CustomColormap[][] blockListToArray(List p_blockListToArray_0_) { + CustomColormap[][] acustomcolormap = new CustomColormap[p_blockListToArray_0_.size()][]; + + for (int i = 0; i < p_blockListToArray_0_.size(); ++i) { + List list = (List) p_blockListToArray_0_.get(i); + + if (list != null) { + CustomColormap[] acustomcolormap1 = (CustomColormap[])((CustomColormap[]) list.toArray(new CustomColormap[list.size()])); + acustomcolormap[i] = acustomcolormap1; + } + } + + return acustomcolormap; + } + + private static int readColor(Properties p_readColor_0_, String[] p_readColor_1_) { + for (int i = 0; i < p_readColor_1_.length; ++i) { + String s = p_readColor_1_[i]; + int j = readColor(p_readColor_0_, s); + + if (j >= 0) { + return j; + } + } + + return -1; + } + + private static int readColor(Properties p_readColor_0_, String p_readColor_1_) { + String s = p_readColor_0_.getProperty(p_readColor_1_); + + if (s == null) { + return -1; + } else { + s = s.trim(); + int i = parseColor(s); + + if (i < 0) { + warn("Invalid color: " + p_readColor_1_ + " = " + s); + return i; + } else { + dbg(p_readColor_1_ + " = " + s); + return i; + } + } + } + + private static int parseColor(String p_parseColor_0_) { + if (p_parseColor_0_ == null) { + return -1; + } else { + p_parseColor_0_ = p_parseColor_0_.trim(); + + try { + int i = Integer.parseInt(p_parseColor_0_, 16) & 16777215; + return i; + } catch (NumberFormatException var2) { + return -1; + } + } + } + + private static Vec3 readColorVec3(Properties p_readColorVec3_0_, String p_readColorVec3_1_) { + int i = readColor(p_readColorVec3_0_, p_readColorVec3_1_); + + 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 p_getCustomColors_0_, String[] p_getCustomColors_1_, int p_getCustomColors_2_, int p_getCustomColors_3_) { + for (int i = 0; i < p_getCustomColors_1_.length; ++i) { + String s = p_getCustomColors_1_[i]; + s = p_getCustomColors_0_ + s; + CustomColormap customcolormap = getCustomColors(s, p_getCustomColors_2_, p_getCustomColors_3_); + + if (customcolormap != null) { + return customcolormap; + } + } + + return null; + } + + public static CustomColormap getCustomColors(String p_getCustomColors_0_, int p_getCustomColors_1_, int p_getCustomColors_2_) { + try { + ResourceLocation resourcelocation = new ResourceLocation(p_getCustomColors_0_); + + if (!Config.hasResource(resourcelocation)) { + return null; + } else { + dbg("Colormap " + p_getCustomColors_0_); + Properties properties = new Properties(); + String s = StrUtils.replaceSuffix(p_getCustomColors_0_, ".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", p_getCustomColors_0_); + s = p_getCustomColors_0_; + } + + CustomColormap customcolormap = new CustomColormap(properties, s, p_getCustomColors_1_, p_getCustomColors_2_, 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 p_getColorMultiplier_0_, Block p_getColorMultiplier_1_, IBlockAccess p_getColorMultiplier_2_, BlockPos p_getColorMultiplier_3_, RenderEnv p_getColorMultiplier_4_) { + if (blockColormaps != null) { + IBlockState iblockstate = p_getColorMultiplier_4_.getBlockState(); + + if (!p_getColorMultiplier_0_.hasTintIndex()) { + if (p_getColorMultiplier_1_ == Blocks.grass) { + iblockstate = BLOCK_STATE_DIRT; + } + + if (p_getColorMultiplier_1_ == Blocks.redstone_wire) { + return -1; + } + } + + if (p_getColorMultiplier_1_ == Blocks.double_plant && p_getColorMultiplier_4_.getMetadata() >= 8) { + p_getColorMultiplier_3_ = p_getColorMultiplier_3_.down(); + iblockstate = p_getColorMultiplier_2_.getBlockState(p_getColorMultiplier_3_); + } + + CustomColormap customcolormap = getBlockColormap(iblockstate); + + if (customcolormap != null) { + if (Config.isSmoothBiomes() && !customcolormap.isColorConstant()) { + return getSmoothColorMultiplier(p_getColorMultiplier_2_, p_getColorMultiplier_3_, customcolormap, p_getColorMultiplier_4_.getColorizerBlockPosM()); + } + + return customcolormap.getColor(p_getColorMultiplier_2_, p_getColorMultiplier_3_); + } + } + + if (!p_getColorMultiplier_0_.hasTintIndex()) { + return -1; + } else if (p_getColorMultiplier_1_ == Blocks.waterlily) { + return getLilypadColorMultiplier(p_getColorMultiplier_2_, p_getColorMultiplier_3_); + } else if (p_getColorMultiplier_1_ == Blocks.redstone_wire) { + return getRedstoneColor(p_getColorMultiplier_4_.getBlockState()); + } else if (p_getColorMultiplier_1_ instanceof BlockStem) { + return getStemColorMultiplier(p_getColorMultiplier_1_, p_getColorMultiplier_2_, p_getColorMultiplier_3_, p_getColorMultiplier_4_); + } else if (useDefaultGrassFoliageColors) { + return -1; + } else { + int i = p_getColorMultiplier_4_.getMetadata(); + CustomColors.IColorizer customcolors$icolorizer; + + if (p_getColorMultiplier_1_ != Blocks.grass && p_getColorMultiplier_1_ != Blocks.tallgrass && p_getColorMultiplier_1_ != Blocks.double_plant) { + if (p_getColorMultiplier_1_ == Blocks.double_plant) { + customcolors$icolorizer = COLORIZER_GRASS; + + if (i >= 8) { + p_getColorMultiplier_3_ = p_getColorMultiplier_3_.down(); + } + } else if (p_getColorMultiplier_1_ == 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 (p_getColorMultiplier_1_ == Blocks.leaves2) { + customcolors$icolorizer = COLORIZER_FOLIAGE; + } else { + if (p_getColorMultiplier_1_ != Blocks.vine) { + return -1; + } + + customcolors$icolorizer = COLORIZER_FOLIAGE; + } + } else { + customcolors$icolorizer = COLORIZER_GRASS; + } + + return Config.isSmoothBiomes() && !customcolors$icolorizer.isColorConstant() ? getSmoothColorMultiplier(p_getColorMultiplier_2_, p_getColorMultiplier_3_, customcolors$icolorizer, p_getColorMultiplier_4_.getColorizerBlockPosM()) : customcolors$icolorizer.getColor(p_getColorMultiplier_2_, p_getColorMultiplier_3_); + } + } + + protected static BiomeGenBase getColorBiome(IBlockAccess p_getColorBiome_0_, BlockPos p_getColorBiome_1_) { + BiomeGenBase biomegenbase = p_getColorBiome_0_.getBiomeGenForCoords(p_getColorBiome_1_); + + if (biomegenbase == BiomeGenBase.swampland && !Config.isSwampColors()) { + biomegenbase = BiomeGenBase.plains; + } + + return biomegenbase; + } + + private static CustomColormap getBlockColormap(IBlockState p_getBlockColormap_0_) { + if (blockColormaps == null) { + return null; + } else if (!(p_getBlockColormap_0_ instanceof BlockStateBase)) { + return null; + } else { + BlockStateBase blockstatebase = (BlockStateBase) p_getBlockColormap_0_; + 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(IBlockAccess p_getSmoothColorMultiplier_0_, BlockPos p_getSmoothColorMultiplier_1_, CustomColors.IColorizer p_getSmoothColorMultiplier_2_, BlockPosM p_getSmoothColorMultiplier_3_) { + int i = 0; + int j = 0; + int k = 0; + int l = p_getSmoothColorMultiplier_1_.getX(); + int i1 = p_getSmoothColorMultiplier_1_.getY(); + int j1 = p_getSmoothColorMultiplier_1_.getZ(); + BlockPosM blockposm = p_getSmoothColorMultiplier_3_; + + 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 = p_getSmoothColorMultiplier_2_.getColor(p_getSmoothColorMultiplier_0_, 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 p_getFluidColor_0_, IBlockState p_getFluidColor_1_, BlockPos p_getFluidColor_2_, RenderEnv p_getFluidColor_3_) { + Block block = p_getFluidColor_1_.getBlock(); + CustomColors.IColorizer customcolors$icolorizer = getBlockColormap(p_getFluidColor_1_); + + if (customcolors$icolorizer == null && block.getMaterial() == Material.water) { + customcolors$icolorizer = COLORIZER_WATER; + } + + return customcolors$icolorizer == null ? block.colorMultiplier(p_getFluidColor_0_, p_getFluidColor_2_) : (Config.isSmoothBiomes() && !customcolors$icolorizer.isColorConstant() ? getSmoothColorMultiplier(p_getFluidColor_0_, p_getFluidColor_2_, customcolors$icolorizer, p_getFluidColor_3_.getColorizerBlockPosM()) : customcolors$icolorizer.getColor(p_getFluidColor_0_, p_getFluidColor_2_)); + } + + public static void updatePortalFX(EntityFX p_updatePortalFX_0_) { + 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; + p_updatePortalFX_0_.setRBGColorF(f, f1, f2); + } + } + + public static void updateMyceliumFX(EntityFX p_updateMyceliumFX_0_) { + 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; + p_updateMyceliumFX_0_.setRBGColorF(f, f1, f2); + } + } + + private static int getRedstoneColor(IBlockState p_getRedstoneColor_0_) { + if (redstoneColors == null) { + return -1; + } else { + int i = getRedstoneLevel(p_getRedstoneColor_0_, 15); + int j = redstoneColors.getColor(i); + return j; + } + } + + public static void updateReddustFX(EntityFX p_updateReddustFX_0_, IBlockAccess p_updateReddustFX_1_, double p_updateReddustFX_2_, double p_updateReddustFX_4_, double p_updateReddustFX_6_) { + if (redstoneColors != null) { + IBlockState iblockstate = p_updateReddustFX_1_.getBlockState(new BlockPos(p_updateReddustFX_2_, p_updateReddustFX_4_, p_updateReddustFX_6_)); + 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; + p_updateReddustFX_0_.setRBGColorF(f, f1, f2); + } + } + + private static int getRedstoneLevel(IBlockState p_getRedstoneLevel_0_, int p_getRedstoneLevel_1_) { + Block block = p_getRedstoneLevel_0_.getBlock(); + + if (!(block instanceof BlockRedstoneWire)) { + return p_getRedstoneLevel_1_; + } else { + Object object = p_getRedstoneLevel_0_.getValue(BlockRedstoneWire.POWER); + + if (!(object instanceof Integer)) { + return p_getRedstoneLevel_1_; + } else { + Integer integer = (Integer) object; + return integer.intValue(); + } + } + } + + public static float getXpOrbTimer(float p_getXpOrbTimer_0_) { + if (xpOrbTime <= 0) { + return p_getXpOrbTimer_0_; + } else { + float f = 628.0F / (float) xpOrbTime; + return p_getXpOrbTimer_0_ * f; + } + } + + public static int getXpOrbColor(float p_getXpOrbColor_0_) { + if (xpOrbColors == null) { + return -1; + } else { + int i = (int) Math.round((double)((MathHelper.sin(p_getXpOrbColor_0_) + 1.0F) * (float)(xpOrbColors.getLength() - 1)) / 2.0D); + int j = xpOrbColors.getColor(i); + return j; + } + } + + public static int getDurabilityColor(int p_getDurabilityColor_0_) { + if (durabilityColors == null) { + return -1; + } else { + int i = p_getDurabilityColor_0_ * durabilityColors.getLength() / 255; + int j = durabilityColors.getColor(i); + return j; + } + } + + public static void updateWaterFX(EntityFX p_updateWaterFX_0_, IBlockAccess p_updateWaterFX_1_, double p_updateWaterFX_2_, double p_updateWaterFX_4_, double p_updateWaterFX_6_) { + if (waterColors != null || blockColormaps != null) { + BlockPos blockpos = new BlockPos(p_updateWaterFX_2_, p_updateWaterFX_4_, p_updateWaterFX_6_); + RenderEnv renderenv = RenderEnv.getInstance(p_updateWaterFX_1_, BLOCK_STATE_WATER, blockpos); + int i = getFluidColor(p_updateWaterFX_1_, 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; + } + + p_updateWaterFX_0_.setRBGColorF(f, f1, f2); + } + } + + private static int getLilypadColorMultiplier(IBlockAccess p_getLilypadColorMultiplier_0_, BlockPos p_getLilypadColorMultiplier_1_) { + return lilyPadColor < 0 ? Blocks.waterlily.colorMultiplier(p_getLilypadColorMultiplier_0_, p_getLilypadColorMultiplier_1_) : lilyPadColor; + } + + private static Vec3 getFogColorNether(Vec3 p_getFogColorNether_0_) { + return fogColorNether == null ? p_getFogColorNether_0_ : fogColorNether; + } + + private static Vec3 getFogColorEnd(Vec3 p_getFogColorEnd_0_) { + return fogColorEnd == null ? p_getFogColorEnd_0_ : fogColorEnd; + } + + private static Vec3 getSkyColorEnd(Vec3 p_getSkyColorEnd_0_) { + return skyColorEnd == null ? p_getSkyColorEnd_0_ : skyColorEnd; + } + + public static Vec3 getSkyColor(Vec3 p_getSkyColor_0_, IBlockAccess p_getSkyColor_1_, double p_getSkyColor_2_, double p_getSkyColor_4_, double p_getSkyColor_6_) { + if (skyColors == null) { + return p_getSkyColor_0_; + } else { + int i = skyColors.getColorSmooth(p_getSkyColor_1_, p_getSkyColor_2_, p_getSkyColor_4_, p_getSkyColor_6_, 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) p_getSkyColor_0_.xCoord / 0.5F; + float f4 = (float) p_getSkyColor_0_.yCoord / 0.66275F; + float f5 = (float) p_getSkyColor_0_.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 p_getFogColor_0_, IBlockAccess p_getFogColor_1_, double p_getFogColor_2_, double p_getFogColor_4_, double p_getFogColor_6_) { + if (fogColors == null) { + return p_getFogColor_0_; + } else { + int i = fogColors.getColorSmooth(p_getFogColor_1_, p_getFogColor_2_, p_getFogColor_4_, p_getFogColor_6_, 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) p_getFogColor_0_.xCoord / 0.753F; + float f4 = (float) p_getFogColor_0_.yCoord / 0.8471F; + float f5 = (float) p_getFogColor_0_.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 p_getUnderwaterColor_0_, double p_getUnderwaterColor_1_, double p_getUnderwaterColor_3_, double p_getUnderwaterColor_5_) { + if (underwaterColors == null) { + return null; + } else { + int i = underwaterColors.getColorSmooth(p_getUnderwaterColor_0_, p_getUnderwaterColor_1_, p_getUnderwaterColor_3_, p_getUnderwaterColor_5_, 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 = underwaterColorFader.getColor((double) f, (double) f1, (double) f2); + return vec3; + } + } + + private static int getStemColorMultiplier(Block p_getStemColorMultiplier_0_, IBlockAccess p_getStemColorMultiplier_1_, BlockPos p_getStemColorMultiplier_2_, RenderEnv p_getStemColorMultiplier_3_) { + CustomColormap customcolormap = stemColors; + + if (p_getStemColorMultiplier_0_ == Blocks.pumpkin_stem && stemPumpkinColors != null) { + customcolormap = stemPumpkinColors; + } + + if (p_getStemColorMultiplier_0_ == Blocks.melon_stem && stemMelonColors != null) { + customcolormap = stemMelonColors; + } + + if (customcolormap == null) { + return -1; + } else { + int i = p_getStemColorMultiplier_3_.getMetadata(); + return customcolormap.getColor(i); + } + } + + public static boolean updateLightmap(World p_updateLightmap_0_, float p_updateLightmap_1_, int[] p_updateLightmap_2_, boolean p_updateLightmap_3_) { + if (p_updateLightmap_0_ == null) { + return false; + } else if (lightMapsColorsRgb == null) { + return false; + } else { + int i = p_updateLightmap_0_.provider.getDimensionId(); + int j = i - lightmapMinDimensionId; + + if (j >= 0 && j < lightMapsColorsRgb.length) { + CustomColormap customcolormap = lightMapsColorsRgb[j]; + + if (customcolormap == null) { + return false; + } else { + int k = customcolormap.getHeight(); + + if (p_updateLightmap_3_ && k < 64) { + return false; + } else { + int l = customcolormap.getWidth(); + + if (l < 16) { + warn("Invalid lightmap width: " + l + " for dimension: " + i); + lightMapsColorsRgb[j] = null; + return false; + } else { + int i1 = 0; + + if (p_updateLightmap_3_) { + i1 = l * 16 * 2; + } + + float f = 1.1666666F * (p_updateLightmap_0_.getSunBrightness(1.0F) - 0.2F); + + if (p_updateLightmap_0_.getLastLightningBolt() > 0) { + f = 1.0F; + } + + f = Config.limitTo1(f); + float f1 = f * (float)(l - 1); + float f2 = Config.limitTo1(p_updateLightmap_1_ + 0.5F) * (float)(l - 1); + float f3 = Config.limitTo1(Config.getGameSettings().gammaSetting); + boolean flag = f3 > 1.0E-4F; + float[][] afloat = customcolormap.getColorsRgb(); + getLightMapColumn(afloat, f1, i1, l, sunRgbs); + getLightMapColumn(afloat, f2, i1 + 16 * l, l, torchRgbs); + float[] afloat1 = new float[3]; + + for (int j1 = 0; j1 < 16; ++j1) { + for (int k1 = 0; k1 < 16; ++k1) { + for (int l1 = 0; l1 < 3; ++l1) { + float f4 = Config.limitTo1(sunRgbs[j1][l1] + torchRgbs[k1][l1]); + + if (flag) { + float f5 = 1.0F - f4; + f5 = 1.0F - f5 * f5 * f5 * f5; + f4 = f3 * f5 + (1.0F - f3) * f4; + } + + afloat1[l1] = f4; + } + + int i2 = (int)(afloat1[0] * 255.0F); + int j2 = (int)(afloat1[1] * 255.0F); + int k2 = (int)(afloat1[2] * 255.0F); + p_updateLightmap_2_[j1 * 16 + k1] = -16777216 | i2 << 16 | j2 << 8 | k2; + } + } + + return true; + } + } + } + } else { + return false; + } + } + } + + private static void getLightMapColumn(float[][] p_getLightMapColumn_0_, float p_getLightMapColumn_1_, int p_getLightMapColumn_2_, int p_getLightMapColumn_3_, float[][] p_getLightMapColumn_4_) { + int i = (int) Math.floor((double) p_getLightMapColumn_1_); + int j = (int) Math.ceil((double) p_getLightMapColumn_1_); + + if (i == j) { + for (int i1 = 0; i1 < 16; ++i1) { + float[] afloat3 = p_getLightMapColumn_0_[p_getLightMapColumn_2_ + i1 * p_getLightMapColumn_3_ + i]; + float[] afloat4 = p_getLightMapColumn_4_[i1]; + + for (int j1 = 0; j1 < 3; ++j1) { + afloat4[j1] = afloat3[j1]; + } + } + } else { + float f = 1.0F - (p_getLightMapColumn_1_ - (float) i); + float f1 = 1.0F - ((float) j - p_getLightMapColumn_1_); + + for (int k = 0; k < 16; ++k) { + float[] afloat = p_getLightMapColumn_0_[p_getLightMapColumn_2_ + k * p_getLightMapColumn_3_ + i]; + float[] afloat1 = p_getLightMapColumn_0_[p_getLightMapColumn_2_ + k * p_getLightMapColumn_3_ + j]; + float[] afloat2 = p_getLightMapColumn_4_[k]; + + for (int l = 0; l < 3; ++l) { + afloat2[l] = afloat[l] * f + afloat1[l] * f1; + } + } + } + } + + public static Vec3 getWorldFogColor(Vec3 p_getWorldFogColor_0_, WorldClient p_getWorldFogColor_1_, Entity p_getWorldFogColor_2_, float p_getWorldFogColor_3_) { + int i = p_getWorldFogColor_1_.provider.getDimensionId(); + + switch (i) { + case -1: + p_getWorldFogColor_0_ = getFogColorNether(p_getWorldFogColor_0_); + break; + + case 0: + Minecraft minecraft = Minecraft.getMinecraft(); + p_getWorldFogColor_0_ = getFogColor(p_getWorldFogColor_0_, minecraft.theWorld, p_getWorldFogColor_2_.posX, p_getWorldFogColor_2_.posY + 1.0D, p_getWorldFogColor_2_.posZ); + break; + + case 1: + p_getWorldFogColor_0_ = getFogColorEnd(p_getWorldFogColor_0_); + } + + return p_getWorldFogColor_0_; + } + + public static Vec3 getWorldSkyColor(Vec3 p_getWorldSkyColor_0_, World p_getWorldSkyColor_1_, Entity p_getWorldSkyColor_2_, float p_getWorldSkyColor_3_) { + int i = p_getWorldSkyColor_1_.provider.getDimensionId(); + + switch (i) { + case 0: + Minecraft minecraft = Minecraft.getMinecraft(); + p_getWorldSkyColor_0_ = getSkyColor(p_getWorldSkyColor_0_, minecraft.theWorld, p_getWorldSkyColor_2_.posX, p_getWorldSkyColor_2_.posY + 1.0D, p_getWorldSkyColor_2_.posZ); + break; + + case 1: + p_getWorldSkyColor_0_ = getSkyColorEnd(p_getWorldSkyColor_0_); + } + + return p_getWorldSkyColor_0_; + } + + private static int[] readSpawnEggColors(Properties p_readSpawnEggColors_0_, String p_readSpawnEggColors_1_, String p_readSpawnEggColors_2_, String p_readSpawnEggColors_3_) { + List < Integer > list = new ArrayList(); + Set set = p_readSpawnEggColors_0_.keySet(); + int i = 0; + + for (Object s: set) { + String s1 = p_readSpawnEggColors_0_.getProperty((String) s); + + if (((String) s).startsWith(p_readSpawnEggColors_2_)) { + String s2 = StrUtils.removePrefix((String) s, p_readSpawnEggColors_2_); + int j = getEntityId(s2); + int k = parseColor(s1); + + if (j >= 0 && k >= 0) { + while (((List) list).size() <= j) { + list.add(Integer.valueOf(-1)); + } + + list.set(j, Integer.valueOf(k)); + ++i; + } else { + warn("Invalid spawn egg color: " + s + " = " + s1); + } + } + } + + if (i <= 0) { + return null; + } else { + dbg(p_readSpawnEggColors_3_ + " 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 p_getSpawnEggColor_0_, ItemStack p_getSpawnEggColor_1_, int p_getSpawnEggColor_2_, int p_getSpawnEggColor_3_) { + int i = p_getSpawnEggColor_1_.getMetadata(); + int[] aint = p_getSpawnEggColor_2_ == 0 ? spawnEggPrimaryColors : spawnEggSecondaryColors; + + if (aint == null) { + return p_getSpawnEggColor_3_; + } else if (i >= 0 && i < aint.length) { + int j = aint[i]; + return j < 0 ? p_getSpawnEggColor_3_ : j; + } else { + return p_getSpawnEggColor_3_; + } + } + + public static int getColorFromItemStack(ItemStack p_getColorFromItemStack_0_, int p_getColorFromItemStack_1_, int p_getColorFromItemStack_2_) { + if (p_getColorFromItemStack_0_ == null) { + return p_getColorFromItemStack_2_; + } else { + Item item = p_getColorFromItemStack_0_.getItem(); + return item == null ? p_getColorFromItemStack_2_ : (item instanceof ItemMonsterPlacer ? getSpawnEggColor((ItemMonsterPlacer) item, p_getColorFromItemStack_0_, p_getColorFromItemStack_1_, p_getColorFromItemStack_2_) : p_getColorFromItemStack_2_); + } + } + + private static float[][] readDyeColors(Properties p_readDyeColors_0_, String p_readDyeColors_1_, String p_readDyeColors_2_, String p_readDyeColors_3_) { + 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 s: p_readDyeColors_0_.keySet()) { + String s1 = p_readDyeColors_0_.getProperty((String) s); + + if (((String) s).startsWith(p_readDyeColors_2_)) { + String s2 = StrUtils.removePrefix((String) s, p_readDyeColors_2_); + + 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(p_readDyeColors_3_ + " colors: " + k); + return afloat1; + } + } + + private static float[] getDyeColors(EnumDyeColor p_getDyeColors_0_, float[][] p_getDyeColors_1_, float[] p_getDyeColors_2_) { + if (p_getDyeColors_1_ == null) { + return p_getDyeColors_2_; + } else if (p_getDyeColors_0_ == null) { + return p_getDyeColors_2_; + } else { + float[] afloat = p_getDyeColors_1_[p_getDyeColors_0_.ordinal()]; + return afloat == null ? p_getDyeColors_2_ : afloat; + } + } + + public static float[] getWolfCollarColors(EnumDyeColor p_getWolfCollarColors_0_, float[] p_getWolfCollarColors_1_) { + return getDyeColors(p_getWolfCollarColors_0_, wolfCollarColors, p_getWolfCollarColors_1_); + } + + public static float[] getSheepColors(EnumDyeColor p_getSheepColors_0_, float[] p_getSheepColors_1_) { + return getDyeColors(p_getSheepColors_0_, sheepColors, p_getSheepColors_1_); + } + + private static int[] readTextColors(Properties p_readTextColors_0_, String p_readTextColors_1_, String p_readTextColors_2_, String p_readTextColors_3_) { + int[] aint = new int[32]; + Arrays.fill((int[]) aint, (int) - 1); + int i = 0; + + for (Object s: p_readTextColors_0_.keySet()) { + String s1 = p_readTextColors_0_.getProperty((String) s); + + if (((String) s).startsWith(p_readTextColors_2_)) { + String s2 = StrUtils.removePrefix((String) s, p_readTextColors_2_); + 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(p_readTextColors_3_ + " colors: " + i); + return aint; + } + } + + public static int getTextColor(int p_getTextColor_0_, int p_getTextColor_1_) { + if (textColors == null) { + return p_getTextColor_1_; + } else if (p_getTextColor_0_ >= 0 && p_getTextColor_0_ < textColors.length) { + int i = textColors[p_getTextColor_0_]; + return i < 0 ? p_getTextColor_1_ : i; + } else { + return p_getTextColor_1_; + } + } + + private static int[] readMapColors(Properties p_readMapColors_0_, String p_readMapColors_1_, String p_readMapColors_2_, String p_readMapColors_3_) { + int[] aint = new int[MapColor.mapColorArray.length]; + Arrays.fill((int[]) aint, (int) - 1); + int i = 0; + + for (Object s: p_readMapColors_0_.keySet()) { + String s1 = p_readMapColors_0_.getProperty((String) s); + + if (((String) s).startsWith(p_readMapColors_2_)) { + String s2 = StrUtils.removePrefix((String) s, p_readMapColors_2_); + 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(p_readMapColors_3_ + " colors: " + i); + return aint; + } + } + + private static int[] readPotionColors(Properties p_readPotionColors_0_, String p_readPotionColors_1_, String p_readPotionColors_2_, String p_readPotionColors_3_) { + int[] aint = new int[Potion.potionTypes.length]; + Arrays.fill((int[]) aint, (int) - 1); + int i = 0; + + for (Object s: p_readPotionColors_0_.keySet()) { + String s1 = p_readPotionColors_0_.getProperty((String) s); + + if (((String) s).startsWith(p_readPotionColors_2_)) { + int j = getPotionId((String) 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(p_readPotionColors_3_ + " colors: " + i); + return aint; + } + } + + private static int getPotionId(String p_getPotionId_0_) { + if (p_getPotionId_0_.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(p_getPotionId_0_)) { + return potion.getId(); + } + } + + return -1; + } + } + + public static int getPotionColor(int p_getPotionColor_0_, int p_getPotionColor_1_) { + if (potionColors == null) { + return p_getPotionColor_1_; + } else if (p_getPotionColor_0_ >= 0 && p_getPotionColor_0_ < potionColors.length) { + int i = potionColors[p_getPotionColor_0_]; + return i < 0 ? p_getPotionColor_1_ : i; + } else { + return p_getPotionColor_1_; + } + } + + private static int getMapColorIndex(String p_getMapColorIndex_0_) { + return p_getMapColorIndex_0_ == null ? -1 : (p_getMapColorIndex_0_.equals("air") ? MapColor.airColor.colorIndex : (p_getMapColorIndex_0_.equals("grass") ? MapColor.grassColor.colorIndex : (p_getMapColorIndex_0_.equals("sand") ? MapColor.sandColor.colorIndex : (p_getMapColorIndex_0_.equals("cloth") ? MapColor.clothColor.colorIndex : (p_getMapColorIndex_0_.equals("tnt") ? MapColor.tntColor.colorIndex : (p_getMapColorIndex_0_.equals("ice") ? MapColor.iceColor.colorIndex : (p_getMapColorIndex_0_.equals("iron") ? MapColor.ironColor.colorIndex : (p_getMapColorIndex_0_.equals("foliage") ? MapColor.foliageColor.colorIndex : (p_getMapColorIndex_0_.equals("clay") ? MapColor.clayColor.colorIndex : (p_getMapColorIndex_0_.equals("dirt") ? MapColor.dirtColor.colorIndex : (p_getMapColorIndex_0_.equals("stone") ? MapColor.stoneColor.colorIndex : (p_getMapColorIndex_0_.equals("water") ? MapColor.waterColor.colorIndex : (p_getMapColorIndex_0_.equals("wood") ? MapColor.woodColor.colorIndex : (p_getMapColorIndex_0_.equals("quartz") ? MapColor.quartzColor.colorIndex : (p_getMapColorIndex_0_.equals("gold") ? MapColor.goldColor.colorIndex : (p_getMapColorIndex_0_.equals("diamond") ? MapColor.diamondColor.colorIndex : (p_getMapColorIndex_0_.equals("lapis") ? MapColor.lapisColor.colorIndex : (p_getMapColorIndex_0_.equals("emerald") ? MapColor.emeraldColor.colorIndex : (p_getMapColorIndex_0_.equals("podzol") ? MapColor.obsidianColor.colorIndex : (p_getMapColorIndex_0_.equals("netherrack") ? MapColor.netherrackColor.colorIndex : (!p_getMapColorIndex_0_.equals("snow") && !p_getMapColorIndex_0_.equals("white") ? (!p_getMapColorIndex_0_.equals("adobe") && !p_getMapColorIndex_0_.equals("orange") ? (p_getMapColorIndex_0_.equals("magenta") ? MapColor.magentaColor.colorIndex : (!p_getMapColorIndex_0_.equals("light_blue") && !p_getMapColorIndex_0_.equals("lightBlue") ? (p_getMapColorIndex_0_.equals("yellow") ? MapColor.yellowColor.colorIndex : (p_getMapColorIndex_0_.equals("lime") ? MapColor.limeColor.colorIndex : (p_getMapColorIndex_0_.equals("pink") ? MapColor.pinkColor.colorIndex : (p_getMapColorIndex_0_.equals("gray") ? MapColor.grayColor.colorIndex : (p_getMapColorIndex_0_.equals("silver") ? MapColor.silverColor.colorIndex : (p_getMapColorIndex_0_.equals("cyan") ? MapColor.cyanColor.colorIndex : (p_getMapColorIndex_0_.equals("purple") ? MapColor.purpleColor.colorIndex : (p_getMapColorIndex_0_.equals("blue") ? MapColor.blueColor.colorIndex : (p_getMapColorIndex_0_.equals("brown") ? MapColor.brownColor.colorIndex : (p_getMapColorIndex_0_.equals("green") ? MapColor.greenColor.colorIndex : (p_getMapColorIndex_0_.equals("red") ? MapColor.redColor.colorIndex : (p_getMapColorIndex_0_.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[] p_setMapColors_0_) { + if (p_setMapColors_0_ != null) { + MapColor[] amapcolor = MapColor.mapColorArray; + boolean flag = false; + + for (int i = 0; i < amapcolor.length && i < p_setMapColors_0_.length; ++i) { + MapColor mapcolor = amapcolor[i]; + + if (mapcolor != null) { + int j = p_setMapColors_0_[i]; + + if (j >= 0 && mapcolor.colorValue != j) { + mapcolor.colorValue = j; + flag = true; + } + } + } + + if (flag) { + Minecraft.getMinecraft().getTextureManager().reloadBannerTextures(); + } + } + } + + private static int getEntityId(String p_getEntityId_0_) { + if (p_getEntityId_0_ == null) { + return -1; + } else { + int i = EntityList.getIDFromString(p_getEntityId_0_); + + if (i < 0) { + return -1; + } else { + String s = EntityList.getStringFromID(i); + return !Config.equals(p_getEntityId_0_, s) ? -1 : i; + } + } + } + + private static void dbg(String p_dbg_0_) { + Config.dbg("CustomColors: " + p_dbg_0_); + } + + private static void warn(String p_warn_0_) { + Config.warn("CustomColors: " + p_warn_0_); + } + + public static int getExpBarTextColor(int p_getExpBarTextColor_0_) { + return expBarTextColor < 0 ? p_getExpBarTextColor_0_ : expBarTextColor; + } + + public static int getBossTextColor(int p_getBossTextColor_0_) { + return bossTextColor < 0 ? p_getBossTextColor_0_ : bossTextColor; + } + + public static int getSignTextColor(int p_getSignTextColor_0_) { + return signTextColor < 0 ? p_getSignTextColor_0_ : signTextColor; + } + + public interface IColorizer { + int getColor(IBlockAccess var1, BlockPos var2); + + boolean isColorConstant(); + } +} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/shadow/ResUtils.java b/src/main/java/net/PeytonPlayz585/shadow/ResUtils.java new file mode 100644 index 0000000..6adfc0c --- /dev/null +++ b/src/main/java/net/PeytonPlayz585/shadow/ResUtils.java @@ -0,0 +1,98 @@ +package net.PeytonPlayz585.shadow; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + +import net.lax1dude.eaglercraft.v1_8.internal.PlatformAssets; +import net.minecraft.client.resources.AbstractResourcePack; +import net.minecraft.client.resources.DefaultResourcePack; +import net.minecraft.client.resources.IResourcePack; +import net.minecraft.util.ResourceLocation; + +public class ResUtils { + public static String[] collectFiles(String p_collectFiles_0_, String p_collectFiles_1_) { + return collectFiles(new String[] { + p_collectFiles_0_ + }, new String[] { + p_collectFiles_1_ + }); + } + + public static String[] collectFiles(String[] p_collectFiles_0_, String[] p_collectFiles_1_) { + Set < String > set = new LinkedHashSet(); + IResourcePack[] airesourcepack = Config.getResourcePacks(); + + for (int i = 0; i < airesourcepack.length; ++i) { + IResourcePack iresourcepack = airesourcepack[i]; + String[] astring = collectFiles(iresourcepack, (String[]) p_collectFiles_0_, (String[]) p_collectFiles_1_, (String[]) null); + set.addAll(Arrays. < String > asList(astring)); + } + + String[] astring1 = (String[]) set.toArray(new String[set.size()]); + return astring1; + } + + public static String[] collectFiles(IResourcePack p_collectFiles_0_, String p_collectFiles_1_, String p_collectFiles_2_, String[] p_collectFiles_3_) { + return collectFiles(p_collectFiles_0_, new String[] { + p_collectFiles_1_ + }, new String[] { + p_collectFiles_2_ + }, p_collectFiles_3_); + } + + public static String[] collectFiles(IResourcePack p_collectFiles_0_, String[] p_collectFiles_1_, String[] p_collectFiles_2_) { + return collectFiles(p_collectFiles_0_, (String[]) p_collectFiles_1_, (String[]) p_collectFiles_2_, (String[]) null); + } + + public static String[] collectFiles(IResourcePack p_collectFiles_0_, String[] p_collectFiles_1_, String[] p_collectFiles_2_, String[] p_collectFiles_3_) { + if (p_collectFiles_0_ instanceof DefaultResourcePack) { + return collectFilesFixed(p_collectFiles_0_, p_collectFiles_3_); + } else if (!(p_collectFiles_0_ instanceof AbstractResourcePack)) { + return new String[0]; + } else { + AbstractResourcePack abstractresourcepack = (AbstractResourcePack) p_collectFiles_0_; + String file1 = abstractresourcepack.resourcePackFile; + return file1 == null || file1.isEmpty() || file1 == "" || file1 == " " ? new String[0] : (isDirectory(file1) ? collectFilesFolder(file1, p_collectFiles_1_, p_collectFiles_2_) : yee()); + } + } + + public static String[] yee() { + System.err.println("[Fatal error] resourcePackFile is NOT empty but it's NOT a directory!"); + return new String[0]; + } + + private static String[] collectFilesFixed(IResourcePack p_collectFilesFixed_0_, String[] p_collectFilesFixed_1_) { + if (p_collectFilesFixed_1_ == null) { + return new String[0]; + } else { + List list = new ArrayList(); + + for (int i = 0; i < p_collectFilesFixed_1_.length; ++i) { + String s = p_collectFilesFixed_1_[i]; + ResourceLocation resourcelocation = new ResourceLocation(s); + + if (p_collectFilesFixed_0_.resourceExists(resourcelocation)) { + list.add(s); + } + } + + String[] astring = (String[])((String[]) list.toArray(new String[list.size()])); + return astring; + } + } + + private static String[] collectFilesFolder(String p_collectFilesFolder_0_, String[] p_collectFilesFolder_1_, String[] p_collectFilesFolder_2_) { + return PlatformAssets.listFilesInDirectory(p_collectFilesFolder_0_, p_collectFilesFolder_1_, p_collectFilesFolder_2_); + } + + public static boolean isFile(String path) { + return path.matches(".+\\.[^.]+$"); + } + + public static boolean isDirectory(String path) { + return path.matches(".+[\\\\/]$"); + } +} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/shadow/StrUtils.java b/src/main/java/net/PeytonPlayz585/shadow/StrUtils.java new file mode 100644 index 0000000..d2b047a --- /dev/null +++ b/src/main/java/net/PeytonPlayz585/shadow/StrUtils.java @@ -0,0 +1,534 @@ +package net.PeytonPlayz585.shadow; + +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; + +public class StrUtils { + public static boolean equalsMask(String p_equalsMask_0_, String p_equalsMask_1_, char p_equalsMask_2_, char p_equalsMask_3_) { + if (p_equalsMask_1_ != null && p_equalsMask_0_ != null) { + if (p_equalsMask_1_.indexOf(p_equalsMask_2_) < 0) { + return p_equalsMask_1_.indexOf(p_equalsMask_3_) < 0 ? p_equalsMask_1_.equals(p_equalsMask_0_) : equalsMaskSingle(p_equalsMask_0_, p_equalsMask_1_, p_equalsMask_3_); + } else { + List list = new ArrayList(); + String s = "" + p_equalsMask_2_; + + if (p_equalsMask_1_.startsWith(s)) { + list.add(""); + } + + StringTokenizer stringtokenizer = new StringTokenizer(p_equalsMask_1_, s); + + while (stringtokenizer.hasMoreElements()) { + list.add(stringtokenizer.nextToken()); + } + + if (p_equalsMask_1_.endsWith(s)) { + list.add(""); + } + + String s1 = (String) list.get(0); + + if (!startsWithMaskSingle(p_equalsMask_0_, s1, p_equalsMask_3_)) { + return false; + } else { + String s2 = (String) list.get(list.size() - 1); + + if (!endsWithMaskSingle(p_equalsMask_0_, s2, p_equalsMask_3_)) { + return false; + } else { + int i = 0; + + for (int j = 0; j < ((List) list).size(); ++j) { + String s3 = (String) list.get(j); + + if (s3.length() > 0) { + int k = indexOfMaskSingle(p_equalsMask_0_, s3, i, p_equalsMask_3_); + + if (k < 0) { + return false; + } + + i = k + s3.length(); + } + } + + return true; + } + } + } + } else { + return p_equalsMask_1_ == p_equalsMask_0_; + } + } + + private static boolean equalsMaskSingle(String p_equalsMaskSingle_0_, String p_equalsMaskSingle_1_, char p_equalsMaskSingle_2_) { + if (p_equalsMaskSingle_0_ != null && p_equalsMaskSingle_1_ != null) { + if (p_equalsMaskSingle_0_.length() != p_equalsMaskSingle_1_.length()) { + return false; + } else { + for (int i = 0; i < p_equalsMaskSingle_1_.length(); ++i) { + char c0 = p_equalsMaskSingle_1_.charAt(i); + + if (c0 != p_equalsMaskSingle_2_ && p_equalsMaskSingle_0_.charAt(i) != c0) { + return false; + } + } + + return true; + } + } else { + return p_equalsMaskSingle_0_ == p_equalsMaskSingle_1_; + } + } + + private static int indexOfMaskSingle(String p_indexOfMaskSingle_0_, String p_indexOfMaskSingle_1_, int p_indexOfMaskSingle_2_, char p_indexOfMaskSingle_3_) { + if (p_indexOfMaskSingle_0_ != null && p_indexOfMaskSingle_1_ != null) { + if (p_indexOfMaskSingle_2_ >= 0 && p_indexOfMaskSingle_2_ <= p_indexOfMaskSingle_0_.length()) { + if (p_indexOfMaskSingle_0_.length() < p_indexOfMaskSingle_2_ + p_indexOfMaskSingle_1_.length()) { + return -1; + } else { + for (int i = p_indexOfMaskSingle_2_; i + p_indexOfMaskSingle_1_.length() <= p_indexOfMaskSingle_0_.length(); ++i) { + String s = p_indexOfMaskSingle_0_.substring(i, i + p_indexOfMaskSingle_1_.length()); + + if (equalsMaskSingle(s, p_indexOfMaskSingle_1_, p_indexOfMaskSingle_3_)) { + return i; + } + } + + return -1; + } + } else { + return -1; + } + } else { + return -1; + } + } + + private static boolean endsWithMaskSingle(String p_endsWithMaskSingle_0_, String p_endsWithMaskSingle_1_, char p_endsWithMaskSingle_2_) { + if (p_endsWithMaskSingle_0_ != null && p_endsWithMaskSingle_1_ != null) { + if (p_endsWithMaskSingle_0_.length() < p_endsWithMaskSingle_1_.length()) { + return false; + } else { + String s = p_endsWithMaskSingle_0_.substring(p_endsWithMaskSingle_0_.length() - p_endsWithMaskSingle_1_.length(), p_endsWithMaskSingle_0_.length()); + return equalsMaskSingle(s, p_endsWithMaskSingle_1_, p_endsWithMaskSingle_2_); + } + } else { + return p_endsWithMaskSingle_0_ == p_endsWithMaskSingle_1_; + } + } + + private static boolean startsWithMaskSingle(String p_startsWithMaskSingle_0_, String p_startsWithMaskSingle_1_, char p_startsWithMaskSingle_2_) { + if (p_startsWithMaskSingle_0_ != null && p_startsWithMaskSingle_1_ != null) { + if (p_startsWithMaskSingle_0_.length() < p_startsWithMaskSingle_1_.length()) { + return false; + } else { + String s = p_startsWithMaskSingle_0_.substring(0, p_startsWithMaskSingle_1_.length()); + return equalsMaskSingle(s, p_startsWithMaskSingle_1_, p_startsWithMaskSingle_2_); + } + } else { + return p_startsWithMaskSingle_0_ == p_startsWithMaskSingle_1_; + } + } + + public static boolean equalsMask(String p_equalsMask_0_, String[] p_equalsMask_1_, char p_equalsMask_2_) { + for (int i = 0; i < p_equalsMask_1_.length; ++i) { + String s = p_equalsMask_1_[i]; + + if (equalsMask(p_equalsMask_0_, s, p_equalsMask_2_)) { + return true; + } + } + + return false; + } + + public static boolean equalsMask(String p_equalsMask_0_, String p_equalsMask_1_, char p_equalsMask_2_) { + if (p_equalsMask_1_ != null && p_equalsMask_0_ != null) { + if (p_equalsMask_1_.indexOf(p_equalsMask_2_) < 0) { + return p_equalsMask_1_.equals(p_equalsMask_0_); + } else { + List list = new ArrayList(); + String s = "" + p_equalsMask_2_; + + if (p_equalsMask_1_.startsWith(s)) { + list.add(""); + } + + StringTokenizer stringtokenizer = new StringTokenizer(p_equalsMask_1_, s); + + while (stringtokenizer.hasMoreElements()) { + list.add(stringtokenizer.nextToken()); + } + + if (p_equalsMask_1_.endsWith(s)) { + list.add(""); + } + + String s1 = (String) list.get(0); + + if (!p_equalsMask_0_.startsWith(s1)) { + return false; + } else { + String s2 = (String) list.get(list.size() - 1); + + if (!p_equalsMask_0_.endsWith(s2)) { + return false; + } else { + int i = 0; + + for (int j = 0; j < ((List) list).size(); ++j) { + String s3 = (String) list.get(j); + + if (s3.length() > 0) { + int k = p_equalsMask_0_.indexOf(s3, i); + + if (k < 0) { + return false; + } + + i = k + s3.length(); + } + } + + return true; + } + } + } + } else { + return p_equalsMask_1_ == p_equalsMask_0_; + } + } + + public static String[] split(String p_split_0_, String p_split_1_) { + if (p_split_0_ != null && p_split_0_.length() > 0) { + if (p_split_1_ == null) { + return new String[] { + p_split_0_ + }; + } else { + List list = new ArrayList(); + int i = 0; + + for (int j = 0; j < p_split_0_.length(); ++j) { + char c0 = p_split_0_.charAt(j); + + if (equals(c0, p_split_1_)) { + list.add(p_split_0_.substring(i, j)); + i = j + 1; + } + } + + list.add(p_split_0_.substring(i, p_split_0_.length())); + return (String[])((String[]) list.toArray(new String[list.size()])); + } + } else { + return new String[0]; + } + } + + private static boolean equals(char p_equals_0_, String p_equals_1_) { + for (int i = 0; i < p_equals_1_.length(); ++i) { + if (p_equals_1_.charAt(i) == p_equals_0_) { + return true; + } + } + + return false; + } + + public static boolean equalsTrim(String p_equalsTrim_0_, String p_equalsTrim_1_) { + if (p_equalsTrim_0_ != null) { + p_equalsTrim_0_ = p_equalsTrim_0_.trim(); + } + + if (p_equalsTrim_1_ != null) { + p_equalsTrim_1_ = p_equalsTrim_1_.trim(); + } + + return equals(p_equalsTrim_0_, p_equalsTrim_1_); + } + + public static boolean isEmpty(String p_isEmpty_0_) { + return p_isEmpty_0_ == null ? true : p_isEmpty_0_.trim().length() <= 0; + } + + public static String stringInc(String p_stringInc_0_) { + int i = parseInt(p_stringInc_0_, -1); + + if (i == -1) { + return ""; + } else { + ++i; + String s = "" + i; + return s.length() > p_stringInc_0_.length() ? "" : fillLeft("" + i, p_stringInc_0_.length(), '0'); + } + } + + public static int parseInt(String p_parseInt_0_, int p_parseInt_1_) { + if (p_parseInt_0_ == null) { + return p_parseInt_1_; + } else { + try { + return Integer.parseInt(p_parseInt_0_); + } catch (NumberFormatException var3) { + return p_parseInt_1_; + } + } + } + + public static boolean isFilled(String p_isFilled_0_) { + return !isEmpty(p_isFilled_0_); + } + + public static String addIfNotContains(String p_addIfNotContains_0_, String p_addIfNotContains_1_) { + for (int i = 0; i < p_addIfNotContains_1_.length(); ++i) { + if (p_addIfNotContains_0_.indexOf(p_addIfNotContains_1_.charAt(i)) < 0) { + p_addIfNotContains_0_ = p_addIfNotContains_0_ + p_addIfNotContains_1_.charAt(i); + } + } + + return p_addIfNotContains_0_; + } + + public static String fillLeft(String p_fillLeft_0_, int p_fillLeft_1_, char p_fillLeft_2_) { + if (p_fillLeft_0_ == null) { + p_fillLeft_0_ = ""; + } + + if (p_fillLeft_0_.length() >= p_fillLeft_1_) { + return p_fillLeft_0_; + } else { + StringBuffer stringbuffer = new StringBuffer(p_fillLeft_0_); + + while (stringbuffer.length() < p_fillLeft_1_) { + stringbuffer.insert(0, (char) p_fillLeft_2_); + } + + return stringbuffer.toString(); + } + } + + public static String fillRight(String p_fillRight_0_, int p_fillRight_1_, char p_fillRight_2_) { + if (p_fillRight_0_ == null) { + p_fillRight_0_ = ""; + } + + if (p_fillRight_0_.length() >= p_fillRight_1_) { + return p_fillRight_0_; + } else { + StringBuffer stringbuffer = new StringBuffer(p_fillRight_0_); + + while (stringbuffer.length() < p_fillRight_1_) { + stringbuffer.append(p_fillRight_2_); + } + + return stringbuffer.toString(); + } + } + + public static boolean equals(Object p_equals_0_, Object p_equals_1_) { + return p_equals_0_ == p_equals_1_ ? true : (p_equals_0_ != null && p_equals_0_.equals(p_equals_1_) ? true : p_equals_1_ != null && p_equals_1_.equals(p_equals_0_)); + } + + public static boolean startsWith(String p_startsWith_0_, String[] p_startsWith_1_) { + if (p_startsWith_0_ == null) { + return false; + } else if (p_startsWith_1_ == null) { + return false; + } else { + for (int i = 0; i < p_startsWith_1_.length; ++i) { + String s = p_startsWith_1_[i]; + + if (p_startsWith_0_.startsWith(s)) { + return true; + } + } + + return false; + } + } + + public static boolean endsWith(String p_endsWith_0_, String[] p_endsWith_1_) { + if (p_endsWith_0_ == null) { + return false; + } else if (p_endsWith_1_ == null) { + return false; + } else { + for (int i = 0; i < p_endsWith_1_.length; ++i) { + String s = p_endsWith_1_[i]; + + if (p_endsWith_0_.endsWith(s)) { + return true; + } + } + + return false; + } + } + + public static String removePrefix(String p_removePrefix_0_, String p_removePrefix_1_) { + if (p_removePrefix_0_ != null && p_removePrefix_1_ != null) { + if (p_removePrefix_0_.startsWith(p_removePrefix_1_)) { + p_removePrefix_0_ = p_removePrefix_0_.substring(p_removePrefix_1_.length()); + } + + return p_removePrefix_0_; + } else { + return p_removePrefix_0_; + } + } + + public static String removeSuffix(String p_removeSuffix_0_, String p_removeSuffix_1_) { + if (p_removeSuffix_0_ != null && p_removeSuffix_1_ != null) { + if (p_removeSuffix_0_.endsWith(p_removeSuffix_1_)) { + p_removeSuffix_0_ = p_removeSuffix_0_.substring(0, p_removeSuffix_0_.length() - p_removeSuffix_1_.length()); + } + + return p_removeSuffix_0_; + } else { + return p_removeSuffix_0_; + } + } + + public static String replaceSuffix(String p_replaceSuffix_0_, String p_replaceSuffix_1_, String p_replaceSuffix_2_) { + if (p_replaceSuffix_0_ != null && p_replaceSuffix_1_ != null) { + if (p_replaceSuffix_2_ == null) { + p_replaceSuffix_2_ = ""; + } + + if (p_replaceSuffix_0_.endsWith(p_replaceSuffix_1_)) { + p_replaceSuffix_0_ = p_replaceSuffix_0_.substring(0, p_replaceSuffix_0_.length() - p_replaceSuffix_1_.length()); + } + + return p_replaceSuffix_0_ + p_replaceSuffix_2_; + } else { + return p_replaceSuffix_0_; + } + } + + public static int findPrefix(String[] p_findPrefix_0_, String p_findPrefix_1_) { + if (p_findPrefix_0_ != null && p_findPrefix_1_ != null) { + for (int i = 0; i < p_findPrefix_0_.length; ++i) { + String s = p_findPrefix_0_[i]; + + if (s.startsWith(p_findPrefix_1_)) { + return i; + } + } + + return -1; + } else { + return -1; + } + } + + public static int findSuffix(String[] p_findSuffix_0_, String p_findSuffix_1_) { + if (p_findSuffix_0_ != null && p_findSuffix_1_ != null) { + for (int i = 0; i < p_findSuffix_0_.length; ++i) { + String s = p_findSuffix_0_[i]; + + if (s.endsWith(p_findSuffix_1_)) { + return i; + } + } + + return -1; + } else { + return -1; + } + } + + public static String[] remove(String[] p_remove_0_, int p_remove_1_, int p_remove_2_) { + if (p_remove_0_ == null) { + return p_remove_0_; + } else if (p_remove_2_ > 0 && p_remove_1_ < p_remove_0_.length) { + if (p_remove_1_ >= p_remove_2_) { + return p_remove_0_; + } else { + List < String > list = new ArrayList(p_remove_0_.length); + + for (int i = 0; i < p_remove_0_.length; ++i) { + String s = p_remove_0_[i]; + + if (i < p_remove_1_ || i >= p_remove_2_) { + list.add(s); + } + } + + String[] astring = (String[]) list.toArray(new String[list.size()]); + return astring; + } + } else { + return p_remove_0_; + } + } + + public static String removeSuffix(String p_removeSuffix_0_, String[] p_removeSuffix_1_) { + if (p_removeSuffix_0_ != null && p_removeSuffix_1_ != null) { + int i = p_removeSuffix_0_.length(); + + for (int j = 0; j < p_removeSuffix_1_.length; ++j) { + String s = p_removeSuffix_1_[j]; + p_removeSuffix_0_ = removeSuffix(p_removeSuffix_0_, s); + + if (p_removeSuffix_0_.length() != i) { + break; + } + } + + return p_removeSuffix_0_; + } else { + return p_removeSuffix_0_; + } + } + + public static String removePrefix(String p_removePrefix_0_, String[] p_removePrefix_1_) { + if (p_removePrefix_0_ != null && p_removePrefix_1_ != null) { + int i = p_removePrefix_0_.length(); + + for (int j = 0; j < p_removePrefix_1_.length; ++j) { + String s = p_removePrefix_1_[j]; + p_removePrefix_0_ = removePrefix(p_removePrefix_0_, s); + + if (p_removePrefix_0_.length() != i) { + break; + } + } + + return p_removePrefix_0_; + } else { + return p_removePrefix_0_; + } + } + + public static String removePrefixSuffix(String p_removePrefixSuffix_0_, String[] p_removePrefixSuffix_1_, String[] p_removePrefixSuffix_2_) { + p_removePrefixSuffix_0_ = removePrefix(p_removePrefixSuffix_0_, p_removePrefixSuffix_1_); + p_removePrefixSuffix_0_ = removeSuffix(p_removePrefixSuffix_0_, p_removePrefixSuffix_2_); + return p_removePrefixSuffix_0_; + } + + public static String removePrefixSuffix(String p_removePrefixSuffix_0_, String p_removePrefixSuffix_1_, String p_removePrefixSuffix_2_) { + return removePrefixSuffix(p_removePrefixSuffix_0_, new String[] { + p_removePrefixSuffix_1_ + }, new String[] { + p_removePrefixSuffix_2_ + }); + } + + public static String getSegment(String p_getSegment_0_, String p_getSegment_1_, String p_getSegment_2_) { + if (p_getSegment_0_ != null && p_getSegment_1_ != null && p_getSegment_2_ != null) { + int i = p_getSegment_0_.indexOf(p_getSegment_1_); + + if (i < 0) { + return null; + } else { + int j = p_getSegment_0_.indexOf(p_getSegment_2_, i); + return j < 0 ? null : p_getSegment_0_.substring(i, j + p_getSegment_2_.length()); + } + } else { + return null; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/shadow/TextureUtils.java b/src/main/java/net/PeytonPlayz585/shadow/TextureUtils.java index 7e4006b..8d81b5b 100644 --- a/src/main/java/net/PeytonPlayz585/shadow/TextureUtils.java +++ b/src/main/java/net/PeytonPlayz585/shadow/TextureUtils.java @@ -130,6 +130,7 @@ public class TextureUtils { public static void resourcesReloaded() { if (getTextureMapBlocks() != null) { Config.dbg("*** Reloading custom textures ***"); + CustomColors.update(); CustomSky.reset(); update(); BetterGrass.update(); diff --git a/src/main/java/net/PeytonPlayz585/shadow/apache/CompareToBuilder.java b/src/main/java/net/PeytonPlayz585/shadow/apache/CompareToBuilder.java new file mode 100644 index 0000000..0125ab3 --- /dev/null +++ b/src/main/java/net/PeytonPlayz585/shadow/apache/CompareToBuilder.java @@ -0,0 +1,990 @@ +/* + * 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.lang.reflect.AccessibleObject; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.Collection; +import java.util.Comparator; +import java.util.Objects; + +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.builder.Builder; + +import net.lax1dude.eaglercraft.v1_8.ArrayUtils; + +/** + * Assists in implementing {@link Comparable#compareTo(Object)} methods. + * + *

It is consistent with {@code equals(Object)} and + * {@code hashCode()} built with {@link EqualsBuilder} and + * {@link HashCodeBuilder}.

+ * + *

Two Objects that compare equal using {@code equals(Object)} should normally + * also compare equal using {@code compareTo(Object)}.

+ * + *

All relevant fields should be included in the calculation of the + * comparison. Derived fields may be ignored. The same fields, in the same + * order, should be used in both {@code compareTo(Object)} and + * {@code equals(Object)}.

+ * + *

To use this class write code as follows:

+ * + *
+ * public class MyClass {
+ *   String field1;
+ *   int field2;
+ *   boolean field3;
+ *
+ *   ...
+ *
+ *   public int compareTo(Object o) {
+ *     MyClass myClass = (MyClass) o;
+ *     return new CompareToBuilder()
+ *       .appendSuper(super.compareTo(o)
+ *       .append(this.field1, myClass.field1)
+ *       .append(this.field2, myClass.field2)
+ *       .append(this.field3, myClass.field3)
+ *       .toComparison();
+ *   }
+ * }
+ * 
+ * + *

Values are compared in the order they are appended to the builder. If any comparison returns + * a non-zero result, then that value will be the result returned by {@code toComparison()} and all + * subsequent comparisons are skipped.

+ * + *

Alternatively, there are {@link #reflectionCompare(Object, Object) reflectionCompare} methods that use + * reflection to determine the fields to append. Because fields can be private, + * {@code reflectionCompare} uses {@link java.lang.reflect.AccessibleObject#setAccessible(boolean)} to + * bypass normal access control checks. This will fail under a security manager, + * unless the appropriate permissions are set up correctly. It is also + * slower than appending explicitly.

+ * + *

A typical implementation of {@code compareTo(Object)} using + * {@code reflectionCompare} looks like:

+ + *
+ * public int compareTo(Object o) {
+ *   return CompareToBuilder.reflectionCompare(this, o);
+ * }
+ * 
+ * + *

The reflective methods compare object fields in the order returned by + * {@link Class#getDeclaredFields()}. The fields of the class are compared first, followed by those + * of its parent classes (in order from the bottom to the top of the class hierarchy).

+ * + * @see Comparable + * @see Object#equals(Object) + * @see Object#hashCode() + * @see EqualsBuilder + * @see HashCodeBuilder + * @since 1.0 + */ +public class CompareToBuilder implements Builder { + + /** + * Appends to {@code builder} the comparison of {@code lhs} + * to {@code rhs} using the fields defined in {@code clazz}. + * + * @param lhs left-hand side object + * @param rhs right-hand side object + * @param clazz {@link Class} that defines fields to be compared + * @param builder {@link CompareToBuilder} to append to + * @param useTransients whether to compare transient fields + * @param excludeFields fields to exclude + */ + private static void reflectionAppend( + final Object lhs, + final Object rhs, + final Class clazz, + final CompareToBuilder builder, + final boolean useTransients, + final String[] excludeFields) { + + final Field[] fields = clazz.getDeclaredFields(); + AccessibleObject.setAccessible(fields, true); + for (int i = 0; i < fields.length && builder.comparison == 0; i++) { + final Field field = fields[i]; + if (!ArrayUtils.contains(excludeFields, field.getName()) + && !field.getName().contains("$") + && (useTransients || !Modifier.isTransient(field.getModifiers())) + && !Modifier.isStatic(field.getModifiers())) { + // IllegalAccessException can't happen. Would get a Security exception instead. + // Throw a runtime exception in case the impossible happens. + builder.append(Reflection.getUnchecked(field, lhs), Reflection.getUnchecked(field, rhs)); + } + } + } + + /** + * Compares two {@link Object}s via reflection. + * + *

Fields can be private, thus {@code AccessibleObject.setAccessible} + * is used to bypass normal access control checks. This will fail under a + * security manager unless the appropriate permissions are set.

+ * + * + * + *

If both {@code lhs} and {@code rhs} are {@code null}, + * they are considered equal.

+ * + * @param lhs left-hand side object + * @param rhs right-hand side object + * @return a negative integer, zero, or a positive integer as {@code lhs} + * is less than, equal to, or greater than {@code rhs} + * @throws NullPointerException if either (but not both) parameters are + * {@code null} + * @throws ClassCastException if {@code rhs} is not assignment-compatible + * with {@code lhs} + */ + public static int reflectionCompare(final Object lhs, final Object rhs) { + return reflectionCompare(lhs, rhs, false, null); + } + + /** + * Compares two {@link Object}s via reflection. + * + *

Fields can be private, thus {@code AccessibleObject.setAccessible} + * is used to bypass normal access control checks. This will fail under a + * security manager unless the appropriate permissions are set.

+ * + * + * + *

If both {@code lhs} and {@code rhs} are {@code null}, + * they are considered equal.

+ * + * @param lhs left-hand side object + * @param rhs right-hand side object + * @param compareTransients whether to compare transient fields + * @return a negative integer, zero, or a positive integer as {@code lhs} + * is less than, equal to, or greater than {@code rhs} + * @throws NullPointerException if either {@code lhs} or {@code rhs} + * (but not both) is {@code null} + * @throws ClassCastException if {@code rhs} is not assignment-compatible + * with {@code lhs} + */ + public static int reflectionCompare(final Object lhs, final Object rhs, final boolean compareTransients) { + return reflectionCompare(lhs, rhs, compareTransients, null); + } + + /** + * Compares two {@link Object}s via reflection. + * + *

Fields can be private, thus {@code AccessibleObject.setAccessible} + * is used to bypass normal access control checks. This will fail under a + * security manager unless the appropriate permissions are set.

+ * + * + * + *

If both {@code lhs} and {@code rhs} are {@code null}, + * they are considered equal.

+ * + * @param lhs left-hand side object + * @param rhs right-hand side object + * @param compareTransients whether to compare transient fields + * @param reflectUpToClass last superclass for which fields are compared + * @param excludeFields fields to exclude + * @return a negative integer, zero, or a positive integer as {@code lhs} + * is less than, equal to, or greater than {@code rhs} + * @throws NullPointerException if either {@code lhs} or {@code rhs} + * (but not both) is {@code null} + * @throws ClassCastException if {@code rhs} is not assignment-compatible + * with {@code lhs} + * @since 2.2 (2.0 as {@code reflectionCompare(Object, Object, boolean, Class)}) + */ + public static int reflectionCompare( + final Object lhs, + final Object rhs, + final boolean compareTransients, + final Class reflectUpToClass, + final String... excludeFields) { + + if (lhs == rhs) { + return 0; + } + Objects.requireNonNull(lhs, "lhs"); + Objects.requireNonNull(rhs, "rhs"); + + Class lhsClazz = lhs.getClass(); + if (!lhsClazz.isInstance(rhs)) { + throw new ClassCastException(); + } + final CompareToBuilder compareToBuilder = new CompareToBuilder(); + reflectionAppend(lhs, rhs, lhsClazz, compareToBuilder, compareTransients, excludeFields); + while (lhsClazz.getSuperclass() != null && lhsClazz != reflectUpToClass) { + lhsClazz = lhsClazz.getSuperclass(); + reflectionAppend(lhs, rhs, lhsClazz, compareToBuilder, compareTransients, excludeFields); + } + return compareToBuilder.toComparison(); + } + + /** + * Compares two {@link Object}s via reflection. + * + *

Fields can be private, thus {@code AccessibleObject.setAccessible} + * is used to bypass normal access control checks. This will fail under a + * security manager unless the appropriate permissions are set.

+ * + * + * + *

If both {@code lhs} and {@code rhs} are {@code null}, + * they are considered equal.

+ * + * @param lhs left-hand side object + * @param rhs right-hand side object + * @param excludeFields array of fields to exclude + * @return a negative integer, zero, or a positive integer as {@code lhs} + * is less than, equal to, or greater than {@code rhs} + * @throws NullPointerException if either {@code lhs} or {@code rhs} + * (but not both) is {@code null} + * @throws ClassCastException if {@code rhs} is not assignment-compatible + * with {@code lhs} + * @since 2.2 + */ + public static int reflectionCompare(final Object lhs, final Object rhs, final String... excludeFields) { + return reflectionCompare(lhs, rhs, false, null, excludeFields); + } + + /** + * Current state of the comparison as appended fields are checked. + */ + private int comparison; + + /** + * Constructor for CompareToBuilder. + * + *

Starts off assuming that the objects are equal. Multiple calls are + * then made to the various append methods, followed by a call to + * {@link #toComparison} to get the result.

+ */ + public CompareToBuilder() { + comparison = 0; + } + + /** + * Appends to the {@code builder} the comparison of + * two {@code booleans}s. + * + * @param lhs left-hand side value + * @param rhs right-hand side value + * @return this + */ + public CompareToBuilder append(final boolean lhs, final boolean rhs) { + if (comparison != 0) { + return this; + } + if (lhs == rhs) { + return this; + } + if (lhs) { + comparison = 1; + } else { + comparison = -1; + } + return this; + } + + /** + * Appends to the {@code builder} the deep comparison of + * two {@code boolean} arrays. + * + *
    + *
  1. Check if arrays are the same using {@code ==}
  2. + *
  3. Check if for {@code null}, {@code null} is less than non-{@code null}
  4. + *
  5. Check array length, a shorter length array is less than a longer length array
  6. + *
  7. Check array contents element by element using {@link #append(boolean, boolean)}
  8. + *
+ * + * @param lhs left-hand side array + * @param rhs right-hand side array + * @return this + */ + public CompareToBuilder append(final boolean[] lhs, final boolean[] rhs) { + if (comparison != 0) { + return this; + } + if (lhs == rhs) { + return this; + } + if (lhs == null) { + comparison = -1; + return this; + } + if (rhs == null) { + comparison = 1; + return this; + } + if (lhs.length != rhs.length) { + comparison = lhs.length < rhs.length ? -1 : 1; + return this; + } + for (int i = 0; i < lhs.length && comparison == 0; i++) { + append(lhs[i], rhs[i]); + } + return this; + } + + /** + * Appends to the {@code builder} the comparison of + * two {@code byte}s. + * + * @param lhs left-hand side value + * @param rhs right-hand side value + * @return this + */ + public CompareToBuilder append(final byte lhs, final byte rhs) { + if (comparison != 0) { + return this; + } + comparison = Byte.compare(lhs, rhs); + return this; + } + + /** + * Appends to the {@code builder} the deep comparison of + * two {@code byte} arrays. + * + *
    + *
  1. Check if arrays are the same using {@code ==}
  2. + *
  3. Check if for {@code null}, {@code null} is less than non-{@code null}
  4. + *
  5. Check array length, a shorter length array is less than a longer length array
  6. + *
  7. Check array contents element by element using {@link #append(byte, byte)}
  8. + *
+ * + * @param lhs left-hand side array + * @param rhs right-hand side array + * @return this + */ + public CompareToBuilder append(final byte[] lhs, final byte[] rhs) { + if (comparison != 0) { + return this; + } + if (lhs == rhs) { + return this; + } + if (lhs == null) { + comparison = -1; + return this; + } + if (rhs == null) { + comparison = 1; + return this; + } + if (lhs.length != rhs.length) { + comparison = lhs.length < rhs.length ? -1 : 1; + return this; + } + for (int i = 0; i < lhs.length && comparison == 0; i++) { + append(lhs[i], rhs[i]); + } + return this; + } + + /** + * Appends to the {@code builder} the comparison of + * two {@code char}s. + * + * @param lhs left-hand side value + * @param rhs right-hand side value + * @return this + */ + public CompareToBuilder append(final char lhs, final char rhs) { + if (comparison != 0) { + return this; + } + comparison = Character.compare(lhs, rhs); + return this; + } + + /** + * Appends to the {@code builder} the deep comparison of + * two {@code char} arrays. + * + *
    + *
  1. Check if arrays are the same using {@code ==}
  2. + *
  3. Check if for {@code null}, {@code null} is less than non-{@code null}
  4. + *
  5. Check array length, a shorter length array is less than a longer length array
  6. + *
  7. Check array contents element by element using {@link #append(char, char)}
  8. + *
+ * + * @param lhs left-hand side array + * @param rhs right-hand side array + * @return this + */ + public CompareToBuilder append(final char[] lhs, final char[] rhs) { + if (comparison != 0) { + return this; + } + if (lhs == rhs) { + return this; + } + if (lhs == null) { + comparison = -1; + return this; + } + if (rhs == null) { + comparison = 1; + return this; + } + if (lhs.length != rhs.length) { + comparison = lhs.length < rhs.length ? -1 : 1; + return this; + } + for (int i = 0; i < lhs.length && comparison == 0; i++) { + append(lhs[i], rhs[i]); + } + return this; + } + + /** + * Appends to the {@code builder} the comparison of + * two {@code double}s. + * + *

This handles NaNs, Infinities, and {@code -0.0}.

+ * + *

It is compatible with the hash code generated by + * {@link HashCodeBuilder}.

+ * + * @param lhs left-hand side value + * @param rhs right-hand side value + * @return this + */ + public CompareToBuilder append(final double lhs, final double rhs) { + if (comparison != 0) { + return this; + } + comparison = Double.compare(lhs, rhs); + return this; + } + + /** + * Appends to the {@code builder} the deep comparison of + * two {@code double} arrays. + * + *
    + *
  1. Check if arrays are the same using {@code ==}
  2. + *
  3. Check if for {@code null}, {@code null} is less than non-{@code null}
  4. + *
  5. Check array length, a shorter length array is less than a longer length array
  6. + *
  7. Check array contents element by element using {@link #append(double, double)}
  8. + *
+ * + * @param lhs left-hand side array + * @param rhs right-hand side array + * @return this + */ + public CompareToBuilder append(final double[] lhs, final double[] rhs) { + if (comparison != 0) { + return this; + } + if (lhs == rhs) { + return this; + } + if (lhs == null) { + comparison = -1; + return this; + } + if (rhs == null) { + comparison = 1; + return this; + } + if (lhs.length != rhs.length) { + comparison = lhs.length < rhs.length ? -1 : 1; + return this; + } + for (int i = 0; i < lhs.length && comparison == 0; i++) { + append(lhs[i], rhs[i]); + } + return this; + } + + /** + * Appends to the {@code builder} the comparison of + * two {@code float}s. + * + *

This handles NaNs, Infinities, and {@code -0.0}.

+ * + *

It is compatible with the hash code generated by + * {@link HashCodeBuilder}.

+ * + * @param lhs left-hand side value + * @param rhs right-hand side value + * @return this + */ + public CompareToBuilder append(final float lhs, final float rhs) { + if (comparison != 0) { + return this; + } + comparison = Float.compare(lhs, rhs); + return this; + } + + /** + * Appends to the {@code builder} the deep comparison of + * two {@code float} arrays. + * + *
    + *
  1. Check if arrays are the same using {@code ==}
  2. + *
  3. Check if for {@code null}, {@code null} is less than non-{@code null}
  4. + *
  5. Check array length, a shorter length array is less than a longer length array
  6. + *
  7. Check array contents element by element using {@link #append(float, float)}
  8. + *
+ * + * @param lhs left-hand side array + * @param rhs right-hand side array + * @return this + */ + public CompareToBuilder append(final float[] lhs, final float[] rhs) { + if (comparison != 0) { + return this; + } + if (lhs == rhs) { + return this; + } + if (lhs == null) { + comparison = -1; + return this; + } + if (rhs == null) { + comparison = 1; + return this; + } + if (lhs.length != rhs.length) { + comparison = lhs.length < rhs.length ? -1 : 1; + return this; + } + for (int i = 0; i < lhs.length && comparison == 0; i++) { + append(lhs[i], rhs[i]); + } + return this; + } + + /** + * Appends to the {@code builder} the comparison of + * two {@code int}s. + * + * @param lhs left-hand side value + * @param rhs right-hand side value + * @return this + */ + public CompareToBuilder append(final int lhs, final int rhs) { + if (comparison != 0) { + return this; + } + comparison = Integer.compare(lhs, rhs); + return this; + } + + /** + * Appends to the {@code builder} the deep comparison of + * two {@code int} arrays. + * + *
    + *
  1. Check if arrays are the same using {@code ==}
  2. + *
  3. Check if for {@code null}, {@code null} is less than non-{@code null}
  4. + *
  5. Check array length, a shorter length array is less than a longer length array
  6. + *
  7. Check array contents element by element using {@link #append(int, int)}
  8. + *
+ * + * @param lhs left-hand side array + * @param rhs right-hand side array + * @return this + */ + public CompareToBuilder append(final int[] lhs, final int[] rhs) { + if (comparison != 0) { + return this; + } + if (lhs == rhs) { + return this; + } + if (lhs == null) { + comparison = -1; + return this; + } + if (rhs == null) { + comparison = 1; + return this; + } + if (lhs.length != rhs.length) { + comparison = lhs.length < rhs.length ? -1 : 1; + return this; + } + for (int i = 0; i < lhs.length && comparison == 0; i++) { + append(lhs[i], rhs[i]); + } + return this; + } + + /** + * Appends to the {@code builder} the comparison of + * two {@code long}s. + * + * @param lhs left-hand side value + * @param rhs right-hand side value + * @return this + */ + public CompareToBuilder append(final long lhs, final long rhs) { + if (comparison != 0) { + return this; + } + comparison = Long.compare(lhs, rhs); + return this; + } + + /** + * Appends to the {@code builder} the deep comparison of + * two {@code long} arrays. + * + *
    + *
  1. Check if arrays are the same using {@code ==}
  2. + *
  3. Check if for {@code null}, {@code null} is less than non-{@code null}
  4. + *
  5. Check array length, a shorter length array is less than a longer length array
  6. + *
  7. Check array contents element by element using {@link #append(long, long)}
  8. + *
+ * + * @param lhs left-hand side array + * @param rhs right-hand side array + * @return this + */ + public CompareToBuilder append(final long[] lhs, final long[] rhs) { + if (comparison != 0) { + return this; + } + if (lhs == rhs) { + return this; + } + if (lhs == null) { + comparison = -1; + return this; + } + if (rhs == null) { + comparison = 1; + return this; + } + if (lhs.length != rhs.length) { + comparison = lhs.length < rhs.length ? -1 : 1; + return this; + } + for (int i = 0; i < lhs.length && comparison == 0; i++) { + append(lhs[i], rhs[i]); + } + return this; + } + + /** + * Appends to the {@code builder} the comparison of + * two {@link Object}s. + * + *
    + *
  1. Check if {@code lhs == rhs}
  2. + *
  3. Check if either {@code lhs} or {@code rhs} is {@code null}, + * a {@code null} object is less than a non-{@code null} object
  4. + *
  5. Check the object contents
  6. + *
+ * + *

{@code lhs} must either be an array or implement {@link Comparable}.

+ * + * @param lhs left-hand side object + * @param rhs right-hand side object + * @return this + * @throws ClassCastException if {@code rhs} is not assignment-compatible + * with {@code lhs} + */ + public CompareToBuilder append(final Object lhs, final Object rhs) { + return append(lhs, rhs, null); + } + + /** + * Appends to the {@code builder} the comparison of + * two {@link Object}s. + * + *
    + *
  1. Check if {@code lhs == rhs}
  2. + *
  3. Check if either {@code lhs} or {@code rhs} is {@code null}, + * a {@code null} object is less than a non-{@code null} object
  4. + *
  5. Check the object contents
  6. + *
+ * + *

If {@code lhs} is an array, array comparison methods will be used. + * Otherwise {@code comparator} will be used to compare the objects. + * If {@code comparator} is {@code null}, {@code lhs} must + * implement {@link Comparable} instead.

+ * + * @param lhs left-hand side object + * @param rhs right-hand side object + * @param comparator {@link Comparator} used to compare the objects, + * {@code null} means treat lhs as {@link Comparable} + * @return this + * @throws ClassCastException if {@code rhs} is not assignment-compatible + * with {@code lhs} + * @since 2.0 + */ + public CompareToBuilder append(final Object lhs, final Object rhs, final Comparator comparator) { + if (comparison != 0) { + return this; + } + if (lhs == rhs) { + return this; + } + if (lhs == null) { + comparison = -1; + return this; + } + if (rhs == null) { + comparison = 1; + return this; + } + if (ObjectUtils.isArray(lhs)) { + // factor out array case in order to keep method small enough to be inlined + appendArray(lhs, rhs, comparator); + } else // the simple case, not an array, just test the element + if (comparator == null) { + @SuppressWarnings("unchecked") // assume this can be done; if not throw CCE as per Javadoc + final Comparable comparable = (Comparable) lhs; + comparison = comparable.compareTo(rhs); + } else { + @SuppressWarnings("unchecked") // assume this can be done; if not throw CCE as per Javadoc + final Comparator comparator2 = (Comparator) comparator; + comparison = comparator2.compare(lhs, rhs); + } + return this; + } + + /** + * Appends to the {@code builder} the deep comparison of + * two {@link Object} arrays. + * + *
    + *
  1. Check if arrays are the same using {@code ==}
  2. + *
  3. Check if for {@code null}, {@code null} is less than non-{@code null}
  4. + *
  5. Check array length, a short length array is less than a long length array
  6. + *
  7. Check array contents element by element using {@link #append(Object, Object, Comparator)}
  8. + *
+ * + *

This method will also will be called for the top level of multi-dimensional, + * ragged, and multi-typed arrays.

+ * + * @param lhs left-hand side array + * @param rhs right-hand side array + * @return this + * @throws ClassCastException if {@code rhs} is not assignment-compatible + * with {@code lhs} + */ + public CompareToBuilder append(final Object[] lhs, final Object[] rhs) { + return append(lhs, rhs, null); + } + + /** + * Appends to the {@code builder} the deep comparison of + * two {@link Object} arrays. + * + *
    + *
  1. Check if arrays are the same using {@code ==}
  2. + *
  3. Check if for {@code null}, {@code null} is less than non-{@code null}
  4. + *
  5. Check array length, a short length array is less than a long length array
  6. + *
  7. Check array contents element by element using {@link #append(Object, Object, Comparator)}
  8. + *
+ * + *

This method will also will be called for the top level of multi-dimensional, + * ragged, and multi-typed arrays.

+ * + * @param lhs left-hand side array + * @param rhs right-hand side array + * @param comparator {@link Comparator} to use to compare the array elements, + * {@code null} means to treat {@code lhs} elements as {@link Comparable}. + * @return this + * @throws ClassCastException if {@code rhs} is not assignment-compatible + * with {@code lhs} + * @since 2.0 + */ + public CompareToBuilder append(final Object[] lhs, final Object[] rhs, final Comparator comparator) { + if (comparison != 0) { + return this; + } + if (lhs == rhs) { + return this; + } + if (lhs == null) { + comparison = -1; + return this; + } + if (rhs == null) { + comparison = 1; + return this; + } + if (lhs.length != rhs.length) { + comparison = lhs.length < rhs.length ? -1 : 1; + return this; + } + for (int i = 0; i < lhs.length && comparison == 0; i++) { + append(lhs[i], rhs[i], comparator); + } + return this; + } + + /** + * Appends to the {@code builder} the comparison of + * two {@code short}s. + * + * @param lhs left-hand side value + * @param rhs right-hand side value + * @return this + */ + public CompareToBuilder append(final short lhs, final short rhs) { + if (comparison != 0) { + return this; + } + comparison = Short.compare(lhs, rhs); + return this; + } + + /** + * Appends to the {@code builder} the deep comparison of + * two {@code short} arrays. + * + *
    + *
  1. Check if arrays are the same using {@code ==}
  2. + *
  3. Check if for {@code null}, {@code null} is less than non-{@code null}
  4. + *
  5. Check array length, a shorter length array is less than a longer length array
  6. + *
  7. Check array contents element by element using {@link #append(short, short)}
  8. + *
+ * + * @param lhs left-hand side array + * @param rhs right-hand side array + * @return this + */ + public CompareToBuilder append(final short[] lhs, final short[] rhs) { + if (comparison != 0) { + return this; + } + if (lhs == rhs) { + return this; + } + if (lhs == null) { + comparison = -1; + return this; + } + if (rhs == null) { + comparison = 1; + return this; + } + if (lhs.length != rhs.length) { + comparison = lhs.length < rhs.length ? -1 : 1; + return this; + } + for (int i = 0; i < lhs.length && comparison == 0; i++) { + append(lhs[i], rhs[i]); + } + return this; + } + + private void appendArray(final Object lhs, final Object rhs, final Comparator comparator) { + // switch on type of array, to dispatch to the correct handler + // handles multidimensional arrays + // throws a ClassCastException if rhs is not the correct array type + if (lhs instanceof long[]) { + append((long[]) lhs, (long[]) rhs); + } else if (lhs instanceof int[]) { + append((int[]) lhs, (int[]) rhs); + } else if (lhs instanceof short[]) { + append((short[]) lhs, (short[]) rhs); + } else if (lhs instanceof char[]) { + append((char[]) lhs, (char[]) rhs); + } else if (lhs instanceof byte[]) { + append((byte[]) lhs, (byte[]) rhs); + } else if (lhs instanceof double[]) { + append((double[]) lhs, (double[]) rhs); + } else if (lhs instanceof float[]) { + append((float[]) lhs, (float[]) rhs); + } else if (lhs instanceof boolean[]) { + append((boolean[]) lhs, (boolean[]) rhs); + } else { + // not an array of primitives + // throws a ClassCastException if rhs is not an array + append((Object[]) lhs, (Object[]) rhs, comparator); + } + } + + /** + * Appends to the {@code builder} the {@code compareTo(Object)} + * result of the superclass. + * + * @param superCompareTo result of calling {@code super.compareTo(Object)} + * @return this + * @since 2.0 + */ + public CompareToBuilder appendSuper(final int superCompareTo) { + if (comparison != 0) { + return this; + } + comparison = superCompareTo; + return this; + } + + /** + * Returns a negative Integer, a positive Integer, or zero as + * the {@code builder} has judged the "left-hand" side + * as less than, greater than, or equal to the "right-hand" + * side. + * + * @return final comparison result as an Integer + * @see #toComparison() + * @since 3.0 + */ + @Override + public Integer build() { + return Integer.valueOf(toComparison()); + } + + /** + * Returns a negative integer, a positive integer, or zero as + * the {@code builder} has judged the "left-hand" side + * as less than, greater than, or equal to the "right-hand" + * side. + * + * @return final comparison result + * @see #build() + */ + public int toComparison() { + return comparison; + } +} \ No newline at end of file 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..642a86d --- /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 ands + * 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..b7099ec --- /dev/null +++ b/src/main/java/net/PeytonPlayz585/shadow/apache/Pair.java @@ -0,0 +1,260 @@ +/* + * 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, Comparable>, 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 the pair based on the left element followed by the right element. + * The types must be {@link Comparable}. + * + * @param other the other pair, not null + * @return negative if this is less, zero if equal, positive if greater + */ + @Override + public int compareTo(final Pair other) { + return new CompareToBuilder().append(getLeft(), other.getLeft()) + .append(getRight(), other.getRight()).toComparison(); + } + + /** + * 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/PeytonPlayz585/shadow/apache/Reflection.java b/src/main/java/net/PeytonPlayz585/shadow/apache/Reflection.java new file mode 100644 index 0000000..e495501 --- /dev/null +++ b/src/main/java/net/PeytonPlayz585/shadow/apache/Reflection.java @@ -0,0 +1,44 @@ +/* + * 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.lang.reflect.Field; +import java.util.Objects; + +/** + * Package-private reflection code. + */ +final class Reflection { + + /** + * Delegates to {@link Field#get(Object)} and rethrows {@link IllegalAccessException} as {@link IllegalArgumentException}. + * + * @param field The receiver of the get call. + * @param obj The argument of the get call. + * @return The result of the get call. + * @throws IllegalArgumentException Thrown after catching {@link IllegalAccessException}. + */ + static Object getUnchecked(final Field field, final Object obj) { + try { + return Objects.requireNonNull(field, "field").get(obj); + } catch (IllegalAccessException e) { + throw new IllegalArgumentException(e); + } + } + +} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/shadow/gui/GuiQuality.java b/src/main/java/net/PeytonPlayz585/shadow/gui/GuiQuality.java index b3ede19..393aa6b 100644 --- a/src/main/java/net/PeytonPlayz585/shadow/gui/GuiQuality.java +++ b/src/main/java/net/PeytonPlayz585/shadow/gui/GuiQuality.java @@ -10,7 +10,7 @@ public class GuiQuality extends GuiScreen { 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.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.FXAA, GameSettings.Options.CLEAR_WATER, GameSettings.Options.BETTER_GRASS, GameSettings.Options.BETTER_SNOW, GameSettings.Options.CUSTOM_FONTS, GameSettings.Options.CUSTOM_SKY, GameSettings.Options.DYNAMIC_LIGHTS}; + private static GameSettings.Options[] enumOptions = new GameSettings.Options[] {GameSettings.Options.MIPMAP_LEVELS, GameSettings.Options.MIPMAP_TYPE, GameSettings.Options.FXAA, GameSettings.Options.CLEAR_WATER, 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.CUSTOM_SKY, GameSettings.Options.DYNAMIC_LIGHTS}; public GuiQuality(GuiScreen p_i53_1_) { this.prevScreen = p_i53_1_; diff --git a/src/main/java/net/PeytonPlayz585/shadow/reflections/Reflector.java b/src/main/java/net/PeytonPlayz585/shadow/reflections/Reflector.java index 9577bf3..f3fd659 100644 --- a/src/main/java/net/PeytonPlayz585/shadow/reflections/Reflector.java +++ b/src/main/java/net/PeytonPlayz585/shadow/reflections/Reflector.java @@ -1,8 +1,12 @@ package net.PeytonPlayz585.shadow.reflections; import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.util.List; +import net.minecraft.world.biome.BiomeGenBase; +import net.PeytonPlayz585.shadow.Config; import net.minecraft.client.resources.DefaultResourcePack; public class Reflector { @@ -11,6 +15,8 @@ public class Reflector { public static ReflectorField ResourcePackRepository_repositoryEntries = new ReflectorField(ResourcePackRepository, List.class, 1); public static ReflectorClass Minecraft = new ReflectorClass(net.minecraft.client.Minecraft.class); public static ReflectorField Minecraft_defaultResourcePack = new ReflectorField(Minecraft, DefaultResourcePack.class); + public static ReflectorClass ForgeBiome = new ReflectorClass(BiomeGenBase.class); + public static ReflectorMethod ForgeBiome_getWaterColorMultiplier = new ReflectorMethod(ForgeBiome, "getWaterColorMultiplier"); public static Object getFieldValue(ReflectorField p_getFieldValue_0_) { return getFieldValue((Object) null, p_getFieldValue_0_); @@ -89,5 +95,100 @@ public class Reflector { return true; } } + + public static int callInt(ReflectorMethod p_callInt_0_, Object... p_callInt_1_) + { + try { + Method method = p_callInt_0_.getTargetMethod(); + + if (method == null) { + return 0; + } else { + Integer integer = (Integer)method.invoke((Object)null, p_callInt_1_); + return integer.intValue(); + } + } catch (Throwable throwable) { + handleException(throwable, (Object)null, p_callInt_0_, p_callInt_1_); + return 0; + } + } + + public static int callInt(Object p_callInt_0_, ReflectorMethod p_callInt_1_, Object... p_callInt_2_) { + try { + Method method = p_callInt_1_.getTargetMethod(); + + if (method == null) { + return 0; + } else { + Integer integer = (Integer)method.invoke(p_callInt_0_, p_callInt_2_); + return integer.intValue(); + } + } catch (Throwable throwable) { + handleException(throwable, p_callInt_0_, p_callInt_1_, p_callInt_2_); + return 0; + } + } + + private static void handleException(Throwable p_handleException_0_, Object p_handleException_1_, ReflectorMethod p_handleException_2_, Object[] p_handleException_3_) { + if (p_handleException_0_ instanceof InvocationTargetException) { + Throwable throwable = p_handleException_0_.getCause(); + + if (throwable instanceof RuntimeException) { + RuntimeException runtimeexception = (RuntimeException)throwable; + throw runtimeexception; + } else { + p_handleException_0_.printStackTrace(); + } + } else { + if (p_handleException_0_ instanceof IllegalArgumentException) { + Config.warn("*** IllegalArgumentException ***"); + Config.warn("Method: " + p_handleException_2_.getTargetMethod()); + Config.warn("Object: " + p_handleException_1_); + Config.warn("Parameter classes: " + Config.arrayToString(getClasses(p_handleException_3_))); + Config.warn("Parameters: " + Config.arrayToString(p_handleException_3_)); + } + + Config.warn("*** Exception outside of method ***"); + Config.warn("Method deactivated: " + p_handleException_2_.getTargetMethod()); + p_handleException_2_.deactivate(); + p_handleException_0_.printStackTrace(); + } + } + + private static void handleException(Throwable p_handleException_0_, ReflectorConstructor p_handleException_1_, Object[] p_handleException_2_) { + if (p_handleException_0_ instanceof InvocationTargetException) { + p_handleException_0_.printStackTrace(); + } else { + if (p_handleException_0_ instanceof IllegalArgumentException) { + Config.warn("*** IllegalArgumentException ***"); + Config.warn("Constructor: " + p_handleException_1_.getTargetConstructor()); + Config.warn("Parameter classes: " + Config.arrayToString(getClasses(p_handleException_2_))); + Config.warn("Parameters: " + Config.arrayToString(p_handleException_2_)); + } + + Config.warn("*** Exception outside of constructor ***"); + Config.warn("Constructor deactivated: " + p_handleException_1_.getTargetConstructor()); + p_handleException_1_.deactivate(); + p_handleException_0_.printStackTrace(); + } + } + + private static Object[] getClasses(Object[] p_getClasses_0_) { + if (p_getClasses_0_ == null) { + return new Class[0]; + } else { + Class[] aclass = new Class[p_getClasses_0_.length]; + + for (int i = 0; i < aclass.length; ++i) { + Object object = p_getClasses_0_[i]; + + if (object != null) { + aclass[i] = object.getClass(); + } + } + + return aclass; + } + } } \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/shadow/reflections/ReflectorConstructor.java b/src/main/java/net/PeytonPlayz585/shadow/reflections/ReflectorConstructor.java new file mode 100644 index 0000000..89a0362 --- /dev/null +++ b/src/main/java/net/PeytonPlayz585/shadow/reflections/ReflectorConstructor.java @@ -0,0 +1,71 @@ +package net.PeytonPlayz585.shadow.reflections; + +import java.lang.reflect.Constructor; + +import net.PeytonPlayz585.shadow.Config; + +public class ReflectorConstructor { + private ReflectorClass reflectorClass = null; + private Class[] parameterTypes = null; + private boolean checked = false; + private Constructor targetConstructor = null; + + public ReflectorConstructor(ReflectorClass p_i84_1_, Class[] p_i84_2_) { + this.reflectorClass = p_i84_1_; + this.parameterTypes = p_i84_2_; + Constructor constructor = this.getTargetConstructor(); + } + + public Constructor getTargetConstructor() { + if (this.checked) { + return this.targetConstructor; + } else { + this.checked = true; + Class oclass = this.reflectorClass.getTargetClass(); + + if (oclass == null) { + return null; + } else { + try { + this.targetConstructor = findConstructor(oclass, this.parameterTypes); + + if (this.targetConstructor == null) { + Config.dbg("(Reflector) Constructor not present: " + oclass.getName() + ", params: " + Config.arrayToString((Object[]) this.parameterTypes)); + } + + if (this.targetConstructor != null) { + this.targetConstructor.setAccessible(true); + } + } catch (Throwable throwable) { + throwable.printStackTrace(); + } + + return this.targetConstructor; + } + } + } + + private static Constructor findConstructor(Class p_findConstructor_0_, Class[] p_findConstructor_1_) { + Constructor[] aconstructor = p_findConstructor_0_.getDeclaredConstructors(); + + for (int i = 0; i < aconstructor.length; ++i) { + Constructor constructor = aconstructor[i]; + Class[] aclass = constructor.getParameterTypes(); + + if (Reflector.matchesTypes(p_findConstructor_1_, aclass)) { + return constructor; + } + } + + return null; + } + + public boolean exists() { + return this.checked ? this.targetConstructor != null : this.getTargetConstructor() != null; + } + + public void deactivate() { + this.checked = true; + this.targetConstructor = null; + } +} \ No newline at end of file diff --git a/src/main/java/net/lax1dude/eaglercraft/v1_8/ArrayUtils.java b/src/main/java/net/lax1dude/eaglercraft/v1_8/ArrayUtils.java index 8c29183..2847903 100644 --- a/src/main/java/net/lax1dude/eaglercraft/v1_8/ArrayUtils.java +++ b/src/main/java/net/lax1dude/eaglercraft/v1_8/ArrayUtils.java @@ -51,5 +51,14 @@ public class ArrayUtils { } return str; } + + public static boolean contains(String[] array, String value) { + for (String item : array) { + if (item.equals(value)) { + return true; + } + } + return false; + } } diff --git a/src/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ImageData.java b/src/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ImageData.java index 6ef3dc7..8be887a 100644 --- a/src/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ImageData.java +++ b/src/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ImageData.java @@ -3,7 +3,6 @@ package net.lax1dude.eaglercraft.v1_8.opengl; import java.io.*; import java.nio.ByteBuffer; import java.nio.IntBuffer; -import java.util.Arrays; import java.util.HashMap; import net.lax1dude.eaglercraft.v1_8.EagRuntime; @@ -19,10 +18,7 @@ public class ImageData { public ImageData(int width, int height, int[] pixels, boolean alpha) { this.width = width; this.height = height; - this.pixels = ByteBuffer.allocateDirect(pixels.length * 4) - .asIntBuffer() - .put(pixels) - .flip(); + this.pixels = (IntBuffer) ByteBuffer.allocateDirect(pixels.length * 4).asIntBuffer().put(pixels).flip(); this.alpha = alpha; } diff --git a/src/main/java/net/lax1dude/eaglercraft/v1_8/profile/GuiScreenEditProfile.java b/src/main/java/net/lax1dude/eaglercraft/v1_8/profile/GuiScreenEditProfile.java index fbc6e86..6bbfab6 100644 --- a/src/main/java/net/lax1dude/eaglercraft/v1_8/profile/GuiScreenEditProfile.java +++ b/src/main/java/net/lax1dude/eaglercraft/v1_8/profile/GuiScreenEditProfile.java @@ -20,12 +20,6 @@ import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*; import java.io.IOException; import java.util.HashMap; -import org.teavm.jso.JSBody; -import org.teavm.jso.dom.events.Event; -import org.teavm.jso.dom.events.EventListener; -import org.teavm.jso.dom.events.MessageEvent; -import org.teavm.jso.websocket.WebSocket; - /** * Copyright (c) 2022-2023 LAX1DUDE. All Rights Reserved. * diff --git a/src/main/java/net/minecraft/block/material/MapColor.java b/src/main/java/net/minecraft/block/material/MapColor.java index ef4ba38..6bd1063 100644 --- a/src/main/java/net/minecraft/block/material/MapColor.java +++ b/src/main/java/net/minecraft/block/material/MapColor.java @@ -60,7 +60,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/gui/FontRenderer.java b/src/main/java/net/minecraft/client/gui/FontRenderer.java index 051559b..6eecb31 100644 --- a/src/main/java/net/minecraft/client/gui/FontRenderer.java +++ b/src/main/java/net/minecraft/client/gui/FontRenderer.java @@ -23,6 +23,7 @@ import net.minecraft.client.settings.GameSettings; import net.minecraft.util.ResourceLocation; import net.PeytonPlayz585.shadow.Config; +import net.PeytonPlayz585.shadow.CustomColors; import net.PeytonPlayz585.shadow.FontUtils; /**+ @@ -372,6 +373,9 @@ public class FontRenderer implements IResourceManagerReloadListener { } int j1 = this.colorCode[i1]; + if (Config.isCustomColors()) { + j1 = CustomColors.getTextColor(i1, j1); + } this.textColor = j1; GlStateManager.color((float) (j1 >> 16) / 255.0F, (float) (j1 >> 8 & 255) / 255.0F, (float) (j1 & 255) / 255.0F, this.alpha); @@ -858,6 +862,18 @@ public class FontRenderer implements IResourceManagerReloadListener { } public int getColorCode(char character) { - return this.colorCode["0123456789abcdef".indexOf(character)]; - } + int i = "0123456789abcdef".indexOf(character); + + if (i >= 0 && i < this.colorCode.length) { + int j = this.colorCode[i]; + + if (Config.isCustomColors()) { + j = CustomColors.getTextColor(i, j); + } + + return j; + } else { + return 16777215; + } + } } \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiIngame.java b/src/main/java/net/minecraft/client/gui/GuiIngame.java index 4f5a1ce..b492363 100644 --- a/src/main/java/net/minecraft/client/gui/GuiIngame.java +++ b/src/main/java/net/minecraft/client/gui/GuiIngame.java @@ -9,6 +9,7 @@ import java.util.List; import net.FatalCodes.shadow.Shadow; import net.FatalCodes.shadow.module.RenderModule; import net.PeytonPlayz585.shadow.Config; +import net.PeytonPlayz585.shadow.CustomColors; import net.PeytonPlayz585.shadow.gui.ArmorGui; import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom; import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerTextureAtlasSprite; @@ -222,6 +223,11 @@ public class GuiIngame extends Gui { GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, 1, 0); int l = 16777215; + + if (Config.isCustomColors()) { + l = CustomColors.getBossTextColor(l); + } + if (this.recordIsPlaying) { l = MathHelper.func_181758_c(f2 / 50.0F, 0.7F, 0.6F) & 16777215; } @@ -396,6 +402,11 @@ public class GuiIngame extends Gui { if (this.mc.thePlayer.experienceLevel > 0) { this.mc.mcProfiler.startSection("expLevel"); int i1 = 8453920; + + if (Config.isCustomColors()) { + i1 = CustomColors.getExpBarTextColor(i1); + } + String s = "" + this.mc.thePlayer.experienceLevel; int j1 = (parScaledResolution.getScaledWidth() - this.getFontRenderer().getStringWidth(s)) / 2; int l = parScaledResolution.getScaledHeight() - 31 - 4; diff --git a/src/main/java/net/minecraft/client/renderer/BlockFluidRenderer.java b/src/main/java/net/minecraft/client/renderer/BlockFluidRenderer.java index 454582f..9ac5f54 100644 --- a/src/main/java/net/minecraft/client/renderer/BlockFluidRenderer.java +++ b/src/main/java/net/minecraft/client/renderer/BlockFluidRenderer.java @@ -1,5 +1,7 @@ package net.minecraft.client.renderer; +import net.PeytonPlayz585.shadow.CustomColors; +import net.PeytonPlayz585.shadow.RenderEnv; import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerTextureAtlasSprite; import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer; import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.BlockVertexIDs; @@ -59,7 +61,8 @@ public class BlockFluidRenderer { boolean realistic = !lava && DeferredStateManager.isRenderingRealisticWater(); blockliquid.setBlockBoundsBasedOnState(blockAccess, blockPosIn); EaglerTextureAtlasSprite[] atextureatlassprite = lava ? this.atlasSpritesLava : this.atlasSpritesWater; - int i = blockliquid.colorMultiplier(blockAccess, blockPosIn); + RenderEnv renderenv = RenderEnv.getInstance(blockAccess, blockStateIn, blockPosIn); + int i = CustomColors.getFluidColor(blockAccess, blockStateIn, blockPosIn, renderenv); float f = (float) (i >> 16 & 255) / 255.0F; float f1 = (float) (i >> 8 & 255) / 255.0F; float f2 = (float) (i & 255) / 255.0F; diff --git a/src/main/java/net/minecraft/client/renderer/BlockModelRenderer.java b/src/main/java/net/minecraft/client/renderer/BlockModelRenderer.java index 091f891..ae658d5 100644 --- a/src/main/java/net/minecraft/client/renderer/BlockModelRenderer.java +++ b/src/main/java/net/minecraft/client/renderer/BlockModelRenderer.java @@ -101,7 +101,7 @@ public class BlockModelRenderer { list = BetterGrass.getFaceQuads(blockAccessIn, blockIn, blockPosIn, enumfacing, list); } - this.renderModelAmbientOcclusionQuads(blockAccessIn, blockIn, blockPosIn, worldRendererIn, list, afloat, bitset, blockmodelrenderer$ambientocclusionface); + this.renderModelAmbientOcclusionQuads(blockAccessIn, blockIn, blockPosIn, worldRendererIn, list, afloat, bitset, blockmodelrenderer$ambientocclusionface, renderenv); flag = true; } } @@ -110,7 +110,7 @@ public class BlockModelRenderer { List list1 = modelIn.getGeneralQuads(); if (list1.size() > 0) { this.renderModelAmbientOcclusionQuads(blockAccessIn, blockIn, blockPosIn, worldRendererIn, list1, afloat, - bitset, blockmodelrenderer$ambientocclusionface); + bitset, blockmodelrenderer$ambientocclusionface, renderenv); flag = true; } @@ -171,7 +171,7 @@ public class BlockModelRenderer { private void renderModelAmbientOcclusionQuads(IBlockAccess blockAccessIn, Block blockIn, BlockPos blockPosIn, WorldRenderer worldRendererIn, List listQuadsIn, float[] quadBounds, BitSet boundsFlags, - BlockModelRenderer.AmbientOcclusionFace aoFaceIn) { + BlockModelRenderer.AmbientOcclusionFace aoFaceIn, RenderEnv renderenv) { boolean isDeferred = DeferredStateManager.isDeferredRenderer(); double d0 = (double) blockPosIn.getX(); double d1 = (double) blockPosIn.getY(); @@ -192,35 +192,35 @@ public class BlockModelRenderer { aoFaceIn.updateVertexBrightness(blockAccessIn, blockIn, blockPosIn, bakedquad.getFace(), quadBounds, boundsFlags); worldRendererIn.addVertexData(vertData); - worldRendererIn.putBrightness4(aoFaceIn.vertexBrightness[0], aoFaceIn.vertexBrightness[1], - aoFaceIn.vertexBrightness[2], aoFaceIn.vertexBrightness[3]); - if (bakedquad.hasTintIndex()) { - int j = blockIn.colorMultiplier(blockAccessIn, blockPosIn, bakedquad.getTintIndex()); - if (EntityRenderer.anaglyphEnable) { - j = TextureUtil.anaglyphColor(j); - } + worldRendererIn.putBrightness4(aoFaceIn.vertexBrightness[0], aoFaceIn.vertexBrightness[1], aoFaceIn.vertexBrightness[2], aoFaceIn.vertexBrightness[3]); + int k = CustomColors.getColorMultiplier(bakedquad, blockIn, blockAccessIn, blockPosIn, renderenv); + + if (!bakedquad.hasTintIndex() && k == -1) { + worldRendererIn.putColorMultiplier(aoFaceIn.vertexColorMultiplier[0], aoFaceIn.vertexColorMultiplier[0], aoFaceIn.vertexColorMultiplier[0], 4); + worldRendererIn.putColorMultiplier(aoFaceIn.vertexColorMultiplier[1], aoFaceIn.vertexColorMultiplier[1], aoFaceIn.vertexColorMultiplier[1], 3); + worldRendererIn.putColorMultiplier(aoFaceIn.vertexColorMultiplier[2], aoFaceIn.vertexColorMultiplier[2], aoFaceIn.vertexColorMultiplier[2], 2); + worldRendererIn.putColorMultiplier(aoFaceIn.vertexColorMultiplier[3], aoFaceIn.vertexColorMultiplier[3], aoFaceIn.vertexColorMultiplier[3], 1); + } else { + int j; - float f = (float) (j >> 16 & 255) / 255.0F; - float f1 = (float) (j >> 8 & 255) / 255.0F; - float f2 = (float) (j & 255) / 255.0F; - worldRendererIn.putColorMultiplier(aoFaceIn.vertexColorMultiplier[0] * f, - aoFaceIn.vertexColorMultiplier[0] * f1, aoFaceIn.vertexColorMultiplier[0] * f2, 4); - worldRendererIn.putColorMultiplier(aoFaceIn.vertexColorMultiplier[1] * f, - aoFaceIn.vertexColorMultiplier[1] * f1, aoFaceIn.vertexColorMultiplier[1] * f2, 3); - worldRendererIn.putColorMultiplier(aoFaceIn.vertexColorMultiplier[2] * f, - aoFaceIn.vertexColorMultiplier[2] * f1, aoFaceIn.vertexColorMultiplier[2] * f2, 2); - worldRendererIn.putColorMultiplier(aoFaceIn.vertexColorMultiplier[3] * f, - aoFaceIn.vertexColorMultiplier[3] * f1, aoFaceIn.vertexColorMultiplier[3] * f2, 1); - } else { - worldRendererIn.putColorMultiplier(aoFaceIn.vertexColorMultiplier[0], aoFaceIn.vertexColorMultiplier[0], - aoFaceIn.vertexColorMultiplier[0], 4); - worldRendererIn.putColorMultiplier(aoFaceIn.vertexColorMultiplier[1], aoFaceIn.vertexColorMultiplier[1], - aoFaceIn.vertexColorMultiplier[1], 3); - worldRendererIn.putColorMultiplier(aoFaceIn.vertexColorMultiplier[2], aoFaceIn.vertexColorMultiplier[2], - aoFaceIn.vertexColorMultiplier[2], 2); - worldRendererIn.putColorMultiplier(aoFaceIn.vertexColorMultiplier[3], aoFaceIn.vertexColorMultiplier[3], - aoFaceIn.vertexColorMultiplier[3], 1); - } + if (k != -1) { + j = k; + } else { + j = blockIn.colorMultiplier(blockAccessIn, blockPosIn, bakedquad.getTintIndex()); + } + + if (EntityRenderer.anaglyphEnable) { + j = TextureUtil.anaglyphColor(j); + } + + float f = (float)(j >> 16 & 255) / 255.0F; + float f1 = (float)(j >> 8 & 255) / 255.0F; + float f2 = (float)(j & 255) / 255.0F; + worldRendererIn.putColorMultiplier(aoFaceIn.vertexColorMultiplier[0] * f, aoFaceIn.vertexColorMultiplier[0] * f1, aoFaceIn.vertexColorMultiplier[0] * f2, 4); + worldRendererIn.putColorMultiplier(aoFaceIn.vertexColorMultiplier[1] * f, aoFaceIn.vertexColorMultiplier[1] * f1, aoFaceIn.vertexColorMultiplier[1] * f2, 3); + worldRendererIn.putColorMultiplier(aoFaceIn.vertexColorMultiplier[2] * f, aoFaceIn.vertexColorMultiplier[2] * f1, aoFaceIn.vertexColorMultiplier[2] * f2, 2); + worldRendererIn.putColorMultiplier(aoFaceIn.vertexColorMultiplier[3] * f, aoFaceIn.vertexColorMultiplier[3] * f1, aoFaceIn.vertexColorMultiplier[3] * f2, 1); + } worldRendererIn.putPosition(d0, d1, d2); } diff --git a/src/main/java/net/minecraft/client/renderer/EntityRenderer.java b/src/main/java/net/minecraft/client/renderer/EntityRenderer.java index 99cf07e..75fbcfa 100644 --- a/src/main/java/net/minecraft/client/renderer/EntityRenderer.java +++ b/src/main/java/net/minecraft/client/renderer/EntityRenderer.java @@ -88,6 +88,7 @@ import net.minecraft.world.WorldSettings; import net.minecraft.world.biome.BiomeGenBase; import net.PeytonPlayz585.shadow.Config; +import net.PeytonPlayz585.shadow.CustomColors; import net.PeytonPlayz585.shadow.Lagometer; import net.PeytonPlayz585.shadow.TextureUtils; import net.PeytonPlayz585.shadow.debug.DebugChunkRenderer; @@ -769,6 +770,14 @@ public class EntityRenderer implements IResourceManagerReloadListener { this.mc.mcProfiler.startSection("lightTex"); WorldClient worldclient = this.mc.theWorld; if (worldclient != null) { + + if (Config.isCustomColors() && CustomColors.updateLightmap(worldclient, this.torchFlickerX, this.lightmapColors, this.mc.thePlayer.isPotionActive(Potion.nightVision))) { + this.lightmapTexture.updateDynamicTexture(); + this.lightmapUpdateNeeded = false; + this.mc.mcProfiler.endSection(); + return; + } + float f = worldclient.getSunBrightness(1.0F); float f1 = f * 0.95F + 0.05F; @@ -1659,10 +1668,12 @@ public class EntityRenderer implements IResourceManagerReloadListener { float f = 0.25F + 0.75F * (float) this.mc.gameSettings.renderDistanceChunks / 32.0F; f = 1.0F - (float) Math.pow((double) f, 0.25D); Vec3 vec3 = worldclient.getSkyColor(this.mc.getRenderViewEntity(), partialTicks); + vec3 = CustomColors.getWorldSkyColor(vec3, worldclient, this.mc.getRenderViewEntity(), partialTicks); float f1 = (float) vec3.xCoord; float f2 = (float) vec3.yCoord; float f3 = (float) vec3.zCoord; Vec3 vec31 = worldclient.getFogColor(partialTicks); + vec31 = CustomColors.getWorldFogColor(vec31, worldclient, this.mc.getRenderViewEntity(), partialTicks); this.fogColorRed = (float) vec31.xCoord; this.fogColorGreen = (float) vec31.yCoord; this.fogColorBlue = (float) vec31.zCoord; @@ -1715,15 +1726,22 @@ public class EntityRenderer implements IResourceManagerReloadListener { this.fogColorGreen = (float) vec33.yCoord; this.fogColorBlue = (float) vec33.zCoord; } else if (block.getMaterial() == Material.water) { - float f12 = (float) EnchantmentHelper.getRespiration(entity) * 0.2F; - if (entity instanceof EntityLivingBase - && ((EntityLivingBase) entity).isPotionActive(Potion.waterBreathing)) { - f12 = f12 * 0.3F + 0.6F; - } + float f10 = (float)EnchantmentHelper.getRespiration(entity) * 0.2F; - this.fogColorRed = 0.02F + f12; - this.fogColorGreen = 0.02F + f12; - this.fogColorBlue = 0.2F + f12; + if (entity instanceof EntityLivingBase && ((EntityLivingBase)entity).isPotionActive(Potion.waterBreathing)) { + f10 = f10 * 0.3F + 0.6F; + } + + this.fogColorRed = 0.02F + f10; + this.fogColorGreen = 0.02F + f10; + this.fogColorBlue = 0.2F + f10; + Vec3 vec34 = CustomColors.getUnderwaterColor(this.mc.theWorld, this.mc.getRenderViewEntity().posX, this.mc.getRenderViewEntity().posY + 1.0D, this.mc.getRenderViewEntity().posZ); + + if (vec34 != null) { + this.fogColorRed = (float)vec34.xCoord; + this.fogColorGreen = (float)vec34.yCoord; + this.fogColorBlue = (float)vec34.zCoord; + } } else if (block.getMaterial() == Material.lava) { this.fogColorRed = 0.6F; this.fogColorGreen = 0.1F; diff --git a/src/main/java/net/minecraft/client/renderer/RenderGlobal.java b/src/main/java/net/minecraft/client/renderer/RenderGlobal.java index 24e0bac..2fb0aa6 100644 --- a/src/main/java/net/minecraft/client/renderer/RenderGlobal.java +++ b/src/main/java/net/minecraft/client/renderer/RenderGlobal.java @@ -11,6 +11,7 @@ import java.util.List; import java.util.Map; import net.PeytonPlayz585.shadow.Config; +import net.PeytonPlayz585.shadow.CustomColors; import net.PeytonPlayz585.shadow.CustomSky; import net.PeytonPlayz585.shadow.DynamicLights; import net.PeytonPlayz585.shadow.Lagometer; @@ -1354,6 +1355,7 @@ public class RenderGlobal implements IWorldAccess, IResourceManagerReloadListene } else if (this.mc.theWorld.provider.isSurfaceWorld()) { GlStateManager.disableTexture2D(); Vec3 vec3 = this.theWorld.getSkyColor(this.mc.getRenderViewEntity(), partialTicks); + vec3 = CustomColors.getSkyColor(vec3, this.mc.theWorld, this.mc.getRenderViewEntity().posX, this.mc.getRenderViewEntity().posY + 1.0D, this.mc.getRenderViewEntity().posZ); float f = (float) vec3.xCoord; float f1 = (float) vec3.yCoord; float f2 = (float) vec3.zCoord; @@ -2201,63 +2203,101 @@ public class RenderGlobal implements IWorldAccess, IResourceManagerReloadListene parDouble3, parDouble4, parDouble5, parDouble6, parArrayOfInt); } - private EntityFX spawnEntityFX(int ignoreRange, boolean parFlag, double parDouble1, double parDouble2, - double parDouble3, double parDouble4, double parDouble5, double parDouble6, int... parArrayOfInt) { - if (this.mc != null && this.mc.getRenderViewEntity() != null && this.mc.effectRenderer != null) { - int i = this.mc.gameSettings.particleSetting; - if (i == 1 && this.theWorld.rand.nextInt(3) == 0) { - i = 2; - } + private EntityFX spawnEntityFX(int ignoreRange, boolean parFlag, double parDouble1, double parDouble2, double parDouble3, double parDouble4, double parDouble5, double parDouble6, int... parArrayOfInt) { + if (this.mc != null && this.mc.getRenderViewEntity() != null && this.mc.effectRenderer != null) { + int i = this.mc.gameSettings.particleSetting; - double d0 = this.mc.getRenderViewEntity().posX - parDouble1; - double d1 = this.mc.getRenderViewEntity().posY - parDouble2; - double d2 = this.mc.getRenderViewEntity().posZ - parDouble3; - - if (ignoreRange == EnumParticleTypes.EXPLOSION_HUGE.getParticleID() && !Config.isAnimatedExplosion()) { - return null; - } else if (ignoreRange == EnumParticleTypes.EXPLOSION_LARGE.getParticleID() && !Config.isAnimatedExplosion()) { - return null; - } else if (ignoreRange == EnumParticleTypes.EXPLOSION_NORMAL.getParticleID() && !Config.isAnimatedExplosion()) { - return null; - } else if (ignoreRange == EnumParticleTypes.SUSPENDED.getParticleID() && !Config.isWaterParticles()) { - return null; - } else if (ignoreRange == EnumParticleTypes.SUSPENDED_DEPTH.getParticleID() && !Config.isVoidParticles()) { - return null; - } else if (ignoreRange == EnumParticleTypes.SMOKE_NORMAL.getParticleID() && !Config.isAnimatedSmoke()) { - return null; - } else if (ignoreRange == EnumParticleTypes.SMOKE_LARGE.getParticleID() && !Config.isAnimatedSmoke()) { - return null; - } else if (ignoreRange == EnumParticleTypes.SPELL_MOB.getParticleID() && !Config.isPotionParticles()) { - return null; - } else if (ignoreRange == EnumParticleTypes.SPELL_MOB_AMBIENT.getParticleID() && !Config.isPotionParticles()) { - return null; - } else if (ignoreRange == EnumParticleTypes.SPELL.getParticleID() && !Config.isPotionParticles()) { - return null; - } else if (ignoreRange == EnumParticleTypes.SPELL_INSTANT.getParticleID() && !Config.isPotionParticles()) { - return null; - } else if (ignoreRange == EnumParticleTypes.SPELL_WITCH.getParticleID() && !Config.isPotionParticles()) { - return null; - } else if (ignoreRange == EnumParticleTypes.PORTAL.getParticleID() && !Config.isAnimatedPortal()) { - return null; - } else if (ignoreRange == EnumParticleTypes.FLAME.getParticleID() && !Config.isAnimatedFlame()) { - return null; - } else if (ignoreRange == EnumParticleTypes.REDSTONE.getParticleID() && !Config.isAnimatedRedstone()) { - return null; - } else if (ignoreRange == EnumParticleTypes.DRIP_WATER.getParticleID() && !Config.isDrippingWaterLava()) { - return null; - } else if (ignoreRange == EnumParticleTypes.DRIP_LAVA.getParticleID() && !Config.isDrippingWaterLava()) { - return null; - } else if (ignoreRange == EnumParticleTypes.FIREWORKS_SPARK.getParticleID() && !Config.isFireworkParticles()) { - return null; - } else if (parFlag) { - return this.mc.effectRenderer.spawnEffectParticle(ignoreRange, parDouble1, parDouble2, parDouble3, - parDouble4, parDouble5, parDouble6, parArrayOfInt); - } else { - return d0 * d0 + d1 * d1 + d2 * d2 > 256.0D ? null : (i > 1 ? null : this.mc.effectRenderer.spawnEffectParticle(ignoreRange, parDouble1, parDouble2, parDouble3, parDouble4, parDouble5, parDouble6, parArrayOfInt)); - } - } else { - return null; - } + if (i == 1 && this.theWorld.rand.nextInt(3) == 0) { + i = 2; + } + + double d0 = this.mc.getRenderViewEntity().posX - parDouble1; + double d1 = this.mc.getRenderViewEntity().posY - parDouble2; + double d2 = this.mc.getRenderViewEntity().posZ - parDouble3; + + if (ignoreRange == EnumParticleTypes.EXPLOSION_HUGE.getParticleID() && !Config.isAnimatedExplosion()) { + return null; + } else if (ignoreRange == EnumParticleTypes.EXPLOSION_LARGE.getParticleID() && !Config.isAnimatedExplosion()) { + return null; + } else if (ignoreRange == EnumParticleTypes.EXPLOSION_NORMAL.getParticleID() && !Config.isAnimatedExplosion()) { + return null; + } else if (ignoreRange == EnumParticleTypes.SUSPENDED.getParticleID() && !Config.isWaterParticles()) { + return null; + } else if (ignoreRange == EnumParticleTypes.SUSPENDED_DEPTH.getParticleID() && !Config.isVoidParticles()) { + return null; + } else if (ignoreRange == EnumParticleTypes.SMOKE_NORMAL.getParticleID() && !Config.isAnimatedSmoke()) { + return null; + } else if (ignoreRange == EnumParticleTypes.SMOKE_LARGE.getParticleID() && !Config.isAnimatedSmoke()) { + return null; + } else if (ignoreRange == EnumParticleTypes.SPELL_MOB.getParticleID() && !Config.isPotionParticles()) { + return null; + } else if (ignoreRange == EnumParticleTypes.SPELL_MOB_AMBIENT.getParticleID() && !Config.isPotionParticles()) { + return null; + } else if (ignoreRange == EnumParticleTypes.SPELL.getParticleID() && !Config.isPotionParticles()) { + return null; + } else if (ignoreRange == EnumParticleTypes.SPELL_INSTANT.getParticleID() && !Config.isPotionParticles()) { + return null; + } else if (ignoreRange == EnumParticleTypes.SPELL_WITCH.getParticleID() && !Config.isPotionParticles()) { + return null; + } else if (ignoreRange == EnumParticleTypes.PORTAL.getParticleID() && !Config.isAnimatedPortal()) { + return null; + } else if (ignoreRange == EnumParticleTypes.FLAME.getParticleID() && !Config.isAnimatedFlame()) { + return null; + } else if (ignoreRange == EnumParticleTypes.REDSTONE.getParticleID() && !Config.isAnimatedRedstone()) { + return null; + } else if (ignoreRange == EnumParticleTypes.DRIP_WATER.getParticleID() && !Config.isDrippingWaterLava()) { + return null; + } else if (ignoreRange == EnumParticleTypes.DRIP_LAVA.getParticleID() && !Config.isDrippingWaterLava()) { + return null; + } else if (ignoreRange == EnumParticleTypes.FIREWORKS_SPARK.getParticleID() && !Config.isFireworkParticles()) { + return null; + } else if (parFlag) { + return this.mc.effectRenderer.spawnEffectParticle(ignoreRange, parDouble1, parDouble2, parDouble3, parDouble4, parDouble5, parDouble6, parArrayOfInt); + } else { + double d3 = 16.0D; + double d4 = 256.0D; + + if (ignoreRange == EnumParticleTypes.CRIT.getParticleID()) { + d4 = 38416.0D; + } + + if (d0 * d0 + d1 * d1 + d2 * d2 > d4) { + return null; + } else if (i > 1) { + return null; + } else { + EntityFX entityfx = this.mc.effectRenderer.spawnEffectParticle(ignoreRange, parDouble1, parDouble2, parDouble3, parDouble4, parDouble5, parDouble6, parArrayOfInt); + + if (ignoreRange == EnumParticleTypes.WATER_BUBBLE.getParticleID()) { + CustomColors.updateWaterFX(entityfx, this.theWorld, parDouble1, parDouble2, parDouble3); + } + + if (ignoreRange == EnumParticleTypes.WATER_SPLASH.getParticleID()) { + CustomColors.updateWaterFX(entityfx, this.theWorld, parDouble1, parDouble2, parDouble3); + } + + if (ignoreRange == EnumParticleTypes.WATER_DROP.getParticleID()) { + CustomColors.updateWaterFX(entityfx, this.theWorld, parDouble1, parDouble2, parDouble3); + } + + if (ignoreRange == EnumParticleTypes.TOWN_AURA.getParticleID()) { + CustomColors.updateMyceliumFX(entityfx); + } + + if (ignoreRange == EnumParticleTypes.PORTAL.getParticleID()) { + CustomColors.updatePortalFX(entityfx); + } + + if (ignoreRange == EnumParticleTypes.REDSTONE.getParticleID()) { + CustomColors.updateReddustFX(entityfx, this.theWorld, parDouble1, parDouble2, parDouble3); + } + + return entityfx; + } + } + } else { + return null; + } } /**+ diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderItem.java b/src/main/java/net/minecraft/client/renderer/entity/RenderItem.java index 3636e3d..52a22c3 100644 --- a/src/main/java/net/minecraft/client/renderer/entity/RenderItem.java +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderItem.java @@ -5,6 +5,8 @@ import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*; import java.util.List; import java.util.concurrent.Callable; +import net.PeytonPlayz585.shadow.Config; +import net.PeytonPlayz585.shadow.CustomColors; import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager; import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer; import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.DeferredStateManager; @@ -294,6 +296,11 @@ public class RenderItem implements IResourceManagerReloadListener { int k = color; if (flag && bakedquad.hasTintIndex()) { k = stack.getItem().getColorFromItemStack(stack, bakedquad.getTintIndex()); + + if (Config.isCustomColors()) { + k = CustomColors.getColorFromItemStack(stack, bakedquad.getTintIndex(), k); + } + if (EntityRenderer.anaglyphEnable) { k = TextureUtil.anaglyphColor(k); } diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderXPOrb.java b/src/main/java/net/minecraft/client/renderer/entity/RenderXPOrb.java index f6db427..c46b21b 100644 --- a/src/main/java/net/minecraft/client/renderer/entity/RenderXPOrb.java +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderXPOrb.java @@ -1,5 +1,7 @@ package net.minecraft.client.renderer.entity; +import net.PeytonPlayz585.shadow.Config; +import net.PeytonPlayz585.shadow.CustomColors; import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager; import net.lax1dude.eaglercraft.v1_8.opengl.OpenGlHelper; import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer; @@ -75,14 +77,24 @@ public class RenderXPOrb extends Render { Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR_NORMAL); - worldrenderer.pos((double) (0.0F - f7), (double) (0.0F - f8), 0.0D).tex((double) f2, (double) f5) - .color(l, 255, i1, 128).normal(0.0F, 1.0F, 0.0F).endVertex(); - worldrenderer.pos((double) (f6 - f7), (double) (0.0F - f8), 0.0D).tex((double) f3, (double) f5) - .color(l, 255, i1, 128).normal(0.0F, 1.0F, 0.0F).endVertex(); - worldrenderer.pos((double) (f6 - f7), (double) (1.0F - f8), 0.0D).tex((double) f3, (double) f4) - .color(l, 255, i1, 128).normal(0.0F, 1.0F, 0.0F).endVertex(); - worldrenderer.pos((double) (0.0F - f7), (double) (1.0F - f8), 0.0D).tex((double) f2, (double) f4) - .color(l, 255, i1, 128).normal(0.0F, 1.0F, 0.0F).endVertex(); + int j1 = l; + int k1 = 255; + int l1 = i1; + + if (Config.isCustomColors()) { + int i2 = CustomColors.getXpOrbColor(f8); + + if (i2 >= 0) { + j1 = i2 >> 16 & 255; + k1 = i2 >> 8 & 255; + l1 = i2 >> 0 & 255; + } + } + + worldrenderer.pos((double)(0.0F - f5), (double)(0.0F - f6), 0.0D).tex((double)f, (double)f3).color(j1, k1, l1, 128).normal(0.0F, 1.0F, 0.0F).endVertex(); + worldrenderer.pos((double)(f4 - f5), (double)(0.0F - f6), 0.0D).tex((double)f1, (double)f3).color(j1, k1, l1, 128).normal(0.0F, 1.0F, 0.0F).endVertex(); + worldrenderer.pos((double)(f4 - f5), (double)(1.0F - f6), 0.0D).tex((double)f1, (double)f2).color(j1, k1, l1, 128).normal(0.0F, 1.0F, 0.0F).endVertex(); + worldrenderer.pos((double)(0.0F - f5), (double)(1.0F - f6), 0.0D).tex((double)f, (double)f2).color(j1, k1, l1, 128).normal(0.0F, 1.0F, 0.0F).endVertex(); tessellator.draw(); GlStateManager.disableBlend(); GlStateManager.disableRescaleNormal(); diff --git a/src/main/java/net/minecraft/client/renderer/entity/layers/LayerSheepWool.java b/src/main/java/net/minecraft/client/renderer/entity/layers/LayerSheepWool.java index 732c429..9d926d1 100644 --- a/src/main/java/net/minecraft/client/renderer/entity/layers/LayerSheepWool.java +++ b/src/main/java/net/minecraft/client/renderer/entity/layers/LayerSheepWool.java @@ -1,5 +1,7 @@ package net.minecraft.client.renderer.entity.layers; +import net.PeytonPlayz585.shadow.Config; +import net.PeytonPlayz585.shadow.CustomColors; import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager; import net.minecraft.client.model.ModelSheep1; import net.minecraft.client.renderer.entity.RenderSheep; @@ -47,10 +49,21 @@ public class LayerSheepWool implements LayerRenderer { float f7 = ((float) (entitysheep.ticksExisted % 25) + f2) / 25.0F; float[] afloat1 = EntitySheep.func_175513_a(EnumDyeColor.byMetadata(k)); float[] afloat2 = EntitySheep.func_175513_a(EnumDyeColor.byMetadata(l)); + + if (Config.isCustomColors()) { + afloat1 = CustomColors.getSheepColors(EnumDyeColor.byMetadata(k), afloat1); + afloat2 = CustomColors.getSheepColors(EnumDyeColor.byMetadata(l), afloat2); + } + GlStateManager.color(afloat1[0] * (1.0F - f7) + afloat2[0] * f7, afloat1[1] * (1.0F - f7) + afloat2[1] * f7, afloat1[2] * (1.0F - f7) + afloat2[2] * f7); } else { float[] afloat = EntitySheep.func_175513_a(entitysheep.getFleeceColor()); + + if (Config.isCustomColors()) { + afloat = CustomColors.getSheepColors(entitysheep.getFleeceColor(), afloat); + } + GlStateManager.color(afloat[0], afloat[1], afloat[2]); } diff --git a/src/main/java/net/minecraft/client/renderer/entity/layers/LayerWolfCollar.java b/src/main/java/net/minecraft/client/renderer/entity/layers/LayerWolfCollar.java index 5a95ba6..62d103a 100644 --- a/src/main/java/net/minecraft/client/renderer/entity/layers/LayerWolfCollar.java +++ b/src/main/java/net/minecraft/client/renderer/entity/layers/LayerWolfCollar.java @@ -1,5 +1,7 @@ package net.minecraft.client.renderer.entity.layers; +import net.PeytonPlayz585.shadow.Config; +import net.PeytonPlayz585.shadow.CustomColors; import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager; import net.minecraft.client.renderer.entity.RenderWolf; import net.minecraft.entity.passive.EntitySheep; @@ -33,12 +35,16 @@ public class LayerWolfCollar implements LayerRenderer { this.wolfRenderer = wolfRendererIn; } - public void doRenderLayer(EntityWolf entitywolf, float f, float f1, float var4, float f2, float f3, float f4, - float f5) { + public void doRenderLayer(EntityWolf entitywolf, float f, float f1, float var4, float f2, float f3, float f4, float f5) { if (entitywolf.isTamed() && !entitywolf.isInvisible()) { this.wolfRenderer.bindTexture(WOLF_COLLAR); EnumDyeColor enumdyecolor = EnumDyeColor.byMetadata(entitywolf.getCollarColor().getMetadata()); float[] afloat = EntitySheep.func_175513_a(enumdyecolor); + + if (Config.isCustomColors()) { + afloat = CustomColors.getWolfCollarColors(enumdyecolor, afloat); + } + GlStateManager.color(afloat[0], afloat[1], afloat[2]); this.wolfRenderer.getMainModel().render(entitywolf, f, f1, f2, f3, f4, f5); } 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 1525ef7..bd0d6c6 100644 --- a/src/main/java/net/minecraft/client/renderer/texture/TextureManager.java +++ b/src/main/java/net/minecraft/client/renderer/texture/TextureManager.java @@ -160,4 +160,15 @@ public class TextureManager implements ITickable, IResourceManagerReloadListener } } + + public void reloadBannerTextures() { + for (Object entry : this.mapTextureObjects.entrySet()) { + ResourceLocation resourcelocation = (ResourceLocation)((Entry) entry).getKey(); + ITextureObject itextureobject = (ITextureObject)((Entry) 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/renderer/tileentity/TileEntitySignRenderer.java b/src/main/java/net/minecraft/client/renderer/tileentity/TileEntitySignRenderer.java index 12d90dd..64eba3b 100644 --- a/src/main/java/net/minecraft/client/renderer/tileentity/TileEntitySignRenderer.java +++ b/src/main/java/net/minecraft/client/renderer/tileentity/TileEntitySignRenderer.java @@ -7,6 +7,8 @@ import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*; import java.util.List; +import net.PeytonPlayz585.shadow.Config; +import net.PeytonPlayz585.shadow.CustomColors; import net.lax1dude.eaglercraft.v1_8.opengl.EaglercraftGPU; import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager; import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.DeferredStateManager; @@ -97,7 +99,10 @@ public class TileEntitySignRenderer extends TileEntitySpecialRenderer= 2) { this.hidePassword = Boolean.valueOf(astring[1]).booleanValue(); } + + if (astring[0].equals("ofCustomColors") && astring.length >= 2) { + this.ofCustomColors = 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(); + } Keyboard.setFunctionKeyModifier(keyBindFunction.getKeyCode()); @@ -1807,6 +1847,9 @@ public class GameSettings { printwriter.println("ofLagometer:" + this.ofLagometer); printwriter.println("ofProfiler:" + this.ofProfiler); printwriter.println("hidePassword:" + this.hidePassword); + printwriter.println("ofCustomColors:" + this.ofCustomColors); + printwriter.println("ofSwampColors:" + this.ofSwampColors); + printwriter.println("ofSmoothBiomes:" + this.ofSmoothBiomes); for (KeyBinding keybinding : this.keyBindings) { printwriter.println("key_" + keybinding.getKeyDescription() + ":" + keybinding.getKeyCode()); @@ -2000,7 +2043,10 @@ public class GameSettings { LEFT_HAND("Main Hand", false, false), LAGOMETER("Lagometer", false, false), PROFILER("Profiler", false, false), - HIDE_PASSWORD("Hide Password", false, false); + HIDE_PASSWORD("Hide Password", false, false), + CUSTOM_COLORS("Custom Colors", false, false), + SWAMP_COLORS("Swamp Colors", false, false), + SMOOTH_BIOMES("Smooth Biomes", false, false); private final boolean enumFloat; private final boolean enumBoolean; diff --git a/src/main/java/net/minecraft/potion/PotionHelper.java b/src/main/java/net/minecraft/potion/PotionHelper.java index 24d5e80..02ed7e9 100644 --- a/src/main/java/net/minecraft/potion/PotionHelper.java +++ b/src/main/java/net/minecraft/potion/PotionHelper.java @@ -8,6 +8,8 @@ import java.util.Map; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import net.PeytonPlayz585.shadow.Config; +import net.PeytonPlayz585.shadow.CustomColors; import net.minecraft.util.IntegerCache; /**+ @@ -108,6 +110,10 @@ public class PotionHelper { for (PotionEffect potioneffect : parCollection) { if (potioneffect.getIsShowParticles()) { int j = Potion.potionTypes[potioneffect.getPotionID()].getLiquidColor(); + + if (Config.isCustomColors()) { + j = CustomColors.getPotionColor(potioneffect.getPotionID(), j); + } for (int k = 0; k <= potioneffect.getAmplifier(); ++k) { f += (float) (j >> 16 & 255) / 255.0F; @@ -127,6 +133,10 @@ public class PotionHelper { return (int) f << 16 | (int) f1 << 8 | (int) f2; } } else { + if (Config.isCustomColors()) { + i = CustomColors.getPotionColor(0, i); + } + return i; } } @@ -489,6 +499,10 @@ public class PotionHelper { | (checkFlag(parInt1, parInt4) ? 4 : 0) | (checkFlag(parInt1, parInt5) ? 2 : 0) | (checkFlag(parInt1, parInt6) ? 1 : 0); } + + public static void clearPotionColorCache() { + DATAVALUE_COLORS.clear(); + } static { potionRequirements.put(Integer.valueOf(Potion.regeneration.getId()), "0 & !1 & !2 & !3 & 0+6"); diff --git a/src/main/java/org/apache/commons/lang3/ObjectUtils.java b/src/main/java/org/apache/commons/lang3/ObjectUtils.java index 6f10917..77b9905 100644 --- a/src/main/java/org/apache/commons/lang3/ObjectUtils.java +++ b/src/main/java/org/apache/commons/lang3/ObjectUtils.java @@ -1374,4 +1374,8 @@ public class ObjectUtils { public ObjectUtils() { } + public static boolean isArray(Object obj) { + return obj != null && obj.getClass().isArray(); + } + } diff --git a/src/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformAssets.java b/src/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformAssets.java index fcd92a6..840cd5f 100644 --- a/src/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformAssets.java +++ b/src/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformAssets.java @@ -1,7 +1,10 @@ package net.lax1dude.eaglercraft.v1_8.internal; 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 org.teavm.interop.Async; @@ -23,6 +26,7 @@ import org.teavm.jso.typedarrays.Uint8ClampedArray; import net.lax1dude.eaglercraft.v1_8.EaglerInputStream; import net.lax1dude.eaglercraft.v1_8.internal.teavm.MainClass; import net.lax1dude.eaglercraft.v1_8.internal.teavm.TeaVMUtils; +import net.lax1dude.eaglercraft.v1_8.internal.vfs.SYS; import net.lax1dude.eaglercraft.v1_8.opengl.ImageData; /** @@ -140,4 +144,64 @@ public class PlatformAssets { } } + public static String[] listFilesInDirectory(String directoryPath, String[] prefixes, String[] suffixes) { + ArrayList fileNames = new ArrayList<>(); + + for(String resourcePackName : SYS.getResourcePackNames()) { + String resourcePack = "resourcepacks/" + resourcePackName + "/" + directoryPath; + List vfsFiles = SYS.VFS.listFiles(resourcePack); + for (String vfsFile : vfsFiles) { + if (!vfsFile.endsWith("/")) { + String fileName = vfsFile; + if (matchesPrefixesAndSuffixes(fileName, prefixes, suffixes)) { + if(!fileNames.contains(fileName)) { + fileNames.add(fileName); + } + } + } else { + String[] filesInSubfolder = listFilesInDirectory(vfsFile, prefixes, suffixes); + for(String file : Arrays.asList(filesInSubfolder)) { + if(!fileNames.contains(file)) { + fileNames.add(file); + } + } + } + } + } + + for (String path : assets.keySet()) { + if (path.startsWith(directoryPath)) { + if (!path.endsWith("/")) { + String fileName = path.substring(directoryPath.length() + 1); + if (matchesPrefixesAndSuffixes(fileName, prefixes, suffixes)) { + if(!fileNames.contains(fileName)) { + fileNames.add(fileName); + } + } + } else { + String[] filesInSubfolder = listFilesInDirectory(path, prefixes, suffixes); + for(String file : Arrays.asList(filesInSubfolder)) { + if(!fileNames.contains(file)) { + fileNames.add(file); + } + } + } + } + } + + return fileNames.toArray(new String[0]); + } + + private static boolean matchesPrefixesAndSuffixes(String fileName, String[] prefixes, String[] suffixes) { + for (String prefix : prefixes) { + if (fileName.startsWith(prefix)) { + for (String suffix : suffixes) { + if (fileName.endsWith(suffix)) { + return true; + } + } + } + } + return false; + } } diff --git a/src/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformRuntime.java b/src/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformRuntime.java index e2ce30e..70998b2 100644 --- a/src/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformRuntime.java +++ b/src/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformRuntime.java @@ -153,6 +153,7 @@ public class PlatformRuntime { try { EPKLoader.loadEPK(epkFileData, epkFiles[i].path, PlatformAssets.assets); + }catch(Throwable t) { throw new RuntimeInitializationFailureException("Could not extract EPK file \"" + url + "\"", t); }