Knockback resistance while on a block

Started by Pepper on Mon, 07/19/2021 - 19:04

Topic category: Help with modding (Java Edition)

Last seen on 20:26, 25. Jul 2021
Joined Nov 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Knockback resistance while on a block
Mon, 07/19/2021 - 19:04

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?

Last seen on 18:59, 19. Sep 2021
Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • 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.