Skip to content

Commit f6d4824

Browse files
authored
Add resource pack base model config (#1215)
* add base model config to resource pack plugin * document base_model config * update base_model config example
1 parent cb0fe45 commit f6d4824

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

docs/resource-pack-management.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,50 @@ model_data:
196196
- reference: item/lump/thorianite
197197
```
198198

199+
- `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.
200+
E.g. to acheive the following custom model data:
201+
```json
202+
{
203+
"threshold": 3420002,
204+
"model": {
205+
"type": "minecraft:model",
206+
"model": "gm4_scuba_gear:item/flippers",
207+
"tints": [
208+
{
209+
"type": "minecraft:dye",
210+
"default": -14455863
211+
}
212+
]
213+
}
214+
}
215+
```
216+
The following `base_model` config can be used:
217+
```yaml
218+
model_data:
219+
- item: leather_boots
220+
reference: item/flippers
221+
template: generated_overlay
222+
base_model:
223+
tints:
224+
- type: minecraft:dye
225+
default: -14455863
226+
```
227+
Or alternatively with JSON:
228+
```yaml
229+
model_data:
230+
- item: leather_boots
231+
reference: item/flippers
232+
template: generated_overlay
233+
base_model: {
234+
"tints": [
235+
{
236+
"type": "minecraft:dye",
237+
"default": -14455863
238+
}
239+
]
240+
}
241+
```
242+
199243
### `gui_fonts` Config
200244
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.
201245

gm4/plugins/resource_pack.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class ModelData(BaseModel):
8181
template: 'str|TemplateOptions' = "custom"
8282
transforms: Optional[list['TransformOptions']]
8383
textures: MapOption[str] = [] # defaults to same value as reference #type:ignore ; the validator handles the default value
84+
base_model: Optional[JsonType]
8485

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

160162
def collapse_broadcast(self) -> list['NestedModelData']:
@@ -504,6 +506,9 @@ def generate_item_definitions(self):
504506
}
505507
else:
506508
model_json = m
509+
510+
if model.base_model:
511+
model_json.update(model.base_model)
507512

508513
itemdef_entries.append({
509514
"threshold": self.cmd_prefix+self.retrieve_index(model.reference)[0],

0 commit comments

Comments
 (0)