Skip to content

Navigation Menu

Sign in
Sign up

🚧 How does it work?

MarcusSlover edited this page Sep 5, 2021 · 5 revisions

πŸ’½ Early Developing

Before developing this software, I had to think of a solution that would allow me to add custom blocks and items without overriding existing textures.
Figuring that out wasn't hard because there are already servers that use this kind of technology. (servers like OriginRealms or MineClub for example).

Again, by saying "without overriding existing textures" I mean it to a certain level.
It is almost impossible to avoid that whilst adding blocks, however, items are much different.
Items have this thing called CustomModelData that is crucial when it comes to custom texturing.
By attaching a special NBT tag to an item, we can easily control its texture.

🧱 Blocks

Each and every single custom block generated by ResourcePacker is based on one of the states of a note block.
Yes, a variant of a note block. Note blocks in Minecraft not only have 23 different note states but also 16 instruments!
With that amount of variations we are able to use them to add our new blocks.

βš–οΈ Block Limitations

Considering the information written above, if we multiply all possible note states by the amount of unique instruments, we get our limit.
Here's the actual math:

23 (all notes) x 16 (all instruments) = 368 (possible combinations)

Therefore, we know the program is capable of creating 368 unique blocks without overriding any blocks other than a note block.
Imagine if we had to override existing blocks like: stone, dirt,, grass_block... and so on.
That would be a disaster. Not only we demand more blocks but also we lose more original textures.
This is why our solution is much better.

πŸ“‹ Block Model

This is what ResourcePacker does to configure the Note Block model.

{
 "variants": {
 "instrument=harp,note=0": {
 "model": "packer:block/dark_tile"
 },
 "instrument=harp,note=1": {
 "model": "packer:block/tile"
 },
 "instrument=harp,note=2": {
 "model": "packer:block/header_tile"
 }
 }
}

We can clearly see above that each custom block model belongs to a unique variant.

When the note finally reaches the Minecraft limit (23), we switch the instrument and start counting notes from 0 again.
That's how we achieve the uniqueness of variants that let us add custom blocks most efficiently!

πŸͺ“ Items

As mentioned in the first paragraph, items use CustomModelData that makes it possibly to control the textures very easily.
Our software uses minecraft:paper item as its worker to put all the textures on top of it.
All custom generated items (which are regular items) are always type of paper and contain a unique NBT data.
However, there are also block items which work the same but use minecraft:note_block instead.

βš–οΈ Item Limitations

The limit here isn't really noticeable, as long as you keep the amount of items at a reasonable range.
What I mean by that is I don't believe someone's going to need a resource pack with 50 million items included in.

But finally, the answer: about 16 million units.
Minecraft internally converts the custom model data integer to float, causing a precision loss for some numbers above 16 million.
Therefore, you can create up to 16 million items without a problem :)

πŸ“‹ Regular Item Model

This is what ResourcePacker does to configure the Paper model for regular items.

{
 "parent": "item/generated",
 "textures": {
 "layer0": "item/paper"
 },
 "overrides": [
 {
 "predicate": {
 "custom_model_data": 1
 },
 "model": "packer:item/eye_fish"
 },
 {
 "predicate": {
 "custom_model_data": 2
 },
 "model": "packer:item/use_lights"
 },
 {
 "predicate": {
 "custom_model_data": 3
 },
 "model": "packer:item/free_parking"
 }
 ]
}

The data starts from 1 and each item has a unique custom model data.

πŸ“‹ Block Item Model

This is what ResourcePacker does to configure the Note Block model for block items.

{
 "parent": "minecraft:block/note_block",
 "overrides": [
 {
 "predicate": {
 "custom_model_data": 1
 },
 "model": "packer:item/dark_tile"
 },
 {
 "predicate": {
 "custom_model_data": 2
 },
 "model": "packer:item/tile"
 },
 {
 "predicate": {
 "custom_model_data": 3
 },
 "model": "packer:item/header_tile"
 }
 ]
}

The data starts from 1 and each item has a unique custom model data.

Clone this wiki locally

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /