Skip to content
Discussion options

You must be logged in to vote

Should I try to create custom UpgradeType for this

Yep! You can probably create a variant of simpleWithCustomItem that constructs your upgrade with the type:

fun <T : UpgradeBase> createWithCustomItem(factory: (ty: UpgradeType<T>, stack: ItemStack) -> T): UpgradeType<T> {
    lateinit var type: UpgradeType<T>
    type = UpgradeType.create(
        BuiltInRegistries.ITEM.byNameCodec()
            .xmap({ factory(type, ItemStack(it)) }, { it.craftingItem.item })
            .fieldOf("item"),
    )
    return type
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@SirEdvin
Comment options

Answer selected by SirEdvin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants