novablocks · 2022Texture Packs

3 min read

Texture Packs Version 1

PR Date: June 20, 2022

The initial task that I got when I got onboarded to the project is to work on the texture packs. The game has a default texture pack that is used in the game. The goal is to let the user change the texture pack of the world via the admin panel.

For the first iteration, I've designed the database structure that will map to the required textures for a specified block.

A diagram showing the relationship between the models. Config and Block Texture File are pointing to the Texture Packs. Then the Blocks and Block Texture Files are pointing to the Block Textures.
A diagram showing the relationship between the models.
  • Config: the settings which is a key-value pair. Currently, it only contains "Default Texture Pack"
  • Texture Packs: the texture pack which contains its name (e.g. Pastelcraft or FPS Pack) and the zip file.
  • Block Textures: the name of the textures available (e.g. cobblestone, grass_top). The default texture pack determines what texture file to fetch for this.
  • Block Texture Files: this is the image file of a certain block texture and texture pack. (e.g. image file of FPS texture pack and cobblestone block)
  • Block: the box geometry definition of a block, it contains the texture file path for each faces, its name, and options.

Then I've updated the engine to enable using a custom texture pack based on the settings in the Admin panel. A zip file of the texture pack can be uploaded in the admin panel to which it will contain block texture images in which the name of the images is based on the Minecraft name convention. For migrating the zip file, I've run it using background jobs, write the blob to a Tempfile, then read the contents using rubyzip. Since reading the zip file takes up a lot of RAM depending on the file size, we had to also increase the RAM of the server.

Admin panel - Edit config page which shows an input for the key which is 'Default Texture Pack' and a dropdown for the value which are the texture packs (e.g. Pastelcraft, FPS, Default).
In the admin panel, there is a setting for the default texture pack.
A game showing the default texture pack.
The game using the default texture pack.
A game showing the pastelcraft texture pack.
The game using the pastelcraft texture pack.

Texture Pack Version 2

Coming Soon.