Jump to content

[1.18] Collisionless block that slows like Soul Sand


fweo

Recommended Posts

I'm looking to create a block like cobwebs that you can walk through which slows you, but I would like it to slow in the manner of soul sand, not of cobwebs. The difference is that cobwebs (or anything using Entity#makeStuckInBlock) set the Entity's deltaMovement to zero. This means that you move much slower, you cannot jump a full block, and your falling is slowed, even if you set the vertical speed multiplier to 1 and the horizontal multiplier close to 1. For example, if I take the cobweb approach with tweaked values as follows:

@Override
public void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) {
	entity.makeStuckInBlock(state, new Vec3(0.95D, 1.0D, 0.95D));
}

This results in a block that slows by much more than the stated 5%, reduces the jump height to less than one block, and reduces your fall speed significantly when you land in it, removing all your momentum.

I would like my block to behave like soul sand, where it does not affect jumping and the speed multiplier translates directly to the resulting speed. However, soul sand works by setting the Block's speedFactor, and only the speedFactor of the block the entity is standing on affects the entity's speed, so I cannot simply set the speedFactor.

Is there a way I can create a block that you can walk through, slowing you down, yet you can still jump your full jump height and walking through does not kill your momentum like cobwebs do?

Link to comment
Share on other sites

Of course, thanks. 

Here's the solution for future reference:

    @Override
    public void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) {
        double factor = 0.4;
        entity.setDeltaMovement(entity.getDeltaMovement().multiply(factor, 1.0D, factor));
    }

 

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.

Announcements



×
×
  • Create New...

Important Information

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