适用于所有事物的 glTF 模型
本模组利用 frapi(Fabric 渲染 API)拦截方块模型的请求。如果这些请求指向 glTF 文件,它会将它们作为静态模型提供,并按常规方式烘焙到区块几何体中。这是一个纯客户端模组,可用于支持那些“诡异”的资源包,将现有方块替换为原版无法制作的非立方体形状。
它也可以作为“内置”模组使用,为你的模组提供非立方体方块的支撑。
详细说明
在 Blockbench 中创建兼容模型是最简单的方法。
- 在应用中,选择“新建 -> 低多边形/通用模型”,然后点击“创建新模型”按钮。
- 任何标识符、UV 模式或其他设置均可。
- 当你满意你的模型后,点击“文件 -> 导出 -> 导出 glTF 模型”。
- Blockbench 会忽略大多数设置,默认值完全没问题。
- 找到你导出的文件,并将其放在你通常放置 json 方块模型的位置(例如
assets/minecraft/models/block)。
- 创建一个子模型,将该 gltf 模型作为父级引用,其根键值对为
"loader": "suspicious_shapes:gltf"。你也可以在此处填写纹理引用并设置颜色索引。
- 编辑 glTF 模型的文本,用纹理引用替换纹理的数据 URL。
最后一步是最难的。在你打开的文件中,你会看到类似以下内容:
"images":[{"mimeType":"image/png","uri":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAr0lEQVQ4y6WTMQrCQBBFt0xtk0YQL+QR0mpnYyk5QbDObTc84YVB0NnFgSGTyf7/5w+bUpJ4LMdaeuI6jzWC5/Vcm0kAAyAleE6Hd00vkn8Fq0oCJv32up9yEg6REPGEQDLemyYR6DS3y7ATp3tQTTCEWqH3U50DcQccRl0b9lKSuAvV0wXG+AQyRTOYiDughkB76bXVgiDr5gkEeYEAu8iuf0L/WiD/Iii94diZ+gZo3N9oOnqLFAAAAABJRU5ErkJggg=="}]
这是你所用纹理的 base64 编码图像。由于方块模型不能使用不在纹理图集(atlas)中的随机纹理,我们必须对此进行修改。将每个标记为 "uri" 的不可读字符串替换为 Minecraft 纹理引用,如下所示:
"images":[{"mimeType":"image/png","uri":"minecraft:blocks/stone"}]
或者,如果你正在使用此形状制作多个模型,可以像往常一样将其作为父级并使用向上引用的纹理:
"images":[{"mimeType":"image/png","uri":"#all"}]
你的子模型可能看起来像这样:
{
"parent": "minecraft:block/sphere_all.gltf",
"loader": "suspicious_shapes:gltf",
"textures": {
"all": "minecraft:block/acacia_leaves"
},
"colorIndexes": [ 0 ]
}
就是这样!启动 Minecraft 或重载资源包,你应该就能看到你的模型了!
glTF models for everything
Using frapi (the fabric-rendering API), this mod intercepts requests for block models, and if they refer to glTF files, provides them as static models that get baked into the chunk geometry as normal. Entirely clientside, this mod can be used to power "cursed" resource packs that replace existing blocks with non-cuboid shapes that vanilla can't make.
It can also be used as an "included" mod to power non-cuboid blocks in your mods.
The Details
The easiest way to create a compatible model is in Blockbench.
- From the app, select "New -> Low Poly / Generic Model" and hit the "Create new model" button.
- Any identifier, UV mode, or other settings are fine.
- When you're satisfied with your model, hit "File -> Export -> Export glTF Model".
- Blockbench ignores most of these settings, and the defaults are perfectly fine.
- Find the file you exported and put it where you would normally put a json blockmodel (e.g.
assets/minecraft/models/block)
- make a child model which refers to the gltf model as a parent, with a root key-value pair of
"loader": "suspicious_shapes:gltf". You can fill-in texture references and set color indices here too.
- Edit the text of the glTF model to replace the texture's data URL with a texture reference.
The last part there is the hard part. In the file you'll see something like,
"images":[{"mimeType":"image/png","uri":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAr0lEQVQ4y6WTMQrCQBBFt0xtk0YQL+QR0mpnYyk5QbDObTc84YVB0NnFgSGTyf7/5w+bUpJ4LMdaeuI6jzWC5/Vcm0kAAyAleE6Hd00vkn8Fq0oCJv32up9yEg6REPGEQDLemyYR6DS3y7ATp3tQTTCEWqH3U50DcQccRl0b9lKSuAvV0wXG+AQyRTOYiDughkB76bXVgiDr5gkEeYEAu8iuf0L/WiD/Iii94diZ+gZo3N9oOnqLFAAAAABJRU5ErkJggg=="}]
This is a base-64 encoded image of the texture you used. Since block models can't use random textures that aren't in the atlas, we'll have to fix that. Replace each of the unreadable strings marked "uri" with a minecraft texture reference, like this
"images":[{"mimeType":"image/png","uri":"minecraft:blocks/stone"}]
Or, if you're making several models with this shape, you can use it as a parent with a texture up-reference like normal:
"images":[{"mimeType":"image/png","uri":"#all"}]
Your child model can look something like this:
{
"parent": "minecraft:block/sphere_all.gltf",
"loader": "suspicious_shapes:gltf",
"textures": {
"all": "minecraft:block/acacia_leaves"
},
"colorIndexes": [ 0 ]
}
And that's it! Load up minecraft or reload resource packs and you should see your model!
评论 0
登录后参与评分
还没有评论,来抢沙发吧