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.