Entities having both ranged and melee attacks

Started by junevolerkes on

Topic category: Help with modding (Java Edition)

Last seen on 05:14, 27. Jun 2020
Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Entities having both ranged and melee attacks
Sat, 06/13/2020 - 06:45 (edited)

Hello! I have been trying to create a mob that could both do melee and ranged attacks, probably depending on how far the attack target is. However, as I have been trying to accomplish that(without coding and only using the interface), the entity could only do one kind of attack, even though I had both ranged attack checked and the “do melee attack” block. Is there any way to get my mob doing both without really getting into coding? Or if not, could you please help me out with the code, I am quite new to this huge world of modding. Thank you in advance!

Edited by junevolerkes on Sat, 06/13/2020 - 06:45
Last seen on 05:29, 31. Jan 2022
Joined Nov 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
i've been trying to do the…
Sat, 06/13/2020 - 08:41

i've been trying to do the same. seems minecraft will only do one of the two if you don't override any of the vanilla AI

Last seen on 05:14, 27. Jun 2020
Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Do you know how is that done?
Sat, 06/13/2020 - 15:48

Do you know how is that done?

Last seen on 05:29, 31. Jan 2022
Joined Nov 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
not without coding
Sat, 06/13/2020 - 17:44

not without coding

Last seen on 05:14, 27. Jun 2020
Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I think I am willing to try…
Sun, 06/21/2020 - 08:09

I think I am willing to try to code it, do you know how to do it(both attack types) and where to start? Thank you!
Nice Rinnegan by the way! :)

Last seen on 05:29, 31. Jan 2022
Joined Nov 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Nice Rinnegan by the way! :)…
Sun, 06/21/2020 - 14:23

Nice Rinnegan by the way! :)

the rinnegan in my mod is even better!

  and where to start?

how much java experience do you have?

Last seen on 04:13, 19. Jun 2023
Joined May 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I mean, you could create an…
Sun, 06/21/2020 - 16:01

I mean, you could create an entity with the model and texture of the projectile and set its movement to turn it into a projectile and make the mob spawn this entity, in the first version of the mod I recently launched I did this and works pretty well

Last seen on 05:14, 27. Jun 2020
Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
That's pretty smart,…
Mon, 06/22/2020 - 03:50

That's pretty smart, actually, thank you!

Last seen on 05:14, 27. Jun 2020
Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
1. How can I look up your…
Mon, 06/22/2020 - 03:53

1. How can I look up your mod? when I click on your profile there is only forum topics.

2. Almost zero experience with Java, I have only figured out how to make hands for armor functional by imitating the code above there, so zero and a half if you will.

Last seen on 05:29, 31. Jan 2022
Joined Nov 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
oh, i haven't uploaded my…
Mon, 06/22/2020 - 07:49

oh, i haven't uploaded my mod. it is a personal mod i made with my son, with naruto and DC comics elements and my son in the mod haha. the reason i didn't upload it is bcuz we superimposed my son's face on a giant entity.

do you have any C/C++/C# experience? i haven't written any java code in my life when i started making mods last december, but you pick it up pretty quick if you have C experience.

so the easiest way is to slightly modify the code to add some checks when to execute the ranged attack AI and/or when to execute the melee AI, for example checking distance from target. in that scenario though, your mob will never try to move towards the attack target if the ranged AI is executing.

another way to do it is make your entity just do melee, and on update tick procedure add code to periodically spawn an entity that flies toward the target (like what @msrodrigues2000 suggested). this involves more coding though.

Last seen on 04:13, 19. Jun 2023
Joined May 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Linear movement is pretty…
Mon, 06/22/2020 - 15:53

Linear movement is pretty simple, in my mod I did parabolic movement which took me more time, but since mcreator supports a lot of math you can create any movement you like for the entity-projectile. On entity tick also you can verify if player is near or not to perform the ranged attack

Last seen on 19:26, 11. Feb 2024
Joined Jun 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Hi i've also been trying to…
Wed, 06/23/2021 - 14:41

Hi i've also been trying to do this but I don't actually know how, the best I could do so far was lag my game with projectiles a milion projectiles with no AI, and they don't even deal damage, I tried several different procedures but I couldn't do it, i have a screenshot of what basically happened after I tried                               trident party

 

yeah i basically made a replica of the trident model and used its textures, but it still doesn't work like one

Last seen on 19:26, 11. Feb 2024
Joined Jun 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
wait im dumb why didnt i…
Wed, 06/23/2021 - 14:46

wait im dumb why didnt i just summon a trident normally