diff options
| author | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2013-12-16 20:27:39 +0200 |
|---|---|---|
| committer | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2013-12-16 20:27:39 +0200 |
| commit | 611c030450614adcb87d5e2af784712e504eeae4 (patch) | |
| tree | 9c1193f6012c8d9182ff9029a61d32ef433ad9a6 | |
| parent | d548c65cf67e9f9605093eade74bef62028b7cf6 (diff) | |
Ring ring ring
3 files changed, 21 insertions, 27 deletions
diff --git a/common/darkknight/jewelrycraft/block/BlockMolder.java b/common/darkknight/jewelrycraft/block/BlockMolder.java index 521698a..0003015 100644 --- a/common/darkknight/jewelrycraft/block/BlockMolder.java +++ b/common/darkknight/jewelrycraft/block/BlockMolder.java @@ -5,9 +5,10 @@ import java.util.Random; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentData; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -108,18 +109,15 @@ public class BlockMolder extends BlockContainer onBlockDestroyedByPlayer(world, i, j, k, 0); } - public void giveJewelToPlayer(TileEntityMolder md, EntityPlayer player, ItemStack item, ItemStack metal) + public void giveJewelToPlayer(TileEntityMolder md, EntityPlayer player, ItemStack item, String metal) { if (item != null) { - ItemStack copy = null; if (item.itemID == ItemList.ring.itemID && metal != null) { - Item r = new ItemRing(ItemList.ring.itemID, metal).setUnlocalizedName("jewelrycraft.ring"); - copy = new ItemStack(r); + ItemRing.addMetal(item, metal); } - else copy = item; - player.inventory.addItemStackToInventory(copy); + player.inventory.addItemStackToInventory(item); } } diff --git a/common/darkknight/jewelrycraft/item/ItemRing.java b/common/darkknight/jewelrycraft/item/ItemRing.java index c96dd2f..d1bf2e0 100644 --- a/common/darkknight/jewelrycraft/item/ItemRing.java +++ b/common/darkknight/jewelrycraft/item/ItemRing.java @@ -1,15 +1,16 @@ package darkknight.jewelrycraft.item; import java.util.List; + 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.world.World; public class ItemRing extends ItemBase { - public ItemStack ingot; + public static String ingot; public PotionEffect effect; public ItemRing(int par1) @@ -18,26 +19,23 @@ public class ItemRing extends ItemBase this.setMaxStackSize(1); } - public ItemRing(int par1, ItemStack ingot) + public ItemRing(int par1, String ingot) { this(par1); this.ingot = ingot; } - public ItemRing(int par1, ItemStack ingot, PotionEffect effect) + public ItemRing(int par1, String ingot, PotionEffect effect) { this(par1, ingot); this.effect = effect; } - public int getColor(ItemStack par1ItemStack) - { - return 65535; - } - public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + public static void addMetal(ItemStack item, String metal) { - par2EntityPlayer.addChatMessage("Hello"); - return true; + NBTTagCompound tag = new NBTTagCompound(); + item.setTagCompound(tag); + tag.setString("ingot", metal); } /** @@ -46,7 +44,7 @@ public class ItemRing extends ItemBase @SuppressWarnings({ "rawtypes", "unchecked" }) public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) { - if(ingot != null) list.add(EnumChatFormatting.GRAY + ingot.getDisplayName()); + if(ingot != null) list.add(EnumChatFormatting.GRAY + ingot); if(effect != null) list.add(EnumChatFormatting.GREEN + effect.getEffectName()); } } diff --git a/common/darkknight/jewelrycraft/tileentity/TileEntityMolder.java b/common/darkknight/jewelrycraft/tileentity/TileEntityMolder.java index 600bc0f..778d05b 100644 --- a/common/darkknight/jewelrycraft/tileentity/TileEntityMolder.java +++ b/common/darkknight/jewelrycraft/tileentity/TileEntityMolder.java @@ -12,14 +12,15 @@ public class TileEntityMolder extends TileEntity { public int cooling; public boolean hasMoltenMetal, hasJewelBase, hasMold; - public ItemStack mold, jewelBase, moltenMetal, ringMetal; + public ItemStack mold, jewelBase, moltenMetal; + public String ringMetal; public TileEntityMolder() { this.moltenMetal = new ItemStack(0, 0, 0); this.jewelBase = new ItemStack(0, 0, 0); this.mold = new ItemStack(0, 0, 0); - this.ringMetal = new ItemStack(0, 0, 0); + this.ringMetal = ""; this.cooling = 0; this.hasJewelBase = false; this.hasMoltenMetal = false; @@ -34,18 +35,16 @@ public class TileEntityMolder extends TileEntity nbt.setBoolean("hasJewelBase", hasJewelBase); nbt.setBoolean("hasMoltenMetal", hasMoltenMetal); nbt.setBoolean("hasMold", hasMold); + nbt.setString("ringMetal", ringMetal); NBTTagCompound tag = new NBTTagCompound(); NBTTagCompound tag1 = new NBTTagCompound(); NBTTagCompound tag2 = new NBTTagCompound(); - NBTTagCompound tag3 = new NBTTagCompound(); this.mold.writeToNBT(tag); nbt.setCompoundTag("mold", tag); this.jewelBase.writeToNBT(tag1); nbt.setCompoundTag("jewelBase", tag1); this.moltenMetal.writeToNBT(tag2); nbt.setCompoundTag("moltenMetal", tag2); - this.ringMetal.writeToNBT(tag2); - nbt.setCompoundTag("ringMetal", tag3); } @Override @@ -55,6 +54,7 @@ public class TileEntityMolder extends TileEntity this.cooling = nbt.getInteger("cooling"); this.hasJewelBase = nbt.getBoolean("hasJewelBase"); this.hasMoltenMetal = nbt.getBoolean("hasMoltenMetal"); + this.ringMetal = nbt.getString("ringMetal"); this.hasMold = nbt.getBoolean("hasMold"); this.mold = new ItemStack(0, 0, 0); this.mold.readFromNBT(nbt.getCompoundTag("mold")); @@ -62,8 +62,6 @@ public class TileEntityMolder extends TileEntity this.jewelBase.readFromNBT(nbt.getCompoundTag("jewelBase")); this.moltenMetal = new ItemStack(0, 0, 0); this.moltenMetal.readFromNBT(nbt.getCompoundTag("moltenMetal")); - this.ringMetal = new ItemStack(0, 0, 0); - this.ringMetal.readFromNBT(nbt.getCompoundTag("ringMetal")); } public void updateEntity() @@ -80,7 +78,7 @@ public class TileEntityMolder extends TileEntity } if(this.hasMoltenMetal && !this.hasJewelBase) { - ringMetal = moltenMetal; + ringMetal = moltenMetal.getDisplayName(); if(cooling > 0) this.cooling--; if(cooling == 0) { |
