Skip to content

Commit

Permalink
[1.2] Added minecraft:block/* Path Support
Browse files Browse the repository at this point in the history
  • Loading branch information
RICE0707 committed Dec 10, 2024
1 parent 5730811 commit e5e0729
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README-中文.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ README LANGUAGES [ [English](README.md) | [**中文**](README-中文.md) ]
1. Custom Model Data 轉換:將舊版 CustomModelData 格式轉換為新格式
2. Item Model 轉換:根據 CustomModelData 的路徑轉換為獨立的模型檔案
- 自動調整資料夾結構(`assets/minecraft/models/item/*``assets/minecraft/items/*`
- 智慧處理 `minecraft:item/``item/` 的路徑前綴
- 智慧處理 `minecraft:item/` ` minecraft:block/ ` `item/` 的路徑前綴
- 批次處理整個資源包
- 即時顯示轉換進度
- 自動打包為可直接使用的資源包
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This tool primarily handles the conversion of item model JSON formats, helping c
1. Custom Model Data Conversion: Converts old CustomModelData format to new format
2. Item Model Conversion: Converts to individual model files based on CustomModelData paths
- Automatically adjusts folder structure (`assets/minecraft/models/item/*``assets/minecraft/items/*`)
- Intelligently handles `minecraft:item/` and `item/` path prefixes
- Intelligently handles `minecraft:item/` , ` minecraft:block/ ` and `item/` path prefixes
- Batch processes entire resource packs
- Real-time conversion progress display
- Automatically packages into a ready-to-use resource pack
Expand Down
16 changes: 13 additions & 3 deletions converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
The module can be used both as a standalone command-line tool and as part of a GUI application.
Author: RiceChen_
Version: 1.1
Version: 1.2
"""

import json
Expand Down Expand Up @@ -217,12 +217,22 @@ def convert_json_format(input_json):
base_texture = input_json.get("textures", {}).get("layer0", "")

if base_texture:
# Handle minecraft:item paths
if base_texture.startswith("minecraft:item/"):
base_texture = f"minecraft:item/{base_texture.split('minecraft:item/')[-1]}"
elif base_texture.startswith("item/"):
base_texture = f"item/{base_texture.split('item/')[-1]}"
elif not any(base_texture.startswith(prefix) for prefix in ["item/", "minecraft:item/"]):
base_texture = f"item/{base_texture}"
# Handle minecraft:block paths
elif base_texture.startswith("minecraft:block/"):
base_texture = f"minecraft:block/{base_texture.split('minecraft:block/')[-1]}"
elif base_texture.startswith("block/"):
base_texture = f"block/{base_texture.split('block/')[-1]}"
# Add default prefix if neither item nor block prefix exists
elif not any(base_texture.startswith(prefix) for prefix in [
"item/", "minecraft:item/",
"block/", "minecraft:block/"
]):
base_texture = f"item/{base_texture}" # Default to item/ prefix

# Create new format structure
new_format = {
Expand Down
2 changes: 1 addition & 1 deletion gui_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
- Cross-platform compatibility
Author: RiceChen_
Version: 1.1
Version: 1.2
"""

import sys
Expand Down
2 changes: 1 addition & 1 deletion run.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
for all user interactions and messages.
Author: RiceChen_
Version: 1.1
Version: 1.2
"""

import subprocess
Expand Down

0 comments on commit e5e0729

Please sign in to comment.