+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;
@@ -0,0 +0,0 @@ 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());