package net.shadowfacts.phycon.item import net.minecraft.client.item.TooltipContext import net.minecraft.item.BlockItem import net.minecraft.item.ItemStack import net.minecraft.text.Text import net.minecraft.world.World import net.shadowfacts.phycon.api.util.IPAddress import net.shadowfacts.phycon.block.DeviceBlock import net.shadowfacts.phycon.util.text /** * @author shadowfacts */ open class DeviceBlockItem(block: DeviceBlock<*>, settings: Settings = Settings()): BlockItem(block, settings) { override fun appendTooltip(stack: ItemStack, world: World?, list: MutableList, context: TooltipContext) { val beTag = stack.getSubNbt("BlockEntityTag") if (beTag != null) { val ip = IPAddress(beTag.getInt("IPAddress")) list.add(text { withStyle(lightPurple) { +translate("tooltip.phycon.device.configured") } +" (" +translate("tooltip.phycon.device.ip") withStyle(darkPurple) { +ip.toString() } +")" }) } } }