[Solved]potion effect on touch or within area

Started by Freddy101 on

Topic category: Help with modding (Java Edition)

Last seen on 03:35, 20. Jul 2024
Joined Aug 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[Solved]potion effect on touch or within area
Thu, 09/21/2023 - 05:49 (edited)

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
Last seen on 18:36, 16. Jul 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
On update tick, have your…
Tue, 09/19/2023 - 22:52

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.) 

Last seen on 03:35, 20. Jul 2024
Joined Aug 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
this is great thanks for the…
Wed, 09/20/2023 - 06:15

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

Last seen on 22:34, 22. Jul 2024
Joined Feb 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Make a toggle! if you press…
Wed, 09/20/2023 - 11:38

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.

Last seen on 03:35, 20. Jul 2024
Joined Aug 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks alot all of you 
Thu, 09/21/2023 - 05:48

Thanks alot all of you