diff options
| author | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2013-12-18 23:54:49 +0200 |
|---|---|---|
| committer | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2013-12-18 23:54:49 +0200 |
| commit | d8bcaa05a5536f76aaf3d2286d3bb1c368586d1e (patch) | |
| tree | daa77ca6797acfe167afdd26632558f055fe6cf0 | |
| parent | 7f332617fa0f706b5c5a266114c56a8cb27c02f2 (diff) | |
Added clay molds, fixed particles issues, rings now take the color of the ingot used.
17 files changed, 174 insertions, 24 deletions
diff --git a/common/darkknight/jewelrycraft/block/BlockSmelter.java b/common/darkknight/jewelrycraft/block/BlockSmelter.java index 9702917..8e97769 100644 --- a/common/darkknight/jewelrycraft/block/BlockSmelter.java +++ b/common/darkknight/jewelrycraft/block/BlockSmelter.java @@ -85,7 +85,7 @@ public class BlockSmelter extends BlockContainer entityPlayer.addChatMessage(StatCollector.translateToLocalFormatted("chatmessage.jewelrycraft.smelter.nowsmeltingingot", item.getDisplayName())); te.metal = new ItemStack(item.itemID, 1, item.getItemDamage()); te.hasMetal = true; - te.melting = 2000; + te.melting = 1500; --item.stackSize; } else if (te.hasMetal && !te.hasMoltenMetal && item != null && item.getDisplayName().contains("Ingot") && !item.getDisplayName().contains("Mold")) @@ -129,6 +129,7 @@ public class BlockSmelter extends BlockContainer me.cooling = 200; te.moltenMetal = new ItemStack(0, 0, 0); te.hasMoltenMetal = false; + me.isDirty = true; } else if (me.hasMoltenMetal) player.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.smelter.molderhasmoltenmetal")); diff --git a/common/darkknight/jewelrycraft/config/ConfigHandler.java b/common/darkknight/jewelrycraft/config/ConfigHandler.java index ab19b5b..9ebfb94 100644 --- a/common/darkknight/jewelrycraft/config/ConfigHandler.java +++ b/common/darkknight/jewelrycraft/config/ConfigHandler.java @@ -10,6 +10,7 @@ public class ConfigHandler public static int idShadowIngot = 17494; public static int idMolds = 17495; public static int idRing = 17496; + public static int idClayMolds = 17497; public static int idShadowOre = 1750; public static int idSmelter = 1751; @@ -29,6 +30,7 @@ public class ConfigHandler idThiefGloves = config.getItem("id.ThiefGloves", idThiefGloves).getInt(); idShadowIngot = config.getItem("id.ShadowIngot", idShadowIngot).getInt(); idMolds = config.getItem("id.Molds", idMolds).getInt(); + idClayMolds = config.getItem("id.ClayMolds", idClayMolds).getInt(); idRing = config.getItem("id.Ring", idRing).getInt(); idShadowOre = config.getBlock("id.ShadowOre", idShadowOre).getInt(); idSmelter = config.getBlock("id.Smelter", idSmelter).getInt(); diff --git a/common/darkknight/jewelrycraft/item/ItemClayMolds.java b/common/darkknight/jewelrycraft/item/ItemClayMolds.java new file mode 100644 index 0000000..184db0d --- /dev/null +++ b/common/darkknight/jewelrycraft/item/ItemClayMolds.java @@ -0,0 +1,72 @@ +package darkknight.jewelrycraft.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; + +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; +import net.minecraft.util.MathHelper; + +public class ItemClayMolds extends Item +{ + /** List of molds color names */ + public static final String[] moldsItemNames = new String[] { "clayIngot", "clayRing" }; + @SideOnly(Side.CLIENT) + private Icon[] moldsIcons; + + public ItemClayMolds(int par1) + { + super(par1); + this.setHasSubtypes(true); + this.setMaxDamage(0); + this.setMaxStackSize(1); + } + + @SideOnly(Side.CLIENT) + /** + * Gets an icon index based on an item's damage value + */ + public Icon getIconFromDamage(int par1) + { + int j = MathHelper.clamp_int(par1, 0, moldsItemNames.length - 1); + return this.moldsIcons[j]; + } + + /** + * Returns the unlocalized name of this item. This version accepts an ItemStack so different stacks can have different names based on + * their damage or NBT. + */ + public String getUnlocalizedName(ItemStack par1ItemStack) + { + int i = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, moldsItemNames.length - 1); + return super.getUnlocalizedName() + "." + moldsItemNames[i]; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @SideOnly(Side.CLIENT) + /** + * returns a list of items with the same ID, but different meta (eg: molds returns 16 items) + */ + public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) + { + for (int j = 0; j < moldsItemNames.length; ++j) + { + par3List.add(new ItemStack(par1, 1, j)); + } + } + + @SideOnly(Side.CLIENT) + public void registerIcons(IconRegister par1IconRegister) + { + this.moldsIcons = new Icon[moldsItemNames.length]; + + for (int i = 0; i < moldsItemNames.length; ++i) + { + this.moldsIcons[i] = par1IconRegister.registerIcon("jewelrycraft:" + moldsItemNames[i] + this.getIconString()); + } + } +} diff --git a/common/darkknight/jewelrycraft/item/ItemList.java b/common/darkknight/jewelrycraft/item/ItemList.java index 3309faf..3810d6a 100644 --- a/common/darkknight/jewelrycraft/item/ItemList.java +++ b/common/darkknight/jewelrycraft/item/ItemList.java @@ -10,6 +10,7 @@ public class ItemList public static Item thiefGloves; public static Item shadowIngot; public static Item molds; + public static Item clayMolds; public static Item ring; private static boolean isInitialized = false; @@ -21,6 +22,7 @@ public class ItemList thiefGloves = new ItemThiefGloves(ConfigHandler.idThiefGloves).setUnlocalizedName("jewelrycraft.thiefGloves").setCreativeTab(JewelrycraftMod.jewelrycraft); shadowIngot = new ItemBase(ConfigHandler.idShadowIngot).setUnlocalizedName("jewelrycraft.ingotShadow").setCreativeTab(JewelrycraftMod.jewelrycraft); molds = new ItemMolds(ConfigHandler.idMolds).setUnlocalizedName("jewelrycraft.mold").setTextureName("Mold").setCreativeTab(JewelrycraftMod.jewelrycraft); + clayMolds = new ItemClayMolds(ConfigHandler.idClayMolds).setUnlocalizedName("jewelrycraft.mold").setTextureName("Mold").setCreativeTab(JewelrycraftMod.jewelrycraft); ring = new ItemRing(ConfigHandler.idRing).setUnlocalizedName("jewelrycraft.ring").setCreativeTab(JewelrycraftMod.jewelrycraft); isInitialized = true; diff --git a/common/darkknight/jewelrycraft/item/ItemRing.java b/common/darkknight/jewelrycraft/item/ItemRing.java index ea75aa2..3941770 100644 --- a/common/darkknight/jewelrycraft/item/ItemRing.java +++ b/common/darkknight/jewelrycraft/item/ItemRing.java @@ -1,13 +1,23 @@ package darkknight.jewelrycraft.item; +import java.awt.image.BufferedImage; +import java.io.IOException; import java.util.List; +import javax.imageio.ImageIO; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.resources.ResourceManager; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.PotionEffect; import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; public class ItemRing extends ItemBase @@ -18,6 +28,47 @@ public class ItemRing extends ItemBase this.setMaxStackSize(1); } + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) + { + try + { + return color(par1ItemStack); + } + catch (IOException e) + { + e.printStackTrace(); + } + return 0; + } + + public int color(ItemStack stack) throws IOException + { + if (stack.hasTagCompound()) + { + if (stack.getTagCompound().hasKey("ingot")) + { + NBTTagCompound ingotNBT = (NBTTagCompound) stack.getTagCompound().getTag("ingot"); + ItemStack ingotStack = new ItemStack(0, 0, 0); + ingotStack.readFromNBT(ingotNBT); + if(ingotStack.getIconIndex().getIconName() != "") + { + String domain = ""; + if(ingotStack.getIconIndex().getIconName().substring(0, ingotStack.getIconIndex().getIconName().indexOf(":") + 1) != "") + domain = ingotStack.getIconIndex().getIconName().substring(0, ingotStack.getIconIndex().getIconName().indexOf(":") + 1).replace(":", " ").trim(); + else + domain = "minecraft"; + String texture = ingotStack.getIconIndex().getIconName().substring(ingotStack.getIconIndex().getIconName().lastIndexOf(":") + 1) + ".png"; + ResourceLocation lava = new ResourceLocation(domain, "textures/items/" + texture); + ResourceManager rm = Minecraft.getMinecraft().getResourceManager(); + BufferedImage bufferedimage = ImageIO.read(rm.getResource(lava).getInputStream()); + return bufferedimage.getRGB(8, 8); + } + } + } + return 0; + } + public static void addMetal(ItemStack item, ItemStack metal) { NBTTagCompound itemStackData; @@ -51,7 +102,7 @@ public class ItemRing extends ItemBase * allows items to add custom lines of information to the mouseover description */ @Override - @SuppressWarnings({ "rawtypes", "unchecked", "static-access" }) + @SuppressWarnings({ "rawtypes", "unchecked"}) public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) { if (stack.hasTagCompound()) diff --git a/common/darkknight/jewelrycraft/recipes/CraftingRecipes.java b/common/darkknight/jewelrycraft/recipes/CraftingRecipes.java index 3f466f4..a24fb88 100644 --- a/common/darkknight/jewelrycraft/recipes/CraftingRecipes.java +++ b/common/darkknight/jewelrycraft/recipes/CraftingRecipes.java @@ -3,6 +3,7 @@ package darkknight.jewelrycraft.recipes; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.FurnaceRecipes; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.registry.GameRegistry; import darkknight.jewelrycraft.block.BlockList; @@ -17,12 +18,14 @@ public class CraftingRecipes if (!isInitialized) { GameRegistry.addRecipe(new ItemStack(ItemList.thiefGloves), "x x", "yxy", "yxy", 'x', ItemList.shadowIngot, 'y', new ItemStack(Block.cloth, 1, 15)); - GameRegistry.addRecipe(new ItemStack(ItemList.molds, 1, 0), "x", "y", 'x', Item.ingotGold, 'y', Block.cobblestone); - GameRegistry.addRecipe(new ItemStack(ItemList.molds, 1, 1), "x x", "xyx", "x x", 'x', Item.ingotGold, 'y', Block.cobblestone); + GameRegistry.addRecipe(new ItemStack(ItemList.clayMolds, 1, 0), "xx", "xx", 'x', Item.clay); + GameRegistry.addRecipe(new ItemStack(ItemList.clayMolds, 1, 1), " x ", "x x", " x ", 'x', Item.clay); GameRegistry.addRecipe(new ItemStack(BlockList.molder), "x x", "xxx", 'x', Block.cobblestone); GameRegistry.addRecipe(new ItemStack(BlockList.smelter), "xyx", "x x", "xzx", 'x', Block.cobblestone, 'y', Item.bucketEmpty, 'z', Item.bucketLava); GameRegistry.addRecipe(new ItemStack(BlockList.jewelCraftingTable), "xxx", "y y", "y y", 'x', Block.planks, 'y', Block.cobblestone); GameRegistry.addSmelting(BlockList.shadowOre.blockID, new ItemStack(ItemList.shadowIngot), 1.5f); + FurnaceRecipes.smelting().addSmelting(ItemList.clayMolds.itemID, 0, new ItemStack(ItemList.molds, 1, 0), 0.85F); + FurnaceRecipes.smelting().addSmelting(ItemList.clayMolds.itemID, 1, new ItemStack(ItemList.molds, 1, 1), 0.85F); isInitialized = true; } diff --git a/common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java b/common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java index 74e681b..c46d7e3 100644 --- a/common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java +++ b/common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java @@ -86,16 +86,19 @@ public class TileEntityJewelrsCraftingTable extends TileEntity } @Override - public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt) + public Packet getDescriptionPacket() { - readFromNBT(pkt.data); + Packet132TileEntityData packet = (Packet132TileEntityData) super.getDescriptionPacket(); + NBTTagCompound dataTag = packet != null ? packet.data : new NBTTagCompound(); + writeToNBT(dataTag); + return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, dataTag); } - + @Override - public Packet getDescriptionPacket() + public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt) { - NBTTagCompound nbtTag = new NBTTagCompound(); - this.writeToNBT(nbtTag); - return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 1, nbtTag); + super.onDataPacket(net, pkt); + NBTTagCompound tag = pkt != null ? pkt.data : new NBTTagCompound(); + readFromNBT(tag); } } diff --git a/common/darkknight/jewelrycraft/tileentity/TileEntityMolder.java b/common/darkknight/jewelrycraft/tileentity/TileEntityMolder.java index 8bf1724..70f0346 100644 --- a/common/darkknight/jewelrycraft/tileentity/TileEntityMolder.java +++ b/common/darkknight/jewelrycraft/tileentity/TileEntityMolder.java @@ -103,16 +103,19 @@ public class TileEntityMolder extends TileEntity } @Override - public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt) + public Packet getDescriptionPacket() { - readFromNBT(pkt.data); + Packet132TileEntityData packet = (Packet132TileEntityData) super.getDescriptionPacket(); + NBTTagCompound dataTag = packet != null ? packet.data : new NBTTagCompound(); + writeToNBT(dataTag); + return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, dataTag); } - + @Override - public Packet getDescriptionPacket() + public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt) { - NBTTagCompound nbtTag = new NBTTagCompound(); - this.writeToNBT(nbtTag); - return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 1, nbtTag); + super.onDataPacket(net, pkt); + NBTTagCompound tag = pkt != null ? pkt.data : new NBTTagCompound(); + readFromNBT(tag); } } diff --git a/common/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java b/common/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java index e656bed..00e727c 100644 --- a/common/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java +++ b/common/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java @@ -4,6 +4,7 @@ import java.util.Random; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet132TileEntityData; import net.minecraft.tileentity.TileEntity; @@ -80,10 +81,10 @@ public class TileEntitySmelter extends TileEntity } if (metal.itemID != 0) { - for (int l = 0; l < 5; ++l) + for (int l = 0; l < 2; ++l) { //EntityFX entityfx = new EntityReddustFX(this.worldObj, (double)xCoord + Math.random(), (double)yCoord + 0.2D, (double)zCoord + Math.random(), 0.0F, 0.0F, 0.0F); - this.worldObj.spawnParticle("flame", xCoord, (double) yCoord + 0.6F, zCoord, 0.0D, 0.0D, 0.0D); + this.worldObj.spawnParticle("flame", xCoord + rand.nextFloat(), (double) yCoord + 0.3F, zCoord + rand.nextFloat(), 0.0D, 0.0D, 0.0D); } } if (rand.nextInt(65) == 0) @@ -109,10 +110,19 @@ public class TileEntitySmelter extends TileEntity } @Override - public Packet getDescriptionPacket() + public Packet getDescriptionPacket() { - NBTTagCompound nbtTag = new NBTTagCompound(); - this.writeToNBT(nbtTag); - return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 1, nbtTag); + Packet132TileEntityData packet = (Packet132TileEntityData) super.getDescriptionPacket(); + NBTTagCompound dataTag = packet != null ? packet.data : new NBTTagCompound(); + writeToNBT(dataTag); + return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, dataTag); + } + + @Override + public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt) + { + super.onDataPacket(net, pkt); + NBTTagCompound tag = pkt != null ? pkt.data : new NBTTagCompound(); + readFromNBT(tag); } } diff --git a/resources/assets/jewelrycraft/lang/en_US.lang b/resources/assets/jewelrycraft/lang/en_US.lang index 9c0952e..ae2cd3f 100644 --- a/resources/assets/jewelrycraft/lang/en_US.lang +++ b/resources/assets/jewelrycraft/lang/en_US.lang @@ -3,6 +3,9 @@ item.jewelrycraft.ingotShadow.name=Shadow Ingot item.jewelrycraft.mold.ingot.name=Ingot Mold item.jewelrycraft.mold.ring.name=Ring Mold item.jewelrycraft.mold.necklace.name=Necklace Mold +item.jewelrycraft.mold.clayIngot.name=Clay Ingot Mold +item.jewelrycraft.mold.clayRing.name=Clay Ring Mold +item.jewelrycraft.mold.clayNecklace.name=Clay Necklace Mold item.jewelrycraft.ring.name=Ring tile.jewelrycraft.oreShadow.name=Shadow Ore tile.jewelrycraft.smelter.name=Smelter diff --git a/resources/assets/jewelrycraft/textures/items/clayIngotMold.png b/resources/assets/jewelrycraft/textures/items/clayIngotMold.png Binary files differnew file mode 100644 index 0000000..b76fed2 --- /dev/null +++ b/resources/assets/jewelrycraft/textures/items/clayIngotMold.png diff --git a/resources/assets/jewelrycraft/textures/items/clayNecklaceMold.png b/resources/assets/jewelrycraft/textures/items/clayNecklaceMold.png Binary files differnew file mode 100644 index 0000000..455f094 --- /dev/null +++ b/resources/assets/jewelrycraft/textures/items/clayNecklaceMold.png diff --git a/resources/assets/jewelrycraft/textures/items/clayRingMold.png b/resources/assets/jewelrycraft/textures/items/clayRingMold.png Binary files differnew file mode 100644 index 0000000..49d2ab1 --- /dev/null +++ b/resources/assets/jewelrycraft/textures/items/clayRingMold.png diff --git a/resources/assets/jewelrycraft/textures/items/ingotMold.png b/resources/assets/jewelrycraft/textures/items/ingotMold.png Binary files differindex ad221b8..c8e9aa9 100644 --- a/resources/assets/jewelrycraft/textures/items/ingotMold.png +++ b/resources/assets/jewelrycraft/textures/items/ingotMold.png diff --git a/resources/assets/jewelrycraft/textures/items/necklaceMold.png b/resources/assets/jewelrycraft/textures/items/necklaceMold.png Binary files differindex edd3424..0df4b65 100644 --- a/resources/assets/jewelrycraft/textures/items/necklaceMold.png +++ b/resources/assets/jewelrycraft/textures/items/necklaceMold.png diff --git a/resources/assets/jewelrycraft/textures/items/ring.png b/resources/assets/jewelrycraft/textures/items/ring.png Binary files differindex 45c03c6..7253e73 100644 --- a/resources/assets/jewelrycraft/textures/items/ring.png +++ b/resources/assets/jewelrycraft/textures/items/ring.png diff --git a/resources/assets/jewelrycraft/textures/items/ringMold.png b/resources/assets/jewelrycraft/textures/items/ringMold.png Binary files differindex d955382..7bab639 100644 --- a/resources/assets/jewelrycraft/textures/items/ringMold.png +++ b/resources/assets/jewelrycraft/textures/items/ringMold.png |
