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

Hello everyone. I am trying to make a status effect that heals you when you stand still on the ground. For this I have to somehow extract the speed the entity is currently moving with and check if it's zero. The closest thing to that I have been able to find is the getDeltaMovement() method, but for some reason it returns zero on the x and z axis regardless of the actual velocity of the entity.
Here is the code I use for the effect application.

    @Override
    public void applyEffectTick(@NotNull LivingEntity entity, int amplifier){
        if (!entity.level.isClientSide) {
            if (entity.getHealth() < entity.getMaxHealth()) {
                Vec3 movement = entity.getDeltaMovement();

                System.out.println(movement);
                if (movement.x == 0.0D && entity.isOnGround() && movement.z == 0.0D) {
                    entity.heal(1.0F);
                }
            }
        }
    }

Also, getDeltaMovement() method seems to return non-zero values on the client side when moving, but you cannot heal on the client side.
I have seen some posts about getting the position of the entity in the previous tick to determine its velocity, but I have not found any methods to do so. What I can do to determine an entity's velocity or just if it is standing still or not?

43 minutes ago, Lithanarianaren said:

What I can do to determine an entity's velocity or just if it is standing still or not?

you can check if the old position (Entity.xOld, Entity.yOld, Entity.zOld) equals the current position (Entity#getX, Entity#getY, Entity#getZ)

  • Author

Just tested the method - entity.xOld equals to entity.getX() no matter the speed for some reason, same with other axes, still heals while moving. Happens on both sides.

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.