🎨 item_models#
Generates the item models of the resource pack.
- add_to_atlas(textures: set[str] = {}) None[source]#
Add textures to the specified atlas.
- Parameters:
textures – The set of texture paths to add. Defaults to an empty set.
- beet_default(ctx: Context)[source]#
Main entry point for the item models plugin.
- Parameters:
ctx – The beet context.
object#
- class BlockShape(parent: str, sides: tuple[str, ...])[source]#
Bases:
objectA vanilla block model a custom block takes when it has a texture for each of its sides.
- BLOCK_SHAPES: tuple[BlockShape, ...] = (BlockShape(parent='block/cake', sides=('bottom', 'side', 'top', 'inner')), BlockShape(parent='block/orientable_with_bottom', sides=('front', 'bottom', 'side', 'top')), BlockShape(parent='block/cube_bottom_top', sides=('bottom', 'side', 'top')), BlockShape(parent='block/orientable', sides=('front', 'side', 'top')), BlockShape(parent='block/cube_column', sides=('end', 'side')))[source]#
Tried in order, the first whose sides all have a texture winning.
- to_atlas(texture: str) str[source]#
Convert a texture path to its atlas sprite path.
- Parameters:
texture – The original texture path.
- Returns:
The converted atlas sprite path.
- Return type:
str
- class AutoModel(
- data: Item,
- source_textures: dict[str, str],
- ignore_textures: bool = False,
Bases:
objectClass to handle item model processing.
- classmethod from_definitions(
- data: Item,
- source_textures: dict[str, str],
- ignore_textures: bool = False,
Create an AutoModel from a definitions entry.
- Parameters:
data – The item data from the definitions.
source_textures – Dictionary of source textures.
ignore_textures – Whether to ignore textures in the model.
- Returns:
The created AutoModel instance.
- Return type:
- get_powered_texture(
- variants: list[str],
- side: str,
- on_off: str,
Get the powered texture for a given side.
- Parameters:
variants – List of texture variants.
side – The side to get the texture for.
on_off – The power state suffix.
- Returns:
The texture path.
- Return type:
str
- model_in_variants(
- models: Iterable[str],
- variants: list[str],
Check if all models are in a string of any variant.
- Parameters:
models – List of models to check.
variants – List of variants to check against.
- Returns:
True if all models are in variants.
- Return type:
bool
- get_same_folder_variants(
- variants: Iterable[str],
Get variants that are in the same folder as the item.
- Parameters:
variants – Iterable of variant names.
- Returns:
List of variants in the same folder.
- Return type:
list[str]
- handle_growing_seeds() None[source]#
Handle growing seeds by adding growth stage models and textures.
- copy_and_register_textures(
- content: JsonDict,
Copy a model’s textures to the assets and register them for atlas handling.
- Parameters:
content – The model content whose textures should be processed (may be modified in place).
- copy_texture(texture: str) None[source]#
Copy one texture of the project into the assets, found in the source textures by its file name.
- Raises:
ValueError – When it is not there and
ignore_texturesis off.
- handle_hand_model(
- variants: list[str],
- on_off: str,
Generate the in-hand model from the item’s hand_model and return the items/ definition switching between the regular and in-hand models based on the display context.
- Parameters:
variants – List of texture variants of the item.
on_off – The power state suffix.
- Returns:
The content of the items/ definition file.
- Return type:
JsonDict
- process() set[str][source]#
Write the item’s models, and its items/ definition, for each of its power states.
- Returns:
Block textures to be added to the items atlas.
- own_variants() list[str][source]#
The source textures named after the item, at most 2 underscores longer than its id.
The bound keeps
awakened_stardust.pngfrom claimingawakened_stardust_furnace_generator_on.png.
- power_states() list[str][source]#
The suffixes to write a model for,
_onfirst when the item has a texture ending in_on.The plain items definition written after it then finds the
_onmodel a lit host shows.
- write_power_state(
- variants: list[str],
- on_off: str,
- overrides: JsonDict,
Write the model and the items/ definition of one power state,
on_offbeing “” or “_on”.
- margin_scale() float[source]#
The scale the elements of the model grow by when a display shows it in a host, 1.0 for none.
- write_displayed_elements(
- content: JsonDict,
- on_off: str,
Grow the elements of the model, and write the copies of it a block shows turned by
uvlock, flipped byhalf, or as the corner its stairs host makes.
- host_state_select(
- model: JsonDict,
- suffix: str,
model, or a select showing the copy of it drawn for the host state the display’s custom_model_data string names.datapack.custom_blockskeeps that string on the state ofVanillaBlock.host_statesthe host is in.
- block_content(
- variants: list[str],
- on_off: str,
- overrides: JsonDict,
A block’s model: one texture on every face, or the first of
BLOCK_SHAPESits textures fill.- Raises:
ValueError – When its textures fill no shape, the model overrides none, and
ignore_texturesis off.
- block_shape(
- variants: list[str],
- overrides: JsonDict,
The first of
BLOCK_SHAPESthe block’s textures fill, None when they fill none.- Raises:
ValueError – When they fill none, the model overrides no texture, and
ignore_texturesis off.
- item_content(
- variants: list[str],
- on_off: str,
- overrides: JsonDict,
An item’s model: its base item’s parent, with a second layer for leather and overlays, and pulling states for a bow.
- write_bow_pulling(
- variants: list[str],
- parent: str,
- on_off: str,
Write a model per
_pulling_<n>texture, and the items/ definition switching between them as the bow is drawn.
- write_layer_model(
- variant: str,
- parent: str,
- suffix: str,
Copy the texture
variantand write the model showing it, the item’s model withsuffix.
- charged_model(
- variants: list[str],
- parent: str,
- charge: str,
- last_pulling: int,
The model of a crossbow loaded with an arrow or a rocket, from its
_arrowor_fireworktexture, else its drawn one.
- displayed_elements(
- model: JsonDict,
The elements a model draws: its own, its first parent’s in the pack, or those of a cube or cake vanilla parent.
- displayed_variants(
- vanilla: VanillaBlock | None,
- on_off: str,
The turn, half and stairs corner of each copy of the model a display shows, all but the model itself.
The corners of a turn and half come before its plain copy, so the items definition written with that copy finds them.
- displayed_copy(
- elements: JsonList,
- y: int,
- upper: bool,
- corner: str,
- scale: float,
The elements cut into a stairs
cornerunless empty, turnedydegrees, flipped on the upper half, grown byscale.