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 would like to change a blocks slipperiness and bounciness in my mod but I don't know how.

I am very new to modding so please keep the explanation simple.

Help.

Edited by 1BowTiesAreCool1
Forgot to put version on title

2 hours ago, 1BowTiesAreCool1 said:

I would like to change a blocks slipperiness and bounciness in my mod but I don't know how.

I am very new to modding so please keep the explanation simple.

Help.

You need to create a block. Then create a event and then register it. In the event.

 + You must check whether the entity is null.

 + You have to check if we have just jumped out from the block

 + And do the method, get the block, state (from the entity) and check if the block is the CustomBounceBlock.

For example: https://pastebin.com/SCEPCZVZ

 

No event is necessary. Look at vanilla BlockSlime. Block#slipperiness is a float field which you can set in the constructor. The bouncing is controlled by the methods onFallenUpon, onLanded, and onEntityWalk.

Edited by Jay Avery

  • Author

Ok, I succesfully made the block bouncy and slippery, but I can't change how high I'm going to bounce.

I've tried changing the values but nothing has helped so far

  • Author
    public void onLanded(World worldIn, Entity entityIn)
    {
        if (entityIn.isSneaking())
        {
            super.onLanded(worldIn, entityIn);
        }
        else if (entityIn.motionY < 0.0D)
        {
            entityIn.motionY = -entityIn.motionY;

            if (!(entityIn instanceof EntityLivingBase))
            {
                entityIn.motionY *= 0.9D;
            }
        }
    }

The last value

That value is a multiplier for the speed the entity was falling when they hit the block. At 0, the entity would stop (land like normal). At 1.0, it would bounce at the same speed it was falling (reaching its original height). At greater than 1, it would bounce higher than its original height. How do you want your bouncing to work?

does that value actually affect players?

because it says:

if (!(entityIn instanceof EntityLivingBase))

doesn't that say if the entityIn is NOT an instance of EntityLivingBase?

1 minute ago, Kriptikz said:

does that value actually affect players?

because it says:


if (!(entityIn instanceof EntityLivingBase))

doesn't that say if the entityIn is NOT an instance of EntityLivingBase?

Oh good point. :$ I guess mobs always bounce to their start height then? I just assumed it was less.

Yea I think that part is for particles:

 

try doing this:

entityIn.motionY = -entityIn.motionY * HEIGHT_MULTIPLIER;

 

Replace the line where you reverse the motionY. Basically the line that is almost identical except I added the

* HEIGHT_MULTIPLIER

Post your code.

Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.

  • Author
    public void onFallenUpon(World worldIn, BlockPos pos, Entity entityIn, float fallDistance)
    {
        if (entityIn.isSneaking())
        {
            super.onFallenUpon(worldIn, pos, entityIn, fallDistance);
        }
        else
        {
            entityIn.fall(fallDistance, 0.0F);
        }
    }
	
    public void onLanded(World worldIn, Entity entityIn)
    {
        if (entityIn.isSneaking())
        {
            super.onLanded(worldIn, entityIn);
        }
        else if (entityIn.motionY < 0.0D)
        {
        	entityIn.motionY = -entityIn.motionY * 1;

            if (!(entityIn instanceof EntityLivingBase))
            {
            	entityIn.motionY *= 0.0D;
            }
        }
    }
    
    public void onEntityWalk(World worldIn, BlockPos pos, Entity entityIn)
    {
        if (Math.abs(entityIn.motionY) < 0.1D && !entityIn.isSneaking())
        {
            double d0 = 0.4D + Math.abs(entityIn.motionY) * 0.2D;
            entityIn.motionX *= d0;
            entityIn.motionZ *= d0;
        }

        super.onEntityWalk(worldIn, pos, entityIn);
    }

 

Do you have a method OnEntityWalk? That could be your problem

Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.

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.