80 lines
3.5 KiB
Markdown
80 lines
3.5 KiB
Markdown
# Textures
|
||
|
||
Every `.png` in a mod's `textures/` folder becomes a texture that blocks, items, entities and screens can use.
|
||
|
||
## Texture Ids
|
||
|
||
A texture's id is `<mod id>:<file name without .png>`. Subfolders are joined with `_`, so in the mod `copper_tools`:
|
||
|
||
| File | Texture id |
|
||
| --------------------------- | --------------------------- |
|
||
| `textures/copper_block.png` | `copper_tools:copper_block` |
|
||
| `textures/ores/tin.png` | `copper_tools:ores_tin` |
|
||
|
||
Any mod can use any texture by its id, including the base game's, like `bworld:stone`.
|
||
|
||
## Sizes
|
||
|
||
Textures can be any size up to 256×256 (for [animated ones](#animated-textures), each frame). Blocks and items are made
|
||
for 16×16 and stretch a texture of another size over the same face, so a 32×32 block texture is just a sharper one.
|
||
Larger ones are for things like entity skins.
|
||
|
||
## Animated Textures
|
||
|
||
A texture animates when a `.json` with the same name sits next to its `.png`, like Minecraft's `.png.mcmeta` and in the
|
||
same format. The png holds every frame, square ones stacked top to bottom by default:
|
||
|
||
```
|
||
textures/lava_lamp.png 16×64, four 16×16 frames
|
||
textures/lava_lamp.json
|
||
```
|
||
|
||
```json
|
||
{
|
||
"animation": {
|
||
"frametime": 2,
|
||
"interpolate": false,
|
||
"frames": [0, 1, 2, { "index": 3, "time": 10 }, 2, 1],
|
||
"width": 16,
|
||
"height": 16
|
||
}
|
||
}
|
||
```
|
||
|
||
Every field is optional, so `{ "animation": {} }` plays every frame in order, one tick each.
|
||
|
||
| Field | What it does |
|
||
| ------------- | ----------------------------------------------------------------------------------------------- |
|
||
| `frametime` | Ticks each frame shows, 1 if not given. There are 20 ticks a second. |
|
||
| `interpolate` | Blends each frame into the next a tick at a time instead of switching. |
|
||
| `frames` | The order to show frames in, by index or `{ "index", "time" }`. Every frame in order otherwise. |
|
||
| `width` | A frame's width in pixels. |
|
||
| `height` | A frame's height in pixels. |
|
||
|
||
Without `width` and `height`, frames are square and as big as the png's shorter side. Frames are counted like reading
|
||
text, left to right then top to bottom, so a png can hold them in a grid as well as a strip.
|
||
|
||
Blocks, items and entities use an animated texture's id like any other and get the current frame. The size limit applies
|
||
to a frame, and the whole png can be at most 4096×4096.
|
||
|
||
Every block using a texture shows the same frame at the same time. Each tick, the client copies the new frame of every
|
||
animated texture whose frame changed into the atlas, and interpolated ones every tick. Long `frametime`s are cheaper
|
||
than short ones.
|
||
|
||
## Missing Textures
|
||
|
||
A texture id that doesn't exist shows the magenta and black checker, `engine:missing`, and `check-mods` warns about it.
|
||
It isn't an error, so a mod still loads while its art is unfinished.
|
||
|
||
## Engine Textures
|
||
|
||
The engine's own textures use the `engine` namespace and come from `assets/`, not from a mod:
|
||
|
||
- `engine:missing`, the missing texture,
|
||
- `engine:break_0` to `engine:break_8`, the cracks drawn on a block being broken.
|
||
|
||
## How Players Get Them
|
||
|
||
Textures go in the mod's `.bmod`. When a player joins, their client puts every mod's textures into one atlas. The server
|
||
never decodes images.
|