Setup
将此库包含到您的 `build.gradle` 中作为一个依赖项
repositories {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
content {
includeGroup "maven.modrinth"
}
}
}
dependencies {
modImplementation "maven.modrinth:structureplacerapi:<version>"
}
已复制!
如果您希望在您的jar文件中包含API,只需添加 `include` 字符串:
repositories {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
content {
includeGroup "maven.modrinth"
}
}
}
dependencies {
modImplementation "maven.modrinth:structureplacerapi:<version>"
include "maven.modrinth:structureplacerapi:<version>"
}
已复制!
小于15 kb!
如何使用
如何创建结构?
您必须使用Minecraft的StructureBlocks创建一个NBT结构,就像这个视频中所示:https://www.youtube.com/watch?v=umhuRXinD3o
我得到的文件放在哪里?
您需要将 structure.nbt 文件放在您的模组数据文件夹中,如下: `data/yourmodid/structures`
创建一个新的放置器对象
为了放置结构,您首先需要创建一个放置器对象,只需简单地创建一个新的 `StructurePlacerAPI` 对象。它有很多参数可以操作:
StructurePlacerAPI(ServerWorld world, Identifier templateName, BlockPos blockPos, BlockMirror mirror, BlockRotation rotation, boolean ignoreEntities, float integrity, BlockPos offset)
已复制!
The parameters
- 第一个参数 `world` 是我们将要放置结构的世界。您可以从实体中获取它,或其他方式获取。
- 第二个参数 `templateName` 是由您模组的MOD_ID和结构的名称组成的标识符
- 第三个参数 `blockPos` 是您的结构将要生成的方块位置。您可以从实体坐标获取
- 第四个 `mirror` 是可选参数之一。 使用 `BlockMirror` 类,您可以将结构进行镜像。无需创建另一个对象,只需输入BlockMirror.#stuff
- 第五个 `rotation` 类似于前一个,您可以使用 `BlockRotation` 类来旋转您的结构。无需创建另一个对象,只需输入BlockMirror.#stuff
- `ignoreEntities` 参数如果设置为 true,则不会生成结构文件中包含的实体。 如果设置为false,它将生成这些实体
- `integrity` 参数非常有趣,因为它是一个值在0f和1f之间的浮点数,它将决定结构的运行状况有多么破旧。 如果将其设置为小于1f的值,则生成时将移除一些方块
- 最后,`offset` 参数是另一个可能有用的BlockPos,用于将结构重新定位在实体的脚下或其他位置。
放置结构
您刚刚创建了一个 `StructurePlacerAPI placer = new StructurePlacerAPI(things up there)`,要生成它,您需要执行:
placer.loadStructure();
已复制!
是的,好吧,这并不困难。您只需要运行那个,而不是直接运行 `.place` 方法,因为加载时还将检查是否存在该结构。
在一段时间后恢复旧地形
从版本`1.1.0`开始,您还可以使用:
placer.loadAndRestoreStructure(int restore_ticks);
已复制!
提供一定数量的ticks( 1秒 = 20 ticks ),之后旧地形将被恢复。
注意:这可能导致性能问题,特别是如果结构真的很大!(需要保存结构内的每个方块!)
您还可以通过使用以下方法为方块重新出现添加动画:
placer.loadAndRestoreStructureAnimated(int restore_ticks, int blocks_per_tick, boolean random);
已复制!
- `blocks_per_tick` 是每个tick要替换的方块数,因此如果您的结构由200个方块组成,而`blocks_per
来自Modrinth
StructurePlacerAPI 1.1.5+1.19.2
structureplacerapi-1.1.5+1.19.2.jar下载1.1.5+1.19.2#Releasestructureplacerapi-1.1.5+1.19.2-javadoc.jar下载1.1.5+1.19.2#Releasestructureplacerapi-1.1.5+1.19.2-sources.jar下载1.1.5+1.19.2#ReleaseFixed issues when using this mod on 1.19.2展开版本: 1.1.5+1.19.2支持游戏: 1.19.2类型: Fabric QuiltRelease下载次数: 171StructurePlacerAPI 1.1.5
structureplacerapi-1.1.5.jar下载1.1.5#Releasestructureplacerapi-1.1.5-javadoc.jar下载1.1.5#Releasestructureplacerapi-1.1.5-sources.jar下载1.1.5#ReleaseUpdated to 1.21展开版本: 1.1.5支持游戏: 1.21, 1.21.1类型: Fabric QuiltRelease下载次数: 589StructurePlacerAPI 1.1.4
structureplacerapi-1.1.4.jar下载1.1.4#Releasestructureplacerapi-1.1.4-javadoc.jar下载1.1.4#Releasestructureplacerapi-1.1.4-sources.jar下载1.1.4#Release- Switched from using `ServerWorld` to `StructureWorldAccessor` so you can use it earlier, from this [suggestion]([https://github.com/Emafire003/StructurePlacerAPI/issues/1](https://github.com/Emafire003/StructurePlacerAPI/issues/1))展开版本: 1.1.4支持游戏: 1.20, 1.20.1, 1.20.2, 1.20.3, 1.20.4, 1.20.5, 1.20.6类型: Fabric QuiltRelease下载次数: 634
收录