Started by
Oskarxisee
on
Topic category: Help with Minecraft modding (Java Edition)
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
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").
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.
comparing objects with == is a very bad idea in Java. Instead, you should use the equals() method.
Sorry, I'm mainly C++ so u know :>
entity.getType().equals(entityiterator.getType())
I think this should be good then >:3
Thank! It's work