Apply native-validated landing damage to resident player health
This commit is contained in:
@@ -93,6 +93,36 @@ def main():
|
||||
(root/'movement-properties.nbt').write_bytes((export/'movement-properties.nbt').read_bytes())
|
||||
(root/'attributes.json').write_bytes((export/'catalog.json').read_bytes())
|
||||
(root/'landing-definitions.json').write_bytes((export/'landing-definitions.json').read_bytes())
|
||||
damage = oracle.with_name('VanillaDamageSourceOracle.java')
|
||||
health = oracle.with_name('VanillaPlayerHealthOracle.java')
|
||||
health_sources = base.source_hashes([damage, health, attributes])
|
||||
health_files = ['damage-types.json', 'damage-tags.json', 'damage-catalog.json', 'player-float-ids.json']
|
||||
if not (previous.get('health_exporters_sha256') == health_sources
|
||||
and previous.get('server_sha256') == origin['server_sha256']
|
||||
and all((root/name).exists() and previous.get('health_files_sha256', {}).get(name)
|
||||
== lab.digest(root/name, 'sha256') for name in health_files)):
|
||||
export = lab.LOCAL/'horizon-client-health'; export.mkdir(exist_ok=True)
|
||||
with zipfile.ZipFile(jars['server']) as archive, zipfile.ZipFile(jars['client']) as client_archive:
|
||||
for file, prefix in [('types.json', 'data/minecraft/damage_type/'), ('tags.json', 'data/minecraft/tags/damage_type/')]:
|
||||
def extract(source):
|
||||
return {'minecraft:'+n[len(prefix):-5]: source.read(n).decode('utf-8')
|
||||
for n in sorted(source.namelist()) if n.startswith(prefix) and n.endswith('.json')}
|
||||
resources = extract(archive)
|
||||
if resources != extract(client_archive): raise ValueError('Reference damage resources disagree')
|
||||
lab.write_json(export/file, resources)
|
||||
classes = export/'classes'; classes.mkdir(exist_ok=True)
|
||||
dependencies = os.pathsep.join(map(str, [jars['server'], *libraries]))
|
||||
with (export/'export.log').open('w') as log:
|
||||
subprocess.run(['javac', '--release', str(lock['minecraft']['java_major']), '-proc:none',
|
||||
'-cp', dependencies, '-d', str(classes), str(damage), str(health), str(attributes)],
|
||||
check=True, stdout=log, stderr=subprocess.STDOUT, timeout=3600)
|
||||
for name in ['VanillaPlayerHealthOracle', 'VanillaDamageSourceOracle']:
|
||||
subprocess.run(['java', '-Xmx768M', '-cp', str(classes)+os.pathsep+dependencies,
|
||||
'dev.horizonlab.parity.'+name, 'export', str(export)],
|
||||
check=True, stdout=log, stderr=subprocess.STDOUT, timeout=3600)
|
||||
for source, target in [('types.json','damage-types.json'), ('tags.json','damage-tags.json'),
|
||||
('catalog.json','damage-catalog.json'), ('ids.json','player-float-ids.json')]:
|
||||
(root/target).write_bytes((export/source).read_bytes())
|
||||
collision_file = root / 'cached-collision.nbt'
|
||||
if not (previous.get('collision_exporters_sha256') == collision_sources
|
||||
and previous.get('server_sha256') == origin['server_sha256']
|
||||
@@ -147,7 +177,9 @@ def main():
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
target.write_bytes(data)
|
||||
count += 1
|
||||
lab.write_json(manifest, {'schema': 6, **origin,
|
||||
lab.write_json(manifest, {'schema': 7, **origin,
|
||||
'health_exporters_sha256': health_sources,
|
||||
'health_files_sha256': {name: lab.digest(root/name, 'sha256') for name in health_files},
|
||||
'motion_exporters_sha256': motion_sources,
|
||||
'motion_files_sha256': {name: lab.digest(root/name, 'sha256') for name in motion_files},
|
||||
'collision_exporters_sha256': collision_sources,
|
||||
|
||||
Reference in New Issue
Block a user