mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-19 14:51:27 +01:00
fallback to default locate logic if no API found
This commit is contained in:
parent
5a7519440e
commit
130e8c090b
@ -85,17 +85,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ final var paperRegistry = io.papermc.paper.registry.PaperRegistry.getRegistry(io.papermc.paper.registry.RegistryKey.CONFIGURED_STRUCTURE_REGISTRY);
|
||||
+ final List<io.papermc.paper.world.structure.ConfiguredStructure> configuredStructures = new ArrayList<>();
|
||||
+ paperRegistry.convertToApi(structures, configuredStructures::add, false); // gracefully handle missing api, use tests to check (or exclude)
|
||||
+ final io.papermc.paper.event.world.StructuresLocateEvent event = new io.papermc.paper.event.world.StructuresLocateEvent(bukkitWorld, origin, configuredStructures, radius, skipReferencedStructures);
|
||||
+ if (!event.callEvent()) {
|
||||
+ return null;
|
||||
+ if (!configuredStructures.isEmpty()) {
|
||||
+ final io.papermc.paper.event.world.StructuresLocateEvent event = new io.papermc.paper.event.world.StructuresLocateEvent(bukkitWorld, origin, configuredStructures, radius, skipReferencedStructures);
|
||||
+ if (!event.callEvent()) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ if (event.getResult() != null) {
|
||||
+ return Pair.of(net.minecraft.server.MCUtil.toBlockPosition(event.getResult().position()), paperRegistry.getMinecraftHolder(event.getResult().configuredStructure()));
|
||||
+ }
|
||||
+ center = net.minecraft.server.MCUtil.toBlockPosition(event.getOrigin());
|
||||
+ radius = event.getRadius();
|
||||
+ skipReferencedStructures = event.shouldFindUnexplored();
|
||||
+ structures = HolderSet.direct(paperRegistry::getMinecraftHolder, event.getConfiguredStructures());
|
||||
+ }
|
||||
+ if (event.getResult() != null) {
|
||||
+ return Pair.of(net.minecraft.server.MCUtil.toBlockPosition(event.getResult().position()), paperRegistry.getMinecraftHolder(event.getResult().configuredStructure()));
|
||||
+ }
|
||||
+ center = net.minecraft.server.MCUtil.toBlockPosition(event.getOrigin());
|
||||
+ radius = event.getRadius();
|
||||
+ skipReferencedStructures = event.shouldFindUnexplored();
|
||||
+ structures = HolderSet.direct(paperRegistry::getMinecraftHolder, event.getConfiguredStructures());
|
||||
+ // Paper end
|
||||
Map<StructurePlacement, Set<Holder<Structure>>> map = new Object2ObjectArrayMap();
|
||||
Iterator iterator = structures.iterator();
|
||||
|
Loading…
Reference in New Issue
Block a user