From 720ebe7c71d61d32329f96518c4567a493514c5e Mon Sep 17 00:00:00 2001 From: maxanier Date: Sat, 14 Oct 2023 14:33:07 +0200 Subject: [PATCH] Minions should not attack team players or players at all if PVP is disabled Close 1268 --- .../de/teamlapen/vampirism/entity/minion/MinionEntity.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/teamlapen/vampirism/entity/minion/MinionEntity.java b/src/main/java/de/teamlapen/vampirism/entity/minion/MinionEntity.java index 1baedef359..d9cff6903b 100644 --- a/src/main/java/de/teamlapen/vampirism/entity/minion/MinionEntity.java +++ b/src/main/java/de/teamlapen/vampirism/entity/minion/MinionEntity.java @@ -21,6 +21,7 @@ import de.teamlapen.vampirism.inventory.MinionContainer; import de.teamlapen.vampirism.util.DamageHandler; import de.teamlapen.vampirism.util.IPlayerOverlay; +import de.teamlapen.vampirism.util.Permissions; import de.teamlapen.vampirism.util.PlayerSkinHelper; import de.teamlapen.vampirism.world.MinionWorldData; import net.minecraft.core.NonNullList; @@ -118,7 +119,8 @@ protected MinionEntity(EntityType type, Level world, this.hardAttackPredicate = livingEntity -> { boolean flag1 = getLordOpt().map(ILordPlayer::getPlayer).filter(entity -> entity == livingEntity).isPresent(); //Don't attack lord boolean flag2 = livingEntity instanceof MinionEntity && ((MinionEntity) livingEntity).getLordID().filter(id -> getLordID().map(id2 -> id == id2).orElse(false)).isPresent(); //Don't attack other minions of lord - return !flag1 && !flag2; + boolean flag3 = livingEntity instanceof Player otherPlayer && getLordOpt().map(ILordPlayer::getPlayer).map(player -> !player.canHarmPlayer(otherPlayer)).orElse(!Permissions.isPvpEnabled(otherPlayer)); + return !flag1 && !flag2 && !flag3; }; setDontDropEquipment(); this.peaceful = true;