How do I tell when an entity is colliding with another entity of the same type?

Started by willk55 on

Topic category: Help with MCreator software

Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How do I tell when an entity is colliding with another entity of the same type?

Exactly what the title says. I want to run some code when a custom entity is colliding with another entity of the same type. The "Does entity exist in square cube of type" block looks promising, but I'm not sure if this will also target the source entity, and I can't get it to do anything anyways.

Joined Jun 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You can use Event/Target…
Thu, 10/08/2020 - 20:25

You can use Event/Target Entity as the one colliding, and the Source Entity as the one being collided with. Or it may be the other way around I could be wrong.
Either way, just have a procedure that checks if both Event/Target Entity, and the Source Entity are of a specific entity.

Im not sure if you can have it check just to see if they are both the same. But you can have it check if both are zombies specifically, for example.

Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I'm not sure what you're…
Thu, 10/08/2020 - 21:42

I'm not sure what you're talking about. Is there an event trigger for when custom entities collide with others? I found a "Player collides with this entity" but it only applies to collisions with the player and it doesn't seem very accurate anyways.

Joined Jun 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Ah, my bad. Yeah. In that…
Thu, 10/08/2020 - 21:53

Ah, my bad. Yeah.
In that case, I think the best way would indeed be to use On entity tick update, and then  get nearest entity in square cube of  _.

Just make sure you use Event/Target Entity for the source entity, as its provided by On entity tick update. And the get nearest entity part for the other entity.

 

Joined Jun 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Oh yeah, my bad. Instead,…
Thu, 10/08/2020 - 21:55

Oh yeah, my bad.

Instead, you should be able to use that get nearest entity of type __ block.
Under the On entity tick update trigger, Event/Target Entity represents the source entity, and the get nearest entity would represent the other entity. So just have it so when it detects a nearby entity, close enough to where they will have to be touching, it does the effects using Event/Target as the source, and Get nearest as the other.

That should work.

Joined Jun 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Sorry for double post,…
Thu, 10/08/2020 - 21:56

Sorry for double post, something glitched and I thought it didnt post the first, so I thought I had to rewrite it.

Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I found a solution: https:/…
Fri, 10/16/2020 - 11:40

I found a solution:

https://drive.google.com/file/d/193KjtEZXKH7UYcvU_CkZcJsUMmDfWACl/view?usp=sharing

I made a procedure that runs an execute store command that checks if the entity is colliding with another entity of the same type (really just one specific type) and then stores that into a NBT value. It then just returns that value in that tag (I now realize that the if statement was unesacary). To make sure it doesn't get the entity it's checking for, I check that it's id is not the same. My entities were already given a unique id for another thing, so this wasn't hard to add. Here is the text that needs to go into each of the blocks (get everything inside the " "):

"execute store success entity @s ForgeData.colliding byte 1 if entity @e[type=mod_name:mob_name,distance=..0.2,nbt=!{ForgeData:{id:"

"}}]"

To get this to work for your mod/mob, change mod_name:mob_name to their correct values. If your not sure what this is, launch Minecraft and type:

/tp @e[type=

and it should bring up a list of all the possible entity types. Just go down the list and you should eventually find your mob.

Joined Feb 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Doesn't work
Thu, 10/27/2022 - 09:22

Doesn't work

Joined Aug 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
^^^^^^ :(
Wed, 12/14/2022 - 05:56

^^^^^^ :(

Joined Apr 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Bump?
Tue, 04/09/2024 - 01:22

Bump?