Jump to content

[1.11.2]How to change block slipperiness and bounciness.


1BowTiesAreCool1

Recommended Posts

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

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

    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);
    }

 

Link to comment
Share on other sites

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.

×
×
  • Create New...

Important Information

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