bunch of cards

This commit is contained in:
2026-04-19 21:22:12 +02:00
parent b025159791
commit 0416ddd4a5
69 changed files with 668 additions and 27 deletions

View File

@@ -0,0 +1,44 @@
package org.neoflock.neocomputers.item
import net.minecraft.network.chat.Component
import net.minecraft.world.item.Item
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.TooltipFlag
import org.neoflock.neocomputers.gui.widget.ComponentRoles
import org.neoflock.neocomputers.network.Networking
// Note: We'll prob want to replace them with NN component configs later on
open class GPUCard(val tier: Int, val vram: Long): Item(Properties()), ComponentItem {
override fun getComponentRoles(itemStack: ItemStack): Set<String> = setOf(ComponentRoles.CARD)
override fun getComponentTier(itemStack: ItemStack): Int = tier
override fun whenComponentPlaced(itemStack: ItemStack, newRole: String) {
ensureHasAddress(itemStack)
super.whenComponentPlaced(itemStack, newRole)
}
// TODO: Modem Component
override fun toComponentNode(itemStack: ItemStack): Networking.Node? = null
override fun appendHoverText(
itemStack: ItemStack,
tooltipContext: TooltipContext,
list: MutableList<Component?>,
tooltipFlag: TooltipFlag
) {
if(tooltipFlag.isAdvanced) {
val addr = itemStack.get(DataComponents.ADDRESS)
val addrComp = if(addr == null) Component.translatable("neocomputers.noaddr") else Component.literal(addr)
list.addLast(addrComp)
list.addLast(Component.translatable("neocomputers.gpu.vram", vram))
// TODO: show VRAM usage and whatnot
}
super.appendHoverText(itemStack, tooltipContext, list, tooltipFlag)
}
}
class GPUCard0: GPUCard(1, 5000)
class GPUCard1: GPUCard(2, 10000)
class GPUCard2: GPUCard(3, 20000)