Posted April 15, 20178 yr 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 April 15, 20178 yr by 1BowTiesAreCool1 Forgot to put version on title
April 15, 20178 yr 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
April 15, 20178 yr 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 April 15, 20178 yr by Jay Avery
April 15, 20178 yr 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
April 15, 20178 yr 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
April 15, 20178 yr 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?
April 15, 20178 yr Author Yeah, but here's the problem, I've tried changing the value but it doesn't seem to affect the bouncing at all
April 15, 20178 yr Is the method actually being called? Use the debugger or a print statement to check.
April 15, 20178 yr 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?
April 15, 20178 yr 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.
April 15, 20178 yr Yea I think that part is for particles: try doing this: entityIn.motionY = -entityIn.motionY * HEIGHT_MULTIPLIER;
April 15, 20178 yr Replace the line where you reverse the motionY. Basically the line that is almost identical except I added the * HEIGHT_MULTIPLIER
April 15, 20178 yr Author But I have one more problem, I bounce when I'm standing still atop the block, is there anyway I can prevent this?
April 15, 20178 yr 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.
April 15, 20178 yr 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); }
April 15, 20178 yr 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.