clean code, acceptable performance

This commit is contained in:
2026-04-26 16:05:46 +00:00
parent ed6ddddf98
commit 8edd36124b
24 changed files with 365 additions and 341 deletions

View File

@@ -3,6 +3,7 @@ package org.neoflock.neocomputers.item
import net.minecraft.world.item.ItemStack
import org.neoflock.neocomputers.entity.MachineEntity
import org.neoflock.neocomputers.entity.MachineEvent
import org.neoflock.neocomputers.network.DeviceNode
import org.neoflock.neocomputers.network.Networking
import java.util.UUID
@@ -33,10 +34,10 @@ interface ComponentItem {
}
// To node, if applicable. Meant to create the node, but not add it, as it will use the itemStack's address to find it again
fun toComponentNode(itemStack: ItemStack, machine: MachineEntity?): Networking.Node?
fun toComponentNode(itemStack: ItemStack, machine: MachineEntity?): DeviceNode?
// Gets the node associated to an item, if it exists
fun getComponentNode(itemStack: ItemStack): Networking.Node? {
fun getComponentNode(itemStack: ItemStack): DeviceNode? {
val address = itemStack.get(DataComponents.ADDRESS) ?: return null
val uuid = UUID.fromString(address) ?: return null
return Networking.getNode(uuid)