Structurized Reborn
这是 Draylar 的 Structurized 的重制版本。原版请参见:
Structurized Reborn 是一个简单的库,用于辅助添加自定义村庄结构。
锁块修改
Structurized 提供了一个注册表,允许你向如村庄等场景中的锁块(jigsaws)的 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) // 该结构在池中的权重
灵活注册
注册方法非常灵活,提供了多个可根据需要使用的可选参数。在许多情况下,使用 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}")
}
Structurized Reborn
THIS IS A REWORK OF DRAYLAR'S STRUCTURIZED. See the original here:
Structurized Reborn is a simple library that helps with the addition of custom village structures.
Jigsaw Modification
Structurized provides a registry that allows you to add custom structures to StructurePools in jigsaws such as villages. Say we wanted to add village/plains/houses/plains_small_house_1 to the desert house pool. Simply register the new structure to the desired pool and give it a weight and some optional modifiers. Call these register methods in the same place you would call any other server-focused registry event (registering items or blocks, for example)
FabricStructurePoolRegistry.register(
Identifier("minecraft:village/desert/houses"), //the target pool
Identifier("minecraft:village/plains/houses/plains_small_house_1"), //the new structure nbt to add
2, //the weight of the structure in the pool
StructureProcessorLists.MOSSIFY_10_PERCENT) //optional processor to add mossiness
If you don't have any special considerations, you can use registerSimple to make your life a bit easier:
FabricStructurePoolRegistry.registerSimple(
Identifier("minecraft:village/desert/houses"), //the target pool
Identifier("minecraft:village/plains/houses/plains_small_house_1"), //the new structure nbt to add
2) //the weight of the structure in the pool
Flexible Registration
The register method is quite flexible, with several optional parameters to use as needed. In many cases you will be OK using the registerSimple method, but the main register method can be useful for doing something like adding the random mossy cobblestone that many village structures have.
Parameters:
poolId: required, the target pool of structures to modify
structureId: required, the new structure nbt location identifier
weight: required, the probability of a structure being chosen for generation. A weight of 1 to 3 is about 1 structure per village
processor: optional, defines custom generation tweaks to apply, like random mossy cobblestone
projection: optional, defines the way the structure interacts with the ground (rigid in space or conform to the landscape)
type: optional, defines the type of structurePoolElement you want. This isn't needed the majority of the time
Callback Registration
If you want to do something more advanced with a structure pool, you can also directly register to the callback and add whatever event code you'd like. Registering to the callback looks like so:
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);
}
});
Adding Dependency
You can add this as a dependency to your project using modrinth's built in maven repository. The {VERSION} will be the version number of the version you are trying to work with. For example, the first version of this library was uploaded under version number 1.18.2-01.
In a 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}")
}
In a 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}")
}
评论 0
登录后参与评分
还没有评论,来抢沙发吧