36 lines
970 B
Kotlin
36 lines
970 B
Kotlin
|
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
|
||
|
*/
|
||
|
class DeviceBlockItem(block: DeviceBlock<*>, settings: Settings = Settings()): BlockItem(block, settings) {
|
||
|
|
||
|
override fun appendTooltip(stack: ItemStack, world: World?, list: MutableList<Text>, context: TooltipContext) {
|
||
|
val beTag = stack.getSubTag("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()
|
||
|
}
|
||
|
+")"
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|