Simple Shelves

Simple Shelves

238k Downloads

Baking Models

Pinaz993 opened this issue ยท 1 comments

commented

This mod has a bit of an efficiency problem. The models for the shelves rely on the vanilla model baking system, but it is NOT built for what I'm doing. The problem is that when the game initializes (and when you reload assets), a multi-part model is completely enumerated: all possible combinations of block states are iterated over and individually baked using the JSON system. Great for things like observers, which can face in six directions and have an active state, meaning there are 12 models to iterate over. However, shelves are a little more complex.

A shelf has 12 Boolean block state properties - one for each book position - and a facing property with four possible values. This means that there are 2^12 * 4 or 2^14, or 16,384 possible block states. Not only does this take a while to process, it also causes some mod combinations to freeze up entirely, meaning that SimpleShelves is unusable for some use cases. I find this unacceptable.

To solve this issue, it was suggested that I bake the models on the fly. That is a more difficult proposition, but one that can be accomplished. I have, however, had many issues in implementing this suggestion, and I've recently figured out why.

First, my understanding of the issue was confused. I knew that the initial processing of all models was an unacceptable inefficiency, but I believed that for me to solve it, I had to eschew block states entirely. I have spent more than 24h cumulatively trying to understand not only how to manually bake a model, but also how to access the block entity while doing so. I now believe that I can still use block states to pass information from the block entity to the rendering pipeline, as long as the JSON model baking pipeline is never involved.

I also, for some god-forsaken reason, decided that having your wings melt and fall apart only happens to stupid people, and that I also wanted to make the books look random while I was at it. I still don't know quite if it is possible, and I want to try. However, in a sudden moment of clarity, I finally realized that I was biting off much more than I could chew, that random books and baking models are separate problems, and that I should tackle one at a time.

Facing both of these problems, trying to tackle too much at once, and finding no success at it, have caused me to lack the motivation to work on this project as of late. However, due to the kind help of @Th3UnknownCoder, who has worked to make this mod accessible to 1.18 and 1.19 versions, I have found some strength to get back on the horse.

This issue will serve as a log of the things I try in order to build a model baking system on the fly, and additional issues I come across in the future. Hopefully, it won't take too long for this to come to a conclusion.

commented

Forgot to close this out. All the changes I'm able to make are in.