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

Don't break blocks with swords in creative #387

Closed

Conversation

Commandcracker
Copy link
Contributor

Description

You can't break blocks in creative while holding those items.

Testing

tested with those items.

Checklist

Things need to be done before this Pull Request can be merged.

  • Code is well-formatted and adheres to project style guidelines: cargo fmt
  • Code does not produce any clippy warnings: cargo clippy
  • All unit tests pass: cargo test
  • I added new unit tests, so other people don't accidentally break my code by changing other parts of the codebase. How?

@Commandcracker Commandcracker changed the title Dont break with swords in creative Don't break blocks with swords in creative Dec 8, 2024
Comment on lines +90 to +95
get_item("wooden_sword").unwrap().id,
get_item("stone_sword").unwrap().id,
get_item("iron_sword").unwrap().id,
get_item("golden_sword").unwrap().id,
get_item("diamond_sword").unwrap().id,
get_item("netherite_sword").unwrap().id,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just check if it's a sword instead of having a hardcoded list of items?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is_sword is also hardcoded, and it is missing the trident and mace

Copy link
Contributor

Choose a reason for hiding this comment

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

is_sword is also hardcoded, and it is missing the trident and mace

🤦
something filtering over all items could filter using contains and checking if the item name contains sword

itemName.contains("sword")

Also, doesn't Minecraft have metadata for which category or what type of item this is (e.g. swords)?

@Snowiiii
Copy link
Member

This is something we want to have abstractions to work with. I would consider an System simliar to the current Interactive blocks System. In the future we will have to add more logic to items and for example a method like Mojang uses canMine would be great

@OfficialKris
Copy link
Contributor

#350 would also benefit from an "item manager." This seems to be pretty important, especially with the rise in added functionality to individual items. I can start work on it once I finish #388 or someone else can give it a shot. Currently, the handle functions have too much going on. Those function should only find out which item is being used and then run the corresponding category, modifier, and specific item code (pickaxes, enchantments, spawn eggs).

@Snowiiii Snowiiii closed this Dec 25, 2024
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.

4 participants