Started by
Freddy101
on
Topic category: Help with Minecraft modding (Java Edition)
I'm making a dash ability but when i dash into an entity i want it to apply a potion effect when touching or even when in a certain range can anyone help with this part
Edited by Freddy101 on Thu, 09/21/2023 - 05:49
On update tick, have your custom entity check for mob within a certain range. (Use the 'if entity exists in square cube size...' procedure block, which is found in the world tab.) If it finds one, have it apply the potion effect to that entity. Use the normal 'apply potion' block, but replace the event/target-entity with a 'nearest entity of type...' block, also found in the world tab.
Be careful with this though! If the range of the initial check if larger than the target check, or if there's too much delay, you might have a situation where the procedure finds the correct entity type within its radius, but then the entity moves out of range, and isn't in range when the procedure tries to actually add the potion. This will almost always crash the game. As such, I recommend setting the radius of 'nearest entity of type...' block to be higher than the first check.
The detection range is measured from the center of the provided coordinates, meaning that if you want a single-block radius, set the first check to a radius of 1, and the coordinates to x + 0.5, y + 0.5, and z + 0.5. (So that it checks from the center of the block, instead of the bottom north west corner.)
this is great thanks for the help now it actually applies the effect but I had it hooked up to a keybind and instead of it activating when I click the key it is just always on how would I fix that
Make a toggle!
if you press the keybind then set a boolean/logic variable or nbt to true then if you release the keybind then to false.
Thanks alot all of you