Compose benefits greatly from immutable structures (skipping recomposition), but Bukkit's ItemStack type that is used to display items in inventories is fundamentally mutable. There are a few potential alternatives to this I can think of, try to decide on the best and implement it:
Immutable itemstack class
- We can reuse SerializableItemStack in Idofront, perhaps with a typealias, and mark it with a compose immutable annotation
- Most of the work is done for us, we just convert to a normal ItemStack in the Item composable before rendering.
- Downsides are the same as any other data class, copy chains when trying to edit small parts of the itemstack. We can theoretically build helpers for this into Idofront but don't currently have many use-cases like this
Modifiers
- Create modifiers for different data components an item might have, ex.
Modifier.itemName("something").lore("a", "b", "c").unbreakable()...
- This is likely the more native compose way of doing things, modifiers can be combined and cached within compose's existing systems
- Theoretically more efficient once we switch to android's newer style Modifier classes, since we can modify an underlying ItemStack on recomposition without needing to create an entirely new class each time
- Downsides are much manual work to implement each modifier, more work to update
Extra parameters on the Item composable
- Simlar to compose's parameters on
Text for styling
- Can be used in conjunction with Modifiers, i.e. the parameters just apply modifiers under the hood for usability, or separately until we work out this system
- Like Modifiers, requires us to manually support all attributes we want to modify
Compose benefits greatly from immutable structures (skipping recomposition), but Bukkit's ItemStack type that is used to display items in inventories is fundamentally mutable. There are a few potential alternatives to this I can think of, try to decide on the best and implement it:
Immutable itemstack class
Modifiers
Modifier.itemName("something").lore("a", "b", "c").unbreakable()...Extra parameters on the
ItemcomposableTextfor styling