SPIGOT-7011, SPIGOT-7065: Overhaul of structures

By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
Bukkit/Spigot
2022-07-01 20:41:02 +10:00
parent 515ae6f2cc
commit 24ea881685
11 changed files with 289 additions and 1 deletions

View File

@@ -23,6 +23,8 @@ import org.bukkit.generator.BiomeProvider;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.generator.WorldInfo;
import org.bukkit.generator.structure.Structure;
import org.bukkit.generator.structure.StructureType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import org.bukkit.metadata.Metadatable;
@@ -32,6 +34,7 @@ import org.bukkit.plugin.messaging.PluginMessageRecipient;
import org.bukkit.util.BoundingBox;
import org.bukkit.util.Consumer;
import org.bukkit.util.RayTraceResult;
import org.bukkit.util.StructureSearchResult;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
@@ -2569,9 +2572,82 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
* @param findUnexplored true to only find unexplored structures
* @return the closest {@link Location}, or null if no structure of the
* specified type exists.
* @see #locateNearestStructure(Location, Structure, int, boolean)
* @see #locateNearestStructure(Location, StructureType, int, boolean)
* @deprecated Use
* {@link #locateNearestStructure(Location, Structure, int, boolean)} or
* {@link #locateNearestStructure(Location, StructureType, int, boolean)}
* instead.
*/
@Nullable
public Location locateNearestStructure(@NotNull Location origin, @NotNull StructureType structureType, int radius, boolean findUnexplored);
@Deprecated
public Location locateNearestStructure(@NotNull Location origin, @NotNull org.bukkit.StructureType structureType, int radius, boolean findUnexplored);
/**
* Find the closest nearby structure of a given {@link StructureType}.
* Finding unexplored structures can, and will, block if the world is
* looking in chunks that gave not generated yet. This can lead to the world
* temporarily freezing while locating an unexplored structure.
* <p>
* The {@code radius} is not a rigid square radius. Each structure may alter
* how many chunks to check for each iteration. Do not assume that only a
* radius x radius chunk area will be checked. For example,
* {@link StructureType#WOODLAND_MANSION} can potentially check up to 20,000
* blocks away (or more) regardless of the radius used.
* <p>
* This will <i>not</i> load or generate chunks. This can also lead to
* instances where the server can hang if you are only looking for
* unexplored structures. This is because it will keep looking further and
* further out in order to find the structure.
* <p>
* The difference between searching for a {@link StructureType} and a
* {@link Structure} is, that a {@link StructureType} can refer to multiple
* {@link Structure Structures} while searching for a {@link Structure}
* while only search for the given {@link Structure}.
*
* @param origin where to start looking for a structure
* @param structureType the type of structure to find
* @param radius the radius, in chunks, around which to search
* @param findUnexplored true to only find unexplored structures
* @return the closest {@link Location} and {@link Structure}, or null if no
* structure of the specified type exists.
* @see #locateNearestStructure(Location, Structure, int, boolean)
*/
@Nullable
StructureSearchResult locateNearestStructure(@NotNull Location origin, @NotNull StructureType structureType, int radius, boolean findUnexplored);
/**
* Find the closest nearby structure of a given {@link Structure}. Finding
* unexplored structures can, and will, block if the world is looking in
* chunks that gave not generated yet. This can lead to the world
* temporarily freezing while locating an unexplored structure.
* <p>
* The {@code radius} is not a rigid square radius. Each structure may alter
* how many chunks to check for each iteration. Do not assume that only a
* radius x radius chunk area will be checked. For example,
* {@link Structure#MANSION} can potentially check up to 20,000 blocks away
* (or more) regardless of the radius used.
* <p>
* This will <i>not</i> load or generate chunks. This can also lead to
* instances where the server can hang if you are only looking for
* unexplored structures. This is because it will keep looking further and
* further out in order to find the structure.
* <p>
* The difference between searching for a {@link StructureType} and a
* {@link Structure} is, that a {@link StructureType} can refer to multiple
* {@link Structure Structures} while searching for a {@link Structure}
* while only search for the given {@link Structure}.
*
* @param origin where to start looking for a structure
* @param structure the structure to find
* @param radius the radius, in chunks, around which to search
* @param findUnexplored true to only find unexplored structures
* @return the closest {@link Location} and {@link Structure}, or null if no
* structure was found.
* @see #locateNearestStructure(Location, StructureType, int, boolean)
*/
@Nullable
StructureSearchResult locateNearestStructure(@NotNull Location origin, @NotNull Structure structure, int radius, boolean findUnexplored);
/**
* Finds the nearest raid close to the given location.