接口 StructureManager
-
方法概要
修饰符和类型方法说明创建此结构的副本.创建一个新的空结构.voiddeleteStructure(@NotNull NamespacedKey structureKey) 注销指定结构并从主世界文件夹中删除其结构文件。voiddeleteStructure(@NotNull NamespacedKey structureKey, boolean unregister) 从主世界文件夹中删除指定结构的结构文件。getStructure(@NotNull NamespacedKey structureKey) 获取已注册的结构。getStructureFile(@NotNull NamespacedKey structureKey) 根据 NamespacedKey 获取结构文件在主世界目录中的位置,使用格式 world/generated/{NAMESPACE}/structures/{KEY}.nbt。获取当前已注册的结构。loadStructure(@NotNull File file) 从磁盘读取结构。loadStructure(@NotNull InputStream inputStream) 从流中读取结构。loadStructure(@NotNull NamespacedKey structureKey) 加载指定键的结构并自动注册它。loadStructure(@NotNull NamespacedKey structureKey, boolean register) 为指定键加载结构,并可选择注册它。registerStructure(@NotNull NamespacedKey structureKey, @NotNull Structure structure) 注册给定的结构。voidsaveStructure(@NotNull File file, @NotNull Structure structure) 将结构保存到文件。voidsaveStructure(@NotNull OutputStream outputStream, @NotNull Structure structure) 将结构保存到流.voidsaveStructure(@NotNull NamespacedKey structureKey) 将当前已注册的结构保存到主世界文件夹, 按照 {#getStructureFile(NamespacedKey} 指定的方式。voidsaveStructure(@NotNull NamespacedKey structureKey, @NotNull Structure structure) 将具有给定键的结构保存到主世界文件夹。unregisterStructure(@NotNull NamespacedKey structureKey) 注销结构。
-
方法详细资料
-
getStructures
获取当前已注册的结构。原文: Gets the currently registered structures.
These are the currently loaded structures that the StructureManager is aware of. When a structure block refers to a structure, these structures are checked first. If the specified structure is not found among the currently registered structures, the StructureManager may dynamically read the structure from the primary world folder, DataPacks, or the server's own resources. Structures can be registered via
registerStructure(NamespacedKey, Structure)- 返回:
- 当前已注册结构的不可修改的浅拷贝。
-
getStructure
获取已注册的结构。原文: Gets a registered Structure.
- 参数:
structureKey- 要获取结构的键。- 返回:
- 属于该键的结构,如果没有注册该键的结构则返回
null。
-
registerStructure
@Nullable @Nullable Structure registerStructure(@NotNull @NotNull NamespacedKey structureKey, @NotNull @NotNull Structure structure) 注册给定的结构。参见getStructures()。原文: Registers the given structure. See
getStructures().- 参数:
structureKey- 要注册结构的键。structure- 要注册的结构。- 返回:
- 指定键的结构,如果找不到结构则返回
null。
-
unregisterStructure
注销结构。注销指定的结构。如果结构仍然存在于主世界文件夹、数据包中, 或是服务器自身资源的一部分,当插件或服务器本身请求时,它可能会被重新加载和注册。原文: Unregisters a structure. Unregisters the specified structure. If the structure still exists in the primary world folder, a DataPack, or is part of the server's own resources, it may be loaded and registered again when it is requested by a plugin or the server itself.
- 参数:
structureKey- 要注销结构的键。- 返回:
- 该键注册的结构,如果没有则返回
null。
-
loadStructure
@Nullable @Nullable Structure loadStructure(@NotNull @NotNull NamespacedKey structureKey, boolean register) 为指定键加载结构,并可选择注册它。原文: Loads a structure for the specified key and optionally
registersit.This will first check the already loaded
registered structures, and otherwise load the structure from the primary world folder, DataPacks, and the server's own resources (in this order).When loading the structure from the primary world folder, the given key is translated to a file as specified by
getStructureFile(NamespacedKey).- 参数:
structureKey- 要加载结构的键。register- 是否注册加载的结构。- 返回:
- 结构,如果未找到指定键的结构则返回
null。
-
loadStructure
加载指定键的结构并自动注册它。参见loadStructure(NamespacedKey, boolean)。原文: Loads the structure for the specified key and automatically registers it. See
loadStructure(NamespacedKey, boolean).- 参数:
structureKey- 要加载结构的键。- 返回:
- 指定键的结构,如果找不到结构则返回
null。
-
saveStructure
将当前已注册的结构保存到主世界文件夹, 按照 {#getStructureFile(NamespacedKey} 指定的方式。原文: Saves the currently
registered structurefor the specifiedkeyto the primary world folder as specified by {#getStructureFile(NamespacedKey}.- 参数:
structureKey- 要保存结构的键。
-
saveStructure
void saveStructure(@NotNull @NotNull NamespacedKey structureKey, @NotNull @NotNull Structure structure) throws IOException 将具有给定键的结构保存到主世界文件夹。原文: Saves a structure with a given key to the primary world folder.
- 参数:
structureKey- 要保存结构的键。structure- 要为此键保存的结构。- 抛出:
IOException
-
deleteStructure
注销指定结构并从主世界文件夹中删除其结构文件。 注意:此方法不能用于删除原版 Minecraft 结构或数据包中的结构。但注销这些结构是可以的。原文: Unregisters the specified structure and deletes its
structure filefrom the primary world folder. Note that this method cannot be used to delete vanilla Minecraft structures, or structures from DataPacks. Unregistering these structures will however work fine.- 参数:
structureKey- 要删除的结构的键。- 抛出:
IOException- 如果文件因某种原因无法删除。
-
deleteStructure
void deleteStructure(@NotNull @NotNull NamespacedKey structureKey, boolean unregister) throws IOException 从主世界文件夹中删除指定结构的结构文件。 注意:此方法不能用于删除原版 Minecraft 结构或数据包中的结构。但注销这些结构是可以的。原文: Deletes the
structure filefor the specified structure from the primary world folder. Note that this method cannot be used to delete vanilla Minecraft structures, or structures from DataPacks. Unregistering these structures will however work fine.- 参数:
structureKey- 要删除的结构的键。unregister- 是否同时注销当前已加载的指定结构。- 抛出:
IOException- 如果文件因某种原因无法删除。
-
getStructureFile
根据 NamespacedKey 获取结构文件在主世界目录中的位置,使用格式 world/generated/{NAMESPACE}/structures/{KEY}.nbt。此方法总是返回一个文件, 即使当前不存在。原文: Gets the location where a structure file would exist in the primary world directory based on the NamespacedKey using the format world/generated/{NAMESPACE}/structures/{KEY}.nbt. This method will always return a file, even if none exists at the moment.
- 参数:
structureKey- 用于构建文件路径的键。- 返回:
- 该键对应的文件位置。
-
loadStructure
从磁盘读取结构。原文: Reads a Structure from disk.
- 参数:
file- 结构的文件。- 返回:
- 读取的结构。
- 抛出:
IOException- 当给定文件无法读取时。
-
loadStructure
@NotNull @NotNull Structure loadStructure(@NotNull @NotNull InputStream inputStream) throws IOException 从流中读取结构。原文: Reads a Structure from a stream.
- 参数:
inputStream- 结构的输入流。- 返回:
- 读取的结构。
- 抛出:
IOException
-
saveStructure
void saveStructure(@NotNull @NotNull File file, @NotNull @NotNull Structure structure) throws IOException 将结构保存到文件。如果文件已存在,将被覆盖.原文: Save a structure to a file. This will overwrite a file if it already exists.
- 参数:
file- 要保存到的目标文件.structure- 要保存的结构.- 抛出:
IOException- 当给定文件无法写入时.
-
saveStructure
void saveStructure(@NotNull @NotNull OutputStream outputStream, @NotNull @NotNull Structure structure) throws IOException 将结构保存到流.原文: Save a structure to a stream.
- 参数:
outputStream- 要写入的流.structure- 要保存的结构.- 抛出:
IOException- 当给定文件无法写入时.
-
createStructure
创建一个新的空结构.原文: Creates a new empty structure.
- 返回:
- 一个空结构.
-
copy
创建此结构的副本.原文: Creates a copy of this structure.
- 参数:
structure- 要复制的结构.- 返回:
- 结构的副本.
-