How do I make an item that does a dash and if you collide with a mob it takes 9 damage but if you run in block you stun?

Started by BeePlay on

Topic category: Help with Minecraft modding (Java Edition)

Joined Aug 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How do I make an item that does a dash and if you collide with a mob it takes 9 damage but if you run in block you stun?

I am doing a new mod with lots of weapons. How do I make a weapon that does a dash by right click and if you collide with entity, it gets 9 damage, but if you run into the block you get damage and get weakness and slowness?

Joined Feb 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Try using the "Override…
Wed, 07/09/2025 - 16:35

Try using the "Override motion vector of <entity/target> to <entity Vx> <entity Vz> <entity VZ>" block on "On item right click".

Then create a procedure on "While item in main hand ticks" that checks if the item has been clicked with an NBT variable and if there is an entity in front of the player, using the "For each entity as entity iterator at <X + entity Vx> <Y + entity Vy> Z + entity Vz> in square of 2" block. Inside this block, check that the iterator entity is not the player and apply 9 damage with the "Damage entity..." block.

To be safe, check if the player has finished dashing and set the NBT variable you created to "false". This way, after you use your weapon's ability, if the player doesn't have dashing enabled, it won't deal damage to other entities.

Joined Aug 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Okay, thanks.  Don't you…
Thu, 07/10/2025 - 05:05

Okay, thanks. 

Don't you know how do I also deal knockback with this dash?

 

Joined Feb 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Regarding this you should…
Thu, 07/10/2025 - 11:37

Regarding this you should create a procedure "On item in inventory ticks" and check through the NBT variable if you are using your skill. So, if you are using it and you haven't hit any entities and there is a solid block in front of you (is block at <X + Vx> <Y + 1> <Z + Vz> solid) then apply slowness, weakness and set the NBT variable to "false".