2021-06-11 12:02:28 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: dfsek <dfsek@protonmail.com>
|
|
|
|
Date: Wed, 16 Sep 2020 01:12:29 -0700
|
|
|
|
Subject: [PATCH] Add StructureLocateEvent
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
|
2022-03-01 05:43:03 +00:00
|
|
|
index f9fc2fc63080a60fe61ebb08ddd93c4f189df84d..4864fce027b0871e50b2060880be9e24bfdd3887 100644
|
2021-06-11 12:02:28 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
|
2022-03-01 05:43:03 +00:00
|
|
|
@@ -294,6 +294,20 @@ public abstract class ChunkGenerator implements BiomeManager.NoiseBiomeSource {
|
2021-06-11 12:02:28 +00:00
|
|
|
|
|
|
|
@Nullable
|
2022-03-01 05:43:03 +00:00
|
|
|
public Pair<BlockPos, Holder<ConfiguredStructureFeature<?, ?>>> findNearestMapFeature(ServerLevel worldserver, HolderSet<ConfiguredStructureFeature<?, ?>> holderset, BlockPos center, int radius, boolean skipExistingChunks) {
|
2021-06-11 12:02:28 +00:00
|
|
|
+ // Paper start
|
2022-03-01 05:43:03 +00:00
|
|
|
+ /*org.bukkit.World world1 = worldserver.getWorld();
|
2021-06-11 12:02:28 +00:00
|
|
|
+ org.bukkit.Location originLocation = new org.bukkit.Location(world1, center.getX(), center.getY(), center.getZ());
|
2021-11-24 18:27:25 +00:00
|
|
|
+ io.papermc.paper.event.world.StructureLocateEvent event = new io.papermc.paper.event.world.StructureLocateEvent(world1, originLocation, org.bukkit.StructureType.getStructureTypes().get(structureFeature.getFeatureName()), radius, skipExistingChunks);
|
2021-06-11 12:02:28 +00:00
|
|
|
+ if(!event.callEvent()) return null;
|
|
|
|
+ // If event call set a final location, skip structure finding and just return set result.
|
|
|
|
+ if(event.getResult() != null) return new BlockPos(event.getResult().getBlockX(), event.getResult().getBlockY(), event.getResult().getBlockZ());
|
|
|
|
+ // Get origin location (re)defined by event call.
|
|
|
|
+ center = new BlockPos(event.getOrigin().getBlockX(), event.getOrigin().getBlockY(), event.getOrigin().getBlockZ());
|
|
|
|
+ // Get radius and whether to find unexplored structures (re)defined by event call.
|
|
|
|
+ radius = event.getRadius();
|
|
|
|
+ skipExistingChunks = event.shouldFindUnexplored();
|
2022-03-01 05:43:03 +00:00
|
|
|
+ structureFeature = StructureFeature.STRUCTURES_REGISTRY.get(event.getType().getName());*/
|
2021-06-11 12:02:28 +00:00
|
|
|
+ // Paper end
|
2022-03-01 05:43:03 +00:00
|
|
|
Set<Holder<Biome>> set = (Set) holderset.stream().flatMap((holder) -> {
|
|
|
|
return ((ConfiguredStructureFeature) holder.value()).biomes().stream();
|
|
|
|
}).collect(Collectors.toSet());
|