From e6f073c8af666f67e8137f865e37531768b47146 Mon Sep 17 00:00:00 2001 From: PeytonPlayz595 <106421860+PeytonPlayz595@users.noreply.github.com> Date: Sun, 21 Jan 2024 20:43:04 -0500 Subject: [PATCH] Custom Colors, Swamp Colors, Smooth Biome --- .../net/PeytonPlayz585/shadow/Config.java | 43 + .../shadow/CustomColorFader.java | 39 + .../PeytonPlayz585/shadow/CustomColormap.java | 458 +++++ .../PeytonPlayz585/shadow/CustomColors.java | 1527 +++++++++++++++++ .../net/PeytonPlayz585/shadow/ResUtils.java | 98 ++ .../net/PeytonPlayz585/shadow/StrUtils.java | 534 ++++++ .../PeytonPlayz585/shadow/TextureUtils.java | 1 + .../shadow/apache/CompareToBuilder.java | 990 +++++++++++ .../shadow/apache/ImmutablePair.java | 214 +++ .../PeytonPlayz585/shadow/apache/Pair.java | 260 +++ .../shadow/apache/Reflection.java | 44 + .../PeytonPlayz585/shadow/gui/GuiQuality.java | 2 +- .../shadow/reflections/Reflector.java | 101 ++ .../reflections/ReflectorConstructor.java | 71 + .../lax1dude/eaglercraft/v1_8/ArrayUtils.java | 9 + .../eaglercraft/v1_8/opengl/ImageData.java | 6 +- .../v1_8/profile/GuiScreenEditProfile.java | 6 - .../minecraft/block/material/MapColor.java | 2 +- .../minecraft/client/gui/FontRenderer.java | 20 +- .../net/minecraft/client/gui/GuiIngame.java | 11 + .../client/renderer/BlockFluidRenderer.java | 5 +- .../client/renderer/BlockModelRenderer.java | 62 +- .../client/renderer/EntityRenderer.java | 34 +- .../client/renderer/RenderGlobal.java | 152 +- .../client/renderer/entity/RenderItem.java | 7 + .../client/renderer/entity/RenderXPOrb.java | 28 +- .../entity/layers/LayerSheepWool.java | 13 + .../entity/layers/LayerWolfCollar.java | 10 +- .../renderer/texture/TextureManager.java | 11 + .../tileentity/TileEntitySignRenderer.java | 7 +- .../resources/AbstractResourcePack.java | 2 +- .../client/settings/GameSettings.java | 50 +- .../net/minecraft/potion/PotionHelper.java | 14 + .../org/apache/commons/lang3/ObjectUtils.java | 4 + .../v1_8/internal/PlatformAssets.java | 64 + .../v1_8/internal/PlatformRuntime.java | 1 + 36 files changed, 4775 insertions(+), 125 deletions(-) create mode 100644 src/main/java/net/PeytonPlayz585/shadow/CustomColorFader.java create mode 100644 src/main/java/net/PeytonPlayz585/shadow/CustomColormap.java create mode 100644 src/main/java/net/PeytonPlayz585/shadow/CustomColors.java create mode 100644 src/main/java/net/PeytonPlayz585/shadow/ResUtils.java create mode 100644 src/main/java/net/PeytonPlayz585/shadow/StrUtils.java create mode 100644 src/main/java/net/PeytonPlayz585/shadow/apache/CompareToBuilder.java create mode 100644 src/main/java/net/PeytonPlayz585/shadow/apache/ImmutablePair.java create mode 100644 src/main/java/net/PeytonPlayz585/shadow/apache/Pair.java create mode 100644 src/main/java/net/PeytonPlayz585/shadow/apache/Reflection.java create mode 100644 src/main/java/net/PeytonPlayz585/shadow/reflections/ReflectorConstructor.java 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 BuilderFields 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. + * + *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. + * + *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. + * + *{@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. + * + *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