Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I am using a modified MeleeAttackGoal to make an entity pick a random button, go to it and press it. But after a while it just stops and stares at the current button target. I found out that it's just staring at it because it's too far away to press it.  And its's not moving because the current path in the mob navigation is "done". If I move it further away it recalculates a non weird path and fixes itself. If I push it towards the button so it can press it, it sets the target to null, so it once again calculates a new path and fixes itself. What is causing the path to be "done"? And how can I fix this?

This is the tick method in the custom goal class:

public void tick() {
        if (mob.buttonTarget != null) {
            float x = mob.buttonTarget.getX();
            float y = mob.buttonTarget.getY();
            float z = mob.buttonTarget.getZ();
            float hx = x + 0.5f;
            float hy = y + 0.5f;
            float hz = z + 0.5f;
            mob.getLookControl().setLookAt(hx, hy, hz, 30.0F, 30.0F);
            double distSqr = mob.distanceToSqr(hx, hy, hz);
            ticksUntilNextPathRecalculation = Math.max(ticksUntilNextPathRecalculation - 1, 0);
            if ((followingTargetEvenIfNotSeen || hasLineOfSight(mob, mob.buttonTarget)) && ticksUntilNextPathRecalculation <= 0 && ((pathedTargetX == 0.0D && pathedTargetY == 0.0D && pathedTargetZ == 0.0D) || mob.buttonTarget.distSqr(new Vec3i(pathedTargetX, pathedTargetY, pathedTargetZ)) >= 1.0D || mob.getRandom().nextFloat() < 0.05F)) {
                pathedTargetX = hx;
                pathedTargetY = hy;
                pathedTargetZ = hz;
                ticksUntilNextPathRecalculation = 4 + mob.getRandom().nextInt(7);
                if (distSqr > 1024.0D) ticksUntilNextPathRecalculation += 10;
                else if (distSqr > 256.0D) ticksUntilNextPathRecalculation += 5;
                Path newPath = mob.getNavigation().createPath(mob.buttonTarget, 0);
                if (newPath != null && !newPath.canReach()) {
                    mob.buttonTarget = null;
                    return;
                }
                if (!mob.getNavigation().moveTo(newPath, speedModifier)) ticksUntilNextPathRecalculation += 15;
                ticksUntilNextPathRecalculation = adjustedTickDelay(ticksUntilNextPathRecalculation);
            }
            ticksUntilNextAttack = Math.max(getTicksUntilNextAttack() - 1, 0);
            checkAndPerformAttack(mob.buttonTarget, distSqr);
        }
    }

 

  • Author

It doesn't seem to be canContinueToUse, especially since it's just a check for if the button still exists.

But the moveTo method in the tick method returns false when in this broken state, it usually returns true.

It seems to be because mob.getNavigation().getPath() is "done", but I don't know how to fix it.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.