Slimefun-Resourcepack icon indicating copy to clipboard operation
Slimefun-Resourcepack copied to clipboard

1.21.4+ Support

Open EagL3-GIT opened this issue 11 months ago • 23 comments

Describe the problem:

In 1.21.4 mojang introduced another resourcepack changes, mainly file structure, which is not that bad but player heads are broken even with the new format. Textures in GUI are small but what is worse, textures in hand are not even showing up. Check pictures.

Screenshots:

Image Image

Version Info:

  • Resourcepack Version: git-f71892a
  • Minecraft Version: 1.21.4
  • CIT Mod: CIT Resewn

EagL3-GIT avatar Jan 20 '25 14:01 EagL3-GIT

Since the 1.21.4 model format requires a near-complete rewrite (including CIT), this will be a breaking change. As a result, it will be implemented in v2.0.0, and we may drop support for older versions.

However, since Slimefun does not yet support 1.21, this update is not a high priority at the moment.

I'm pinning this issue to inform anyone attempting to use the Slimefun Resourcepack on Minecraft 1.21.4 about this situation.

xMikux avatar Mar 02 '25 16:03 xMikux

汉化版已经支持了1.21.4(虽然不是全部)有什么材质包升级版本的教程吗?

BerryMC avatar Mar 09 '25 08:03 BerryMC

https://github.com/BrilliantTeam/Minecraft-ResourcePack-Migrator 可以試試看這個,也許可以

xMikux avatar Mar 09 '25 10:03 xMikux

https://github.com/BrilliantTeam/Minecraft-ResourcePack-Migrator 可以試試看這個,也許可以

非常感谢!除了一些头颅显示错误,主要是不加材质包一堆锭啊粉啊的分不清,头颅之类的倒无所谓

BerryMC avatar Mar 10 '25 11:03 BerryMC

可以試看看我上傳的,修復了頭顱的問題

xiaomaomi9427 avatar Apr 26 '25 16:04 xiaomaomi9427

I suggest using resourcepack overlays, this way you could support all 1.20.2+ versions { "pack":{ "pack_format":16, "supported_formats": {"min_inclusive": 16, "max_inclusive": 99}, "description": "multi version pack" }, "overlays": { "entries": [ { "directory": "_MULTI_items_old_", "formats": {"min_inclusive": 16, "max_inclusive": 45} }, { "directory": "_MULTI_items_new_", "formats": {"min_inclusive": 46, "max_inclusive": 99} } ]}, }

MULTI_items_old is a folder in root next to assets containing assets>minecraft>models>item MULTI_items_new is a folder in root next to assets containing assets>minecraft>items

and the main assets folder does NOT contain any item or items folder, this is applied by the overlay above

R411gun avatar May 01 '25 23:05 R411gun

我成功完全兼容了1.21.4(除了CIT),是基于那个migrator和自己写了一个附加程序修复

jiajia06403 avatar Jun 02 '25 06:06 jiajia06403

可以試看看我上傳的,修復了頭顱的問題

感谢,很有参考价值

jiajia06403 avatar Jun 02 '25 06:06 jiajia06403

将以下代码放在一个文件夹里,文件夹里需要一个input文件夹,放置待修复的minecraft/items的json文件,然后还有resource文件夹,放置从官方版本jar里解压出来的minecraft/items,然后执行该程序即可修复所有!

import json
import concurrent.futures
from pathlib import Path
from rich.progress import Progress, BarColumn, TextColumn, SpinnerColumn
from rich.console import Console
from rich.panel import Panel
import time
import os

def transform_player_head_entry(entry):
    """精确转换 player_head.json 中的 entry"""
    if "model" not in entry or not isinstance(entry["model"], dict):
        return
    
    model_dict = entry["model"]
    
    # 提取基础值
    base_value = model_dict.get("base")
    if not base_value:
        return
    
    # 获取并处理 type 值
    entry_type = model_dict.get("type", "")
    if entry_type == "minecraft:special":
        entry_type = "model"
    
    # 创建新的 model 对象
    entry["model"] = {
        "type": entry_type,
        "model": base_value
    }

def process_player_head(input_path: Path, output_path: Path):
    """精确处理 player_head.json 文件"""
    try:
        with open(input_path, 'r', encoding='utf-8') as f:
            data = json.load(f)
        
        # 处理 entries
        model_data = data.get("model", {})
        entries = model_data.get("entries", [])
        for entry in entries:
            transform_player_head_entry(entry)
        
        # 写入处理后的数据
        with open(output_path, 'w', encoding='utf-8') as f:
            json.dump(data, f, ensure_ascii=False, indent=2)
        return True
    except Exception as e:
        print(f"处理 player_head 时出错: {e}")
        return False

def apply_fallback_override(data, resource_model):
    """应用 fallback 覆盖"""
    # 在顶层查找 fallback
    if "fallback" in data:
        data["fallback"] = resource_model
        return True
    
    # 在 model 对象中查找 fallback
    if "model" in data and isinstance(data["model"], dict):
        if "fallback" in data["model"]:
            data["model"]["fallback"] = resource_model
            return True
    
    # 在嵌套结构中查找 fallback
    for key, value in data.items():
        if isinstance(value, dict):
            if apply_fallback_override(value, resource_model):
                return True
        elif isinstance(value, list):
            for item in value:
                if isinstance(item, dict) and apply_fallback_override(item, resource_model):
                    return True
    return False

def process_other_files(input_path: Path, output_path: Path, resource_model: dict):
    """精确处理其他文件"""
    try:
        with open(input_path, 'r', encoding='utf-8') as f:
            data = json.load(f)
        
        # 应用 fallback 覆盖
        apply_fallback_override(data, resource_model)
        
        # 写入处理后的数据
        with open(output_path, 'w', encoding='utf-8') as f:
            json.dump(data, f, ensure_ascii=False, indent=2)
        return True
    except Exception as e:
        print(f"处理 {input_path.name} 时出错: {e}")
        return False

def load_resource_file(res_file: Path):
    """加载单个资源文件"""
    try:
        with open(res_file, 'r', encoding='utf-8') as f:
            data = json.load(f)
            return res_file.stem, data.get("model", {})
    except Exception as e:
        print(f"加载资源 {res_file.name} 时出错: {e}")
        return res_file.stem, {}

def scan_files(directory: Path):
    """高效扫描文件系统"""
    file_paths = []
    for root, _, files in os.walk(directory):
        for file in files:
            if file.lower().endswith('.json'):
                file_paths.append(Path(root) / file)
    return file_paths

def main():
    # 配置路径
    input_dir = Path("input")
    output_dir = Path("output")
    resource_dir = Path("resource")
    
    # 确保输出目录存在
    output_dir.mkdir(parents=True, exist_ok=True)
    
    console = Console()
    console.print("[bold green]JSON文件修复程序启动[/bold green]")
    start_time = time.time()
    
    # 创建进度条
    progress = Progress(
        SpinnerColumn(),
        TextColumn("[bold blue]{task.description}"),
        BarColumn(bar_width=40),
        TextColumn("[progress.percentage]{task.percentage:>3.0f}%"),
        TextColumn("[green]{task.completed}/{task.total}"),
        console=console,
        expand=True
    )
    
    # 阶段1:扫描和加载资源文件
    with progress:
        # 扫描资源文件
        task_scan_res = progress.add_task("扫描资源文件...", total=None)
        resource_files = scan_files(resource_dir)
        progress.update(task_scan_res, completed=len(resource_files), total=len(resource_files))
        
        # 并行加载资源文件
        task_load = progress.add_task("加载资源模板...", total=len(resource_files))
        resources = {}
        
        # 使用线程池并行加载
        with concurrent.futures.ThreadPoolExecutor() as executor:
            futures = {executor.submit(load_resource_file, res_file): res_file for res_file in resource_files}
            
            for future in concurrent.futures.as_completed(futures):
                stem, model_data = future.result()
                resources[stem] = model_data
                progress.update(task_load, advance=1)
        
        progress.remove_task(task_scan_res)
        progress.remove_task(task_load)
    
    # 阶段2:扫描输入文件
    with progress:
        task_scan = progress.add_task("扫描输入文件...", total=None)
        file_paths = scan_files(input_dir)
        total_files = len(file_paths)
        progress.update(task_scan, description="扫描完成", completed=total_files, total=total_files)
        time.sleep(0.3)
        progress.remove_task(task_scan)
    
    if not file_paths:
        console.print("[bold yellow]警告: 未发现任何JSON文件[/bold yellow]")
        return
    
    # 阶段3:处理文件
    success_count = 0
    with progress:
        task_id = progress.add_task("处理文件中", total=total_files)
        
        with concurrent.futures.ThreadPoolExecutor() as executor:
            futures = []
            
            # 提交所有任务
            for file_path in file_paths:
                # 准备输出路径
                rel_path = file_path.relative_to(input_dir)
                output_file = output_dir / rel_path
                output_file.parent.mkdir(parents=True, exist_ok=True)
                
                # 根据文件类型提交任务
                if file_path.name == "player_head.json":
                    future = executor.submit(process_player_head, file_path, output_file)
                else:
                    resource_key = file_path.stem
                    resource_model = resources.get(resource_key, {})
                    future = executor.submit(process_other_files, file_path, output_file, resource_model)
                
                futures.append(future)
            
            # 监控任务完成情况
            for future in concurrent.futures.as_completed(futures):
                if future.result():
                    success_count += 1
                progress.update(task_id, advance=1)
    
    # 显示统计信息
    elapsed = time.time() - start_time
    console.print(
        Panel(
            f"[bold green]处理完成! 成功: [cyan]{success_count}[/cyan]/[yellow]{total_files}[/yellow] 个文件\n"
            f"耗时: [magenta]{elapsed:.2f}秒[/magenta][/bold green]",
            title="处理结果",
            border_style="green"
        )
    )
    console.print(f"[bold]输出目录: [blue]{output_dir.resolve()}[/blue][/bold]")

if __name__ == "__main__":
    main()

需要额外安装rich等库

jiajia06403 avatar Jun 02 '25 07:06 jiajia06403

将以下代码放在一个文件夹里,文件夹里需要一个input文件夹,放置待修复的minecraft/items的json文件,然后还有resource文件夹,放置从官方版本jar里解压出来的minecraft/items,然后执行该程序即可修复所有!

我這上面扔的資源包是很久的了 後面有發現一些問題我有改但沒放上來

migrator轉換後會出現 例如,玻璃片錯亂,部分物品為3D而非2D,樹叶煙花等顏色丟失

xiaomaomi9427 avatar Jun 02 '25 19:06 xiaomaomi9427

将以下代码放在一个文件夹里,文件夹里需要一个input文件夹,放置待修复的minecraft/items的json文件,然后还有resource文件夹,放置从官方版本jar里解压出来的minecraft/items,然后执行该程序即可修复所有!

我這上面扔的資源包是很久的了 後面有發現一些問題我有改但沒放上來

migrator轉換後會出現 例如,玻璃片錯亂,部分物品為3D而非2D,樹叶煙花等顏色丟失

是的,我的这个程序就是修复这些问题的

jiajia06403 avatar Jun 06 '25 08:06 jiajia06403

将以下代码放在一个文件夹里,文件夹里需要一个input文件夹,放置待修复的minecraft/items的json文件,然后还有resource文件夹,放置从官方版本jar里解压出来的minecraft/items,然后执行该程序即可修复所有!

我這上面扔的資源包是很久的了 後面有發現一些問題我有改但沒放上來

migrator轉換後會出現 例如,玻璃片錯亂,部分物品為3D而非2D,樹叶煙花等顏色丟失

通过与原版的items进行合并就能很方便地修复这些所有问题

jiajia06403 avatar Jun 06 '25 08:06 jiajia06403

已知1.21.2之后盔甲模型可以直接通过命名空间修改,那么cit里的盔甲是不是都能“原版化”而不依赖cit了?有人有试过吗?

jiajia06403 avatar Jun 08 '25 04:06 jiajia06403

我们需要一个cit转原版equipment的程序

jiajia06403 avatar Jun 08 '25 13:06 jiajia06403

我发现cem也能完成类似cit的盔甲材质定义工作: <item_name>.cem

{
    "Conditions": [
        {
            "name":"CustomModelData",
            "value":"<CustomModelData>",
            "model":"<model path>"
    ]
}

这个cem是修改模型的,如果只是修改材质也许只需要把model换成texture?(没仔细研究过)

jiajia06403 avatar Jun 10 '25 11:06 jiajia06403

Any English instructions to properly convert the pack to new format ?

MeowIce avatar Jul 18 '25 11:07 MeowIce

https://github.com/BrilliantTeam/Minecraft-ResourcePack-Migrator You can use this tool to temporarily support 1.21.4+ format, until we finish updating the pack.

xMikux avatar Jul 18 '25 16:07 xMikux

https://github.com/BrilliantTeam/Minecraft-ResourcePack-Migrator You can use this tool to temporarily support 1.21.4+ format, until we finish updating the pack.

I need an instruction...

MeowIce avatar Jul 18 '25 17:07 MeowIce

We now have 1.21.4+ beta support, there still have some issues on player head handheld looks like, but it should be fine. 現在有測試版支援 1.21.4+ 了,雖說對於手持頭顱類物品仍然會有些顯示問題,但應該還好。

Modrinth 1.21.4+

xMikux avatar Jul 27 '25 13:07 xMikux

1.21.4->1.21.8 有什么资源包格式上的修改吗

jiajia06403 avatar Jul 29 '25 10:07 jiajia06403

基本上就是 1.21.4+ 是用新的 model json 格式 因為 Mojang 改了,導致之前在 1.21.4 以上版本,無法套用任何材質 現在 ItemsAdder 有透過 Overlay 與一些神奇的魔術(?)讓其支援 1.21.4 以上或以下

可以看看以下圖片,來比對舊版與新版的差異

Image

文章來源:巴哈 【密技】Minecraft 資源包更新工具 (1.14 ~ 1.21.4+) | Minecraft-ResourcePack-Migrator 1.14 ~ 1.21.4+ 順代一提,上面所提供的資源包更新工具也是上方文章作者所寫的

xMikux avatar Jul 29 '25 11:07 xMikux

啊不是说这个,我意思在1.21.4之后,还有改吗,就是.4的包能兼容.9吗

jiajia06403 avatar Aug 02 '25 12:08 jiajia06403

只要 Mojang 沒突然改變格式 這可以支援 1.21.4+ 以上的任何版本

xMikux avatar Aug 04 '25 04:08 xMikux