|
StructurePlacerAPI (结构放置API)Github |相关wiki |源站链接支持: fabric , quilt一个为Fabric模组开发者制作的API,用于生成NBT结构
*Setup*
将此库包含到您的 `build.gradle` 中作为一个依赖项
repositories {
maven {
name = \"Modrinth\"
url = \"https://api.modrinth.com/maven\"
content {
includeGroup \"maven.modrinth\"
}
}
}
dependencies {
modImplementation \"maven.modrinth:structureplacerapi:<version>\"
}Copy已复制!
如果您希望在您的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>\"
}Copy已复制!
小于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)Copy已复制!
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();Copy已复制!
是的,好吧,这并不困难。您只需要运行那个,而不是直接运行 `.place` 方法,因为加载时还将检查是否存在该结构。
*在一段时间后恢复旧地形*
从版本`1.1.0`开始,您还可以使用:
placer.loadAndRestoreStructure(int restore_ticks);Copy已复制!
提供一定数量的ticks( 1秒 = 20 ticks ),之后旧地形将被恢复。
*注意*:这可能导致性能问题,特别是如果结构真的很大!(需要保存结构内的每个方块!)
您还可以通过使用以下方法为方块重新出现添加动画:
placer.loadAndRestoreStructureAnimated(int restore_ticks, int blocks_per_tick, boolean random);Copy已复制!
- `blocks_per_tick` 是每个tick要替换的方块数,因此如果您的结构由200个方块组成,而`blocks_per
来自Modrinth所有游戏版本1.19.21.211.21.11.21.21.21.31.21.41.21.51.21.61.21.71.201.20.11.20.21.20.31.20.41.20.51.20.61.191.19.1所有类型fabricquiltStructurePlacerAPI 1.1.5+1.19.2structureplacerapi-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类型:FabricQuiltRelease下载次数: 204StructurePlacerAPI 1.1.5structureplacerapi-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.21EDIT: Still works in 1.21.7展开版本: 1.1.5支持游戏: 1.21, 1.21.1, 1.21.2, 1.21.3, 1.21.4, 1.21.5, 1.21.6, 1.21.7类型:FabricQuiltRelease下载次数: 870StructurePlacerAPI 1.1.4structureplacerapi-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类型:FabricQuiltRelease下载次数: 733StructurePlacerAPI 1.1.3structureplacerapi-1.1.3.jar下载1.1.3#Releasestructureplacerapi-1.1.3-javadoc.jar下载1.1.3#Releasestructureplacerapi-1.1.3-sources.jar下载1.1.3#Release- Fixed an issue with loadAndRestoreAnimated where executing it in rapid succession made a loop of regenerating blocks (like [so]([https://github.com/Emafire003/LightWithin/issues/14](https://github.com/Emafire003/LightWithin/issues/14)))- Added javadoc & sources展开版本: 1.1.3支持游戏: 1.20, 1.20.1, 1.20.2, 1.20.3, 1.20.4, 1.20.5类型:FabricQuiltRelease下载次数: 212StructurePlacerAPI 1.1.2structureplacerapi-1.1.2.jar下载1.1.2#Release- I had accidentally removed the setblockstate for the animated method, so it didn\'t work. It is now fixed, sorry!展开版本: 1.1.2支持游戏: 1.20, 1.20.1, 1.20.2, 1.20.3, 1.20.4类型:FabricQuiltRelease下载次数: 215StructurePlacerAPI 1.1.1structureplacerapi-1.1.1.jar下载1.1.1#Release- Added a way to regenerate the old terrain after a structure has been placed, optionally with a small animation! Check the description or github page for more info! You can also look at the javadocs.- Updated the javadocs between 1.1.0 and 1.1.1- Hopefull fixed the maven mess i made- FabricAPI is now required as a dependency展开版本: 1.1.1支持游戏: 1.20, 1.20.1, 1.20.2, 1.20.3, 1.20.4类型:FabricQuiltRelease下载次数: 80StructurePlacerAPI 1.1.0 - IGNORE ME, use 1.1.1 i made a messstructureplacerapi-1.1.0.jar下载1.1.0#Alpha- I made a mess with modrinth versioning, so 1.1.0 won\'t with maven, use 1.1.1 please!展开版本: 1.1.0支持游戏: 1.20, 1.20.1, 1.20.2, 1.20.3, 1.20.4类型:FabricQuiltAlpha下载次数: 121StructurePlacerAPI 1.0.2structureplacerapi-1.0.2.jar下载1.0.2#Release- Updated to 1.20.x展开版本: 1.0.2支持游戏: 1.20, 1.20.1类型:FabricQuiltRelease下载次数: 216StructurePlacerAPI - 1.0.1structureplacerapi-1.0.1.jar下载1.0.1#ReleaseOops forgot to change the modid, it showed the one from potionrecipesmod展开版本: 1.0.1支持游戏: 1.19, 1.19.1, 1.19.2类型:FabricQuiltRelease下载次数: 200StructurePlacerAPIstructureplacerapi-1.0.0.jar下载1.0.0#Release展开版本: 1.0.0支持游戏: 1.19类型:FabricQuiltRelease下载次数: 142全部版本
文章类型:收录layui.use([\'form\'], function(){
var form = layui.form;
});
StructurePlacerAPI |
楼主
2025-8-10 19:30:00
回复(0)
收起回复
|