Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 20:40:07 +01:00
32 Zeilen
2.2 KiB
Diff
32 Zeilen
2.2 KiB
Diff
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
|
|
index 583b87b20490fd7254f5e966af3b6a627f53a7cb..13e789b3b7ea3be73ec73bb5357cb603da8d5e0d 100644
|
|
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
|
|
+++ b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
|
|
@@ -183,6 +183,20 @@ public abstract class ChunkGenerator implements BiomeManager.NoiseBiomeSource {
|
|
|
|
@Nullable
|
|
public BlockPos findNearestMapFeature(ServerLevel world, StructureFeature<?> structureFeature, BlockPos center, int radius, boolean skipExistingChunks) {
|
|
+ // Paper start
|
|
+ org.bukkit.World world1 = world.getWorld();
|
|
+ org.bukkit.Location originLocation = new org.bukkit.Location(world1, center.getX(), center.getY(), center.getZ());
|
|
+ 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);
|
|
+ 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();
|
|
+ structureFeature = StructureFeature.STRUCTURES_REGISTRY.get(event.getType().getName());
|
|
+ // Paper end
|
|
if (structureFeature == StructureFeature.STRONGHOLD) {
|
|
this.generateStrongholds();
|
|
BlockPos blockposition1 = null;
|