Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b323646
Add 1.21.4 to test workflow matrix
misode Nov 28, 2024
6e4c04c
Update versions and pack formats
misode Nov 28, 2024
9d2bb16
Remove unnecessary short_grass backwards compatibility
misode Nov 28, 2024
068a256
Remove reliance on tall_flowers block tag
misode Nov 28, 2024
06ea9f7
Use 1.21.3 for auto crafting script
misode Nov 28, 2024
b429d5e
Use 1.21.3 for standard crafting script
misode Nov 28, 2024
04c2a1b
Exclude pale_oak in double doors
misode Nov 28, 2024
88aad0d
Upgrade custom model data mecha rules to 1.21.4
misode Nov 28, 2024
1420bd2
Fix custom model data values that are not using string references
misode Nov 28, 2024
533a715
Exclude 3 item tags that were removed in 1.21.4
misode Nov 28, 2024
483cf28
Also exclude item tags from check_item_tags mcfunction
misode Nov 28, 2024
3722207
Rename furnace NBT fields
misode Nov 28, 2024
f0d0a17
Backport furnace fields
misode Dec 4, 2024
43fe6ec
Update backwards plugin to account for overlay files
misode Dec 4, 2024
0ccaf0a
Rename all instances of overlay_48 to backport_48
misode Dec 4, 2024
7580741
Backport custom model data syntax
misode Dec 4, 2024
976d483
Remove debug message
misode Dec 4, 2024
601b3e0
Update biome extensions lib
misode Dec 5, 2024
685af5d
Add overlay info to biome extensions
misode Dec 5, 2024
157981a
Move pale garden json files to "since_61" overlay
misode Dec 5, 2024
5e87d9f
Allow dangerous dungeons to spawn in the pale garden
misode Dec 5, 2024
6e2ce11
Update base tags with new blocks and entities
misode Dec 5, 2024
00adcec
Modernize podzol rooting soil
misode Dec 5, 2024
651885e
Fix plantable block tag in 1.21.1
misode Dec 5, 2024
cc875af
Enable pale oak and resin in standard crafting
misode Dec 5, 2024
5e3e34e
Fix some bugs introduced in the 1.20.5/1.21 update
misode Dec 5, 2024
00f8109
Add pale oak boat support to vecto shamir
misode Dec 5, 2024
61aaa48
Modernize soul glass by using components in the blasting recipe
misode Dec 5, 2024
95d5ff2
Simplify some holding_item predicates
misode Dec 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ jobs:
fabric_server_url: https://meta.fabricmc.net/v2/versions/loader/1.21.3/0.16.7/1.0.1/server/jar
fabric_api_url: https://cdn.modrinth.com/data/P7dR8mSH/versions/dhD4I4lJ/fabric-api-0.106.1%2B1.21.3.jar
packtest_url: https://cdn.modrinth.com/data/XsKUhp45/versions/wjOUK14F/packtest-1.9-mc1.21.2.jar
- version: '1.21.4'
fabric_server_url: https://meta.fabricmc.net/v2/versions/loader/1.21.4-rc1/0.16.9/1.0.1/server/jar
fabric_api_url: https://cdn.modrinth.com/data/P7dR8mSH/versions/X7o8njVT/fabric-api-0.110.2%2B1.21.4.jar
packtest_url: https://cdn.modrinth.com/data/XsKUhp45/versions/owHaqexZ/packtest-1.10-beta1-mc1.21.4.jar
name: 'test-${{ matrix.version }}'
runs-on: ubuntu-24.04
steps:
Expand Down
6 changes: 5 additions & 1 deletion base/data/gm4/advancement/intro_song/welcome_toast.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
"icon": {
"id": "minecraft:command_block",
"components": {
"minecraft:custom_model_data": 3420001
"minecraft:custom_model_data": {
"floats": [
3420001
]
}
}
},
"title": {
Expand Down
11 changes: 8 additions & 3 deletions base/data/gm4/tags/block/foliage.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"values": [
"#minecraft:small_flowers",
"#minecraft:tall_flowers",
"minecraft:sunflower",
"minecraft:lilac",
"minecraft:peony",
"minecraft:rose_bush",
"minecraft:pitcher_plant",
"minecraft:azalea",
"minecraft:flowering_azalea",
"minecraft:big_dripleaf",
Expand All @@ -14,13 +18,14 @@
"minecraft:dead_bush",
"minecraft:fern",
"minecraft:glow_lichen",
{ "id": "minecraft:grass", "required": false },
{ "id": "minecraft:short_grass", "required": false },
"minecraft:short_grass",
"minecraft:hanging_roots",
"minecraft:large_fern",
"minecraft:mangrove_propagule",
"minecraft:moss_carpet",
"minecraft:nether_sprouts",
{ "id": "minecraft:pale_hanging_moss", "required": false },
{ "id": "minecraft:pale_moss_carpet", "required": false },
"minecraft:pink_petals",
"minecraft:red_mushroom",
"minecraft:small_dripleaf",
Expand Down
4 changes: 4 additions & 0 deletions base/data/gm4/tags/block/full_collision.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"minecraft:chiseled_polished_blackstone",
"minecraft:chiseled_quartz_block",
"minecraft:chiseled_red_sandstone",
{ "id": "minecraft:chiseled_resin_bricks", "required": false },
"minecraft:chiseled_sandstone",
"minecraft:chiseled_stone_bricks",
"minecraft:chiseled_tuff",
Expand All @@ -74,6 +75,7 @@
"minecraft:cracked_stone_bricks",
"minecraft:crafter",
"minecraft:crafting_table",
{ "id": "minecraft:creaking_heart", "required": false },
"minecraft:crimson_nylium",
"minecraft:crying_obsidian",
"minecraft:cut_copper",
Expand Down Expand Up @@ -255,6 +257,8 @@
"minecraft:redstone_ore",
"minecraft:reinforced_deepslate",
"minecraft:repeating_command_block",
{ "id": "minecraft:resin_block", "required": false },
{ "id": "minecraft:resin_bricks", "required": false },
"minecraft:respawn_anchor",
"minecraft:sand",
"minecraft:sandstone",
Expand Down
11 changes: 8 additions & 3 deletions base/data/gm4/tags/block/no_collision.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
"#minecraft:rails",
"#minecraft:signs",
"#minecraft:small_flowers",
"#minecraft:tall_flowers",
"minecraft:sunflower",
"minecraft:lilac",
"minecraft:peony",
"minecraft:rose_bush",
"minecraft:pitcher_plant",
"#minecraft:wall_corals",
"minecraft:acacia_sapling",
"minecraft:attached_melon_stem",
Expand Down Expand Up @@ -48,8 +52,7 @@
"minecraft:fern",
"minecraft:frogspawn",
"minecraft:glow_lichen",
{ "id": "minecraft:grass", "required": false },
{ "id": "minecraft:short_grass", "required": false },
"minecraft:short_grass",
"minecraft:hanging_roots",
"minecraft:jungle_sapling",
"minecraft:ladder",
Expand All @@ -61,6 +64,8 @@
"minecraft:nether_sprouts",
"minecraft:nether_wart",
"minecraft:oak_sapling",
{ "id": "minecraft:pale_hanging_moss", "required": false },
{ "id": "minecraft:pale_oak_sapling", "required": false },
"minecraft:pink_petals",
"minecraft:powder_snow",
"minecraft:red_mushroom",
Expand Down
4 changes: 2 additions & 2 deletions base/data/gm4/tags/block/replaceable.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
"minecraft:dead_bush",
"minecraft:fern",
"minecraft:glow_lichen",
{ "id": "minecraft:grass", "required": false },
{ "id": "minecraft:short_grass", "required": false },
"minecraft:short_grass",
"minecraft:hanging_roots",
"minecraft:large_fern",
"minecraft:lava",
"minecraft:light",
"minecraft:nether_sprouts",
{ "id": "minecraft:resin_clump", "required": false },
"minecraft:sculk_vein",
"minecraft:seagrass",
"minecraft:snow",
Expand Down
1 change: 1 addition & 0 deletions base/data/gm4/tags/block/waterloggable.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"minecraft:pointed_dripstone",
"minecraft:purple_stained_glass_pane",
"minecraft:red_stained_glass_pane",
{ "id": "minecraft:resin_clump", "required": false },
"minecraft:scaffolding",
"minecraft:sculk_sensor",
"minecraft:sculk_vein",
Expand Down
1 change: 1 addition & 0 deletions base/data/gm4/tags/entity_type/neutral_hostile.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"values": [
"minecraft:cave_spider",
{ "id": "minecraft:creaking", "required": false },
"minecraft:drowned",
"minecraft:enderman",
"minecraft:piglin",
Expand Down
170 changes: 118 additions & 52 deletions gm4/plugins/backwards.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,58 @@
import re
import logging
from typing import Any
from beet import Context, TextFileBase, Recipe
from typing import Any, Tuple, Callable
from beet import Context, Pack, TextFileBase, Recipe, Function, NamespaceFile
from beet.core.utils import SupportedFormats

logger = logging.getLogger("gm4.backwards")

# Generates overlays to support older versions
def beet_default(ctx: Context):
yield

rewrite_attributes(ctx)
rewrite_recipes(ctx)
# backporting to 1.21.3 (57)
backport(ctx.data, 57, rewrite_furnace_nbt)
backport(ctx.data, 57, rewrite_custom_model_data)

# backporting to 1.21.1 (48)
backport(ctx.data, 48, rewrite_attributes)
backport(ctx.data, 48, rewrite_recipe)


FURNACE_RENAMES = {
"cooking_time_spent": "CookTime",
"cooking_total_time": "CookTimeTotal",
"lit_time_remaining": "BurnTime",
"lit_total_time": None,
}

def rewrite_furnace_nbt(id: str, resource: NamespaceFile):
if not isinstance(resource, Function):
return None
text = resource.text
for src_field, overlay_field in FURNACE_RENAMES.items():
if overlay_field is None:
if re.match("\\b" + src_field + "\\b", text):
logger.error(f"Cannot backport furnace field {src_field} in function {id}")
else:
text = re.sub("\\b" + src_field + "\\b", overlay_field, text)
if text == resource.text:
return None
overlay = resource.copy()
overlay.text = text
return overlay


def rewrite_custom_model_data(id: str, resource: NamespaceFile):
if not isinstance(resource, TextFileBase):
return None
text = resource.text
text = re.sub(r"\{\s*[\"']?floats[\"']?\s*:\s*\[\s*(\d+)[Ff]?\s*\]\s*\}", r"\1", text)
if text == resource.text:
return None
overlay = resource.copy()
overlay.text = text
return overlay


ATTRIBUTES_RENAMES = {
Expand Down Expand Up @@ -49,63 +91,87 @@ def beet_default(ctx: Context):
}

# Removes the generic. and other prefixes from attribute IDs
def rewrite_attributes(ctx: Context):
for id, resource in ctx.data.all():
if isinstance(resource, TextFileBase):
resource.source_stop
overlay_text = resource.text
for src_attribute, overlay_attribute in ATTRIBUTES_RENAMES.items():
overlay_text = re.sub("\\b" + src_attribute + "\\b", overlay_attribute, overlay_text)
if overlay_text != resource.text:
overlay_resource = resource.copy()
overlay_resource.text = overlay_text
overlay = ctx.data.overlays["overlay_48"]
overlay.supported_formats = { "min_inclusive": 48, "max_inclusive": 48 }
overlay[id] = overlay_resource
def rewrite_attributes(id: str, resource: NamespaceFile):
if not isinstance(resource, TextFileBase):
return None
text = resource.text
for src_attribute, overlay_attribute in ATTRIBUTES_RENAMES.items():
text = re.sub("\\b" + src_attribute + "\\b", overlay_attribute, text)
if text == resource.text:
return None
overlay = resource.copy()
overlay.text = text
return overlay


# Rewrites the recipe ingredients to the old {"item": "..."} format
def rewrite_recipes(ctx: Context):
def rewrite_recipe(id: str, resource: NamespaceFile):
if not isinstance(resource, Recipe):
return None

def rewrite_ingredient(ingr: str | list[str]) -> Any:
if isinstance(ingr, list):
return [rewrite_ingredient(item) for item in ingr]
if ingr.startswith("#"):
return { "tag": ingr[1:] }
return { "item": ingr }

def rewrite_recipe(id: str, resource: Recipe):
# If an overlay already exists for this recipe, us the contents of that
# TODO: generalize this for all rewrite functions and handle multiple overlays
for overlay in ctx.data.overlays.values():
if id in overlay.recipes:
resource = overlay.recipes[id]
break

overlay_resource = resource.copy()
data = overlay_resource.data

if "crafting_transmute" in data["type"]:
logger.warning(f"Cannot backport crafting_transmute recipe {id}")
return

if "base" in data:
data["base"] = rewrite_ingredient(data["base"])
if "addition" in data:
data["addition"] = rewrite_ingredient(data["addition"])
if "ingredient" in data:
data["ingredient"] = rewrite_ingredient(data["ingredient"])
if "ingredients" in data:
data["ingredients"] = [rewrite_ingredient(ingr) for ingr in data["ingredients"]]
if "key" in data:
data["key"] = {k: rewrite_ingredient(ingr) for k, ingr in data["key"].items()}

overlay = ctx.data.overlays["overlay_48"]
overlay.supported_formats = { "min_inclusive": 48, "max_inclusive": 48 }
overlay[id] = overlay_resource

for id, resource in ctx.data.recipes.items():

overlay = resource.copy()
data = overlay.data

if "crafting_transmute" in data["type"]:
logger.warning(f"Cannot backport crafting_transmute recipe {id}")
return None

if "base" in data:
data["base"] = rewrite_ingredient(data["base"])
if "addition" in data:
data["addition"] = rewrite_ingredient(data["addition"])
if "ingredient" in data:
data["ingredient"] = rewrite_ingredient(data["ingredient"])
if "ingredients" in data:
data["ingredients"] = [rewrite_ingredient(ingr) for ingr in data["ingredients"]]
if "key" in data:
data["key"] = {k: rewrite_ingredient(ingr) for k, ingr in data["key"].items()}

return overlay


def backport(pack: Pack[Any], format: int, run: Callable[[str, NamespaceFile], NamespaceFile | None]):
resources: dict[Tuple[type[NamespaceFile], str], NamespaceFile] = dict()

for file_type in pack.resolve_scope_map().values():
proxy = pack[file_type]
for path in proxy.keys():
resources[(file_type, path)] = proxy[path]

for overlay in pack.overlays.values():
overlay_formats = overlay.supported_formats or overlay.pack_format
if check_formats(overlay_formats, format):
for file_type in overlay.resolve_scope_map().values():
proxy = overlay[file_type]
for path in proxy.keys():
resources[(file_type, path)] = proxy[path]

for (file_type, path), resource in resources.items():
try:
rewrite_recipe(id, resource)
new_resource = run(path, resource)
except BaseException as e:
logger.error(f"Failed to backport recipe {id}: {e}")
e.add_note(f"Failed to backport[{run.__name__}] {file_type.snake_name} {path}")
raise e
if new_resource:
overlay = pack.overlays[f"backport_{format}"]
overlay.supported_formats = { "min_inclusive": 0, "max_inclusive": format }
overlay[path] = new_resource


def check_formats(supported: SupportedFormats, format: int):
match supported:
case int(value):
return value == format
case [min, max]:
return min <= format <= max
case { "min_inclusive": min, "max_inclusive": max }:
return min <= format <= max
case _:
raise ValueError(f"Unknown supported)formats structure {supported}")
2 changes: 1 addition & 1 deletion gm4/plugins/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

parent_logger = logging.getLogger("gm4.manifest")

SUPPORTED_GAME_VERSIONS = ["1.21", "1.21.1", "1.21.2", "1.21.3"]
SUPPORTED_GAME_VERSIONS = ["1.21", "1.21.1", "1.21.2", "1.21.3", "1.21.4"]

# config models for beet.yaml metas
CreditsModel = dict[str, list[str]]
Expand Down
6 changes: 5 additions & 1 deletion gm4/plugins/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ def gm4_root_advancement(ctx: Context):
"icon": {
"id": "command_block",
"components": {
"minecraft:custom_model_data": 3420001
"minecraft:custom_model_data": {
"floats": [
3420001
]
}
}
},
"title": {
Expand Down
Loading
Loading