结构化重生

结构化重生

一个简单的库,帮助添加自定义村庄结构。

基础库

Structurized Reborn

这是 DRAYLAR 作品 Structurized 的重制版。原版请见:https://github.com/omega-mc/structurized/tree/1.18

Structurized Reborn 是一个简单的库,帮助您向游戏中添加自定义村庄结构。

Bisect Hosting Banner

拼图(Jigsaw)修改

Structurized 提供了一个注册表,允许您将自定义结构添加到拼图(如村庄)的 StructurePool 中。假设我们想要将 village/plains/houses/plains_small_house_1 添加到沙漠房屋池中。只需将新结构注册到目标池,并为其赋予权重和一些可选修饰符即可。在与注册其他服务器相关注册表事件(例如注册物品或方块)相同的位置调用这些 register 方法。

FabricStructurePoolRegistry.register(
    Identifier("minecraft:village/desert/houses"),                       //目标池
    Identifier("minecraft:village/plains/houses/plains_small_house_1"),  //要添加的新结构 NBT
    2,                                                                   //结构在池中的权重
    StructureProcessorLists.MOSSIFY_10_PERCENT)                          //可选处理器,用于添加苔藓化效果

如果您没有特殊需求,可以使用 registerSimple 来简化操作:

FabricStructurePoolRegistry.registerSimple(
    Identifier("minecraft:village/desert/houses"),                       //目标池
    Identifier("minecraft:village/plains/houses/plains_small_house_1"),  //要添加的新结构 NBT
    2)                                                                   //结构在池中的权重

灵活的注册方式

register 方法非常灵活,可根据需要提供多个可选参数。在许多情况下,您可以直接使用 registerSimple 方法,但主 register 方法在需要添加许多村庄结构中常见的随机苔藓圆石等效果时会很有用。

参数:

poolId:必填,要修改的目标结构池

structureId:必填,新结构 NBT 位置的标识符

weight:必填,结构在生成时被选中的概率。权重为 1 到 3 时,每个村庄大约生成 1 个结构

processor:可选,定义要应用的自定义生成调整,如随机苔藓圆石

projection:可选,定义结构与地面的交互方式(固定于空间中或贴合地形)

type:可选,定义您想要的 structurePoolElement 类型。大多数情况下不需要

回调注册

如果您想对结构池进行更高级的操作,也可以直接注册到回调中,并添加任何您想要的事件代码。注册回调的方式如下:

StructurePoolAddCallback.EVENT.register(structurePool -> {
    if(structurePool.getUnderlying().getId().toString().equals("minecraft:village/plains/houses")) {
        structurePool.addStructurePoolElement(new SinglePoolElement("village/desert/houses/desert_small_house_1"), 50);
    }
});

添加依赖

您可以使用 modrinth 内置的 maven 仓库将此库作为项目的依赖项添加。{VERSION} 是您要使用的版本的版本号。例如,本库首个版本以 1.18.2-01 版本号上传。

在 build.gradle 中:

repositories {
    maven {
        name = "Modrinth"
        url = "https://api.modrinth.com/maven"
        content {
            includeGroup "maven.modrinth"
        }
    }
}

dependencies {
    modImplementation "maven.modrinth:Wd844r7Q:{VERSION}"
    include("maven.modrinth:Wd844r7Q:{VERSION}")
}

在 build.gradle.kts 中:

repositories {
    maven {
        name = "Modrinth"
        url = uri("https://api.modrinth.com/maven")
        content {
            includeGroup("maven.modrinth")
        }
    }
}

dependencies {
    modImplementation("maven.modrinth:Wd844r7Q:{VERSION}")
    include("maven.modrinth:Wd844r7Q:{VERSION}")
}