-
-
Notifications
You must be signed in to change notification settings - Fork 184
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
Fix dupe, doubble click and shift click #577
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,6 +122,10 @@ impl PlayerInventory { | |
self.selected + 36 | ||
} | ||
|
||
pub fn increment_state_id(&mut self) { | ||
self.state_id = self.state_id % 100 + 1; | ||
kralverde marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
pub fn held_item(&self) -> Option<&ItemStack> { | ||
debug_assert!((0..9).contains(&self.selected)); | ||
self.items[self.selected as usize + 36 - 9].as_ref() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you also make constants for the inventory locations? Like MAX_SLOT, HOTBAR_SLOTS = (0..9), etc. |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,70 @@ | ||
use pumpkin_data::item::Item; | ||
|
||
use crate::item::ItemStack; | ||
|
||
impl ItemStack { | ||
pub fn is_sword(&self) -> bool { | ||
[ | ||
818, // Wooden | ||
823, // Stone | ||
828, // Gold | ||
833, // Iron | ||
838, // Diamond | ||
843, // Netherite | ||
Item::WOODEN_SWORD.id, // Wooden | ||
Item::STONE_SWORD.id, // Stone | ||
Item::GOLDEN_SWORD.id, // Gold | ||
Item::IRON_SWORD.id, // Iron | ||
Item::DIAMOND_SWORD.id, // Diamond | ||
Item::NETHERITE_SWORD.id, // Netherite | ||
Comment on lines
-6
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can use our item tags for this instead of explicitly writing them out. See #566 (Ideally with my recommendations to @Jayryn) See also https://minecraft.wiki/w/Item_tag_(Java_Edition) |
||
] | ||
.contains(&self.item.id) | ||
} | ||
|
||
pub fn is_helmet(&self) -> bool { | ||
[ | ||
// Leather | ||
856, // Netherite | ||
876, // Turtle helmet | ||
794, // Chainmail | ||
860, // Diamond | ||
868, // Gold | ||
872, // Iron | ||
864, | ||
Item::NETHERITE_HELMET.id, // Netherite | ||
Item::TURTLE_HELMET.id, // Turtle helmet | ||
Item::CHAINMAIL_HELMET.id, // Chainmail | ||
Item::DIAMOND_HELMET.id, // Diamond | ||
Item::GOLDEN_HELMET.id, // Gold | ||
Item::IRON_HELMET.id, // Iron | ||
Item::LEATHER_HELMET.id, | ||
] | ||
.contains(&self.item.id) | ||
} | ||
|
||
pub fn is_chestplate(&self) -> bool { | ||
[ | ||
// Leather | ||
857, // Netherite | ||
877, // Chainmail | ||
861, // Diamond | ||
869, // Gold | ||
873, // Iron | ||
865, // Elytra | ||
773, | ||
Item::NETHERITE_CHESTPLATE.id, // Netherite | ||
Item::CHAINMAIL_CHESTPLATE.id, // Chainmail | ||
Item::DIAMOND_CHESTPLATE.id, // Diamond | ||
Item::GOLDEN_CHESTPLATE.id, // Gold | ||
Item::IRON_CHESTPLATE.id, // Iron | ||
Item::ELYTRA.id, // Elytra | ||
Item::LEATHER_CHESTPLATE.id, | ||
] | ||
.contains(&self.item.id) | ||
} | ||
|
||
pub fn is_leggings(&self) -> bool { | ||
[ | ||
// Leather | ||
858, // Netherite | ||
878, // Chainmail | ||
862, // Diamond | ||
870, // Gold | ||
874, // Iron | ||
866, | ||
Item::NETHERITE_LEGGINGS.id, // Netherite | ||
Item::CHAINMAIL_LEGGINGS.id, // Chainmail | ||
Item::DIAMOND_LEGGINGS.id, // Diamond | ||
Item::GOLDEN_LEGGINGS.id, // Gold | ||
Item::IRON_LEGGINGS.id, // Iron | ||
Item::LEATHER_LEGGINGS.id, | ||
] | ||
.contains(&self.item.id) | ||
} | ||
|
||
pub fn is_boots(&self) -> bool { | ||
[ | ||
// Leather | ||
859, // Netherite | ||
879, // Chainmail | ||
863, // Diamond | ||
871, // Gold | ||
875, // Iron | ||
867, | ||
Item::NETHERITE_BOOTS.id, // Netherite | ||
Item::CHAINMAIL_BOOTS.id, // Chainmail | ||
Item::DIAMOND_BOOTS.id, // Diamond | ||
Item::GOLDEN_BOOTS.id, // Gold | ||
Item::IRON_BOOTS.id, // Iron | ||
Item::LEATHER_BOOTS.id, | ||
] | ||
.contains(&self.item.id) | ||
} | ||
|
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.
Could you create constants for these magic numbers? like left click, right click, outside