Jump to content

Help making entities "bounce" on all blocks like they would do when falling on a Slimeblock [1.19.2]


Recommended Posts

Posted

I'm trying to make a event which will make entities in the world bounce when they fall from any distance, like they would if they fell onto a slimeblock. I created a event that triggers on LivingFallEvent in my mod's event class to multiply the y_motion of the target when they land by d; which works, however, the distance the entity bounces up to is very small compared to a slime block. How would I make it more accurate to how entities bounce when falling onto a slimeblock?

public static void onEntityLand(LivingFallEvent event) {
        LivingEntity entity = event.getEntity();
        Vec3 motion = entity.getDeltaMovement();

        event.setDistance(event.getDistance() + 2);

        if(motion.y < 0.0D && event.getDistance() > 1.0F) {
            float d = (float)0.9 + event.getDistance();
            entity.setDeltaMovement(motion.x, -motion.y * d, motion.z);
        }
    }

 

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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