From 4774926ed9703b000ecbcff69636dd7ea4abf5d6 Mon Sep 17 00:00:00 2001 From: OnyxDarkKnight Date: Tue, 28 Apr 2015 23:46:37 +0100 Subject: Fixed the mod from crashing with other mods --- .../jewelrycraft/client/gui/GuiJewelryModifier.java | 17 +++++++++++------ .../jewelrycraft/util/JewelrycraftUtil.java | 21 ++++++++++++--------- .../darkknight/jewelrycraft/util/Variables.java | 2 +- src/main/resources/mcmod.info | 2 +- 4 files changed, 25 insertions(+), 17 deletions(-) (limited to 'src/main') diff --git a/src/main/java/darkknight/jewelrycraft/client/gui/GuiJewelryModifier.java b/src/main/java/darkknight/jewelrycraft/client/gui/GuiJewelryModifier.java index 64c8dda..30b6f64 100644 --- a/src/main/java/darkknight/jewelrycraft/client/gui/GuiJewelryModifier.java +++ b/src/main/java/darkknight/jewelrycraft/client/gui/GuiJewelryModifier.java @@ -70,7 +70,12 @@ public class GuiJewelryModifier extends GuiContainer GL11.glColor3f(1F, 1F, 1F); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL12.GL_RESCALE_NORMAL); - if (i >= (page - 1) * 48 && i < page * 48) itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), item, 88 + 20 * (i % 6), 7 + 17 * (i / 6) - 136 * (page - 1)); + 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++; } @@ -113,7 +118,7 @@ public class GuiJewelryModifier extends GuiContainer ((GuiButton)buttonList.get(2)).enabled = true; ((GuiButton)buttonList.get(3)).enabled = true; ((GuiButton)button).enabled = false; - enabled = ((GuiButton)button).id; + enabled = ((GuiButton)button).id; } } int i = 0; @@ -149,21 +154,21 @@ public class GuiJewelryModifier extends GuiContainer if (((GuiButton)buttonList.get(4)).mousePressed(mc, x, y) && !((GuiButton)buttonList.get(0)).enabled){ JewelryNBT.addIngotColor(targetItem, 16777215); JewelryNBT.addMetal(targetItem, new ItemStack(Item.getItemById(0), 0, 0)); - if(selectedItem != null) JewelryNBT.addMetal(targetItem, this.selectedItem); + if (selectedItem != null) JewelryNBT.addMetal(targetItem, this.selectedItem); JewelrycraftMod.netWrapper.sendToServer(new PacketRequestSetSlot(targetItem)); } if (((GuiButton)buttonList.get(4)).mousePressed(mc, x, y) && !((GuiButton)buttonList.get(1)).enabled){ JewelryNBT.addGemColor(targetItem, 16777215); JewelryNBT.addGem(targetItem, new ItemStack(Item.getItemById(0), 0, 0)); - if(selectedItem != null) JewelryNBT.addGem(targetItem, this.selectedItem); + if (selectedItem != null) JewelryNBT.addGem(targetItem, this.selectedItem); JewelrycraftMod.netWrapper.sendToServer(new PacketRequestSetSlot(targetItem)); } if (((GuiButton)buttonList.get(4)).mousePressed(mc, x, y) && !((GuiButton)buttonList.get(2)).enabled){ - if(selectedItem != null) JewelryNBT.addItem(targetItem, selectedItem); + if (selectedItem != null) JewelryNBT.addItem(targetItem, selectedItem); JewelrycraftMod.netWrapper.sendToServer(new PacketRequestSetSlot(targetItem)); } if (((GuiButton)buttonList.get(4)).mousePressed(mc, x, y) && !((GuiButton)buttonList.get(3)).enabled){ - if(!selectedItems.isEmpty()) JewelryNBT.addModifiers(targetItem, selectedItems); + if (!selectedItems.isEmpty()) JewelryNBT.addModifiers(targetItem, selectedItems); JewelrycraftMod.netWrapper.sendToServer(new PacketRequestSetSlot(targetItem)); } } diff --git a/src/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java b/src/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java index a1a6eb9..a9d0a13 100644 --- a/src/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java +++ b/src/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java @@ -28,6 +28,7 @@ public class JewelrycraftUtil public static ArrayList ores = new ArrayList(); public static HashMap oreToIngot = new HashMap(); public static ArrayList jamcraftPlayers = new ArrayList(); + private static ArrayList items = new ArrayList(); public static Random rand = new Random(); /** @@ -51,15 +52,17 @@ public class JewelrycraftUtil jewelry.add(new ItemStack(ItemList.bracelet)); jewelry.add(new ItemStack(ItemList.earrings)); for(Object item: GameData.getItemRegistry()){ - ArrayList items = new ArrayList(); - if (Loader.isModLoaded("Mantle") && ((Item)item).getUnlocalizedName().equals("Mantle:item.mantle.manual")) continue; - if (Loader.isModLoaded("Fossil/Archeology") && ((Item)item).getUnlocalizedName().equals("Fossil/Archeology") && (((Item)item).getUnlocalizedName().equals("legBone") || - ((Item)item).getUnlocalizedName().equals("uniqueItem") || ((Item)item).getUnlocalizedName().equals("foot") || ((Item)item).getUnlocalizedName().equals("skull") || - ((Item)item).getUnlocalizedName().equals("armBone") || ((Item)item).getUnlocalizedName().equals("dinoRibCage") || ((Item)item).getUnlocalizedName().equals("vertebrae"))) continue; - if (item != null && ((Item)item).getHasSubtypes()) ((Item)item).getSubItems((Item)item, null, items); - else objects.add(new ItemStack((Item)item)); - - if (!items.isEmpty()) objects.addAll(items); + if (Loader.isModLoaded("Mantle") && ((Item)item).getUnlocalizedName().equals("Mantle:item.mantle.manual")) continue; + try{ + if (item != null && (Item)item != null && ((Item)item).getHasSubtypes()){ + ((Item)item).getSubItems((Item)item, ((Item)item).getCreativeTab(), items); + }else objects.add(new ItemStack((Item)item)); + if (!items.isEmpty()) objects.addAll(items); + items.removeAll(items); + } + catch(Exception e){ + JewelrycraftMod.logger.info("Error, tried to add subtypes of item " + ((Item)item).getUnlocalizedName() + "\nItem is not added in the list."); + } } } diff --git a/src/main/java/darkknight/jewelrycraft/util/Variables.java b/src/main/java/darkknight/jewelrycraft/util/Variables.java index 5fd59b0..2a4259d 100644 --- a/src/main/java/darkknight/jewelrycraft/util/Variables.java +++ b/src/main/java/darkknight/jewelrycraft/util/Variables.java @@ -6,7 +6,7 @@ public class Variables { public static final String MODID = "jewelrycraft2"; public static final String MODNAME = "Jewelrycraft 2"; - public static final String VERSION = "1.0.1"; + public static final String VERSION = "1.0.2"; public static final String PACKET_CHANNEL = "jewelrycraft2"; public static final String CONFIG_GUI = "darkknight.jewelrycraft.config.ConfigGuiFactory"; diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index 442280d..b8c3b3b 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -4,7 +4,7 @@ "modid": "jewelrycraft2", "name": "Jewelrycraft 2", "description": "Jewelrycraft 2 is a mod about creating jewellery and imbuing them with mystical powers. However, they have both positives and negatives. There are also curses, some good, some bad. Maybe acquiring some wouldn't be that bad.", - "version": "1.0.1", + "version": "1.0.2", "mcversion": "1.7.10", "url": "http://www.minecraftforum.net/forums/topic/2414865", "updateUrl": "", -- cgit v1.2.3