How it Works - Randores/Randores2 GitHub Wiki

This page is for those interested in how Randores works internally.

Definitions and Seeds

Randores works primarily with MaterialDefinitions, objects which are separate from the actual blocks or items registered. These definitions define all the properties of a material, including its type, recipes, harvest level, dimension, etc. These definitions are generated with the integer value of a Color. Colors, on the other hand, are randomly generated from the Randores Seed. The Randores Seed is not the world seed, but it is derived from the world seed through a one-to-many function. Therefore, it is impossible to use the Randores Seed to find the world seed. Each definition is uniquely identified by two things, its world-id and its index.

The Textures

Textures are probably the easiest part to explain. They work the same ways as leather armor textures, and use the BlockColors and ItemColors registries to apply the necessary tints.

The Blocks

Don't be too horrified, but every Randores block is a tile entity. This tile entity holds both the index and the world-id of the MaterialDefinition it is associated with. It uses that information to determine it's various properties. Furthermore, ores utilize blockstates to determine their harvest level. Blocks can have metadata from 0-15, and that metadata value defines the ore's harvest level. Since the tile entities do not hold a lot of data, and aren't dynamically rendered, they don't actually cause as much lag as you might expect.

The Items

Items primarily work the NBT data attached to their ItemStack. This data stores both the index and the world-id of the MaterialDefinition it is associated with. It uses that information to determine it's various properties. Furthermore, some items delegate all of their function to dummy items, or backers, that are never registered. These items are associated with a specific index and world-id.