Knockback resistance while on a block

Started by Pepper on

Topic category: Help with Minecraft modding (Java Edition)

Joined Nov 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Knockback resistance while on a block

I made a bear trap that traps entities stuck in it, i want the thing caught in it to have high knockback resist. how do i do that?

Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Have the bear trap execute…
Tue, 07/20/2021 - 02:03

Have the bear trap execute this command on update tick:

/data merge entity @e[limit=1,sort=nearest,dx=0,dy=1,dz=0] {Attributes:[{Name:generic.knockback_resistance,Base:1},{Name:generic.movement_speed,Base:0}]}

This command will take any one entity that is 1 block above the bear trap and change the entity's knockback_resistance attribute to 100%, and also change movement_speed to 0.

It might need some tweaking, I have not tested it fully. Hopefully it is what you are looking for.
I made this using https://mcstacker.net. It is a very helpful tool.