Skip to content

Migrating from 1.1.2 to 1.1.3

1.1.3 reworks how textures are given to blocks, items, entities and particles, and moves every vanilla import to one module. Most projects only need the changes on this page; each one fails loudly at import or export time if it is missed.


Vanilla imports

Import vanilla content from anvil.api.vanilla (and experimental content from anvil.beta.vanilla). The type factories are no longer re-exported from the submodules.

# 1.1.2
from anvil.api.vanilla.blocks import MinecraftBlockTypes
from anvil.api.vanilla.items import MinecraftItemTypes
from anvil.api.vanilla.entities import MinecraftEntityTypes

# 1.1.3
from anvil.api.vanilla import MinecraftBlockTypes, MinecraftEntityTypes, MinecraftItemTypes

Block material instances

BlockMaterialInstance().add_instance(spec=InstanceSpec(...)) is replaced by BlockMaterialInstance().face(face, texture, ...). InstanceSpec, InstanceVariant, MaterialParams and FlipbookParams are removed.

1.1.2 1.1.3
InstanceSpec(blockbench=..., variations=[InstanceVariant(color=..., mer=...)]) BlockTexture(blockbench=..., color=..., mer=...)
InstanceSpec(face=...) the first argument of face()
MaterialParams(render_method=..., ...) keyword arguments of face()
FlipbookParams(frames=..., ticks_per_frame=...) .animated(frames, ticks=...)
several InstanceVariant(..., weight=...) BlockTexture.weighted((texture, weight), ...)
force_vanilla=True a MinecraftTerrainTextures member
from anvil.api.blocks.components import BlockMaterial, BlockMaterialInstance
from anvil.api.textures import BlockTexture
from anvil.api.vanilla import MinecraftTerrainTextures
from anvil.lib.jsonmodel.enums import BlockFaceValues

# 1.1.2
BlockMaterialInstance().add_instance(
    spec=InstanceSpec(
        blockbench="lamp",
        variations=[InstanceVariant(color="lamp", mer="lamp_mer")],
        params=MaterialParams(render_method=BlockMaterial.AlphaTest),
        flipbooks=[FlipbookParams(frames=[0, 1], ticks_per_frame=20)],
    )
)

# 1.1.3
BlockMaterialInstance().face(
    BlockFaceValues.All,
    BlockTexture(blockbench="lamp", color="lamp", mer="lamp_mer").animated([0, 1], ticks=20),
    render_method=BlockMaterial.AlphaTest,
)

# A vanilla texture, only referenced by its short name
BlockMaterialInstance().face(BlockFaceValues.Up, MinecraftTerrainTextures.Stone)

Call face() once per face on the same BlockMaterialInstance() to give faces different textures.

Terrain atlas names changed

A block face texture is now registered in terrain_texture.json as <namespace>:<block>_<face> (for example <namespace>:lamp_all) instead of <namespace>:<color>. A block that shows a second texture on the same face in another permutation gets _2, _3, ... Update anything that names the atlas entry by hand, such as BlockDestructionParticles(texture=...).

BlockTexture.weighted weights are now numbers from 0.05 to 1000000, and every texture in it must carry the same PBR maps. A flipbook in a weighted set is given per texture with .animated(...).


Item icons

ItemIcon takes the texture and its maps as keyword arguments; TextureComponents is no longer passed.

from anvil.api.items.components import ItemIcon
from anvil.api.vanilla import MinecraftItemTextures

# 1.1.2
ItemIcon(textures=TextureComponents(color="gem", mer="gem_mer"))
ItemIcon(textures=TextureComponents(color="blade"), blockbench="sword")

# 1.1.3
ItemIcon(color="gem", mer="gem_mer")
ItemIcon(blockbench="sword", color="blade")
ItemIcon(color=MinecraftItemTextures.Apple)  # a vanilla icon, only referenced

The atlas name is unchanged: <namespace>:<color>.


Entities, attachables and particles

Every call that took a TextureComponents now takes keyword-only color and normal, height, mer, mers instead.

1.1.2 1.1.3
description.add_texture("lamp", TextureComponents(color="body", mer="body_mer")) description.add_texture(blockbench="lamp", color="body", mer="body_mer")
description.particle_effect("sparks", TextureComponents(color="sparks")) description.particle_effect("sparks", color="sparks")
description.set_spawn_egg(TextureComponents(color="egg"), 2) description.set_spawn_egg(color="egg", texture_index=2)
Particle("sparks", TextureComponents(color="sparks")) Particle("sparks", color="sparks")
block.override_vanilla_texture("stone_bb", TextureComponents(color="stone"), "sub") block.override_vanilla_texture(blockbench="stone_bb", color="stone", subfolder="sub")

Render controllers still reference an entity texture by its color name.


Other changes

  • A block with the multi_block trait must have a BlockMovable in its root components; export stops with an error otherwise.
  • Packaging reads at most 9 screenshots, 0.png to 8.png, from the marketing folder.