Apply the Ordos ore palette in sulfur caves and badlands #52
7 changed files with 724 additions and 53 deletions
34
.forgejo/workflows/sigma-ore-palette.yml
Normal file
34
.forgejo/workflows/sigma-ore-palette.yml
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
name: Sigma Ore Palette Build
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: ['fix/sigma-native-ore-palette-*']
|
||||
|
||||
jobs:
|
||||
sigma-ore-palette:
|
||||
runs-on: dune-ci
|
||||
steps:
|
||||
- name: Check out exact revision
|
||||
shell: bash
|
||||
env:
|
||||
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git init .
|
||||
git -c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$REPO_TOKEN" | base64 -w0)" fetch --depth=1 https://www.dunerealms.com/git/unimatrix/plugins.git "$GITHUB_SHA"
|
||||
git checkout --detach FETCH_HEAD
|
||||
- name: Validate and package the three Sigma biomes
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
python3 tools/test_planet_ore_release.py
|
||||
mkdir sigma-ore-artifacts
|
||||
cp DuneTerrain/planet-datapacks/sigma_draconis_iv/data/minecraft/worldgen/biome/{badlands,eroded_badlands,sulfur_caves}.json sigma-ore-artifacts/
|
||||
cp tools/{planet_ore_release,reset-planet-ores,reset-sigma-ore-pack}.py sigma-ore-artifacts/
|
||||
printf '%s\n' "$(git rev-parse HEAD)" > sigma-ore-artifacts/SOURCE_COMMIT
|
||||
(cd sigma-ore-artifacts && sha256sum -- *.json *.py SOURCE_COMMIT > SHA256SUMS)
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: DuneRealms-Sigma-Ore-Palette
|
||||
path: sigma-ore-artifacts/
|
||||
if-no-files-found: error
|
||||
|
|
@ -0,0 +1,183 @@
|
|||
{
|
||||
"attributes": {
|
||||
"minecraft:audio/background_music": {
|
||||
"default": {
|
||||
"max_delay": 24000,
|
||||
"min_delay": 12000,
|
||||
"sound": "minecraft:music.overworld.badlands"
|
||||
}
|
||||
},
|
||||
"minecraft:gameplay/snow_golem_melts": true,
|
||||
"minecraft:visual/sky_color": "#6eb1ff"
|
||||
},
|
||||
"carvers": [
|
||||
"minecraft:cave",
|
||||
"minecraft:cave_extra_underground",
|
||||
"minecraft:canyon"
|
||||
],
|
||||
"creature_spawn_probability": 0.03,
|
||||
"downfall": 0.0,
|
||||
"effects": {
|
||||
"foliage_color": "#9e814d",
|
||||
"grass_color": "#90814d",
|
||||
"water_color": "#3f76e4"
|
||||
},
|
||||
"features": [
|
||||
[],
|
||||
[
|
||||
"minecraft:lake_lava_underground",
|
||||
"minecraft:lake_lava_surface"
|
||||
],
|
||||
[
|
||||
"minecraft:amethyst_geode"
|
||||
],
|
||||
[
|
||||
"minecraft:monster_room",
|
||||
"minecraft:monster_room_deep"
|
||||
],
|
||||
[],
|
||||
[],
|
||||
[
|
||||
"minecraft:ore_dirt",
|
||||
"minecraft:ore_gravel",
|
||||
"minecraft:ore_granite_upper",
|
||||
"minecraft:ore_granite_lower",
|
||||
"minecraft:ore_diorite_upper",
|
||||
"minecraft:ore_diorite_lower",
|
||||
"minecraft:ore_andesite_upper",
|
||||
"minecraft:ore_andesite_lower",
|
||||
"minecraft:ore_tuff",
|
||||
"minecraft:underwater_magma",
|
||||
"minecraft:disk_sand",
|
||||
"minecraft:disk_clay",
|
||||
"minecraft:disk_gravel"
|
||||
],
|
||||
[],
|
||||
[
|
||||
"minecraft:spring_water",
|
||||
"minecraft:spring_lava"
|
||||
],
|
||||
[
|
||||
"minecraft:glow_lichen",
|
||||
"minecraft:patch_grass_badlands",
|
||||
"minecraft:patch_dry_grass_badlands",
|
||||
"minecraft:patch_dead_bush_badlands",
|
||||
"minecraft:brown_mushroom_normal",
|
||||
"minecraft:red_mushroom_normal",
|
||||
"minecraft:patch_sugar_cane_badlands",
|
||||
"minecraft:patch_pumpkin",
|
||||
"minecraft:patch_cactus_decorated",
|
||||
"minecraft:patch_firefly_bush_near_water"
|
||||
],
|
||||
[
|
||||
"minecraft:freeze_top_layer"
|
||||
]
|
||||
],
|
||||
"has_precipitation": false,
|
||||
"spawn_costs": {},
|
||||
"spawners": {
|
||||
"ambient": [
|
||||
{
|
||||
"type": "minecraft:bat",
|
||||
"maxCount": 8,
|
||||
"minCount": 8,
|
||||
"weight": 10
|
||||
}
|
||||
],
|
||||
"axolotls": [],
|
||||
"creature": [
|
||||
{
|
||||
"type": "minecraft:sheep",
|
||||
"maxCount": 4,
|
||||
"minCount": 4,
|
||||
"weight": 12
|
||||
},
|
||||
{
|
||||
"type": "minecraft:pig",
|
||||
"maxCount": 4,
|
||||
"minCount": 4,
|
||||
"weight": 10
|
||||
},
|
||||
{
|
||||
"type": "minecraft:chicken",
|
||||
"maxCount": 4,
|
||||
"minCount": 4,
|
||||
"weight": 10
|
||||
},
|
||||
{
|
||||
"type": "minecraft:cow",
|
||||
"maxCount": 4,
|
||||
"minCount": 4,
|
||||
"weight": 8
|
||||
},
|
||||
{
|
||||
"type": "minecraft:armadillo",
|
||||
"maxCount": 2,
|
||||
"minCount": 1,
|
||||
"weight": 6
|
||||
}
|
||||
],
|
||||
"misc": [],
|
||||
"monster": [
|
||||
{
|
||||
"type": "minecraft:spider",
|
||||
"maxCount": 4,
|
||||
"minCount": 4,
|
||||
"weight": 100
|
||||
},
|
||||
{
|
||||
"type": "minecraft:zombie",
|
||||
"maxCount": 4,
|
||||
"minCount": 4,
|
||||
"weight": 95
|
||||
},
|
||||
{
|
||||
"type": "minecraft:zombie_villager",
|
||||
"maxCount": 1,
|
||||
"minCount": 1,
|
||||
"weight": 5
|
||||
},
|
||||
{
|
||||
"type": "minecraft:skeleton",
|
||||
"maxCount": 4,
|
||||
"minCount": 4,
|
||||
"weight": 100
|
||||
},
|
||||
{
|
||||
"type": "minecraft:creeper",
|
||||
"maxCount": 4,
|
||||
"minCount": 4,
|
||||
"weight": 100
|
||||
},
|
||||
{
|
||||
"type": "minecraft:slime",
|
||||
"maxCount": 4,
|
||||
"minCount": 4,
|
||||
"weight": 100
|
||||
},
|
||||
{
|
||||
"type": "minecraft:enderman",
|
||||
"maxCount": 4,
|
||||
"minCount": 1,
|
||||
"weight": 10
|
||||
},
|
||||
{
|
||||
"type": "minecraft:witch",
|
||||
"maxCount": 1,
|
||||
"minCount": 1,
|
||||
"weight": 5
|
||||
}
|
||||
],
|
||||
"underground_water_creature": [
|
||||
{
|
||||
"type": "minecraft:glow_squid",
|
||||
"maxCount": 6,
|
||||
"minCount": 4,
|
||||
"weight": 10
|
||||
}
|
||||
],
|
||||
"water_ambient": [],
|
||||
"water_creature": []
|
||||
},
|
||||
"temperature": 2.0
|
||||
}
|
||||
|
|
@ -0,0 +1,183 @@
|
|||
{
|
||||
"attributes": {
|
||||
"minecraft:audio/background_music": {
|
||||
"default": {
|
||||
"max_delay": 24000,
|
||||
"min_delay": 12000,
|
||||
"sound": "minecraft:music.overworld.badlands"
|
||||
}
|
||||
},
|
||||
"minecraft:gameplay/snow_golem_melts": true,
|
||||
"minecraft:visual/sky_color": "#6eb1ff"
|
||||
},
|
||||
"carvers": [
|
||||
"minecraft:cave",
|
||||
"minecraft:cave_extra_underground",
|
||||
"minecraft:canyon"
|
||||
],
|
||||
"creature_spawn_probability": 0.03,
|
||||
"downfall": 0.0,
|
||||
"effects": {
|
||||
"foliage_color": "#9e814d",
|
||||
"grass_color": "#90814d",
|
||||
"water_color": "#3f76e4"
|
||||
},
|
||||
"features": [
|
||||
[],
|
||||
[
|
||||
"minecraft:lake_lava_underground",
|
||||
"minecraft:lake_lava_surface"
|
||||
],
|
||||
[
|
||||
"minecraft:amethyst_geode"
|
||||
],
|
||||
[
|
||||
"minecraft:monster_room",
|
||||
"minecraft:monster_room_deep"
|
||||
],
|
||||
[],
|
||||
[],
|
||||
[
|
||||
"minecraft:ore_dirt",
|
||||
"minecraft:ore_gravel",
|
||||
"minecraft:ore_granite_upper",
|
||||
"minecraft:ore_granite_lower",
|
||||
"minecraft:ore_diorite_upper",
|
||||
"minecraft:ore_diorite_lower",
|
||||
"minecraft:ore_andesite_upper",
|
||||
"minecraft:ore_andesite_lower",
|
||||
"minecraft:ore_tuff",
|
||||
"minecraft:underwater_magma",
|
||||
"minecraft:disk_sand",
|
||||
"minecraft:disk_clay",
|
||||
"minecraft:disk_gravel"
|
||||
],
|
||||
[],
|
||||
[
|
||||
"minecraft:spring_water",
|
||||
"minecraft:spring_lava"
|
||||
],
|
||||
[
|
||||
"minecraft:glow_lichen",
|
||||
"minecraft:patch_grass_badlands",
|
||||
"minecraft:patch_dry_grass_badlands",
|
||||
"minecraft:patch_dead_bush_badlands",
|
||||
"minecraft:brown_mushroom_normal",
|
||||
"minecraft:red_mushroom_normal",
|
||||
"minecraft:patch_sugar_cane_badlands",
|
||||
"minecraft:patch_pumpkin",
|
||||
"minecraft:patch_cactus_decorated",
|
||||
"minecraft:patch_firefly_bush_near_water"
|
||||
],
|
||||
[
|
||||
"minecraft:freeze_top_layer"
|
||||
]
|
||||
],
|
||||
"has_precipitation": false,
|
||||
"spawn_costs": {},
|
||||
"spawners": {
|
||||
"ambient": [
|
||||
{
|
||||
"type": "minecraft:bat",
|
||||
"maxCount": 8,
|
||||
"minCount": 8,
|
||||
"weight": 10
|
||||
}
|
||||
],
|
||||
"axolotls": [],
|
||||
"creature": [
|
||||
{
|
||||
"type": "minecraft:sheep",
|
||||
"maxCount": 4,
|
||||
"minCount": 4,
|
||||
"weight": 12
|
||||
},
|
||||
{
|
||||
"type": "minecraft:pig",
|
||||
"maxCount": 4,
|
||||
"minCount": 4,
|
||||
"weight": 10
|
||||
},
|
||||
{
|
||||
"type": "minecraft:chicken",
|
||||
"maxCount": 4,
|
||||
"minCount": 4,
|
||||
"weight": 10
|
||||
},
|
||||
{
|
||||
"type": "minecraft:cow",
|
||||
"maxCount": 4,
|
||||
"minCount": 4,
|
||||
"weight": 8
|
||||
},
|
||||
{
|
||||
"type": "minecraft:armadillo",
|
||||
"maxCount": 2,
|
||||
"minCount": 1,
|
||||
"weight": 6
|
||||
}
|
||||
],
|
||||
"misc": [],
|
||||
"monster": [
|
||||
{
|
||||
"type": "minecraft:spider",
|
||||
"maxCount": 4,
|
||||
"minCount": 4,
|
||||
"weight": 100
|
||||
},
|
||||
{
|
||||
"type": "minecraft:zombie",
|
||||
"maxCount": 4,
|
||||
"minCount": 4,
|
||||
"weight": 95
|
||||
},
|
||||
{
|
||||
"type": "minecraft:zombie_villager",
|
||||
"maxCount": 1,
|
||||
"minCount": 1,
|
||||
"weight": 5
|
||||
},
|
||||
{
|
||||
"type": "minecraft:skeleton",
|
||||
"maxCount": 4,
|
||||
"minCount": 4,
|
||||
"weight": 100
|
||||
},
|
||||
{
|
||||
"type": "minecraft:creeper",
|
||||
"maxCount": 4,
|
||||
"minCount": 4,
|
||||
"weight": 100
|
||||
},
|
||||
{
|
||||
"type": "minecraft:slime",
|
||||
"maxCount": 4,
|
||||
"minCount": 4,
|
||||
"weight": 100
|
||||
},
|
||||
{
|
||||
"type": "minecraft:enderman",
|
||||
"maxCount": 4,
|
||||
"minCount": 1,
|
||||
"weight": 10
|
||||
},
|
||||
{
|
||||
"type": "minecraft:witch",
|
||||
"maxCount": 1,
|
||||
"minCount": 1,
|
||||
"weight": 5
|
||||
}
|
||||
],
|
||||
"underground_water_creature": [
|
||||
{
|
||||
"type": "minecraft:glow_squid",
|
||||
"maxCount": 6,
|
||||
"minCount": 4,
|
||||
"weight": 10
|
||||
}
|
||||
],
|
||||
"water_ambient": [],
|
||||
"water_creature": []
|
||||
},
|
||||
"temperature": 2.0
|
||||
}
|
||||
|
|
@ -0,0 +1,147 @@
|
|||
{
|
||||
"attributes": {
|
||||
"minecraft:audio/background_music": {
|
||||
"default": {
|
||||
"max_delay": 24000,
|
||||
"min_delay": 12000,
|
||||
"sound": "minecraft:music.overworld.sulfur_caves"
|
||||
}
|
||||
},
|
||||
"minecraft:visual/fog_color": "#8cb831",
|
||||
"minecraft:visual/sky_color": "#78a7ff",
|
||||
"minecraft:visual/water_fog_color": "#17543c"
|
||||
},
|
||||
"carvers": [
|
||||
"minecraft:cave",
|
||||
"minecraft:cave_extra_underground",
|
||||
"minecraft:canyon"
|
||||
],
|
||||
"downfall": 0.4,
|
||||
"effects": {
|
||||
"grass_color": "#aba64f",
|
||||
"water_color": "#34bf89"
|
||||
},
|
||||
"features": [
|
||||
[],
|
||||
[
|
||||
"minecraft:lake_lava_underground",
|
||||
"minecraft:lake_lava_surface",
|
||||
"minecraft:rooted_sulfur_spring",
|
||||
"minecraft:sulfur_pool"
|
||||
],
|
||||
[
|
||||
"minecraft:amethyst_geode"
|
||||
],
|
||||
[
|
||||
"minecraft:monster_room",
|
||||
"minecraft:monster_room_deep"
|
||||
],
|
||||
[],
|
||||
[],
|
||||
[
|
||||
"minecraft:ore_dirt",
|
||||
"minecraft:ore_gravel",
|
||||
"minecraft:ore_granite_upper",
|
||||
"minecraft:ore_granite_lower",
|
||||
"minecraft:ore_diorite_upper",
|
||||
"minecraft:ore_diorite_lower",
|
||||
"minecraft:ore_andesite_upper",
|
||||
"minecraft:ore_andesite_lower",
|
||||
"minecraft:ore_tuff",
|
||||
"minecraft:underwater_magma",
|
||||
"minecraft:disk_sand",
|
||||
"minecraft:disk_clay",
|
||||
"minecraft:disk_gravel"
|
||||
],
|
||||
[
|
||||
"minecraft:sulfur_spike_cluster",
|
||||
"minecraft:sulfur_spike"
|
||||
],
|
||||
[
|
||||
"minecraft:spring_water",
|
||||
"minecraft:spring_lava"
|
||||
],
|
||||
[
|
||||
"minecraft:glow_lichen",
|
||||
"minecraft:patch_tall_grass_2"
|
||||
],
|
||||
[
|
||||
"minecraft:freeze_top_layer"
|
||||
]
|
||||
],
|
||||
"has_precipitation": true,
|
||||
"spawn_costs": {},
|
||||
"spawners": {
|
||||
"ambient": [
|
||||
{
|
||||
"type": "minecraft:bat",
|
||||
"maxCount": 8,
|
||||
"minCount": 8,
|
||||
"weight": 10
|
||||
}
|
||||
],
|
||||
"axolotls": [],
|
||||
"creature": [],
|
||||
"misc": [],
|
||||
"monster": [
|
||||
{
|
||||
"type": "minecraft:sulfur_cube",
|
||||
"maxCount": 4,
|
||||
"minCount": 2,
|
||||
"weight": 100
|
||||
},
|
||||
{
|
||||
"type": "minecraft:creeper",
|
||||
"maxCount": 2,
|
||||
"minCount": 2,
|
||||
"weight": 50
|
||||
},
|
||||
{
|
||||
"type": "minecraft:skeleton",
|
||||
"maxCount": 2,
|
||||
"minCount": 2,
|
||||
"weight": 50
|
||||
},
|
||||
{
|
||||
"type": "minecraft:slime",
|
||||
"maxCount": 1,
|
||||
"minCount": 1,
|
||||
"weight": 25
|
||||
},
|
||||
{
|
||||
"type": "minecraft:cave_spider",
|
||||
"maxCount": 1,
|
||||
"minCount": 1,
|
||||
"weight": 20
|
||||
},
|
||||
{
|
||||
"type": "minecraft:zombie",
|
||||
"maxCount": 2,
|
||||
"minCount": 2,
|
||||
"weight": 50
|
||||
},
|
||||
{
|
||||
"type": "minecraft:enderman",
|
||||
"maxCount": 1,
|
||||
"minCount": 1,
|
||||
"weight": 10
|
||||
},
|
||||
{
|
||||
"type": "minecraft:witch",
|
||||
"maxCount": 1,
|
||||
"minCount": 1,
|
||||
"weight": 1
|
||||
},
|
||||
{
|
||||
"type": "minecraft:zombie_villager",
|
||||
"maxCount": 1,
|
||||
"minCount": 1,
|
||||
"weight": 5
|
||||
}
|
||||
],
|
||||
"underground_water_creature": [],
|
||||
"water_ambient": [],
|
||||
"water_creature": []
|
||||
},
|
||||
"temperature": 0.8
|
||||
}
|
||||
|
|
@ -80,10 +80,10 @@ def state(unit):
|
|||
return service('show', unit, '--property=ActiveState', '--value')
|
||||
|
||||
|
||||
def verify_bundle(bundle, source):
|
||||
def verify_bundle(bundle, source, expected=ASSETS):
|
||||
rows = (bundle / 'SHA256SUMS').read_text().splitlines()
|
||||
sums = dict(row.split(' ', 1)[::-1] for row in rows)
|
||||
if not re.fullmatch(r'[0-9a-f]{40}', source) or len(rows) != len(ASSETS) or sums.keys() != ASSETS:
|
||||
if not re.fullmatch(r'[0-9a-f]{40}', source) or len(rows) != len(expected) or sums.keys() != expected:
|
||||
raise ValueError('Unexpected canonical artifact manifest')
|
||||
if any(fingerprint(bundle / name)[0] != digest for name, digest in sums.items()):
|
||||
raise ValueError('Canonical artifact checksum mismatch')
|
||||
|
|
@ -153,56 +153,63 @@ def run(planet, bundle, source, candidate, expected_candidate, apply, receipt):
|
|||
'chunkFileCount': len(chunk_files(dimension)), 'status': 'planned'}
|
||||
if not apply:
|
||||
return report
|
||||
with receipt.open('x') as stream, ExitStack() as stack:
|
||||
os.fchmod(stream.fileno(), 0o600)
|
||||
originals = {target: stage(target, target.read_bytes(), previous[target], stack) for target in targets}
|
||||
staged = {target: stage(target, candidate.read_bytes(), previous[target], stack)
|
||||
for target, candidate in targets.items()}
|
||||
if any(fingerprint(path) != previous[target] for target, path in originals.items()):
|
||||
raise ValueError('Previous bytes changed during staging')
|
||||
if any(fingerprint(path)[0] != report['incoming'][str(target)] for target, path in staged.items()):
|
||||
raise ValueError('Incoming bytes changed during staging')
|
||||
replaced, deleting = [], False
|
||||
try:
|
||||
service('stop', unit)
|
||||
if state(unit) not in {'inactive', 'failed'} or service('show', unit, '--property=MainPID', '--value') != '0':
|
||||
raise ValueError('Planet service failed to stop')
|
||||
if snapshot_server(root) != before or any(fingerprint(target) != value for target, value in previous.items()):
|
||||
raise ValueError('Protected server files changed during shutdown')
|
||||
if any(fingerprint(dimension / name) != value for name, value in identity.items()):
|
||||
raise ValueError('Primary seed or Paper identity changed during shutdown')
|
||||
exclusions = {pack, *originals.values(), *staged.values()}
|
||||
protected = world_snapshot(world, exclusions)
|
||||
chunks = chunk_files(dimension)
|
||||
for target, candidate in staged.items():
|
||||
os.replace(candidate, target)
|
||||
replaced.append(target)
|
||||
for file in chunks:
|
||||
file.unlink()
|
||||
deleting = True
|
||||
if world_snapshot(world, exclusions) != protected:
|
||||
raise ValueError('Protected world files changed before restart')
|
||||
expected_server = before
|
||||
expected_server['jars'][jar.name] = (report['incoming'][str(jar)], *previous[jar][1:])
|
||||
if snapshot_server(root) != expected_server or any(
|
||||
fingerprint(target) != (report['incoming'][str(target)], *previous[target][1:]) for target in targets):
|
||||
raise ValueError('Installed or retained bytes changed before restart')
|
||||
report['chunkFileCount'] = len(chunks)
|
||||
report['protectedWorldFileCount'] = len(protected)
|
||||
service('start', unit)
|
||||
report['status'] = 'start-accepted'
|
||||
except BaseException:
|
||||
report['status'] = 'needs-review' if deleting else 'aborted-before-world-reset'
|
||||
if not deleting:
|
||||
for target in reversed(replaced):
|
||||
os.replace(originals[target], target)
|
||||
if state(unit) in {'inactive', 'failed'}:
|
||||
service('start', unit)
|
||||
raise
|
||||
finally:
|
||||
json.dump(report, stream, indent=2)
|
||||
stream.write('\n')
|
||||
return report
|
||||
return apply_transition(root, world, dimension, unit, before, identity, previous, targets, report, receipt)
|
||||
|
||||
|
||||
def apply_transition(root, world, dimension, unit, before, identity, previous, targets, report, receipt):
|
||||
with receipt.open('x') as stream, ExitStack() as stack:
|
||||
os.fchmod(stream.fileno(), 0o600)
|
||||
originals = {target: stage(target, target.read_bytes(), previous[target], stack) for target in targets}
|
||||
staged = {target: stage(target, candidate.read_bytes(), previous[target], stack)
|
||||
for target, candidate in targets.items()}
|
||||
if any(fingerprint(path) != previous[target] for target, path in originals.items()):
|
||||
raise ValueError('Previous bytes changed during staging')
|
||||
if any(fingerprint(path)[0] != report['incoming'][str(target)] for target, path in staged.items()):
|
||||
raise ValueError('Incoming bytes changed during staging')
|
||||
replaced, deleting = [], False
|
||||
try:
|
||||
service('stop', unit)
|
||||
if state(unit) not in {'inactive', 'failed'} or service('show', unit, '--property=MainPID', '--value') != '0':
|
||||
raise ValueError('Planet service failed to stop')
|
||||
if snapshot_server(root) != before or any(fingerprint(target) != value for target, value in previous.items()):
|
||||
raise ValueError('Protected server files changed during shutdown')
|
||||
if any(fingerprint(dimension / name) != value for name, value in identity.items()):
|
||||
raise ValueError('Primary seed or Paper identity changed during shutdown')
|
||||
exclusions = {target for target in targets if target.is_relative_to(world)}
|
||||
exclusions.update(originals.values(), staged.values())
|
||||
protected = world_snapshot(world, exclusions)
|
||||
chunks = chunk_files(dimension)
|
||||
for target, candidate in staged.items():
|
||||
os.replace(candidate, target)
|
||||
replaced.append(target)
|
||||
for file in chunks:
|
||||
file.unlink()
|
||||
deleting = True
|
||||
if world_snapshot(world, exclusions) != protected:
|
||||
raise ValueError('Protected world files changed before restart')
|
||||
expected_server = before
|
||||
for target in targets:
|
||||
if target.parent == root / 'plugins':
|
||||
expected_server['jars'][target.name] = (report['incoming'][str(target)], *previous[target][1:])
|
||||
if snapshot_server(root) != expected_server or any(
|
||||
fingerprint(target) != (report['incoming'][str(target)], *previous[target][1:]) for target in targets):
|
||||
raise ValueError('Installed or retained bytes changed before restart')
|
||||
report['chunkFileCount'] = len(chunks)
|
||||
report['protectedWorldFileCount'] = len(protected)
|
||||
service('start', unit)
|
||||
report['status'] = 'start-accepted'
|
||||
except BaseException:
|
||||
report['status'] = 'needs-review' if deleting else 'aborted-before-world-reset'
|
||||
if not deleting:
|
||||
for target in reversed(replaced):
|
||||
os.replace(originals[target], target)
|
||||
if state(unit) in {'inactive', 'failed'}:
|
||||
service('start', unit)
|
||||
raise
|
||||
finally:
|
||||
json.dump(report, stream, indent=2)
|
||||
stream.write('\n')
|
||||
return report
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
93
tools/reset-sigma-ore-pack.py
Normal file
93
tools/reset-sigma-ore-pack.py
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
"""Complete the Sigma primary overworld ore palette without replacing Terrain."""
|
||||
|
||||
import argparse
|
||||
import importlib.util
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
import tempfile
|
||||
from zipfile import ZIP_DEFLATED, ZipFile, ZipInfo
|
||||
|
||||
from planet_ore_release import NATIVE_ORES, archive_names, sha
|
||||
|
||||
|
||||
spec = importlib.util.spec_from_file_location('reset_planet_ores', Path(__file__).with_name('reset-planet-ores.py'))
|
||||
reset = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(reset)
|
||||
|
||||
PLANET = 'sigma_draconis_iv'
|
||||
UNIT = f'dune-{PLANET}.service'
|
||||
TERRAIN = 'c1a564402a9cfea8be942d4945cdc55af36b7ffb441707ce683a177ab397494e'
|
||||
PACK = 'e44c703a480916190c9ce9c22d8c2a4bb03822e95cfb02cf85bc88e825e2f3a5'
|
||||
BIOMES = ('badlands.json', 'eroded_badlands.json', 'sulfur_caves.json')
|
||||
PATHS = {name: 'data/minecraft/worldgen/biome/' + name for name in BIOMES}
|
||||
ASSETS = {*BIOMES, 'planet_ore_release.py', 'reset-planet-ores.py', 'reset-sigma-ore-pack.py', 'SOURCE_COMMIT'}
|
||||
|
||||
|
||||
def build_pack(previous, bundle, output):
|
||||
if sha(previous) != PACK:
|
||||
raise ValueError('Expected the exact previously installed Sigma biome pack')
|
||||
features = {f'minecraft:ore_{name}' for name in NATIVE_ORES | {'gold_extra'}}
|
||||
with ZipFile(previous) as source:
|
||||
names = archive_names(source)
|
||||
if names.intersection(PATHS.values()):
|
||||
raise ValueError('Expected these three biome definitions to be new')
|
||||
with ZipFile(output, 'x', ZIP_DEFLATED) as result:
|
||||
for entry in source.infolist():
|
||||
result.writestr(entry, source.read(entry))
|
||||
for name, internal in PATHS.items():
|
||||
data = (bundle / name).read_bytes()
|
||||
biome = json.loads(data)
|
||||
if features.intersection(feature for layer in biome['features'] for feature in layer):
|
||||
raise ValueError(f'Native mineral feature remains in {name}')
|
||||
info = ZipInfo(internal)
|
||||
info.compress_type = ZIP_DEFLATED
|
||||
result.writestr(info, data)
|
||||
|
||||
|
||||
def run(bundle, source, apply, receipt):
|
||||
reset.verify_bundle(reset.checked(bundle), source, ASSETS)
|
||||
root = reset.checked(reset.ROOT / PLANET)
|
||||
if (reset.state(UNIT) != 'active' or
|
||||
reset.service('show', UNIT, '--property=WorkingDirectory', '--value') != str(root)):
|
||||
raise ValueError('Unexpected Sigma service or working directory')
|
||||
before = reset.snapshot_server(root)
|
||||
if (before['settings'].get('level-name') != PLANET or
|
||||
sum(details[0] == TERRAIN for details in before['jars'].values()) != 1):
|
||||
raise ValueError('Expected Sigma primary world and exact installed ore Terrain')
|
||||
if not re.search(rf'^\s+generator:\s*[\'\"]?DuneTerrain:{PLANET}[\'\"]?\s*$', (root / 'bukkit.yml').read_text(), re.M):
|
||||
raise ValueError('Expected the current Sigma DuneTerrain generator')
|
||||
world = reset.checked(root / PLANET)
|
||||
dimension = reset.checked(world / reset.DIMENSION)
|
||||
identity = {name: reset.fingerprint(dimension / name) for name in reset.IDENTITY}
|
||||
target = world / reset.PACK
|
||||
previous = {target: reset.fingerprint(target)}
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
candidate = Path(temp) / 'sigma-biomes.zip'
|
||||
build_pack(target, bundle, candidate)
|
||||
report = {'source': source, 'planet': PLANET, 'world': str(world), 'unit': UNIT,
|
||||
'identity': identity, 'incoming': {str(target): sha(candidate)},
|
||||
'chunkFileCount': len(reset.chunk_files(dimension)), 'status': 'planned'}
|
||||
if not apply:
|
||||
return report
|
||||
return reset.apply_transition(root, world, dimension, UNIT, before, identity, previous,
|
||||
{target: candidate}, report, receipt)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--bundle', required=True, type=Path)
|
||||
parser.add_argument('--expected-source', required=True)
|
||||
parser.add_argument('--apply-reset-no-backup', action='store_true')
|
||||
parser.add_argument('--receipt', type=Path)
|
||||
args = parser.parse_args()
|
||||
if args.apply_reset_no_backup != (args.receipt is not None):
|
||||
parser.error('An apply requires a new private receipt path')
|
||||
if args.apply_reset_no_backup:
|
||||
import fcntl
|
||||
with Path('/run/lock/dunerealms-planet-ore-reset.lock').open('a') as lock:
|
||||
fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||
result = run(args.bundle, args.expected_source, True, args.receipt)
|
||||
else:
|
||||
result = run(args.bundle, args.expected_source, False, None)
|
||||
print(json.dumps(result, indent=2))
|
||||
|
|
@ -1,15 +1,21 @@
|
|||
import importlib.util
|
||||
import json
|
||||
from pathlib import Path
|
||||
from shutil import copyfile
|
||||
from tempfile import TemporaryDirectory
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
from zipfile import ZipFile
|
||||
|
||||
from planet_ore_release import GENERATOR, PLANETS, SAMPLER, verify_terrain
|
||||
from planet_ore_release import GENERATOR, PLANETS, SAMPLER, sha, verify_terrain
|
||||
|
||||
|
||||
spec = importlib.util.spec_from_file_location('reset_planet_ores', Path(__file__).with_name('reset-planet-ores.py'))
|
||||
reset = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(reset)
|
||||
spec = importlib.util.spec_from_file_location('reset_sigma_ore_pack', Path(__file__).with_name('reset-sigma-ore-pack.py'))
|
||||
sigma = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(sigma)
|
||||
|
||||
|
||||
class PlanetOreReleaseTest(unittest.TestCase):
|
||||
|
|
@ -59,6 +65,24 @@ class PlanetOreReleaseTest(unittest.TestCase):
|
|||
self.assertEqual(set(PLANETS), {'arrakis', 'caladan', 'giedi_prime', 'kaitain', 'sigma_draconis_iv'})
|
||||
self.assertTrue(all(len(pin) == 64 for pin in PLANETS.values()))
|
||||
|
||||
def test_sigma_pack_adds_only_three_biomes_and_retains_sulfur_features(self):
|
||||
source = Path(__file__).resolve().parents[1] / 'DuneTerrain/planet-datapacks/sigma_draconis_iv'
|
||||
with TemporaryDirectory() as temp:
|
||||
folder = Path(temp)
|
||||
previous, candidate = folder / 'previous.zip', folder / 'candidate.zip'
|
||||
with ZipFile(previous, 'w') as archive:
|
||||
archive.writestr('existing.json', b'unchanged bytes')
|
||||
for name, internal in sigma.PATHS.items():
|
||||
copyfile(source / internal, folder / name)
|
||||
with patch.object(sigma, 'PACK', sha(previous)):
|
||||
sigma.build_pack(previous, folder, candidate)
|
||||
with ZipFile(candidate) as archive:
|
||||
self.assertEqual(set(archive.namelist()), {'existing.json', *sigma.PATHS.values()})
|
||||
self.assertEqual(archive.read('existing.json'), b'unchanged bytes')
|
||||
sulfur = json.loads(archive.read(sigma.PATHS['sulfur_caves.json']))
|
||||
features = {feature for layer in sulfur['features'] for feature in layer}
|
||||
self.assertTrue({'minecraft:rooted_sulfur_spring', 'minecraft:sulfur_spike', 'minecraft:sulfur_pool'} <= features)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff