Skip to content

Ported AI Goals to 26.1.x#2650

Open
albazavr-alba wants to merge 18 commits into
TeamTwilight:latestfrom
albazavr-alba:port-ai-goals
Open

Ported AI Goals to 26.1.x#2650
albazavr-alba wants to merge 18 commits into
TeamTwilight:latestfrom
albazavr-alba:port-ai-goals

Conversation

@albazavr-alba

Copy link
Copy Markdown

No description provided.

Comment thread src/main/java/twilightforest/entity/ai/goal/LichPopMobsGoal.java
Comment thread src/main/java/twilightforest/entity/ai/goal/ThrowRiderGoal.java
@albazavr-alba
albazavr-alba requested a review from a6tumn June 25, 2026 12:00
@LightgraycaAT

Copy link
Copy Markdown

I think snapTo in 26.1 is equal to moveTo in 1.21.1 though, at least in methods like Entity.copyPosition.

@a6tumn

a6tumn commented Jun 25, 2026

Copy link
Copy Markdown

I think snapTo in 26.1 is equal to moveTo in 1.21.1 though, at least in methods like Entity.copyPosition.

I was able to compare the decompiled source code and this is correct. Let's go with snapTo() for those two cases.

Comment thread src/main/java/twilightforest/entity/ai/goal/LichMinionsGoal.java Outdated

@a6tumn a6tumn left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See LightgraycaAT's suggestion regarding the projectile movement and other new comments/questions.

@albazavr-alba
albazavr-alba requested a review from a6tumn June 26, 2026 08:32
Comment thread src/main/java/twilightforest/entity/ai/goal/LichMinionsGoal.java Outdated
Comment thread src/main/java/twilightforest/entity/ai/goal/LichMinionsGoal.java Outdated
@albazavr-alba
albazavr-alba requested a review from a6tumn July 5, 2026 01:34
Comment thread src/main/java/twilightforest/entity/ai/goal/PhantomThrowWeaponGoal.java Outdated
@LightgraycaAT

Copy link
Copy Markdown

maybe cast check is unnecessary since Mob.serverAiStep() and Goal.getServerLevel() also do such cast.

@a6tumn

a6tumn commented Jul 20, 2026

Copy link
Copy Markdown

By the way, there is a getServerlLevel(...) method available in the Goal classes that can take a Level or Entity. This is probably a better option than casting everywhere(even if it is safe). It does cast internally, but it is what Mojang would prefer to be used and you never know if they will change the implementation to add any additional guards or logging.

@a6tumn a6tumn left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very close to being ready, see my previous comment for requested changes.

@albazavr-alba
albazavr-alba requested a review from a6tumn July 20, 2026 17:48
Comment thread src/main/java/twilightforest/entity/ai/goal/BreathAttackGoal.java Outdated
@albazavr-alba
albazavr-alba requested a review from a6tumn July 20, 2026 18:02
} else if (dist < ATTACK_RANGE && this.lich.getSensing().hasLineOfSight(targetedEntity)) {
if (this.lich.getNextAttackType() == 0) this.lich.launchProjectileAt(new LichBolt(this.lich.level(), this.lich));
else this.lich.launchProjectileAt(new LichBomb(this.lich.level(), this.lich));
if (this.lich.level() instanceof ServerLevel serverLevel) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if the constructors for LichBolt and LichBomb were changed in another PR, or if you encountered an error here that required the type check, but would it be possible to just pass in Level here and then change the type check around line 93 to use the helper method from Goal to get the ServerLevel? If not, could we try to avoid repeated lookups and checks?

//difficulty is also factored in. The higher the difficulty the greater the chance
float healthRatio = 1.0F - (this.naga.getHealth() / (this.naga.getMaxHealth())) - 0.25F;
float chance = Mth.clamp(healthRatio + (this.naga.level().getCurrentDifficultyAt(this.naga.blockPosition()).getDifficulty().getId() * 0.05F), 0.0F, 0.5F);
float chance = Mth.clamp(healthRatio + (serverLevel.getCurrentDifficultyAt(this.naga.blockPosition()).getDifficulty().getId() * 0.05F), 0.0F, 0.5F);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could also use the helper method from Goal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants