aboutsummaryrefslogtreecommitdiff
path: root/codegen/lib
diff options
context:
space:
mode:
Diffstat (limited to 'codegen/lib')
-rw-r--r--codegen/lib/code/blocks.py5
-rw-r--r--codegen/lib/download.py23
-rw-r--r--codegen/lib/extract.py24
3 files changed, 23 insertions, 29 deletions
diff --git a/codegen/lib/code/blocks.py b/codegen/lib/code/blocks.py
index e3becfe5..722a0581 100644
--- a/codegen/lib/code/blocks.py
+++ b/codegen/lib/code/blocks.py
@@ -236,13 +236,12 @@ def get_property_struct_name(
return "StructureMode"
if "harp" in property_variants and "didgeridoo" in property_variants:
return "Sound"
- if is_list_of_string_integers(property_variants):
- # if the values are all integers, then prepend the block name
- return to_camel_case(block_id) + to_camel_case(property_id)
if property_variants == ["up", "side", "none"]:
return "Wire" + to_camel_case(property_id)
if property_variants == ["none", "low", "tall"]:
return "Wall" + to_camel_case(property_id)
+ if property_id in {"age", "level", "distance"}:
+ return to_camel_case(block_id) + to_camel_case(property_id)
return to_camel_case(property_id)
diff --git a/codegen/lib/download.py b/codegen/lib/download.py
index fa963188..8819cf61 100644
--- a/codegen/lib/download.py
+++ b/codegen/lib/download.py
@@ -5,6 +5,9 @@ import requests
import json
import os
+PUMPKIN_EXTRACTOR_COMMIT = "82926545925baf5f50414cc9374f1cc340b7de0f"
+BURGER_COMMIT = "366d6e4bed0e9e6505d9c40c83628ab80a5fe001"
+
# make sure the cache directory exists
print("Making __cache__")
if not os.path.exists(get_dir_location("__cache__")):
@@ -16,7 +19,7 @@ def get_burger():
if not os.path.exists(get_dir_location("__cache__/Burger")):
print("\033[92mDownloading Burger...\033[m")
os.system(
- f"cd {get_dir_location('__cache__')} && git clone https://github.com/mat-1/Burger && cd Burger && git pull"
+ f"cd {get_dir_location('__cache__')} && git clone https://github.com/mat-1/Burger && cd Burger && git pull && git reset --hard {BURGER_COMMIT}"
)
print("\033[92mInstalling dependencies...\033[m")
@@ -29,7 +32,7 @@ def get_pumpkin_extractor():
if not os.path.exists(get_dir_location("__cache__/pumpkin-extractor")):
print("\033[92mDownloading Pumpkin-MC/Extractor...\033[m")
os.system(
- f"cd {get_dir_location('__cache__')} && git clone https://github.com/Pumpkin-MC/Extractor pumpkin-extractor && cd pumpkin-extractor && git pull"
+ f"cd {get_dir_location('__cache__')} && git clone https://github.com/Pumpkin-MC/Extractor pumpkin-extractor && cd pumpkin-extractor && git pull && git reset --hard {PUMPKIN_EXTRACTOR_COMMIT}"
)
return get_dir_location("__cache__/pumpkin-extractor")
@@ -123,7 +126,7 @@ def get_fabric_data(version_id: str):
return yarn_versions_data
-def get_latest_fabric_api_version():
+def get_fabric_api_version(version_id: str):
path = get_dir_location("__cache__/fabric-api-maven-metadata.xml")
if not os.path.exists(path):
@@ -137,10 +140,12 @@ def get_latest_fabric_api_version():
maven_metadata_xml = json.load(f)
tree = ET.ElementTree(ET.fromstring(maven_metadata_xml))
- name = tree.find(".//latest").text
- if name.endswith('_unobfuscated'):
- name = name[:-len('_unobfuscated')]
- return name
+ expected_suffix = "+" + version_id.split("-")[0]
+ versions = tree.findall(".//version")
+ for candidate in reversed(versions):
+ candidate = candidate.text
+ if candidate.endswith(expected_suffix):
+ return candidate
def get_latest_fabric_kotlin_version():
@@ -244,9 +249,9 @@ def clear_version_cache():
burger_path = get_dir_location("__cache__/Burger")
if os.path.exists(burger_path):
- os.system(f"cd {burger_path} && git pull")
+ os.system(f"cd {burger_path} && git pull && git reset --hard {BURGER_COMMIT}")
pumpkin_path = get_dir_location("__cache__/pumpkin-extractor")
if os.path.exists(pumpkin_path):
os.system(
- f"cd {pumpkin_path} && git add . && git stash && git pull && git stash pop && git checkout HEAD -- src/main/resources/fabric.mod.json"
+ f"cd {pumpkin_path} && git add . && git stash && git checkout master && git pull && git stash pop && git reset --hard {PUMPKIN_EXTRACTOR_COMMIT}"
)
diff --git a/codegen/lib/extract.py b/codegen/lib/extract.py
index b07e17ba..f2f7f4a2 100644
--- a/codegen/lib/extract.py
+++ b/codegen/lib/extract.py
@@ -2,7 +2,7 @@
import shutil
from lib.download import (
- get_latest_fabric_api_version,
+ get_fabric_api_version,
get_latest_fabric_kotlin_version,
get_latest_fabric_loom_version,
get_mappings_for_version,
@@ -179,9 +179,8 @@ def get_pumpkin_data(version_id: str, category: str):
f.write("server-port=0")
fabric_data = get_fabric_data(version_id)[0]
- fabric_api_version = get_latest_fabric_api_version()
+ fabric_api_version = get_fabric_api_version(version_id)
fabric_kotlin_version = get_latest_fabric_kotlin_version()
- fabric_loom_version = get_latest_fabric_loom_version()
gradle_properties = f"""# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G
@@ -205,23 +204,14 @@ fabric_version={fabric_api_version}
fabric_mod_json_path = f"{pumpkin_dir}/src/main/resources/fabric.mod.json"
with open(fabric_mod_json_path, "r") as f:
fabric_mod_json = f.read()
- with open(fabric_mod_json_path, "w") as f:
- fabric_mod_json = fabric_mod_json.replace(
- '"minecraft": "${minecraft_version}"', '"minecraft": "*"'
- )
- f.write(fabric_mod_json)
with open(f"{pumpkin_dir}/build.gradle.kts", "r") as f:
build_gradle_kts = f.read()
with open(f"{pumpkin_dir}/build.gradle.kts", "w") as f:
- build_gradle_kts = re.sub(
- r'(id\("fabric-loom"\) version )"[^"]+"',
- rf'\1"{fabric_loom_version}"',
- build_gradle_kts,
- )
- # kotlin complains about nullable types if we don't add this
- build_gradle_kts = re.sub(
- r'(to project.property\("\w+"\))([\n,])', r"\1!!\2", build_gradle_kts
- )
+ # build_gradle_kts = re.sub(
+ # r'(id\("fabric-loom"\) version )"[^"]+"',
+ # rf'\1"{fabric_loom_version}"',
+ # build_gradle_kts,
+ # )
f.write(build_gradle_kts)
# run ./gradlew runServer until it logs "(pumpkin_extractor) Done"