Skip to content

Ajout d'un système de région ( zone ) - #1485

Open
Nocolm wants to merge 1 commit into
ServerOpenMC:masterfrom
Nocolm:regions
Open

Nocolm wants to merge 1 commit into
ServerOpenMC:masterfrom
Nocolm:regions

Conversation

@Nocolm

@Nocolm Nocolm commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Petit résumé de la PR:

Ajout d'un système de région avec détection d'entité dedans

Étape nécessaire afin que la PR soit fini (si PR en draft)

  • Suivre le Code de Conduite
  • Enlever tous les imports non utilisés
  • Bien documenter la feature
  • Fournir un profileur (si besoin/demandé par un admin)
  • Avoir une milestone associée à la PR
  • Valider tout les checks
  • Tester et valider la feature/changement
  • Les Issues corrigée(s) en commun :

Decrivez vos changements

Le système est assez simple, c'est un zone, on peut ajouter une détection sur les entités pour dire de faire quelque chose si tel entité est dedans... ( pour détecter les entités, la région récupères les chunks dans les quel elle se situe et récupère les entité dedans )

@iambibi iambibi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Pas de registre + tu as mis tes packages dans core.utils alors que c'est pas un utils, je te conseille de regarder le commentaire + de les moves dans core.registry.region
  • Méthode pas du tout optimisé (utilise plutot des points que des chunks ou tu parcours TOUTES les entites, j'imagine meme pas avec une région qui fait 1000x1000)

0L,
10L // 0.5s
);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vive les perf, tu mets des entités dont on s'en fou totalement et si tu fais tout ça juste pour dire des que le joueur rentre dans une zone, on affiche un message, et quand il sort et qu'il rerentre on l'affiche et que tu mets du code plus compliqué pour gerer ça aucun interet


return !wasInside;
}
} No newline at end of file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

y'a pas de registre ? ex
(et tu enregistres simplement et clairement les regions)

/**
 * Registre qui mets à la disposition d'enregistrer des POI (Point of Interest)
 * qui est conretement une region, entre 2 points
 */
public class CustomPoiRegistry extends Registry<String, CustomPoi>
        implements KeyedRegistry<String, CustomPoi>, HasListeners {

    // ** REGISTER POIs **
    public final CustomPoi SINGULARITY = register(new SingularityPoi());

    @Override
    public void postInit() {
        for (CustomPoi poi : values()) {
            poi.firstLoad();

            WorldGuardHook.registerWorldGuardRegion(poi.getKey(), poi.getWorld(), poi.getPos1(), poi.getPos2());
        }
    }

    @Override
    public String key(CustomPoi registryObject) {
        return registryObject.getKey().asString();
    }

    @Override
    public Set<ListenerFactory> getListeners() {
        return Set.of(
                PoiDetectionListener::new
        );
    }

    public Optional<CustomPoi> getByLocation(Location location) {
        BlockVector3 locVec3 = BlockVector3.at(location.getX(), location.getY(), location.getZ());
        World world = location.getWorld();
        for (CustomPoi poi : values()) {
            if (!poi.getWorld().getName().equals(world.getName())) continue;
            if (!locVec3.containedWithin(poi.getPos1(), poi.getPos2())) continue;

            return Optional.of(poi);
        }
        return Optional.empty();
    }
}

}

// use for enter/exit detection only
public boolean simpleInOutVerification(Entity entity) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pas compris?

}

public void initChunks() {
chunks = getChunks();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

en plus tu load les chunks lors du init de la classe, c'est pas opti, alors que tu pourrais faire juste un truc avec 2 points (et 1 points + distance pour cylinderRegion). qui est concretement un BlockVector3. au lieu d'enregistrer les instances des chunks

Comment on lines +91 to +98
@Override
public SquareRegion clone() {
try {
return (SquareRegion) super.clone();
} catch (CloneNotSupportedException e) {
throw new RuntimeException(e);
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hein clone des regions?


for (int cx = minChunkX; cx <= maxChunkX; cx++) {
for (int cz = minChunkZ; cz <= maxChunkZ; cz++) {
chunks.add(regionWorld.getChunkAt(cx, cz));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ça ne va pas cette histoire, pourquoi travailler avec des chunks alors tu pourrais juste avec des nombres qui sont en réalité tes co.

continue;
}

chunks = Stream.concat(chunks.stream(), region.getChunks().stream())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

concat, mh

Comment on lines +17 to +21
BlockVector3 cylCenter;
World regionWorld;
double radius;
double minY;
double maxY;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tt en public meme pas de private + @Getter

@iambibi iambibi added the 📦 Feature Ajout d'une fonctionnalité label Sep 16, 2026
@iambibi iambibi added this to the 2.5.0-beta-10 milestone Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📦 Feature Ajout d'une fonctionnalité

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants