Skip to content
Open
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
6 changes: 5 additions & 1 deletion src/smithed/weld/merging/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class since several methods based on each file are passing similar parameters wi
from importlib import resources
from typing import Iterator, Literal, cast, overload

from beet import Context, JsonFile, NamespaceFile
from beet import Context, JsonFile, Language, NamespaceFile
from beet.contrib.format_json import get_formatter
from beet.contrib.vanilla import Vanilla
from pydantic import ValidationError
Expand Down Expand Up @@ -76,6 +76,10 @@ def __call__(self, pack: Pack, path: str, current: JsonFile, conflict: JsonFile,
physical_file = json_file_type, path

logger.debug(f"Registering conflict: {path!r}")
if json_file_type is Language:
current.data.update(conflict.data)
return True

if physical_file in self.overrides[pack]:
logger.debug("Skipping due to override")
return True
Expand Down
15 changes: 14 additions & 1 deletion tests/test_overlay_merging.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from copy import deepcopy

from beet import DataPack, Function, LootTable, Predicate
from beet import DataPack, Function, Language, LootTable, Predicate, ResourcePack
import pytest

from smithed.weld import run_weld
Expand Down Expand Up @@ -172,3 +172,16 @@ def test_override_skips_queued_rules_only_for_its_physical_file(
predicate = _file_at_format(ctx.data, Predicate, path, pack_format)
assert [pool["name"] for pool in loot.data["pools"]] == ["override"]
assert [pool["name"] for pool in predicate.data["pools"]] == expected


def test_language_files_merge_by_key_in_pack_order(monkeypatch):
first, second = ResourcePack(), ResourcePack()
first[Language]["minecraft:en_us"] = Language({"a": "first", "b": "first"})
second[Language]["minecraft:en_us"] = Language({"b": "second", "c": "second"})

with _weld_sources(monkeypatch, {"first": first, "second": second}) as ctx:
assert ctx.assets[Language]["minecraft:en_us"].data == {
"a": "first",
"b": "second",
"c": "second",
}
Loading