mappingsDownloader.py: remove entities (burger), add blockModels.json (chain load other python file)

This commit is contained in:
Bixilon 2020-11-15 18:51:15 +01:00
parent 7818623c71
commit aa3b9a1a05
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
7 changed files with 190 additions and 15 deletions

8
util/.idea/.gitignore generated vendored Normal file
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/

View File

@ -0,0 +1,12 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="N802" />
</list>
</option>
</inspection_tool>
</profile>
</component>

6
util/.idea/misc.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_15" default="false" project-jdk-name="Python 3.8" project-jdk-type="Python SDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
util/.idea/modules.xml generated Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/util.iml" filepath="$PROJECT_DIR$/.idea/util.iml" />
</modules>
</component>
</project>

6
util/.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

143
util/.idea/workspace.xml generated Normal file
View File

@ -0,0 +1,143 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="34edf7e9-254a-4d39-b77b-418e1a3041e3" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/.idea/.gitignore" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/mappingsDownloader.py" beforeDir="false" afterPath="$PROJECT_DIR$/mappingsDownloader.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
</component>
<component name="JupyterTrust" id="3ba42325-b135-4b61-8478-0100f79ae820" />
<component name="KotlinMultiplatform">
<executables />
</component>
<component name="MacroExpansionManager">
<option name="directoryName" value="npii8wlv" />
</component>
<component name="MavenImportPreferences">
<option name="generalSettings">
<MavenGeneralSettings>
<option name="mavenHome" value="$APPLICATION_HOME_DIR$/plugins/maven/lib/maven3" />
</MavenGeneralSettings>
</option>
</component>
<component name="ProjectId" id="1kKvLMXadVYXYOiRowX5t0eW2oL" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectViewState">
<option name="compactDirectories" value="true" />
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
<option name="showMembers" value="true" />
<option name="sortByType" value="true" />
</component>
<component name="PropertiesComponent">
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="android.sdk.path" value="/opt/AndroidSDK" />
<property name="aspect.path.notification.shown" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="project.structure.last.edited" value="SDKs" />
<property name="project.structure.proportion" value="0.0" />
<property name="project.structure.side.proportion" value="0.2" />
<property name="settings.editor.selected.configurable" value="AndroidSdkUpdater" />
</component>
<component name="RunManager">
<configuration default="true" type="ArquillianJUnit" factoryName="" nameIsGenerated="true">
<option name="arquillianRunConfiguration">
<value>
<option name="containerStateName" value="" />
</value>
</option>
<option name="TEST_OBJECT" value="class" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="mappingsDownloader" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="util" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/mappingsDownloader.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="Python.mappingsDownloader" />
</list>
</recent_temporary>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="34edf7e9-254a-4d39-b77b-418e1a3041e3" name="Default Changelist" comment="" />
<created>1605462040905</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1605462040905</updated>
<workItem from="1605462041949" duration="558000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="WindowStateProjectService">
<state x="444" y="1168" key="#Project_Structure" timestamp="1605462076420">
<screen x="0" y="1050" width="1920" height="1080" />
</state>
<state x="444" y="1168" key="#Project_Structure/0.40.1680.1010/0.1050.1920.1080/1680.26.1280.1024@0.1050.1920.1080" timestamp="1605462076420" />
<state x="419" y="1248" key="#com.intellij.execution.impl.EditConfigurationsDialog" timestamp="1605462499568">
<screen x="0" y="1050" width="1920" height="1080" />
</state>
<state x="419" y="1248" key="#com.intellij.execution.impl.EditConfigurationsDialog/0.40.1680.1010/0.1050.1920.1080/1680.26.1280.1024@0.1050.1920.1080" timestamp="1605462499568" />
<state width="1874" height="281" key="GridCell.Tab.0.bottom" timestamp="1605462580595">
<screen x="0" y="1050" width="1920" height="1080" />
</state>
<state width="1874" height="281" key="GridCell.Tab.0.bottom/0.40.1680.1010/0.1050.1920.1080/1680.26.1280.1024@0.1050.1920.1080" timestamp="1605462580595" />
<state width="1874" height="281" key="GridCell.Tab.0.center" timestamp="1605462580595">
<screen x="0" y="1050" width="1920" height="1080" />
</state>
<state width="1874" height="281" key="GridCell.Tab.0.center/0.40.1680.1010/0.1050.1920.1080/1680.26.1280.1024@0.1050.1920.1080" timestamp="1605462580595" />
<state width="1874" height="281" key="GridCell.Tab.0.left" timestamp="1605462580595">
<screen x="0" y="1050" width="1920" height="1080" />
</state>
<state width="1874" height="281" key="GridCell.Tab.0.left/0.40.1680.1010/0.1050.1920.1080/1680.26.1280.1024@0.1050.1920.1080" timestamp="1605462580595" />
<state width="1874" height="281" key="GridCell.Tab.0.right" timestamp="1605462580595">
<screen x="0" y="1050" width="1920" height="1080" />
</state>
<state width="1874" height="281" key="GridCell.Tab.0.right/0.40.1680.1010/0.1050.1920.1080/1680.26.1280.1024@0.1050.1920.1080" timestamp="1605462580595" />
</component>
<component name="XSLT-Support.FileAssociations.UIState">
<expand />
<select />
</component>
<component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/util$mappingsDownloader.coverage" NAME="mappingsDownloader Coverage Results" MODIFIED="1605462580588" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
</component>
</project>

View File

@ -9,14 +9,6 @@
#
# This software is not affiliated with Mojang AB, the original developer of Minecraft.
#
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with this program.If not, see <https://www.gnu.org/licenses/>.
#
# This software is not affiliated with Mojang AB, the original developer of Minecraft.
#
import hashlib
import os
import requests
@ -30,7 +22,7 @@ print("Minecraft mappings downloader (and generator)")
PRE_FLATTENING_UPDATE_VERSION = "17w46a"
DATA_FOLDER = "../data/resources/"
TEMP_FOLDER = DATA_FOLDER + "tmp/"
FILES_PER_VERSION = ["blocks.json", "registries.json"]
FILES_PER_VERSION = ["blocks.json", "registries.json", "blockModels.json"]
DOWNLOAD_BASE_URL = "https://apimon.de/mcdata/"
manifest = requests.get('https://launchermeta.mojang.com/mc/game/version_manifest.json').json()
failed = []
@ -57,6 +49,7 @@ if not os.path.isdir(TEMP_FOLDER):
for version in manifest["versions"]:
if version["id"] == PRE_FLATTENING_UPDATE_VERSION:
break
versionJson = requests.get(version['url']).json()
versionBaseFolder = TEMP_FOLDER + version["id"] + "/"
resourcesJsonPath = ("mappings/%s" % version["id"])
if resourcesJsonPath in resourceMappingsIndex and os.path.isfile(DATA_FOLDER + resourceMappingsIndex[resourcesJsonPath][:2] + "/" + resourceMappingsIndex[resourcesJsonPath] + ".tar.gz"):
@ -66,6 +59,11 @@ for version in manifest["versions"]:
os.mkdir(versionBaseFolder)
for fileName in FILES_PER_VERSION:
if not os.path.isfile(versionBaseFolder + fileName):
if fileName == "blockModels.json":
# blockModelsCombiner.py will do the trick for us
os.popen('python3 blockModelGenerator.py %s %s' % (versionBaseFolder + "blockModels.json", versionJson['downloads']['client']['url'])).read()
exit()
continue
print("Downloading %s for %s" % (fileName, version["id"]))
try:
reformatted = requests.get(DOWNLOAD_BASE_URL + version["id"] + "/" + fileName).json()
@ -89,12 +87,6 @@ for version in manifest["versions"]:
for key in burger["items"]["item"]:
registries["item"]["entries"][key] = {"id": burger["items"]["item"][key]["numeric_id"]}
# entities
for key in burger["entities"]["entity"]:
if key.startswith("~abstract_"):
continue
registries["entity_type"]["entries"][key] = {"id": burger["entities"]["entity"][key]["id"]}
# biome
for key in burger["biomes"]["biome"]:
registries["biome"]["entries"][key] = {"id": burger["biomes"]["biome"][key]["id"]}