mirror of
https://github.com/mat-1/azalea.git
synced 2024-09-19 22:52:32 +00:00
fix block codegen for newer versions
This commit is contained in:
parent
dbb2092ac0
commit
2fff0e7564
2 changed files with 35 additions and 5 deletions
|
@ -146,12 +146,32 @@ def get_fabric_api_versions():
|
|||
return fabric_api_versions
|
||||
|
||||
|
||||
def get_fabric_loader_versions():
|
||||
# https://meta.fabricmc.net/v2/versions/loader
|
||||
if not os.path.exists(get_dir_location('downloads/fabric_loader_versions.json')):
|
||||
print('\033[92mDownloading Fabric loader versions...\033[m')
|
||||
fabric_api_versions_json = requests.get(
|
||||
'https://meta.fabricmc.net/v2/versions/loader').json()
|
||||
|
||||
fabric_api_versions = []
|
||||
for version in fabric_api_versions_json:
|
||||
fabric_api_versions.append(version['version'])
|
||||
|
||||
with open(get_dir_location('downloads/fabric_loader_versions.json'), 'w') as f:
|
||||
f.write(json.dumps(fabric_api_versions))
|
||||
else:
|
||||
with open(get_dir_location('downloads/fabric_loader_versions.json'), 'r') as f:
|
||||
fabric_api_versions = json.loads(f.read())
|
||||
return fabric_api_versions
|
||||
|
||||
|
||||
def clear_version_cache():
|
||||
print('\033[92mClearing version cache...\033[m')
|
||||
files = [
|
||||
'version_manifest.json',
|
||||
'yarn_versions.json',
|
||||
'fabric_api_versions.json'
|
||||
'fabric_api_versions.json',
|
||||
'fabric_loader_versions.json'
|
||||
]
|
||||
for file in files:
|
||||
if os.path.exists(get_dir_location(f'downloads/{file}')):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Extracting data from the Minecraft jars
|
||||
|
||||
from lib.download import get_server_jar, get_burger, get_client_jar, get_generator_mod, get_yarn_data, get_fabric_api_versions
|
||||
from lib.download import get_server_jar, get_burger, get_client_jar, get_generator_mod, get_yarn_data, get_fabric_api_versions, get_fabric_loader_versions
|
||||
from lib.utils import get_dir_location
|
||||
import subprocess
|
||||
import json
|
||||
|
@ -33,7 +33,10 @@ def get_ordered_blocks_burger(version_id: str):
|
|||
burger_data = get_burger_data_for_version(version_id)
|
||||
return burger_data[0]['blocks']['ordered_blocks']
|
||||
|
||||
|
||||
python_command = None
|
||||
|
||||
|
||||
def determine_python_command():
|
||||
global python_command
|
||||
if python_command:
|
||||
|
@ -46,7 +49,9 @@ def determine_python_command():
|
|||
if try_python_command(version):
|
||||
python_command = version
|
||||
return version
|
||||
raise Exception('Couldn\'t determine python command to use to run burger with!')
|
||||
raise Exception(
|
||||
'Couldn\'t determine python command to use to run burger with!')
|
||||
|
||||
|
||||
def get_burger_data_for_version(version_id: str):
|
||||
if not os.path.exists(get_dir_location(f'downloads/burger-{version_id}.json')):
|
||||
|
@ -59,12 +64,14 @@ def get_burger_data_for_version(version_id: str):
|
|||
capture_output=True,
|
||||
shell=True
|
||||
)
|
||||
regex_match = re.search(r'ModuleNotFoundError: No module named \'(\w+?)\'', r.stderr.decode())
|
||||
regex_match = re.search(
|
||||
r'ModuleNotFoundError: No module named \'(\w+?)\'', r.stderr.decode())
|
||||
if not regex_match:
|
||||
break
|
||||
missing_lib = regex_match.group(1)
|
||||
print('Missing required lib for Burger:', missing_lib)
|
||||
os.system(f'{determine_python_command()} -m pip install {missing_lib}')
|
||||
os.system(
|
||||
f'{determine_python_command()} -m pip install {missing_lib}')
|
||||
with open(get_dir_location(f'downloads/burger-{version_id}.json'), 'r') as f:
|
||||
return json.load(f)
|
||||
|
||||
|
@ -87,6 +94,7 @@ def get_generator_mod_data(version_id: str, category: str):
|
|||
yarn_version = yarn_data['version']
|
||||
|
||||
fabric_api_version = get_fabric_api_versions()[-1]
|
||||
fabric_loader_version = get_fabric_loader_versions()[0]
|
||||
|
||||
# the mod has the minecraft version hard-coded by default, so we just change the gradle.properties and fabric.mod.json
|
||||
with open(get_dir_location(f'{generator_mod_dir}/gradle.properties'), 'r') as f:
|
||||
|
@ -99,6 +107,8 @@ def get_generator_mod_data(version_id: str, category: str):
|
|||
line = f'yarn_mappings={yarn_version}\n'
|
||||
if line.startswith('fabric_version='):
|
||||
line = f'fabric_version={fabric_api_version}\n'
|
||||
if line.startswith('loader_version='):
|
||||
line = f'loader_version={fabric_loader_version}\n'
|
||||
f.write(line)
|
||||
# edit the fabric.mod.json to support this version
|
||||
with open(get_dir_location(f'{generator_mod_dir}/src/main/resources/fabric.mod.json'), 'r') as f:
|
||||
|
|
Loading…
Reference in a new issue