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

Fixed TODO: "Is main hand always the correct slot?" #893

Closed
wants to merge 1 commit into from

Conversation

Projects
None yet
4 participants
@fionera
Copy link
Contributor

fionera commented Mar 31, 2018

This pull request removes the TODO in the Bow Item

Its now checked in which Hand the Bow is so he can be damaged

@CLAassistant

This comment has been minimized.

Copy link

CLAassistant commented Mar 31, 2018

CLA assistant check
All committers have signed the CLA.

// TODO: Is main hand always the correct slot?
player.setItemInHand(InventoryUtil.damageItem(player, bow));

if (player.getItemInHand() == bow) {

This comment has been minimized.

Copy link
@momothereal

momothereal Mar 31, 2018

Member

The way Vanilla functionality works, you can predict in which slot the bow was in:

  • If the item type of the main slot is Material.BOW, the main slot was used.
  • Else, the off slot was used.

(The main slot takes priority, so even if the player has bows in both hands, you can expect that the one in the main hand was used).

This avoids the risk that the bow item is changed in the meantime, thus potentially breaking any equality check.

@mastercoms

This comment has been minimized.

Copy link
Member

mastercoms commented May 21, 2018

Merged in db9e671, with the material check.

@mastercoms mastercoms closed this May 21, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.