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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
package goodgenerator.items;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import goodgenerator.main.GoodGenerator;
public class GGItem extends Item {
@SideOnly(Side.CLIENT)
protected IIcon[] texture;
private String tex;
private String[] textureNames;
private final String Name;
private List<String> tooltips = new ArrayList<>();
private List<String> tooltipses = new ArrayList<>();
public GGItem(String name, CreativeTabs Tab) {
this.setUnlocalizedName(name);
this.setCreativeTab(Tab);
this.tex = name;
this.Name = name;
}
public GGItem(String name, CreativeTabs Tab, String[] textures) {
this.setUnlocalizedName(name);
this.setCreativeTab(Tab);
this.setHasSubtypes(true);
this.textureNames = textures;
this.Name = name;
}
public GGItem(String name, String[] tooltip, CreativeTabs Tab, String[] textures) {
this.setUnlocalizedName(name);
this.setCreativeTab(Tab);
this.setHasSubtypes(true);
this.textureNames = textures;
this.Name = name;
this.tooltipses = Arrays.asList(tooltip);
}
public GGItem(String name, String tooltip, CreativeTabs Tab) {
this.setUnlocalizedName(name);
this.setCreativeTab(Tab);
this.tex = name;
this.tooltips.add(tooltip);
this.Name = name;
}
public GGItem(String name, String[] tooltip, CreativeTabs Tab) {
this.setUnlocalizedName(name);
this.setCreativeTab(Tab);
this.tex = name;
this.tooltips = Arrays.asList(tooltip);
this.Name = name;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int meta) {
if (this.texture == null || this.texture.length < 1) return this.itemIcon;
else return meta < this.texture.length ? this.texture[meta] : this.texture[0];
}
@Override
public int getMetadata(int aMeta) {
return aMeta;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister) {
if (this.textureNames == null || this.textureNames.length < 1) {
this.itemIcon = iconRegister.registerIcon(GoodGenerator.MOD_ID + ":" + this.tex);
} else {
this.texture = new IIcon[this.textureNames.length];
for (int i = 0; i < this.textureNames.length; ++i) {
this.texture[i] = iconRegister.registerIcon(this.textureNames[i]);
}
}
}
@Override
public String getUnlocalizedName(ItemStack p_77667_1_) {
if (this.textureNames == null || this.textureNames.length < 1) {
return "item." + this.Name;
} else {
return "item." + this.Name + "." + p_77667_1_.getItemDamage();
}
}
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings("unchecked")
public void getSubItems(Item item, CreativeTabs tab, List list) {
if (this.texture == null || this.texture.length < 1) list.add(new ItemStack(item, 1, 0));
else {
for (int i = 0; i < this.texture.length; ++i) {
list.add(new ItemStack(item, 1, i));
}
}
}
@SideOnly(Side.CLIENT)
@SuppressWarnings({ "unchecked" })
public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List p_77624_3_, boolean p_77624_4_) {
if (!tooltips.isEmpty()) {
p_77624_3_.addAll(tooltips);
}
if (!tooltipses.isEmpty()) {
int meta = p_77624_1_.getItemDamage();
if (tooltipses.size() - 1 < meta) meta = tooltipses.size() - 1;
p_77624_3_.add(tooltipses.get(meta));
}
}
}
|