Custom Colors, Swamp Colors, Smooth Biome

This commit is contained in:
PeytonPlayz595 2024-01-21 20:43:04 -05:00
parent a77cd0d448
commit e6f073c8af
36 changed files with 4775 additions and 125 deletions

View File

@ -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;
}

View File

@ -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;
}
}
}
}
}

View File

@ -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;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -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(".+[\\\\/]$");
}
}

View File

@ -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;
}
}
}

View File

@ -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();

View File

@ -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.
*
* <p>It is consistent with {@code equals(Object)} and
* {@code hashCode()} built with {@link EqualsBuilder} and
* {@link HashCodeBuilder}.</p>
*
* <p>Two Objects that compare equal using {@code equals(Object)} should normally
* also compare equal using {@code compareTo(Object)}.</p>
*
* <p>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)}.</p>
*
* <p>To use this class write code as follows:</p>
*
* <pre>
* 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();
* }
* }
* </pre>
*
* <p>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.</p>
*
* <p>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.</p>
*
* <p>A typical implementation of {@code compareTo(Object)} using
* {@code reflectionCompare} looks like:</p>
* <pre>
* public int compareTo(Object o) {
* return CompareToBuilder.reflectionCompare(this, o);
* }
* </pre>
*
* <p>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).</p>
*
* @see Comparable
* @see Object#equals(Object)
* @see Object#hashCode()
* @see EqualsBuilder
* @see HashCodeBuilder
* @since 1.0
*/
public class CompareToBuilder implements Builder<Integer> {
/**
* Appends to {@code builder} the comparison of {@code lhs}
* to {@code rhs} using the fields defined in {@code clazz}.
*
* @param lhs left-hand side object
* @param rhs right-hand side object
* @param clazz {@link Class} that defines fields to be compared
* @param builder {@link CompareToBuilder} to append to
* @param useTransients whether to compare transient fields
* @param excludeFields fields to exclude
*/
private static void reflectionAppend(
final Object lhs,
final Object rhs,
final Class<?> clazz,
final CompareToBuilder builder,
final boolean useTransients,
final String[] excludeFields) {
final Field[] fields = clazz.getDeclaredFields();
AccessibleObject.setAccessible(fields, true);
for (int i = 0; i < fields.length && builder.comparison == 0; i++) {
final Field field = fields[i];
if (!ArrayUtils.contains(excludeFields, field.getName())
&& !field.getName().contains("$")
&& (useTransients || !Modifier.isTransient(field.getModifiers()))
&& !Modifier.isStatic(field.getModifiers())) {
// IllegalAccessException can't happen. Would get a Security exception instead.
// Throw a runtime exception in case the impossible happens.
builder.append(Reflection.getUnchecked(field, lhs), Reflection.getUnchecked(field, rhs));
}
}
}
/**
* Compares two {@link Object}s via reflection.
*
* <p>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.</p>
*
* <ul>
* <li>Static fields will not be compared</li>
* <li>Transient members will be not be compared, as they are likely derived
* fields</li>
* <li>Superclass fields will be compared</li>
* </ul>
*
* <p>If both {@code lhs} and {@code rhs} are {@code null},
* they are considered equal.</p>
*
* @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.
*
* <p>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.</p>
*
* <ul>
* <li>Static fields will not be compared</li>
* <li>If {@code compareTransients} is {@code true},
* compares transient members. Otherwise ignores them, as they
* are likely derived fields.</li>
* <li>Superclass fields will be compared</li>
* </ul>
*
* <p>If both {@code lhs} and {@code rhs} are {@code null},
* they are considered equal.</p>
*
* @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.
*
* <p>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.</p>
*
* <ul>
* <li>Static fields will not be compared</li>
* <li>If the {@code compareTransients} is {@code true},
* compares transient members. Otherwise ignores them, as they
* are likely derived fields.</li>
* <li>Compares superclass fields up to and including {@code reflectUpToClass}.
* If {@code reflectUpToClass} is {@code null}, compares all superclass fields.</li>
* </ul>
*
* <p>If both {@code lhs} and {@code rhs} are {@code null},
* they are considered equal.</p>
*
* @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.
*
* <p>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.</p>
*
* <ul>
* <li>Static fields will not be compared</li>
* <li>If {@code compareTransients} is {@code true},
* compares transient members. Otherwise ignores them, as they
* are likely derived fields.</li>
* <li>Superclass fields will be compared</li>
* </ul>
*
* <p>If both {@code lhs} and {@code rhs} are {@code null},
* they are considered equal.</p>
*
* @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.
*
* <p>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.</p>
*/
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.
*
* <ol>
* <li>Check if arrays are the same using {@code ==}</li>
* <li>Check if for {@code null}, {@code null} is less than non-{@code null}</li>
* <li>Check array length, a shorter length array is less than a longer length array</li>
* <li>Check array contents element by element using {@link #append(boolean, boolean)}</li>
* </ol>
*
* @param lhs left-hand side array
* @param rhs right-hand side array
* @return this
*/
public CompareToBuilder append(final boolean[] lhs, final boolean[] rhs) {
if (comparison != 0) {
return this;
}
if (lhs == rhs) {
return this;
}
if (lhs == null) {
comparison = -1;
return this;
}
if (rhs == null) {
comparison = 1;
return this;
}
if (lhs.length != rhs.length) {
comparison = lhs.length < rhs.length ? -1 : 1;
return this;
}
for (int i = 0; i < lhs.length && comparison == 0; i++) {
append(lhs[i], rhs[i]);
}
return this;
}
/**
* Appends to the {@code builder} the comparison of
* two {@code byte}s.
*
* @param lhs left-hand side value
* @param rhs right-hand side value
* @return this
*/
public CompareToBuilder append(final byte lhs, final byte rhs) {
if (comparison != 0) {
return this;
}
comparison = Byte.compare(lhs, rhs);
return this;
}
/**
* Appends to the {@code builder} the deep comparison of
* two {@code byte} arrays.
*
* <ol>
* <li>Check if arrays are the same using {@code ==}</li>
* <li>Check if for {@code null}, {@code null} is less than non-{@code null}</li>
* <li>Check array length, a shorter length array is less than a longer length array</li>
* <li>Check array contents element by element using {@link #append(byte, byte)}</li>
* </ol>
*
* @param lhs left-hand side array
* @param rhs right-hand side array
* @return this
*/
public CompareToBuilder append(final byte[] lhs, final byte[] rhs) {
if (comparison != 0) {
return this;
}
if (lhs == rhs) {
return this;
}
if (lhs == null) {
comparison = -1;
return this;
}
if (rhs == null) {
comparison = 1;
return this;
}
if (lhs.length != rhs.length) {
comparison = lhs.length < rhs.length ? -1 : 1;
return this;
}
for (int i = 0; i < lhs.length && comparison == 0; i++) {
append(lhs[i], rhs[i]);
}
return this;
}
/**
* Appends to the {@code builder} the comparison of
* two {@code char}s.
*
* @param lhs left-hand side value
* @param rhs right-hand side value
* @return this
*/
public CompareToBuilder append(final char lhs, final char rhs) {
if (comparison != 0) {
return this;
}
comparison = Character.compare(lhs, rhs);
return this;
}
/**
* Appends to the {@code builder} the deep comparison of
* two {@code char} arrays.
*
* <ol>
* <li>Check if arrays are the same using {@code ==}</li>
* <li>Check if for {@code null}, {@code null} is less than non-{@code null}</li>
* <li>Check array length, a shorter length array is less than a longer length array</li>
* <li>Check array contents element by element using {@link #append(char, char)}</li>
* </ol>
*
* @param lhs left-hand side array
* @param rhs right-hand side array
* @return this
*/
public CompareToBuilder append(final char[] lhs, final char[] rhs) {
if (comparison != 0) {
return this;
}
if (lhs == rhs) {
return this;
}
if (lhs == null) {
comparison = -1;
return this;
}
if (rhs == null) {
comparison = 1;
return this;
}
if (lhs.length != rhs.length) {
comparison = lhs.length < rhs.length ? -1 : 1;
return this;
}
for (int i = 0; i < lhs.length && comparison == 0; i++) {
append(lhs[i], rhs[i]);
}
return this;
}
/**
* Appends to the {@code builder} the comparison of
* two {@code double}s.
*
* <p>This handles NaNs, Infinities, and {@code -0.0}.</p>
*
* <p>It is compatible with the hash code generated by
* {@link HashCodeBuilder}.</p>
*
* @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.
*
* <ol>
* <li>Check if arrays are the same using {@code ==}</li>
* <li>Check if for {@code null}, {@code null} is less than non-{@code null}</li>
* <li>Check array length, a shorter length array is less than a longer length array</li>
* <li>Check array contents element by element using {@link #append(double, double)}</li>
* </ol>
*
* @param lhs left-hand side array
* @param rhs right-hand side array
* @return this
*/
public CompareToBuilder append(final double[] lhs, final double[] rhs) {
if (comparison != 0) {
return this;
}
if (lhs == rhs) {
return this;
}
if (lhs == null) {
comparison = -1;
return this;
}
if (rhs == null) {
comparison = 1;
return this;
}
if (lhs.length != rhs.length) {
comparison = lhs.length < rhs.length ? -1 : 1;
return this;
}
for (int i = 0; i < lhs.length && comparison == 0; i++) {
append(lhs[i], rhs[i]);
}
return this;
}
/**
* Appends to the {@code builder} the comparison of
* two {@code float}s.
*
* <p>This handles NaNs, Infinities, and {@code -0.0}.</p>
*
* <p>It is compatible with the hash code generated by
* {@link HashCodeBuilder}.</p>
*
* @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.
*
* <ol>
* <li>Check if arrays are the same using {@code ==}</li>
* <li>Check if for {@code null}, {@code null} is less than non-{@code null}</li>
* <li>Check array length, a shorter length array is less than a longer length array</li>
* <li>Check array contents element by element using {@link #append(float, float)}</li>
* </ol>
*
* @param lhs left-hand side array
* @param rhs right-hand side array
* @return this
*/
public CompareToBuilder append(final float[] lhs, final float[] rhs) {
if (comparison != 0) {
return this;
}
if (lhs == rhs) {
return this;
}
if (lhs == null) {
comparison = -1;
return this;
}
if (rhs == null) {
comparison = 1;
return this;
}
if (lhs.length != rhs.length) {
comparison = lhs.length < rhs.length ? -1 : 1;
return this;
}
for (int i = 0; i < lhs.length && comparison == 0; i++) {
append(lhs[i], rhs[i]);
}
return this;
}
/**
* Appends to the {@code builder} the comparison of
* two {@code int}s.
*
* @param lhs left-hand side value
* @param rhs right-hand side value
* @return this
*/
public CompareToBuilder append(final int lhs, final int rhs) {
if (comparison != 0) {
return this;
}
comparison = Integer.compare(lhs, rhs);
return this;
}
/**
* Appends to the {@code builder} the deep comparison of
* two {@code int} arrays.
*
* <ol>
* <li>Check if arrays are the same using {@code ==}</li>
* <li>Check if for {@code null}, {@code null} is less than non-{@code null}</li>
* <li>Check array length, a shorter length array is less than a longer length array</li>
* <li>Check array contents element by element using {@link #append(int, int)}</li>
* </ol>
*
* @param lhs left-hand side array
* @param rhs right-hand side array
* @return this
*/
public CompareToBuilder append(final int[] lhs, final int[] rhs) {
if (comparison != 0) {
return this;
}
if (lhs == rhs) {
return this;
}
if (lhs == null) {
comparison = -1;
return this;
}
if (rhs == null) {
comparison = 1;
return this;
}
if (lhs.length != rhs.length) {
comparison = lhs.length < rhs.length ? -1 : 1;
return this;
}
for (int i = 0; i < lhs.length && comparison == 0; i++) {
append(lhs[i], rhs[i]);
}
return this;
}
/**
* Appends to the {@code builder} the comparison of
* two {@code long}s.
*
* @param lhs left-hand side value
* @param rhs right-hand side value
* @return this
*/
public CompareToBuilder append(final long lhs, final long rhs) {
if (comparison != 0) {
return this;
}
comparison = Long.compare(lhs, rhs);
return this;
}
/**
* Appends to the {@code builder} the deep comparison of
* two {@code long} arrays.
*
* <ol>
* <li>Check if arrays are the same using {@code ==}</li>
* <li>Check if for {@code null}, {@code null} is less than non-{@code null}</li>
* <li>Check array length, a shorter length array is less than a longer length array</li>
* <li>Check array contents element by element using {@link #append(long, long)}</li>
* </ol>
*
* @param lhs left-hand side array
* @param rhs right-hand side array
* @return this
*/
public CompareToBuilder append(final long[] lhs, final long[] rhs) {
if (comparison != 0) {
return this;
}
if (lhs == rhs) {
return this;
}
if (lhs == null) {
comparison = -1;
return this;
}
if (rhs == null) {
comparison = 1;
return this;
}
if (lhs.length != rhs.length) {
comparison = lhs.length < rhs.length ? -1 : 1;
return this;
}
for (int i = 0; i < lhs.length && comparison == 0; i++) {
append(lhs[i], rhs[i]);
}
return this;
}
/**
* Appends to the {@code builder} the comparison of
* two {@link Object}s.
*
* <ol>
* <li>Check if {@code lhs == rhs}</li>
* <li>Check if either {@code lhs} or {@code rhs} is {@code null},
* a {@code null} object is less than a non-{@code null} object</li>
* <li>Check the object contents</li>
* </ol>
*
* <p>{@code lhs} must either be an array or implement {@link Comparable}.</p>
*
* @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.
*
* <ol>
* <li>Check if {@code lhs == rhs}</li>
* <li>Check if either {@code lhs} or {@code rhs} is {@code null},
* a {@code null} object is less than a non-{@code null} object</li>
* <li>Check the object contents</li>
* </ol>
*
* <p>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.</p>
*
* @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<Object> comparable = (Comparable<Object>) lhs;
comparison = comparable.compareTo(rhs);
} else {
@SuppressWarnings("unchecked") // assume this can be done; if not throw CCE as per Javadoc
final Comparator<Object> comparator2 = (Comparator<Object>) comparator;
comparison = comparator2.compare(lhs, rhs);
}
return this;
}
/**
* Appends to the {@code builder} the deep comparison of
* two {@link Object} arrays.
*
* <ol>
* <li>Check if arrays are the same using {@code ==}</li>
* <li>Check if for {@code null}, {@code null} is less than non-{@code null}</li>
* <li>Check array length, a short length array is less than a long length array</li>
* <li>Check array contents element by element using {@link #append(Object, Object, Comparator)}</li>
* </ol>
*
* <p>This method will also will be called for the top level of multi-dimensional,
* ragged, and multi-typed arrays.</p>
*
* @param lhs left-hand side array
* @param rhs right-hand side array
* @return this
* @throws ClassCastException if {@code rhs} is not assignment-compatible
* with {@code lhs}
*/
public CompareToBuilder append(final Object[] lhs, final Object[] rhs) {
return append(lhs, rhs, null);
}
/**
* Appends to the {@code builder} the deep comparison of
* two {@link Object} arrays.
*
* <ol>
* <li>Check if arrays are the same using {@code ==}</li>
* <li>Check if for {@code null}, {@code null} is less than non-{@code null}</li>
* <li>Check array length, a short length array is less than a long length array</li>
* <li>Check array contents element by element using {@link #append(Object, Object, Comparator)}</li>
* </ol>
*
* <p>This method will also will be called for the top level of multi-dimensional,
* ragged, and multi-typed arrays.</p>
*
* @param lhs left-hand side array
* @param rhs right-hand side array
* @param comparator {@link Comparator} to use to compare the array elements,
* {@code null} means to treat {@code lhs} elements as {@link Comparable}.
* @return this
* @throws ClassCastException if {@code rhs} is not assignment-compatible
* with {@code lhs}
* @since 2.0
*/
public CompareToBuilder append(final Object[] lhs, final Object[] rhs, final Comparator<?> comparator) {
if (comparison != 0) {
return this;
}
if (lhs == rhs) {
return this;
}
if (lhs == null) {
comparison = -1;
return this;
}
if (rhs == null) {
comparison = 1;
return this;
}
if (lhs.length != rhs.length) {
comparison = lhs.length < rhs.length ? -1 : 1;
return this;
}
for (int i = 0; i < lhs.length && comparison == 0; i++) {
append(lhs[i], rhs[i], comparator);
}
return this;
}
/**
* Appends to the {@code builder} the comparison of
* two {@code short}s.
*
* @param lhs left-hand side value
* @param rhs right-hand side value
* @return this
*/
public CompareToBuilder append(final short lhs, final short rhs) {
if (comparison != 0) {
return this;
}
comparison = Short.compare(lhs, rhs);
return this;
}
/**
* Appends to the {@code builder} the deep comparison of
* two {@code short} arrays.
*
* <ol>
* <li>Check if arrays are the same using {@code ==}</li>
* <li>Check if for {@code null}, {@code null} is less than non-{@code null}</li>
* <li>Check array length, a shorter length array is less than a longer length array</li>
* <li>Check array contents element by element using {@link #append(short, short)}</li>
* </ol>
*
* @param lhs left-hand side array
* @param rhs right-hand side array
* @return this
*/
public CompareToBuilder append(final short[] lhs, final short[] rhs) {
if (comparison != 0) {
return this;
}
if (lhs == rhs) {
return this;
}
if (lhs == null) {
comparison = -1;
return this;
}
if (rhs == null) {
comparison = 1;
return this;
}
if (lhs.length != rhs.length) {
comparison = lhs.length < rhs.length ? -1 : 1;
return this;
}
for (int i = 0; i < lhs.length && comparison == 0; i++) {
append(lhs[i], rhs[i]);
}
return this;
}
private void appendArray(final Object lhs, final Object rhs, final Comparator<?> comparator) {
// switch on type of array, to dispatch to the correct handler
// handles multidimensional arrays
// throws a ClassCastException if rhs is not the correct array type
if (lhs instanceof long[]) {
append((long[]) lhs, (long[]) rhs);
} else if (lhs instanceof int[]) {
append((int[]) lhs, (int[]) rhs);
} else if (lhs instanceof short[]) {
append((short[]) lhs, (short[]) rhs);
} else if (lhs instanceof char[]) {
append((char[]) lhs, (char[]) rhs);
} else if (lhs instanceof byte[]) {
append((byte[]) lhs, (byte[]) rhs);
} else if (lhs instanceof double[]) {
append((double[]) lhs, (double[]) rhs);
} else if (lhs instanceof float[]) {
append((float[]) lhs, (float[]) rhs);
} else if (lhs instanceof boolean[]) {
append((boolean[]) lhs, (boolean[]) rhs);
} else {
// not an array of primitives
// throws a ClassCastException if rhs is not an array
append((Object[]) lhs, (Object[]) rhs, comparator);
}
}
/**
* Appends to the {@code builder} the {@code compareTo(Object)}
* result of the superclass.
*
* @param superCompareTo result of calling {@code super.compareTo(Object)}
* @return this
* @since 2.0
*/
public CompareToBuilder appendSuper(final int superCompareTo) {
if (comparison != 0) {
return this;
}
comparison = superCompareTo;
return this;
}
/**
* Returns a negative Integer, a positive Integer, or zero as
* the {@code builder} has judged the "left-hand" side
* as less than, greater than, or equal to the "right-hand"
* side.
*
* @return final comparison result as an Integer
* @see #toComparison()
* @since 3.0
*/
@Override
public Integer build() {
return Integer.valueOf(toComparison());
}
/**
* Returns a negative integer, a positive integer, or zero as
* the {@code builder} has judged the "left-hand" side
* as less than, greater than, or equal to the "right-hand"
* side.
*
* @return final comparison result
* @see #build()
*/
public int toComparison() {
return comparison;
}
}

View File

@ -0,0 +1,214 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions ands
* limitations under the License.
*/
package net.PeytonPlayz585.shadow.apache;
import java.util.Map;
import java.util.Objects;
/**
* An immutable pair consisting of two {@link Object} elements.
*
* <p>Although the implementation is immutable, there is no restriction on the objects
* that may be stored. If mutable objects are stored in the pair, then the pair
* itself effectively becomes mutable.</p>
*
* <p>#ThreadSafe# if both paired objects are thread-safe</p>
*
* @param <L> the left element type
* @param <R> the right element type
*
* @since 3.0
*/
public class ImmutablePair<L, R> extends Pair<L, R> {
/**
* An empty array.
* <p>
* Consider using {@link #emptyArray()} to avoid generics warnings.
* </p>
*
* @since 3.10.
*/
public static final ImmutablePair<?, ?>[] EMPTY_ARRAY = {};
/**
* An immutable pair of nulls.
*/
// This is not defined with generics to avoid warnings in call sites.
@SuppressWarnings("rawtypes")
private static final ImmutablePair NULL = new ImmutablePair<>(null, null);
/** Serialization version */
private static final long serialVersionUID = 4954918890077093841L;
/**
* Returns the empty array singleton that can be assigned without compiler warning.
*
* @param <L> the left element type
* @param <R> the right element type
* @return the empty array singleton that can be assigned without compiler warning.
*
* @since 3.10.
*/
@SuppressWarnings("unchecked")
public static <L, R> ImmutablePair<L, R>[] emptyArray() {
return (ImmutablePair<L, R>[]) EMPTY_ARRAY;
}
/**
* Creates an immutable pair of two objects inferring the generic types.
*
* <p>This factory allows the pair to be created using inference to
* obtain the generic types.</p>
*
* @param <L> the left element type
* @param <R> the right element type
* @param left the left element, may be null
* @return a pair formed from the two parameters, not null
* @since 3.11
*/
public static <L, R> Pair<L, R> left(final L left) {
return ImmutablePair.of(left, null);
}
/**
* Returns an immutable pair of nulls.
*
* @param <L> the left element of this pair. Value is {@code null}.
* @param <R> the right element of this pair. Value is {@code null}.
* @return an immutable pair of nulls.
* @since 3.6
*/
@SuppressWarnings("unchecked")
public static <L, R> ImmutablePair<L, R> nullPair() {
return NULL;
}
/**
* Creates an immutable pair of two objects inferring the generic types.
*
* <p>This factory allows the pair to be created using inference to
* obtain the generic types.</p>
*
* @param <L> the left element type
* @param <R> the right element type
* @param left the left element, may be null
* @param right the right element, may be null
* @return a pair formed from the two parameters, not null
*/
public static <L, R> ImmutablePair<L, R> of(final L left, final R right) {
return left != null || right != null ? new ImmutablePair<>(left, right) : nullPair();
}
/**
* Creates an immutable pair from a map entry.
*
* <p>This factory allows the pair to be created using inference to
* obtain the generic types.</p>
*
* @param <L> the left element type
* @param <R> the right element type
* @param pair the existing map entry.
* @return a pair formed from the map entry
* @since 3.10
*/
public static <L, R> ImmutablePair<L, R> of(final Map.Entry<L, R> pair) {
return pair != null ? new ImmutablePair<>(pair.getKey(), pair.getValue()) : nullPair();
}
/**
* Creates an immutable pair of two non-null objects inferring the generic types.
*
* <p>This factory allows the pair to be created using inference to
* obtain the generic types.</p>
*
* @param <L> the left element type
* @param <R> the right element type
* @param left the left element, may not be null
* @param right the right element, may not be null
* @return a pair formed from the two parameters, not null
* @throws NullPointerException if any input is null
* @since 3.13.0
*/
public static <L, R> ImmutablePair<L, R> ofNonNull(final L left, final R right) {
return of(Objects.requireNonNull(left, "left"), Objects.requireNonNull(right, "right"));
}
/**
* Creates an immutable pair of two objects inferring the generic types.
*
* <p>This factory allows the pair to be created using inference to
* obtain the generic types.</p>
*
* @param <L> the left element type
* @param <R> the right element type
* @param right the right element, may be null
* @return a pair formed from the two parameters, not null
* @since 3.11
*/
public static <L, R> Pair<L, R> right(final R right) {
return ImmutablePair.of(null, right);
}
/** Left object */
public final L left;
/** Right object */
public final R right;
/**
* Create a new pair instance.
*
* @param left the left value, may be null
* @param right the right value, may be null
*/
public ImmutablePair(final L left, final R right) {
this.left = left;
this.right = right;
}
/**
* {@inheritDoc}
*/
@Override
public L getLeft() {
return left;
}
/**
* {@inheritDoc}
*/
@Override
public R getRight() {
return right;
}
/**
* Throws {@link UnsupportedOperationException}.
*
* <p>This pair is immutable, so this operation is not supported.</p>
*
* @param value the value to set
* @return never
* @throws UnsupportedOperationException as this operation is not supported
*/
@Override
public R setValue(final R value) {
throw new UnsupportedOperationException();
}
}

View File

@ -0,0 +1,260 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.PeytonPlayz585.shadow.apache;
import java.io.Serializable;
import java.util.Map;
import java.util.Objects;
import org.apache.commons.lang3.function.FailableBiConsumer;
import org.apache.commons.lang3.function.FailableBiFunction;
/**
* A pair consisting of two elements.
*
* <p>This class is an abstract implementation defining the basic API.
* It refers to the elements as 'left' and 'right'. It also implements the
* {@code Map.Entry} interface where the key is 'left' and the value is 'right'.</p>
*
* <p>Subclass implementations may be mutable or immutable.
* However, there is no restriction on the type of the stored objects that may be stored.
* If mutable objects are stored in the pair, then the pair itself effectively becomes mutable.</p>
*
* @param <L> the left element type
* @param <R> the right element type
*
* @since 3.0
*/
public abstract class Pair<L, R> implements Map.Entry<L, R>, Comparable<Pair<L, R>>, Serializable {
/** Serialization version */
private static final long serialVersionUID = 4954918890077093841L;
/**
* An empty array.
* <p>
* Consider using {@link #emptyArray()} to avoid generics warnings.
* </p>
*
* @since 3.10.
*/
public static final Pair<?, ?>[] EMPTY_ARRAY = {};
/**
* Returns the empty array singleton that can be assigned without compiler warning.
*
* @param <L> the left element type
* @param <R> the right element type
* @return the empty array singleton that can be assigned without compiler warning.
*
* @since 3.10.
*/
@SuppressWarnings("unchecked")
public static <L, R> Pair<L, R>[] emptyArray() {
return (Pair<L, R>[]) EMPTY_ARRAY;
}
/**
* Creates an immutable pair of two objects inferring the generic types.
*
* <p>This factory allows the pair to be created using inference to
* obtain the generic types.</p>
*
* @param <L> the left element type
* @param <R> the right element type
* @param left the left element, may be null
* @param right the right element, may be null
* @return a pair formed from the two parameters, not null
*/
public static <L, R> Pair<L, R> of(final L left, final R right) {
return ImmutablePair.of(left, right);
}
/**
* Creates an immutable pair from a map entry.
*
* <p>This factory allows the pair to be created using inference to
* obtain the generic types.</p>
*
* @param <L> the left element type
* @param <R> the right element type
* @param pair the map entry.
* @return a pair formed from the map entry
* @since 3.10
*/
public static <L, R> Pair<L, R> of(final Map.Entry<L, R> pair) {
return ImmutablePair.of(pair);
}
/**
* Creates an immutable pair of two non-null objects inferring the generic types.
*
* <p>This factory allows the pair to be created using inference to
* obtain the generic types.</p>
*
* @param <L> the left element type
* @param <R> the right element type
* @param left the left element, may not be null
* @param right the right element, may not be null
* @return a pair formed from the two parameters, not null
* @throws NullPointerException if any input is null
* @since 3.13.0
*/
public static <L, R> Pair<L, R> ofNonNull(final L left, final R right) {
return ImmutablePair.ofNonNull(left, right);
}
/**
* Accepts this key and value as arguments to the given consumer.
*
* @param <E> The kind of thrown exception or error.
* @param consumer the consumer to call.
* @throws E Thrown when the consumer fails.
* @since 3.13.0
*/
public <E extends Throwable> void accept(final FailableBiConsumer<L, R, E> consumer) throws E {
consumer.accept(getKey(), getValue());
}
/**
* Applies this key and value as arguments to the given function.
*
* @param <V> The function return type.
* @param <E> The kind of thrown exception or error.
* @param function the consumer to call.
* @return the function's return value.
* @throws E Thrown when the consumer fails.
* @since 3.13.0
*/
public <V, E extends Throwable> V apply(final FailableBiFunction<L, R, V, E> function) throws E {
return function.apply(getKey(), getValue());
}
/**
* Compares the pair based on the left element followed by the right element.
* The types must be {@link Comparable}.
*
* @param other the other pair, not null
* @return negative if this is less, zero if equal, positive if greater
*/
@Override
public int compareTo(final Pair<L, R> other) {
return new CompareToBuilder().append(getLeft(), other.getLeft())
.append(getRight(), other.getRight()).toComparison();
}
/**
* Compares this pair to another based on the two elements.
*
* @param obj the object to compare to, null returns false
* @return true if the elements of the pair are equal
*/
@Override
public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof Map.Entry<?, ?>) {
final Map.Entry<?, ?> other = (Map.Entry<?, ?>) obj;
return Objects.equals(getKey(), other.getKey())
&& Objects.equals(getValue(), other.getValue());
}
return false;
}
/**
* Gets the key from this pair.
*
* <p>This method implements the {@code Map.Entry} interface returning the
* left element as the key.</p>
*
* @return the left element as the key, may be null
*/
@Override
public final L getKey() {
return getLeft();
}
/**
* Gets the left element from this pair.
*
* <p>When treated as a key-value pair, this is the key.</p>
*
* @return the left element, may be null
*/
public abstract L getLeft();
/**
* Gets the right element from this pair.
*
* <p>When treated as a key-value pair, this is the value.</p>
*
* @return the right element, may be null
*/
public abstract R getRight();
/**
* Gets the value from this pair.
*
* <p>This method implements the {@code Map.Entry} interface returning the
* right element as the value.</p>
*
* @return the right element as the value, may be null
*/
@Override
public R getValue() {
return getRight();
}
/**
* Returns a suitable hash code.
* The hash code follows the definition in {@code Map.Entry}.
*
* @return the hash code
*/
@Override
public int hashCode() {
// see Map.Entry API specification
return Objects.hashCode(getKey()) ^ Objects.hashCode(getValue());
}
/**
* Returns a String representation of this pair using the format {@code ($left,$right)}.
*
* @return a string describing this object, not null
*/
@Override
public String toString() {
return "(" + getLeft() + ',' + getRight() + ')';
}
/**
* Formats the receiver using the given format.
*
* <p>This uses {@link java.util.Formattable} to perform the formatting. Two variables may
* be used to embed the left and right elements. Use {@code %1$s} for the left
* element (key) and {@code %2$s} for the right element (value).
* The default format used by {@code toString()} is {@code (%1$s,%2$s)}.</p>
*
* @param format the format string, optionally containing {@code %1$s} and {@code %2$s}, not null
* @return the formatted string, not null
*/
public String toString(final String format) {
return String.format(format, getLeft(), getRight());
}
}

View File

@ -0,0 +1,44 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.PeytonPlayz585.shadow.apache;
import java.lang.reflect.Field;
import java.util.Objects;
/**
* Package-private reflection code.
*/
final class Reflection {
/**
* Delegates to {@link Field#get(Object)} and rethrows {@link IllegalAccessException} as {@link IllegalArgumentException}.
*
* @param field The receiver of the get call.
* @param obj The argument of the get call.
* @return The result of the get call.
* @throws IllegalArgumentException Thrown after catching {@link IllegalAccessException}.
*/
static Object getUnchecked(final Field field, final Object obj) {
try {
return Objects.requireNonNull(field, "field").get(obj);
} catch (IllegalAccessException e) {
throw new IllegalArgumentException(e);
}
}
}

View File

@ -10,7 +10,7 @@ public class GuiQuality extends GuiScreen {
protected String title;
private GameSettings settings;
//private static GameSettings.Options[] enumOptions = new GameSettings.Options[] {GameSettings.Options.MIPMAP_LEVELS, GameSettings.Options.MIPMAP_TYPE, GameSettings.Options.AF_LEVEL, GameSettings.Options.AA_LEVEL, GameSettings.Options.CLEAR_WATER, GameSettings.Options.RANDOM_MOBS, GameSettings.Options.BETTER_GRASS, GameSettings.Options.BETTER_SNOW, GameSettings.Options.CUSTOM_FONTS, GameSettings.Options.CUSTOM_COLORS, GameSettings.Options.SWAMP_COLORS, GameSettings.Options.SMOOTH_BIOMES, GameSettings.Options.CONNECTED_TEXTURES, GameSettings.Options.NATURAL_TEXTURES, GameSettings.Options.CUSTOM_SKY, GameSettings.Options.CUSTOM_ITEMS, GameSettings.Options.DYNAMIC_LIGHTS};
private static GameSettings.Options[] enumOptions = new GameSettings.Options[] {GameSettings.Options.MIPMAP_LEVELS, GameSettings.Options.MIPMAP_TYPE, GameSettings.Options.FXAA, GameSettings.Options.CLEAR_WATER, GameSettings.Options.BETTER_GRASS, GameSettings.Options.BETTER_SNOW, GameSettings.Options.CUSTOM_FONTS, GameSettings.Options.CUSTOM_SKY, GameSettings.Options.DYNAMIC_LIGHTS};
private static GameSettings.Options[] enumOptions = new GameSettings.Options[] {GameSettings.Options.MIPMAP_LEVELS, GameSettings.Options.MIPMAP_TYPE, GameSettings.Options.FXAA, GameSettings.Options.CLEAR_WATER, GameSettings.Options.BETTER_GRASS, GameSettings.Options.BETTER_SNOW, GameSettings.Options.CUSTOM_FONTS, GameSettings.Options.CUSTOM_COLORS, GameSettings.Options.SWAMP_COLORS, GameSettings.Options.SMOOTH_BIOMES, GameSettings.Options.CUSTOM_SKY, GameSettings.Options.DYNAMIC_LIGHTS};
public GuiQuality(GuiScreen p_i53_1_) {
this.prevScreen = p_i53_1_;

View File

@ -1,8 +1,12 @@
package net.PeytonPlayz585.shadow.reflections;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;
import net.minecraft.world.biome.BiomeGenBase;
import net.PeytonPlayz585.shadow.Config;
import net.minecraft.client.resources.DefaultResourcePack;
public class Reflector {
@ -11,6 +15,8 @@ public class Reflector {
public static ReflectorField ResourcePackRepository_repositoryEntries = new ReflectorField(ResourcePackRepository, List.class, 1);
public static ReflectorClass Minecraft = new ReflectorClass(net.minecraft.client.Minecraft.class);
public static ReflectorField Minecraft_defaultResourcePack = new ReflectorField(Minecraft, DefaultResourcePack.class);
public static ReflectorClass ForgeBiome = new ReflectorClass(BiomeGenBase.class);
public static ReflectorMethod ForgeBiome_getWaterColorMultiplier = new ReflectorMethod(ForgeBiome, "getWaterColorMultiplier");
public static Object getFieldValue(ReflectorField p_getFieldValue_0_) {
return getFieldValue((Object) null, p_getFieldValue_0_);
@ -89,5 +95,100 @@ public class Reflector {
return true;
}
}
public static int callInt(ReflectorMethod p_callInt_0_, Object... p_callInt_1_)
{
try {
Method method = p_callInt_0_.getTargetMethod();
if (method == null) {
return 0;
} else {
Integer integer = (Integer)method.invoke((Object)null, p_callInt_1_);
return integer.intValue();
}
} catch (Throwable throwable) {
handleException(throwable, (Object)null, p_callInt_0_, p_callInt_1_);
return 0;
}
}
public static int callInt(Object p_callInt_0_, ReflectorMethod p_callInt_1_, Object... p_callInt_2_) {
try {
Method method = p_callInt_1_.getTargetMethod();
if (method == null) {
return 0;
} else {
Integer integer = (Integer)method.invoke(p_callInt_0_, p_callInt_2_);
return integer.intValue();
}
} catch (Throwable throwable) {
handleException(throwable, p_callInt_0_, p_callInt_1_, p_callInt_2_);
return 0;
}
}
private static void handleException(Throwable p_handleException_0_, Object p_handleException_1_, ReflectorMethod p_handleException_2_, Object[] p_handleException_3_) {
if (p_handleException_0_ instanceof InvocationTargetException) {
Throwable throwable = p_handleException_0_.getCause();
if (throwable instanceof RuntimeException) {
RuntimeException runtimeexception = (RuntimeException)throwable;
throw runtimeexception;
} else {
p_handleException_0_.printStackTrace();
}
} else {
if (p_handleException_0_ instanceof IllegalArgumentException) {
Config.warn("*** IllegalArgumentException ***");
Config.warn("Method: " + p_handleException_2_.getTargetMethod());
Config.warn("Object: " + p_handleException_1_);
Config.warn("Parameter classes: " + Config.arrayToString(getClasses(p_handleException_3_)));
Config.warn("Parameters: " + Config.arrayToString(p_handleException_3_));
}
Config.warn("*** Exception outside of method ***");
Config.warn("Method deactivated: " + p_handleException_2_.getTargetMethod());
p_handleException_2_.deactivate();
p_handleException_0_.printStackTrace();
}
}
private static void handleException(Throwable p_handleException_0_, ReflectorConstructor p_handleException_1_, Object[] p_handleException_2_) {
if (p_handleException_0_ instanceof InvocationTargetException) {
p_handleException_0_.printStackTrace();
} else {
if (p_handleException_0_ instanceof IllegalArgumentException) {
Config.warn("*** IllegalArgumentException ***");
Config.warn("Constructor: " + p_handleException_1_.getTargetConstructor());
Config.warn("Parameter classes: " + Config.arrayToString(getClasses(p_handleException_2_)));
Config.warn("Parameters: " + Config.arrayToString(p_handleException_2_));
}
Config.warn("*** Exception outside of constructor ***");
Config.warn("Constructor deactivated: " + p_handleException_1_.getTargetConstructor());
p_handleException_1_.deactivate();
p_handleException_0_.printStackTrace();
}
}
private static Object[] getClasses(Object[] p_getClasses_0_) {
if (p_getClasses_0_ == null) {
return new Class[0];
} else {
Class[] aclass = new Class[p_getClasses_0_.length];
for (int i = 0; i < aclass.length; ++i) {
Object object = p_getClasses_0_[i];
if (object != null) {
aclass[i] = object.getClass();
}
}
return aclass;
}
}
}

View File

@ -0,0 +1,71 @@
package net.PeytonPlayz585.shadow.reflections;
import java.lang.reflect.Constructor;
import net.PeytonPlayz585.shadow.Config;
public class ReflectorConstructor {
private ReflectorClass reflectorClass = null;
private Class[] parameterTypes = null;
private boolean checked = false;
private Constructor targetConstructor = null;
public ReflectorConstructor(ReflectorClass p_i84_1_, Class[] p_i84_2_) {
this.reflectorClass = p_i84_1_;
this.parameterTypes = p_i84_2_;
Constructor constructor = this.getTargetConstructor();
}
public Constructor getTargetConstructor() {
if (this.checked) {
return this.targetConstructor;
} else {
this.checked = true;
Class oclass = this.reflectorClass.getTargetClass();
if (oclass == null) {
return null;
} else {
try {
this.targetConstructor = findConstructor(oclass, this.parameterTypes);
if (this.targetConstructor == null) {
Config.dbg("(Reflector) Constructor not present: " + oclass.getName() + ", params: " + Config.arrayToString((Object[]) this.parameterTypes));
}
if (this.targetConstructor != null) {
this.targetConstructor.setAccessible(true);
}
} catch (Throwable throwable) {
throwable.printStackTrace();
}
return this.targetConstructor;
}
}
}
private static Constructor findConstructor(Class p_findConstructor_0_, Class[] p_findConstructor_1_) {
Constructor[] aconstructor = p_findConstructor_0_.getDeclaredConstructors();
for (int i = 0; i < aconstructor.length; ++i) {
Constructor constructor = aconstructor[i];
Class[] aclass = constructor.getParameterTypes();
if (Reflector.matchesTypes(p_findConstructor_1_, aclass)) {
return constructor;
}
}
return null;
}
public boolean exists() {
return this.checked ? this.targetConstructor != null : this.getTargetConstructor() != null;
}
public void deactivate() {
this.checked = true;
this.targetConstructor = null;
}
}

View File

@ -51,5 +51,14 @@ public class ArrayUtils {
}
return str;
}
public static boolean contains(String[] array, String value) {
for (String item : array) {
if (item.equals(value)) {
return true;
}
}
return false;
}
}

View File

@ -3,7 +3,6 @@ package net.lax1dude.eaglercraft.v1_8.opengl;
import java.io.*;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.util.Arrays;
import java.util.HashMap;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
@ -19,10 +18,7 @@ public class ImageData {
public ImageData(int width, int height, int[] pixels, boolean alpha) {
this.width = width;
this.height = height;
this.pixels = ByteBuffer.allocateDirect(pixels.length * 4)
.asIntBuffer()
.put(pixels)
.flip();
this.pixels = (IntBuffer) ByteBuffer.allocateDirect(pixels.length * 4).asIntBuffer().put(pixels).flip();
this.alpha = alpha;
}

View File

@ -20,12 +20,6 @@ import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
import java.io.IOException;
import java.util.HashMap;
import org.teavm.jso.JSBody;
import org.teavm.jso.dom.events.Event;
import org.teavm.jso.dom.events.EventListener;
import org.teavm.jso.dom.events.MessageEvent;
import org.teavm.jso.websocket.WebSocket;
/**
* Copyright (c) 2022-2023 LAX1DUDE. All Rights Reserved.
*

View File

@ -60,7 +60,7 @@ public class MapColor {
public static final MapColor emeraldColor = new MapColor(33, '\ud93a');
public static final MapColor obsidianColor = new MapColor(34, 8476209);
public static final MapColor netherrackColor = new MapColor(35, 7340544);
public final int colorValue;
public int colorValue;
public final int colorIndex;
private MapColor(int index, int color) {

View File

@ -23,6 +23,7 @@ import net.minecraft.client.settings.GameSettings;
import net.minecraft.util.ResourceLocation;
import net.PeytonPlayz585.shadow.Config;
import net.PeytonPlayz585.shadow.CustomColors;
import net.PeytonPlayz585.shadow.FontUtils;
/**+
@ -372,6 +373,9 @@ public class FontRenderer implements IResourceManagerReloadListener {
}
int j1 = this.colorCode[i1];
if (Config.isCustomColors()) {
j1 = CustomColors.getTextColor(i1, j1);
}
this.textColor = j1;
GlStateManager.color((float) (j1 >> 16) / 255.0F, (float) (j1 >> 8 & 255) / 255.0F,
(float) (j1 & 255) / 255.0F, this.alpha);
@ -858,6 +862,18 @@ public class FontRenderer implements IResourceManagerReloadListener {
}
public int getColorCode(char character) {
return this.colorCode["0123456789abcdef".indexOf(character)];
}
int i = "0123456789abcdef".indexOf(character);
if (i >= 0 && i < this.colorCode.length) {
int j = this.colorCode[i];
if (Config.isCustomColors()) {
j = CustomColors.getTextColor(i, j);
}
return j;
} else {
return 16777215;
}
}
}

View File

@ -9,6 +9,7 @@ import java.util.List;
import net.FatalCodes.shadow.Shadow;
import net.FatalCodes.shadow.module.RenderModule;
import net.PeytonPlayz585.shadow.Config;
import net.PeytonPlayz585.shadow.CustomColors;
import net.PeytonPlayz585.shadow.gui.ArmorGui;
import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerTextureAtlasSprite;
@ -222,6 +223,11 @@ public class GuiIngame extends Gui {
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, 1, 0);
int l = 16777215;
if (Config.isCustomColors()) {
l = CustomColors.getBossTextColor(l);
}
if (this.recordIsPlaying) {
l = MathHelper.func_181758_c(f2 / 50.0F, 0.7F, 0.6F) & 16777215;
}
@ -396,6 +402,11 @@ public class GuiIngame extends Gui {
if (this.mc.thePlayer.experienceLevel > 0) {
this.mc.mcProfiler.startSection("expLevel");
int i1 = 8453920;
if (Config.isCustomColors()) {
i1 = CustomColors.getExpBarTextColor(i1);
}
String s = "" + this.mc.thePlayer.experienceLevel;
int j1 = (parScaledResolution.getScaledWidth() - this.getFontRenderer().getStringWidth(s)) / 2;
int l = parScaledResolution.getScaledHeight() - 31 - 4;

View File

@ -1,5 +1,7 @@
package net.minecraft.client.renderer;
import net.PeytonPlayz585.shadow.CustomColors;
import net.PeytonPlayz585.shadow.RenderEnv;
import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerTextureAtlasSprite;
import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.BlockVertexIDs;
@ -59,7 +61,8 @@ public class BlockFluidRenderer {
boolean realistic = !lava && DeferredStateManager.isRenderingRealisticWater();
blockliquid.setBlockBoundsBasedOnState(blockAccess, blockPosIn);
EaglerTextureAtlasSprite[] atextureatlassprite = lava ? this.atlasSpritesLava : this.atlasSpritesWater;
int i = blockliquid.colorMultiplier(blockAccess, blockPosIn);
RenderEnv renderenv = RenderEnv.getInstance(blockAccess, blockStateIn, blockPosIn);
int i = CustomColors.getFluidColor(blockAccess, blockStateIn, blockPosIn, renderenv);
float f = (float) (i >> 16 & 255) / 255.0F;
float f1 = (float) (i >> 8 & 255) / 255.0F;
float f2 = (float) (i & 255) / 255.0F;

View File

@ -101,7 +101,7 @@ public class BlockModelRenderer {
list = BetterGrass.getFaceQuads(blockAccessIn, blockIn, blockPosIn, enumfacing, list);
}
this.renderModelAmbientOcclusionQuads(blockAccessIn, blockIn, blockPosIn, worldRendererIn, list, afloat, bitset, blockmodelrenderer$ambientocclusionface);
this.renderModelAmbientOcclusionQuads(blockAccessIn, blockIn, blockPosIn, worldRendererIn, list, afloat, bitset, blockmodelrenderer$ambientocclusionface, renderenv);
flag = true;
}
}
@ -110,7 +110,7 @@ public class BlockModelRenderer {
List list1 = modelIn.getGeneralQuads();
if (list1.size() > 0) {
this.renderModelAmbientOcclusionQuads(blockAccessIn, blockIn, blockPosIn, worldRendererIn, list1, afloat,
bitset, blockmodelrenderer$ambientocclusionface);
bitset, blockmodelrenderer$ambientocclusionface, renderenv);
flag = true;
}
@ -171,7 +171,7 @@ public class BlockModelRenderer {
private void renderModelAmbientOcclusionQuads(IBlockAccess blockAccessIn, Block blockIn, BlockPos blockPosIn,
WorldRenderer worldRendererIn, List<BakedQuad> listQuadsIn, float[] quadBounds, BitSet boundsFlags,
BlockModelRenderer.AmbientOcclusionFace aoFaceIn) {
BlockModelRenderer.AmbientOcclusionFace aoFaceIn, RenderEnv renderenv) {
boolean isDeferred = DeferredStateManager.isDeferredRenderer();
double d0 = (double) blockPosIn.getX();
double d1 = (double) blockPosIn.getY();
@ -192,35 +192,35 @@ public class BlockModelRenderer {
aoFaceIn.updateVertexBrightness(blockAccessIn, blockIn, blockPosIn, bakedquad.getFace(), quadBounds,
boundsFlags);
worldRendererIn.addVertexData(vertData);
worldRendererIn.putBrightness4(aoFaceIn.vertexBrightness[0], aoFaceIn.vertexBrightness[1],
aoFaceIn.vertexBrightness[2], aoFaceIn.vertexBrightness[3]);
if (bakedquad.hasTintIndex()) {
int j = blockIn.colorMultiplier(blockAccessIn, blockPosIn, bakedquad.getTintIndex());
if (EntityRenderer.anaglyphEnable) {
j = TextureUtil.anaglyphColor(j);
}
worldRendererIn.putBrightness4(aoFaceIn.vertexBrightness[0], aoFaceIn.vertexBrightness[1], aoFaceIn.vertexBrightness[2], aoFaceIn.vertexBrightness[3]);
int k = CustomColors.getColorMultiplier(bakedquad, blockIn, blockAccessIn, blockPosIn, renderenv);
if (!bakedquad.hasTintIndex() && k == -1) {
worldRendererIn.putColorMultiplier(aoFaceIn.vertexColorMultiplier[0], aoFaceIn.vertexColorMultiplier[0], aoFaceIn.vertexColorMultiplier[0], 4);
worldRendererIn.putColorMultiplier(aoFaceIn.vertexColorMultiplier[1], aoFaceIn.vertexColorMultiplier[1], aoFaceIn.vertexColorMultiplier[1], 3);
worldRendererIn.putColorMultiplier(aoFaceIn.vertexColorMultiplier[2], aoFaceIn.vertexColorMultiplier[2], aoFaceIn.vertexColorMultiplier[2], 2);
worldRendererIn.putColorMultiplier(aoFaceIn.vertexColorMultiplier[3], aoFaceIn.vertexColorMultiplier[3], aoFaceIn.vertexColorMultiplier[3], 1);
} else {
int j;
float f = (float) (j >> 16 & 255) / 255.0F;
float f1 = (float) (j >> 8 & 255) / 255.0F;
float f2 = (float) (j & 255) / 255.0F;
worldRendererIn.putColorMultiplier(aoFaceIn.vertexColorMultiplier[0] * f,
aoFaceIn.vertexColorMultiplier[0] * f1, aoFaceIn.vertexColorMultiplier[0] * f2, 4);
worldRendererIn.putColorMultiplier(aoFaceIn.vertexColorMultiplier[1] * f,
aoFaceIn.vertexColorMultiplier[1] * f1, aoFaceIn.vertexColorMultiplier[1] * f2, 3);
worldRendererIn.putColorMultiplier(aoFaceIn.vertexColorMultiplier[2] * f,
aoFaceIn.vertexColorMultiplier[2] * f1, aoFaceIn.vertexColorMultiplier[2] * f2, 2);
worldRendererIn.putColorMultiplier(aoFaceIn.vertexColorMultiplier[3] * f,
aoFaceIn.vertexColorMultiplier[3] * f1, aoFaceIn.vertexColorMultiplier[3] * f2, 1);
} else {
worldRendererIn.putColorMultiplier(aoFaceIn.vertexColorMultiplier[0], aoFaceIn.vertexColorMultiplier[0],
aoFaceIn.vertexColorMultiplier[0], 4);
worldRendererIn.putColorMultiplier(aoFaceIn.vertexColorMultiplier[1], aoFaceIn.vertexColorMultiplier[1],
aoFaceIn.vertexColorMultiplier[1], 3);
worldRendererIn.putColorMultiplier(aoFaceIn.vertexColorMultiplier[2], aoFaceIn.vertexColorMultiplier[2],
aoFaceIn.vertexColorMultiplier[2], 2);
worldRendererIn.putColorMultiplier(aoFaceIn.vertexColorMultiplier[3], aoFaceIn.vertexColorMultiplier[3],
aoFaceIn.vertexColorMultiplier[3], 1);
}
if (k != -1) {
j = k;
} else {
j = blockIn.colorMultiplier(blockAccessIn, blockPosIn, bakedquad.getTintIndex());
}
if (EntityRenderer.anaglyphEnable) {
j = TextureUtil.anaglyphColor(j);
}
float f = (float)(j >> 16 & 255) / 255.0F;
float f1 = (float)(j >> 8 & 255) / 255.0F;
float f2 = (float)(j & 255) / 255.0F;
worldRendererIn.putColorMultiplier(aoFaceIn.vertexColorMultiplier[0] * f, aoFaceIn.vertexColorMultiplier[0] * f1, aoFaceIn.vertexColorMultiplier[0] * f2, 4);
worldRendererIn.putColorMultiplier(aoFaceIn.vertexColorMultiplier[1] * f, aoFaceIn.vertexColorMultiplier[1] * f1, aoFaceIn.vertexColorMultiplier[1] * f2, 3);
worldRendererIn.putColorMultiplier(aoFaceIn.vertexColorMultiplier[2] * f, aoFaceIn.vertexColorMultiplier[2] * f1, aoFaceIn.vertexColorMultiplier[2] * f2, 2);
worldRendererIn.putColorMultiplier(aoFaceIn.vertexColorMultiplier[3] * f, aoFaceIn.vertexColorMultiplier[3] * f1, aoFaceIn.vertexColorMultiplier[3] * f2, 1);
}
worldRendererIn.putPosition(d0, d1, d2);
}

View File

@ -88,6 +88,7 @@ import net.minecraft.world.WorldSettings;
import net.minecraft.world.biome.BiomeGenBase;
import net.PeytonPlayz585.shadow.Config;
import net.PeytonPlayz585.shadow.CustomColors;
import net.PeytonPlayz585.shadow.Lagometer;
import net.PeytonPlayz585.shadow.TextureUtils;
import net.PeytonPlayz585.shadow.debug.DebugChunkRenderer;
@ -769,6 +770,14 @@ public class EntityRenderer implements IResourceManagerReloadListener {
this.mc.mcProfiler.startSection("lightTex");
WorldClient worldclient = this.mc.theWorld;
if (worldclient != null) {
if (Config.isCustomColors() && CustomColors.updateLightmap(worldclient, this.torchFlickerX, this.lightmapColors, this.mc.thePlayer.isPotionActive(Potion.nightVision))) {
this.lightmapTexture.updateDynamicTexture();
this.lightmapUpdateNeeded = false;
this.mc.mcProfiler.endSection();
return;
}
float f = worldclient.getSunBrightness(1.0F);
float f1 = f * 0.95F + 0.05F;
@ -1659,10 +1668,12 @@ public class EntityRenderer implements IResourceManagerReloadListener {
float f = 0.25F + 0.75F * (float) this.mc.gameSettings.renderDistanceChunks / 32.0F;
f = 1.0F - (float) Math.pow((double) f, 0.25D);
Vec3 vec3 = worldclient.getSkyColor(this.mc.getRenderViewEntity(), partialTicks);
vec3 = CustomColors.getWorldSkyColor(vec3, worldclient, this.mc.getRenderViewEntity(), partialTicks);
float f1 = (float) vec3.xCoord;
float f2 = (float) vec3.yCoord;
float f3 = (float) vec3.zCoord;
Vec3 vec31 = worldclient.getFogColor(partialTicks);
vec31 = CustomColors.getWorldFogColor(vec31, worldclient, this.mc.getRenderViewEntity(), partialTicks);
this.fogColorRed = (float) vec31.xCoord;
this.fogColorGreen = (float) vec31.yCoord;
this.fogColorBlue = (float) vec31.zCoord;
@ -1715,15 +1726,22 @@ public class EntityRenderer implements IResourceManagerReloadListener {
this.fogColorGreen = (float) vec33.yCoord;
this.fogColorBlue = (float) vec33.zCoord;
} else if (block.getMaterial() == Material.water) {
float f12 = (float) EnchantmentHelper.getRespiration(entity) * 0.2F;
if (entity instanceof EntityLivingBase
&& ((EntityLivingBase) entity).isPotionActive(Potion.waterBreathing)) {
f12 = f12 * 0.3F + 0.6F;
}
float f10 = (float)EnchantmentHelper.getRespiration(entity) * 0.2F;
this.fogColorRed = 0.02F + f12;
this.fogColorGreen = 0.02F + f12;
this.fogColorBlue = 0.2F + f12;
if (entity instanceof EntityLivingBase && ((EntityLivingBase)entity).isPotionActive(Potion.waterBreathing)) {
f10 = f10 * 0.3F + 0.6F;
}
this.fogColorRed = 0.02F + f10;
this.fogColorGreen = 0.02F + f10;
this.fogColorBlue = 0.2F + f10;
Vec3 vec34 = CustomColors.getUnderwaterColor(this.mc.theWorld, this.mc.getRenderViewEntity().posX, this.mc.getRenderViewEntity().posY + 1.0D, this.mc.getRenderViewEntity().posZ);
if (vec34 != null) {
this.fogColorRed = (float)vec34.xCoord;
this.fogColorGreen = (float)vec34.yCoord;
this.fogColorBlue = (float)vec34.zCoord;
}
} else if (block.getMaterial() == Material.lava) {
this.fogColorRed = 0.6F;
this.fogColorGreen = 0.1F;

View File

@ -11,6 +11,7 @@ import java.util.List;
import java.util.Map;
import net.PeytonPlayz585.shadow.Config;
import net.PeytonPlayz585.shadow.CustomColors;
import net.PeytonPlayz585.shadow.CustomSky;
import net.PeytonPlayz585.shadow.DynamicLights;
import net.PeytonPlayz585.shadow.Lagometer;
@ -1354,6 +1355,7 @@ public class RenderGlobal implements IWorldAccess, IResourceManagerReloadListene
} else if (this.mc.theWorld.provider.isSurfaceWorld()) {
GlStateManager.disableTexture2D();
Vec3 vec3 = this.theWorld.getSkyColor(this.mc.getRenderViewEntity(), partialTicks);
vec3 = CustomColors.getSkyColor(vec3, this.mc.theWorld, this.mc.getRenderViewEntity().posX, this.mc.getRenderViewEntity().posY + 1.0D, this.mc.getRenderViewEntity().posZ);
float f = (float) vec3.xCoord;
float f1 = (float) vec3.yCoord;
float f2 = (float) vec3.zCoord;
@ -2201,63 +2203,101 @@ public class RenderGlobal implements IWorldAccess, IResourceManagerReloadListene
parDouble3, parDouble4, parDouble5, parDouble6, parArrayOfInt);
}
private EntityFX spawnEntityFX(int ignoreRange, boolean parFlag, double parDouble1, double parDouble2,
double parDouble3, double parDouble4, double parDouble5, double parDouble6, int... parArrayOfInt) {
if (this.mc != null && this.mc.getRenderViewEntity() != null && this.mc.effectRenderer != null) {
int i = this.mc.gameSettings.particleSetting;
if (i == 1 && this.theWorld.rand.nextInt(3) == 0) {
i = 2;
}
private EntityFX spawnEntityFX(int ignoreRange, boolean parFlag, double parDouble1, double parDouble2, double parDouble3, double parDouble4, double parDouble5, double parDouble6, int... parArrayOfInt) {
if (this.mc != null && this.mc.getRenderViewEntity() != null && this.mc.effectRenderer != null) {
int i = this.mc.gameSettings.particleSetting;
double d0 = this.mc.getRenderViewEntity().posX - parDouble1;
double d1 = this.mc.getRenderViewEntity().posY - parDouble2;
double d2 = this.mc.getRenderViewEntity().posZ - parDouble3;
if (ignoreRange == EnumParticleTypes.EXPLOSION_HUGE.getParticleID() && !Config.isAnimatedExplosion()) {
return null;
} else if (ignoreRange == EnumParticleTypes.EXPLOSION_LARGE.getParticleID() && !Config.isAnimatedExplosion()) {
return null;
} else if (ignoreRange == EnumParticleTypes.EXPLOSION_NORMAL.getParticleID() && !Config.isAnimatedExplosion()) {
return null;
} else if (ignoreRange == EnumParticleTypes.SUSPENDED.getParticleID() && !Config.isWaterParticles()) {
return null;
} else if (ignoreRange == EnumParticleTypes.SUSPENDED_DEPTH.getParticleID() && !Config.isVoidParticles()) {
return null;
} else if (ignoreRange == EnumParticleTypes.SMOKE_NORMAL.getParticleID() && !Config.isAnimatedSmoke()) {
return null;
} else if (ignoreRange == EnumParticleTypes.SMOKE_LARGE.getParticleID() && !Config.isAnimatedSmoke()) {
return null;
} else if (ignoreRange == EnumParticleTypes.SPELL_MOB.getParticleID() && !Config.isPotionParticles()) {
return null;
} else if (ignoreRange == EnumParticleTypes.SPELL_MOB_AMBIENT.getParticleID() && !Config.isPotionParticles()) {
return null;
} else if (ignoreRange == EnumParticleTypes.SPELL.getParticleID() && !Config.isPotionParticles()) {
return null;
} else if (ignoreRange == EnumParticleTypes.SPELL_INSTANT.getParticleID() && !Config.isPotionParticles()) {
return null;
} else if (ignoreRange == EnumParticleTypes.SPELL_WITCH.getParticleID() && !Config.isPotionParticles()) {
return null;
} else if (ignoreRange == EnumParticleTypes.PORTAL.getParticleID() && !Config.isAnimatedPortal()) {
return null;
} else if (ignoreRange == EnumParticleTypes.FLAME.getParticleID() && !Config.isAnimatedFlame()) {
return null;
} else if (ignoreRange == EnumParticleTypes.REDSTONE.getParticleID() && !Config.isAnimatedRedstone()) {
return null;
} else if (ignoreRange == EnumParticleTypes.DRIP_WATER.getParticleID() && !Config.isDrippingWaterLava()) {
return null;
} else if (ignoreRange == EnumParticleTypes.DRIP_LAVA.getParticleID() && !Config.isDrippingWaterLava()) {
return null;
} else if (ignoreRange == EnumParticleTypes.FIREWORKS_SPARK.getParticleID() && !Config.isFireworkParticles()) {
return null;
} else if (parFlag) {
return this.mc.effectRenderer.spawnEffectParticle(ignoreRange, parDouble1, parDouble2, parDouble3,
parDouble4, parDouble5, parDouble6, parArrayOfInt);
} else {
return d0 * d0 + d1 * d1 + d2 * d2 > 256.0D ? null : (i > 1 ? null : this.mc.effectRenderer.spawnEffectParticle(ignoreRange, parDouble1, parDouble2, parDouble3, parDouble4, parDouble5, parDouble6, parArrayOfInt));
}
} else {
return null;
}
if (i == 1 && this.theWorld.rand.nextInt(3) == 0) {
i = 2;
}
double d0 = this.mc.getRenderViewEntity().posX - parDouble1;
double d1 = this.mc.getRenderViewEntity().posY - parDouble2;
double d2 = this.mc.getRenderViewEntity().posZ - parDouble3;
if (ignoreRange == EnumParticleTypes.EXPLOSION_HUGE.getParticleID() && !Config.isAnimatedExplosion()) {
return null;
} else if (ignoreRange == EnumParticleTypes.EXPLOSION_LARGE.getParticleID() && !Config.isAnimatedExplosion()) {
return null;
} else if (ignoreRange == EnumParticleTypes.EXPLOSION_NORMAL.getParticleID() && !Config.isAnimatedExplosion()) {
return null;
} else if (ignoreRange == EnumParticleTypes.SUSPENDED.getParticleID() && !Config.isWaterParticles()) {
return null;
} else if (ignoreRange == EnumParticleTypes.SUSPENDED_DEPTH.getParticleID() && !Config.isVoidParticles()) {
return null;
} else if (ignoreRange == EnumParticleTypes.SMOKE_NORMAL.getParticleID() && !Config.isAnimatedSmoke()) {
return null;
} else if (ignoreRange == EnumParticleTypes.SMOKE_LARGE.getParticleID() && !Config.isAnimatedSmoke()) {
return null;
} else if (ignoreRange == EnumParticleTypes.SPELL_MOB.getParticleID() && !Config.isPotionParticles()) {
return null;
} else if (ignoreRange == EnumParticleTypes.SPELL_MOB_AMBIENT.getParticleID() && !Config.isPotionParticles()) {
return null;
} else if (ignoreRange == EnumParticleTypes.SPELL.getParticleID() && !Config.isPotionParticles()) {
return null;
} else if (ignoreRange == EnumParticleTypes.SPELL_INSTANT.getParticleID() && !Config.isPotionParticles()) {
return null;
} else if (ignoreRange == EnumParticleTypes.SPELL_WITCH.getParticleID() && !Config.isPotionParticles()) {
return null;
} else if (ignoreRange == EnumParticleTypes.PORTAL.getParticleID() && !Config.isAnimatedPortal()) {
return null;
} else if (ignoreRange == EnumParticleTypes.FLAME.getParticleID() && !Config.isAnimatedFlame()) {
return null;
} else if (ignoreRange == EnumParticleTypes.REDSTONE.getParticleID() && !Config.isAnimatedRedstone()) {
return null;
} else if (ignoreRange == EnumParticleTypes.DRIP_WATER.getParticleID() && !Config.isDrippingWaterLava()) {
return null;
} else if (ignoreRange == EnumParticleTypes.DRIP_LAVA.getParticleID() && !Config.isDrippingWaterLava()) {
return null;
} else if (ignoreRange == EnumParticleTypes.FIREWORKS_SPARK.getParticleID() && !Config.isFireworkParticles()) {
return null;
} else if (parFlag) {
return this.mc.effectRenderer.spawnEffectParticle(ignoreRange, parDouble1, parDouble2, parDouble3, parDouble4, parDouble5, parDouble6, parArrayOfInt);
} else {
double d3 = 16.0D;
double d4 = 256.0D;
if (ignoreRange == EnumParticleTypes.CRIT.getParticleID()) {
d4 = 38416.0D;
}
if (d0 * d0 + d1 * d1 + d2 * d2 > d4) {
return null;
} else if (i > 1) {
return null;
} else {
EntityFX entityfx = this.mc.effectRenderer.spawnEffectParticle(ignoreRange, parDouble1, parDouble2, parDouble3, parDouble4, parDouble5, parDouble6, parArrayOfInt);
if (ignoreRange == EnumParticleTypes.WATER_BUBBLE.getParticleID()) {
CustomColors.updateWaterFX(entityfx, this.theWorld, parDouble1, parDouble2, parDouble3);
}
if (ignoreRange == EnumParticleTypes.WATER_SPLASH.getParticleID()) {
CustomColors.updateWaterFX(entityfx, this.theWorld, parDouble1, parDouble2, parDouble3);
}
if (ignoreRange == EnumParticleTypes.WATER_DROP.getParticleID()) {
CustomColors.updateWaterFX(entityfx, this.theWorld, parDouble1, parDouble2, parDouble3);
}
if (ignoreRange == EnumParticleTypes.TOWN_AURA.getParticleID()) {
CustomColors.updateMyceliumFX(entityfx);
}
if (ignoreRange == EnumParticleTypes.PORTAL.getParticleID()) {
CustomColors.updatePortalFX(entityfx);
}
if (ignoreRange == EnumParticleTypes.REDSTONE.getParticleID()) {
CustomColors.updateReddustFX(entityfx, this.theWorld, parDouble1, parDouble2, parDouble3);
}
return entityfx;
}
}
} else {
return null;
}
}
/**+

View File

@ -5,6 +5,8 @@ import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
import java.util.List;
import java.util.concurrent.Callable;
import net.PeytonPlayz585.shadow.Config;
import net.PeytonPlayz585.shadow.CustomColors;
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.DeferredStateManager;
@ -294,6 +296,11 @@ public class RenderItem implements IResourceManagerReloadListener {
int k = color;
if (flag && bakedquad.hasTintIndex()) {
k = stack.getItem().getColorFromItemStack(stack, bakedquad.getTintIndex());
if (Config.isCustomColors()) {
k = CustomColors.getColorFromItemStack(stack, bakedquad.getTintIndex(), k);
}
if (EntityRenderer.anaglyphEnable) {
k = TextureUtil.anaglyphColor(k);
}

View File

@ -1,5 +1,7 @@
package net.minecraft.client.renderer.entity;
import net.PeytonPlayz585.shadow.Config;
import net.PeytonPlayz585.shadow.CustomColors;
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
import net.lax1dude.eaglercraft.v1_8.opengl.OpenGlHelper;
import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer;
@ -75,14 +77,24 @@ public class RenderXPOrb extends Render<EntityXPOrb> {
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR_NORMAL);
worldrenderer.pos((double) (0.0F - f7), (double) (0.0F - f8), 0.0D).tex((double) f2, (double) f5)
.color(l, 255, i1, 128).normal(0.0F, 1.0F, 0.0F).endVertex();
worldrenderer.pos((double) (f6 - f7), (double) (0.0F - f8), 0.0D).tex((double) f3, (double) f5)
.color(l, 255, i1, 128).normal(0.0F, 1.0F, 0.0F).endVertex();
worldrenderer.pos((double) (f6 - f7), (double) (1.0F - f8), 0.0D).tex((double) f3, (double) f4)
.color(l, 255, i1, 128).normal(0.0F, 1.0F, 0.0F).endVertex();
worldrenderer.pos((double) (0.0F - f7), (double) (1.0F - f8), 0.0D).tex((double) f2, (double) f4)
.color(l, 255, i1, 128).normal(0.0F, 1.0F, 0.0F).endVertex();
int j1 = l;
int k1 = 255;
int l1 = i1;
if (Config.isCustomColors()) {
int i2 = CustomColors.getXpOrbColor(f8);
if (i2 >= 0) {
j1 = i2 >> 16 & 255;
k1 = i2 >> 8 & 255;
l1 = i2 >> 0 & 255;
}
}
worldrenderer.pos((double)(0.0F - f5), (double)(0.0F - f6), 0.0D).tex((double)f, (double)f3).color(j1, k1, l1, 128).normal(0.0F, 1.0F, 0.0F).endVertex();
worldrenderer.pos((double)(f4 - f5), (double)(0.0F - f6), 0.0D).tex((double)f1, (double)f3).color(j1, k1, l1, 128).normal(0.0F, 1.0F, 0.0F).endVertex();
worldrenderer.pos((double)(f4 - f5), (double)(1.0F - f6), 0.0D).tex((double)f1, (double)f2).color(j1, k1, l1, 128).normal(0.0F, 1.0F, 0.0F).endVertex();
worldrenderer.pos((double)(0.0F - f5), (double)(1.0F - f6), 0.0D).tex((double)f, (double)f2).color(j1, k1, l1, 128).normal(0.0F, 1.0F, 0.0F).endVertex();
tessellator.draw();
GlStateManager.disableBlend();
GlStateManager.disableRescaleNormal();

View File

@ -1,5 +1,7 @@
package net.minecraft.client.renderer.entity.layers;
import net.PeytonPlayz585.shadow.Config;
import net.PeytonPlayz585.shadow.CustomColors;
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
import net.minecraft.client.model.ModelSheep1;
import net.minecraft.client.renderer.entity.RenderSheep;
@ -47,10 +49,21 @@ public class LayerSheepWool implements LayerRenderer<EntitySheep> {
float f7 = ((float) (entitysheep.ticksExisted % 25) + f2) / 25.0F;
float[] afloat1 = EntitySheep.func_175513_a(EnumDyeColor.byMetadata(k));
float[] afloat2 = EntitySheep.func_175513_a(EnumDyeColor.byMetadata(l));
if (Config.isCustomColors()) {
afloat1 = CustomColors.getSheepColors(EnumDyeColor.byMetadata(k), afloat1);
afloat2 = CustomColors.getSheepColors(EnumDyeColor.byMetadata(l), afloat2);
}
GlStateManager.color(afloat1[0] * (1.0F - f7) + afloat2[0] * f7,
afloat1[1] * (1.0F - f7) + afloat2[1] * f7, afloat1[2] * (1.0F - f7) + afloat2[2] * f7);
} else {
float[] afloat = EntitySheep.func_175513_a(entitysheep.getFleeceColor());
if (Config.isCustomColors()) {
afloat = CustomColors.getSheepColors(entitysheep.getFleeceColor(), afloat);
}
GlStateManager.color(afloat[0], afloat[1], afloat[2]);
}

View File

@ -1,5 +1,7 @@
package net.minecraft.client.renderer.entity.layers;
import net.PeytonPlayz585.shadow.Config;
import net.PeytonPlayz585.shadow.CustomColors;
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
import net.minecraft.client.renderer.entity.RenderWolf;
import net.minecraft.entity.passive.EntitySheep;
@ -33,12 +35,16 @@ public class LayerWolfCollar implements LayerRenderer<EntityWolf> {
this.wolfRenderer = wolfRendererIn;
}
public void doRenderLayer(EntityWolf entitywolf, float f, float f1, float var4, float f2, float f3, float f4,
float f5) {
public void doRenderLayer(EntityWolf entitywolf, float f, float f1, float var4, float f2, float f3, float f4, float f5) {
if (entitywolf.isTamed() && !entitywolf.isInvisible()) {
this.wolfRenderer.bindTexture(WOLF_COLLAR);
EnumDyeColor enumdyecolor = EnumDyeColor.byMetadata(entitywolf.getCollarColor().getMetadata());
float[] afloat = EntitySheep.func_175513_a(enumdyecolor);
if (Config.isCustomColors()) {
afloat = CustomColors.getWolfCollarColors(enumdyecolor, afloat);
}
GlStateManager.color(afloat[0], afloat[1], afloat[2]);
this.wolfRenderer.getMainModel().render(entitywolf, f, f1, f2, f3, f4, f5);
}

View File

@ -160,4 +160,15 @@ public class TextureManager implements ITickable, IResourceManagerReloadListener
}
}
public void reloadBannerTextures() {
for (Object entry : this.mapTextureObjects.entrySet()) {
ResourceLocation resourcelocation = (ResourceLocation)((Entry) entry).getKey();
ITextureObject itextureobject = (ITextureObject)((Entry) entry).getValue();
if (itextureobject instanceof LayeredColorMaskTexture) {
this.loadTexture(resourcelocation, itextureobject);
}
}
}
}

View File

@ -7,6 +7,8 @@ import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*;
import java.util.List;
import net.PeytonPlayz585.shadow.Config;
import net.PeytonPlayz585.shadow.CustomColors;
import net.lax1dude.eaglercraft.v1_8.opengl.EaglercraftGPU;
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.DeferredStateManager;
@ -97,7 +99,10 @@ public class TileEntitySignRenderer extends TileEntitySpecialRenderer<TileEntity
GlStateManager.scale(f3, -f3, f3);
EaglercraftGPU.glNormal3f(0.0F, 0.0F, -1.0F * f3);
GlStateManager.depthMask(false);
byte b0 = 0;
int b0 = 0;
if (Config.isCustomColors()) {
i = CustomColors.getSignTextColor(i);
}
if (i < 0) {
if (DeferredStateManager.isInDeferredPass()) {
_wglDrawBuffers(_GL_COLOR_ATTACHMENT0);

View File

@ -20,7 +20,7 @@ import net.minecraft.util.ResourceLocation;
public abstract class AbstractResourcePack implements IResourcePack {
private static final Logger resourceLog = LogManager.getLogger();
protected final String resourcePackFile;
public final String resourcePackFile;
public AbstractResourcePack(String resourcePackFileIn) {
this.resourcePackFile = resourcePackFileIn;

View File

@ -17,6 +17,7 @@ import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import net.PeytonPlayz585.shadow.Config;
import net.PeytonPlayz585.shadow.CustomColors;
import net.PeytonPlayz585.shadow.CustomSky;
import net.PeytonPlayz585.shadow.DynamicLights;
import net.PeytonPlayz585.shadow.shaders.Shaders;
@ -198,6 +199,9 @@ public class GameSettings {
public boolean ofCustomFonts = true;
public int ofBetterGrass = 3;
public int ofDynamicLights = 3;
public boolean ofCustomColors = true;
public boolean ofSwampColors = true;
public boolean ofSmoothBiomes = true;
//Detail Settings
/** Clouds flag */
@ -790,6 +794,24 @@ public class GameSettings {
if (parOptions == GameSettings.Options.HIDE_PASSWORD) {
this.hidePassword = !this.hidePassword;
}
if (parOptions == GameSettings.Options.CUSTOM_COLORS) {
this.ofCustomColors = !this.ofCustomColors;
CustomColors.update();
this.mc.renderGlobal.loadRenderers();
}
if (parOptions == GameSettings.Options.SWAMP_COLORS) {
this.ofSwampColors = !this.ofSwampColors;
CustomColors.updateUseDefaultGrassFoliageColors();
this.mc.renderGlobal.loadRenderers();
}
if (parOptions == GameSettings.Options.SMOOTH_BIOMES) {
this.ofSmoothBiomes = !this.ofSmoothBiomes;
CustomColors.updateUseDefaultGrassFoliageColors();
this.mc.renderGlobal.loadRenderers();
}
this.saveOptions();
}
@ -1155,7 +1177,13 @@ public class GameSettings {
return this.ofProfiler ? s + "ON" : s + "OFF";
} else if (parOptions == GameSettings.Options.HIDE_PASSWORD) {
return hidePassword ? s + "ON" : s + "OFF";
} else {
} else if (parOptions == GameSettings.Options.CUSTOM_COLORS) {
return this.ofCustomColors ? s + "ON" : s + "OFF";
} else if (parOptions == GameSettings.Options.SWAMP_COLORS) {
return this.ofSwampColors ? s + "ON" : s + "OFF";
} else if (parOptions == GameSettings.Options.SMOOTH_BIOMES) {
return this.ofSmoothBiomes ? s + "ON" : s + "OFF";
} else {
return s;
}
}
@ -1651,6 +1679,18 @@ public class GameSettings {
if (astring[0].equals("hidePassword") && astring.length >= 2) {
this.hidePassword = Boolean.valueOf(astring[1]).booleanValue();
}
if (astring[0].equals("ofCustomColors") && astring.length >= 2) {
this.ofCustomColors = Boolean.valueOf(astring[1]).booleanValue();
}
if (astring[0].equals("ofSwampColors") && astring.length >= 2) {
this.ofSwampColors = Boolean.valueOf(astring[1]).booleanValue();
}
if (astring[0].equals("ofSmoothBiomes") && astring.length >= 2) {
this.ofSmoothBiomes = Boolean.valueOf(astring[1]).booleanValue();
}
Keyboard.setFunctionKeyModifier(keyBindFunction.getKeyCode());
@ -1807,6 +1847,9 @@ public class GameSettings {
printwriter.println("ofLagometer:" + this.ofLagometer);
printwriter.println("ofProfiler:" + this.ofProfiler);
printwriter.println("hidePassword:" + this.hidePassword);
printwriter.println("ofCustomColors:" + this.ofCustomColors);
printwriter.println("ofSwampColors:" + this.ofSwampColors);
printwriter.println("ofSmoothBiomes:" + this.ofSmoothBiomes);
for (KeyBinding keybinding : this.keyBindings) {
printwriter.println("key_" + keybinding.getKeyDescription() + ":" + keybinding.getKeyCode());
@ -2000,7 +2043,10 @@ public class GameSettings {
LEFT_HAND("Main Hand", false, false),
LAGOMETER("Lagometer", false, false),
PROFILER("Profiler", false, false),
HIDE_PASSWORD("Hide Password", false, false);
HIDE_PASSWORD("Hide Password", false, false),
CUSTOM_COLORS("Custom Colors", false, false),
SWAMP_COLORS("Swamp Colors", false, false),
SMOOTH_BIOMES("Smooth Biomes", false, false);
private final boolean enumFloat;
private final boolean enumBoolean;

View File

@ -8,6 +8,8 @@ import java.util.Map;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import net.PeytonPlayz585.shadow.Config;
import net.PeytonPlayz585.shadow.CustomColors;
import net.minecraft.util.IntegerCache;
/**+
@ -108,6 +110,10 @@ public class PotionHelper {
for (PotionEffect potioneffect : parCollection) {
if (potioneffect.getIsShowParticles()) {
int j = Potion.potionTypes[potioneffect.getPotionID()].getLiquidColor();
if (Config.isCustomColors()) {
j = CustomColors.getPotionColor(potioneffect.getPotionID(), j);
}
for (int k = 0; k <= potioneffect.getAmplifier(); ++k) {
f += (float) (j >> 16 & 255) / 255.0F;
@ -127,6 +133,10 @@ public class PotionHelper {
return (int) f << 16 | (int) f1 << 8 | (int) f2;
}
} else {
if (Config.isCustomColors()) {
i = CustomColors.getPotionColor(0, i);
}
return i;
}
}
@ -489,6 +499,10 @@ public class PotionHelper {
| (checkFlag(parInt1, parInt4) ? 4 : 0) | (checkFlag(parInt1, parInt5) ? 2 : 0)
| (checkFlag(parInt1, parInt6) ? 1 : 0);
}
public static void clearPotionColorCache() {
DATAVALUE_COLORS.clear();
}
static {
potionRequirements.put(Integer.valueOf(Potion.regeneration.getId()), "0 & !1 & !2 & !3 & 0+6");

View File

@ -1374,4 +1374,8 @@ public class ObjectUtils {
public ObjectUtils() {
}
public static boolean isArray(Object obj) {
return obj != null && obj.getClass().isArray();
}
}

View File

@ -1,7 +1,10 @@
package net.lax1dude.eaglercraft.v1_8.internal;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.teavm.interop.Async;
@ -23,6 +26,7 @@ import org.teavm.jso.typedarrays.Uint8ClampedArray;
import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
import net.lax1dude.eaglercraft.v1_8.internal.teavm.MainClass;
import net.lax1dude.eaglercraft.v1_8.internal.teavm.TeaVMUtils;
import net.lax1dude.eaglercraft.v1_8.internal.vfs.SYS;
import net.lax1dude.eaglercraft.v1_8.opengl.ImageData;
/**
@ -140,4 +144,64 @@ public class PlatformAssets {
}
}
public static String[] listFilesInDirectory(String directoryPath, String[] prefixes, String[] suffixes) {
ArrayList<String> fileNames = new ArrayList<>();
for(String resourcePackName : SYS.getResourcePackNames()) {
String resourcePack = "resourcepacks/" + resourcePackName + "/" + directoryPath;
List<String> vfsFiles = SYS.VFS.listFiles(resourcePack);
for (String vfsFile : vfsFiles) {
if (!vfsFile.endsWith("/")) {
String fileName = vfsFile;
if (matchesPrefixesAndSuffixes(fileName, prefixes, suffixes)) {
if(!fileNames.contains(fileName)) {
fileNames.add(fileName);
}
}
} else {
String[] filesInSubfolder = listFilesInDirectory(vfsFile, prefixes, suffixes);
for(String file : Arrays.asList(filesInSubfolder)) {
if(!fileNames.contains(file)) {
fileNames.add(file);
}
}
}
}
}
for (String path : assets.keySet()) {
if (path.startsWith(directoryPath)) {
if (!path.endsWith("/")) {
String fileName = path.substring(directoryPath.length() + 1);
if (matchesPrefixesAndSuffixes(fileName, prefixes, suffixes)) {
if(!fileNames.contains(fileName)) {
fileNames.add(fileName);
}
}
} else {
String[] filesInSubfolder = listFilesInDirectory(path, prefixes, suffixes);
for(String file : Arrays.asList(filesInSubfolder)) {
if(!fileNames.contains(file)) {
fileNames.add(file);
}
}
}
}
}
return fileNames.toArray(new String[0]);
}
private static boolean matchesPrefixesAndSuffixes(String fileName, String[] prefixes, String[] suffixes) {
for (String prefix : prefixes) {
if (fileName.startsWith(prefix)) {
for (String suffix : suffixes) {
if (fileName.endsWith(suffix)) {
return true;
}
}
}
}
return false;
}
}

View File

@ -153,6 +153,7 @@ public class PlatformRuntime {
try {
EPKLoader.loadEPK(epkFileData, epkFiles[i].path, PlatformAssets.assets);
}catch(Throwable t) {
throw new RuntimeInitializationFailureException("Could not extract EPK file \"" + url + "\"", t);
}