Topic category: Help with MCreator software
Hello! I'm on a mission to create stupid things that could also somewhat be useful in a mod using MCreator.
My current mission is to make an item that will allow the holder to hit enemies from a greater distance.
To further explain, I am making a new item called "The Wooden Staff" which is simply made with 2 sticks on top of each other in the crafting table, and I want this staff to essentially work like a sword, but it can reach enemies that are further away than normal. Since you can only attack monsters with a sword when they're right in front of you, I wanted to create another melee weapon that has more range on it.
Does anyone know how I can make this simple weapon reach out further to hit enemies that are slightly further away, where a normal sword wouldn't be able to hit them?
I think that the distance of reach is hard coded in game, but I might be wrong.
I figured out how to do it with two procedures
In the image above is the first procedure, which increases the range by steadily increasing the raytracing distance and checking for an entity. This procedure will be put into the "when item is swung" trigger The range local variable starts at 2.5 because that is about how far you can reach in vanilla Minecraft (which means the procedure starts checking for mobs at 2.5 blocks from the player, since you can already hit them within that range), and to change how many more blocks it will reach past 2.5 you change how many times it repeats. every time it repeats is one more half block, so with 6 repeats it is 3 blocks more, so in total it is 8.5 blocks because it gets added to the 2.5. Then there is the damageMult nbt tag, which ties into attack speed, since I made this for 1.16.5, the cooldown nbt tag will always have the 20 in it, but the part you change is the 0.7 and you change that to match the attack speed you want. The local damage variable is how much damage you want it to do. Then there are various checks to make sure that you don't hit yourself and that you don't double hit something. Then there is the part that damages the mob and plays a sound (forgot to fix the second sound, oops). this part accounts for if you are falling and will perform a crit. Then the part that adds 0.5 to the range is how it makes it reach farther, so leave that how it is, and the part that subtracts 1 from the damage is optional, I just put it in so that the further away the mob is, the less damage you do to it. Then it sets the nbt time to 0, which is part of the next procedure.
This second procedure is pretty self explanatory, it increases the nbt called time by 1 every tick, and then that nbt is used in the equation for attack speed in the first procedure, which is the same as the one in vanilla.
I hope this helped, and it took a lot of time for me to figure out on my own for my project, especially because I am new to modding, but I wanted to share it with someone in case it helped, so good luck with your endeavors!
oops the pics didnt link properly, my bad
https://imgur.com/a/gaIcasd
https://imgur.com/j2r9PzN
this really isn't working lol, so I tried a different way and included the links here too