< Back
Page 6 of 6
This chapter is from the book
Exercises
Improve the item even more by passing the unlocalized name of the item through the constructor. Some things you will have to do for that:
- Add a String variable to the constructor.
- Add the unlocalized name in the mod file where you use the constructor, which should be the item init line.
- Remove the String variable in the ItemKey class because you don’t need it anymore.
The code in the mod file:
key
=new
ItemKey(“key”
);
The constructor of ItemKey:
public
ItemKey(String name) { setUnlocalizedName(SamsMod.MODID
+“_”
+name
); setTextureName(SamsMod.MODID
+“:”
+name
); setCreativeTab(CreativeTabs.tabMisc
); }
< Back
Page 6 of 6