Temp fix for Custom Item animations
This commit is contained in:
parent
33347dc322
commit
35c95f2aad
|
@ -305,6 +305,18 @@ public class Config {
|
|||
return gameSettings.ofCustomItems;
|
||||
}
|
||||
|
||||
public static boolean isSwampColors() {
|
||||
return gameSettings.ofSwampColors;
|
||||
}
|
||||
|
||||
public static boolean isSmoothBiomes() {
|
||||
return gameSettings.ofSmoothBiomes;
|
||||
}
|
||||
|
||||
public static boolean isCustomColors() {
|
||||
return gameSettings.ofCustomColors;
|
||||
}
|
||||
|
||||
public static int limit(int p_limit_0_, int p_limit_1_, int p_limit_2_) {
|
||||
return p_limit_0_ < p_limit_1_ ? p_limit_1_ : (p_limit_0_ > p_limit_2_ ? p_limit_2_ : p_limit_0_);
|
||||
}
|
||||
|
@ -629,4 +641,13 @@ public class Config {
|
|||
public static void warn(String s, Throwable t) {
|
||||
LOGGER.warn("[Shadow Client] " + s, t);
|
||||
}
|
||||
|
||||
public static int intHash(int p_intHash_0_) {
|
||||
p_intHash_0_ = p_intHash_0_ ^ 61 ^ p_intHash_0_ >> 16;
|
||||
p_intHash_0_ = p_intHash_0_ + (p_intHash_0_ << 3);
|
||||
p_intHash_0_ = p_intHash_0_ ^ p_intHash_0_ >> 4;
|
||||
p_intHash_0_ = p_intHash_0_ * 668265261;
|
||||
p_intHash_0_ = p_intHash_0_ ^ p_intHash_0_ >> 15;
|
||||
return p_intHash_0_;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package net.PeytonPlayz585.shadow;
|
||||
|
||||
import net.minecraft.util.Vec3;
|
||||
|
||||
public class CustomColorFader {
|
||||
private Vec3 color = null;
|
||||
private long timeUpdate = System.currentTimeMillis();
|
||||
|
||||
public Vec3 getColor(double x, double y, double z) {
|
||||
if (this.color == null) {
|
||||
this.color = new Vec3(x, y, z);
|
||||
return this.color;
|
||||
} else {
|
||||
long i = System.currentTimeMillis();
|
||||
long j = i - this.timeUpdate;
|
||||
|
||||
if (j == 0L) {
|
||||
return this.color;
|
||||
} else {
|
||||
this.timeUpdate = i;
|
||||
|
||||
if (Math.abs(x - this.color.xCoord) < 0.004D && Math.abs(y - this.color.yCoord) < 0.004D && Math.abs(z - this.color.zCoord) < 0.004D) {
|
||||
return this.color;
|
||||
} else {
|
||||
double d0 = (double) j * 0.001D;
|
||||
d0 = Config.limit(d0, 0.0D, 1.0D);
|
||||
double d1 = x - this.color.xCoord;
|
||||
double d2 = y - this.color.yCoord;
|
||||
double d3 = z - this.color.zCoord;
|
||||
double d4 = this.color.xCoord + d1 * d0;
|
||||
double d5 = this.color.yCoord + d2 * d0;
|
||||
double d6 = this.color.zCoord + d3 * d0;
|
||||
this.color = new Vec3(d4, d5, d6);
|
||||
return this.color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
468
src/main/java/net/PeytonPlayz585/shadow/CustomColormap.java
Normal file
468
src/main/java/net/PeytonPlayz585/shadow/CustomColormap.java
Normal file
|
@ -0,0 +1,468 @@
|
|||
package net.PeytonPlayz585.shadow;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashSet;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.ImageData;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.BlockStateBase;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.texture.TextureUtil;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
public class CustomColormap implements CustomColors.IColorizer {
|
||||
public String name = null;
|
||||
public String basePath = null;
|
||||
private int format = -1;
|
||||
private MatchBlock[] matchBlocks = null;
|
||||
private String source = null;
|
||||
private int color = -1;
|
||||
private int yVariance = 0;
|
||||
private int yOffset = 0;
|
||||
private int width = 0;
|
||||
private int height = 0;
|
||||
private int[] colors = null;
|
||||
private float[][] colorsRgb = (float[][]) null;
|
||||
private static final int FORMAT_UNKNOWN = -1;
|
||||
private static final int FORMAT_VANILLA = 0;
|
||||
private static final int FORMAT_GRID = 1;
|
||||
private static final int FORMAT_FIXED = 2;
|
||||
public static final String FORMAT_VANILLA_STRING = "vanilla";
|
||||
public static final String FORMAT_GRID_STRING = "grid";
|
||||
public static final String FORMAT_FIXED_STRING = "fixed";
|
||||
public static final String[] FORMAT_STRINGS = new String[] {
|
||||
"vanilla",
|
||||
"grid",
|
||||
"fixed"
|
||||
};
|
||||
public static final String KEY_FORMAT = "format";
|
||||
public static final String KEY_BLOCKS = "blocks";
|
||||
public static final String KEY_SOURCE = "source";
|
||||
public static final String KEY_COLOR = "color";
|
||||
public static final String KEY_Y_VARIANCE = "yVariance";
|
||||
public static final String KEY_Y_OFFSET = "yOffset";
|
||||
|
||||
public CustomColormap(Properties props, String path, int width, int height, String formatDefault) {
|
||||
ConnectedParser connectedparser = new ConnectedParser("Colormap");
|
||||
this.name = connectedparser.parseName(path);
|
||||
this.basePath = connectedparser.parseBasePath(path);
|
||||
this.format = this.parseFormat(props.getProperty("format", formatDefault));
|
||||
this.matchBlocks = connectedparser.parseMatchBlocks(props.getProperty("blocks"));
|
||||
this.source = parseTexture(props.getProperty("source"), path, this.basePath);
|
||||
this.color = ConnectedParser.parseColor(props.getProperty("color"), -1);
|
||||
this.yVariance = connectedparser.parseInt(props.getProperty("yVariance"), 0);
|
||||
this.yOffset = connectedparser.parseInt(props.getProperty("yOffset"), 0);
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
private int parseFormat(String str) {
|
||||
if (str == null) {
|
||||
return 0;
|
||||
} else {
|
||||
str = str.trim();
|
||||
|
||||
if (str.equals("vanilla")) {
|
||||
return 0;
|
||||
} else if (str.equals("grid")) {
|
||||
return 1;
|
||||
} else if (str.equals("fixed")) {
|
||||
return 2;
|
||||
} else {
|
||||
warn("Unknown format: " + str);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isValid(String path) {
|
||||
if (this.format != 0 && this.format != 1) {
|
||||
if (this.format != 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.color < 0) {
|
||||
this.color = 16777215;
|
||||
}
|
||||
} else {
|
||||
if (this.source == null) {
|
||||
warn("Source not defined: " + path);
|
||||
return false;
|
||||
}
|
||||
|
||||
this.readColors();
|
||||
|
||||
if (this.colors == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.color < 0) {
|
||||
if (this.format == 0) {
|
||||
this.color = this.getColor(127, 127);
|
||||
}
|
||||
|
||||
if (this.format == 1) {
|
||||
this.color = this.getColorGrid(BiomeGenBase.plains, new BlockPos(0, 64, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isValidMatchBlocks(String path) {
|
||||
if (this.matchBlocks == null) {
|
||||
this.matchBlocks = this.detectMatchBlocks();
|
||||
|
||||
if (this.matchBlocks == null) {
|
||||
warn("Match blocks not defined: " + path);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private MatchBlock[] detectMatchBlocks() {
|
||||
Block block = Block.getBlockFromName(this.name);
|
||||
|
||||
if (block != null) {
|
||||
return new MatchBlock[] {
|
||||
new MatchBlock(Block.getIdFromBlock(block))
|
||||
};
|
||||
} else {
|
||||
Pattern pattern = Pattern.compile("^block([0-9]+).*$");
|
||||
Matcher matcher = pattern.matcher(this.name);
|
||||
|
||||
if (matcher.matches()) {
|
||||
String s = matcher.group(1);
|
||||
int i = Config.parseInt(s, -1);
|
||||
|
||||
if (i >= 0) {
|
||||
return new MatchBlock[] {
|
||||
new MatchBlock(i)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
ConnectedParser connectedparser = new ConnectedParser("Colormap");
|
||||
MatchBlock[] amatchblock = connectedparser.parseMatchBlock(this.name);
|
||||
return amatchblock != null ? amatchblock : null;
|
||||
}
|
||||
}
|
||||
|
||||
private void readColors() {
|
||||
try {
|
||||
this.colors = null;
|
||||
|
||||
if (this.source == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String s = this.source + ".png";
|
||||
ResourceLocation resourcelocation = new ResourceLocation(s);
|
||||
InputStream inputstream = Config.getResourceStream(resourcelocation);
|
||||
|
||||
if (inputstream == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ImageData bufferedimage = TextureUtil.readBufferedImage(inputstream);
|
||||
|
||||
if (bufferedimage == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int i = bufferedimage.width;
|
||||
int j = bufferedimage.height;
|
||||
boolean flag = this.width < 0 || this.width == i;
|
||||
boolean flag1 = this.height < 0 || this.height == j;
|
||||
|
||||
if (!flag || !flag1) {
|
||||
dbg("Non-standard palette size: " + i + "x" + j + ", should be: " + this.width + "x" + this.height + ", path: " + s);
|
||||
}
|
||||
|
||||
this.width = i;
|
||||
this.height = j;
|
||||
|
||||
if (this.width <= 0 || this.height <= 0) {
|
||||
warn("Invalid palette size: " + i + "x" + j + ", path: " + s);
|
||||
return;
|
||||
}
|
||||
|
||||
this.colors = new int[i * j];
|
||||
bufferedimage.getRGB(0, 0, i, j, this.colors, 0, i);
|
||||
} catch (IOException ioexception) {
|
||||
ioexception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void dbg(String str) {
|
||||
Config.dbg("CustomColors: " + str);
|
||||
}
|
||||
|
||||
private static void warn(String str) {
|
||||
Config.warn("CustomColors: " + str);
|
||||
}
|
||||
|
||||
private static String parseTexture(String texStr, String path, String basePath) {
|
||||
if (texStr != null) {
|
||||
texStr = texStr.trim();
|
||||
String s1 = ".png";
|
||||
|
||||
if (texStr.endsWith(s1)) {
|
||||
texStr = texStr.substring(0, texStr.length() - s1.length());
|
||||
}
|
||||
|
||||
texStr = fixTextureName(texStr, basePath);
|
||||
return texStr;
|
||||
} else {
|
||||
String s = path;
|
||||
int i = path.lastIndexOf(47);
|
||||
|
||||
if (i >= 0) {
|
||||
s = path.substring(i + 1);
|
||||
}
|
||||
|
||||
int j = s.lastIndexOf(46);
|
||||
|
||||
if (j >= 0) {
|
||||
s = s.substring(0, j);
|
||||
}
|
||||
|
||||
s = fixTextureName(s, basePath);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
private static String fixTextureName(String iconName, String basePath) {
|
||||
iconName = TextureUtils.fixResourcePath(iconName, basePath);
|
||||
|
||||
if (!iconName.startsWith(basePath) && !iconName.startsWith("textures/") && !iconName.startsWith("mcpatcher/")) {
|
||||
iconName = basePath + "/" + iconName;
|
||||
}
|
||||
|
||||
if (iconName.endsWith(".png")) {
|
||||
iconName = iconName.substring(0, iconName.length() - 4);
|
||||
}
|
||||
|
||||
String s = "textures/blocks/";
|
||||
|
||||
if (iconName.startsWith(s)) {
|
||||
iconName = iconName.substring(s.length());
|
||||
}
|
||||
|
||||
if (iconName.startsWith("/")) {
|
||||
iconName = iconName.substring(1);
|
||||
}
|
||||
|
||||
return iconName;
|
||||
}
|
||||
|
||||
public boolean matchesBlock(BlockStateBase blockState) {
|
||||
return Matches.block(blockState, this.matchBlocks);
|
||||
}
|
||||
|
||||
public int getColorRandom() {
|
||||
if (this.format == 2) {
|
||||
return this.color;
|
||||
} else {
|
||||
int i = CustomColors.random.nextInt(this.colors.length);
|
||||
return this.colors[i];
|
||||
}
|
||||
}
|
||||
|
||||
public int getColor(int index) {
|
||||
index = Config.limit(index, 0, this.colors.length - 1);
|
||||
return this.colors[index] & 16777215;
|
||||
}
|
||||
|
||||
public int getColor(int cx, int cy) {
|
||||
cx = Config.limit(cx, 0, this.width - 1);
|
||||
cy = Config.limit(cy, 0, this.height - 1);
|
||||
return this.colors[cy * this.width + cx] & 16777215;
|
||||
}
|
||||
|
||||
public float[][] getColorsRgb() {
|
||||
if (this.colorsRgb == null) {
|
||||
this.colorsRgb = toRgb(this.colors);
|
||||
}
|
||||
|
||||
return this.colorsRgb;
|
||||
}
|
||||
|
||||
public int getColor(IBlockState blockState, IBlockAccess blockAccess, BlockPos blockPos) {
|
||||
return this.getColor(blockAccess, blockPos);
|
||||
}
|
||||
|
||||
public int getColor(IBlockAccess blockAccess, BlockPos blockPos) {
|
||||
BiomeGenBase biomegenbase = CustomColors.getColorBiome(blockAccess, blockPos);
|
||||
return this.getColor(biomegenbase, blockPos);
|
||||
}
|
||||
|
||||
public boolean isColorConstant() {
|
||||
return this.format == 2;
|
||||
}
|
||||
|
||||
public int getColor(BiomeGenBase biome, BlockPos blockPos) {
|
||||
return this.format == 0 ? this.getColorVanilla(biome, blockPos) : (this.format == 1 ? this.getColorGrid(biome, blockPos) : this.color);
|
||||
}
|
||||
|
||||
public int getColorSmooth(IBlockAccess blockAccess, double x, double y, double z, int radius) {
|
||||
if (this.format == 2) {
|
||||
return this.color;
|
||||
} else {
|
||||
int i = MathHelper.floor_double(x);
|
||||
int j = MathHelper.floor_double(y);
|
||||
int k = MathHelper.floor_double(z);
|
||||
int l = 0;
|
||||
int i1 = 0;
|
||||
int j1 = 0;
|
||||
int k1 = 0;
|
||||
BlockPosM blockposm = new BlockPosM(0, 0, 0);
|
||||
|
||||
for (int l1 = i - radius; l1 <= i + radius; ++l1) {
|
||||
for (int i2 = k - radius; i2 <= k + radius; ++i2) {
|
||||
blockposm.setXyz(l1, j, i2);
|
||||
int j2 = this.getColor((IBlockAccess) blockAccess, blockposm);
|
||||
l += j2 >> 16 & 255;
|
||||
i1 += j2 >> 8 & 255;
|
||||
j1 += j2 & 255;
|
||||
++k1;
|
||||
}
|
||||
}
|
||||
|
||||
int k2 = l / k1;
|
||||
int l2 = i1 / k1;
|
||||
int i3 = j1 / k1;
|
||||
return k2 << 16 | l2 << 8 | i3;
|
||||
}
|
||||
}
|
||||
|
||||
private int getColorVanilla(BiomeGenBase biome, BlockPos blockPos) {
|
||||
double d0 = (double) MathHelper.clamp_float(biome.getFloatTemperature(blockPos), 0.0F, 1.0F);
|
||||
double d1 = (double) MathHelper.clamp_float(biome.getFloatRainfall(), 0.0F, 1.0F);
|
||||
d1 = d1 * d0;
|
||||
int i = (int)((1.0D - d0) * (double)(this.width - 1));
|
||||
int j = (int)((1.0D - d1) * (double)(this.height - 1));
|
||||
return this.getColor(i, j);
|
||||
}
|
||||
|
||||
private int getColorGrid(BiomeGenBase biome, BlockPos blockPos) {
|
||||
int i = biome.biomeID;
|
||||
int j = blockPos.getY() - this.yOffset;
|
||||
|
||||
if (this.yVariance > 0) {
|
||||
int k = blockPos.getX() << 16 + blockPos.getZ();
|
||||
int l = Config.intHash(k);
|
||||
int i1 = this.yVariance * 2 + 1;
|
||||
int j1 = (l & 255) % i1 - this.yVariance;
|
||||
j += j1;
|
||||
}
|
||||
|
||||
return this.getColor(i, j);
|
||||
}
|
||||
|
||||
public int getLength() {
|
||||
return this.format == 2 ? 1 : this.colors.length;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return this.width;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return this.height;
|
||||
}
|
||||
|
||||
private static float[][] toRgb(int[] cols) {
|
||||
float[][] afloat = new float[cols.length][3];
|
||||
|
||||
for (int i = 0; i < cols.length; ++i) {
|
||||
int j = cols[i];
|
||||
float f = (float)(j >> 16 & 255) / 255.0F;
|
||||
float f1 = (float)(j >> 8 & 255) / 255.0F;
|
||||
float f2 = (float)(j & 255) / 255.0F;
|
||||
float[] afloat1 = afloat[i];
|
||||
afloat1[0] = f;
|
||||
afloat1[1] = f1;
|
||||
afloat1[2] = f2;
|
||||
}
|
||||
|
||||
return afloat;
|
||||
}
|
||||
|
||||
public void addMatchBlock(MatchBlock mb) {
|
||||
if (this.matchBlocks == null) {
|
||||
this.matchBlocks = new MatchBlock[0];
|
||||
}
|
||||
|
||||
this.matchBlocks = (MatchBlock[])((MatchBlock[]) Config.addObjectToArray(this.matchBlocks, mb));
|
||||
}
|
||||
|
||||
public void addMatchBlock(int blockId, int metadata) {
|
||||
MatchBlock matchblock = this.getMatchBlock(blockId);
|
||||
|
||||
if (matchblock != null) {
|
||||
if (metadata >= 0) {
|
||||
matchblock.addMetadata(metadata);
|
||||
}
|
||||
} else {
|
||||
this.addMatchBlock(new MatchBlock(blockId, metadata));
|
||||
}
|
||||
}
|
||||
|
||||
private MatchBlock getMatchBlock(int blockId) {
|
||||
if (this.matchBlocks == null) {
|
||||
return null;
|
||||
} else {
|
||||
for (int i = 0; i < this.matchBlocks.length; ++i) {
|
||||
MatchBlock matchblock = this.matchBlocks[i];
|
||||
|
||||
if (matchblock.getBlockId() == blockId) {
|
||||
return matchblock;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public int[] getMatchBlockIds() {
|
||||
if (this.matchBlocks == null) {
|
||||
return null;
|
||||
} else {
|
||||
Set set = new HashSet();
|
||||
|
||||
for (int i = 0; i < this.matchBlocks.length; ++i) {
|
||||
MatchBlock matchblock = this.matchBlocks[i];
|
||||
|
||||
if (matchblock.getBlockId() >= 0) {
|
||||
set.add(Integer.valueOf(matchblock.getBlockId()));
|
||||
}
|
||||
}
|
||||
|
||||
Integer[] ainteger = (Integer[])((Integer[]) set.toArray(new Integer[set.size()]));
|
||||
int[] aint = new int[ainteger.length];
|
||||
|
||||
for (int j = 0; j < ainteger.length; ++j) {
|
||||
aint[j] = ainteger[j].intValue();
|
||||
}
|
||||
|
||||
return aint;
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "" + this.basePath + "/" + this.name + ", blocks: " + Config.arrayToString((Object[]) this.matchBlocks) + ", source: " + this.source;
|
||||
}
|
||||
}
|
1461
src/main/java/net/PeytonPlayz585/shadow/CustomColors.java
Normal file
1461
src/main/java/net/PeytonPlayz585/shadow/CustomColors.java
Normal file
File diff suppressed because it is too large
Load Diff
59
src/main/java/net/PeytonPlayz585/shadow/EntityUtils.java
Normal file
59
src/main/java/net/PeytonPlayz585/shadow/EntityUtils.java
Normal file
|
@ -0,0 +1,59 @@
|
|||
package net.PeytonPlayz585.shadow;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
|
||||
public class EntityUtils {
|
||||
private static final Map < Class, Integer > mapIdByClass = new HashMap();
|
||||
private static final Map < String, Integer > mapIdByName = new HashMap();
|
||||
private static final Map < String, Class > mapClassByName = new HashMap();
|
||||
|
||||
public static int getEntityIdByClass(Entity entity) {
|
||||
return entity == null ? -1 : getEntityIdByClass(entity.getClass());
|
||||
}
|
||||
|
||||
public static int getEntityIdByClass(Class cls) {
|
||||
Integer integer = (Integer) mapIdByClass.get(cls);
|
||||
return integer == null ? -1 : integer.intValue();
|
||||
}
|
||||
|
||||
public static int getEntityIdByName(String name) {
|
||||
Integer integer = (Integer) mapIdByName.get(name);
|
||||
return integer == null ? -1 : integer.intValue();
|
||||
}
|
||||
|
||||
public static Class getEntityClassByName(String name) {
|
||||
Class oclass = (Class) mapClassByName.get(name);
|
||||
return oclass;
|
||||
}
|
||||
|
||||
static {
|
||||
for (int i = 0; i < 1000; ++i) {
|
||||
Class oclass = EntityList.getClassFromID(i);
|
||||
|
||||
if (oclass != null) {
|
||||
String s = EntityList.getStringFromID(i);
|
||||
|
||||
if (s != null) {
|
||||
if (mapIdByClass.containsKey(oclass)) {
|
||||
Config.warn("Duplicate entity class: " + oclass + ", id1: " + mapIdByClass.get(oclass) + ", id2: " + i);
|
||||
}
|
||||
|
||||
if (mapIdByName.containsKey(s)) {
|
||||
Config.warn("Duplicate entity name: " + s + ", id1: " + mapIdByName.get(s) + ", id2: " + i);
|
||||
}
|
||||
|
||||
if (mapClassByName.containsKey(s)) {
|
||||
Config.warn("Duplicate entity name: " + s + ", class1: " + mapClassByName.get(s) + ", class2: " + oclass);
|
||||
}
|
||||
|
||||
mapIdByClass.put(oclass, Integer.valueOf(i));
|
||||
mapIdByName.put(s, Integer.valueOf(i));
|
||||
mapClassByName.put(s, oclass);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,8 +11,7 @@ public class GuiQualitySettingsOF extends GuiScreen {
|
|||
private GuiScreen prevScreen;
|
||||
protected String title;
|
||||
private GameSettings settings;
|
||||
private static GameSettings.Options[] enumOptions = new GameSettings.Options[] {GameSettings.Options.MIPMAP_LEVELS, GameSettings.Options.MIPMAP_TYPE, GameSettings.Options.AF_LEVEL, GameSettings.Options.FXAA, GameSettings.Options.CLEAR_WATER, GameSettings.Options.BETTER_GRASS, GameSettings.Options.BETTER_SNOW, GameSettings.Options.CUSTOM_FONTS, GameSettings.Options.CUSTOM_SKY, GameSettings.Options.CUSTOM_ITEMS, GameSettings.Options.DYNAMIC_LIGHTS};
|
||||
//private static GameSettings.Options[] enumOptions = new GameSettings.Options[] {GameSettings.Options.MIPMAP_LEVELS, GameSettings.Options.MIPMAP_TYPE, GameSettings.Options.AF_LEVEL, GameSettings.Options.AA_LEVEL, GameSettings.Options.CLEAR_WATER, GameSettings.Options.RANDOM_MOBS, GameSettings.Options.BETTER_GRASS, GameSettings.Options.BETTER_SNOW, GameSettings.Options.CUSTOM_FONTS, GameSettings.Options.CUSTOM_COLORS, GameSettings.Options.SWAMP_COLORS, GameSettings.Options.SMOOTH_BIOMES, GameSettings.Options.CONNECTED_TEXTURES, GameSettings.Options.NATURAL_TEXTURES, GameSettings.Options.CUSTOM_SKY, GameSettings.Options.CUSTOM_ITEMS, GameSettings.Options.DYNAMIC_LIGHTS};
|
||||
private static GameSettings.Options[] enumOptions = new GameSettings.Options[] {GameSettings.Options.MIPMAP_LEVELS, GameSettings.Options.MIPMAP_TYPE, GameSettings.Options.AF_LEVEL, GameSettings.Options.FXAA, GameSettings.Options.CLEAR_WATER, GameSettings.Options.RANDOM_MOBS, GameSettings.Options.BETTER_GRASS, GameSettings.Options.BETTER_SNOW, GameSettings.Options.CUSTOM_FONTS, GameSettings.Options.CUSTOM_COLORS, GameSettings.Options.SWAMP_COLORS, GameSettings.Options.SMOOTH_BIOMES, /*GameSettings.Options.CONNECTED_TEXTURES, GameSettings.Options.NATURAL_TEXTURES,*/ GameSettings.Options.CUSTOM_SKY, GameSettings.Options.CUSTOM_ITEMS, GameSettings.Options.DYNAMIC_LIGHTS};
|
||||
|
||||
public GuiQualitySettingsOF(GuiScreen p_i53_1_, GameSettings p_i53_2_) {
|
||||
this.prevScreen = p_i53_1_;
|
||||
|
|
119
src/main/java/net/PeytonPlayz585/shadow/LightMap.java
Normal file
119
src/main/java/net/PeytonPlayz585/shadow/LightMap.java
Normal file
|
@ -0,0 +1,119 @@
|
|||
package net.PeytonPlayz585.shadow;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class LightMap {
|
||||
private CustomColormap lightMapRgb = null;
|
||||
private float[][] sunRgbs = new float[16][3];
|
||||
private float[][] torchRgbs = new float[16][3];
|
||||
|
||||
public LightMap(CustomColormap lightMapRgb) {
|
||||
this.lightMapRgb = lightMapRgb;
|
||||
}
|
||||
|
||||
public CustomColormap getColormap() {
|
||||
return this.lightMapRgb;
|
||||
}
|
||||
|
||||
public boolean updateLightmap(World world, float torchFlickerX, int[] lmColors, boolean nightvision) {
|
||||
if (this.lightMapRgb == null) {
|
||||
return false;
|
||||
} else {
|
||||
int i = this.lightMapRgb.getHeight();
|
||||
|
||||
if (nightvision && i < 64) {
|
||||
return false;
|
||||
} else {
|
||||
int j = this.lightMapRgb.getWidth();
|
||||
|
||||
if (j < 16) {
|
||||
warn("Invalid lightmap width: " + j);
|
||||
this.lightMapRgb = null;
|
||||
return false;
|
||||
} else {
|
||||
int k = 0;
|
||||
|
||||
if (nightvision) {
|
||||
k = j * 16 * 2;
|
||||
}
|
||||
|
||||
float f = 1.1666666F * (world.getSunBrightness(1.0F) - 0.2F);
|
||||
|
||||
if (world.getLastLightningBolt() > 0) {
|
||||
f = 1.0F;
|
||||
}
|
||||
|
||||
f = Config.limitTo1(f);
|
||||
float f1 = f * (float)(j - 1);
|
||||
float f2 = Config.limitTo1(torchFlickerX + 0.5F) * (float)(j - 1);
|
||||
float f3 = Config.limitTo1(Config.getGameSettings().saturation);
|
||||
boolean flag = f3 > 1.0E-4F;
|
||||
float[][] afloat = this.lightMapRgb.getColorsRgb();
|
||||
this.getLightMapColumn(afloat, f1, k, j, this.sunRgbs);
|
||||
this.getLightMapColumn(afloat, f2, k + 16 * j, j, this.torchRgbs);
|
||||
float[] afloat1 = new float[3];
|
||||
|
||||
for (int l = 0; l < 16; ++l) {
|
||||
for (int i1 = 0; i1 < 16; ++i1) {
|
||||
for (int j1 = 0; j1 < 3; ++j1) {
|
||||
float f4 = Config.limitTo1(this.sunRgbs[l][j1] + this.torchRgbs[i1][j1]);
|
||||
|
||||
if (flag) {
|
||||
float f5 = 1.0F - f4;
|
||||
f5 = 1.0F - f5 * f5 * f5 * f5;
|
||||
f4 = f3 * f5 + (1.0F - f3) * f4;
|
||||
}
|
||||
|
||||
afloat1[j1] = f4;
|
||||
}
|
||||
|
||||
int k1 = (int)(afloat1[0] * 255.0F);
|
||||
int l1 = (int)(afloat1[1] * 255.0F);
|
||||
int i2 = (int)(afloat1[2] * 255.0F);
|
||||
lmColors[l * 16 + i1] = -16777216 | k1 << 16 | l1 << 8 | i2;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void getLightMapColumn(float[][] origMap, float x, int offset, int width, float[][] colRgb) {
|
||||
int i = (int) Math.floor((double) x);
|
||||
int j = (int) Math.ceil((double) x);
|
||||
|
||||
if (i == j) {
|
||||
for (int i1 = 0; i1 < 16; ++i1) {
|
||||
float[] afloat3 = origMap[offset + i1 * width + i];
|
||||
float[] afloat4 = colRgb[i1];
|
||||
|
||||
for (int j1 = 0; j1 < 3; ++j1) {
|
||||
afloat4[j1] = afloat3[j1];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
float f = 1.0F - (x - (float) i);
|
||||
float f1 = 1.0F - ((float) j - x);
|
||||
|
||||
for (int k = 0; k < 16; ++k) {
|
||||
float[] afloat = origMap[offset + k * width + i];
|
||||
float[] afloat1 = origMap[offset + k * width + j];
|
||||
float[] afloat2 = colRgb[k];
|
||||
|
||||
for (int l = 0; l < 3; ++l) {
|
||||
afloat2[l] = afloat[l] * f + afloat1[l] * f1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void dbg(String str) {
|
||||
Config.dbg("CustomColors: " + str);
|
||||
}
|
||||
|
||||
private static void warn(String str) {
|
||||
Config.warn("CustomColors: " + str);
|
||||
}
|
||||
}
|
136
src/main/java/net/PeytonPlayz585/shadow/LightMapPack.java
Normal file
136
src/main/java/net/PeytonPlayz585/shadow/LightMapPack.java
Normal file
|
@ -0,0 +1,136 @@
|
|||
package net.PeytonPlayz585.shadow;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class LightMapPack {
|
||||
private LightMap lightMap;
|
||||
private LightMap lightMapRain;
|
||||
private LightMap lightMapThunder;
|
||||
private int[] colorBuffer1 = new int[0];
|
||||
private int[] colorBuffer2 = new int[0];
|
||||
|
||||
public LightMapPack(LightMap lightMap, LightMap lightMapRain, LightMap lightMapThunder) {
|
||||
if (lightMapRain != null || lightMapThunder != null) {
|
||||
if (lightMapRain == null) {
|
||||
lightMapRain = lightMap;
|
||||
}
|
||||
|
||||
if (lightMapThunder == null) {
|
||||
lightMapThunder = lightMapRain;
|
||||
}
|
||||
}
|
||||
|
||||
this.lightMap = lightMap;
|
||||
this.lightMapRain = lightMapRain;
|
||||
this.lightMapThunder = lightMapThunder;
|
||||
}
|
||||
|
||||
public boolean updateLightmap(World world, float torchFlickerX, int[] lmColors, boolean nightvision, float partialTicks) {
|
||||
if (this.lightMapRain == null && this.lightMapThunder == null) {
|
||||
return this.lightMap.updateLightmap(world, torchFlickerX, lmColors, nightvision);
|
||||
} else {
|
||||
int i = world.provider.getDimensionId();
|
||||
|
||||
if (i != 1 && i != -1) {
|
||||
float f = world.getRainStrength(partialTicks);
|
||||
float f1 = world.getThunderStrength(partialTicks);
|
||||
float f2 = 1.0E-4F;
|
||||
boolean flag = f > f2;
|
||||
boolean flag1 = f1 > f2;
|
||||
|
||||
if (!flag && !flag1) {
|
||||
return this.lightMap.updateLightmap(world, torchFlickerX, lmColors, nightvision);
|
||||
} else {
|
||||
if (f > 0.0F) {
|
||||
f1 /= f;
|
||||
}
|
||||
|
||||
float f3 = 1.0F - f;
|
||||
float f4 = f - f1;
|
||||
|
||||
if (this.colorBuffer1.length != lmColors.length) {
|
||||
this.colorBuffer1 = new int[lmColors.length];
|
||||
this.colorBuffer2 = new int[lmColors.length];
|
||||
}
|
||||
|
||||
int j = 0;
|
||||
int[][] aint = new int[][] {
|
||||
lmColors,
|
||||
this.colorBuffer1,
|
||||
this.colorBuffer2
|
||||
};
|
||||
float[] afloat = new float[3];
|
||||
|
||||
if (f3 > f2 && this.lightMap.updateLightmap(world, torchFlickerX, aint[j], nightvision)) {
|
||||
afloat[j] = f3;
|
||||
++j;
|
||||
}
|
||||
|
||||
if (f4 > f2 && this.lightMapRain != null && this.lightMapRain.updateLightmap(world, torchFlickerX, aint[j], nightvision)) {
|
||||
afloat[j] = f4;
|
||||
++j;
|
||||
}
|
||||
|
||||
if (f1 > f2 && this.lightMapThunder != null && this.lightMapThunder.updateLightmap(world, torchFlickerX, aint[j], nightvision)) {
|
||||
afloat[j] = f1;
|
||||
++j;
|
||||
}
|
||||
|
||||
return j == 2 ? this.blend(aint[0], afloat[0], aint[1], afloat[1]) : (j == 3 ? this.blend(aint[0], afloat[0], aint[1], afloat[1], aint[2], afloat[2]) : true);
|
||||
}
|
||||
} else {
|
||||
return this.lightMap.updateLightmap(world, torchFlickerX, lmColors, nightvision);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean blend(int[] cols0, float br0, int[] cols1, float br1) {
|
||||
if (cols1.length != cols0.length) {
|
||||
return false;
|
||||
} else {
|
||||
for (int i = 0; i < cols0.length; ++i) {
|
||||
int j = cols0[i];
|
||||
int k = j >> 16 & 255;
|
||||
int l = j >> 8 & 255;
|
||||
int i1 = j & 255;
|
||||
int j1 = cols1[i];
|
||||
int k1 = j1 >> 16 & 255;
|
||||
int l1 = j1 >> 8 & 255;
|
||||
int i2 = j1 & 255;
|
||||
int j2 = (int)((float) k * br0 + (float) k1 * br1);
|
||||
int k2 = (int)((float) l * br0 + (float) l1 * br1);
|
||||
int l2 = (int)((float) i1 * br0 + (float) i2 * br1);
|
||||
cols0[i] = -16777216 | j2 << 16 | k2 << 8 | l2;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean blend(int[] cols0, float br0, int[] cols1, float br1, int[] cols2, float br2) {
|
||||
if (cols1.length == cols0.length && cols2.length == cols0.length) {
|
||||
for (int i = 0; i < cols0.length; ++i) {
|
||||
int j = cols0[i];
|
||||
int k = j >> 16 & 255;
|
||||
int l = j >> 8 & 255;
|
||||
int i1 = j & 255;
|
||||
int j1 = cols1[i];
|
||||
int k1 = j1 >> 16 & 255;
|
||||
int l1 = j1 >> 8 & 255;
|
||||
int i2 = j1 & 255;
|
||||
int j2 = cols2[i];
|
||||
int k2 = j2 >> 16 & 255;
|
||||
int l2 = j2 >> 8 & 255;
|
||||
int i3 = j2 & 255;
|
||||
int j3 = (int)((float) k * br0 + (float) k1 * br1 + (float) k2 * br2);
|
||||
int k3 = (int)((float) l * br0 + (float) l1 * br1 + (float) l2 * br2);
|
||||
int l3 = (int)((float) i1 * br0 + (float) i2 * br1 + (float) i3 * br2);
|
||||
cols0[i] = -16777216 | j3 << 16 | k3 << 8 | l3;
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,7 +14,6 @@ import net.minecraft.util.EnumFacing;
|
|||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class RenderEnv {
|
||||
private IBlockAccess blockAccess;
|
||||
private IBlockState blockState;
|
||||
private BlockPos blockPos;
|
||||
private GameSettings gameSettings;
|
||||
|
@ -29,7 +28,6 @@ public class RenderEnv {
|
|||
private static ThreadLocal threadLocalInstance = new ThreadLocal();
|
||||
|
||||
private RenderEnv(IBlockAccess p_i94_1_, IBlockState p_i94_2_, BlockPos p_i94_3_) {
|
||||
this.blockAccess = p_i94_1_;
|
||||
this.blockState = p_i94_2_;
|
||||
this.blockPos = p_i94_3_;
|
||||
this.gameSettings = Config.getGameSettings();
|
||||
|
@ -48,8 +46,18 @@ public class RenderEnv {
|
|||
}
|
||||
}
|
||||
|
||||
public void reset(IBlockState blockStateIn, BlockPos blockPosIn) {
|
||||
if (this.blockState != blockStateIn || this.blockPos != blockPosIn) {
|
||||
this.blockState = blockStateIn;
|
||||
this.blockPos = blockPosIn;
|
||||
this.blockId = -1;
|
||||
this.metadata = -1;
|
||||
this.breakingAnimation = -1;
|
||||
this.boundsFlags.clear();
|
||||
}
|
||||
}
|
||||
|
||||
private void reset(IBlockAccess p_reset_1_, IBlockState p_reset_2_, BlockPos p_reset_3_) {
|
||||
this.blockAccess = p_reset_1_;
|
||||
this.blockState = p_reset_2_;
|
||||
this.blockPos = p_reset_3_;
|
||||
this.blockId = -1;
|
||||
|
|
|
@ -0,0 +1,214 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package net.PeytonPlayz585.shadow.apache;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* An immutable pair consisting of two {@link Object} elements.
|
||||
*
|
||||
* <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();
|
||||
}
|
||||
|
||||
}
|
247
src/main/java/net/PeytonPlayz585/shadow/apache/Pair.java
Normal file
247
src/main/java/net/PeytonPlayz585/shadow/apache/Pair.java
Normal file
|
@ -0,0 +1,247 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package net.PeytonPlayz585.shadow.apache;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.apache.commons.lang3.function.FailableBiConsumer;
|
||||
import org.apache.commons.lang3.function.FailableBiFunction;
|
||||
|
||||
/**
|
||||
* A pair consisting of two elements.
|
||||
*
|
||||
* <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>, 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 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());
|
||||
}
|
||||
|
||||
}
|
|
@ -71,6 +71,25 @@ public class IOUtils {
|
|||
}
|
||||
}
|
||||
|
||||
public static String inputStreamToString(InputStream is, Charset c, boolean b1) throws IOException {
|
||||
if(is instanceof EaglerInputStream) {
|
||||
return new String(((EaglerInputStream)is).getAsArray(), c);
|
||||
}else {
|
||||
try {
|
||||
StringBuilder b = new StringBuilder();
|
||||
BufferedReader rd = new BufferedReader(new InputStreamReader(is, c));
|
||||
String s;
|
||||
while((s = rd.readLine()) != null) {
|
||||
b.append(s).append('\n');
|
||||
}
|
||||
return b.toString();
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int readFully(InputStream is, byte[] out) throws IOException {
|
||||
int i = 0, j;
|
||||
while(i < out.length && (j = is.read(out, i, out.length - i)) != -1) {
|
||||
|
|
|
@ -62,7 +62,7 @@ public class MapColor {
|
|||
public static final MapColor emeraldColor = new MapColor(33, '\ud93a');
|
||||
public static final MapColor obsidianColor = new MapColor(34, 8476209);
|
||||
public static final MapColor netherrackColor = new MapColor(35, 7340544);
|
||||
public final int colorValue;
|
||||
public int colorValue;
|
||||
public final int colorIndex;
|
||||
|
||||
private MapColor(int index, int color) {
|
||||
|
|
|
@ -3,6 +3,7 @@ package net.minecraft.client.renderer.texture;
|
|||
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
@ -162,4 +163,16 @@ public class TextureManager implements ITickable, IResourceManagerReloadListener
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
public void reloadBannerTextures() {
|
||||
for (Object entry0 : new HashSet(this.mapTextureObjects.entrySet())) {
|
||||
Entry<ResourceLocation, ITextureObject> entry = (Entry<ResourceLocation, ITextureObject>) entry0;
|
||||
ResourceLocation resourcelocation = (ResourceLocation)entry.getKey();
|
||||
ITextureObject itextureobject = (ITextureObject)entry.getValue();
|
||||
|
||||
if (itextureobject instanceof LayeredColorMaskTexture) {
|
||||
this.loadTexture(resourcelocation, itextureobject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -86,7 +86,12 @@ public class SimpleResource implements IResource {
|
|||
|
||||
IMetadataSection imetadatasection = (IMetadataSection) this.mapMetadataSections.get(s);
|
||||
if (imetadatasection == null) {
|
||||
try {
|
||||
imetadatasection = this.srMetadataSerializer.parseMetadataSection(s, this.mcmetaJson);
|
||||
} catch(Exception e) {
|
||||
//Temp fix, no frame time :(
|
||||
imetadatasection = this.srMetadataSerializer.parseMetadataSection(s, new JSONObject("{\"animation\":{}}"));
|
||||
}
|
||||
}
|
||||
|
||||
return (T) imetadatasection;
|
||||
|
|
|
@ -29,10 +29,8 @@ import net.minecraft.util.RegistrySimple;
|
|||
public class IMetadataSerializer {
|
||||
private final IRegistry<String, IMetadataSerializer.Registration<? extends IMetadataSection>> metadataSectionSerializerRegistry = new RegistrySimple();
|
||||
|
||||
public <T extends IMetadataSection> void registerMetadataSectionType(
|
||||
IMetadataSectionSerializer<T> parIMetadataSectionSerializer, Class<T> parClass1) {
|
||||
this.metadataSectionSerializerRegistry.putObject(parIMetadataSectionSerializer.getSectionName(),
|
||||
new IMetadataSerializer.Registration(parIMetadataSectionSerializer, parClass1));
|
||||
public <T extends IMetadataSection> void registerMetadataSectionType(IMetadataSectionSerializer<T> parIMetadataSectionSerializer, Class<T> parClass1) {
|
||||
this.metadataSectionSerializerRegistry.putObject(parIMetadataSectionSerializer.getSectionName(), new IMetadataSerializer.Registration(parIMetadataSectionSerializer, parClass1));
|
||||
}
|
||||
|
||||
public <T extends IMetadataSection> T parseMetadataSection(String parString1, JSONObject parJsonObject) {
|
||||
|
|
|
@ -18,6 +18,7 @@ import com.google.common.collect.Sets;
|
|||
|
||||
import net.PeytonPlayz585.shadow.ClearWater;
|
||||
import net.PeytonPlayz585.shadow.Config;
|
||||
import net.PeytonPlayz585.shadow.CustomColors;
|
||||
import net.PeytonPlayz585.shadow.CustomSky;
|
||||
import net.PeytonPlayz585.shadow.DynamicLights;
|
||||
import net.PeytonPlayz585.shadow.GuiYesNo;
|
||||
|
@ -260,6 +261,9 @@ public class GameSettings {
|
|||
public boolean experimentalVisGraph = false;
|
||||
public boolean experimentalBufferQueue = false;
|
||||
public GuiScreen lastGuiScreen;
|
||||
public boolean ofSwampColors = true;
|
||||
public boolean ofSmoothBiomes = true;
|
||||
public boolean ofCustomColors = true;
|
||||
|
||||
public GameSettings(Minecraft mcIn) {
|
||||
this.keyBindings = (KeyBinding[]) ArrayUtils.addAll(new KeyBinding[] { this.keyBindAttack, this.keyBindUseItem,
|
||||
|
@ -870,6 +874,24 @@ public class GameSettings {
|
|||
this.mc.refreshResources();
|
||||
}
|
||||
|
||||
if (parOptions == GameSettings.Options.SWAMP_COLORS) {
|
||||
this.ofSwampColors = !this.ofSwampColors;
|
||||
CustomColors.updateUseDefaultGrassFoliageColors();
|
||||
this.mc.renderGlobal.loadRenderers();
|
||||
}
|
||||
|
||||
if (parOptions == GameSettings.Options.SMOOTH_BIOMES) {
|
||||
this.ofSmoothBiomes = !this.ofSmoothBiomes;
|
||||
CustomColors.updateUseDefaultGrassFoliageColors();
|
||||
this.mc.renderGlobal.loadRenderers();
|
||||
}
|
||||
|
||||
if (parOptions == GameSettings.Options.CUSTOM_COLORS) {
|
||||
this.ofCustomColors = !this.ofCustomColors;
|
||||
CustomColors.update();
|
||||
this.mc.renderGlobal.loadRenderers();
|
||||
}
|
||||
|
||||
this.saveOptions();
|
||||
}
|
||||
|
||||
|
@ -984,6 +1006,12 @@ public class GameSettings {
|
|||
return this.experimentalBufferQueue;
|
||||
case CUSTOM_ITEMS:
|
||||
return this.ofCustomItems;
|
||||
case SWAMP_COLORS:
|
||||
return this.ofSwampColors;
|
||||
case SMOOTH_BIOMES:
|
||||
return this.ofSmoothBiomes;
|
||||
case CUSTOM_COLORS:
|
||||
return this.ofCustomColors;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -1254,6 +1282,12 @@ public class GameSettings {
|
|||
return this.experimentalBufferQueue ? s + Lang.getOn() : s + Lang.getOff();
|
||||
} else if (parOptions == GameSettings.Options.CUSTOM_ITEMS) {
|
||||
return this.ofCustomItems ? s + Lang.getOn() : s + Lang.getOff();
|
||||
} else if (parOptions == GameSettings.Options.SWAMP_COLORS) {
|
||||
return this.ofSwampColors ? s + Lang.getOn() : s + Lang.getOff();
|
||||
} else if (parOptions == GameSettings.Options.SMOOTH_BIOMES) {
|
||||
return this.ofSmoothBiomes ? s + Lang.getOn() : s + Lang.getOff();
|
||||
} else if (parOptions == GameSettings.Options.CUSTOM_COLORS) {
|
||||
return this.ofCustomColors ? s + Lang.getOn() : s + Lang.getOff();
|
||||
} else {
|
||||
return s;
|
||||
}
|
||||
|
@ -1809,6 +1843,18 @@ public class GameSettings {
|
|||
this.ofCustomItems = Boolean.valueOf(astring[1]).booleanValue();
|
||||
}
|
||||
|
||||
if (astring[0].equals("ofSwampColors") && astring.length >= 2) {
|
||||
this.ofSwampColors = Boolean.valueOf(astring[1]).booleanValue();
|
||||
}
|
||||
|
||||
if (astring[0].equals("ofSmoothBiomes") && astring.length >= 2) {
|
||||
this.ofSmoothBiomes = Boolean.valueOf(astring[1]).booleanValue();
|
||||
}
|
||||
|
||||
if (astring[0].equals("ofCustomColors") && astring.length >= 2) {
|
||||
this.ofCustomColors = Boolean.valueOf(astring[1]).booleanValue();
|
||||
}
|
||||
|
||||
Keyboard.setFunctionKeyModifier(keyBindFunction.getKeyCode());
|
||||
|
||||
for (SoundCategory soundcategory : SoundCategory._VALUES) {
|
||||
|
@ -1983,6 +2029,9 @@ public class GameSettings {
|
|||
printwriter.println("visGraph:" + this.experimentalVisGraph);
|
||||
printwriter.println("bufferQueue:" + this.experimentalBufferQueue);
|
||||
printwriter.println("ofCustomItems:" + this.ofCustomItems);
|
||||
printwriter.println("ofSwampColors:" + this.ofSwampColors);
|
||||
printwriter.println("ofSmoothBiomes:" + this.ofSmoothBiomes);
|
||||
printwriter.println("ofCustomColors:" + this.ofCustomColors);
|
||||
|
||||
for (KeyBinding keybinding : this.keyBindings) {
|
||||
printwriter.println("key_" + keybinding.getKeyDescription() + ":" + keybinding.getKeyCode());
|
||||
|
@ -2187,7 +2236,10 @@ public class GameSettings {
|
|||
CHUNK_BORDERS("Chunk Borders", false, false),
|
||||
VIS_GRAPH("Experimental VisGraph", false, false),
|
||||
BUFFER_QUEUE("Experimental Queuing", false, false),
|
||||
CUSTOM_ITEMS("Custom Items", false, false);
|
||||
CUSTOM_ITEMS("Custom Items", false, false),
|
||||
SWAMP_COLORS("Swamp Colors", false, false),
|
||||
SMOOTH_BIOMES("Smooth Biomes", false, false),
|
||||
CUSTOM_COLORS("Custom Colors", false, false);
|
||||
|
||||
private final boolean enumFloat;
|
||||
private final boolean enumBoolean;
|
||||
|
|
Loading…
Reference in New Issue
Block a user