libcraft
libcraft copied to clipboard
Migrating and enhancing Item related code
This issue is to track all item-related code implemented in the feather repo that should be migrated to libcraft.
If I'm not wrong that would be the code under the core/items crate and the definition of Item in definitions. This would also require the migration of the code generator under feather/definitions.
It would also be great to add the Enchantments to the ItemStack struct and other related ItemStack data.
Added ItemStack struct.
Changes to existing functions:
-
has_same_typeno longer checks for the item damage. -
removewill returnResult<u32, ()>instead of aboolbeing theOkvariant the current count of theItemStack. -
takereturnsResult<ItemStack, ()>as the take might fail if there are not enough items to be taken. -
take_halfuses thetakefunction to take half the stack. It returnsItemStackbyunwrappingthe result as thetakefunction will never fail if we call it with an amount of(self.count as f64 / 2 as f64).ceil() as u32 -
merge_withreturns aboolinstead of() - Replaced
&mut ItemStackwith&mut Self
Added functions:
-
has_same_damage: Checks if twoItemStackstructs have the same damage value. -
has_same_count: Checks if twoItemStackstructs have the same count. -
has_same_type_and_count: Checks if twoItemStackstructs have the same type and count. -
has_same_type_and_damage: The oldhas_same_type. Checks if twoItemStackstructs have the same type and damage.
TODO:
- Add the codegen for
Item. For now, I am using a dummyItemstruct. - Create a separate crate for
itemsincore. - Add enchantments and other item data such as title, lore, etc., and its functions.
I will continue with these missing features tomorrow.