Skip to content

Commit 0a65230

Browse files
edayottryashtar
andcommitted
feat: adding decorated pots
Co-authored-by: tryashtar <tryashtar@gmail.com>
1 parent d327628 commit 0a65230

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

examples/test_item_model/my_pipeline.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ def beet_default(ctx: Context):
119119
"minecraft:item_model": "minecraft:red_bed"
120120
}), path_ctx="test:render/red_bed", render_size=512)
121121

122+
render.add_item_task(Item(id="minecraft:bedrock", components={
123+
"minecraft:item_model": "minecraft:decorated_pot",
124+
# "minecraft:pot_decorations": ["minecraft:blade_pottery_sherd", "minecraft:archer_pottery_sherd", "minecraft:brewer_pottery_sherd", "minecraft:burn_pottery_sherd"]
125+
}), path_ctx="test:render/pot", render_size=512)
126+
127+
122128

123129
render.add_model_task("test:item/conduit", path_ctx="test:render/conduit", render_size=512)
124130
render.add_item_task(Item(id="stone", components={

model_resolver/item_model/special.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,69 @@ class SpecialModelTrident(SpecialModelBase):
10641064
class SpecialModelDecoratedPot(SpecialModelBase):
10651065
type: Literal["minecraft:decorated_pot", "decorated_pot"]
10661066

1067+
1068+
def get_texture(self, pot_decorations: list[str] | None, index: int) -> str:
1069+
if pot_decorations is None or index >= len(pot_decorations):
1070+
return "minecraft:entity/decorated_pot/decorated_pot_side"
1071+
decoration = resolve_key(pot_decorations[index])
1072+
if decoration == "minecraft:brick":
1073+
return "minecraft:entity/decorated_pot/decorated_pot_side"
1074+
namespace, path = decoration.split(":", 1)
1075+
return f"{namespace}:entity/decorated_pot/{path.removesuffix("_sherd")}_pattern"
1076+
1077+
1078+
def get_model(self, getter: PackGetterV2, item: Item) -> dict[str, Any]:
1079+
pot_decorations = item.components.get("minecraft:pot_decorations", None)
1080+
1081+
model: dict[str, Any] = {
1082+
"textures": {
1083+
"base": "minecraft:entity/decorated_pot/decorated_pot_base",
1084+
"north": self.get_texture(pot_decorations, 0),
1085+
"east": self.get_texture(pot_decorations, 2),
1086+
"south": self.get_texture(pot_decorations, 3),
1087+
"west": self.get_texture(pot_decorations, 1),
1088+
},
1089+
"elements": [
1090+
{
1091+
"from": [4.1, 17.1, 4.1],
1092+
"to": [11.9, 19.9, 11.9],
1093+
"faces": {
1094+
"north": {"uv": [12, 4, 16, 5.5], "texture": "#base"},
1095+
"east": {"uv": [8, 4, 12, 5.5], "texture": "#base"},
1096+
"south": {"uv": [4, 4, 8, 5.5], "texture": "#base"},
1097+
"west": {"uv": [0, 4, 3.5, 5.5], "texture": "#base"},
1098+
"up": {"uv": [4, 0, 8, 4], "texture": "#base"},
1099+
"down": {"uv": [8, 4, 12, 0], "texture": "#base"}
1100+
}
1101+
},
1102+
{
1103+
"from": [4.8, 15.8, 4.8],
1104+
"to": [11.2, 17.2, 11.2],
1105+
"faces": {
1106+
"north": {"uv": [9, 5.5, 12, 6], "texture": "#base"},
1107+
"east": {"uv": [6, 5.5, 9, 6], "texture": "#base"},
1108+
"south": {"uv": [3, 5.5, 6, 6], "texture": "#base"},
1109+
"west": {"uv": [0, 5.5, 3, 6], "texture": "#base"},
1110+
"up": {"uv": [3, 2.5, 6, 5.5], "texture": "#base"},
1111+
"down": {"uv": [6, 5.5, 9, 2.5], "texture": "#base"}
1112+
}
1113+
},
1114+
{
1115+
"from": [1, 0, 1],
1116+
"to": [15, 16, 15],
1117+
"faces": {
1118+
"north": {"uv": [1, 0, 15, 16], "texture": "#north"},
1119+
"east": {"uv": [1, 0, 15, 16], "texture": "#east"},
1120+
"south": {"uv": [1, 0, 15, 16], "texture": "#south"},
1121+
"west": {"uv": [1, 0, 15, 16], "texture": "#west"},
1122+
"up": {"uv": [7, 13.5, 14, 6.5], "texture": "#base"},
1123+
"down": {"uv": [0, 6.5, 7, 13.5], "texture": "#base"}
1124+
}
1125+
}
1126+
]
1127+
}
1128+
return model
1129+
10671130

10681131
wood_types = Literal[
10691132
"oak",

0 commit comments

Comments
 (0)