-
Notifications
You must be signed in to change notification settings - Fork 4
Item Builder Update #352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Item Builder Update #352
Conversation
Marked as a draft on the chance I misunderstood the resolution we came to in #325 but reviews are welcome even now |
pylon-core/src/main/kotlin/io/github/pylonmc/pylon/core/fluid/PylonFluid.kt
Show resolved
Hide resolved
Have thought about this for a while and I don't like the fact that PylonItemStackBuilder is named as such but is not actually a builder (or even a class), but a set of utility methods that return builders. It feels quite misleading. It's also rather unclear at first glance why for example there is an |
Sure |
doesn't compile, no review for you |
#blame-idra he broke master, you can still review it though?? (/lh) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cw stuff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class feels like some of the excessive abstraction we're trying to avoid. Can the block tags not just be used directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will switch this to some static constants referenced in the doc o7
addAttributeModifier(Attribute.ATTACK_KNOCKBACK, AttributeModifier(baseAttackKnockback, knockback, AttributeModifier.Operation.ADD_NUMBER, EquipmentSlotGroup.MAINHAND)) | ||
} | ||
|
||
fun durability(durability: Int) = set(DataComponentTypes.MAX_DAMAGE, durability) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fun durability(durability: Int) = set(DataComponentTypes.MAX_DAMAGE, durability) | |
fun durability(durability: Int) = durability(durability, 0) | |
fun durability(durability: Int, damage: Int) = apply { | |
set(DataComponentTypes.MAX_DAMAGE, durability) | |
set(DataComponentTypes.DAMAGE, damage) | |
} |
if the item doesn't have a durability by default, durability bar won't work since the item has no damage. eg reactivated wither skull
* ``` | ||
*/ | ||
@JvmStatic | ||
fun pylonHelmet(stack: ItemStack, key: NamespacedKey, durability: Boolean) = pylonArmor(stack, key, EquipmentSlotGroup.HEAD, durability) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the name durability makes it seem like that param should be an int and not a boolean, but that's not accurate. Instead use hasDurability or similar to make it more clear that it's a boolean value not an int
pylon-core/src/main/kotlin/io/github/pylonmc/pylon/core/item/builder/ItemStackBuilder.kt
Show resolved
Hide resolved
private fun create(stack: ItemStack, key: NamespacedKey, consumer: (ItemStackBuilder, Config) -> Unit): ItemStackBuilder { | ||
val builder = pylon(stack, key) | ||
val settings = Settings.get(key) | ||
consumer(builder, settings) | ||
return builder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exact same as pylon fun on L437, can probably be removed in favor of that
Supercedes #325
Based on #341 as it modified the stack builder already and started on some of the changes I needed for this
Adds a PylonItemStackBuilder with new utils and moves the previous pylon item related ones from ItemStackBuilder to it.
Adds a number of new utility methods for both.
Gives ui items specific keys to be identifiable, also gives PylonFluid items a specific key and adds a method to get the fluid from the item stack representation