Перейти к содержимому
Mineforgian

Suspicious Shapes

Use glTF models in resource packs and mods!

4K загрузок19 подписчиковMITfabricquilt

Обновлён 21 января 2025 г. · опубликован 16 июня 2023 г.

  • Duke

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!

Версии

ВерсияКаналИграЗагрузчикиДатаСкачать
1.1.0-alpha.1+1.21.1Альфа1.21.1, 1.21.2, 1.21.3, 1.21.4fabric21 января 2025 г.Скачать (95 КБ)
1.0.5+1.20.4Релиз1.20.4fabric17 декабря 2023 г.Скачать (95 КБ)
1.0.4+1.20.1Релиз1.20, 1.20.1quilt21 августа 2023 г.Скачать (97 КБ)
1.0.3+1.20.1Релиз1.20, 1.20.1quilt9 августа 2023 г.Скачать (94 КБ)
1.0.2+1.20.1Релиз1.20, 1.20.1quilt12 июля 2023 г.Скачать (83 КБ)
1.0.1+1.20.1Релиз1.20, 1.20.1quilt2 июля 2023 г.Скачать (83 КБ)
1.0.0+1.20.1Релиз1.20, 1.20.1quilt18 июня 2023 г.Скачать (82 КБ)

Ченджлог

1.1.0-alpha.1+1.21.1Альфа1.21.2, 1.21.3, 1.21.4 · 21 января 2025 г.

This is a mostly-unmolested forward-port of Suspicious Shapes to 1.21.1. for the most part, resource packs designed for the original will work in the updated version.

Previously, Suspicious Shapes would ignore models parented to a gltf without the key-value pair,

"loader": "suspicious_shapes:gltf"

The new version has namespaced this key to be less intrusive when loaded alongside connector and/or the upcoming fabric model loader API. Models should be updated as follows:

"suspicious_shapes:loader": "suspicious_shapes:gltf"

Sorry for the difficulty this may cause, but I promise it'll be worth the trouble with all the wild new mod interactions this makes possible.

1.0.5+1.20.4Релиз1.20.4 · 17 декабря 2023 г.
  • Port back to fabric
  • Update to 1.20.4
1.0.4+1.20.1Релиз1.20, 1.20.1 · 21 августа 2023 г.

Bugfix release

  • Adds null guards around the deserialized json to make model loading more resilient.
  • Adds a barebones config file to control how aggressively errors get logged (defaults to reporting number of model errors collectively).
1.0.3+1.20.1Релиз1.20, 1.20.1 · 9 августа 2023 г.

Reworks model loading almost entirely to deal with the new model-loader-api-v1 in fabric and the sudden no-deprecation removal of v0 from dev artifacts.

The new loader:

  • Grabs all its raw data ahead of time on a DataLoader worker thread - this is extremely fast, usually on the order of 300-400msec on a vanilla instance, but times are posted in the logs now.
  • Builds and prunes model trees in a preparation worker thread. Typically around 400-500msec for the whole kit, this time is also posted in the log. This is when memory usage peaks, but big data structures are nulled out ASAP for the garbage collector in case things get hairy.
  • Builds / provides / bakes the final model in yet another worker thread. The main speed benefit is here, that by the time the model is requested by Id, the data is already present and we don't need to touch ResourceLoader at all.

The speed boost in loading individual models comes at the expense of a moderate memory spike and some very particular setup steps. Please let me know if either of these gets out of hand.

1.0.2+1.20.1Релиз1.20, 1.20.1 · 12 июля 2023 г.

This is a minor bugfix release.

  • Fixes "uvLock" property to be "uvlock" like vanilla
1.0.1+1.20.1Релиз1.20, 1.20.1 · 2 июля 2023 г.

Worked out a lot of the initial kinks!

  • Fixed normals and shading on rotated shapes
  • Now honors uvLock
  • Invalid json in one model no longer destroys all models for everyone
  • Lots of little cleanups everywhere
1.0.0+1.20.1Релиз1.20, 1.20.1 · 18 июня 2023 г.

Initial release!

Late additions:

  • Will not load models without the following key-value-pair on the child model: "loader": "suspicious_shapes:gltf" - this is to let other model loaders know we're here, and to avoid clobbering their models.
  • Some previously-broken untextured models will now load. Faces with no textures specified will act like an "#all" up-reference, subject to change in future versions.

Known Issues

  • obj+mtl loading isn't in yet, but is planned for the future. Its loader key will be "suspicious_shapes:obj".
  • vertex colors aren't yet honored. This is also planned for the future.

Комментарии

Загружаем…