@Override public void addInformation( ItemStack itemStack, EntityPlayer player, List list, boolean p_77624_4_) { super.addInformation(itemStack, player, list, p_77624_4_); if (!NBTHelper.hasTag(itemStack, "owner")) { list.add("Right Click to bind deck."); } else { list.remove("Right Click to bind deck."); list.add(1, "Owner: " + NBTHelper.getString(itemStack, "owner")); list.add( 2, "Cards: " + (itemStack.getMaxDamage() - itemStack.getItemDamage() + 1) + "/" + (itemStack.getMaxDamage() + 1)); list.add( 3, "Current Timeout: " + (NBTHelper.getLong(itemStack, "timeout") == 0 ? TIMEOUT : player.worldObj.getTotalWorldTime() - NBTHelper.getLong(itemStack, "timeout")) + "/" + TIMEOUT); } }
@Override public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { if (!world.isRemote) { if (NBTHelper.hasTag(itemStack, "owner") && NBTHelper.hasTag(itemStack, "timeout")) { /* If the timeout is 0, draw a new card. */ if (NBTHelper.getLong(itemStack, "timeout") == 0) { drawCard(itemStack, world, player); itemStack.damageItem(1, player); NBTHelper.setLong(itemStack, "timeout", world.getTotalWorldTime()); } else { ChatHelper.send(player, "Timeout time: " + NBTHelper.getLong(itemStack, "timeout")); ChatHelper.send(player, "World time: " + world.getTotalWorldTime()); } } else { /* Initialize NBT values */ NBTHelper.setLong(itemStack, "timeout", 0); NBTHelper.setString(itemStack, "owner", player.getDisplayName()); makeDeck(itemStack); } } return super.onItemRightClick(itemStack, world, player); }