1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
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 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);
this.effect = effect;
}
public int getColor(ItemStack par1ItemStack)
{
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");
return true;
}
/**
* 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());
}
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);
}
}
|