From 3e0556ee7aadfbb7695f87063662a9ca0d28175f Mon Sep 17 00:00:00 2001 From: OnyxDarkKnight Date: Sat, 8 Mar 2014 22:16:06 +0200 Subject: Lots of new things --- .../darkknight/jewelrycraft/item/ItemCrystal.java | 59 ++++++++++++++ common/darkknight/jewelrycraft/item/ItemList.java | 7 +- common/darkknight/jewelrycraft/item/ItemRing.java | 94 ++++++++++++++++------ 3 files changed, 132 insertions(+), 28 deletions(-) create mode 100644 common/darkknight/jewelrycraft/item/ItemCrystal.java (limited to 'common/darkknight/jewelrycraft/item') diff --git a/common/darkknight/jewelrycraft/item/ItemCrystal.java b/common/darkknight/jewelrycraft/item/ItemCrystal.java new file mode 100644 index 0000000..325c2ce --- /dev/null +++ b/common/darkknight/jewelrycraft/item/ItemCrystal.java @@ -0,0 +1,59 @@ +package darkknight.jewelrycraft.item; + +import java.util.List; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; + +public class ItemCrystal extends Item +{ + public Icon overlay; + public static final int[] dyeColors = new int[] {1973019, 11743532, 3887386, 5320730, 2437522, 8073150, 2651799, 11250603, 4408131, 14188952, 4312372, 14602026, 6719955, 12801229, 15435844, 15790320}; + + public ItemCrystal(int par1) + { + super(par1); + this.setHasSubtypes(true); + this.setMaxDamage(0); + } + + public void registerIcons(IconRegister iconRegister) + { + itemIcon = iconRegister.registerIcon("jewelrycraft:crystal"); + overlay = iconRegister.registerIcon("jewelrycraft:crystalOverlay"); + } + + @Override + public boolean requiresMultipleRenderPasses() + { + return true; + } + + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack stack, int pass) + { + if(pass == 1 && this.getDamage(stack) != 16) return dyeColors[this.getDamage(stack)]; + return 16777215; + } + + public Icon getIcon(ItemStack stack, int pass) + { + return pass == 0 ? itemIcon : overlay; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) + { + for (int j = 0; j < 16; ++j) + { + par3List.add(new ItemStack(par1, 1, j)); + } + } + +} diff --git a/common/darkknight/jewelrycraft/item/ItemList.java b/common/darkknight/jewelrycraft/item/ItemList.java index 83bf91b..027f0a6 100644 --- a/common/darkknight/jewelrycraft/item/ItemList.java +++ b/common/darkknight/jewelrycraft/item/ItemList.java @@ -12,7 +12,8 @@ public class ItemList public static Item shadowIngot; public static Item molds; public static Item clayMolds; - public static Item ring; + public static Item crystal; + public static ItemRing ring; private static boolean isInitialized = false; @@ -24,13 +25,15 @@ public class ItemList shadowIngot = new Item(ConfigHandler.idShadowIngot - 256).setUnlocalizedName("Jewelrycraft.ingotShadow").setTextureName("jewelrycraft:ingotShadow").setCreativeTab(JewelrycraftMod.jewelrycraft); molds = new ItemMolds(ConfigHandler.idMolds - 256).setUnlocalizedName("Jewelrycraft.mold").setTextureName("Mold").setCreativeTab(JewelrycraftMod.jewelrycraft); clayMolds = new ItemClayMolds(ConfigHandler.idClayMolds - 256).setUnlocalizedName("Jewelrycraft.mold").setTextureName("Mold").setCreativeTab(JewelrycraftMod.jewelrycraft); - ring = new ItemRing(ConfigHandler.idRing - 256).setUnlocalizedName("Jewelrycraft.ring").setTextureName("jewelrycraft:ring").setCreativeTab(JewelrycraftMod.jewelrycraft); + ring = (ItemRing) new ItemRing(ConfigHandler.idRing - 256).setUnlocalizedName("Jewelrycraft.ring").setTextureName("jewelrycraft:ring"); + crystal = new ItemCrystal(ConfigHandler.idCrystal - 256).setUnlocalizedName("Jewelrycraft.crystal").setTextureName("jewelrycraft:crystal").setCreativeTab(JewelrycraftMod.jewelrycraft); GameRegistry.registerItem(thiefGloves, "thiefGloves"); GameRegistry.registerItem(shadowIngot, "shadowIngot"); GameRegistry.registerItem(molds, "molds"); GameRegistry.registerItem(clayMolds, "clayMolds"); GameRegistry.registerItem(ring, "ring"); + GameRegistry.registerItem(crystal, "crystal"); isInitialized = true; } diff --git a/common/darkknight/jewelrycraft/item/ItemRing.java b/common/darkknight/jewelrycraft/item/ItemRing.java index 184d3f3..bb09d69 100644 --- a/common/darkknight/jewelrycraft/item/ItemRing.java +++ b/common/darkknight/jewelrycraft/item/ItemRing.java @@ -64,11 +64,11 @@ public class ItemRing extends Item } @SideOnly(Side.CLIENT) - public int getColorFromItemStack(ItemStack par1ItemStack, int pass) + public int getColorFromItemStack(ItemStack stack, int pass) { try { - return color(par1ItemStack, pass); + return color(stack, pass); } catch (IOException e) { @@ -79,7 +79,8 @@ public class ItemRing extends Item public Icon getIcon(ItemStack stack, int pass) { - if (JewelryNBT.jewel(stack) != null) return pass == 0 ? itemIcon : jewel; + if(pass == 0) return itemIcon; + if(pass == 1 && JewelryNBT.jewel(stack) != null) return jewel; return itemIcon; } @@ -87,7 +88,8 @@ public class ItemRing extends Item { String domain = "", texture; ResourceManager rm = Minecraft.getMinecraft().getResourceManager(); - if (pass == 1 && JewelryNBT.ingot(stack) != null && JewelryNBT.jewel(stack) == null) + int x=0, y=0, ok = 0; + if (pass == 0 && JewelryNBT.ingot(stack) != null) { if (JewelryNBT.ingot(stack).getIconIndex().getIconName().substring(0, JewelryNBT.ingot(stack).getIconIndex().getIconName().indexOf(":") + 1) != "") domain = JewelryNBT.ingot(stack).getIconIndex().getIconName().substring(0, JewelryNBT.ingot(stack).getIconIndex().getIconName().indexOf(":") + 1).replace(":", " ").trim(); else domain = "minecraft"; @@ -96,30 +98,52 @@ public class ItemRing extends Item if (JewelryNBT.ingot(stack).getUnlocalizedName().contains("item")) ingot = new ResourceLocation(domain, "textures/items/" + texture); else ingot = new ResourceLocation(domain, "textures/blocks/" + texture); BufferedImage bufferedimage = ImageIO.read(rm.getResource(ingot).getInputStream()); - return bufferedimage.getRGB(9, 9); + while(ok == 0){ + int red = (bufferedimage.getRGB(x, y) >> 16) & 0xFF; + int green = (bufferedimage.getRGB(x, y) >> 8) & 0xFF; + int blue = bufferedimage.getRGB(x, y) & 0xFF; + if((red <= 80 && green <=80 && blue <= 80) || (red >= 180 && green >= 180 && blue >= 180)){ + if(x=bufferedimage.getTileWidth()-1 && y> 16) & 0xFF; + int green = (bufferedimage.getRGB(x, y) >> 8) & 0xFF; + int blue = bufferedimage.getRGB(x, y) & 0xFF; + if((red <= 80 && green <=80 && blue <= 80) || (red >= 180 && green >= 180 && blue >= 180)){ + if(x=bufferedimage.getTileWidth()-1 && y