42 lines
2.5 KiB
Diff
42 lines
2.5 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/server/ChunkGenerator.java b/src/main/java/net/minecraft/server/ChunkGenerator.java
|
||
|
index 9a6fef215052f9c513b23024968995c97863a453..097cb9896c525a605c50e83548f828e0c71ab3d5 100644
|
||
|
--- a/src/main/java/net/minecraft/server/ChunkGenerator.java
|
||
|
+++ b/src/main/java/net/minecraft/server/ChunkGenerator.java
|
||
|
@@ -2,6 +2,7 @@ package net.minecraft.server;
|
||
|
|
||
|
import com.google.common.collect.Lists;
|
||
|
import com.mojang.serialization.Codec;
|
||
|
+import io.papermc.paper.event.world.StructureLocateEvent; // Paper - Add import due to naming conflict.
|
||
|
import java.util.BitSet;
|
||
|
import java.util.Iterator;
|
||
|
import java.util.List;
|
||
|
@@ -124,6 +125,22 @@ public abstract class ChunkGenerator {
|
||
|
|
||
|
@Nullable
|
||
|
public BlockPosition findNearestMapFeature(WorldServer worldserver, StructureGenerator<?> structuregenerator, BlockPosition blockposition, int i, boolean flag) {
|
||
|
+ // Paper start
|
||
|
+ org.bukkit.World world = worldserver.getWorld();
|
||
|
+ org.bukkit.Location originLocation = new org.bukkit.Location(world, blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
||
|
+ StructureLocateEvent event = new StructureLocateEvent(world, originLocation, org.bukkit.StructureType.getStructureTypes().get(structuregenerator.i()), i, flag);
|
||
|
+ 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 BlockPosition(event.getResult().getBlockX(), event.getResult().getBlockY(), event.getResult().getBlockZ());
|
||
|
+ // Get origin location (re)defined by event call.
|
||
|
+ blockposition = new BlockPosition(event.getOrigin().getBlockX(), event.getOrigin().getBlockY(), event.getOrigin().getBlockZ());
|
||
|
+ // Get world (re)defined by event call.
|
||
|
+ worldserver = ((org.bukkit.craftbukkit.CraftWorld) event.getOrigin().getWorld()).getHandle();
|
||
|
+ // Get radius and whether to find unexplored structures (re)defined by event call.
|
||
|
+ i = event.getRadius();
|
||
|
+ flag = event.shouldFindUnexplored();
|
||
|
+ structuregenerator = StructureGenerator.a.get(event.getType().getName());
|
||
|
+ // Paper end
|
||
|
if (!this.b.a(structuregenerator)) {
|
||
|
return null;
|
||
|
} else if (structuregenerator == StructureGenerator.STRONGHOLD) {
|