Custom Items

This commit is contained in:
PeytonPlayz595 2024-01-26 02:19:29 +00:00
parent 61d4655c73
commit 49759827f0
15 changed files with 40325 additions and 38377 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -247,6 +247,10 @@ public class Config {
return Minecraft.getMinecraft().gameSettings.ofSmoothBiomes; return Minecraft.getMinecraft().gameSettings.ofSmoothBiomes;
} }
public static boolean isCustomItems() {
return Minecraft.getMinecraft().gameSettings.ofCustomItems;
}
public static int limit(int p_limit_0_, int p_limit_1_, int p_limit_2_) { 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_); return p_limit_0_ < p_limit_1_ ? p_limit_1_ : (p_limit_0_ > p_limit_2_ ? p_limit_2_ : p_limit_0_);
} }
@ -359,6 +363,19 @@ public class Config {
} }
} }
public static boolean parseBoolean(String p_parseBoolean_0_, boolean p_parseBoolean_1_) {
try {
if (p_parseBoolean_0_ == null) {
return p_parseBoolean_1_;
} else {
p_parseBoolean_0_ = p_parseBoolean_0_.trim();
return Boolean.parseBoolean(p_parseBoolean_0_);
}
} catch (NumberFormatException var3) {
return p_parseBoolean_1_;
}
}
public static String[] tokenize(String p_tokenize_0_, String p_tokenize_1_) { public static String[] tokenize(String p_tokenize_0_, String p_tokenize_1_) {
StringTokenizer stringtokenizer = new StringTokenizer(p_tokenize_0_, p_tokenize_1_); StringTokenizer stringtokenizer = new StringTokenizer(p_tokenize_0_, p_tokenize_1_);
List<String> list = new ArrayList<String>(); List<String> list = new ArrayList<String>();

View File

@ -0,0 +1,738 @@
package net.PeytonPlayz585.shadow;
import java.util.ArrayList;
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.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.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;
import net.PeytonPlayz585.shadow.math.*;
import net.PeytonPlayz585.shadow.opengl.*;
import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerTextureAtlasSprite;
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 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 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 model = null;
public Map < String, IBakedModel > mapModels = 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 CustomItemProperties(Properties p_i34_1_, String p_i34_2_) {
this.name = parseName(p_i34_2_);
this.basePath = parseBasePath(p_i34_2_);
this.type = this.parseType(p_i34_1_.getProperty("type"));
this.items = this.parseItems(p_i34_1_.getProperty("items"), p_i34_1_.getProperty("matchItems"));
this.mapTextures = parseTextures(p_i34_1_, this.basePath);
this.texture = parseTexture(p_i34_1_.getProperty("texture"), p_i34_1_.getProperty("tile"), p_i34_1_.getProperty("source"), p_i34_2_, this.basePath, this.type, this.mapTextures);
String s = p_i34_1_.getProperty("damage");
if (s != null) {
this.damagePercent = s.contains("%");
s.replace("%", "");
this.damage = this.parseRangeListInt(s);
this.damageMask = this.parseInt(p_i34_1_.getProperty("damageMask"), 0);
}
this.stackSize = this.parseRangeListInt(p_i34_1_.getProperty("stackSize"));
this.enchantmentIds = this.parseRangeListInt(p_i34_1_.getProperty("enchantmentIDs"));
this.enchantmentLevels = this.parseRangeListInt(p_i34_1_.getProperty("enchantmentLevels"));
this.nbtTagValues = this.parseNbtTagValues(p_i34_1_);
this.blend = Blender.parseBlend(p_i34_1_.getProperty("blend"));
this.speed = this.parseFloat(p_i34_1_.getProperty("speed"), 0.0F);
this.rotation = this.parseFloat(p_i34_1_.getProperty("rotation"), 0.0F);
this.layer = this.parseInt(p_i34_1_.getProperty("layer"), 0);
this.weight = this.parseInt(p_i34_1_.getProperty("weight"), 0);
this.duration = this.parseFloat(p_i34_1_.getProperty("duration"), 1.0F);
}
private static String parseName(String p_parseName_0_) {
String s = p_parseName_0_;
int i = p_parseName_0_.lastIndexOf(47);
if (i >= 0) {
s = p_parseName_0_.substring(i + 1);
}
int j = s.lastIndexOf(46);
if (j >= 0) {
s = s.substring(0, j);
}
return s;
}
private static String parseBasePath(String p_parseBasePath_0_) {
int i = p_parseBasePath_0_.lastIndexOf(47);
return i < 0 ? "" : p_parseBasePath_0_.substring(0, i);
}
private int parseType(String p_parseType_1_) {
if (p_parseType_1_ == null) {
return 1;
} else if (p_parseType_1_.equals("item")) {
return 1;
} else if (p_parseType_1_.equals("enchantment")) {
return 2;
} else if (p_parseType_1_.equals("armor")) {
return 3;
} else {
Config.warn("Unknown method: " + p_parseType_1_);
return 0;
}
}
private int[] parseItems(String p_parseItems_1_, String p_parseItems_2_) {
if (p_parseItems_1_ == null) {
p_parseItems_1_ = p_parseItems_2_;
}
if (p_parseItems_1_ == null) {
return null;
} else {
p_parseItems_1_ = p_parseItems_1_.trim();
Set set = new TreeSet();
String[] astring = Config.tokenize(p_parseItems_1_, " ");
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 p_parseTexture_0_, String p_parseTexture_1_, String p_parseTexture_2_, String p_parseTexture_3_, String p_parseTexture_4_, int p_parseTexture_5_, Map < String, String > p_parseTexture_6_) {
if (p_parseTexture_0_ == null) {
p_parseTexture_0_ = p_parseTexture_1_;
}
if (p_parseTexture_0_ == null) {
p_parseTexture_0_ = p_parseTexture_2_;
}
if (p_parseTexture_0_ != null) {
String s2 = ".png";
if (p_parseTexture_0_.endsWith(s2)) {
p_parseTexture_0_ = p_parseTexture_0_.substring(0, p_parseTexture_0_.length() - s2.length());
}
p_parseTexture_0_ = fixTextureName(p_parseTexture_0_, p_parseTexture_4_);
return p_parseTexture_0_;
} else if (p_parseTexture_5_ == 3) {
return null;
} else {
if (p_parseTexture_6_ != null) {
String s = (String) p_parseTexture_6_.get("texture.bow_standby");
if (s != null) {
return s;
}
}
String s1 = p_parseTexture_3_;
int i = p_parseTexture_3_.lastIndexOf(47);
if (i >= 0) {
s1 = p_parseTexture_3_.substring(i + 1);
}
int j = s1.lastIndexOf(46);
if (j >= 0) {
s1 = s1.substring(0, j);
}
s1 = fixTextureName(s1, p_parseTexture_4_);
return s1;
}
}
private static Map parseTextures(Properties p_parseTextures_0_, String p_parseTextures_1_) {
String s = "texture.";
Map map = getMatchingProperties(p_parseTextures_0_, s);
if (map.size() <= 0) {
return null;
} else {
Set set = map.keySet();
Map map1 = new LinkedHashMap();
for (Object s1: set) {
String s2 = (String) map.get(s1);
s2 = fixTextureName(s2, p_parseTextures_1_);
map1.put(s1, s2);
}
return map1;
}
}
private static String fixTextureName(String p_fixTextureName_0_, String p_fixTextureName_1_) {
p_fixTextureName_0_ = TextureUtils.fixResourcePath(p_fixTextureName_0_, p_fixTextureName_1_);
if (!p_fixTextureName_0_.startsWith(p_fixTextureName_1_) && !p_fixTextureName_0_.startsWith("textures/") && !p_fixTextureName_0_.startsWith("mcpatcher/")) {
p_fixTextureName_0_ = p_fixTextureName_1_ + "/" + p_fixTextureName_0_;
}
if (p_fixTextureName_0_.endsWith(".png")) {
p_fixTextureName_0_ = p_fixTextureName_0_.substring(0, p_fixTextureName_0_.length() - 4);
}
String s = "textures/blocks/";
if (p_fixTextureName_0_.startsWith(s)) {
p_fixTextureName_0_ = p_fixTextureName_0_.substring(s.length());
}
if (p_fixTextureName_0_.startsWith("/")) {
p_fixTextureName_0_ = p_fixTextureName_0_.substring(1);
}
return p_fixTextureName_0_;
}
private int parseInt(String p_parseInt_1_, int p_parseInt_2_) {
if (p_parseInt_1_ == null) {
return p_parseInt_2_;
} else {
p_parseInt_1_ = p_parseInt_1_.trim();
int i = Config.parseInt(p_parseInt_1_, Integer.MIN_VALUE);
if (i == Integer.MIN_VALUE) {
Config.warn("Invalid integer: " + p_parseInt_1_);
return p_parseInt_2_;
} else {
return i;
}
}
}
private float parseFloat(String p_parseFloat_1_, float p_parseFloat_2_) {
if (p_parseFloat_1_ == null) {
return p_parseFloat_2_;
} else {
p_parseFloat_1_ = p_parseFloat_1_.trim();
float f = Config.parseFloat(p_parseFloat_1_, Float.MIN_VALUE);
if (f == Float.MIN_VALUE) {
Config.warn("Invalid float: " + p_parseFloat_1_);
return p_parseFloat_2_;
} else {
return f;
}
}
}
private RangeListInt parseRangeListInt(String p_parseRangeListInt_1_) {
if (p_parseRangeListInt_1_ == null) {
return null;
} else {
String[] astring = Config.tokenize(p_parseRangeListInt_1_, " ");
RangeListInt rangelistint = new RangeListInt();
for (int i = 0; i < astring.length; ++i) {
String s = astring[i];
RangeInt rangeint = this.parseRangeInt(s);
if (rangeint == null) {
Config.warn("Invalid range list: " + p_parseRangeListInt_1_);
return null;
}
rangelistint.addRange(rangeint);
}
return rangelistint;
}
}
private RangeInt parseRangeInt(String p_parseRangeInt_1_) {
if (p_parseRangeInt_1_ == null) {
return null;
} else {
p_parseRangeInt_1_ = p_parseRangeInt_1_.trim();
int i = p_parseRangeInt_1_.length() - p_parseRangeInt_1_.replace("-", "").length();
if (i > 1) {
Config.warn("Invalid range: " + p_parseRangeInt_1_);
return null;
} else {
String[] astring = Config.tokenize(p_parseRangeInt_1_, "- ");
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: " + p_parseRangeInt_1_);
return null;
}
aint[j] = k;
}
if (aint.length == 1) {
int i1 = aint[0];
if (p_parseRangeInt_1_.startsWith("-")) {
return new RangeInt(0, i1);
} else if (p_parseRangeInt_1_.endsWith("-")) {
return new RangeInt(i1, 255);
} 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: " + p_parseRangeInt_1_);
return null;
}
}
}
}
private NbtTagValue[] parseNbtTagValues(Properties p_parseNbtTagValues_1_) {
String s = "nbt.";
Map map = getMatchingProperties(p_parseNbtTagValues_1_, s);
if (map.size() <= 0) {
return null;
} else {
List list = new ArrayList();
for (Object s1: map.keySet()) {
String s2 = (String) map.get(s1);
String s3 = ((String) 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 p_getMatchingProperties_0_, String p_getMatchingProperties_1_) {
Map map = new LinkedHashMap();
for (Object s: p_getMatchingProperties_0_.keySet()) {
String s1 = p_getMatchingProperties_0_.getProperty((String) s);
if (((String) s).startsWith(p_getMatchingProperties_1_)) {
map.put(s, s1);
}
}
return map;
}
public boolean isValid(String p_isValid_1_) {
if (this.name != null && this.name.length() > 0) {
if (this.basePath == null) {
Config.warn("No base path found: " + p_isValid_1_);
return false;
} else if (this.type == 0) {
Config.warn("No type defined: " + p_isValid_1_);
return false;
} else if ((this.type == 1 || this.type == 3) && this.items == null) {
Config.warn("No items defined: " + p_isValid_1_);
return false;
} else if (this.texture == null && this.mapTextures == null) {
Config.warn("No texture specified: " + p_isValid_1_);
return false;
} else if (this.type == 2 && this.enchantmentIds == null) {
Config.warn("No enchantmentIDs specified: " + p_isValid_1_);
return false;
} else {
return true;
}
} else {
Config.warn("No name found: " + p_isValid_1_);
return false;
}
}
public void updateIcons(TextureMap p_updateIcons_1_) {
if (this.texture != null) {
this.textureLocation = this.getTextureLocation(this.texture);
if (this.type == 1) {
ResourceLocation resourcelocation = this.getSpriteLocation(this.textureLocation);
this.sprite = p_updateIcons_1_.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 = p_updateIcons_1_.registerSprite(resourcelocation2);
this.mapSprites.put(s, textureatlassprite);
}
}
}
}
private ResourceLocation getTextureLocation(String p_getTextureLocation_1_) {
if (p_getTextureLocation_1_ == null) {
return null;
} else {
ResourceLocation resourcelocation = new ResourceLocation(p_getTextureLocation_1_);
String s = resourcelocation.getResourceDomain();
String s1 = resourcelocation.getResourcePath();
if (!s1.contains("/")) {
s1 = "textures/blocks/" + 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 p_getSpriteLocation_1_) {
String s = p_getSpriteLocation_1_.getResourcePath();
s = StrUtils.removePrefix(s, "textures/");
s = StrUtils.removeSuffix(s, ".png");
ResourceLocation resourcelocation = new ResourceLocation(p_getSpriteLocation_1_.getResourceDomain(), s);
return resourcelocation;
}
public void updateModel(TextureMap p_updateModel_1_, ItemModelGenerator p_updateModel_2_) {
String[] astring = this.getModelTextures();
boolean flag = this.isUseTint();
this.model = makeBakedModel(p_updateModel_1_, p_updateModel_2_, 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")) {
String[] astring1 = new String[] {
s1
};
IBakedModel ibakedmodel = makeBakedModel(p_updateModel_1_, p_updateModel_2_, astring1, flag);
if (this.mapModels == null) {
this.mapModels = new HashMap();
}
this.mapModels.put(s2, ibakedmodel);
}
}
}
}
private boolean isUseTint() {
return true;
}
private static IBakedModel makeBakedModel(TextureMap p_makeBakedModel_0_, ItemModelGenerator p_makeBakedModel_1_, String[] p_makeBakedModel_2_, boolean p_makeBakedModel_3_) {
ModelBlock modelblock = makeModelBlock(p_makeBakedModel_2_);
ModelBlock modelblock1 = p_makeBakedModel_1_.makeItemModel(p_makeBakedModel_0_, modelblock);
IBakedModel ibakedmodel = bakeModel(p_makeBakedModel_0_, modelblock1, p_makeBakedModel_3_);
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 > p_getMapTexture_1_, String p_getMapTexture_2_, String p_getMapTexture_3_) {
if (p_getMapTexture_1_ == null) {
return p_getMapTexture_3_;
} else {
String s = (String) p_getMapTexture_1_.get(p_getMapTexture_2_);
return s == null ? p_getMapTexture_3_ : s;
}
}
private static ModelBlock makeModelBlock(String[] p_makeModelBlock_0_) {
StringBuffer stringbuffer = new StringBuffer();
stringbuffer.append("{\"parent\": \"builtin/generated\",\"textures\": {");
for (int i = 0; i < p_makeModelBlock_0_.length; ++i) {
String s = p_makeModelBlock_0_[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 p_bakeModel_0_, ModelBlock p_bakeModel_1_, boolean p_bakeModel_2_) {
ModelRotation modelrotation = ModelRotation.X0_Y0;
boolean flag = false;
EaglerTextureAtlasSprite textureatlassprite = p_bakeModel_0_.getSpriteSafe(p_bakeModel_1_.resolveTextureName("particle"));
SimpleBakedModel.Builder simplebakedmodel$builder = (new SimpleBakedModel.Builder(p_bakeModel_1_)).setTexture(textureatlassprite);
for (BlockPart blockpart: p_bakeModel_1_.getElements()) {
for (EnumFacing enumfacing: blockpart.mapFaces.keySet()) {
BlockPartFace blockpartface = (BlockPartFace) blockpart.mapFaces.get(enumfacing);
if (!p_bakeModel_2_) {
blockpartface = new BlockPartFace(blockpartface.cullFace, -1, blockpartface.texture, blockpartface.blockFaceUV);
}
EaglerTextureAtlasSprite textureatlassprite1 = p_bakeModel_0_.getSpriteSafe(p_bakeModel_1_.resolveTextureName(blockpartface.texture));
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 p_makeBakedQuad_0_, BlockPartFace p_makeBakedQuad_1_, EaglerTextureAtlasSprite p_makeBakedQuad_2_, EnumFacing p_makeBakedQuad_3_, ModelRotation p_makeBakedQuad_4_, boolean p_makeBakedQuad_5_) {
FaceBakery facebakery = new FaceBakery();
return facebakery.makeBakedQuad(p_makeBakedQuad_0_.positionFrom, p_makeBakedQuad_0_.positionTo, p_makeBakedQuad_1_, p_makeBakedQuad_2_, p_makeBakedQuad_3_, p_makeBakedQuad_4_, p_makeBakedQuad_0_.partRotation, p_makeBakedQuad_5_, p_makeBakedQuad_0_.shade);
}
public String toString() {
return "" + this.basePath + "/" + this.name + ", type: " + this.type + ", items: [" + Config.arrayToString(this.items) + "], textture: " + this.texture;
}
public float getTextureWidth(TextureManager p_getTextureWidth_1_) {
if (this.textureWidth <= 0) {
if (this.textureLocation != null) {
ITextureObject itextureobject = p_getTextureWidth_1_.getTexture(this.textureLocation);
int i = itextureobject.getGlTextureId();
int j = GlStateManager.getBoundTexture();
GlStateManager.bindTexture(i);
this.textureWidth = GL11.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 p_getTextureHeight_1_) {
if (this.textureHeight <= 0) {
if (this.textureLocation != null) {
ITextureObject itextureobject = p_getTextureHeight_1_.getTexture(this.textureLocation);
int i = itextureobject.getGlTextureId();
int j = GlStateManager.getBoundTexture();
GlStateManager.bindTexture(i);
this.textureHeight = GL11.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 getModel(ModelResourceLocation p_getModel_1_) {
if (p_getModel_1_ != null && this.mapTextures != null) {
String s = p_getModel_1_.getResourcePath();
if (this.mapModels != null) {
IBakedModel ibakedmodel = (IBakedModel) this.mapModels.get(s);
if (ibakedmodel != null) {
return ibakedmodel;
}
}
}
return this.model;
}
}

View File

@ -0,0 +1,781 @@
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.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBase;
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
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.ModelResourceLocation;
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;
public static final int MASK_POTION_SPLASH = 16384;
public static final int MASK_POTION_NAME = 63;
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_INT_ARRAY = new int[0];
private static final int[][] EMPTY_INT2_ARRAY = new int[0][];
public static void updateIcons(TextureMap p_updateIcons_0_) {
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];
updateIcons(p_updateIcons_0_, iresourcepack);
}
updateIcons(p_updateIcons_0_, Config.getDefaultResourcePack());
if (itemProperties.length <= 0) {
itemProperties = (CustomItemProperties[][]) null;
}
if (enchantmentProperties.length <= 0) {
enchantmentProperties = (CustomItemProperties[][]) null;
}
}
}
private static void readCitProperties(String p_readCitProperties_0_) {
try {
ResourceLocation resourcelocation = new ResourceLocation(p_readCitProperties_0_);
InputStream inputstream = Config.getResourceStream(resourcelocation);
if (inputstream == null) {
return;
}
Config.dbg("CustomItems: Loading " + p_readCitProperties_0_);
Properties properties = new Properties();
properties.load(inputstream);
inputstream.close();
useGlint = Config.parseBoolean(properties.getProperty("useGlint"), true);
} catch (FileNotFoundException var4) {
return;
} catch (IOException ioexception) {
ioexception.printStackTrace();
}
}
private static void updateIcons(TextureMap p_updateIcons_0_, IResourcePack p_updateIcons_1_) {
String[] astring = ResUtils.collectFiles(p_updateIcons_1_, (String)
"mcpatcher/cit/", (String)
".properties", (String[]) null);
Map map = makeAutoImageProperties(p_updateIcons_1_);
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 = p_updateIcons_1_.getInputStream(resourcelocation);
if (inputstream == null) {
Config.warn("CustomItems file not found: " + s);
continue;
}
Properties properties = new Properties();
properties.load(inputstream);
customitemproperties = new CustomItemProperties(properties, s);
}
if (customitemproperties.isValid(s)) {
customitemproperties.updateIcons(p_updateIcons_0_);
addToItemList(customitemproperties, list);
addToEnchantmentList(customitemproperties, list1);
}
} catch (FileNotFoundException var12) {
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 p_compare_1_, Object p_compare_2_) {
CustomItemProperties customitemproperties = (CustomItemProperties) p_compare_1_;
CustomItemProperties customitemproperties1 = (CustomItemProperties) p_compare_2_;
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 updateModels() {
if (itemProperties != null) {
for (int i = 0; i < itemProperties.length; ++i) {
CustomItemProperties[] acustomitemproperties = itemProperties[i];
if (acustomitemproperties != null) {
for (int j = 0; j < acustomitemproperties.length; ++j) {
CustomItemProperties customitemproperties = acustomitemproperties[j];
if (customitemproperties != null && customitemproperties.type == 1) {
TextureMap texturemap = Minecraft.getMinecraft().getTextureMapBlocks();
customitemproperties.updateModel(texturemap, itemModelGenerator);
}
}
}
}
}
}
private static Map makeAutoImageProperties(IResourcePack p_makeAutoImageProperties_0_) {
Map map = new HashMap();
map.putAll(makePotionImageProperties(p_makeAutoImageProperties_0_, false));
map.putAll(makePotionImageProperties(p_makeAutoImageProperties_0_, true));
return map;
}
private static Map makePotionImageProperties(IResourcePack p_makePotionImageProperties_0_, boolean p_makePotionImageProperties_1_) {
Map map = new HashMap();
String s = p_makePotionImageProperties_1_ ? "splash/" : "normal/";
String[] astring = new String[] {
"mcpatcher/cit/potion/" + s, "mcpatcher/cit/Potion/" + s
};
String[] astring1 = new String[] {
".png"
};
String[] astring2 = ResUtils.collectFiles(p_makePotionImageProperties_0_, 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, p_makePotionImageProperties_1_, 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 p_makePotionProperties_0_, boolean p_makePotionProperties_1_, String p_makePotionProperties_2_) {
if (StrUtils.endsWith(p_makePotionProperties_0_, new String[] {
"_n",
"_s"
})) {
return null;
} else if (p_makePotionProperties_0_.equals("empty") && !p_makePotionProperties_1_) {
int l = Item.getIdFromItem(Items.glass_bottle);
Properties properties = new Properties();
properties.put("type", "item");
properties.put("items", "" + l);
return properties;
} else {
int i = Item.getIdFromItem(Items.potionitem);
int[] aint = (int[])((int[]) getMapPotionIds().get(p_makePotionProperties_0_));
if (aint == null) {
Config.warn("Potion not found for image: " + p_makePotionProperties_2_);
return null;
} else {
StringBuffer stringbuffer = new StringBuffer();
for (int j = 0; j < aint.length; ++j) {
int k = aint[j];
if (p_makePotionProperties_1_) {
k |= 16384;
}
if (j > 0) {
stringbuffer.append(" ");
}
stringbuffer.append(k);
}
int i1 = 16447;
Properties properties1 = new Properties();
properties1.put("type", "item");
properties1.put("items", "" + i);
properties1.put("damage", "" + stringbuffer.toString());
properties1.put("damageMask", "" + i1);
if (p_makePotionProperties_1_) {
properties1.put("texture.potion_bottle_splash", p_makePotionProperties_0_);
} else {
properties1.put("texture.potion_bottle_drinkable", p_makePotionProperties_0_);
}
return properties1;
}
}
}
private static Map getMapPotionIds() {
if (mapPotionIds == null) {
mapPotionIds = new LinkedHashMap();
mapPotionIds.put("water", new int[] {
0
});
mapPotionIds.put("awkward", new int[] {
16
});
mapPotionIds.put("thick", new int[] {
32
});
mapPotionIds.put("potent", new int[] {
48
});
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", getPotionIds(7));
mapPotionIds.put("bungling", getPotionIds(23));
mapPotionIds.put("charming", getPotionIds(39));
mapPotionIds.put("rank", getPotionIds(55));
mapPotionIds.put("weakness", getPotionIds(8));
mapPotionIds.put("damageBoost", getPotionIds(9));
mapPotionIds.put("moveSlowdown", getPotionIds(10));
mapPotionIds.put("diffuse", getPotionIds(11));
mapPotionIds.put("smooth", getPotionIds(27));
mapPotionIds.put("refined", getPotionIds(43));
mapPotionIds.put("acrid", getPotionIds(59));
mapPotionIds.put("harm", getPotionIds(12));
mapPotionIds.put("waterBreathing", getPotionIds(13));
mapPotionIds.put("invisibility", getPotionIds(14));
mapPotionIds.put("thin", getPotionIds(15));
mapPotionIds.put("debonair", getPotionIds(31));
mapPotionIds.put("sparkling", getPotionIds(47));
mapPotionIds.put("stinky", getPotionIds(63));
}
return mapPotionIds;
}
private static int[] getPotionIds(int p_getPotionIds_0_) {
return new int[] {
p_getPotionIds_0_,
p_getPotionIds_0_ + 16,
p_getPotionIds_0_ + 32,
p_getPotionIds_0_ + 48
};
}
private static int getPotionNameDamage(String p_getPotionNameDamage_0_) {
String s = "potion." + p_getPotionNameDamage_0_;
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[][] p_makePropertyList_0_) {
List list = new ArrayList();
if (p_makePropertyList_0_ != null) {
for (int i = 0; i < p_makePropertyList_0_.length; ++i) {
CustomItemProperties[] acustomitemproperties = p_makePropertyList_0_[i];
List list1 = null;
if (acustomitemproperties != null) {
list1 = new ArrayList(Arrays.asList(acustomitemproperties));
}
list.add(list1);
}
}
return list;
}
private static CustomItemProperties[][] propertyListToArray(List p_propertyListToArray_0_) {
CustomItemProperties[][] acustomitemproperties = new CustomItemProperties[p_propertyListToArray_0_.size()][];
for (int i = 0; i < p_propertyListToArray_0_.size(); ++i) {
List list = (List) p_propertyListToArray_0_.get(i);
if (list != null) {
CustomItemProperties[] acustomitemproperties1 = (CustomItemProperties[])((CustomItemProperties[]) list.toArray(new CustomItemProperties[list.size()]));
Arrays.sort(acustomitemproperties1, new CustomItemsComparator());
acustomitemproperties[i] = acustomitemproperties1;
}
}
return acustomitemproperties;
}
private static void addToItemList(CustomItemProperties p_addToItemList_0_, List p_addToItemList_1_) {
if (p_addToItemList_0_.items != null) {
for (int i = 0; i < p_addToItemList_0_.items.length; ++i) {
int j = p_addToItemList_0_.items[i];
if (j <= 0) {
Config.warn("Invalid item ID: " + j);
} else {
addToList(p_addToItemList_0_, p_addToItemList_1_, j);
}
}
}
}
private static void addToEnchantmentList(CustomItemProperties p_addToEnchantmentList_0_, List p_addToEnchantmentList_1_) {
if (p_addToEnchantmentList_0_.type == 2) {
if (p_addToEnchantmentList_0_.enchantmentIds != null) {
for (int i = 0; i < 256; ++i) {
if (p_addToEnchantmentList_0_.enchantmentIds.isInRange(i)) {
addToList(p_addToEnchantmentList_0_, p_addToEnchantmentList_1_, i);
}
}
}
}
}
private static void addToList(CustomItemProperties p_addToList_0_, List p_addToList_1_, int p_addToList_2_) {
while (p_addToList_2_ >= p_addToList_1_.size()) {
p_addToList_1_.add(null);
}
List list = (List) p_addToList_1_.get(p_addToList_2_);
if (list == null) {
list = new ArrayList();
p_addToList_1_.set(p_addToList_2_, list);
}
list.add(p_addToList_0_);
}
public static IBakedModel getCustomItemModel(ItemStack p_getCustomItemModel_0_, IBakedModel p_getCustomItemModel_1_, ModelResourceLocation p_getCustomItemModel_2_) {
if (p_getCustomItemModel_1_.isGui3d()) {
return p_getCustomItemModel_1_;
} else if (itemProperties == null) {
return p_getCustomItemModel_1_;
} else {
CustomItemProperties customitemproperties = getCustomItemProperties(p_getCustomItemModel_0_, 1);
return customitemproperties == null ? p_getCustomItemModel_1_ : customitemproperties.getModel(p_getCustomItemModel_2_);
}
}
public static boolean bindCustomArmorTexture(ItemStack p_bindCustomArmorTexture_0_, int p_bindCustomArmorTexture_1_, String p_bindCustomArmorTexture_2_) {
if (itemProperties == null) {
return false;
} else {
ResourceLocation resourcelocation = getCustomArmorLocation(p_bindCustomArmorTexture_0_, p_bindCustomArmorTexture_1_, p_bindCustomArmorTexture_2_);
if (resourcelocation == null) {
return false;
} else {
Config.getTextureManager().bindTexture(resourcelocation);
return true;
}
}
}
private static ResourceLocation getCustomArmorLocation(ItemStack p_getCustomArmorLocation_0_, int p_getCustomArmorLocation_1_, String p_getCustomArmorLocation_2_) {
CustomItemProperties customitemproperties = getCustomItemProperties(p_getCustomArmorLocation_0_, 3);
if (customitemproperties == null) {
return null;
} else if (customitemproperties.mapTextureLocations == null) {
return null;
} else {
Item item = p_getCustomArmorLocation_0_.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(p_getCustomArmorLocation_1_);
if (p_getCustomArmorLocation_2_ != null) {
stringbuffer.append("_");
stringbuffer.append(p_getCustomArmorLocation_2_);
}
String s1 = stringbuffer.toString();
ResourceLocation resourcelocation = (ResourceLocation) customitemproperties.mapTextureLocations.get(s1);
return resourcelocation;
}
}
}
private static CustomItemProperties getCustomItemProperties(ItemStack p_getCustomItemProperties_0_, int p_getCustomItemProperties_1_) {
if (itemProperties == null) {
return null;
} else if (p_getCustomItemProperties_0_ == null) {
return null;
} else {
Item item = p_getCustomItemProperties_0_.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 == p_getCustomItemProperties_1_ && matchesProperties(customitemproperties, p_getCustomItemProperties_0_, (int[][]) null)) {
return customitemproperties;
}
}
}
}
return null;
}
}
private static boolean matchesProperties(CustomItemProperties p_matchesProperties_0_, ItemStack p_matchesProperties_1_, int[][] p_matchesProperties_2_) {
Item item = p_matchesProperties_1_.getItem();
if (p_matchesProperties_0_.damage != null) {
int i = p_matchesProperties_1_.getItemDamage();
if (p_matchesProperties_0_.damageMask != 0) {
i &= p_matchesProperties_0_.damageMask;
}
if (p_matchesProperties_0_.damagePercent) {
int j = item.getMaxDamage();
i = (int)((double)(i * 100) / (double) j);
}
if (!p_matchesProperties_0_.damage.isInRange(i)) {
return false;
}
}
if (p_matchesProperties_0_.stackSize != null && !p_matchesProperties_0_.stackSize.isInRange(p_matchesProperties_1_.stackSize)) {
return false;
} else {
int[][] aint = p_matchesProperties_2_;
if (p_matchesProperties_0_.enchantmentIds != null) {
if (p_matchesProperties_2_ == null) {
aint = getEnchantmentIdLevels(p_matchesProperties_1_);
}
boolean flag = false;
for (int k = 0; k < aint.length; ++k) {
int l = aint[k][0];
if (p_matchesProperties_0_.enchantmentIds.isInRange(l)) {
flag = true;
break;
}
}
if (!flag) {
return false;
}
}
if (p_matchesProperties_0_.enchantmentLevels != null) {
if (aint == null) {
aint = getEnchantmentIdLevels(p_matchesProperties_1_);
}
boolean flag1 = false;
for (int i1 = 0; i1 < aint.length; ++i1) {
int k1 = aint[i1][1];
if (p_matchesProperties_0_.enchantmentLevels.isInRange(k1)) {
flag1 = true;
break;
}
}
if (!flag1) {
return false;
}
}
if (p_matchesProperties_0_.nbtTagValues != null) {
NBTTagCompound nbttagcompound = p_matchesProperties_1_.getTagCompound();
for (int j1 = 0; j1 < p_matchesProperties_0_.nbtTagValues.length; ++j1) {
NbtTagValue nbttagvalue = p_matchesProperties_0_.nbtTagValues[j1];
if (!nbttagvalue.matches(nbttagcompound)) {
return false;
}
}
}
return true;
}
}
private static int[][] getEnchantmentIdLevels(ItemStack p_getEnchantmentIdLevels_0_) {
Item item = p_getEnchantmentIdLevels_0_.getItem();
NBTTagList nbttaglist = item == Items.enchanted_book ? Items.enchanted_book.getEnchantments(p_getEnchantmentIdLevels_0_) : p_getEnchantmentIdLevels_0_.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 p_renderCustomEffect_0_, ItemStack p_renderCustomEffect_1_, IBakedModel p_renderCustomEffect_2_) {
if (enchantmentProperties == null) {
return false;
} else if (p_renderCustomEffect_1_ == null) {
return false;
} else {
int[][] aint = getEnchantmentIdLevels(p_renderCustomEffect_1_);
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, p_renderCustomEffect_1_, 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);
p_renderCustomEffect_0_.renderModel(p_renderCustomEffect_2_, -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 p_renderCustomArmorEffect_0_, ItemStack p_renderCustomArmorEffect_1_, ModelBase p_renderCustomArmorEffect_2_, float p_renderCustomArmorEffect_3_, float p_renderCustomArmorEffect_4_, float p_renderCustomArmorEffect_5_, float p_renderCustomArmorEffect_6_, float p_renderCustomArmorEffect_7_, float p_renderCustomArmorEffect_8_, float p_renderCustomArmorEffect_9_) {
if (enchantmentProperties == null) {
return false;
} else if (p_renderCustomArmorEffect_1_ == null) {
return false;
} else {
int[][] aint = getEnchantmentIdLevels(p_renderCustomArmorEffect_1_);
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, p_renderCustomArmorEffect_1_, 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);
p_renderCustomArmorEffect_2_.render(p_renderCustomArmorEffect_0_, p_renderCustomArmorEffect_3_, p_renderCustomArmorEffect_4_, p_renderCustomArmorEffect_6_, p_renderCustomArmorEffect_7_, p_renderCustomArmorEffect_8_, p_renderCustomArmorEffect_9_);
}
}
}
}
}
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 p_compare_1_, Object p_compare_2_) {
CustomItemProperties customitemproperties = (CustomItemProperties)p_compare_1_;
CustomItemProperties customitemproperties1 = (CustomItemProperties)p_compare_2_;
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,223 @@
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_ = 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();
}
public static String unescapeJava(String str) {
return str.replaceAll("\\\\([btnrf\"\'\\/])", "$1");
}
}

View File

@ -136,6 +136,7 @@ public class TextureUtils {
BetterGrass.update(); BetterGrass.update();
BetterSnow.update(); BetterSnow.update();
CustomSky.update(); CustomSky.update();
CustomItems.updateModels();
SmartLeaves.updateLeavesModels(); SmartLeaves.updateLeavesModels();
} }
} }

View File

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

View File

@ -0,0 +1,22 @@
package net.PeytonPlayz585.shadow.opengl;
import org.teavm.jso.core.JSNumber;
import org.teavm.jso.JSObject;
import org.teavm.jso.webgl.*;
import net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL;
import net.lax1dude.eaglercraft.v1_8.internal.teavm.WebGL2RenderingContext;
import net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums;
public class GL11 {
public static int glGetTexLevelParameteri(int target, int level, int pname) {
WebGL2RenderingContext gl = PlatformOpenGL.ctx;
WebGLTexture texture = gl.createTexture();
gl.bindTexture(target, texture);
JSObject parameterObj = gl.getTexParameter(target, pname);
JSNumber parameterNumber = parameterObj.cast();
int parameter = parameterNumber.intValue();
gl.bindTexture(target, null);
return parameter;
}
}

View File

@ -120,6 +120,8 @@ public class GlStateManager {
static float clearDepth = -999.0f; static float clearDepth = -999.0f;
private static GlStateManager.TextureState[] textureState = new GlStateManager.TextureState[32];
public static enum TexGen { public static enum TexGen {
S, T, R, Q; S, T, R, Q;
@ -1196,4 +1198,63 @@ public class GlStateManager {
public static void recompileShaders() { public static void recompileShaders() {
FixedFunctionPipeline.flushCache(); FixedFunctionPipeline.flushCache();
} }
public static int getBoundTexture() {
return textureState[activeTexture].textureName;
}
static {
for (int j = 0; j < textureState.length; ++j) {
textureState[j] = new GlStateManager.TextureState((GlStateManager.GlStateManager$1)null);
}
}
static final class GlStateManager$1 {
}
static class BooleanState {
private final int capability;
private boolean currentState = false;
private static final String __OBFID = "CL_00002554";
public BooleanState(int capabilityIn) {
this.capability = capabilityIn;
}
public void setDisabled() {
this.setState(false);
}
public void setEnabled() {
this.setState(true);
}
public void setState(boolean state) {
if (state != this.currentState) {
this.currentState = state;
if (state) {
_wglEnable(this.capability);
} else {
_wglDisable(this.capability);
}
}
}
}
static class TextureState {
public GlStateManager.BooleanState texture2DState;
public int textureName;
private static final String __OBFID = "CL_00002539";
private TextureState() {
this.texture2DState = new GlStateManager.BooleanState(3553);
this.textureName = 0;
}
TextureState(GlStateManager.GlStateManager$1 p_i46476_1_) {
this();
}
}
} }

View File

@ -7,6 +7,7 @@ import java.util.concurrent.Callable;
import net.PeytonPlayz585.shadow.Config; import net.PeytonPlayz585.shadow.Config;
import net.PeytonPlayz585.shadow.CustomColors; import net.PeytonPlayz585.shadow.CustomColors;
import net.PeytonPlayz585.shadow.CustomItems;
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager; import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer; import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.DeferredStateManager; import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.DeferredStateManager;
@ -96,6 +97,8 @@ public class RenderItem implements IResourceManagerReloadListener {
private final ItemModelMesher itemModelMesher; private final ItemModelMesher itemModelMesher;
private final TextureManager textureManager; private final TextureManager textureManager;
private ModelResourceLocation modelLocation = null;
public RenderItem(TextureManager textureManager, ModelManager modelManager) { public RenderItem(TextureManager textureManager, ModelManager modelManager) {
this.textureManager = textureManager; this.textureManager = textureManager;
this.modelManager = modelManager; this.modelManager = modelManager;
@ -127,15 +130,15 @@ public class RenderItem implements IResourceManagerReloadListener {
this.registerItem(itm, 0, identifier); this.registerItem(itm, 0, identifier);
} }
private void renderModel(IBakedModel model, ItemStack stack) { public void renderModel(IBakedModel model, ItemStack stack) {
this.renderModel(model, -1, stack); 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); this.renderModel(model, color, (ItemStack) null);
} }
private void renderModel(IBakedModel model, int color, ItemStack stack) { public void renderModel(IBakedModel model, int color, ItemStack stack) {
Tessellator tessellator = Tessellator.getInstance(); Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldrenderer = tessellator.getWorldRenderer(); WorldRenderer worldrenderer = tessellator.getWorldRenderer();
worldrenderer.begin(7, DefaultVertexFormats.ITEM); worldrenderer.begin(7, DefaultVertexFormats.ITEM);
@ -153,17 +156,24 @@ public class RenderItem implements IResourceManagerReloadListener {
public static float renderPosZ = 0.0f; public static float renderPosZ = 0.0f;
public ModelManager modelManager = null; public ModelManager modelManager = null;
public void renderItem(ItemStack stack, IBakedModel model) { public void renderItem(ItemStack stack, IBakedModel model1) {
if (stack != null) { if (stack != null) {
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
GlStateManager.scale(0.5F, 0.5F, 0.5F); GlStateManager.scale(0.5F, 0.5F, 0.5F);
if (model.isBuiltInRenderer()) { if (model1.isBuiltInRenderer()) {
GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
GlStateManager.translate(-0.5F, -0.5F, -0.5F); GlStateManager.translate(-0.5F, -0.5F, -0.5F);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.enableRescaleNormal(); GlStateManager.enableRescaleNormal();
TileEntityItemStackRenderer.instance.renderByItem(stack); TileEntityItemStackRenderer.instance.renderByItem(stack);
} else { } else {
if (Config.isCustomItems()) {
model1 = CustomItems.getCustomItemModel(stack, model1, this.modelLocation);
}
final IBakedModel model = model1;
GlStateManager.translate(-0.5F, -0.5F, -0.5F); GlStateManager.translate(-0.5F, -0.5F, -0.5F);
if (DeferredStateManager.isInDeferredPass() && isTransparentItem(stack)) { if (DeferredStateManager.isInDeferredPass() && isTransparentItem(stack)) {
if (DeferredStateManager.forwardCallbackHandler != null) { if (DeferredStateManager.forwardCallbackHandler != null) {
@ -206,6 +216,7 @@ public class RenderItem implements IResourceManagerReloadListener {
&& !DeferredStateManager.isEnableShadowRender()) { && !DeferredStateManager.isEnableShadowRender()) {
final Matrix4f mat = new Matrix4f(GlStateManager.getModelViewReference()); final Matrix4f mat = new Matrix4f(GlStateManager.getModelViewReference());
final float lx = GlStateManager.getTexCoordX(1), ly = GlStateManager.getTexCoordY(1); final float lx = GlStateManager.getTexCoordX(1), ly = GlStateManager.getTexCoordY(1);
RenderItem itemRenderer = this;
DeferredStateManager.forwardCallbackHandler.push(new ShadersRenderPassFuture(renderPosX, DeferredStateManager.forwardCallbackHandler.push(new ShadersRenderPassFuture(renderPosX,
renderPosY, renderPosZ, EaglerDeferredPipeline.instance.getPartialTicks()) { renderPosY, renderPosZ, EaglerDeferredPipeline.instance.getPartialTicks()) {
@Override @Override
@ -222,7 +233,9 @@ public class RenderItem implements IResourceManagerReloadListener {
GlStateManager.loadMatrix(mat); GlStateManager.loadMatrix(mat);
GlStateManager.texCoords2DDirect(1, lx, ly); GlStateManager.texCoords2DDirect(1, lx, ly);
GlStateManager.tryBlendFuncSeparate(GL_ONE, GL_ONE, GL_ZERO, GL_ONE); GlStateManager.tryBlendFuncSeparate(GL_ONE, GL_ONE, GL_ZERO, GL_ONE);
renderEffect(model); if (stack.hasEffect() && (!Config.isCustomItems() || !CustomItems.renderCustomEffect(itemRenderer, stack, model))) {
renderEffect(model);
}
DeferredStateManager.setHDRTranslucentPassBlendFunc(); DeferredStateManager.setHDRTranslucentPassBlendFunc();
GlStateManager.popMatrix(); GlStateManager.popMatrix();
EntityRenderer.disableLightmapStatic(); EntityRenderer.disableLightmapStatic();
@ -232,7 +245,9 @@ public class RenderItem implements IResourceManagerReloadListener {
} }
} else { } else {
GlStateManager.blendFunc(GL_SRC_COLOR, GL_ONE); GlStateManager.blendFunc(GL_SRC_COLOR, GL_ONE);
this.renderEffect(model); if (stack.hasEffect() && (!Config.isCustomItems() || !CustomItems.renderCustomEffect(this, stack, model))) {
renderEffect(model);
}
} }
} }
} }
@ -249,31 +264,33 @@ public class RenderItem implements IResourceManagerReloadListener {
} }
private void renderEffect(IBakedModel model) { private void renderEffect(IBakedModel model) {
GlStateManager.depthMask(false); if(!Config.isCustomItems() || CustomItems.isUseGlint()) {
GlStateManager.depthFunc(GL_EQUAL); GlStateManager.depthMask(false);
GlStateManager.disableLighting(); GlStateManager.depthFunc(GL_EQUAL);
this.textureManager.bindTexture(RES_ITEM_GLINT); GlStateManager.disableLighting();
GlStateManager.matrixMode(GL_TEXTURE); this.textureManager.bindTexture(RES_ITEM_GLINT);
GlStateManager.pushMatrix(); GlStateManager.matrixMode(GL_TEXTURE);
GlStateManager.scale(8.0F, 8.0F, 8.0F); GlStateManager.pushMatrix();
float f = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F / 8.0F; GlStateManager.scale(8.0F, 8.0F, 8.0F);
GlStateManager.translate(f, 0.0F, 0.0F); float f = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F / 8.0F;
GlStateManager.rotate(-50.0F, 0.0F, 0.0F, 1.0F); GlStateManager.translate(f, 0.0F, 0.0F);
this.renderModel(model, -8372020); GlStateManager.rotate(-50.0F, 0.0F, 0.0F, 1.0F);
GlStateManager.popMatrix(); this.renderModel(model, -8372020);
GlStateManager.pushMatrix(); GlStateManager.popMatrix();
GlStateManager.scale(8.0F, 8.0F, 8.0F); GlStateManager.pushMatrix();
float f1 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F / 8.0F; GlStateManager.scale(8.0F, 8.0F, 8.0F);
GlStateManager.translate(-f1, 0.0F, 0.0F); float f1 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F / 8.0F;
GlStateManager.rotate(10.0F, 0.0F, 0.0F, 1.0F); GlStateManager.translate(-f1, 0.0F, 0.0F);
this.renderModel(model, -8372020); GlStateManager.rotate(10.0F, 0.0F, 0.0F, 1.0F);
GlStateManager.popMatrix(); this.renderModel(model, -8372020);
GlStateManager.matrixMode(GL_MODELVIEW); GlStateManager.popMatrix();
GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); GlStateManager.matrixMode(GL_MODELVIEW);
GlStateManager.enableLighting(); GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.depthFunc(GL_LEQUAL); GlStateManager.enableLighting();
GlStateManager.depthMask(true); GlStateManager.depthFunc(GL_LEQUAL);
this.textureManager.bindTexture(TextureMap.locationBlocksTexture); GlStateManager.depthMask(true);
this.textureManager.bindTexture(TextureMap.locationBlocksTexture);
}
} }
private void putQuadNormal(WorldRenderer renderer, BakedQuad quad) { private void putQuadNormal(WorldRenderer renderer, BakedQuad quad) {
@ -359,12 +376,15 @@ public class RenderItem implements IResourceManagerReloadListener {
} }
} }
this.modelLocation = modelresourcelocation;
if (modelresourcelocation != null) { if (modelresourcelocation != null) {
ibakedmodel = this.itemModelMesher.getModelManager().getModel(modelresourcelocation); ibakedmodel = this.itemModelMesher.getModelManager().getModel(modelresourcelocation);
} }
} }
this.renderItemModelTransform(stack, ibakedmodel, cameraTransformType); this.renderItemModelTransform(stack, ibakedmodel, cameraTransformType);
this.modelLocation = null;
} }
} }

View File

@ -583,6 +583,11 @@ public class TextureMap extends AbstractTexture implements ITickableTextureObjec
} }
} }
public EaglerTextureAtlasSprite getSpriteSafe(String p_getSpriteSafe_1_) {
ResourceLocation resourcelocation = new ResourceLocation(p_getSpriteSafe_1_);
return (EaglerTextureAtlasSprite)this.mapRegisteredSprites.get(resourcelocation.toString());
}
private boolean isTerrainAnimationActive(EaglerTextureAtlasSprite p_isTerrainAnimationActive_0_) { private boolean isTerrainAnimationActive(EaglerTextureAtlasSprite p_isTerrainAnimationActive_0_) {
String p_isTerrainAnimationActive_1_ = p_isTerrainAnimationActive_0_.iconName; String p_isTerrainAnimationActive_1_ = p_isTerrainAnimationActive_0_.iconName;
return p_isTerrainAnimationActive_1_ != TextureUtils.iconWaterStill && p_isTerrainAnimationActive_1_ != TextureUtils.iconWaterFlow ? (p_isTerrainAnimationActive_1_ != TextureUtils.iconLavaStill && p_isTerrainAnimationActive_1_ != TextureUtils.iconLavaFlow ? (p_isTerrainAnimationActive_1_ != TextureUtils.iconFireLayer0 && p_isTerrainAnimationActive_1_ != TextureUtils.iconFireLayer1 ? (p_isTerrainAnimationActive_1_ == TextureUtils.iconPortal ? Config.isAnimatedPortal() : (p_isTerrainAnimationActive_1_ != TextureUtils.iconClock && p_isTerrainAnimationActive_1_ != TextureUtils.iconCompass ? Config.isAnimatedTerrain() : true)) : Config.isAnimatedFire()) : Config.isAnimatedLava()) : Config.isAnimatedWater(); return p_isTerrainAnimationActive_1_ != TextureUtils.iconWaterStill && p_isTerrainAnimationActive_1_ != TextureUtils.iconWaterFlow ? (p_isTerrainAnimationActive_1_ != TextureUtils.iconLavaStill && p_isTerrainAnimationActive_1_ != TextureUtils.iconLavaFlow ? (p_isTerrainAnimationActive_1_ != TextureUtils.iconFireLayer0 && p_isTerrainAnimationActive_1_ != TextureUtils.iconFireLayer1 ? (p_isTerrainAnimationActive_1_ == TextureUtils.iconPortal ? Config.isAnimatedPortal() : (p_isTerrainAnimationActive_1_ != TextureUtils.iconClock && p_isTerrainAnimationActive_1_ != TextureUtils.iconCompass ? Config.isAnimatedTerrain() : true)) : Config.isAnimatedFire()) : Config.isAnimatedLava()) : Config.isAnimatedWater();

View File

@ -202,6 +202,7 @@ public class GameSettings {
public boolean ofCustomColors = true; public boolean ofCustomColors = true;
public boolean ofSwampColors = true; public boolean ofSwampColors = true;
public boolean ofSmoothBiomes = true; public boolean ofSmoothBiomes = true;
public boolean ofCustomItems = true;
//Detail Settings //Detail Settings
/** Clouds flag */ /** Clouds flag */
@ -813,6 +814,11 @@ public class GameSettings {
this.mc.renderGlobal.loadRenderers(); this.mc.renderGlobal.loadRenderers();
} }
if (parOptions == GameSettings.Options.CUSTOM_ITEMS) {
this.ofCustomItems = !this.ofCustomItems;
this.mc.refreshResources();
}
this.saveOptions(); this.saveOptions();
} }
@ -1183,6 +1189,8 @@ public class GameSettings {
return this.ofSwampColors ? s + "ON" : s + "OFF"; return this.ofSwampColors ? s + "ON" : s + "OFF";
} else if (parOptions == GameSettings.Options.SMOOTH_BIOMES) { } else if (parOptions == GameSettings.Options.SMOOTH_BIOMES) {
return this.ofSmoothBiomes ? s + "ON" : s + "OFF"; return this.ofSmoothBiomes ? s + "ON" : s + "OFF";
} else if (parOptions == GameSettings.Options.CUSTOM_ITEMS) {
return this.ofCustomItems ? s + "ON" : s + "OFF";
} else { } else {
return s; return s;
} }
@ -1692,6 +1700,10 @@ public class GameSettings {
this.ofSmoothBiomes = Boolean.valueOf(astring[1]).booleanValue(); this.ofSmoothBiomes = Boolean.valueOf(astring[1]).booleanValue();
} }
if (astring[0].equals("ofCustomItems") && astring.length >= 2) {
this.ofCustomItems = Boolean.valueOf(astring[1]).booleanValue();
}
Keyboard.setFunctionKeyModifier(keyBindFunction.getKeyCode()); Keyboard.setFunctionKeyModifier(keyBindFunction.getKeyCode());
for (SoundCategory soundcategory : SoundCategory.values()) { for (SoundCategory soundcategory : SoundCategory.values()) {
@ -1850,6 +1862,7 @@ public class GameSettings {
printwriter.println("ofCustomColors:" + this.ofCustomColors); printwriter.println("ofCustomColors:" + this.ofCustomColors);
printwriter.println("ofSwampColors:" + this.ofSwampColors); printwriter.println("ofSwampColors:" + this.ofSwampColors);
printwriter.println("ofSmoothBiomes:" + this.ofSmoothBiomes); printwriter.println("ofSmoothBiomes:" + this.ofSmoothBiomes);
printwriter.println("ofDroppedItems:" + this.ofDroppedItems);
for (KeyBinding keybinding : this.keyBindings) { for (KeyBinding keybinding : this.keyBindings) {
printwriter.println("key_" + keybinding.getKeyDescription() + ":" + keybinding.getKeyCode()); printwriter.println("key_" + keybinding.getKeyDescription() + ":" + keybinding.getKeyCode());
@ -2046,7 +2059,8 @@ public class GameSettings {
HIDE_PASSWORD("Hide Password", false, false), HIDE_PASSWORD("Hide Password", false, false),
CUSTOM_COLORS("Custom Colors", false, false), CUSTOM_COLORS("Custom Colors", false, false),
SWAMP_COLORS("Swamp Colors", false, false), SWAMP_COLORS("Swamp Colors", false, false),
SMOOTH_BIOMES("Smooth Biomes", false, false); SMOOTH_BIOMES("Smooth Biomes", false, false),
CUSTOM_ITEMS("Custom Items", false, false);
private final boolean enumFloat; private final boolean enumFloat;
private final boolean enumBoolean; private final boolean enumBoolean;

View File

@ -29,7 +29,7 @@ public class PlatformOpenGL {
private static final Logger logger = LogManager.getLogger("PlatformOpenGL"); private static final Logger logger = LogManager.getLogger("PlatformOpenGL");
static WebGL2RenderingContext ctx = null; public static WebGL2RenderingContext ctx = null;
static boolean hasDebugRenderInfoExt = false; static boolean hasDebugRenderInfoExt = false;
static boolean hasFramebufferHDR16FSupport = false; static boolean hasFramebufferHDR16FSupport = false;