Mutual existence of entities

Started by Oskarxisee on

Topic category: Help with modding (Java Edition)

Last seen on 09:36, 16. Feb 2024
Joined Jan 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Mutual existence of entities

Hello. I want to make mutual existence. That is, the procedure for an entity that checks whether there is another same entity within a radius of 4 blocks. It must be the same entity. But I don't know how to check if there is another entity of the same type in area 4 of the block, or even nearby. Thank

Last seen on 15:21, 16. Oct 2023
Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
To check entities around…
Tue, 01/17/2023 - 16:07

To check entities around there's a procedure for it ("For each entity as...")

To check if entities are the same, then you need an if statement with a code snippet in previous mentioned procedure (you can try this inside a code snippet: "entityiterator instanceof entity"). 

Last seen on 15:21, 16. Oct 2023
Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Update, try this code…
Tue, 01/17/2023 - 16:16

Update, try this code snippet:

entityiterator.getType() == entity.getType()

It checks if entities (entity from event and entityiterator is entity from "for each entity" procedure) are the same type. 

Last seen on 08:03, 24. Apr 2024
Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
comparing objects with == is…
Tue, 01/17/2023 - 16:55

comparing objects with == is a very bad idea in Java. Instead, you should use the equals() method.

Last seen on 15:21, 16. Oct 2023
Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Sorry, I'm mainly C++ so u…
Tue, 01/17/2023 - 18:51

Sorry, I'm mainly C++ so u know :>

entity.getType().equals(entityiterator.getType())

I think this should be good then >:3

Last seen on 09:36, 16. Feb 2024
Joined Jan 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thank! It's work
Wed, 01/18/2023 - 17:05

Thank! It's work