Got Custom Items working (Kinda)

This commit is contained in:
PeytonPlayz595 2024-04-14 01:39:14 -04:00
parent c8dddcdd1f
commit ab3bf15fec
48 changed files with 5214 additions and 82 deletions

View File

@ -7,6 +7,8 @@ import net.lax1dude.eaglercraft.v1_8.internal.buffer.IntBuffer;
import static org.lwjgl.opengles.GLES30.*;
import org.lwjgl.opengles.GLES31;
/**
* Copyright (c) 2022-2023 lax1dude, ayunami2000. All Rights Reserved.
*
@ -527,4 +529,8 @@ public class PlatformOpenGL {
return true;
}
public static int _wglGetTexLevelParameteri(int glTexture2d, int i, int glTextureWidth) {
return GLES31.glGetTexLevelParameteri(glTexture2d, i, glTextureWidth);
}
}

View File

@ -0,0 +1,61 @@
/*
* 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;
import java.io.IOException;
import java.io.Writer;
/**
* Executes a sequence of translators one after the other. Execution ends whenever
* the first translator consumes code points from the input.
*
* @since 3.0
* @deprecated As of 3.6, use Apache Commons Text
* <a href="https://commons.apache.org/proper/commons-text/javadocs/api-release/org/apache/commons/text/translate/AggregateTranslator.html">
* AggregateTranslator</a> instead
*/
@Deprecated
public class AggregateTranslator extends CharSequenceTranslator {
private final CharSequenceTranslator[] translators;
/**
* Specify the translators to be used at creation time.
*
* @param translators CharSequenceTranslator array to aggregate
*/
public AggregateTranslator(final CharSequenceTranslator... translators) {
this.translators = ArrayUtils.clone(translators);
}
/**
* The first translator to consume code points from the input is the 'winner'.
* Execution stops with the number of consumed code points being returned.
* {@inheritDoc}
*/
@Override
public int translate(final CharSequence input, final int index, final Writer out) throws IOException {
for (final CharSequenceTranslator translator : translators) {
final int consumed = translator.translate(input, index, out);
if (consumed != 0) {
return consumed;
}
}
return 0;
}
}

View File

@ -0,0 +1,360 @@
package net.PeytonPlayz585.shadow;
import java.util.function.Function;
import java.util.function.Supplier;
public class ArrayUtils {
/**
* Clones an array or returns {@code null}.
* <p>
* This method returns {@code null} for a {@code null} input array.
* </p>
*
* @param array the array to clone, may be {@code null}
* @return the cloned array, {@code null} if {@code null} input
*/
public static boolean[] clone(final boolean[] array) {
return array != null ? array.clone() : null;
}
/**
* Clones an array or returns {@code null}.
* <p>
* This method returns {@code null} for a {@code null} input array.
* </p>
*
* @param array the array to clone, may be {@code null}
* @return the cloned array, {@code null} if {@code null} input
*/
public static byte[] clone(final byte[] array) {
return array != null ? array.clone() : null;
}
/**
* Clones an array or returns {@code null}.
* <p>
* This method returns {@code null} for a {@code null} input array.
* </p>
*
* @param array the array to clone, may be {@code null}
* @return the cloned array, {@code null} if {@code null} input
*/
public static char[] clone(final char[] array) {
return array != null ? array.clone() : null;
}
/**
* Clones an array or returns {@code null}.
* <p>
* This method returns {@code null} for a {@code null} input array.
* </p>
*
* @param array the array to clone, may be {@code null}
* @return the cloned array, {@code null} if {@code null} input
*/
public static double[] clone(final double[] array) {
return array != null ? array.clone() : null;
}
/**
* Clones an array or returns {@code null}.
* <p>
* This method returns {@code null} for a {@code null} input array.
* </p>
*
* @param array the array to clone, may be {@code null}
* @return the cloned array, {@code null} if {@code null} input
*/
public static float[] clone(final float[] array) {
return array != null ? array.clone() : null;
}
/**
* Clones an array or returns {@code null}.
* <p>
* This method returns {@code null} for a {@code null} input array.
* </p>
*
* @param array the array to clone, may be {@code null}
* @return the cloned array, {@code null} if {@code null} input
*/
public static int[] clone(final int[] array) {
return array != null ? array.clone() : null;
}
/**
* Clones an array or returns {@code null}.
* <p>
* This method returns {@code null} for a {@code null} input array.
* </p>
*
* @param array the array to clone, may be {@code null}
* @return the cloned array, {@code null} if {@code null} input
*/
public static long[] clone(final long[] array) {
return array != null ? array.clone() : null;
}
/**
* Clones an array or returns {@code null}.
* <p>
* This method returns {@code null} for a {@code null} input array.
* </p>
*
* @param array the array to clone, may be {@code null}
* @return the cloned array, {@code null} if {@code null} input
*/
public static short[] clone(final short[] array) {
return array != null ? array.clone() : null;
}
/**
* Shallow clones an array or returns {@code null}.
* <p>
* The objects in the array are not cloned, thus there is no special handling for multi-dimensional arrays.
* </p>
* <p>
* This method returns {@code null} for a {@code null} input array.
* </p>
*
* @param <T> the component type of the array
* @param array the array to shallow clone, may be {@code null}
* @return the cloned array, {@code null} if {@code null} input
*/
public static <T> T[] clone(final T[] array) {
return array != null ? array.clone() : null;
}
/**
* A fluent version of {@link System#arraycopy(Object, int, Object, int, int)} that returns the destination array.
*
* @param <T> the type.
* @param source the source array.
* @param sourcePos starting position in the source array.
* @param destPos starting position in the destination data.
* @param length the number of array elements to be copied.
* @param allocator allocates the array to populate and return.
* @return dest
* @throws IndexOutOfBoundsException if copying would cause access of data outside array bounds.
* @throws ArrayStoreException if an element in the <code>src</code> array could not be stored into the <code>dest</code> array because of a type
* mismatch.
* @throws NullPointerException if either <code>src</code> or <code>dest</code> is <code>null</code>.
* @since 3.15.0
*/
public static <T> T arraycopy(final T source, final int sourcePos, final int destPos, final int length, final Function<Integer, T> allocator) {
return arraycopy(source, sourcePos, allocator.apply(length), destPos, length);
}
/**
* A fluent version of {@link System#arraycopy(Object, int, Object, int, int)} that returns the destination array.
*
* @param <T> the type.
* @param source the source array.
* @param sourcePos starting position in the source array.
* @param destPos starting position in the destination data.
* @param length the number of array elements to be copied.
* @param allocator allocates the array to populate and return.
* @return dest
* @throws IndexOutOfBoundsException if copying would cause access of data outside array bounds.
* @throws ArrayStoreException if an element in the <code>src</code> array could not be stored into the <code>dest</code> array because of a type
* mismatch.
* @throws NullPointerException if either <code>src</code> or <code>dest</code> is <code>null</code>.
* @since 3.15.0
*/
public static <T> T arraycopy(final T source, final int sourcePos, final int destPos, final int length, final Supplier<T> allocator) {
return arraycopy(source, sourcePos, allocator.get(), destPos, length);
}
/**
* A fluent version of {@link System#arraycopy(Object, int, Object, int, int)} that returns the destination array.
*
* @param <T> the type
* @param source the source array.
* @param sourcePos starting position in the source array.
* @param dest the destination array.
* @param destPos starting position in the destination data.
* @param length the number of array elements to be copied.
* @return dest
* @throws IndexOutOfBoundsException if copying would cause access of data outside array bounds.
* @throws ArrayStoreException if an element in the <code>src</code> array could not be stored into the <code>dest</code> array because of a type
* mismatch.
* @throws NullPointerException if either <code>src</code> or <code>dest</code> is <code>null</code>.
* @since 3.15.0
*/
public static <T> T arraycopy(final T source, final int sourcePos, final T dest, final int destPos, final int length) {
System.arraycopy(source, sourcePos, dest, destPos, length);
return dest;
}
public static String arrayToString(boolean[] arr, String separator)
{
if (arr == null)
{
return "";
}
else
{
StringBuffer stringbuffer = new StringBuffer(arr.length * 5);
for (int i = 0; i < arr.length; ++i)
{
boolean flag = arr[i];
if (i > 0)
{
stringbuffer.append(separator);
}
stringbuffer.append(String.valueOf(flag));
}
return stringbuffer.toString();
}
}
public static String arrayToString(float[] arr)
{
return arrayToString(arr, ", ");
}
public static String arrayToString(float[] arr, String separator)
{
if (arr == null)
{
return "";
}
else
{
StringBuffer stringbuffer = new StringBuffer(arr.length * 5);
for (int i = 0; i < arr.length; ++i)
{
float f = arr[i];
if (i > 0)
{
stringbuffer.append(separator);
}
stringbuffer.append(String.valueOf(f));
}
return stringbuffer.toString();
}
}
public static String arrayToString(float[] arr, String separator, String format)
{
if (arr == null)
{
return "";
}
else
{
StringBuffer stringbuffer = new StringBuffer(arr.length * 5);
for (int i = 0; i < arr.length; ++i)
{
float f = arr[i];
if (i > 0)
{
stringbuffer.append(separator);
}
stringbuffer.append(String.format(format, new Object[] {Float.valueOf(f)}));
}
return stringbuffer.toString();
}
}
public static String arrayToString(int[] arr)
{
return arrayToString(arr, ", ");
}
public static String arrayToString(int[] arr, String separator)
{
if (arr == null)
{
return "";
}
else
{
StringBuffer stringbuffer = new StringBuffer(arr.length * 5);
for (int i = 0; i < arr.length; ++i)
{
int j = arr[i];
if (i > 0)
{
stringbuffer.append(separator);
}
stringbuffer.append(String.valueOf(j));
}
return stringbuffer.toString();
}
}
public static String arrayToHexString(int[] arr, String separator)
{
if (arr == null)
{
return "";
}
else
{
StringBuffer stringbuffer = new StringBuffer(arr.length * 5);
for (int i = 0; i < arr.length; ++i)
{
int j = arr[i];
if (i > 0)
{
stringbuffer.append(separator);
}
stringbuffer.append("0x");
stringbuffer.append(Integer.toHexString(j));
}
return stringbuffer.toString();
}
}
public static String arrayToString(Object[] arr)
{
return arrayToString(arr, ", ");
}
public static String arrayToString(Object[] arr, String separator)
{
if (arr == null)
{
return "";
}
else
{
StringBuffer stringbuffer = new StringBuffer(arr.length * 5);
for (int i = 0; i < arr.length; ++i)
{
Object object = arr[i];
if (i > 0)
{
stringbuffer.append(separator);
}
stringbuffer.append(String.valueOf(object));
}
return stringbuffer.toString();
}
}
}

View File

@ -0,0 +1,138 @@
/*
* 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;
import java.io.IOException;
import java.io.StringWriter;
import java.io.UncheckedIOException;
import java.io.Writer;
import java.util.Locale;
import java.util.Objects;
/**
* An API for translating text.
* Its core use is to escape and unescape text. Because escaping and unescaping
* is completely contextual, the API does not present two separate signatures.
*
* @since 3.0
* @deprecated As of 3.6, use Apache Commons Text
* <a href="https://commons.apache.org/proper/commons-text/javadocs/api-release/org/apache/commons/text/translate/CharSequenceTranslator.html">
* CharSequenceTranslator</a> instead
*/
@Deprecated
public abstract class CharSequenceTranslator {
static final char[] HEX_DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
/**
* Returns an upper case hexadecimal {@link String} for the given
* character.
*
* @param codePoint The code point to convert.
* @return An upper case hexadecimal {@link String}
*/
public static String hex(final int codePoint) {
return Integer.toHexString(codePoint).toUpperCase(Locale.ENGLISH);
}
/**
* Helper for non-Writer usage.
* @param input CharSequence to be translated
* @return String output of translation
*/
public final String translate(final CharSequence input) {
if (input == null) {
return null;
}
try {
final StringWriter writer = new StringWriter(input.length() * 2);
translate(input, writer);
return writer.toString();
} catch (final IOException ioe) {
// this should never ever happen while writing to a StringWriter
throw new UncheckedIOException(ioe);
}
}
/**
* Translate a set of code points, represented by an int index into a CharSequence,
* into another set of code points. The number of code points consumed must be returned,
* and the only IOExceptions thrown must be from interacting with the Writer so that
* the top level API may reliably ignore StringWriter IOExceptions.
*
* @param input CharSequence that is being translated
* @param index int representing the current point of translation
* @param out Writer to translate the text to
* @return int count of code points consumed
* @throws IOException if and only if the Writer produces an IOException
*/
public abstract int translate(CharSequence input, int index, Writer out) throws IOException;
/**
* Translate an input onto a Writer. This is intentionally final as its algorithm is
* tightly coupled with the abstract method of this class.
*
* @param input CharSequence that is being translated
* @param writer Writer to translate the text to
* @throws IOException if and only if the Writer produces an IOException
*/
public final void translate(final CharSequence input, final Writer writer) throws IOException {
Objects.requireNonNull(writer, "writer");
if (input == null) {
return;
}
int pos = 0;
final int len = input.length();
while (pos < len) {
final int consumed = translate(input, pos, writer);
if (consumed == 0) {
// inlined implementation of Character.toChars(Character.codePointAt(input, pos))
// avoids allocating temp char arrays and duplicate checks
final char c1 = input.charAt(pos);
writer.write(c1);
pos++;
if (Character.isHighSurrogate(c1) && pos < len) {
final char c2 = input.charAt(pos);
if (Character.isLowSurrogate(c2)) {
writer.write(c2);
pos++;
}
}
continue;
}
// contract with translators is that they have to understand code points
// and they just took care of a surrogate pair
for (int pt = 0; pt < consumed; pt++) {
pos += Character.charCount(Character.codePointAt(input, pos));
}
}
}
/**
* Helper method to create a merger of this translator with another set of
* translators. Useful in customizing the standard functionality.
*
* @param translators CharSequenceTranslator array of translators to merge with this one
* @return CharSequenceTranslator merging this translator with the others
*/
public final CharSequenceTranslator with(final CharSequenceTranslator... translators) {
final CharSequenceTranslator[] newArray = new CharSequenceTranslator[translators.length + 1];
newArray[0] = this;
return new AggregateTranslator(ArrayUtils.arraycopy(translators, 0, newArray, 1, translators.length));
}
}

View File

@ -3,12 +3,14 @@ package net.PeytonPlayz585.shadow;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
import net.PeytonPlayz585.shadow.reflect.Reflector;
import net.lax1dude.eaglercraft.v1_8.internal.PlatformRuntime;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
@ -298,6 +300,10 @@ public class Config {
}
return !isDynamicLights() ? false : true;
}
public static boolean isCustomItems() {
return gameSettings.ofCustomItems;
}
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_);
@ -410,7 +416,7 @@ public class Config {
public static DefaultResourcePack getDefaultResourcePack() {
if (defaultResourcePackLazy == null) {
Minecraft minecraft = Minecraft.getMinecraft();
defaultResourcePackLazy = (DefaultResourcePack)Minecraft.getMinecraft().mcDefaultResourcePack;
defaultResourcePackLazy = (DefaultResourcePack)Reflector.getFieldValue(minecraft, Reflector.Minecraft_defaultResourcePack);
if (defaultResourcePackLazy == null) {
ResourcePackRepository resourcepackrepository = minecraft.getResourcePackRepository();
@ -452,8 +458,9 @@ public class Config {
List list = resourcepackrepository.getRepositoryEntries();
List list1 = new ArrayList();
for (Object resourcepackrepository$entry : list) {
list1.add(((ResourcePackRepository.Entry) resourcepackrepository$entry).getResourcePack());
for (Object resourcepackrepository$entry0 : list) {
ResourcePackRepository.Entry resourcepackrepository$entry = (ResourcePackRepository.Entry) resourcepackrepository$entry0;
list1.add(resourcepackrepository$entry.getResourcePack());
}
if (resourcepackrepository.getResourcePackInstance() != null) {
@ -595,4 +602,31 @@ public class Config {
return stringbuffer.toString();
}
}
public static Object[] addObjectsToArray(Object[] p_addObjectsToArray_0_, Object[] p_addObjectsToArray_1_) {
if (p_addObjectsToArray_0_ == null) {
throw new NullPointerException("The given array is NULL");
} else if (p_addObjectsToArray_1_.length == 0) {
return p_addObjectsToArray_0_;
} else {
int i = p_addObjectsToArray_0_.length;
int j = i + p_addObjectsToArray_1_.length;
Object[] aobject = (Object[])((Object[])Array.newInstance(p_addObjectsToArray_0_.getClass().getComponentType(), j));
System.arraycopy(p_addObjectsToArray_0_, 0, aobject, 0, i);
System.arraycopy(p_addObjectsToArray_1_, 0, aobject, i, p_addObjectsToArray_1_.length);
return aobject;
}
}
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 void error(String s, Throwable t) {
LOGGER.error("[Shadow Client] " + s, t);
}
public static void warn(String s, Throwable t) {
LOGGER.warn("[Shadow Client] " + s, t);
}
}

View File

@ -0,0 +1,968 @@
package net.PeytonPlayz585.shadow;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.TreeSet;
import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerTextureAtlasSprite;
import net.lax1dude.eaglercraft.v1_8.opengl.EaglercraftGPU;
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
import net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.BlockPart;
import net.minecraft.client.renderer.block.model.BlockPartFace;
import net.minecraft.client.renderer.block.model.FaceBakery;
import net.minecraft.client.renderer.block.model.ItemModelGenerator;
import net.minecraft.client.renderer.block.model.ModelBlock;
import net.minecraft.client.renderer.texture.ITextureObject;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.model.IBakedModel;
import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.client.resources.model.ModelManager;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.client.resources.model.ModelRotation;
import net.minecraft.client.resources.model.SimpleBakedModel;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
public class CustomItemProperties {
public String name = null;
public String basePath = null;
public int type = 1;
public int[] items = null;
public String texture = null;
public Map < String, String > mapTextures = null;
public String model = null;
public Map < String, String > mapModels = null;
public RangeListInt damage = null;
public boolean damagePercent = false;
public int damageMask = 0;
public RangeListInt stackSize = null;
public RangeListInt enchantmentIds = null;
public RangeListInt enchantmentLevels = null;
public NbtTagValue[] nbtTagValues = null;
public int hand = 0;
public int blend = 1;
public float speed = 0.0F;
public float rotation = 0.0F;
public int layer = 0;
public float duration = 1.0F;
public int weight = 0;
public ResourceLocation textureLocation = null;
public Map mapTextureLocations = null;
public EaglerTextureAtlasSprite sprite = null;
public Map mapSprites = null;
public IBakedModel bakedModelTexture = null;
public Map < String, IBakedModel > mapBakedModelsTexture = null;
public IBakedModel bakedModelFull = null;
public Map < String, IBakedModel > mapBakedModelsFull = null;
private int textureWidth = 0;
private int textureHeight = 0;
public static final int TYPE_UNKNOWN = 0;
public static final int TYPE_ITEM = 1;
public static final int TYPE_ENCHANTMENT = 2;
public static final int TYPE_ARMOR = 3;
public static final int HAND_ANY = 0;
public static final int HAND_MAIN = 1;
public static final int HAND_OFF = 2;
public static final String INVENTORY = "inventory";
public CustomItemProperties(Properties props, String path) {
this.name = parseName(path);
this.basePath = parseBasePath(path);
this.type = this.parseType(props.getProperty("type"));
this.items = this.parseItems(props.getProperty("items"), props.getProperty("matchItems"));
this.mapModels = parseModels(props, this.basePath);
this.model = parseModel(props.getProperty("model"), path, this.basePath, this.type, this.mapModels);
this.mapTextures = parseTextures(props, this.basePath);
boolean flag = this.mapModels == null && this.model == null;
this.texture = parseTexture(props.getProperty("texture"), props.getProperty("tile"), props.getProperty("source"), path, this.basePath, this.type, this.mapTextures, flag);
String s = props.getProperty("damage");
if (s != null) {
this.damagePercent = s.contains("%");
s = s.replace("%", "");
this.damage = this.parseRangeListInt(s);
this.damageMask = this.parseInt(props.getProperty("damageMask"), 0);
}
this.stackSize = this.parseRangeListInt(props.getProperty("stackSize"));
this.enchantmentIds = this.parseRangeListInt(props.getProperty("enchantmentIDs"), new ParserEnchantmentId());
this.enchantmentLevels = this.parseRangeListInt(props.getProperty("enchantmentLevels"));
this.nbtTagValues = this.parseNbtTagValues(props);
this.hand = this.parseHand(props.getProperty("hand"));
this.blend = Blender.parseBlend(props.getProperty("blend"));
this.speed = this.parseFloat(props.getProperty("speed"), 0.0F);
this.rotation = this.parseFloat(props.getProperty("rotation"), 0.0F);
this.layer = this.parseInt(props.getProperty("layer"), 0);
this.weight = this.parseInt(props.getProperty("weight"), 0);
this.duration = this.parseFloat(props.getProperty("duration"), 1.0F);
}
private static String parseName(String path) {
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);
}
return s;
}
private static String parseBasePath(String path) {
int i = path.lastIndexOf(47);
return i < 0 ? "" : path.substring(0, i);
}
private int parseType(String str) {
if (str == null) {
return 1;
} else if (str.equals("item")) {
return 1;
} else if (str.equals("enchantment")) {
return 2;
} else if (str.equals("armor")) {
return 3;
} else {
Config.warn("Unknown method: " + str);
return 0;
}
}
private int[] parseItems(String str, String str2) {
if (str == null) {
str = str2;
}
if (str == null) {
return null;
} else {
str = str.trim();
Set set = new TreeSet();
String[] astring = Config.tokenize(str, " ");
label45:
for (int i = 0; i < astring.length; ++i) {
String s = astring[i];
int j = Config.parseInt(s, -1);
if (j >= 0) {
set.add(new Integer(j));
} else {
if (s.contains("-")) {
String[] astring1 = Config.tokenize(s, "-");
if (astring1.length == 2) {
int k = Config.parseInt(astring1[0], -1);
int l = Config.parseInt(astring1[1], -1);
if (k >= 0 && l >= 0) {
int i1 = Math.min(k, l);
int j1 = Math.max(k, l);
int k1 = i1;
while (true) {
if (k1 > j1) {
continue label45;
}
set.add(new Integer(k1));
++k1;
}
}
}
}
Item item = Item.getByNameOrId(s);
if (item == null) {
Config.warn("Item not found: " + s);
} else {
int i2 = Item.getIdFromItem(item);
if (i2 <= 0) {
Config.warn("Item not found: " + s);
} else {
set.add(new Integer(i2));
}
}
}
}
Integer[] ainteger = (Integer[])((Integer[]) set.toArray(new Integer[set.size()]));
int[] aint = new int[ainteger.length];
for (int l1 = 0; l1 < aint.length; ++l1) {
aint[l1] = ainteger[l1].intValue();
}
return aint;
}
}
private static String parseTexture(String texStr, String texStr2, String texStr3, String path, String basePath, int type, Map < String, String > mapTexs, boolean textureFromPath) {
if (texStr == null) {
texStr = texStr2;
}
if (texStr == null) {
texStr = texStr3;
}
if (texStr != null) {
String s2 = ".png";
if (texStr.endsWith(s2)) {
texStr = texStr.substring(0, texStr.length() - s2.length());
}
texStr = fixTextureName(texStr, basePath);
return texStr;
} else if (type == 3) {
return null;
} else {
if (mapTexs != null) {
String s = (String) mapTexs.get("texture.bow_standby");
if (s != null) {
return s;
}
}
if (!textureFromPath) {
return null;
} else {
String s1 = path;
int i = path.lastIndexOf(47);
if (i >= 0) {
s1 = path.substring(i + 1);
}
int j = s1.lastIndexOf(46);
if (j >= 0) {
s1 = s1.substring(0, j);
}
s1 = fixTextureName(s1, basePath);
return s1;
}
}
}
private static Map parseTextures(Properties props, String basePath) {
String s = "texture.";
Map map = getMatchingProperties(props, s);
if (map.size() <= 0) {
return null;
} else {
Set set = map.keySet();
Map map1 = new LinkedHashMap();
for (Object e: set) {
String s1 = (String) e;
String s2 = (String) map.get(s1);
s2 = fixTextureName(s2, basePath);
map1.put(s1, s2);
}
return map1;
}
}
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);
}
if (iconName.startsWith("/")) {
iconName = iconName.substring(1);
}
return iconName;
}
private static String parseModel(String modelStr, String path, String basePath, int type, Map < String, String > mapModelNames) {
if (modelStr != null) {
String s1 = ".json";
if (modelStr.endsWith(s1)) {
modelStr = modelStr.substring(0, modelStr.length() - s1.length());
}
modelStr = fixModelName(modelStr, basePath);
return modelStr;
} else if (type == 3) {
return null;
} else {
if (mapModelNames != null) {
String s = (String) mapModelNames.get("model.bow_standby");
if (s != null) {
return s;
}
}
return modelStr;
}
}
private static Map parseModels(Properties props, String basePath) {
String s = "model.";
Map map = getMatchingProperties(props, s);
if (map.size() <= 0) {
return null;
} else {
Set set = map.keySet();
Map map1 = new LinkedHashMap();
for (Object e: set) {
String s1 = (String) e;
String s2 = (String) map.get(s1);
s2 = fixModelName(s2, basePath);
map1.put(s1, s2);
}
return map1;
}
}
private static String fixModelName(String modelName, String basePath) {
modelName = TextureUtils.fixResourcePath(modelName, basePath);
boolean flag = modelName.startsWith("block/") || modelName.startsWith("item/");
if (!modelName.startsWith(basePath) && !flag && !modelName.startsWith("mcpatcher/")) {
modelName = basePath + "/" + modelName;
}
String s = ".json";
if (modelName.endsWith(s)) {
modelName = modelName.substring(0, modelName.length() - s.length());
}
if (modelName.startsWith("/")) {
modelName = modelName.substring(1);
}
return modelName;
}
private int parseInt(String str, int defVal) {
if (str == null) {
return defVal;
} else {
str = str.trim();
int i = Config.parseInt(str, Integer.MIN_VALUE);
if (i == Integer.MIN_VALUE) {
Config.warn("Invalid integer: " + str);
return defVal;
} else {
return i;
}
}
}
private float parseFloat(String str, float defVal) {
if (str == null) {
return defVal;
} else {
str = str.trim();
float f = Config.parseFloat(str, Float.MIN_VALUE);
if (f == Float.MIN_VALUE) {
Config.warn("Invalid float: " + str);
return defVal;
} else {
return f;
}
}
}
private RangeListInt parseRangeListInt(String str) {
return this.parseRangeListInt(str, (IParserInt) null);
}
private RangeListInt parseRangeListInt(String str, IParserInt parser) {
if (str == null) {
return null;
} else {
String[] astring = Config.tokenize(str, " ");
RangeListInt rangelistint = new RangeListInt();
for (int i = 0; i < astring.length; ++i) {
String s = astring[i];
if (parser != null) {
int j = parser.parse(s, Integer.MIN_VALUE);
if (j != Integer.MIN_VALUE) {
rangelistint.addRange(new RangeInt(j, j));
continue;
}
}
RangeInt rangeint = this.parseRangeInt(s);
if (rangeint == null) {
Config.warn("Invalid range list: " + str);
return null;
}
rangelistint.addRange(rangeint);
}
return rangelistint;
}
}
private RangeInt parseRangeInt(String str) {
if (str == null) {
return null;
} else {
str = str.trim();
int i = str.length() - str.replace("-", "").length();
if (i > 1) {
Config.warn("Invalid range: " + str);
return null;
} else {
String[] astring = Config.tokenize(str, "- ");
int[] aint = new int[astring.length];
for (int j = 0; j < astring.length; ++j) {
String s = astring[j];
int k = Config.parseInt(s, -1);
if (k < 0) {
Config.warn("Invalid range: " + str);
return null;
}
aint[j] = k;
}
if (aint.length == 1) {
int i1 = aint[0];
if (str.startsWith("-")) {
return new RangeInt(0, i1);
} else if (str.endsWith("-")) {
return new RangeInt(i1, 65535);
} else {
return new RangeInt(i1, i1);
}
} else if (aint.length == 2) {
int l = Math.min(aint[0], aint[1]);
int j1 = Math.max(aint[0], aint[1]);
return new RangeInt(l, j1);
} else {
Config.warn("Invalid range: " + str);
return null;
}
}
}
}
private NbtTagValue[] parseNbtTagValues(Properties props) {
String s = "nbt.";
Map map = getMatchingProperties(props, s);
if (map.size() <= 0) {
return null;
} else {
List list = new ArrayList();
for (Object e: map.keySet()) {
String s1 = (String) e;
String s2 = (String) map.get(s1);
String s3 = s1.substring(s.length());
NbtTagValue nbttagvalue = new NbtTagValue(s3, s2);
list.add(nbttagvalue);
}
NbtTagValue[] anbttagvalue = (NbtTagValue[])((NbtTagValue[]) list.toArray(new NbtTagValue[list.size()]));
return anbttagvalue;
}
}
private static Map getMatchingProperties(Properties props, String keyPrefix) {
Map map = new LinkedHashMap();
for (Object e: props.keySet()) {
String s = (String) e;
String s1 = props.getProperty(s);
if (s.startsWith(keyPrefix)) {
map.put(s, s1);
}
}
return map;
}
private int parseHand(String str) {
if (str == null) {
return 0;
} else {
str = str.toLowerCase();
if (str.equals("any")) {
return 0;
} else if (str.equals("main")) {
return 1;
} else if (str.equals("off")) {
return 2;
} else {
Config.warn("Invalid hand: " + str);
return 0;
}
}
}
public boolean isValid(String path) {
if (this.name != null && this.name.length() > 0) {
if (this.basePath == null) {
Config.warn("No base path found: " + path);
return false;
} else if (this.type == 0) {
Config.warn("No type defined: " + path);
return false;
} else {
if (this.type == 1 || this.type == 3) {
if (this.items == null) {
this.items = this.detectItems();
}
if (this.items == null) {
Config.warn("No items defined: " + path);
return false;
}
}
if (this.texture == null && this.mapTextures == null && this.model == null && this.mapModels == null) {
Config.warn("No texture or model specified: " + path);
return false;
} else if (this.type == 2 && this.enchantmentIds == null) {
Config.warn("No enchantmentIDs specified: " + path);
return false;
} else {
return true;
}
}
} else {
Config.warn("No name found: " + path);
return false;
}
}
private int[] detectItems() {
Item item = Item.getByNameOrId(this.name);
if (item == null) {
return null;
} else {
int i = Item.getIdFromItem(item);
return i <= 0 ? null : new int[] {
i
};
}
}
public void updateIcons(TextureMap textureMap) {
if (this.texture != null) {
this.textureLocation = this.getTextureLocation(this.texture);
if (this.type == 1) {
ResourceLocation resourcelocation = this.getSpriteLocation(this.textureLocation);
this.sprite = textureMap.registerSprite(resourcelocation);
}
}
if (this.mapTextures != null) {
this.mapTextureLocations = new HashMap();
this.mapSprites = new HashMap();
for (String s: this.mapTextures.keySet()) {
String s1 = (String) this.mapTextures.get(s);
ResourceLocation resourcelocation1 = this.getTextureLocation(s1);
this.mapTextureLocations.put(s, resourcelocation1);
if (this.type == 1) {
ResourceLocation resourcelocation2 = this.getSpriteLocation(resourcelocation1);
EaglerTextureAtlasSprite textureatlassprite = textureMap.registerSprite(resourcelocation2);
this.mapSprites.put(s, textureatlassprite);
}
}
}
}
private ResourceLocation getTextureLocation(String texName) {
if (texName == null) {
return null;
} else {
ResourceLocation resourcelocation = new ResourceLocation(texName);
String s = resourcelocation.getResourceDomain();
String s1 = resourcelocation.getResourcePath();
if (!s1.contains("/")) {
s1 = "textures/items/" + s1;
}
String s2 = s1 + ".png";
ResourceLocation resourcelocation1 = new ResourceLocation(s, s2);
boolean flag = Config.hasResource(resourcelocation1);
if (!flag) {
Config.warn("File not found: " + s2);
}
return resourcelocation1;
}
}
private ResourceLocation getSpriteLocation(ResourceLocation resLoc) {
String s = resLoc.getResourcePath();
s = StrUtils.removePrefix(s, "textures/");
s = StrUtils.removeSuffix(s, ".png");
ResourceLocation resourcelocation = new ResourceLocation(resLoc.getResourceDomain(), s);
return resourcelocation;
}
public void updateModelTexture(TextureMap textureMap, ItemModelGenerator itemModelGenerator) {
if (this.texture != null || this.mapTextures != null) {
String[] astring = this.getModelTextures();
boolean flag = this.isUseTint();
this.bakedModelTexture = makeBakedModel(textureMap, itemModelGenerator, astring, flag);
if (this.type == 1 && this.mapTextures != null) {
for (String s: this.mapTextures.keySet()) {
String s1 = (String) this.mapTextures.get(s);
String s2 = StrUtils.removePrefix(s, "texture.");
if (s2.startsWith("bow") || s2.startsWith("fishing_rod") || s2.startsWith("shield")) {
String[] astring1 = new String[] {
s1
};
IBakedModel ibakedmodel = makeBakedModel(textureMap, itemModelGenerator, astring1, flag);
if (this.mapBakedModelsTexture == null) {
this.mapBakedModelsTexture = new HashMap();
}
this.mapBakedModelsTexture.put(s2, ibakedmodel);
}
}
}
}
}
private boolean isUseTint() {
return true;
}
private static IBakedModel makeBakedModel(TextureMap textureMap, ItemModelGenerator itemModelGenerator, String[] textures, boolean useTint) {
String[] astring = new String[textures.length];
for (int i = 0; i < astring.length; ++i) {
String s = textures[i];
astring[i] = StrUtils.removePrefix(s, "textures/");
}
ModelBlock modelblock = makeModelBlock(astring);
ModelBlock modelblock1 = itemModelGenerator.makeItemModel(textureMap, modelblock);
IBakedModel ibakedmodel = bakeModel(textureMap, modelblock1, useTint);
return ibakedmodel;
}
private String[] getModelTextures() {
if (this.type == 1 && this.items.length == 1) {
Item item = Item.getItemById(this.items[0]);
if (item == Items.potionitem && this.damage != null && this.damage.getCountRanges() > 0) {
RangeInt rangeint = this.damage.getRange(0);
int i = rangeint.getMin();
boolean flag = (i & 16384) != 0;
String s5 = this.getMapTexture(this.mapTextures, "texture.potion_overlay", "items/potion_overlay");
String s6 = null;
if (flag) {
s6 = this.getMapTexture(this.mapTextures, "texture.potion_bottle_splash", "items/potion_bottle_splash");
} else {
s6 = this.getMapTexture(this.mapTextures, "texture.potion_bottle_drinkable", "items/potion_bottle_drinkable");
}
return new String[] {
s5,
s6
};
}
if (item instanceof ItemArmor) {
ItemArmor itemarmor = (ItemArmor) item;
if (itemarmor.getArmorMaterial() == ItemArmor.ArmorMaterial.LEATHER) {
String s = "leather";
String s1 = "helmet";
if (itemarmor.armorType == 0) {
s1 = "helmet";
}
if (itemarmor.armorType == 1) {
s1 = "chestplate";
}
if (itemarmor.armorType == 2) {
s1 = "leggings";
}
if (itemarmor.armorType == 3) {
s1 = "boots";
}
String s2 = s + "_" + s1;
String s3 = this.getMapTexture(this.mapTextures, "texture." + s2, "items/" + s2);
String s4 = this.getMapTexture(this.mapTextures, "texture." + s2 + "_overlay", "items/" + s2 + "_overlay");
return new String[] {
s3,
s4
};
}
}
}
return new String[] {
this.texture
};
}
private String getMapTexture(Map < String, String > map, String key, String def) {
if (map == null) {
return def;
} else {
String s = (String) map.get(key);
return s == null ? def : s;
}
}
private static ModelBlock makeModelBlock(String[] modelTextures) {
StringBuffer stringbuffer = new StringBuffer();
stringbuffer.append("{\"parent\": \"builtin/generated\",\"textures\": {");
for (int i = 0; i < modelTextures.length; ++i) {
String s = modelTextures[i];
if (i > 0) {
stringbuffer.append(", ");
}
stringbuffer.append("\"layer" + i + "\": \"" + s + "\"");
}
stringbuffer.append("}}");
String s1 = stringbuffer.toString();
ModelBlock modelblock = ModelBlock.deserialize(s1);
return modelblock;
}
private static IBakedModel bakeModel(TextureMap textureMap, ModelBlock modelBlockIn, boolean useTint) {
ModelRotation modelrotation = ModelRotation.X0_Y0;
boolean flag = false;
String s = modelBlockIn.resolveTextureName("particle");
EaglerTextureAtlasSprite textureatlassprite = textureMap.getAtlasSprite((new ResourceLocation(s)).toString());
SimpleBakedModel.Builder simplebakedmodel$builder = (new SimpleBakedModel.Builder(modelBlockIn)).setTexture(textureatlassprite);
for (BlockPart blockpart: modelBlockIn.getElements()) {
for (EnumFacing enumfacing: blockpart.mapFaces.keySet()) {
BlockPartFace blockpartface = (BlockPartFace) blockpart.mapFaces.get(enumfacing);
if (!useTint) {
blockpartface = new BlockPartFace(blockpartface.cullFace, -1, blockpartface.texture, blockpartface.blockFaceUV);
}
String s1 = modelBlockIn.resolveTextureName(blockpartface.texture);
EaglerTextureAtlasSprite textureatlassprite1 = textureMap.getAtlasSprite((new ResourceLocation(s1)).toString());
BakedQuad bakedquad = makeBakedQuad(blockpart, blockpartface, textureatlassprite1, enumfacing, modelrotation, flag);
if (blockpartface.cullFace == null) {
simplebakedmodel$builder.addGeneralQuad(bakedquad);
} else {
simplebakedmodel$builder.addFaceQuad(modelrotation.rotateFace(blockpartface.cullFace), bakedquad);
}
}
}
return simplebakedmodel$builder.makeBakedModel();
}
private static BakedQuad makeBakedQuad(BlockPart blockPart, BlockPartFace blockPartFace, EaglerTextureAtlasSprite textureAtlasSprite, EnumFacing enumFacing, ModelRotation modelRotation, boolean uvLocked) {
FaceBakery facebakery = new FaceBakery();
return facebakery.makeBakedQuad(blockPart.positionFrom, blockPart.positionTo, blockPartFace, textureAtlasSprite, enumFacing, modelRotation, blockPart.partRotation, uvLocked, blockPart.shade);
}
public String toString() {
return "" + this.basePath + "/" + this.name + ", type: " + this.type + ", items: [" + Config.arrayToString(this.items) + "], textture: " + this.texture;
}
public float getTextureWidth(TextureManager textureManager) {
if (this.textureWidth <= 0) {
if (this.textureLocation != null) {
ITextureObject itextureobject = textureManager.getTexture(this.textureLocation);
int i = itextureobject.getGlTextureId();
int j = GlStateManager.getBoundTexture();
GlStateManager.bindTexture(i);
this.textureWidth = EaglercraftGPU.glGetTexLevelParameteri(RealOpenGLEnums.GL_TEXTURE_2D, 0, RealOpenGLEnums.GL_TEXTURE_WIDTH);
GlStateManager.bindTexture(j);
}
if (this.textureWidth <= 0) {
this.textureWidth = 16;
}
}
return (float) this.textureWidth;
}
public float getTextureHeight(TextureManager textureManager) {
if (this.textureHeight <= 0) {
if (this.textureLocation != null) {
ITextureObject itextureobject = textureManager.getTexture(this.textureLocation);
int i = itextureobject.getGlTextureId();
int j = GlStateManager.getBoundTexture();
GlStateManager.bindTexture(i);
this.textureHeight = EaglercraftGPU.glGetTexLevelParameteri(RealOpenGLEnums.GL_TEXTURE_2D, 0, RealOpenGLEnums.GL_TEXTURE_HEIGHT);
GlStateManager.bindTexture(j);
}
if (this.textureHeight <= 0) {
this.textureHeight = 16;
}
}
return (float) this.textureHeight;
}
public IBakedModel getBakedModel(ResourceLocation modelLocation, boolean fullModel) {
IBakedModel ibakedmodel;
Map < String, IBakedModel > map;
if (fullModel) {
ibakedmodel = this.bakedModelFull;
map = this.mapBakedModelsFull;
} else {
ibakedmodel = this.bakedModelTexture;
map = this.mapBakedModelsTexture;
}
if (modelLocation != null && map != null) {
String s = modelLocation.getResourcePath();
IBakedModel ibakedmodel1 = (IBakedModel) map.get(s);
if (ibakedmodel1 != null) {
return ibakedmodel1;
}
}
return ibakedmodel;
}
public void loadModels(ModelBakery modelBakery) {
if (this.model != null) {
loadItemModel(modelBakery, this.model);
}
if (this.type == 1 && this.mapModels != null) {
for (String s: this.mapModels.keySet()) {
String s1 = (String) this.mapModels.get(s);
String s2 = StrUtils.removePrefix(s, "model.");
if (s2.startsWith("bow") || s2.startsWith("fishing_rod") || s2.startsWith("shield")) {
loadItemModel(modelBakery, s1);
}
}
}
}
public void updateModelsFull() {
ModelManager modelmanager = Config.getModelManager();
IBakedModel ibakedmodel = modelmanager.getMissingModel();
if (this.model != null) {
ResourceLocation resourcelocation = getModelLocation(this.model);
ModelResourceLocation modelresourcelocation = new ModelResourceLocation(resourcelocation, "inventory");
this.bakedModelFull = modelmanager.getModel(modelresourcelocation);
if (this.bakedModelFull == ibakedmodel) {
Config.warn("Custom Items: Model not found " + modelresourcelocation.getResourcePath());
this.bakedModelFull = null;
}
}
if (this.type == 1 && this.mapModels != null) {
for (String s: this.mapModels.keySet()) {
String s1 = (String) this.mapModels.get(s);
String s2 = StrUtils.removePrefix(s, "model.");
if (s2.startsWith("bow") || s2.startsWith("fishing_rod") || s2.startsWith("shield")) {
ResourceLocation resourcelocation1 = getModelLocation(s1);
ModelResourceLocation modelresourcelocation1 = new ModelResourceLocation(resourcelocation1, "inventory");
IBakedModel ibakedmodel1 = modelmanager.getModel(modelresourcelocation1);
if (ibakedmodel1 == ibakedmodel) {
Config.warn("Custom Items: Model not found " + modelresourcelocation1.getResourcePath());
} else {
if (this.mapBakedModelsFull == null) {
this.mapBakedModelsFull = new HashMap();
}
this.mapBakedModelsFull.put(s2, ibakedmodel1);
}
}
}
}
}
private static void loadItemModel(ModelBakery modelBakery, String model) {
ResourceLocation resourcelocation = getModelLocation(model);
ModelResourceLocation modelresourcelocation = new ModelResourceLocation(resourcelocation, "inventory");
modelBakery.loadItemModel(resourcelocation.toString(), modelresourcelocation, resourcelocation);
}
private static void checkNull(Object obj, String msg) throws NullPointerException {
if (obj == null) {
throw new NullPointerException(msg);
}
}
private static ResourceLocation getModelLocation(String modelName) {
return new ResourceLocation(modelName);
}
}

View File

@ -0,0 +1,841 @@
package net.PeytonPlayz585.shadow;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.block.model.ItemModelGenerator;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.IResourcePack;
import net.minecraft.client.resources.model.IBakedModel;
import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.potion.Potion;
import net.minecraft.util.ResourceLocation;
public class CustomItems {
private static CustomItemProperties[][] itemProperties = (CustomItemProperties[][]) null;
private static CustomItemProperties[][] enchantmentProperties = (CustomItemProperties[][]) null;
private static Map mapPotionIds = null;
private static ItemModelGenerator itemModelGenerator = new ItemModelGenerator();
private static boolean useGlint = true;
private static boolean renderOffHand = false;
public static final int MASK_POTION_SPLASH = 16384;
public static final int MASK_POTION_NAME = 63;
public static final int MASK_POTION_EXTENDED = 64;
public static final String KEY_TEXTURE_OVERLAY = "texture.potion_overlay";
public static final String KEY_TEXTURE_SPLASH = "texture.potion_bottle_splash";
public static final String KEY_TEXTURE_DRINKABLE = "texture.potion_bottle_drinkable";
public static final String DEFAULT_TEXTURE_OVERLAY = "items/potion_overlay";
public static final String DEFAULT_TEXTURE_SPLASH = "items/potion_bottle_splash";
public static final String DEFAULT_TEXTURE_DRINKABLE = "items/potion_bottle_drinkable";
private static final int[][] EMPTY_INT2_ARRAY = new int[0][];
private static final String TYPE_POTION_NORMAL = "normal";
private static final String TYPE_POTION_SPLASH = "splash";
private static final String TYPE_POTION_LINGER = "linger";
public static void update() {
itemProperties = (CustomItemProperties[][]) null;
enchantmentProperties = (CustomItemProperties[][]) null;
useGlint = true;
if (Config.isCustomItems()) {
readCitProperties("mcpatcher/cit.properties");
IResourcePack[] airesourcepack = Config.getResourcePacks();
for (int i = airesourcepack.length - 1; i >= 0; --i) {
IResourcePack iresourcepack = airesourcepack[i];
update(iresourcepack);
}
update(Config.getDefaultResourcePack());
if (itemProperties.length <= 0) {
itemProperties = (CustomItemProperties[][]) null;
}
if (enchantmentProperties.length <= 0) {
enchantmentProperties = (CustomItemProperties[][]) null;
}
}
}
private static void readCitProperties(String fileName) {
try {
ResourceLocation resourcelocation = new ResourceLocation(fileName);
InputStream inputstream = Config.getResourceStream(resourcelocation);
if (inputstream == null) {
return;
}
Config.dbg("CustomItems: Loading " + fileName);
Properties properties = new PropertiesOrdered();
properties.load(inputstream);
inputstream.close();
useGlint = Config.parseBoolean(properties.getProperty("useGlint"), true);
} catch (FileNotFoundException var4) {
return;
} catch (IOException ioexception) {
ioexception.printStackTrace();
}
}
private static void update(IResourcePack rp) {
String[] astring = ResUtils.collectFiles(rp, (String)
"mcpatcher/cit/", (String)
".properties", (String[]) null);
Map map = makeAutoImageProperties(rp);
if (map.size() > 0) {
Set set = map.keySet();
String[] astring1 = (String[])((String[]) set.toArray(new String[set.size()]));
astring = (String[])((String[]) Config.addObjectsToArray(astring, astring1));
}
Arrays.sort((Object[]) astring);
List list = makePropertyList(itemProperties);
List list1 = makePropertyList(enchantmentProperties);
for (int i = 0; i < astring.length; ++i) {
String s = astring[i];
Config.dbg("CustomItems: " + s);
try {
CustomItemProperties customitemproperties = null;
if (map.containsKey(s)) {
customitemproperties = (CustomItemProperties) map.get(s);
}
if (customitemproperties == null) {
ResourceLocation resourcelocation = new ResourceLocation(s);
InputStream inputstream = rp.getInputStream(resourcelocation);
if (inputstream == null) {
Config.warn("CustomItems file not found: " + s);
continue;
}
Properties properties = new PropertiesOrdered();
properties.load(inputstream);
inputstream.close();
customitemproperties = new CustomItemProperties(properties, s);
}
if (customitemproperties.isValid(s)) {
addToItemList(customitemproperties, list);
addToEnchantmentList(customitemproperties, list1);
}
} catch (FileNotFoundException var11) {
Config.warn("CustomItems file not found: " + s);
} catch (Exception exception) {
exception.printStackTrace();
}
}
itemProperties = propertyListToArray(list);
enchantmentProperties = propertyListToArray(list1);
Comparator comparator = getPropertiesComparator();
for (int j = 0; j < itemProperties.length; ++j) {
CustomItemProperties[] acustomitemproperties = itemProperties[j];
if (acustomitemproperties != null) {
Arrays.sort(acustomitemproperties, comparator);
}
}
for (int k = 0; k < enchantmentProperties.length; ++k) {
CustomItemProperties[] acustomitemproperties1 = enchantmentProperties[k];
if (acustomitemproperties1 != null) {
Arrays.sort(acustomitemproperties1, comparator);
}
}
}
private static Comparator getPropertiesComparator() {
Comparator comparator = new Comparator() {
public int compare(Object o1, Object o2) {
CustomItemProperties customitemproperties = (CustomItemProperties) o1;
CustomItemProperties customitemproperties1 = (CustomItemProperties) o2;
return customitemproperties.layer != customitemproperties1.layer ? customitemproperties.layer - customitemproperties1.layer : (customitemproperties.weight != customitemproperties1.weight ? customitemproperties1.weight - customitemproperties.weight : (!customitemproperties.basePath.equals(customitemproperties1.basePath) ? customitemproperties.basePath.compareTo(customitemproperties1.basePath) : customitemproperties.name.compareTo(customitemproperties1.name)));
}
};
return comparator;
}
public static void updateIcons(TextureMap textureMap) {
for (CustomItemProperties customitemproperties: getAllProperties()) {
customitemproperties.updateIcons(textureMap);
}
}
public static void loadModels(ModelBakery modelBakery) {
for (CustomItemProperties customitemproperties: getAllProperties()) {
customitemproperties.loadModels(modelBakery);
}
}
public static void updateModels() {
for (CustomItemProperties customitemproperties: getAllProperties()) {
if (customitemproperties.type == 1) {
TextureMap texturemap = Minecraft.getMinecraft().getTextureMapBlocks();
customitemproperties.updateModelTexture(texturemap, itemModelGenerator);
customitemproperties.updateModelsFull();
}
}
}
private static List < CustomItemProperties > getAllProperties() {
List < CustomItemProperties > list = new ArrayList();
addAll(itemProperties, list);
addAll(enchantmentProperties, list);
return list;
}
private static void addAll(CustomItemProperties[][] cipsArr, List < CustomItemProperties > list) {
if (cipsArr != null) {
for (int i = 0; i < cipsArr.length; ++i) {
CustomItemProperties[] acustomitemproperties = cipsArr[i];
if (acustomitemproperties != null) {
for (int j = 0; j < acustomitemproperties.length; ++j) {
CustomItemProperties customitemproperties = acustomitemproperties[j];
if (customitemproperties != null) {
list.add(customitemproperties);
}
}
}
}
}
}
private static Map makeAutoImageProperties(IResourcePack rp) {
Map map = new HashMap();
map.putAll(makePotionImageProperties(rp, "normal", Item.getIdFromItem(Items.potionitem)));
map.putAll(makePotionImageProperties(rp, "splash", Item.getIdFromItem(Items.potionitem)));
map.putAll(makePotionImageProperties(rp, "linger", Item.getIdFromItem(Items.potionitem)));
return map;
}
private static Map makePotionImageProperties(IResourcePack rp, String type, int itemId) {
Map map = new HashMap();
String s = type + "/";
String[] astring = new String[] {
"mcpatcher/cit/potion/" + s, "mcpatcher/cit/Potion/" + s
};
String[] astring1 = new String[] {
".png"
};
String[] astring2 = ResUtils.collectFiles(rp, astring, astring1);
for (int i = 0; i < astring2.length; ++i) {
String s1 = astring2[i];
String name = StrUtils.removePrefixSuffix(s1, astring, astring1);
Properties properties = makePotionProperties(name, type, itemId, s1);
if (properties != null) {
String s3 = StrUtils.removeSuffix(s1, astring1) + ".properties";
CustomItemProperties customitemproperties = new CustomItemProperties(properties, s3);
map.put(s3, customitemproperties);
}
}
return map;
}
private static Properties makePotionProperties(String name, String type, int itemId, String path) {
if (StrUtils.endsWith(name, new String[] {
"_n",
"_s"
})) {
return null;
} else if (name.equals("empty") && type.equals("normal")) {
itemId = Item.getIdFromItem(Items.glass_bottle);
Properties properties = new PropertiesOrdered();
properties.put("type", "item");
properties.put("items", "" + itemId);
return properties;
} else {
int[] aint = (int[])((int[]) getMapPotionIds().get(name));
if (aint == null) {
Config.warn("Potion not found for image: " + path);
return null;
} else {
StringBuffer stringbuffer = new StringBuffer();
for (int i = 0; i < aint.length; ++i) {
int j = aint[i];
if (type.equals("splash")) {
j |= 16384;
}
if (i > 0) {
stringbuffer.append(" ");
}
stringbuffer.append(j);
}
int k = 16447;
if (name.equals("water") || name.equals("mundane")) {
k |= 64;
}
Properties properties1 = new PropertiesOrdered();
properties1.put("type", "item");
properties1.put("items", "" + itemId);
properties1.put("damage", "" + stringbuffer.toString());
properties1.put("damageMask", "" + k);
if (type.equals("splash")) {
properties1.put("texture.potion_bottle_splash", name);
} else {
properties1.put("texture.potion_bottle_drinkable", name);
}
return properties1;
}
}
}
private static Map getMapPotionIds() {
if (mapPotionIds == null) {
mapPotionIds = new LinkedHashMap();
mapPotionIds.put("water", getPotionId(0, 0));
mapPotionIds.put("awkward", getPotionId(0, 1));
mapPotionIds.put("thick", getPotionId(0, 2));
mapPotionIds.put("potent", getPotionId(0, 3));
mapPotionIds.put("regeneration", getPotionIds(1));
mapPotionIds.put("movespeed", getPotionIds(2));
mapPotionIds.put("fireresistance", getPotionIds(3));
mapPotionIds.put("poison", getPotionIds(4));
mapPotionIds.put("heal", getPotionIds(5));
mapPotionIds.put("nightvision", getPotionIds(6));
mapPotionIds.put("clear", getPotionId(7, 0));
mapPotionIds.put("bungling", getPotionId(7, 1));
mapPotionIds.put("charming", getPotionId(7, 2));
mapPotionIds.put("rank", getPotionId(7, 3));
mapPotionIds.put("weakness", getPotionIds(8));
mapPotionIds.put("damageboost", getPotionIds(9));
mapPotionIds.put("moveslowdown", getPotionIds(10));
mapPotionIds.put("leaping", getPotionIds(11));
mapPotionIds.put("harm", getPotionIds(12));
mapPotionIds.put("waterbreathing", getPotionIds(13));
mapPotionIds.put("invisibility", getPotionIds(14));
mapPotionIds.put("thin", getPotionId(15, 0));
mapPotionIds.put("debonair", getPotionId(15, 1));
mapPotionIds.put("sparkling", getPotionId(15, 2));
mapPotionIds.put("stinky", getPotionId(15, 3));
mapPotionIds.put("mundane", getPotionId(0, 4));
mapPotionIds.put("speed", mapPotionIds.get("movespeed"));
mapPotionIds.put("fire_resistance", mapPotionIds.get("fireresistance"));
mapPotionIds.put("instant_health", mapPotionIds.get("heal"));
mapPotionIds.put("night_vision", mapPotionIds.get("nightvision"));
mapPotionIds.put("strength", mapPotionIds.get("damageboost"));
mapPotionIds.put("slowness", mapPotionIds.get("moveslowdown"));
mapPotionIds.put("instant_damage", mapPotionIds.get("harm"));
mapPotionIds.put("water_breathing", mapPotionIds.get("waterbreathing"));
}
return mapPotionIds;
}
private static int[] getPotionIds(int baseId) {
return new int[] {
baseId,
baseId + 16,
baseId + 32,
baseId + 48
};
}
private static int[] getPotionId(int baseId, int subId) {
return new int[] {
baseId + subId * 16
};
}
private static int getPotionNameDamage(String name) {
String s = "potion." + name;
Potion[] apotion = Potion.potionTypes;
for (int i = 0; i < apotion.length; ++i) {
Potion potion = apotion[i];
if (potion != null) {
String s1 = potion.getName();
if (s.equals(s1)) {
return potion.getId();
}
}
}
return -1;
}
private static List makePropertyList(CustomItemProperties[][] propsArr) {
List list = new ArrayList();
if (propsArr != null) {
for (int i = 0; i < propsArr.length; ++i) {
CustomItemProperties[] acustomitemproperties = propsArr[i];
List list1 = null;
if (acustomitemproperties != null) {
list1 = new ArrayList(Arrays.asList(acustomitemproperties));
}
list.add(list1);
}
}
return list;
}
private static CustomItemProperties[][] propertyListToArray(List list) {
CustomItemProperties[][] acustomitemproperties = new CustomItemProperties[list.size()][];
for (int i = 0; i < list.size(); ++i) {
List list1 = (List) list.get(i);
if (list1 != null) {
CustomItemProperties[] acustomitemproperties1 = (CustomItemProperties[])((CustomItemProperties[]) list1.toArray(new CustomItemProperties[list1.size()]));
Arrays.sort(acustomitemproperties1, new CustomItemsComparator());
acustomitemproperties[i] = acustomitemproperties1;
}
}
return acustomitemproperties;
}
private static void addToItemList(CustomItemProperties cp, List itemList) {
if (cp.items != null) {
for (int i = 0; i < cp.items.length; ++i) {
int j = cp.items[i];
if (j <= 0) {
Config.warn("Invalid item ID: " + j);
} else {
addToList(cp, itemList, j);
}
}
}
}
private static void addToEnchantmentList(CustomItemProperties cp, List enchantmentList) {
if (cp.type == 2) {
if (cp.enchantmentIds != null) {
for (int i = 0; i < 256; ++i) {
if (cp.enchantmentIds.isInRange(i)) {
addToList(cp, enchantmentList, i);
}
}
}
}
}
private static void addToList(CustomItemProperties cp, List list, int id) {
while (id >= list.size()) {
list.add(null);
}
List list1 = (List) list.get(id);
if (list1 == null) {
list1 = new ArrayList();
list.set(id, list1);
}
list1.add(cp);
}
public static IBakedModel getCustomItemModel(ItemStack itemStack, IBakedModel model, ResourceLocation modelLocation, boolean fullModel) {
if (!fullModel && model.isGui3d()) {
return model;
} else if (itemProperties == null) {
return model;
} else {
CustomItemProperties customitemproperties = getCustomItemProperties(itemStack, 1);
if (customitemproperties == null) {
return model;
} else {
IBakedModel ibakedmodel = customitemproperties.getBakedModel(modelLocation, fullModel);
return ibakedmodel != null ? ibakedmodel : model;
}
}
}
public static boolean bindCustomArmorTexture(ItemStack itemStack, int layer, String overlay) {
if (itemProperties == null) {
return false;
} else {
ResourceLocation resourcelocation = getCustomArmorLocation(itemStack, layer, overlay);
if (resourcelocation == null) {
return false;
} else {
Config.getTextureManager().bindTexture(resourcelocation);
return true;
}
}
}
private static ResourceLocation getCustomArmorLocation(ItemStack itemStack, int layer, String overlay) {
CustomItemProperties customitemproperties = getCustomItemProperties(itemStack, 3);
if (customitemproperties == null) {
return null;
} else if (customitemproperties.mapTextureLocations == null) {
return customitemproperties.textureLocation;
} else {
Item item = itemStack.getItem();
if (!(item instanceof ItemArmor)) {
return null;
} else {
ItemArmor itemarmor = (ItemArmor) item;
String s = itemarmor.getArmorMaterial().getName();
StringBuffer stringbuffer = new StringBuffer();
stringbuffer.append("texture.");
stringbuffer.append(s);
stringbuffer.append("_layer_");
stringbuffer.append(layer);
if (overlay != null) {
stringbuffer.append("_");
stringbuffer.append(overlay);
}
String s1 = stringbuffer.toString();
ResourceLocation resourcelocation = (ResourceLocation) customitemproperties.mapTextureLocations.get(s1);
return resourcelocation == null ? customitemproperties.textureLocation : resourcelocation;
}
}
}
private static CustomItemProperties getCustomItemProperties(ItemStack itemStack, int type) {
if (itemProperties == null) {
return null;
} else if (itemStack == null) {
return null;
} else {
Item item = itemStack.getItem();
int i = Item.getIdFromItem(item);
if (i >= 0 && i < itemProperties.length) {
CustomItemProperties[] acustomitemproperties = itemProperties[i];
if (acustomitemproperties != null) {
for (int j = 0; j < acustomitemproperties.length; ++j) {
CustomItemProperties customitemproperties = acustomitemproperties[j];
if (customitemproperties.type == type && matchesProperties(customitemproperties, itemStack, (int[][]) null)) {
return customitemproperties;
}
}
}
}
return null;
}
}
private static boolean matchesProperties(CustomItemProperties cip, ItemStack itemStack, int[][] enchantmentIdLevels) {
Item item = itemStack.getItem();
if (cip.damage != null) {
int i = itemStack.getItemDamage();
if (cip.damageMask != 0) {
i &= cip.damageMask;
}
if (cip.damagePercent) {
int j = item.getMaxDamage();
i = (int)((double)(i * 100) / (double) j);
}
if (!cip.damage.isInRange(i)) {
return false;
}
}
if (cip.stackSize != null && !cip.stackSize.isInRange(itemStack.stackSize)) {
return false;
} else {
int[][] aint = enchantmentIdLevels;
if (cip.enchantmentIds != null) {
if (enchantmentIdLevels == null) {
aint = getEnchantmentIdLevels(itemStack);
}
boolean flag = false;
for (int k = 0; k < aint.length; ++k) {
int l = aint[k][0];
if (cip.enchantmentIds.isInRange(l)) {
flag = true;
break;
}
}
if (!flag) {
return false;
}
}
if (cip.enchantmentLevels != null) {
if (aint == null) {
aint = getEnchantmentIdLevels(itemStack);
}
boolean flag1 = false;
for (int i1 = 0; i1 < aint.length; ++i1) {
int k1 = aint[i1][1];
if (cip.enchantmentLevels.isInRange(k1)) {
flag1 = true;
break;
}
}
if (!flag1) {
return false;
}
}
if (cip.nbtTagValues != null) {
NBTTagCompound nbttagcompound = itemStack.getTagCompound();
for (int j1 = 0; j1 < cip.nbtTagValues.length; ++j1) {
NbtTagValue nbttagvalue = cip.nbtTagValues[j1];
if (!nbttagvalue.matches(nbttagcompound)) {
return false;
}
}
}
if (cip.hand != 0) {
if (cip.hand == 1 && renderOffHand) {
return false;
}
if (cip.hand == 2 && !renderOffHand) {
return false;
}
}
return true;
}
}
private static int[][] getEnchantmentIdLevels(ItemStack itemStack) {
Item item = itemStack.getItem();
NBTTagList nbttaglist = item == Items.enchanted_book ? Items.enchanted_book.getEnchantments(itemStack) : itemStack.getEnchantmentTagList();
if (nbttaglist != null && nbttaglist.tagCount() > 0) {
int[][] aint = new int[nbttaglist.tagCount()][2];
for (int i = 0; i < nbttaglist.tagCount(); ++i) {
NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
int j = nbttagcompound.getShort("id");
int k = nbttagcompound.getShort("lvl");
aint[i][0] = j;
aint[i][1] = k;
}
return aint;
} else {
return EMPTY_INT2_ARRAY;
}
}
public static boolean renderCustomEffect(RenderItem renderItem, ItemStack itemStack, IBakedModel model) {
if (enchantmentProperties == null) {
return false;
} else if (itemStack == null) {
return false;
} else {
int[][] aint = getEnchantmentIdLevels(itemStack);
if (aint.length <= 0) {
return false;
} else {
Set set = null;
boolean flag = false;
TextureManager texturemanager = Config.getTextureManager();
for (int i = 0; i < aint.length; ++i) {
int j = aint[i][0];
if (j >= 0 && j < enchantmentProperties.length) {
CustomItemProperties[] acustomitemproperties = enchantmentProperties[j];
if (acustomitemproperties != null) {
for (int k = 0; k < acustomitemproperties.length; ++k) {
CustomItemProperties customitemproperties = acustomitemproperties[k];
if (set == null) {
set = new HashSet();
}
if (set.add(Integer.valueOf(j)) && matchesProperties(customitemproperties, itemStack, aint) && customitemproperties.textureLocation != null) {
texturemanager.bindTexture(customitemproperties.textureLocation);
float f = customitemproperties.getTextureWidth(texturemanager);
if (!flag) {
flag = true;
GlStateManager.depthMask(false);
GlStateManager.depthFunc(514);
GlStateManager.disableLighting();
GlStateManager.matrixMode(5890);
}
Blender.setupBlend(customitemproperties.blend, 1.0F);
GlStateManager.pushMatrix();
GlStateManager.scale(f / 2.0F, f / 2.0F, f / 2.0F);
float f1 = customitemproperties.speed * (float)(Minecraft.getSystemTime() % 3000L) / 3000.0F / 8.0F;
GlStateManager.translate(f1, 0.0F, 0.0F);
GlStateManager.rotate(customitemproperties.rotation, 0.0F, 0.0F, 1.0F);
renderItem.renderModel(model, -1);
GlStateManager.popMatrix();
}
}
}
}
}
if (flag) {
GlStateManager.enableAlpha();
GlStateManager.enableBlend();
GlStateManager.blendFunc(770, 771);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.matrixMode(5888);
GlStateManager.enableLighting();
GlStateManager.depthFunc(515);
GlStateManager.depthMask(true);
texturemanager.bindTexture(TextureMap.locationBlocksTexture);
}
return flag;
}
}
}
public static boolean renderCustomArmorEffect(EntityLivingBase entity, ItemStack itemStack, ModelBase model, float limbSwing, float prevLimbSwing, float partialTicks, float timeLimbSwing, float yaw, float pitch, float scale) {
if (enchantmentProperties == null) {
return false;
} else if (Config.isShaders()) {
return false;
} else if (itemStack == null) {
return false;
} else {
int[][] aint = getEnchantmentIdLevels(itemStack);
if (aint.length <= 0) {
return false;
} else {
Set set = null;
boolean flag = false;
TextureManager texturemanager = Config.getTextureManager();
for (int i = 0; i < aint.length; ++i) {
int j = aint[i][0];
if (j >= 0 && j < enchantmentProperties.length) {
CustomItemProperties[] acustomitemproperties = enchantmentProperties[j];
if (acustomitemproperties != null) {
for (int k = 0; k < acustomitemproperties.length; ++k) {
CustomItemProperties customitemproperties = acustomitemproperties[k];
if (set == null) {
set = new HashSet();
}
if (set.add(Integer.valueOf(j)) && matchesProperties(customitemproperties, itemStack, aint) && customitemproperties.textureLocation != null) {
texturemanager.bindTexture(customitemproperties.textureLocation);
float f = customitemproperties.getTextureWidth(texturemanager);
if (!flag) {
flag = true;
GlStateManager.enableBlend();
GlStateManager.depthFunc(514);
GlStateManager.depthMask(false);
}
Blender.setupBlend(customitemproperties.blend, 1.0F);
GlStateManager.disableLighting();
GlStateManager.matrixMode(5890);
GlStateManager.loadIdentity();
GlStateManager.rotate(customitemproperties.rotation, 0.0F, 0.0F, 1.0F);
float f1 = f / 8.0F;
GlStateManager.scale(f1, f1 / 2.0F, f1);
float f2 = customitemproperties.speed * (float)(Minecraft.getSystemTime() % 3000L) / 3000.0F / 8.0F;
GlStateManager.translate(0.0F, f2, 0.0F);
GlStateManager.matrixMode(5888);
model.render(entity, limbSwing, prevLimbSwing, timeLimbSwing, yaw, pitch, scale);
}
}
}
}
}
if (flag) {
GlStateManager.enableAlpha();
GlStateManager.enableBlend();
GlStateManager.blendFunc(770, 771);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.matrixMode(5890);
GlStateManager.loadIdentity();
GlStateManager.matrixMode(5888);
GlStateManager.enableLighting();
GlStateManager.depthMask(true);
GlStateManager.depthFunc(515);
GlStateManager.disableBlend();
}
return flag;
}
}
}
public static boolean isUseGlint() {
return useGlint;
}
}

View File

@ -0,0 +1,11 @@
package net.PeytonPlayz585.shadow;
import java.util.Comparator;
public class CustomItemsComparator implements Comparator {
public int compare(Object o1, Object o2) {
CustomItemProperties customitemproperties = (CustomItemProperties)o1;
CustomItemProperties customitemproperties1 = (CustomItemProperties)o2;
return customitemproperties.weight != customitemproperties1.weight ? customitemproperties1.weight - customitemproperties.weight : (!Config.equals(customitemproperties.basePath, customitemproperties1.basePath) ? customitemproperties.basePath.compareTo(customitemproperties1.basePath) : customitemproperties.name.compareTo(customitemproperties1.name));
}
}

View File

@ -0,0 +1,30 @@
package net.PeytonPlayz585.shadow;
public class EntityArrays {
private static final String[][] JAVA_CTRL_CHARS_ESCAPE = {{"\b", "\\b"}, {"\n", "\\n"}, {"\t", "\\t"}, {"\f", "\\f"}, {"\r", "\\r"}};
private static final String[][] JAVA_CTRL_CHARS_UNESCAPE = invert(JAVA_CTRL_CHARS_ESCAPE);
/**
* Used to invert an escape array into an unescape array
* @param array String[][] to be inverted
* @return String[][] inverted array
*/
public static String[][] invert(final String[][] array) {
final String[][] newarray = new String[array.length][2];
for (int i = 0; i<array.length; i++) {
newarray[i][0] = array[i][1];
newarray[i][1] = array[i][0];
}
return newarray;
}
/**
* Reverse of {@link #JAVA_CTRL_CHARS_ESCAPE()} for unescaping purposes.
* @return the mapping table
*/
public static String[][] JAVA_CTRL_CHARS_UNESCAPE() {
return JAVA_CTRL_CHARS_UNESCAPE.clone();
}
}

View File

@ -11,7 +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.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.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};
public GuiQualitySettingsOF(GuiScreen p_i53_1_, GameSettings p_i53_2_) {

View File

@ -0,0 +1,5 @@
package net.PeytonPlayz585.shadow;
public interface IParserInt {
int parse(String var1, int var2);
}

View File

@ -0,0 +1,95 @@
/*
* 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;
import java.io.IOException;
import java.io.Writer;
import java.util.HashMap;
import java.util.HashSet;
/**
* Translates a value using a lookup table.
*
* @since 3.0
* @deprecated As of 3.6, use Apache Commons Text
* <a href="https://commons.apache.org/proper/commons-text/javadocs/api-release/org/apache/commons/text/translate/LookupTranslator.html">
* LookupTranslator</a> instead
*/
@Deprecated
public class LookupTranslator extends CharSequenceTranslator {
private final HashMap<String, String> lookupMap;
private final HashSet<Character> prefixSet;
private final int shortest;
private final int longest;
/**
* Define the lookup table to be used in translation
*
* Note that, as of Lang 3.1, the key to the lookup table is converted to a
* java.lang.String. This is because we need the key to support hashCode and
* equals(Object), allowing it to be the key for a HashMap. See LANG-882.
*
* @param lookup CharSequence[][] table of size [*][2]
*/
public LookupTranslator(final CharSequence[]... lookup) {
lookupMap = new HashMap<>();
prefixSet = new HashSet<>();
int tmpShortest = Integer.MAX_VALUE;
int tmpLongest = 0;
if (lookup != null) {
for (final CharSequence[] seq : lookup) {
this.lookupMap.put(seq[0].toString(), seq[1].toString());
this.prefixSet.add(seq[0].charAt(0));
final int sz = seq[0].length();
if (sz < tmpShortest) {
tmpShortest = sz;
}
if (sz > tmpLongest) {
tmpLongest = sz;
}
}
}
this.shortest = tmpShortest;
this.longest = tmpLongest;
}
/**
* {@inheritDoc}
*/
@Override
public int translate(final CharSequence input, final int index, final Writer out) throws IOException {
// check if translation exists for the input at position index
if (prefixSet.contains(input.charAt(index))) {
int max = longest;
if (index + longest > input.length()) {
max = input.length() - index;
}
// implement greedy algorithm by trying maximum match first
for (int i = max; i >= shortest; i--) {
final CharSequence subSeq = input.subSequence(index, index + i);
final String result = lookupMap.get(subSeq.toString());
if (result != null) {
out.write(result);
return i;
}
}
}
return 0;
}
}

View File

@ -0,0 +1,214 @@
package net.PeytonPlayz585.shadow;
import java.util.Arrays;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagByte;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagDouble;
import net.minecraft.nbt.NBTTagFloat;
import net.minecraft.nbt.NBTTagInt;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagLong;
import net.minecraft.nbt.NBTTagShort;
import net.minecraft.nbt.NBTTagString;
public class NbtTagValue {
private String[] parents = null;
private String name = null;
private int type = 0;
private String value = null;
private static final int TYPE_TEXT = 0;
private static final int TYPE_PATTERN = 1;
private static final int TYPE_IPATTERN = 2;
private static final int TYPE_REGEX = 3;
private static final int TYPE_IREGEX = 4;
private static final String PREFIX_PATTERN = "pattern:";
private static final String PREFIX_IPATTERN = "ipattern:";
private static final String PREFIX_REGEX = "regex:";
private static final String PREFIX_IREGEX = "iregex:";
public NbtTagValue(String p_i69_1_, String p_i69_2_) {
String[] astring = Config.tokenize(p_i69_1_, ".");
this.parents = (String[]) Arrays.copyOfRange(astring, 0, astring.length - 1);
this.name = astring[astring.length - 1];
if (p_i69_2_.startsWith("pattern:")) {
this.type = 1;
p_i69_2_ = p_i69_2_.substring("pattern:".length());
} else if (p_i69_2_.startsWith("ipattern:")) {
this.type = 2;
p_i69_2_ = p_i69_2_.substring("ipattern:".length()).toLowerCase();
} else if (p_i69_2_.startsWith("regex:")) {
this.type = 3;
p_i69_2_ = p_i69_2_.substring("regex:".length());
} else if (p_i69_2_.startsWith("iregex:")) {
this.type = 4;
p_i69_2_ = p_i69_2_.substring("iregex:".length()).toLowerCase();
} else {
this.type = 0;
}
p_i69_2_ = StringEscapeUtils.unescapeJava(p_i69_2_);
this.value = p_i69_2_;
}
public boolean matches(NBTTagCompound p_matches_1_) {
if (p_matches_1_ == null) {
return false;
} else {
NBTBase nbtbase = p_matches_1_;
for (int i = 0; i < this.parents.length; ++i) {
String s = this.parents[i];
nbtbase = getChildTag(nbtbase, s);
if (nbtbase == null) {
return false;
}
}
if (this.name.equals("*")) {
return this.matchesAnyChild(nbtbase);
} else {
nbtbase = getChildTag(nbtbase, this.name);
if (nbtbase == null) {
return false;
} else if (this.matches(nbtbase)) {
return true;
} else {
return false;
}
}
}
}
private boolean matchesAnyChild(NBTBase p_matchesAnyChild_1_) {
if (p_matchesAnyChild_1_ instanceof NBTTagCompound) {
NBTTagCompound nbttagcompound = (NBTTagCompound) p_matchesAnyChild_1_;
for (String s: nbttagcompound.getKeySet()) {
NBTBase nbtbase = nbttagcompound.getTag(s);
if (this.matches(nbtbase)) {
return true;
}
}
}
if (p_matchesAnyChild_1_ instanceof NBTTagList) {
NBTTagList nbttaglist = (NBTTagList) p_matchesAnyChild_1_;
int i = nbttaglist.tagCount();
for (int j = 0; j < i; ++j) {
NBTBase nbtbase1 = nbttaglist.get(j);
if (this.matches(nbtbase1)) {
return true;
}
}
}
return false;
}
private static NBTBase getChildTag(NBTBase p_getChildTag_0_, String p_getChildTag_1_) {
if (p_getChildTag_0_ instanceof NBTTagCompound) {
NBTTagCompound nbttagcompound = (NBTTagCompound) p_getChildTag_0_;
return nbttagcompound.getTag(p_getChildTag_1_);
} else if (p_getChildTag_0_ instanceof NBTTagList) {
NBTTagList nbttaglist = (NBTTagList) p_getChildTag_0_;
int i = Config.parseInt(p_getChildTag_1_, -1);
return i < 0 ? null : nbttaglist.get(i);
} else {
return null;
}
}
private boolean matches(NBTBase p_matches_1_) {
if (p_matches_1_ == null) {
return false;
} else {
String s = getValue(p_matches_1_);
if (s == null) {
return false;
} else {
switch (this.type) {
case 0:
return s.equals(this.value);
case 1:
return this.matchesPattern(s, this.value);
case 2:
return this.matchesPattern(s.toLowerCase(), this.value);
case 3:
return this.matchesRegex(s, this.value);
case 4:
return this.matchesRegex(s.toLowerCase(), this.value);
default:
throw new IllegalArgumentException("Unknown NbtTagValue type: " + this.type);
}
}
}
}
private boolean matchesPattern(String p_matchesPattern_1_, String p_matchesPattern_2_) {
return StrUtils.equalsMask(p_matchesPattern_1_, p_matchesPattern_2_, '*', '?');
}
private boolean matchesRegex(String p_matchesRegex_1_, String p_matchesRegex_2_) {
return p_matchesRegex_1_.matches(p_matchesRegex_2_);
}
private static String getValue(NBTBase p_getValue_0_) {
if (p_getValue_0_ == null) {
return null;
} else if (p_getValue_0_ instanceof NBTTagString) {
NBTTagString nbttagstring = (NBTTagString) p_getValue_0_;
return nbttagstring.getString();
} else if (p_getValue_0_ instanceof NBTTagInt) {
NBTTagInt nbttagint = (NBTTagInt) p_getValue_0_;
return Integer.toString(nbttagint.getInt());
} else if (p_getValue_0_ instanceof NBTTagByte) {
NBTTagByte nbttagbyte = (NBTTagByte) p_getValue_0_;
return Byte.toString(nbttagbyte.getByte());
} else if (p_getValue_0_ instanceof NBTTagShort) {
NBTTagShort nbttagshort = (NBTTagShort) p_getValue_0_;
return Short.toString(nbttagshort.getShort());
} else if (p_getValue_0_ instanceof NBTTagLong) {
NBTTagLong nbttaglong = (NBTTagLong) p_getValue_0_;
return Long.toString(nbttaglong.getLong());
} else if (p_getValue_0_ instanceof NBTTagFloat) {
NBTTagFloat nbttagfloat = (NBTTagFloat) p_getValue_0_;
return Float.toString(nbttagfloat.getFloat());
} else if (p_getValue_0_ instanceof NBTTagDouble) {
NBTTagDouble nbttagdouble = (NBTTagDouble) p_getValue_0_;
return Double.toString(nbttagdouble.getDouble());
} else {
return p_getValue_0_.toString();
}
}
public String toString() {
StringBuffer stringbuffer = new StringBuffer();
for (int i = 0; i < this.parents.length; ++i) {
String s = this.parents[i];
if (i > 0) {
stringbuffer.append(".");
}
stringbuffer.append(s);
}
if (stringbuffer.length() > 0) {
stringbuffer.append(".");
}
stringbuffer.append(this.name);
stringbuffer.append(" = ");
stringbuffer.append(this.value);
return stringbuffer.toString();
}
}

View File

@ -0,0 +1,83 @@
/*
* 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;
import java.io.IOException;
import java.io.Writer;
/**
* Translate escaped octal Strings back to their octal values.
*
* For example, "\45" should go back to being the specific value (a %).
*
* Note that this currently only supports the viable range of octal for Java; namely
* 1 to 377. This is because parsing Java is the main use case.
*
* @since 3.0
* @deprecated As of 3.6, use Apache Commons Text
* <a href="https://commons.apache.org/proper/commons-text/javadocs/api-release/org/apache/commons/text/translate/OctalUnescaper.html">
* OctalUnescaper</a> instead
*/
@Deprecated
public class OctalUnescaper extends CharSequenceTranslator {
/**
* Checks if the given char is an octal digit. Octal digits are the character representations of the digits 0 to 7.
* @param ch the char to check
* @return true if the given char is the character representation of one of the digits from 0 to 7
*/
private boolean isOctalDigit(final char ch) {
return ch >= '0' && ch <= '7';
}
/**
* Checks if the given char is the character representation of one of the digit from 0 to 3.
* @param ch the char to check
* @return true if the given char is the character representation of one of the digits from 0 to 3
*/
private boolean isZeroToThree(final char ch) {
return ch >= '0' && ch <= '3';
}
/**
* {@inheritDoc}
*/
@Override
public int translate(final CharSequence input, final int index, final Writer out) throws IOException {
final int remaining = input.length() - index - 1; // how many characters left, ignoring the first \
final StringBuilder builder = new StringBuilder();
if (input.charAt(index) == '\\' && remaining > 0 && isOctalDigit(input.charAt(index + 1)) ) {
final int next = index + 1;
final int next2 = index + 2;
final int next3 = index + 3;
// we know this is good as we checked it in the if block above
builder.append(input.charAt(next));
if (remaining > 1 && isOctalDigit(input.charAt(next2))) {
builder.append(input.charAt(next2));
if (remaining > 2 && isZeroToThree(input.charAt(next)) && isOctalDigit(input.charAt(next3))) {
builder.append(input.charAt(next3));
}
}
out.write( Integer.parseInt(builder.toString(), 8) );
return 1 + builder.length();
}
return 0;
}
}

View File

@ -0,0 +1,10 @@
package net.PeytonPlayz585.shadow;
import net.minecraft.enchantment.Enchantment;
public class ParserEnchantmentId implements IParserInt {
public int parse(String str, int defVal) {
Enchantment enchantment = Enchantment.getEnchantmentByLocation(str);
return enchantment == null ? defVal : enchantment.effectId;
}
}

View File

@ -0,0 +1,26 @@
package net.PeytonPlayz585.shadow;
import java.util.Collections;
import java.util.Enumeration;
import java.util.LinkedHashSet;
import java.util.Properties;
import java.util.Set;
public class PropertiesOrdered extends Properties {
private Set<Object> keysOrdered = new LinkedHashSet();
public synchronized Object put(Object key, Object value) {
this.keysOrdered.add(key);
return super.put(key, value);
}
public Set<Object> keySet() {
Set<Object> set = super.keySet();
this.keysOrdered.retainAll(set);
return Collections.<Object>unmodifiableSet(this.keysOrdered);
}
public synchronized Enumeration<Object> keys() {
return Collections.<Object>enumeration(this.keySet());
}
}

View File

@ -0,0 +1,109 @@
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.vfs2.VFile2;
import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerFolderResourcePack;
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<String>();
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;
if(file1 == null) {
return new String[0];
}
String path = new VFile2(EaglerFolderResourcePack.RESOURCE_PACKS, file1).getPath();
return collectFiles(new VFile2(path), "", p_collectFiles_1_, p_collectFiles_2_, file1);
}
}
private static String[] collectFilesFixed(IResourcePack p_collectFilesFixed_0_, String[] p_collectFilesFixed_1_) {
if (p_collectFilesFixed_1_ == null) {
return new String[0];
} else {
List<String> list = new ArrayList<String>();
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[] collectFiles(VFile2 p_collectFilesFolder_0_, String p_collectFilesFolder_1_, String[] p_collectFilesFolder_2_, String[] p_collectFilesFolder_3_, String texturePackName) {
List<String> list = new ArrayList<String>();
String s = "assets/minecraft/";
List<String> afile = p_collectFilesFolder_0_.listFilenames(true);
if (afile == null || afile.isEmpty()) {
return new String[0];
} else {
for (int i = 0; i < afile.size(); ++i) {
VFile2 file1 = new VFile2(afile.get(i));
if (file1.getPath().contains(".")) {
String s3 = p_collectFilesFolder_1_ + file1.getPath();
s3 = s3.replace("resourcepacks/", "");
s3 = s3.replace(texturePackName, "");
if(s3.startsWith("/")) {
s3 = s3.substring(1);
}
if (s3.startsWith(s)) {
s3 = s3.substring(s.length());
if (StrUtils.startsWith(s3, p_collectFilesFolder_2_) && StrUtils.endsWith(s3, p_collectFilesFolder_3_)) {
list.add(s3);
}
}
}
}
String[] astring1 = (String[])((String[])list.toArray(new String[list.size()]));
return astring1;
}
}
}

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

@ -0,0 +1,19 @@
package net.PeytonPlayz585.shadow;
public class StringEscapeUtils {
public static final CharSequenceTranslator UNESCAPE_JAVA = new AggregateTranslator(new OctalUnescaper(), /* .between('\1', '\377'), */ new UnicodeUnescaper(), new LookupTranslator(EntityArrays.JAVA_CTRL_CHARS_UNESCAPE()), new LookupTranslator( new String[][] {{"\\\\", "\\"}, {"\\\"", "\""}, {"\\'", "'"}, {"\\", ""} }));
/**
* Unescapes any Java literals found in the {@link String}.
* For example, it will turn a sequence of {@code '\'} and
* {@code 'n'} into a newline character, unless the {@code '\'}
* is preceded by another {@code '\'}.
*
* @param input the {@link String} to unescape, may be null
* @return a new unescaped {@link String}, {@code null} if null string input
*/
public static final String unescapeJava(final String input) {
return UNESCAPE_JAVA.translate(input);
}
}

View File

@ -98,6 +98,7 @@ public class TextureUtils {
BetterGrass.update();
BetterSnow.update();
CustomSky.update();
CustomItems.updateModels();
//SmartLeaves.updateLeavesModels();
Config.getTextureManager().tick();
}

View File

@ -0,0 +1,68 @@
/*
* 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;
import java.io.IOException;
import java.io.Writer;
/**
* Translates escaped Unicode values of the form \\u+\d\d\d\d back to
* Unicode. It supports multiple 'u' characters and will work with or
* without the +.
*
* @since 3.0
* @deprecated As of 3.6, use Apache Commons Text
* <a href="https://commons.apache.org/proper/commons-text/javadocs/api-release/org/apache/commons/text/translate/UnicodeUnescaper.html">
* UnicodeUnescaper</a> instead
*/
@Deprecated
public class UnicodeUnescaper extends CharSequenceTranslator {
/**
* {@inheritDoc}
*/
@Override
public int translate(final CharSequence input, final int index, final Writer out) throws IOException {
if (input.charAt(index) == '\\' && index + 1 < input.length() && input.charAt(index + 1) == 'u') {
// consume optional additional 'u' chars
int i = 2;
while (index + i < input.length() && input.charAt(index + i) == 'u') {
i++;
}
if (index + i < input.length() && input.charAt(index + i) == '+') {
i++;
}
if (index + i + 4 <= input.length()) {
// Get 4 hex digits
final CharSequence unicode = input.subSequence(index + i, index + i + 4);
try {
final int value = Integer.parseInt(unicode.toString(), 16);
out.write((char) value);
} catch (final NumberFormatException nfe) {
throw new IllegalArgumentException("Unable to parse unicode value: " + unicode, nfe);
}
return i + 4;
}
throw new IllegalArgumentException("Less than 4 hex digits in unicode value: '" + input.subSequence(index, input.length())
+ "' due to end of CharSequence");
}
return 0;
}
}

View File

@ -0,0 +1,47 @@
package net.PeytonPlayz585.shadow.reflect;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import net.PeytonPlayz585.shadow.Config;
import net.minecraft.client.Minecraft;
public class FieldLocatorActionKeyF3 implements IFieldLocator {
public Field getField() {
Class oclass = Minecraft.class;
Field field = this.getFieldRenderChunksMany();
if (field == null) {
Config.log("(Reflector) Field not present: " + oclass.getName() + ".actionKeyF3 (field renderChunksMany not found)");
return null;
} else {
Field field1 = ReflectorRaw.getFieldAfter(Minecraft.class, field, Boolean.TYPE, 0);
if (field1 == null) {
Config.log("(Reflector) Field not present: " + oclass.getName() + ".actionKeyF3");
return null;
} else {
return field1;
}
}
}
private Field getFieldRenderChunksMany() {
Minecraft minecraft = Minecraft.getMinecraft();
boolean flag = minecraft.renderChunksMany;
Field[] afield = Minecraft.class.getDeclaredFields();
minecraft.renderChunksMany = true;
Field[] afield1 = ReflectorRaw.getFields(minecraft, afield, Boolean.TYPE, Boolean.TRUE);
minecraft.renderChunksMany = false;
Field[] afield2 = ReflectorRaw.getFields(minecraft, afield, Boolean.TYPE, Boolean.FALSE);
minecraft.renderChunksMany = flag;
Set < Field > set = new HashSet(Arrays.asList(afield1));
Set < Field > set1 = new HashSet(Arrays.asList(afield2));
Set < Field > set2 = new HashSet(set);
set2.retainAll(set1);
Field[] afield3 = (Field[])((Field[]) set2.toArray(new Field[set2.size()]));
return afield3.length != 1 ? null : afield3[0];
}
}

View File

@ -0,0 +1,15 @@
package net.PeytonPlayz585.shadow.reflect;
import java.lang.reflect.Field;
public class FieldLocatorFixed implements IFieldLocator {
private Field field;
public FieldLocatorFixed(Field field) {
this.field = field;
}
public Field getField() {
return this.field;
}
}

View File

@ -0,0 +1,56 @@
package net.PeytonPlayz585.shadow.reflect;
import java.lang.reflect.Field;
import net.PeytonPlayz585.shadow.Config;
public class FieldLocatorName implements IFieldLocator {
private ReflectorClass reflectorClass = null;
private String targetFieldName = null;
public FieldLocatorName(ReflectorClass reflectorClass, String targetFieldName) {
this.reflectorClass = reflectorClass;
this.targetFieldName = targetFieldName;
}
public Field getField() {
Class oclass = this.reflectorClass.getTargetClass();
if (oclass == null) {
return null;
} else {
try {
Field field = this.getDeclaredField(oclass, this.targetFieldName);
field.setAccessible(true);
return field;
} catch (NoSuchFieldException var3) {
Config.log("(Reflector) Field not present: " + oclass.getName() + "." + this.targetFieldName);
return null;
} catch (SecurityException securityexception) {
securityexception.printStackTrace();
return null;
} catch (Throwable throwable) {
throwable.printStackTrace();
return null;
}
}
}
private Field getDeclaredField(Class cls, String name) throws NoSuchFieldException {
Field[] afield = cls.getDeclaredFields();
for (int i = 0; i < afield.length; ++i) {
Field field = afield[i];
if (field.getName().equals(name)) {
return field;
}
}
if (cls == Object.class) {
throw new NoSuchFieldException(name);
} else {
return this.getDeclaredField(cls.getSuperclass(), name);
}
}
}

View File

@ -0,0 +1,58 @@
package net.PeytonPlayz585.shadow.reflect;
import java.lang.reflect.Field;
import net.PeytonPlayz585.shadow.Config;
public class FieldLocatorType implements IFieldLocator {
private ReflectorClass reflectorClass;
private Class targetFieldType;
private int targetFieldIndex;
public FieldLocatorType(ReflectorClass reflectorClass, Class targetFieldType) {
this(reflectorClass, targetFieldType, 0);
}
public FieldLocatorType(ReflectorClass reflectorClass, Class targetFieldType, int targetFieldIndex) {
this.reflectorClass = null;
this.targetFieldType = null;
this.reflectorClass = reflectorClass;
this.targetFieldType = targetFieldType;
this.targetFieldIndex = targetFieldIndex;
}
public Field getField() {
Class oclass = this.reflectorClass.getTargetClass();
if (oclass == null) {
return null;
} else {
try {
Field[] afield = oclass.getDeclaredFields();
int i = 0;
for (int j = 0; j < afield.length; ++j) {
Field field = afield[j];
if (field.getType() == this.targetFieldType) {
if (i == this.targetFieldIndex) {
field.setAccessible(true);
return field;
}
++i;
}
}
Config.log("(Reflector) Field not present: " + oclass.getName() + ".(type: " + this.targetFieldType + ", index: " + this.targetFieldIndex + ")");
return null;
} catch (SecurityException securityexception) {
securityexception.printStackTrace();
return null;
} catch (Throwable throwable) {
throwable.printStackTrace();
return null;
}
}
}
}

View File

@ -0,0 +1,46 @@
package net.PeytonPlayz585.shadow.reflect;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import net.PeytonPlayz585.shadow.Config;
public class FieldLocatorTypes implements IFieldLocator {
private Field field = null;
public FieldLocatorTypes(Class cls, Class[] preTypes, Class type, Class[] postTypes, String errorName) {
Field[] afield = cls.getDeclaredFields();
List < Class > list = new ArrayList();
for (int i = 0; i < afield.length; ++i) {
Field field = afield[i];
list.add(field.getType());
}
List < Class > list1 = new ArrayList();
list1.addAll(Arrays. < Class > asList(preTypes));
list1.add(type);
list1.addAll(Arrays. < Class > asList(postTypes));
int l = Collections.indexOfSubList(list, list1);
if (l < 0) {
Config.log("(Reflector) Field not found: " + errorName);
} else {
int j = Collections.indexOfSubList(list.subList(l + 1, list.size()), list1);
if (j >= 0) {
Config.log("(Reflector) More than one match found for field: " + errorName);
} else {
int k = l + preTypes.length;
this.field = afield[k];
}
}
}
public Field getField() {
return this.field;
}
}

View File

@ -0,0 +1,7 @@
package net.PeytonPlayz585.shadow.reflect;
import java.lang.reflect.Field;
public interface IFieldLocator {
Field getField();
}

View File

@ -0,0 +1,5 @@
package net.PeytonPlayz585.shadow.reflect;
public interface IResolvable {
void resolve();
}

View File

@ -0,0 +1,551 @@
package net.PeytonPlayz585.shadow.reflect;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import net.PeytonPlayz585.shadow.ArrayUtils;
import net.PeytonPlayz585.shadow.Config;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.DefaultResourcePack;
public class Reflector {
private static final Logger LOGGER = LogManager.getLogger();
public static ReflectorClass Minecraft = new ReflectorClass(Minecraft.class);
public static ReflectorField Minecraft_defaultResourcePack = new ReflectorField(Minecraft, DefaultResourcePack.class);
public static void callVoid(ReflectorMethod refMethod, Object...params) {
try {
Method method = refMethod.getTargetMethod();
if (method == null) {
return;
}
method.invoke((Object) null, params);
} catch (Throwable throwable) {
handleException(throwable, (Object) null, refMethod, params);
}
}
public static boolean callBoolean(ReflectorMethod refMethod, Object...params) {
try {
Method method = refMethod.getTargetMethod();
if (method == null) {
return false;
} else {
Boolean obool = (Boolean) method.invoke((Object) null, params);
return obool.booleanValue();
}
} catch (Throwable throwable) {
handleException(throwable, (Object) null, refMethod, params);
return false;
}
}
public static int callInt(ReflectorMethod refMethod, Object...params) {
try {
Method method = refMethod.getTargetMethod();
if (method == null) {
return 0;
} else {
Integer integer = (Integer) method.invoke((Object) null, params);
return integer.intValue();
}
} catch (Throwable throwable) {
handleException(throwable, (Object) null, refMethod, params);
return 0;
}
}
public static float callFloat(ReflectorMethod refMethod, Object...params) {
try {
Method method = refMethod.getTargetMethod();
if (method == null) {
return 0.0F;
} else {
Float f = (Float) method.invoke((Object) null, params);
return f.floatValue();
}
} catch (Throwable throwable) {
handleException(throwable, (Object) null, refMethod, params);
return 0.0F;
}
}
public static double callDouble(ReflectorMethod refMethod, Object...params) {
try {
Method method = refMethod.getTargetMethod();
if (method == null) {
return 0.0D;
} else {
Double d0 = (Double) method.invoke((Object) null, params);
return d0.doubleValue();
}
} catch (Throwable throwable) {
handleException(throwable, (Object) null, refMethod, params);
return 0.0D;
}
}
public static String callString(ReflectorMethod refMethod, Object...params) {
try {
Method method = refMethod.getTargetMethod();
if (method == null) {
return null;
} else {
String s = (String) method.invoke((Object) null, params);
return s;
}
} catch (Throwable throwable) {
handleException(throwable, (Object) null, refMethod, params);
return null;
}
}
public static Object call(ReflectorMethod refMethod, Object...params) {
try {
Method method = refMethod.getTargetMethod();
if (method == null) {
return null;
} else {
Object object = method.invoke((Object) null, params);
return object;
}
} catch (Throwable throwable) {
handleException(throwable, (Object) null, refMethod, params);
return null;
}
}
public static void callVoid(Object obj, ReflectorMethod refMethod, Object...params) {
try {
if (obj == null) {
return;
}
Method method = refMethod.getTargetMethod();
if (method == null) {
return;
}
method.invoke(obj, params);
} catch (Throwable throwable) {
handleException(throwable, obj, refMethod, params);
}
}
public static boolean callBoolean(Object obj, ReflectorMethod refMethod, Object...params) {
try {
Method method = refMethod.getTargetMethod();
if (method == null) {
return false;
} else {
Boolean obool = (Boolean) method.invoke(obj, params);
return obool.booleanValue();
}
} catch (Throwable throwable) {
handleException(throwable, obj, refMethod, params);
return false;
}
}
public static int callInt(Object obj, ReflectorMethod refMethod, Object...params) {
try {
Method method = refMethod.getTargetMethod();
if (method == null) {
return 0;
} else {
Integer integer = (Integer) method.invoke(obj, params);
return integer.intValue();
}
} catch (Throwable throwable) {
handleException(throwable, obj, refMethod, params);
return 0;
}
}
public static float callFloat(Object obj, ReflectorMethod refMethod, Object...params) {
try {
Method method = refMethod.getTargetMethod();
if (method == null) {
return 0.0F;
} else {
Float f = (Float) method.invoke(obj, params);
return f.floatValue();
}
} catch (Throwable throwable) {
handleException(throwable, obj, refMethod, params);
return 0.0F;
}
}
public static double callDouble(Object obj, ReflectorMethod refMethod, Object...params) {
try {
Method method = refMethod.getTargetMethod();
if (method == null) {
return 0.0D;
} else {
Double d0 = (Double) method.invoke(obj, params);
return d0.doubleValue();
}
} catch (Throwable throwable) {
handleException(throwable, obj, refMethod, params);
return 0.0D;
}
}
public static String callString(Object obj, ReflectorMethod refMethod, Object...params) {
try {
Method method = refMethod.getTargetMethod();
if (method == null) {
return null;
} else {
String s = (String) method.invoke(obj, params);
return s;
}
} catch (Throwable throwable) {
handleException(throwable, obj, refMethod, params);
return null;
}
}
public static Object call(Object obj, ReflectorMethod refMethod, Object...params) {
try {
Method method = refMethod.getTargetMethod();
if (method == null) {
return null;
} else {
Object object = method.invoke(obj, params);
return object;
}
} catch (Throwable throwable) {
handleException(throwable, obj, refMethod, params);
return null;
}
}
public static Object getFieldValue(ReflectorField refField) {
return getFieldValue((Object) null, refField);
}
public static Object getFieldValue(Object obj, ReflectorField refField) {
try {
Field field = refField.getTargetField();
if (field == null) {
return null;
} else {
Object object = field.get(obj);
return object;
}
} catch (Throwable throwable) {
Config.error("", throwable);
return null;
}
}
public static boolean getFieldValueBoolean(ReflectorField refField, boolean def) {
try {
Field field = refField.getTargetField();
if (field == null) {
return def;
} else {
boolean flag = field.getBoolean((Object) null);
return flag;
}
} catch (Throwable throwable) {
Config.error("", throwable);
return def;
}
}
public static boolean getFieldValueBoolean(Object obj, ReflectorField refField, boolean def) {
try {
Field field = refField.getTargetField();
if (field == null) {
return def;
} else {
boolean flag = field.getBoolean(obj);
return flag;
}
} catch (Throwable throwable) {
Config.error("", throwable);
return def;
}
}
public static Object getFieldValue(ReflectorFields refFields, int index) {
ReflectorField reflectorfield = refFields.getReflectorField(index);
return reflectorfield == null ? null : getFieldValue(reflectorfield);
}
public static Object getFieldValue(Object obj, ReflectorFields refFields, int index) {
ReflectorField reflectorfield = refFields.getReflectorField(index);
return reflectorfield == null ? null : getFieldValue(obj, reflectorfield);
}
public static float getFieldValueFloat(Object obj, ReflectorField refField, float def) {
try {
Field field = refField.getTargetField();
if (field == null) {
return def;
} else {
float f = field.getFloat(obj);
return f;
}
} catch (Throwable throwable) {
Config.error("", throwable);
return def;
}
}
public static int getFieldValueInt(Object obj, ReflectorField refField, int def) {
try {
Field field = refField.getTargetField();
if (field == null) {
return def;
} else {
int i = field.getInt(obj);
return i;
}
} catch (Throwable throwable) {
Config.error("", throwable);
return def;
}
}
public static long getFieldValueLong(Object obj, ReflectorField refField, long def) {
try {
Field field = refField.getTargetField();
if (field == null) {
return def;
} else {
long i = field.getLong(obj);
return i;
}
} catch (Throwable throwable) {
Config.error("", throwable);
return def;
}
}
public static boolean setFieldValue(ReflectorField refField, Object value) {
return setFieldValue((Object) null, refField, value);
}
public static boolean setFieldValue(Object obj, ReflectorField refField, Object value) {
try {
Field field = refField.getTargetField();
if (field == null) {
return false;
} else {
field.set(obj, value);
return true;
}
} catch (Throwable throwable) {
Config.error("", throwable);
return false;
}
}
public static boolean setFieldValueInt(ReflectorField refField, int value) {
return setFieldValueInt((Object) null, refField, value);
}
public static boolean setFieldValueInt(Object obj, ReflectorField refField, int value) {
try {
Field field = refField.getTargetField();
if (field == null) {
return false;
} else {
field.setInt(obj, value);
return true;
}
} catch (Throwable throwable) {
Config.error("", throwable);
return false;
}
}
public static Object newInstance(ReflectorConstructor constr, Object...params) {
Constructor constructor = constr.getTargetConstructor();
if (constructor == null) {
return null;
} else {
try {
Object object = constructor.newInstance(params);
return object;
} catch (Throwable throwable) {
handleException(throwable, constr, params);
return null;
}
}
}
public static boolean matchesTypes(Class[] pTypes, Class[] cTypes) {
if (pTypes.length != cTypes.length) {
return false;
} else {
for (int i = 0; i < cTypes.length; ++i) {
Class oclass = pTypes[i];
Class oclass1 = cTypes[i];
if (oclass != oclass1) {
return false;
}
}
return true;
}
}
private static void dbgCall(boolean isStatic, String callType, ReflectorMethod refMethod, Object[] params, Object retVal) {
String s = refMethod.getTargetMethod().getDeclaringClass().getName();
String s1 = refMethod.getTargetMethod().getName();
String s2 = "";
if (isStatic) {
s2 = " static";
}
Config.dbg(callType + s2 + " " + s + "." + s1 + "(" + ArrayUtils.arrayToString(params) + ") => " + retVal);
}
private static void dbgCallVoid(boolean isStatic, String callType, ReflectorMethod refMethod, Object[] params) {
String s = refMethod.getTargetMethod().getDeclaringClass().getName();
String s1 = refMethod.getTargetMethod().getName();
String s2 = "";
if (isStatic) {
s2 = " static";
}
Config.dbg(callType + s2 + " " + s + "." + s1 + "(" + ArrayUtils.arrayToString(params) + ")");
}
private static void dbgFieldValue(boolean isStatic, String accessType, ReflectorField refField, Object val) {
String s = refField.getTargetField().getDeclaringClass().getName();
String s1 = refField.getTargetField().getName();
String s2 = "";
if (isStatic) {
s2 = " static";
}
Config.dbg(accessType + s2 + " " + s + "." + s1 + " => " + val);
}
private static void handleException(Throwable e, Object obj, ReflectorMethod refMethod, Object[] params) {
if (e instanceof InvocationTargetException) {
Throwable throwable = e.getCause();
if (throwable instanceof RuntimeException) {
RuntimeException runtimeexception = (RuntimeException) throwable;
throw runtimeexception;
} else {
Config.error("", e);
}
} else {
Config.warn("*** Exception outside of method ***");
Config.warn("Method deactivated: " + refMethod.getTargetMethod());
refMethod.deactivate();
if (e instanceof IllegalArgumentException) {
Config.warn("*** IllegalArgumentException ***");
Config.warn("Method: " + refMethod.getTargetMethod());
Config.warn("Object: " + obj);
Config.warn("Parameter classes: " + ArrayUtils.arrayToString(getClasses(params)));
Config.warn("Parameters: " + ArrayUtils.arrayToString(params));
}
Config.warn("", e);
}
}
private static void handleException(Throwable e, ReflectorConstructor refConstr, Object[] params) {
if (e instanceof InvocationTargetException) {
Config.error("", e);
} else {
Config.warn("*** Exception outside of constructor ***");
Config.warn("Constructor deactivated: " + refConstr.getTargetConstructor());
refConstr.deactivate();
if (e instanceof IllegalArgumentException) {
Config.warn("*** IllegalArgumentException ***");
Config.warn("Constructor: " + refConstr.getTargetConstructor());
Config.warn("Parameter classes: " + ArrayUtils.arrayToString(getClasses(params)));
Config.warn("Parameters: " + ArrayUtils.arrayToString(params));
}
Config.warn("", e);
}
}
private static Object[] getClasses(Object[] objs) {
if (objs == null) {
return new Class[0];
} else {
Class[] aclass = new Class[objs.length];
for (int i = 0; i < aclass.length; ++i) {
Object object = objs[i];
if (object != null) {
aclass[i] = object.getClass();
}
}
return aclass;
}
}
private static ReflectorField[] getReflectorFields(ReflectorClass parentClass, Class fieldType, int count) {
ReflectorField[] areflectorfield = new ReflectorField[count];
for (int i = 0; i < areflectorfield.length; ++i) {
areflectorfield[i] = new ReflectorField(parentClass, fieldType, i);
}
return areflectorfield;
}
private static boolean logEntry(String str) {
LOGGER.info("[OptiFine] " + str);
return true;
}
private static boolean registerResolvable(final String str) {
IResolvable iresolvable = new IResolvable() {
public void resolve() {
Reflector.LOGGER.info("[OptiFine] " + str);
}
};
ReflectorResolver.register(iresolvable);
return true;
}
}

View File

@ -0,0 +1,66 @@
package net.PeytonPlayz585.shadow.reflect;
import net.PeytonPlayz585.shadow.Config;
public class ReflectorClass implements IResolvable {
private String targetClassName = null;
private boolean checked = false;
private Class targetClass = null;
public ReflectorClass(String targetClassName) {
this.targetClassName = targetClassName;
ReflectorResolver.register(this);
}
public ReflectorClass(Class targetClass) {
this.targetClass = targetClass;
this.targetClassName = targetClass.getName();
this.checked = true;
}
public Class getTargetClass() {
if (this.checked) {
return this.targetClass;
} else {
this.checked = true;
try {
this.targetClass = Class.forName(this.targetClassName);
} catch (ClassNotFoundException var2) {
Config.log("(Reflector) Class not present: " + this.targetClassName);
} catch (Throwable throwable) {
throwable.printStackTrace();
}
return this.targetClass;
}
}
public boolean exists() {
return this.getTargetClass() != null;
}
public String getTargetClassName() {
return this.targetClassName;
}
public boolean isInstance(Object obj) {
return this.getTargetClass() == null ? false : this.getTargetClass().isInstance(obj);
}
public ReflectorField makeField(String name) {
return new ReflectorField(this, name);
}
public ReflectorMethod makeMethod(String name) {
return new ReflectorMethod(this, name);
}
public ReflectorMethod makeMethod(String name, Class[] paramTypes) {
return new ReflectorMethod(this, name, paramTypes);
}
public void resolve() {
Class oclass = this.getTargetClass();
}
}

View File

@ -0,0 +1,80 @@
package net.PeytonPlayz585.shadow.reflect;
import java.lang.reflect.Constructor;
import net.PeytonPlayz585.shadow.ArrayUtils;
import net.PeytonPlayz585.shadow.Config;
public class ReflectorConstructor implements IResolvable {
private ReflectorClass reflectorClass = null;
private Class[] parameterTypes = null;
private boolean checked = false;
private Constructor targetConstructor = null;
public ReflectorConstructor(ReflectorClass reflectorClass, Class[] parameterTypes) {
this.reflectorClass = reflectorClass;
this.parameterTypes = parameterTypes;
ReflectorResolver.register(this);
}
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: " + ArrayUtils.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 cls, Class[] paramTypes) {
Constructor[] aconstructor = cls.getDeclaredConstructors();
for (int i = 0; i < aconstructor.length; ++i) {
Constructor constructor = aconstructor[i];
Class[] aclass = constructor.getParameterTypes();
if (Reflector.matchesTypes(paramTypes, 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;
}
public Object newInstance(Object...params) {
return Reflector.newInstance(this, params);
}
public void resolve() {
Constructor constructor = this.getTargetConstructor();
}
}

View File

@ -0,0 +1,68 @@
package net.PeytonPlayz585.shadow.reflect;
import java.lang.reflect.Field;
public class ReflectorField implements IResolvable {
private IFieldLocator fieldLocator;
private boolean checked;
private Field targetField;
public ReflectorField(ReflectorClass reflectorClass, String targetFieldName) {
this((IFieldLocator)(new FieldLocatorName(reflectorClass, targetFieldName)));
}
public ReflectorField(ReflectorClass reflectorClass, Class targetFieldType) {
this(reflectorClass, targetFieldType, 0);
}
public ReflectorField(ReflectorClass reflectorClass, Class targetFieldType, int targetFieldIndex) {
this((IFieldLocator)(new FieldLocatorType(reflectorClass, targetFieldType, targetFieldIndex)));
}
public ReflectorField(Field field) {
this((IFieldLocator)(new FieldLocatorFixed(field)));
}
public ReflectorField(IFieldLocator fieldLocator) {
this.fieldLocator = null;
this.checked = false;
this.targetField = null;
this.fieldLocator = fieldLocator;
ReflectorResolver.register(this);
}
public Field getTargetField() {
if (this.checked) {
return this.targetField;
} else {
this.checked = true;
this.targetField = this.fieldLocator.getField();
if (this.targetField != null) {
this.targetField.setAccessible(true);
}
return this.targetField;
}
}
public Object getValue() {
return Reflector.getFieldValue((Object) null, this);
}
public void setValue(Object value) {
Reflector.setFieldValue((Object) null, this, value);
}
public void setValue(Object obj, Object value) {
Reflector.setFieldValue(obj, this, value);
}
public boolean exists() {
return this.getTargetField() != null;
}
public void resolve() {
Field field = this.getTargetField();
}
}

View File

@ -0,0 +1,39 @@
package net.PeytonPlayz585.shadow.reflect;
public class ReflectorFields {
private ReflectorClass reflectorClass;
private Class fieldType;
private int fieldCount;
private ReflectorField[] reflectorFields;
public ReflectorFields(ReflectorClass reflectorClass, Class fieldType, int fieldCount) {
this.reflectorClass = reflectorClass;
this.fieldType = fieldType;
if (reflectorClass.exists()) {
if (fieldType != null) {
this.reflectorFields = new ReflectorField[fieldCount];
for (int i = 0; i < this.reflectorFields.length; ++i) {
this.reflectorFields[i] = new ReflectorField(reflectorClass, fieldType, i);
}
}
}
}
public ReflectorClass getReflectorClass() {
return this.reflectorClass;
}
public Class getFieldType() {
return this.fieldType;
}
public int getFieldCount() {
return this.fieldCount;
}
public ReflectorField getReflectorField(int index) {
return index >= 0 && index < this.reflectorFields.length ? this.reflectorFields[index] : null;
}
}

View File

@ -0,0 +1,197 @@
package net.PeytonPlayz585.shadow.reflect;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import net.PeytonPlayz585.shadow.Config;
public class ReflectorMethod implements IResolvable {
private ReflectorClass reflectorClass;
private String targetMethodName;
private Class[] targetMethodParameterTypes;
private boolean checked;
private Method targetMethod;
public ReflectorMethod(ReflectorClass reflectorClass, String targetMethodName) {
this(reflectorClass, targetMethodName, (Class[]) null);
}
public ReflectorMethod(ReflectorClass reflectorClass, String targetMethodName, Class[] targetMethodParameterTypes) {
this.reflectorClass = null;
this.targetMethodName = null;
this.targetMethodParameterTypes = null;
this.checked = false;
this.targetMethod = null;
this.reflectorClass = reflectorClass;
this.targetMethodName = targetMethodName;
this.targetMethodParameterTypes = targetMethodParameterTypes;
ReflectorResolver.register(this);
}
public Method getTargetMethod() {
if (this.checked) {
return this.targetMethod;
} else {
this.checked = true;
Class oclass = this.reflectorClass.getTargetClass();
if (oclass == null) {
return null;
} else {
try {
if (this.targetMethodParameterTypes == null) {
Method[] amethod = getMethods(oclass, this.targetMethodName);
if (amethod.length <= 0) {
Config.log("(Reflector) Method not present: " + oclass.getName() + "." + this.targetMethodName);
return null;
}
if (amethod.length > 1) {
Config.warn("(Reflector) More than one method found: " + oclass.getName() + "." + this.targetMethodName);
for (int i = 0; i < amethod.length; ++i) {
Method method = amethod[i];
Config.warn("(Reflector) - " + method);
}
return null;
}
this.targetMethod = amethod[0];
} else {
this.targetMethod = getMethod(oclass, this.targetMethodName, this.targetMethodParameterTypes);
}
if (this.targetMethod == null) {
Config.log("(Reflector) Method not present: " + oclass.getName() + "." + this.targetMethodName);
return null;
} else {
this.targetMethod.setAccessible(true);
return this.targetMethod;
}
} catch (Throwable throwable) {
throwable.printStackTrace();
return null;
}
}
}
}
public boolean exists() {
return this.checked ? this.targetMethod != null : this.getTargetMethod() != null;
}
public Class getReturnType() {
Method method = this.getTargetMethod();
return method == null ? null : method.getReturnType();
}
public void deactivate() {
this.checked = true;
this.targetMethod = null;
}
public Object call(Object...params) {
return Reflector.call(this, params);
}
public boolean callBoolean(Object...params) {
return Reflector.callBoolean(this, params);
}
public int callInt(Object...params) {
return Reflector.callInt(this, params);
}
public float callFloat(Object...params) {
return Reflector.callFloat(this, params);
}
public double callDouble(Object...params) {
return Reflector.callDouble(this, params);
}
public String callString(Object...params) {
return Reflector.callString(this, params);
}
public Object call(Object param) {
return Reflector.call(this, new Object[] {
param
});
}
public boolean callBoolean(Object param) {
return Reflector.callBoolean(this, new Object[] {
param
});
}
public int callInt(Object param) {
return Reflector.callInt(this, new Object[] {
param
});
}
public float callFloat(Object param) {
return Reflector.callFloat(this, new Object[] {
param
});
}
public double callDouble(Object param) {
return Reflector.callDouble(this, new Object[] {
param
});
}
public String callString1(Object param) {
return Reflector.callString(this, new Object[] {
param
});
}
public void callVoid(Object...params) {
Reflector.callVoid(this, params);
}
public static Method getMethod(Class cls, String methodName, Class[] paramTypes) {
Method[] amethod = cls.getDeclaredMethods();
for (int i = 0; i < amethod.length; ++i) {
Method method = amethod[i];
if (method.getName().equals(methodName)) {
Class[] aclass = method.getParameterTypes();
if (Reflector.matchesTypes(paramTypes, aclass)) {
return method;
}
}
}
return null;
}
public static Method[] getMethods(Class cls, String methodName) {
List list = new ArrayList();
Method[] amethod = cls.getDeclaredMethods();
for (int i = 0; i < amethod.length; ++i) {
Method method = amethod[i];
if (method.getName().equals(methodName)) {
list.add(method);
}
}
Method[] amethod1 = (Method[])((Method[]) list.toArray(new Method[list.size()]));
return amethod1;
}
public void resolve() {
Method method = this.getTargetMethod();
}
}

View File

@ -0,0 +1,157 @@
package net.PeytonPlayz585.shadow.reflect;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class ReflectorRaw {
public static Field getField(Class cls, Class fieldType) {
try {
Field[] afield = cls.getDeclaredFields();
for (int i = 0; i < afield.length; ++i) {
Field field = afield[i];
if (field.getType() == fieldType) {
field.setAccessible(true);
return field;
}
}
return null;
} catch (Exception var5) {
return null;
}
}
public static Field[] getFields(Class cls, Class fieldType) {
try {
Field[] afield = cls.getDeclaredFields();
return getFields(afield, fieldType);
} catch (Exception var3) {
return null;
}
}
public static Field[] getFields(Field[] fields, Class fieldType) {
try {
List list = new ArrayList();
for (int i = 0; i < fields.length; ++i) {
Field field = fields[i];
if (field.getType() == fieldType) {
field.setAccessible(true);
list.add(field);
}
}
Field[] afield = (Field[])((Field[]) list.toArray(new Field[list.size()]));
return afield;
} catch (Exception var5) {
return null;
}
}
public static Field[] getFieldsAfter(Class cls, Field field, Class fieldType) {
try {
Field[] afield = cls.getDeclaredFields();
List < Field > list = Arrays. < Field > asList(afield);
int i = list.indexOf(field);
if (i < 0) {
return new Field[0];
} else {
List < Field > list1 = list.subList(i + 1, list.size());
Field[] afield1 = (Field[])((Field[]) list1.toArray(new Field[list1.size()]));
return getFields(afield1, fieldType);
}
} catch (Exception var8) {
return null;
}
}
public static Field[] getFields(Object obj, Field[] fields, Class fieldType, Object value) {
try {
List < Field > list = new ArrayList();
for (int i = 0; i < fields.length; ++i) {
Field field = fields[i];
if (field.getType() == fieldType) {
boolean flag = Modifier.isStatic(field.getModifiers());
if ((obj != null || flag) && (obj == null || !flag)) {
field.setAccessible(true);
Object object = field.get(obj);
if (object == value) {
list.add(field);
} else if (object != null && value != null && object.equals(value)) {
list.add(field);
}
}
}
}
Field[] afield = (Field[])((Field[]) list.toArray(new Field[list.size()]));
return afield;
} catch (Exception var9) {
return null;
}
}
public static Field getField(Class cls, Class fieldType, int index) {
Field[] afield = getFields(cls, fieldType);
return index >= 0 && index < afield.length ? afield[index] : null;
}
public static Field getFieldAfter(Class cls, Field field, Class fieldType, int index) {
Field[] afield = getFieldsAfter(cls, field, fieldType);
return index >= 0 && index < afield.length ? afield[index] : null;
}
public static Object getFieldValue(Object obj, Class cls, Class fieldType) {
ReflectorField reflectorfield = getReflectorField(cls, fieldType);
return reflectorfield == null ? null : (!reflectorfield.exists() ? null : Reflector.getFieldValue(obj, reflectorfield));
}
public static Object getFieldValue(Object obj, Class cls, Class fieldType, int index) {
ReflectorField reflectorfield = getReflectorField(cls, fieldType, index);
return reflectorfield == null ? null : (!reflectorfield.exists() ? null : Reflector.getFieldValue(obj, reflectorfield));
}
public static boolean setFieldValue(Object obj, Class cls, Class fieldType, Object value) {
ReflectorField reflectorfield = getReflectorField(cls, fieldType);
return reflectorfield == null ? false : (!reflectorfield.exists() ? false : Reflector.setFieldValue(obj, reflectorfield, value));
}
public static boolean setFieldValue(Object obj, Class cls, Class fieldType, int index, Object value) {
ReflectorField reflectorfield = getReflectorField(cls, fieldType, index);
return reflectorfield == null ? false : (!reflectorfield.exists() ? false : Reflector.setFieldValue(obj, reflectorfield, value));
}
public static ReflectorField getReflectorField(Class cls, Class fieldType) {
Field field = getField(cls, fieldType);
if (field == null) {
return null;
} else {
ReflectorClass reflectorclass = new ReflectorClass(cls);
return new ReflectorField(reflectorclass, field.getName());
}
}
public static ReflectorField getReflectorField(Class cls, Class fieldType, int index) {
Field field = getField(cls, fieldType, index);
if (field == null) {
return null;
} else {
ReflectorClass reflectorclass = new ReflectorClass(cls);
return new ReflectorField(reflectorclass, field.getName());
}
}
}

View File

@ -0,0 +1,28 @@
package net.PeytonPlayz585.shadow.reflect;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class ReflectorResolver {
private static final List < IResolvable > RESOLVABLES = Collections. < IResolvable > synchronizedList(new ArrayList());
private static boolean resolved = false;
protected static void register(IResolvable resolvable) {
if (!resolved) {
RESOLVABLES.add(resolvable);
} else {
resolvable.resolve();
}
}
public static void resolve() {
if (!resolved) {
for (IResolvable iresolvable: RESOLVABLES) {
iresolvable.resolve();
}
resolved = true;
}
}
}

View File

@ -616,4 +616,8 @@ public class EaglercraftGPU {
public static final boolean checkHasHDRFramebufferSupport() {
return hasFramebufferHDR16FSupport || hasFramebufferHDR32FSupport;
}
public static int glGetTexLevelParameteri(int glTexture2d, int i, int glTextureWidth) {
return PlatformOpenGL._wglGetTexLevelParameteri(glTexture2d, i, glTextureWidth);
}
}

View File

@ -1198,4 +1198,8 @@ public class GlStateManager {
public static boolean isFogEnabled() {
return stateFog;
}
public static int getBoundTexture() {
return boundTexture[activeTexture];
}
}

View File

@ -27,5 +27,4 @@ public class OpenGlHelper {
GlStateManager.setActiveTexture(defaultTexUnit);
}
}

View File

@ -79,7 +79,7 @@ public class DeferredStateManager {
static int projMatrixSerial = -1;
static int passViewMatrixSerial = -1;
static int passProjMatrixSerial = -1;
static boolean isShadowPassMatrixLoaded = false;
public static boolean isShadowPassMatrixLoaded = false;
static final Matrix4f viewMatrix = new Matrix4f();
static final Matrix4f projMatrix = new Matrix4f();
static final Matrix4f inverseViewMatrix = new Matrix4f();

View File

@ -5,12 +5,15 @@ import java.util.Map.Entry;
import com.google.common.collect.Maps;
import net.PeytonPlayz585.shadow.Config;
import net.PeytonPlayz585.shadow.CustomItems;
import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerTextureAtlasSprite;
import net.minecraft.client.resources.model.IBakedModel;
import net.minecraft.client.resources.model.ModelManager;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
/**+
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
@ -63,6 +66,10 @@ public class ItemModelMesher {
if (ibakedmodel == null) {
ibakedmodel = this.modelManager.getMissingModel();
}
if (Config.isCustomItems()) {
ibakedmodel = CustomItems.getCustomItemModel(stack, ibakedmodel, (ResourceLocation)null, true);
}
return ibakedmodel;
}

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.CustomItems;
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;
@ -95,6 +97,7 @@ public class RenderItem implements IResourceManagerReloadListener {
private final ItemModelMesher itemModelMesher;
private final TextureManager textureManager;
public ModelManager modelManager = null;
private ModelResourceLocation modelLocation = null;
public RenderItem(TextureManager textureManager, ModelManager modelManager) {
this.modelManager = modelManager;
@ -131,7 +134,7 @@ public class RenderItem implements IResourceManagerReloadListener {
this.renderModel(model, -1, stack);
}
private void renderModel(IBakedModel model, int color) {
public void renderModel(IBakedModel model, int color) {
this.renderModel(model, color, (ItemStack) null);
}
@ -165,13 +168,20 @@ public class RenderItem implements IResourceManagerReloadListener {
GlStateManager.enableRescaleNormal();
TileEntityItemStackRenderer.instance.renderByItem(stack);
} else {
final IBakedModel model1;
if (Config.isCustomItems()) {
model1 = CustomItems.getCustomItemModel(stack, model, this.modelLocation, false);
} else {
model1 = model;
}
GlStateManager.translate(-0.5F, -0.5F, -0.5F);
if (DeferredStateManager.isInDeferredPass() && isTransparentItem(stack)) {
if (DeferredStateManager.forwardCallbackHandler != null) {
final Matrix4f mat = new Matrix4f(GlStateManager.getModelViewReference());
final float lx = GlStateManager.getTexCoordX(1), ly = GlStateManager.getTexCoordY(1);
DeferredStateManager.forwardCallbackHandler.push(new ShadersRenderPassFuture(renderPosX,
renderPosY, renderPosZ, EaglerDeferredPipeline.instance.getPartialTicks()) {
DeferredStateManager.forwardCallbackHandler.push(new ShadersRenderPassFuture(renderPosX, renderPosY, renderPosZ, EaglerDeferredPipeline.instance.getPartialTicks()) {
@Override
public void draw(PassType pass) {
if (pass == PassType.MAIN) {
@ -183,14 +193,14 @@ public class RenderItem implements IResourceManagerReloadListener {
GlStateManager.texCoords2DDirect(1, lx, ly);
Minecraft.getMinecraft().getTextureManager()
.bindTexture(TextureMap.locationBlocksTexture);
RenderItem.this.renderModel(model, stack);
if (pass != PassType.SHADOW && stack.hasEffect()) {
RenderItem.this.renderModel(model1, stack);
if (pass != PassType.SHADOW && stack.hasEffect() && (!Config.isCustomItems() || !CustomItems.renderCustomEffect(RenderItem.this, stack, model1))) {
GlStateManager.color(1.5F, 0.5F, 1.5F, 1.0F);
DeferredStateManager.setDefaultMaterialConstants();
DeferredStateManager.setRoughnessConstant(0.05f);
DeferredStateManager.setMetalnessConstant(0.01f);
GlStateManager.blendFunc(GL_SRC_COLOR, GL_ONE);
renderEffect(model);
renderEffect(model1);
DeferredStateManager.setHDRTranslucentPassBlendFunc();
}
GlStateManager.popMatrix();
@ -200,8 +210,8 @@ public class RenderItem implements IResourceManagerReloadListener {
});
}
} else {
this.renderModel(model, stack);
if (stack.hasEffect()) {
this.renderModel(model1, stack);
if (stack.hasEffect() && (!Config.isCustomItems() || !CustomItems.renderCustomEffect(this, stack, model))) {
if (DeferredStateManager.isInDeferredPass()) {
if (DeferredStateManager.forwardCallbackHandler != null
&& !DeferredStateManager.isEnableShadowRender()) {
@ -223,7 +233,7 @@ public class RenderItem implements IResourceManagerReloadListener {
GlStateManager.loadMatrix(mat);
GlStateManager.texCoords2DDirect(1, lx, ly);
GlStateManager.tryBlendFuncSeparate(GL_ONE, GL_ONE, GL_ZERO, GL_ONE);
renderEffect(model);
renderEffect(model1);
DeferredStateManager.setHDRTranslucentPassBlendFunc();
GlStateManager.popMatrix();
EntityRenderer.disableLightmapStatic();
@ -233,7 +243,7 @@ public class RenderItem implements IResourceManagerReloadListener {
}
} else {
GlStateManager.blendFunc(GL_SRC_COLOR, GL_ONE);
this.renderEffect(model);
this.renderEffect(model1);
}
}
}
@ -250,31 +260,33 @@ public class RenderItem implements IResourceManagerReloadListener {
}
private void renderEffect(IBakedModel model) {
GlStateManager.depthMask(false);
GlStateManager.depthFunc(GL_EQUAL);
GlStateManager.disableLighting();
this.textureManager.bindTexture(RES_ITEM_GLINT);
GlStateManager.matrixMode(GL_TEXTURE);
GlStateManager.pushMatrix();
GlStateManager.scale(8.0F, 8.0F, 8.0F);
float f = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F / 8.0F;
GlStateManager.translate(f, 0.0F, 0.0F);
GlStateManager.rotate(-50.0F, 0.0F, 0.0F, 1.0F);
this.renderModel(model, -8372020);
GlStateManager.popMatrix();
GlStateManager.pushMatrix();
GlStateManager.scale(8.0F, 8.0F, 8.0F);
float f1 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F / 8.0F;
GlStateManager.translate(-f1, 0.0F, 0.0F);
GlStateManager.rotate(10.0F, 0.0F, 0.0F, 1.0F);
this.renderModel(model, -8372020);
GlStateManager.popMatrix();
GlStateManager.matrixMode(GL_MODELVIEW);
GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.enableLighting();
GlStateManager.depthFunc(GL_LEQUAL);
GlStateManager.depthMask(true);
this.textureManager.bindTexture(TextureMap.locationBlocksTexture);
if (!Config.isCustomItems() || CustomItems.isUseGlint()) {
GlStateManager.depthMask(false);
GlStateManager.depthFunc(GL_EQUAL);
GlStateManager.disableLighting();
this.textureManager.bindTexture(RES_ITEM_GLINT);
GlStateManager.matrixMode(GL_TEXTURE);
GlStateManager.pushMatrix();
GlStateManager.scale(8.0F, 8.0F, 8.0F);
float f = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F / 8.0F;
GlStateManager.translate(f, 0.0F, 0.0F);
GlStateManager.rotate(-50.0F, 0.0F, 0.0F, 1.0F);
this.renderModel(model, -8372020);
GlStateManager.popMatrix();
GlStateManager.pushMatrix();
GlStateManager.scale(8.0F, 8.0F, 8.0F);
float f1 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F / 8.0F;
GlStateManager.translate(-f1, 0.0F, 0.0F);
GlStateManager.rotate(10.0F, 0.0F, 0.0F, 1.0F);
this.renderModel(model, -8372020);
GlStateManager.popMatrix();
GlStateManager.matrixMode(GL_MODELVIEW);
GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.enableLighting();
GlStateManager.depthFunc(GL_LEQUAL);
GlStateManager.depthMask(true);
this.textureManager.bindTexture(TextureMap.locationBlocksTexture);
}
}
private void putQuadNormal(WorldRenderer renderer, BakedQuad quad) {
@ -354,6 +366,8 @@ public class RenderItem implements IResourceManagerReloadListener {
modelresourcelocation = new ModelResourceLocation("bow_pulling_0", "inventory");
}
}
this.modelLocation = modelresourcelocation;
if (modelresourcelocation != null) {
ibakedmodel = this.itemModelMesher.getModelManager().getModel(modelresourcelocation);
@ -361,6 +375,7 @@ public class RenderItem implements IResourceManagerReloadListener {
}
this.renderItemModelTransform(stack, ibakedmodel, cameraTransformType);
this.modelLocation = null;
}
}

View File

@ -6,6 +6,8 @@ import java.util.Map;
import com.google.common.collect.Maps;
import net.PeytonPlayz585.shadow.Config;
import net.PeytonPlayz585.shadow.CustomItems;
import net.lax1dude.eaglercraft.v1_8.HString;
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.DeferredStateManager;
@ -84,7 +86,11 @@ public abstract class LayerArmorBase<T extends ModelBase> implements LayerRender
modelbase.setLivingAnimations(entitylivingbaseIn, armorSlot, parFloat2, parFloat3);
this.func_177179_a((T) modelbase, parInt1);
boolean flag = this.isSlotForLeggings(parInt1);
this.renderer.bindTexture(this.getArmorResource(itemarmor, flag));
if (!Config.isCustomItems() || !CustomItems.bindCustomArmorTexture(itemstack, flag ? 2 : 1, (String)null)) {
this.renderer.bindTexture(this.getArmorResource(itemarmor, flag));
}
DeferredStateManager.setDefaultMaterialConstants();
switch (itemarmor.getArmorMaterial()) {
case CHAIN:
@ -111,7 +117,9 @@ public abstract class LayerArmorBase<T extends ModelBase> implements LayerRender
float f2 = (float) (i & 255) / 255.0F;
GlStateManager.color(this.colorR * f, this.colorG * f1, this.colorB * f2, this.alpha);
modelbase.render(entitylivingbaseIn, armorSlot, parFloat2, parFloat4, parFloat5, parFloat6, parFloat7);
this.renderer.bindTexture(this.getArmorResource(itemarmor, flag, "overlay"));
if (!Config.isCustomItems() || !CustomItems.bindCustomArmorTexture(itemstack, flag ? 2 : 1, "overlay")) {
this.renderer.bindTexture(this.getArmorResource(itemarmor, flag, "overlay"));
}
case CHAIN:
case IRON:
case GOLD:
@ -159,8 +167,9 @@ public abstract class LayerArmorBase<T extends ModelBase> implements LayerRender
}
break;
}
this.func_177183_a(entitylivingbaseIn, (T) modelbase, armorSlot, parFloat2, parFloat3, parFloat4,
parFloat5, parFloat6, parFloat7);
if (!this.field_177193_i && itemstack.isItemEnchanted() && (!Config.isCustomItems() || !CustomItems.renderCustomArmorEffect(entitylivingbaseIn, itemstack, modelbase, armorSlot, parFloat2, parFloat3, parFloat4, parFloat5, parFloat6, parFloat7))) {
this.func_177183_a(entitylivingbaseIn, (T) modelbase, armorSlot, parFloat2, parFloat3, parFloat4, parFloat5, parFloat6, parFloat7);
}
}
}
@ -179,43 +188,44 @@ public abstract class LayerArmorBase<T extends ModelBase> implements LayerRender
return armorSlot == 2;
}
private void func_177183_a(EntityLivingBase entitylivingbaseIn, T modelbaseIn, float parFloat1, float parFloat2,
float parFloat3, float parFloat4, float parFloat5, float parFloat6, float parFloat7) {
float f = (float) entitylivingbaseIn.ticksExisted + parFloat3;
this.renderer.bindTexture(ENCHANTED_ITEM_GLINT_RES);
GlStateManager.enableBlend();
GlStateManager.depthFunc(GL_EQUAL);
GlStateManager.depthMask(false);
float f1 = 0.5F;
boolean d = !DeferredStateManager.isInDeferredPass();
if (d) {
GlStateManager.color(f1, f1, f1, 1.0F);
}
for (int i = 0; i < 2; ++i) {
GlStateManager.disableLighting();
float f2 = 0.76F;
private void func_177183_a(EntityLivingBase entitylivingbaseIn, T modelbaseIn, float parFloat1, float parFloat2, float parFloat3, float parFloat4, float parFloat5, float parFloat6, float parFloat7) {
if (!Config.isCustomItems() || CustomItems.isUseGlint()) {
float f = (float) entitylivingbaseIn.ticksExisted + parFloat3;
this.renderer.bindTexture(ENCHANTED_ITEM_GLINT_RES);
GlStateManager.enableBlend();
GlStateManager.depthFunc(GL_EQUAL);
GlStateManager.depthMask(false);
float f1 = 0.5F;
boolean d = !DeferredStateManager.isInDeferredPass();
if (d) {
GlStateManager.blendFunc(GL_SRC_COLOR, GL_ONE);
GlStateManager.color(0.5F * f2, 0.25F * f2, 0.8F * f2, 1.0F);
GlStateManager.color(f1, f1, f1, 1.0F);
}
for (int i = 0; i < 2; ++i) {
GlStateManager.disableLighting();
float f2 = 0.76F;
if (d) {
GlStateManager.blendFunc(GL_SRC_COLOR, GL_ONE);
GlStateManager.color(0.5F * f2, 0.25F * f2, 0.8F * f2, 1.0F);
}
GlStateManager.matrixMode(GL_TEXTURE);
GlStateManager.loadIdentity();
float f3 = 0.33333334F;
GlStateManager.scale(f3, f3, f3);
GlStateManager.rotate(30.0F - (float) i * 60.0F, 0.0F, 0.0F, 1.0F);
GlStateManager.translate(0.0F, f * (0.001F + (float) i * 0.003F) * 20.0F, 0.0F);
GlStateManager.matrixMode(GL_MODELVIEW);
modelbaseIn.render(entitylivingbaseIn, parFloat1, parFloat2, parFloat4, parFloat5, parFloat6, parFloat7);
}
GlStateManager.matrixMode(GL_TEXTURE);
GlStateManager.loadIdentity();
float f3 = 0.33333334F;
GlStateManager.scale(f3, f3, f3);
GlStateManager.rotate(30.0F - (float) i * 60.0F, 0.0F, 0.0F, 1.0F);
GlStateManager.translate(0.0F, f * (0.001F + (float) i * 0.003F) * 20.0F, 0.0F);
GlStateManager.matrixMode(GL_MODELVIEW);
modelbaseIn.render(entitylivingbaseIn, parFloat1, parFloat2, parFloat4, parFloat5, parFloat6, parFloat7);
GlStateManager.enableLighting();
GlStateManager.depthMask(true);
GlStateManager.depthFunc(GL_LEQUAL);
GlStateManager.disableBlend();
}
GlStateManager.matrixMode(GL_TEXTURE);
GlStateManager.loadIdentity();
GlStateManager.matrixMode(GL_MODELVIEW);
GlStateManager.enableLighting();
GlStateManager.depthMask(true);
GlStateManager.depthFunc(GL_LEQUAL);
GlStateManager.disableBlend();
}
private ResourceLocation getArmorResource(ItemArmor parItemArmor, boolean parFlag) {

View File

@ -15,6 +15,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import net.PeytonPlayz585.shadow.Config;
import net.PeytonPlayz585.shadow.CustomItems;
import net.PeytonPlayz585.shadow.TextureUtils;
import net.lax1dude.eaglercraft.v1_8.HString;
import net.lax1dude.eaglercraft.v1_8.internal.IFramebufferGL;
@ -180,6 +181,7 @@ public class TextureMap extends AbstractTexture implements ITickableTextureObjec
}
}
CustomItems.updateIcons(this);
int i = Minecraft.getGLMaximumTextureSize();
Stitcher stitcher = new Stitcher(i, i, true, 0, this.mipmapLevels);
this.mapUploadedSprites.clear();
@ -333,7 +335,25 @@ public class TextureMap extends AbstractTexture implements ITickableTextureObjec
}
try {
IResource iresource = resourceManager.getResource(resourcelocation1);
boolean isFuckedUp = false;
ResourceLocation shit = null;
if(resourcelocation1.toString().contains("mcpatcher") || resourcelocation1.toString().contains("optifine")) {
if(resourcelocation1.toString().contains("textures/")) {
String s = resourcelocation1.toString().replace("textures/", "");
shit = new ResourceLocation(s);
isFuckedUp = true;
}
}
IResource iresource;
if(isFuckedUp) {
if(shit != null) { //Just in case
iresource = resourceManager.getResource(shit);
} else {
iresource = resourceManager.getResource(resourcelocation1);
}
} else {
iresource = resourceManager.getResource(resourcelocation1);
}
ImageData[] abufferedimage = new ImageData[1 + this.mipmapLevels];
abufferedimage[0] = TextureUtil.readBufferedImage(iresource.getInputStream());
TextureMetadataSection texturemetadatasection = (TextureMetadataSection) iresource

View File

@ -40,7 +40,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

@ -21,6 +21,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import net.PeytonPlayz585.shadow.CustomItems;
import net.lax1dude.eaglercraft.v1_8.IOUtils;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
@ -390,6 +391,9 @@ public class ModelBakery {
this.variantNames.put(Item.getItemFromBlock(Blocks.oak_fence),
Lists.newArrayList(new String[] { "oak_fence" }));
this.variantNames.put(Items.oak_door, Lists.newArrayList(new String[] { "oak_door" }));
CustomItems.update();
CustomItems.loadModels(this);
}
private List<String> getVariantNames(Item parItem) {
@ -479,6 +483,20 @@ public class ModelBakery {
}
}
public void loadItemModel(String p_loadItemModel_1_, ResourceLocation p_loadItemModel_2_, ResourceLocation p_loadItemModel_3_) {
this.itemLocations.put(p_loadItemModel_1_, p_loadItemModel_2_);
if (this.models.get(p_loadItemModel_2_) == null) {
try {
ModelBlock modelblock = this.loadModel(p_loadItemModel_2_);
this.models.put(p_loadItemModel_2_, modelblock);
} catch (Exception exception) {
LOGGER.warn("Unable to load item model: \'{}\' for item: \'{}\'", new Object[] {p_loadItemModel_2_, p_loadItemModel_3_});
LOGGER.warn(exception.getClass().getName() + ": " + exception.getMessage());
}
}
}
private Set<ResourceLocation> getVariantsTextureLocations() {
HashSet hashset = Sets.newHashSet();

View File

@ -38,9 +38,7 @@ import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.EaglerDeferredConfig;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.SoundCategory;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiNewChat;
import net.minecraft.client.gui.GuiOptionButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.I18n;
@ -254,6 +252,7 @@ public class GameSettings {
public boolean ofBetterSnow = false;
public boolean ofCustomFonts = true;
public boolean ofCustomSky = true;
public boolean ofCustomItems = true;
public int ofDynamicLights = 3;
public boolean toggleSprint = false;
public boolean toggleSprintEnabled = false;
@ -865,6 +864,11 @@ public class GameSettings {
this.mc.renderGlobal.loadRenderers();
}
}
if (parOptions == GameSettings.Options.CUSTOM_ITEMS) {
this.ofCustomItems = !this.ofCustomItems;
this.mc.refreshResources();
}
this.saveOptions();
}
@ -978,6 +982,8 @@ public class GameSettings {
return this.experimentalVisGraph;
case BUFFER_QUEUE:
return this.experimentalBufferQueue;
case CUSTOM_ITEMS:
return this.ofCustomItems;
default:
return false;
}
@ -1246,7 +1252,9 @@ public class GameSettings {
return this.experimentalVisGraph ? s + Lang.getOn() : s + Lang.getOff();
} else if(parOptions == GameSettings.Options.BUFFER_QUEUE) {
return this.experimentalBufferQueue ? s + Lang.getOn() : s + Lang.getOff();
} else {
} else if (parOptions == GameSettings.Options.CUSTOM_ITEMS) {
return this.ofCustomItems ? s + Lang.getOn() : s + Lang.getOff();
} else {
return s;
}
}
@ -1796,6 +1804,10 @@ public class GameSettings {
if(astring[0].equals("bufferQueue") && astring.length >= 2) {
this.experimentalBufferQueue = Boolean.valueOf(astring[1]).booleanValue();
}
if (astring[0].equals("ofCustomItems") && astring.length >= 2) {
this.ofCustomItems = Boolean.valueOf(astring[1]).booleanValue();
}
Keyboard.setFunctionKeyModifier(keyBindFunction.getKeyCode());
@ -1970,6 +1982,7 @@ public class GameSettings {
printwriter.println("chunkBorders:" + this.chunkBorders);
printwriter.println("visGraph:" + this.experimentalVisGraph);
printwriter.println("bufferQueue:" + this.experimentalBufferQueue);
printwriter.println("ofCustomItems:" + this.ofCustomItems);
for (KeyBinding keybinding : this.keyBindings) {
printwriter.println("key_" + keybinding.getKeyDescription() + ":" + keybinding.getKeyCode());
@ -2173,7 +2186,8 @@ public class GameSettings {
TOGGLE_SPRINT("Sprint", false, false),
CHUNK_BORDERS("Chunk Borders", false, false),
VIS_GRAPH("Experimental VisGraph", false, false),
BUFFER_QUEUE("Experimental Queuing", false, false);
BUFFER_QUEUE("Experimental Queuing", false, false),
CUSTOM_ITEMS("Custom Items", false, false);
private final boolean enumFloat;
private final boolean enumBoolean;

View File

@ -1,6 +1,8 @@
package net.lax1dude.eaglercraft.v1_8.internal;
import org.teavm.jso.JSBody;
import org.teavm.jso.JSObject;
import org.teavm.jso.core.JSNumber;
import org.teavm.jso.webgl.WebGLUniformLocation;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
@ -592,4 +594,10 @@ public class PlatformOpenGL {
logger.error("##############################");
}
}
public static int _wglGetTexLevelParameteri(int glTexture2d, int i, int glTextureWidth) {
JSObject object = ctx.getTexParameter(glTexture2d, glTextureWidth);
int parameterValue = ((JSNumber) object).intValue();
return parameterValue;
}
}