-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add ExperienceOrb attracts lock feature #4623
Conversation
Unexpected, but an interesting-looking solution. |
src/entity/object/ExperienceOrb.php
Outdated
$this->targetPlayerRuntimeId = $player !== null ? $player->getId() : null; | ||
}else{ | ||
$this->targetPlayerRuntimeId = null; | ||
} |
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.
This looks really overcomplicated. This would be much simpler
if($player !== null && !$player->getXpManager()->isAttractsLocked()){
$this->targetPlayerRuntimeId = $player->getId();
}else{
$this->targetPlayerRuntimeId = null;
}
or
$this->targetPlayerRuntimeId = $player !== null && !$player->getXpManager()->isAttractsLocked() ? $player->getId() : null;
But does this check even belong there? In every case, where pm would set the target player itself, it does the checks alone. So shouldn't plugin devs be required to do their own checks? Possibly someone wants to bypass the lock of another plugin (whyever).
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.
No, it doesn't belong here. If the player can't be tracked, the orb should try to find a different target.
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.
This whole change is redundant.
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.
Code looks OK (as in it will work) but attractsLocked
is a really abysmal name.
Wouldn't it be better to call it :
I otherwise agree that the changes in |
* removal of conditions in getTargetPlayer and setTargetPlayer * entityBaseTick only will check the condition
|
Indeed, it makes a little more sense |
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.
Tested and found working.
Introduction
As explained in the issue #4589 , there is a need to allow developers to remove players from the attraction of xp orbs.
Relevant issues
Changes
API changes
The following methods have been added to the
ExperienceManager
:isAttractsLocked
: Returns true if the Human no longer accepts xp orbs attracts, false otherwisesetAttractsLocked
: The setter to change the acceptance status of xp orbsBehavioural changes
In
ExperienceOrb
:getTargetPlayer
method will no longer return an instance ofHuman
ifisAttractsLocked
return true for the instancesetTargetPlayer
method will no longer choose aHuman
that returns true toisAttractsLocked
entityBaseTick
the orb will no longer choose a target that returns true toisAttractsLocked
Follow-up
No specific action is required
Tests