Skip to content
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

ItemStack refactor #12

Merged
merged 14 commits into from
Mar 3, 2021
Merged

ItemStack refactor #12

merged 14 commits into from
Mar 3, 2021

Conversation

PauMAVA
Copy link
Member

@PauMAVA PauMAVA commented Feb 24, 2021

This draft PR is related to #6. We can discuss the implementation of the new ItemStack type here.

@oxkitsune
Copy link
Member

I think it's a good idea to provide "native" support for an ItemBuilder utility.

@PauMAVA
Copy link
Member Author

PauMAVA commented Feb 24, 2021

That's a good idea. I'll try to implement one once the ItemStack struct is finished.

Copy link
Member

@Defman Defman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Respect stack size, other than that it looks pretty good.

crates/items/src/item_stack.rs Outdated Show resolved Hide resolved
crates/items/src/item_stack.rs Outdated Show resolved Hide resolved
crates/items/src/item_stack.rs Outdated Show resolved Hide resolved
crates/items/src/item_stack.rs Outdated Show resolved Hide resolved
@PauMAVA
Copy link
Member Author

PauMAVA commented Feb 24, 2021

@Defman I will add the stack limitations now.

crates/items/src/item_stack.rs Outdated Show resolved Hide resolved
crates/items/src/item_stack.rs Outdated Show resolved Hide resolved
crates/items/src/item_stack.rs Outdated Show resolved Hide resolved
crates/items/src/item_stack.rs Outdated Show resolved Hide resolved
Copy link
Member

@Defman Defman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, though I'm not sure how we should handle operations that can lead to ItemStacks having self.count = 0

crates/items/src/item.rs Outdated Show resolved Hide resolved
crates/items/src/item.rs Outdated Show resolved Hide resolved
crates/items/src/item_stack.rs Outdated Show resolved Hide resolved
crates/items/src/item_stack.rs Outdated Show resolved Hide resolved
crates/items/src/item_stack.rs Outdated Show resolved Hide resolved
crates/items/src/item_stack.rs Outdated Show resolved Hide resolved
crates/items/src/item_stack.rs Outdated Show resolved Hide resolved
crates/items/src/item_stack.rs Outdated Show resolved Hide resolved
Copy link
Member

@caelunshun caelunshun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, thanks! I've left some comments.

crates/generators/python/item.py Show resolved Hide resolved
crates/items/src/item_stack.rs Outdated Show resolved Hide resolved
crates/items/src/item_stack.rs Outdated Show resolved Hide resolved
crates/items/src/item_stack.rs Outdated Show resolved Hide resolved
crates/items/src/item_stack.rs Outdated Show resolved Hide resolved
crates/items/src/item_stack.rs Outdated Show resolved Hide resolved
pub fn take(&mut self, amount: u32) -> Result<ItemStack, ItemStackError> {
if self.count <= amount {
return Err(if self.count == amount {
ItemStackError::EmptyStack
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do need to provide a good solution for taking the whole stack—this is useful for inventory handling in Feather, for example. I know there are talks of refactoring ItemStack to properly account for empty stacks, so we should revisit this point.

crates/items/src/item_stack.rs Outdated Show resolved Hide resolved
crates/items/src/item_stack.rs Show resolved Hide resolved
Base automatically changed from master to main February 27, 2021 01:50
@caelunshun
Copy link
Member

Hi @PauMAVA! We decided on Discord to merge libcraft into the main Feather repository to avoid dependency conflicts. This means the PR will have to be transferred over there, which might involve some Git magic.

If this PR is nearly ready, we can merge it now and finish the remaining work in a separate PR. Alternatively, we can move the PR to Feather.

@PauMAVA
Copy link
Member Author

PauMAVA commented Mar 3, 2021

Hey! There are still lots of things to implement (mainly Item Stack Metadata). I think we could merge this and open a new PR on the feather repo and continue the implementation there. What do you think about it? I can open a new Draft PR there if you want.

@caelunshun
Copy link
Member

Hey! There are still lots of things to implement (mainly Item Stack Metadata). I think we could merge this and open a new PR on the feather repo and continue the implementation there. What do you think about it? I can open a new Draft PR there if you want.

Sounds good to me. I'll merge the PR as is, and we can finish up the work in the Feather repo.

@caelunshun caelunshun marked this pull request as ready for review March 3, 2021 23:01
@PauMAVA
Copy link
Member Author

PauMAVA commented Mar 3, 2021

Let me know when the repo has been moved to feather so I can open the draft PR there. 😄

@caelunshun caelunshun merged commit 3772479 into feather-rs:main Mar 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants