#Controlling Allay's AI

5 messages · Page 1 of 1 (latest)

trim dagger
#

Hello! I tried manipulating Villager AI before and I gave up and just repeatedly set the target position of their brain memory over and over until they got to the target position, but that led to very janky behaviour and I'm sure its not the correct solution.

I want to make a mod that lets me copy and paste stuff like in Axiom, but in survival, using Allays. I want Allays to be basically a schematicannon from create. Is there a good way to get the Allays to move to a location? I'm very new to modding, I only made one (villager business) and its very janky.

trim dagger
#

Im trying to add a goal, but no matter what I do I cant seem to get the mixin that adds the goal to the entity to actually work

trim dagger
#

I tried adding the goal to the goal selector at:
@Inject(method = "initGoals", at = @At("TAIL"))
and
@Inject(method = "initGoals()V", at = @At("TAIL"))
but it says the Mixin transformation failed.

I try
@Inject(method = "<init>", at = @At("TAIL"))
and it works, but then my goal crashes the game as soon as an Allay is ticked

    private final PathAwareEntity entity;

    public FlyToLocationGoal(PathAwareEntity entity) {
        this.entity = entity;
    }

    @Override
    public boolean canStart() {
        if (!(entity instanceof AllayEntityMixin mixin)) return false;
        return mixin.getFlyTarget() != null;
    }

    @Override
    public void start() {
        if (entity instanceof AllayEntityMixin mixin) {
            BlockPos target = mixin.getFlyTarget();
            entity.getNavigation().startMovingTo(target.getX(), target.getY(), target.getZ(), 1.2);
        }
    }

    @Override
    public boolean shouldContinue() {
        return !entity.getNavigation().isIdle();
    }
}```
#

The culprit seems to be both entity instanceof AllayEntityMixin mixin lines, if I comment them out it doesn't crash

#

Ah, I found the issue. AllayEntityMixin doesn't exist at runtime. I had to make an interface and use instanceof AllayInterface instead 😬