蓝图枢纽

蓝图枢纽

Hytale高性能预制建筑与结构生成引擎。由introllmortal提供资源缓存与核心卡顿修复。

图书馆

蓝图链接

蓝图链接是一个针对 Hytale 服务器的先进结构分布与生成引擎。它提供了一个强大且高性能的框架,用于生成复杂的结构,并具备智能地形适应和高级生物群系过滤功能。


🚀 功能特性

  • 智能地形适应:内置“自动地基”和地形平整功能,确保结构在斜坡、山脉或不平坦地形上看起来自然。
  • 严格资产注册:引擎严格遵循服务器当前启用的模组列表,防止因禁用或缺失资产而产生“幽灵”结构。
  • 双重集成:同时支持基于代码的 Java API 注册和零代码的资产文件注册。
  • 免代码生物群系标签:通过在文件夹名称中使用简单标签(例如 [desert])来限制生成,无需编写任何 JSON 代码。
  • 零粉色纹理:重新设计的资产映射确保了所有方块在放置前都能被正确解析,消除了渲染故障。

🛠 集成方法

1. 传统路径(免代码)

蓝图链接为结构包提供完整的向后兼容性。只需将您的 .prefab.json.lpf 文件放入以下路径: assets/server/worldgen/sharedstructures/prefabs/

  • 文件夹标签:您可以通过使用方括号为文件夹命名来添加生物群系限制。
    • 示例prefabs/[desert]/temple.json 将仅在沙漠生物群系中生成。

2. Java API

对于高级开发者,蓝图链接提供了一个全面的 API,允许在运行时动态注册、管理和监控结构条目。


🔄 兼容性

蓝图链接是一个分布引擎,而非内容包。它不包含内置结构,但提供了生成它们的逻辑。它提供了100% 的向后兼容性,兼容为旧版 SharedStructures 插件设计的结构,并提供 100 倍的性能提升和更强的稳定性。


📦 安装

  1. 下载 BlueprintNexus.jar 并将其放入服务器目录中的 Mods 文件夹。
  2. 将任何兼容的结构包(JAR 或 ZIP)添加到同一目录。
  3. 重启服务器。引擎将自动扫描并注册所有有效的结构。

📖 开发者指南

将蓝图链接添加为依赖项

要确保您的模组在引擎之后加载并能访问 API,请将其添加到您的 manifest.json 中:

"dependencies": [
  { "name": "BlueprintNexus", "version": ">=1.1.3" }
]

开发环境:将 BlueprintNexus.jar 添加到您项目的类路径中。如果您的模组声明了此依赖关系并使用旧版资产路径,蓝图链接将自动处理注册。

API 参考

BlueprintNexusPlugin

  • public static BlueprintNexusPlugin getAPI():返回插件的活动实例。
  • public BlueprintRegistry getRegistry():返回全局结构注册表实例。
  • public List<StructureEntry> getEntries():返回当前所有活动结构条目的不可修改列表。
  • public int getGlobalMaxExtent():返回用于结构放置的最大搜索半径(以方块为单位)。
  • public CompletableFuture<Void> reloadFromAssetPacksAsync():触发从当前 AssetModule 注册表异步重新加载所有结构。

BlueprintRegistry

  • public void register(StructureEntry entry):将新的结构条目注册到全局池中。
  • public boolean unregister(String id):通过其唯一 ID 移除一个结构。如果成功则返回 true
  • public boolean isRegistered(String id):检查某个结构 ID 是否已在注册表中。
  • public List<StructureEntry> getAll():返回所有已注册条目的快照列表。

示例插件代码

/*
 * Required manifest.json dependency:
 * "dependencies": [{ "name": "BlueprintNexus", "version": ">=1.1.3" }]
 */
package com.example.mod;

import com.hypixel.hytale.server.core.plugin.JavaPlugin;
import com.hypixel.hytale.server.core.plugin.JavaPluginInit;
import com.hypixel.hytale.logger.HytaleLogger;
import blueprint.nexus.BlueprintNexusPlugin;
import blueprint.nexus.BlueprintRegistry;
import blueprint.nexus.BlueprintNexusPlugin.StructureEntry;
import com.google.gson.JsonParser;
import javax.annotation.Nonnull;
import java.util.List;
import java.util.Set;

public class ExampleStructureMod extends JavaPlugin {
    private static final HytaleLogger LOGGER = HytaleLogger.get("ExampleStructureMod");

    public ExampleStructureMod(@Nonnull JavaPluginInit init) {
        super(init);
    }

    @Override
    protected void onEnable() {
        // Get the BlueprintNexus API and Registry
        BlueprintRegistry registry = BlueprintNexusPlugin.getAPI().getRegistry();

        // 1. Register a Desert-only structure
        registry.register(new StructureEntry(
                "example_desert_shrine", // Unique ID
                Set.of("desert"), // Allowed Biomes
                Set.of(), // Allowed Zones (Empty for all)
                List.of("hytale:shrine_desert"), // Prefab key
                List.of(1.0), // Weight
                JsonParser.parseString("{}"), // Spawning Pattern (Default)
                Set.of(), // Folder tags
                0, // Surface offset
                true, // Clearance check
                true // Auto-foundation
        ));

        // 2. Register a Rare structure with low rarity (0.1 weight)
        registry.register(new StructureEntry(
                "example_rare_tower",
                Set.of(), // All biomes
                Set.of(), // All zones
                List.of("hytale:wizard_tower"),
                List.of(0.1), // Low weight relative to others
                JsonParser.parseString("{}"),
                Set.of(),
                0,
                true,
                true
        ));

        LOGGER.atInfo().log("ExampleStructureMod: Successfully registered structures via BlueprintNexus API!");
    }
}

👤 鸣谢

  • 作者/维护者: introllmortal
  • 原始概念: 基于 SharedStructures (旧版)