Skip to content

Commit 3f29b02

Browse files
fix: custom files in minecraft caused errors
1 parent 0350dba commit 3f29b02

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

smithed/weld/merging/handler.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ def __call__(
119119

120120
# Handle vanilla paths as the base / current file
121121
if path.startswith("minecraft:"):
122-
if path not in self.vanilla:
123-
current.data = self.grab_vanilla(path, json_file_type)
122+
if path not in self.vanilla and (data := self.grab_vanilla(path, json_file_type)):
123+
current.data = data
124124
self.vanilla.add(path)
125125

126126
# Handle non-vanilla paths, swap conflict w/ current if no smithed rules exist
@@ -180,11 +180,16 @@ def parse_smithed_file(
180180

181181
return obj
182182

183-
def grab_vanilla(self, path: str, json_file_type: type[NamespaceFile]) -> JsonDict:
183+
def grab_vanilla(self, path: str, json_file_type: type[NamespaceFile]) -> JsonDict|None:
184184
"""Grabs the vanilla file to load as the current file (aka the base)."""
185185

186186
vanilla = self.ctx.inject(Vanilla)
187-
return cast(JsonFile, vanilla.data[json_file_type][path]).data
187+
file = vanilla.data[json_file_type].get(path)
188+
189+
if file is None:
190+
return None
191+
192+
return cast(JsonFile, file).data
188193

189194
def process(self):
190195
"""Main entrypoint for smithed merge solving"""

0 commit comments

Comments
 (0)