summaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorOnyxDarkKnight <sor1n.iliutza16@gmail.com>2015-06-14 16:04:29 +0100
committerOnyxDarkKnight <sor1n.iliutza16@gmail.com>2015-06-14 16:04:29 +0100
commitb56652854253bfa502d0f21afb7d47ca77ba8266 (patch)
tree979dd4eba218ac6f48b8388b2f3ae6d1db058a87 /src/main/java
parent01c68617fea5d860dec350583fa3433326f14a7d (diff)
Woohoo! Improvements!
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/darkknight/jewelrycraft/client/gui/GuiJewelryModifier.java94
-rw-r--r--src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java6
-rw-r--r--src/main/java/darkknight/jewelrycraft/events/PlayerRenderHandler.java30
-rw-r--r--src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java127
-rw-r--r--src/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java21
5 files changed, 83 insertions, 195 deletions
diff --git a/src/main/java/darkknight/jewelrycraft/client/gui/GuiJewelryModifier.java b/src/main/java/darkknight/jewelrycraft/client/gui/GuiJewelryModifier.java
index 31660d4..9ed23b4 100644
--- a/src/main/java/darkknight/jewelrycraft/client/gui/GuiJewelryModifier.java
+++ b/src/main/java/darkknight/jewelrycraft/client/gui/GuiJewelryModifier.java
@@ -66,22 +66,18 @@ public class GuiJewelryModifier extends GuiContainer {
public void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
int i = 0;
for (ItemStack item : JewelrycraftUtil.objects) {
- try {
- if (item != null && item.getDisplayName() != null && (this.searchField.getText() == "" || item.getDisplayName().toLowerCase().contains(this.searchField.getText().toLowerCase()))) {
- GL11.glDisable(GL11.GL_LIGHTING);
- GL11.glColor3f(1F, 1F, 1F);
- GL11.glEnable(GL11.GL_LIGHTING);
- GL11.glEnable(GL12.GL_RESCALE_NORMAL);
- if (i >= (page - 1) * 48 && i < page * 48) try {
- itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), item, 88 + 20 * (i % 6), 7 + 17 * (i / 6) - 136 * (page - 1));
- } catch (Exception e) {
- JewelrycraftMod.logger.info("Trying to display an item but gets this error: " + e.getMessage() + "\nThe item causing the issue is: " + item);
- }
- GL11.glDisable(GL11.GL_LIGHTING);
- i++;
+ if (item != null && item.getDisplayName() != null && (this.searchField.getText() == "" || item.getDisplayName().toLowerCase().contains(this.searchField.getText().toLowerCase()))) {
+ GL11.glDisable(GL11.GL_LIGHTING);
+ GL11.glColor3f(1F, 1F, 1F);
+ GL11.glEnable(GL11.GL_LIGHTING);
+ GL11.glEnable(GL12.GL_RESCALE_NORMAL);
+ if (i >= (page - 1) * 48 && i < page * 48) try {
+ itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), item, 88 + 20 * (i % 6), 7 + 17 * (i / 6) - 136 * (page - 1));
+ } catch (Exception e) {
+ JewelrycraftMod.logger.info("Trying to display an item but gets this error: " + e.getMessage() + "\nThe item causing the issue is: " + item);
}
- } catch (Exception e) {
- JewelrycraftMod.logger.info("Trying to display an item but gets this error: " + e.getMessage() + "\nThe item causing the issue is: " + item);
+ GL11.glDisable(GL11.GL_LIGHTING);
+ i++;
}
}
}
@@ -89,16 +85,12 @@ public class GuiJewelryModifier extends GuiContainer {
@Override
protected void keyTyped(char character, int key) {
if (this.searchField.textboxKeyTyped(character, key)) {
- try {
- int items = 0;
- for (ItemStack item : JewelrycraftUtil.objects)
- if (item != null && searchField.getText() != "" && item.getDisplayName() != null && item.getDisplayName().toLowerCase().contains(this.searchField.getText().toLowerCase())) items++;
- maxPages = items / 48 + 1;
- page = 1;
- this.pages.setText(page + "/" + maxPages);
- } catch (Exception e) {
- JewelrycraftMod.logger.info("Trying to display an item but gets this error: " + e.getMessage());
- }
+ int items = 0;
+ for (ItemStack item : JewelrycraftUtil.objects)
+ if (item != null && searchField.getText() != "" && item.getDisplayName() != null && item.getDisplayName().toLowerCase().contains(this.searchField.getText().toLowerCase())) items++;
+ maxPages = items / 48 + 1;
+ page = 1;
+ this.pages.setText(page + "/" + maxPages);
} else super.keyTyped(character, key);
}
@@ -131,23 +123,27 @@ public class GuiJewelryModifier extends GuiContainer {
for (ItemStack item : JewelrycraftUtil.objects) {
if (item != null && item.getDisplayName() != null && (this.searchField.getText() == "" || item.getDisplayName().toLowerCase().contains(this.searchField.getText().toLowerCase()))) {
if (i >= (page - 1) * 48 && i < page * 48 && x >= this.guiLeft + 88 + 20 * (i % 6) && x < this.guiLeft + 108 + 20 * (i % 6) && y >= this.guiTop + 9 + 17 * (i / 6) - 136 * (page - 1) && y < this.guiTop + 25 + 17 * (i / 6) - 136 * (page - 1)) {
- if (!((GuiButton) buttonList.get(0)).enabled || !((GuiButton) buttonList.get(1)).enabled || !((GuiButton) buttonList.get(2)).enabled) {
- this.selectedItem = item;
- this.selectedX = 87 + 20 * (i % 6);
- this.selectedY = 6 + 17 * (i / 6) - 136 * (page - 1);
- this.selectedPage = page;
- } else if (!((GuiButton) buttonList.get(3)).enabled) {
- Map<Integer, Map<Integer, Integer>> itemPage = new HashMap<Integer, Map<Integer, Integer>>();
- Map<Integer, Integer> pos = new HashMap<Integer, Integer>();
- pos.put(87 + 20 * (i % 6), 6 + 17 * (i / 6) - 136 * (page - 1));
- itemPage.put(page, pos);
- if (!this.selectedItems.contains(item)) {
- this.selectedItems.add(item);
- this.selectedItemsPos.add(itemPage);
- } else {
- this.selectedItems.remove(item);
- this.selectedItemsPos.remove(itemPage);
+ try {
+ if (!((GuiButton) buttonList.get(0)).enabled || !((GuiButton) buttonList.get(1)).enabled || !((GuiButton) buttonList.get(2)).enabled) {
+ this.selectedItem = item;
+ this.selectedX = 87 + 20 * (i % 6);
+ this.selectedY = 6 + 17 * (i / 6) - 136 * (page - 1);
+ this.selectedPage = page;
+ } else if (!((GuiButton) buttonList.get(3)).enabled) {
+ Map<Integer, Map<Integer, Integer>> itemPage = new HashMap<Integer, Map<Integer, Integer>>();
+ Map<Integer, Integer> pos = new HashMap<Integer, Integer>();
+ pos.put(87 + 20 * (i % 6), 6 + 17 * (i / 6) - 136 * (page - 1));
+ itemPage.put(page, pos);
+ if (!this.selectedItems.contains(item)) {
+ this.selectedItems.add(item);
+ this.selectedItemsPos.add(itemPage);
+ } else {
+ this.selectedItems.remove(item);
+ this.selectedItemsPos.remove(itemPage);
+ }
}
+ } catch (Exception e) {
+ JewelrycraftMod.logger.info("Trying to display an item but gets this error: " + e.getMessage() + "\nThe item causing the issue is: " + item);
}
}
i++;
@@ -209,17 +205,13 @@ public class GuiJewelryModifier extends GuiContainer {
int i = 0;
List<String> list = new ArrayList<String>();
for (ItemStack item : JewelrycraftUtil.objects) {
- try {
- if (item != null && item.getDisplayName() != null && (this.searchField.getText() == "" || item.getDisplayName().toLowerCase().contains(this.searchField.getText().toLowerCase()))) {
- if (i >= (page - 1) * 48 && i < page * 48 && x >= this.guiLeft + 88 + 20 * (i % 6) && x < this.guiLeft + 108 + 20 * (i % 6) && y >= this.guiTop + 9 + 17 * (i / 6) - 136 * (page - 1) && y < this.guiTop + 25 + 17 * (i / 6) - 136 * (page - 1)) {
- list.add(item.getDisplayName());
- if (item.getTooltip(mc.thePlayer, mc.gameSettings.advancedItemTooltips) != null) this.renderToolTip(item, x, y);
- else this.drawHoveringText(list, x, y, this.fontRendererObj);
- }
- i++;
+ if (item != null && item.getDisplayName() != null && (this.searchField.getText() == "" || item.getDisplayName().toLowerCase().contains(this.searchField.getText().toLowerCase()))) {
+ if (i >= (page - 1) * 48 && i < page * 48 && x >= this.guiLeft + 88 + 20 * (i % 6) && x < this.guiLeft + 108 + 20 * (i % 6) && y >= this.guiTop + 9 + 17 * (i / 6) - 136 * (page - 1) && y < this.guiTop + 25 + 17 * (i / 6) - 136 * (page - 1)) {
+ list.add(item.getDisplayName());
+ if (item.getTooltip(mc.thePlayer, mc.gameSettings.advancedItemTooltips) != null) this.renderToolTip(item, x, y);
+ else this.drawHoveringText(list, x, y, this.fontRendererObj);
}
- } catch (Exception e) {
- JewelrycraftMod.logger.info("Trying to display an item but gets this error: " + e.getMessage());
+ i++;
}
}
}
diff --git a/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java b/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java
index b760706..0bc2257 100644
--- a/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java
+++ b/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java
@@ -217,7 +217,7 @@ public class EntityEventHandler {
if (damage >= 0) playerInfo.setFloat("BlueHeart", damage);
else playerInfo.setFloat("BlueHeart", 0f);
JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo());
- if(damage < 0){
+ if (damage < 0) {
System.out.println(damage);
player.attackEntityFrom(event.source, Math.abs(damage));
}
@@ -239,7 +239,7 @@ public class EntityEventHandler {
if (damage >= 0) playerInfo.setFloat("BlackHeart", damage);
else playerInfo.setFloat("BlackHeart", 0f);
JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo());
- if(damage < 0) player.attackEntityFrom(event.source, Math.abs(damage));
+ if (damage < 0) player.attackEntityFrom(event.source, Math.abs(damage));
player.hurtResistantTime = player.maxHurtResistantTime;
player.hurtTime = player.maxHurtTime = 10;
player.worldObj.playSoundAtEntity(player, "game.player.hurt", 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
@@ -328,6 +328,8 @@ public class EntityEventHandler {
playerInfo.setInteger(cur.getName(), 1);
Curse.availableCurses.remove(cur);
addedCurses = true;
+ JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo());
+ JewelrycraftMod.netWrapper.sendToAll(new PacketSendServerPlayersInfo());
}
}
diff --git a/src/main/java/darkknight/jewelrycraft/events/PlayerRenderHandler.java b/src/main/java/darkknight/jewelrycraft/events/PlayerRenderHandler.java
index 9bbb419..cb4b8c8 100644
--- a/src/main/java/darkknight/jewelrycraft/events/PlayerRenderHandler.java
+++ b/src/main/java/darkknight/jewelrycraft/events/PlayerRenderHandler.java
@@ -29,6 +29,7 @@ import darkknight.jewelrycraft.item.render.EarringsRender;
import darkknight.jewelrycraft.item.render.NecklaceRender;
import darkknight.jewelrycraft.item.render.RingRender;
import darkknight.jewelrycraft.util.JewelryNBT;
+import darkknight.jewelrycraft.util.JewelrycraftUtil;
public class PlayerRenderHandler {
EarringsRender earrings = new EarringsRender();
@@ -60,19 +61,6 @@ public class PlayerRenderHandler {
if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0 && event.entityPlayer.getDisplayName().equals(player.getDisplayName()) && playerInfo.getInteger("cursePoints") > 0) curse.playerRender(player, event);
int no = 0;
ModelRenderer arm = rightArm;
- if (player.inventory.getCurrentItem() != null && Block.getBlockFromItem(player.inventory.getCurrentItem().getItem()) instanceof BlockAir) {
- GL11.glDisable(GL11.GL_LIGHT1);
- FloatBuffer colorBuffer = BufferUtils.createFloatBuffer(4);
- Vec3 lightPos = Vec3.createVectorHelper(0.0D, 2.0D, 1.0D).normalize();
- colorBuffer.clear();
- colorBuffer.put((float) lightPos.xCoord).put((float) lightPos.yCoord).put((float) lightPos.zCoord).put(-1F);
- colorBuffer.flip();
- GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, colorBuffer);
- colorBuffer.clear();
- colorBuffer.put(0.03f).put(0.03f).put(0.03f).put(1.0F);
- colorBuffer.flip();
- GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, colorBuffer);
- }
for (int i = 0; i <= 9; i++)
if (playerInfo.hasKey("ext" + i) && event.entityPlayer.getDisplayName().equals(player.getDisplayName())) {
gem = -1;
@@ -91,8 +79,8 @@ public class PlayerRenderHandler {
if (arm.rotateAngleY != 0.0F) GL11.glRotatef(arm.rotateAngleY * (180F / (float) Math.PI), 0.0F, 1.0F, 0.0F);
if (arm.rotateAngleX != 0.0F) GL11.glRotatef(arm.rotateAngleX * (180F / (float) Math.PI), 1.0F, 0.0F, 0.0F);
}
- if (JewelryNBT.ingot(item) != null) ingot = JewelryNBT.ingotColor(item);
- if (JewelryNBT.gem(item) != null) gem = JewelryNBT.gemColor(item);
+ if (JewelryNBT.ingot(item) != null) ingot = JewelrycraftUtil.getColor(JewelryNBT.ingot(item));
+ if (JewelryNBT.gem(item) != null) gem = JewelrycraftUtil.getColor(JewelryNBT.gem(item));
float scale = 0.1f;
if (Loader.isModLoaded("alpaca") /*&& fiskfille.alpaca.AlpacaAPI.isAlpacaClient(event.entityPlayer)*/) {
if (no <= 4) {
@@ -116,8 +104,8 @@ public class PlayerRenderHandler {
if (playerInfo.hasKey("ext" + i) && event.entityPlayer.getDisplayName().equals(player.getDisplayName())) {
NBTTagCompound nbt = (NBTTagCompound) playerInfo.getTag("ext" + i);
ItemStack item = ItemStack.loadItemStackFromNBT(nbt);
- if (JewelryNBT.gem(item) != null) gemColor[i - 10] = JewelryNBT.gemColor(item);
- if (JewelryNBT.ingot(item) != null) ingotColor[i - 10] = JewelryNBT.ingotColor(item);
+ if (JewelryNBT.ingot(item) != null) ingotColor[i - 10] = JewelrycraftUtil.getColor(JewelryNBT.ingot(item));
+ if (JewelryNBT.gem(item) != null) gemColor[i - 10] = JewelrycraftUtil.getColor(JewelryNBT.gem(item));
}
if ((playerInfo.hasKey("ext10") || playerInfo.hasKey("ext11")) && event.entityPlayer.getDisplayName().equals(player.getDisplayName())) {
GL11.glPushMatrix();
@@ -177,8 +165,8 @@ public class PlayerRenderHandler {
}
if (Loader.isModLoaded("alpaca") /*&& fiskfille.alpaca.AlpacaAPI.isAlpacaClient(event.entityPlayer)*/) GL11.glTranslatef(0.0F, 0.55F, -0.28F);
GL11.glScalef(0.0625f, 0.0625f, 0.0625f);
- if (JewelryNBT.gem(item) != null) gem = JewelryNBT.gemColor(item);
- if (JewelryNBT.ingot(item) != null) ingot = JewelryNBT.ingotColor(item);
+ if (JewelryNBT.ingot(item) != null) ingot = JewelrycraftUtil.getColor(JewelryNBT.ingot(item));
+ if (JewelryNBT.gem(item) != null) gem = JewelrycraftUtil.getColor(JewelryNBT.gem(item));
if (no > 0) {
GL11.glRotatef(no == 1 ? 25f : -25f, 0F, 0f, 1f);
GL11.glRotatef(no == 1 ? -5f : -10f, 1F, 0f, 0f);
@@ -206,8 +194,8 @@ public class PlayerRenderHandler {
if (Loader.isModLoaded("alpaca") /*&& fiskfille.alpaca.AlpacaAPI.isAlpacaClient(event.entityPlayer)*/) GL11.glTranslatef(0.0F, 0.7F, -0.2F);
GL11.glScalef(s, s, s);
GL11.glTranslatef(0.0F, 1.0F, -2.0F);
- if (JewelryNBT.gem(item) != null) gem = JewelryNBT.gemColor(item);
- if (JewelryNBT.ingot(item) != null) ingot = JewelryNBT.ingotColor(item);
+ if (JewelryNBT.ingot(item) != null) ingot = JewelrycraftUtil.getColor(JewelryNBT.ingot(item));
+ if (JewelryNBT.gem(item) != null) gem = JewelrycraftUtil.getColor(JewelryNBT.gem(item));
earrings.doRender(event.entityPlayer, 0F, 0F, (float) ingot, (float) gem, 0F);
GL11.glPopMatrix();
}
diff --git a/src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java b/src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java
index 8a3af07..204ec9b 100644
--- a/src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java
+++ b/src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java
@@ -9,7 +9,9 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+
import javax.imageio.ImageIO;
+
import net.minecraft.block.Block;
import net.minecraft.block.BlockAir;
import net.minecraft.client.Minecraft;
@@ -31,6 +33,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import darkknight.jewelrycraft.JewelrycraftMod;
import darkknight.jewelrycraft.api.ModifierEffects;
import darkknight.jewelrycraft.util.JewelryNBT;
+import darkknight.jewelrycraft.util.JewelrycraftUtil;
import darkknight.jewelrycraft.util.Variables;
public abstract class ItemBaseJewelry extends Item
@@ -50,130 +53,14 @@ public abstract class ItemBaseJewelry extends Item
@SideOnly (Side.CLIENT)
public int getColorFromItemStack(ItemStack stack, int pass)
{
- try{
- return color(stack, pass);
- }
- catch(IOException e){
- e.printStackTrace();
- }
+ if (pass == 0 && JewelryNBT.ingot(stack) != null) return JewelrycraftUtil.getColor(JewelryNBT.ingot(stack));
+ if (pass == 1 && JewelryNBT.gem(stack) != null) return JewelrycraftUtil.getColor(JewelryNBT.gem(stack));
+ else if (JewelryNBT.ingot(stack) != null) return JewelrycraftUtil.getColor(JewelryNBT.ingot(stack));
return 16777215;
}
/**
* @param stack
- * @param pass
- * @return
- * @throws IOException
- */
- public static int color(ItemStack stack, int pass) throws IOException
- {
- IResourceManager rm = Minecraft.getMinecraft().getResourceManager();
- BufferedImage icon;
- if (pass == 0 && stack != null && JewelryNBT.ingot(stack) != null && Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) > 0 && JewelryNBT.ingot(stack).getIconIndex() != null && JewelryNBT.ingotColor(stack) == 16777215){
- ItemStack ingot = JewelryNBT.ingot(stack);
- icon = ImageIO.read(rm.getResource(getLocation(ingot, stack, true)).getInputStream());
- int height = icon.getHeight();
- int width = icon.getWidth();
- Map m = new HashMap();
- for(int i = 0; i < width; i++)
- for(int j = 0; j < height; j++){
- int rgb = icon.getRGB(i, j);
- int red = rgb >> 16 & 0xff;
- int green = rgb >> 8 & 0xff;
- int blue = rgb & 0xff;
- int[] rgbArr = {red, green, blue};
- int Cmax = Math.max(red, Math.max(green, blue));
- int Cmin = Math.min(red, Math.min(green, blue));
- if (!isGray(rgbArr)) m.put(rgb, (Cmax + Cmin) / 2);
- }
- int color = getMostCommonColour(m);
- if (JewelryNBT.ingot(stack) != null && JewelryNBT.ingot(stack).getItem().getColorFromItemStack(JewelryNBT.ingot(stack), 1) != 16777215) JewelryNBT.addIngotColor(stack, JewelryNBT.ingot(stack).getItem().getColorFromItemStack(JewelryNBT.ingot(stack), 1));
- else JewelryNBT.addIngotColor(stack, color);
- }else if (pass == 1 && stack != null && stack.getItem() != null && JewelryNBT.gem(stack) != null && !(Block.getBlockFromItem(JewelryNBT.gem(stack).getItem()) instanceof BlockAir) && JewelryNBT.gem(stack).getIconIndex() != null){
- ItemStack gem = JewelryNBT.gem(stack);
- icon = ImageIO.read(rm.getResource(getLocation(gem, stack, true)).getInputStream());
- int height = icon.getHeight();
- int width = icon.getWidth();
- Map m = new HashMap();
- for(int i = 0; i < width; i++)
- for(int j = 0; j < height; j++){
- int rgb = icon.getRGB(i, j);
- int red = rgb >> 16 & 0xff;
- int green = rgb >> 8 & 0xff;
- int blue = rgb & 0xff;
- int[] rgbArr = {red, green, blue};
- int Cmax = Math.max(red, Math.max(green, blue));
- int Cmin = Math.min(red, Math.min(green, blue));
- if (!isGray(rgbArr)) m.put(rgb, (Cmax + Cmin) / 2);
- }
- int color = getMostCommonColour(m);
- if (JewelryNBT.gem(stack).getItem().getColorFromItemStack(JewelryNBT.gem(stack), 1) == 16777215) JewelryNBT.addGemColor(stack, color);
- else JewelryNBT.addGemColor(stack, JewelryNBT.gem(stack).getItem().getColorFromItemStack(JewelryNBT.gem(stack), 1));
- }
- if (pass == 0 && JewelryNBT.ingot(stack) != null) return JewelryNBT.ingotColor(stack);
- if (pass == 1 && JewelryNBT.gem(stack) != null) return JewelryNBT.gemColor(stack);
- else if (JewelryNBT.ingot(stack) != null) return JewelryNBT.ingotColor(stack);
- return 16777215;
- }
-
- /**
- * @param item
- * @param stack
- * @param changeMeta
- * @return
- */
- public static ResourceLocation getLocation(ItemStack item, ItemStack stack, boolean changeMeta)
- {
- String domain = "";
- String texture;
- if (changeMeta && (Item.getIdFromItem(item.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(item.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(item.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(item.getItem()) == Block.getIdFromBlock(Blocks.carpet))) item.setItemDamage(15 - item.getItemDamage());
- IIcon itemIcon = item.getItem().getIcon(item, 0);
- String iconName = itemIcon.getIconName();
- if (iconName.substring(0, iconName.indexOf(":") + 1) != "") domain = iconName.substring(0, iconName.indexOf(":") + 1).replace(":", " ").trim();
- else domain = "minecraft";
- texture = iconName.substring(iconName.lastIndexOf(":") + 1) + ".png";
- ResourceLocation textureLocation = null;
- TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
- if (texturemanager.getResourceLocation(item.getItemSpriteNumber()).toString().contains("items")) textureLocation = new ResourceLocation(domain.toLowerCase(), "textures/items/" + texture);
- else textureLocation = new ResourceLocation(domain.toLowerCase(), "textures/blocks/" + texture);
- return textureLocation;
- }
-
- /**
- * @param map
- * @return
- */
- public static int getMostCommonColour(Map map)
- {
- List list = new LinkedList(map.entrySet());
- Collections.sort(list, new Comparator(){
- public int compare(Object o1, Object o2)
- {
- return ((Comparable)((Map.Entry)o1).getValue()).compareTo(((Map.Entry)o2).getValue());
- }
- });
- Map.Entry me = (Map.Entry)list.get(list.size() - 1);
- for(int i = 0; i < list.size(); i++){
- float alpha = Float.valueOf(list.get(i).toString().split("=")[1]);
- if (alpha < 180) me = (Map.Entry)list.get(i);
- }
- int rgb = (Integer)me.getKey();
- return rgb;
- }
-
- /**
- * @param rgbArr
- * @return
- */
- public static boolean isGray(int[] rgbArr)
- {
- int rgbSum = rgbArr[0] + rgbArr[1] + rgbArr[2];
- if (rgbSum > 0 && rgbSum < 256 * 3) return false;
- return true;
- }
-
- /**
- * @param stack
* @return
*/
public String getItemStackDisplayName(ItemStack stack)
@@ -192,7 +79,7 @@ public abstract class ItemBaseJewelry extends Item
*/
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4)
{
- if (stack.hasTagCompound() && par4){
+ if (stack.hasTagCompound()){
ItemStack ingot = JewelryNBT.ingot(stack);
if (ingot != null && Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) > 0) list.add(StatCollector.translateToLocal("info." + Variables.MODID + ".metal") + ": " + EnumChatFormatting.YELLOW + ingot.getDisplayName().replace(StatCollector.translateToLocal("info." + Variables.MODID + ".ingot"), " "));
ItemStack gem = JewelryNBT.gem(stack);
diff --git a/src/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java b/src/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java
index 4cf9ced..bee2c95 100644
--- a/src/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java
+++ b/src/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java
@@ -15,7 +15,9 @@ import java.util.Random;
import javax.imageio.ImageIO;
+import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.entity.EnumCreatureAttribute;
import net.minecraft.entity.player.EntityPlayer;
@@ -25,6 +27,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
@@ -133,7 +136,7 @@ public class JewelrycraftUtil {
BufferedImage icon;
if (stack != null && Item.getIdFromItem(stack.getItem()) > 0 && stack.getIconIndex() != null && stack.getItem().getColorFromItemStack(stack, pass) == 16777215) {
try {
- ingot = ItemBaseJewelry.getLocation(stack, stack, false);
+ ingot = getLocation(stack, stack, false);
} catch (Exception e) {
ingot = new ResourceLocation("textures/items/apple.png");
}
@@ -155,6 +158,22 @@ public class JewelrycraftUtil {
return getMostCommonColour(m);
} else return stack.getItem().getColorFromItemStack(stack, pass);
}
+
+ public static ResourceLocation getLocation(ItemStack item, ItemStack stack, boolean changeMeta)
+ {
+ String domain = "";
+ String texture;
+ IIcon itemIcon = item.getItem().getIcon(item, 0);
+ String iconName = itemIcon.getIconName();
+ if (iconName.substring(0, iconName.indexOf(":") + 1) != "") domain = iconName.substring(0, iconName.indexOf(":") + 1).replace(":", " ").trim();
+ else domain = "minecraft";
+ texture = iconName.substring(iconName.lastIndexOf(":") + 1) + ".png";
+ ResourceLocation textureLocation = null;
+ TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
+ if (texturemanager.getResourceLocation(item.getItemSpriteNumber()).toString().contains("items")) textureLocation = new ResourceLocation(domain.toLowerCase(), "textures/items/" + texture);
+ else textureLocation = new ResourceLocation(domain.toLowerCase(), "textures/blocks/" + texture);
+ return textureLocation;
+ }
@SideOnly(Side.CLIENT)
public static int getMostCommonColour(Map map) {