Started by
BeePlay
on
Topic category: Help with Minecraft modding (Java Edition)
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?
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.
Okay, thanks.
Don't you know how do I also deal knockback with this dash?
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".