blob: 41af1208ed8321c80505b911b2b1ab74456114a0 [file] [log] [blame] [raw]
package li.cil.oc.common.item
import net.minecraft.item.ItemStack
import net.minecraft.entity.player.EntityPlayer
import li.cil.oc.util.Tooltip
import net.minecraft.client.renderer.texture.IconRegister
import li.cil.oc.Settings
import java.util
class LinkedCard(val parent: Delegator) extends Delegate {
val unlocalizedName = "LinkedCard"
override def tooltipLines(stack: ItemStack, player: EntityPlayer, tooltip: util.List[String], advanced: Boolean) {
if (stack.hasTagCompound && stack.getTagCompound.hasKey(Settings.namespace + "data")) {
val data = stack.getTagCompound.getCompoundTag(Settings.namespace + "data")
if (data.hasKey(Settings.namespace + "tunnel")) {
val channel = data.getString(Settings.namespace + "tunnel")
if (channel.length > 13) {
tooltip.addAll(Tooltip.get(unlocalizedName + "_Channel", channel.substring(0, 13) + "..."))
}
else {
tooltip.addAll(Tooltip.get(unlocalizedName + "_Channel", channel))
}
}
}
tooltip.addAll(Tooltip.get(unlocalizedName))
super.tooltipLines(stack, player, tooltip, advanced)
}
override def registerIcons(iconRegister: IconRegister) = {
super.registerIcons(iconRegister)
icon = iconRegister.registerIcon(Settings.resourceDomain + ":card_linked")
}
}