Add tamable entity's owner check in effect behavior.

This commit is contained in:
xypp
2025-05-27 00:48:36 +08:00
parent 3e5879471e
commit b3d6464dc7
2 changed files with 10 additions and 3 deletions

View File

@@ -38,7 +38,7 @@ mod_name=maid useful task
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=MIT
# The mod version. See https://semver.org/
mod_version=1.3.3_a
mod_version=1.3.3_a_1
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html

View File

@@ -47,10 +47,17 @@ public class SupportEffectBehavior extends Behavior<EntityMaid> {
return memory.map(list -> list
.find(entity -> entity instanceof Monster)
.map(monster -> (Monster) monster)
.anyMatch(monster -> {
if (monster.getTarget() != null && monster.getTarget().equals(player)) {
.map(Mob::getTarget)
.anyMatch(target -> {
if (target == null)
return false;
if (target.equals(player)) {
return true;
}
if (target instanceof TamableAnimal tamed) {
if (tamed.getOwner() != null && tamed.getOwner().equals(player))
return true;
}
return false;
})
).orElse(false);