forked from DonBruce64/MTSOfficialPack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWORKING_FIX.py
More file actions
74 lines (59 loc) · 2.77 KB
/
WORKING_FIX.py
File metadata and controls
74 lines (59 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python3
import os
import json
from pathlib import Path
def fix_to_working_pattern():
"""Fix all models to use the EXACT same pattern as the working engineallison250"""
namespace = "mtsofficialpack"
models_dir = Path(f"src/main/resources/assets/{namespace}/models/item")
textures_dir = Path(f"src/main/resources/assets/{namespace}/textures")
print("=== FIXING TO WORKING PATTERN ===")
print("Using the exact same pattern as engineallison250 (the one that works)")
if not models_dir.exists():
print(f"Models directory not found: {models_dir}")
return
# Build a simple map of textures in the item/ directory
item_textures = {}
item_dir = textures_dir / "item"
if item_dir.exists():
for png_file in item_dir.rglob("*.png"):
# Get relative path from item directory
rel_path = png_file.relative_to(item_dir)
filename = png_file.stem
# Store the path relative to textures/item/
texture_path = str(rel_path).replace("\\", "/").replace(".png", "")
item_textures[filename] = f"item/{texture_path}"
print(f"Found item texture: {filename} -> {texture_path}")
print(f"Found {len(item_textures)} textures in item/ directory")
fixed_count = 0
processed_count = 0
for model_file in models_dir.rglob("*.json"):
try:
with open(model_file, 'r') as f:
model_data = json.load(f)
processed_count += 1
changed = False
item_name = model_file.stem
# Fix texture paths in the model - use item/ directory like the working one
if "textures" in model_data:
for layer, texture_path in model_data["textures"].items():
# Check if this item has a texture in the item/ directory
if item_name in item_textures:
new_path = f"{namespace}:{item_textures[item_name]}"
if new_path != texture_path:
print(f"FIXING {model_file.name}: {texture_path} -> {new_path}")
model_data["textures"][layer] = new_path
changed = True
# Save if changed
if changed:
with open(model_file, 'w') as f:
json.dump(model_data, f, indent=2)
fixed_count += 1
except Exception as e:
print(f"Error processing {model_file.name}: {e}")
print(f"\n=== WORKING PATTERN RESULTS ===")
print(f"Processed {processed_count} model files")
print(f"Fixed {fixed_count} models to use working item/ pattern")
print("Now they should work exactly like engineallison250!")
if __name__ == "__main__":
fix_to_working_pattern()