Merge pull request #1 from Fretuks/claude/minecraft-mod-mob-behavior-4zrl1u
Improve anti-cheese detection and fix AI goal priorities
This commit is contained in:
@@ -102,7 +102,9 @@ public final class AdaptiveGoalInjector {
|
||||
mob.goalSelector.addGoal(4, new AdaptiveFlankGoal(pathfinder, tier, 2, 8.0D, 1.0D, true));
|
||||
} else if (pathfinder != null && mob instanceof Zombie && AMConfig.AI_ZOMBIE.get()) {
|
||||
mob.goalSelector.addGoal(3, new AdaptiveFlankGoal(pathfinder, tier, 2, 2.5D, 1.05D, true));
|
||||
mob.goalSelector.addGoal(2, new AdaptiveZombiePackTacticsGoal((Zombie) mob, tier));
|
||||
// Priority 1: must be able to interrupt the vanilla melee attack goal (priority 2),
|
||||
// otherwise it can never take over while the zombie is already fighting.
|
||||
mob.goalSelector.addGoal(1, new AdaptiveZombiePackTacticsGoal((Zombie) mob, tier));
|
||||
} else if (pathfinder != null && mob instanceof Creeper creeper && AMConfig.AI_CREEPER.get()) {
|
||||
mob.goalSelector.addGoal(2, new AdaptiveCreeperPressureGoal(creeper, tier));
|
||||
mob.goalSelector.addGoal(4, new AdaptiveFlankGoal(pathfinder, tier, 2, 3.0D, 1.0D, false));
|
||||
@@ -159,8 +161,10 @@ public final class AdaptiveGoalInjector {
|
||||
mob.goalSelector.addGoal(3, new AdaptiveCreeperTacticsGoal(creeper, tier));
|
||||
}
|
||||
if (pathfinder != null && mob instanceof Spider && AMConfig.ENABLE_SPIDER_AI.get() && AMConfig.AI_SPIDER.get()) {
|
||||
mob.goalSelector.addGoal(3, new AdaptiveSpiderTacticsGoal(pathfinder, tier, mob instanceof CaveSpider));
|
||||
mob.goalSelector.addGoal(2, new AdaptiveSpiderDisengageGoal(pathfinder, tier, mob instanceof CaveSpider ? 3 : 4, 0.14D, 1.3D));
|
||||
// Priority 2: below disengage (1, flee always wins) but still above the vanilla
|
||||
// attack goal (3) so it can actually interrupt combat instead of being starved by it.
|
||||
mob.goalSelector.addGoal(2, new AdaptiveSpiderTacticsGoal(pathfinder, tier, mob instanceof CaveSpider));
|
||||
mob.goalSelector.addGoal(1, new AdaptiveSpiderDisengageGoal(pathfinder, tier, mob instanceof CaveSpider ? 3 : 4, 0.14D, 1.3D));
|
||||
mob.goalSelector.addGoal(5, new AdaptiveLowHealthRetreatGoal(pathfinder, tier, 4, 0.38D, 1.15D));
|
||||
}
|
||||
if (mob instanceof Witch witch && AMConfig.ENABLE_WITCH_AI.get() && AMConfig.AI_WITCH.get()) {
|
||||
|
||||
@@ -45,13 +45,31 @@ public class AdaptiveAntiCheeseGoal extends Goal {
|
||||
if (target == null || !target.isAlive()) {
|
||||
return false;
|
||||
}
|
||||
if (isInTrapVehicle() || isNearTrapVehicle()) {
|
||||
if (isInTrapVehicle() || isNearTrapVehicle() || nearestTrapBlock() != null) {
|
||||
return true;
|
||||
}
|
||||
if (tierSupplier.getAsInt() >= 5 && mob instanceof Zombie && isVerticalObstacleCheese(target)) {
|
||||
if (--cooldown > 0) {
|
||||
return false;
|
||||
}
|
||||
if (mob instanceof Zombie && isVerticalObstacleCheese(target)) {
|
||||
return true;
|
||||
}
|
||||
return --cooldown <= 0;
|
||||
if ((mob instanceof AbstractSkeleton || mob instanceof Pillager) && !mob.hasLineOfSight(target)) {
|
||||
return true;
|
||||
}
|
||||
if (mob instanceof Creeper creeper && target.hasLineOfSight(creeper)
|
||||
&& AdaptivePositioningUtils.isOpenToSky(mob)
|
||||
&& Math.sqrt(mob.distanceToSqr(target)) > 4.0D) {
|
||||
return true;
|
||||
}
|
||||
if (mob instanceof EnderMan && (mob.level().getFluidState(mob.blockPosition()).is(FluidTags.WATER)
|
||||
|| target.level().getFluidState(target.blockPosition()).is(FluidTags.WATER))) {
|
||||
return true;
|
||||
}
|
||||
// Nothing to correct right now; keep the cooldown short so we re-check soon instead of
|
||||
// burning a long cooldown on a tick where no cheese pattern was actually detected.
|
||||
cooldown = 10 + mob.getRandom().nextInt(15);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user