Ported AI Goals to 26.1.x#2650
Conversation
|
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. |
|
maybe cast check is unnecessary since |
This reverts commit d80fb6b.
|
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
left a comment
There was a problem hiding this comment.
This looks very close to being ready, see my previous comment for requested changes.
| } 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) { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
I think this could also use the helper method from Goal.
No description provided.