Add Allies and additional rule API#13853
Open
Doc94 wants to merge 2 commits intoPaperMC:mainfrom
Open
Conversation
Contributor
|
I would personally like to have the following. player.getWorld().spawn(player.getLocation(), Warden.class, entity -> {
entity.addAdditionalAlliedRule(Key.of(plugin, "ignore_sword"), target -> {
return target instanceof Player playerTarget && playerTarget.getInventory().getItemInMainHand().getType().name().contains("SWORD");
});
});So that you can remove the additional rule at any time using. entity.removeAdditionalAlliedRule(Key.of(plugin, "ignore_sword"));Advantages: Multiple plugins can declare and handle allies. |
Member
Author
|
@yannicklamprecht sounds good, i make a change for allow that now... still require the user listen for remove/add entity for add the rule again when the entity was loaded (like when change dimension) but i feel its ok. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently exists a "isAllies" method in NMS used for things like target/considerations in Entities, one rule of that is if two entities share a team then are allies, this API allow pass additional rules by Key, this its a good alternative for listen every time the Target Event or track Memory for entities who not use that event.
This allow things like.
for
2026-05-02_11-00-58.mp4