Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions docs/resource-pack-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,50 @@ model_data:
- reference: item/lump/thorianite
```

- `base_model` (optional), a json (or yaml) object that will be merged into the base model's custom model data definition. This used when specific control over the minecraft base item model is required (e.g. adding a tints field for leather armor). The `base_model` json object will be merged into the `model` json object, overwriting existing fields.
E.g. to acheive the following custom model data:
```json
{
"threshold": 3420002,
"model": {
"type": "minecraft:model",
"model": "gm4_scuba_gear:item/flippers",
"tints": [
{
"type": "minecraft:dye",
"default": -14455863
}
]
}
}
```
The following `base_model` config can be used:
```yaml
model_data:
- item: leather_boots
reference: item/flippers
template: generated_overlay
base_model:
tints:
- type: minecraft:dye
default: -14455863
```
Or alternatively with JSON:
```yaml
model_data:
- item: leather_boots
reference: item/flippers
template: generated_overlay
base_model: {
"tints": [
{
"type": "minecraft:dye",
"default": -14455863
}
]
}
```

### `gui_fonts` Config
Custom textured GUIs using fonts can easily be setup using the `meta.gm4.gui_fonts` entry of `beet.yaml` or the `gui_fonts` entry of `model_data.yaml`. These will create a translation that displays a given image texture inside a container, like a dropper or hopper. Empty images of the correct size are available in the `base` to use as a starting point for custom GUIs.

Expand Down
5 changes: 5 additions & 0 deletions gm4/plugins/resource_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class ModelData(BaseModel):
template: 'str|TemplateOptions' = "custom"
transforms: Optional[list['TransformOptions']]
textures: MapOption[str] = [] # defaults to same value as reference #type:ignore ; the validator handles the default value
base_model: Optional[JsonType]

@validator('model', pre=True, always=True) # type: ignore ; v1 validator behaves strangely with type checking
def default_model(cls, model: Any, values: JsonType) -> dict[str, str]:
Expand Down Expand Up @@ -155,6 +156,7 @@ class NestedModelData(BaseModel):
template: Optional['str|TemplateOptions'] = "custom"
transforms: Optional[list['TransformOptions']]
textures: Optional[MapOption[str]]
base_model: Optional[JsonType]
broadcast: Optional[list['NestedModelData']] = []

def collapse_broadcast(self) -> list['NestedModelData']:
Expand Down Expand Up @@ -504,6 +506,9 @@ def generate_item_definitions(self):
}
else:
model_json = m

if model.base_model:
model_json.update(model.base_model)

itemdef_entries.append({
"threshold": self.cmd_prefix+self.retrieve_index(model.reference)[0],
Expand Down
Loading