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

Implement item stacking #562

Merged
merged 7 commits into from
Feb 20, 2025
Merged

Implement item stacking #562

merged 7 commits into from
Feb 20, 2025

Conversation

4lve
Copy link
Contributor

@4lve 4lve commented Feb 18, 2025

Description

What's added:

  • Picking up items prioritizes your hotbar
  • Stacking works when picking up items. (Before it would just add to your current stack allowing you to have more than stack limit items)

Fixes:
#546
#534

Testing

Please follow our Coding Guidelines

Comment on lines 56 to 59
let max_stack = Item::from_id(self.id)
.unwrap_or(Item::AIR)
.components
.max_stack_size;
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should rather save the Item/Itemstack somewhere instead of this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ye, good idea

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure from where though, as storing the item itself on the entity would take up memory. Having the item being created runtime might be the best option

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Even Slot::to_item uses Item::from_id

@Snowiiii
Copy link
Collaborator

I changed some of the code, this is definitely faster now. Only found a bug that item picking is now broken, Currently don't have time maybe you can fix that ?

@4lve
Copy link
Contributor Author

4lve commented Feb 19, 2025

Thanks, gonna take a look

@4lve
Copy link
Contributor Author

4lve commented Feb 19, 2025

You can item pick now but there's still something odd about it, will have to take another look later

@4lve
Copy link
Contributor Author

4lve commented Feb 19, 2025

Pickblock is now fixed

@Snowiiii
Copy link
Collaborator

In Vanilla the Item stack you currently holding is prioritized, this means when you have a free slot at the first hotbar slot but already holding stone in an other slot while picking up stone you get the stone in the current held slot

@4lve
Copy link
Contributor Author

4lve commented Feb 19, 2025

Fixed

@Snowiiii
Copy link
Collaborator

Looks good now. Thank you @4lve! 👍

@Snowiiii Snowiiii merged commit b428fdc into Pumpkin-MC:master Feb 20, 2025
10 checks passed
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.

Picking up items doesn't put them into your hotbar first Item duplication glitch
2 participants