Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * This class can be referred to as your AuroniumCrystal
- */
- public class ItemFirst extends ItemModded {
- public ItemFirst(String unlocalizedName) {
- super(unlocalizedName);
- }
- @Override
- public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
- if (player.inventory.hasItem(ModdedItems.second)) {
- ItemStack itemStacks[] = player.inventory.mainInventory;
- ItemStack secondItem = null;
- for (ItemStack stack : itemStacks) {
- if (stack != null && stack.getItem() == ModdedItems.second) {
- if (secondItem != null)
- break;
- secondItem = stack;
- }
- }
- if (secondItem != null) {
- if (!secondItem.hasTagCompound())
- secondItem.setTagCompound(new NBTTagCompound());
- if (secondItem.getTagCompound().getTag("someTag") == null)
- secondItem.setTagInfo("someTag", new NBTTagInt(0));
- else {
- int amount = secondItem.getTagCompound().getInteger("someTag");
- secondItem.getTagCompound().setInteger("someTag", ++amount); // In the previous example I made a minor mistake here
- }
- }
- }
- return super.onItemRightClick(itemStack, world, player);
- }
- }
- /**
- * And this class will represent the AuroniumHolder
- */
- public class ItemSecond extends ItemModded {
- public ItemSecond(String unlocalizedName) {
- super(unlocalizedName);
- }
- @Override
- public void addInformation(ItemStack itemStack, EntityPlayer player, List toolTip, boolean flag) {
- if (!itemStack.hasTagCompound()
- || (itemStack.getTagCompound() != null && !itemStack.getTagCompound().hasKey("someTag")))
- return;
- toolTip.add(String.format("Value: %d", itemStack.getTagCompound().getInteger("someTag")));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement