summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbspkrs <bspkrs@gmail.com>2013-12-16 13:47:14 -0500
committerbspkrs <bspkrs@gmail.com>2013-12-16 13:47:14 -0500
commit54138e01c39832c7d95fb76e83b6a1d7ae30087a (patch)
tree0e6e4f27527083e9917f03c385256d2ed1bdc734
parentd548c65cf67e9f9605093eade74bef62028b7cf6 (diff)
working on ItemRing
-rw-r--r--common/darkknight/jewelrycraft/block/BlockMolder.java14
-rw-r--r--common/darkknight/jewelrycraft/item/ItemRing.java57
2 files changed, 58 insertions, 13 deletions
diff --git a/common/darkknight/jewelrycraft/block/BlockMolder.java b/common/darkknight/jewelrycraft/block/BlockMolder.java
index 521698a..39d567a 100644
--- a/common/darkknight/jewelrycraft/block/BlockMolder.java
+++ b/common/darkknight/jewelrycraft/block/BlockMolder.java
@@ -7,7 +7,6 @@ import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
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;
@@ -42,7 +41,7 @@ public class BlockMolder extends BlockContainer
@Override
public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9)
- {
+ {
TileEntityMolder te = (TileEntityMolder) world.getBlockTileEntity(i, j, k);
ItemStack item = entityPlayer.inventory.getCurrentItem();
if (te != null && item != null && !te.hasMold && item.itemID == ItemList.molds.itemID)
@@ -62,7 +61,7 @@ public class BlockMolder extends BlockContainer
@Override
public void onBlockDestroyedByPlayer(World world, int i, int j, int k, int par5)
- {
+ {
TileEntityMolder te = (TileEntityMolder) world.getBlockTileEntity(i, j, k);
if (te != null)
{
@@ -104,7 +103,7 @@ public class BlockMolder extends BlockContainer
@Override
public void onBlockDestroyedByExplosion(World world, int i, int j, int k, Explosion par5Explosion)
- {
+ {
onBlockDestroyedByPlayer(world, i, j, k, 0);
}
@@ -115,17 +114,18 @@ public class BlockMolder extends BlockContainer
ItemStack copy = null;
if (item.itemID == ItemList.ring.itemID && metal != null)
{
- Item r = new ItemRing(ItemList.ring.itemID, metal).setUnlocalizedName("jewelrycraft.ring");
+ ItemRing r = (ItemRing) new ItemRing(ItemList.ring.itemID, metal).setUnlocalizedName("jewelrycraft.ring");
copy = new ItemStack(r);
}
- else copy = item;
+ else
+ copy = item;
player.inventory.addItemStackToInventory(copy);
}
}
@Override
public void onBlockClicked(World world, int i, int j, int k, EntityPlayer player)
- {
+ {
TileEntityMolder me = (TileEntityMolder) world.getBlockTileEntity(i, j, k);
if (me != null && me.hasJewelBase)
{
diff --git a/common/darkknight/jewelrycraft/item/ItemRing.java b/common/darkknight/jewelrycraft/item/ItemRing.java
index c96dd2f..30d0be4 100644
--- a/common/darkknight/jewelrycraft/item/ItemRing.java
+++ b/common/darkknight/jewelrycraft/item/ItemRing.java
@@ -1,29 +1,32 @@
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.nbt.NBTTagList;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
public class ItemRing extends ItemBase
{
- public ItemStack ingot;
+ public ItemStack ingot;
public PotionEffect effect;
-
+
public ItemRing(int par1)
{
super(par1);
this.setMaxStackSize(1);
}
-
+
public ItemRing(int par1, ItemStack ingot)
{
this(par1);
this.ingot = ingot;
}
-
+
public ItemRing(int par1, ItemStack ingot, PotionEffect effect)
{
this(par1, ingot);
@@ -34,6 +37,8 @@ public class ItemRing extends ItemBase
{
return 65535;
}
+
+ @Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
{
par2EntityPlayer.addChatMessage("Hello");
@@ -43,10 +48,50 @@ public class ItemRing extends ItemBase
/**
* allows items to add custom lines of information to the mouseover description
*/
+ @Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4)
{
- if(ingot != null) list.add(EnumChatFormatting.GRAY + ingot.getDisplayName());
- if(effect != null) list.add(EnumChatFormatting.GREEN + effect.getEffectName());
+ if (ingot != null)
+ list.add(EnumChatFormatting.GRAY + ingot.getDisplayName());
+ if (effect != null)
+ list.add(EnumChatFormatting.GREEN + effect.getEffectName());
+ }
+
+ public void addEnchantment(ItemStack ringStack, ItemStack ingotStack)
+ {
+ NBTTagList nbttaglist = this.func_92110_g(ringStack);
+ boolean flag = true;
+
+ for (int i = 0; i < nbttaglist.tagCount(); ++i)
+ {
+ NBTTagCompound nbttagcompound = (NBTTagCompound) nbttaglist.tagAt(i);
+
+ if (nbttagcompound.getShort("id") == par2EnchantmentData.enchantmentobj.effectId)
+ {
+ if (nbttagcompound.getShort("lvl") < par2EnchantmentData.enchantmentLevel)
+ {
+ nbttagcompound.setShort("lvl", (short) par2EnchantmentData.enchantmentLevel);
+ }
+
+ flag = false;
+ break;
+ }
+ }
+
+ if (flag)
+ {
+ NBTTagCompound nbttagcompound1 = new NBTTagCompound();
+ nbttagcompound1.setShort("id", (short) par2EnchantmentData.enchantmentobj.effectId);
+ nbttagcompound1.setShort("lvl", (short) par2EnchantmentData.enchantmentLevel);
+ nbttaglist.appendTag(nbttagcompound1);
+ }
+
+ if (!ringStack.hasTagCompound())
+ {
+ ringStack.setTagCompound(new NBTTagCompound());
+ }
+
+ ringStack.getTagCompound().setTag("StoredEnchantments", nbttaglist);
}
}