Compare commits
19
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf327b75d4 | ||
|
|
8c90c61c53 | ||
|
|
9f82577927 | ||
|
|
79d3185cba | ||
|
|
ad234a808f | ||
|
|
392ade0b7e | ||
|
|
e7d1f298b9 | ||
|
|
27d7cba93f | ||
|
|
fbefb2e6d6 | ||
|
|
e654d565f6 | ||
|
|
c9d9dab1b5 | ||
|
|
a633d4cac9 | ||
|
|
d6e0c144d0 | ||
|
|
d462f01e2b | ||
|
|
bb63fab388 | ||
|
|
ae4c6200db | ||
|
|
0edac29dd8 | ||
|
|
2facf6f722 | ||
|
|
c23e72b8e6 |
@@ -15,3 +15,4 @@ screenshots/
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
__pycache__/
|
||||
|
||||
@@ -1,5 +1,90 @@
|
||||
# Changelog
|
||||
|
||||
## 0.1.0-alpha.30 — 2026-09-12
|
||||
|
||||
Trois zones de déformation 3D, plateaux naturels entre les massifs, grande rivière
|
||||
à niveaux locaux et brèches de berge de cinq blocs maximum laissant couler l’eau.
|
||||
Recherche des traversées mieux répartie, sanctuaire minéral avec seconde recherche
|
||||
sur les flancs, mines vanilla mieux admises. Les navires conservent leur modèle
|
||||
et leur placement proche du rivage. Nouveau monde de test nécessaire.
|
||||
Voir [la génération](docs/generation-alpha30.md) et [les essais](docs/testing-alpha30.md).
|
||||
|
||||
## 0.1.0-alpha.29 — 2026-09-12
|
||||
|
||||
Petites corniches variables sur le relief 3D de la28 ; correction des traversées
|
||||
et de l’admission des mines natives. Voir [le périmètre](docs/generation-alpha29.md)
|
||||
et [les essais](docs/testing-alpha29.md). Nouveau monde de test nécessaire.
|
||||
|
||||
## 0.1.0-alpha.28 — 2026-09-12
|
||||
|
||||
Spéléologie par bruits natifs, déformations volumiques 3D et failles obliques bornées ;
|
||||
bateaux rapprochés et îlots au-dessus de Sanctuary. Marais réduits. Mines,
|
||||
huttes et donjons vanilla adaptés aux souterrains ; filons natifs selon la
|
||||
profondeur dans la roche, dans l’île et les expansions. Nouveau monde de test.
|
||||
Voir [génération](docs/generation-alpha28.md) et [validation](docs/testing-alpha28.md).
|
||||
|
||||
## 0.1.0-alpha.27 — 2026-09-12
|
||||
|
||||
Retour à la base alpha.24 après rejet visuel de l’alpha.25. Le relief et les
|
||||
souterrains de la 24 sont conservés ; la montgolfière est retirée. Première
|
||||
passe limitée aux marais souterrains et à des épaves vanilla redressées
|
||||
et restaurées pour les navires marchands. Les nouvelles
|
||||
montagnes, cavités et garanties océaniques propres à la 25 ne sont pas reprises.
|
||||
Alpha.26 sautée ; essai sur nouveau monde, sans migration. Voir le
|
||||
[contrat alpha.27](docs/generation-alpha27.md) et les [vérifications](docs/testing-alpha27.md).
|
||||
|
||||
## 0.1.0-alpha.20 — 2026-09-10
|
||||
|
||||
- Passe architecturale sur les six bâtiments urbains, les quatorze anciennes
|
||||
infrastructures, les espaces publics et les réseaux souterrains. Palettes
|
||||
propres aux usages : chêne, bouleau, granit, diorite, andésite et tuf ;
|
||||
fondations maçonnées en briques de pierre conservées.
|
||||
- Angles coupés, baies en saillie, portiques, retraits, loggias, toitures
|
||||
nervurées et verrières avec passage lumineux. Sols et plafonds détaillés,
|
||||
corniches, encadrements, murets et blocs ciselés ; bordures de routes en
|
||||
briques de tuf et accents ciselés.
|
||||
- Vitres, barreaux, clôtures, murs bas et angles d’escaliers raccordés depuis
|
||||
la géométrie complète de chaque pièce avant son découpage entre chunks.
|
||||
- Nouveau codec `sanctuary:island_v20`, journal et pièces distincts. Les mondes
|
||||
19 et antérieurs gardent leurs rendus et futurs chunks. Les plans de terrain,
|
||||
d’hydrologie et d’implantation restent ceux de la génération précédente.
|
||||
Personnaliser conserve les trois tailles et les structures expérimentales.
|
||||
|
||||
`check build assemblePack` passe, avec huit GameTests généraux. Création et
|
||||
réouverture de la ville et des infrastructures passent ; les rapports 19 restent
|
||||
identiques aux témoins publiés. Option désactivée et Petit/graine42 passent.
|
||||
JAR, MRpack et ZIP Prism vérifiés ; release et canal packwiz publiés. Deux
|
||||
synchronisations isolées puis deux dans la même instance Prism passent, avec
|
||||
925 fichiers personnels et réglages suivis conservés.
|
||||
|
||||
Voir le [catalogue illustré](docs/architecture-alpha20.md) et les
|
||||
[vérifications et limites](docs/testing-alpha20.md). Les fonctions de la bêta
|
||||
restent à construire ; aucun nouveau système économique n’est activé.
|
||||
|
||||
## 0.1.0-alpha.19 — 2026-09-09
|
||||
|
||||
- Quatorze nouvelles infrastructures abandonnées sur l’île initiale, avec pièces,
|
||||
accès, mobilier, secrets et outils vanilla associés. La présence varie selon
|
||||
la graine et le relief ; les quatorze types ont été rencontrés en tests natifs.
|
||||
- Voies de fret aux rails incomplets et chemins entre destinations réelles.
|
||||
Le témoin Moyen, graine 0, contient treize lieux et sept liaisons, dont un
|
||||
fret de 499 blocs entre dépôt et pompage. Tracés enregistrés par chunk.
|
||||
- Option FR/EN « Structures expérimentales » dans le bouton natif Personnaliser,
|
||||
trois tailles conservées. Codec `sanctuary:island_v19` et journal 19 ; les
|
||||
anciens mondes gardent leurs plans et futurs chunks. Un nouveau monde avec
|
||||
l’option désactivée conserve le socle urbain sans les expériences 17/19.
|
||||
- Commande opérateur `/sanctuary structures` pour relever les entrées.
|
||||
La ville et ses sous-sols sont conservés ; les systèmes de la bêta restent
|
||||
à construire.
|
||||
|
||||
`check build assemblePack` passe, dont les huit GameTests généraux. Les trois
|
||||
formats sont vérifiés nativement ; le témoin moyen se rouvre avec ses 112 pièces,
|
||||
13 coffres, 68 cibles accessibles et la modification témoin. Les identités 17
|
||||
restent identiques à la release publiée. JAR, MRpack et ZIP Prism vérifiés ;
|
||||
release et canal packwiz publiés. Deux synchronisations isolées puis deux dans
|
||||
la même instance Prism passent, avec 767 fichiers personnels et réglages suivis
|
||||
conservés. Voir [les preuves et limites](docs/testing-alpha19.md).
|
||||
|
||||
## 0.1.0-alpha.17 — 2026-09-09
|
||||
|
||||
- Prototype de trois réseaux oubliés sur l’île initiale : mines et ateliers,
|
||||
|
||||
@@ -15,10 +15,199 @@ infrastructures qui permettront progressivement d'ouvrir de nouveaux continents.
|
||||
Ce dépôt démarre la nouvelle base Fabric. La [vision complète](docs/vision.md)
|
||||
conserve les intentions ; le [backlog](docs/backlog.md) suit les
|
||||
tickets. Les systèmes d’économie, de progression collective et les dimensions
|
||||
décrits dans la vision ne sont pas encore implémentés. **L’alpha.17 est publiée** :
|
||||
trois familles de réseaux oubliés expérimentaux rejoignent la ville et ses grands
|
||||
sous-sols sur les nouvelles îles de départ. Le canal packwiz et la même instance
|
||||
Prism sont à jour ; voir [Distribution](docs/packwiz.md).
|
||||
décrits dans la vision ne sont pas encore implémentés. **L’alpha.27 repart de
|
||||
l’alpha.24**, après le rejet du rendu de l’alpha.25. Cette première passe conserve
|
||||
le relief et les souterrains de la 24, retire la montgolfière et travaille les
|
||||
marais souterrains et la restauration de vrais modèles d’épaves vanilla. Voir le
|
||||
[chantier et ses limites](docs/generation-alpha27.md).
|
||||
|
||||
## Alpha.30 — plateaux, rivières ouvertes et traversées
|
||||
|
||||
La déformation 3D se concentre dans trois grandes zones ; les plateaux naturels
|
||||
reprennent leur place entre elles. Une rivière cherche un parcours à l’échelle
|
||||
de l’île. Des brèches courtes dans ses berges et celles des bassins laissent
|
||||
l’eau tomber sur les flancs ou dans le vide. Les traversées souterraines et
|
||||
le placement du sanctuaire minéral sont renforcés ; les navires restaurés
|
||||
restent proches des rivages.
|
||||
|
||||
Créer un **nouveau monde**. Voir [la génération](docs/generation-alpha30.md),
|
||||
[les essais et leurs limites](docs/testing-alpha30.md) et [packwiz](docs/packwiz.md).
|
||||
L’alpha.29 reste un point de reprise local non publié, intégré à cette livraison.
|
||||
|
||||
## Alpha.28 — grottes et lieux proches
|
||||
|
||||
Cette passe prolonge la 27 validée en jeu : bruits de grottes vanilla dans
|
||||
la roche, failles moins traversantes, reliefs déplacés et affaissés par du bruit 3D,
|
||||
bateaux près des berges et deux îlots au-dessus de Sanctuary. Les marais
|
||||
occupent moins de place. Mines, huttes et donjons vanilla bénéficient de
|
||||
contrôles adaptés aux cavités ; les filons suivent la profondeur de la masse
|
||||
rocheuse, y compris dans les expansions.
|
||||
|
||||
Créer un **nouveau monde**. Voir le [périmètre](docs/generation-alpha28.md),
|
||||
les [résultats effectivement vérifiés](docs/testing-alpha28.md) et la
|
||||
[distribution](docs/packwiz.md).
|
||||
|
||||
## Alpha.27 — retour au terrain de la 24
|
||||
|
||||
La base est le commit `e7d1f29`, sans les massifs coniques, chambres creusées
|
||||
et couches de planification de l’alpha.25. Les changements de relief seront
|
||||
repris séparément après un essai visuel. L’alpha.26 est sautée à la demande
|
||||
du créateur.
|
||||
|
||||
Les deux navires et les deux îlots restent présents, avec un seul îlot à
|
||||
cascade. Les marais occupent des volumes de biomes dans les cavités existantes,
|
||||
sans produire une nouvelle géométrie de grotte. Ce retour ne prétend pas
|
||||
remplacer le creusement Sanctuary par l’ensemble du moteur de grottes vanilla.
|
||||
|
||||
Créer un **nouveau monde Sanctuary** ; tailles 512 / 724 / 1 024 et Moyen par
|
||||
défaut conservés. Le codec de terrain reste `sanctuary:island_v24` dans ce
|
||||
prototype alpha.27 ; la reprise des anciennes sauvegardes n’est pas un objectif.
|
||||
La distribution et les vérifications effectuées sont détaillées dans
|
||||
[les essais alpha.27](docs/testing-alpha27.md) et [packwiz](docs/packwiz.md).
|
||||
|
||||
## Alpha.24 — les lieux suspendus
|
||||
|
||||
La nouvelle génération `sanctuary:island_v24` ajoute une montgolfière, deux
|
||||
navires marchands habités et deux îlots riches en minerais autour de Sanctuary.
|
||||
Les îlots reçoivent de l’herbe, des fleurs et des petits arbres ; exactement
|
||||
l’un des deux possède une cascade. Chaque lieu contient un coffre, enterré
|
||||
dans les îlots. Il faut construire pour les atteindre et ramener les villageois.
|
||||
|
||||
Les cinq emplacements sont réservés dès la création du monde, même avant leur
|
||||
exploration. Les expansions respectent ces réservations ; les anciennes
|
||||
sauvegardes gardent leur génération. Créer un **nouveau monde Sanctuary** pour
|
||||
les découvrir, avec les structures et l’option expérimentale activées.
|
||||
Les tailles 512 / 724 / 1 024 et le bouton natif **Personnaliser** restent
|
||||
inchangés. Voir [le contrat](docs/generation-alpha24.md) et
|
||||
[les vérifications](docs/testing-alpha24.md). Les quatorze scénarios de génération,
|
||||
les 24 GameTests généraux, `check build assemblePack` et le MRpack passent sur
|
||||
Mac. Le [MRpack alpha.24](https://git.botsu.net/koka/sanctuary-beta/releases/download/v0.1.0-alpha.24/Sanctuary-0.1.0-alpha.24.mrpack)
|
||||
est publié, le canal packwiz et la même instance Prism sont synchronisés. Les
|
||||
925 fichiers personnels et réglages suivis sont conservés. Les essais sont
|
||||
réalisés sur Mac ; aucun essai Windows natif n’est revendiqué.
|
||||
|
||||
## Alpha.23.1 — livraison locale vérifiée
|
||||
|
||||
Le [chantier de génération](docs/generation-alpha23.1.md) réunit le Blocodex, une
|
||||
île initiale naturelle avec quelques secrets, le sanctuaire minéral, les océans
|
||||
et le catalogue des structures vanilla. Chaque nouvelle expansion acceptée, avec
|
||||
les structures activées, prévoit au moins une structure adaptée avant sa réservation.
|
||||
Les familles absentes des régions entièrement vérifiées sont favorisées.
|
||||
|
||||
`check build`, `assemblePack`, les essais natifs et le MRpack passent sur Mac.
|
||||
Voir les [vérifications et limites](docs/testing-alpha23.1.md). Créer un nouveau
|
||||
monde Sanctuary pour `island_v23` ; les anciennes sauvegardes gardent leur génération.
|
||||
La publication séparée de l’alpha.23.1 était bloquée par les identifiants Git.
|
||||
Ce socle est désormais inclus dans l’alpha.24 publiée ci-dessus.
|
||||
|
||||
## Alpha.23 — Blocodex et socle commun de données, livraison locale
|
||||
|
||||
Le Blocodex fait partie de Sanctuary et s’ouvre avec **B**, touche modifiable
|
||||
dans les contrôles. Son catalogue permet de rechercher et filtrer les blocs
|
||||
inconnus, vus, minés, déjà possédés, jetés ou posés. Le stock actuellement porté
|
||||
est affiché séparément de la possession passée. Aucun objet ni permission
|
||||
opérateur n’est nécessaire.
|
||||
|
||||
La mémoire est personnelle et conservée côté serveur. Les compteurs de minage
|
||||
et de jet viennent des statistiques Minecraft ; les observations et poses
|
||||
commencent avec cette version. Les sauvegardes précédentes gardent leur terrain
|
||||
et leur génération.
|
||||
|
||||
Le socle commun ajoute la distribution du terrain chargé par dimension et
|
||||
chunk, ainsi que les quantités d’items dans les inventaires connectés, les
|
||||
conteneurs chargés et au sol. La couverture et l’actualité accompagnent chaque
|
||||
relevé ; les coffres dont le butin n’est pas encore généré restent intacts.
|
||||
Les opérateurs disposent de `/sanctuary census`. Palettes de structures,
|
||||
expansions et shop pourront réutiliser ces données côté serveur.
|
||||
|
||||
Des relevés par jour UTC des activités de minage, pose, ramassage, jet et
|
||||
fabrication conservent des périodes de
|
||||
l’histoire du serveur. Le [contrat Blocodex](docs/blocodex.md) précise les APIs,
|
||||
la persistance et les exclusions. Shop, ballast, Backrooms et leurs règles de
|
||||
progression restent à construire ; la direction narrative est conservée dans
|
||||
la [cosmologie](docs/cosmologie.md). Le Blocodex initial est désormais inclus dans l’alpha.24 publiée sur le
|
||||
canal packwiz. `check build assemblePack`, les 24 GameTests natifs et
|
||||
le client graphique connecté passent ; voir [les essais alpha.23](docs/testing-alpha23.md).
|
||||
|
||||
La suite est en [conception](docs/structures-conception.md) :
|
||||
départ naturel, quelques lieux isolés, fonctions reproductibles et donjon majeur
|
||||
à définir. Ce cahier accompagne la poursuite des systèmes après la génération ;
|
||||
l’alpha.24 est la livraison actuelle.
|
||||
|
||||
## Alpha.22 — trouver le bon terrain
|
||||
|
||||
La nouvelle génération préfère refuser une ville ou un bâtiment facultatif
|
||||
qui ne trouve pas un emplacement adapté. Plus de ville forcée sur une réserve
|
||||
artificielle ; moins de terrassement, des fondations proches de la roche et des
|
||||
chemins qui suivent le relief. La grande traversée et la salle d’expansion sont
|
||||
réservées en priorité et peuvent exister sans ville au-dessus. Les autres lieux
|
||||
n’ont pas de quota garanti.
|
||||
|
||||
Créer un **nouveau monde Sanctuary** pour utiliser ces règles. Les tailles
|
||||
512/724/1024 et le bouton natif **Personnaliser** restent inchangés ; les anciens
|
||||
mondes conservent leurs générateurs. La vision retient désormais **Minecraft
|
||||
comme archéologie d’un autre Minecraft** : chaque ruine témoigne d’une ancienne
|
||||
solution, et de ceux qui l’ont construite puis ont disparu.
|
||||
|
||||
Les trois tailles natives, la réouverture, le cas expérimental OFF et la
|
||||
compatibilité21 passent, ainsi que `check build assemblePack` et ses huit
|
||||
GameTests généraux. Le [MRpack alpha.22](https://git.botsu.net/koka/sanctuary-beta/releases/download/v0.1.0-alpha.22/Sanctuary-0.1.0-alpha.22.mrpack)
|
||||
est disponible, le canal packwiz et la même instance Prism sont synchronisés.
|
||||
Les925 fichiers personnels et réglages suivis sont conservés. Voir
|
||||
[la distribution](docs/packwiz.md).
|
||||
|
||||
## Alpha.21 — matériaux, quartiers et traversées
|
||||
|
||||
La ville revient à la pierre lisse, pierre, briques de pierre, andésite et chêne.
|
||||
Le tuf accompagne surtout les chemins et les sous-sols. Les toits et ornements
|
||||
sont raccordés à leurs appuis ; les pièces gardent leurs aménagements. La ville
|
||||
recherche des petits quartiers séparés par du terrain naturel, avec des chemins
|
||||
vers le cœur. Les lieux patrimoniaux recherchent davantage de raccords.
|
||||
|
||||
L’option expérimentale ajoute une recherche de galeries industrielles : chaussée
|
||||
cinq blocs, deux trottoirs, salles et escaliers de surface. Les placements sur
|
||||
pente sont assouplis et les destinations isolées sont prioritaires pour les chemins.
|
||||
Créer un **nouveau monde Sanctuary** pour ce générateur21. Les anciens mondes
|
||||
conservent leur génération. Les vérifications et coordonnées du
|
||||
témoin sont consignées dans [les essais](docs/testing-alpha21.md).
|
||||
|
||||
Le [MRpack alpha.21](https://git.botsu.net/koka/sanctuary-beta/releases/download/v0.1.0-alpha.21/Sanctuary-0.1.0-alpha.21.mrpack)
|
||||
est disponible. Le canal packwiz et la même instance Prism sont synchronisés ;
|
||||
les 925 fichiers personnels et réglages suivis sont conservés. Les tests de
|
||||
création/réouverture, le cas OFF et `check build assemblePack` passent.
|
||||
|
||||
## Alpha.20 — identité des bâtiments
|
||||
|
||||
La passe reprend les six bâtiments de ville, les quatorze infrastructures,
|
||||
les parcs et les sous-sols. Bois de chêne et de bouleau, granit, diorite et tuf
|
||||
identifient les usages ; biseaux, baies, corniches, portiques et verrières
|
||||
donnent du relief aux volumes. Les routes reçoivent des bordures de briques
|
||||
de tuf et des blocs ciselés. Les vitres et grilles se raccordent entre chunks.
|
||||
|
||||
Créer un **nouveau monde Sanctuary, Moyen, graine 0**, avec **Structures
|
||||
expérimentales** activées pour retrouver le témoin. Les anciens mondes gardent
|
||||
leur génération. Le bouton natif **Personnaliser** et ses trois tailles restent
|
||||
identiques. Voir le [catalogue illustré](docs/architecture-alpha20.md) et les
|
||||
[essais alpha.20](docs/testing-alpha20.md). `check build assemblePack`, les essais natifs et les artefacts sont vérifiés ;
|
||||
la [release](https://git.botsu.net/koka/sanctuary-beta/releases/tag/v0.1.0-alpha.20)
|
||||
et le canal packwiz sont publiés. La même instance Prism est synchronisée
|
||||
deux fois, avec 925 fichiers personnels et réglages suivis conservés.
|
||||
|
||||
## Alpha.19 — anciennes infrastructures
|
||||
|
||||
Le chantier ajoute une première passe des quatorze lieux du
|
||||
[catalogue](docs/structures-audit.md), avec leurs accès, des petits butins vanilla
|
||||
et des voies de fret ou chemins abandonnés entre destinations réelles.
|
||||
L’option **Structures expérimentales** reste enregistrée à la création du monde.
|
||||
La nouvelle génération garde les anciennes sauvegardes intactes. Aucun système
|
||||
de progression, mailbox, caméra ou réacteur n’est activé.
|
||||
Les trois tailles sont vérifiées en génération native ; création et réouverture
|
||||
conservent les structures et les coffres. `check build assemblePack` passe.
|
||||
Pour voir le grand fret : **Moyen, graine 0**, option activée ;
|
||||
`/sanctuary structures` liste les entrées. Voir [les preuves et la carte](docs/testing-alpha19.md).
|
||||
La [release alpha.19](https://git.botsu.net/koka/sanctuary-beta/releases/tag/v0.1.0-alpha.19)
|
||||
et le canal packwiz sont publiés. La même instance Prism est synchronisée deux
|
||||
fois, avec 767 fichiers personnels et réglages suivis conservés.
|
||||
|
||||
## Alpha.17 — prototype des réseaux oubliés
|
||||
|
||||
@@ -409,7 +598,7 @@ sera une mise à jour explicite, avec vérification des API et des sauvegardes.
|
||||
| Fabric API | 0.160.0+26.3 |
|
||||
| Fabric Loom | 1.17.20 |
|
||||
| Gradle Wrapper | 9.5.1, distribution vérifiée par SHA-256 |
|
||||
| Sanctuary / pack | 0.1.0-alpha.17 |
|
||||
| Sanctuary / pack | 0.1.0-alpha.29 |
|
||||
|
||||
Java 25 et Python 3.11 ou plus récent sont nécessaires. Le script pack utilise
|
||||
uniquement la bibliothèque standard et repère aussi une installation Python
|
||||
@@ -438,7 +627,7 @@ décrits dans [Validation](docs/testing.md).
|
||||
|
||||
Résultats :
|
||||
|
||||
- `mods/sanctuary/build/libs/sanctuary-0.1.0-alpha.17.jar` : mod à installer avec
|
||||
- `mods/sanctuary/build/libs/sanctuary-0.1.0-alpha.29.jar` : mod à installer avec
|
||||
Fabric API sur la version Minecraft indiquée.
|
||||
- `build/packwiz/` : pack de développement complet, avec le mod construit et
|
||||
l'index vérifié. Voir [Installation packwiz](packwiz/README.md).
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
# Architecture de l’alpha.20
|
||||
|
||||
Cette passe donne une identité visuelle aux lieux déjà planifiés : volumes,
|
||||
façades, sols, plafonds et mobilier. Elle réutilise les emprises et les accès
|
||||
certifiés des générations précédentes. Les bâtiments de ville et les sites
|
||||
expérimentaux restent inscrits dans leurs parcelles de 17 × 17 blocs ; leurs
|
||||
corniches et leurs retraits restent à l’intérieur de cette limite.
|
||||
|
||||
Les nouveaux rendus demandent un **nouveau monde de génération 20**. Les mondes
|
||||
19 et antérieurs conservent leurs bâtiments, y compris dans les futurs chunks.
|
||||
Le bouton **Personnaliser**, les trois tailles et l’option **Structures
|
||||
expérimentales** restent disponibles. Le catalogue n’impose pas que chaque lieu
|
||||
apparaisse sur chaque île.
|
||||
|
||||

|
||||
|
||||
*Vues des blocs réellement émis par les générateurs, affichés avec les modèles
|
||||
Minecraft, sans terrain. Ce montage est une prévisualisation géométrique, pas
|
||||
une capture du client en jeu ; il montre une sélection du catalogue.*
|
||||
|
||||
## Les six bâtiments de Lost City
|
||||
|
||||
Les étages conservent leurs plans alternés, leurs pièces et leurs escaliers.
|
||||
Les sanitaires sont clos, les lits adossés à de vrais murs, et les lampes
|
||||
reposent sur des blocs complets. Les aménagements de toit décrits ci-dessous
|
||||
possèdent des points d’accès vérifiés par le smoke du renderer.
|
||||
|
||||
| Fonction | Forme et façade | Espaces et détails construits |
|
||||
| --- | --- | --- |
|
||||
| Immeuble | Angles avant coupés, baies en saillie, montants de chêne écorcé et bandeaux de tuf. | Parquets alternant chêne et bouleau, logements avec cuisine et chambre ; jardinières, portique de bois et table sur le toit. |
|
||||
| Hôtel | Portique et travées encadrées de diorite polie, garde-corps et bandeaux en bouleau ; pavillon de toit en retrait. | Réception, chambres, salons, sanitaires et buanderie ; petit local de linge et bancs sur le toit. |
|
||||
| Bibliothèque | Grandes baies, angles coupés et lames verticales en bouleau écorcé ; lanterneau vitré avec ouverture à travers le toit et le plafond du dernier étage. | Rayonnages, archives, tables et lutrins ; sols délimitant les espaces de lecture et terrasse de lecture sur le toit. |
|
||||
| Restaurant | Encadrements de granit poli, vitrines et auvents associant chêne et bouleau. | Salles à manger et cuisines réparties par étage, garde-manger et sanitaires ; tables sur le toit et sorties d’extraction maçonnées. |
|
||||
| Caserne | Piles épaisses de briques de tuf, soubassements ciselés et fenêtres grillagées. | Dortoirs, bureau de service, réserves d’équipement et sanitaires ; cage d’escalier coiffée d’un pavillon accessible. |
|
||||
| Hall | Travées monumentales, piliers ciselés, corniches de diorite et fronton de toit en gradins. | Billetterie, bureaux, salle avec scène sur deux niveaux, galerie protégée, salles de réunion et archives. |
|
||||
|
||||
## Les quatorze anciennes infrastructures
|
||||
|
||||
Chaque site conserve ses seuils, son accès de service et son coffre de découverte.
|
||||
Les fonctions ci-dessous sont exprimées par les pièces et les blocs vanilla
|
||||
présents ; elles ne constituent pas de nouveaux systèmes de progression.
|
||||
|
||||
| Lieu | Architecture et usage visibles |
|
||||
| --- | --- |
|
||||
| Gare de fret | Halle aux angles coupés, lanterneau vitré et long auvent de quai en chêne ; voie, salle d’attente et petit bureau de signalisation. |
|
||||
| Poste et centre de tri | Façade de granit, accents de diorite et toiture en retrait ; guichet, rangées de tonneaux, passage de tri et bureau. |
|
||||
| Dépôt communal | Grand entrepôt nervuré de pierre, toiture industrielle à trois travées vitrées en dents de scie ; rails, chargement, caisses et mezzanine d’inventaire. |
|
||||
| Cartothèque d’expédition | Corps en bouleau, petites ailes différenciées et balcon arrière abrité ; table de cartographie, lutrin, archives et réserve. |
|
||||
| Observatoire et météo | Tour à pans coupés, contreforts de diorite et couronne ouverte portée par des nervures ; deux volées d’escalier, salle d’instruments et plateforme d’observation. |
|
||||
| Atelier ferroviaire | Large couverture à nervures et vitrages, piles de granit ; deux voies, fosse d’entretien avec escalier, établi, fourneau, meule et petite réserve. |
|
||||
| Station de pompage et château d’eau | Bâtiment bas, conduites figurées par des grilles et murets, cuve haute sur quatre piles ciselées ; galerie d’entretien et réserve sèche. L’eau reste dans la cuve. |
|
||||
| Sous-station | Cour clôturée, supports et grilles autour des équipements, locaux bas à toiture nervurée ; commandes vanilla et tranchée d’entretien accessible. |
|
||||
| Serre et graineterie | Verrière haute rythmée par des nervures de bouleau ; cultures, deux points d’irrigation contenus, allée de tuf et remise de rempotage. |
|
||||
| Quai sur le vide | Platelage en chêne, garde-corps à piliers sculptés, abris bas et grue de bois à chaîne ; attente, débarcadère et réserve. |
|
||||
| Relais radio et maison du gardien | Petite maison de chêne avec toiture à deux matières et cheminée ; antenne haute à traverses, plateforme accessible et chambre du gardien. |
|
||||
| Club photo et chambre noire | Façade claire de diorite, corniche sculptée et toiture arrière en retrait ; salle du club, chambre noire, bacs et espace de séchage à chaînes. |
|
||||
| Vestiaires et salles étranges | Entrée basse et étroite suivie d’une salle haute à colonnes répétées ; casiers, sols carrelés, alcôve et petite pièce de service. |
|
||||
| Refuge de chantier | Cabane surélevée sur piles ciselées, toiture inclinée et ossature inachevée ; couchage, établi, escalier extérieur et trappe avec échelle vers la réserve inférieure. |
|
||||
|
||||
Les voies de fret gardent leur ballast, leurs traverses, leurs courbes et leurs
|
||||
rails manquants. Les chemins reçoivent des bordures de briques de tuf et des
|
||||
accents ciselés ; leurs pentes et leurs destinations restent celles du plan
|
||||
sauvegardé.
|
||||
|
||||
## Espaces publics et équipements extérieurs
|
||||
|
||||
| Espace | Détails présents en génération 20 |
|
||||
| --- | --- |
|
||||
| Rues et ponts | Chaussée d’andésite polie, bordures de tuf poli, bandes de briques de tuf ponctuées de blocs ciselés ; marches sur les pentes, piles de garde-corps et grilles sur les ponts. Les tabliers n’ajoutent pas de colonnes vers le vide. |
|
||||
| Parc arboré | Allées en croix, bancs de chêne à accoudoirs minéraux, lampadaires et petite couronne de bouleau à côté des arbres existants. |
|
||||
| Jardin | Quatre parterres bordés de diorite, angles de tuf sculpté, portique de bois et promenade centrale. |
|
||||
| Aire de jeux | Bac à sable bordé de bouleau, portique de balançoire, plateforme de jeu avec marches et garde-corps, bancs et éclairage. |
|
||||
| Place | Sol organisé en couronnes de diorite, granit et tuf ; fontaine sèche à coupe basse et piédestal sculpté. |
|
||||
| Mémorial | Sol minéral à lignes de tuf, marches autour du socle, colonne mêlant tuf et briques de pierre sculptées. |
|
||||
| Marché | Croisement piéton, quatre étals avec pieds ciselés, poteaux de chêne et couvertures alternant dalles de chêne et de bouleau. |
|
||||
| Parking | Rampe et stationnements conservés ; piliers d’andésite, assises ciselées, bandeau en tuf, grilles de ventilation et lampes de plafond. Il reste enterré seulement lorsque le sol est certifié. |
|
||||
| Piscine extérieure | Bassin et marches immergées conservés, margelles de diorite, chaises longues et auvent de bouleau près des bacs de douche. |
|
||||
| Excavation | Escalier central vers la fosse, barrières, piles sculptées, poutre sur appuis, établi et meule ; le chantier reste limité à la roche certifiée. |
|
||||
|
||||
## Sous la ville et réseaux oubliés
|
||||
|
||||
| Ensemble | Traitement architectural |
|
||||
| --- | --- |
|
||||
| Grande piscine couverte | Bassin, escaliers et colonnade conservés ; parois de calcite, bandeaux de diorite, chapiteaux ciselés et nervures hautes répétées. |
|
||||
| Parkings souterrains | Plateformes et rampes conservées ; fondations maçonnées et bandeaux de tuf ponctués de motifs ciselés. |
|
||||
| Grande salle sèche | Boiseries de chêne, assises de tuf, murs clairs, corniches et bancs de chêne ; le socle central reste sans machine de progression. |
|
||||
| Égouts et sorties d’eau | Briques de tuf, motifs ciselés et corniches hautes ; les canaux, passerelles et écoulements existants sont conservés. |
|
||||
| Passages et accès | Liserés de granit ou de tuf, seuils et accès verticaux conservés. |
|
||||
| Mines, ateliers et réserves oubliés | Poutres de chêne, tuf, sols bordés de granit, établi et outillage vanilla ; rails, réserves et plateforme de travaux interrompus. |
|
||||
| Archives et salles étranges | Parquets de bouleau, boiseries, rayonnages ; ailleurs, carrelages de calcite et diorite, colonnes et niches répétées. |
|
||||
| Salles techniques oubliées | Nervures minérales, corniches et encadrements ciselés autour des seuils ; pompes figurées, grilles et postes de commande vanilla. |
|
||||
|
||||
## Matériaux et raccords
|
||||
|
||||
Les fondations des nouveaux bâtiments et chemins sont en **briques de pierre**.
|
||||
La stone et la smooth stone restent présentes ; l’andésite, la diorite et le
|
||||
granit différencient les sols et les usages. Le tuf existe brut, poli, en
|
||||
briques et sous ses deux formes ciselées. Les dalles, escaliers inversés,
|
||||
murets, grilles et trappes donnent de l’épaisseur aux corniches, aux appuis de
|
||||
fenêtre et aux équipements. Le chêne et le bouleau apparaissent comme poteaux,
|
||||
boiseries, parquets, charpentes et couvertures selon les lieux.
|
||||
|
||||
Le rendu 20 calcule les raccords des vitres, barreaux, clôtures, murets et
|
||||
angles d’escaliers à partir de tous les blocs de la pièce, après sa rotation
|
||||
et avant son découpage entre chunks. Une fenêtre peut ainsi rejoindre son
|
||||
véritable encadrement, même lorsque le chargement découpe le bâtiment.
|
||||
|
||||
Les smokes des bâtiments de ville et des espaces extérieurs passent, notamment
|
||||
pour les accès, les sanitaires, les lits, les lampes, les rampes et les bassins.
|
||||
Les essais natifs de création et de réouverture de la ville et des infrastructures
|
||||
passent ; leurs résultats et les contrôles de compatibilité sont suivis dans [les essais alpha.20](testing-alpha20.md).
|
||||
|
||||
Aucune caméra, mailbox, machine d’expansion ou production électrique dédiée
|
||||
n’est ajoutée par cette passe. Les meubles utilisables restent les blocs
|
||||
vanilla, et les butins de découverte restent partagés et non renouvelés.
|
||||
@@ -0,0 +1,24 @@
|
||||
# Alpha.21 — palettes et couvertures
|
||||
|
||||
La ville revient à une base commune : pierre lisse, pierre, briques de pierre,
|
||||
andésite et chêne. Les façades, seuils, corniches et verrières gardent leurs
|
||||
formes ; les pièces conservent leurs fonctions et leur circulation. La serre
|
||||
emploie le bouleau comme bois propre. Le tuf accompagne les routes et les
|
||||
parties souterraines.
|
||||
|
||||

|
||||
|
||||
Ces vues sont calculées depuis les blocs produits par les renderers21 et les
|
||||
modèles/textures de Minecraft 26.3-pre-2. Elles montrent des variantes choisies,
|
||||
sans terrain, éclairage ni végétation de la partie. Ce ne sont pas des captures
|
||||
du client et elles ne prouvent pas les raccords avec le relief.
|
||||
|
||||
Les couvertures de l’atelier, du dépôt, de la serre, du relais radio et du refuge
|
||||
reposent sur des murs ou charpentes. L’ancien plafond opaque sous leur nouvelle
|
||||
couverture est retiré. Les vérifications contrôlent aussi les petits appuis des
|
||||
excavations, piscines, rampes de garage et ornements.
|
||||
|
||||

|
||||
|
||||
La seconde planche coupe volontairement les murs pour voir les dessous des toits.
|
||||
Les détails de validation et la graine d’essai sont dans [le protocole](testing-alpha21.md).
|
||||
+260
-1
@@ -717,6 +717,190 @@ Aucune structure, règle de butin, version binaire ou instance Prism modifiée.
|
||||
La sélection des lieux et la réalisation des axes feront l’objet du chantier
|
||||
suivant ; ce catalogue n’est pas une liste d’ajouts tous validés.
|
||||
|
||||
### WG-22 — Anciennes infrastructures et liaisons — alpha.19
|
||||
|
||||
**Branche :** `codex/heritage-worldgen-alpha19`.
|
||||
|
||||
**Demande validée :** première passe de toutes les nouvelles structures du
|
||||
catalogue WG-21 et de leurs liaisons avant la bêta, en conservant la possibilité
|
||||
de revenir à une génération sans ce chantier.
|
||||
|
||||
- Ajouter les quatorze lieux avec architectures, entrées, pièces, mobilier et
|
||||
petits butins vanilla associés à leur usage. Présence selon le terrain ;
|
||||
relever les lieux réellement générés et donner les coordonnées des témoins.
|
||||
- Planifier des voies de fret et chemins entre destinations réelles, avec
|
||||
sections abandonnées lisibles, appuis et passages vérifiés. Rechercher les
|
||||
raccords aux anciennes installations dans un budget borné.
|
||||
- Garder une majorité naturelle à l’île ; conserver le terrain, l’hydrologie,
|
||||
la ville et les réseaux existants comme base. Première île uniquement.
|
||||
- Nouveau codec 19, option expérimentale sauvegardée à la création du monde.
|
||||
Option désactivée : socle urbain seul. Les mondes 17 et antérieurs gardent
|
||||
leur génération, leurs pièces et leurs futurs chunks. Aucune conversion,
|
||||
suppression de structures ou rétrogradation d’une sauvegarde 19.
|
||||
- Les bâtiments préparent les futurs services ; mailbox, deposit boxes,
|
||||
caméra, réacteur, progression et récompenses personnelles restent pour la
|
||||
bêta. Les coffres de cette passe sont partagés et utilisent du butin vanilla.
|
||||
- Vérifier créations/réouvertures, option désactivée, anciens mondes, supports,
|
||||
circulations et vrais placements. `check build assemblePack`, artefacts,
|
||||
publication packwiz et mise à jour de la même instance Prism.
|
||||
|
||||
**État : livré en alpha.19 ; code, artefacts et synchronisation Prism vérifiés.** Voir
|
||||
[les essais natifs et la carte des lieux](testing-alpha19.md). Version 19 demandée
|
||||
explicitement ; aucune version 18 publiée
|
||||
dans ce dépôt à l’ouverture du chantier. Le catalogue est maintenant accepté
|
||||
pour une première passe, sans imposer sa présence exhaustive sur chaque graine.
|
||||
|
||||
### WG-23 — Identité architecturale et blocs détaillés — alpha.20
|
||||
|
||||
**Branche :** `codex/architecture-alpha20`.
|
||||
|
||||
**Demande :** donner aux bâtiments une identité contemporaine lisible selon
|
||||
leur fonction, corriger les vitres isolées et détailler formes, façades et
|
||||
circulations. Employer du tuf, ses briques et variantes ciselées, du chêne,
|
||||
du bouleau, du granit, de la diorite et de l’andésite ; conserver les fondations
|
||||
en briques de pierre. Ajouter des blocs sculptés et du relief architectural.
|
||||
|
||||
- Reprendre les quatorze lieux expérimentaux, les bâtiments de Lost City,
|
||||
leurs espaces extérieurs et leurs sous-sols ; palettes par usage, volumes
|
||||
en retrait, biseaux, baies, corniches, liserés et mobilier adapté.
|
||||
- Résoudre les connexions des vitres, grilles, clôtures et murs ainsi que les
|
||||
angles d’escaliers depuis la géométrie complète, avant le découpage par chunk.
|
||||
- Dessiner les bordures de routes avec les briques de tuf et le tuf ciselé,
|
||||
en conservant la circulation et les tracés sauvegardés.
|
||||
- Garder les plans de placement et les emprises certifiées ; génération 20
|
||||
et types de pièces distincts. Les mondes 19 et antérieurs gardent leurs
|
||||
rendus, y compris dans les futurs chunks. Aucune rénovation rétroactive.
|
||||
- Garder le bouton natif Personnaliser, les trois tailles et l’option des
|
||||
structures expérimentales pour les nouveaux mondes.
|
||||
- Vérifier les états réels des blocs, les accès, les supports, les coffres,
|
||||
la création/réouverture et la compatibilité avec la version 19 publiée.
|
||||
Livrer le pack 20 par le canal stable et synchroniser la même instance Prism.
|
||||
|
||||
**État : livré en alpha.20 ; code, artefacts et même instance Prism vérifiés.** Voir
|
||||
[le contrat et les essais alpha.20](testing-alpha20.md).
|
||||
|
||||
### WG-24 — Palettes sobres, toits portés et galeries — alpha.21
|
||||
|
||||
**Branche :** `codex/palettes-reseaux-alpha21`.
|
||||
|
||||
Reprendre les extérieurs sans changer les plans intérieurs approuvés : smooth
|
||||
stone, stone brick, stone, andésite et chêne dominants en ville ; un bois cohérent
|
||||
par bâtiment unique et tuf surtout au sol et sous terre. Corriger les toits
|
||||
suspendus et les anciens plafonds superposés, avec appuis vérifiables.
|
||||
|
||||
Étendre la ville par au plus deux petits quartiers séparés de terrain naturel,
|
||||
reliés par des chemins praticables ; rapprocher les destinations patrimoniales
|
||||
par un graphe de chemins. Ajouter des galeries industrielles abandonnées :
|
||||
chaussée de cinq blocs, deux trottoirs, quelques grandes salles et deux accès
|
||||
par escaliers depuis la surface, en respectant les eaux et structures existantes.
|
||||
|
||||
Ajouter des fronts rocheux et de petits filons intacts dans les galeries et
|
||||
leurs salles de maintenance : ressources vanilla réellement minables, sans
|
||||
régénération de butin ni remplacement des blocs déjà extraits. Fournir un MRpack
|
||||
pour l’essai séparé demandé.
|
||||
|
||||
Assouplir les refus de placement : admettre les pentes, des volumes partiellement
|
||||
enfouis et des appuis adaptés ; rechercher des détours et prioriser les lieux
|
||||
isolés pour les chemins. Garder une ville fragmentée sans socle géant.
|
||||
|
||||
Nouvelle génération21 réservée aux nouveaux mondes ; tous les codecs et rendus
|
||||
20 et antérieurs restent disponibles. Tailles512/724/1024, Moyen par défaut ;
|
||||
option expérimentale enregistrée. Aucun monde personnel modifié. Vérifier les
|
||||
pièces natives, accès, connexions, supports, création/réouverture, ancien monde20,
|
||||
puis livrer le pack stable21 et synchroniser la même instance Prism.
|
||||
|
||||
**État : livré en alpha.21 ; MRpack, release et canal packwiz publiés, même instance Prism synchronisée deux fois. Tests, sauvegardes et limites documentés dans `docs/testing-alpha21.md`.**
|
||||
|
||||
### WG-25 — Placement sélectif et archéologie — alpha.22
|
||||
|
||||
**Branche :** `codex/placement-selectif-alpha22`.
|
||||
|
||||
Annule pour les nouveaux mondes l’assouplissement de WG-24. Chercher un terrain
|
||||
vraiment adapté et accepter l’absence d’une structure plutôt que de forcer son
|
||||
implantation. La ville ne reçoit plus de réservation artificielle de secours.
|
||||
Bâtiments et chemins limitent terrassement et remblai. Exception explicite :
|
||||
la grande traversée et la salle d’expansion sont des éléments de base, à placer
|
||||
en priorité indépendamment de la ville ; les égouts peuvent être ailleurs.
|
||||
Les galeries gardent leur génie civil et la salle reçoit un accès autonome.
|
||||
Les recherches restent bornées.
|
||||
|
||||
Conserver les palettes, les intérieurs, les filons et le rendu21. Nouveau codec22
|
||||
pour les nouveaux mondes, sans migration ni retouche des mondes précédents.
|
||||
Vérifier l’admission sur les bons terrains, les refus sur les mauvais, la création
|
||||
native, la réouverture et la compatibilité21. Livrer le MRpack et mettre à jour
|
||||
le canal et la même instance Prism en conservant les données personnelles.
|
||||
|
||||
Inscrire dans la vision « Minecraft comme archéologie d’un autre Minecraft » :
|
||||
chaque ruine garde la trace d’une solution ancienne. Les neuf personnages sont
|
||||
ceux nommés dans la vision ; la découverte et les rôles restent à définir.
|
||||
Ce cadre narratif ne constitue pas une nouvelle mécanique implémentée.
|
||||
|
||||
**État : livré en alpha.22 ; MRpack, release et canal packwiz publiés, même instance Prism synchronisée deux fois.** Voir [les essais22](testing-alpha22.md).
|
||||
|
||||
### WG-26 — Définir les lieux et leurs usages avant de reprendre le code
|
||||
|
||||
**Branche :** `codex/conception-territoire`.
|
||||
|
||||
Construire ensemble le [cahier de conception](structures-conception.md) de la
|
||||
prochaine organisation de Sanctuary Island. La direction retenue est un départ
|
||||
naturel, quelques lieux isolés et mystérieux, des fonctions reproductibles par
|
||||
les joueurs et un donjon majeur nécessaire à la progression. Villes,
|
||||
regroupements et autres structures restent en réserve. L’installation
|
||||
d’expansion peut être reconstruite ailleurs que dans la salle historique.
|
||||
|
||||
Le résultat attendu est une sélection précise, les règles d’implantation et de
|
||||
découverte, des fiches de lieux avec utilité et architecture, le rôle du boss et
|
||||
de son objet de quête, puis les besoins des machines qui déterminent la salle.
|
||||
Distinguer décisions retenues, propositions et questions ouvertes. La sélection
|
||||
actuelle et les principes sont consignés ; plans, nombres, distances, rencontres
|
||||
et règles de progression restent à définir.
|
||||
|
||||
**État : conception en discussion ; aucun code, nouveau binaire ou déploiement.**
|
||||
Ce ticket documentaire n’incrémente pas les versions et ne clôture pas les
|
||||
décisions encore ouvertes. Les critères de la prochaine implémentation seront
|
||||
établis à partir du cahier validé.
|
||||
|
||||
### META-01 — Blocodex natif et socle commun de données — alpha.23
|
||||
|
||||
**Branche :** `codex/blocodex-natif`.
|
||||
|
||||
**Demande :** intégrer à Sanctuary une connaissance des blocs inconnus, vus,
|
||||
minés, possédés, jetés et posés, puis la distribution du terrain et des stocks
|
||||
accessibles. Les palettes, expansions et shop futurs doivent consulter un socle
|
||||
commun, avec des périodes d’activité utilisables pour l’histoire du serveur.
|
||||
|
||||
- Mémoire personnelle par UUID et sauvegarde, commune aux dimensions ;
|
||||
états indépendants et stock porté distinct de la possession historique.
|
||||
- Minage et jet issus des statistiques vanilla ; suivi serveur des observations
|
||||
et poses réellement réussies. Pas d’inférence des poses depuis `used`.
|
||||
- Catalogue natif accessible sans item ni droit opérateur, recherche, filtres,
|
||||
pagination, aide FR/EN et touche configurable.
|
||||
- Service de lecture et notifications pour les futurs consommateurs ;
|
||||
aucune récompense ni restriction de recette ajoutée par ce ticket.
|
||||
- Sélection de palettes pour les futures structures : critères de connaissance
|
||||
combinables et familles de matériaux définies par tags, dont une base naturelle.
|
||||
- Terrain chargé par dimension et chunk : comptage progressif de 16 sections
|
||||
non vides par tick, couverture et actualité explicites, sans charger ni
|
||||
régénérer de chunk absent.
|
||||
- Stocks courants séparés entre joueurs connectés, conteneurs blocs,
|
||||
conteneurs entités et objets au sol. Tables de butin laissées intactes ;
|
||||
stocks hors couverture et contenus imbriqués explicitement exclus.
|
||||
- API commune `WorldCensusService` et diagnostics opérateur `/sanctuary census`.
|
||||
Le shop et les règles de consommation ou d’expansion ne sont pas activés.
|
||||
- Collecte datée : unités minées, posées, ramassées, jetées et
|
||||
fabriquées par jour UTC, avec persistance séparée et sauvegarde tous les
|
||||
600 ticks. Ni reconstruction rétroactive ni journal transactionnel de ballast.
|
||||
- Contrat additif de persistance v1 documenté dans [Blocodex](blocodex.md),
|
||||
conservation des identifiants et refus d’écraser une mémoire invalide.
|
||||
- Vérification des actions natives, de l’isolement des joueurs, de la persistance,
|
||||
du rendu et des messages réseau ; contrôle des catégories de stocks, des tables
|
||||
de butin et de la couverture du terrain ; `check build assemblePack`.
|
||||
|
||||
**État : Blocodex, recensements et relevés datés implémentés et vérifiés localement.
|
||||
Publication demandée, préparation des artefacts en cours.** `check build assemblePack`, les 24 GameTests natifs
|
||||
et le client graphique avec connexion réelle passent. Voir
|
||||
[les preuves alpha.23](testing-alpha23.md).
|
||||
|
||||
## Réserve de thèmes futurs
|
||||
|
||||
Ces thèmes servent à retrouver la vision, pas à demander leur implémentation immédiate. On en extrait un ticket seulement lorsqu'il devient utile au prochain incrément jouable.
|
||||
@@ -729,7 +913,7 @@ Ces thèmes servent à retrouver la vision, pas à demander leur implémentation
|
||||
| Économie | gemmes, mailbox, shop, offres horaires, bourse du navet (achat à la loterie du dimanche, revente au shop pendant la semaine), black market, catalogue, coffre-fort et drill |
|
||||
| Groupes et métiers | couleurs, équipes temporaires, factions et slots liés aux prestiges, cloches et bannières, villageois et copper golems |
|
||||
| Production et construction | convoyeurs, stockage, terminaux, ordinateur 8 bits, vein mining/building, plans et prefabs |
|
||||
| Dimensions | cavernes, Alpha, Backrooms, indoors, salles secrètes et récupération des objets perdus |
|
||||
| Dimensions et espaces | cavernes, Alpha ; Indoors artificiels intentionnels et référencés ; Backrooms orphelines liées à l’histoire économique, avec hébergement technique et récupération des objets perdus à articuler selon la [cosmologie](cosmologie.md) |
|
||||
| Faune et combats | zombies, fantômes, baleine, creepers, poules rares, Mooblooms, noms, armes et explosifs |
|
||||
| Mobilité | waystones, téléporteurs, ziplines, grappin, aéronefs, Magic Carpet et interactions physiques |
|
||||
| Temps et histoire | temps réel, calendrier, événements, loterie, étoiles, constellations, cube et sept boules |
|
||||
@@ -741,3 +925,78 @@ Ces thèmes servent à retrouver la vision, pas à demander leur implémentation
|
||||
## Définition pratique d'un ticket terminé
|
||||
|
||||
Un ticket contient un résultat observable, un périmètre limité et des critères d'acceptation vérifiables. Sa conclusion indique le comportement livré, la version testée, les vérifications réellement exécutées et les limitations qui subsistent. Les nouveaux besoins découverts deviennent de nouveaux tickets plutôt que des ajouts implicites à tous les systèmes.
|
||||
|
||||
### WG-27 — Île naturelle, sanctuaire minéral et structures natives — alpha.23.1
|
||||
|
||||
**Implémenté et vérifié localement.** Branche `codex/natural-secrets-alpha23`,
|
||||
depuis le Blocodex alpha.23. MRpack alpha.23.1 produit ; publication et
|
||||
synchronisation Prism en attente de l’accès Git.
|
||||
|
||||
Le [contrat](generation-alpha23.1.md) conserve les secrets, le hall et les voies,
|
||||
retire les bâtiments Sanctuary ordinaires de l’île initiale, introduit le
|
||||
sanctuaire minéral et les océans d’expansion. Le catalogue vanilla est conservé
|
||||
et étendu, avec registre persistant et priorités figées. Chaque expansion doit
|
||||
prévoir au moins une structure adaptée avant réservation, sans placement forcé.
|
||||
Deep Dark et cités anciennes attendent les Cavernes.
|
||||
|
||||
Les [preuves de validation](testing-alpha23.1.md) séparent intentions, tests
|
||||
exécutés et état de la distribution. Aucun boss, portail actif ou raid livré ici.
|
||||
|
||||
### WG-28 — Les lieux suspendus de Sanctuary — alpha.24
|
||||
|
||||
Branche `codex/aerial-sanctuary-alpha24`. [Contrat](generation-alpha24.md) :
|
||||
une montgolfière, deux navires avec villageois vanilla, deux îlots riches avec
|
||||
coffres enterrés et exactement une cascade. Sites planifiés avant expansion,
|
||||
réservations locales, vrais départs de structures dans le vide et scopes
|
||||
opérateur distincts. Les îlots ont une surface végétalisée, avec petits arbres,
|
||||
herbes et fleurs. [Validation](testing-alpha24.md) réussie sur Mac : 14 scénarios,
|
||||
écoulement et admission réels, 24 GameTests généraux, build et MRpack vérifiés.
|
||||
Release alpha.24 publiée ; canal packwiz et instance Prism existante
|
||||
synchronisés deux fois. Les 925 fichiers personnels et réglages suivis sont
|
||||
conservés. Aucun essai Windows natif revendiqué.
|
||||
|
||||
### WG-29 — Reprendre la génération par petits incréments — alpha.27
|
||||
|
||||
Branche `codex/reprise-sanctuary-alpha27`, directement depuis `e7d1f29` (alpha.24).
|
||||
La 25 est rejetée pour son rendu artificiel : les validations fonctionnelles ne
|
||||
validaient pas l’expérience visuelle attendue. Alpha.26 sautée.
|
||||
|
||||
Première passe : retrouver le terrain 24, enlever la montgolfière, proposer des
|
||||
marais volumétriques dans les cavités existantes et affiner les coques. Voir le
|
||||
[contrat](generation-alpha27.md). Les étagements, l’érosion, les nouvelles grottes
|
||||
et les petites sorties d’eau seront traités un à un, avec retour en jeu entre
|
||||
les changements ; ils ne sont pas déclarés implémentés dans cette passe.
|
||||
|
||||
|
||||
### WG-30 — Spéléologie, reliefs et satellites proches — alpha.28
|
||||
|
||||
Branche `codex/caves-relief-alpha28`, depuis la 27 validée visuellement par le
|
||||
créateur. Ajouter les bruits de grottes vanilla dans les masses rocheuses,
|
||||
limiter et incliner les failles, développer des hauteurs avec ridge/erosion,
|
||||
rapprocher les bateaux des vraies berges et placer les îlots au-dessus du terrain.
|
||||
Moins de marais ; mines, huttes et donjons vanilla adaptés aux cavités réelles.
|
||||
Les filons natifs doivent aussi alimenter les continents ouverts ensuite.
|
||||
Aucun retour des salles ellipsoïdales ni des cônes de l’alpha.25.
|
||||
Résultats et limites : [génération](generation-alpha28.md), [essais](testing-alpha28.md).
|
||||
|
||||
|
||||
### WG-31 — Corniches fines et traversées présentes — alpha.29
|
||||
|
||||
Branche `codex/terraces-transit-alpha29`, depuis l’alpha.28 validée en jeu
|
||||
sur Windows par le créateur. Reproduire la traversée manquante sur Grand,
|
||||
graine `-7228211907433324401`, corriger l’admission et la pose des modules.
|
||||
Ajouter un léger terracement variable au relief3D, préserver les profondeurs,
|
||||
et vérifier les véritables mines vanilla sur la graine signalée.
|
||||
Voir [génération](generation-alpha29.md) et [vérifications](testing-alpha29.md).
|
||||
|
||||
|
||||
### WG-32 — Dernière passe de terrain alpha — alpha.30
|
||||
|
||||
Branche `codex/terrain-finale-alpha30`, depuis le point de reprise local alpha.29
|
||||
`8c90c61`. Concentrer la déformation signée dans trois zones, retrouver les
|
||||
plateaux naturels entre elles et des rivières longues à niveaux locaux.
|
||||
Ouvrir des brèches de berge courtes pour laisser l’eau couler librement.
|
||||
Assurer une recherche mieux répartie des traversées, notamment en Grand ;
|
||||
chercher aussi le sanctuaire minéral sur les flancs en cas de refus intérieur.
|
||||
Conserver les bateaux proches, les cavités et les générateurs vanilla de la 28/29.
|
||||
Voir [le périmètre](generation-alpha30.md) et [les preuves](testing-alpha30.md).
|
||||
|
||||
@@ -0,0 +1,255 @@
|
||||
# Blocodex natif — connaissances, matière et stocks
|
||||
|
||||
Ticket META-01, branche `codex/blocodex-natif`, cible Minecraft **26.3-pre-2**.
|
||||
Le Blocodex appartient au mod Sanctuary. Il est disponible sans appareil,
|
||||
recette ni déblocage. La mémoire personnelle, le recensement du terrain et
|
||||
celui des stocks forment un socle commun aux futures palettes de structures,
|
||||
règles d’expansion et règles du shop. Les relevés datés ajoutent la temporalité
|
||||
nécessaire à une future lecture de l’histoire économique du serveur.
|
||||
|
||||
## Contrat des informations
|
||||
|
||||
La mémoire est personnelle : une identité de joueur (UUID), dans une sauvegarde
|
||||
de serveur, partagée entre ses dimensions. Les indicateurs sont indépendants.
|
||||
|
||||
| Information | Sens |
|
||||
| --- | --- |
|
||||
| Inconnu | Aucune observation, possession, pose ni statistique de minage ou de jet. C'est un état calculé, pas une étape enregistrée. |
|
||||
| Vu | Le premier bloc rencontré par le regard du joueur, à au plus 32 blocs, observé côté serveur tous les 5 ticks. Les obstacles arrêtent le rayon ; les chunks absents ne sont pas chargés. Ce relevé ne couvre pas chaque pixel du champ de vision. |
|
||||
| Miné | Compteur vanilla `mined` du bloc. Ses règles sont conservées : notamment pas de minage créatif, ni de minage sans l'outil requis. |
|
||||
| Déjà possédé | Le bloc, sous forme d'item, a été présent dans l'inventaire personnel ou sur le curseur d'un menu. Les statistiques vanilla de ramassage et de jet prouvent aussi une possession passée. |
|
||||
| Jeté | Compteur vanilla `dropped` de l'item du bloc. Il compte les unités volontairement jetées, pas les objets éjectés à la mort ni le butin produit par le bloc cassé. |
|
||||
| Posé | Nombre de placements réussis par le joueur avec un item de bloc, y compris en créatif. Une tentative refusée, une interaction ou un placement par commande ne compte pas. |
|
||||
| En inventaire | Quantité actuellement dans l'inventaire personnel, équipement et curseur compris. Les coffres ouverts, ender chests et contenus imbriqués des boîtes ne sont pas inclus. |
|
||||
|
||||
Les blocs sont identifiés par leur identifiant de registre ; les propriétés
|
||||
d'état (orientation, humidité, etc.) ne créent pas une nouvelle fiche. Deux
|
||||
identifiants restent distincts : une torche murale peut être vue et posée tandis
|
||||
que l'item possédé correspond à la torche debout. Les noms des blocs inconnus
|
||||
restent consultables, comme un catalogue ; cette version ne décide pas d'une
|
||||
politique de secrets ou de verrouillage des recettes.
|
||||
|
||||
L'inventaire est observé chaque tick serveur, après les transactions de menus
|
||||
et avant la consommation d'un item placé. Les statistiques de ramassage/jet
|
||||
complètent ce relevé. Une mutation d'inventaire entièrement réalisée entre ces
|
||||
points par un autre mod ne peut pas être reconstruite après coup.
|
||||
Les spectateurs ne découvrent pas de blocs par le regard.
|
||||
|
||||
## Persistance et arrivée dans une sauvegarde antérieure
|
||||
|
||||
Contrat additif v1 : fichiers `data/sanctuary-blocodex/<uuid>.json`, enveloppe
|
||||
avec `schema: 1` et UUID, puis observations, possessions et poses par identifiant.
|
||||
Les statistiques vanilla restent dans leurs propres fichiers et sont seulement
|
||||
lues. Aucune conversion du terrain, des paramètres de génération, des chunks,
|
||||
du journal d'expansion ou des statistiques existantes n'est effectuée.
|
||||
|
||||
Sans fichier Blocodex, les observations et poses commencent vides. Le minage,
|
||||
le jet et les preuves de possession sont disponibles depuis les statistiques
|
||||
vanilla déjà présentes. On n'invente pas les observations ni les poses passées
|
||||
à partir de `used`, qui compte aussi d'autres usages.
|
||||
|
||||
Les changements sont sauvegardés tous les 600 ticks, lors de la sauvegarde du
|
||||
serveur, à la déconnexion et à l'arrêt. Un crash peut perdre les dernières
|
||||
observations ou poses non sauvegardées. Un fichier invalide ou d'une version
|
||||
inconnue désactive la mémoire concernée et n'est jamais remplacé silencieusement.
|
||||
Les identifiants de mods absents sont conservés sur disque. Les anciennes
|
||||
versions de Sanctuary ignorent ce répertoire additionnel ; les poses réalisées
|
||||
pendant un retour à une ancienne version ne peuvent pas être récupérées.
|
||||
|
||||
## Réutilisation
|
||||
|
||||
`BlockKnowledgeService.knowledge(player, block)` et `snapshot(player)` renvoient
|
||||
des valeurs immuables calculées côté serveur. Le service expose aussi sa santé ;
|
||||
un consommateur doit refuser une condition de progression si la mémoire est
|
||||
indisponible, plutôt que d'interpréter une panne comme une découverte vierge.
|
||||
`BlockKnowledgeEvents.CHANGED` permet de réagir aux observations, possessions,
|
||||
poses et changements de statistiques. Les écouteurs s'exécutent sur le thread
|
||||
serveur ; ils ne constituent pas un journal transactionnel de récompenses.
|
||||
|
||||
Cette livraison ne verrouille aucune recette et n'accorde aucune récompense.
|
||||
Palettes disponibles, recherches, progression et structures pourront ensuite
|
||||
définir leurs propres conditions en utilisant cette API commune.
|
||||
|
||||
### Palettes de structures
|
||||
|
||||
`BlockKnowledgeService.palette(player, condition, tag)` croise les connaissances
|
||||
du joueur avec une famille de matériaux. Les critères `BlockKnowledgeFacet`
|
||||
sont combinables avec `and` et `or` : vus **ou** déjà possédés, minés **et**
|
||||
actuellement portés, etc. Le résultat immuable garde les identifiants triés et
|
||||
les quantités réellement portées.
|
||||
|
||||
```java
|
||||
var candidates = BlockKnowledgeService.palette(player,
|
||||
BlockKnowledgeFacet.SEEN.or(BlockKnowledgeFacet.POSSESSED),
|
||||
BlockKnowledgeService.NATURAL_STRUCTURE_MATERIALS);
|
||||
```
|
||||
|
||||
Le tag `sanctuary:structure_palette/natural` fournit une première famille de
|
||||
pierres, terres, bois, feuilles et autres matériaux naturels, modifiable par
|
||||
datapack. D'autres tags pourront définir des palettes minérales, végétales ou
|
||||
propres à un biome. Le choix des couleurs, les contraintes physiques des blocs,
|
||||
les quantités nécessaires et la construction de la structure appartiendront au
|
||||
moteur de structures : une sélection de palette ne réserve aucun stock et ne
|
||||
place aucun bloc.
|
||||
|
||||
## Recensement du terrain chargé
|
||||
|
||||
`TerrainCensus.snapshot(server)` expose une distribution des blocs par dimension ;
|
||||
`TerrainCensus.chunkSnapshot(level, pos)` fournit le détail d’un chunk déjà
|
||||
chargé. Ces lectures se font sur le thread serveur et renvoient des valeurs
|
||||
immuables. Elles parcourent les chunks `FULL` déjà accessibles, sans charger
|
||||
de chunk absent ni attendre la fin d’une génération.
|
||||
|
||||
Le comptage utilise les palettes des sections de 16 × 16 × 16 blocs. Il regroupe
|
||||
les orientations et autres propriétés sous l’identifiant du bloc. Les blocs
|
||||
d’air sont exclus ; l’eau et la lave conservent leurs identifiants de blocs.
|
||||
Le budget est de **16 sections non vides par tick serveur**, partagé entre les
|
||||
dimensions et les demandes du même tick. Une section entièrement vide est
|
||||
reconnue par ses métadonnées, sans parcourir sa palette.
|
||||
|
||||
Le relevé est progressif. Une section modifiée est retirée des totaux dès que
|
||||
sa révision change, puis remise dans la file de comptage. Les sections et
|
||||
chunks déchargés sortent du relevé. Un consommateur dispose, par dimension ou
|
||||
chunk, du nombre de sections chargées et comptées, du tick de capture, du tick
|
||||
du dernier comptage effectué et de l’âge de la plus ancienne attente.
|
||||
`complete()` et `coverage()` décrivent la couverture **des zones chargées**.
|
||||
Une couverture de 100 % ne signifie jamais que toute la sauvegarde a été lue.
|
||||
|
||||
Pendant un rattrapage, zéro bloc compté ne prouve donc pas l’absence de ce bloc.
|
||||
Les futures règles d’expansion devront fixer leur couverture minimale et leur
|
||||
zone d’étude avant de prendre une décision. Les résultats en mémoire sont
|
||||
reconstruits après redémarrage ; ce service n’écrit pas dans les chunks et ne
|
||||
modifie pas leur génération.
|
||||
|
||||
## Recensement des stocks présents
|
||||
|
||||
`StockCensus.snapshot(server)` photographie les objets accessibles au tick de
|
||||
la demande, sur le thread serveur. Le parcours des slots et des entités chargées
|
||||
est effectué à la demande ; aucun abonnement ne le relance à chaque tick.
|
||||
Les quantités sont des unités d’items, tous
|
||||
types confondus : un lingot, un outil ou une graine sont comptés même s’ils ne
|
||||
correspondent pas à un bloc. Les composants, l’usure et les enchantements ne
|
||||
créent pas de nouveaux identifiants de stock dans cette version.
|
||||
|
||||
| Catégorie | Couverture |
|
||||
| --- | --- |
|
||||
| `playerItems` | Joueurs connectés : inventaire personnel, équipement et curseur du menu. Le contenu du menu ouvert n’est pas additionné. |
|
||||
| `blockContainerItems` | Entités de blocs déjà instanciées dans les chunks chargés, qui exposent l’interface `Container` : coffres, hoppers, fours, pots décorés, etc. Chaque moitié d’un double coffre est comptée une fois. |
|
||||
| `entityContainerItems` | Entités chargées qui exposent `Container`, notamment les wagonnets et bateaux à coffre. |
|
||||
| `groundItems` | Quantités des `ItemEntity` chargées et encore présentes au sol. |
|
||||
|
||||
Le relevé ne déballe **aucune table de butin**. Tout conteneur dont la table
|
||||
reste à résoudre est ignoré avant la lecture de ses slots ; son existence
|
||||
augmente `pendingLootContainers`. Les entités de blocs encore stockées sous
|
||||
forme de NBT et non instanciées sont également laissées intactes, avec leur
|
||||
nombre dans `pendingBlockEntities`. Leur contenu n’est pas remplacé par une
|
||||
estimation.
|
||||
|
||||
La couverture exclut les joueurs hors ligne, les chunks et entités déchargés,
|
||||
les ender chests, le contenu imbriqué des shulker boxes et bundles, les grilles
|
||||
de fabrication en cours dans l’inventaire ou l’établi (`menuInputsIncluded()`
|
||||
est faux), les inventaires et équipements des créatures. Le résultat de
|
||||
fabrication affiché avant validation ne constitue pas un stock supplémentaire.
|
||||
Elle exclut aussi les objets internes
|
||||
des entités de blocs qui n’exposent pas `Container`, comme les aliments d’un feu
|
||||
de camp ou le livre d’un pupitre. Une shulker box portée compte comme un item ;
|
||||
une shulker box posée et chargée expose son conteneur. Les exclusions figurent
|
||||
dans le contrat de couverture ; `partial()` reste vrai.
|
||||
|
||||
Ce relevé indique où se trouvent les unités observées. Il ne les réserve pas,
|
||||
ne les transfère pas et n’évalue pas leur prix. Ajouter le terrain aux stocks
|
||||
ne donne pas une quantité immédiatement vendable : une roche dans un chunk
|
||||
reste différente d’un item dans un coffre.
|
||||
|
||||
## Consultation et futurs consommateurs communs
|
||||
|
||||
`WorldCensusService.capture(server)` rassemble les deux relevés pour une même
|
||||
lecture côté serveur. Le consommateur réutilise cet instantané pendant son
|
||||
calcul et conserve ses informations de couverture. Le shop et les expansions
|
||||
pourront ainsi consulter la même base, avec leurs propres règles de fraîcheur,
|
||||
de portée géographique, de prix, de consommation et de réservation.
|
||||
|
||||
Les diagnostics suivants sont réservés aux opérateurs :
|
||||
|
||||
```text
|
||||
/sanctuary census
|
||||
/sanctuary census block minecraft:stone
|
||||
/sanctuary census item minecraft:gold_ingot
|
||||
```
|
||||
|
||||
Le résumé présente la couverture du terrain par dimension, les quatre catégories
|
||||
de stocks et les conteneurs au butin encore indéterminé. Le Blocodex personnel
|
||||
accessible par **B** conserve les données du joueur ; ces diagnostics ne diffusent
|
||||
pas les inventaires agrégés aux autres joueurs.
|
||||
|
||||
## Relevés datés — portée de l’alpha.23
|
||||
|
||||
La collecte regroupe les activités observées par **jour civil UTC**, pour
|
||||
l’ensemble du serveur, sans attribution à un UUID ou à une dimension :
|
||||
|
||||
| Action | Registre et unité |
|
||||
| --- | --- |
|
||||
| `mined` | `block` : nombre de blocs minés, selon les règles des statistiques vanilla. |
|
||||
| `placed` | `block` : placements réussis par le joueur, créatif inclus et spectateurs exclus. |
|
||||
| `picked_up` | `item` : unités ramassées observées par les statistiques vanilla. |
|
||||
| `dropped` | `item` : unités volontairement jetées observées par les statistiques vanilla. |
|
||||
| `crafted` | `item` : unités fabriquées créditées au joueur par les statistiques vanilla. |
|
||||
|
||||
Chaque combinaison conserve son action, son registre, son identifiant et une
|
||||
quantité entière sur 64 bits, saturée à la valeur maximale en cas de dépassement.
|
||||
Un compteur de minage n’est pas transformé en nombre d’items produits. Les actions
|
||||
antérieures à l’installation ne sont pas réparties artificiellement entre des
|
||||
dates à partir des statistiques cumulées de Minecraft.
|
||||
|
||||
`MaterialActivityHistory.snapshot(server, day)` expose un instantané immuable
|
||||
avec le jour, les compteurs, `recorded` et `unsaved`. Un jour sans données
|
||||
enregistrées demeure inconnu ; il ne constitue pas un historique d’activité nulle.
|
||||
Les opérateurs peuvent consulter `/sanctuary history` ou préciser une date avec
|
||||
`/sanctuary history 2026-09-10`. La commande affiche au plus les 16 lignes aux
|
||||
quantités les plus élevées et indique combien ont été omises ; l’API conserve
|
||||
l’ensemble des compteurs du jour.
|
||||
|
||||
La persistance additionnelle utilise `data/sanctuary-activity/YYYY-MM-DD.json`,
|
||||
avec un schéma 1 et des dates UTC. Elle est séparée de la mémoire personnelle
|
||||
et des chunks. Les écritures ont lieu tous les **600 ticks**, à la sauvegarde
|
||||
et à l’arrêt du serveur, ainsi qu’au changement de jour observé par le service.
|
||||
Un crash peut perdre les derniers relevés non sauvegardés, soit normalement
|
||||
jusqu’à 30 secondes de jeu à 20 ticks par seconde. Le fichier conserve les
|
||||
identifiants de mods absents ; il refuse les schémas inconnus, doublons,
|
||||
compteurs invalides et changements externes. Une erreur arrête la collecte et
|
||||
rend le service indisponible jusqu’à réparation puis redémarrage, en conservant
|
||||
le fichier en cause. Les limites sont de 100 000 tuples et 16 Mio par jour.
|
||||
|
||||
Ces relevés permettent de distinguer des périodes d’activité. Ils ne conservent
|
||||
pas d’historique des instantanés de stocks, ne couvrent pas la fabrication automatique des
|
||||
machines et n’établissent ni consommation, ni perte, ni destination des objets.
|
||||
Ils ne retracent pas chaque transfert entre coffres ou chaque changement de propriétaire, et
|
||||
ne constituent pas un journal transactionnel d’achats, de récompenses ou de
|
||||
réservations. Le **ballast**, ses unités, ses conversions et sa traduction en
|
||||
géologie restent à concevoir dans le [cahier de cosmologie](cosmologie.md).
|
||||
Aucun objet n’est consommé et aucune Backroom n’est générée par ces mesures.
|
||||
|
||||
## Référence WSMC retrouvée
|
||||
|
||||
La recherche locale a retrouvé une partie du travail précédent dans
|
||||
`/Users/koka/Documents/sanctuary/Gameplay/blocodex` :
|
||||
`ClientVoxelProjectBuilder` convertit des apparences de blocs et d’items en
|
||||
volumes/couches de blocs ; `BlocodexStudioPalettes` sélectionne des matériaux
|
||||
opaques appris. Le projet conserve aussi un instantané WSMC de 1 881 entrées
|
||||
(1 168 blocs, 490 items, 223 mobs), issu de Minecraft 1.21.11.
|
||||
|
||||
Cette référence reste historique. La nouvelle API fournit la connaissance et
|
||||
les candidats de palette ; la traduction de modèles d’entités en structures
|
||||
(visage de creeper, squelette géant, etc.) reste un chantier distinct. Aucun
|
||||
générateur d’entités ni import de ce snapshot ancien n’est ajouté au registre
|
||||
de Minecraft 26.3 par le socle méta.
|
||||
|
||||
## Validation
|
||||
|
||||
Validation locale du 10 septembre 2026 : `./gradlew check build assemblePack`
|
||||
passe, avec **24 GameTests natifs réussis**. Le client graphique vérifie les
|
||||
widgets et les messages réels dans un nouveau monde intégré, avec B sans droit
|
||||
opérateur, observation serveur et possession conservée après retrait du stock.
|
||||
Les tests de stockage passent. Les [preuves et limites](testing-alpha23.md)
|
||||
détaillent le protocole, l’artefact et son empreinte. Alpha.23 assemblée localement ;
|
||||
publication du MRpack et mise à jour du canal demandées, en préparation.
|
||||
@@ -0,0 +1,275 @@
|
||||
# Sanctuary — matière, espaces et mémoire
|
||||
|
||||
**Cahier de conception issu du texte de l’auteur.** Il prolonge
|
||||
[la vision](vision.md) et [la conception des lieux](structures-conception.md).
|
||||
Les citations conservent les formulations fournies ; les points à préciser
|
||||
sont identifiés comme tels. Ce document ne livre aucun générateur ni système
|
||||
économique. **Backrooms, Indoors, shop et ballast ne sont pas implémentés.**
|
||||
Le Blocodex natif de l’alpha.23 locale fournit un premier socle de données
|
||||
pour des mécaniques futures, avec les limites décrites dans [son contrat](blocodex.md).
|
||||
|
||||
## Minecraft comme archéologie d’un autre Minecraft
|
||||
|
||||
Steve, Ari, Sunny, Kai, Zuri, Alex, Mefe, Makena et Noor sont les neuf personnages
|
||||
disparus de la partie. Ils ont découvert quelque chose de révolutionnaire et ont
|
||||
continué parce que ça marchait. Jusqu’au moment où ça n’a plus marché.
|
||||
|
||||
> Ils n’ont pas ouvert quelque chose qu’ils n’auraient pas dû ouvrir. Ils ont
|
||||
> construit quelque chose qu’ils ne savaient plus refermer.
|
||||
|
||||
L’histoire part de quelque chose qui a fonctionné : des besoins satisfaits, des
|
||||
lieux devenus utilisables, des opérations répétées et des installations agrandies.
|
||||
Une ruine doit permettre de retrouver cette ancienne solution. Ses circulations,
|
||||
ses raccords, ses réparations et ses extensions racontent un fonctionnement avant
|
||||
de raconter son interruption.
|
||||
|
||||
> Chaque ruine de sanctuary doit être une trace d’une ancienne solution pas
|
||||
> seulement la trace d’un problème.
|
||||
|
||||
La découverte précise, la succession des expériences et les rôles des neuf
|
||||
personnages restent à écrire. Aucun métier, aucune responsabilité individuelle
|
||||
ni cause définitive de leur disparition ne leur sont attribués ici. On conserve
|
||||
en particulier **Mefe**, tel que nommé par l’auteur. Il n’est pas décidé que
|
||||
chacun possède un bâtiment, une machine, une gemme ou une quête correspondante.
|
||||
|
||||
## Deux devenirs de la même technologie
|
||||
|
||||
Les Indoors et les Backrooms appartiennent à la même logique de fabrication des
|
||||
espaces. Ce qui les distingue est leur relation à une intention et à une
|
||||
référence : sait-on encore pourquoi cet espace existe et comment le retrouver ?
|
||||
|
||||
| Espace | Direction donnée par l’auteur | Conséquence pour la conception |
|
||||
| --- | --- | --- |
|
||||
| **Indoor** | « espace artificiel référencé et contrôlé » | Un intérieur est produit intentionnellement et reste associé à son accès et à son usage. Une porte peut mener à un espace dix fois plus grand que le bâtiment extérieur. |
|
||||
| **Backroom** | « espace artificiel orphelin » | Un espace demeure alors que sa destination ou sa raison d’être a disparu. Sa forme peut conserver les restes d’une fonction sans retrouver l’ensemble auquel elle appartenait. |
|
||||
|
||||
L’auteur décrit chaque Indoor comme une petite dimension instanciée. Les
|
||||
computers utilisent **probablement** cette technologie pour leurs expériences :
|
||||
cette relation est une piste forte, sans avoir encore de protocole ni de machine
|
||||
définitivement assignée.
|
||||
|
||||
Les Backrooms, dans cette cosmologie, ne sont pas une destination demandée au
|
||||
même titre qu’un monde. Elles sont ce que la machine produit lorsqu’elle ne sait
|
||||
pas où mettre quelque chose :
|
||||
|
||||
- un espace généré puis annulé ;
|
||||
- une expérience interrompue ;
|
||||
- deux règles demandant deux états incompatibles ;
|
||||
- une room qui n’est plus référencée ;
|
||||
- une coordonnée qu’aucun monde ne revendique.
|
||||
|
||||
> La machine ne détruit pas parfaitement les espaces. Elle les laisse derrière.
|
||||
> Backrooms.
|
||||
|
||||
L’image du « garbage collector raté de Minecraft » exprime cette accumulation.
|
||||
L’arborescence proposée par l’auteur la représente ainsi :
|
||||
|
||||
```text
|
||||
WORLD
|
||||
├── overworld
|
||||
├── caverns
|
||||
├── nether
|
||||
├── end
|
||||
├── sanctuary
|
||||
└── /unreferenced/
|
||||
└── backrooms
|
||||
```
|
||||
|
||||
C’est une représentation narrative, pas une arborescence de fichiers ni la
|
||||
liste des dimensions actuellement enregistrées par le mod. **L’espace orphelin
|
||||
est une fiction à mettre en scène.** Une réalisation Minecraft devra conserver
|
||||
des espaces correctement sauvegardés, identifiés et référencés côté serveur.
|
||||
Le choix entre dimensions techniques et régions d’un espace partagé reste à
|
||||
concevoir. Rien ici ne prévoit de perdre de vraies références de sauvegarde,
|
||||
de supprimer des chunks ou de provoquer leur corruption pour obtenir cet effet.
|
||||
|
||||
## De la matière sans contexte
|
||||
|
||||
Le système reçoit des matériaux et tente de les réorganiser en espace valide :
|
||||
|
||||
```text
|
||||
stone stone dirt copper oak_planks iron stone glass ...
|
||||
```
|
||||
|
||||
Il possède de la matière, mais aucune destination n’a été demandée. Il tente
|
||||
alors de l’encoder sous forme de chunks : un couloir, une salle, encore une
|
||||
salle, un plafond, une porte donnant sur rien, une plomberie sans bâtiment,
|
||||
un entrepôt infini.
|
||||
|
||||
> Les Backrooms sont la tentative du générateur de Minecraft de faire quelque
|
||||
> chose avec de la matière sans contexte.
|
||||
|
||||
La **matière** donne une palette et une présence physique. Le **contexte** lui
|
||||
donnait un usage, des dimensions, des voisins, un accès ou une destination.
|
||||
Cette distinction permet de dessiner un lieu dont les parties sont intelligibles
|
||||
alors que leur assemblage ne retrouve plus son intention : une plomberie garde
|
||||
sa logique de raccord, mais le bâtiment qu’elle devait desservir n’est plus là.
|
||||
Elle ne justifie pas de remplacer la conception par des blocs placés au hasard.
|
||||
|
||||
Il reste à définir ce que la machine conserve de ce contexte : seulement les
|
||||
matériaux, des fragments de plans, des types de pièces, des relations entre
|
||||
espaces ou des traces d’opérations. Aucun catalogue de rooms ni algorithme de
|
||||
recomposition n’est arrêté. Les palettes limitées et le futur moteur de
|
||||
traduction en structures peuvent servir cette direction ; le moteur n’est pas
|
||||
créé par ce document.
|
||||
|
||||
## Le ballast de l’économie
|
||||
|
||||
La direction fournie relie directement cette cosmologie aux actions des joueurs.
|
||||
Utiliser le shop, téléporter, ouvrir des Indoors, déplacer de la matière ou
|
||||
expandre le monde produit du **ballast**. Plus ces opérations se multiplient,
|
||||
plus les Backrooms se remplissent. Elles deviennent l’externalité du système
|
||||
économique de Sanctuary : une activité visible laisse ailleurs des conséquences
|
||||
que ses utilisateurs pourront découvrir beaucoup plus tard.
|
||||
|
||||
Le ballast relie donc production, échanges et géographie. Un objet déplacé ne
|
||||
change pas seulement de propriétaire ou de position dans cette vision ; son
|
||||
passage par ces technologies peut laisser une empreinte dans le monde.
|
||||
La forme de cette empreinte reste à décider pour chaque opération.
|
||||
|
||||
| Opération envisagée | Articulation à définir avant de l’implémenter |
|
||||
| --- | --- |
|
||||
| Shop et échanges | Quel événement produit du ballast : vente, achat, consommation par un service, autre opération ? Quelle matière lui correspond et à quel moment l’échange est-il terminé ? |
|
||||
| Téléportation | Que laisse le déplacement : trace de matière transportée, coût matériel ou autre résidu à choisir ? Les types de téléportation partagent-ils cette règle ? |
|
||||
| Ouverture d’un Indoor | Que produit la création d’un espace contrôlé ? Que deviennent ensuite une fermeture, un transfert d’accès ou une expérience interrompue ? |
|
||||
| Déplacement de matière | Quelles opérations participent à cette économie ? Un transport manuel, un convoyeur, un stockage ou une transformation ne sont pas encore déclarés équivalents. |
|
||||
| Expansion | Comment la préparation et la création d’un continent se rattachent-elles aux matériaux engagés et aux espaces laissés derrière ? |
|
||||
|
||||
« Ballast » ne fixe pas encore une quantité, une unité, un coût ou une monnaie.
|
||||
Il faut notamment décider s’il représente une matière effectivement retirée,
|
||||
une trace de son traitement ou les deux selon les opérations. Aucun taux de
|
||||
conversion ni conservation quantitative stricte n’est établi. Le document
|
||||
n’autorise donc pas à prélever des objets dans les inventaires ou à les dupliquer
|
||||
dans des coffres au nom de cette cosmologie.
|
||||
|
||||
## Lire l’histoire économique dans la géologie
|
||||
|
||||
La génération doit dépendre du comportement réel des joueurs. L’auteur donne
|
||||
trois exemples qui fixent la direction sans constituer des recettes de génération :
|
||||
|
||||
| Histoire du serveur | Trace possible dans les Backrooms |
|
||||
| --- | --- |
|
||||
| Le serveur consomme énormément de pierre. | Les premières couches deviennent minérales. |
|
||||
| Une phase d’industrialisation utilise beaucoup de cuivre. | Des zones techniques apparaissent. |
|
||||
| Des tonnes de bois sont sacrifiées. | Un gigantesque Indoor abandonné peut émerger. |
|
||||
|
||||
Des mois après, les joueurs peuvent descendre et reconnaître dans les lieux
|
||||
traversés une période de l’histoire du serveur. Le choix des matériaux doit
|
||||
pouvoir conserver une différence entre une phase minérale, une phase industrielle
|
||||
et d’autres formes de production, au lieu de tout réduire à la dernière palette
|
||||
dominante.
|
||||
|
||||
Cette intention demande une temporalité explicite. Deux histoires se rencontrent :
|
||||
celle des neuf personnages, antérieure à l’arrivée des joueurs, et celle que le
|
||||
serveur écrit pendant la partie. La première fournit les vestiges d’un autre
|
||||
Minecraft ; la seconde peut produire de nouveaux dépôts et de nouvelles traces.
|
||||
La présence de strates initiales issues de l’ancienne partie, leur contenu et
|
||||
leur articulation avec les apports actuels restent à décider.
|
||||
|
||||
Il faut encore choisir la durée des périodes observées, ce qui forme un dépôt,
|
||||
le moment où un dépôt devient un lieu et la manière dont les périodes se
|
||||
succèdent dans l’espace. Une couche n’est pas nécessairement un niveau vertical :
|
||||
la géographie de cette chronologie reste à dessiner. La règle devra préserver
|
||||
les espaces déjà visités et construits ; changer les statistiques actuelles ne
|
||||
doit pas devenir une régénération implicite d’anciens chunks.
|
||||
|
||||
## Ce que le socle méta peut fournir
|
||||
|
||||
Le Blocodex appartient à Sanctuary et peut être consulté par plusieurs mécaniques.
|
||||
Il distingue actuellement connaissance, observation, minage, possession passée,
|
||||
jet, pose et stock porté. Les critères de connaissance et les familles de
|
||||
matériaux peuvent aider un futur moteur à constituer une palette utilisable.
|
||||
|
||||
Ces informations personnelles ne suffisent cependant pas à décrire l’histoire économique :
|
||||
|
||||
- **miné** ne veut pas dire consommé par le shop ou engagé dans une machine ;
|
||||
- **jeté** compte les jets volontaires vanilla, pas les objets brûlés ou perdus
|
||||
dans le vide ;
|
||||
- **déjà possédé** est une preuve persistante, pas un stock encore disponible ;
|
||||
- **posé** ne fournit pas à lui seul le plan d’une construction ni sa date ;
|
||||
- le stock personnel ne recense pas tous les coffres et réseaux du serveur.
|
||||
|
||||
Le socle méta distingue maintenant trois relevés :
|
||||
|
||||
| Relevé | Ce qu’il permet de connaître |
|
||||
| --- | --- |
|
||||
| Mémoire personnelle | Ce qu’un joueur a vu, miné, possédé, jeté ou posé ; des critères pour ses palettes. |
|
||||
| Distribution actuelle | Les blocs du terrain chargé et les stocks accessibles, comptés séparément avec leur couverture. |
|
||||
| Activité datée du serveur | Les quantités minées, posées, ramassées, jetées et fabriquées, agrégées par jour UTC depuis l’installation. |
|
||||
|
||||
Le troisième relevé conserve une trace des périodes d’activité après le
|
||||
déplacement des stocks. Il peut montrer une période de minage intense de cuivre,
|
||||
mais ne prouve pas que ce cuivre a été sacrifié à une machine. Il ne reconstruit
|
||||
pas les mois précédant son installation et ne calcule aucun ballast. Les limites
|
||||
de persistance et de couverture figurent dans le [contrat méta](blocodex.md).
|
||||
|
||||
Avant la génération historique, il faudra donc définir quels faits les systèmes
|
||||
économiques enregistrent : action réalisée, matériau, quantité, moment ou période,
|
||||
origine et destination utiles à cette action. Leur traitement devra distinguer
|
||||
une opération terminée d’une tentative refusée et éviter de compter plusieurs
|
||||
fois la même opération après reprise. La granularité, la conservation et le
|
||||
format de ces transactions restent à concevoir dans un contrat propre. Les
|
||||
agrégats journaliers déjà disponibles ne sont pas un journal transactionnel :
|
||||
ils ne doivent autoriser ni prélèvement, ni récompense, ni restitution d’objet.
|
||||
|
||||
## Machines, références et anciennes solutions
|
||||
|
||||
Les computers pourraient expérimenter dans les Indoors parce qu’ils offrent
|
||||
des espaces contrôlés. Il reste à préciser ce qu’ils demandent à un espace et
|
||||
comment cette demande le rattache à une installation, une porte ou un usage.
|
||||
La cause d’un orphelin dans la fiction devra être compréhensible sans demander
|
||||
au joueur de connaître les fichiers de sauvegarde.
|
||||
|
||||
L’assembleur, le contrôleur, le terminal, le dépôt et l’ancre spatiale restent
|
||||
des concepts en discussion dans [le cahier des machines](structures-conception.md#ordinateurs-et-installation-dexpansion).
|
||||
Les questions communes sont maintenant plus précises : qui formule la demande
|
||||
d’espace, qui fournit sa matière, qui conserve sa référence, qui présente son
|
||||
état, et comment une fermeture ou une interruption est représentée ? Cette liste
|
||||
ne répartit pas arbitrairement cinq fonctions entre cinq blocs.
|
||||
|
||||
Les ruines peuvent rendre ces questions visibles par leurs usages passés.
|
||||
L’observatoire, la salle d’expansion rééquipable, l’atelier caché et la grande
|
||||
traversée restent la sélection de conception actuelle. Pour chacun, il faut
|
||||
retrouver ce qui y était observé, préparé, fabriqué ou relié, puis montrer les
|
||||
extensions et le travail interrompu. Ce sont des questions de fiche de lieu,
|
||||
pas la confirmation de machines présentes ni d’un accès aux Backrooms dans
|
||||
chaque ruine. Le donjon majeur conserve son boss et son objet de quête à définir ;
|
||||
il n’est pas automatiquement identifié au réacteur ou à l’origine de la panne.
|
||||
|
||||
La même ligne relie le passé et la partie actuelle :
|
||||
|
||||
> une infrastructure dont l’auteur a progressivement disparu derrière son
|
||||
> fonctionnement.
|
||||
|
||||
## Accès, retour et récupération : règles encore ouvertes
|
||||
|
||||
La vision antérieure envisage le lit pour entrer dans les Backrooms, des sources
|
||||
de lumière pour les explorer et des coffres recueillant des objets perdus dans
|
||||
le vide ou brûlés. Elle prévoit aussi des accès d’Indoors liés à la mailbox de
|
||||
leur propriétaire. Ces intentions doivent être raccordées à la cosmologie du
|
||||
ballast ; elles ne définissent pas encore un parcours complet.
|
||||
|
||||
Avant un ticket jouable, il faut notamment arrêter :
|
||||
|
||||
1. Les moyens d’entrer, les destinations d’arrivée, le retour et le comportement
|
||||
lors d’une mort ou d’une déconnexion.
|
||||
2. La propriété et le partage des Indoors, la perte de leur objet d’accès, leur
|
||||
fermeture et la distinction entre un accès absent et un espace fictionnellement
|
||||
devenu orphelin.
|
||||
3. Le rapport entre ballast, géologie et objets récupérables : quelle part fait
|
||||
décor ou ressource, quelle part demeure un objet identifiable, et comment sa
|
||||
récupération évite une restitution multiple.
|
||||
4. Les opérations qui alimentent réellement les dépôts, leurs unités, leur
|
||||
cadence et les limites de stockage et de génération.
|
||||
5. Les indices permettant de lire une période économique ou une ancienne solution,
|
||||
sans attribuer d’avance une cause à tous les lieux et aux neuf disparus.
|
||||
|
||||
Les pool rooms et salles étranges physiques sous l’île restent des structures
|
||||
de l’Overworld. Leur ressemblance éventuelle avec les Backrooms ne les transforme
|
||||
pas automatiquement en espaces orphelins. Les passages entre ces lieux, les
|
||||
Indoors et les Backrooms devront être décidés explicitement.
|
||||
|
||||
La prochaine étape de conception peut prendre un seul cas complet : une
|
||||
opération économique réelle, la trace qu’elle conserve, son dépôt, puis le lieu
|
||||
que ce dépôt permettrait de générer et d’explorer. Ce cas permettrait de fixer un
|
||||
premier contrat vérifiable sans prétendre que toute la cosmologie est déjà jouable.
|
||||
@@ -0,0 +1,105 @@
|
||||
# Alpha.23.1 — île naturelle, secrets et continents
|
||||
|
||||
Contrat du ticket **WG-27**, branche `codex/natural-secrets-alpha23`.
|
||||
Cette livraison réunit le Blocodex alpha.23 et la génération `sanctuary:island_v23`.
|
||||
Les résultats des essais sont consignés dans [le rapport](testing-alpha23.1.md).
|
||||
|
||||
## Sanctuary Island
|
||||
|
||||
Le point de départ reste naturel. Les quartiers Lost City et les infrastructures
|
||||
ordinaires Sanctuary ne sont plus demandés sur l’île initiale. Leur code et les
|
||||
anciennes générations sont conservés ; les expansions Lost City restent possibles.
|
||||
Les structures vanilla ne sont pas supprimées : leur admission dépend du biome,
|
||||
du relief, des appuis et des volumes déjà occupés.
|
||||
|
||||
La sélection des lieux Sanctuary conserve l’observatoire, un atelier caché,
|
||||
la grande traversée et la salle d’expansion indépendante. La piscine attenante
|
||||
est retirée ; les égouts et leurs ouvertures restent possibles. Les anciennes voies
|
||||
ferrées peuvent exister sans gare ni bâtiment au bout : leur remise en service
|
||||
reste une construction des joueurs.
|
||||
|
||||
Le **sanctuaire minéral** est une grande cavité géologique explorable, dominante
|
||||
pierre et cobblestone, avec voûtes, piliers, corniches et filons minables. Il peut
|
||||
affleurer sur les flancs ou sous l’île avec des attaches rocheuses. L’enveloppe
|
||||
maximale est 79 × 73 × 27 ; ce volume ne désigne pas une façade rectangulaire.
|
||||
Il ne comporte ni briques, mobilier, machines, ni éclairage manufacturé.
|
||||
Le mot laboratoire reste réservé à la future structure des Mooblooms.
|
||||
|
||||
Le gardien et le portail des Cavernes ne sont pas activés ici. L’intention de
|
||||
progression demeure : vaincre le gardien stabilisera l’accès aux Cavernes pour
|
||||
tout le serveur, puis chacun pourra construire son portail. Le Deep Dark et les
|
||||
cités anciennes appartiendront à ces Cavernes. Le lieu des raids appartient aux
|
||||
expansions et n’est pas construit dans cette livraison.
|
||||
|
||||
## Structures natives et garantie d’expansion
|
||||
|
||||
Le catalogue s’appuie sur les 52 identifiants de structures présents dans le JAR
|
||||
Minecraft 26.3-pre-2 : 47 de l’Overworld, dont la cité ancienne réservée aux Cavernes,
|
||||
et cinq propres au Nether ou à l’End. Les petits donjons `monster_room` sont des
|
||||
features et font l’objet d’un suivi séparé. Les modèles, identifiants, coffres,
|
||||
spawners et comportements natifs sont conservés.
|
||||
|
||||
Les placements distinguent surface, sous-sol et milieu aquatique. Les hauteurs
|
||||
souterraines vanilla ne sont pas recopiées sous Y=0 : elles sont adaptées à la
|
||||
roche de l’île. Les monuments conservent aussi leur hauteur lors du rechargement.
|
||||
L’adaptation ne remplace pas les définitions `minecraft:*` du registre.
|
||||
Les ruines océaniques et les trésors enterrés conservent leur ajustement fin
|
||||
vanilla au fond réel pendant la pose des blocs : leur hauteur peut encore se
|
||||
préciser après l’acceptation du départ.
|
||||
|
||||
**Correction approuvée après le plan initial : chaque nouvelle expansion 23 avec
|
||||
les structures activées doit disposer d’au moins une structure adaptée avant sa
|
||||
réservation.** Les familles absentes restent préférées, sans rendre obligatoire
|
||||
une famille incompatible. Une recherche infructueuse ne publie pas une île vide
|
||||
de structures et ne contourne pas les exigences d’appui. Aucune structure n’est
|
||||
ajoutée rétroactivement aux îles déjà enregistrées.
|
||||
|
||||
Les yeux de l’Ender, cartes d’exploration et `/locate` recherchent les vrais
|
||||
départs dans les îles ouvertes. Une recherche n’active jamais d’expansion.
|
||||
Le compteur natif de références cartographiques n’indique pas une visite réelle.
|
||||
|
||||
## Océans
|
||||
|
||||
Le relief `ocean` est réservé aux expansions 23 de 512 ou 1024 blocs. Les grandes
|
||||
expansions rapides sans relief explicite peuvent le choisir dans un tirage
|
||||
déterministe d’environ un tiers. Le climat et la taille restent ceux du descripteur.
|
||||
|
||||
Le champ océanique commun au terrain, à l’eau et aux biomes produit une mer
|
||||
intérieure irrégulière, des hauts-fonds, des côtes et une zone profonde, en
|
||||
conservant une majorité de terres. Cible : 30–45 % de surface aquatique nominale,
|
||||
profondeurs maximales 32–56 blocs. Une coque rocheuse continue retient l’eau ;
|
||||
le reste du vide conserve l’air. Le niveau d’eau est local à l’expansion.
|
||||
Ce niveau accompagne aussi les décorations natives, notamment les icebergs ;
|
||||
il est rétabli après chaque passe pour ne pas affecter les autres îles.
|
||||
|
||||
Les températures utilisent les biomes natifs océan, océan froid, gelé, tiède et
|
||||
chaud, avec les variantes profondes disponibles. Il n’existe pas de
|
||||
`deep_warm_ocean` natif. Les monuments exigent un océan profond réellement adapté.
|
||||
Aucun océan ni Deep Dark n’est ajouté à Sanctuary Island.
|
||||
|
||||
## Mémoire serveur et sauvegardes
|
||||
|
||||
Le registre des structures est persistant et distinct du census des seuls chunks
|
||||
chargés. Il distingue départ accepté, bâtiment partiellement ou complètement
|
||||
généré, région encore inconnue et absence confirmée dans une région vérifiée.
|
||||
Une démolition ne supprime pas le fait historique de génération. Une erreur de
|
||||
lecture ne transforme pas le registre en liste vide.
|
||||
|
||||
`/sanctuary census structures` expose les relevés aux opérateurs ; l’option
|
||||
`island <id>` précise la région et `dimension <id>` distingue les dimensions natives.
|
||||
L’île propriétaire se déduit des descripteurs immuables du journal d’expansion.
|
||||
Le suivi automatique ne charge pas la carte et
|
||||
ne révèle pas les secrets dans le Blocodex personnel.
|
||||
|
||||
Le champ optionnel plat `structure_priorities` d’une nouvelle expansion 23
|
||||
contient les familles bonifiées. Il est capturé une fois avant l’inspection,
|
||||
figé dans le journal et lié au certificat de réutilisation du vide. Bonus initial
|
||||
de sélection : × 4. Une reprise réutilise ce profil même si le registre a évolué.
|
||||
Les générations historiques restent neutres, sans champ ajouté à leurs écritures.
|
||||
|
||||
Les mondes existants gardent leur codec et leur terrain. Les nouvelles règles
|
||||
nécessitent un nouveau monde ; aucune conversion ou régénération n’est effectuée.
|
||||
Petit 512, Moyen 724 par défaut et Grand 1024 restent dans Personnaliser. L’option
|
||||
expérimentale commande les secrets optionnels et les rails ; le hall et la
|
||||
traversée restent dans le socle. Les structures vanilla en sont indépendantes.
|
||||
La désactivation générale des structures reste prioritaire.
|
||||
@@ -0,0 +1,90 @@
|
||||
# Alpha.24 — les lieux suspendus de Sanctuary
|
||||
|
||||
## Contrat
|
||||
|
||||
Le nouveau codec `sanctuary:island_v24` ajoute cinq lieux au monde initial :
|
||||
une montgolfière, deux bateaux de fret et deux îlots minéraux. Ils sont planifiés
|
||||
à la création et construits seulement lorsque leurs chunks sont générés.
|
||||
La génération de terrain reste celle de l’alpha.23.1 : mêmes trois tailles
|
||||
512 / 724 / 1 024, Moyen par défaut, bouton Minecraft **Personnaliser**,
|
||||
secrets minéraux, voies abandonnées, structures vanilla, océans d’expansion,
|
||||
registre et admission d’au moins une structure adaptée par expansion acceptée.
|
||||
|
||||
Les cinq sites cherchent la périphérie, hors de l’emprise du terrain initial.
|
||||
Chaque site possède un point de rivage vérifié, à moins de 512 blocs, et un
|
||||
segment de vue dégagé dans le relief et hors des volumes des secrets déjà
|
||||
planifiés. Les distances de rendu du client et du
|
||||
serveur déterminent sa visibilité en jeu ; les arbres ultérieurs peuvent
|
||||
masquer une partie de cette vue. Le relief n’est pas prolongé vers les sites.
|
||||
Aucun pont, quai, pilier jusqu’au sol ou accès automatique n’est fourni.
|
||||
|
||||
## Formes et ressources
|
||||
|
||||
La montgolfière possède une enveloppe arrondie de laine claire, un accent,
|
||||
une nacelle en chêne et des suspentes attachées. Elle reste sous Y350.
|
||||
Les deux navires ont une coque biseautée, des voiles, un pont protégé,
|
||||
une cabine et une cale. Le navire de vivres accueille un fermier adulte ;
|
||||
celui de matériel, un outilleur adulte. Leurs postes de travail sont vanilla.
|
||||
Il faut construire pour atteindre les lieux et ramener les villageois.
|
||||
|
||||
Les îlots ont une roche irrégulière, une base effilée et des filons connectés.
|
||||
Leur surface reçoit une couverture de terre et d’herbe majoritaire, des fleurs,
|
||||
des herbes et quelques petits chênes ou bouleaux. Le volume réservé comprend
|
||||
les couronnes ; l’épaisseur rocheuse reste de 20 à 35 blocs.
|
||||
Leur profondeur relative détermine les minerais : charbon, fer et cuivre
|
||||
abondants ; poches d’or, lapis, redstone, diamant et émeraude. Ces réserves
|
||||
sont finies. Le recensement existant compte les blocs dans les chunks
|
||||
observés, sans charger toute la région ni lire le butin encore fermé.
|
||||
Exactement un îlot possède une source d’eau qui s’écoule suivant les règles
|
||||
Minecraft et peut tomber dans le vide.
|
||||
|
||||
Chaque lieu contient exactement un coffre dédié. Ceux des îlots sont enterrés
|
||||
sous une couverture stable, à l’écart de la cascade. Les tables de butin
|
||||
utilisent exclusivement des objets vanilla, sans récompense future ni Anomaly.
|
||||
Ni le butin, ni les habitants, ni les blocs détruits ne se renouvellent au
|
||||
rechargement d’un chunk déjà généré.
|
||||
|
||||
## Persistance et expansions
|
||||
|
||||
La recherche est déterministe, limitée à 64 candidats par site et 8 192
|
||||
colonnes de terrain mises en cache pour l’ensemble du plan. Les plans des
|
||||
secrets racine sont calculés auparavant, puis réutilisés au démarrage ; une
|
||||
voûte ou une galerie ne peut ainsi recouvrir le point côtier certifié. Cette
|
||||
planification ne demande aucun chunk. Un échec interrompt explicitement la création du plan plutôt que
|
||||
de livrer un monde avec un satellite silencieusement manquant.
|
||||
|
||||
Le manifeste immuable est écrit dans `data/sanctuary-aerial-v24/` avant le
|
||||
premier journal `data/sanctuary-world-v24/`. Son SHA-256 est lié au journal24.
|
||||
Un rechargement relit le plan stocké ; il ne le recalcule pas. Un manifeste
|
||||
manquant, altéré ou incompatible bloque la reprise avant toute expansion.
|
||||
Ce contrat ne s’applique qu’aux nouveaux mondes24 ; les anciens journaux,
|
||||
codecs, profils et terrains restent lisibles sans migration.
|
||||
|
||||
Les réservations couvrent exactement les chunks des cinq structures et un
|
||||
petit masque local autour de la sortie d’eau, sans marge sur tout le pourtour
|
||||
des sites. Elles ne deviennent pas des propriétaires de terrain :
|
||||
les biomes du vide et le bruit de génération restent inchangés. L’admission
|
||||
d’expansion, le journal et la reprise de vide vérifient ces emprises même si
|
||||
aucun joueur n’a encore exploré le site. Les passages entre elles restent libres.
|
||||
|
||||
Les départs et pièces sont natifs, enregistrés sous `aerial_balloon`,
|
||||
`aerial_merchant_ship` et `aerial_mineral_islet`. Les écritures sont limitées
|
||||
au site et au chunk courant. Le registre distingue les sites planifiés,
|
||||
les départs acceptés et la génération observée. Les scopes aériens ne servent
|
||||
pas à conclure qu’une famille de structures vanilla manque au serveur.
|
||||
`/locate structure` et `/sanctuary census structures aerial [site]` les
|
||||
référencent sans ouvrir d’expansion ni transformer une consultation en visite.
|
||||
|
||||
Les options **Structures expérimentales** et **Générer les structures**
|
||||
contrôlent les satellites. Leur désactivation produit un plan vide, sans
|
||||
réservations aériennes. Les options sont sauvegardées avec le monde.
|
||||
|
||||
## Limites de cette livraison
|
||||
|
||||
Minecraft reste en 26.3-pre-2. Les nuages et la hauteur du monde sont inchangés.
|
||||
Aucun véhicule pilotable, bateau-poule, temple, commerce Sanctuary, boss,
|
||||
portail des Cavernes ou raid n’est ajouté. Deep Dark et cités anciennes
|
||||
restent réservés aux futures Cavernes.
|
||||
|
||||
Les vérifications réellement exécutées, les témoins et l’état de distribution
|
||||
figurent dans [testing-alpha24.md](testing-alpha24.md).
|
||||
@@ -0,0 +1,64 @@
|
||||
# Alpha.27 — reprendre la 24 et regarder le résultat
|
||||
|
||||
Le retour du 12 septembre 2026 rejette l'alpha.25 : cônes creux, enveloppes
|
||||
rocheuses trop minces, cavités génériques et île trop perforée. Les tests
|
||||
fonctionnels passaient mais ne démontraient pas un rendu naturel. La branche
|
||||
`codex/reprise-sanctuary-alpha27` repart directement de `e7d1f29`, la base 24
|
||||
publiée ; elle ne désactive pas simplement quelques options de la 25.
|
||||
|
||||
## Cette première passe
|
||||
|
||||
- Retrouver le relief, les cavités et l'hydrologie de la 24. Aucun ajout de
|
||||
montagne, volume de cavité, lac ou plateforme pour faire tenir un biome.
|
||||
- Retirer la montgolfière, son placement et ses réservations ; conserver les
|
||||
deux navires marchands et les deux îlots minéraux, dont un seul à cascade.
|
||||
- Reprendre directement `minecraft:shipwreck/rightsideup_full`, une épave
|
||||
vanilla complète déjà à l’endroit, puis restaurer les trous, les mâts et
|
||||
l’accès. Conserver ses blocs, dalles, escaliers et sa cabine, au lieu de
|
||||
dessiner une nouvelle coque approximative. Garder les marchands et un
|
||||
coffre de cargaison par navire.
|
||||
- Répartir des secteurs de marais en trois dimensions dans les souterrains
|
||||
existants, remplaçant localement les autres biomes de grottes. Le sol et les
|
||||
végétaux changent, pas la densité rocheuse. Chêne et végétation humide plutôt
|
||||
que bosquets de chêne noir dans ces secteurs.
|
||||
|
||||
Minecraft reste en **26.3-pre-2**. Les tailles restent **512 / 724 / 1 024**, Moyen
|
||||
par défaut, avec le bouton natif Personnaliser. Les options existantes des
|
||||
structures gardent leur rôle. Les marais sont naturels, indépendants de ces
|
||||
options. Le Deep Dark n'est pas ajouté.
|
||||
|
||||
Le prototype alpha.27 conserve le codec `sanctuary:island_v24` et ses ressources
|
||||
de terrain. Le créateur teste des mondes jetables et a levé l'objectif de
|
||||
compatibilité ; on ne convertit ni ne régénère ses sauvegardes. **Nouveau monde
|
||||
nécessaire.** Les archives de la 25 restent sur `codex/terrain-sanctuary-alpha25`,
|
||||
commit de livraison `df51e17` et documentation `1bf3a3b`.
|
||||
|
||||
## Ce qui reste à travailler après l'essai
|
||||
|
||||
Les plateaux étagés, l'érosion, les galeries proches des bruits de grottes
|
||||
vanilla et les sorties d'eau libres ne sont pas réintroduits en bloc. Ils
|
||||
seront examinés séparément, à partir de ce que l'on voit en jeu. Des points
|
||||
d'eau peuvent retomber sur l'île ou dans le vide ; leur intérêt ne dépend pas
|
||||
d'une arrivée dans un bassin calculé.
|
||||
|
||||
Mangroves, grenouilles, slimes et lucioles restent les références de l'écologie
|
||||
des marais. La liste réellement présente et les restrictions natives sont
|
||||
consignées dans [les vérifications](testing-alpha27.md), sans promettre une
|
||||
population observée à partir d'une simple entrée dans un biome.
|
||||
|
||||
Les fonctions propres à la 25 — nouveau village souterrain, cabane du mineur,
|
||||
cadre du sanctuaire et garantie spécifique du monument — sont écartées avec
|
||||
sa base. La 24 conserve ses structures et expansions ; leur présence n'est
|
||||
pas présentée comme une reprise de tous les contrats de la 25.
|
||||
|
||||
## Méthode retenue
|
||||
|
||||
Une passe limitée, un pack jouable, puis un retour sur son apparence. Vérifier
|
||||
le build et les nouveaux points de comportement ne remplace pas ce retour.
|
||||
Pas de matrice exhaustive ni de benchmark supplémentaire avant cet essai.
|
||||
Les prochaines optimisations devront conserver les formes jugées bonnes,
|
||||
au lieu de fabriquer des espaces faciles à certifier.
|
||||
|
||||
Le benchmark archivé de la 25 mesurait 169,816 s contre 60,932 s pour un parcours
|
||||
de 369 chunks (générations 24/25 dans les mêmes sources 25). Il documente un coût
|
||||
sur ce témoin Mac ; il ne sauve pas le rendu refusé et ne mesure pas cette 27.
|
||||
@@ -0,0 +1,61 @@
|
||||
# Alpha.28 — roche à explorer
|
||||
|
||||
La 27 est la base validée par le créateur. Cette passe garde son île, les
|
||||
secrets minéraux et les réseaux, puis ajoute du creusement dans la roche.
|
||||
Les nouvelles cavités ne sont pas des salles de structure aux volumes prescrits.
|
||||
|
||||
## Terrain
|
||||
|
||||
Le champ commun compose les fonctions de bruit de Minecraft 26.3-pre-2 :
|
||||
cheese et cave_layer, entrées/spaghetti 3D, spaghetti 2D et roughness, piliers
|
||||
et noodle. Leur altitude est déplacée pour la masse flottante. Les coupes
|
||||
restent soustractives et s’atténuent vers les limites verticales ; il ne
|
||||
s’agit pas de recopier toute la génération Overworld ou ses aquifères.
|
||||
Les carvers historiques restent désactivés pour ne pas ajouter une seconde
|
||||
passe étrangère aux colonnes de certification.
|
||||
|
||||
Le relief supérieur déforme le volume rocheux dans les trois axes avec les
|
||||
bruits ridge/erosion natifs échantillonnés en 3D. Les déplacements sont signés :
|
||||
soulèvements, affaissements et cisaillements varient aussi avec la profondeur.
|
||||
Le déplacement est borné à ±16 blocs horizontalement et ±40 verticalement,
|
||||
avec une transition progressive de Y180 à Y228. L’enveloppe de l’île reste
|
||||
évaluée aux coordonnées réelles ; seul le champ rocheux interne est déplacé.
|
||||
Ce n’est pas une simulation physique de plaques tectoniques. Aucun cône ni
|
||||
salle géométrique ne sert de forme à ajouter au terrain.
|
||||
L’arrivée et les côtes gardent leur place. Les anciennes failles deviennent
|
||||
obliques, interrompues et limitées en hauteur, avec de la roche au-dessus et
|
||||
en dessous. Les expansions utilisent la même source de terrain ; leur climat
|
||||
et leur déformation propre s’appliquent ensuite.
|
||||
|
||||
Le seuil du champ de marais passe de 0,04 à 0,25 : les anciens secteurs se
|
||||
réduisent au profit des biomes de grottes précédents, dont les champignons.
|
||||
La hauteur du monde, les nuages et les trois diamètres sont conservés.
|
||||
|
||||
## Exploration et ressources
|
||||
|
||||
Les bateaux vanilla restaurés recherchent désormais les vraies berges proches.
|
||||
Les deux îlots sont au-dessus de Sanctuary, avec un espace libre sous leur
|
||||
roche et un seul exutoire d’eau. Leurs corps et leurs chutes d’eau ont des
|
||||
emprises distinctes ; rien ne réserve toute la colonne sous un îlot sec.
|
||||
|
||||
Les mines emploient les pièces vanilla, leurs supports, rails, coffres et
|
||||
spawners. Une partie exposée peut passer si l’ensemble reste ancré. Les huttes
|
||||
cherchent aussi des berges souterraines de marais : sol local, couverture de
|
||||
la cavité et quatre pilotis natifs. Les salles à spawner sont de vraies
|
||||
MonsterRoomFeature, posées sur des candidats réels et soumises aux refus
|
||||
natifs. Leur présence n’est pas garantie sur chaque île.
|
||||
|
||||
Une passe de filons native complète les distributions existantes dans les
|
||||
chunks de l’île et des expansions. Charbon, fer, cuivre, or, lapis, redstone,
|
||||
diamant et émeraude utilisent les formes OreFeature vanilla. La profondeur
|
||||
se mesure dans l’enveloppe rocheuse entière de la colonne, sans recommencer
|
||||
le calcul à chaque plafond de grotte. Les stocks restent finis. Les minerais
|
||||
du Nether restent dans le Nether ; le Deep Dark n’est pas ajouté à l’île.
|
||||
|
||||
## Livraison de test
|
||||
|
||||
Mod et pack `0.1.0-alpha.28`, Minecraft `26.3-pre-2`, codec de prototype
|
||||
`sanctuary:island_v24` conservé. Créer un nouveau monde. Aucune migration,
|
||||
aucune régénération ni intervention dans les sauvegardes personnelles.
|
||||
L’alpha.27 et ses artefacts restent disponibles. Les vérifications réelles
|
||||
et leurs limites sont dans [le compte rendu](testing-alpha28.md).
|
||||
@@ -0,0 +1,56 @@
|
||||
# Alpha.29 — corniches fines et traversées présentes
|
||||
|
||||
La 28 a été validée visuellement par le créateur sur Windows, avec un chargement
|
||||
correct. Cette livraison conserve cette base et traite trois observations :
|
||||
la grande traversée absente en Grand, le relief un peu trop lissé et les mines
|
||||
vanilla difficiles à rencontrer.
|
||||
|
||||
## Témoin signalé
|
||||
|
||||
Grand **1 024**, graine **-7228211907433324401**. La reproduction avec le code
|
||||
28 confirme un plan de transit vide : 419 alignements examinés, 13 000 colonnes,
|
||||
75,114 secondes de recherche et aucun couple de portiques naturels accepté.
|
||||
Dans les douze premiers candidats natifs examinés, aucune mine n’est admise.
|
||||
Le résultat ne prétend pas inventorier les parties inconnues de toute l’île.
|
||||
|
||||
## Relief
|
||||
|
||||
La déformation 3D de la 28 reste en place. Une modulation fine du Y échantillonné
|
||||
forme de petites corniches avec des ruptures plus franches. Période locale de
|
||||
6 à 9 blocs et phase variables avec les bruits 3D existants, décalage supplémentaire
|
||||
borné à ±2,5 blocs. Aucune grille de plateaux horizontaux commune à toute l’île.
|
||||
Le raccord commence à Y214 et atteint sa pleine amplitude à Y244, à l’écart
|
||||
de l’arrivée et du contour. Les densités sous Y214 sont exactement celles de
|
||||
la 28 ; les grottes, failles, minerais, marais et lieux aériens sont conservés.
|
||||
Le même champ sert aux colonnes, chunks, biomes et certifications.
|
||||
|
||||
## Infrastructures et mines
|
||||
|
||||
Le correctif de traversée conserve le génie civil et les galeries industrielles
|
||||
existants. Les accès doivent s’adapter au relief sans transformer la surface en
|
||||
une grande fondation. Deux accès relient une chaussée et ses trottoirs ; la
|
||||
branche vers une salle conserve une paroi pleine du côté fermé de sa jonction.
|
||||
Les modules déjà certifiés ne sont plus refiltrés par un
|
||||
biome souterrain incompatible avec leur ancien tag de structure.
|
||||
|
||||
Pour les mines, les protections sont vérifiées autour des vraies pièces et de
|
||||
leurs appuis, et non dans tout le rectangle vide entre leurs branches. Le
|
||||
graphe, les pièces, les rails, coffres, toiles et spawners restent vanilla.
|
||||
Un sol rocheux portant déjà la galerie est reconnu comme appui natif ; il ne
|
||||
nécessite pas un second pilier ou une chaîne. Les galeries exposées gardent les
|
||||
ancrages bornés du vanilla et les réservations protègent aussi leurs appuis.
|
||||
Les trois essais d’altitude sont choisis dans les couches rocheuses réellement
|
||||
présentes autour des pièces, après un sondage de 32 colonnes au maximum. Les
|
||||
croisements utilisent le contrat de leur plancher vanilla : une voûte rocheuse
|
||||
proche n’est pas nécessaire à un pont de planches portant sur un corridor ancré.
|
||||
Les marches creusées et les salles gardent leurs contrôles de couverture.
|
||||
Les mines restent conditionnelles : le correctif n’impose pas une mine à chaque
|
||||
graine et ne modifie pas la politique des autres familles de structures.
|
||||
|
||||
## Distribution
|
||||
|
||||
Mod et pack **0.1.0-alpha.29**, Minecraft **26.3-pre-2**, codec de prototype
|
||||
`sanctuary:island_v24`, mêmes tailles et bouton Personnaliser. Les options de
|
||||
structures gardent leur autorité. Créer un nouveau monde ; aucune modification
|
||||
ou régénération d’une sauvegarde personnelle. Les artefacts28 restent accessibles.
|
||||
Les constats mesurés et les limites sont consignés dans [les essais](testing-alpha29.md).
|
||||
@@ -0,0 +1,80 @@
|
||||
# Alpha.30 — plateaux, rivières et traversées
|
||||
|
||||
Dernière passe de génération alpha demandée par le créateur. Branche
|
||||
`codex/terrain-finale-alpha30`, depuis le point de reprise local alpha.29
|
||||
`8c90c61` ; cette dernière n’a pas été publiée. Minecraft **26.3-pre-2**,
|
||||
Fabric Loader **0.19.5**, Fabric API **0.160.0+26.3** conservés.
|
||||
|
||||
## Relief
|
||||
|
||||
La déformation signée par les bruits Minecraft de la 28 agit dans trois zones
|
||||
étendues, orientées par la graine. Entre elles, son poids devient nul et le
|
||||
champ de plateaux naturel précédent reprend sa place. Il s’agit de déplacer
|
||||
et d’affaisser la roche existante, pas d’ajouter trois cônes. Le petit
|
||||
terracement systématique essayé en 29 est désactivé.
|
||||
|
||||
Les cavités et failles bornées de la 28 restent actives. Aucun nouveau
|
||||
creusement ellipsoïdal, plafond du monde ou changement des nuages. La variation
|
||||
de relief est nulle sous Y180. Les tailles 512 / 724 / 1 024 et le bouton natif
|
||||
Personnaliser sont conservés, avec Moyen par défaut.
|
||||
|
||||
Ce changement vise des étendues plus calmes séparées par du relief marqué.
|
||||
Il ne garantit pas que toute surface ait exactement deux niveaux, ni que toute
|
||||
petite pointe rocheuse ait disparu. Le rendu est à juger dans un nouveau monde.
|
||||
|
||||
## Hydrologie
|
||||
|
||||
Une recherche sur la principale masse connectée cherche une rivière longue,
|
||||
évitant les fortes pentes quand un passage plus bas existe. Elle suit le terrain
|
||||
réel avec un lit de cinq blocs environ, des niveaux locaux, du gravier et de
|
||||
l’argile. Les petits bassins et réseaux précédents restent présents.
|
||||
|
||||
Quand une berge est séparée d’un espace ouvert par **cinq blocs au maximum**,
|
||||
une brèche de trois blocs de largeur ouvre le passage. Le plan cherche jusqu’à
|
||||
six sorties espacées pour la grande rivière et une sortie supplémentaire par
|
||||
réseau régional. Il n’impose pas deux cascades terminales, ni de bassin de
|
||||
réception : l’eau peut descendre sur l’île ou dans le vide. La brèche ne pose
|
||||
ni fondation ni colonne d’eau artificielle ; les ticks vanilla propagent l’eau
|
||||
depuis les sources voisines. Les emprises de chute restent réservées aux
|
||||
expansions. L’arrivée naturelle reste à l’écart du tracé.
|
||||
|
||||
La recherche travaille sur une grille puis vérifie les blocs du lit. Les
|
||||
passages trop creux peuvent interrompre ce lit et laisser fuir l’eau. Ce n’est
|
||||
pas une simulation de bassin versant avec débit conservé ou pente monotone.
|
||||
Ces ajouts concernent l’île initiale ; les profils des continents d’expansion
|
||||
ne sont pas remplacés par cette rivière.
|
||||
|
||||
## Traversée et sanctuaire minéral
|
||||
|
||||
La recherche des deux entrées répartit plus tôt ses essais entre plusieurs
|
||||
alignements au lieu d’épuiser une seule bande. Les appuis et la protection
|
||||
des secrets gardent leur autorité. La seconde passe peut omettre un pied
|
||||
optionnel protégé seulement si les autres appuis restent valides. Les modules
|
||||
industriels, escaliers, trottoirs et parois existants sont conservés.
|
||||
|
||||
Le sanctuaire garde ses 79 × 73 × 27 blocs et sa palette minérale. Après les
|
||||
48 candidats intérieurs, une seconde recherche de 48 candidats sur les flancs
|
||||
accepte davantage d’exposition, avec des attaches rocheuses et le plancher
|
||||
praticable. Un échec complet reste diagnostiqué ; la structure ne peut pas être
|
||||
posée dans un volume intégralement vide ou en écrasant un autre secret.
|
||||
Aucun boss, machine, portail actif ou dimension ajouté.
|
||||
|
||||
Les corrections de mines de la 29 sont intégrées : hauteur choisie dans la
|
||||
roche disponible, admission des pièces et appuis réels, croisements en bois
|
||||
acceptés lorsqu’ils sont portés. Les pièces, spawners, rails et butins restent
|
||||
vanilla. Leur présence reste conditionnelle aux candidats et au terrain.
|
||||
|
||||
## Satellites et sauvegardes
|
||||
|
||||
Deux navires restaurés près des rivages et deux îlots au-dessus de Sanctuary,
|
||||
dont un à cascade : modèles et règles de proximité conservés. Les points de
|
||||
vue doivent désormais éviter les sommets que l’hydrologie va creuser en bassin
|
||||
ou en brèche ; aucun bloc artificiel n’est ajouté pour soutenir un témoin.
|
||||
|
||||
Le prototype conserve `sanctuary:island_v24` et ses profils courants, conformément
|
||||
au choix de travailler sur des mondes de test jetables. **Créer un nouveau monde.**
|
||||
Il n’y a ni migration ni régénération d’une sauvegarde personnelle. Les réglages
|
||||
Générer les structures et Structures expérimentales gardent leur rôle ; la
|
||||
rivière et le relief sont des phénomènes naturels indépendants de ces options.
|
||||
|
||||
Les résultats effectivement mesurés sont dans [les vérifications](testing-alpha30.md).
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.4 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 306 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.7 MiB |
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 19 KiB |
+281
-1
@@ -13,10 +13,290 @@ JAR Sanctuary sont des pièces jointes de releases Gitea. Aucun JAR de mod ou
|
||||
dépendance téléchargée n'entre dans l'historique Git. Le canal Beta est distinct
|
||||
de l'ancien pack 26.2.
|
||||
|
||||
## Alpha.28 publiée — 12 septembre 2026
|
||||
|
||||
La [release alpha.28](https://git.botsu.net/koka/sanctuary-beta/releases/tag/v0.1.0-alpha.28)
|
||||
est publiée depuis `79d3185`. Elle prolonge la 27 avec les cavités natives,
|
||||
la déformation 3D signée du relief, des failles bornées, les mines/donjons et
|
||||
les filons, moins de marais, deux bateaux près des berges et deux îlots au-dessus
|
||||
de Sanctuary. Les huttes restent conditionnelles. Voir
|
||||
[la génération](generation-alpha28.md) et [les résultats](testing-alpha28.md).
|
||||
|
||||
`check build` passe sur Mac : **21/21 GameTests natifs**. `assemblePack`,
|
||||
JAR, MRpack et ZIP d’amorçage sont vérifiés localement puis par téléchargement
|
||||
public. Minecraft 26.3-pre-2 et les dépendances restent inchangés.
|
||||
|
||||
Le [MRpack autonome](https://git.botsu.net/koka/sanctuary-beta/releases/download/v0.1.0-alpha.28/Sanctuary-0.1.0-alpha.28.mrpack)
|
||||
est disponible. Le canal packwiz est au commit
|
||||
`6ec1c10c710870a2ccc591b524cc26d125ca03a2`. Deux synchronisations isolées,
|
||||
puis deux dans l’instance existante **Sanctuary Beta**, réussissent.
|
||||
Un seul JAR Sanctuary alpha.28 est actif ; les **925 fichiers personnels
|
||||
et réglages suivis** gardent leurs empreintes. Le jeu était fermé.
|
||||
Sauvegarde ciblée : `sanctuary-backups/before-0.1.0-alpha.28/`.
|
||||
|
||||
SHA-256 JAR : `7f95e9ebd50063c7ebfc649fa325e75263649e42c02e7159244953e09e27d24e`.
|
||||
SHA-256 MRpack : `12d4db8f06a13fb19feb08e61325361f7ab4d783d6f43b3d0c3582d316c54d0f`.
|
||||
Reçus : `build/alpha28-delivery-public.json`,
|
||||
`build/alpha28-isolated-validation.json`, `build/alpha28-prism-validation.json`.
|
||||
|
||||
Créer un **nouveau monde Sanctuary** ; témoin **Moyen 724, graine 0**.
|
||||
Les tests natifs concernent Mac, pas Windows. Le rendu client et les surplombs
|
||||
restent à juger en jeu. Aucun monde personnel n’a été régénéré.
|
||||
|
||||
## Alpha.27 publiée — 12 septembre 2026
|
||||
|
||||
La reprise repart directement de l’alpha.24 : relief et cavités conservés,
|
||||
marais souterrains localisés, montgolfière retirée et navires fondés sur le
|
||||
véritable template vanilla `minecraft:shipwreck/rightsideup_full`, restauré.
|
||||
Voir [le périmètre](generation-alpha27.md) et [les essais](testing-alpha27.md).
|
||||
Minecraft 26.3-pre-2 et les dépendances de la 24 sont conservés.
|
||||
|
||||
`check build` puis `assemblePack` passent sur Mac. Le JAR, le MRpack et le ZIP
|
||||
d’amorçage sont vérifiés localement puis par téléchargement public.
|
||||
|
||||
La [release alpha.27](https://git.botsu.net/koka/sanctuary-beta/releases/tag/v0.1.0-alpha.27)
|
||||
est publiée depuis `392ade0`. Le canal packwiz est au commit
|
||||
`9803b2279aa5242c9e3e7202b940bf47e1c3f404`. Le
|
||||
[MRpack](https://git.botsu.net/koka/sanctuary-beta/releases/download/v0.1.0-alpha.27/Sanctuary-0.1.0-alpha.27.mrpack)
|
||||
est disponible séparément.
|
||||
|
||||
Deux synchronisations isolées, puis deux synchronisations dans la même instance
|
||||
Prism **Sanctuary Beta** réussissent. Un seul JAR Sanctuary alpha.27 est actif.
|
||||
Les **925 fichiers personnels et réglages suivis** gardent leurs empreintes ;
|
||||
le jeu était fermé. Le dossier reste `Sanctuary-0.1.0-alpha.1`, avec sauvegarde
|
||||
ciblée dans `sanctuary-backups/before-0.1.0-alpha.27/`.
|
||||
Reçus locaux : `build/alpha27-delivery-public.json`,
|
||||
`build/alpha27-isolated-validation.json`, `build/alpha27-prism-validation.json`.
|
||||
|
||||
SHA-256 JAR : `56144b291407650e148aa3769596165a5e87398ea4a847cf67352ce2a2c625bf`.
|
||||
SHA-256 MRpack : `e13be90c6454bad3cdd3418fc54b827488700876f6e4ddb42e4a05f57acfecb6`.
|
||||
|
||||
Créer un **nouveau monde Sanctuary** pour cet essai. Les sauvegardes et réglages
|
||||
personnels sont conservés. Aucun essai Windows natif n’est revendiqué.
|
||||
|
||||
## Alpha.24 publiée — 11 septembre 2026
|
||||
|
||||
`check build assemblePack` et les essais natifs passent. Le JAR et
|
||||
`build/Sanctuary-0.1.0-alpha.24.mrpack` sont vérifiés : versions, index,
|
||||
empreintes et JAR intégré concordent. Minecraft 26.3-pre-2, Fabric Loader
|
||||
0.19.5 et Fabric API 0.160.0+26.3 sont conservés. Voir
|
||||
[les vérifications](testing-alpha24.md) et [la génération](generation-alpha24.md).
|
||||
|
||||
SHA-256 du JAR :
|
||||
|
||||
```text
|
||||
f045655cef30bbaa93099a24443462f213d7851fecd03b7b00c6ca874c9d9c45
|
||||
```
|
||||
|
||||
La [release alpha.24](https://git.botsu.net/koka/sanctuary-beta/releases/tag/v0.1.0-alpha.24)
|
||||
est publiée depuis le commit source `27d7cba`. Le canal packwiz est au commit
|
||||
`bd9b4c4`. Le JAR, le
|
||||
[MRpack](https://git.botsu.net/koka/sanctuary-beta/releases/download/v0.1.0-alpha.24/Sanctuary-0.1.0-alpha.24.mrpack)
|
||||
et le ZIP d’amorçage ont été vérifiés par téléchargement public.
|
||||
|
||||
Deux installations isolées, puis deux synchronisations dans la même instance
|
||||
Sanctuary Beta réussissent. Un seul JAR Sanctuary alpha.24 est actif ; les
|
||||
**925 fichiers personnels et réglages suivis** conservent leurs empreintes.
|
||||
Le dossier reste `Sanctuary-0.1.0-alpha.1`. Sauvegarde ciblée :
|
||||
`sanctuary-backups/before-0.1.0-alpha.24/`, hors de `mods/`.
|
||||
Reçus locaux : `build/alpha24-artifacts.json`,
|
||||
`build/alpha24-isolated-validation.json`, `build/alpha24-prism-validation.json`.
|
||||
Le jeu est fermé pendant la mise à jour ; aucun monde personnel n’est ouvert,
|
||||
converti ou régénéré. Le lanceur est resté ouvert et ses réglages sont inchangés.
|
||||
|
||||
Pour essayer : créer un **nouveau monde Sanctuary**, avec les structures et
|
||||
l’option expérimentale activées. Les cinq lieux sont référencés dans le
|
||||
[guide des témoins](testing-alpha24.md). Le ZIP d’amorçage suit le canal stable ;
|
||||
il ne sert pas à réimporter l’instance existante. Aucun essai Windows natif
|
||||
n’est revendiqué.
|
||||
|
||||
## Alpha.23.1 locale vérifiée — 11 septembre 2026
|
||||
|
||||
Le JAR et `build/Sanctuary-0.1.0-alpha.23.1.mrpack` sont construits et vérifiés
|
||||
après `check build` et `assemblePack`. Les versions Minecraft 26.3-pre-2,
|
||||
Fabric Loader 0.19.5 et Fabric API 0.160.0+26.3 sont conservées.
|
||||
Voir [les validations](testing-alpha23.1.md) et
|
||||
[le contrat de génération](generation-alpha23.1.md).
|
||||
|
||||
SHA-256 du JAR :
|
||||
|
||||
```text
|
||||
906fd2e12be4233676a1a561556508eee7412183698c2cac704dc1191324f136
|
||||
```
|
||||
|
||||
**Publication en attente :** le gestionnaire d’identifiants Git ne fournit pas
|
||||
l’authentification nécessaire. Le canal public reste à l’alpha.22 ; aucune
|
||||
synchronisation de l’instance Prism n’a été effectuée pour l’alpha.23.1.
|
||||
Le MRpack local peut être conservé pour les essais. Le ZIP d’amorçage préparé
|
||||
suit encore le canal public alpha.22 et ne doit pas être présenté comme une
|
||||
installation publiée de l’alpha.23.1. Les étapes de publication puis de
|
||||
synchronisation ci-dessous restent à exécuter après rétablissement de l’accès.
|
||||
|
||||
## Alpha.22 publiée — 10 septembre 2026
|
||||
|
||||
[Sanctuary 0.1.0-alpha.22](https://git.botsu.net/koka/sanctuary-beta/releases/tag/v0.1.0-alpha.22)
|
||||
est publiée depuis le commit source `d6e0c14`. Le canal stable est au commit
|
||||
`0019178`. Le JAR, le
|
||||
[MRpack](https://git.botsu.net/koka/sanctuary-beta/releases/download/v0.1.0-alpha.22/Sanctuary-0.1.0-alpha.22.mrpack)
|
||||
et le ZIP d’amorçage Prism ont été vérifiés par téléchargement public.
|
||||
SHA-256 du JAR :
|
||||
|
||||
```text
|
||||
10d7ef32ac2e81a977ea4854503bafa29e0bc10929984b76df01d6f5f61f9056
|
||||
```
|
||||
|
||||
Les bâtiments de surface recherchent des terrains adaptés ; la grande traversée
|
||||
et la salle d’expansion restent des éléments de base, indépendants d’une ville.
|
||||
Les galeries peuvent chercher un détour et de nouveaux accès. Le hall peut
|
||||
accueillir des égouts ailleurs dans l’île. Les trois tailles natives, le cas OFF,
|
||||
la réouverture et la comparaison21 passent. `check build assemblePack` passe
|
||||
avec75 tâches et les huit GameTests généraux. Voir [les essais22](testing-alpha22.md).
|
||||
|
||||
Deux synchronisations isolées puis deux dans la même instance Prism réussissent.
|
||||
Un seul JAR Sanctuary alpha.22 est actif ; les **925 fichiers personnels et
|
||||
réglages suivis** gardent leurs hashes. Le dossier reste
|
||||
`Sanctuary-0.1.0-alpha.1`, affiché « Sanctuary Beta ». Le JAR21 et le suivi
|
||||
packwiz sont sauvegardés sous `sanctuary-backups/before-0.1.0-alpha.22/`.
|
||||
Reçus locaux : `build/alpha22-isolated-validation.json` et
|
||||
`build/alpha22-prism-validation.json`.
|
||||
|
||||
Pour tester : **nouveau monde Sanctuary, Moyen, graine0**. Les portiques de la
|
||||
traversée sont `-170 253 -98` et `170 254 -98` ; la trappe du hall indépendant
|
||||
est `2 252 0`. `/sanctuary structures` liste les lieux. Les villes et bâtiments
|
||||
facultatifs peuvent être refusés. Les graines vérifiées ne prouvent pas la
|
||||
présence des infrastructures sur toutes les graines ; les recherches restent
|
||||
bornées. Aucun monde personnel n’a été ouvert, converti ou régénéré. Aucun
|
||||
essai client visuel ni essai Windows natif n’est revendiqué.
|
||||
|
||||
## Alpha.21 publiée — 10 septembre 2026
|
||||
|
||||
[Sanctuary 0.1.0-alpha.21](https://git.botsu.net/koka/sanctuary-beta/releases/tag/v0.1.0-alpha.21)
|
||||
est publiée depuis le commit source `bb63fab`. Le canal stable utilisait cette version au commit
|
||||
`8002fce`. Le JAR, le
|
||||
[MRpack](https://git.botsu.net/koka/sanctuary-beta/releases/download/v0.1.0-alpha.21/Sanctuary-0.1.0-alpha.21.mrpack)
|
||||
et le ZIP d’amorçage Prism ont été vérifiés. SHA-256 du JAR :
|
||||
|
||||
```text
|
||||
e528e42d99f9e1ea221f780ea089b49b42a1a4e9e24e4ddd001d045183202c21
|
||||
```
|
||||
|
||||
Palettes sobres, toitures portées, quartiers reliés, placements patrimoniaux
|
||||
assouplis et premières galeries industrielles avec fronts rocheux et filons.
|
||||
Voir le [catalogue](architecture-alpha21.md) et les [essais](testing-alpha21.md).
|
||||
`check build assemblePack`, les huit GameTests généraux, les créations et
|
||||
réouvertures natives passent. Le cas expérimental OFF passe. Les fichiers
|
||||
historiques et les témoins natifs de la génération20 sont conservés.
|
||||
|
||||
Deux synchronisations isolées puis deux dans la même instance Prism réussissent.
|
||||
Un seul JAR Sanctuary alpha.21 est actif ; les **925 fichiers personnels et
|
||||
réglages suivis** gardent leurs hashes. Le dossier reste
|
||||
`Sanctuary-0.1.0-alpha.1`, affiché « Sanctuary Beta ». Le JAR20 et le suivi
|
||||
packwiz sont sauvegardés sous `sanctuary-backups/before-0.1.0-alpha.21/`.
|
||||
Reçus locaux : `build/alpha21-isolated-validation.json` et
|
||||
`build/alpha21-prism-validation.json`.
|
||||
|
||||
Pour tester : **nouveau monde Sanctuary, Moyen, graine0**, **Structures
|
||||
expérimentales** activées dans **Personnaliser**. Entrées des galeries :
|
||||
`-135 253 -178` et `-135 249 162`. `/sanctuary structures` liste les lieux.
|
||||
Les raccords dépendent du relief ; certains sites restent isolés et les réseaux
|
||||
souterrains ne sont pas tous reliés. Aucun monde personnel n’a été ouvert,
|
||||
converti ou régénéré. Aucun essai Windows natif ni essai visuel client n’est
|
||||
revendiqué. Une sauvegarde21 nécessite le binaire21 ou un futur binaire compatible.
|
||||
|
||||
## Alpha.20 publiée — 10 septembre 2026
|
||||
|
||||
[Sanctuary 0.1.0-alpha.20](https://git.botsu.net/koka/sanctuary-beta/releases/tag/v0.1.0-alpha.20)
|
||||
est publiée depuis le commit source `0edac29`. Le canal stable utilisait cette
|
||||
version au commit `4e0967d`. Le JAR, le
|
||||
[MRpack](https://git.botsu.net/koka/sanctuary-beta/releases/download/v0.1.0-alpha.20/Sanctuary-0.1.0-alpha.20.mrpack)
|
||||
et le ZIP d’amorçage Prism ont été vérifiés par téléchargement public.
|
||||
SHA-256 du JAR :
|
||||
|
||||
```text
|
||||
9ea10576e641d83c13e1277960a375448a22d416a98a6b327c4d6d2a204c423a
|
||||
```
|
||||
|
||||
Passe de détails sur six bâtiments de ville, quatorze infrastructures,
|
||||
espaces publics et réseaux souterrains : palettes propres aux usages,
|
||||
boiseries, tuf ciselé, corniches, biseaux, verrières et raccords des vitres.
|
||||
Voir le [catalogue illustré](architecture-alpha20.md).
|
||||
|
||||
`check build assemblePack` passe, avec huit GameTests généraux. Les créations
|
||||
et réouvertures natives conservent les structures, accès, supports et coffres.
|
||||
Le bassin et les sorties d’égout restent fonctionnels. Les rapports de la
|
||||
version19 restent identiques à ceux de la release publiée. Le mode désactivé
|
||||
et une petite île passent ; les quatorze infrastructures sont rencontrées sur
|
||||
les deux témoins. Les limites des raccords au terrain sont détaillées dans
|
||||
[les preuves alpha.20](testing-alpha20.md).
|
||||
|
||||
Deux synchronisations isolées puis deux dans la même instance Prism Mac
|
||||
réussissent. Un seul JAR Sanctuary alpha.20 est actif ; les **925 fichiers
|
||||
personnels et réglages suivis** conservent leurs hashes. Le dossier reste
|
||||
`Sanctuary-0.1.0-alpha.1`, affiché « Sanctuary Beta ». Le JAR19 et le suivi
|
||||
packwiz sont sauvegardés dans `sanctuary-backups/before-0.1.0-alpha.20/`.
|
||||
Reçus locaux : `build/alpha20-isolated-validation.json` et
|
||||
`build/alpha20-prism-validation.json`.
|
||||
|
||||
Pour voir cette architecture, créer un **nouveau monde Sanctuary, Moyen,
|
||||
graine 0**, avec **Structures expérimentales** activées dans **Personnaliser**.
|
||||
`/sanctuary structures` liste les entrées. Petit, graine42, possède la
|
||||
cartothèque à `-101 251 -25`. L’option désactivée d’un autre nouveau monde
|
||||
conserve la ville sans les réseaux expérimentaux. Les anciens mondes gardent
|
||||
leur génération ; aucune sauvegarde personnelle n’a été ouverte, convertie ou
|
||||
régénérée. Une sauvegarde20 ne se rétrograde pas vers le binaire19.
|
||||
|
||||
Les vues du catalogue viennent des modèles et ne sont pas des captures de
|
||||
partie. Aucun essai client visuel ni essai Windows natif n’a été effectué.
|
||||
Les nouvelles fonctions de la bêta restent à construire.
|
||||
|
||||
## Alpha.19 publiée — 9 septembre 2026
|
||||
|
||||
[Sanctuary 0.1.0-alpha.19](https://git.botsu.net/koka/sanctuary-beta/releases/tag/v0.1.0-alpha.19)
|
||||
est publiée depuis le commit source `c23e72b`. Le canal stable utilisait alors
|
||||
cette version, au commit `ea883b7`. JAR, [MRpack](https://git.botsu.net/koka/sanctuary-beta/releases/download/v0.1.0-alpha.19/Sanctuary-0.1.0-alpha.19.mrpack)
|
||||
et ZIP d’amorçage Prism ont été vérifiés par téléchargement public.
|
||||
SHA-256 du JAR :
|
||||
|
||||
```text
|
||||
a159b00a2778020800e81381e0608495a4d7909f1f853f0b8812cd4017865b0b
|
||||
```
|
||||
|
||||
Première passe de quatorze architectures et de leurs voies de fret ou chemins
|
||||
abandonnés sur l’île initiale. Les trois tailles sont vérifiées nativement ;
|
||||
les quatorze types ont chacun été rencontrés et parcourus sur ces témoins.
|
||||
Créer un **nouveau monde Sanctuary, Moyen, graine 0**, puis garder
|
||||
**Structures expérimentales** activées dans **Personnaliser** : ce témoin
|
||||
contient treize lieux et sept liaisons, dont un fret de 499 blocs.
|
||||
`/sanctuary structures` relève les entrées. La présence des bâtiments et les
|
||||
raccords dépendent du relief ; voir [les preuves et la carte](testing-alpha19.md).
|
||||
|
||||
`check build assemblePack` et les huit GameTests généraux passent.
|
||||
Création et réouverture natives conservent 112 pièces et 13 coffres ; 68 cibles
|
||||
sont accessibles. Le mode désactivé passe. Les empreintes de la génération 17
|
||||
restent identiques aux preuves publiées, y compris après réouverture.
|
||||
|
||||
Deux synchronisations isolées puis deux dans la même instance Prism Mac
|
||||
réussissent. Un seul JAR Sanctuary alpha.19 est actif ; les **767 fichiers
|
||||
personnels et réglages suivis** conservent leurs hashes. Aucune sauvegarde
|
||||
personnelle n’a été ouverte, convertie ou régénérée. Le dossier reste
|
||||
`Sanctuary-0.1.0-alpha.1`, affiché « Sanctuary Beta ».
|
||||
|
||||
Le JAR 17 et le suivi packwiz sont sauvegardés dans
|
||||
`sanctuary-backups/before-0.1.0-alpha.19/`. Reçus locaux ignorés :
|
||||
`build/alpha19-isolated-validation.json` et `build/alpha19-prism-validation.json`.
|
||||
|
||||
Pour comparer, créer un autre nouveau monde avec l’option désactivée : le socle
|
||||
urbain demeure, sans les expériences 17/19. Cette option ne supprime pas de
|
||||
structures dans une sauvegarde existante. Les anciens mondes conservent leur
|
||||
génération ; une sauvegarde 19 ne doit pas être ouverte avec l’ancien binaire 17.
|
||||
Les bâtiments préparent les futurs usages, mais mailbox, caméra, réacteur et
|
||||
progression restent pour la bêta. Aucun essai visuel dans le client ni essai
|
||||
Windows natif n’a été effectué.
|
||||
|
||||
## Alpha.17 publiée — 9 septembre 2026
|
||||
|
||||
[Sanctuary 0.1.0-alpha.17](https://git.botsu.net/koka/sanctuary-beta/releases/tag/v0.1.0-alpha.17)
|
||||
est publiée depuis le commit source `0969ed5`. Le canal stable utilise cette
|
||||
est publiée depuis le commit source `0969ed5`. Le canal stable utilisait alors cette
|
||||
version, au commit `6e0c297`. JAR, [MRpack](https://git.botsu.net/koka/sanctuary-beta/releases/download/v0.1.0-alpha.17/Sanctuary-0.1.0-alpha.17.mrpack)
|
||||
et ZIP d’amorçage Prism ont été vérifiés par téléchargement public.
|
||||
SHA-256 du JAR :
|
||||
|
||||
@@ -25,6 +25,33 @@ Sources locales : [planificateur17](../mods/sanctuary/src/main/java/fr/koka/sanc
|
||||
[rendu17](../mods/sanctuary/src/main/java/fr/koka/sanctuary/worldgen/ruins/RuinsRenderer17.java),
|
||||
[preuves alpha.17](testing-alpha17.md), [vision](vision.md).
|
||||
|
||||
## Ligne de conception retenue après cet audit
|
||||
|
||||
**Minecraft comme archéologie d’un autre Minecraft.** Steve, Ari, Sunny, Kai,
|
||||
Zuri, Alex, Mefe, Makena, Noor sont les personnages disparus de la partie. Ils
|
||||
ont découvert quelque chose de révolutionnaire et ont continué parce que ça
|
||||
marchait, jusqu’au moment où ça n’a plus marché.
|
||||
|
||||
> Ils n’ont pas ouvert quelque chose qu’ils n’auraient pas dû ouvrir. Ils ont
|
||||
> construit quelque chose qu’ils ne savaient plus refermer.
|
||||
|
||||
Chaque ruine doit conserver la trace d’une ancienne solution : une infrastructure
|
||||
dont l’auteur a progressivement disparu derrière son fonctionnement. Ce canon
|
||||
ne définit pas la découverte, les rôles individuels ou une catastrophe confirmée.
|
||||
Il guide les prochaines structures ; il n’ajoute aucun personnage, récit jouable
|
||||
ou système de progression aux versions déjà livrées. L’état alpha.17 décrit
|
||||
ci-dessus reste le constat historique de cet audit.
|
||||
|
||||
Pour valider la conception d’un lieu, relever concrètement :
|
||||
|
||||
- **Un usage ancien lisible** dans les pièces, les outils et les circulations.
|
||||
- **Une implantation fonctionnelle** expliquée par le terrain, une ressource
|
||||
ou une destination réellement présente.
|
||||
- **Des traces d’entretien, d’extension ou de chantier** qui montrent comment
|
||||
l’installation a été utilisée et adaptée.
|
||||
- **Un lien futur à la progression**, explicitement décrit comme une intention
|
||||
tant que son système et ses interactions ne sont pas implémentés.
|
||||
|
||||
## Faire comprendre les usages avant d’introduire leurs systèmes
|
||||
|
||||
Chaque lieu devrait répondre à trois questions : pourquoi était-il construit
|
||||
|
||||
@@ -0,0 +1,192 @@
|
||||
# Sanctuary — définir les lieux avant de reprendre la génération
|
||||
|
||||
**Document de travail, en discussion.** Ticket WG-26, branche
|
||||
`codex/conception-territoire`. Ce document prépare la prochaine passe ; il ne
|
||||
décrit pas une nouvelle version livrée. L’alpha.22 reste la version publiée.
|
||||
|
||||
Le périmètre est l’organisation de Sanctuary Island, la sélection des vestiges,
|
||||
leurs usages, leurs relations et les besoins des futurs ordinateurs qui
|
||||
influencent leurs espaces. Les règles détaillées des autres systèmes de la
|
||||
bêta restent dans leurs futurs chantiers.
|
||||
|
||||
## Décisions retenues dans la discussion
|
||||
|
||||
| Sujet | Décision |
|
||||
| --- | --- |
|
||||
| Arrivée | Commencer dans un endroit naturel et découvrir les premières installations en explorant. |
|
||||
| Présence ancienne | Retenir quelques lieux isolés : observatoire, salle d’expansion et atelier caché, avec la grande traversée souterraine. Renforcer leur importance et leur mystère. |
|
||||
| Villes et regroupements | Garder villes, clusters, satellites et autres bâtiments en réserve. La proposition d’un noyau gare–poste–dépôt n’est pas la sélection actuelle. |
|
||||
| Réappropriation | Les fonctions des ruines sont reproductibles dans les installations des joueurs, avec quelques lieux collectifs uniques encore à définir. |
|
||||
| Expansion | La grande salle ancienne est rééquipable. Les joueurs peuvent construire une autre installation d’expansion ailleurs ; la salle historique n’est pas un monopole géographique. |
|
||||
| Donjon majeur | Ajouter au moins un donjon difficile, essentiel à la progression, avec un boss et un objet de quête. Son objectif précis, son boss et son fonctionnement restent à définir. D’autres tunnels sont souhaités ; leur organisation reste ouverte. |
|
||||
| Architecture | Préférer les blocs de verre pour les grandes baies. Conserver les matériaux sobres appréciés ; rendre les usages lisibles dans les volumes et leurs abords. |
|
||||
| Récit | Minecraft comme archéologie d’un autre Minecraft : chaque ruine témoigne d’une ancienne solution, d’installations utilisées et de chantiers interrompus. |
|
||||
| Méthode | Définir ensemble avant de reprendre le code. Aucun nouveau binaire, aucune modification de monde ou mise à jour d’instance dans ce chantier documentaire. |
|
||||
|
||||
La demande antérieure de conserver **la grande traversée souterraine et la salle
|
||||
d’expansion indépendamment d’une ville** reste une contrainte de travail. Leur
|
||||
place exacte dans cette sélection restreinte doit être dessinée ; on ne déduit
|
||||
pas du retrait de la ville la suppression de ses infrastructures souterraines.
|
||||
|
||||
La nature de la découverte des anciens joueurs, leurs rôles et la cause précise
|
||||
de leur disparition restent ouverts. Les neuf noms et le canon sont conservés
|
||||
dans [la vision](vision.md#minecraft-comme-archéologie-dun-autre-minecraft).
|
||||
|
||||
## Ce que change cette direction
|
||||
|
||||
Le test alpha.22 Moyen, graine 0, conserve quatorze infrastructures alors que la
|
||||
ville est refusée. Cela explique qu’un placement plus exigeant puisse encore
|
||||
donner une impression d’île très occupée. La prochaine conception doit choisir
|
||||
une petite sélection avant de chercher ses emplacements : le catalogue entier
|
||||
n’est pas une liste à remplir à chaque génération.
|
||||
|
||||
Le projet de regroupements reste disponible pour la suite. La sélection actuelle
|
||||
privilégie les découvertes isolées et l’espace laissé aux nouvelles constructions.
|
||||
Les bâtiments mis en réserve restent documentés et réutilisables ; cette mise
|
||||
en réserve ne signifie pas effacer des structures dans des sauvegardes existantes.
|
||||
|
||||
## Sélection retenue et variantes en réserve
|
||||
|
||||
**Sélection validée :** observatoire, salle d’expansion et atelier caché, avec la
|
||||
grande traversée souterraine. Un donjon difficile avec boss et objet de quête
|
||||
s’ajoute à cette sélection. Les plans et la fréquence des trois lieux restent
|
||||
à définir. Excavation et piscine sont des variantes en réserve, sans ajout
|
||||
automatique à la sélection.
|
||||
|
||||
| Lieu ou variante | Ancienne solution et implantation | Utilité à définir pour l’exploration | Prolongement possible en bêta |
|
||||
| --- | --- | --- | --- |
|
||||
| Observatoire | Observer depuis une hauteur avec un ciel dégagé ; instruments et traces de relevés. | Panorama, orientation, emplacement d’observation et objet vanilla cohérent. | Comprendre les étoiles et les constellations, que les joueurs pourront observer et tracer depuis leurs propres lieux. |
|
||||
| Salle d’expansion | Volume souterrain ayant accueilli une installation collective ; accès et raccordements à comprendre. | Découverte majeure et espace rééquipable. Son état initial et les éléments récupérables restent à choisir. | Assembler une installation d’expansion ici ou ailleurs. L’architecture exacte des machines reste à définir. |
|
||||
| Atelier caché | Petit espace personnel aménagé derrière une entrée secondaire ou dans un ouvrage. | Abri, outillage ou équipement utile ; indices d’un travail interrompu. Contenu exact à choisir. | Modèle d’une installation reproductible ; aucune caméra ou machine encore absente promise dans les coffres. |
|
||||
| Donjon majeur | Ancienne fonction, implantation et cause de danger à concevoir ; le lieu doit conserver la trace d’une ancienne solution. | Objectif de conception : une exploration difficile, une rencontre avec un boss et un objet de quête nécessaire à la progression. Aucune rencontre n’est implémentée par ce document. | Étape de progression à choisir ; règles collectives, répétition du combat et attribution de l’objet encore ouvertes. |
|
||||
| Excavation rare — alternative | Ancien front d’extraction, lié à une masse rocheuse et à un gisement réel. | Descendre dans des grottes contenant des ressources encore exploitables. Richesse et rareté à équilibrer. | Extraction, transport et production construits par les joueurs. |
|
||||
| Piscine ou pool rooms — alternative | Installation hydraulique avec un premier usage identifiable, puis des espaces plus mystérieux. | Exploration, circulations humides et sèches, passages vers les profondeurs. | Éventuel donjon physique ; distinct des Backrooms, espaces artificiels orphelins dont l’histoire et l’hébergement restent à concevoir selon la [cosmologie](cosmologie.md). |
|
||||
|
||||
La traversée est une infrastructure de circulation, pas un quota de bâtiments
|
||||
annexes. Ses sorties peuvent être isolées. Les égouts peuvent exister ailleurs
|
||||
que sous une ville ; leur sélection et leurs liens avec les lieux retenus restent
|
||||
à décider. Plusieurs réseaux peuvent se rejoindre ponctuellement, conformément
|
||||
à la direction déjà retenue.
|
||||
|
||||
Restent notamment en réserve : logements, hôtel, restaurant, bibliothèque,
|
||||
caserne, places et parcs urbains ; gare, maintenance, poste, dépôt, cartothèque,
|
||||
quai, relais, serre, pompage, sous-station, club photo, scierie et autres chantiers.
|
||||
Ce regroupement sert à organiser la conception, sans modifier leurs identifiants
|
||||
ou affirmer que chaque nom correspond à un type de structure distinct déjà codé.
|
||||
|
||||
## Définir le territoire
|
||||
|
||||
Les points suivants doivent devenir des règles explicites avant l’implémentation.
|
||||
Ils n’ont pas encore de valeurs chiffrées acceptées.
|
||||
|
||||
| Règle | Choix à fixer |
|
||||
| --- | --- |
|
||||
| Départ naturel | Ce que le joueur peut voir depuis son arrivée et les espaces proches réservés à sa première construction. Traiter aussi les trappes et portiques souterrains. |
|
||||
| Première découverte | Type d’indice, distance d’exploration souhaitée, visibilité d’un lieu ou de son entrée. Une vue cachée par le relief n’est pas équivalente à un simple éloignement. |
|
||||
| Nombre de lieux | Lieux présents à chaque graine, lieux variables, remplacements possibles et limites de répétition. |
|
||||
| Espacement | Distances entre destinations, secteurs naturels continus et proximité éventuelle d’entrées de sous-sols. |
|
||||
| Tailles d’île | Base actuelle : Petit 512, Moyen 724 par défaut, Grand 1024. Décider si la sélection reste la même selon la taille ou si seuls les espacements changent. Aucun agrandissement supplémentaire n’est décidé. |
|
||||
| Relations | Pour chaque chemin ou galerie, deux destinations réelles ou une extrémité de chantier lisible ; choix des connexions directes, interrompues et seulement suggérées. |
|
||||
| Refus | Règle pour un lieu facultatif sans terrain adapté ; recherche d’un autre accès ou emplacement pour une infrastructure de base. Les garanties et les budgets devront être conciliés. |
|
||||
| Ressources | Ce que la ruine offre comme butin et comme matériaux démontables ; ce que le joueur doit encore produire lui-même. |
|
||||
|
||||
## Fiche à remplir pour chaque lieu retenu
|
||||
|
||||
Une fiche complète doit permettre de dessiner et de tester le lieu sans inventer
|
||||
sa fonction pendant le codage.
|
||||
|
||||
1. **Ancien usage :** quelle solution apportait-il, à quoi et à qui servait-il ?
|
||||
2. **Implantation :** quel terrain ou quelle ressource justifie sa présence ici ?
|
||||
3. **Découverte :** premier indice, silhouette, cheminement, entrée principale et éventuel secret.
|
||||
4. **Plan :** pièces nécessaires, dimensions, cours ou abords, circulations, accès aux sous-sols.
|
||||
5. **Architecture :** palette, structure porteuse, toiture, vitrage, détails qui expliquent l’usage.
|
||||
6. **État :** parties entretenues autrefois, réparations, chantier arrêté, dommages localisés ; aucun défaut de raccord ne fait office de ruine.
|
||||
7. **Usage dans la prochaine livraison :** ce qu’un joueur peut réellement faire dès sa découverte.
|
||||
8. **Lien futur :** système bêta envisagé, connaissances transmises, éléments reproductibles et éventuelle exception collective.
|
||||
9. **Valeur :** butin, matériaux récupérables, gisement restant, répétition et effets pour plusieurs joueurs.
|
||||
10. **Admission et vérification :** placement acceptable, cas de refus, accès praticables, limites d’eau et de lave, exemples à voir en jeu.
|
||||
|
||||
## Ordinateurs et installation d’expansion
|
||||
|
||||
**Décision acquise : l’installation est reproductible ailleurs.** Cela ne décide
|
||||
pas encore son coût, ses prérequis ou les permissions pour ouvrir un continent.
|
||||
La reproduction d’une fonction n’implique pas qu’elle soit disponible dès le début.
|
||||
|
||||
L’utilisateur réfléchit aux éléments suivants : **assembleur, bloc contrôleur,
|
||||
bloc terminal, bloc de dépôt et ancre spatiale**. Ce sont des concepts à définir,
|
||||
pas cinq blocs déjà implémentés avec des rôles figés. La vision évoque aussi un
|
||||
ordinateur 8 bits programmable avec six ports de redstone ; il faut préciser
|
||||
comment ces éléments se composent.
|
||||
|
||||
Avant de fixer le plan intérieur de la salle, décider :
|
||||
|
||||
- ce que chaque élément reçoit, conserve, exécute ou affiche ;
|
||||
- ce que désigne exactement l’assembleur et comment le joueur programme ;
|
||||
- la différence entre terminal informatique et terminal de stockage en titane ;
|
||||
- la différence entre dépôt de machine, deposit box collective et mailbox personnelle ;
|
||||
- les connexions physiques et l’encombrement d’une installation complète ;
|
||||
- la fonction de l’ancre : rattachement à un lieu, orientation, destination ou autre rôle à définir ;
|
||||
- les conditions de découverte, construction et activation, dont les ressources et autorisations côté serveur ;
|
||||
- ce qu’il reste dans la salle ancienne : installation incomplète, pièces récupérables, schéma, emplacement ou traces seulement.
|
||||
|
||||
On doit pouvoir décrire le parcours « découvrir → comprendre → construire ou
|
||||
rééquiper → préparer une expansion » avant de dessiner une interface ou de fixer
|
||||
des recettes. Cette séquence est un outil de conception, pas une campagne imposée.
|
||||
|
||||
## Donjon majeur et tunnels supplémentaires
|
||||
|
||||
Le donjon doit compter dans la progression et comporter un boss ainsi qu’un objet
|
||||
de quête. **Le blocage levé par cet objet n’est pas encore choisi** : première
|
||||
expansion, étape avancée ou objectif collectif final sont des possibilités en
|
||||
discussion, pas des règles cumulatives.
|
||||
|
||||
Sa nécessité impose de concevoir sa présence et son accessibilité sur l’île.
|
||||
Un lieu indispensable ne peut pas être traité comme une décoration facultative
|
||||
dont l’absence serait sans conséquence. Les contraintes de génération devront
|
||||
être définies avec cette exigence avant son implémentation.
|
||||
|
||||
À préciser ensemble :
|
||||
|
||||
- **Fonction ancienne :** qu’avait-on résolu ou protégé dans ce lieu ? Ne pas décider par défaut que c’est le réacteur.
|
||||
- **Découverte :** indices depuis la surface, tunnels d’approche, entrée principale et éventuels raccourcis.
|
||||
- **Difficulté :** type de préparation attendu, dangers des salles et possibilités de retraite.
|
||||
- **Boss :** identité, relation au lieu, comportements reconnaissables et conditions de victoire.
|
||||
- **Objet de quête :** ce qu’il est, ce qu’il débloque et s’il est consommé, conservé ou installé.
|
||||
- **Coopération :** victoire et déblocage à l’échelle du joueur, du groupe ou du serveur ; accueil des joueurs arrivés plus tard.
|
||||
- **Persistance :** combat unique ou rejouable, partage du butin, conséquence d’un objet perdu ou d’un site endommagé.
|
||||
- **Après la victoire :** usage de la structure, exploitation éventuelle des spawners, accès aux galeries et ressources restantes.
|
||||
|
||||
La direction antérieure des donjons prévoit des reliques collectives uniques et
|
||||
des récompenses personnelles, avec des spawners potentiellement exploitables
|
||||
après exploration. Elle ne fixe pas encore l’attribution de cet objet précis.
|
||||
|
||||
Des tunnels supplémentaires peuvent accompagner cette destination. Leur nombre,
|
||||
leurs connexions et leur étendue restent ouverts : on conserve l’idée de réseaux
|
||||
parfois connectés, sans imposer une galerie continue sous toute l’île. La grande
|
||||
traversée utile aux déplacements et le parcours difficile du donjon doivent être
|
||||
distingués lors du dessin de leurs accès.
|
||||
|
||||
## Décisions ouvertes et ordre de discussion
|
||||
|
||||
| Étape | Résultat attendu | État |
|
||||
| --- | --- | --- |
|
||||
| 1. Fonctions reproductibles | Règle commune et place des exceptions collectives. | Principe retenu ; exceptions à nommer. |
|
||||
| 2. Salle d’expansion | Lieu rééquipable et installation reproductible ailleurs. | Retenu ; contenu initial à définir. |
|
||||
| 3. Sélection | Observatoire, salle d’expansion, atelier caché, grande traversée et donjon majeur. | Retenue ; tunnels supplémentaires et fréquences à définir. |
|
||||
| 4. Objet du donjon | Étape de progression débloquée, puis nature du boss et de l’objet. | Question en cours. |
|
||||
| 5. Territoire | Arrivée, découverte, quantités, espacements et différences entre les trois tailles. | À définir. |
|
||||
| 6. Fiches des lieux | Plans, utilité immédiate, indices, matériaux et état d’abandon. | À définir pour la sélection retenue. |
|
||||
| 7. Machines | Rôles et connexions nécessaires pour dimensionner la salle. | Concepts en discussion. |
|
||||
| 8. Contrat de génération | Garanties, refus, ressources, exemples visuels et critères d’essai. | À définir avant de créer les tickets de code. |
|
||||
|
||||
Le document pourra alors servir de cahier de conception validé. Chaque future
|
||||
livraison prendra un périmètre vérifiable dans ce cahier ; une discussion ou une
|
||||
fiche incomplète n’est pas une fonctionnalité implémentée.
|
||||
|
||||
## Références et constats
|
||||
|
||||
- [Vision](vision.md) : intentions de jeu et canon narratif.
|
||||
- [Audit des structures](structures-audit.md) : audit historique et catalogue de possibilités.
|
||||
- [Architecture alpha.20](architecture-alpha20.md) : formes de bâtiments construites lors de cette passe.
|
||||
- [Essais alpha.22](testing-alpha22.md) : état livré, graines et limites vérifiées.
|
||||
- Les difficultés Windows signalées restent un sujet de diagnostic distinct ; leur cause n’est pas attribuée à la préversion sans preuve.
|
||||
@@ -0,0 +1,173 @@
|
||||
# Alpha.19 — anciennes infrastructures de Sanctuary
|
||||
|
||||
**État : alpha.19 publiée, même instance Prism synchronisée et vérifiée.** Ticket WG-22, branche
|
||||
`codex/heritage-worldgen-alpha19`. Minecraft 26.3-pre-2, mêmes dépendances que
|
||||
l’alpha.17. La numérotation 19 est demandée explicitement ; aucune 18 n’est
|
||||
intercalée dans ce dépôt.
|
||||
|
||||
## Périmètre et réversibilité
|
||||
|
||||
Première passe des quatorze lieux du [catalogue](structures-audit.md) : gare de
|
||||
marchandises, centre postal, dépôt communal, cartothèque, observatoire,
|
||||
maintenance ferroviaire, pompage, sous-station, serre, quai d’expédition,
|
||||
relais radio, club photo, vestiaires/salles étranges et refuge de chantier.
|
||||
Les plans recherchent des sites admissibles et des voies de fret ou chemins
|
||||
entre destinations réelles ; ils ne garantissent pas tous les lieux sur chaque
|
||||
graine. Les mesures et coordonnées des essais figurent ci-dessous.
|
||||
|
||||
Créer un **nouveau monde Sanctuary** et utiliser **Personnaliser** :
|
||||
Petit 512, Moyen 724 par défaut ou Grand 1 024, avec **Structures expérimentales**.
|
||||
L’option est activée par défaut et enregistrée avec le générateur 19. La désactiver
|
||||
pour un autre nouveau monde conserve le socle urbain sans les réseaux
|
||||
expérimentaux 17 et les infrastructures 19. Elle ne retire aucun bloc ni ne change
|
||||
les règles d’une sauvegarde existante.
|
||||
|
||||
Les mondes 17 et antérieurs gardent leurs codecs, plans, pièces et futurs chunks.
|
||||
Le preset 17 public est conservé octet par octet sous un identifiant historique
|
||||
caché à la création. Le générateur 19 et son journal sont distincts. Il n’existe
|
||||
aucune conversion ou rétrogradation de sauvegarde 19 vers un ancien binaire.
|
||||
L’ancienne release reste disponible pour ses propres mondes, et l’option d’un
|
||||
nouveau monde permet de comparer les deux configurations du nouveau binaire.
|
||||
|
||||
Les nouveaux lieux sont réservés à l’île initiale. La ville et les anciens
|
||||
réseaux servent de base ; leurs protections et celles de l’hydrologie restent
|
||||
respectées. Les liaisons vers de futurs continents seront construites après
|
||||
leur apparition, sans présumer leurs emplacements dans cette génération.
|
||||
|
||||
## Objets et systèmes
|
||||
|
||||
Les bâtiments suggèrent leurs usages futurs par leurs pièces et aménagements.
|
||||
Mailbox, deposit boxes, caméra, réacteur, progression et récompenses
|
||||
personnelles ne sont pas activés. Chaque nouveau lieu dispose d’une table
|
||||
de coffre propre à la génération 19, avec un outil vanilla lié à son usage et
|
||||
quelques fournitures. Les coffres sont partagés et ne se renouvellent pas.
|
||||
|
||||
La valeur des rails, équipements et blocs récupérables du décor s’ajoute au
|
||||
butin. Leur distribution doit être constatée sur les témoins, sans transformer
|
||||
cette première passe en une garantie d’équilibrage économique pour la bêta.
|
||||
|
||||
## Vérifications effectuées
|
||||
|
||||
- Placement des quatorze architectures, ouvertures, circulation, orientation
|
||||
et appuis du mobilier ; accès réel au coffre et retour possible.
|
||||
- Plans bornés sur les trois tailles, terrain non occupé, supports, continuité
|
||||
des tracés et distinction entre ballast praticable et rails retirés.
|
||||
- Pièces natives et références locales, y compris pour les longues voies ;
|
||||
géométrie, orientation et rails sauvegardés dans un schéma strict.
|
||||
- Création et réouverture d’un monde 19 avec modification témoin ; conservation
|
||||
des starts, butins différés, accès, routes et supports.
|
||||
- Option désactivée, paramètres sauvegardés, génération 17 comparée aux preuves
|
||||
de la version publiée, refus des migrations implicites de journaux.
|
||||
- `./gradlew check build assemblePack`, artefacts et index, publication immuable
|
||||
puis canal packwiz et deux synchronisations de la même instance Prism.
|
||||
|
||||
Les smokes des quatorze architectures, de leurs quatre orientations, des
|
||||
plans sur les trois tailles et des pièces natives passent. Le mode désactivé
|
||||
est vérifié dans un monde 19 neuf : aucun site ni liaison expérimental.
|
||||
`./gradlew check build assemblePack` passe, avec les huit GameTests généraux,
|
||||
125 chunks FULL, 5 923 blocs d’eau conservés et 1 800 ticks de fluides.
|
||||
Le JAR, le MRpack, les hashes du pack et le ZIP Prism sont vérifiés.
|
||||
La release et le canal packwiz sont publiés. Deux synchronisations isolées puis
|
||||
deux dans la même instance Prism passent ; 767 fichiers personnels et réglages
|
||||
suivis conservent leurs hashes. Le JAR précédent et le suivi packwiz sont
|
||||
sauvegardés dans `sanctuary-backups/before-0.1.0-alpha.19/`.
|
||||
Voir [le reçu de distribution](packwiz.md#alpha19-publiée--9-septembre-2026).
|
||||
Aucun essai visuel dans le client ni essai Windows natif n’a été effectué.
|
||||
|
||||
## Témoin natif Moyen, graine 0
|
||||
|
||||
Créer un nouveau monde avec **Structures expérimentales activées**.
|
||||
`/sanctuary structures` liste les entrées prévues sans charger de chunks ;
|
||||
`/locate structure sanctuary:heritage_networks` retrouve l’entrée d’un site.
|
||||
Le relevé ci-dessous provient des placements et parcours vérifiés par le moteur.
|
||||
|
||||

|
||||
|
||||
Treize des quatorze lieux apparaissent. **La cartothèque est absente de cette
|
||||
graine** : la recherche n’a pas trouvé d’emplacement admissible. La ville et les
|
||||
trois réseaux souterrains 17 sont conservés. Les raccords recherchés vers la
|
||||
ville et l’ancienne mine ne sont pas admis sur ce témoin.
|
||||
|
||||
Les sept liaisons comprennent un tracé de fret **dépôt → pompage de 499 blocs**,
|
||||
d’une étendue de 245 blocs sur X et 181 sur Z. Son ballast est praticable ;
|
||||
478 rails sont présents et 21 sont volontairement manquants. Les autres voies
|
||||
et chemins relient gare, dépôt, atelier, poste, club photo, serre et vestiaires.
|
||||
Le quai, l’observatoire, le relais, la sous-station et le refuge gardent leurs
|
||||
propres accès au terrain, même sans liaison avec ce réseau.
|
||||
|
||||
La création et la réouverture dans deux JVM distinctes passent chacune les deux
|
||||
GameTests : **112 pièces natives, 111 chunks FULL, 80 487 blocs contrôlés,
|
||||
2 882 contrôles de portance, 13 coffres différés et 68 cibles accessibles**.
|
||||
Trois tirages de chacune des quatorze tables de butin sont vérifiés
|
||||
séparément, sans ouvrir les coffres persistants. Une modification témoin à
|
||||
`-204 / 255 / -13` est conservée à la réouverture.
|
||||
|
||||
Empreinte stable du plan :
|
||||
`7f476c2ecca703a05bf88a550c61cc5cbeff2594024c43ccd9f3620bbc2ad3de`.
|
||||
JVM de création `36366`, de réouverture `36481`. Reçus locaux ignorés :
|
||||
`build/alpha19-evidence/heritage19-create.json` et `heritage19-reload.json`.
|
||||
|
||||
La planification supplémentaire utilise 15 144 colonnes natives, dans un plafond
|
||||
de 16 000, en 20,7 s sur le Mac de développement. Ce temps concerne ce plan,
|
||||
pas le chargement total du jeu. Les routes sont découpées par chunk ; aucun
|
||||
start ne couvre toute leur longueur ni ne charge une destination lointaine.
|
||||
|
||||
La prospection 19 consulte les plans hydrologiques de toute l’enveloppe de
|
||||
départ, avant de publier les sites. Le contrôle général utilise donc pour 19
|
||||
une limite géographique calculée : 5 régions possibles pour Petit, 9 pour
|
||||
Moyen/Grand, avec les budgets de colonnes et de sondes contrôlés séparément.
|
||||
Le témoin Moyen en consulte 5 ; les quatre régions périphériques représentent
|
||||
3,38 s de calcul hydrologique supplémentaire dans le relevé du build.
|
||||
Ces consultations ne matérialisent aucun chunk. Les générations historiques
|
||||
conservent le contrôle initial de 4 régions maximum autour du spawn.
|
||||
|
||||
```sh
|
||||
./gradlew :sanctuary:runGameTest -PsanctuaryHeritage19Tests=true -PsanctuaryResourceSurvey=off -PsanctuaryDensityMaps=false
|
||||
./gradlew :sanctuary:runGameTest -PsanctuaryHeritage19Tests=true -PsanctuaryExpansionReload=true -PsanctuaryResourceSurvey=off -PsanctuaryDensityMaps=false
|
||||
```
|
||||
|
||||
## Autres tailles et couverture du catalogue
|
||||
|
||||
Les deux GameTests natifs passent aussi sur Petit et Grand, graine 42.
|
||||
Les quatorze architectures ont ainsi chacune été rencontrées et parcourues
|
||||
sur le terrain réel, en complément des rotations vérifiées par les smokes.
|
||||
|
||||
| Taille et graine | Lieux | Liaisons | Pièces natives | Chunks FULL |
|
||||
| --- | ---: | ---: | ---: | ---: |
|
||||
| Petit 512, 42 | 10 | 2 | 35 | 44 |
|
||||
| Moyen 724, 0 | 13 | 7 | 112 | 111 |
|
||||
| Grand 1 024, 42 | 13 | 4 | 47 | 61 |
|
||||
|
||||
Pour visiter la cartothèque : **Petit, graine 42**, entrée
|
||||
`-101 / 251 / -25`, ou **Grand, graine 42**, entrée `-252 / 249 / 146`.
|
||||
Le Petit testé n’a ni poste, ni observatoire, ni atelier ferroviaire, ni quai.
|
||||
Le Grand testé n’a pas de quai. Aucun grand axe n’est admis sur ces deux témoins :
|
||||
les portées maximales de leurs liaisons sont respectivement de 32 et 55 blocs.
|
||||
Le témoin Moyen, graine 0, reste celui conseillé pour découvrir le grand fret.
|
||||
Ces résultats rendent explicite la variation de cette première passe ; ils ne
|
||||
constituent pas une garantie de présence ou de connectivité pour chaque graine.
|
||||
|
||||
Reçus locaux ignorés : `build/alpha19-evidence/small42-create.json` (JVM 36591)
|
||||
et `large42-create.json` (JVM 36669).
|
||||
|
||||
## Compatibilité 17 vérifiée
|
||||
|
||||
Deux JVM de développement distinctes créent puis rouvrent le témoin 17
|
||||
**Moyen, graine 0**, avec le nouveau binaire. Les deux GameTests passent dans
|
||||
chaque exécution. Le codec, les starts natifs, les butins différés et les
|
||||
parcours restent identiques aux preuves de l’alpha.17 publiée. Le bloc d’or
|
||||
placé par le test est conservé à la réouverture.
|
||||
|
||||
Empreinte du plan 17 :
|
||||
`7358ecd7841c03be1977a7f45f37c0c3ef83a32dc27e8d3ec4f0d85d6ee5d3ef`.
|
||||
Les trois starts restent ceux documentés dans [le témoin 17](testing-alpha17.md).
|
||||
Reçus locaux ignorés : `build/alpha19-evidence/legacy17-create.json` et
|
||||
`legacy17-reload.json`.
|
||||
|
||||
```sh
|
||||
./gradlew :sanctuary:runGameTest -PsanctuaryRuins17Tests=true -PsanctuaryResourceSurvey=off -PsanctuaryDensityMaps=false
|
||||
./gradlew :sanctuary:runGameTest -PsanctuaryRuins17Tests=true -PsanctuaryExpansionReload=true -PsanctuaryResourceSurvey=off -PsanctuaryDensityMaps=false
|
||||
```
|
||||
|
||||
Ces commandes visent uniquement le monde de développement ignoré. La première
|
||||
le recrée ; la seconde conserve ce même monde et lit ses preuves précédentes.
|
||||
@@ -0,0 +1,327 @@
|
||||
# Alpha.20 — identité architecturale
|
||||
|
||||
**État : alpha.20 publiée, même instance Prism synchronisée et vérifiée.**
|
||||
Ticket WG-23, branche `codex/architecture-alpha20`.
|
||||
Minecraft 26.3-pre-2, dépendances identiques à la version 19 publiée.
|
||||
|
||||
## Intention
|
||||
|
||||
Chaque fonction reçoit une palette et une composition propre : bois clairs et
|
||||
grandes baies des lieux publics, pierre et tuf des installations techniques,
|
||||
loggias et retraits des logements. Les détails utilisent les blocs vanilla :
|
||||
tuf ciselé, briques de tuf ciselées, briques de pierre sculptées, bois et
|
||||
planches de chêne/bouleau, granit, diorite et andésite. Moulures, liserés,
|
||||
encadrements, murs bas et corniches utilisent escaliers, dalles et trappes.
|
||||
Les fondations restent en briques de pierre. Le [catalogue architectural](architecture-alpha20.md)
|
||||
décrit les formes et les matériaux effectivement construits pour chaque usage.
|
||||
|
||||
La passe concerne les quatorze infrastructures, la ville et ses sous-sols,
|
||||
ainsi que les petits réseaux oubliés. Elle ne déplace pas les sites ni les
|
||||
routes pour obtenir ses silhouettes. Les plans 19/17/16 servent d’emprises
|
||||
certifiées aux nouveaux rendus 20.
|
||||
|
||||
## Connexions des blocs
|
||||
|
||||
La géométrie complète d’une pièce est assemblée avant le découpage par chunk.
|
||||
Les états des vitres, grilles, clôtures et murets sont calculés à partir des voisins
|
||||
réellement présents dans ce plan ; les escaliers reçoivent leurs angles.
|
||||
Cela évite d’écrire des vitres sans raccord malgré leur juxtaposition, ou de
|
||||
dépendre de l’ordre de chargement des chunks voisins. Aucun chunk extérieur
|
||||
n’est chargé pour compléter ces états.
|
||||
|
||||
## Sauvegardes et réversibilité
|
||||
|
||||
Créer un **nouveau monde Sanctuary** pour voir la génération 20. Le bouton
|
||||
natif **Personnaliser** garde Petit 512, Moyen 724 et Grand 1 024.
|
||||
**Structures expérimentales** reste activé par défaut, enregistré avec le
|
||||
monde ; le désactiver dans un autre nouveau monde garde la ville sans les
|
||||
réseaux expérimentaux. Les détails urbains de la version 20 restent présents.
|
||||
|
||||
Le nouveau codec `sanctuary:island_v20`, son journal et ses types de pièces
|
||||
distinguent les nouveaux rendus des précédents. Les mondes 19 et antérieurs
|
||||
gardent leurs codecs, leurs pièces et leurs futurs chunks. Aucun monde
|
||||
personnel n’est ouvert ni rénové par la mise à jour. Une sauvegarde 20 ne se
|
||||
rétrograde pas vers un ancien binaire ; la release 19 reste disponible pour
|
||||
ses propres mondes.
|
||||
|
||||
## Vérification avant livraison
|
||||
|
||||
- Parcours des entrées, pièces et coffres, quatre orientations, marches,
|
||||
supports et limites d’écriture pour chaque type.
|
||||
- Connexions des vitres et grilles, angles d’escaliers, comparaison du rendu
|
||||
complet et du rendu découpé selon plusieurs ordres de chunks.
|
||||
- Création et réouverture natives, option désactivée, ancien témoin 19.
|
||||
- `check build assemblePack`, intégrité des artefacts, publication immuable,
|
||||
deux synchronisations isolées puis deux dans la même instance Prism.
|
||||
|
||||
## Reçus natifs : infrastructures et réseaux oubliés
|
||||
|
||||
**Création et réouverture réussies**, dans deux JVM distinctes, pour un monde
|
||||
jetable **Moyen 724, graine 0**, structures et structures expérimentales activées,
|
||||
codec `sanctuary:island_v20`. Les rapports locaux conservés sont
|
||||
`build/alpha20-evidence/heritage20-create.json` (processus 39381) et
|
||||
`build/alpha20-evidence/heritage20-reload.json` (processus 39736).
|
||||
Les journaux correspondants sont `build/alpha20-heritage-create-2.log` et
|
||||
`build/alpha20-heritage-reload.log`. Ces fichiers de développement restent
|
||||
ignorés par Git ; les valeurs utiles sont transcrites ci-dessous.
|
||||
|
||||
| Vérification | Création | Réouverture |
|
||||
| --- | --- | --- |
|
||||
| Sites expérimentaux naturels | 13 types présents sur 14 | Mêmes 13 sites |
|
||||
| Structures natives des sites et voies | 85 starts, 112 pièces | Mêmes empreintes NBT et références |
|
||||
| Positions de blocs contrôlées pour sites et voies | 80 487 | 80 487, hors modification témoin autorisée |
|
||||
| Chunks `FULL` contrôlés pour sites, voies et réseaux oubliés | 120 | 120 |
|
||||
| Contrôles de roche porteuse | 2 882 | 2 882 |
|
||||
| Coffres des sites | 13 butins différés, non ouverts | Tables et graines conservées |
|
||||
| Réseaux oubliés | 3 réseaux, 15 pièces, 7 639 positions contrôlées | Mêmes plans et structures natives |
|
||||
| Coffres des réseaux oubliés | 3 butins différés, non ouverts | Tables et graines conservées |
|
||||
| Parcours depuis les entrées | 68 cibles dans les sites et 49 dans les réseaux oubliés | Parcours revérifiés |
|
||||
| Modification témoin | Bloc d’or placé en `-203 255 -13` | Bloc d’or conservé |
|
||||
|
||||
La cartothèque d’expédition (`EXPEDITION_OFFICE`) n’a pas trouvé d’emplacement
|
||||
sur cette graine. Elle fait partie du catalogue et de ses smokes, mais ce reçu
|
||||
ne constitue pas une preuve de sa génération naturelle. Les quatorze tables
|
||||
de butin sont échantillonnées séparément sans consommer les coffres sauvegardés.
|
||||
Les portes et trappes ouvertes pendant le parcours retrouvent leur état initial.
|
||||
Aucune expansion ni sauvegarde personnelle n’est ouverte dans ces essais.
|
||||
|
||||
Le plan des infrastructures conserve l’empreinte
|
||||
`7f476c2ecca703a05bf88a550c61cc5cbeff2594024c43ccd9f3620bbc2ad3de`
|
||||
entre création et réouverture. Celui des réseaux oubliés conserve
|
||||
`7358ecd7841c03be1977a7f45f37c0c3ef83a32dc27e8d3ec4f0d85d6ee5d3ef`.
|
||||
Les pièces passent aussi un aller-retour NBT exact et refusent un numéro de
|
||||
schéma inconnu.
|
||||
|
||||
### Portée des vérifications de connexion
|
||||
|
||||
Les états complets de **594 blocs détaillés** des infrastructures sont comparés
|
||||
au rendu : 362 vitres ou barreaux, 49 clôtures, 18 murets et 165 escaliers.
|
||||
Sur ce total, **565** sont aussi confrontés aux règles natives de mise à jour
|
||||
des voisins (`updateShape`), avec les tags du serveur chargés. **Onze raccords
|
||||
de vitres ou barreaux traversent une frontière de chunk** et restent connectés.
|
||||
|
||||
Les **29 autres blocs détaillés** ont un voisinage extérieur au plan : leur
|
||||
état sauvegardé est bien comparé au rendu, mais ils sont exclus de cet oracle
|
||||
natif. Le compteur `externalNeighbors=29` désigne ces 29 blocs contrôlés,
|
||||
non un nombre de voisins uniques ; aucune stabilité complète vis-à-vis de ce
|
||||
voisinage extérieur n’est revendiquée. Les réseaux oubliés passent pour leur
|
||||
part **211 comparaisons d’états et 211 vérifications natives** : 6 vitres ou
|
||||
barreaux, 1 clôture et 204 escaliers. Ces résultats sont identiques à la
|
||||
réouverture.
|
||||
|
||||
### Coordonnées du monde témoin
|
||||
|
||||
Créer un nouveau monde **Moyen, graine 0**, avec les deux options de structures
|
||||
activées. Les coordonnées indiquent les pieds à l’entrée, pas le centre d’un
|
||||
toit. `/sanctuary structures` liste les lieux ;
|
||||
`/locate structure sanctuary:heritage_networks`, recherché depuis `0 250 0`
|
||||
dans le test, désigne l’entrée du refuge de chantier.
|
||||
|
||||
| Lieu | Entrée X Y Z |
|
||||
| --- | --- |
|
||||
| Gare de fret | `-110 252 -144` |
|
||||
| Dépôt communal | `-75 254 -184` |
|
||||
| Atelier ferroviaire | `-83 253 -83` |
|
||||
| Château d’eau | `164 252 -3` |
|
||||
| Serre | `173 252 -42` |
|
||||
| Observatoire | `51 251 210` |
|
||||
| Quai sur le vide | `184 181 218` |
|
||||
| Refuge de chantier | `-10 251 -15` |
|
||||
| Réseau minier oublié | `78 252 179` |
|
||||
| Salles étranges oubliées | `-194 254 -22` |
|
||||
| Réseau technique oublié | `116 253 -157` |
|
||||
|
||||
Sept liaisons sont parcourues dans le monde natif. La voie dépôt–château d’eau
|
||||
compte **499 positions**, 478 rails présents et 21 rails volontairement absents,
|
||||
avec une emprise de 245 blocs en X et 181 en Z. Le test prouve un parcours à pied,
|
||||
le ballast et les formes de rails sauvegardées ; il ne prouve pas un trajet
|
||||
ininterrompu en wagonnet sur ces voies abandonnées.
|
||||
|
||||
## Reçu natif : ville, expansion et grands sous-sols
|
||||
|
||||
**Création réussie ; réouverture encore en cours.** Le rapport
|
||||
`build/alpha20-evidence/city20-create.json` (processus 40221), associé au journal
|
||||
`build/alpha20-city-create.log`, couvre deux villes de génération 20 dans un
|
||||
monde de développement jetable. L’île initiale est **Moyen 724, graine 0**.
|
||||
Après trois prospections en lecture seule, une expansion de diamètre **256**
|
||||
est effectivement préparée : `city16_0_2`, graine `9111000990819250332`, centre
|
||||
`2000 -608`, climat `lost_city`. Les deux premiers prospects sont restés sans
|
||||
ville et n’ont pas été activés. L’identifiant de test historique ne change pas
|
||||
la version 20 enregistrée dans cette expansion.
|
||||
|
||||
| Mesure | Ville initiale | Ville d’expansion |
|
||||
| --- | --- | --- |
|
||||
| Pièces natives | 48 | 23 |
|
||||
| Chunks `FULL` inspectés autour des districts | 43 | 19 |
|
||||
| Bâtiments parcourus | Immeuble, hôtel, bibliothèque | Immeuble, hall |
|
||||
| Cibles intérieures et de toit atteintes | 65 | 46 |
|
||||
| Entrées reliées par les rues et les porches seuls | 5 | 2 |
|
||||
| Pièces de rue ou pont traversées | 33 | 17, dont un pont |
|
||||
| Appuis contrôlés | 71 | 3 |
|
||||
| Coffres gardant leur butin différé, non ouvert | 3 | 2 |
|
||||
| Témoins de biome urbain | 38 | 19 |
|
||||
|
||||
Les **71 pièces** sont issues des plans naturels des deux îles. Le parcours
|
||||
urbain ne prend aucun raccourci par le terrain naturel, les intérieurs ou les
|
||||
toits : il confirme la continuité des entrées par les rues dessinées.
|
||||
La table native d’apparition des monstres est vérifiée comme limitée aux
|
||||
zombies vanilla ; cela ne mesure pas un nombre de zombies effectivement apparus.
|
||||
Le pont de l’expansion se traverse de `2000 226 -613` à `2000 224 -597`.
|
||||
Aucune pile de viaduc n’est présente dans ces deux districts.
|
||||
|
||||
Vingt-quatre pièces de test supplémentaires couvrent la sauvegarde des six
|
||||
modèles de bâtiments dans quatre orientations. Ce sont des témoins de
|
||||
sérialisation, pas vingt-quatre bâtiments naturels. Restaurant et caserne,
|
||||
ainsi que la piscine extérieure, ne sont pas présents dans ces deux villes ;
|
||||
leurs smokes ne constituent pas une preuve d’apparition naturelle ici.
|
||||
|
||||
### Grands équipements du témoin initial
|
||||
|
||||
| Repère | Géométrie ou coordonnées constatées |
|
||||
| --- | --- |
|
||||
| Entrée de l’immeuble | `-30 252 21` |
|
||||
| Entrée de l’hôtel | `-8 252 21` |
|
||||
| Entrée de la bibliothèque | `-52 252 43` |
|
||||
| Trappe d’accès aux sous-sols, position du bloc | `-19 252 41` |
|
||||
| Grande piscine, emprise du bâtiment | De `-47 224 -26` à `9 236 4` |
|
||||
| Volume d’eau du bassin | 50 × 25 blocs, quatre couches ; de `-44 225 -23` à `5 228 1`, avec les marches dans cette emprise |
|
||||
| Grande salle sèche, emprise | De `-54 228 8` à `-30 237 32`, niveau d’entrée 229 |
|
||||
| Parking, emprise | De `-8 116 8` à `22 237 32` |
|
||||
| Huit planchers du parking, niveaux Y | `117, 133, 149, 165, 181, 197, 213, 229` |
|
||||
| Bouche de sortie de l’égout | `-50 117 20` |
|
||||
|
||||
La piscine conserve ses 40 appuis, la grande salle 16, le parking 9 et la
|
||||
sortie d’égout 6. Ces présences sont constatées sur cette graine ; elles ne
|
||||
sont pas garanties sur toutes les îles.
|
||||
|
||||
### Fluides et connexions en création
|
||||
|
||||
L’essai observe **120 ticks du monde** après la mise en activité des chunks.
|
||||
Dix-neuf petits témoins temporaires fermés, placés dans le ciel, démontrent
|
||||
l’exécution réelle des fluides par une descente d’eau observée dans chaque
|
||||
chunk concerné. Ils sont retirés avant la sauvegarde et exclus des quantités
|
||||
d’eau des structures.
|
||||
|
||||
Après cette simulation, le grand bassin garde **4 976 cellules d’eau** dans
|
||||
son enceinte, et chaque égout conserve ses cinq cellules contrôlées. Les deux
|
||||
bouches gardent leur source et produisent de l’eau à l’extérieur. Leur écoulement
|
||||
rencontre cependant du terrain : premier bloc solide sous les sorties aux
|
||||
niveaux **113** et **191**. Ce témoin prouve des sorties d’eau actives, pas une
|
||||
chute libre continue jusqu’au vide.
|
||||
|
||||
Les chiffres de connexion suivants sont ceux de l’inspection initiale des
|
||||
pièces, avant la simulation des fluides. Le contrôle de réouverture ci-dessous complète ces premières mesures.
|
||||
|
||||
| États détaillés | Ville initiale | Expansion | Total |
|
||||
| --- | --- | --- | --- |
|
||||
| Vitres ou barreaux | 1 457 | 577 | 2 034 |
|
||||
| Clôtures | 36 | 14 | 50 |
|
||||
| Escaliers | 1 451 | 699 | 2 150 |
|
||||
| Comparaisons complètes au rendu | 2 944 | 1 290 | 4 234 |
|
||||
| Vérifications supplémentaires par règles natives | 2 277 | 1 276 | 3 553 |
|
||||
| Blocs exclus de cet oracle pour voisinage extérieur | 667 | 14 | 681 |
|
||||
| Raccords de vitres/barreaux à travers des frontières de chunks | 82 | 22 | 104 |
|
||||
|
||||
Les **681 exclusions** gardent leur comparaison d’état au rendu. Elles ne
|
||||
prouvent pas la stabilité de la connexion face au voisinage extérieur, comme
|
||||
pour les infrastructures. Aucun muret n’est représenté dans cette partie du
|
||||
contrôle urbain. Le bloc d’or témoin est placé en `-38 252 21` et le journal
|
||||
est sauvegardé avec l’empreinte
|
||||
`e776dcab879458b3268ad34f44a003cb53b8b03cfcb67378559d40732f8ce73f` ;
|
||||
ils sont conservés à la réouverture.
|
||||
|
||||
### Réouverture de la ville et raccords avec le terrain
|
||||
|
||||
La réouverture passe dans une seconde JVM (40687), avec **71 pièces natives**,
|
||||
**5 coffres différés**, **74 appuis**, **111 cibles accessibles**, le bloc d’or et
|
||||
le journal conservés. Reçu : `build/alpha20-evidence/city20-reload.json` ; journal
|
||||
`build/alpha20-city-reload-2.log`. La piscine et les sorties d’eau sont revérifiées.
|
||||
|
||||
Le test confronte les raccords au voisinage réellement présent. Au coin du
|
||||
parking `-8 118 8`, les grilles touchent de la deepslate au nord et à l’ouest :
|
||||
Minecraft ajoute légitimement ces raccords après une mise à jour de blocs.
|
||||
Le contrôle refuse tout changement de matériau, orientation, demi-bloc ou
|
||||
waterlogging ; seules les propriétés de raccord peuvent suivre les règles
|
||||
natives. À l’intérieur d’une géométrie connue, l’état du rendu reste exigé.
|
||||
|
||||
Sur les **4 234 blocs détaillés**, **4 178** sont alors des états stables selon
|
||||
l’oracle Minecraft ; **640** de ces états ont un voisinage extérieur ou un
|
||||
voisin ayant lui-même évolué. **56** autres gardent exactement leur état de
|
||||
plan et attendent une mise à jour native extérieure : ils sont comptés
|
||||
séparément, sans revendiquer leur stabilisation. Les **104 raccords entre
|
||||
chunks** restent présents. `externalNeighbors=696` compte les blocs dont le
|
||||
voisinage n’est plus entièrement identique au plan, dont les 640 + 56 cas ;
|
||||
ce compteur a donc une portée plus large que les 681 exclusions initiales.
|
||||
|
||||
## Compatibilité avec la version 19 publiée
|
||||
|
||||
Avec le binaire 20, les deux rapports natifs 19 sont **identiques intégralement**
|
||||
aux reçus publiés, en retirant seulement le PID et le chemin du monde de test.
|
||||
La comparaison porte sur plans, pièces, paramètres, parcours, supports, butins
|
||||
et modification témoin, à la création comme à la réouverture.
|
||||
|
||||
- Création canonique SHA-256 : `3b055a3bc0fc2ddf4146aef035f5103bb7fe20d55a86fa1d4b87aeedc02f7879`.
|
||||
- Réouverture canonique SHA-256 : `aed0962f8dfbfbbf69da1b2153861801c58a3ea2376e6bbec2ef44b90d555d63`.
|
||||
- Référence source publiée : `c23e72b8e6fd8308855459f26c08082a68e81b61`.
|
||||
- Reçus : `build/alpha20-evidence/legacy19-create.json` et `legacy19-reload.json`.
|
||||
|
||||
Les renderers, modèles et pièces historiques restent inchangés ; le preset 19
|
||||
caché est identique octet par octet au preset public de la version publiée.
|
||||
Les journaux refusent les chargements croisés 19/20 au lieu de convertir un monde.
|
||||
|
||||
## Option désactivée et petite île
|
||||
|
||||
Le scénario **Moyen, graine 0, option désactivée** passe : plan expérimental
|
||||
vide, aucun start natif expérimental et aucune entrée localisable. Le paramètre
|
||||
est enregistré. Reçu : `build/alpha20-evidence/experimental-off.json`.
|
||||
|
||||
Le témoin **Petit 512, graine 42, option activée** passe avec dix types de lieux,
|
||||
35 pièces de sites/voies et 50 chunks `FULL` contrôlés, réseaux oubliés compris.
|
||||
La cartothèque est présente, entrée **`-101 251 -25`**, et ses cinq cibles sont
|
||||
accessibles. Les **436 états détaillés** des infrastructures passent l’oracle
|
||||
natif, dont un avec voisin extérieur ; vingt raccords traversent des frontières
|
||||
de chunks. Reçu : `build/alpha20-evidence/small42-create.json`.
|
||||
|
||||
Les deux témoins 20 réunis rencontrent et parcourent les **quatorze types
|
||||
d’infrastructures**. Ils ne garantissent pas leur présence sur toutes les îles.
|
||||
La génération native 20 Grand n’est pas rejouée ici : ses réglages sont couverts
|
||||
par les contrôles de codec et les plans de placement conservés. Les six modèles
|
||||
urbains sont vérifiés dans les quatre orientations ; leur apparition naturelle
|
||||
est distinguée des fixtures ci-dessus.
|
||||
|
||||
## Prévisualisation et état de livraison
|
||||
|
||||
Le [montage du catalogue](architecture-alpha20.md) provient des exports de
|
||||
blocs des renderers et des modèles Minecraft. Il permet de comparer les
|
||||
silhouettes, matières, escaliers, vitres et corniches. Il ne montre ni le
|
||||
terrain final ni le rendu d’un client avec ses shaders ; ce n’est pas une
|
||||
capture de partie et il ne remplace pas les essais de circulation ou de lumière.
|
||||
|
||||
| Étape | État de ce reçu |
|
||||
| --- | --- |
|
||||
| Infrastructures et petits réseaux : création/réouverture natives | Réussi, dans le périmètre détaillé ci-dessus |
|
||||
| Ville 20, espaces publics et grands sous-sols : essais natifs | Création et réouverture réussies, 71 pièces et 5 coffres conservés |
|
||||
| Compatibilité avec le témoin 19 publié | Rapports complets identiques à la création et à la réouverture |
|
||||
| Autres configurations | Petit 512/graine 42 et option désactivée passent ; Grand 20 non rejoué nativement |
|
||||
| `check build assemblePack` final et intégrité des artefacts | Réussi ; huit GameTests généraux, JAR/MRpack/ZIP et hashes vérifiés |
|
||||
| Publication, canal packwiz et synchronisations Prism | Réussi ; deux passages isolés puis deux dans la même instance, 925 fichiers personnels et réglages préservés |
|
||||
|
||||
`./gradlew check build assemblePack --max-workers=1` passe en 4 min 39 s sur
|
||||
la machine de développement : 62 tâches, dont 55 exécutées, huit GameTests,
|
||||
125 chunks `FULL`, 5 923 blocs d’eau conservés et 1 800 ticks de fluides.
|
||||
Les tests des sept nouveaux composants 20 et des anciennes générations passent.
|
||||
Les réglages des trois tailles et leur sauvegarde passent également.
|
||||
Journal : `build/alpha20-check-build-pack.log`.
|
||||
|
||||
Le JAR de production ne contient aucune classe de test. Son identité est
|
||||
vérifiée dans le MRpack et le pack local ; les index et le bootstrap officiel
|
||||
Prism sont contrôlés. SHA-256 du JAR :
|
||||
`9ea10576e641d83c13e1277960a375448a22d416a98a6b327c4d6d2a204c423a`.
|
||||
Reçu : `build/alpha20-artifact-validation.log`.
|
||||
|
||||
Release immuable depuis `0edac29`, canal packwiz `4e0967d` et deux
|
||||
synchronisations isolées vérifiés. Les deux passages dans la même instance
|
||||
Prism conservent les hashes de 925 fichiers personnels et réglages. Un seul
|
||||
JAR20 est actif ; JAR19 et suivi packwiz sont sauvegardés avant remplacement.
|
||||
Voir le [reçu de distribution](packwiz.md#alpha20-publiée--10-septembre-2026).
|
||||
Aucun essai client visuel ni essai Windows natif n’a été effectué.
|
||||
@@ -0,0 +1,140 @@
|
||||
# Alpha.21 — contrat et vérification
|
||||
|
||||
Ticket WG-24, branche `codex/palettes-reseaux-alpha21`.
|
||||
Minecraft 26.3-pre-2, Fabric Loader 0.19.5, Fabric API 0.160.0+26.3,
|
||||
Java 25. Les dépendances restent celles de l’alpha.20.
|
||||
|
||||
## Résultat recherché
|
||||
|
||||
La ville reprend une palette de pierre lisse, pierre, briques de pierre,
|
||||
andésite et chêne. Les plans intérieurs sont conservés ; les corrections
|
||||
portent sur les matériaux, les appuis et les couvertures. Chaque infrastructure
|
||||
emploie un bois cohérent. Le tuf reste surtout au sol et dans les sous-sols.
|
||||
|
||||
La ville peut accueillir deux petits quartiers supplémentaires reliés à son
|
||||
cœur, avec du terrain naturel entre eux. La réserve centrale existante n’est
|
||||
pas agrandie. Les infrastructures reçoivent davantage de chemins entre des
|
||||
entrées réelles. Les recherches respectent des budgets de colonnes et refusent
|
||||
un quartier si sa liaison entière ne peut pas être construite.
|
||||
|
||||
Les galeries industrielles expérimentales ont cinq blocs de chaussée et un
|
||||
trottoir de chaque côté, des salles de maintenance et deux accès par escaliers.
|
||||
Le plan est recherché après les structures précédentes et évite leurs volumes,
|
||||
l’hydrologie. Un tablier continu peut franchir une cavité entre ses appuis ;
|
||||
les travées sans appuis complets sont limitées à 34 blocs, avec des piliers
|
||||
locaux d’au plus 16 blocs et deux couches de roche intacte sous les appuis. Chaque tronçon a une pièce native
|
||||
locale ; aucun démarrage de structure ne charge toute l’île.
|
||||
|
||||
## Sauvegardes et comparaison
|
||||
|
||||
Créer un **nouveau monde Sanctuary**, taille **Moyen**, graine **0**, avec
|
||||
**Structures expérimentales** activées. Petit 512, Moyen 724 et Grand 1024 restent
|
||||
les tailles proposées par le bouton natif **Personnaliser**.
|
||||
|
||||
Le nouveau codec est `sanctuary:island_v21`. Les codecs et pièces 20 et
|
||||
antérieurs restent disponibles, sans modifier leurs rendus. Le journal 21
|
||||
réutilise le schéma de persistance existant avec une génération distincte ;
|
||||
les ouvertures entre versions incompatibles sont refusées. Aucune conversion
|
||||
ni rénovation automatique des mondes précédents n’est effectuée.
|
||||
|
||||
Pour comparer sans les infrastructures, créer un autre monde avec l’option
|
||||
expérimentale désactivée. Une sauvegarde 21 nécessite le binaire 21 ou un futur
|
||||
binaire compatible ; elle ne se rétrograde pas en remplaçant simplement le JAR.
|
||||
|
||||
## Compatibilité vérifiée
|
||||
|
||||
373 fichiers de production historiques sont identiques au commit de publication
|
||||
20 (`0edac29`). Le preset caché `sanctuary_v20` est une copie exacte de son
|
||||
ancien preset public. Création et réouverture natives de la génération 20 donnent
|
||||
les mêmes plans, structures, appuis, accès et coffres que les rapports publiés.
|
||||
La comparaison ignore seulement l’identifiant du processus, le chemin du monde
|
||||
et deux nouveaux compteurs de détail ajoutés à l’oracle de connexion des tests.
|
||||
|
||||
## Galeries vérifiées dans Minecraft
|
||||
|
||||
Moyen, graine 0 : 23 modules dont deux accès et une salle, sur un axe de 340 blocs.
|
||||
Les entrées sont `-135 253 -178` et `-135 249 162` ; chaussée à Y 216. La portée
|
||||
sans appuis complets la plus longue du témoin est 17 blocs. Le plan emploie
|
||||
8 686 colonnes de bruit, avec un budget maximal de 12 000 ; cette recherche prend
|
||||
environ 11 secondes sur la machine de développement, hors reste du monde.
|
||||
|
||||
La création et la réouverture dans deux JVM distinctes passent : 34 chunks
|
||||
FULL, 57 635 blocs vérifiés, mêmes pièces natives, mêmes coffres différés et
|
||||
modification témoin conservée. L’oracle de collision de Minecraft vérifie un
|
||||
corps de 0,6×1,8 bloc, 74 cibles et 520 pas entre les deux portiques ; il utilise
|
||||
les vrais escaliers et les demi-marches des trottoirs.
|
||||
|
||||
Une alcôve d’excavation inachevée ouvre le parement de la salle sur une paroi
|
||||
irrégulière de tuf, pierre et deepslate. Certains tronçons exposent de petits
|
||||
filons ordinaires. Le témoin contient cinq minerais de charbon, dix-neuf de
|
||||
fer, cinq de redstone, un de diamant et un d’émeraude ajoutés dans ces fronts.
|
||||
Cuivre, or et lapis font aussi partie des variantes possibles. Ce sont des
|
||||
blocs finis, sans mécanisme de réapparition après minage. Ces quantités excluent
|
||||
les minerais naturels de l’île et ne constituent pas une garantie par graine.
|
||||
|
||||
## Autres vérifications
|
||||
|
||||
La création et la réouverture natives de la ville passent. Le témoin possède
|
||||
un cœur et deux quartiers reliés, 65 pièces de rue, trois immeubles de logements,
|
||||
un hôtel, une bibliothèque, un jardin et une place. La réserve centrale n’est
|
||||
pas étendue. Les deux nouveaux chemins sont longs de 51 et 38 cellules. Une
|
||||
expansion de test distincte est également vérifiée ; aucune expansion personnelle
|
||||
n’est activée.
|
||||
|
||||
La piscine couverte, le garage, la salle d’expansion, leurs accès et les égouts
|
||||
restent présents. Les contrôles natifs vérifient les bassins et sorties après
|
||||
exécution observée de la simulation des fluides.
|
||||
|
||||
Les quatorze types de lieux patrimoniaux apparaissent sur Moyen, graine 0,
|
||||
avec douze liaisons et 127 segments. Leur création native passe : 141 pièces,
|
||||
91 271 blocs, 140 chunks FULL et quatorze coffres différés. Les trois réseaux
|
||||
oubliés sont également parcourus. Les chemins rejoignent deux entrées de ville.
|
||||
L’observatoire et le quai du vide restent isolés sur ce témoin : leurs chemins
|
||||
n’ont pas trouvé de tracé admissible dans le budget. La commande `/sanctuary structures` indique leurs entrées ; aucun raccord
|
||||
construit complet n’est revendiqué.
|
||||
|
||||
Les smokes des renderers, plans, pièces enregistrées et raccords passent.
|
||||
La réouverture des lieux patrimoniaux conserve également le plan, les pièces,
|
||||
les coffres et la modification témoin. L’option expérimentale désactivée passe :
|
||||
elle ne publie aucun module de galerie. `check build assemblePack` passe, avec les huit GameTests généraux. Le
|
||||
MRpack, son index et le JAR embarqué sont vérifiés. La release et le canal
|
||||
packwiz sont publiés. Deux synchronisations isolées puis deux dans la même
|
||||
instance Prism conservent les 925 fichiers personnels et réglages suivis.
|
||||
Voir le [reçu de distribution](packwiz.md#alpha21-publiée--10-septembre-2026).
|
||||
|
||||
Les chemins de quartier regroupent leurs pentes à l’intérieur de rectangles ;
|
||||
leurs frontières et raccords sont des paliers plats. Les structures restent
|
||||
conditionnées par le terrain admissible, dans un budget borné. La traversée
|
||||
industrielle ne relie pas encore tous les réseaux souterrains historiques.
|
||||
|
||||
Les vues de modèles éventuelles ne remplacent pas une inspection dans le client.
|
||||
Aucune validation Windows native ni charge multijoueur n’est revendiquée.
|
||||
|
||||
|
||||
## Reproduire les contrôles
|
||||
|
||||
Depuis ce dépôt, avec Java 25, les mondes de test restent sous `mods/sanctuary/build/`.
|
||||
Pour chaque scénario, exécuter la création puis sa réouverture avant tout autre
|
||||
scénario qui nettoie ce monde de développement :
|
||||
|
||||
```sh
|
||||
./gradlew :sanctuary:runGameTest -PsanctuaryTransit21Tests=true -PsanctuaryResourceSurvey=off -PsanctuaryDensityMaps=false --max-workers=1
|
||||
./gradlew :sanctuary:runGameTest -PsanctuaryTransit21Tests=true -PsanctuaryExpansionReload=true -PsanctuaryResourceSurvey=off -PsanctuaryDensityMaps=false --max-workers=1
|
||||
```
|
||||
|
||||
Remplacer `sanctuaryTransit21Tests` par `sanctuaryLostCity21Tests` pour la ville
|
||||
ou `sanctuaryHeritage21Tests` pour les infrastructures. Le cas OFF ajoute
|
||||
`-PsanctuaryExperimentalStructures=false` à une création du scénario transit.
|
||||
Les rapports de cette livraison sont conservés localement dans
|
||||
`build/alpha21-evidence/`. `./gradlew check build assemblePack` constitue la
|
||||
vérification complète avant export.
|
||||
|
||||
## Artefacts vérifiés
|
||||
|
||||
MRpack : `Sanctuary-0.1.0-alpha.21.mrpack`. Son JAR est identique au JAR du build.
|
||||
Les versions et hashes de l’index packwiz sont contrôlés, ainsi que le ZIP
|
||||
d’amorçage Prism. SHA-256 du JAR :
|
||||
|
||||
```text
|
||||
e528e42d99f9e1ea221f780ea089b49b42a1a4e9e24e4ddd001d045183202c21
|
||||
```
|
||||
@@ -0,0 +1,153 @@
|
||||
# Alpha.22 — placement sélectif
|
||||
|
||||
Ticket WG-25, branche `codex/placement-selectif-alpha22`.
|
||||
Minecraft 26.3-pre-2, Fabric Loader 0.19.5, Fabric API 0.160.0+26.3 et Java25,
|
||||
sans changement de dépendances.
|
||||
|
||||
## Contrat
|
||||
|
||||
Les bâtiments de surface redeviennent sélectifs : une ville peut être absente
|
||||
si aucun emplacement n’est adéquat. Deux éléments de base sont prioritaires :
|
||||
**la grande traversée souterraine et la salle d’expansion**, même sans ville.
|
||||
Leurs emplacements sont réservés avant les petits réseaux et le catalogue
|
||||
expérimental. Une recherche bornée ne prouve pas qu’aucun autre emplacement
|
||||
possible n’existe dans toute l’île.
|
||||
|
||||
- Ville : aucune réserve artificielle de secours, aucun pilier de rattrapage,
|
||||
terrassement/remblai limité à deux blocs par colonne. Les fondations sont
|
||||
entièrement recertifiées dans la roche. Les quartiers supplémentaires exigent
|
||||
un chemin complet vers les quartiers retenus. Au plus trois propositions dans
|
||||
un budget partagé de20 000 colonnes et1 120 000 contrôles de volume.
|
||||
- Infrastructures : relief maximal de quatre blocs sur l’emprise17×17, coupe et
|
||||
remblai limités à deux blocs, deux couches de roche intacte sous chaque colonne
|
||||
de fondation, sans piliers de secours. Jusqu’à24 candidats par famille, avec
|
||||
les mêmes plafonds globaux de16 000 colonnes et800 000 sondages.
|
||||
- Chemins patrimoniaux : coupe/remblai limité à un bloc, accès indépendant et
|
||||
raccord complet requis pour publier une liaison.
|
||||
- Traversée : conserve le génie civil21, avec deux accès réels, une chaussée
|
||||
de cinq blocs et deux trottoirs. Les piliers sont bornés à16 blocs ; les
|
||||
travées sans grille complète sont limitées à34 blocs et reposent sur les
|
||||
modules adjacents. La recherche22 intervient avant les structures facultatives
|
||||
pour leur réserver l’emprise. Si les lignes droites sont refusées, une seconde
|
||||
passe cherche des accès différents et des détours. Chaque passe est limitée à
|
||||
12 000 colonnes et3 millions de sondages (24 000 et6 millions au total au plus).
|
||||
Ses parois peuvent traverser des cavités existantes sans écraser les volumes
|
||||
d’eau et de lave protégés.
|
||||
- Salle : recherche autonome d’un accès de surface et d’une salle25×25, sans
|
||||
faux quartier ni socle de ville. Une salle déjà présente sous une ville évite
|
||||
un doublon. Les égouts et annexes peuvent accompagner ce lieu indépendant.
|
||||
|
||||
|
||||
Les palettes, les plans intérieurs et les petits filons minables restent ceux
|
||||
de21. Les anciens petits réseaux expérimentaux17 et les sous-sols des villes gardent
|
||||
leur géométrie ; leurs protections restent respectées.
|
||||
Le nouveau principe narratif est documenté dans [la vision](vision.md) et
|
||||
[l’audit](structures-audit.md), sans activer de système de progression.
|
||||
|
||||
## Sauvegardes
|
||||
|
||||
Le seul preset public utilise désormais `sanctuary:island_v22`. Le preset caché
|
||||
`sanctuary_v21` est la copie de l’ancien preset public. Les anciens codecs,
|
||||
planificateurs et rendus restent disponibles. Les pièces21 sont réutilisées
|
||||
avec leur format existant ; les nouveaux coudes possèdent une pièce22 distincte
|
||||
pour fermer leurs murs sans modifier les jonctions21 sauvegardées.
|
||||
La salle indépendante possède un type de structure22
|
||||
et réutilise les pièces souterraines20.
|
||||
Le journal identifie la génération22 et refuse une lecture croisée avec21.
|
||||
Aucun monde personnel n’est ouvert, converti ou régénéré.
|
||||
|
||||
Les nouvelles règles nécessitent un **nouveau monde Sanctuary**. Petit512,
|
||||
Moyen724 par défaut et Grand1024 restent proposés. L’option **Structures
|
||||
expérimentales** reste enregistrée à la création ; en22 elle retire le catalogue
|
||||
facultatif, tandis que la traversée et la salle restent des éléments de base.
|
||||
Le commutateur Minecraft général des structures demeure respecté.
|
||||
|
||||
## Témoin natif Moyen, graine0
|
||||
|
||||
La création et la réouverture dans deux JVM distinctes passent. La ville est
|
||||
refusée ; la traversée comporte23 modules, dont deux accès et une salle de
|
||||
maintenance. Son axe s’étend sur340 blocs. Les accès sont `-170 253 -100` et
|
||||
`170 254 -100`. Le hall d’expansion indépendant se rejoint par la trappe
|
||||
`2 252 0` ; son réseau comprend l’accès, la salle, deux passages et un égout.
|
||||
La piscine est une annexe conditionnelle, absente sur ce témoin.
|
||||
|
||||
Les14 bâtiments patrimoniaux trouvent un terrain adapté ; sept liaisons sont
|
||||
retenues. Les115 chunks de l’emprise sont générés en statut FULL. Les plans,
|
||||
pièces natives et une modification témoin persistent après réouverture. Le
|
||||
contrôle natif de circulation vérifie la vraie trappe, les échelles soutenues,
|
||||
les ouvertures et le trajet jusqu’au socle central. Aucun déplacement de joueur
|
||||
ou chargement d’un monde personnel n’a été utilisé pour ces essais.
|
||||
|
||||
## Vérifications complémentaires
|
||||
|
||||
**Petit512, graine42 :**17 modules, dont un coude sauvegardé avec sa pièce22,
|
||||
et une salle indépendante. Les anciens alignements droits sont refusés ; le
|
||||
repli trouve une paire d’accès naturels et conserve une chaussée continue.
|
||||
Les portiques sont `-68 250 -93` et `68 250 43`, la trappe du hall `43 244 -10`.
|
||||
La marche native relie les sorties en564 déplacements et atteint53 points de
|
||||
contrôle. Huit bâtiments patrimoniaux et six liaisons sont admis ; aucune ville
|
||||
n’est forcée. Les88 chunks de l’emprise sont vérifiés en statut FULL.
|
||||
|
||||
**Grand1024, graine42 :** un quartier naturel est admis avec son réseau de
|
||||
sous-sols : salle d’expansion, piscine, égout et parking. Aucun hall autonome
|
||||
supplémentaire n’est créé. La traversée comporte31 modules et s’étend sur476
|
||||
blocs ; portiques `-272 249 -8` et `204 250 -8`. La marche native les relie
|
||||
en740 déplacements et atteint98 points de contrôle. Quatorze bâtiments
|
||||
patrimoniaux et huit liaisons sont admis. Les179 chunks de l’emprise sont
|
||||
vérifiés en statut FULL ; la salle et ses17 ouvertures sont accessibles.
|
||||
|
||||
Les tests purs des trois tailles passent sur des terrains plats adaptés ;
|
||||
falaises, eau/protections, vides et appuis insuffisants sont refusés pour les
|
||||
bâtiments. Le hall autonome et ses annexes sont vérifiés sans fixture de ville.
|
||||
Les suites historiques restent actives. Avec l’option expérimentale désactivée,
|
||||
le témoin Moyen conserve ses23 modules de traversée et sa salle indépendante,
|
||||
sans bâtiments patrimoniaux ni petits réseaux expérimentaux. La marche native
|
||||
relie les deux sorties en548 déplacements et atteint74 points de contrôle ;
|
||||
les échelles et l’accès au hall restent praticables.
|
||||
|
||||
Les créations et réouvertures de génération21 sont identiques aux rapports de
|
||||
la release21, hors identifiants de processus et dossier de test. Les391 fichiers
|
||||
de production historiques qui ne nécessitent pas de raccord22 restent identiques
|
||||
octet pour octet ; le preset caché21 est la copie exacte du précédent preset
|
||||
public. Les masques sont vérifiés à l’intérieur et hors des structures.
|
||||
|
||||
`check build assemblePack` passe :75 tâches, dont les huit GameTests généraux.
|
||||
Le JAR, l’index packwiz, le MRpack et le ZIP Prism sont vérifiés. Aucun code de
|
||||
test n’est embarqué dans le JAR. SHA-256 du JAR :
|
||||
|
||||
```text
|
||||
10d7ef32ac2e81a977ea4854503bafa29e0bc10929984b76df01d6f5f61f9056
|
||||
```
|
||||
|
||||
SHA-256 du MRpack :
|
||||
|
||||
```text
|
||||
0b553fcdd8b6a2ec26f72059e428d2cc0ce526f36ef8580dd3e50c1dfa40ec78
|
||||
```
|
||||
|
||||
Les reçus de publication et de synchronisation sont suivis dans
|
||||
[la distribution](packwiz.md).
|
||||
|
||||
Ces témoins vérifient les trois tailles, avec et sans ville ; ils ne constituent
|
||||
pas une preuve de présence pour toutes les graines. La recherche reste bornée
|
||||
et refuse un volume protégé ou insuffisamment porté. Aucun essai visuel client
|
||||
ou essai Windows natif n’est revendiqué.
|
||||
|
||||
## Reproduire dans le dossier de développement
|
||||
|
||||
Avec Java25, création du témoin Moyen puis réouverture du même monde de test :
|
||||
|
||||
```sh
|
||||
./gradlew :sanctuary:runGameTest -PsanctuarySelective22Tests=true -PsanctuaryDensityMaps=false
|
||||
./gradlew :sanctuary:runGameTest -PsanctuarySelective22Tests=true -PsanctuaryDensityMaps=false -PsanctuaryExpansionReload=true
|
||||
```
|
||||
|
||||
Pour une nouvelle création Petit ou Grand, ajouter `-PsanctuaryTestSeed=42`
|
||||
et `-PsanctuaryTestDiameter=512` ou `1024`. Le cas OFF utilise
|
||||
`-PsanctuaryExperimentalStructures=false`. Chaque réouverture doit suivre la
|
||||
création correspondante, avec les mêmes paramètres. Les rapports sont dans
|
||||
`mods/sanctuary/build/run/gameTest/diagnostics/selective22-<graine>-<diamètre>/`.
|
||||
|
||||
Le témoin historique utilise `-PsanctuaryHeritage21Tests=true`, puis le même
|
||||
drapeau avec `-PsanctuaryExpansionReload=true`. La vérification de livraison
|
||||
reste `./gradlew check build assemblePack`. Exécuter ces JVM séquentiellement.
|
||||
@@ -0,0 +1,433 @@
|
||||
# Validation alpha.23.1
|
||||
|
||||
Cible : Minecraft 26.3-pre-2, Fabric Loader 0.19.5, Fabric API
|
||||
0.160.0+26.3, Java 25. Branche `codex/natural-secrets-alpha23`, ticket WG-27.
|
||||
|
||||
**Livraison locale vérifiée le 11 septembre 2026.** Les neuf cas de la matrice
|
||||
initiale, les structures natives et leurs réouvertures, les océans échantillonnés
|
||||
et le cycle réel d’expansion passent. `check build`, `assemblePack` et le MRpack
|
||||
sont vérifiés. **Publication et synchronisation Prism restent bloquées par
|
||||
l’authentification Git indisponible.** Le [contrat de génération](generation-alpha23.1.md)
|
||||
décrit le périmètre ; les limites de chaque preuve sont conservées ci-dessous.
|
||||
|
||||
## Environnement et preuves
|
||||
|
||||
Les essais utilisent un serveur Fabric GameTest sans interface graphique sur
|
||||
Mac, dans des mondes de développement ignorés. Aucun monde personnel n’a été
|
||||
ouvert ou modifié. **Windows n’a pas été testé ; aucune validation visuelle
|
||||
client, avec ou sans shaders, n’a été effectuée.**
|
||||
|
||||
Les preuves locales sont dans `build/alpha231-evidence/matrix.json` et les
|
||||
rapports `secrets-<graine>-<diamètre>.json` du même dossier. Pour le Moyen,
|
||||
graine 0, les rapports finaux `final-medium.json` et `final-medium-reload.json`
|
||||
remplacent le résultat intermédiaire de `secrets-0-724.json` ; leurs durées
|
||||
figurent dans `postchecks.json`. Les réouvertures possèdent un rapport
|
||||
`*-reload.json`. Ces fichiers de développement ne sont
|
||||
pas des artefacts publics versionnés. Les journaux correspondants sont indiqués
|
||||
dans la matrice ; les assertions sont dans
|
||||
[Secrets23WorldGameTests](../mods/sanctuary/src/gametest/java/fr/koka/sanctuary/gametest/Secrets23WorldGameTests.java).
|
||||
|
||||
Les premières exécutions précèdent la dernière optimisation du préfiltre
|
||||
minéral. La distinction est conservée ci-dessous, avec la reprise du Moyen,
|
||||
graine 0, et la réouverture du Petit, graine 42, sur le préfiltre final.
|
||||
|
||||
## Créations réellement vérifiées en FULL
|
||||
|
||||
Les neuf cas ci-dessous ont `passed: true` et un code de sortie nul. Dans ces
|
||||
témoins, aucun quartier Lost City n’est demandé sur l’île initiale ; un
|
||||
observatoire et un hall indépendant sont toujours présents. Le réseau d’atelier
|
||||
caché apparaît dans huit cas sur neuf : il n’est pas retenu dans le Petit,
|
||||
graine 0. Lorsqu’il est présent, il ne contient que son accès, un corridor et
|
||||
l’atelier. Le hall n’inclut aucune piscine. Les structures expérimentales sont
|
||||
activées.
|
||||
|
||||
| Graine | Taille nominale | Chunks FULL contrôlés | Modules de traversée | Liaisons patrimoniales | Rails natifs vérifiés | Sanctuaire minéral | État |
|
||||
| --- | --- | ---: | ---: | ---: | ---: | --- | --- |
|
||||
| 0 | Petit 512 | 88 | 19 | 2 | 85 | Présent | Réussi avec le préfiltre final ; atelier caché non retenu |
|
||||
| 0 | Moyen 724 | 85 | 23 | 2 | 68 | Présent | Création et réouverture finales réussies (`final-medium*.json`) |
|
||||
| 0 | Grand 1 024 | 105 | 35 | 2 | 73 | Présent | Réussi avec le préfiltre final |
|
||||
| 42 | Petit 512 | 88 | 17 | 1 | 23 | Présent | Création réussie ; réouverture avec le préfiltre final réussie |
|
||||
| 42 | Moyen 724 | 82 | 23 | 3 | 135 | Présent | Réussi avec le préfiltre final |
|
||||
| 42 | Grand 1 024 | 125 | 31 | 1 | 43 | Présent | Réussi avec le préfiltre final |
|
||||
| 2026 | Petit 512 | 85 | 17 | 2 | 36 | Présent | Réussi avec le préfiltre final |
|
||||
| 2026 | Moyen 724 | 79 | 23 | 1 | 54 | Présent | Réussi avec le préfiltre final |
|
||||
| 2026 | Grand 1 024 | 107 | 31 | 2 | 58 | Présent | Réussi avec le préfiltre final |
|
||||
|
||||
Le nombre de chunks contrôlés correspond aux emprises des structures retenues,
|
||||
pas à toute l’île. Ces neuf témoins ne garantissent pas le même résultat sur
|
||||
toutes les graines.
|
||||
Le nombre de liaisons ne signifie pas que tous les lieux sont reliés : les
|
||||
tronçons ferroviaires locaux peuvent subsister quand un raccord lointain est
|
||||
refusé par le terrain.
|
||||
|
||||
Les durées du runner consignées pour les neuf créations retenues vont de
|
||||
68,38 à 148,52 secondes. Elles incluent le lancement de la JVM, la
|
||||
préparation du monde, la génération FULL des emprises et les assertions.
|
||||
|
||||
| Graine | Petit 512 | Moyen 724 | Grand 1 024 |
|
||||
| --- | ---: | ---: | ---: |
|
||||
| 0 | 78,86 s | 96,19 s | 148,52 s |
|
||||
| 42 | 68,38 s | 79,60 s | 113,23 s |
|
||||
| 2026 | 70,20 s | 89,04 s | 133,05 s |
|
||||
|
||||
Le Moyen, graine 0, utilise ici la durée de sa création finale dans
|
||||
`postchecks.json`, et non les 99,07 secondes de son ancien essai. Sa réouverture
|
||||
finale prend 57,24 secondes.
|
||||
|
||||
**Ce ne sont ni des temps de rendu client, ni un benchmark Windows, ni une
|
||||
mesure du gain de performance par rapport à l’alpha.22.**
|
||||
|
||||
## Ce que le GameTest contrôle
|
||||
|
||||
- Chaque emplacement accepté possède un vrai départ de structure natif. Les
|
||||
pièces sauvegardées retrouvent les mêmes données après sérialisation puis
|
||||
lecture ; leurs emprises sont chargées jusqu’au statut FULL.
|
||||
- La traversée est parcourue par un contrôle des collisions natives pour un
|
||||
volume de joueur de 0,6 × 1,8 bloc. Les montées souterraines exigent un escalier
|
||||
orienté ; les abords naturels des portiques peuvent comporter un saut normal
|
||||
d’un bloc. La trappe, les échelles et les ouvertures du hall sont contrôlées.
|
||||
- Toutes les cellules marquées comme portant un rail possèdent réellement un
|
||||
bloc de rail après décoration, avec un ballast solide dessous. Les lacunes
|
||||
prévues restent réparables ; aucun trajet réel en wagon n’a été testé.
|
||||
- Le centre du sanctuaire minéral est contrôlé par échantillonnage dans les
|
||||
chunks FULL : sol solide et deux blocs d’air au-dessus. Le test pur vérifie
|
||||
aussi l’intégralité du centre de 39 × 39 et les quatre orientations.
|
||||
- Les voies de surface préservent le disque naturel d’arrivée de 48 blocs de
|
||||
rayon. Les volumes retenus ne nécessitent aucune ville de surface.
|
||||
|
||||
Ces contrôles ne constituent pas une appréciation esthétique des ruines ou des
|
||||
cavités. La présence de géométrie et la circulation vérifiée ne valident pas
|
||||
encore l’équilibrage des ressources, l’expérience multijoueur ou les effets
|
||||
visuels de l’eau et de la lumière.
|
||||
|
||||
## Repères de visite — graine 42
|
||||
|
||||
Ces coordonnées proviennent des géométries des rapports. Elles s’appliquent à
|
||||
un **nouveau monde de génération 23**, avec les structures et les secrets
|
||||
expérimentaux activés, dans la taille correspondante. Ce sont des repères de
|
||||
développement ; aucune téléportation dans un monde personnel n’a été effectuée.
|
||||
|
||||
| Lieu ou accès, coordonnées X Y Z | Petit 512 | Moyen 724 | Grand 1 024 |
|
||||
| --- | --- | --- | --- |
|
||||
| Entrée de l’observatoire | `54 243 -40` | `186 251 -110` | `204 250 -121` |
|
||||
| Accès de l’atelier caché | `-45 244 -131` | `-116 250 -157` | `-174 251 -128` |
|
||||
| Trappe du hall indépendant | `32 168 -72` | `-97 223 -53` | `46 256 146` |
|
||||
| Premier portique parcouru | `-68 250 -93` | `-170 256 82` | `-272 249 -8` |
|
||||
| Second portique parcouru | `68 250 43` | `170 252 82` | `204 250 -8` |
|
||||
| Point de localisation intérieur du sanctuaire minéral | `-144 165 -61` | `-121 208 -23` | `-103 144 194` |
|
||||
| Coin minimal de son enveloppe | `-183 161 -97` | `-160 204 -59` | `-142 140 158` |
|
||||
|
||||
L’enveloppe minérale conserve 79 × 73 × 27 blocs — largeur, profondeur, hauteur —
|
||||
et un centre dégagé de 39 × 39. Une ouverture sur un flanc exposé peut donner
|
||||
sur le vide ; les essais ne garantissent pas un chemin extérieur déjà construit
|
||||
jusqu’à elle. Le point de localisation reste dans la salle.
|
||||
|
||||
## Réouverture et limites de l’admission minérale
|
||||
|
||||
Le Petit, graine 42, passe sa réouverture dans une JVM distincte : processus
|
||||
7581 pour la création et 7664 pour la lecture. Les paramètres du générateur,
|
||||
les plans, les départs natifs et la modification témoin de l’observatoire sont
|
||||
conservés. Le sanctuaire reste présent, avec 23 rails natifs dans le monde.
|
||||
La création précédait le préfiltre final ; sa réouverture, avec ce préfiltre,
|
||||
conserve la même géométrie. Ce cas ne valide pas toutes les sauvegardes.
|
||||
|
||||
Le Moyen, graine 0, passe sa création et sa réouverture finales dans deux JVM
|
||||
distinctes, processus 8650 puis 8777 (`final-medium.json` et
|
||||
`final-medium-reload.json`). Le sanctuaire est présent, avec 85 chunks FULL
|
||||
contrôlés et 68 rails natifs. Les paramètres du générateur, les géométries,
|
||||
les départs natifs et la modification témoin sauvegardée sont identiques entre
|
||||
les deux rapports. Le point de localisation intérieur du sanctuaire est
|
||||
`-93 143 81`, dans une enveloppe dont le coin minimal est `-132 139 45`.
|
||||
Ce résultat final remplace le refus minéral de la recherche intermédiaire.
|
||||
|
||||
La recherche du sanctuaire reste bornée : 48 positions, quatre orientations,
|
||||
trois profondeurs, au plus 10 000 colonnes et 1 200 000 sondages. Le préfiltre
|
||||
examine une grille avant la certification détaillée. Celle-ci conserve au moins
|
||||
60 % de couverture et d’appuis directs sur deux blocs de roche native ; chaque
|
||||
colonne sans appui direct doit être à dix blocs au plus d’un appui. Le volume
|
||||
protégé est vérifié intégralement. Le rendu ne pose aucun pilier hors de son
|
||||
enveloppe pour sauver un mauvais emplacement.
|
||||
|
||||
Les diagnostics distinguent ouverture obstruée, couverture ou roche
|
||||
insuffisantes, appuis trop éloignés, volumes protégés et budget épuisé. Un refus
|
||||
ne prouve pas qu’aucun emplacement imaginable n’existe ailleurs dans l’île.
|
||||
Les témoins obtenus ne garantissent donc pas la présence du sanctuaire pour
|
||||
toutes les graines. Les règles des autres structures n’ont pas été assouplies
|
||||
pour faire accepter ce lieu.
|
||||
|
||||
## Autres vérifications
|
||||
|
||||
### Réalisées
|
||||
|
||||
Le smoke ciblé `secrets23Smoke` a passé ses témoins de géométrie, sauvegarde et
|
||||
refus ; `structureCensusSmoke` possède également une réussite dans le journal
|
||||
local `build/alpha23.1-corrected-smokes.log`.
|
||||
|
||||
La suite générale réussit ses **24 GameTests obligatoires** dans
|
||||
`build/alpha23.1-general.log` : 51,84 secondes pour l’exécution des tests et
|
||||
117,75 secondes pour le runner complet. La dernière entrée `general` de
|
||||
`postchecks.json` possède un code de sortie nul. Elle remplace le premier
|
||||
essai interrompu par l’ancienne assertion du nombre de biomes, depuis
|
||||
actualisée. Les suites spécialisées et les commandes finales sont attestées
|
||||
séparément dans les sections suivantes.
|
||||
|
||||
Les deux modes OFF passent dans les mondes de développement de graine 0,
|
||||
taille Moyen 724. Les reçus et les durées se trouvent dans
|
||||
`build/alpha231-evidence/` et `postchecks.json` :
|
||||
|
||||
| Option | Preuve | Résultat contrôlé | Durée du runner |
|
||||
| --- | --- | --- | ---: |
|
||||
| `sanctuaryExperimentalStructures=false` | `optional-off.json` | Aucun observatoire, atelier, sanctuaire minéral ni rail patrimonial ; les 23 modules de traversée et le hall indépendant restent présents. 43 chunks FULL contrôlés, parcours de la traversée et accès du hall réussis. | 69,04 s |
|
||||
| `sanctuaryGenerateStructures=false` | `global-off.json` | Aucun départ natif valide dans les trois chunks contrôlés ; 293 376 positions vérifiées sans les rails et blocs manufacturés ciblés par le test. | 30,50 s |
|
||||
|
||||
Ces essais attestent les comportements observés dans leurs emprises ; le
|
||||
contrôle global OFF n’est pas un inventaire de tous les chunks de l’île.
|
||||
|
||||
La création puis la réouverture du générateur historique
|
||||
`sanctuary:island_v22` passent également pour la graine 0, taille Moyen 724,
|
||||
avec les structures expérimentales activées. Les rapports `legacy22.json`
|
||||
et `legacy22-reload.json` proviennent de JVM distinctes, processus 9088 puis
|
||||
9208, en 130,05 et 86,11 secondes. Ils contrôlent 115 chunks FULL et conservent
|
||||
14 sites patrimoniaux, sept liaisons, 23 modules de traversée, un hall indépendant
|
||||
et la modification témoin sauvegardée.
|
||||
|
||||
`legacy22-comparison.json` compare ces résultats aux rapports alpha.22 de
|
||||
référence `build/alpha22-evidence/native22-create.json` et
|
||||
`native22-reload.json`. Tous les champs de référence restent identiques, à
|
||||
l’exception des identifiants de processus et chemins de mondes, volontairement
|
||||
exclus. Les seules clés supplémentaires autorisées dans les nouveaux rapports
|
||||
sont `transit_native_walk` et `hall_native_access` : ce sont des diagnostics
|
||||
de parcours ajoutés au test, pas une modification du format de sauvegarde.
|
||||
Ils passent aussi : les deux portiques sont reliés par un parcours de 548
|
||||
pas de contrôle et le hall dispose d’un accès utilisable avec 22 blocs d’échelle
|
||||
et huit ouvertures libres.
|
||||
|
||||
Le même reçu atteste que le preset conservé `sanctuary_v22.json` est identique
|
||||
octet par octet à l’ancien preset `sanctuary.json` du commit `e654d56`.
|
||||
Cette comparaison porte sur ce témoin de génération 22 créé et rechargé avec
|
||||
le code actuel ; elle ne constitue ni une migration ni un essai de tous les
|
||||
anciens mondes personnels.
|
||||
|
||||
### Réservations réelles d’expansion
|
||||
|
||||
Quatre appels réels à `ExpansionRuntime.Session.create` passent dans des JVM
|
||||
neuves, sans aperçu d’expansion avant l’appel, sur des mondes de développement
|
||||
de graine 0 et de génération 23. Chaque essai réussit dès le premier identifiant
|
||||
`admission_23_0`, conserve le délai de recherche de production de 30 secondes
|
||||
et termine avec une seule nouvelle île au statut `reserved`.
|
||||
|
||||
Les preuves sont dans `build/alpha231-evidence/admission-costs.json` et les
|
||||
quatre rapports ci-dessous. La durée d’admission est celle de l’appel à
|
||||
`Session.create` ; la durée du runner inclut le lancement et les contrôles.
|
||||
|
||||
| Demande | Preuve | Admission | Runner complet |
|
||||
| --- | --- | ---: | ---: |
|
||||
| 512, tempéré, naturel | `reserve-512-temperate-natural.json` | 206 ms | 53,62 s |
|
||||
| 1 024, tempéré, naturel | `reserve-1024-temperate-natural.json` | 698 ms | 52,33 s |
|
||||
| 1 024, tempéré, océan | `reserve-1024-temperate-ocean.json` | 441 ms | 53,40 s |
|
||||
| 1 024, Lost City, naturel | `reserve-1024-lost_city-natural.json` | 12 849 ms | 64,15 s |
|
||||
|
||||
Le contrôle vérifie la garantie native appliquée par `Session.create`, la
|
||||
relecture du journal durable, la conservation du profil capturé avant l’appel
|
||||
et l’idempotence : répéter le même identifiant ne crée pas une seconde
|
||||
réservation et ne réécrit pas le journal. Le profil initial de priorités est
|
||||
vide dans ces quatre témoins ; ils ne couvrent pas encore son évolution après
|
||||
le recensement d’un continent généré.
|
||||
|
||||
Pour Lost City, le journal
|
||||
`build/alpha23.1-reserve-1024-lost_city-natural.log` atteste un plan accepté
|
||||
comportant un quartier et un réseau souterrain ; cette planification prend
|
||||
12 575 ms à l’intérieur de l’appel d’admission.
|
||||
|
||||
**Ces quatre essais sont des réservations uniquement.** Leurs reçus indiquent
|
||||
`reserve_only: true` et `full_generation_checked: false`. Ils ne valident pas
|
||||
la préparation complète, le passage à `ready`, les blocs posés en FULL ou leur
|
||||
réouverture ; leurs durées ne sont donc pas des temps de génération de
|
||||
continents. Aucune publication ni expansion dans un monde personnel n’est
|
||||
attestée par ces essais.
|
||||
|
||||
### Cycle complet d’une expansion réelle
|
||||
|
||||
`build/alpha231-evidence/admission.json` atteste le passage complet de
|
||||
`Session.create` à `ready`, processus 11335, sur un monde de graine 0 :
|
||||
expansion tempérée naturelle de **256 blocs**, identifiant `admission_23_0`,
|
||||
centre `2096 -160`, graine d’île `-6422943410799146666`. Cette taille est
|
||||
distincte des réservations de 512 et 1 024 blocs mesurées plus haut.
|
||||
|
||||
La première demande est réservée en 1 034 ms sous le délai de 30 secondes.
|
||||
La préparation prend 94 780 ms ; le journal `build/alpha23.1-admission.log`
|
||||
confirme **418 chunks FULL** lorsque l’expansion devient prête. Le runner
|
||||
complet termine avec un code de sortie nul en 160,01 secondes.
|
||||
|
||||
Un portail en ruine natif est effectivement généré au départ de chunk
|
||||
`131 -10`. Le contrôle vérifie la couverture complète du recensement, la
|
||||
présence de ce départ natif, le journal durable et l’idempotence avant et après
|
||||
la préparation. Le profil capturé pour cette réservation reste vide ; après
|
||||
génération, le recensement propose douze familles prioritaires pour les
|
||||
recherches suivantes, sans réécrire le profil de l’île déjà créée.
|
||||
|
||||
Le reçu indique `reserve_only: false`, `census_verified: true`,
|
||||
`idempotent: true` et `passed: true`. Ce terrain distant ne nécessite pas de
|
||||
certificat de réutilisation de chunks du vide.
|
||||
|
||||
`admission-reload.json` confirme la réouverture réussie dans le processus
|
||||
11614, distinct du processus 11335 de création, en 56,07 secondes de runner.
|
||||
L’île est immédiatement retrouvée à l’état `ready`, sans nouvel appel de
|
||||
création (`create_called: false`) ni redémarrage de sa préparation. Le test retrouve le journal à
|
||||
l’identique, le descripteur et son profil, le départ natif et ses références,
|
||||
ainsi que le recensement. La preuve reste limitée à ce cycle tempéré naturel
|
||||
de 256 blocs ; les grandes réservations ne deviennent pas pour autant des
|
||||
témoins FULL.
|
||||
|
||||
### Catalogue et structures natives en FULL
|
||||
|
||||
`build/alpha231-evidence/native-create.json` atteste la réussite de la création
|
||||
native, processus 10548 : **206 chunks FULL contrôlés**, sur cinq témoins de
|
||||
structures. La dernière entrée `native-create` de `postchecks.json` possède
|
||||
un code de sortie nul, en 232,40 secondes de runner. Les assertions sont dans
|
||||
[Native23WorldGameTests](../mods/sanctuary/src/gametest/java/fr/koka/sanctuary/gametest/Native23WorldGameTests.java).
|
||||
Les témoins utilisent des îles et des priorités choisies pour exercer ces
|
||||
structures ; ils ne constituent pas une mesure de leur fréquence naturelle.
|
||||
|
||||
Le catalogue contient exactement les **52 identifiants distincts** du registre
|
||||
Minecraft 26.3-pre-2. Parmi eux, 46 sont classés admissibles dans l’Overworld ;
|
||||
la cité ancienne reste réservée aux Cavernes, quatre entrées au Nether et la
|
||||
cité de l’End à l’End. Cette concordance du catalogue ne signifie pas que les
|
||||
52 structures ont été générées en FULL dans cet essai.
|
||||
|
||||
La vérification d’admission est rejouée avec le descripteur Lost City du témoin
|
||||
de réservation précédent : le quartier et le réseau souterrain existent dans
|
||||
le plan avant et après son insertion dans la liste des îles du générateur.
|
||||
Le placement natif reste accepté lorsque leurs volumes de construction sont
|
||||
pris en compte. Ce contrôle porte sur une ville réellement planifiée,
|
||||
pas sur un plan vide ; il ne valide pas encore son quartier entier en FULL.
|
||||
|
||||
| Témoin FULL | Présences contrôlées après décoration |
|
||||
| --- | --- |
|
||||
| Forteresse (`stronghold`) | Salle de portail native, 12 cadres de portail de l’End, générateur de monstres et coffres. |
|
||||
| Chambres des épreuves (`trial_chambers`) | Générateurs d’épreuves et coffres-forts natifs (`vault`). |
|
||||
| Monument océanique | Salles immergées en prismarine, eau et trois grands gardiens chargés dans le monde ; eau de surface et roche sous le fond vérifiées au centre de l’île témoin. |
|
||||
| Igloo | Neige, coffre du sous-sol natif et échelles de son puits. |
|
||||
| Pyramide du désert | Grès, quatre coffres et neuf TNT du piège natif. |
|
||||
|
||||
Les compteurs bruts `full_blocks` parcourent les emprises des pièces, qui
|
||||
peuvent se recouvrir : leurs valeurs ne forment pas un inventaire de blocs
|
||||
uniques. Ainsi, la valeur 91 pour `vault` n’atteste pas 91 coffres-forts
|
||||
distincts. Le tableau rapporte surtout les présences requises. Aucun combat,
|
||||
déclenchement d’épreuve, ouverture de butin ou usage du portail n’a été joué.
|
||||
|
||||
Les départs gardent leur identité dans le registre, leur géométrie admise et
|
||||
leurs données après sérialisation et lecture. Le monument est adapté au fond
|
||||
océanique et son agencement intérieur se reconstruit avec la graine de l’île.
|
||||
Pour les chambres des épreuves, seule la hauteur absolue de départ est adaptée :
|
||||
les pools, processeurs, alias et contenus natifs restent identiques.
|
||||
|
||||
La localisation par les tags natifs de l’œil de l’Ender et des cartes de
|
||||
monument, de chambres des épreuves et de pyramide trouve les vrais départs.
|
||||
Une sélection mélangeant plusieurs types vanilla réussit également. La
|
||||
recherche en lecture seule conserve les compteurs de références ; avec
|
||||
`skipReferenced`, seul le départ gagnant reçoit une référence supplémentaire.
|
||||
Ces recherches ne changent pas la liste des îles.
|
||||
|
||||
La présence des trois grands gardiens est vérifiée après chargement effectif
|
||||
des entités des chunks du monument. Elle ne repose pas uniquement sur leur
|
||||
NBT sauvegardé. La réouverture réussit aussi : `native-reload.json`, processus
|
||||
10722, contrôle de nouveau 206 chunks FULL. Les données `full_tags` des cinq
|
||||
départs, incluant leurs références, et les compteurs `full_blocks` sont
|
||||
identiques entre création et réouverture ; les trois grands gardiens sont
|
||||
présents après rechargement des entités. Cette preuve reste limitée aux cinq
|
||||
témoins retenus.
|
||||
|
||||
### Six profils océaniques en FULL
|
||||
|
||||
`build/alpha231-evidence/ocean.json` atteste la réussite de la matrice
|
||||
océanique, processus 11735, graine de monde 0, génération 23 : **34 chunks
|
||||
échantillons demandés au statut FULL** pour six îles temporaires. Le runner
|
||||
termine en 91,39 secondes, avec un code de sortie nul. Cette sélection couvre
|
||||
un bassin profond, une rive et l’extérieur de chaque profil, ainsi que les
|
||||
chunks voisins nécessaires aux témoins de glace ; elle ne génère pas la
|
||||
totalité des six océans.
|
||||
|
||||
| Diamètre | Climat | Graine d’île | Eau à Y | Fond au point témoin | Biome profond stocké |
|
||||
| --- | --- | ---: | ---: | ---: | --- |
|
||||
| 512 | Glacial | 23 042 | 220 | 176 | `minecraft:deep_frozen_ocean` |
|
||||
| 512 | Tempéré | 23 143 | 220 | 171 | `minecraft:deep_ocean` |
|
||||
| 512 | Chaud | 23 244 | 220 | 176 | `minecraft:deep_lukewarm_ocean` |
|
||||
| 1 024 | Glacial | 23 345 | 241 | 193 | `minecraft:deep_frozen_ocean` |
|
||||
| 1 024 | Tempéré | 23 446 | 241 | 195 | `minecraft:deep_ocean` |
|
||||
| 1 024 | Chaud | 23 547 | 241 | 198 | `minecraft:deep_lukewarm_ocean` |
|
||||
|
||||
Chaque profil conserve 16 appuis rocheux sur 16 et 16 échantillons immergés
|
||||
sur 16, après décoration native. Les rives stockent `minecraft:snowy_beach`
|
||||
pour les deux profils glaciaux et `minecraft:beach` pour les autres. Les
|
||||
points extérieurs contrôlés restent entièrement dans l’air et le biome
|
||||
`minecraft:the_void`.
|
||||
|
||||
Les deux profils glaciaux passent également un placement explicite des
|
||||
features natives d’iceberg et de glace bleue. Avec la graine de feature
|
||||
23 041, les sommets de glace atteignent respectivement Y 223 et Y 244,
|
||||
au-dessus de leur niveau marin local. Le contexte de décoration de production
|
||||
fournit ce niveau au générateur et à la région, conserve la protection du fond,
|
||||
puis restaure le niveau global à −64. Ces placements explicites contrôlent
|
||||
la compatibilité des features ; ils n’attestent pas une fréquence naturelle
|
||||
d’icebergs dans toutes les graines.
|
||||
|
||||
L’ancien échec `ocean-ice-failure.json` utilisait un tirage d’iceberg pouvant
|
||||
ne poser aucune glace dans le code vanilla. Le nouveau témoin déterministe
|
||||
remplace ce tirage ; `ocean.json` constitue la preuve finale de cette suite.
|
||||
La liste initiale des îles et les fichiers du journal sont inchangés après
|
||||
les essais (`journal_unchanged: true`). **La réouverture des six profils dans
|
||||
une autre JVM n’a pas été exécutée** ; le monument océanique dispose, lui,
|
||||
de la preuve de réouverture décrite plus haut.
|
||||
|
||||
### Fabrication et distribution
|
||||
|
||||
`./gradlew check build` réussit en 3 min 48 s : 80 tâches, dont 73 exécutées.
|
||||
Ses **24 GameTests** passent en 51,12 s, avec les régressions historiques,
|
||||
le Blocodex, les priorités, le journal, le recensement et les protections.
|
||||
`./gradlew assemblePack` réussit en 3 min 45 s : 81 tâches, dont 70 exécutées.
|
||||
Cette seconde commande relance ses dépendances de vérification ; aucun échec.
|
||||
Journaux : `build/alpha23.1-check-build.log` et
|
||||
`build/alpha23.1-assemble-pack.log`.
|
||||
|
||||
L’export packwiz produit `build/Sanctuary-0.1.0-alpha.23.1.mrpack`.
|
||||
Le contrôle des artefacts vérifie les versions, le contenu de l’index packwiz,
|
||||
le JAR embarqué identique au JAR construit, l’absence de classes de test dans
|
||||
le JAR et le bootstrap Prism officiel v0.0.3. Reçu :
|
||||
`build/alpha231-evidence/delivery.json`.
|
||||
|
||||
| Artefact | SHA-256 |
|
||||
| --- | --- |
|
||||
| JAR Sanctuary alpha.23.1 | `906fd2e12be4233676a1a561556508eee7412183698c2cac704dc1191324f136` |
|
||||
| MRpack alpha.23.1 | `d791025721ae52a3bb7b8d385fd5930cd4fc1a2dc9a4fa255ffb72a27a2455ad` |
|
||||
|
||||
Le MRpack est **local**, pas encore publié. Le gestionnaire d’identifiants Git
|
||||
ne fournit aucun accès à `git.botsu.net` ; aucune release ni mise à jour du canal
|
||||
n’a été effectuée. Le canal public a été relu à `0.1.0-alpha.22`.
|
||||
L’instance Prism existante, ses sauvegardes et ses réglages n’ont pas été modifiés.
|
||||
Les synchronisations réelles de l’installateur et de Prism restent à effectuer
|
||||
après publication. Le ZIP d’amorçage préparé pointe vers ce canal stable ; il ne
|
||||
constitue donc pas une installation de l’alpha.23.1 à ce stade.
|
||||
|
||||
La matrice océanique ne possède pas de réouverture complète ; le monument
|
||||
océanique a son témoin de réouverture. Windows et le rendu client restent non testés.
|
||||
|
||||
## Reproduire les essais de secrets
|
||||
|
||||
Utiliser uniquement un dossier de monde de développement prévu pour la création
|
||||
correspondante. Chaque nouvelle création doit disposer d’un monde de test neuf ;
|
||||
une réouverture suit sa création avec la même graine, la même taille et les mêmes
|
||||
options. Exécuter les JVM Gradle séquentiellement.
|
||||
|
||||
```sh
|
||||
./gradlew :sanctuary:secrets23Smoke
|
||||
./gradlew :sanctuary:runGameTest -PsanctuarySecrets23Tests=true -PsanctuaryDensityMaps=false -PsanctuaryTestSeed=42 -PsanctuaryTestDiameter=512
|
||||
./gradlew :sanctuary:runGameTest -PsanctuarySecrets23Tests=true -PsanctuaryDensityMaps=false -PsanctuaryTestSeed=42 -PsanctuaryTestDiameter=512 -PsanctuaryExpansionReload=true
|
||||
```
|
||||
|
||||
Les tailles alternatives utilisent `724` et `1024`. Les scénarios OFF ajoutent
|
||||
respectivement `-PsanctuaryExperimentalStructures=false` ou
|
||||
`-PsanctuaryGenerateStructures=false`. Ces commandes décrivent les contrôles à
|
||||
exécuter ; leur présence dans le rapport n’atteste pas leur réussite. Les rapports
|
||||
originaux du runner sont dans
|
||||
`mods/sanctuary/build/run/gameTest/diagnostics/secrets23-<graine>-<diamètre>/`.
|
||||
@@ -0,0 +1,104 @@
|
||||
# Validation alpha.23 — Blocodex et socle méta
|
||||
|
||||
Relevé du **10 septembre 2026**, branche `codex/blocodex-natif`.
|
||||
Cible : Minecraft **26.3-pre-2**, Fabric Loader **0.19.5**, Fabric API
|
||||
**0.160.0+26.3**, Java **25**, Sanctuary/pack **0.1.0-alpha.23**.
|
||||
Le [contrat Blocodex](blocodex.md) définit les informations et leur couverture.
|
||||
|
||||
## Résultats disponibles
|
||||
|
||||
| Vérification | Résultat observé | Preuve locale |
|
||||
| --- | --- | --- |
|
||||
| Client natif : widgets, interface et connexion au serveur intégré | **Réussie**, `BUILD SUCCESSFUL in 34s` | `build/blocodex-client-network-tests.log` |
|
||||
| Compilation et persistance quotidienne des activités | **Réussies**, `BUILD SUCCESSFUL in 9s` | `build/blocodex-meta-compile.log` |
|
||||
| Persistance de la mémoire personnelle | Smoke réussi dans la passe complète | `build/blocodex-meta-check-build.log`, ligne `Block knowledge smoke passed` |
|
||||
| GameTests natifs | **24/24 réussis**, dont 16 pour le socle méta | `build/blocodex-meta-check-build.log`, `All 24 required tests passed` |
|
||||
| Passe complète et assemblage du pack | **Réussis**, `BUILD SUCCESSFUL in 4m 18s` | `build/blocodex-meta-check-build.log` |
|
||||
|
||||
Les tests de stockage couvrent les instantanés immuables, les compteurs exacts,
|
||||
l’isolement des UUID ou des journées, les identifiants de mods absents, le JSON
|
||||
strict et le refus d’écraser silencieusement un fichier invalide. Leur succès
|
||||
est complété par les tests natifs ci-dessous.
|
||||
|
||||
Les neuf tests de connaissance vérifient poses réussies et refusées, variantes
|
||||
murales, statistiques de minage et jets volontaires, distinction des morts,
|
||||
regard occulté, inventaire/curseur, états et notifications indépendants,
|
||||
sauvegarde après déconnexion depuis un thread réseau, et palettes combinables.
|
||||
Deux tests terrain vérifient pose/remplacement/retrait, exclusion immédiate des
|
||||
comptages obsolètes, couverture et budget partagé entre lectures, sans charger
|
||||
de chunk absent. Deux tests stocks vérifient les quatre catégories, un double
|
||||
coffre ouvert sans double comptage et la conservation du butin non généré.
|
||||
Trois tests d’activité vérifient les actions natives, les quantités datées,
|
||||
la séparation des observations et des actions, la relecture après sauvegarde,
|
||||
les journées absentes et les commandes avec identifiants complets. Le test de
|
||||
fabrication appelle la complétion vanilla d’un item ; il ne joue pas une recette
|
||||
entière dans l’établi. Les huit tests généraux de génération passent aussi.
|
||||
|
||||
## Artefact local vérifié
|
||||
|
||||
Le JAR `mods/sanctuary/build/libs/sanctuary-0.1.0-alpha.23.jar` mesure
|
||||
**1 914 798 octets**. Sa copie dans `build/packwiz/mods/` est identique.
|
||||
SHA-256 :
|
||||
|
||||
```text
|
||||
740107901c06d1c54838a944d01431e4f134f6989e1900b294cc0c0d210b1d4f
|
||||
```
|
||||
|
||||
Le manifeste embarqué, l’entrée client, les classes de recensement et
|
||||
d’historique, le tag de palette naturelle et les paramètres des traductions
|
||||
FR/EN sont vérifiés. Les manifestes du dépôt et du pack assemblé indiquent
|
||||
`0.1.0-alpha.23`. Le contrôle pack vérifie les versions et empreintes de l’index.
|
||||
|
||||
## Protocole client exécuté
|
||||
|
||||
Le client de développement commence par une fixture explicite de **260 blocs
|
||||
en trois fragments**. Les widgets réels vérifient recherche, filtres et
|
||||
pagination, assemblage atomique, rejet des réponses périmées ou invalides,
|
||||
et conservation des grands compteurs dans la narration. Deux dimensions de
|
||||
GUI sont exercées : **854 × 480** et **427 × 240**, avec une aide défilante.
|
||||
Cette fixture ne prétend pas représenter un inventaire de joueur.
|
||||
|
||||
La seconde passe crée un **nouveau monde plat de développement**, graine 1,
|
||||
en survie, avec les commandes désactivées. Elle utilise la véritable touche
|
||||
**B**, la connexion Minecraft et les paquets du mod :
|
||||
|
||||
1. Préparer côté serveur un bloc d’or devant le joueur et trois blocs de diamant
|
||||
dans son inventaire ; laisser les observations ordinaires du serveur agir.
|
||||
2. Regarder l’or puis ouvrir B : l’or est vu sans être possédé ; le diamant est
|
||||
possédé avec un stock de 3 sans être vu ; l’émeraude reste inconnue.
|
||||
3. Fermer l’écran, retirer les diamants, puis rouvrir avec B : la possession
|
||||
passée reste vraie et le stock actuel vaut 0.
|
||||
4. Fermer le monde et vérifier le fichier de mémoire personnelle sauvegardé.
|
||||
|
||||
Les deux diagnostics signalent `passed: true` dans
|
||||
`mods/sanctuary/build/run/clientGameTest/diagnostics/` :
|
||||
|
||||
- `sanctuary-blocodex-client.json` : fixture, widgets et fragments ;
|
||||
- `sanctuary-blocodex-network-client.json` : états avant/après, touche et paquets
|
||||
réels, observation du regard et sauvegarde à la fermeture.
|
||||
|
||||
Les captures `0005_sanctuary-blocodex-network-carried-three.png` et
|
||||
`0006_sanctuary-blocodex-network-sticky-possession.png` se trouvent dans le dossier
|
||||
`screenshots/` du même client. La seconde a été inspectée : le diamant reste
|
||||
connu et possédé, avec **Inventory: 0**, dans l’interface anglaise du test.
|
||||
|
||||
## Reproduction et limites
|
||||
|
||||
Depuis la racine du dépôt, avec Java 25 et un environnement graphique :
|
||||
|
||||
```sh
|
||||
./gradlew -PsanctuaryClientTests=true :sanctuary:runClientGameTest
|
||||
./gradlew :sanctuary:materialActivitySmoke
|
||||
./gradlew check build assemblePack
|
||||
```
|
||||
|
||||
La dernière commande a terminé avec succès. Le scénario client prouve une
|
||||
connexion intégrée réelle ; il ne constitue pas une validation
|
||||
réseau à plusieurs clients sur un serveur distant.
|
||||
Les essais ne constituent pas un profil de performance d’un grand serveur.
|
||||
|
||||
Les mondes, captures, diagnostics et journaux de test restent dans les dossiers
|
||||
de développement ignorés. Le scénario réseau vérifie que sa nouvelle sauvegarde
|
||||
est créée sous `mods/sanctuary/build/run/clientGameTest/saves/`. Aucune instance
|
||||
Prism ni sauvegarde personnelle n’a été mise à jour. Aucune publication ni
|
||||
modification du canal packwiz n’a été effectuée pour ces essais.
|
||||
@@ -0,0 +1,272 @@
|
||||
# Vérifications alpha.24
|
||||
|
||||
Branche `codex/aerial-sanctuary-alpha24`, base alpha.23.1 `fbefb2e`.
|
||||
Minecraft 26.3-pre-2, Fabric Loader 0.19.5, Fabric API 0.160.0+26.3,
|
||||
Java 25 ; mod et pack `0.1.0-alpha.24`.
|
||||
|
||||
**Matrice de génération réussie le 11 septembre 2026.** Les quatorze scénarios
|
||||
passent : neuf créations, deux réouvertures, deux options OFF et l’ordre inverse
|
||||
de chargement. Les tests purs, deux admissions réelles d’expansion et la
|
||||
cascade native jusqu’à Y8 réussissent également. Les 24 GameTests généraux passent également.
|
||||
`check build assemblePack` passe en 3 min 56 s (83 tâches), avec les 24
|
||||
GameTests natifs également réussis dans ce build. JAR, MRpack, index packwiz
|
||||
et bootstrap officiel sont vérifiés. La release est publiée, le canal packwiz
|
||||
et la même instance Prism sont synchronisés ; 925 fichiers personnels et
|
||||
réglages suivis conservent leurs empreintes.
|
||||
Le [contrat de génération](generation-alpha24.md) décrit le périmètre.
|
||||
|
||||
## Environnement et preuves
|
||||
|
||||
Les essais utilisent un serveur Fabric GameTest sans interface graphique sur
|
||||
Mac. Les mondes jetables restent dans `mods/sanctuary/build/run/gameTest/` ;
|
||||
aucune sauvegarde personnelle n’est ouverte ou modifiée. Aucun essai Windows
|
||||
natif ni contrôle graphique du client avec shaders n’a été exécuté.
|
||||
|
||||
Les résultats retenus figurent dans `build/alpha24-evidence/matrix.json`,
|
||||
avec les rapports `<phase>-<graine>-<diamètre>.json` et leurs journaux `.log`.
|
||||
Un résultat n’est retenu qu’après sortie réussie du processus et
|
||||
`passed: true` dans le rapport. Ces fichiers de développement sont ignorés par
|
||||
Git. Les essais précédant la végétation sont conservés séparément dans
|
||||
`build/alpha24-evidence-before-vegetation/` et ne valident pas les formes finales.
|
||||
Ceux précédant la correction du rivage sont dans
|
||||
`build/alpha24-evidence-before-shore-fix/` ; ils attestent les contrôles déjà
|
||||
réussis, mais pas les nouveaux emplacements recherchés par le filtre corrigé.
|
||||
|
||||
Le journal `build/alpha24-shore-smoke.log` atteste les tests purs finaux.
|
||||
Les images `balloon.png`, `merchant_*.png` et `mineral_islet_*.png` sont des
|
||||
projections de contrôle calculées depuis l’export des blocs du renderer :
|
||||
ce ne sont pas des captures d’écran Minecraft. Le test FULL vérifie séparément
|
||||
que les matériaux prévus existent dans le monde natif.
|
||||
|
||||
## Résultats exécutés
|
||||
|
||||
| Essai | Résultat | Preuve |
|
||||
| --- | --- | --- |
|
||||
| Placement pur : 3 tailles × graines 0, 42, 2026 ; rotations, emprises, conflits et rivage obstrué | Réussi après correction | `alpha24-shore-smoke.log`, `Aerial24Smoke` |
|
||||
| Manifeste avant journal, relecture stricte, corruption, absence, conflits, plan vide et historique23 | Réussi | Même journal, `AerialPersistence24Smoke` |
|
||||
| Neuf créations de la matrice après correction du rivage | 9 sur 9 réussies | Tableau ci-dessous |
|
||||
| Moyen 724, graine 0, première réouverture | Réussi, 54,85 s | `reload1-0-724.json` |
|
||||
| Même monde, seconde réouverture | Réussi, 54,50 s | `reload2-0-724.json` |
|
||||
| Option expérimentale OFF, en serveur natif | Réussi, 52,93 s | `create-0-724-experimental-off.json` |
|
||||
| Structures globales OFF, en serveur natif | Réussi, 27,19 s | `create-0-724-global-off.json` |
|
||||
| Génération des chunks dans l’ordre inverse | Réussi, 81,58 s ; sept champs strictement identiques | `create-0-724-reverse.json`, `reverse-comparison.json` |
|
||||
| Cascade jusqu’à Y8 et deux admissions réelles entre les emprises | Réussi, 2 min 39 s | `flow-admission-0-724.json`, `alpha24-flow-admission.log` |
|
||||
| Comparaison du témoin historique23 avec l’alpha.23.1 | Réussie sur le code24 avant la passe végétale | `legacy23-comparison.json` |
|
||||
| GameTests généraux : Blocodex, options, population et hydrologie | 24 sur 24 réussis, JVM 2 min 2 s ; suite 54,47 s | `build/alpha24-general-gametest.log` |
|
||||
| `check build assemblePack`, contrôle des artefacts | Réussi ; 83 tâches, suite native 24/24 | `build/alpha24-check-build-pack.log`, `build/alpha24-artifacts.json` |
|
||||
|
||||
| Graine | Petit 512 | Moyen 724 | Grand 1 024 |
|
||||
| --- | --- | --- | --- |
|
||||
| 0 | Réussi, 62,64 s ; 57 chunks FULL | Réussi, 80,96 s ; 61 chunks FULL | Réussi, 128,84 s ; 48 chunks FULL |
|
||||
| 42 | Réussi, 58,25 s ; 61 chunks FULL | Réussi, 72,91 s ; 57 chunks FULL | Réussi, 92,08 s ; 58 chunks FULL |
|
||||
| 2026 | Réussi, 59,43 s ; 44 chunks FULL | Réussi, 80,77 s ; 37 chunks FULL | Réussi, 115,93 s ; 48 chunks FULL |
|
||||
|
||||
Chaque création active retrouve les cinq sites, leurs cinq coffres, deux
|
||||
marchands et une source de cascade. Les emprises réservées vont de 31 à 55
|
||||
chunks selon le monde. Les deux cas OFF retrouvent un plan vide, aucune
|
||||
réservation aérienne et aucun site aérien annoncé dans le registre.
|
||||
|
||||
L’ordre inverse, exécuté sur un nouveau Moyen, graine 0, conserve exactement
|
||||
la géométrie, le codec, les départs NBT, les blocs avant et après usage,
|
||||
les mutations du test et la végétation. `reverse-comparison.json` consigne
|
||||
l’égalité stricte de ces sept champs ; les durées et états transitoires de
|
||||
chargement ne sont pas comparés comme s’ils devaient être identiques.
|
||||
|
||||
Les durées incluent Gradle, le lancement du serveur, la préparation du monde,
|
||||
les chunks FULL demandés et les assertions. Ce ne sont ni des temps de rendu
|
||||
client, ni une mesure Windows, ni le délai nécessaire pour générer toute l’île.
|
||||
|
||||
### Correction du point de vue de rivage
|
||||
|
||||
La première matrice végétalisée avait échoué sur le Petit, graine 42 : le
|
||||
sanctuaire minéral construisait sa voûte jusqu’à Y187 au-dessus d’un point
|
||||
calculé sur le terrain brut à Y174. Le planner prépare désormais les plans
|
||||
racine avant le manifeste aérien, puis refuse leurs volumes au niveau du
|
||||
support, du point de vue et de la ligne de visée. Les assertions FULL restent
|
||||
strictes ; le cas fautif passe dans la nouvelle série. Deux tests purs
|
||||
vérifient une obstruction au rivage et au milieu du segment de vue.
|
||||
|
||||
Cette correction peut changer le candidat retenu pour un nouveau monde24.
|
||||
Un plan déjà sauvegardé reste relu tel quel : aucun recalcul implicite et
|
||||
aucune modification des anciens mondes23.
|
||||
|
||||
### Ce que le témoin Moyen vérifie
|
||||
|
||||
Les cinq sites réservent **55 chunks**, sans réserver un anneau entier. Le test
|
||||
charge **61 chunks FULL**, comprenant ces emprises, leurs points de rivage et
|
||||
le chunk qui reçoit les villageois extraits. Il vérifie notamment :
|
||||
|
||||
- Les cinq vrais départs de structures natifs, leurs pièces, leurs coordonnées,
|
||||
la sérialisation NBT et les états d’occupation conservés.
|
||||
- Cinq coffres réellement placés, leurs tables vanilla et un butin non vide,
|
||||
puis leur maintien à vide après deux redémarrages.
|
||||
- Deux villageois présents, un par navire, puis déplacés dans le chunk de test.
|
||||
Leur position reste conservée et aucun remplaçant n’apparaît dans les navires.
|
||||
- Des blocs de minerai et un élément de nacelle retirés restent absents après
|
||||
les deux réouvertures. Cette manipulation est limitée au monde de développement.
|
||||
- Des accès et intérieurs avec un sol et deux blocs libres, ainsi que les trois
|
||||
couches de couverture des coffres enterrés lors de la création.
|
||||
- Les points de rivage reposent sur le terrain FULL et ne sont pas enfouis.
|
||||
Les colonnes extérieures échantillonnées restent vides de construction.
|
||||
- Le registre passe de `PLANNED` à `GENERATED`, les recherches utilisent les
|
||||
vrais départs et le journal d’expansion reste inchangé pendant ces visites.
|
||||
|
||||
La source d’eau est présente et conservée ; l’essai séparé ci-dessous vérifie
|
||||
sa descente par les ticks de fluide jusqu’à Y8.
|
||||
|
||||
La création et les deux réouvertures contrôlent aussi la végétation réelle. Sur l’îlot avec
|
||||
cascade, **596 des 783 colonnes de surface intactes portent de l’herbe**
|
||||
(76,1 %), avec deux arbres et 27 blocs de hauteur rocheuse. Sur l’îlot sec,
|
||||
ce sont **1 506 sur 1 788** (84,2 %), quatre arbres et 21 blocs de roche.
|
||||
Chaque enveloppe ajoute huit blocs pour les couronnes. Les troncs ont un appui
|
||||
en terre, les couronnes restent dans l’emprise et les feuilles utilisent les
|
||||
propriétés natives de distance, sans persistance forcée.
|
||||
`persistence-comparison.json` confirme également l’égalité de la géométrie,
|
||||
du codec, des départs natifs, des blocs après usage, des mutations et des
|
||||
mesures de végétation dans les deux relectures.
|
||||
|
||||
### Admission réelle et écoulement natif
|
||||
|
||||
`flow-admission-0-724.json` et `build/alpha24-flow-admission.log` attestent le
|
||||
test dans un autre monde jetable Moyen, graine 0. Il appelle le véritable
|
||||
`ExpansionRuntime.Session.create` avant que les satellites soient visités.
|
||||
|
||||
| Expansion de test, diamètre 128 | Premier centre envisagé X Z | Centre réellement réservé X Z | Appel de réservation | Résultat |
|
||||
| --- | --- | --- | ---: | --- |
|
||||
| `aerial_collision_0_southeast` | `496 336`, chevauche un satellite | `368 496` | 114 ms | `READY`, un départ vanilla valide |
|
||||
| `aerial_interval_0_northeast` | `400 -432`, passage libre | `400 -432` | 54 ms | `READY`, un départ vanilla valide |
|
||||
|
||||
La première demande filtre le candidat en conflit, puis poursuit les
|
||||
vérifications d’adaptation avant sa réservation définitive. La seconde
|
||||
montre que la bande entre les satellites reste utilisable. Les deux
|
||||
réservations sont idempotentes, respectent leurs emprises et atteignent
|
||||
`READY` avec une structure native adaptée. Ces durées d’appels ne représentent
|
||||
pas la préparation complète, comprise dans le test de 2 min 39 s.
|
||||
|
||||
Après chargement et activation des ticks des chunks concernés, l’unique
|
||||
source prévue produit de l’eau sous l’îlot à `399 194 312`, puis à
|
||||
`399 8 312`, après **1 180 ticks d’attente contrôlée**. À Y8, le fluide
|
||||
est de l’eau courante, pas une source artificiellement posée. Aucun chemin
|
||||
vertical de blocs sources n’est fabriqué par le renderer. Cet essai valide
|
||||
ce trajet réel ; il ne garantit pas la forme de l’écoulement après des
|
||||
constructions ou excavations effectuées par les joueurs.
|
||||
|
||||
### Chargement des habitants dans le test Grand
|
||||
|
||||
Le premier essai Grand, graine 0, a rencontré un délai de visibilité des
|
||||
entités : les marchands existaient sur disque mais n’étaient pas encore
|
||||
exposés au test. Le protocole de lecture charge désormais les navires entiers,
|
||||
vérifie la disponibilité native des entités et attend au plus 600 ticks.
|
||||
L’exigence reste de deux marchands distincts, sans création ou remplacement
|
||||
par le test. Les trois Grands passent ensuite : le témoin graine0 attend
|
||||
250 ticks et celui de graine2026, 323 ticks, avant de voir les deux habitants.
|
||||
Cela confirme que l’ancienne limite de 200 ticks du fixture était trop courte.
|
||||
Le premier essai interrompu n’est pas compté dans les réussites de la matrice.
|
||||
|
||||
## Repères de visite — Moyen 724, graine 0
|
||||
|
||||
Créer un **nouveau monde Sanctuary de génération24**, taille Moyen, graine `0`,
|
||||
avec **Générer les structures** et **Structures expérimentales** activés.
|
||||
Les coordonnées proviennent de `create-0-724.json`, champ `look_views`.
|
||||
Le nouveau rapport après correction du rivage confirme ces mêmes coordonnées.
|
||||
Les repères de rivage désignent un point de vue deux blocs au-dessus du témoin
|
||||
enregistré ; ils ne constituent pas des téléportations de survie exécutées.
|
||||
|
||||
| Lieu | Entrée X Y Z | Point de vue au rivage X Y Z | Distance horizontale entrée–rivage |
|
||||
| --- | --- | --- | ---: |
|
||||
| Montgolfière | `-492 288 110` | `-251 219 55` | 247,2 blocs |
|
||||
| Navire de vivres | `-35 186 -503` | `-19 176 -282` | 221,6 blocs |
|
||||
| Navire de matériel | `463 186 -204` | `229 159 -102` | 255,3 blocs |
|
||||
| Îlot avec cascade | `399 237 333` | `195 161 163` | 265,5 blocs |
|
||||
| Îlot sec | `-277 256 456` | `-125 227 207` | 291,7 blocs |
|
||||
|
||||
Pour un repérage de développement, `/locate structure sanctuary:aerial_balloon`,
|
||||
`sanctuary:aerial_merchant_ship` et `sanctuary:aerial_mineral_islet` utilisent
|
||||
les types natifs. `/sanctuary census structures aerial` distingue les cinq
|
||||
sites. Aucun pont ou véhicule n’est ajouté pour les atteindre. La limite de
|
||||
512 blocs depuis un rivage ne force pas les réglages de rendu du client ou
|
||||
du serveur, ni la visibilité à travers les feuillages.
|
||||
|
||||
## Historique23
|
||||
|
||||
Le rapport `legacy23-0-724.json`, produit sur un monde de génération23 avec le
|
||||
code24 avant l’ajout de végétation aérienne, a été comparé à
|
||||
`build/alpha231-evidence/final-medium.json`. Tous les champs sont identiques,
|
||||
à l’exception attendue de `process_id` : codec, plans, départs natifs,
|
||||
géométrie, rails et traversées contrôlés dans **85 chunks FULL**.
|
||||
`legacy23-comparison.json` consigne cette égalité.
|
||||
|
||||
Cette preuve porte sur ce témoin précis, pas sur toutes les graines ni toutes
|
||||
les dimensions. Les tests de persistance conservent aussi les octets du journal23
|
||||
et refusent une conversion implicite vers24. Aucun monde existant ne reçoit
|
||||
automatiquement les satellites24 ; le nouveau manifeste appartient uniquement
|
||||
aux nouveaux mondes24.
|
||||
|
||||
## Reproduction
|
||||
|
||||
Depuis la racine du dépôt, exécuter les commandes **séquentiellement**.
|
||||
`runGameTest` recrée son monde de développement par défaut. Pour les phases
|
||||
de réouverture, garder le même dossier et ajouter impérativement
|
||||
`sanctuaryExpansionReload=true`.
|
||||
|
||||
```sh
|
||||
./gradlew :sanctuary:aerial24Smoke :sanctuary:aerialPersistence24Smoke
|
||||
|
||||
./gradlew :sanctuary:runGameTest \
|
||||
-PsanctuaryAerial24Tests=true \
|
||||
-PsanctuaryTestDiameter=724 -PsanctuaryTestSeed=0 \
|
||||
-PsanctuaryAerial24Phase=create -PsanctuaryDensityMaps=false
|
||||
|
||||
./gradlew :sanctuary:runGameTest \
|
||||
-PsanctuaryAerial24Tests=true \
|
||||
-PsanctuaryTestDiameter=724 -PsanctuaryTestSeed=0 \
|
||||
-PsanctuaryAerial24Phase=reload1 -PsanctuaryExpansionReload=true \
|
||||
-PsanctuaryDensityMaps=false
|
||||
|
||||
./gradlew :sanctuary:runGameTest \
|
||||
-PsanctuaryAerial24Tests=true \
|
||||
-PsanctuaryTestDiameter=724 -PsanctuaryTestSeed=0 \
|
||||
-PsanctuaryAerial24Phase=reload2 -PsanctuaryExpansionReload=true \
|
||||
-PsanctuaryDensityMaps=false
|
||||
```
|
||||
|
||||
La matrice de créations reprend les diamètres `512`, `724`, `1024` et les
|
||||
graines `0`, `42`, `2026`. Les variantes du Moyen, graine0, ajoutent séparément
|
||||
`-PsanctuaryExperimentalStructures=false`,
|
||||
`-PsanctuaryGenerateStructures=false` ou
|
||||
`-PsanctuaryAerial24ReverseChunks=true` à la commande de création.
|
||||
L’essai d’admission et d’eau utilise un nouveau monde :
|
||||
|
||||
```sh
|
||||
./gradlew :sanctuary:runGameTest \
|
||||
-PsanctuaryAerial24FlowAdmission=true \
|
||||
-PsanctuaryTestGeneration=24 -PsanctuaryTestDiameter=724 \
|
||||
-PsanctuaryTestSeed=0 -PsanctuaryDensityMaps=false
|
||||
```
|
||||
|
||||
Cette dernière commande reproduit l’essai d’admission et d’écoulement réussi.
|
||||
Les assertions sont dans
|
||||
[Aerial24WorldGameTests](../mods/sanctuary/src/gametest/java/fr/koka/sanctuary/gametest/Aerial24WorldGameTests.java)
|
||||
et [Aerial24FlowAdmissionGameTests](../mods/sanctuary/src/gametest/java/fr/koka/sanctuary/gametest/Aerial24FlowAdmissionGameTests.java).
|
||||
|
||||
## Limites et distribution
|
||||
|
||||
Les essais ne valident pas encore le ressenti en vol, la lisibilité dans le
|
||||
client, l’équilibrage économique des filons, les performances multijoueurs ou
|
||||
les incidents Windows rapportés sur cette préversion Minecraft. Le test pur
|
||||
des neuf plans emploie un terrain synthétique ; seule la matrice FULL valide
|
||||
leur adaptation au relief réel des graines retenues.
|
||||
|
||||
La [release alpha.24](https://git.botsu.net/koka/sanctuary-beta/releases/tag/v0.1.0-alpha.24)
|
||||
est publiée depuis `27d7cba`. Le canal packwiz (`bd9b4c4`) et la même instance
|
||||
Prism sont synchronisés, avec deux passages isolés puis deux sur l’instance.
|
||||
Le second passage conserve les fichiers gérés identiques. Un seul JAR Sanctuary
|
||||
alpha.24 est installé ; les 925 fichiers personnels et réglages suivis sont
|
||||
inchangés. Aucune sauvegarde personnelle n’a été ouverte ou régénérée.
|
||||
Voir [la distribution et les empreintes](packwiz.md).
|
||||
|
||||
Preuves locales : `build/alpha24-artifacts.json`,
|
||||
`build/alpha24-isolated-validation.json`, `build/alpha24-prism-validation.json`
|
||||
et `build/alpha24-distribution-status.json`. Le build final dure 3 min 56 s,
|
||||
avec 83 tâches et les 24 GameTests natifs réussis en 52,92 s. Ces durées ne
|
||||
constituent pas une mesure des performances du client.
|
||||
@@ -0,0 +1,105 @@
|
||||
# Alpha.27 — vérifications de reprise
|
||||
|
||||
Base de travail : `e7d1f29` (alpha.24), branche
|
||||
`codex/reprise-sanctuary-alpha27`. Mod et pack : `0.1.0-alpha.27`, Minecraft
|
||||
`26.3-pre-2`. Nouveau monde Sanctuary, Moyen 724 par défaut.
|
||||
|
||||
Les fichiers de densité et les ressources de relief de la 24 sont conservés.
|
||||
Les deux changements localisés concernent les biomes de marais et les lieux
|
||||
aériens. Voir le [périmètre exact](generation-alpha27.md).
|
||||
|
||||
## Résultat local du 12 septembre 2026
|
||||
|
||||
`./gradlew check build` réussit en **3 min 28 s**. Le serveur de développement
|
||||
termine ses **19 tests obligatoires**, dont les témoins marais et aériens, sans
|
||||
échec. Le journal faisant foi est `build/alpha27-check-build-final.log` ; les
|
||||
premiers journaux de préparation ne décrivent pas ce résultat final.
|
||||
|
||||
Commande exacte :
|
||||
|
||||
```sh
|
||||
./gradlew check build -PsanctuaryDensityMaps=false -PsanctuaryAerialPreview -PsanctuaryAerial24Tests=true
|
||||
./gradlew assemblePack -x :sanctuary:check
|
||||
```
|
||||
|
||||
La première option désactive les images de densité facultatives. Le contrôle
|
||||
`check` vient de réussir et n’est pas répété pendant l’assemblage du pack.
|
||||
Les 56 fichiers de densité, relief et hydrologie recensés sont identiques à
|
||||
la base `e7d1f29` (`build/alpha27-evidence/terrain-base.json`).
|
||||
|
||||
Les deux reçus natifs ci-dessous proviennent du même processus `48406`, dans
|
||||
un **nouveau monde Moyen, diamètre 724, graine 0**, avec les structures et
|
||||
l'option expérimentale activées. Ils ont été écrits à 00:32:38 et 00:32:47,
|
||||
pendant le dernier passage réussi. Le générateur reste `sanctuary:island_v24`
|
||||
dans cette reprise ; la version du mod est bien alpha.27.
|
||||
|
||||
## Marais souterrain réel
|
||||
|
||||
`Swamp27WorldGameTests` réutilise le plan hydrologique central déjà en cache,
|
||||
puis inspecte au maximum huit chunks FULL demandés explicitement. Aucune
|
||||
région supplémentaire n'est planifiée pour sélectionner les eaux témoins ;
|
||||
aucun bloc ni point d'eau n'est posé par le test.
|
||||
|
||||
Le reçu `mods/sanctuary/build/run/gameTest/diagnostics/swamp27/native.json`
|
||||
confirme :
|
||||
|
||||
- **1 444 sols de cavités sous voûte**, dont 1 315 couverts d'herbe, mousse ou boue ;
|
||||
- **355 blocs d'eau** dans le biome de marais ;
|
||||
- **494 plantes** : 107 buissons à lucioles, 292 herbes courtes et 95 lianes ;
|
||||
- des eaux souterraines existantes à Y118, 120, 129 et 130 ; 289 colonnes d'eau
|
||||
recoupent le champ du marais dans la région inspectée.
|
||||
|
||||
Repère pour visiter ce témoin dans un nouveau monde de mêmes paramètres :
|
||||
|
||||
```text
|
||||
/tp @s -6.5 130 -92.5
|
||||
```
|
||||
|
||||
`diagnostics/swamp27/blocks.json` exporte une fenêtre des **blocs FULL réels**
|
||||
et une coupe destinée à l'aperçu. Le monde reste intact. Cette projection ne
|
||||
reproduit pas l'éclairage, les shaders ou le rendu exact du client Minecraft.
|
||||
|
||||
## Quatre lieux aériens
|
||||
|
||||
Le reçu `mods/sanctuary/build/run/gameTest/diagnostics/aerial24/create.json`
|
||||
porte `passed: true` et confirme **deux bateaux, deux îlots, deux marchands
|
||||
réels, quatre coffres et une source de cascade**. Les deux marchands sont
|
||||
observés après chargement effectif des entités. Les 56 chunks du témoin
|
||||
aérien incluent les structures et leurs points de rivage.
|
||||
|
||||
Les coques lisent le vrai template Minecraft `shipwreck/rightsideup_full`,
|
||||
palette 0 : 643 des 659 blocs physiques d’origine sont conservés lors de la
|
||||
restauration, 16 remplacés et 76 ajoutés avant le mobilier marchand. Les
|
||||
escaliers, dalles et la cabine native restent présents. Les aperçus de blocs
|
||||
simplifiés ont été inspectés ; ils ne sont pas des captures du client.
|
||||
|
||||
Le test contrôle les blocs posés, les accès, les coffres enterrés des îlots,
|
||||
les starts natifs et leur sérialisation. Il ouvre les quatre coffres,
|
||||
déplace les deux marchands et retire quelques blocs dans le monde jetable,
|
||||
puis sauvegarde. Les quatre sites restent enregistrés comme générés ; le
|
||||
journal d'expansion est inchangé.
|
||||
|
||||
Les tests purs couvrent également **neuf combinaisons** de graines 0/42/2026
|
||||
et diamètres 512/724/1024 : déterminisme des plans, orientations, limites et
|
||||
réservations. Ce sont des calculs de plans et de géométrie, **pas neuf mondes
|
||||
natifs intégralement générés**.
|
||||
|
||||
## Limites
|
||||
|
||||
Cette passe ne valide pas une nouvelle matrice de rechargements, toutes les
|
||||
graines ni toute l'île. Elle ne garantit pas des grenouilles ou des chênes
|
||||
dans chaque cavité. Le premier témoin sec a servi à corriger la sélection
|
||||
du test ; les chiffres ci-dessus proviennent du témoin humide final.
|
||||
|
||||
Aucun essai Windows natif, mesure de FPS ou validation visuelle par le joueur
|
||||
n'est revendiqué. La durée du build comprend les vérifications et ne mesure
|
||||
pas le temps de chargement d'une partie. La publication des artefacts et la
|
||||
synchronisation Prism font l'objet de reçus de livraison distincts.
|
||||
|
||||
## Livraison
|
||||
|
||||
`assemblePack` réussit. JAR, MRpack, dépendances et ZIP d’amorçage vérifiés,
|
||||
puis téléchargement anonyme des mêmes artefacts. Deux installations isolées
|
||||
et deux synchronisations de l’instance Prism existante réussissent ; les
|
||||
925 fichiers personnels et réglages suivis sont inchangés. Voir
|
||||
[la livraison](packwiz.md#alpha27-publiée--12-septembre-2026).
|
||||
@@ -0,0 +1,110 @@
|
||||
# Alpha.28 — vérifications
|
||||
|
||||
## Protocole
|
||||
|
||||
Tests sur macOS avec Java 25 et Minecraft 26.3-pre-2. Aucun essai Windows
|
||||
natif ni jugement de rendu client n’est revendiqué. Le créateur a validé
|
||||
visuellement la 27 ; les coupes de densité servent ici à contrôler cette
|
||||
nouvelle passe, sans représenter l’eau, la végétation ou les structures.
|
||||
|
||||
Commande de livraison :
|
||||
|
||||
```sh
|
||||
./gradlew check build -PsanctuaryDensityMaps=false -PsanctuaryAerial24Tests=true
|
||||
```
|
||||
|
||||
`sanctuaryDensityMaps=false` coupe la production des anciennes images,
|
||||
pas les assertions. Le monde GameTest est recréé dans le dossier de développement
|
||||
ignoré. Les sauvegardes personnelles ne sont pas utilisées par les tests.
|
||||
|
||||
Les smokes de placement aérien examinent 512 / 724 / 1 024, graines 0 / 42 /
|
||||
2026. Le témoin natif chargé en chunks FULL est Moyen 724, graine 0 ; ceci
|
||||
ne prétend pas être neuf îles entièrement explorées. Les comparaisons de
|
||||
terrain analysent deux coupes espacées de 2 blocs et une grille de hauteurs
|
||||
espacée de 32 blocs. Une expansion naturelle de 512 est contrôlée par son
|
||||
vrai champ de densité sans être réservée ni ouverte dans le serveur.
|
||||
|
||||
## Résultats
|
||||
|
||||
`check build` passe en **4 min 15 s**, dont **21/21 GameTests natifs**
|
||||
en 57,06 s. `assemblePack` passe ensuite sans recompilation des binaires vérifiés.
|
||||
Les smokes couvrent aussi le Blocodex, les formats de journal, les priorités
|
||||
et les réservations d’expansion, ainsi que les anciennes géométries pures.
|
||||
|
||||
Le terrain de référence conserve **6 098 des 6 860** anciens échantillons
|
||||
rocheux intérieurs (88,9 %), avec **762** désormais creusés. Cette comparaison
|
||||
inclut les raccords du nouveau cisaillement, pas seulement les grottes.
|
||||
L’expansion de 512 conserve 1 299 échantillons contre 136 creusés.
|
||||
|
||||
Sur la grille de hauteurs, 54 colonnes hautes montent et 84 s’abaissent.
|
||||
La hausse maximale relevée est de 32 blocs et le sommet échantillonné atteint
|
||||
Y280. La baisse maximale de sommet, 132 blocs en (0,160), correspond à un
|
||||
lobe supérieur qui quitte cette colonne : le sol observé passe de Y248 à
|
||||
Y116. Elle ne désigne pas un déplacement vertical de 132 blocs ; le déplacement
|
||||
3D est borné à ±40 en Y. Des surplombs et étranglements subsistent et restent
|
||||
à apprécier visuellement dans le jeu.
|
||||
|
||||
Les **9 chunks FULL** inspectés contiennent les huit minerais Overworld :
|
||||
|
||||
| Minerai | Blocs observés, variantes deepslate comprises |
|
||||
|---|---:|
|
||||
| Charbon | 1408 |
|
||||
| Fer | 325 |
|
||||
| Cuivre | 302 |
|
||||
| Or | 87 |
|
||||
| Lapis | 53 |
|
||||
| Redstone | 77 |
|
||||
| Diamant | 16 |
|
||||
| Émeraude | 4 |
|
||||
|
||||
Il s’agit d’un relevé après génération, pas de quotas imposés à chaque chunk.
|
||||
|
||||
La relecture finale des fichiers de région confirme **trois donjons vanilla**
|
||||
avec spawners zombies et coffres `minecraft:chests/simple_dungeon` :
|
||||
`-101 170 100`, `-92 175 -92` et `-85 178 11`. Une vraie mine est présente
|
||||
vers `152 176 -120`, avec **143 pièces sauvegardées**. Dans les 14 chunks FULL
|
||||
du contrôle des structures : 91 planches, 88 barrières, 13 rails, 29 toiles
|
||||
et un spawner ont été observés dans les pièces chargées. Ce relevé sur les
|
||||
fichiers MCA après fermeture du serveur ne génère aucun chunk supplémentaire.
|
||||
|
||||
Les quatre lieux aériens ont de vrais départs et pièces sauvegardées,
|
||||
quatre coffres et deux marchands adultes au total, puis passent les contrôles
|
||||
après ouverture, extraction et modification dans le protocole natif. Il y a
|
||||
exactement une source de cascade et deux îlots survolant le terrain. Aucun
|
||||
nouveau site ni habitant n’est recréé pour remplacer ce qui a été utilisé.
|
||||
|
||||
Preuves locales ignorées : `build/alpha28-check-build-final.log`,
|
||||
`build/alpha28-preview/geology-final.json`,
|
||||
`build/alpha28-preview/geology-final-comparison.png`,
|
||||
`build/alpha28-evidence/final/` et reçus de distribution `build/alpha28-*`.
|
||||
|
||||
|
||||
## Limites et essai du créateur
|
||||
|
||||
- La hutte de sorcière est conditionnelle aux berges 3D, à l’espace et aux quatre
|
||||
appuis natifs. Le premier petit échantillon n’en contient aucune : son audit
|
||||
de placement ne constitue pas une preuve de présence en jeu.
|
||||
- Les quatre départs et les deux UUID de marchands persistants sont relus
|
||||
dans les données sauvegardées. Aucun second lancement JVM avec ce monde
|
||||
alpha.28 n’est revendiqué.
|
||||
- La source de la cascade est contrôlée ; son écoulement complet jusqu’au vide
|
||||
n’est pas mesuré par ce protocole. La propagation reste celle de Minecraft.
|
||||
- Les témoins historiques purs restent vérifiés ; les comparaisons exactes de
|
||||
l’ancien champ utilisent explicitement `legacy27()`. Elles ne prétendent pas
|
||||
que le nouveau relief serait identique à celui de la 27.
|
||||
- Il ne s’agit pas d’un benchmark client ni d’une simulation physique tectonique.
|
||||
Les performances pourront être étudiées après ce retour visuel.
|
||||
|
||||
Créer un **nouveau monde Sanctuary**, taille **Moyen**, graine **0** pour
|
||||
retrouver le témoin. Garder ses autres sauvegardes ; aucune migration ni
|
||||
régénération n’est réalisée. Valider en priorité les masses soulevées et
|
||||
abaissées, les cavités à explorer, les îlots au-dessus du terrain et les
|
||||
navires proches des berges.
|
||||
|
||||
## Distribution
|
||||
|
||||
Le JAR, le MRpack et le ZIP d’amorçage ont les mêmes empreintes sur disque
|
||||
et après téléchargement anonyme de la release. Les deux synchronisations
|
||||
isolées sont identiques ; les deux synchronisations de l’instance Prism
|
||||
existante conservent les empreintes des 925 fichiers personnels et réglages
|
||||
suivis. Un seul JAR alpha.28 est actif. Voir [le reçu de livraison](packwiz.md).
|
||||
@@ -0,0 +1,109 @@
|
||||
# Alpha.29 — vérifications
|
||||
|
||||
**Point de reprise local, non publié.** Le chantier se poursuit directement
|
||||
en alpha.30 à la demande du créateur. Le contrôle supplémentaire Petit512,
|
||||
graine2026, a refusé la traversée et révélé un témoin côtier aérien sans appui
|
||||
après génération. Ces limites empêchent de considérer la29 comme livrée.
|
||||
Les artefacts préparatoires et reçus locaux restent des preuves intermédiaires.
|
||||
|
||||
État des preuves au 12 septembre 2026. Les essais natifs ci-dessous ont été
|
||||
exécutés sur **Mac, en serveur de développement sans rendu client**. Le retour
|
||||
Windows du créateur concerne l’alpha.28 ; aucun essai Windows de la 29 n’est
|
||||
revendiqué. Créer un **nouveau monde** pour tester cette génération.
|
||||
|
||||
## Traversées réellement générées et parcourues
|
||||
|
||||
| Monde | Départs / chunks FULL | Distance entre accès | Parcours avec collisions natives |
|
||||
|---|---:|---:|---:|
|
||||
| Grand 1 024, graine **-7228211907433324401** | 23 / 52 | 340 blocs | 652 pas, 74 points accessibles |
|
||||
| Moyen 724, graine **0** | 17 / 27 | 238 blocs | 390 pas, 56 points accessibles |
|
||||
|
||||
Chaque témoin vérifie les blocs posés, les escaliers, les approches naturelles,
|
||||
les raccords entre modules, les départs sauvegardables et le locator d’entrée.
|
||||
Les **cinq cellules du côté fermé de la jonction en T** sont contrôlées après
|
||||
la correction du renderer. Ces recherches n’ouvrent aucune expansion.
|
||||
|
||||
Preuves : `build/alpha29-evidence/user-locate-before-crossing/transit29-native.json`
|
||||
(PID 55232) et `build/alpha29-evidence/medium-0/` (reçus du PID 56574).
|
||||
La correction ultérieure de l’admission des mines ne modifie pas le transit.
|
||||
|
||||
Sur la même graine Grand, la référence alpha.28 produisait un plan vide après
|
||||
419 alignements et 13 000 colonnes. Cette reproduction est conservée dans
|
||||
`build/alpha29-evidence/baseline-user/` ; le succès de ses anciens GameTests
|
||||
ne démontrait pas la présence d’une traversée.
|
||||
|
||||
## Relief : comparaison exacte avec la 28
|
||||
|
||||
| Monde | Densités inférieures identiques bit à bit | Échantillons supérieurs ayant changé de signe |
|
||||
|---|---:|---:|
|
||||
| Grand, graine signalée | 10 140 | 303 / 71 656, soit **0,423 %** |
|
||||
| Moyen, graine 0 | 7 935 | 166 / 56 074, soit **0,296 %** |
|
||||
|
||||
Les densités inférieures sont échantillonnées entre Y32 et Y214. Les deux
|
||||
coupes à Z0 et Z96, au pas d’un bloc dans la bande Y205–305, ont été comparées
|
||||
pour la graine signalée : petites corniches, quelques arêtes plus dentelées,
|
||||
grandes silhouettes de la 28 conservées. Cela ne remplace pas un essai visuel
|
||||
dans le client. Le déplacement supplémentaire des coordonnées est borné à
|
||||
2,5 blocs ; cette borne ne porte pas sur le changement de sommet lorsqu’une
|
||||
petite lèvre disparaît.
|
||||
|
||||
Reçus `alpha29-terraces-*.json` des dossiers de preuve ; aperçu local :
|
||||
`build/alpha29-preview/terraces-1024--7228211907433324401.png`.
|
||||
|
||||
## Mine vanilla et satellites
|
||||
|
||||
**Moyen, graine 0 :** une véritable mine vanilla de **143 pièces acceptées**
|
||||
est trouvée parmi les candidats normaux. L’inspection est partielle :
|
||||
**16 chunks FULL** sont demandés par le test. Elle observe notamment
|
||||
244 planches de chêne, 200 barrières, 102 rails et 50 toiles dans les pièces
|
||||
chargées. Une salle `monster_room` avec spawner de zombies est également
|
||||
observée. Le test ne prétend pas avoir exploré les 143 pièces, ni avoir
|
||||
déclenché tous les spawners ou contrôlé tous les butins. La hutte de sorcière
|
||||
est absente de cet échantillon ; ce n’est pas une absence prouvée sur l’île.
|
||||
|
||||
Une lecture séparée du monde sauvegardé confirme deux spawners vanilla
|
||||
`cave_spider` aux positions **156 171 -138** et **140 175 -97**, dans les
|
||||
corridors correspondants (`sc=1`, `hps=1`). Reçu :
|
||||
`build/alpha29-evidence/medium-0/mineshaft-spawners-saved.json`.
|
||||
|
||||
Sur ce même monde, **quatre satellites**, **deux villageois**, **quatre coffres**
|
||||
et **une source de cascade** passent la création puis un véritable redémarrage.
|
||||
Les 47 chunks FULL contrôlés conservent le pillage, les villageois déplacés
|
||||
et les blocs détruits, sans duplication ni reconstruction des témoins.
|
||||
Le journal d’expansion reste inchangé. Création PID 56060, rechargement
|
||||
PID 56574 ; les **23 GameTests natifs** de ce dernier processus passent.
|
||||
Preuves regroupées dans `build/alpha29-evidence/medium-0/`.
|
||||
|
||||
## Tests ciblés et portée
|
||||
|
||||
Les smokes terrain, appuis de mines et transit couvrent les bornes, les
|
||||
orientations et les refus protégés. Le test pur de traversée couvre
|
||||
0 / 42 / 2026 × 512 / 724 / 1 024 **sur un terrain synthétique portant** :
|
||||
ce n’est pas une matrice de neuf mondes Minecraft réellement générés.
|
||||
Les contrôles natifs ci-dessus portent sur les témoins explicitement cités.
|
||||
|
||||
`./gradlew check build` passe : **86 tâches**, dont les **23 GameTests natifs**,
|
||||
en 2 min 58 s pour cette exécution. Journal :
|
||||
`build/alpha29-evidence/medium-0/gradle.log`. Ce temps n’est pas un benchmark de génération.
|
||||
|
||||
`./gradlew assemblePack` passe également. JAR, MRpack autonome, index packwiz
|
||||
et ZIP d’amorçage sont vérifiés localement : versions, dépendances, CRC et
|
||||
empreintes concordent. Reçus `build/alpha29-artifacts.json` et
|
||||
`build/alpha29-delivery-local.json`.
|
||||
|
||||
Restent en attente de leurs reçus :
|
||||
- Contrôles natifs de **planification seule** Grand/graine42 et Petit/graine2026 ;
|
||||
même réussis, ils ne prouveront pas un parcours sur des chunks FULL.
|
||||
- Publication, canal packwiz et synchronisation Prism.
|
||||
|
||||
Pas de preuve d’exécution avec structures désactivées propre à l’alpha.29,
|
||||
ni de nouvelle validation visuelle client ou Windows à ce stade.
|
||||
|
||||
## Repères pour un essai manuel
|
||||
|
||||
Avec les structures activées, sur un nouveau Grand de graine
|
||||
`-7228211907433324401`, les entrées parcourues sont **128 252 -127** et
|
||||
**128 257 213**. Sur Moyen/graine0 : **-90 235 -127** et **-90 235 111**.
|
||||
`/locate structure sanctuary:industrial_transit` recherche une entrée du réseau.
|
||||
Le repère **152 175 -120** désigne la mine de Moyen/graine0 : l’utiliser en
|
||||
spectateur pour l’inspection, sans supposer une arrivée sûre en survie.
|
||||
@@ -0,0 +1,145 @@
|
||||
# Alpha.30 — vérifications
|
||||
|
||||
Essais du 12 septembre 2026 sur **Mac**, dans des serveurs de développement
|
||||
sans rendu client. Le retour Windows du créateur concerne la 28 ; aucun essai
|
||||
Windows natif de la 30 n’est revendiqué. Nouveau monde nécessaire.
|
||||
|
||||
## Témoin Grand signalé par le créateur
|
||||
|
||||
**1 024 blocs, graine `-7228211907433324401`**, processus 62002 :
|
||||
**24/24 GameTests passent**. Reçus dans `build/alpha30-evidence/grand-user/`.
|
||||
|
||||
- Traversée réellement générée : 23 modules, 52 chunks FULL, 374 blocs entre
|
||||
les accès ; parcours contrôlé sur 736 pas et 71 points, avec les collisions
|
||||
natives, escaliers et raccords. Entrées : **192 238 -195** et **192 256 179**.
|
||||
- Rivière : tracé entre des points distants d’environ **865 blocs**, 6 924 cellules
|
||||
de lit et de brèche, six ouvertures. Huit chunks FULL échantillonnés ; après
|
||||
120 ticks, six échantillons contiennent de l’eau sous les deux sorties suivies.
|
||||
Ce test ne prétend pas simuler toutes les chutes jusqu’à Y0.
|
||||
- Sanctuaire minéral accepté dès la recherche intérieure ; emprise depuis
|
||||
**-122 131 265**, 79 × 73 × 27. Le recours exposé n’est pas exercé sur ce témoin.
|
||||
- Quatre satellites, deux villageois, quatre coffres et une cascade d’îlot :
|
||||
44 chunks FULL contrôlés. Les témoins de pillage, déplacement et démolition
|
||||
sont préparés pour le contrôle de persistance.
|
||||
- Le petit échantillon de structures vanilla ne contient pas de mine. Ce n’est
|
||||
pas un inventaire exhaustif de l’île et aucune présence de mine n’y est annoncée.
|
||||
|
||||
## Petit 512, graine 2026
|
||||
|
||||
Processus **62463**, **24/24 GameTests passent**. Reçus :
|
||||
`build/alpha30-evidence/small-2026-final2/`.
|
||||
|
||||
La traversée produit 15 modules et leurs départs natifs, avec 204 blocs entre
|
||||
les entrées. Ce contrôle est limité aux plans et départs ; aucun parcours FULL
|
||||
complet de cette traversée n’est revendiqué sur Petit. La rivière couvre une
|
||||
distance d’environ 362 blocs, avec 2 551 cellules et quatre brèches. Sept chunks
|
||||
FULL sont échantillonnés ; l’eau coule sous les sorties contrôlées.
|
||||
|
||||
Le sanctuaire possède son véritable départ de structure et son sol central
|
||||
est contrôlé après génération au point **-54 162 69**, avec l’espace libre
|
||||
au-dessus. Les quatre satellites passent sur 41 chunks FULL.
|
||||
|
||||
Un premier essai a révélé que le témoin de vue de l’îlot à cascade se trouvait
|
||||
sur une ancienne hauteur creusée en bassin. La correction choisit une berge
|
||||
sèche proche, sans ajouter de support artificiel. Une première correction trop
|
||||
large épuisait le budget de colonnes ; elle a été remplacée avant validation.
|
||||
La commande finale dure 2 min 8 s.
|
||||
|
||||
## Moyen 724, graine 0
|
||||
|
||||
Processus **62604**, reçus `build/alpha30-evidence/medium-0/`.
|
||||
La traversée réelle passe : **19 modules, 42 chunks FULL, 272 blocs entre les
|
||||
accès, 456 pas et 62 points accessibles**. Entrées : **-136 248 -53** et
|
||||
**136 260 -53**. La rivière s’étend sur environ 554 blocs : 3 942 cellules,
|
||||
six brèches, neuf chunks FULL contrôlés et écoulement sous les sorties suivies.
|
||||
Le sol central du sanctuaire est présent en **106 189 -63**, avec l’espace
|
||||
libre au-dessus ; les satellites passent également.
|
||||
|
||||
Le test exigeant une mine sur cette graine échoue : aucun départ de mine n’est
|
||||
retenu parmi ses 19 candidats, y compris via la recherche native. Les **23 autres
|
||||
tests passent**. Le témoin de mine de la 29 n’est donc pas réutilisé comme preuve
|
||||
de présence en 30. Un témoin séparé est recherché, sans forcer une implantation
|
||||
incompatible. Les refus conditionnels restent un comportement voulu du jeu.
|
||||
|
||||
## Grand 1 024, graine 42 — témoin de mine
|
||||
|
||||
Processus **62979**, **24/24 GameTests passent**, y compris l’exigence de trouver
|
||||
une mine réelle. Reçus dans `build/alpha30-evidence/grand-42/`.
|
||||
|
||||
Deux départs de mines vanilla sont observés dans les candidats examinés. La
|
||||
mine visitée possède **83 pièces** ; l’échantillon de 16 chunks FULL du test
|
||||
contient notamment **138 planches de chêne, 120 barrières, 43 rails et 23 toiles**.
|
||||
Point de visite : **6 189 6**. Le test contrôle les pièces sauvegardées et leur
|
||||
aller-retour NBT ; il ne visite pas l’intégralité de la mine et ne garantit pas
|
||||
un spawner dans chaque corridor. Une lecture séparée de la sauvegarde confirme
|
||||
un véritable spawner `cave_spider` en **46 188 25** dans un corridor :
|
||||
`build/alpha30-evidence/grand-42/saved-spawners.json`. Son activation par un joueur
|
||||
n’a pas été testée.
|
||||
|
||||
Deux huttes de sorcière sont également observées. La hutte visitée est en
|
||||
**83 148 -396**, avec ses pièces, appuis et son mobilier vanilla.
|
||||
La traversée possède **25 modules répartis sur 24 départs natifs**, avec 374 blocs entre
|
||||
les entrées ; cette graine utilise le contrôle des plans, sans nouveau parcours
|
||||
FULL de toute la traversée. Le sanctuaire possède son vrai départ et son sol
|
||||
central. La rivière s’étend sur environ **882 blocs**, avec 5 822 cellules et
|
||||
six ouvertures ; les écoulements suivis passent sous ticks réels.
|
||||
|
||||
`./gradlew check build` passe sur ce témoin : **88 tâches**, dont les tests purs,
|
||||
les contrôles de sérialisation et les **24 GameTests natifs**, en **6 min 28 s**.
|
||||
Le coût inclut toute la suite et n’est pas un temps de chargement de partie.
|
||||
Commande :
|
||||
|
||||
```sh
|
||||
./gradlew check build -PsanctuaryTestDiameter=1024 -PsanctuaryTestSeed=42 \
|
||||
-PsanctuaryDensityMaps=false -PsanctuaryAerial24Tests=true \
|
||||
-PsanctuaryTransit29Tests=true -PsanctuaryTransit29PlanOnly=true \
|
||||
-PsanctuaryRequireMineshaft29=true
|
||||
```
|
||||
|
||||
## Relief
|
||||
|
||||
Sur ce Grand, 8 112 densités sous Y180 sont identiques bit à bit à la 28.
|
||||
Dans les coupes hautes, 4 544 / 94 640 échantillons changent de signe, soit
|
||||
**4,80 %**. Deux coupes au pas d’un bloc, Z0 et Z96, ont été rendues et examinées :
|
||||
les plateaux redeviennent larges entre les zones où subsistent les surplombs.
|
||||
Aperçu local `build/alpha30-preview/relief-1024--7228211907433324401.png`.
|
||||
Les mêmes coupes ont aussi été examinées sur Petit2026 : 602 / 40 460 signes
|
||||
modifiés (1,49 %), avec des sommets plus plats entre les zones déformées.
|
||||
Ce contrôle de densité ne remplace pas une exploration visuelle dans le client
|
||||
et ne démontre pas l’absence de toute petite pointe ou masse déconnectée.
|
||||
|
||||
## Tests ciblés et limites
|
||||
|
||||
Le test pur `river30Smoke` couvre trois rayons sur une masse rocheuse synthétique :
|
||||
longueur du tracé, lit dans la roche, arrivée protégée, brèches de cinq blocs
|
||||
maximum, déterminisme et espaces non déformés entre les trois secteurs.
|
||||
Ce n’est pas une matrice de neuf mondes Minecraft natifs.
|
||||
|
||||
La recherche reste bornée par la taille de l’île et le nombre de candidats.
|
||||
Sur le Grand, la commande native complète dure **4 min 44 s**, incluant le
|
||||
lancement, la planification, les structures et les nombreux chunks demandés
|
||||
par les tests. Ce temps n’est ni un temps de rendu client, ni un benchmark
|
||||
comparatif avec la 28. Aucun objectif chiffré de performance n’est revendiqué.
|
||||
|
||||
Les tests vérifient des occurrences et parcours précis, pas une garantie
|
||||
universelle sur toutes les graines. Les mines restent conditionnelles, et le
|
||||
sanctuaire peut encore être refusé si aucune implantation n’a d’attache valable.
|
||||
Les réglages, le Blocodex et la suite générale restent soumis à `check build`.
|
||||
|
||||
## Redémarrage et artefacts
|
||||
|
||||
Grand1 024, graine42, processus **63276** : **24/24 tests passent après un
|
||||
redémarrage réel** (2 min 14 s). Les 47 chunks FULL du contrôle aérien conservent
|
||||
coffres pillés, villageois déplacés et destructions préparées à la création,
|
||||
sans duplication ni reconstruction des témoins. Les départs de mine et leurs
|
||||
pièces, le sol du sanctuaire et les écoulements échantillonnés passent à nouveau.
|
||||
Le journal d’expansion reste inchangé. Preuves :
|
||||
`build/alpha30-evidence/grand-42-reload/` et `build/alpha30-reload.log`.
|
||||
|
||||
`./gradlew assemblePack` passe après `check build` (le second lancement exclut
|
||||
la tâche `:sanctuary:check` déjà réussie). Le JAR, le MRpack autonome et le ZIP
|
||||
d’amorçage Prism passent la vérification locale : versions, dépendances exactes,
|
||||
index et empreintes concordent. Reçus : `build/alpha30-artifacts.json`,
|
||||
`build/alpha30-delivery-local.json`. Les fichiers du client Windows n’ont pas
|
||||
été modifiés. La publication et la synchronisation de l’instance Mac sont
|
||||
suivies dans [la distribution](packwiz.md).
|
||||
+70
-5
@@ -22,6 +22,37 @@ L'objectif mythologique est de progresser d'une condition très limitée, proche
|
||||
- **Humour, surprise et souvenirs.** Les noms d'entités, les événements, les animaux rares et les objets insolites comptent autant que les systèmes économiques.
|
||||
- **Un développement par tickets.** Livrer une petite mécanique jouable et vérifiable, puis l'ajuster avec des tickets de fonctionnalités et de bugs. Ne pas construire tous les systèmes avant de pouvoir jouer.
|
||||
|
||||
## Minecraft comme archéologie d’un autre Minecraft
|
||||
|
||||
**Canon et ligne de conception retenus.** Steve, Ari, Sunny, Kai, Zuri, Alex,
|
||||
Mefe, Makena, Noor sont les personnages disparus de la partie. Ils ont découvert
|
||||
quelque chose de révolutionnaire et ont continué parce que ça marchait. Jusqu’au
|
||||
moment où ça n’a plus marché.
|
||||
|
||||
> Ils n’ont pas ouvert quelque chose qu’ils n’auraient pas dû ouvrir. Ils ont
|
||||
> construit quelque chose qu’ils ne savaient plus refermer.
|
||||
|
||||
Chaque ruine doit être une trace d’une ancienne solution, pas seulement la trace
|
||||
d’un problème : une infrastructure dont l’auteur a progressivement disparu
|
||||
derrière son fonctionnement. Son ancien usage, ses circulations, ses réparations,
|
||||
ses extensions et ses chantiers doivent permettre de comprendre ce qui avait
|
||||
été résolu ici, même quand l’installation est abandonnée.
|
||||
|
||||
La nature de la découverte et les rôles individuels restent à définir. Aucune
|
||||
catastrophe précise n’est confirmée par ce principe. **La mise en scène de cette
|
||||
histoire et ses liens avec la progression restent à implémenter** ; les versions
|
||||
livrées et leurs tests établissent ce que chaque structure contient effectivement.
|
||||
|
||||
Les **Indoors** prolongent cette histoire comme espaces artificiels intentionnels,
|
||||
référencés et contrôlés. Les **Backrooms** en sont les espaces orphelins : la
|
||||
machine tente d’organiser de la matière dont elle a perdu le contexte. Le ballast
|
||||
produit par les échanges, déplacements et créations d’espaces doit pouvoir y
|
||||
inscrire le comportement réel des joueurs, jusqu’à rendre l’histoire économique
|
||||
du serveur lisible dans leur géologie. Le [cahier de cosmologie](cosmologie.md)
|
||||
conserve le texte de l’auteur, ses exemples et les articulations encore à définir.
|
||||
**Ces espaces, le shop et le ballast ne sont pas implémentés.** Le socle méta
|
||||
des blocs pourra les alimenter ; il ne constitue pas encore un journal économique.
|
||||
|
||||
## Périmètre de départ
|
||||
|
||||
Le premier incrément porte sur le socle Fabric et la génération du monde : retrouver le générateur 26.2, produire une île principale dans un vrai vide, assurer une arrivée commune et sûre, puis poser une manière reproductible de générer des continents à une distance, une direction et une taille choisies.
|
||||
@@ -171,6 +202,19 @@ L'ambition est de reprendre puis d'étendre la centaine de biomes du catalogue T
|
||||
|
||||
### Structures et territoires
|
||||
|
||||
**Direction en conception après l’alpha.22 :** départ dans un endroit naturel,
|
||||
puis découverte de quelques lieux isolés. La sélection retient l’observatoire,
|
||||
la salle d’expansion, un atelier caché et la grande traversée, avec l’ajout à
|
||||
concevoir d’un donjon difficile, un boss et un objet de quête essentiel à la
|
||||
progression. Les villes, regroupements et autres structures restent en réserve.
|
||||
Les fonctions sont reproductibles chez les joueurs, y compris l’installation
|
||||
d’expansion ; quelques exceptions collectives restent à définir. La salle
|
||||
ancienne peut être rééquipée et servir de modèle. Voir le
|
||||
[cahier de conception en discussion](structures-conception.md).
|
||||
Ces décisions préparent la suite ; les paragraphes datés ci-dessous conservent
|
||||
l’historique des versions et ne signifient pas que cette nouvelle sélection est
|
||||
déjà implémentée.
|
||||
|
||||
- **Structures vanilla** : admises dans les nouvelles générations lorsque leur
|
||||
biome, leur emprise et leurs fondations conviennent au terrain flottant.
|
||||
L’autorisation ne garantit pas leur présence sur chaque île. Le laboratoire
|
||||
@@ -226,7 +270,7 @@ L'ambition est de reprendre puis d'étendre la centaine de biomes du catalogue T
|
||||
ces connexions fait partie de l’exploration. Privilégier les installations
|
||||
encore utilisables et les chantiers interrompus pour raconter cette histoire.
|
||||
Les back rooms de ces donjons sont des lieux physiques dans l’île, distincts
|
||||
de la dimension Backrooms recevant les objets perdus. Le futur butin combine
|
||||
des futurs espaces Backrooms recevant les objets perdus. Le futur butin combine
|
||||
des reliques collectives uniques et des récompenses personnelles ; les
|
||||
spawners pourront rester exploitables après exploration sans régénérer les
|
||||
donjons. Les règles précises restent à concevoir. Le réacteur et ces nouveaux
|
||||
@@ -238,14 +282,20 @@ L'ambition est de reprendre puis d'étendre la centaine de biomes du catalogue T
|
||||
à construire ; voir [le contrat du prototype](testing-alpha17.md).
|
||||
- **Secret rooms et challenge rooms** : des accès présents dans le monde mènent à des indoors aménagés, avec des équipements, des épreuves ou des gisements de fer, d'or, d'argent ou de titane.
|
||||
|
||||
### Dimensions
|
||||
### Dimensions et espaces
|
||||
|
||||
| Dimension | Intention |
|
||||
| Monde ou espace | Intention |
|
||||
| --- | --- |
|
||||
| **Cavernes** | Monde destiné au minage, avec des biomes souterrains, sans mineshafts ni parkings. Des cités anciennes particulièrement difficiles accueillent plusieurs types de squelettes et un nécromancien illageois qui les invoque. Il détient une boule de cristal. |
|
||||
| **Alpha** | Monde inspiré de Minecraft Indev et des premières versions, avec les anciennes textures de Golden Days actives uniquement dans cette dimension. Notch y est un boss. |
|
||||
| **Backrooms** | Monde sombre à plusieurs niveaux, exploré avec une source de lumière. Les joueurs y arrivent dans un lit. Il reçoit dans des coffres les objets perdus dans le vide ou brûlés ; c'est aussi un territoire d'exploration et un lieu de quête. |
|
||||
| **Indoors** | Petits espaces associés à des objets, déclinés en classes de volume, avec une taille indicative allant de 5 × 5 × 5 à 100 × 100 × 100 blocs. Ils peuvent servir d'intérieurs, de salles secrètes ou de lieux d'événements. |
|
||||
| **Backrooms** | Espaces artificiels orphelins dans la cosmologie, dont la géologie doit conserver l’histoire économique du serveur. L’intention antérieure d’un territoire sombre à plusieurs niveaux, accessible par le lit et recueillant des objets perdus, reste à articuler avec cette direction. |
|
||||
| **Indoors** | Espaces artificiels intentionnels, référencés et contrôlés : une porte peut mener à un intérieur plus grand que le bâtiment. L’auteur les décrit comme de petites dimensions instanciées. Les classes de volume envisagées vont indicativement de 5 × 5 × 5 à 100 × 100 × 100 blocs. |
|
||||
|
||||
Le [cahier de cosmologie](cosmologie.md#deux-devenirs-de-la-même-technologie)
|
||||
distingue cette représentation narrative de son futur hébergement technique.
|
||||
Un espace dit « orphelin » devra rester correctement identifié et sauvegardé
|
||||
par Minecraft ; aucune perte réelle de référence ou corruption de chunks n’est
|
||||
prévue. Backrooms et Indoors restent à implémenter.
|
||||
|
||||
La géométrie des indoors reste à décider : certains peuvent être des volumes précisément délimités, d'autres des espaces fermés qui se rebouclent en trois dimensions, de type tore 3D. Leurs objets d'accès sont liés à la mailbox de leur propriétaire et doivent être récupérables s'ils sont perdus. Les règles de propriété, de partage, de transfert et de sortie sûre seront définies avant leur implémentation.
|
||||
|
||||
@@ -269,6 +319,20 @@ La progression peut débloquer une table de fabrication dans l'inventaire, des c
|
||||
|
||||
Les recettes de Just Enough Items sont révélées par paliers liés aux advancements. Les advancements Minecraft donnent accès aux recettes Minecraft ; ceux de Sanctuary ouvrent les blocs décoratifs, équipements et systèmes correspondants. Il faudra distinguer dans chaque ticket l'affichage des recettes, leur connaissance et l'autorisation réelle de fabriquer.
|
||||
|
||||
Le **Blocodex natif** fournit une mémoire personnelle des blocs : inconnus, vus,
|
||||
minés, déjà possédés, jetés et posés, avec le stock porté actuel séparé de
|
||||
l’historique. Cette base appartient à Sanctuary et reste disponible sans
|
||||
appareil à fabriquer. Les palettes de construction, recherches ou objectifs
|
||||
pourront consulter ces informations côté serveur ; leurs conditions et
|
||||
récompenses seront définies par leurs propres tickets. Le socle alpha.23 et
|
||||
ses limites sont décrits dans [Blocodex](blocodex.md). Ce socle distingue aussi
|
||||
les blocs du terrain chargé des objets en inventaires et stockages, avec des
|
||||
relevés de couverture séparés. Un historique global par jour UTC conserve les
|
||||
actions matérielles observées depuis l’installation. Ces données pourront
|
||||
servir aux palettes, au shop, aux expansions et à la géologie historique des
|
||||
Backrooms ; elles ne définissent pas encore les coûts, transactions ou règles
|
||||
de ballast de ces systèmes.
|
||||
|
||||
### Construction et production
|
||||
|
||||
- **Mining** améliore la vitesse de minage et ouvre le vein mining : extraction de blocs d'une même veine ou sur un plan défini par l'orientation du joueur.
|
||||
@@ -316,6 +380,7 @@ Les **conveyor belts**, fabriqués notamment avec du cuir de vache, déplacent l
|
||||
## Machines, équipements et redstone
|
||||
|
||||
- **Ordinateur 8 bits** : bloc programmable avec six ports d'entrée et de sortie, permettant de construire ses propres comportements de redstone. Des évolutions en contrôleur et en ordinateur d'interface donnent accès, dans le monde, aux systèmes d'expansion.
|
||||
- **Installation d’expansion à définir** : assembleur, bloc contrôleur, bloc terminal, bloc de dépôt et ancre spatiale sont les éléments actuellement envisagés. Leurs rôles et connexions restent à concevoir. L’installation pourra être reconstruite ailleurs que dans la salle ancienne ; voir le [cahier de conception](structures-conception.md#ordinateurs-et-installation-dexpansion).
|
||||
- **Terminal et storage en titane** : stockage de fin de progression, avec jusqu'à 128 coffres connectés consultables par un terminal commun, afin de déposer et retrouver ses objets sans tri manuel constant.
|
||||
- **Chunky et clé de chunk** : bloc fabriquable maintenant un chunk actif. Son activation requiert une clé trouvable dans les donjons et structures, afin que le chargement permanent ait une valeur d'exploration et d'échange. L'orthographe des noms sera fixée à partir de l'historique.
|
||||
- **Particuleur** : émetteur de particules dont l'effet dépend de l'objet inséré et dont l'intensité dépend du signal de redstone.
|
||||
|
||||
+2
-2
@@ -8,6 +8,6 @@ loader_version=0.19.5
|
||||
loom_version=1.17.20
|
||||
fabric_api_version=0.160.0+26.3
|
||||
|
||||
mod_version=0.1.0-alpha.17
|
||||
pack_version=0.1.0-alpha.17
|
||||
mod_version=0.1.0-alpha.30
|
||||
pack_version=0.1.0-alpha.30
|
||||
maven_group=fr.koka.sanctuary
|
||||
|
||||
+252
-2
@@ -40,13 +40,38 @@ tasks.named('runGameTest') {
|
||||
systemProperty('sanctuary.test.unified', providers.gradleProperty('sanctuaryUnifiedTests').getOrElse('true'))
|
||||
systemProperty('sanctuary.test.diameter', providers.gradleProperty('sanctuaryTestDiameter').getOrElse('724'))
|
||||
systemProperty('sanctuary.test.generation', providers.gradleProperty('sanctuaryTestGeneration').getOrElse(
|
||||
providers.gradleProperty('sanctuaryLostCityTests').map { it.toBoolean() }.getOrElse(false) ? '14' : providers.gradleProperty('sanctuaryLostCity15Tests').map { it.toBoolean() }.getOrElse(false) ? '15' : providers.gradleProperty('sanctuaryLostCity16Tests').map { it.toBoolean() }.getOrElse(false) ? '16' : '17'))
|
||||
providers.gradleProperty('sanctuaryLostCityTests').map { it.toBoolean() }.getOrElse(false) ? '14' : providers.gradleProperty('sanctuaryLostCity15Tests').map { it.toBoolean() }.getOrElse(false) ? '15' : providers.gradleProperty('sanctuaryLostCity16Tests').map { it.toBoolean() }.getOrElse(false) ? '16' : providers.gradleProperty('sanctuaryRuins17Tests').map { it.toBoolean() }.getOrElse(false) ? '17' : providers.gradleProperty('sanctuaryHeritage19Tests').map { it.toBoolean() }.getOrElse(false) ? '19' : (providers.gradleProperty('sanctuaryHeritage20Tests').map { it.toBoolean() }.getOrElse(false) || providers.gradleProperty('sanctuaryLostCity20Tests').map { it.toBoolean() }.getOrElse(false)) ? '20' : (providers.gradleProperty('sanctuaryHeritage21Tests').map { it.toBoolean() }.getOrElse(false) || providers.gradleProperty('sanctuaryLostCity21Tests').map { it.toBoolean() }.getOrElse(false) || providers.gradleProperty('sanctuaryTransit21Tests').map { it.toBoolean() }.getOrElse(false)) ? '21' : providers.gradleProperty('sanctuarySelective22Tests').map { it.toBoolean() }.getOrElse(false) ? '22' : ['sanctuarySecrets23Tests', 'sanctuaryNative23Tests', 'sanctuaryOcean23Tests', 'sanctuaryAdmission23Tests'].any { providers.gradleProperty(it).map { v -> v.toBoolean() }.getOrElse(false) } ? '23' : '24'))
|
||||
systemProperty('sanctuary.test.aerial24.flowAdmission', providers.gradleProperty('sanctuaryAerial24FlowAdmission').getOrElse('false'))
|
||||
systemProperty('sanctuary.test.aerial24', providers.gradleProperty('sanctuaryAerial24Tests').getOrElse('false'))
|
||||
systemProperty('sanctuary.test.aerial24.reverseChunks', providers.gradleProperty('sanctuaryAerial24ReverseChunks').getOrElse('false'))
|
||||
systemProperty('sanctuary.test.aerial24.phase', providers.gradleProperty('sanctuaryAerial24Phase').getOrElse('create'))
|
||||
systemProperty('sanctuary.test.secrets23', providers.gradleProperty('sanctuarySecrets23Tests').getOrElse('false'))
|
||||
systemProperty('sanctuary.test.admission23', providers.gradleProperty('sanctuaryAdmission23Tests').getOrElse('false'))
|
||||
systemProperty('sanctuary.test.admission23.reserveOnly', providers.gradleProperty('sanctuaryAdmission23ReserveOnly').getOrElse('false'))
|
||||
systemProperty('sanctuary.test.admission23.diameter', providers.gradleProperty('sanctuaryAdmission23Diameter').getOrElse('256'))
|
||||
systemProperty('sanctuary.test.admission23.climate', providers.gradleProperty('sanctuaryAdmission23Climate').getOrElse('temperate'))
|
||||
systemProperty('sanctuary.test.admission23.relief', providers.gradleProperty('sanctuaryAdmission23Relief').getOrElse('natural'))
|
||||
systemProperty('sanctuary.test.ocean23', providers.gradleProperty('sanctuaryOcean23Tests').getOrElse('false'))
|
||||
systemProperty('sanctuary.test.native23', providers.gradleProperty('sanctuaryNative23Tests').getOrElse('false'))
|
||||
systemProperty('sanctuary.test.generateStructures', providers.gradleProperty('sanctuaryGenerateStructures').getOrElse('true'))
|
||||
systemProperty('sanctuary.test.selective22', providers.gradleProperty('sanctuarySelective22Tests').getOrElse('false'))
|
||||
systemProperty('sanctuary.transit.plannerDiagnostics', providers.gradleProperty('sanctuaryTransitDiagnostics').getOrElse('false'))
|
||||
systemProperty('sanctuary.test.transit29', providers.gradleProperty('sanctuaryTransit29Tests').getOrElse('false'))
|
||||
systemProperty('sanctuary.test.transit29.planOnly', providers.gradleProperty('sanctuaryTransit29PlanOnly').getOrElse('false'))
|
||||
systemProperty('sanctuary.test.requireMineshaft29', providers.gradleProperty('sanctuaryRequireMineshaft29').getOrElse('false'))
|
||||
systemProperty('sanctuary.expansion.structureDiagnostics', providers.gradleProperty('sanctuaryStructureDiagnostics').getOrElse('false'))
|
||||
systemProperty('sanctuary.test.heritage21', providers.gradleProperty('sanctuaryHeritage21Tests').getOrElse('false'))
|
||||
systemProperty('sanctuary.test.lostCity21', providers.gradleProperty('sanctuaryLostCity21Tests').getOrElse('false'))
|
||||
systemProperty('sanctuary.test.transit21', providers.gradleProperty('sanctuaryTransit21Tests').getOrElse('false'))
|
||||
systemProperty('sanctuary.test.expansion', providers.gradleProperty('sanctuaryExpansionTests').getOrElse('false'))
|
||||
systemProperty('sanctuary.test.expansionReload', providers.gradleProperty('sanctuaryExpansionReload').getOrElse('false'))
|
||||
systemProperty('sanctuary.test.lostCity', providers.gradleProperty('sanctuaryLostCityTests').getOrElse('false'))
|
||||
systemProperty('sanctuary.test.lostCity15', providers.gradleProperty('sanctuaryLostCity15Tests').getOrElse('false'))
|
||||
systemProperty('sanctuary.test.lostCity20', providers.gradleProperty('sanctuaryLostCity20Tests').getOrElse('false'))
|
||||
systemProperty('sanctuary.test.lostCity16', providers.gradleProperty('sanctuaryLostCity16Tests').getOrElse('false'))
|
||||
systemProperty('sanctuary.test.ruins17', providers.gradleProperty('sanctuaryRuins17Tests').getOrElse('false'))
|
||||
systemProperty('sanctuary.test.heritage20', providers.gradleProperty('sanctuaryHeritage20Tests').getOrElse('false'))
|
||||
systemProperty('sanctuary.test.heritage19', providers.gradleProperty('sanctuaryHeritage19Tests').getOrElse('false'))
|
||||
systemProperty('sanctuary.test.experimentalStructures', providers.gradleProperty('sanctuaryExperimentalStructures').getOrElse('true'))
|
||||
systemProperty('sanctuary.test.cityMatrix', providers.gradleProperty('sanctuaryCityMatrix').getOrElse('false'))
|
||||
systemProperty('sanctuary.test.cityMatrixOnly', providers.gradleProperty('sanctuaryCityMatrixOnly').getOrElse('false'))
|
||||
@@ -69,10 +94,36 @@ tasks.named('processGametestResources') {
|
||||
inputs.property('lostCity16', lostCity16)
|
||||
def ruins17 = providers.gradleProperty('sanctuaryRuins17Tests').map { it.toBoolean() }.getOrElse(false)
|
||||
inputs.property('ruins17', ruins17)
|
||||
def lostCity20 = providers.gradleProperty('sanctuaryLostCity20Tests').map { it.toBoolean() }.getOrElse(false)
|
||||
inputs.property('lostCity20', lostCity20)
|
||||
def heritage20 = providers.gradleProperty('sanctuaryHeritage20Tests').map { it.toBoolean() }.getOrElse(false)
|
||||
inputs.property('heritage20', heritage20)
|
||||
def heritage21 = providers.gradleProperty('sanctuaryHeritage21Tests').map { it.toBoolean() }.getOrElse(false)
|
||||
inputs.property('heritage21', heritage21)
|
||||
def lostCity21 = providers.gradleProperty('sanctuaryLostCity21Tests').map { it.toBoolean() }.getOrElse(false)
|
||||
inputs.property('lostCity21', lostCity21)
|
||||
def aerial24Flow = providers.gradleProperty('sanctuaryAerial24FlowAdmission').map { it.toBoolean() }.getOrElse(false)
|
||||
inputs.property('aerial24Flow', aerial24Flow)
|
||||
def aerial24 = providers.gradleProperty('sanctuaryAerial24Tests').map { it.toBoolean() }.getOrElse(false)
|
||||
inputs.property('aerial24', aerial24)
|
||||
def secrets23 = providers.gradleProperty('sanctuarySecrets23Tests').map { it.toBoolean() }.getOrElse(false)
|
||||
def admission23 = providers.gradleProperty('sanctuaryAdmission23Tests').map { it.toBoolean() }.getOrElse(false)
|
||||
inputs.property('admission23', admission23)
|
||||
def ocean23 = providers.gradleProperty('sanctuaryOcean23Tests').map { it.toBoolean() }.getOrElse(false)
|
||||
inputs.property('ocean23', ocean23)
|
||||
def native23 = providers.gradleProperty('sanctuaryNative23Tests').map { it.toBoolean() }.getOrElse(false)
|
||||
inputs.property('secrets23', secrets23)
|
||||
inputs.property('native23', native23)
|
||||
def selective22 = providers.gradleProperty('sanctuarySelective22Tests').map { it.toBoolean() }.getOrElse(false)
|
||||
inputs.property('selective22', selective22)
|
||||
def transit21 = providers.gradleProperty('sanctuaryTransit21Tests').map { it.toBoolean() }.getOrElse(false)
|
||||
inputs.property('transit21', transit21)
|
||||
def heritage19 = providers.gradleProperty('sanctuaryHeritage19Tests').map { it.toBoolean() }.getOrElse(false)
|
||||
inputs.property('heritage19', heritage19)
|
||||
def voidReuse = providers.gradleProperty('sanctuaryVoidReuseTests').map { it.toBoolean() }.getOrElse(false)
|
||||
inputs.property('voidReuse', voidReuse)
|
||||
filesMatching('fabric.mod.json') {
|
||||
expand(gametest_entrypoint: ruins17 ? 'fr.koka.sanctuary.gametest.Ruins17WorldGameTests' : voidReuse ? 'fr.koka.sanctuary.gametest.ExpansionVoidReuseGameTests' : lostCity16 ? 'fr.koka.sanctuary.gametest.LostCity16WorldGameTests' : lostCity15 ? 'fr.koka.sanctuary.gametest.LostCity15WorldGameTests' : lostCity ? 'fr.koka.sanctuary.gametest.LostCityWorldGameTests' : expansion ? 'fr.koka.sanctuary.gametest.ExpansionWorldGameTests' : benchmark
|
||||
expand(gametest_entrypoint: aerial24Flow ? 'fr.koka.sanctuary.gametest.Aerial24FlowAdmissionGameTests' : aerial24 ? 'fr.koka.sanctuary.gametest.Aerial24WorldGameTests' : admission23 ? 'fr.koka.sanctuary.gametest.Expansion23AdmissionGameTests' : ocean23 ? 'fr.koka.sanctuary.gametest.Ocean23WorldGameTests' : secrets23 ? 'fr.koka.sanctuary.gametest.Secrets23WorldGameTests' : native23 ? 'fr.koka.sanctuary.gametest.Native23WorldGameTests' : selective22 ? 'fr.koka.sanctuary.gametest.Selective22WorldGameTests' : transit21 ? 'fr.koka.sanctuary.gametest.Transit21WorldGameTests' : lostCity21 ? 'fr.koka.sanctuary.gametest.LostCity21WorldGameTests' : heritage21 ? 'fr.koka.sanctuary.gametest.Heritage21WorldGameTests' : lostCity20 ? 'fr.koka.sanctuary.gametest.LostCity20WorldGameTests' : heritage20 ? 'fr.koka.sanctuary.gametest.Heritage20WorldGameTests' : heritage19 ? 'fr.koka.sanctuary.gametest.Heritage19WorldGameTests' : ruins17 ? 'fr.koka.sanctuary.gametest.Ruins17WorldGameTests' : voidReuse ? 'fr.koka.sanctuary.gametest.ExpansionVoidReuseGameTests' : lostCity16 ? 'fr.koka.sanctuary.gametest.LostCity16WorldGameTests' : lostCity15 ? 'fr.koka.sanctuary.gametest.LostCity15WorldGameTests' : lostCity ? 'fr.koka.sanctuary.gametest.LostCityWorldGameTests' : expansion ? 'fr.koka.sanctuary.gametest.ExpansionWorldGameTests' : benchmark
|
||||
? 'fr.koka.sanctuary.gametest.WorldgenPerformanceGameTests'
|
||||
: unified ? 'fr.koka.sanctuary.gametest.UnifiedWorldGameTests'
|
||||
: 'fr.koka.sanctuary.gametest.SanctuaryWorldGameTests')
|
||||
@@ -132,6 +183,24 @@ tasks.named('check') { dependsOn('hydrologySmoke') }
|
||||
// src/test contains a JavaExec assertion harness; engine tests use Fabric's gametest source set.
|
||||
tasks.named('test') { failOnNoDiscoveredTests = false }
|
||||
|
||||
tasks.register('blockKnowledgeSmoke', JavaExec) {
|
||||
group = 'verification'
|
||||
description = 'Check personal block history, atomic persistence and corrupt-file refusal.'
|
||||
dependsOn('testClasses')
|
||||
classpath = sourceSets.test.runtimeClasspath
|
||||
mainClass = 'fr.koka.sanctuary.knowledge.BlockKnowledgeSmoke'
|
||||
}
|
||||
tasks.named('check') { dependsOn('blockKnowledgeSmoke') }
|
||||
|
||||
tasks.register('materialActivitySmoke', JavaExec) {
|
||||
group = 'verification'
|
||||
description = 'Check dated material observations, daily isolation and atomic persistence.'
|
||||
dependsOn('testClasses')
|
||||
classpath = sourceSets.test.runtimeClasspath
|
||||
mainClass = 'fr.koka.sanctuary.knowledge.history.MaterialActivitySmoke'
|
||||
}
|
||||
tasks.named('check') { dependsOn('materialActivitySmoke') }
|
||||
|
||||
tasks.register('naturalHydrologySmoke', JavaExec) {
|
||||
group = 'verification'
|
||||
description = 'Check broad shores, supported sediments and natural rock springs.'
|
||||
@@ -415,3 +484,184 @@ tasks.named('check') { dependsOn('lostCityFoundation16Smoke') }
|
||||
}
|
||||
tasks.named('check') { dependsOn(smoke) }
|
||||
}
|
||||
|
||||
// Local native starts keep the long heritage routes bounded by Minecraft's reference range.
|
||||
['Planner', 'Renderer', 'Piece'].each { component ->
|
||||
def smoke = tasks.register("heritage19${component}Smoke", JavaExec) {
|
||||
group = 'verification'
|
||||
dependsOn('testClasses')
|
||||
classpath = sourceSets.test.runtimeClasspath
|
||||
mainClass = "fr.koka.sanctuary.worldgen.heritage.Heritage${component}19Smoke"
|
||||
}
|
||||
tasks.named('check') { dependsOn(smoke) }
|
||||
}
|
||||
|
||||
// Generation20 architecture retains the previous renderers and verifies connected block states.
|
||||
[
|
||||
connectedBlocks20Smoke: 'detail.ConnectedBlocks20Smoke',
|
||||
heritage20RendererSmoke: 'heritage.HeritageRenderer20Smoke',
|
||||
heritage20PieceSmoke: 'heritage.HeritagePiece20Smoke',
|
||||
ruins20RendererSmoke: 'ruins.RuinsRenderer20Smoke',
|
||||
lostCityUnderground20Smoke: 'city.LostCityUnderground20Smoke',
|
||||
lostCitySurface20Smoke: 'city.LostCitySurface20Smoke',
|
||||
lostCityInteriors20Smoke: 'city.LostCityInteriors20Smoke'
|
||||
].each { name, harness ->
|
||||
def smoke = tasks.register(name, JavaExec) {
|
||||
group = 'verification'
|
||||
dependsOn('testClasses')
|
||||
classpath = sourceSets.test.runtimeClasspath
|
||||
mainClass = "fr.koka.sanctuary.worldgen.${harness}"
|
||||
}
|
||||
tasks.named('check') { dependsOn(smoke) }
|
||||
}
|
||||
|
||||
// Optional actual block-state exports for architectural review; never enabled in ordinary checks.
|
||||
tasks.named('heritage20RendererSmoke') {
|
||||
if (providers.gradleProperty('sanctuaryArchitecturePreview').isPresent())
|
||||
systemProperty('sanctuary.test.heritage20.export', rootProject.layout.buildDirectory.dir('alpha20-preview/heritage').get().asFile.absolutePath)
|
||||
}
|
||||
tasks.named('lostCityInteriors20Smoke') {
|
||||
if (providers.gradleProperty('sanctuaryArchitecturePreview').isPresent())
|
||||
systemProperty('sanctuary.city20.preview', rootProject.layout.buildDirectory.file('alpha20-preview/city.json').get().asFile.absolutePath)
|
||||
}
|
||||
tasks.named('lostCitySurface20Smoke') {
|
||||
if (providers.gradleProperty('sanctuaryArchitecturePreview').isPresent())
|
||||
systemProperty('sanctuary.city20.exteriorPreview', rootProject.layout.buildDirectory.file('alpha20-preview/exterior.json').get().asFile.absolutePath)
|
||||
}
|
||||
|
||||
// Generation21 keeps published20 renderers immutable.
|
||||
[
|
||||
heritage21RendererSmoke: 'heritage.HeritageRenderer21Smoke',
|
||||
heritage21PieceSmoke: 'heritage.HeritagePiece21Smoke',
|
||||
heritage21PlannerSmoke: 'heritage.HeritagePlanner21Smoke',
|
||||
lostCity21PlannerSmoke: 'city.LostCityPlanner21Smoke',
|
||||
lostCitySurface21Smoke: 'city.LostCitySurface21Smoke',
|
||||
lostCityInteriors21Smoke: 'city.LostCityInteriors21Smoke',
|
||||
transit21Smoke: 'transit.Transit21Smoke'
|
||||
].each { name, harness ->
|
||||
def smoke = tasks.register(name, JavaExec) {
|
||||
group = 'verification'
|
||||
dependsOn('testClasses')
|
||||
classpath = sourceSets.test.runtimeClasspath
|
||||
mainClass = "fr.koka.sanctuary.worldgen.${harness}"
|
||||
}
|
||||
tasks.named('check') { dependsOn(smoke) }
|
||||
}
|
||||
tasks.named('heritage21RendererSmoke') {
|
||||
if (providers.gradleProperty('sanctuaryArchitecturePreview').isPresent())
|
||||
systemProperty('sanctuary.test.heritage21.export', rootProject.layout.buildDirectory.dir('alpha21-preview/heritage').get().asFile.absolutePath)
|
||||
}
|
||||
tasks.named('lostCityInteriors21Smoke') {
|
||||
if (providers.gradleProperty('sanctuaryArchitecturePreview').isPresent())
|
||||
systemProperty('sanctuary.city21.preview', rootProject.layout.buildDirectory.file('alpha21-preview/city.json').get().asFile.absolutePath)
|
||||
}
|
||||
tasks.named('lostCitySurface21Smoke') {
|
||||
if (providers.gradleProperty('sanctuaryArchitecturePreview').isPresent())
|
||||
systemProperty('sanctuary.city21.exteriorPreview', rootProject.layout.buildDirectory.file('alpha21-preview/exterior.json').get().asFile.absolutePath)
|
||||
}
|
||||
|
||||
// Generation22 filters surface placement and adds an independent core hall; historical tests still run.
|
||||
[
|
||||
lostCity22PlannerSmoke: 'city.LostCityPlanner22Smoke',
|
||||
underground22Smoke: 'city.LostCityUnderground22Smoke',
|
||||
heritage22PlannerSmoke: 'heritage.HeritagePlanner22Smoke',
|
||||
transit22PlannerSmoke: 'transit.TransitPlanner22Smoke',
|
||||
transit22RouteSmoke: 'transit.TransitRoute22Smoke',
|
||||
transit22RendererSmoke: 'transit.TransitRenderer22Smoke'
|
||||
].each { name, harness ->
|
||||
def smoke = tasks.register(name, JavaExec) {
|
||||
group = 'verification'
|
||||
dependsOn('testClasses')
|
||||
classpath = sourceSets.test.runtimeClasspath
|
||||
mainClass = "fr.koka.sanctuary.worldgen.${harness}"
|
||||
}
|
||||
tasks.named('check') { dependsOn(smoke) }
|
||||
}
|
||||
|
||||
// New geography has a pure harness in addition to native world witnesses.
|
||||
tasks.register('expansionOcean23Smoke', JavaExec) {
|
||||
group = 'verification'
|
||||
dependsOn('testClasses')
|
||||
classpath = sourceSets.test.runtimeClasspath
|
||||
mainClass = 'fr.koka.sanctuary.expansion.ExpansionOcean23Smoke'
|
||||
}
|
||||
tasks.named('check') { dependsOn('expansionOcean23Smoke') }
|
||||
|
||||
[
|
||||
secrets23Smoke: 'fr.koka.sanctuary.worldgen.mineral.Secrets23Smoke',
|
||||
structureCensusSmoke: 'fr.koka.sanctuary.knowledge.structures.StructureCensusSmoke',
|
||||
expansionPriorities23Smoke: 'fr.koka.sanctuary.expansion.ExpansionPriorities23Smoke'
|
||||
].each { taskName, harness ->
|
||||
tasks.register(taskName, JavaExec) {
|
||||
group = 'verification'
|
||||
dependsOn('testClasses')
|
||||
classpath = sourceSets.test.runtimeClasspath
|
||||
mainClass = harness
|
||||
}
|
||||
tasks.named('check') { dependsOn(taskName) }
|
||||
}
|
||||
|
||||
// Versioned aerial planner: bounded search, native pieces and local claims.
|
||||
tasks.register('aerial24Smoke', JavaExec) {
|
||||
group = 'verification'
|
||||
dependsOn('testClasses')
|
||||
classpath = sourceSets.test.runtimeClasspath
|
||||
mainClass = 'fr.koka.sanctuary.worldgen.aerial.Aerial24Smoke'
|
||||
if (providers.gradleProperty('sanctuaryAerialPreview').isPresent())
|
||||
systemProperty('sanctuary.aerial.preview', rootProject.layout.buildDirectory.file('alpha27-preview/native-ships.json').get().asFile.absolutePath)
|
||||
}
|
||||
tasks.named('check') { dependsOn('aerial24Smoke') }
|
||||
|
||||
tasks.register('aerialPersistence24Smoke', JavaExec) {
|
||||
group = 'verification'
|
||||
dependsOn('testClasses')
|
||||
classpath = sourceSets.test.runtimeClasspath
|
||||
mainClass = 'fr.koka.sanctuary.worldgen.aerial.AerialPersistence24Smoke'
|
||||
}
|
||||
tasks.named('check') { dependsOn('aerialPersistence24Smoke') }
|
||||
|
||||
tasks.register('swamp27VolumesSmoke', JavaExec) {
|
||||
group = 'verification'
|
||||
dependsOn('testClasses')
|
||||
classpath = sourceSets.test.runtimeClasspath
|
||||
mainClass = 'fr.koka.sanctuary.worldgen.Swamp27VolumesSmoke'
|
||||
}
|
||||
tasks.named('check') { dependsOn('swamp27VolumesSmoke') }
|
||||
|
||||
tasks.register('cavesRelief28Smoke', JavaExec) {
|
||||
group = 'verification'
|
||||
dependsOn('testClasses')
|
||||
classpath = sourceSets.test.runtimeClasspath
|
||||
mainClass = 'fr.koka.sanctuary.worldgen.CavesRelief28Smoke'
|
||||
}
|
||||
tasks.named('check') { dependsOn('cavesRelief28Smoke') }
|
||||
|
||||
// Fine ledges retain the alpha28 field below the upper relief.
|
||||
tasks.register('terraces29Smoke', JavaExec) {
|
||||
group = 'verification'
|
||||
dependsOn tasks.named('testClasses')
|
||||
classpath = sourceSets.test.runtimeClasspath
|
||||
mainClass = 'fr.koka.sanctuary.worldgen.Terraces29Smoke'
|
||||
}
|
||||
tasks.named('check') { dependsOn('terraces29Smoke') }
|
||||
|
||||
[
|
||||
transit29Smoke: 'fr.koka.sanctuary.worldgen.transit.Transit29Smoke',
|
||||
mineshaftAdmission29Smoke: 'fr.koka.sanctuary.expansion.MineshaftAdmission29Smoke'
|
||||
].each { taskName, harness ->
|
||||
tasks.register(taskName, JavaExec) {
|
||||
group = 'verification'
|
||||
dependsOn tasks.named('testClasses')
|
||||
classpath = sourceSets.test.runtimeClasspath
|
||||
mainClass = harness
|
||||
}
|
||||
tasks.named('check') { dependsOn(taskName) }
|
||||
}
|
||||
|
||||
tasks.register('river30Smoke', JavaExec) {
|
||||
group = 'verification'
|
||||
dependsOn tasks.named('testClasses')
|
||||
classpath = sourceSets.test.runtimeClasspath
|
||||
mainClass = 'fr.koka.sanctuary.worldgen.River30Smoke'
|
||||
}
|
||||
tasks.named('check') { dependsOn('river30Smoke') }
|
||||
|
||||
+295
@@ -0,0 +1,295 @@
|
||||
package fr.koka.sanctuary.gametest;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import fr.koka.sanctuary.SanctuaryMod;
|
||||
import fr.koka.sanctuary.client.SanctuaryBlocodexScreen;
|
||||
import fr.koka.sanctuary.knowledge.BlockKnowledge;
|
||||
import fr.koka.sanctuary.knowledge.BlockKnowledgePayloads;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
import net.fabricmc.fabric.api.client.gametest.v1.context.ClientGameTestContext;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.components.CycleButton;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
import net.minecraft.client.gui.components.ObjectSelectionList;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.input.KeyEvent;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.world.item.Items;
|
||||
|
||||
/** Native rendering with an explicit test fixture; no world or server state is fabricated. */
|
||||
final class BlocodexClientChecks {
|
||||
private static final KeyEvent PRESS = new KeyEvent(InputConstants.KEY_RETURN, 0, 0);
|
||||
private static final String LARGE_COUNTER_ID = "minecraft:ancient_debris";
|
||||
private static final String REMOVED_MOD_ID = "fixture_missing_mod:retained_block";
|
||||
|
||||
static void run(ClientGameTestContext context) {
|
||||
Screen previous = context.computeOnClient(client -> client.gui.screen());
|
||||
int previousScale = context.computeOnClient(client -> client.options.guiScale().get());
|
||||
List<BlockKnowledge> fixture = context.computeOnClient(client -> fixture());
|
||||
List<Map<String, Object>> screenshots = new ArrayList<>();
|
||||
try {
|
||||
context.runOnClient(client -> {
|
||||
client.options.guiScale().set(1);
|
||||
client.resizeGui();
|
||||
client.gui.setScreen(new SanctuaryBlocodexScreen());
|
||||
});
|
||||
SanctuaryBlocodexScreen screen = context.computeOnClient(client -> (SanctuaryBlocodexScreen) client.gui.screen());
|
||||
context.runOnClient(client -> {
|
||||
require(list(screen).children().isEmpty(), "No connection must not invent unknown block rows");
|
||||
fixtureRequest(screen, 401);
|
||||
screen.accept(wireRoundTrip(part(fixture, 999, 0)));
|
||||
require(list(screen).children().isEmpty(), "A stale request must not populate the screen");
|
||||
screen.accept(wireRoundTrip(part(fixture, 401, 0)));
|
||||
require(list(screen).children().isEmpty(), "An incomplete snapshot must not reveal partial knowledge");
|
||||
for (int index = 1; index < partCount(fixture); index++) {
|
||||
screen.accept(wireRoundTrip(part(fixture, 401, index)));
|
||||
}
|
||||
require(filteredCount(screen) == fixture.size(), "The full snapshot must become visible together");
|
||||
verifyControls(screen, fixture);
|
||||
assertWidgetBounds(screen);
|
||||
});
|
||||
context.waitTick();
|
||||
Path large = context.takeScreenshot("sanctuary-blocodex-fixture-large");
|
||||
screenshots.add(context.computeOnClient(client -> Map.of("file", large.toString(),
|
||||
"gui_width", screen.width, "gui_height", screen.height, "gui_scale", client.getWindow().getGuiScale())));
|
||||
|
||||
context.runOnClient(client -> {
|
||||
// Vanilla auto scale chooses its largest permitted scale and therefore its smallest GUI.
|
||||
client.options.guiScale().set(0);
|
||||
client.resizeGui();
|
||||
require(client.gui.screen() == screen, "Changing GUI scale must retain the Blocodex");
|
||||
require(filteredCount(screen) == fixture.size(), "Resizing must retain the loaded catalogue");
|
||||
assertWidgetBounds(screen);
|
||||
verifyControls(screen, fixture);
|
||||
});
|
||||
context.waitTick();
|
||||
Path small = context.takeScreenshot("sanctuary-blocodex-fixture-minimum-gui");
|
||||
screenshots.add(context.computeOnClient(client -> Map.of("file", small.toString(),
|
||||
"gui_width", screen.width, "gui_height", screen.height, "gui_scale", client.getWindow().getGuiScale())));
|
||||
context.runOnClient(client -> {
|
||||
search(screen).setValue(LARGE_COUNTER_ID);
|
||||
require(list(screen).children().size() == 1, "Counter fixture must be reachable by identifier");
|
||||
String narration = list(screen).children().getFirst().getNarration().getString();
|
||||
require(narration.contains(Long.toString(Long.MAX_VALUE))
|
||||
&& narration.contains(Long.toString(Long.MAX_VALUE - 1))
|
||||
&& narration.contains(Long.toString(Long.MAX_VALUE - 2))
|
||||
&& narration.contains(Integer.toString(Integer.MAX_VALUE)),
|
||||
"Exact counters must remain available in narration without overflow or truncation");
|
||||
});
|
||||
context.waitTick();
|
||||
context.takeScreenshot("sanctuary-blocodex-fixture-large-counters");
|
||||
|
||||
context.clickScreenButton("sanctuary.blocodex.help");
|
||||
context.runOnClient(client -> {
|
||||
require(client.gui.screen() != screen, "Help must open an actual readable screen");
|
||||
assertWidgetBounds(client.gui.screen());
|
||||
});
|
||||
context.waitTick();
|
||||
context.takeScreenshot("sanctuary-blocodex-help-minimum-gui");
|
||||
context.clickScreenButton("gui.back");
|
||||
context.runOnClient(client -> {
|
||||
require(client.gui.screen() == screen, "Closing help must return to the same Blocodex");
|
||||
require(search(screen).getValue().equals(LARGE_COUNTER_ID), "Help must retain the search");
|
||||
verifyFragmentFailures(screen, fixture);
|
||||
});
|
||||
|
||||
Path diagnostics = Path.of("diagnostics").toAbsolutePath();
|
||||
Files.createDirectories(diagnostics);
|
||||
Files.writeString(diagnostics.resolve("sanctuary-blocodex-client.json"),
|
||||
new GsonBuilder().setPrettyPrinting().create().toJson(Map.of(
|
||||
"fixture", "Explicit client test snapshot; no server or saved world is used",
|
||||
"entries", fixture.size(), "fragments", partCount(fixture),
|
||||
"search_filters_pagination", true, "exact_counter_narration", true,
|
||||
"fragment_atomicity_and_stale_requests", true, "invalid_snapshots_clear_state", true,
|
||||
"screenshots", screenshots, "passed", true)) + "\n");
|
||||
SanctuaryMod.LOGGER.info("Blocodex native client checks passed: explicit fixture, real widgets, two GUI scales, exact counters and fragment atomicity.");
|
||||
} catch (IOException failure) {
|
||||
throw new AssertionError("Unable to write Blocodex client diagnostics", failure);
|
||||
} finally {
|
||||
context.runOnClient(client -> {
|
||||
client.gui.setScreen(previous);
|
||||
client.options.guiScale().set(previousScale);
|
||||
client.resizeGui();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static List<BlockKnowledge> fixture() {
|
||||
List<BlockKnowledge> entries = new ArrayList<>();
|
||||
entries.add(new BlockKnowledge(LARGE_COUNTER_ID, true, true,
|
||||
Long.MAX_VALUE, Long.MAX_VALUE - 1, Long.MAX_VALUE - 2, Integer.MAX_VALUE));
|
||||
List<String> ids = BuiltInRegistries.BLOCK.stream()
|
||||
.filter(block -> block.asItem() != Items.AIR)
|
||||
.map(block -> BuiltInRegistries.BLOCK.getKey(block).toString())
|
||||
.filter(id -> !id.equals(LARGE_COUNTER_ID)).sorted().limit(258).toList();
|
||||
require(ids.size() == 258, "The native registry must contain enough blocks to exercise three fragments");
|
||||
for (int index = 0; index < ids.size(); index++) {
|
||||
int evidence = index % 7;
|
||||
entries.add(new BlockKnowledge(ids.get(index), evidence == 0, evidence == 1,
|
||||
evidence == 2 ? 7 : 0, evidence == 3 ? 11 : 0,
|
||||
evidence == 4 ? 13 : 0, evidence == 5 ? 17 : 0));
|
||||
}
|
||||
entries.add(new BlockKnowledge(REMOVED_MOD_ID, false, true, 0, 0, 0, 0));
|
||||
return List.copyOf(entries);
|
||||
}
|
||||
|
||||
private static void verifyControls(SanctuaryBlocodexScreen screen, List<BlockKnowledge> fixture) {
|
||||
search(screen).setValue(REMOVED_MOD_ID.toUpperCase(java.util.Locale.ROOT));
|
||||
require(filteredCount(screen) == 1 && list(screen).children().size() == 1,
|
||||
"Identifier search must ignore case and preserve absent mod identifiers");
|
||||
search(screen).setValue("fixture_no_matching_block");
|
||||
require(filteredCount(screen) == 0 && list(screen).children().isEmpty()
|
||||
&& !button(screen, "<").active && !button(screen, ">").active,
|
||||
"Empty search results must not retain a previous page or active pagination");
|
||||
search(screen).setValue("");
|
||||
for (var filter : Map.<String, Predicate<BlockKnowledge>>of(
|
||||
"UNKNOWN", entry -> !entry.known(), "KNOWN", BlockKnowledge::known,
|
||||
"SEEN", BlockKnowledge::seen, "POSSESSED", BlockKnowledge::possessed,
|
||||
"MINED", entry -> entry.mined() > 0, "DROPPED", entry -> entry.dropped() > 0,
|
||||
"PLACED", entry -> entry.placed() > 0, "CARRIED", entry -> entry.carried() > 0).entrySet()) {
|
||||
chooseFilter(screen, filter.getKey());
|
||||
require(filteredCount(screen) == fixture.stream().filter(filter.getValue()).count(),
|
||||
"Facet " + filter.getKey() + " must use only its own evidence");
|
||||
}
|
||||
chooseFilter(screen, "ALL");
|
||||
require(filteredCount(screen) == fixture.size(), "All filter must restore the whole catalogue");
|
||||
List<String> first = narrations(screen);
|
||||
require(!first.isEmpty() && button(screen, ">").active && !button(screen, "<").active,
|
||||
"A full catalogue must expose another page while starting on page one");
|
||||
button(screen, ">").onPress(PRESS);
|
||||
require(!narrations(screen).equals(first) && button(screen, "<").active,
|
||||
"Next page must replace the visible rows and enable return");
|
||||
button(screen, "<").onPress(PRESS);
|
||||
require(narrations(screen).equals(first), "Returning to the first page must restore its exact rows");
|
||||
}
|
||||
|
||||
private static void verifyFragmentFailures(SanctuaryBlocodexScreen screen, List<BlockKnowledge> fixture) {
|
||||
search(screen).setValue("");
|
||||
List<String> before = narrations(screen);
|
||||
fixtureRequest(screen, 402);
|
||||
screen.accept(part(fixture, 402, 0));
|
||||
screen.accept(part(fixture, 401, 1));
|
||||
require(narrations(screen).equals(before) && filteredCount(screen) == fixture.size(),
|
||||
"An incomplete refresh and stale fragment must retain only the prior complete snapshot");
|
||||
screen.accept(part(fixture, 402, 2));
|
||||
require(list(screen).children().isEmpty() && filteredCount(screen) == 0,
|
||||
"Out-of-order fragments must invalidate the view without inventing zero counters");
|
||||
|
||||
fixtureRequest(screen, 403);
|
||||
List<BlockKnowledge> duplicate = new ArrayList<>(fixture);
|
||||
duplicate.set(128, duplicate.getFirst());
|
||||
screen.accept(part(duplicate, 403, 0));
|
||||
screen.accept(part(duplicate, 403, 1));
|
||||
require(list(screen).children().isEmpty(), "Duplicate block identifiers across fragments must never publish");
|
||||
|
||||
fixtureRequest(screen, 404);
|
||||
screen.accept(new BlockKnowledgePayloads.SnapshotPart(404, 0, 1, 0, false, List.of()));
|
||||
require(list(screen).children().isEmpty() && !(boolean) read(screen, "available"),
|
||||
"An unhealthy server snapshot must remain unavailable rather than become an unknown catalogue");
|
||||
fixtureRequest(screen, 405);
|
||||
for (int index = 0; index < partCount(fixture); index++) screen.accept(part(fixture, 405, index));
|
||||
require(filteredCount(screen) == fixture.size(), "A complete fresh request must recover after a failed snapshot");
|
||||
}
|
||||
|
||||
private static BlockKnowledgePayloads.SnapshotPart part(List<BlockKnowledge> entries, int request, int index) {
|
||||
int start = index * BlockKnowledgePayloads.FRAGMENT_SIZE;
|
||||
return new BlockKnowledgePayloads.SnapshotPart(request, index, partCount(entries), entries.size(), true,
|
||||
entries.subList(start, Math.min(entries.size(), start + BlockKnowledgePayloads.FRAGMENT_SIZE)));
|
||||
}
|
||||
|
||||
private static int partCount(List<BlockKnowledge> entries) {
|
||||
return Math.max(1, (entries.size() + BlockKnowledgePayloads.FRAGMENT_SIZE - 1) / BlockKnowledgePayloads.FRAGMENT_SIZE);
|
||||
}
|
||||
|
||||
private static BlockKnowledgePayloads.SnapshotPart wireRoundTrip(BlockKnowledgePayloads.SnapshotPart part) {
|
||||
RegistryFriendlyByteBuf buffer = new RegistryFriendlyByteBuf(Unpooled.buffer(), RegistryAccess.EMPTY);
|
||||
try {
|
||||
BlockKnowledgePayloads.SnapshotPart.CODEC.encode(buffer, part);
|
||||
var decoded = BlockKnowledgePayloads.SnapshotPart.CODEC.decode(buffer);
|
||||
require(decoded.equals(part) && buffer.readableBytes() == 0,
|
||||
"The real payload codec must retain exact counters, flags and fragment boundaries");
|
||||
return decoded;
|
||||
} finally {
|
||||
buffer.release();
|
||||
}
|
||||
}
|
||||
|
||||
private static void fixtureRequest(SanctuaryBlocodexScreen screen, int request) {
|
||||
// Only tests bypass the live connection prerequisite. Production has no fixture entry point.
|
||||
write(screen, "activeRequest", request);
|
||||
write(screen, "nextPart", 0);
|
||||
write(screen, "expectedParts", -1);
|
||||
write(screen, "expectedTotal", -1);
|
||||
write(screen, "pending", true);
|
||||
write(screen, "lastRequestTick", 1_000_000); // Keep screenshots independent of offline auto-refresh.
|
||||
((List<?>) read(screen, "incoming")).clear();
|
||||
((java.util.Set<?>) read(screen, "incomingIds")).clear();
|
||||
}
|
||||
|
||||
private static int filteredCount(SanctuaryBlocodexScreen screen) {
|
||||
return ((List<?>) read(screen, "filtered")).size();
|
||||
}
|
||||
|
||||
private static List<String> narrations(SanctuaryBlocodexScreen screen) {
|
||||
return list(screen).children().stream().map(entry -> entry.getNarration().getString()).toList();
|
||||
}
|
||||
|
||||
private static ObjectSelectionList<?> list(Screen screen) {
|
||||
return screen.children().stream().filter(ObjectSelectionList.class::isInstance)
|
||||
.map(child -> (ObjectSelectionList<?>) child).findFirst().orElseThrow();
|
||||
}
|
||||
|
||||
private static EditBox search(Screen screen) {
|
||||
return screen.children().stream().filter(EditBox.class::isInstance).map(EditBox.class::cast).findFirst().orElseThrow();
|
||||
}
|
||||
|
||||
private static Button button(Screen screen, String text) {
|
||||
return screen.children().stream().filter(Button.class::isInstance).map(Button.class::cast)
|
||||
.filter(button -> button.getMessage().getString().equals(text)).findFirst().orElseThrow();
|
||||
}
|
||||
|
||||
private static void chooseFilter(Screen screen, String target) {
|
||||
CycleButton<?> button = screen.children().stream().filter(CycleButton.class::isInstance)
|
||||
.map(CycleButton.class::cast).findFirst().orElseThrow();
|
||||
int attempts = 9;
|
||||
while (!button.getValue().toString().equals(target) && attempts-- > 0) button.onPress(PRESS);
|
||||
require(button.getValue().toString().equals(target), "Filter cycle must expose " + target);
|
||||
}
|
||||
|
||||
private static void assertWidgetBounds(Screen screen) {
|
||||
for (var child : screen.children()) {
|
||||
if (child instanceof AbstractWidget widget) {
|
||||
require(widget.getX() >= 0 && widget.getY() >= 0
|
||||
&& widget.getX() + widget.getWidth() <= screen.width
|
||||
&& widget.getY() + widget.getHeight() <= screen.height,
|
||||
"Widget must remain inside the native GUI: " + widget.getMessage().getString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Object read(Object target, String name) {
|
||||
try { Field field = target.getClass().getDeclaredField(name); field.setAccessible(true); return field.get(target); }
|
||||
catch (ReflectiveOperationException failure) { throw new AssertionError("Missing client fixture field " + name, failure); }
|
||||
}
|
||||
|
||||
private static void write(Object target, String name, Object value) {
|
||||
try { Field field = target.getClass().getDeclaredField(name); field.setAccessible(true); field.set(target, value); }
|
||||
catch (ReflectiveOperationException failure) { throw new AssertionError("Missing client fixture field " + name, failure); }
|
||||
}
|
||||
|
||||
private static void require(boolean condition, String message) {
|
||||
if (!condition) throw new AssertionError(message);
|
||||
}
|
||||
}
|
||||
+230
@@ -0,0 +1,230 @@
|
||||
package fr.koka.sanctuary.gametest;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import fr.koka.sanctuary.SanctuaryMod;
|
||||
import fr.koka.sanctuary.client.SanctuaryBlocodexScreen;
|
||||
import fr.koka.sanctuary.knowledge.BlockKnowledge;
|
||||
import fr.koka.sanctuary.knowledge.BlockKnowledgePayloads;
|
||||
import fr.koka.sanctuary.knowledge.BlockKnowledgeService;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import net.fabricmc.fabric.api.client.gametest.v1.context.ClientGameTestContext;
|
||||
import net.fabricmc.fabric.api.client.gametest.v1.context.TestServerContext;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
import net.minecraft.client.gui.components.ObjectSelectionList;
|
||||
import net.minecraft.client.gui.screens.worldselection.WorldCreationUiState;
|
||||
import net.minecraft.client.input.KeyEvent;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
/** Real key mapping, connection and server observations in a newly created development world. */
|
||||
final class BlocodexNetworkClientChecks {
|
||||
private static final String SEEN_ID = "minecraft:gold_block";
|
||||
private static final String POSSESSED_ID = "minecraft:diamond_block";
|
||||
private static final String UNKNOWN_ID = "minecraft:emerald_block";
|
||||
|
||||
static void run(ClientGameTestContext context) {
|
||||
Path runDirectory = Path.of("").toAbsolutePath().normalize();
|
||||
Path saves = context.computeOnClient(client -> client.getLevelSource().getBaseDir().toAbsolutePath().normalize());
|
||||
require(runDirectory.endsWith(Path.of("build", "run", "clientGameTest"))
|
||||
&& saves.startsWith(runDirectory),
|
||||
"The network test must create worlds only inside the ignored development client run directory");
|
||||
context.runOnClient(client -> {
|
||||
var matches = Arrays.stream(client.options.keyMappings)
|
||||
.filter(key -> key.getName().equals("sanctuary.blocodex.key")).toList();
|
||||
require(matches.size() == 1, "Exactly one innate Blocodex key mapping must be registered");
|
||||
var key = matches.getFirst();
|
||||
require(key.getCategory().id().equals(SanctuaryMod.id("sanctuary"))
|
||||
&& key.matches(new KeyEvent(InputConstants.KEY_B, 0, 0)),
|
||||
"The Sanctuary category must expose the real B binding in the development client");
|
||||
});
|
||||
|
||||
String worldName = "Sanctuary Blocodex network " + UUID.randomUUID();
|
||||
Path saveDirectory;
|
||||
UUID playerId;
|
||||
Map<String, BlockKnowledge> firstServerSnapshot;
|
||||
Map<String, BlockKnowledge> secondServerSnapshot;
|
||||
// Fabric's consistent defaults are a fresh flat world, seed 1, no structures or mobs.
|
||||
try (var world = context.worldBuilder().adjustSettings(settings -> {
|
||||
settings.setName(worldName);
|
||||
settings.setGameMode(WorldCreationUiState.SelectedGameMode.SURVIVAL);
|
||||
settings.setAllowCommands(false);
|
||||
}).create()) {
|
||||
saveDirectory = world.getWorldSave().getSaveDirectory().toAbsolutePath().normalize();
|
||||
require(saveDirectory.startsWith(saves) && !saveDirectory.equals(saves),
|
||||
"The new test save must remain inside the development saves directory");
|
||||
var connection = world.getConnection();
|
||||
var serverContext = world.getServer();
|
||||
connection.waitForChunksDownload(1200);
|
||||
context.waitFor(client -> client.player != null && client.gui.screen() == null
|
||||
&& ClientPlayNetworking.canSend(BlockKnowledgePayloads.Request.TYPE), 600);
|
||||
playerId = serverContext.computeOnServer(server -> player(server).getUUID());
|
||||
serverContext.runOnServer(server -> {
|
||||
require(!BlockKnowledgeService.knowledge(player(server), Blocks.GOLD_BLOCK).known(),
|
||||
"A fresh flat world must not already know the observation target");
|
||||
require(!BlockKnowledgeService.knowledge(player(server), Blocks.DIAMOND_BLOCK).known(),
|
||||
"A fresh player must not already possess the inventory target");
|
||||
});
|
||||
|
||||
BlockPos target = serverContext.computeOnServer(server -> {
|
||||
ServerPlayer player = player(server);
|
||||
BlockPos pos = player.blockPosition().offset(0, 1, 3);
|
||||
// Explicit test setup; normal tick observation must discover both facts itself.
|
||||
player.level().setBlockAndUpdate(pos, Blocks.GOLD_BLOCK.defaultBlockState());
|
||||
player.getInventory().setItem(0, new ItemStack(Items.DIAMOND_BLOCK, 3));
|
||||
player.inventoryMenu.broadcastChanges();
|
||||
return pos;
|
||||
});
|
||||
connection.waitForClientboundPackets();
|
||||
context.waitFor(client -> client.level.getBlockState(target).is(Blocks.GOLD_BLOCK)
|
||||
&& client.player.getInventory().getItem(0).is(Items.DIAMOND_BLOCK), 600);
|
||||
context.getInput().lookAt(target);
|
||||
connection.waitForServerboundPackets();
|
||||
context.waitTicks(BlockKnowledgeService.OBSERVATION_INTERVAL + 1);
|
||||
serverContext.waitFor(server -> {
|
||||
ServerPlayer player = player(server);
|
||||
var observed = BlockKnowledgeService.knowledge(player, Blocks.GOLD_BLOCK);
|
||||
var carried = BlockKnowledgeService.knowledge(player, Blocks.DIAMOND_BLOCK);
|
||||
return observed.seen() && carried.possessed() && carried.carried() == 3;
|
||||
}, 600);
|
||||
firstServerSnapshot = expected(serverContext);
|
||||
require(firstServerSnapshot.get(SEEN_ID).seen()
|
||||
&& !firstServerSnapshot.get(SEEN_ID).possessed()
|
||||
&& !firstServerSnapshot.get(POSSESSED_ID).seen()
|
||||
&& firstServerSnapshot.get(POSSESSED_ID).carried() == 3
|
||||
&& !firstServerSnapshot.get(UNKNOWN_ID).known(),
|
||||
"The live server must retain independent seen, possessed and unknown states");
|
||||
|
||||
SanctuaryBlocodexScreen first = openWithB(context);
|
||||
context.runOnClient(client -> assertSnapshot(first, firstServerSnapshot));
|
||||
context.runOnClient(client -> search(first).setValue(POSSESSED_ID));
|
||||
context.waitTick();
|
||||
context.takeScreenshot("sanctuary-blocodex-network-carried-three");
|
||||
context.getInput().pressKey(InputConstants.KEY_ESCAPE);
|
||||
context.waitFor(client -> client.gui.screen() == null, 120);
|
||||
|
||||
serverContext.runOnServer(server -> {
|
||||
ServerPlayer player = player(server);
|
||||
player.getInventory().setItem(0, ItemStack.EMPTY);
|
||||
player.inventoryMenu.broadcastChanges();
|
||||
});
|
||||
context.waitTicks(2);
|
||||
serverContext.waitFor(server -> {
|
||||
var knowledge = BlockKnowledgeService.knowledge(player(server), Blocks.DIAMOND_BLOCK);
|
||||
return knowledge.possessed() && knowledge.carried() == 0;
|
||||
}, 600);
|
||||
connection.waitForClientboundPackets();
|
||||
secondServerSnapshot = expected(serverContext);
|
||||
|
||||
// The production request limiter uses wall time, while game-test ticks can run faster.
|
||||
long reopenAt = System.nanoTime() + 1_100_000_000L;
|
||||
context.waitFor(client -> System.nanoTime() >= reopenAt, 2400);
|
||||
SanctuaryBlocodexScreen second = openWithB(context);
|
||||
require(second != first, "Closing and reopening with B must issue a fresh screen request");
|
||||
context.runOnClient(client -> {
|
||||
assertSnapshot(second, secondServerSnapshot);
|
||||
search(second).setValue(POSSESSED_ID);
|
||||
require(list(second).children().size() == 1,
|
||||
"The received block must remain searchable after its current inventory becomes empty");
|
||||
});
|
||||
context.waitTick();
|
||||
context.takeScreenshot("sanctuary-blocodex-network-sticky-possession");
|
||||
context.getInput().pressKey(InputConstants.KEY_ESCAPE);
|
||||
context.waitFor(client -> client.gui.screen() == null, 120);
|
||||
}
|
||||
|
||||
try {
|
||||
Path sidecar = saveDirectory.resolve("data/sanctuary-blocodex").resolve(playerId + ".json");
|
||||
require(Files.isRegularFile(sidecar), "Closing the real server must persist its observed player history");
|
||||
Path diagnostics = runDirectory.resolve("diagnostics");
|
||||
Files.createDirectories(diagnostics);
|
||||
Files.writeString(diagnostics.resolve("sanctuary-blocodex-network-client.json"),
|
||||
new GsonBuilder().setPrettyPrinting().create().toJson(Map.of(
|
||||
"fixture", "New flat development world; gold block and three diamond blocks prepared on the server",
|
||||
"save_directory", saveDirectory.toString(), "player_uuid", playerId.toString(),
|
||||
"real_b_key_and_payloads", true, "server_gaze_and_inventory", true,
|
||||
"before_removal", firstServerSnapshot, "after_removal", secondServerSnapshot,
|
||||
"sidecar_saved_on_close", true, "passed", true)) + "\n");
|
||||
SanctuaryMod.LOGGER.info("Blocodex network client checks passed: real B key, native server snapshots, observed gaze, sticky possession and empty carried stock in {}", saveDirectory);
|
||||
} catch (IOException failure) {
|
||||
throw new AssertionError("Unable to verify native Blocodex network diagnostics", failure);
|
||||
}
|
||||
}
|
||||
|
||||
private static SanctuaryBlocodexScreen openWithB(ClientGameTestContext context) {
|
||||
context.getInput().pressKey(InputConstants.KEY_B);
|
||||
context.waitForScreen(SanctuaryBlocodexScreen.class);
|
||||
context.waitFor(client -> client.gui.screen() instanceof SanctuaryBlocodexScreen screen
|
||||
&& (boolean) read(screen, "loaded"), 1200);
|
||||
return context.computeOnClient(client -> (SanctuaryBlocodexScreen) client.gui.screen());
|
||||
}
|
||||
|
||||
private static Map<String, BlockKnowledge> expected(TestServerContext context) {
|
||||
return context.computeOnServer(server -> {
|
||||
ServerPlayer player = player(server);
|
||||
return Map.of(SEEN_ID, BlockKnowledgeService.knowledge(player, Blocks.GOLD_BLOCK),
|
||||
POSSESSED_ID, BlockKnowledgeService.knowledge(player, Blocks.DIAMOND_BLOCK),
|
||||
UNKNOWN_ID, BlockKnowledgeService.knowledge(player, Blocks.EMERALD_BLOCK));
|
||||
});
|
||||
}
|
||||
|
||||
private static void assertSnapshot(SanctuaryBlocodexScreen screen, Map<String, BlockKnowledge> expected) {
|
||||
require((boolean) read(screen, "available"), "The real server snapshot must be available");
|
||||
List<?> rows = (List<?>) read(screen, "catalogue");
|
||||
Map<String, BlockKnowledge> received = rows.stream().map(BlocodexNetworkClientChecks::knowledge)
|
||||
.collect(Collectors.toUnmodifiableMap(BlockKnowledge::blockId, value -> value));
|
||||
for (var entry : expected.entrySet()) {
|
||||
require(entry.getValue().equals(received.get(entry.getKey())),
|
||||
"The live network snapshot must retain the server's exact evidence and counters for " + entry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
private static BlockKnowledge knowledge(Object row) {
|
||||
try {
|
||||
Method method = row.getClass().getDeclaredMethod("knowledge");
|
||||
method.setAccessible(true);
|
||||
return (BlockKnowledge) method.invoke(row);
|
||||
} catch (ReflectiveOperationException failure) {
|
||||
throw new AssertionError("Unable to read received Blocodex row", failure);
|
||||
}
|
||||
}
|
||||
|
||||
private static ServerPlayer player(MinecraftServer server) {
|
||||
List<ServerPlayer> players = server.getPlayerList().getPlayers();
|
||||
require(players.size() == 1, "The development integrated server must have one actual connected player");
|
||||
return players.getFirst();
|
||||
}
|
||||
|
||||
private static EditBox search(SanctuaryBlocodexScreen screen) {
|
||||
return screen.children().stream().filter(EditBox.class::isInstance)
|
||||
.map(EditBox.class::cast).findFirst().orElseThrow();
|
||||
}
|
||||
|
||||
private static ObjectSelectionList<?> list(SanctuaryBlocodexScreen screen) {
|
||||
return screen.children().stream().filter(ObjectSelectionList.class::isInstance)
|
||||
.map(child -> (ObjectSelectionList<?>) child).findFirst().orElseThrow();
|
||||
}
|
||||
|
||||
private static Object read(Object target, String name) {
|
||||
try { Field field = target.getClass().getDeclaredField(name); field.setAccessible(true); return field.get(target); }
|
||||
catch (ReflectiveOperationException failure) { throw new AssertionError("Unable to read received Blocodex state " + name, failure); }
|
||||
}
|
||||
|
||||
private static void require(boolean condition, String message) {
|
||||
if (!condition) throw new AssertionError(message);
|
||||
}
|
||||
}
|
||||
+2
@@ -17,6 +17,8 @@ public final class SanctuaryClientRenderTests implements FabricClientGameTest {
|
||||
SanctuaryMod.LOGGER.info("Client render tests passed: Sanctuary sky and fog mixins applied.");
|
||||
});
|
||||
SanctuaryWorldOptionsClientChecks.run(context);
|
||||
BlocodexClientChecks.run(context);
|
||||
BlocodexNetworkClientChecks.run(context);
|
||||
}
|
||||
|
||||
private static void assertApplied(ClassLoader loader, String target, String hook) {
|
||||
|
||||
+183
@@ -0,0 +1,183 @@
|
||||
package fr.koka.sanctuary.gametest;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import fr.koka.sanctuary.SanctuaryMod;
|
||||
import fr.koka.sanctuary.expansion.*;
|
||||
import fr.koka.sanctuary.knowledge.structures.StructureCensusMemory;
|
||||
import fr.koka.sanctuary.knowledge.structures.StructureCensusService;
|
||||
import fr.koka.sanctuary.worldgen.SanctuaryChunkGenerator;
|
||||
import fr.koka.sanctuary.worldgen.aerial.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import net.fabricmc.fabric.api.gametest.v1.GameTest;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.gametest.framework.GameTestHelper;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.TicketType;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureStart;
|
||||
|
||||
/** Separate disposable world: real admission before visiting satellites, then an actual ticking waterfall. */
|
||||
public final class Aerial24FlowAdmissionGameTests {
|
||||
private record Request(String id, String direction, int diameter, ExpansionIsland raw, ExpansionIsland filtered) {}
|
||||
|
||||
@GameTest(maxTicks = 24000)
|
||||
public void reservedSatellitesAndNativeWaterfall(GameTestHelper helper) throws Exception {
|
||||
var report = new LinkedHashMap<String, Object>();
|
||||
var level = helper.getLevel();
|
||||
var generator = (SanctuaryChunkGenerator) level.getChunkSource().getGenerator();
|
||||
helper.assertTrue(generator.rootGeneration() == 24 && generator.experimentalStructures()
|
||||
&& level.structureManager().shouldGenerateStructures(), "Fresh generation24 with aerial sites and native structures enabled");
|
||||
var plan = generator.aerialPlan24();
|
||||
var session = Objects.requireNonNull(ExpansionRuntime.session(level));
|
||||
helper.assertTrue(session.islands().size() == 1 && plan.sites().size() == 4, "Use an untouched disposable world for admission witnesses");
|
||||
var evidence = StructureCensusService.snapshot(level.getServer()).evidence();
|
||||
String dimension = level.dimension().identifier().toString();
|
||||
for (var site : plan.sites()) for (var chunk : site.claimedChunks())
|
||||
helper.assertTrue((evidence.chunks().getOrDefault(new StructureCensusMemory.ChunkKey(dimension, chunk.x(), chunk.z()), 0) & StructureCensusMemory.FULL) == 0,
|
||||
"Satellite claims are protected before any of their chunks reach FULL");
|
||||
report.put("seed", level.getSeed()); report.put("diameter", generator.initialDiameter()); report.put("process_id", ProcessHandle.current().pid());
|
||||
report.put("unvisited_claims_verified", true); report.put("sites", plan.sites());
|
||||
var admitted = new ArrayList<ExpansionIsland>();
|
||||
try {
|
||||
report.put("stage", "real admission toward an unseen satellite");
|
||||
if (!requests(level.getSeed(), session.islands(), plan, true).isEmpty())
|
||||
admitted.add(admit(helper, level, generator, session, plan, true, report));
|
||||
else report.put("collision_admission", "No raw expansion candidate reaches the close sites; initial island ownership already excludes them");
|
||||
report.put("stage", "real admission through an unclaimed interval");
|
||||
admitted.add(admit(helper, level, generator, session, plan, false, report));
|
||||
} catch (Exception error) { failure(report, error); throw error; }
|
||||
var waterfall = plan.sites().stream().filter(AerialPlan24.Site::waterfall).findFirst().orElseThrow();
|
||||
var requested = waterfall.claimedChunks(); var iterator = requested.iterator();
|
||||
boolean[] tickets = {false}; int[] flowTicks = {0};
|
||||
Runnable release = () -> {
|
||||
if (tickets[0]) requested.forEach(chunk -> level.getChunkSource().removeTicketWithRadius(TicketType.DRAGON, chunk, 2));
|
||||
tickets[0] = false;
|
||||
};
|
||||
Runnable[] step = new Runnable[1];
|
||||
step[0] = () -> {
|
||||
try {
|
||||
if (admitted.stream().anyMatch(island -> !session.island(island.id()).status().equals("ready"))) {
|
||||
report.put("stage", "prepare admitted expansions"); report.put("progress", session.progress());
|
||||
helper.assertTrue(!session.progress().contains("failed") && !session.progress().contains("reload_required")
|
||||
&& !session.progress().contains("unavailable"), "Real admission preparation progresses without reload or failure");
|
||||
helper.runAtTickTime(helper.getTick() + 5, () -> step[0].run()); return;
|
||||
}
|
||||
if (!report.containsKey("native_ready_starts")) {
|
||||
var nativeStarts = new TreeMap<String, Integer>();
|
||||
for (var reserved : admitted) {
|
||||
var ready = session.island(reserved.id());
|
||||
helper.assertTrue(ready.equals(reserved.ready()) && !plan.conflicts(ready), "READY retains its immutable safe placement");
|
||||
int count = 0;
|
||||
for (var candidate : ExpansionStructures23.candidates(ready)) {
|
||||
var chunk = level.getChunk(candidate.chunk().x(), candidate.chunk().z(), ChunkStatus.STRUCTURE_STARTS, true);
|
||||
count += (int) chunk.getAllStarts().values().stream().filter(StructureStart::isValid)
|
||||
.filter(start -> ((Object) start) instanceof NativeStructureMetadata23 metadata && metadata.sanctuary$native23() != null).count();
|
||||
}
|
||||
helper.assertTrue(count > 0, "Admitted generation24 expansion produces at least one real native start");
|
||||
nativeStarts.put(ready.id(), count);
|
||||
}
|
||||
report.put("native_ready_starts", nativeStarts);
|
||||
}
|
||||
if (iterator.hasNext()) {
|
||||
var chunk = iterator.next(); report.put("stage", "FULL waterfall " + chunk);
|
||||
level.getChunk(chunk.x(), chunk.z(), ChunkStatus.FULL, true);
|
||||
helper.runAtTickTime(helper.getTick() + 1, () -> step[0].run()); return;
|
||||
}
|
||||
if (!tickets[0]) {
|
||||
requested.forEach(chunk -> level.getChunkSource().addTicketWithRadius(TicketType.DRAGON, chunk, 2)); tickets[0] = true;
|
||||
}
|
||||
flowTicks[0] += 20; report.put("flow_wait_ticks", flowTicks[0]); report.put("stage", "native fluid ticks beneath the suspended island");
|
||||
var source = AerialGeometry24.waterfallSource(waterfall);
|
||||
helper.assertTrue(level.getFluidState(source).is(FluidTags.WATER) && level.getFluidState(source).isSource(), "The authored source remains a single native water source");
|
||||
// Alpha28 islets stand above real terrain: a cascade may land on Sanctuary.
|
||||
// Require native flow through the free air gap, not an impossible route through rock.
|
||||
var below = waterAt(level, waterfall, waterfall.minY() - 1);
|
||||
var low = waterAt(level, waterfall, waterfall.minY() - AerialPlanner24.MIN_ISLET_GAP);
|
||||
report.put("water_below_islet", below == null ? List.of() : coords(below));
|
||||
report.put("water_across_air_gap", low == null ? List.of() : coords(low));
|
||||
if (below == null || low == null) {
|
||||
helper.assertTrue(flowTicks[0] <= 4000, "Scheduled vanilla fluid ticks carry the waterfall through the sixteen-block air gap");
|
||||
helper.runAtTickTime(helper.getTick() + 20, () -> step[0].run()); return;
|
||||
}
|
||||
helper.assertTrue(!level.getFluidState(low).isSource(), "Low waterfall water is flowing, not a fabricated source column");
|
||||
report.put("expansions", admitted.stream().map(island -> session.island(island.id())).toList());
|
||||
report.put("passed", true);
|
||||
StructureCensusService.flush(level.getServer());
|
||||
helper.assertTrue(level.getServer().saveEverything(true, true, true), "Persist the disposable flow/admission witness");
|
||||
write(report, "full.json"); release.run(); helper.succeed();
|
||||
} catch (Exception error) { release.run(); failure(report, error); throw new IllegalStateException("Aerial24 flow/admission failed: " + error.getMessage(), error); }
|
||||
};
|
||||
helper.runAtTickTime(helper.getTick() + 1, () -> step[0].run());
|
||||
}
|
||||
|
||||
private static ExpansionIsland admit(GameTestHelper helper, ServerLevel level, SanctuaryChunkGenerator generator,
|
||||
ExpansionRuntime.Session session, AerialPlan24 plan, boolean collision, Map<String, Object> report) throws Exception {
|
||||
var requests = requests(level.getSeed(), session.islands(), plan, collision);
|
||||
helper.assertTrue(!requests.isEmpty(), "The finite candidate search contains a " + (collision ? "satellite overlap" : "free interval") + " witness");
|
||||
var attempts = new ArrayList<Map<String, Object>>(); report.put(collision ? "collision_attempts" : "interval_attempts", attempts);
|
||||
for (var request : requests.stream().limit(8).toList()) {
|
||||
var before = List.copyOf(session.islands());
|
||||
var filtered = session.candidate(request.id(), "sanctuary", request.direction(), "temperate", request.diameter(), "natural");
|
||||
helper.assertTrue(filtered.equals(request.filtered()), "Real runtime candidate uses the same immutable aerial claims before any terrain inspection");
|
||||
if (collision) helper.assertTrue(plan.conflicts(request.raw()) && !plan.conflicts(filtered) && !filtered.equals(request.raw()),
|
||||
"The first overlapping candidate is rejected before the satellite is visited");
|
||||
long start = System.nanoTime();
|
||||
try {
|
||||
var reserved = session.create(request.id(), "sanctuary", request.direction(), "temperate", request.diameter(), "natural");
|
||||
long elapsed = (System.nanoTime() - start) / 1_000_000;
|
||||
helper.assertTrue(elapsed <= 31_000, "Actual Session.create keeps its production thirty-second deadline");
|
||||
helper.assertTrue(!plan.conflicts(reserved), "The admitted expansion cannot claim any satellite chunk");
|
||||
helper.assertTrue(!ExpansionVoidReuse.requiresReload(level, reserved.id()), "Untouched candidate prepares in the same development session");
|
||||
|
||||
helper.assertTrue(session.create(request.id(), "sanctuary", request.direction(), "temperate", request.diameter(), "natural").equals(reserved),
|
||||
"Reservation retry is idempotent");
|
||||
attempts.add(Map.of("request", request, "reserved", reserved, "elapsed_ms", elapsed));
|
||||
return reserved;
|
||||
} catch (IllegalArgumentException refused) {
|
||||
helper.assertTrue(before.equals(session.islands()), "Refused native admission writes no reservation");
|
||||
attempts.add(Map.of("request", request, "refused", String.valueOf(refused.getMessage()), "elapsed_ms", (System.nanoTime() - start) / 1_000_000));
|
||||
if (!"native_structure_unavailable".equals(refused.getMessage())) throw refused;
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("No native expansion fits the bounded aerial admission witnesses");
|
||||
}
|
||||
|
||||
private static List<Request> requests(long seed, List<ExpansionIsland> islands, AerialPlan24 plan, boolean collision) {
|
||||
var result = new ArrayList<Request>();
|
||||
for (int index = 0; index < 32 && result.size() < 16; index++) for (var direction : ExpansionIsland.DIRECTIONS) {
|
||||
String id = (collision ? "aerial_collision_" : "aerial_interval_") + index + "_" + direction.replace("_", "");
|
||||
var raw = ExpansionPlacement.candidates(seed, islands, id, "sanctuary", direction, "temperate", 128, "natural", 0);
|
||||
if (raw.isEmpty() || plan.conflicts(raw.getFirst()) != collision) continue;
|
||||
var filtered = raw.stream().filter(candidate -> !plan.conflicts(candidate)).findFirst().orElse(null);
|
||||
if (filtered == null) continue;
|
||||
result.add(new Request(id, direction, 128, raw.getFirst(), filtered));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private static boolean inAerialBand(ExpansionIsland island, AerialPlan24 plan) {
|
||||
double outside = plan.claimsChunks().stream().map(ChunkPos::unpack).mapToDouble(chunk -> Math.hypot(chunk.getMiddleBlockX(), chunk.getMiddleBlockZ()) + 12).max().orElseThrow();
|
||||
return Math.hypot(island.centerX(), island.centerZ()) - island.reservedRadius() < outside;
|
||||
}
|
||||
private static BlockPos waterAt(ServerLevel level, AerialPlan24.Site site, int y) {
|
||||
for (int x = site.minX() - 3; x <= site.maxX() + 3; x++) for (int z = site.minZ() - 3; z <= site.maxZ() + 3; z++) {
|
||||
var pos = new BlockPos(x, y, z);
|
||||
if (level.getFluidState(pos).is(FluidTags.WATER)) return pos;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private static List<Integer> coords(BlockPos pos) { return List.of(pos.getX(), pos.getY(), pos.getZ()); }
|
||||
private static void write(Map<String, Object> report, String name) throws java.io.IOException {
|
||||
var directory = Path.of("diagnostics/aerial24-flow-admission"); Files.createDirectories(directory);
|
||||
Files.writeString(directory.resolve(name), new GsonBuilder().setPrettyPrinting().create().toJson(report));
|
||||
}
|
||||
private static void failure(Map<String, Object> report, Exception error) {
|
||||
report.put("passed", false); report.put("failure", error.toString());
|
||||
var stack = new java.io.StringWriter(); error.printStackTrace(new java.io.PrintWriter(stack)); report.put("stacktrace", stack.toString());
|
||||
SanctuaryMod.LOGGER.error("Aerial24 flow/admission failed at {}", report.get("stage"), error);
|
||||
try { write(report, "failure.json"); } catch (java.io.IOException failed) { error.addSuppressed(failed); }
|
||||
}
|
||||
}
|
||||
+442
@@ -0,0 +1,442 @@
|
||||
package fr.koka.sanctuary.gametest;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import fr.koka.sanctuary.SanctuaryMod;
|
||||
import fr.koka.sanctuary.expansion.ExpansionIsland;
|
||||
import fr.koka.sanctuary.expansion.ExpansionStructures23;
|
||||
import fr.koka.sanctuary.knowledge.structures.StructureCensusService;
|
||||
import fr.koka.sanctuary.worldgen.SanctuaryChunkGenerator;
|
||||
import fr.koka.sanctuary.worldgen.aerial.*;
|
||||
import fr.koka.sanctuary.worldgen.city.LostCityRenderer;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import net.fabricmc.fabric.api.gametest.v1.GameTest;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.HolderSet;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.gametest.framework.GameTestHelper;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.TicketType;
|
||||
import net.minecraft.world.entity.npc.villager.Villager;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
import net.minecraft.world.level.levelgen.structure.Structure;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureStart;
|
||||
import net.minecraft.world.level.levelgen.structure.pieces.StructurePieceSerializationContext;
|
||||
import net.minecraft.world.level.storage.LevelResource;
|
||||
import net.minecraft.world.level.storage.loot.LootTable;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
/** One real world per size/seed. Separate JVM phases preserve looting, mining and extracted occupants. */
|
||||
public final class Aerial24WorldGameTests {
|
||||
private static final com.google.gson.Gson JSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
|
||||
@GameTest(maxTicks = 24000)
|
||||
public void fourSitesPersistAfterUse(GameTestHelper helper) throws Exception {
|
||||
var report = new LinkedHashMap<String, Object>();
|
||||
try { begin(helper, report); }
|
||||
catch (Exception failure) { failure(report, failure); throw failure; }
|
||||
}
|
||||
|
||||
private static void begin(GameTestHelper helper, Map<String, Object> report) throws Exception {
|
||||
var level = helper.getLevel();
|
||||
var generator = (SanctuaryChunkGenerator) level.getChunkSource().getGenerator();
|
||||
helper.assertTrue(generator.rootGeneration() == 24, "Aerial24 requires a disposable generation24 world");
|
||||
String phase = System.getProperty("sanctuary.test.aerial24.phase", "create");
|
||||
helper.assertTrue(List.of("create", "reload1", "reload2").contains(phase), "Known aerial lifecycle phase");
|
||||
boolean create = phase.equals("create");
|
||||
var plan = generator.aerialPlan24();
|
||||
report.put("phase", phase); report.put("seed", level.getSeed()); report.put("diameter", generator.initialDiameter());
|
||||
report.put("process_id", ProcessHandle.current().pid()); report.put("experimental", generator.experimentalStructures());
|
||||
report.put("generate_structures", level.structureManager().shouldGenerateStructures());
|
||||
if (!level.structureManager().shouldGenerateStructures() || !generator.experimentalStructures()) {
|
||||
helper.assertTrue(plan.isEmpty() && plan.claimsChunks().isEmpty(), "Disabled aerial generation reserves no space");
|
||||
helper.assertTrue(StructureCensusService.aerialSites(level).isEmpty(), "Disabled aerial sites are not presented as planned");
|
||||
report.put("passed", true); write(Path.of("diagnostics/aerial24/off.json"), report); helper.succeed(); return;
|
||||
}
|
||||
helper.assertTrue(plan.sites().size() == 4, "All four initial aerial sites have a finite saved plan");
|
||||
helper.assertTrue(plan.sites().stream().filter(AerialPlan24.Site::merchant).count() == 2, "Two merchant ships");
|
||||
helper.assertTrue(plan.sites().stream().filter(AerialPlan24.Site::waterfall).count() == 1, "One waterfall site");
|
||||
if (generator.initialDiameter() == 724 && (level.getSeed() == 0 || level.getSeed() == 42))
|
||||
AerialRenderer24.writeDiagnostic(Path.of("diagnostics/aerial24/blocks.json"), plan.sites());
|
||||
report.put("geometry", JSON.toJsonTree(plan.sites())); report.put("claim_count", plan.claimsChunks().size());
|
||||
report.put("census_before", StructureCensusService.aerialSites(level));
|
||||
report.put("generator_codec", ChunkGenerator.CODEC.encodeStart(RegistryOps.create(JsonOps.INSTANCE, level.registryAccess()), generator).getOrThrow());
|
||||
var journalBefore = files(level.getServer().getWorldPath(LevelResource.ROOT).resolve("data").resolve(generator.journalDirectory()));
|
||||
verifyClaims(helper, generator, plan, report);
|
||||
Path world = level.getServer().getWorldPath(LevelResource.ROOT);
|
||||
JsonObject previous = create ? null : JsonParser.parseString(Files.readString(world.resolve("aerial24-" + (phase.equals("reload1") ? "create" : "reload1") + ".json"))).getAsJsonObject();
|
||||
if (previous != null) {
|
||||
helper.assertTrue(previous.get("passed").getAsBoolean() && previous.get("process_id").getAsLong() != ProcessHandle.current().pid(), "Reload occurs in a separate JVM after a successful phase");
|
||||
helper.assertTrue(previous.get("geometry").equals(JSON.toJsonTree(plan.sites())), "Site geometry and palette seeds survive reload");
|
||||
helper.assertTrue(previous.get("generator_codec").equals(report.get("generator_codec")), "Generator options survive reload");
|
||||
}
|
||||
var chunks = new TreeSet<ChunkPos>(Comparator.comparingInt(ChunkPos::x).thenComparingInt(ChunkPos::z));
|
||||
plan.sites().forEach(site -> chunks.addAll(site.claimedChunks()));
|
||||
plan.sites().forEach(site -> chunks.add(ChunkPos.containing(new BlockPos(site.shoreX(), site.shoreY(), site.shoreZ()))));
|
||||
// The two extracted merchants are retained in a separate, existing root chunk.
|
||||
chunks.add(new ChunkPos(0, 0));
|
||||
var loadOrder = new ArrayList<>(chunks);
|
||||
boolean reverseChunks = Boolean.getBoolean("sanctuary.test.aerial24.reverseChunks");
|
||||
if (reverseChunks) Collections.reverse(loadOrder);
|
||||
report.put("reverse_chunks", reverseChunks);
|
||||
var iterator = loadOrder.iterator();
|
||||
var entityChunks = new HashSet<ChunkPos>();
|
||||
plan.sites().stream().filter(AerialPlan24.Site::merchant).forEach(site -> entityChunks.addAll(site.claimedChunks()));
|
||||
entityChunks.add(new ChunkPos(0, 0));
|
||||
boolean[] tickets = {false}; int[] wait = {0};
|
||||
Runnable release = () -> {
|
||||
if (tickets[0]) entityChunks.forEach(pos -> level.getChunkSource().removeTicketWithRadius(TicketType.DRAGON, pos, 2));
|
||||
tickets[0] = false;
|
||||
};
|
||||
Runnable[] step = new Runnable[1];
|
||||
step[0] = () -> {
|
||||
try {
|
||||
if (iterator.hasNext()) {
|
||||
var chunk = iterator.next(); report.put("stage", "FULL " + chunk);
|
||||
level.getChunk(chunk.x(), chunk.z(), ChunkStatus.FULL, true);
|
||||
helper.runAtTickTime(helper.getTick() + 1, () -> step[0].run()); return;
|
||||
}
|
||||
if (!report.containsKey("native_departures_ready")) {
|
||||
// Fail on a missing native start immediately instead of waiting for entities
|
||||
// which could never have been placed (for example, an obsolete void-only gate).
|
||||
report.put("stage", "verify saved aerial departures before entity loading");
|
||||
report.put("native_departures_ready", starts(helper, level, plan).size());
|
||||
}
|
||||
if (!tickets[0]) {
|
||||
entityChunks.forEach(pos -> level.getChunkSource().addTicketWithRadius(TicketType.DRAGON, pos, 2)); tickets[0] = true;
|
||||
}
|
||||
var occupants = occupants(level, plan);
|
||||
var readiness = new TreeMap<String, Object>(); boolean entitiesReady = true;
|
||||
for (var pos : entityChunks) {
|
||||
boolean loaded = level.areEntitiesLoaded(pos.pack()), ticking = level.areEntitiesActuallyLoadedAndTicking(pos);
|
||||
readiness.put(pos.toString(), Map.of("loaded", loaded, "ticking", ticking));
|
||||
entitiesReady &= loaded && ticking;
|
||||
}
|
||||
report.put("entity_chunks", readiness);
|
||||
report.put("occupants_observed", occupants.stream().map(villager -> Map.of("uuid", villager.getUUID().toString(),
|
||||
"position", List.of(villager.getX(), villager.getY(), villager.getZ()))).toList());
|
||||
report.put("visible_occupants", occupants.size()); report.put("entity_wait_ticks", wait[0]);
|
||||
if ((!entitiesReady || occupants.size() < 2) && wait[0]++ < 600) {
|
||||
report.put("stage", "wait for persistent merchants");
|
||||
helper.runAtTickTime(helper.getTick() + 1, () -> step[0].run()); return;
|
||||
}
|
||||
helper.assertTrue(entitiesReady, "All ship chunks finish native entity loading and become ticking before occupant inspection");
|
||||
helper.assertTrue(occupants.size() == 2, "Both one-time merchants are present after native entity loading");
|
||||
report.put("stage", "inspect native structures");
|
||||
var starts = starts(helper, level, plan);
|
||||
var before = inspect(helper, level, plan, create, report);
|
||||
if (create) {
|
||||
verifyLocator(helper, level, plan, starts);
|
||||
report.put("stage", "loot, extract and dismantle disposable witnesses");
|
||||
report.put("mutations", mutate(helper, level, plan, occupants, before));
|
||||
} else {
|
||||
report.put("mutations", previous.get("mutations"));
|
||||
verifyMutations(helper, level, plan, previous.getAsJsonObject("mutations"), occupants);
|
||||
}
|
||||
var tags = tags(level, starts);
|
||||
if (!create) helper.assertTrue(previous.get("native_tags").equals(JSON.toJsonTree(tags)), "Native starts, references and occupant flags survive both reloads");
|
||||
report.put("native_tags", tags); report.put("full_chunks", chunks.size());
|
||||
report.put("blocks_after", countSites(level, plan));
|
||||
var census = StructureCensusService.aerialSites(level);
|
||||
helper.assertTrue(census.size() == 4 && census.stream().allMatch(site -> site.status() == StructureCensusService.AerialStatus.GENERATED),
|
||||
"Four historical generated sites remain indexed after loot, mining and demolition");
|
||||
report.put("census_after", census);
|
||||
helper.assertTrue(equalFiles(journalBefore, files(world.resolve("data").resolve(generator.journalDirectory()))), "Aerial tests never reserve or activate an expansion");
|
||||
report.put("expansion_journal_unchanged", true);
|
||||
StructureCensusService.flush(level.getServer());
|
||||
helper.assertTrue(level.getServer().saveEverything(true, true, true), "Save actual blocks, loot state, starts and occupants");
|
||||
report.put("passed", true);
|
||||
write(world.resolve("aerial24-" + phase + ".json"), report);
|
||||
write(Path.of("diagnostics/aerial24/" + phase + ".json"), report);
|
||||
release.run(); helper.succeed();
|
||||
} catch (Exception error) {
|
||||
release.run(); failure(report, error); throw new IllegalStateException("Aerial24 failed: " + error.getMessage(), error);
|
||||
}
|
||||
};
|
||||
helper.runAtTickTime(helper.getTick() + 1, () -> step[0].run());
|
||||
}
|
||||
|
||||
private static void verifyClaims(GameTestHelper helper, SanctuaryChunkGenerator generator, AerialPlan24 plan, Map<String, Object> report) {
|
||||
var root = generator.source().islands().stream().filter(ExpansionIsland::origin).findFirst().orElseThrow();
|
||||
var views = new LinkedHashMap<String, Object>();
|
||||
for (var site : plan.sites()) {
|
||||
if (site.merchant()) {
|
||||
double gap = AerialPlanner24.shoreDistance(site);
|
||||
helper.assertTrue(gap >= 16 && gap <= 48, "Native ship is just off its verified shore");
|
||||
helper.assertTrue(Math.abs(AerialGeometry24.entry(site).getY() - site.shoreY()) <= 4, "Boarding deck follows the nearby shore height");
|
||||
} else {
|
||||
helper.assertTrue(root.ownsChunk(site.startChunkX(), site.startChunkZ()), "Mineral islet floats above Sanctuary terrain");
|
||||
var column = generator.aerialBaseColumn24(site.shoreX(), site.shoreZ());
|
||||
helper.assertTrue(column.getBlock(site.shoreY() - 1).isSolid(), "Overhead islet retains a real ground witness below it");
|
||||
int highest = 0;
|
||||
for (int y = 382; y > 0; y--) if (!column.getBlock(y).isAir()) { highest = y; break; }
|
||||
helper.assertTrue(site.minY() - highest - 1 >= AerialPlanner24.MIN_ISLET_GAP, "At least sixteen air blocks separate ground and suspended rock");
|
||||
}
|
||||
var overlap = new ExpansionIsland("aerial_overlap", root.id(), "east", "temperate", 64,
|
||||
site.startChunkX() * 16, site.startChunkZ() * 16, 42, "natural", "reserved", 24);
|
||||
helper.assertTrue(plan.conflicts(overlap), "An unseen site already prevents overlapping expansion ownership");
|
||||
double distance = Math.hypot(site.locator().getX() - site.shoreX(), site.locator().getZ() - site.shoreZ());
|
||||
helper.assertTrue(distance <= 512, "Aerial site remains within 512 blocks of a real shore witness");
|
||||
views.put(site.id(), Map.of("shore", List.of(site.shoreX(), site.shoreY() + 2, site.shoreZ()),
|
||||
"entry", coordinates(AerialGeometry24.entry(site)), "centre", coordinates(site.locator()), "shore_distance", distance, "hull_to_shore", AerialPlanner24.shoreDistance(site),
|
||||
"exterior_view", List.of(site.minX() - 24, site.minY() + site.height() / 2, site.minZ() - 24)));
|
||||
}
|
||||
helper.assertTrue(!plan.conflicts(new ExpansionIsland("aerial_far", root.id(), "east", "temperate", 64, 4096, 4096, 42, "natural", "reserved", 24)),
|
||||
"Unclaimed space remains available; there is no blanket exclusion ring");
|
||||
report.put("look_views", views);
|
||||
}
|
||||
|
||||
private static List<Villager> occupants(ServerLevel level, AerialPlan24 plan) {
|
||||
var expected = plan.sites().stream().filter(AerialPlan24.Site::merchant).map(AerialGeometry24::occupantUuid).collect(java.util.stream.Collectors.toSet());
|
||||
return level.getEntitiesOfClass(Villager.class, new AABB(-2048, 0, -2048, 2048, 384, 2048))
|
||||
.stream().filter(villager -> expected.contains(villager.getUUID())).toList();
|
||||
}
|
||||
|
||||
private static Map<String, StructureStart> starts(GameTestHelper helper, ServerLevel level, AerialPlan24 plan) {
|
||||
var registry = level.registryAccess().lookupOrThrow(Registries.STRUCTURE);
|
||||
var result = new TreeMap<String, StructureStart>();
|
||||
for (var site : plan.sites()) {
|
||||
var type = registry.get(Identifier.parse(AerialStructures24.structureId(site))).orElseThrow().value();
|
||||
var start = level.getChunk(site.startChunkX(), site.startChunkZ(), ChunkStatus.FULL, true).getStartForStructure(type);
|
||||
helper.assertTrue(start != null && start.isValid(), "Planned aerial site has a real persisted native start: " + site.id());
|
||||
helper.assertTrue(start.getPieces().stream().filter(piece -> piece instanceof AerialPiece24 aerial && aerial.site().equals(site)).count() == 1,
|
||||
"Exactly one piece retains the site's immutable descriptor");
|
||||
var context = StructurePieceSerializationContext.fromLevel(level);
|
||||
var tag = start.createTag(context, start.getChunkPos());
|
||||
var restored = StructureStart.loadStaticStart(context, tag, level.getSeed());
|
||||
helper.assertTrue(restored != null && tag.equals(restored.createTag(context, start.getChunkPos())), "Aerial start round-trips through native serialization");
|
||||
if (site.merchant()) helper.assertTrue(start.getPieces().stream().filter(AerialPiece24.class::isInstance).map(AerialPiece24.class::cast)
|
||||
.allMatch(AerialPiece24::occupantPlaced), "Merchant placement flag is stored after its first creation");
|
||||
result.put(site.id(), start);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Map<String, Map<BlockPos, BlockState>> inspect(GameTestHelper helper, ServerLevel level, AerialPlan24 plan,
|
||||
boolean fresh, Map<String, Object> report) {
|
||||
var expected = new LinkedHashMap<String, Map<BlockPos, BlockState>>(); int chestCount = 0, waterSources = 0;
|
||||
var vegetation = new TreeMap<String, Object>();
|
||||
var shores = new TreeMap<String, Object>(); report.put("shore_witnesses", shores);
|
||||
for (var site : plan.sites()) {
|
||||
var model = render(site); expected.put(site.id(), model);
|
||||
var shore = new BlockPos(site.shoreX(), site.shoreY(), site.shoreZ());
|
||||
var column = new TreeMap<Integer, String>();
|
||||
for (int dy = -2; dy <= 20; dy++) column.put(shore.getY() + dy, level.getBlockState(shore.above(dy)).toString());
|
||||
shores.put(site.id(), Map.of("position", coordinates(shore), "column", column));
|
||||
helper.assertTrue(level.getBlockState(shore.below()).isSolid(), "Saved shore witness has a real FULL terrain support: " + site.id() + " " + shore);
|
||||
if (site.merchant()) {
|
||||
helper.assertTrue(level.getBlockState(shore.above()).getCollisionShape(level, shore.above()).isEmpty(),
|
||||
"Shore viewpoint is not buried inside the island: " + site.id() + " " + shore.above() + " " + level.getBlockState(shore.above()));
|
||||
} else {
|
||||
// Natural trees may occupy the mathematical ground reference below an islet.
|
||||
// Observe a real nearby walking position without removing that vegetation.
|
||||
var viewpoint = nearbyGroundView(level, shore);
|
||||
helper.assertTrue(viewpoint != null, "A walkable ground viewpoint exists within twelve horizontal blocks below the suspended islet: " + site.id());
|
||||
shores.put(site.id(), Map.of("position", coordinates(shore), "column", column,
|
||||
"walkable_viewpoint", coordinates(viewpoint), "reference_obstruction", level.getBlockState(shore.above()).toString()));
|
||||
}
|
||||
var chestAt = AerialGeometry24.chest(site);
|
||||
helper.assertTrue(level.getBlockEntity(chestAt) instanceof RandomizableContainerBlockEntity, "Real chest at " + site.id()); chestCount++;
|
||||
var chest = (RandomizableContainerBlockEntity) level.getBlockEntity(chestAt);
|
||||
if (fresh) {
|
||||
helper.assertTrue(AerialRenderer24.loot(site).equals(chest.getLootTable()), "Aerial chest retains its unopened site-specific loot table");
|
||||
for (var entry : model.entrySet()) if (!entry.getValue().isAir() && !entry.getValue().is(Blocks.WATER))
|
||||
helper.assertTrue(level.getBlockState(entry.getKey()).is(entry.getValue().getBlock()), "Native FULL keeps authored material at " + site.id() + " " + entry.getKey());
|
||||
for (var pos : AerialGeometry24.interiorChecks(site)) {
|
||||
helper.assertTrue(level.getBlockState(pos).getCollisionShape(level, pos).isEmpty()
|
||||
&& level.getBlockState(pos.above()).getCollisionShape(level, pos.above()).isEmpty(), "Usable two-block headroom at " + site.id());
|
||||
helper.assertTrue(!level.getBlockState(pos.below()).getCollisionShape(level, pos.below()).isEmpty(), "Interior stands on a real floor");
|
||||
}
|
||||
if (site.kind() == AerialPlan24.Kind.MINERAL_ISLET) for (int dy = 1; dy <= 3; dy++)
|
||||
helper.assertTrue(level.getBlockState(chestAt.above(dy)).isSolid(), "Mineral chest needs excavation through three layers");
|
||||
} else helper.assertTrue(chest.getLootTable() == null && chest.isEmpty(), "Looted chest never refills on reload");
|
||||
if (site.kind() == AerialPlan24.Kind.MINERAL_ISLET)
|
||||
vegetation.put(site.id(), vegetation(helper, level, site));
|
||||
if (site.waterfall()) {
|
||||
var source = AerialGeometry24.waterfallSource(site);
|
||||
helper.assertTrue(level.getFluidState(source).isSource(), "The one real source drives the native waterfall"); waterSources++;
|
||||
}
|
||||
// Root terrain and its own trees may now exist outside these aerial envelopes.
|
||||
// Chunk clipping is checked against every authored position; do not confuse legal
|
||||
// surrounding terrain with a structure leak by requiring a whole exterior air column.
|
||||
helper.assertTrue(model.keySet().stream().allMatch(site.bounds()::isInside), "Every proposed structure block is inside its finite envelope");
|
||||
var exterior = new ArrayList<Map<String, Object>>();
|
||||
for (var at : List.of(new BlockPos(site.minX() - 2, site.minY(), site.minZ() - 2),
|
||||
new BlockPos(site.maxX() + 2, site.minY(), site.maxZ() + 2)))
|
||||
exterior.add(Map.of("position", coordinates(at), "observed_block", level.getBlockState(at).toString()));
|
||||
report.put(site.id() + "_exterior_observations", exterior);
|
||||
}
|
||||
helper.assertTrue(chestCount == 4 && waterSources == 1, "Four physical chests and exactly one planned source");
|
||||
report.put("chests", chestCount); report.put("waterfall_sources", waterSources); report.put("blocks_before", countSites(level, plan));
|
||||
report.put("vegetation", vegetation);
|
||||
return expected;
|
||||
}
|
||||
|
||||
private static BlockPos nearbyGroundView(ServerLevel level, BlockPos reference) {
|
||||
for (int radius = 0; radius <= 12; radius++) for (int dx = -radius; dx <= radius; dx++) for (int dz = -radius; dz <= radius; dz++) {
|
||||
if (Math.max(Math.abs(dx), Math.abs(dz)) != radius || Math.hypot(dx, dz) > 12) continue;
|
||||
for (int dy = 8; dy >= -8; dy--) {
|
||||
var at = reference.offset(dx, dy, dz);
|
||||
var floor = level.getBlockState(at.below());
|
||||
if (!floor.isSolid() || floor.is(net.minecraft.tags.BlockTags.LEAVES) || floor.is(net.minecraft.tags.BlockTags.LOGS)) continue;
|
||||
if (level.getBlockState(at).getCollisionShape(level, at).isEmpty()
|
||||
&& level.getBlockState(at.above()).getCollisionShape(level, at.above()).isEmpty()
|
||||
&& level.getFluidState(at).isEmpty() && level.getFluidState(at.above()).isEmpty()) return at;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Map<String, Object> vegetation(GameTestHelper helper, ServerLevel level, AerialPlan24.Site site) {
|
||||
helper.assertTrue(site.rockHeight() >= 20 && site.rockHeight() <= 35
|
||||
&& site.height() == site.rockHeight() + AerialPlan24.VEGETATION_HEADROOM,
|
||||
"Tree headroom preserves the original stone height");
|
||||
int surface = 0, grass = 0;
|
||||
for (int x = 0; x < site.width(); x++) for (int z = 0; z < site.depth(); z++) {
|
||||
int top = AerialGeometry24.terrainTop(site, x, z);
|
||||
if (!AerialGeometry24.mineralBody(site, x, top, z)) continue;
|
||||
surface++;
|
||||
if (level.getBlockState(AerialGeometry24.world(site, x, top, z)).is(Blocks.GRASS_BLOCK)) grass++;
|
||||
}
|
||||
helper.assertTrue(grass * 2 > surface, "Most real intact surface columns carry grass: " + site.id());
|
||||
var trees = AerialGeometry24.trees(site);
|
||||
helper.assertTrue(!trees.isEmpty(), "At least one real tree on each mineral islet");
|
||||
for (var tree : trees) {
|
||||
var ground = AerialGeometry24.world(site, tree.x(), tree.groundY(), tree.z());
|
||||
var floor = level.getBlockState(ground);
|
||||
helper.assertTrue(floor.is(Blocks.GRASS_BLOCK) || floor.is(Blocks.DIRT), "Tree stands on soil, never in the air");
|
||||
for (int y = 1; y <= tree.trunkHeight(); y++)
|
||||
helper.assertTrue(level.getBlockState(ground.above(y)).is(tree.birch() ? Blocks.BIRCH_LOG : Blocks.OAK_LOG), "Native tree trunk stays continuous");
|
||||
var crown = ground.above(tree.trunkHeight() + 1);
|
||||
var leaves = level.getBlockState(crown);
|
||||
helper.assertTrue(site.bounds().isInside(crown) && leaves.is(tree.birch() ? Blocks.BIRCH_LEAVES : Blocks.OAK_LEAVES)
|
||||
&& !leaves.getValue(BlockStateProperties.PERSISTENT) && leaves.getValue(BlockStateProperties.DISTANCE) < 7,
|
||||
"Complete natural crown survives native chunk decoration and reload");
|
||||
}
|
||||
return Map.of("rock_height", site.rockHeight(), "headroom", AerialPlan24.VEGETATION_HEADROOM,
|
||||
"surface_columns", surface, "grass_columns", grass, "grass_percent", 100.0 * grass / surface, "trees", trees);
|
||||
}
|
||||
|
||||
private static Map<String, Object> mutate(GameTestHelper helper, ServerLevel level, AerialPlan24 plan, List<Villager> occupants,
|
||||
Map<String, Map<BlockPos, BlockState>> models) {
|
||||
var emptied = new ArrayList<List<Integer>>(); var removed = new ArrayList<List<Integer>>(); var loot = new TreeMap<String, Integer>();
|
||||
for (var site : plan.sites()) {
|
||||
var at = AerialGeometry24.chest(site); var chest = (RandomizableContainerBlockEntity) level.getBlockEntity(at);
|
||||
chest.unpackLootTable(null); int quantity = 0;
|
||||
for (int slot = 0; slot < chest.getContainerSize(); slot++) quantity += chest.getItem(slot).getCount();
|
||||
helper.assertTrue(quantity > 0, "Site-specific chest produces usable vanilla loot"); loot.put(site.id(), quantity);
|
||||
chest.clearContent(); chest.setChanged(); emptied.add(coordinates(at));
|
||||
if (site.kind() == AerialPlan24.Kind.MINERAL_ISLET) {
|
||||
var ores = models.get(site.id()).entrySet().stream().filter(entry -> ore(entry.getValue())).sorted(Map.Entry.comparingByKey(
|
||||
Comparator.<BlockPos>comparingInt(BlockPos::getX).thenComparingInt(BlockPos::getY).thenComparingInt(BlockPos::getZ))).limit(16).toList();
|
||||
helper.assertTrue(!ores.isEmpty(), "Each mineral island contains actual finite veins");
|
||||
for (var entry : ores) { level.setBlock(entry.getKey(), Blocks.AIR.defaultBlockState(), 2); removed.add(coordinates(entry.getKey())); }
|
||||
}
|
||||
}
|
||||
var ship = plan.sites().stream().filter(AerialPlan24.Site::merchant).findFirst().orElseThrow();
|
||||
var demolition = AerialGeometry24.entry(ship).below();
|
||||
helper.assertTrue(level.getBlockState(demolition).isSolid(), "The demolition witness removes an existing floor");
|
||||
level.setBlock(demolition, Blocks.AIR.defaultBlockState(), 2); removed.add(coordinates(demolition));
|
||||
var extracted = new TreeMap<String, List<Double>>(); int i = 0;
|
||||
for (var villager : occupants.stream().sorted(Comparator.comparing(v -> v.getUUID().toString())).toList()) {
|
||||
// This fixture parks extracted merchants in an existing root chunk, outside both ships.
|
||||
villager.setNoAi(true); villager.setNoGravity(true); villager.setDeltaMovement(Vec3.ZERO);
|
||||
villager.snapTo(4.5 + i++ * 4, 330, 4.5); villager.setPersistenceRequired();
|
||||
extracted.put(villager.getUUID().toString(), List.of(villager.getX(), villager.getY(), villager.getZ()));
|
||||
}
|
||||
return Map.of("emptied_chests", emptied, "removed_blocks", removed, "extracted_merchants", extracted, "loot_items_obtained", loot);
|
||||
}
|
||||
|
||||
private static void verifyMutations(GameTestHelper helper, ServerLevel level, AerialPlan24 plan, JsonObject mutations, List<Villager> occupants) {
|
||||
for (var value : mutations.getAsJsonArray("removed_blocks")) {
|
||||
var pos = position(value.getAsJsonArray()); helper.assertTrue(level.getBlockState(pos).isAir(), "Mined ore and dismantled floor remain absent after reload");
|
||||
}
|
||||
var extracted = mutations.getAsJsonObject("extracted_merchants");
|
||||
for (var villager : occupants) {
|
||||
var at = extracted.getAsJsonArray(villager.getUUID().toString());
|
||||
helper.assertTrue(at != null && Math.abs(villager.getX() - at.get(0).getAsDouble()) < .01
|
||||
&& Math.abs(villager.getY() - at.get(1).getAsDouble()) < .01 && Math.abs(villager.getZ() - at.get(2).getAsDouble()) < .01,
|
||||
"Extracted merchant stays outside its original ship without respawning");
|
||||
}
|
||||
for (var site : plan.sites()) if (site.merchant()) helper.assertTrue(level.getEntitiesOfClass(Villager.class, AABB.of(site.bounds())).isEmpty(),
|
||||
"The visited ship does not replenish an extracted merchant");
|
||||
}
|
||||
|
||||
private static void verifyLocator(GameTestHelper helper, ServerLevel level, AerialPlan24 plan, Map<String, StructureStart> starts) {
|
||||
var registry = level.registryAccess().lookupOrThrow(Registries.STRUCTURE);
|
||||
var holders = new ArrayList<Holder<Structure>>();
|
||||
plan.sites().stream().map(AerialStructures24::structureId).distinct().forEach(id -> holders.add(registry.get(Identifier.parse(id)).orElseThrow()));
|
||||
holders.add(registry.get(Identifier.withDefaultNamespace("stronghold")).orElseThrow());
|
||||
var wanted = HolderSet.direct(holders); var origin = plan.sites().getFirst().locator();
|
||||
var activeBefore = ((SanctuaryChunkGenerator) level.getChunkSource().getGenerator()).source().islands();
|
||||
int before = starts.values().stream().mapToInt(StructureStart::getReferences).sum();
|
||||
var found = ExpansionStructures23.findNearest(level, wanted, origin, 100, false);
|
||||
helper.assertTrue(found != null, "Mixed vanilla/aerial locator finds a real accepted start");
|
||||
helper.assertTrue(starts.values().stream().mapToInt(StructureStart::getReferences).sum() == before, "Ordinary locate never marks a site referenced");
|
||||
var referenced = ExpansionStructures23.findNearest(level, wanted, origin, 100, true);
|
||||
helper.assertTrue(referenced != null && starts.values().stream().mapToInt(StructureStart::getReferences).sum() == before + 1,
|
||||
"Mixed map lookup references exactly its one winning aerial start");
|
||||
helper.assertTrue(activeBefore.equals(((SanctuaryChunkGenerator) level.getChunkSource().getGenerator()).source().islands()), "Locator never activates an expansion");
|
||||
}
|
||||
|
||||
private static Map<BlockPos, BlockState> render(AerialPlan24.Site site) {
|
||||
var result = new HashMap<BlockPos, BlockState>();
|
||||
AerialRenderer24.render(site, new LostCityRenderer.BlockWriter() {
|
||||
public void set(int x, int y, int z, BlockState state) { result.put(new BlockPos(site.minX() + x, site.minY() + y, site.minZ() + z), state); }
|
||||
public void chest(int x, int y, int z, ResourceKey<LootTable> table, long seed) { set(x, y, z, Blocks.CHEST.defaultBlockState()); }
|
||||
});
|
||||
return result;
|
||||
}
|
||||
private static Map<String, Map<String, Integer>> countSites(ServerLevel level, AerialPlan24 plan) {
|
||||
var all = new TreeMap<String, Map<String, Integer>>();
|
||||
for (var site : plan.sites()) {
|
||||
var counts = new TreeMap<String, Integer>();
|
||||
for (int x = site.minX(); x <= site.maxX(); x++) for (int z = site.minZ(); z <= site.maxZ(); z++) for (int y = site.minY(); y <= site.maxY(); y++) {
|
||||
var state = level.getBlockState(new BlockPos(x, y, z));
|
||||
if (!state.isAir()) counts.merge(BuiltInRegistries.BLOCK.getKey(state.getBlock()).toString(), 1, Integer::sum);
|
||||
}
|
||||
all.put(site.id(), counts);
|
||||
}
|
||||
return all;
|
||||
}
|
||||
private static boolean ore(BlockState state) { return BuiltInRegistries.BLOCK.getKey(state.getBlock()).getPath().endsWith("_ore"); }
|
||||
private static Map<String, String> tags(ServerLevel level, Map<String, StructureStart> starts) {
|
||||
var result = new TreeMap<String, String>(); var context = StructurePieceSerializationContext.fromLevel(level);
|
||||
starts.forEach((id, start) -> result.put(id, start.createTag(context, start.getChunkPos()).toString())); return result;
|
||||
}
|
||||
private static List<Integer> coordinates(BlockPos pos) { return List.of(pos.getX(), pos.getY(), pos.getZ()); }
|
||||
private static BlockPos position(com.google.gson.JsonArray value) { return new BlockPos(value.get(0).getAsInt(), value.get(1).getAsInt(), value.get(2).getAsInt()); }
|
||||
private static Map<String, byte[]> files(Path directory) throws java.io.IOException {
|
||||
var found = new TreeMap<String, byte[]>();
|
||||
if (Files.exists(directory)) try (var paths = Files.walk(directory)) {
|
||||
for (var path : paths.filter(Files::isRegularFile).toList()) found.put(directory.relativize(path).toString(), Files.readAllBytes(path));
|
||||
}
|
||||
return found;
|
||||
}
|
||||
private static boolean equalFiles(Map<String, byte[]> a, Map<String, byte[]> b) {
|
||||
return a.keySet().equals(b.keySet()) && a.entrySet().stream().allMatch(entry -> Arrays.equals(entry.getValue(), b.get(entry.getKey())));
|
||||
}
|
||||
private static void write(Path path, Map<String, Object> report) throws java.io.IOException { Files.createDirectories(path.toAbsolutePath().getParent()); Files.writeString(path, JSON.toJson(report)); }
|
||||
private static void failure(Map<String, Object> report, Exception error) {
|
||||
report.put("passed", false); report.put("failure", error.toString());
|
||||
var stack = new java.io.StringWriter(); error.printStackTrace(new java.io.PrintWriter(stack)); report.put("stacktrace", stack.toString());
|
||||
SanctuaryMod.LOGGER.error("Aerial24 fixture failed at {}", report.get("stage"), error);
|
||||
try { write(Path.of("diagnostics/aerial24/failure.json"), report); } catch (java.io.IOException failed) { error.addSuppressed(failed); }
|
||||
}
|
||||
}
|
||||
+239
@@ -0,0 +1,239 @@
|
||||
package fr.koka.sanctuary.gametest;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import fr.koka.sanctuary.SanctuaryMod;
|
||||
import fr.koka.sanctuary.expansion.ExpansionStructures23;
|
||||
import fr.koka.sanctuary.expansion.SwampHutPlacement28;
|
||||
import fr.koka.sanctuary.knowledge.structures.StructureCensusMemory;
|
||||
import fr.koka.sanctuary.knowledge.structures.StructureCensusService;
|
||||
import fr.koka.sanctuary.worldgen.SanctuaryChunkGenerator;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import net.fabricmc.fabric.api.gametest.v1.GameTest;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.gametest.framework.GameTestHelper;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.entity.SpawnerBlockEntity;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureStart;
|
||||
import net.minecraft.world.level.levelgen.structure.pieces.StructurePieceSerializationContext;
|
||||
|
||||
/** Observes normal root generation only. No start injection, fake room, expansion or seed search. */
|
||||
public final class Alpha28NativeStructuresGameTests {
|
||||
private static final com.google.gson.Gson JSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
private static final Path OUT = Path.of("diagnostics/native28");
|
||||
|
||||
@GameTest(maxTicks = 3600)
|
||||
public void actualNativeStructures(GameTestHelper helper) throws Exception {
|
||||
var report = new LinkedHashMap<String, Object>();
|
||||
try {
|
||||
var level = helper.getLevel(); var host = (SanctuaryChunkGenerator) level.getChunkSource().getGenerator();
|
||||
report.put("seed", level.getSeed()); report.put("diameter", host.initialDiameter());
|
||||
report.put("process_id", ProcessHandle.current().pid()); report.put("generate_structures", level.structureManager().shouldGenerateStructures());
|
||||
if (!level.structureManager().shouldGenerateStructures()) {
|
||||
report.put("scope", "Native structures globally disabled"); report.put("passed", true); write(report); helper.succeed(); return;
|
||||
}
|
||||
var root = host.source().islands().stream().filter(island -> island.origin()).findFirst().orElseThrow();
|
||||
var candidates = ExpansionStructures23.candidates(root).stream().limit(24).toList();
|
||||
var registry = level.registryAccess().lookupOrThrow(Registries.STRUCTURE);
|
||||
var found = new LinkedHashMap<String, StructureStart>(); var observed = new TreeMap<String, Integer>();
|
||||
var firstTwelve = new TreeMap<String, Integer>(); int candidateIndex = 0;
|
||||
for (var candidate : candidates) {
|
||||
var chunk = level.getChunk(candidate.chunk().x(), candidate.chunk().z(), ChunkStatus.STRUCTURE_STARTS, true);
|
||||
for (var start : chunk.getAllStarts().values()) {
|
||||
if (!start.isValid()) continue;
|
||||
String id = registry.getKey(start.getStructure()).toString(); observed.merge(id, 1, Integer::sum);
|
||||
if (candidateIndex < 12) firstTwelve.merge(id, 1, Integer::sum);
|
||||
if (List.of("minecraft:mineshaft", "minecraft:mineshaft_mesa", "minecraft:swamp_hut").contains(id)) found.putIfAbsent(id, start);
|
||||
}
|
||||
candidateIndex++;
|
||||
}
|
||||
report.put("candidate_chunks", candidates.size()); report.put("observed_starts", observed);
|
||||
report.put("first_twelve_starts", firstTwelve);
|
||||
if (Boolean.getBoolean("sanctuary.test.requireMineshaft29") && found.keySet().stream().noneMatch(id -> id.contains("mineshaft"))) {
|
||||
var islandsBefore = List.copyOf(host.source().islands());
|
||||
var wanted = net.minecraft.core.HolderSet.direct(registry.get(Identifier.parse("minecraft:mineshaft")).orElseThrow(),
|
||||
registry.get(Identifier.parse("minecraft:mineshaft_mesa")).orElseThrow());
|
||||
// Same finite real-start path as /locate; no injected plan, reference increment or expansion.
|
||||
var located = ExpansionStructures23.findNearest(level, wanted, BlockPos.ZERO, 8, false);
|
||||
helper.assertTrue(islandsBefore.equals(host.source().islands()), "Native /locate never adds an expansion or changes the island descriptors");
|
||||
var locateProof = new LinkedHashMap<String, Object>();
|
||||
locateProof.put("invoked", true); locateProof.put("found", located != null);
|
||||
locateProof.put("islands_unchanged", true); locateProof.put("skip_referenced", false);
|
||||
locateProof.put("root_candidates_available", ExpansionStructures23.candidates(root).size());
|
||||
report.put("locate_mineshaft", locateProof);
|
||||
if (located != null) {
|
||||
String id = located.getSecond().unwrapKey().orElseThrow().identifier().toString();
|
||||
for (var candidate : ExpansionStructures23.candidates(root)) {
|
||||
var start = level.getChunk(candidate.chunk().x(), candidate.chunk().z(), ChunkStatus.STRUCTURE_STARTS, true)
|
||||
.getStartForStructure(located.getSecond().value());
|
||||
if (start != null && start.isValid() && start.getPieces().getFirst().getLocatorPosition().equals(located.getFirst())) {
|
||||
found.put(id, start); locateProof.put("start_chunk", List.of(candidate.chunk().x(), candidate.chunk().z())); break;
|
||||
}
|
||||
}
|
||||
helper.assertTrue(found.containsKey(id), "The native /locate result belongs to a real saved start");
|
||||
locateProof.put("id", id); locateProof.put("position", located.getFirst().toShortString());
|
||||
}
|
||||
} else report.put("locate_mineshaft", Map.of("invoked", false));
|
||||
var full = new LinkedHashSet<ChunkPos>();
|
||||
// Visit actual corridor bodies (including both endpoint chunks), not just four
|
||||
// piece centres that could all belong to unadorned rooms. No graph is truncated.
|
||||
var pieceContext = StructurePieceSerializationContext.fromLevel(level);
|
||||
int mineFamilies = (int) found.keySet().stream().filter(id -> id.contains("mineshaft")).count();
|
||||
for (var entry : found.entrySet()) {
|
||||
full.add(entry.getValue().getChunkPos());
|
||||
var pieces = entry.getValue().getPieces();
|
||||
if (entry.getKey().contains("mineshaft")) pieces = pieces.stream()
|
||||
.filter(piece -> piece instanceof net.minecraft.world.level.levelgen.structure.structures.MineshaftPieces.MineShaftCorridor)
|
||||
.sorted(Comparator.comparingInt(piece -> {
|
||||
var tag = piece.createTag(pieceContext);
|
||||
return tag.getBoolean("hr").orElse(false) ? 0 : tag.getBoolean("sc").orElse(false) ? 1 : 2;
|
||||
})).limit(mineFamilies > 1 ? 2 : 4).toList();
|
||||
for (var piece : pieces) {
|
||||
var proposed = new LinkedHashSet<>(full); piece.getBoundingBox().intersectingChunks().forEach(proposed::add);
|
||||
if (proposed.size() <= 24) full.addAll(proposed);
|
||||
}
|
||||
}
|
||||
// A few additional real generation chunks can contain native monster_room attempts.
|
||||
for (var candidate : candidates) {
|
||||
if (full.size() >= 16) break;
|
||||
full.add(candidate.chunk());
|
||||
}
|
||||
helper.assertTrue(full.size() <= 24, "Bounded native structure witness requests at most24 FULL chunks");
|
||||
var iterator = full.iterator(); Runnable[] step = new Runnable[1];
|
||||
step[0] = () -> {
|
||||
try {
|
||||
if (iterator.hasNext()) {
|
||||
var at = iterator.next(); report.put("stage", "FULL " + at);
|
||||
level.getChunk(at.x(), at.z(), ChunkStatus.FULL, true);
|
||||
helper.runAtTickTime(helper.getTick() + 1, () -> step[0].run()); return;
|
||||
}
|
||||
inspect(helper, level, found, full, report);
|
||||
report.put("passed", true); write(report); helper.succeed();
|
||||
} catch (Exception error) { failure(report, error); throw new IllegalStateException("Native28 witness failed", error); }
|
||||
};
|
||||
helper.runAtTickTime(helper.getTick() + 1, () -> step[0].run());
|
||||
} catch (Exception error) { failure(report, error); throw error; }
|
||||
}
|
||||
|
||||
private static void inspect(GameTestHelper helper, ServerLevel level, Map<String, StructureStart> found,
|
||||
Set<ChunkPos> full, Map<String, Object> report) {
|
||||
var registry = level.registryAccess().lookupOrThrow(Registries.STRUCTURE);
|
||||
var context = StructurePieceSerializationContext.fromLevel(level);
|
||||
var proofs = new LinkedHashMap<String, Object>();
|
||||
var census = StructureCensusService.snapshot(level.getServer()).evidence().sites().values();
|
||||
var monsterPositions = new HashSet<BlockPos>();
|
||||
for (var site : census) {
|
||||
var key = site.key();
|
||||
if (key.id().equals(StructureCensusMemory.MONSTER_ROOM) && key.dimension().equals(level.dimension().identifier().toString()))
|
||||
monsterPositions.add(new BlockPos(key.x(), key.y(), key.z()));
|
||||
}
|
||||
for (var entry : found.entrySet()) {
|
||||
var expected = entry.getValue(); var cp = expected.getChunkPos();
|
||||
var actual = level.getChunk(cp.x(), cp.z(), ChunkStatus.FULL, true)
|
||||
.getStartForStructure(registry.getValue(Identifier.parse(entry.getKey())));
|
||||
helper.assertTrue(actual != null && actual.isValid(), "The real selected native start survives FULL: " + entry.getKey());
|
||||
var tag = actual.createTag(context, cp);
|
||||
var restored = StructureStart.loadStaticStart(context, tag, level.getSeed());
|
||||
helper.assertTrue(restored != null && tag.equals(restored.createTag(context, cp)), "Native piece NBT roundtrip: " + entry.getKey());
|
||||
var counts = new TreeMap<String, Integer>(); var positions = new HashSet<BlockPos>();
|
||||
var spawners = new ArrayList<Object>(); var corridorFlags = new ArrayList<Object>();
|
||||
var spawnerTypes = new HashMap<BlockPos, String>();
|
||||
for (var piece : actual.getPieces()) {
|
||||
var b = piece.getBoundingBox();
|
||||
if (piece instanceof net.minecraft.world.level.levelgen.structure.structures.MineshaftPieces.MineShaftCorridor) {
|
||||
var flags = piece.createTag(context);
|
||||
corridorFlags.add(Map.of("box", b.toString(), "fully_visited", b.intersectingChunks().allMatch(full::contains),
|
||||
"rails", flags.getBoolean("hr").orElse(false), "spider_corridor", flags.getBoolean("sc").orElse(false),
|
||||
"spawner_placed", flags.getBoolean("hps").orElse(false)));
|
||||
}
|
||||
for (int x = b.minX(); x <= b.maxX(); x++) for (int z = b.minZ(); z <= b.maxZ(); z++) {
|
||||
if (!full.contains(new ChunkPos(x >> 4, z >> 4))) continue;
|
||||
for (int y = b.minY() - 1; y <= b.maxY() + 1; y++) {
|
||||
BlockPos pos = new BlockPos(x, y, z); if (!positions.add(pos)) continue;
|
||||
var state = level.getBlockState(pos);
|
||||
if (!state.isAir()) counts.merge(BuiltInRegistries.BLOCK.getKey(state.getBlock()).toString(), 1, Integer::sum);
|
||||
if (state.is(Blocks.SPAWNER)) {
|
||||
helper.assertTrue(level.getBlockEntity(pos) instanceof SpawnerBlockEntity, "A mine spawner has its actual native block entity");
|
||||
var saved = ((SpawnerBlockEntity) level.getBlockEntity(pos)).saveWithFullMetadata(level.registryAccess());
|
||||
String mob = saved.getCompoundOrEmpty("SpawnData").getCompoundOrEmpty("entity").getStringOr("id", "");
|
||||
spawnerTypes.put(pos, mob);
|
||||
String origin = monsterPositions.contains(pos) ? "monster_room" : "mineshaft";
|
||||
if (entry.getKey().contains("mineshaft")) {
|
||||
if (origin.equals("monster_room")) helper.assertTrue(List.of("minecraft:zombie", "minecraft:skeleton", "minecraft:spider").contains(mob),
|
||||
"A recorded vanilla dungeon inside the mine retains its own monster type");
|
||||
else {
|
||||
var flags = piece.createTag(context);
|
||||
helper.assertTrue(mob.equals("minecraft:cave_spider") && flags.getBooleanOr("sc", false) && flags.getBooleanOr("hps", false),
|
||||
"A native mine spawner agrees with its cave-spider piece flags");
|
||||
}
|
||||
}
|
||||
spawners.add(Map.of("position", pos.toShortString(), "origin", origin, "entity", mob, "nbt", saved.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (piece instanceof net.minecraft.world.level.levelgen.structure.structures.MineshaftPieces.MineShaftCorridor) {
|
||||
var flags = piece.createTag(context);
|
||||
if (flags.getBooleanOr("sc", false) && flags.getBooleanOr("hps", false) && b.intersectingChunks().allMatch(full::contains)) {
|
||||
boolean actualSpider = spawnerTypes.entrySet().stream().anyMatch(e -> b.isInside(e.getKey()) && e.getValue().equals("minecraft:cave_spider"));
|
||||
// A later successful native monster_room may replace a mine's spawner. Its real
|
||||
// census coordinate must then lie on this corridor's native spawner centreline.
|
||||
boolean recordedReplacement = false;
|
||||
int length = piece.getOrientation().getAxis() == net.minecraft.core.Direction.Axis.Z ? b.getZSpan() : b.getXSpan();
|
||||
for (int z = 1; z < length; z++) {
|
||||
var at = SwampHutPlacement28.worldPosition(piece,1,0,z);
|
||||
if (monsterPositions.contains(at) && spawnerTypes.containsKey(at)) recordedReplacement = true;
|
||||
}
|
||||
helper.assertTrue(actualSpider || recordedReplacement, "A fully visited sc/hps corridor has its actual cave-spider spawner or an evidenced later vanilla dungeon");
|
||||
}
|
||||
}
|
||||
if (entry.getKey().equals("minecraft:swamp_hut")) for (var pier : SwampHutPlacement28.piers(piece)) {
|
||||
var state = level.getBlockState(pier);
|
||||
helper.assertTrue(state.is(Blocks.OAK_LOG) || state.isSolid(), "A native hut pier has wood or a real solid foot: " + pier);
|
||||
}
|
||||
}
|
||||
if (entry.getKey().contains("mineshaft")) helper.assertTrue(counts.entrySet().stream()
|
||||
.filter(e -> e.getKey().endsWith("_planks") || e.getKey().endsWith("_fence") || e.getKey().equals("minecraft:rail"))
|
||||
.mapToInt(Map.Entry::getValue).sum() > 0, "A selected mine creates actual native timber/rail geometry");
|
||||
proofs.put(entry.getKey(), Map.of("start_chunk", List.of(cp.x(), cp.z()), "pieces", actual.getPieces().size(),
|
||||
"blocks_in_loaded_pieces", counts, "native_tag", tag.toString(), "visit", actual.getPieces().getFirst().getLocatorPosition().toShortString(),
|
||||
"corridor_flags", corridorFlags, "spawners", spawners));
|
||||
}
|
||||
var rooms = new ArrayList<Object>();
|
||||
for (var site : census) {
|
||||
var key = site.key();
|
||||
if (!key.id().equals(StructureCensusMemory.MONSTER_ROOM) || !key.dimension().equals(level.dimension().identifier().toString())) continue;
|
||||
var cp = new ChunkPos(key.x() >> 4, key.z() >> 4);
|
||||
if (!full.contains(cp)) continue;
|
||||
var at = new BlockPos(key.x(), key.y(), key.z());
|
||||
helper.assertTrue(level.getBlockEntity(at) instanceof SpawnerBlockEntity, "Successful vanilla monster_room has its real spawner at " + at);
|
||||
var spawnerNbt = ((SpawnerBlockEntity) level.getBlockEntity(at)).saveWithFullMetadata(level.registryAccess());
|
||||
helper.assertTrue(List.of("minecraft:zombie", "minecraft:skeleton", "minecraft:spider").stream().anyMatch(spawnerNbt.toString()::contains), "Vanilla dungeon retains a real vanilla monster type");
|
||||
rooms.add(Map.of("position", List.of(key.x(), key.y(), key.z()), "spawner", true, "spawner_nbt", spawnerNbt.toString()));
|
||||
}
|
||||
report.put("structures", proofs); report.put("monster_rooms", rooms); report.put("full_chunks", full.size());
|
||||
boolean mineFound = found.keySet().stream().anyMatch(id -> id.contains("mineshaft"));
|
||||
report.put("mineshaft_found", mineFound);
|
||||
report.put("mineshaft_required", Boolean.getBoolean("sanctuary.test.requireMineshaft29"));
|
||||
report.put("swamp_hut_found", found.containsKey("minecraft:swamp_hut"));
|
||||
report.put("monster_room_found", !rooms.isEmpty());
|
||||
report.put("scope", "Sample of24 normal start candidates, optional real /locate when a mine is required, and at most24 requested FULL chunks; the first12 remain separately reported. Corridor flags and optional spawners do not impose random-content quotas");
|
||||
if (Boolean.getBoolean("sanctuary.test.requireMineshaft29"))
|
||||
helper.assertTrue(mineFound, "The required mine witness has a real native start and inspected FULL timber/rail geometry");
|
||||
}
|
||||
private static void write(Map<String, Object> report) throws Exception {
|
||||
Files.createDirectories(OUT); Files.writeString(OUT.resolve("native.json"), JSON.toJson(report) + "\n");
|
||||
}
|
||||
private static void failure(Map<String, Object> report, Exception error) {
|
||||
report.put("passed", false); report.put("error", error.toString());
|
||||
try { Files.createDirectories(OUT); Files.writeString(OUT.resolve("failure.json"), JSON.toJson(report) + "\n"); }
|
||||
catch (Exception io) { error.addSuppressed(io); }
|
||||
SanctuaryMod.LOGGER.error("Native28 witness failed", error);
|
||||
}
|
||||
}
|
||||
+384
@@ -0,0 +1,384 @@
|
||||
package fr.koka.sanctuary.gametest;
|
||||
|
||||
import fr.koka.sanctuary.knowledge.BlockKnowledge;
|
||||
import fr.koka.sanctuary.knowledge.BlockKnowledgeEvents;
|
||||
import fr.koka.sanctuary.knowledge.BlockKnowledgeFacet;
|
||||
import fr.koka.sanctuary.knowledge.BlockKnowledgeService;
|
||||
import fr.koka.sanctuary.knowledge.BlockKnowledgeStore;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import net.fabricmc.fabric.api.gametest.v1.GameTest;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.gametest.framework.GameTestHelper;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.PacketFlow;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.network.CommonListenerCookie;
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.util.Prediction;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.SimpleContainer;
|
||||
import net.minecraft.world.inventory.ChestMenu;
|
||||
import net.minecraft.world.inventory.ContainerInput;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.storage.LevelResource;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
/** Exercise native actions so invalid placements and death drops cannot unlock false history. */
|
||||
public final class BlockKnowledgeGameTests {
|
||||
@GameTest(maxTicks = 100)
|
||||
public void placementCountsConfirmedStatesAndRejectsFailure(GameTestHelper helper) {
|
||||
ServerPlayer player = player(helper);
|
||||
BlockPos support = helper.absolutePos(new BlockPos(1, 1, 1));
|
||||
helper.getLevel().setBlockAndUpdate(support, Blocks.STONE.defaultBlockState());
|
||||
helper.getLevel().setBlockAndUpdate(support.above(), Blocks.AIR.defaultBlockState());
|
||||
helper.getLevel().setBlockAndUpdate(support.east(), Blocks.AIR.defaultBlockState());
|
||||
|
||||
helper.assertTrue(place(player, Items.COBBLESTONE, support, Direction.UP),
|
||||
"A valid block placement must succeed");
|
||||
helper.assertTrue(BlockKnowledgeService.knowledge(player, Blocks.COBBLESTONE).placed() == 1,
|
||||
"A successful placement must be recorded exactly once");
|
||||
helper.assertTrue(BlockKnowledgeService.knowledge(player, Blocks.COBBLESTONE).possessed(),
|
||||
"The final held block must be observed before placement consumes it");
|
||||
|
||||
helper.assertTrue(place(player, Items.TORCH, support, Direction.EAST),
|
||||
"A torch must attach to the side of a solid support");
|
||||
helper.assertTrue(helper.getLevel().getBlockState(support.east()).is(Blocks.WALL_TORCH),
|
||||
"The placement fixture must produce a wall torch");
|
||||
helper.assertTrue(BlockKnowledgeService.knowledge(player, Blocks.WALL_TORCH).placed() == 1,
|
||||
"Placement history must use the actual wall block");
|
||||
helper.assertTrue(BlockKnowledgeService.knowledge(player, Blocks.TORCH).placed() == 0,
|
||||
"The item form must not receive a second placement");
|
||||
|
||||
BlockPos invalidSupport = helper.absolutePos(new BlockPos(3, 1, 1));
|
||||
helper.getLevel().setBlockAndUpdate(invalidSupport, Blocks.STONE.defaultBlockState());
|
||||
helper.getLevel().setBlockAndUpdate(invalidSupport.above(), Blocks.AIR.defaultBlockState());
|
||||
helper.assertTrue(!place(player, Items.OAK_SAPLING, invalidSupport, Direction.UP),
|
||||
"A sapling cannot be placed on stone");
|
||||
helper.assertTrue(BlockKnowledgeService.knowledge(player, Blocks.OAK_SAPLING).placed() == 0,
|
||||
"A failed item use must not count as a placement");
|
||||
helper.succeed();
|
||||
}
|
||||
|
||||
@GameTest(maxTicks = 100)
|
||||
public void vanillaMiningAndVoluntaryDropsRemainAuthoritative(GameTestHelper helper) {
|
||||
ServerPlayer player = player(helper);
|
||||
BlockPos mined = helper.absolutePos(new BlockPos(1, 1, 1));
|
||||
helper.getLevel().setBlockAndUpdate(mined, Blocks.STONE.defaultBlockState());
|
||||
player.setItemInHand(InteractionHand.MAIN_HAND, new ItemStack(Items.DIAMOND_PICKAXE));
|
||||
helper.assertTrue(player.gameMode.destroyBlock(mined), "The test player must mine stone");
|
||||
helper.assertTrue(player.getStats().getValue(Stats.BLOCK_MINED.get(Blocks.STONE)) == 1,
|
||||
"The successful harvest must increment Minecraft's mined counter");
|
||||
helper.assertTrue(BlockKnowledgeService.knowledge(player, Blocks.STONE).mined() == 1,
|
||||
"Sanctuary must expose Minecraft's counter without double counting");
|
||||
|
||||
helper.getLevel().setBlockAndUpdate(mined, Blocks.STONE.defaultBlockState());
|
||||
player.setItemInHand(InteractionHand.MAIN_HAND, ItemStack.EMPTY);
|
||||
player.gameMode.destroyBlock(mined);
|
||||
helper.assertTrue(BlockKnowledgeService.knowledge(player, Blocks.STONE).mined() == 1,
|
||||
"Breaking stone with the wrong tool must preserve vanilla mining semantics");
|
||||
|
||||
player.drop(new ItemStack(Items.DIRT, 3), true, Prediction.PREDICTED);
|
||||
helper.assertTrue(BlockKnowledgeService.knowledge(player, Blocks.DIRT).dropped() == 3,
|
||||
"Voluntary drops must count individual items exactly once");
|
||||
player.getInventory().setItem(0, new ItemStack(Items.DIRT, 5));
|
||||
player.getInventory().dropAll();
|
||||
helper.assertTrue(BlockKnowledgeService.knowledge(player, Blocks.DIRT).dropped() == 3,
|
||||
"The inventory's death-drop path must not count as voluntary drops");
|
||||
helper.succeed();
|
||||
}
|
||||
|
||||
@GameTest(maxTicks = 100)
|
||||
public void cursorPossessionSurvivesImmediateReturnToChest(GameTestHelper helper) {
|
||||
ServerPlayer player = player(helper);
|
||||
SimpleContainer chest = new SimpleContainer(27);
|
||||
chest.setItem(0, new ItemStack(Items.EMERALD_BLOCK, 5));
|
||||
ChestMenu menu = ChestMenu.threeRows(1, player.getInventory(), chest);
|
||||
player.containerMenu = menu;
|
||||
helper.assertTrue(!BlockKnowledgeService.knowledge(player, Blocks.EMERALD_BLOCK).possessed(),
|
||||
"An unopened chest stack must not count as player possession");
|
||||
|
||||
// No service query or tick between taking and returning the stack.
|
||||
menu.clicked(0, 0, ContainerInput.PICKUP, player);
|
||||
menu.clicked(0, 0, ContainerInput.PICKUP, player);
|
||||
var knowledge = BlockKnowledgeService.knowledge(player, Blocks.EMERALD_BLOCK);
|
||||
helper.assertTrue(knowledge.possessed(),
|
||||
"A stack briefly held on the cursor must remain in possession history");
|
||||
helper.assertTrue(knowledge.carried() == 0,
|
||||
"Returning the stack must remove current stock without erasing its history");
|
||||
helper.succeed();
|
||||
}
|
||||
|
||||
@GameTest(maxTicks = 100)
|
||||
public void gazeStopsAtFirstBlockAndSpectatorsRevealNothing(GameTestHelper helper) {
|
||||
ServerPlayer player = player(helper);
|
||||
Vec3 feet = helper.absoluteVec(new Vec3(1.5, 2, 1.5));
|
||||
player.setPos(feet);
|
||||
player.setYRot(0);
|
||||
player.setXRot(0);
|
||||
BlockPos eye = BlockPos.containing(player.getEyePosition());
|
||||
// The observer deliberately never requests missing chunks. Load its short ray here,
|
||||
// in the isolated test world, before asking it to observe anything.
|
||||
int minX = (int) Math.floor(player.getX() - 1) >> 4;
|
||||
int maxX = (int) Math.floor(player.getX() + 1) >> 4;
|
||||
int minZ = (int) Math.floor(player.getZ() - 1) >> 4;
|
||||
int maxZ = (int) Math.floor(player.getZ() + BlockKnowledgeService.OBSERVATION_DISTANCE + 1) >> 4;
|
||||
for (int x = minX; x <= maxX; x++) for (int z = minZ; z <= maxZ; z++) {
|
||||
helper.getLevel().getChunk(x, z);
|
||||
}
|
||||
for (int z = 0; z <= 4; z++) {
|
||||
helper.getLevel().setBlockAndUpdate(eye.offset(0, 0, z), Blocks.AIR.defaultBlockState());
|
||||
}
|
||||
BlockPos visible = eye.offset(0, 0, 2);
|
||||
BlockPos hidden = eye.offset(0, 0, 3);
|
||||
helper.getLevel().setBlockAndUpdate(visible, Blocks.STONE.defaultBlockState());
|
||||
helper.getLevel().setBlockAndUpdate(hidden, Blocks.DIAMOND_ORE.defaultBlockState());
|
||||
|
||||
BlockKnowledgeService.observeLook(player);
|
||||
helper.assertTrue(BlockKnowledgeService.knowledge(player, Blocks.STONE).seen(),
|
||||
"The first block on the player's gaze ray must become seen");
|
||||
helper.assertTrue(!BlockKnowledgeService.knowledge(player, Blocks.DIAMOND_ORE).known(),
|
||||
"An ore behind the first block must remain unknown");
|
||||
|
||||
ServerPlayer spectator = (ServerPlayer) helper.makeMockServerPlayer(GameType.SPECTATOR);
|
||||
spectator.setPos(feet);
|
||||
spectator.setYRot(0);
|
||||
spectator.setXRot(0);
|
||||
helper.assertTrue(spectator.isSpectator(), "The observer fixture must be a spectator");
|
||||
BlockKnowledgeService.observeLook(spectator);
|
||||
helper.assertTrue(!BlockKnowledgeService.knowledge(spectator, Blocks.STONE).known()
|
||||
&& !BlockKnowledgeService.knowledge(spectator, Blocks.DIAMOND_ORE).known(),
|
||||
"Spectator gaze must not discover either visible or occluded blocks");
|
||||
helper.succeed();
|
||||
}
|
||||
|
||||
@GameTest(maxTicks = 100)
|
||||
public void existingStatsRemainPersonalWithoutInventingSightOrPlacements(GameTestHelper helper) {
|
||||
ServerPlayer first = player(helper);
|
||||
ServerPlayer second = player(helper);
|
||||
// Restore vanilla values directly, without going through an action hook.
|
||||
first.getStats().setValue(first, Stats.BLOCK_MINED.get(Blocks.DIAMOND_ORE), 7);
|
||||
first.getStats().setValue(first, Stats.ITEM_DROPPED.get(Items.EMERALD_BLOCK), 4);
|
||||
first.getStats().setValue(first, Stats.ITEM_PICKED_UP.get(Items.REDSTONE_BLOCK), 9);
|
||||
var mined = BlockKnowledgeService.knowledge(first, Blocks.DIAMOND_ORE);
|
||||
var dropped = BlockKnowledgeService.knowledge(first, Blocks.EMERALD_BLOCK);
|
||||
var pickedUp = BlockKnowledgeService.knowledge(first, Blocks.REDSTONE_BLOCK);
|
||||
helper.assertTrue(mined.mined() == 7 && !mined.possessed() && !mined.seen() && mined.placed() == 0,
|
||||
"A historical mining counter must not invent possession, sight or placement evidence");
|
||||
helper.assertTrue(dropped.dropped() == 4 && dropped.possessed() && !dropped.seen() && dropped.placed() == 0,
|
||||
"Historical drops imply possession but cannot reconstruct sight or placements");
|
||||
helper.assertTrue(pickedUp.possessed() && pickedUp.dropped() == 0 && !pickedUp.seen() && pickedUp.placed() == 0,
|
||||
"Historical pickups imply possession without inventing other actions");
|
||||
helper.assertTrue(mined.carried() == 0 && dropped.carried() == 0 && pickedUp.carried() == 0,
|
||||
"Historical counters must not create current inventory stock");
|
||||
|
||||
BlockKnowledgeService.recordSeen(first, Blocks.GOLD_BLOCK);
|
||||
helper.assertTrue(!BlockKnowledgeService.knowledge(second, Blocks.DIAMOND_ORE).known()
|
||||
&& !BlockKnowledgeService.knowledge(second, Blocks.EMERALD_BLOCK).known()
|
||||
&& !BlockKnowledgeService.knowledge(second, Blocks.REDSTONE_BLOCK).known()
|
||||
&& !BlockKnowledgeService.knowledge(second, Blocks.GOLD_BLOCK).known(),
|
||||
"Both vanilla evidence and Sanctuary history must stay isolated by player UUID");
|
||||
helper.succeed();
|
||||
}
|
||||
|
||||
@GameTest(maxTicks = 100)
|
||||
public void currentStockSumsPersonalSlotsAndLeavesPossessionHistory(GameTestHelper helper) {
|
||||
ServerPlayer player = player(helper);
|
||||
player.setItemInHand(InteractionHand.MAIN_HAND, new ItemStack(Items.LAPIS_BLOCK, 4));
|
||||
player.setItemInHand(InteractionHand.OFF_HAND, new ItemStack(Items.LAPIS_BLOCK, 2));
|
||||
player.containerMenu.setCarried(new ItemStack(Items.LAPIS_BLOCK, 3));
|
||||
var held = BlockKnowledgeService.knowledge(player, Blocks.LAPIS_BLOCK);
|
||||
helper.assertTrue(held.carried() == 9 && held.possessed(),
|
||||
"Inventory, offhand and cursor must be counted once each");
|
||||
|
||||
player.setItemInHand(InteractionHand.MAIN_HAND, ItemStack.EMPTY);
|
||||
player.setItemInHand(InteractionHand.OFF_HAND, ItemStack.EMPTY);
|
||||
player.containerMenu.setCarried(ItemStack.EMPTY);
|
||||
var emptied = BlockKnowledgeService.knowledge(player, Blocks.LAPIS_BLOCK);
|
||||
helper.assertTrue(emptied.carried() == 0 && emptied.possessed(),
|
||||
"Empty current stock must retain historical possession");
|
||||
helper.assertTrue(!emptied.seen() && emptied.mined() == 0 && emptied.placed() == 0 && emptied.dropped() == 0,
|
||||
"Inventory evidence must not manufacture other kinds of progression");
|
||||
helper.succeed();
|
||||
}
|
||||
|
||||
@GameTest(maxTicks = 100)
|
||||
public void listenersReceiveUpdatedProgressionAndStockChanges(GameTestHelper helper) {
|
||||
ServerPlayer player = player(helper);
|
||||
var uuid = player.getUUID();
|
||||
List<Notice> notices = new ArrayList<>();
|
||||
BlockKnowledgeEvents.CHANGED.register((source, knowledge, activity) -> {
|
||||
if (source.getUUID().equals(uuid) && knowledge.blockId().equals("minecraft:gold_block")) {
|
||||
notices.add(new Notice(activity, knowledge));
|
||||
}
|
||||
});
|
||||
|
||||
// Vanilla pickup inserts the stack before awarding its statistic. Inventory observation
|
||||
// and the statistic hook must publish one discovery between them, then remain sticky.
|
||||
player.setItemInHand(InteractionHand.MAIN_HAND, new ItemStack(Items.GOLD_BLOCK));
|
||||
player.awardStat(Stats.ITEM_PICKED_UP.get(Items.GOLD_BLOCK), 1);
|
||||
helper.assertTrue(notices.stream().filter(n -> n.activity() == BlockKnowledgeEvents.Activity.POSSESSED).count() == 1,
|
||||
"One pickup must not duplicate first-possession notifications through its inventory and stat paths");
|
||||
player.setItemInHand(InteractionHand.MAIN_HAND, new ItemStack(Items.GOLD_BLOCK, 2));
|
||||
player.awardStat(Stats.ITEM_PICKED_UP.get(Items.GOLD_BLOCK), 1);
|
||||
helper.assertTrue(notices.stream().filter(n -> n.activity() == BlockKnowledgeEvents.Activity.POSSESSED).count() == 1,
|
||||
"A later pickup must change stock without publishing another first-possession notification");
|
||||
|
||||
BlockKnowledgeService.recordSeen(player, Blocks.GOLD_BLOCK);
|
||||
BlockKnowledgeService.recordSeen(player, Blocks.GOLD_BLOCK);
|
||||
player.awardStat(Stats.BLOCK_MINED.get(Blocks.GOLD_BLOCK), 2);
|
||||
BlockPos support = helper.absolutePos(new BlockPos(1, 1, 1));
|
||||
helper.getLevel().setBlockAndUpdate(support, Blocks.STONE.defaultBlockState());
|
||||
helper.getLevel().setBlockAndUpdate(support.above(), Blocks.AIR.defaultBlockState());
|
||||
helper.assertTrue(place(player, Items.GOLD_BLOCK, support, Direction.UP),
|
||||
"The event fixture must place a gold block");
|
||||
player.setItemInHand(InteractionHand.MAIN_HAND, new ItemStack(Items.GOLD_BLOCK, 5));
|
||||
BlockKnowledgeService.observeInventory(player);
|
||||
player.getInventory().removeItem(player.getInventory().getSelectedSlot(), 1);
|
||||
player.drop(new ItemStack(Items.GOLD_BLOCK), true, Prediction.PREDICTED);
|
||||
|
||||
helper.assertTrue(notices.stream().filter(n -> n.activity() == BlockKnowledgeEvents.Activity.SEEN).count() == 1,
|
||||
"Repeated sight of the same block must not emit duplicate discoveries");
|
||||
helper.assertTrue(notices.stream().anyMatch(n -> n.activity() == BlockKnowledgeEvents.Activity.MINED && n.knowledge().mined() == 2),
|
||||
"Mining listeners must receive the already updated vanilla counter");
|
||||
helper.assertTrue(notices.stream().anyMatch(n -> n.activity() == BlockKnowledgeEvents.Activity.PLACED && n.knowledge().placed() == 1),
|
||||
"Placement listeners must receive the confirmed placement count");
|
||||
helper.assertTrue(notices.stream().anyMatch(n -> n.activity() == BlockKnowledgeEvents.Activity.POSSESSED && n.knowledge().possessed()),
|
||||
"First possession must be available to future progression listeners");
|
||||
helper.assertTrue(notices.stream().anyMatch(n -> n.activity() == BlockKnowledgeEvents.Activity.DROPPED && n.knowledge().dropped() == 1),
|
||||
"Drop listeners must receive the already updated vanilla counter");
|
||||
helper.assertTrue(notices.stream().anyMatch(n -> n.activity() == BlockKnowledgeEvents.Activity.INVENTORY && n.knowledge().carried() == 4),
|
||||
"Dropping an item must also notify consumers of the changed current stock");
|
||||
helper.succeed();
|
||||
}
|
||||
|
||||
@GameTest(maxTicks = 100)
|
||||
public void disconnectFromNetworkThreadSavesAndReloadsOnServer(GameTestHelper helper) throws InterruptedException {
|
||||
ServerPlayer player = player(helper);
|
||||
var server = helper.getLevel().getServer();
|
||||
// A real packet listener, but no player-list registration or live connection. The only
|
||||
// DISCONNECT subscriber in this test runtime is Sanctuary's history lifecycle handler.
|
||||
var listener = new ServerGamePacketListenerImpl(server, new Connection(PacketFlow.SERVERBOUND),
|
||||
player, CommonListenerCookie.createInitial(player.getGameProfile(), false));
|
||||
player.setItemInHand(InteractionHand.MAIN_HAND, new ItemStack(Items.PRISMARINE, 2));
|
||||
BlockKnowledgeService.recordSeen(player, Blocks.PRISMARINE);
|
||||
BlockKnowledgeService.recordPlaced(player, Blocks.PRISMARINE);
|
||||
var directory = server.getWorldPath(LevelResource.ROOT).resolve("data/sanctuary-blocodex");
|
||||
var file = directory.resolve(player.getUUID() + ".json");
|
||||
helper.assertTrue(!Files.exists(file), "Fresh history must still be in memory before its first save");
|
||||
|
||||
AtomicReference<Throwable> workerFailure = new AtomicReference<>();
|
||||
Thread worker = new Thread(() -> {
|
||||
try {
|
||||
if (server.isSameThread()) throw new AssertionError("The disconnect fixture must run outside the server thread");
|
||||
ServerPlayConnectionEvents.DISCONNECT.invoker().onPlayDisconnect(listener, server);
|
||||
} catch (Throwable failure) {
|
||||
workerFailure.set(failure);
|
||||
}
|
||||
}, "sanctuary-blocodex-disconnect-test");
|
||||
worker.setDaemon(true);
|
||||
worker.start();
|
||||
worker.join(5000);
|
||||
helper.assertTrue(!worker.isAlive(), "The network callback must return without waiting for the server tick");
|
||||
helper.assertTrue(workerFailure.get() == null, "The network callback must safely schedule its work: " + workerFailure.get());
|
||||
helper.assertTrue(!Files.exists(file),
|
||||
"A network-thread disconnect must defer history writes until the server can execute them");
|
||||
player.setItemInHand(InteractionHand.MAIN_HAND, ItemStack.EMPTY);
|
||||
|
||||
helper.runAfterDelay(2, () -> {
|
||||
try {
|
||||
helper.assertTrue(Files.isRegularFile(file), "The queued disconnect must save history on the server thread");
|
||||
var disk = new BlockKnowledgeStore(directory, player.getUUID()).load().entry("minecraft:prismarine");
|
||||
helper.assertTrue(disk.seen() && disk.possessed() && disk.placed() == 1,
|
||||
"The saved file must retain all Sanctuary evidence from before disconnect");
|
||||
var reloaded = BlockKnowledgeService.knowledge(player, Blocks.PRISMARINE);
|
||||
helper.assertTrue(reloaded.seen() && reloaded.possessed() && reloaded.placed() == 1 && reloaded.carried() == 0,
|
||||
"A fresh service session must reload history while rebuilding empty current stock");
|
||||
BlockKnowledgeService.recordPlaced(player, Blocks.PRISMARINE);
|
||||
BlockKnowledgeService.flush(server);
|
||||
var updated = new BlockKnowledgeStore(directory, player.getUUID()).load().entry("minecraft:prismarine");
|
||||
helper.assertTrue(updated.placed() == 2,
|
||||
"A reloaded service session must be able to extend and flush its verified history");
|
||||
helper.succeed();
|
||||
} catch (IOException failure) {
|
||||
helper.fail("Cannot read native block knowledge history: " + failure.getMessage());
|
||||
} finally {
|
||||
player.getTextFilter().leave();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@GameTest(maxTicks = 100)
|
||||
public void structurePalettesCombinePersonalEvidenceWithAllowedMaterials(GameTestHelper helper) {
|
||||
ServerPlayer player = player(helper);
|
||||
var natural = BlockKnowledgeService.NATURAL_STRUCTURE_MATERIALS;
|
||||
helper.assertTrue(Blocks.STONE.defaultBlockState().is(natural)
|
||||
&& Blocks.OAK_LOG.defaultBlockState().is(natural)
|
||||
&& !Blocks.CONCRETE.pick(net.minecraft.world.item.DyeColor.WHITE).defaultBlockState().is(natural),
|
||||
"The structure palette tag must include stone and logs while excluding concrete");
|
||||
|
||||
player.setItemInHand(InteractionHand.MAIN_HAND, new ItemStack(Items.STONE, 3));
|
||||
BlockKnowledgeService.observeInventory(player);
|
||||
player.setItemInHand(InteractionHand.MAIN_HAND, ItemStack.EMPTY);
|
||||
BlockKnowledgeService.recordSeen(player, Blocks.OAK_LOG);
|
||||
player.setItemInHand(InteractionHand.OFF_HAND, new ItemStack(Items.CONCRETE.pick(net.minecraft.world.item.DyeColor.WHITE), 5));
|
||||
|
||||
var possessed = BlockKnowledgeService.palette(player, BlockKnowledgeFacet.POSSESSED, natural);
|
||||
helper.assertTrue(possessed.stream().map(BlockKnowledge::blockId).toList().equals(List.of("minecraft:stone")),
|
||||
"A possessed-material palette must retain historical stone, exclude seen-only oak and reject concrete");
|
||||
helper.assertTrue(possessed.getFirst().carried() == 0,
|
||||
"An unlocked material must not invent remaining stock after its items are removed");
|
||||
helper.assertTrue(BlockKnowledgeService.palette(player, BlockKnowledgeFacet.CARRIED, natural).isEmpty(),
|
||||
"Current natural stock must be empty even while the player carries disallowed concrete");
|
||||
|
||||
var discovered = BlockKnowledgeService.palette(player,
|
||||
BlockKnowledgeFacet.SEEN.or(BlockKnowledgeFacet.POSSESSED), natural);
|
||||
helper.assertTrue(discovered.stream().map(BlockKnowledge::blockId).toList()
|
||||
.equals(List.of("minecraft:oak_log", "minecraft:stone")),
|
||||
"Composed evidence must produce a stable sorted palette without admitting unknown materials");
|
||||
helper.assertTrue(discovered.getFirst().seen() && !discovered.getFirst().possessed()
|
||||
&& discovered.getFirst().carried() == 0,
|
||||
"Seeing a log must not manufacture possession or a usable quantity");
|
||||
boolean immutable = false;
|
||||
try { discovered.clear(); }
|
||||
catch (UnsupportedOperationException expected) { immutable = true; }
|
||||
helper.assertTrue(immutable, "Consumers must receive an immutable material palette");
|
||||
|
||||
player.setItemInHand(InteractionHand.MAIN_HAND, new ItemStack(Items.STONE, 2));
|
||||
var available = BlockKnowledgeService.palette(player,
|
||||
BlockKnowledgeFacet.POSSESSED.and(BlockKnowledgeFacet.CARRIED), natural);
|
||||
helper.assertTrue(available.size() == 1 && available.getFirst().blockId().equals("minecraft:stone")
|
||||
&& available.getFirst().carried() == 2,
|
||||
"An available-material palette must report only the exact current allowed quantity");
|
||||
helper.succeed();
|
||||
}
|
||||
|
||||
private record Notice(BlockKnowledgeEvents.Activity activity, BlockKnowledge knowledge) { }
|
||||
|
||||
private static ServerPlayer player(GameTestHelper helper) {
|
||||
ServerPlayer player = (ServerPlayer) helper.makeMockServerPlayer(GameType.SURVIVAL);
|
||||
player.setPos(helper.absoluteVec(new Vec3(5.5, 3, 5.5)));
|
||||
return player;
|
||||
}
|
||||
|
||||
private static boolean place(ServerPlayer player, Item item, BlockPos support, Direction face) {
|
||||
player.setItemInHand(InteractionHand.MAIN_HAND, new ItemStack(item));
|
||||
var hit = new BlockHitResult(Vec3.atCenterOf(support), face, support, false);
|
||||
var context = new BlockPlaceContext(new UseOnContext(player, InteractionHand.MAIN_HAND, hit));
|
||||
return ((BlockItem) item).place(context).consumesAction();
|
||||
}
|
||||
}
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
package fr.koka.sanctuary.gametest;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import fr.koka.sanctuary.SanctuaryMod;
|
||||
import fr.koka.sanctuary.worldgen.PopulationIslandDensity;
|
||||
import fr.koka.sanctuary.worldgen.SanctuaryChunkGenerator;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import net.fabricmc.fabric.api.gametest.v1.GameTest;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.gametest.framework.GameTestHelper;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
import net.minecraft.world.level.levelgen.densityfunction.SamplerContext;
|
||||
|
||||
/** Bounded comparison of the real registered density, followed by inspection of ordinary FULL chunks. */
|
||||
public final class Caves28WorldGameTests {
|
||||
@GameTest(maxTicks = 3600)
|
||||
public void geologyAndNativeOres(GameTestHelper helper) throws Exception {
|
||||
var level = helper.getLevel();
|
||||
var generator = (SanctuaryChunkGenerator) level.getChunkSource().getGenerator();
|
||||
var binding = generator.starterContext();
|
||||
var field = (PopulationIslandDensity) level.registryAccess().lookupOrThrow(Registries.DENSITY_FUNCTION)
|
||||
.getOrThrow(ResourceKey.create(Registries.DENSITY_FUNCTION,
|
||||
SanctuaryMod.id("population_" + generator.capacity().players()))).value();
|
||||
helper.assertTrue(field.geology28(), "Current world uses the native-cave adaptation");
|
||||
var current = binding.random().getSampler(field);
|
||||
var previous = binding.random().getSampler(field.legacy27());
|
||||
var context = SamplerContext.builder().enableCaches().build();
|
||||
var report = new LinkedHashMap<String, Object>();
|
||||
report.put("seed", level.getSeed()); report.put("diameter", generator.initialDiameter());
|
||||
report.put("scope", "Registered density comparison; no synthetic terrain, water, ore or room is placed by the test");
|
||||
var heights = new ArrayList<List<Integer>>();
|
||||
long oldSolid = 0, remainingSolid = 0, excavated = 0, restored = 0;
|
||||
int min = -Math.min(320, generator.initialDiameter() / 2), max = -min, raised = 0, lowered = 0, largestUplift = 0, largestSubsidence = 0;
|
||||
for (int z = min; z <= max; z += 32) for (int x = min; x <= max; x += 32) {
|
||||
int oldTop = 0, newTop = 0;
|
||||
for (int y = 2; y <= 382; y += 2) {
|
||||
boolean old = previous.sampleValue(context, x, y, z) > 0;
|
||||
boolean now = current.sampleValue(context, x, y, z) > 0;
|
||||
if (old) oldTop = y; if (now) newTop = y;
|
||||
if (y >= 48 && y <= 202) {
|
||||
if (old) { oldSolid++; if (now) remainingSolid++; else excavated++; }
|
||||
else if (now) restored++;
|
||||
}
|
||||
if (Math.hypot(x, z) < 40 && y >= 240)
|
||||
helper.assertTrue(old == now, "High arrival neighbourhood remains unchanged");
|
||||
}
|
||||
if (newTop > oldTop && oldTop > 208) { raised++; largestUplift = Math.max(largestUplift, newTop - oldTop); }
|
||||
if (newTop < oldTop && oldTop > 240) { lowered++; largestSubsidence = Math.max(largestSubsidence, oldTop - newTop); }
|
||||
heights.add(List.of(x, z, oldTop, newTop));
|
||||
}
|
||||
report.put("heights", heights); report.put("old_solid_samples", oldSolid);
|
||||
report.put("remaining_solid_samples", remainingSolid); report.put("excavated_samples", excavated);
|
||||
report.put("restored_rift_samples", restored); report.put("raised_columns", raised);
|
||||
report.put("largest_uplift", largestUplift);
|
||||
report.put("lowered_columns", lowered); report.put("largest_subsidence", largestSubsidence);
|
||||
helper.assertTrue(excavated > 0 && remainingSolid > excavated, "New passages exist while most sampled former rock remains");
|
||||
helper.assertTrue(raised > 0, "Native volumetric deformation raises some uplands");
|
||||
var childField = (PopulationIslandDensity) level.registryAccess().lookupOrThrow(Registries.DENSITY_FUNCTION)
|
||||
.getOrThrow(ResourceKey.create(Registries.DENSITY_FUNCTION, SanctuaryMod.id("population_5"))).value();
|
||||
var child = new fr.koka.sanctuary.expansion.ExpansionIsland("geology_witness", "sanctuary", "east", "temperate",
|
||||
512, 2048, 0, level.getSeed(), "natural", "ready", 24);
|
||||
var childSettings = level.registryAccess().lookupOrThrow(Registries.NOISE_SETTINGS)
|
||||
.getOrThrow(ResourceKey.create(Registries.NOISE_SETTINGS, SanctuaryMod.id("population_5"))).value();
|
||||
var childState = net.minecraft.world.level.levelgen.RandomState.create(level.registryAccess().lookupOrThrow(Registries.NOISE), child.seed(), childSettings);
|
||||
var childNew = childState.getSampler(new fr.koka.sanctuary.expansion.ExpansionDensity(childField, child));
|
||||
var childOld = childState.getSampler(new fr.koka.sanctuary.expansion.ExpansionDensity(childField.legacy27(), child));
|
||||
long childExcavated = 0, childRemaining = 0;
|
||||
for (int z = -160; z <= 160; z += 32) for (int dx = -160; dx <= 160; dx += 32)
|
||||
for (int y = 48; y <= 202; y += 4) {
|
||||
if (childOld.sampleValue(context, 2048 + dx, y, z) > 0) {
|
||||
if (childNew.sampleValue(context, 2048 + dx, y, z) <= 0) childExcavated++;
|
||||
else childRemaining++;
|
||||
}
|
||||
}
|
||||
report.put("expansion_density", Map.of("diameter", 512, "excavated", childExcavated,
|
||||
"remaining", childRemaining, "reserved_or_opened", false));
|
||||
helper.assertTrue(childExcavated > 0 && childRemaining > childExcavated, "The actual expansion wrapper uses the same finite cave field");
|
||||
var sections = new LinkedHashMap<String, Object>();
|
||||
for (int z : new int[]{0, 96}) {
|
||||
var before = new ArrayList<String>(); var after = new ArrayList<String>();
|
||||
for (int y = 382; y >= 0; y -= 2) {
|
||||
var a = new StringBuilder(); var b = new StringBuilder();
|
||||
for (int x = min; x <= max; x += 2) {
|
||||
a.append(previous.sampleValue(context, x, y, z) > 0 ? '#' : '.');
|
||||
b.append(current.sampleValue(context, x, y, z) > 0 ? '#' : '.');
|
||||
}
|
||||
before.add(a.toString()); after.add(b.toString());
|
||||
}
|
||||
sections.put("z" + z, Map.of("before", before, "after", after, "min_x", min, "step", 2));
|
||||
}
|
||||
report.put("sections", sections);
|
||||
var ores = new TreeMap<String, Integer>(); var oreDepths = new TreeMap<String, List<Integer>>();
|
||||
for (int cx : new int[]{-6, 0, 6}) for (int cz : new int[]{-6, 0, 6}) {
|
||||
var chunk = level.getChunk(cx, cz, ChunkStatus.FULL, true);
|
||||
for (int x = 0; x < 16; x++) for (int z = 0; z < 16; z++) for (int y = 1; y < 383; y++) {
|
||||
var state = chunk.getBlockState(new BlockPos(cx * 16 + x, y, cz * 16 + z));
|
||||
String id = BuiltInRegistries.BLOCK.getKey(state.getBlock()).toString();
|
||||
if (id.endsWith("_ore")) {
|
||||
ores.merge(id, 1, Integer::sum);
|
||||
var band = oreDepths.computeIfAbsent(id, ignored -> new ArrayList<>(List.of(384, 0)));
|
||||
band.set(0, Math.min(band.get(0), y)); band.set(1, Math.max(band.get(1), y));
|
||||
}
|
||||
}
|
||||
}
|
||||
report.put("full_chunks_inspected", 9); report.put("ores", ores); report.put("ore_y_ranges", oreDepths);
|
||||
helper.assertTrue(!ores.isEmpty(), "Actual generated rock contains native ore deposits");
|
||||
report.put("passed", true);
|
||||
Path path = Path.of("diagnostics/alpha28/geology.json"); Files.createDirectories(path.getParent());
|
||||
Files.writeString(path, new GsonBuilder().setPrettyPrinting().create().toJson(report));
|
||||
helper.succeed();
|
||||
}
|
||||
}
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
package fr.koka.sanctuary.gametest;
|
||||
|
||||
import fr.koka.sanctuary.knowledge.census.LoadedChunks;
|
||||
import fr.koka.sanctuary.knowledge.census.TerrainCensus;
|
||||
import net.fabricmc.fabric.api.gametest.v1.GameTest;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.gametest.framework.GameTestHelper;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
/** Native material changes and the non-loading contract of the live terrain census. */
|
||||
public final class CensusGameTestsTerrain {
|
||||
@GameTest(maxTicks = 3000)
|
||||
public void chunkCensusRecountsPlacementReplacementAndRemoval(GameTestHelper helper) {
|
||||
var level = helper.getLevel();
|
||||
BlockPos pos = helper.absolutePos(new BlockPos(2, 3, 2));
|
||||
ChunkPos chunkPos = new ChunkPos(pos.getX() >> 4, pos.getZ() >> 4);
|
||||
var original = level.getBlockState(pos);
|
||||
long[] baseline = new long[2];
|
||||
TerrainCensus.ChunkSnapshot[] immutableBefore = new TerrainCensus.ChunkSnapshot[1];
|
||||
String pink = "minecraft:pink_glazed_terracotta";
|
||||
String orange = "minecraft:orange_glazed_terracotta";
|
||||
|
||||
helper.startSequence()
|
||||
.thenWaitUntil(() -> helper.assertTrue(current(helper, chunkPos).complete(),
|
||||
"The fixture chunk must finish its bounded initial material census"))
|
||||
.thenExecute(() -> {
|
||||
var snapshot = current(helper, chunkPos);
|
||||
baseline[0] = snapshot.blockCounts().getOrDefault(pink, 0L);
|
||||
baseline[1] = snapshot.blockCounts().getOrDefault(orange, 0L);
|
||||
immutableBefore[0] = snapshot;
|
||||
level.setBlockAndUpdate(pos, Blocks.GLAZED_TERRACOTTA.pick(DyeColor.PINK).defaultBlockState());
|
||||
})
|
||||
.thenWaitUntil(() -> {
|
||||
var placed = current(helper, chunkPos);
|
||||
helper.assertTrue(placed.complete() && placed.blockCounts().getOrDefault(pink, 0L) == baseline[0] + 1,
|
||||
"A native placement must add exactly one material to its loaded chunk");
|
||||
helper.assertTrue(immutableBefore[0].blockCounts().getOrDefault(pink, 0L) == baseline[0],
|
||||
"A previously returned census must not mutate when terrain changes");
|
||||
})
|
||||
.thenExecute(() -> {
|
||||
level.setBlockAndUpdate(pos, Blocks.GLAZED_TERRACOTTA.pick(DyeColor.ORANGE).defaultBlockState());
|
||||
var pending = current(helper, chunkPos);
|
||||
helper.assertTrue(pending.blockCounts().getOrDefault(pink, 0L) <= baseline[0],
|
||||
"A dirty section must stop contributing its obsolete material count immediately");
|
||||
helper.assertTrue(pending.countedSections() <= pending.loadedSections()
|
||||
&& pending.coverage() >= 0 && pending.coverage() <= 1,
|
||||
"Coverage must honestly describe the sections contributing to this snapshot");
|
||||
})
|
||||
.thenWaitUntil(() -> {
|
||||
var replaced = current(helper, chunkPos);
|
||||
helper.assertTrue(replaced.complete() && replaced.blockCounts().getOrDefault(pink, 0L) == baseline[0]
|
||||
&& replaced.blockCounts().getOrDefault(orange, 0L) == baseline[1] + 1,
|
||||
"Recounting must remove the replaced material and count its replacement once");
|
||||
})
|
||||
.thenExecute(() -> level.setBlockAndUpdate(pos, original))
|
||||
.thenWaitUntil(() -> {
|
||||
var removed = current(helper, chunkPos);
|
||||
helper.assertTrue(removed.complete() && removed.blockCounts().getOrDefault(pink, 0L) == baseline[0]
|
||||
&& removed.blockCounts().getOrDefault(orange, 0L) == baseline[1],
|
||||
"Removing the placed material must restore its original material totals");
|
||||
helper.assertTrue(removed.dimensionId().equals(level.dimension().identifier().toString())
|
||||
&& removed.chunkX() == chunkPos.x() && removed.chunkZ() == chunkPos.z(),
|
||||
"Spatial snapshots must retain their stable dimension and chunk coordinates");
|
||||
}).thenSucceed();
|
||||
}
|
||||
|
||||
@GameTest(maxTicks = 100)
|
||||
public void missingChunksStayUnloadedAndRepeatedReadsShareBudget(GameTestHelper helper) {
|
||||
var level = helper.getLevel();
|
||||
var server = level.getServer();
|
||||
ChunkPos absent = new ChunkPos(1_000_000, 1_000_000);
|
||||
helper.assertTrue(level.getChunkSource().getChunkNow(absent.x(), absent.z()) == null,
|
||||
"The distant fixture must begin unloaded");
|
||||
int holdersBefore = level.getChunkSource().getLoadedChunksCount();
|
||||
var first = TerrainCensus.snapshot(server);
|
||||
int countedBefore = first.dimensions().stream().mapToInt(TerrainCensus.DimensionSnapshot::countedSections).sum();
|
||||
for (int read = 0; read < 32; read++) {
|
||||
helper.assertTrue(TerrainCensus.chunkSnapshot(level, absent).isEmpty(),
|
||||
"Requesting spatial metadata for a missing chunk must return absence");
|
||||
}
|
||||
var repeated = TerrainCensus.snapshot(server);
|
||||
helper.assertTrue(repeated.dimensions().stream().mapToInt(TerrainCensus.DimensionSnapshot::countedSections).sum() == countedBefore,
|
||||
"Repeated reads in the same tick must not spend another palette scan budget");
|
||||
helper.assertTrue(level.getChunkSource().getLoadedChunksCount() == holdersBefore
|
||||
&& level.getChunkSource().getChunkNow(absent.x(), absent.z()) == null,
|
||||
"Census reads must neither create holders nor load or generate distant chunks");
|
||||
var dimension = repeated.dimensions().stream()
|
||||
.filter(value -> value.dimensionId().equals(level.dimension().identifier().toString())).findFirst().orElseThrow();
|
||||
helper.assertTrue(dimension.loadedChunks() == LoadedChunks.full(level).size(),
|
||||
"Coverage must count only currently available FULL chunks, excluding unloaded terrain");
|
||||
helper.assertTrue(!dimension.blockCounts().containsKey("minecraft:air")
|
||||
&& !dimension.blockCounts().containsKey("minecraft:cave_air")
|
||||
&& !dimension.blockCounts().containsKey("minecraft:void_air"),
|
||||
"Terrain materials must not count empty space as available matter");
|
||||
helper.succeed();
|
||||
}
|
||||
|
||||
private static TerrainCensus.ChunkSnapshot current(GameTestHelper helper, ChunkPos pos) {
|
||||
var result = TerrainCensus.chunkSnapshot(helper.getLevel(), pos);
|
||||
helper.assertTrue(result.isPresent(), "The active GameTest fixture chunk must already be loaded FULL");
|
||||
return result.orElseThrow();
|
||||
}
|
||||
}
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
package fr.koka.sanctuary.gametest;
|
||||
|
||||
import fr.koka.sanctuary.knowledge.census.StockCensus;
|
||||
import net.fabricmc.fabric.api.gametest.v1.GameTest;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.gametest.framework.GameTestHelper;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.CompoundContainer;
|
||||
import net.minecraft.world.entity.EntityTypes;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.vehicle.minecart.MinecartChest;
|
||||
import net.minecraft.world.inventory.ChestMenu;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.ChestBlock;
|
||||
import net.minecraft.world.level.block.entity.ChestBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.HopperBlockEntity;
|
||||
import net.minecraft.world.level.block.state.properties.ChestType;
|
||||
import net.minecraft.world.level.storage.loot.BuiltInLootTables;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
/** Native fixtures: a census must not move items, invent stock or open unopened loot. */
|
||||
public final class CensusStockGameTests {
|
||||
@GameTest(maxTicks = 100)
|
||||
public void categoriesRemainSeparateAndOpenDoubleChestIsCountedOnce(GameTestHelper helper) {
|
||||
var level = helper.getLevel();
|
||||
var server = level.getServer();
|
||||
var before = StockCensus.snapshot(server);
|
||||
BlockPos leftPos = helper.absolutePos(new BlockPos(1, 1, 1));
|
||||
BlockPos rightPos = leftPos.east();
|
||||
BlockPos hopperPos = helper.absolutePos(new BlockPos(4, 1, 1));
|
||||
var state = Blocks.CHEST.defaultBlockState().setValue(ChestBlock.FACING, Direction.NORTH);
|
||||
level.setBlockAndUpdate(leftPos, state.setValue(ChestBlock.TYPE, ChestType.LEFT));
|
||||
level.setBlockAndUpdate(rightPos, state.setValue(ChestBlock.TYPE, ChestType.RIGHT));
|
||||
level.setBlockAndUpdate(hopperPos, Blocks.HOPPER.defaultBlockState());
|
||||
var left = (ChestBlockEntity) level.getBlockEntity(leftPos);
|
||||
var right = (ChestBlockEntity) level.getBlockEntity(rightPos);
|
||||
var hopper = (HopperBlockEntity) level.getBlockEntity(hopperPos);
|
||||
left.setItem(0, new ItemStack(Items.GOLD_INGOT, 3));
|
||||
right.setItem(0, new ItemStack(Items.GOLD_INGOT, 5));
|
||||
hopper.setItem(0, new ItemStack(Items.GOLD_INGOT, 7));
|
||||
|
||||
ServerPlayer player = (ServerPlayer) helper.makeMockServerPlayer(GameType.SURVIVAL);
|
||||
player.getInventory().setItem(0, new ItemStack(Items.GOLD_INGOT, 6));
|
||||
player.setItemSlot(EquipmentSlot.OFFHAND, new ItemStack(Items.GOLD_INGOT, 2));
|
||||
player.setItemSlot(EquipmentSlot.HEAD, new ItemStack(Items.CARVED_PUMPKIN));
|
||||
player.containerMenu = ChestMenu.sixRows(1, player.getInventory(), new CompoundContainer(left, right));
|
||||
player.containerMenu.setCarried(new ItemStack(Items.GOLD_INGOT, 3));
|
||||
helper.assertTrue(!server.getPlayerList().getPlayers().contains(player), "Mock player must start outside the online list");
|
||||
helper.assertTrue(StockCensus.snapshot(server).playerItems().equals(before.playerItems()),
|
||||
"An offline player's inventory must not enter loaded online stock");
|
||||
|
||||
Vec3 position = helper.absoluteVec(new Vec3(3.5, 2, 3.5));
|
||||
var cart = new MinecartChest(EntityTypes.CHEST_MINECART, level);
|
||||
cart.setPos(position);
|
||||
cart.setItem(0, new ItemStack(Items.GOLD_INGOT, 11));
|
||||
level.addFreshEntity(cart);
|
||||
var item = new ItemEntity(level, position.x, position.y, position.z, new ItemStack(Items.GOLD_INGOT, 13));
|
||||
level.addFreshEntity(item);
|
||||
server.getPlayerList().getPlayers().add(player);
|
||||
try {
|
||||
var census = StockCensus.snapshot(server);
|
||||
String gold = "minecraft:gold_ingot";
|
||||
helper.assertTrue(census.playerItems().getOrDefault(gold, 0L) - before.playerItems().getOrDefault(gold, 0L) == 11,
|
||||
"Personal stock must include main inventory, equipment and cursor without the open chest");
|
||||
helper.assertTrue(census.blockContainerItems().getOrDefault(gold, 0L) - before.blockContainerItems().getOrDefault(gold, 0L) == 15,
|
||||
"Two chest halves and a hopper must each be counted once");
|
||||
helper.assertTrue(census.entityContainerItems().getOrDefault(gold, 0L) - before.entityContainerItems().getOrDefault(gold, 0L) == 11,
|
||||
"Chest minecart stock belongs to its own category");
|
||||
helper.assertTrue(census.groundItems().getOrDefault(gold, 0L) - before.groundItems().getOrDefault(gold, 0L) == 13,
|
||||
"Dropped stack units belong only to ground stock");
|
||||
helper.assertTrue(census.total(gold) - before.total(gold) == 50, "All four categories must total 50 real items");
|
||||
helper.assertTrue(census.playerItems().getOrDefault("minecraft:carved_pumpkin", 0L)
|
||||
- before.playerItems().getOrDefault("minecraft:carved_pumpkin", 0L) == 1,
|
||||
"Head equipment must be included exactly once");
|
||||
helper.assertTrue(left.getItem(0).getCount() == 3 && right.getItem(0).getCount() == 5 && hopper.getItem(0).getCount() == 7,
|
||||
"A stock census must preserve all container contents");
|
||||
helper.assertTrue(census.coverage().partial() && !census.coverage().offlineIncluded()
|
||||
&& !census.coverage().nestedContentsIncluded() && !census.coverage().mobInventoriesIncluded(),
|
||||
"Coverage must explicitly distinguish this loaded census from total world wealth");
|
||||
boolean immutable = false;
|
||||
try { census.playerItems().clear(); } catch (UnsupportedOperationException expected) { immutable = true; }
|
||||
helper.assertTrue(immutable, "Consumers must receive immutable stock maps");
|
||||
} finally {
|
||||
server.getPlayerList().getPlayers().remove(player);
|
||||
cart.discard();
|
||||
item.discard();
|
||||
}
|
||||
helper.succeed();
|
||||
}
|
||||
|
||||
@GameTest(maxTicks = 100)
|
||||
public void unopenedBlockAndVehicleLootRemainUnresolved(GameTestHelper helper) {
|
||||
var level = helper.getLevel();
|
||||
var server = level.getServer();
|
||||
var before = StockCensus.snapshot(server);
|
||||
BlockPos chestPos = helper.absolutePos(new BlockPos(1, 1, 1));
|
||||
level.setBlockAndUpdate(chestPos, Blocks.CHEST.defaultBlockState());
|
||||
var chest = (ChestBlockEntity) level.getBlockEntity(chestPos);
|
||||
chest.setLootTable(BuiltInLootTables.SIMPLE_DUNGEON, 41L);
|
||||
|
||||
var cart = new MinecartChest(EntityTypes.CHEST_MINECART, level);
|
||||
cart.setPos(helper.absoluteVec(new Vec3(3.5, 2, 3.5)));
|
||||
cart.setContainerLootTable(BuiltInLootTables.ABANDONED_MINESHAFT);
|
||||
cart.setContainerLootTableSeed(73L);
|
||||
level.addFreshEntity(cart);
|
||||
try {
|
||||
var census = StockCensus.snapshot(server);
|
||||
helper.assertTrue(chest.getLootTable().equals(BuiltInLootTables.SIMPLE_DUNGEON) && chest.getLootTableSeed() == 41L,
|
||||
"Reading stock must preserve the chest's unopened loot table and seed");
|
||||
helper.assertTrue(cart.getContainerLootTable().equals(BuiltInLootTables.ABANDONED_MINESHAFT)
|
||||
&& cart.getContainerLootTableSeed() == 73L,
|
||||
"Reading stock must also preserve a minecart's unopened loot table and seed");
|
||||
helper.assertTrue(census.coverage().pendingLootContainers() - before.coverage().pendingLootContainers() == 2,
|
||||
"Both unopened containers must be explicitly reported as omitted loot");
|
||||
helper.assertTrue(census.blockContainerItems().equals(before.blockContainerItems())
|
||||
&& census.entityContainerItems().equals(before.entityContainerItems()),
|
||||
"An unresolved loot table must not manufacture counted item stacks");
|
||||
} finally {
|
||||
// Prevent cleanup from generating loot after the assertions.
|
||||
cart.setContainerLootTable(null);
|
||||
cart.discard();
|
||||
chest.setLootTable(null);
|
||||
}
|
||||
helper.succeed();
|
||||
}
|
||||
}
|
||||
+278
@@ -0,0 +1,278 @@
|
||||
package fr.koka.sanctuary.gametest;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import fr.koka.sanctuary.expansion.ExpansionAdmission;
|
||||
import fr.koka.sanctuary.expansion.ExpansionIsland;
|
||||
import fr.koka.sanctuary.expansion.ExpansionJournal;
|
||||
import fr.koka.sanctuary.expansion.ExpansionRuntime;
|
||||
import fr.koka.sanctuary.expansion.ExpansionStructures23;
|
||||
import fr.koka.sanctuary.expansion.ExpansionVoidCertificate;
|
||||
import fr.koka.sanctuary.expansion.ExpansionVoidReuse;
|
||||
import fr.koka.sanctuary.expansion.NativeStructureMetadata23;
|
||||
import fr.koka.sanctuary.knowledge.structures.StructureCensusMemory;
|
||||
import fr.koka.sanctuary.knowledge.structures.StructureCensusService;
|
||||
import fr.koka.sanctuary.worldgen.SanctuaryChunkGenerator;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import net.fabricmc.fabric.api.gametest.v1.GameTest;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.gametest.framework.GameTestHelper;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureStart;
|
||||
import net.minecraft.world.level.levelgen.structure.pieces.StructurePieceSerializationContext;
|
||||
import net.minecraft.world.level.storage.LevelResource;
|
||||
|
||||
/** The real public admission transaction and preparation queue, with the production thirty-second deadline. */
|
||||
public final class Expansion23AdmissionGameTests {
|
||||
private static final int DISTANCE = 2048;
|
||||
|
||||
@GameTest(maxTicks = 24000)
|
||||
public void createPreparePersistAndReload(GameTestHelper helper) throws Exception {
|
||||
helper.assertTrue(Boolean.getBoolean("sanctuary.test.admission23"), "Admission fixture must be explicitly enabled");
|
||||
var generator = (SanctuaryChunkGenerator) helper.getLevel().getChunkSource().getGenerator();
|
||||
helper.assertTrue(generator.rootGeneration() == 23 && helper.getLevel().structureManager().shouldGenerateStructures(),
|
||||
"Admission fixture requires generation23 with native structures enabled");
|
||||
var scenario = new Scenario(helper, generator);
|
||||
if (scenario.reload) scenario.verifyReload(); else scenario.create();
|
||||
}
|
||||
|
||||
private static final class Scenario {
|
||||
final GameTestHelper helper;
|
||||
final ServerLevel level;
|
||||
final SanctuaryChunkGenerator generator;
|
||||
final ExpansionRuntime.Session session;
|
||||
final boolean reload = Boolean.getBoolean("sanctuary.test.expansionReload");
|
||||
final boolean reserveOnly = Boolean.getBoolean("sanctuary.test.admission23.reserveOnly");
|
||||
final int diameter = Integer.getInteger("sanctuary.test.admission23.diameter", 256);
|
||||
final String climate = System.getProperty("sanctuary.test.admission23.climate", "temperate");
|
||||
final String relief = System.getProperty("sanctuary.test.admission23.relief", "natural");
|
||||
final Path world, directory, journal, proof;
|
||||
final Map<String, Object> report = new LinkedHashMap<>();
|
||||
final List<Map<String, Object>> attempts = new ArrayList<>();
|
||||
ExpansionIsland reservation;
|
||||
List<String> captured;
|
||||
String certificate = "";
|
||||
long preparationStarted;
|
||||
boolean drained;
|
||||
|
||||
Scenario(GameTestHelper helper, SanctuaryChunkGenerator generator) {
|
||||
this.helper = helper; this.level = helper.getLevel(); this.generator = generator;
|
||||
helper.assertTrue(!reload || !reserveOnly, "Reserve-only costs require a fresh JVM and disposable world, not reload mode");
|
||||
session = ExpansionRuntime.session(level);
|
||||
world = level.getServer().getWorldPath(LevelResource.ROOT).toAbsolutePath().normalize();
|
||||
directory = world.resolve("data").resolve(generator.journalDirectory());
|
||||
journal = directory.resolve(ExpansionJournal.FILE_NAME); proof = world.resolve("admission23-create.json");
|
||||
report.put("process_id", ProcessHandle.current().pid()); report.put("world_directory", world.toString());
|
||||
report.put("world_seed", level.getSeed()); report.put("generation", generator.rootGeneration());
|
||||
report.put("deadline_seconds", 30); report.put("attempts", attempts);
|
||||
report.put("reserve_only", reserveOnly); report.put("requested_diameter", diameter);
|
||||
report.put("requested_climate", climate); report.put("requested_relief", relief);
|
||||
report.put("no_expansion_preview_before_create", true);
|
||||
}
|
||||
|
||||
void create() throws Exception {
|
||||
helper.assertTrue(!Files.exists(proof) && session.islands().size() == 1, "Use a new disposable world for the first admission pass");
|
||||
long remaining = ExpansionAdmission.searchDeadline() - System.nanoTime();
|
||||
helper.assertTrue(remaining > TimeUnit.SECONDS.toNanos(29) && remaining <= TimeUnit.SECONDS.toNanos(30),
|
||||
"Fixture uses the unchanged production30s deadline");
|
||||
byte[] untouchedJournal = Files.readAllBytes(journal);
|
||||
var initialIslands = session.islands();
|
||||
try {
|
||||
for (int draw = 0; draw < 3 && reservation == null; draw++) {
|
||||
String id = "admission_23_" + draw;
|
||||
captured = StructureCensusService.priorities(level);
|
||||
long started = System.nanoTime();
|
||||
try {
|
||||
reservation = session.create(id, "sanctuary", "east", climate, diameter, relief, DISTANCE);
|
||||
long elapsed = elapsedMillis(started);
|
||||
attempts.add(Map.of("id", id, "result", "reserved", "milliseconds", elapsed));
|
||||
helper.assertTrue(elapsed <= 31_000, "Real admission completes within its30s budget plus bounded clock/IO overhead");
|
||||
} catch (IllegalArgumentException | IOException refused) {
|
||||
attempts.add(Map.of("id", id, "result", String.valueOf(refused.getMessage()), "milliseconds", elapsedMillis(started)));
|
||||
helper.assertTrue(session.islands().equals(initialIslands) && Arrays.equals(untouchedJournal, Files.readAllBytes(journal)),
|
||||
"A refused request leaves no reservation or journal mutation");
|
||||
// A timeout, IO failure or other implementation error is not a new random draw.
|
||||
if (!"native_structure_unavailable".equals(refused.getMessage())) throw refused;
|
||||
}
|
||||
}
|
||||
helper.assertTrue(reservation != null, "A real expansion is admitted within three bounded feature refusals: " + diameter + " " + climate + " " + relief);
|
||||
helper.assertTrue(reservation.status().equals("reserved") && session.islands().size() == 2,
|
||||
"The transaction durably reserves exactly one child before preparation");
|
||||
helper.assertTrue(reservation.structurePriorities().equals(captured), "The stored profile equals the snapshot taken before create");
|
||||
helper.assertTrue(!ExpansionVoidReuse.requiresReload(level, reservation.id()), "Fresh distant terrain prepares without a void-reuse reload");
|
||||
certificate = certificate(reservation);
|
||||
verifyJournal(reservation);
|
||||
var snapshot = Files.readAllBytes(journal);
|
||||
var repeated = session.create(reservation.id(), "sanctuary", "east", climate, diameter, relief, DISTANCE);
|
||||
helper.assertTrue(repeated.equals(reservation) && Arrays.equals(snapshot, Files.readAllBytes(journal)) && session.islands().size() == 2,
|
||||
"Repeating create on the reserved ID does not reserve again or rewrite the profile");
|
||||
if (reserveOnly) {
|
||||
report.put("island", encode(reservation)); report.put("captured_priorities", captured);
|
||||
report.put("journal_sha256", ExpansionVoidCertificate.digest(Files.readString(journal)));
|
||||
report.put("certificate", certificate); report.put("certificate_required", !reservation.reuseToken().isEmpty());
|
||||
report.put("generator_codec", generatorCodec()); report.put("idempotent", true);
|
||||
report.put("native_guarantee_checked_by_session_create", true);
|
||||
report.put("full_generation_checked", false); report.put("passed", true);
|
||||
write("reserve-" + diameter + "-" + climate + "-" + relief);
|
||||
helper.succeed(); return;
|
||||
}
|
||||
preparationStarted = System.nanoTime();
|
||||
helper.runAfterDelay(5, this::awaitReady);
|
||||
} catch (Exception failure) { fail(failure); }
|
||||
}
|
||||
|
||||
void awaitReady() {
|
||||
try {
|
||||
var current = session.island(reservation.id());
|
||||
if (!current.status().equals("ready")) {
|
||||
helper.assertTrue(session.progress().matches(java.util.regex.Pattern.quote(reservation.id()) + ": \\d+/\\d+"),
|
||||
"Real preparation must keep progressing, not stop silently: " + session.progress());
|
||||
helper.runAfterDelay(5, this::awaitReady); return;
|
||||
}
|
||||
if (!drained) { drained = true; helper.runAfterDelay(5, this::awaitReady); return; }
|
||||
helper.assertTrue(current.equals(reservation.ready()), "Preparation changes only reserved→ready, preserving identity and priorities");
|
||||
verifyJournal(current);
|
||||
helper.assertTrue(certificate.equals(certificate(current)), "Preparation cannot rewrite the certified terrain identity");
|
||||
var starts = nativeStarts(current);
|
||||
helper.assertTrue(!starts.isEmpty(), "An admitted expansion really creates at least one registered native start");
|
||||
verifyCensus(current, starts);
|
||||
report.put("priorities_after_generation", StructureCensusService.priorities(level));
|
||||
byte[] readyJournal = Files.readAllBytes(journal);
|
||||
helper.assertTrue(session.create(current.id(), "sanctuary", "east", current.climate(), current.diameter(), current.relief(), DISTANCE).equals(current),
|
||||
"A ready ID stays idempotent even after census evidence has changed");
|
||||
helper.assertTrue(Arrays.equals(readyJournal, Files.readAllBytes(journal)), "Idempotence preserves exact journal bytes");
|
||||
StructureCensusService.flush(level.getServer());
|
||||
helper.assertTrue(level.getServer().saveEverything(true, true, true), "Persist actual FULL preparation and census before shutdown");
|
||||
report.put("preparation_milliseconds", elapsedMillis(preparationStarted));
|
||||
report.put("island", encode(current)); report.put("captured_priorities", captured);
|
||||
report.put("journal_sha256", ExpansionVoidCertificate.digest(Files.readString(journal)));
|
||||
report.put("certificate", certificate); report.put("certificate_required", !current.reuseToken().isEmpty());
|
||||
report.put("generator_codec", generatorCodec()); report.put("native_starts", tags(starts));
|
||||
report.put("native_count", starts.size()); report.put("census_verified", true); report.put("idempotent", true);
|
||||
report.put("passed", true); write("create");
|
||||
Files.writeString(proof, json()); helper.succeed();
|
||||
} catch (Exception failure) { fail(failure); }
|
||||
}
|
||||
|
||||
void verifyReload() throws Exception {
|
||||
try {
|
||||
var previous = JsonParser.parseString(Files.readString(proof)).getAsJsonObject();
|
||||
helper.assertTrue(previous.get("passed").getAsBoolean(), "Reload requires a successful first admission pass");
|
||||
helper.assertTrue(previous.get("process_id").getAsLong() != ProcessHandle.current().pid(), "Reload must use another JVM");
|
||||
helper.assertTrue(previous.get("world_directory").getAsString().equals(world.toString())
|
||||
&& previous.get("world_seed").getAsLong() == level.getSeed(), "Reload preserves the same development world and seed");
|
||||
var saved = ExpansionIsland.CODEC.parse(JsonOps.INSTANCE, previous.get("island")).getOrThrow();
|
||||
var current = session.island(saved.id());
|
||||
helper.assertTrue(current.equals(saved) && current.status().equals("ready") && session.islands().size() == 2,
|
||||
"Startup restores the ready child directly, without another create call");
|
||||
helper.assertTrue(generator.source().islands().equals(session.islands()), "Loaded world generation uses the journal snapshot");
|
||||
helper.assertTrue(ExpansionVoidCertificate.digest(Files.readString(journal)).equals(previous.get("journal_sha256").getAsString()),
|
||||
"Opening a ready journal preserves its exact bytes");
|
||||
verifyJournal(current);
|
||||
helper.assertTrue(previous.get("generator_codec").equals(generatorCodec()), "The generator codec survives a full process restart");
|
||||
helper.assertTrue(previous.get("certificate").getAsString().equals(certificate(current)), "The same certificate decision survives startup");
|
||||
var starts = nativeStarts(current);
|
||||
helper.assertTrue(previous.get("native_starts").equals(tags(starts)), "Native start identity, contents and reference counters survive reload");
|
||||
verifyCensus(current, starts);
|
||||
helper.assertTrue(session.progress().equals("idle"), "Ready regions do not restart their preparation job");
|
||||
report.put("island", encode(current)); report.put("native_count", starts.size());
|
||||
report.put("previous_process_id", previous.get("process_id").getAsLong());
|
||||
report.put("create_called", false); report.put("census_verified", true); report.put("passed", true);
|
||||
write("reload"); helper.succeed();
|
||||
} catch (Exception failure) { fail(failure); }
|
||||
}
|
||||
|
||||
private List<StructureStart> nativeStarts(ExpansionIsland island) {
|
||||
var registry = level.registryAccess().lookupOrThrow(Registries.STRUCTURE);
|
||||
var starts = new ArrayList<StructureStart>();
|
||||
for (var candidate : ExpansionStructures23.candidates(island)) {
|
||||
var chunk = level.getChunk(candidate.chunk().x(), candidate.chunk().z(), ChunkStatus.STRUCTURE_STARTS, true);
|
||||
for (var start : chunk.getAllStarts().values()) {
|
||||
if (!start.isValid()) continue;
|
||||
var id = registry.getKey(start.getStructure());
|
||||
if (id != null && id.getNamespace().equals("minecraft")
|
||||
&& ((NativeStructureMetadata23) (Object) start).sanctuary$native23() != null) starts.add(start);
|
||||
}
|
||||
}
|
||||
starts.sort(Comparator.comparingInt((StructureStart s) -> s.getChunkPos().x()).thenComparingInt(s -> s.getChunkPos().z())
|
||||
.thenComparing(s -> registry.getKey(s.getStructure()).toString()));
|
||||
return List.copyOf(starts);
|
||||
}
|
||||
|
||||
private void verifyCensus(ExpansionIsland island, List<StructureStart> starts) {
|
||||
var view = StructureCensusService.snapshot(level.getServer());
|
||||
helper.assertTrue(view.available(), "Passive structure census stays available through actual generation and reload");
|
||||
var region = view.regions().stream().filter(r -> r.island().equals(island.id())).findFirst().orElseThrow();
|
||||
helper.assertTrue(region.coverage().startsComplete() && region.coverage().fullChunks() == region.coverage().expectedChunks(),
|
||||
"The preparation queue certifies finite native-start and FULL coverage of the ready island");
|
||||
var registry = level.registryAccess().lookupOrThrow(Registries.STRUCTURE);
|
||||
for (var start : starts) {
|
||||
String id = registry.getKey(start.getStructure()).toString();
|
||||
var key = new StructureCensusMemory.SiteKey(level.dimension().identifier().toString(), id,
|
||||
start.getChunkPos().x(), 0, start.getChunkPos().z(), false);
|
||||
var indexed = view.evidence().sites().get(key);
|
||||
helper.assertTrue(indexed != null && view.evidence().generated(indexed), "The census records the real generated occurrence: " + id);
|
||||
var family = region.families().get(StructureCensusService.family(id));
|
||||
helper.assertTrue(family != null && family.presence() == StructureCensusService.Presence.PRESENT && family.generated() > 0,
|
||||
"A generated native family is present, never absent or unknown");
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyJournal(ExpansionIsland island) throws IOException {
|
||||
helper.assertTrue(ExpansionIsland.CODEC.parse(JsonOps.INSTANCE, encode(island)).getOrThrow().equals(island), "Every descriptor field survives CODEC roundtrip");
|
||||
var reopened = new ExpansionJournal(directory, level.getSeed(), generator.initialDiameter(), generator.rootGeneration());
|
||||
helper.assertTrue(reopened.islands().equals(session.islands()) && reopened.islands().contains(island),
|
||||
"A separate read of the durable journal agrees with the live session");
|
||||
}
|
||||
|
||||
private String certificate(ExpansionIsland island) throws IOException {
|
||||
if (island.reuseToken().isEmpty()) return ""; // Fully absent terrain needs no void-reuse certificate.
|
||||
String text = Files.readString(directory.resolve("void-reuse").resolve(island.reuseToken() + ".json"));
|
||||
helper.assertTrue(ExpansionVoidCertificate.digest(text).equals(island.reuseToken()), "Certificate content matches its immutable token");
|
||||
var body = JsonParser.parseString(text).getAsJsonObject();
|
||||
helper.assertTrue(ExpansionIsland.CODEC.parse(JsonOps.INSTANCE, body.get("island")).getOrThrow().equals(island.withReuseToken("").ready()),
|
||||
"Certificate binds the same immutable descriptor and priority profile");
|
||||
return text;
|
||||
}
|
||||
|
||||
private JsonArray tags(List<StructureStart> starts) {
|
||||
var result = new JsonArray(); var registry = level.registryAccess().lookupOrThrow(Registries.STRUCTURE);
|
||||
var context = StructurePieceSerializationContext.fromLevel(level);
|
||||
for (var start : starts) {
|
||||
var saved = new JsonObject(); saved.addProperty("id", registry.getKey(start.getStructure()).toString());
|
||||
saved.addProperty("x", start.getChunkPos().x()); saved.addProperty("z", start.getChunkPos().z());
|
||||
saved.addProperty("nbt", start.createTag(context, start.getChunkPos()).toString()); result.add(saved);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private com.google.gson.JsonElement encode(ExpansionIsland island) { return ExpansionIsland.CODEC.encodeStart(JsonOps.INSTANCE, island).getOrThrow(); }
|
||||
private com.google.gson.JsonElement generatorCodec() {
|
||||
return ChunkGenerator.CODEC.encodeStart(RegistryOps.create(JsonOps.INSTANCE, level.registryAccess()), generator).getOrThrow();
|
||||
}
|
||||
private String json() { return new GsonBuilder().setPrettyPrinting().create().toJson(report); }
|
||||
private void write(String name) throws IOException {
|
||||
var output = Path.of("diagnostics", "admission23"); Files.createDirectories(output); Files.writeString(output.resolve(name + ".json"), json());
|
||||
}
|
||||
private void fail(Exception failure) {
|
||||
report.put("passed", false); report.put("failure", failure.toString()); report.put("progress", session.progress());
|
||||
try { write("failure"); } catch (IOException ignored) {}
|
||||
throw new IllegalStateException("Production admission23 failed", failure);
|
||||
}
|
||||
}
|
||||
private static long elapsedMillis(long started) { return TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - started); }
|
||||
}
|
||||
+452
@@ -0,0 +1,452 @@
|
||||
package fr.koka.sanctuary.gametest;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import fr.koka.sanctuary.SanctuaryMod;
|
||||
import fr.koka.sanctuary.worldgen.SanctuaryChunkGenerator;
|
||||
import fr.koka.sanctuary.worldgen.city.LostCityRenderer;
|
||||
import fr.koka.sanctuary.worldgen.heritage.HeritagePiece19;
|
||||
import fr.koka.sanctuary.worldgen.heritage.HeritagePlan19;
|
||||
import fr.koka.sanctuary.worldgen.heritage.HeritageRenderer19;
|
||||
import fr.koka.sanctuary.worldgen.heritage.HeritageStructures19;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.HexFormat;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import net.fabricmc.fabric.api.gametest.v1.GameTest;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.HolderSet;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.gametest.framework.GameTestHelper;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.DoorBlock;
|
||||
import net.minecraft.world.level.block.TrapDoorBlock;
|
||||
import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureStart;
|
||||
import net.minecraft.world.level.levelgen.structure.pieces.StructurePieceSerializationContext;
|
||||
import net.minecraft.world.level.storage.LevelResource;
|
||||
import net.minecraft.world.level.storage.loot.LootParams;
|
||||
import net.minecraft.world.level.storage.loot.LootTable;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
/** Native creation/reload proof confined to a disposable generation19 starter island. */
|
||||
public final class Heritage19WorldGameTests {
|
||||
private static final Direction[] HORIZONTAL = {Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST};
|
||||
@GameTest(maxTicks = 12000)
|
||||
public void heritagePersistsWithRealDestinations(GameTestHelper helper) {
|
||||
helper.assertTrue(helper.getLevel().getChunkSource().getGenerator() instanceof SanctuaryChunkGenerator,
|
||||
"The heritage proof requires a Sanctuary generator");
|
||||
var generator = (SanctuaryChunkGenerator) helper.getLevel().getChunkSource().getGenerator();
|
||||
helper.assertTrue(generator.rootGeneration() == 19, "Use a fresh generation19 test world; do not convert an old save");
|
||||
new Scenario(helper, generator, Boolean.getBoolean("sanctuary.test.expansionReload")).advance();
|
||||
}
|
||||
private static final class Scenario {
|
||||
final GameTestHelper helper;
|
||||
final ServerLevel level;
|
||||
final SanctuaryChunkGenerator generator;
|
||||
final HeritagePlan19 plan;
|
||||
final boolean reload;
|
||||
final Map<String, Object> report = new LinkedHashMap<>();
|
||||
final List<ChunkPos> chunks = new ArrayList<>();
|
||||
final List<StructureStart> starts = new ArrayList<>();
|
||||
JsonObject previous;
|
||||
BlockPos gold;
|
||||
int nextChunk;
|
||||
boolean prepared;
|
||||
Scenario(GameTestHelper helper, SanctuaryChunkGenerator generator, boolean reload) {
|
||||
this.helper = helper; this.level = helper.getLevel(); this.generator = generator; this.reload = reload;
|
||||
this.plan = generator.heritagePlan19();
|
||||
report.put("seed", level.getSeed()); report.put("size", generator.initialDiameter());
|
||||
report.put("process_id", ProcessHandle.current().pid()); report.put("world_directory", world(level).toString());
|
||||
report.put("experimental_structures", generator.experimentalStructures());
|
||||
report.put("structures_enabled", level.structureManager().shouldGenerateStructures());
|
||||
report.put("scope", "Native local starts, saved sites and routes, player-sized entrances, supports and unopened chests on the starter island. "
|
||||
+ "All14 tool tables are sampled separately without consuming a saved chest. Door states are restored after traversal. "
|
||||
+ "No personal save or expansion is opened; one disposable outer-wall edit is checked in a second JVM. "
|
||||
+ "Missing rails are intentional; this proof checks walking and saved rail shapes, not an uninterrupted minecart journey.");
|
||||
}
|
||||
void advance() {
|
||||
try {
|
||||
if (!prepared) { report.put("stage", "prepare"); prepare(); prepared = true; if (plan.isEmpty()) { finishDisabled(); return; } }
|
||||
if (nextChunk < chunks.size()) {
|
||||
report.put("stage", "load_full_chunks"); var pos = chunks.get(nextChunk++);
|
||||
helper.assertTrue(level.getChunk(pos.x(), pos.z(), ChunkStatus.FULL, true) instanceof LevelChunk,
|
||||
"Heritage footprint must reach native FULL: " + pos);
|
||||
if (nextChunk % 20 == 0) SanctuaryMod.LOGGER.info("Heritage19 loaded {}/{} footprint chunks", nextChunk, chunks.size());
|
||||
helper.runAtTickTime(helper.getTick() + 1, this::advance); return;
|
||||
}
|
||||
report.put("stage", "verify_native_geometry"); verifyPlaced(); report.put("passed", true);
|
||||
if (!reload) {
|
||||
helper.assertTrue(gold != null && level.getBlockState(gold).isCollisionShapeFullBlock(level, gold), "Gold witness must replace a solid wall away from circulation");
|
||||
level.setBlock(gold, Blocks.GOLD_BLOCK.defaultBlockState(), 3); report.put("gold_witness", coords(gold));
|
||||
helper.assertTrue(level.getServer().saveEverything(true, true, true), "Flush native starts, unopened loot and the wall edit");
|
||||
report.put("world_flushed_before_shutdown", true);
|
||||
} else {
|
||||
helper.assertTrue(level.getBlockState(gold).is(Blocks.GOLD_BLOCK), "Reload replaced the player's wall edit");
|
||||
report.put("gold_witness", coords(gold)); report.put("gold_witness_preserved", true);
|
||||
}
|
||||
write(level, report, reload); helper.succeed();
|
||||
} catch (Exception failure) {
|
||||
report.put("passed", false); report.put("failure", failure.toString());
|
||||
try { write(level, report, reload); } catch (IOException ignored) { }
|
||||
throw new IllegalStateException("Heritage19 native " + (reload ? "reload" : "creation") + " failed", failure);
|
||||
}
|
||||
}
|
||||
void prepare() throws IOException {
|
||||
var ops = RegistryOps.create(JsonOps.INSTANCE, level.registryAccess());
|
||||
var encoded = ChunkGenerator.CODEC.encodeStart(ops, generator).getOrThrow();
|
||||
var decoded = ChunkGenerator.CODEC.parse(ops, encoded).getOrThrow();
|
||||
helper.assertTrue(decoded instanceof SanctuaryChunkGenerator copy && copy.rootGeneration() == 19
|
||||
&& copy.experimentalStructures() == generator.experimentalStructures(), "Generation19 codec lost its experimental switch");
|
||||
report.put("generator_codec", encoded); report.put("plan_sha256", planHash(plan));
|
||||
report.put("planned_sites", plan.sites().stream().map(site -> Map.of("id", site.id(), "kind", site.kind().name(),
|
||||
"entry", coords(HeritagePiece19.locator(site)), "floor_y", site.floorY(), "foundation_depth", site.foundationDepth(), "footings", site.supports().size())).toList());
|
||||
report.put("planned_links", plan.links().stream().map(link -> Map.of("id", link.id(), "from", link.fromId(), "to", link.toId(), "kind", link.kind().name(), "length", link.path().size(), "path", pathCoords(link))).toList());
|
||||
report.put("planning_samples", plan.samples()); report.put("planning_columns", plan.columns()); report.put("planning_diagnostics", plan.diagnostics());
|
||||
helper.assertTrue(plan.samples() <= HeritagePlan19.MAX_SAMPLES && plan.columns() <= HeritagePlan19.MAX_COLUMNS, "Heritage planning exceeded its budget");
|
||||
verifyLootTables(helper, report);
|
||||
if (reload) {
|
||||
previous = JsonParser.parseString(Files.readString(proof(level))).getAsJsonObject();
|
||||
helper.assertTrue(previous.get("passed").getAsBoolean() && previous.get("world_flushed_before_shutdown").getAsBoolean(), "Reload needs a successful flushed creation proof");
|
||||
helper.assertTrue(previous.get("process_id").getAsLong() != ProcessHandle.current().pid(), "Reload must use a second JVM");
|
||||
helper.assertTrue(previous.get("seed").getAsLong() == level.getSeed() && previous.get("size").getAsInt() == generator.initialDiameter()
|
||||
&& previous.get("world_directory").getAsString().equals(world(level).toString()), "Reload selected another world");
|
||||
helper.assertTrue(previous.get("generator_codec").equals(encoded) && previous.get("plan_sha256").getAsString().equals(planHash(plan)), "Saved settings or planned identities changed on reload");
|
||||
if (previous.has("gold_witness")) gold = readPos(previous.getAsJsonArray("gold_witness"));
|
||||
}
|
||||
if (!generator.experimentalStructures() || !level.structureManager().shouldGenerateStructures()) {
|
||||
helper.assertTrue(plan.isEmpty() && plan.segments().isEmpty() && plan.links().isEmpty(), "Disabled generation published heritage geometry"); return;
|
||||
}
|
||||
helper.assertTrue(!plan.isEmpty(), "Enabled reference island has no heritage site");
|
||||
report.put("present_site_kinds", plan.sites().stream().map(s -> s.kind().name()).distinct().sorted().toList());
|
||||
report.put("missing_site_kinds", java.util.Arrays.stream(HeritagePlan19.Kind.values()).filter(k -> plan.sites().stream().noneMatch(s -> s.kind() == k)).map(Enum::name).toList());
|
||||
var structure = level.registryAccess().lookupOrThrow(Registries.STRUCTURE).getOrThrow(HeritageStructures19.KEY);
|
||||
var origins = new HashSet<ChunkPos>(); var uniqueChunks = new HashSet<ChunkPos>();
|
||||
plan.sites().forEach(s -> origins.add(new ChunkPos(s.startChunkX(), s.startChunkZ())));
|
||||
plan.segments().forEach(s -> origins.add(new ChunkPos(s.startChunkX(), s.startChunkZ())));
|
||||
for (var origin : origins.stream().sorted(Comparator.comparingInt(ChunkPos::x).thenComparingInt(ChunkPos::z)).toList()) {
|
||||
var chunk = level.getChunk(origin.x(), origin.z(), ChunkStatus.STRUCTURE_STARTS, true);
|
||||
var start = chunk.getStartForStructure(structure.value());
|
||||
helper.assertTrue(start != null && start.isValid(), "Accepted site/route has no native start at " + origin); starts.add(start);
|
||||
for (var piece : start.getPieces()) {
|
||||
helper.assertTrue(piece instanceof HeritagePiece19, "Heritage loaded a foreign piece type");
|
||||
var box = piece.getBoundingBox();
|
||||
helper.assertTrue(Math.abs((long) (box.minX() >> 4) - origin.x()) <= 7 && Math.abs((long) (box.maxX() >> 4) - origin.x()) <= 7
|
||||
&& Math.abs((long) (box.minZ() >> 4) - origin.z()) <= 7 && Math.abs((long) (box.maxZ() >> 4) - origin.z()) <= 7, "Native start references a distant route endpoint");
|
||||
box.intersectingChunks().forEach(uniqueChunks::add);
|
||||
}
|
||||
}
|
||||
for (var site : plan.sites()) uniqueChunks.add(ChunkPos.containing(HeritagePiece19.locator(site)));
|
||||
for (var link : plan.links()) for (var point : link.path()) uniqueChunks.add(new ChunkPos(point.x() >> 4, point.z() >> 4));
|
||||
helper.assertTrue(uniqueChunks.size() <= 1024, "Bounded proof footprint exceeds1024 chunks");
|
||||
chunks.addAll(uniqueChunks.stream().sorted(Comparator.comparingInt(ChunkPos::x).thenComparingInt(ChunkPos::z)).toList());
|
||||
}
|
||||
void finishDisabled() throws IOException {
|
||||
var structure = level.registryAccess().lookupOrThrow(Registries.STRUCTURE).getOrThrow(HeritageStructures19.KEY);
|
||||
var start = level.getChunk(0, 0, ChunkStatus.STRUCTURE_STARTS, true).getStartForStructure(structure.value());
|
||||
helper.assertTrue(start == null || !start.isValid(), "Disabled heritage emitted a native start");
|
||||
helper.assertTrue(generator.findNearestMapStructure(level, HolderSet.direct(structure), new BlockPos(0, 250, 0), 100, false) == null, "Disabled heritage is locatable");
|
||||
report.put("empty_plan_verified", true); report.put("passed", true);
|
||||
if (!reload) { helper.assertTrue(level.getServer().saveEverything(true, true, true), "Save disabled experiment setting"); report.put("world_flushed_before_shutdown", true); }
|
||||
write(level, report, reload); helper.succeed();
|
||||
}
|
||||
void verifyPlaced() {
|
||||
var structure = level.registryAccess().lookupOrThrow(Registries.STRUCTURE).getOrThrow(HeritageStructures19.KEY);
|
||||
var context = StructurePieceSerializationContext.fromLevel(level); var summaries = new ArrayList<Map<String, Object>>();
|
||||
int blocks = 0, chests = 0, pieces = 0, supports = 0;
|
||||
for (var start : starts) {
|
||||
var origin = start.getChunkPos(); var saved = start.createTag(context, origin); String nativeHash = hash(saved.toString());
|
||||
var copy = StructureStart.loadStaticStart(context, saved, level.getSeed());
|
||||
helper.assertTrue(copy != null && copy.isValid() && copy.createTag(context, origin).equals(saved), "Native start failed an exact NBT roundtrip");
|
||||
var expectedPayloads = new HashSet<net.minecraft.nbt.CompoundTag>();
|
||||
plan.sites().stream().filter(s -> s.startChunkX() == origin.x() && s.startChunkZ() == origin.z()).forEach(s -> expectedPayloads.add(HeritagePiece19.encodeSite(s)));
|
||||
plan.segments().stream().filter(s -> s.startChunkX() == origin.x() && s.startChunkZ() == origin.z()).forEach(s -> expectedPayloads.add(HeritagePiece19.encodeSegment(s)));
|
||||
var actualPayloads = new HashSet<net.minecraft.nbt.CompoundTag>();
|
||||
if (reload) {
|
||||
JsonObject prior = null;
|
||||
for (var value : previous.getAsJsonArray("starts")) { var item = value.getAsJsonObject(); var at = item.getAsJsonArray("start_chunk"); if (at.get(0).getAsInt() == origin.x() && at.get(1).getAsInt() == origin.z()) prior = item; }
|
||||
helper.assertTrue(prior != null && prior.get("native_start_sha256").getAsString().equals(nativeHash), "Reload changed saved geometry or native reference count");
|
||||
}
|
||||
var loot = new ArrayList<Map<String, Object>>();
|
||||
for (var value : start.getPieces()) {
|
||||
var piece = (HeritagePiece19) value; pieces++;
|
||||
var tag = piece.createTag(context); var restored = new HeritagePiece19(context, tag);
|
||||
helper.assertTrue(restored.createTag(context).equals(tag), "Saved piece parameters changed on native load");
|
||||
actualPayloads.add(tag.getCompound("SanctuaryHeritage").orElseThrow());
|
||||
var corrupt = tag.copy(); corrupt.getCompound("SanctuaryHeritage").orElseThrow().putInt("Schema", 20);
|
||||
boolean rejected = false; try { new HeritagePiece19(context, corrupt); } catch (IllegalArgumentException expected) { rejected = true; }
|
||||
helper.assertTrue(rejected, "Unknown schema must fail closed");
|
||||
piece.getBoundingBox().intersectingChunks().forEach(at -> helper.assertTrue(level.getChunk(at.x(), at.z(), ChunkStatus.FULL, true)
|
||||
.getReferencesForStructure(structure.value()).contains(origin.pack()), "FULL chunk lost its native structure reference"));
|
||||
var expected = rendered(piece); blocks += expected.blocks().size();
|
||||
for (var entry : expected.blocks().entrySet()) {
|
||||
var at = entry.getKey(); var wanted = entry.getValue(); helper.assertTrue(piece.getBoundingBox().isInside(at), "Renderer escaped saved bounds");
|
||||
if (reload && at.equals(gold)) continue;
|
||||
helper.assertTrue(level.getBlockState(at).is(wanted.getBlock()), "Clipping or decoration changed heritage at " + at + ": expected " + wanted + " got " + level.getBlockState(at));
|
||||
helper.assertTrue(!wanted.is(Blocks.SPAWNER), "Heritage must not create spawners");
|
||||
}
|
||||
if (piece.isSite()) {
|
||||
supports += verifySiteBearing(helper, generator, plan, piece.site());
|
||||
if (!reload && gold == null) {
|
||||
gold = expected.blocks().entrySet().stream().filter(e -> isOuterWall(piece.site(), e.getKey()) && e.getValue().isCollisionShapeFullBlock(level, e.getKey()))
|
||||
.map(Map.Entry::getKey).sorted(Comparator.<BlockPos>comparingInt(p -> p.getY()).thenComparingInt(p -> p.getX()).thenComparingInt(p -> p.getZ())).findFirst().orElse(null);
|
||||
}
|
||||
} else for (var cell : piece.segment().cells()) { supports++; assertRock(helper, new BlockPos(cell.x(), cell.minY() - 1, cell.z())); }
|
||||
for (var chest : expected.chests()) {
|
||||
helper.assertTrue(level.getBlockEntity(chest.position()) instanceof RandomizableContainerBlockEntity, "Deferred chest is missing");
|
||||
var entity = (RandomizableContainerBlockEntity) level.getBlockEntity(chest.position());
|
||||
helper.assertTrue(entity.getLootTable() != null && entity.getLootTable().equals(chest.table()) && entity.getLootTableSeed() == chest.seed(), "Deferred loot table/seed was lost or consumed");
|
||||
if (piece.isSite()) helper.assertTrue(chest.table().equals(lootKey(piece.site().kind())), "Site uses another kind's tool table");
|
||||
loot.add(Map.of("position", coords(chest.position()), "table", chest.table().identifier().toString(), "seed", chest.seed())); chests++;
|
||||
}
|
||||
}
|
||||
helper.assertTrue(actualPayloads.equals(expectedPayloads) && start.getPieces().size() == expectedPayloads.size(), "Native start lost or duplicated planned pieces");
|
||||
summaries.add(Map.of("start_chunk", List.of(origin.x(), origin.z()), "native_start_sha256", nativeHash, "pieces", start.getPieces().size(), "unopened_chests", loot));
|
||||
}
|
||||
report.put("starts", summaries); report.put("native_pieces", pieces); report.put("native_blocks_checked", blocks);
|
||||
report.put("full_chunks_checked", chunks.size()); report.put("rock_supports_checked", supports); report.put("unopened_deferred_chests", chests);
|
||||
report.put("stage", "verify_site_routes"); var sites = new ArrayList<Map<String, Object>>(); for (var site : plan.sites()) sites.add(verifyAccess(helper, site)); report.put("native_sites", sites);
|
||||
report.put("stage", "verify_read_only_landings");
|
||||
report.put("read_only_landmarks", verifyReadOnlyLandings(helper, generator, plan));
|
||||
report.put("stage", "verify_island_routes"); report.put("native_links", verifyLinks(helper, plan));
|
||||
int greatestSpan = plan.links().stream().mapToInt(Heritage19WorldGameTests::routeSpan).max().orElse(0);
|
||||
report.put("greatest_single_route_span", greatestSpan);
|
||||
if (level.getSeed() == 0 && generator.initialDiameter() == 724) {
|
||||
int requiredSpan = generator.initialDiameter() / 4;
|
||||
report.put("reference_minimum_route_span", requiredSpan);
|
||||
helper.assertTrue(greatestSpan >= requiredSpan, "Seed0 Medium must demonstrate an island-scale route spanning at least "
|
||||
+ requiredSpan + " blocks on X or Z; got " + greatestSpan);
|
||||
}
|
||||
var located = generator.findNearestMapStructure(level, HolderSet.direct(structure), new BlockPos(0, 250, 0), 100, false);
|
||||
helper.assertTrue(located != null && located.getSecond().is(HeritageStructures19.KEY) && plan.sites().stream().anyMatch(s -> HeritagePiece19.locator(s).equals(located.getFirst())), "Locate must lead to a real exterior site entry");
|
||||
report.put("locate", coords(located.getFirst()));
|
||||
}
|
||||
}
|
||||
private record Chest(BlockPos position, ResourceKey<LootTable> table, long seed) {}
|
||||
private record Rendered(Map<BlockPos, BlockState> blocks, List<Chest> chests) {}
|
||||
private static Rendered rendered(HeritagePiece19 piece) {
|
||||
var blocks = new HashMap<BlockPos, BlockState>(); var chests = new ArrayList<Chest>();
|
||||
int x0 = piece.isSite() ? piece.site().minX() : piece.segment().minX();
|
||||
int y0 = piece.isSite() ? piece.site().floorY() : piece.segment().minY();
|
||||
int z0 = piece.isSite() ? piece.site().minZ() : piece.segment().minZ();
|
||||
var writer = new LostCityRenderer.BlockWriter() {
|
||||
@Override public void set(int x, int y, int z, BlockState state) { blocks.put(new BlockPos(x0 + x, y0 + y, z0 + z), state); }
|
||||
@Override public void chest(int x, int y, int z, ResourceKey<LootTable> table, long seed) {
|
||||
var at = new BlockPos(x0 + x, y0 + y, z0 + z); blocks.put(at, Blocks.CHEST.defaultBlockState()); chests.add(new Chest(at, table, RandomSource.create(seed).nextLong()));
|
||||
}
|
||||
};
|
||||
if (piece.isSite()) HeritageRenderer19.render(piece.site(), writer); else HeritageRenderer19.renderSegment(piece.segment(), writer);
|
||||
return new Rendered(blocks, chests);
|
||||
}
|
||||
private static boolean isOuterWall(HeritagePlan19.Site site, BlockPos pos) {
|
||||
return pos.getY() >= site.floorY() + 2 && pos.getY() <= site.floorY() + 3
|
||||
&& (pos.getX() == site.minX() + 2 || pos.getX() == site.maxX() - 2 || pos.getZ() == site.minZ() + 2 || pos.getZ() == site.maxZ() - 2)
|
||||
&& Math.abs(pos.getX() - site.entry().x()) + Math.abs(pos.getZ() - site.entry().z()) > 6;
|
||||
}
|
||||
private static Map<String, Object> verifyAccess(GameTestHelper helper, HeritagePlan19.Site site) {
|
||||
var level = helper.getLevel(); var expected = rendered(new HeritagePiece19(site)); var doors = new HashMap<BlockPos, BlockState>();
|
||||
expected.blocks().forEach((at, state) -> {
|
||||
if ((state.getBlock() instanceof DoorBlock || state.getBlock() instanceof TrapDoorBlock) && state.hasProperty(BlockStateProperties.OPEN)) doors.put(at, level.getBlockState(at));
|
||||
});
|
||||
doors.forEach((at, state) -> level.setBlock(at, state.setValue(BlockStateProperties.OPEN, true), 2));
|
||||
try {
|
||||
var entry = HeritagePiece19.locator(site);
|
||||
Predicate<BlockPos> inside = p -> p.equals(entry) || p.getX() >= site.minX() && p.getX() <= site.maxX()
|
||||
&& p.getZ() >= site.minZ() && p.getZ() <= site.maxZ() && p.getY() >= site.floorY() - 4 && p.getY() < site.maxY();
|
||||
var reached = walk(helper, entry, inside); int targets = 0;
|
||||
for (var target : HeritageRenderer19.targets(site)) {
|
||||
var at = new BlockPos(site.minX() + target.x(), site.floorY() + target.y(), site.minZ() + target.z());
|
||||
helper.assertTrue(reached.contains(at), "Site " + site.id() + " cannot reach " + target.name() + " at " + at); targets++;
|
||||
}
|
||||
return Map.of("id", site.id(), "kind", site.kind().name(), "entry", coords(entry), "standing_cells", reached.size(), "walkable_targets", targets);
|
||||
} finally { doors.forEach((at, state) -> level.setBlock(at, state, 2)); }
|
||||
}
|
||||
private static List<Map<String, Object>> verifyLinks(GameTestHelper helper, HeritagePlan19 plan) {
|
||||
helper.assertTrue(!plan.links().isEmpty(), "Reference island needs a real route between accepted destinations");
|
||||
var entries = new HashMap<String, HeritagePlan19.Entry>(); plan.sites().forEach(s -> entries.put(s.id(), s.entry())); plan.landmarks().forEach(s -> entries.put(s.id(), s.entry()));
|
||||
var cells = new HashMap<Long, HeritagePlan19.Cell>(); plan.segments().forEach(s -> s.cells().forEach(c -> cells.put(column(c.x(), c.z()), c)));
|
||||
var result = new ArrayList<Map<String, Object>>();
|
||||
for (var link : plan.links()) {
|
||||
var from = entries.get(link.fromId()); var to = entries.get(link.toId());
|
||||
helper.assertTrue(from != null && to != null, "Route points to an absent destination");
|
||||
var first = link.path().getFirst(); var last = link.path().getLast();
|
||||
helper.assertTrue(first.x() == from.x() && first.z() == from.z() && first.floorY() + 1 == from.y()
|
||||
&& last.x() == to.x() && last.z() == to.z() && last.floorY() + 1 == to.y(), "Route does not meet its real entrances");
|
||||
int present = 0, missing = 0;
|
||||
for (int i = 0; i < link.path().size(); i++) {
|
||||
var point = link.path().get(i); var at = new BlockPos(point.x(), point.floorY() + 1, point.z());
|
||||
helper.assertTrue(standable(helper.getLevel(), at), "Ballast route " + link.id() + " is blocked at " + at);
|
||||
if (i > 0) { var prior = link.path().get(i - 1); if (point.floorY() > prior.floorY()) helper.assertTrue(clearBody(helper.getLevel(), new BlockPos(prior.x(), prior.floorY() + 2, prior.z())), "Route slope cannot be climbed by a player"); }
|
||||
var cell = cells.get(column(point.x(), point.z()));
|
||||
if (cell != null && cell.rail() != HeritagePlan19.Rail.NONE) {
|
||||
var actual = helper.getLevel().getBlockState(at);
|
||||
if (cell.railPresent()) {
|
||||
helper.assertTrue(actual.is(Blocks.RAIL), "Saved existing rail disappeared");
|
||||
helper.assertTrue(actual.getValue(BlockStateProperties.RAIL_SHAPE).name().equals(cell.rail().name()), "Native rail update changed the intended slope or curve at " + at); present++;
|
||||
} else { helper.assertTrue(!actual.is(Blocks.RAIL), "An intentionally missing rail regenerated"); missing++; }
|
||||
}
|
||||
}
|
||||
int spanX = link.path().stream().mapToInt(HeritagePlan19.Point::x).max().orElseThrow() - link.path().stream().mapToInt(HeritagePlan19.Point::x).min().orElseThrow();
|
||||
int spanZ = link.path().stream().mapToInt(HeritagePlan19.Point::z).max().orElseThrow() - link.path().stream().mapToInt(HeritagePlan19.Point::z).min().orElseThrow();
|
||||
result.add(Map.of("id", link.id(), "from", link.fromId(), "to", link.toId(), "kind", link.kind().name(), "length", link.path().size(),
|
||||
"span_x", spanX, "span_z", spanZ, "existing_rails", present, "deliberately_missing_rails", missing, "path", pathCoords(link)));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private static int routeSpan(HeritagePlan19.Link link) {
|
||||
int spanX = link.path().stream().mapToInt(HeritagePlan19.Point::x).max().orElseThrow()
|
||||
- link.path().stream().mapToInt(HeritagePlan19.Point::x).min().orElseThrow();
|
||||
int spanZ = link.path().stream().mapToInt(HeritagePlan19.Point::z).max().orElseThrow()
|
||||
- link.path().stream().mapToInt(HeritagePlan19.Point::z).min().orElseThrow();
|
||||
return Math.max(spanX, spanZ);
|
||||
}
|
||||
private static List<List<Integer>> pathCoords(HeritagePlan19.Link link) {
|
||||
return link.path().stream().map(point -> List.of(point.x(), point.floorY(), point.z())).toList();
|
||||
}
|
||||
private static int verifySiteBearing(GameTestHelper helper, SanctuaryChunkGenerator generator, HeritagePlan19 plan, HeritagePlan19.Site site) {
|
||||
int checked = 0;
|
||||
// The planner certifies a nine-point bearing grid, either directly below its slab or below a saved short footing.
|
||||
for (int dx : new int[] {1, 8, 15}) for (int dz : new int[] {1, 8, 15}) {
|
||||
int x = site.minX() + dx, z = site.minZ() + dz;
|
||||
var support = site.supports().stream().filter(s -> s.x() == x && s.z() == z).findFirst();
|
||||
int bottom = support.map(HeritagePlan19.Support::minY).orElse(site.minY());
|
||||
for (int below = 1; below <= 2; below++) {
|
||||
var at = new BlockPos(x, bottom - below, z); assertRock(helper, at);
|
||||
helper.assertTrue(plan.protects(at.getX(), at.getY(), at.getZ()) && generator.protectsCityDecoration(at),
|
||||
"Site's certified bearing layer is not published in the decoration mask: " + site.id() + " at " + at);
|
||||
helper.assertTrue(!plan.contains(at.getX(), at.getY(), at.getZ()), "Original bearing rock became a writable heritage volume: " + at);
|
||||
checked++;
|
||||
}
|
||||
}
|
||||
return checked;
|
||||
}
|
||||
private static List<Map<String, Object>> verifyReadOnlyLandings(GameTestHelper helper, SanctuaryChunkGenerator generator, HeritagePlan19 plan) {
|
||||
var used = new HashSet<String>(); plan.links().forEach(link -> { used.add(link.fromId()); used.add(link.toId()); });
|
||||
var result = new ArrayList<Map<String, Object>>();
|
||||
for (var landmark : plan.landmarks()) if (used.contains(landmark.id())) {
|
||||
var e = landmark.entry(); int checked = 0;
|
||||
for (int side = -1; side <= 1; side++) {
|
||||
int x = e.x() + ((e.facing() & 1) == 0 ? side : 0), z = e.z() + ((e.facing() & 1) == 1 ? side : 0);
|
||||
for (int y = e.y() - 2; y <= e.y() + 2; y++) {
|
||||
var at = new BlockPos(x, y, z);
|
||||
helper.assertTrue(plan.protects(x, y, z) && generator.protectsCityDecoration(at), "Read-only arrival lost its decoration mask: " + landmark.id() + " at " + at);
|
||||
helper.assertTrue(!plan.contains(x, y, z), "Heritage gained write ownership of a historical arrival: " + landmark.id() + " at " + at);
|
||||
if (y == e.y() - 1) assertRock(helper, at);
|
||||
if (y >= e.y()) helper.assertTrue(helper.getLevel().getBlockState(at).isAir(), "Decoration obstructed a certified historical arrival: " + at);
|
||||
checked++;
|
||||
}
|
||||
}
|
||||
result.add(Map.of("id", landmark.id(), "entry", List.of(e.x(), e.y(), e.z()), "read_only_cells", checked));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private static void assertRock(GameTestHelper helper, BlockPos at) {
|
||||
helper.assertTrue(helper.getLevel().getBlockState(at).isSolid() && helper.getLevel().getFluidState(at).isEmpty(), "Lost original rock bearing at " + at);
|
||||
}
|
||||
private static void verifyLootTables(GameTestHelper helper, Map<String, Object> report) {
|
||||
var result = new ArrayList<Map<String, Object>>(); var level = helper.getLevel();
|
||||
var params = new LootParams.Builder(level).withParameter(LootContextParams.ORIGIN, new Vec3(0, 160, 0)).create(LootContextParamSets.CHEST);
|
||||
for (var kind : HeritagePlan19.Kind.values()) {
|
||||
var table = level.getServer().reloadableRegistries().getLootTable(lootKey(kind));
|
||||
helper.assertTrue(table != LootTable.EMPTY, "Heritage tool table did not load: " + kind);
|
||||
for (long seed : new long[] {0, 42, -1}) helper.assertTrue(table.getRandomItems(params, seed).stream().anyMatch(stack -> stack.is(tool(kind))), "Tool table is empty or lacks its expected primary tool: " + kind);
|
||||
result.add(Map.of("kind", kind.name(), "table", lootKey(kind).identifier().toString(), "sampled_seeds", List.of(0, 42, -1)));
|
||||
}
|
||||
report.put("tool_tables_sampled_separately", result);
|
||||
}
|
||||
private static ResourceKey<LootTable> lootKey(HeritagePlan19.Kind kind) { return ResourceKey.create(Registries.LOOT_TABLE, SanctuaryMod.id("chests/heritage19/" + kind.name().toLowerCase(Locale.ROOT))); }
|
||||
private static Item tool(HeritagePlan19.Kind kind) {
|
||||
return switch (kind) {
|
||||
case OBSERVATORY -> Items.SPYGLASS;
|
||||
case POST_OFFICE, EXPEDITION_OFFICE, RADIO_RELAY -> Items.COMPASS;
|
||||
case SUBSTATION, IMPOSSIBLE_SERVICE -> Items.CLOCK;
|
||||
case FREIGHT_STATION -> Items.MINECART;
|
||||
case COMMUNAL_DEPOT -> Items.IRON_AXE;
|
||||
case RAIL_WORKSHOP -> Items.IRON_PICKAXE;
|
||||
case PUMP_STATION -> Items.BUCKET;
|
||||
case GREENHOUSE -> Items.IRON_HOE;
|
||||
case VOID_DOCK -> Items.LEAD;
|
||||
case PHOTO_CLUB -> Items.BOOK;
|
||||
case CONSTRUCTION_REFUGE -> Items.IRON_SHOVEL;
|
||||
};
|
||||
}
|
||||
private static Set<BlockPos> walk(GameTestHelper helper, BlockPos start, Predicate<BlockPos> inside) {
|
||||
var level = helper.getLevel(); helper.assertTrue(inside.test(start) && standable(level, start), "Blocked or unsupported exterior entrance: " + start);
|
||||
var seen = new HashSet<BlockPos>(); var queue = new ArrayDeque<BlockPos>(); seen.add(start); queue.add(start);
|
||||
while (!queue.isEmpty()) {
|
||||
var pos = queue.removeFirst();
|
||||
for (var direction : HORIZONTAL) for (int dy = -1; dy <= 1; dy++) {
|
||||
var next = pos.relative(direction).offset(0, dy, 0);
|
||||
if (!inside.test(next) || dy > 0 && !clearBody(level, pos.above())) continue;
|
||||
if (standable(level, next) && seen.add(next)) queue.add(next);
|
||||
}
|
||||
for (int dy : new int[] {-1, 1}) {
|
||||
var next = pos.offset(0, dy, 0); if (!inside.test(next)) continue;
|
||||
if ((level.getBlockState(pos).is(Blocks.LADDER) || level.getBlockState(next).is(Blocks.LADDER) || level.getBlockState(pos.below()).is(Blocks.LADDER))
|
||||
&& standable(level, next) && seen.add(next)) queue.add(next);
|
||||
}
|
||||
helper.assertTrue(seen.size() <= 50_000, "Native site traversal escaped its bounds");
|
||||
}
|
||||
return seen;
|
||||
}
|
||||
private static boolean standable(ServerLevel level, BlockPos pos) {
|
||||
if (!clearBody(level, pos)) return false;
|
||||
if (level.getBlockState(pos).is(Blocks.LADDER) || level.getBlockState(pos.below()).is(Blocks.LADDER)) return true;
|
||||
var below = pos.below(); return level.getBlockState(below).getCollisionShape(level, below).toAabbs().stream()
|
||||
.anyMatch(b -> b.maxY >= .5 && b.minX <= .5 && b.maxX >= .5 && b.minZ <= .5 && b.maxZ >= .5);
|
||||
}
|
||||
private static boolean clearBody(ServerLevel level, BlockPos pos) {
|
||||
var body = new AABB(pos.getX() + .2, pos.getY(), pos.getZ() + .2, pos.getX() + .8, pos.getY() + 1.8, pos.getZ() + .8);
|
||||
for (var at : new BlockPos[] {pos, pos.above()}) {
|
||||
if (!level.getFluidState(at).isEmpty()) return false;
|
||||
for (var shape : level.getBlockState(at).getCollisionShape(level, at).toAabbs()) if (shape.move(at.getX(), at.getY(), at.getZ()).intersects(body)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private static long column(int x, int z) { return (long) x << 32 ^ z & 0xffffffffL; }
|
||||
private static List<Integer> coords(BlockPos pos) { return List.of(pos.getX(), pos.getY(), pos.getZ()); }
|
||||
private static BlockPos readPos(com.google.gson.JsonArray value) { return new BlockPos(value.get(0).getAsInt(), value.get(1).getAsInt(), value.get(2).getAsInt()); }
|
||||
private static Path world(ServerLevel level) { return level.getServer().getWorldPath(LevelResource.ROOT).toAbsolutePath().normalize(); }
|
||||
private static Path proof(ServerLevel level) { return world(level).resolve("heritage19-create-proof.json"); }
|
||||
private static String planHash(HeritagePlan19 plan) { return hash(plan.sites().toString() + plan.landmarks() + plan.links() + plan.segments()); }
|
||||
private static void write(ServerLevel level, Map<String, Object> report, boolean reload) throws IOException {
|
||||
var path = Path.of("diagnostics", "heritage19-" + (reload ? "reload" : "create") + ".json"); Files.createDirectories(path.getParent());
|
||||
var value = new GsonBuilder().setPrettyPrinting().create().toJson(report) + "\n"; Files.writeString(path, value); if (!reload) Files.writeString(proof(level), value);
|
||||
}
|
||||
private static String hash(String value) {
|
||||
try { return HexFormat.of().formatHex(MessageDigest.getInstance("SHA-256").digest(value.getBytes(StandardCharsets.UTF_8))); }
|
||||
catch (NoSuchAlgorithmException impossible) { throw new AssertionError(impossible); }
|
||||
}
|
||||
}
|
||||
+556
@@ -0,0 +1,556 @@
|
||||
package fr.koka.sanctuary.gametest;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import fr.koka.sanctuary.SanctuaryMod;
|
||||
import fr.koka.sanctuary.worldgen.SanctuaryChunkGenerator;
|
||||
import fr.koka.sanctuary.worldgen.city.LostCityRenderer;
|
||||
import fr.koka.sanctuary.worldgen.heritage.HeritagePiece20;
|
||||
import fr.koka.sanctuary.worldgen.heritage.HeritagePlan19;
|
||||
import fr.koka.sanctuary.worldgen.heritage.HeritageRenderer20;
|
||||
import fr.koka.sanctuary.worldgen.heritage.HeritageStructures19;
|
||||
import fr.koka.sanctuary.worldgen.ruins.RuinsPiece20;
|
||||
import fr.koka.sanctuary.worldgen.ruins.RuinsPlan17;
|
||||
import fr.koka.sanctuary.worldgen.ruins.RuinsRenderer20;
|
||||
import fr.koka.sanctuary.worldgen.ruins.RuinsStructures17;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.HexFormat;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import net.fabricmc.fabric.api.gametest.v1.GameTest;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.HolderSet;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.gametest.framework.GameTestHelper;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.DoorBlock;
|
||||
import net.minecraft.world.level.block.TrapDoorBlock;
|
||||
import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureStart;
|
||||
import net.minecraft.world.level.levelgen.structure.pieces.StructurePieceSerializationContext;
|
||||
import net.minecraft.world.level.storage.LevelResource;
|
||||
import net.minecraft.world.level.storage.loot.LootParams;
|
||||
import net.minecraft.world.level.storage.loot.LootTable;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
/** Native creation/reload proof confined to a disposable generation20 starter island. */
|
||||
public final class Heritage20WorldGameTests {
|
||||
private static final Direction[] HORIZONTAL = {Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST};
|
||||
@GameTest(maxTicks = 12000)
|
||||
public void heritagePersistsWithRealDestinations(GameTestHelper helper) {
|
||||
helper.assertTrue(helper.getLevel().getChunkSource().getGenerator() instanceof SanctuaryChunkGenerator,
|
||||
"The heritage proof requires a Sanctuary generator");
|
||||
var generator = (SanctuaryChunkGenerator) helper.getLevel().getChunkSource().getGenerator();
|
||||
helper.assertTrue(generator.rootGeneration() == 20, "Use a fresh generation20 test world; do not convert an old save");
|
||||
new Scenario(helper, generator, Boolean.getBoolean("sanctuary.test.expansionReload")).advance();
|
||||
}
|
||||
private static final class Scenario {
|
||||
final GameTestHelper helper;
|
||||
final ServerLevel level;
|
||||
final SanctuaryChunkGenerator generator;
|
||||
final HeritagePlan19 plan;
|
||||
final boolean reload;
|
||||
final Map<String, Object> report = new LinkedHashMap<>();
|
||||
final List<ChunkPos> chunks = new ArrayList<>();
|
||||
final List<StructureStart> starts = new ArrayList<>();
|
||||
final List<StructureStart> ruinsStarts = new ArrayList<>();
|
||||
JsonObject previous;
|
||||
BlockPos gold;
|
||||
int nextChunk;
|
||||
boolean prepared;
|
||||
Scenario(GameTestHelper helper, SanctuaryChunkGenerator generator, boolean reload) {
|
||||
this.helper = helper; this.level = helper.getLevel(); this.generator = generator; this.reload = reload;
|
||||
this.plan = generator.heritagePlan19();
|
||||
report.put("seed", level.getSeed()); report.put("size", generator.initialDiameter());
|
||||
report.put("process_id", ProcessHandle.current().pid()); report.put("world_directory", world(level).toString());
|
||||
report.put("experimental_structures", generator.experimentalStructures());
|
||||
report.put("structures_enabled", level.structureManager().shouldGenerateStructures());
|
||||
report.put("scope", "Native local starts, saved sites and routes, player-sized entrances, supports and unopened chests on the starter island. "
|
||||
+ "All14 tool tables are sampled separately without consuming a saved chest. Door states are restored after traversal. "
|
||||
+ "No personal save or expansion is opened; one disposable outer-wall edit is checked in a second JVM. "
|
||||
+ "Missing rails are intentional; this proof checks walking and saved rail shapes, not an uninterrupted minecart journey.");
|
||||
}
|
||||
void advance() {
|
||||
try {
|
||||
if (!prepared) { report.put("stage", "prepare"); prepare(); prepared = true; if (plan.isEmpty()) { finishDisabled(); return; } }
|
||||
if (nextChunk < chunks.size()) {
|
||||
report.put("stage", "load_full_chunks"); var pos = chunks.get(nextChunk++);
|
||||
helper.assertTrue(level.getChunk(pos.x(), pos.z(), ChunkStatus.FULL, true) instanceof LevelChunk,
|
||||
"Heritage footprint must reach native FULL: " + pos);
|
||||
if (nextChunk % 20 == 0) SanctuaryMod.LOGGER.info("Heritage20 loaded {}/{} footprint chunks", nextChunk, chunks.size());
|
||||
helper.runAtTickTime(helper.getTick() + 1, this::advance); return;
|
||||
}
|
||||
report.put("stage", "verify_native_geometry"); verifyPlaced(); report.put("passed", true);
|
||||
if (!reload) {
|
||||
helper.assertTrue(gold != null && level.getBlockState(gold).isCollisionShapeFullBlock(level, gold), "Gold witness must replace a solid wall away from circulation");
|
||||
level.setBlock(gold, Blocks.GOLD_BLOCK.defaultBlockState(), 3); report.put("gold_witness", coords(gold));
|
||||
helper.assertTrue(level.getServer().saveEverything(true, true, true), "Flush native starts, unopened loot and the wall edit");
|
||||
report.put("world_flushed_before_shutdown", true);
|
||||
} else {
|
||||
helper.assertTrue(level.getBlockState(gold).is(Blocks.GOLD_BLOCK), "Reload replaced the player's wall edit");
|
||||
report.put("gold_witness", coords(gold)); report.put("gold_witness_preserved", true);
|
||||
}
|
||||
write(level, report, reload); helper.succeed();
|
||||
} catch (Exception failure) {
|
||||
report.put("passed", false); report.put("failure", failure.toString());
|
||||
try { write(level, report, reload); } catch (IOException ignored) { }
|
||||
throw new IllegalStateException("Heritage20 native " + (reload ? "reload" : "creation") + " failed", failure);
|
||||
}
|
||||
}
|
||||
void prepare() throws IOException {
|
||||
var ops = RegistryOps.create(JsonOps.INSTANCE, level.registryAccess());
|
||||
var encoded = ChunkGenerator.CODEC.encodeStart(ops, generator).getOrThrow();
|
||||
var decoded = ChunkGenerator.CODEC.parse(ops, encoded).getOrThrow();
|
||||
helper.assertTrue(decoded instanceof SanctuaryChunkGenerator copy && copy.rootGeneration() == 20
|
||||
&& copy.experimentalStructures() == generator.experimentalStructures(), "Generation20 codec lost its experimental switch");
|
||||
report.put("generator_codec", encoded); report.put("plan_sha256", planHash(plan));
|
||||
report.put("planned_sites", plan.sites().stream().map(site -> Map.of("id", site.id(), "kind", site.kind().name(),
|
||||
"entry", coords(HeritagePiece20.locator(site)), "floor_y", site.floorY(), "foundation_depth", site.foundationDepth(), "footings", site.supports().size())).toList());
|
||||
report.put("planned_links", plan.links().stream().map(link -> Map.of("id", link.id(), "from", link.fromId(), "to", link.toId(), "kind", link.kind().name(), "length", link.path().size(), "path", pathCoords(link))).toList());
|
||||
report.put("planning_samples", plan.samples()); report.put("planning_columns", plan.columns()); report.put("planning_diagnostics", plan.diagnostics());
|
||||
helper.assertTrue(plan.samples() <= HeritagePlan19.MAX_SAMPLES && plan.columns() <= HeritagePlan19.MAX_COLUMNS, "Heritage planning exceeded its budget");
|
||||
verifyLootTables(helper, report);
|
||||
if (reload) {
|
||||
previous = JsonParser.parseString(Files.readString(proof(level))).getAsJsonObject();
|
||||
helper.assertTrue(previous.get("passed").getAsBoolean() && previous.get("world_flushed_before_shutdown").getAsBoolean(), "Reload needs a successful flushed creation proof");
|
||||
helper.assertTrue(previous.get("process_id").getAsLong() != ProcessHandle.current().pid(), "Reload must use a second JVM");
|
||||
helper.assertTrue(previous.get("seed").getAsLong() == level.getSeed() && previous.get("size").getAsInt() == generator.initialDiameter()
|
||||
&& previous.get("world_directory").getAsString().equals(world(level).toString()), "Reload selected another world");
|
||||
helper.assertTrue(previous.get("generator_codec").equals(encoded) && previous.get("plan_sha256").getAsString().equals(planHash(plan)), "Saved settings or planned identities changed on reload");
|
||||
if (previous.has("gold_witness")) gold = readPos(previous.getAsJsonArray("gold_witness"));
|
||||
}
|
||||
if (!generator.experimentalStructures() || !level.structureManager().shouldGenerateStructures()) {
|
||||
helper.assertTrue(plan.isEmpty() && plan.segments().isEmpty() && plan.links().isEmpty(), "Disabled generation published heritage geometry"); return;
|
||||
}
|
||||
helper.assertTrue(!plan.isEmpty(), "Enabled reference island has no heritage site");
|
||||
report.put("present_site_kinds", plan.sites().stream().map(s -> s.kind().name()).distinct().sorted().toList());
|
||||
report.put("missing_site_kinds", java.util.Arrays.stream(HeritagePlan19.Kind.values()).filter(k -> plan.sites().stream().noneMatch(s -> s.kind() == k)).map(Enum::name).toList());
|
||||
var structure = level.registryAccess().lookupOrThrow(Registries.STRUCTURE).getOrThrow(HeritageStructures19.KEY);
|
||||
var origins = new HashSet<ChunkPos>(); var uniqueChunks = new HashSet<ChunkPos>();
|
||||
plan.sites().forEach(s -> origins.add(new ChunkPos(s.startChunkX(), s.startChunkZ())));
|
||||
plan.segments().forEach(s -> origins.add(new ChunkPos(s.startChunkX(), s.startChunkZ())));
|
||||
for (var origin : origins.stream().sorted(Comparator.comparingInt(ChunkPos::x).thenComparingInt(ChunkPos::z)).toList()) {
|
||||
var chunk = level.getChunk(origin.x(), origin.z(), ChunkStatus.STRUCTURE_STARTS, true);
|
||||
var start = chunk.getStartForStructure(structure.value());
|
||||
helper.assertTrue(start != null && start.isValid(), "Accepted site/route has no native start at " + origin); starts.add(start);
|
||||
for (var piece : start.getPieces()) {
|
||||
helper.assertTrue(piece instanceof HeritagePiece20, "Heritage loaded a foreign piece type");
|
||||
var box = piece.getBoundingBox();
|
||||
helper.assertTrue(Math.abs((long) (box.minX() >> 4) - origin.x()) <= 7 && Math.abs((long) (box.maxX() >> 4) - origin.x()) <= 7
|
||||
&& Math.abs((long) (box.minZ() >> 4) - origin.z()) <= 7 && Math.abs((long) (box.maxZ() >> 4) - origin.z()) <= 7, "Native start references a distant route endpoint");
|
||||
box.intersectingChunks().forEach(uniqueChunks::add);
|
||||
}
|
||||
}
|
||||
for (var site : plan.sites()) uniqueChunks.add(ChunkPos.containing(HeritagePiece20.locator(site)));
|
||||
for (var link : plan.links()) for (var point : link.path()) uniqueChunks.add(new ChunkPos(point.x() >> 4, point.z() >> 4));
|
||||
helper.assertTrue(uniqueChunks.size() <= 1024, "Bounded proof footprint exceeds1024 chunks");
|
||||
var ruins = generator.ruinsPlan17();
|
||||
report.put("ruins_plan_sha256", hash(ruins.networks().toString()));
|
||||
if (reload) helper.assertTrue(previous.get("ruins_plan_sha256").getAsString().equals(hash(ruins.networks().toString())), "Reload changed forgotten room planning");
|
||||
helper.assertTrue(!ruins.isEmpty(), "Reference20 must demonstrate native experimental room architecture");
|
||||
var ruinsType = level.registryAccess().lookupOrThrow(Registries.STRUCTURE).getOrThrow(RuinsStructures17.KEY);
|
||||
var ruinsOrigins = new HashSet<ChunkPos>();
|
||||
for (var network : ruins.networks()) {
|
||||
var origin = new ChunkPos(network.startChunkX(), network.startChunkZ()); if (!ruinsOrigins.add(origin)) continue;
|
||||
var nativeStart = level.getChunk(origin.x(), origin.z(), ChunkStatus.STRUCTURE_STARTS, true).getStartForStructure(ruinsType.value());
|
||||
helper.assertTrue(nativeStart != null && nativeStart.isValid(), "Missing native20 forgotten network: " + network.id());
|
||||
ruinsStarts.add(nativeStart);
|
||||
for (var piece : nativeStart.getPieces()) {
|
||||
helper.assertTrue(piece instanceof RuinsPiece20, "Generation20 loaded a historical forgotten piece");
|
||||
piece.getBoundingBox().intersectingChunks().forEach(uniqueChunks::add);
|
||||
}
|
||||
}
|
||||
chunks.addAll(uniqueChunks.stream().sorted(Comparator.comparingInt(ChunkPos::x).thenComparingInt(ChunkPos::z)).toList());
|
||||
}
|
||||
void finishDisabled() throws IOException {
|
||||
var structure = level.registryAccess().lookupOrThrow(Registries.STRUCTURE).getOrThrow(HeritageStructures19.KEY);
|
||||
var start = level.getChunk(0, 0, ChunkStatus.STRUCTURE_STARTS, true).getStartForStructure(structure.value());
|
||||
helper.assertTrue(start == null || !start.isValid(), "Disabled heritage emitted a native start");
|
||||
helper.assertTrue(generator.findNearestMapStructure(level, HolderSet.direct(structure), new BlockPos(0, 250, 0), 100, false) == null, "Disabled heritage is locatable");
|
||||
report.put("empty_plan_verified", true); report.put("passed", true);
|
||||
if (!reload) { helper.assertTrue(level.getServer().saveEverything(true, true, true), "Save disabled experiment setting"); report.put("world_flushed_before_shutdown", true); }
|
||||
write(level, report, reload); helper.succeed();
|
||||
}
|
||||
void verifyPlaced() {
|
||||
var structure = level.registryAccess().lookupOrThrow(Registries.STRUCTURE).getOrThrow(HeritageStructures19.KEY);
|
||||
var context = StructurePieceSerializationContext.fromLevel(level); var summaries = new ArrayList<Map<String, Object>>();
|
||||
int blocks = 0, chests = 0, pieces = 0, supports = 0;
|
||||
var connections = NativeConnections20.Stats.empty();
|
||||
for (var start : starts) {
|
||||
var origin = start.getChunkPos(); var saved = start.createTag(context, origin); String nativeHash = hash(saved.toString());
|
||||
var copy = StructureStart.loadStaticStart(context, saved, level.getSeed());
|
||||
helper.assertTrue(copy != null && copy.isValid() && copy.createTag(context, origin).equals(saved), "Native start failed an exact NBT roundtrip");
|
||||
var expectedPayloads = new HashSet<net.minecraft.nbt.CompoundTag>();
|
||||
plan.sites().stream().filter(s -> s.startChunkX() == origin.x() && s.startChunkZ() == origin.z()).forEach(s -> expectedPayloads.add(HeritagePiece20.encodeSite(s)));
|
||||
plan.segments().stream().filter(s -> s.startChunkX() == origin.x() && s.startChunkZ() == origin.z()).forEach(s -> expectedPayloads.add(HeritagePiece20.encodeSegment(s)));
|
||||
var actualPayloads = new HashSet<net.minecraft.nbt.CompoundTag>();
|
||||
if (reload) {
|
||||
JsonObject prior = null;
|
||||
for (var value : previous.getAsJsonArray("starts")) { var item = value.getAsJsonObject(); var at = item.getAsJsonArray("start_chunk"); if (at.get(0).getAsInt() == origin.x() && at.get(1).getAsInt() == origin.z()) prior = item; }
|
||||
helper.assertTrue(prior != null && prior.get("native_start_sha256").getAsString().equals(nativeHash), "Reload changed saved geometry or native reference count");
|
||||
}
|
||||
var loot = new ArrayList<Map<String, Object>>();
|
||||
for (var value : start.getPieces()) {
|
||||
var piece = (HeritagePiece20) value; pieces++;
|
||||
var tag = piece.createTag(context); var restored = new HeritagePiece20(context, tag);
|
||||
helper.assertTrue(restored.createTag(context).equals(tag), "Saved piece parameters changed on native load");
|
||||
actualPayloads.add(tag.getCompound("SanctuaryHeritage").orElseThrow());
|
||||
var corrupt = tag.copy(); corrupt.getCompound("SanctuaryHeritage").orElseThrow().putInt("Schema", 21);
|
||||
boolean rejected = false; try { new HeritagePiece20(context, corrupt); } catch (IllegalArgumentException expected) { rejected = true; }
|
||||
helper.assertTrue(rejected, "Unknown schema must fail closed");
|
||||
piece.getBoundingBox().intersectingChunks().forEach(at -> helper.assertTrue(level.getChunk(at.x(), at.z(), ChunkStatus.FULL, true)
|
||||
.getReferencesForStructure(structure.value()).contains(origin.pack()), "FULL chunk lost its native structure reference"));
|
||||
var expected = rendered(piece); blocks += expected.blocks().size();
|
||||
for (var entry : expected.blocks().entrySet()) {
|
||||
var at = entry.getKey(); var wanted = entry.getValue(); helper.assertTrue(piece.getBoundingBox().isInside(at), "Renderer escaped saved bounds");
|
||||
if (reload && at.equals(gold)) continue;
|
||||
helper.assertTrue(level.getBlockState(at).is(wanted.getBlock()), "Clipping or decoration changed heritage at " + at + ": expected " + wanted + " got " + level.getBlockState(at));
|
||||
helper.assertTrue(!wanted.is(Blocks.SPAWNER), "Heritage must not create spawners");
|
||||
}
|
||||
connections = connections.add(NativeConnections20.verify(helper, expected.blocks(), reload ? Set.of(gold) : Set.of()));
|
||||
if (piece.isSite()) {
|
||||
supports += verifySiteBearing(helper, generator, plan, piece.site());
|
||||
if (!reload && gold == null) {
|
||||
gold = expected.blocks().entrySet().stream().filter(e -> isOuterWall(piece.site(), e.getKey()) && e.getValue().isCollisionShapeFullBlock(level, e.getKey()))
|
||||
.map(Map.Entry::getKey).sorted(Comparator.<BlockPos>comparingInt(p -> p.getY()).thenComparingInt(p -> p.getX()).thenComparingInt(p -> p.getZ())).findFirst().orElse(null);
|
||||
}
|
||||
} else for (var cell : piece.segment().cells()) { supports++; assertRock(helper, new BlockPos(cell.x(), cell.minY() - 1, cell.z())); }
|
||||
for (var chest : expected.chests()) {
|
||||
helper.assertTrue(level.getBlockEntity(chest.position()) instanceof RandomizableContainerBlockEntity, "Deferred chest is missing");
|
||||
var entity = (RandomizableContainerBlockEntity) level.getBlockEntity(chest.position());
|
||||
helper.assertTrue(entity.getLootTable() != null && entity.getLootTable().equals(chest.table()) && entity.getLootTableSeed() == chest.seed(), "Deferred loot table/seed was lost or consumed");
|
||||
if (piece.isSite()) helper.assertTrue(chest.table().equals(lootKey(piece.site().kind())), "Site uses another kind's tool table");
|
||||
loot.add(Map.of("position", coords(chest.position()), "table", chest.table().identifier().toString(), "seed", chest.seed())); chests++;
|
||||
}
|
||||
}
|
||||
helper.assertTrue(actualPayloads.equals(expectedPayloads) && start.getPieces().size() == expectedPayloads.size(), "Native start lost or duplicated planned pieces");
|
||||
summaries.add(Map.of("start_chunk", List.of(origin.x(), origin.z()), "native_start_sha256", nativeHash, "pieces", start.getPieces().size(), "unopened_chests", loot));
|
||||
}
|
||||
report.put("connected_blocks", connections);
|
||||
helper.assertTrue(connections.panes() > 0 && connections.stairs() > 0 && connections.nativeOracles() > 0,
|
||||
"Reference20 needs real panes/stairs validated by vanilla neighbor rules");
|
||||
if (level.getSeed() == 0 && generator.initialDiameter() == 724)
|
||||
helper.assertTrue(connections.crossChunkPaneLinks() > 0, "Reference20 must demonstrate a real pane join across a chunk boundary");
|
||||
verifyRuins();
|
||||
report.put("starts", summaries); report.put("native_pieces", pieces); report.put("native_blocks_checked", blocks);
|
||||
report.put("full_chunks_checked", chunks.size()); report.put("rock_supports_checked", supports); report.put("unopened_deferred_chests", chests);
|
||||
report.put("stage", "verify_site_routes"); var sites = new ArrayList<Map<String, Object>>(); for (var site : plan.sites()) sites.add(verifyAccess(helper, site)); report.put("native_sites", sites);
|
||||
report.put("stage", "verify_read_only_landings");
|
||||
report.put("read_only_landmarks", verifyReadOnlyLandings(helper, generator, plan));
|
||||
report.put("stage", "verify_island_routes"); report.put("native_links", verifyLinks(helper, plan));
|
||||
int greatestSpan = plan.links().stream().mapToInt(Heritage20WorldGameTests::routeSpan).max().orElse(0);
|
||||
report.put("greatest_single_route_span", greatestSpan);
|
||||
if (level.getSeed() == 0 && generator.initialDiameter() == 724) {
|
||||
int requiredSpan = generator.initialDiameter() / 4;
|
||||
report.put("reference_minimum_route_span", requiredSpan);
|
||||
helper.assertTrue(greatestSpan >= requiredSpan, "Seed0 Medium must demonstrate an island-scale route spanning at least "
|
||||
+ requiredSpan + " blocks on X or Z; got " + greatestSpan);
|
||||
}
|
||||
var located = generator.findNearestMapStructure(level, HolderSet.direct(structure), new BlockPos(0, 250, 0), 100, false);
|
||||
helper.assertTrue(located != null && located.getSecond().is(HeritageStructures19.KEY) && plan.sites().stream().anyMatch(s -> HeritagePiece20.locator(s).equals(located.getFirst())), "Locate must lead to a real exterior site entry");
|
||||
report.put("locate", coords(located.getFirst()));
|
||||
}
|
||||
void verifyRuins() {
|
||||
var context = StructurePieceSerializationContext.fromLevel(level);
|
||||
var registry = level.registryAccess().lookupOrThrow(Registries.STRUCTURE).getOrThrow(RuinsStructures17.KEY);
|
||||
var summaries = new ArrayList<Map<String, Object>>(); int count = 0, blockCount = 0, lootCount = 0;
|
||||
var connections = NativeConnections20.Stats.empty();
|
||||
for (var start : ruinsStarts) {
|
||||
var origin = start.getChunkPos(); var saved = start.createTag(context, origin); var digest = hash(saved.toString());
|
||||
var loaded = StructureStart.loadStaticStart(context, saved, level.getSeed());
|
||||
helper.assertTrue(loaded != null && loaded.createTag(context, origin).equals(saved), "Forgotten20 native start NBT changed");
|
||||
var expectedRooms = generator.ruinsPlan17().networks().stream().filter(n -> n.startChunkX() == origin.x() && n.startChunkZ() == origin.z()).flatMap(n -> n.rooms().stream()).toList();
|
||||
var actualRooms = start.getPieces().stream().map(RuinsPiece20.class::cast).map(RuinsPiece20::room).toList();
|
||||
helper.assertTrue(expectedRooms.size() == actualRooms.size() && new HashSet<>(expectedRooms).equals(new HashSet<>(actualRooms)), "Forgotten20 native rooms differ from plan");
|
||||
if (reload) {
|
||||
JsonObject prior = null;
|
||||
for (var value : previous.getAsJsonArray("ruins_starts")) { var item = value.getAsJsonObject(); var at = item.getAsJsonArray("start_chunk"); if (at.get(0).getAsInt() == origin.x() && at.get(1).getAsInt() == origin.z()) prior = item; }
|
||||
helper.assertTrue(prior != null && prior.get("native_start_sha256").getAsString().equals(digest), "Forgotten20 native start changed on a second JVM load");
|
||||
}
|
||||
for (var raw : start.getPieces()) {
|
||||
var piece = (RuinsPiece20) raw; var room = piece.room(); count++;
|
||||
var tag = piece.createTag(context); var roundtrip = new RuinsPiece20(context, tag);
|
||||
helper.assertTrue(roundtrip.room().equals(room) && roundtrip.createTag(context).equals(tag), "Forgotten20 piece lost saved parameters");
|
||||
piece.getBoundingBox().intersectingChunks().forEach(at -> helper.assertTrue(level.getChunk(at.x(), at.z(), ChunkStatus.FULL, true).getReferencesForStructure(registry.value()).contains(origin.pack()), "Forgotten20 chunk lost native references"));
|
||||
var expected = rendered(room); blockCount += expected.blocks().size();
|
||||
for (var entry : expected.blocks().entrySet()) {
|
||||
helper.assertTrue(piece.getBoundingBox().isInside(entry.getKey()), "Forgotten20 renderer escaped saved bounds");
|
||||
helper.assertTrue(level.getBlockState(entry.getKey()).is(entry.getValue().getBlock()), "Forgotten20 native geometry changed at " + entry.getKey());
|
||||
}
|
||||
connections = connections.add(NativeConnections20.verify(helper, expected.blocks(), Set.of()));
|
||||
for (var support : room.supports()) assertRock(helper, new BlockPos(support.x(), support.minY() - 1, support.z()));
|
||||
for (var chest : expected.chests()) {
|
||||
helper.assertTrue(level.getBlockEntity(chest.position()) instanceof RandomizableContainerBlockEntity, "Forgotten20 missing deferred chest");
|
||||
var entity = (RandomizableContainerBlockEntity) level.getBlockEntity(chest.position());
|
||||
helper.assertTrue(chest.table().equals(entity.getLootTable()) && chest.seed() == entity.getLootTableSeed(), "Forgotten20 consumed/changed saved loot"); lootCount++;
|
||||
}
|
||||
}
|
||||
summaries.add(Map.of("start_chunk", List.of(origin.x(), origin.z()), "native_start_sha256", digest, "pieces", start.getPieces().size()));
|
||||
}
|
||||
report.put("ruins_starts", summaries); report.put("ruins_native_pieces", count); report.put("ruins_native_blocks_checked", blockCount);
|
||||
report.put("ruins_unopened_deferred_chests", lootCount); report.put("ruins_connections", connections);
|
||||
report.put("ruins_access", generator.ruinsPlan17().networks().stream().map(n -> verifyAccess(helper, n)).toList());
|
||||
}
|
||||
}
|
||||
private record Chest(BlockPos position, ResourceKey<LootTable> table, long seed) {}
|
||||
private record Rendered(Map<BlockPos, BlockState> blocks, List<Chest> chests) {}
|
||||
private static Rendered rendered(HeritagePiece20 piece) {
|
||||
var blocks = new HashMap<BlockPos, BlockState>(); var chests = new ArrayList<Chest>();
|
||||
int x0 = piece.isSite() ? piece.site().minX() : piece.segment().minX();
|
||||
int y0 = piece.isSite() ? piece.site().floorY() : piece.segment().minY();
|
||||
int z0 = piece.isSite() ? piece.site().minZ() : piece.segment().minZ();
|
||||
var writer = new LostCityRenderer.BlockWriter() {
|
||||
@Override public void set(int x, int y, int z, BlockState state) { blocks.put(new BlockPos(x0 + x, y0 + y, z0 + z), state); }
|
||||
@Override public void chest(int x, int y, int z, ResourceKey<LootTable> table, long seed) {
|
||||
var at = new BlockPos(x0 + x, y0 + y, z0 + z); blocks.put(at, Blocks.CHEST.defaultBlockState()); chests.add(new Chest(at, table, RandomSource.create(seed).nextLong()));
|
||||
}
|
||||
};
|
||||
if (piece.isSite()) HeritageRenderer20.render(piece.site(), writer); else HeritageRenderer20.renderSegment(piece.segment(), writer);
|
||||
return new Rendered(blocks, chests);
|
||||
}
|
||||
private static Rendered rendered(RuinsPlan17.Room room) {
|
||||
var blocks = new HashMap<BlockPos, BlockState>(); var chests = new ArrayList<Chest>();
|
||||
RuinsRenderer20.render(room, new LostCityRenderer.BlockWriter() {
|
||||
@Override public void set(int x, int y, int z, BlockState state) { blocks.put(at(room, x, y, z), state); }
|
||||
@Override public void chest(int x, int y, int z, ResourceKey<LootTable> table, long seed) {
|
||||
var position = at(room, x, y, z); blocks.put(position, Blocks.CHEST.defaultBlockState()); chests.add(new Chest(position, table, RandomSource.create(seed).nextLong()));
|
||||
}
|
||||
});
|
||||
return new Rendered(blocks, chests);
|
||||
}
|
||||
private static Map<String, Object> verifyAccess(GameTestHelper helper, RuinsPlan17.Network network) {
|
||||
var level = helper.getLevel(); var access = network.rooms().stream().filter(r -> r.kind() == RuinsPlan17.Kind.ACCESS).findFirst().orElseThrow();
|
||||
var hatches = new HashMap<BlockPos, BlockState>();
|
||||
rendered(access).blocks().forEach((at, state) -> { if (state.is(Blocks.DARK_OAK_TRAPDOOR)) hatches.put(at, level.getBlockState(at)); });
|
||||
helper.assertTrue(hatches.size() == 1, "Each network must have one usable wooden surface hatch");
|
||||
hatches.forEach((at, state) -> {
|
||||
helper.assertTrue(state.is(Blocks.DARK_OAK_TRAPDOOR) && state.canSurvive(level, at), "Surface hatch is missing its native support");
|
||||
level.setBlock(at, state.setValue(BlockStateProperties.OPEN, true), 2);
|
||||
});
|
||||
try {
|
||||
Predicate<BlockPos> inside = pos -> network.rooms().stream().anyMatch(r -> r.contains(pos.getX(), pos.getY(), pos.getZ()));
|
||||
var start = RuinsPiece20.locator(access); var reached = walk(helper, start, inside);
|
||||
int targets = 0;
|
||||
for (var room : network.rooms()) for (var target : RuinsRenderer20.targets(room)) {
|
||||
var point = at(room, target.x(), target.y(), target.z());
|
||||
helper.assertTrue(reached.contains(point), "Native network " + network.id() + " cannot reach " + room.kind() + "/" + target.name() + " at " + point);
|
||||
targets++;
|
||||
}
|
||||
for (var hatch : hatches.keySet()) helper.assertTrue(reached.contains(hatch), "Surface approach cannot enter its ladder shaft");
|
||||
return Map.of("id", network.id(), "family", network.family().name(), "rooms", network.rooms().size(),
|
||||
"entrance", coords(start), "walkable_targets", targets, "standing_cells", reached.size());
|
||||
} finally { hatches.forEach((at, state) -> level.setBlock(at, state, 2)); }
|
||||
}
|
||||
private static BlockPos at(RuinsPlan17.Room room, int x, int y, int z) { return new BlockPos(room.minX() + x, room.minY() + y, room.minZ() + z); }
|
||||
private static boolean isOuterWall(HeritagePlan19.Site site, BlockPos pos) {
|
||||
return pos.getY() >= site.floorY() + 2 && pos.getY() <= site.floorY() + 3
|
||||
&& (pos.getX() == site.minX() + 2 || pos.getX() == site.maxX() - 2 || pos.getZ() == site.minZ() + 2 || pos.getZ() == site.maxZ() - 2)
|
||||
&& Math.abs(pos.getX() - site.entry().x()) + Math.abs(pos.getZ() - site.entry().z()) > 6;
|
||||
}
|
||||
private static Map<String, Object> verifyAccess(GameTestHelper helper, HeritagePlan19.Site site) {
|
||||
var level = helper.getLevel(); var expected = rendered(new HeritagePiece20(site)); var doors = new HashMap<BlockPos, BlockState>();
|
||||
expected.blocks().forEach((at, state) -> {
|
||||
if ((state.getBlock() instanceof DoorBlock || state.getBlock() instanceof TrapDoorBlock) && state.hasProperty(BlockStateProperties.OPEN)) doors.put(at, level.getBlockState(at));
|
||||
});
|
||||
doors.forEach((at, state) -> level.setBlock(at, state.setValue(BlockStateProperties.OPEN, true), 2));
|
||||
try {
|
||||
var entry = HeritagePiece20.locator(site);
|
||||
Predicate<BlockPos> inside = p -> p.equals(entry) || p.getX() >= site.minX() && p.getX() <= site.maxX()
|
||||
&& p.getZ() >= site.minZ() && p.getZ() <= site.maxZ() && p.getY() >= site.floorY() - 4 && p.getY() < site.maxY();
|
||||
var reached = walk(helper, entry, inside); int targets = 0;
|
||||
for (var target : HeritageRenderer20.targets(site)) {
|
||||
var at = new BlockPos(site.minX() + target.x(), site.floorY() + target.y(), site.minZ() + target.z());
|
||||
helper.assertTrue(reached.contains(at), "Site " + site.id() + " cannot reach " + target.name() + " at " + at); targets++;
|
||||
}
|
||||
return Map.of("id", site.id(), "kind", site.kind().name(), "entry", coords(entry), "standing_cells", reached.size(), "walkable_targets", targets);
|
||||
} finally { doors.forEach((at, state) -> level.setBlock(at, state, 2)); }
|
||||
}
|
||||
private static List<Map<String, Object>> verifyLinks(GameTestHelper helper, HeritagePlan19 plan) {
|
||||
helper.assertTrue(!plan.links().isEmpty(), "Reference island needs a real route between accepted destinations");
|
||||
var entries = new HashMap<String, HeritagePlan19.Entry>(); plan.sites().forEach(s -> entries.put(s.id(), s.entry())); plan.landmarks().forEach(s -> entries.put(s.id(), s.entry()));
|
||||
var cells = new HashMap<Long, HeritagePlan19.Cell>(); plan.segments().forEach(s -> s.cells().forEach(c -> cells.put(column(c.x(), c.z()), c)));
|
||||
var result = new ArrayList<Map<String, Object>>();
|
||||
for (var link : plan.links()) {
|
||||
var from = entries.get(link.fromId()); var to = entries.get(link.toId());
|
||||
helper.assertTrue(from != null && to != null, "Route points to an absent destination");
|
||||
var first = link.path().getFirst(); var last = link.path().getLast();
|
||||
helper.assertTrue(first.x() == from.x() && first.z() == from.z() && first.floorY() + 1 == from.y()
|
||||
&& last.x() == to.x() && last.z() == to.z() && last.floorY() + 1 == to.y(), "Route does not meet its real entrances");
|
||||
int present = 0, missing = 0;
|
||||
for (int i = 0; i < link.path().size(); i++) {
|
||||
var point = link.path().get(i); var at = new BlockPos(point.x(), point.floorY() + 1, point.z());
|
||||
helper.assertTrue(standable(helper.getLevel(), at), "Ballast route " + link.id() + " is blocked at " + at);
|
||||
if (i > 0) { var prior = link.path().get(i - 1); if (point.floorY() > prior.floorY()) helper.assertTrue(clearBody(helper.getLevel(), new BlockPos(prior.x(), prior.floorY() + 2, prior.z())), "Route slope cannot be climbed by a player"); }
|
||||
var cell = cells.get(column(point.x(), point.z()));
|
||||
if (cell != null && cell.rail() != HeritagePlan19.Rail.NONE) {
|
||||
var actual = helper.getLevel().getBlockState(at);
|
||||
if (cell.railPresent()) {
|
||||
helper.assertTrue(actual.is(Blocks.RAIL), "Saved existing rail disappeared");
|
||||
helper.assertTrue(actual.getValue(BlockStateProperties.RAIL_SHAPE).name().equals(cell.rail().name()), "Native rail update changed the intended slope or curve at " + at); present++;
|
||||
} else { helper.assertTrue(!actual.is(Blocks.RAIL), "An intentionally missing rail regenerated"); missing++; }
|
||||
}
|
||||
}
|
||||
int spanX = link.path().stream().mapToInt(HeritagePlan19.Point::x).max().orElseThrow() - link.path().stream().mapToInt(HeritagePlan19.Point::x).min().orElseThrow();
|
||||
int spanZ = link.path().stream().mapToInt(HeritagePlan19.Point::z).max().orElseThrow() - link.path().stream().mapToInt(HeritagePlan19.Point::z).min().orElseThrow();
|
||||
result.add(Map.of("id", link.id(), "from", link.fromId(), "to", link.toId(), "kind", link.kind().name(), "length", link.path().size(),
|
||||
"span_x", spanX, "span_z", spanZ, "existing_rails", present, "deliberately_missing_rails", missing, "path", pathCoords(link)));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private static int routeSpan(HeritagePlan19.Link link) {
|
||||
int spanX = link.path().stream().mapToInt(HeritagePlan19.Point::x).max().orElseThrow()
|
||||
- link.path().stream().mapToInt(HeritagePlan19.Point::x).min().orElseThrow();
|
||||
int spanZ = link.path().stream().mapToInt(HeritagePlan19.Point::z).max().orElseThrow()
|
||||
- link.path().stream().mapToInt(HeritagePlan19.Point::z).min().orElseThrow();
|
||||
return Math.max(spanX, spanZ);
|
||||
}
|
||||
private static List<List<Integer>> pathCoords(HeritagePlan19.Link link) {
|
||||
return link.path().stream().map(point -> List.of(point.x(), point.floorY(), point.z())).toList();
|
||||
}
|
||||
private static int verifySiteBearing(GameTestHelper helper, SanctuaryChunkGenerator generator, HeritagePlan19 plan, HeritagePlan19.Site site) {
|
||||
int checked = 0;
|
||||
// The planner certifies a nine-point bearing grid, either directly below its slab or below a saved short footing.
|
||||
for (int dx : new int[] {1, 8, 15}) for (int dz : new int[] {1, 8, 15}) {
|
||||
int x = site.minX() + dx, z = site.minZ() + dz;
|
||||
var support = site.supports().stream().filter(s -> s.x() == x && s.z() == z).findFirst();
|
||||
int bottom = support.map(HeritagePlan19.Support::minY).orElse(site.minY());
|
||||
for (int below = 1; below <= 2; below++) {
|
||||
var at = new BlockPos(x, bottom - below, z); assertRock(helper, at);
|
||||
helper.assertTrue(plan.protects(at.getX(), at.getY(), at.getZ()) && generator.protectsCityDecoration(at),
|
||||
"Site's certified bearing layer is not published in the decoration mask: " + site.id() + " at " + at);
|
||||
helper.assertTrue(!plan.contains(at.getX(), at.getY(), at.getZ()), "Original bearing rock became a writable heritage volume: " + at);
|
||||
checked++;
|
||||
}
|
||||
}
|
||||
return checked;
|
||||
}
|
||||
private static List<Map<String, Object>> verifyReadOnlyLandings(GameTestHelper helper, SanctuaryChunkGenerator generator, HeritagePlan19 plan) {
|
||||
var used = new HashSet<String>(); plan.links().forEach(link -> { used.add(link.fromId()); used.add(link.toId()); });
|
||||
var result = new ArrayList<Map<String, Object>>();
|
||||
for (var landmark : plan.landmarks()) if (used.contains(landmark.id())) {
|
||||
var e = landmark.entry(); int checked = 0;
|
||||
for (int side = -1; side <= 1; side++) {
|
||||
int x = e.x() + ((e.facing() & 1) == 0 ? side : 0), z = e.z() + ((e.facing() & 1) == 1 ? side : 0);
|
||||
for (int y = e.y() - 2; y <= e.y() + 2; y++) {
|
||||
var at = new BlockPos(x, y, z);
|
||||
helper.assertTrue(plan.protects(x, y, z) && generator.protectsCityDecoration(at), "Read-only arrival lost its decoration mask: " + landmark.id() + " at " + at);
|
||||
helper.assertTrue(!plan.contains(x, y, z), "Heritage gained write ownership of a historical arrival: " + landmark.id() + " at " + at);
|
||||
if (y == e.y() - 1) assertRock(helper, at);
|
||||
if (y >= e.y()) helper.assertTrue(helper.getLevel().getBlockState(at).isAir(), "Decoration obstructed a certified historical arrival: " + at);
|
||||
checked++;
|
||||
}
|
||||
}
|
||||
result.add(Map.of("id", landmark.id(), "entry", List.of(e.x(), e.y(), e.z()), "read_only_cells", checked));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private static void assertRock(GameTestHelper helper, BlockPos at) {
|
||||
helper.assertTrue(helper.getLevel().getBlockState(at).isSolid() && helper.getLevel().getFluidState(at).isEmpty(), "Lost original rock bearing at " + at);
|
||||
}
|
||||
private static void verifyLootTables(GameTestHelper helper, Map<String, Object> report) {
|
||||
var result = new ArrayList<Map<String, Object>>(); var level = helper.getLevel();
|
||||
var params = new LootParams.Builder(level).withParameter(LootContextParams.ORIGIN, new Vec3(0, 160, 0)).create(LootContextParamSets.CHEST);
|
||||
for (var kind : HeritagePlan19.Kind.values()) {
|
||||
var table = level.getServer().reloadableRegistries().getLootTable(lootKey(kind));
|
||||
helper.assertTrue(table != LootTable.EMPTY, "Heritage tool table did not load: " + kind);
|
||||
for (long seed : new long[] {0, 42, -1}) helper.assertTrue(table.getRandomItems(params, seed).stream().anyMatch(stack -> stack.is(tool(kind))), "Tool table is empty or lacks its expected primary tool: " + kind);
|
||||
result.add(Map.of("kind", kind.name(), "table", lootKey(kind).identifier().toString(), "sampled_seeds", List.of(0, 42, -1)));
|
||||
}
|
||||
report.put("tool_tables_sampled_separately", result);
|
||||
}
|
||||
private static ResourceKey<LootTable> lootKey(HeritagePlan19.Kind kind) { return ResourceKey.create(Registries.LOOT_TABLE, SanctuaryMod.id("chests/heritage19/" + kind.name().toLowerCase(Locale.ROOT))); }
|
||||
private static Item tool(HeritagePlan19.Kind kind) {
|
||||
return switch (kind) {
|
||||
case OBSERVATORY -> Items.SPYGLASS;
|
||||
case POST_OFFICE, EXPEDITION_OFFICE, RADIO_RELAY -> Items.COMPASS;
|
||||
case SUBSTATION, IMPOSSIBLE_SERVICE -> Items.CLOCK;
|
||||
case FREIGHT_STATION -> Items.MINECART;
|
||||
case COMMUNAL_DEPOT -> Items.IRON_AXE;
|
||||
case RAIL_WORKSHOP -> Items.IRON_PICKAXE;
|
||||
case PUMP_STATION -> Items.BUCKET;
|
||||
case GREENHOUSE -> Items.IRON_HOE;
|
||||
case VOID_DOCK -> Items.LEAD;
|
||||
case PHOTO_CLUB -> Items.BOOK;
|
||||
case CONSTRUCTION_REFUGE -> Items.IRON_SHOVEL;
|
||||
};
|
||||
}
|
||||
private static Set<BlockPos> walk(GameTestHelper helper, BlockPos start, Predicate<BlockPos> inside) {
|
||||
var level = helper.getLevel(); helper.assertTrue(inside.test(start) && standable(level, start), "Blocked or unsupported exterior entrance: " + start);
|
||||
var seen = new HashSet<BlockPos>(); var queue = new ArrayDeque<BlockPos>(); seen.add(start); queue.add(start);
|
||||
while (!queue.isEmpty()) {
|
||||
var pos = queue.removeFirst();
|
||||
for (var direction : HORIZONTAL) for (int dy = -1; dy <= 1; dy++) {
|
||||
var next = pos.relative(direction).offset(0, dy, 0);
|
||||
if (!inside.test(next) || dy > 0 && !clearBody(level, pos.above())) continue;
|
||||
if (standable(level, next) && seen.add(next)) queue.add(next);
|
||||
}
|
||||
for (int dy : new int[] {-1, 1}) {
|
||||
var next = pos.offset(0, dy, 0); if (!inside.test(next)) continue;
|
||||
if ((level.getBlockState(pos).is(Blocks.LADDER) || level.getBlockState(next).is(Blocks.LADDER) || level.getBlockState(pos.below()).is(Blocks.LADDER))
|
||||
&& standable(level, next) && seen.add(next)) queue.add(next);
|
||||
}
|
||||
helper.assertTrue(seen.size() <= 50_000, "Native site traversal escaped its bounds");
|
||||
}
|
||||
return seen;
|
||||
}
|
||||
private static boolean standable(ServerLevel level, BlockPos pos) {
|
||||
if (!clearBody(level, pos)) return false;
|
||||
if (level.getBlockState(pos).is(Blocks.LADDER) || level.getBlockState(pos.below()).is(Blocks.LADDER)) return true;
|
||||
var below = pos.below(); return level.getBlockState(below).getCollisionShape(level, below).toAabbs().stream()
|
||||
.anyMatch(b -> b.maxY >= .5 && b.minX <= .5 && b.maxX >= .5 && b.minZ <= .5 && b.maxZ >= .5);
|
||||
}
|
||||
private static boolean clearBody(ServerLevel level, BlockPos pos) {
|
||||
var body = new AABB(pos.getX() + .2, pos.getY(), pos.getZ() + .2, pos.getX() + .8, pos.getY() + 1.8, pos.getZ() + .8);
|
||||
for (var at : new BlockPos[] {pos, pos.above()}) {
|
||||
if (!level.getFluidState(at).isEmpty()) return false;
|
||||
for (var shape : level.getBlockState(at).getCollisionShape(level, at).toAabbs()) if (shape.move(at.getX(), at.getY(), at.getZ()).intersects(body)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private static long column(int x, int z) { return (long) x << 32 ^ z & 0xffffffffL; }
|
||||
private static List<Integer> coords(BlockPos pos) { return List.of(pos.getX(), pos.getY(), pos.getZ()); }
|
||||
private static BlockPos readPos(com.google.gson.JsonArray value) { return new BlockPos(value.get(0).getAsInt(), value.get(1).getAsInt(), value.get(2).getAsInt()); }
|
||||
private static Path world(ServerLevel level) { return level.getServer().getWorldPath(LevelResource.ROOT).toAbsolutePath().normalize(); }
|
||||
private static Path proof(ServerLevel level) { return world(level).resolve("heritage20-create-proof.json"); }
|
||||
private static String planHash(HeritagePlan19 plan) { return hash(plan.sites().toString() + plan.landmarks() + plan.links() + plan.segments()); }
|
||||
private static void write(ServerLevel level, Map<String, Object> report, boolean reload) throws IOException {
|
||||
var path = Path.of("diagnostics", "heritage20-" + (reload ? "reload" : "create") + ".json"); Files.createDirectories(path.getParent());
|
||||
var value = new GsonBuilder().setPrettyPrinting().create().toJson(report) + "\n"; Files.writeString(path, value); if (!reload) Files.writeString(proof(level), value);
|
||||
}
|
||||
private static String hash(String value) {
|
||||
try { return HexFormat.of().formatHex(MessageDigest.getInstance("SHA-256").digest(value.getBytes(StandardCharsets.UTF_8))); }
|
||||
catch (NoSuchAlgorithmException impossible) { throw new AssertionError(impossible); }
|
||||
}
|
||||
}
|
||||
+554
@@ -0,0 +1,554 @@
|
||||
package fr.koka.sanctuary.gametest;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import fr.koka.sanctuary.SanctuaryMod;
|
||||
import fr.koka.sanctuary.worldgen.SanctuaryChunkGenerator;
|
||||
import fr.koka.sanctuary.worldgen.city.LostCityRenderer;
|
||||
import fr.koka.sanctuary.worldgen.heritage.HeritagePiece21;
|
||||
import fr.koka.sanctuary.worldgen.heritage.HeritagePlan19;
|
||||
import fr.koka.sanctuary.worldgen.heritage.HeritageRenderer21;
|
||||
import fr.koka.sanctuary.worldgen.heritage.HeritageStructures19;
|
||||
import fr.koka.sanctuary.worldgen.ruins.RuinsPiece20;
|
||||
import fr.koka.sanctuary.worldgen.ruins.RuinsPlan17;
|
||||
import fr.koka.sanctuary.worldgen.ruins.RuinsRenderer20;
|
||||
import fr.koka.sanctuary.worldgen.ruins.RuinsStructures17;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.HexFormat;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import net.fabricmc.fabric.api.gametest.v1.GameTest;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.HolderSet;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.gametest.framework.GameTestHelper;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.DoorBlock;
|
||||
import net.minecraft.world.level.block.TrapDoorBlock;
|
||||
import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureStart;
|
||||
import net.minecraft.world.level.levelgen.structure.pieces.StructurePieceSerializationContext;
|
||||
import net.minecraft.world.level.storage.LevelResource;
|
||||
import net.minecraft.world.level.storage.loot.LootParams;
|
||||
import net.minecraft.world.level.storage.loot.LootTable;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
/** Native creation/reload proof confined to a disposable generation21 starter island. */
|
||||
public final class Heritage21WorldGameTests {
|
||||
private static final Direction[] HORIZONTAL = {Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST};
|
||||
@GameTest(maxTicks = 12000)
|
||||
public void heritagePersistsWithRealDestinations(GameTestHelper helper) {
|
||||
helper.assertTrue(helper.getLevel().getChunkSource().getGenerator() instanceof SanctuaryChunkGenerator,
|
||||
"The heritage proof requires a Sanctuary generator");
|
||||
var generator = (SanctuaryChunkGenerator) helper.getLevel().getChunkSource().getGenerator();
|
||||
helper.assertTrue(generator.rootGeneration() == 21, "Use a fresh generation21 test world; do not convert an old save");
|
||||
new Scenario(helper, generator, Boolean.getBoolean("sanctuary.test.expansionReload")).advance();
|
||||
}
|
||||
private static final class Scenario {
|
||||
final GameTestHelper helper;
|
||||
final ServerLevel level;
|
||||
final SanctuaryChunkGenerator generator;
|
||||
final HeritagePlan19 plan;
|
||||
final boolean reload;
|
||||
final Map<String, Object> report = new LinkedHashMap<>();
|
||||
final List<ChunkPos> chunks = new ArrayList<>();
|
||||
final List<StructureStart> starts = new ArrayList<>();
|
||||
final List<StructureStart> ruinsStarts = new ArrayList<>();
|
||||
JsonObject previous;
|
||||
BlockPos gold;
|
||||
int nextChunk;
|
||||
boolean prepared;
|
||||
Scenario(GameTestHelper helper, SanctuaryChunkGenerator generator, boolean reload) {
|
||||
this.helper = helper; this.level = helper.getLevel(); this.generator = generator; this.reload = reload;
|
||||
this.plan = generator.heritagePlan19();
|
||||
report.put("seed", level.getSeed()); report.put("size", generator.initialDiameter());
|
||||
report.put("process_id", ProcessHandle.current().pid()); report.put("world_directory", world(level).toString());
|
||||
report.put("experimental_structures", generator.experimentalStructures());
|
||||
report.put("structures_enabled", level.structureManager().shouldGenerateStructures());
|
||||
report.put("scope", "Native local starts, saved sites and routes, player-sized entrances, supports and unopened chests on the starter island. "
|
||||
+ "All14 tool tables are sampled separately without consuming a saved chest. Door states are restored after traversal. "
|
||||
+ "No personal save or expansion is opened; one disposable outer-wall edit is checked in a second JVM. "
|
||||
+ "Missing rails are intentional; this proof checks walking and saved rail shapes, not an uninterrupted minecart journey.");
|
||||
}
|
||||
void advance() {
|
||||
try {
|
||||
if (!prepared) { report.put("stage", "prepare"); prepare(); prepared = true; if (plan.isEmpty()) { finishDisabled(); return; } }
|
||||
if (nextChunk < chunks.size()) {
|
||||
report.put("stage", "load_full_chunks"); var pos = chunks.get(nextChunk++);
|
||||
helper.assertTrue(level.getChunk(pos.x(), pos.z(), ChunkStatus.FULL, true) instanceof LevelChunk,
|
||||
"Heritage footprint must reach native FULL: " + pos);
|
||||
if (nextChunk % 20 == 0) SanctuaryMod.LOGGER.info("Heritage21 loaded {}/{} footprint chunks", nextChunk, chunks.size());
|
||||
helper.runAtTickTime(helper.getTick() + 1, this::advance); return;
|
||||
}
|
||||
report.put("stage", "verify_native_geometry"); verifyPlaced(); report.put("passed", true);
|
||||
if (!reload) {
|
||||
helper.assertTrue(gold != null && level.getBlockState(gold).isCollisionShapeFullBlock(level, gold), "Gold witness must replace a solid wall away from circulation");
|
||||
level.setBlock(gold, Blocks.GOLD_BLOCK.defaultBlockState(), 3); report.put("gold_witness", coords(gold));
|
||||
helper.assertTrue(level.getServer().saveEverything(true, true, true), "Flush native starts, unopened loot and the wall edit");
|
||||
report.put("world_flushed_before_shutdown", true);
|
||||
} else {
|
||||
helper.assertTrue(level.getBlockState(gold).is(Blocks.GOLD_BLOCK), "Reload replaced the player's wall edit");
|
||||
report.put("gold_witness", coords(gold)); report.put("gold_witness_preserved", true);
|
||||
}
|
||||
write(level, report, reload); helper.succeed();
|
||||
} catch (Exception failure) {
|
||||
report.put("passed", false); report.put("failure", failure.toString());
|
||||
try { write(level, report, reload); } catch (IOException ignored) { }
|
||||
throw new IllegalStateException("Heritage21 native " + (reload ? "reload" : "creation") + " failed", failure);
|
||||
}
|
||||
}
|
||||
void prepare() throws IOException {
|
||||
var ops = RegistryOps.create(JsonOps.INSTANCE, level.registryAccess());
|
||||
var encoded = ChunkGenerator.CODEC.encodeStart(ops, generator).getOrThrow();
|
||||
var decoded = ChunkGenerator.CODEC.parse(ops, encoded).getOrThrow();
|
||||
helper.assertTrue(decoded instanceof SanctuaryChunkGenerator copy && copy.rootGeneration() == 21
|
||||
&& copy.experimentalStructures() == generator.experimentalStructures(), "Generation21 codec lost its experimental switch");
|
||||
report.put("generator_codec", encoded); report.put("plan_sha256", planHash(plan));
|
||||
report.put("planned_sites", plan.sites().stream().map(site -> Map.of("id", site.id(), "kind", site.kind().name(),
|
||||
"entry", coords(HeritagePiece21.locator(site)), "floor_y", site.floorY(), "foundation_depth", site.foundationDepth(), "footings", site.supports().size())).toList());
|
||||
report.put("planned_links", plan.links().stream().map(link -> Map.of("id", link.id(), "from", link.fromId(), "to", link.toId(), "kind", link.kind().name(), "length", link.path().size(), "path", pathCoords(link))).toList());
|
||||
report.put("planning_samples", plan.samples()); report.put("planning_columns", plan.columns()); report.put("planning_diagnostics", plan.diagnostics());
|
||||
helper.assertTrue(plan.samples() <= HeritagePlan19.MAX_SAMPLES && plan.columns() <= HeritagePlan19.MAX_COLUMNS, "Heritage planning exceeded its budget");
|
||||
verifyLootTables(helper, report);
|
||||
if (reload) {
|
||||
previous = JsonParser.parseString(Files.readString(proof(level))).getAsJsonObject();
|
||||
helper.assertTrue(previous.get("passed").getAsBoolean() && previous.get("world_flushed_before_shutdown").getAsBoolean(), "Reload needs a successful flushed creation proof");
|
||||
helper.assertTrue(previous.get("process_id").getAsLong() != ProcessHandle.current().pid(), "Reload must use a second JVM");
|
||||
helper.assertTrue(previous.get("seed").getAsLong() == level.getSeed() && previous.get("size").getAsInt() == generator.initialDiameter()
|
||||
&& previous.get("world_directory").getAsString().equals(world(level).toString()), "Reload selected another world");
|
||||
helper.assertTrue(previous.get("generator_codec").equals(encoded) && previous.get("plan_sha256").getAsString().equals(planHash(plan)), "Saved settings or planned identities changed on reload");
|
||||
if (previous.has("gold_witness")) gold = readPos(previous.getAsJsonArray("gold_witness"));
|
||||
}
|
||||
if (!generator.experimentalStructures() || !level.structureManager().shouldGenerateStructures()) {
|
||||
helper.assertTrue(plan.isEmpty() && plan.segments().isEmpty() && plan.links().isEmpty(), "Disabled generation published heritage geometry"); return;
|
||||
}
|
||||
helper.assertTrue(!plan.isEmpty(), "Enabled reference island has no heritage site");
|
||||
report.put("present_site_kinds", plan.sites().stream().map(s -> s.kind().name()).distinct().sorted().toList());
|
||||
report.put("missing_site_kinds", java.util.Arrays.stream(HeritagePlan19.Kind.values()).filter(k -> plan.sites().stream().noneMatch(s -> s.kind() == k)).map(Enum::name).toList());
|
||||
var structure = level.registryAccess().lookupOrThrow(Registries.STRUCTURE).getOrThrow(HeritageStructures19.KEY);
|
||||
var origins = new HashSet<ChunkPos>(); var uniqueChunks = new HashSet<ChunkPos>();
|
||||
plan.sites().forEach(s -> origins.add(new ChunkPos(s.startChunkX(), s.startChunkZ())));
|
||||
plan.segments().forEach(s -> origins.add(new ChunkPos(s.startChunkX(), s.startChunkZ())));
|
||||
for (var origin : origins.stream().sorted(Comparator.comparingInt(ChunkPos::x).thenComparingInt(ChunkPos::z)).toList()) {
|
||||
var chunk = level.getChunk(origin.x(), origin.z(), ChunkStatus.STRUCTURE_STARTS, true);
|
||||
var start = chunk.getStartForStructure(structure.value());
|
||||
helper.assertTrue(start != null && start.isValid(), "Accepted site/route has no native start at " + origin); starts.add(start);
|
||||
for (var piece : start.getPieces()) {
|
||||
helper.assertTrue(piece instanceof HeritagePiece21, "Heritage loaded a foreign piece type");
|
||||
var box = piece.getBoundingBox();
|
||||
helper.assertTrue(Math.abs((long) (box.minX() >> 4) - origin.x()) <= 7 && Math.abs((long) (box.maxX() >> 4) - origin.x()) <= 7
|
||||
&& Math.abs((long) (box.minZ() >> 4) - origin.z()) <= 7 && Math.abs((long) (box.maxZ() >> 4) - origin.z()) <= 7, "Native start references a distant route endpoint");
|
||||
box.intersectingChunks().forEach(uniqueChunks::add);
|
||||
}
|
||||
}
|
||||
for (var site : plan.sites()) uniqueChunks.add(ChunkPos.containing(HeritagePiece21.locator(site)));
|
||||
for (var link : plan.links()) for (var point : link.path()) uniqueChunks.add(new ChunkPos(point.x() >> 4, point.z() >> 4));
|
||||
helper.assertTrue(uniqueChunks.size() <= 1024, "Bounded proof footprint exceeds1024 chunks");
|
||||
var ruins = generator.ruinsPlan17();
|
||||
report.put("ruins_plan_sha256", hash(ruins.networks().toString()));
|
||||
if (reload) helper.assertTrue(previous.get("ruins_plan_sha256").getAsString().equals(hash(ruins.networks().toString())), "Reload changed forgotten room planning");
|
||||
helper.assertTrue(!ruins.isEmpty(), "Reference20 must demonstrate native experimental room architecture");
|
||||
var ruinsType = level.registryAccess().lookupOrThrow(Registries.STRUCTURE).getOrThrow(RuinsStructures17.KEY);
|
||||
var ruinsOrigins = new HashSet<ChunkPos>();
|
||||
for (var network : ruins.networks()) {
|
||||
var origin = new ChunkPos(network.startChunkX(), network.startChunkZ()); if (!ruinsOrigins.add(origin)) continue;
|
||||
var nativeStart = level.getChunk(origin.x(), origin.z(), ChunkStatus.STRUCTURE_STARTS, true).getStartForStructure(ruinsType.value());
|
||||
helper.assertTrue(nativeStart != null && nativeStart.isValid(), "Missing native20 forgotten network: " + network.id());
|
||||
ruinsStarts.add(nativeStart);
|
||||
for (var piece : nativeStart.getPieces()) {
|
||||
helper.assertTrue(piece instanceof RuinsPiece20, "Generation21 loaded a historical forgotten piece");
|
||||
piece.getBoundingBox().intersectingChunks().forEach(uniqueChunks::add);
|
||||
}
|
||||
}
|
||||
chunks.addAll(uniqueChunks.stream().sorted(Comparator.comparingInt(ChunkPos::x).thenComparingInt(ChunkPos::z)).toList());
|
||||
}
|
||||
void finishDisabled() throws IOException {
|
||||
var structure = level.registryAccess().lookupOrThrow(Registries.STRUCTURE).getOrThrow(HeritageStructures19.KEY);
|
||||
var start = level.getChunk(0, 0, ChunkStatus.STRUCTURE_STARTS, true).getStartForStructure(structure.value());
|
||||
helper.assertTrue(start == null || !start.isValid(), "Disabled heritage emitted a native start");
|
||||
helper.assertTrue(generator.findNearestMapStructure(level, HolderSet.direct(structure), new BlockPos(0, 250, 0), 100, false) == null, "Disabled heritage is locatable");
|
||||
report.put("empty_plan_verified", true); report.put("passed", true);
|
||||
if (!reload) { helper.assertTrue(level.getServer().saveEverything(true, true, true), "Save disabled experiment setting"); report.put("world_flushed_before_shutdown", true); }
|
||||
write(level, report, reload); helper.succeed();
|
||||
}
|
||||
void verifyPlaced() {
|
||||
var structure = level.registryAccess().lookupOrThrow(Registries.STRUCTURE).getOrThrow(HeritageStructures19.KEY);
|
||||
var context = StructurePieceSerializationContext.fromLevel(level); var summaries = new ArrayList<Map<String, Object>>();
|
||||
int blocks = 0, chests = 0, pieces = 0, supports = 0;
|
||||
var connections = NativeConnections20.Stats.empty();
|
||||
for (var start : starts) {
|
||||
var origin = start.getChunkPos(); var saved = start.createTag(context, origin); String nativeHash = hash(saved.toString());
|
||||
var copy = StructureStart.loadStaticStart(context, saved, level.getSeed());
|
||||
helper.assertTrue(copy != null && copy.isValid() && copy.createTag(context, origin).equals(saved), "Native start failed an exact NBT roundtrip");
|
||||
var expectedPayloads = new HashSet<net.minecraft.nbt.CompoundTag>();
|
||||
plan.sites().stream().filter(s -> s.startChunkX() == origin.x() && s.startChunkZ() == origin.z()).forEach(s -> expectedPayloads.add(HeritagePiece21.encodeSite(s)));
|
||||
plan.segments().stream().filter(s -> s.startChunkX() == origin.x() && s.startChunkZ() == origin.z()).forEach(s -> expectedPayloads.add(HeritagePiece21.encodeSegment(s)));
|
||||
var actualPayloads = new HashSet<net.minecraft.nbt.CompoundTag>();
|
||||
if (reload) {
|
||||
JsonObject prior = null;
|
||||
for (var value : previous.getAsJsonArray("starts")) { var item = value.getAsJsonObject(); var at = item.getAsJsonArray("start_chunk"); if (at.get(0).getAsInt() == origin.x() && at.get(1).getAsInt() == origin.z()) prior = item; }
|
||||
helper.assertTrue(prior != null && prior.get("native_start_sha256").getAsString().equals(nativeHash), "Reload changed saved geometry or native reference count");
|
||||
}
|
||||
var loot = new ArrayList<Map<String, Object>>();
|
||||
for (var value : start.getPieces()) {
|
||||
var piece = (HeritagePiece21) value; pieces++;
|
||||
var tag = piece.createTag(context); var restored = new HeritagePiece21(context, tag);
|
||||
helper.assertTrue(restored.createTag(context).equals(tag), "Saved piece parameters changed on native load");
|
||||
actualPayloads.add(tag.getCompound("SanctuaryHeritage").orElseThrow());
|
||||
var corrupt = tag.copy(); corrupt.getCompound("SanctuaryHeritage").orElseThrow().putInt("Schema", 22);
|
||||
boolean rejected = false; try { new HeritagePiece21(context, corrupt); } catch (IllegalArgumentException expected) { rejected = true; }
|
||||
helper.assertTrue(rejected, "Unknown schema must fail closed");
|
||||
piece.getBoundingBox().intersectingChunks().forEach(at -> helper.assertTrue(level.getChunk(at.x(), at.z(), ChunkStatus.FULL, true)
|
||||
.getReferencesForStructure(structure.value()).contains(origin.pack()), "FULL chunk lost its native structure reference"));
|
||||
var expected = rendered(piece); blocks += expected.blocks().size();
|
||||
for (var entry : expected.blocks().entrySet()) {
|
||||
var at = entry.getKey(); var wanted = entry.getValue(); helper.assertTrue(piece.getBoundingBox().isInside(at), "Renderer escaped saved bounds");
|
||||
if (reload && at.equals(gold)) continue;
|
||||
helper.assertTrue(level.getBlockState(at).is(wanted.getBlock()), "Clipping or decoration changed heritage at " + at + ": expected " + wanted + " got " + level.getBlockState(at));
|
||||
helper.assertTrue(!wanted.is(Blocks.SPAWNER), "Heritage must not create spawners");
|
||||
}
|
||||
connections = connections.add(NativeConnections20.verify(helper, expected.blocks(), reload ? Set.of(gold) : Set.of()));
|
||||
if (piece.isSite()) {
|
||||
supports += verifySiteBearing(helper, generator, plan, piece.site());
|
||||
if (!reload && gold == null) {
|
||||
gold = expected.blocks().entrySet().stream().filter(e -> isOuterWall(piece.site(), e.getKey()) && e.getValue().isCollisionShapeFullBlock(level, e.getKey()))
|
||||
.map(Map.Entry::getKey).sorted(Comparator.<BlockPos>comparingInt(p -> p.getY()).thenComparingInt(p -> p.getX()).thenComparingInt(p -> p.getZ())).findFirst().orElse(null);
|
||||
}
|
||||
} else for (var cell : piece.segment().cells()) { supports++; assertRock(helper, new BlockPos(cell.x(), cell.minY() - 1, cell.z())); }
|
||||
for (var chest : expected.chests()) {
|
||||
helper.assertTrue(level.getBlockEntity(chest.position()) instanceof RandomizableContainerBlockEntity, "Deferred chest is missing");
|
||||
var entity = (RandomizableContainerBlockEntity) level.getBlockEntity(chest.position());
|
||||
helper.assertTrue(entity.getLootTable() != null && entity.getLootTable().equals(chest.table()) && entity.getLootTableSeed() == chest.seed(), "Deferred loot table/seed was lost or consumed");
|
||||
if (piece.isSite()) helper.assertTrue(chest.table().equals(lootKey(piece.site().kind())), "Site uses another kind's tool table");
|
||||
loot.add(Map.of("position", coords(chest.position()), "table", chest.table().identifier().toString(), "seed", chest.seed())); chests++;
|
||||
}
|
||||
}
|
||||
helper.assertTrue(actualPayloads.equals(expectedPayloads) && start.getPieces().size() == expectedPayloads.size(), "Native start lost or duplicated planned pieces");
|
||||
summaries.add(Map.of("start_chunk", List.of(origin.x(), origin.z()), "native_start_sha256", nativeHash, "pieces", start.getPieces().size(), "unopened_chests", loot));
|
||||
}
|
||||
report.put("connected_blocks", connections);
|
||||
helper.assertTrue(connections.panes() > 0 && connections.stairs() > 0 && connections.nativeOracles() > 0,
|
||||
"Reference20 needs real panes/stairs validated by vanilla neighbor rules");
|
||||
if (level.getSeed() == 0 && generator.initialDiameter() == 724)
|
||||
helper.assertTrue(connections.crossChunkPaneLinks() > 0, "Reference20 must demonstrate a real pane join across a chunk boundary");
|
||||
verifyRuins();
|
||||
report.put("starts", summaries); report.put("native_pieces", pieces); report.put("native_blocks_checked", blocks);
|
||||
report.put("full_chunks_checked", chunks.size()); report.put("rock_supports_checked", supports); report.put("unopened_deferred_chests", chests);
|
||||
report.put("stage", "verify_site_routes"); var sites = new ArrayList<Map<String, Object>>(); for (var site : plan.sites()) sites.add(verifyAccess(helper, site)); report.put("native_sites", sites);
|
||||
report.put("stage", "verify_read_only_landings");
|
||||
report.put("read_only_landmarks", verifyReadOnlyLandings(helper, generator, plan));
|
||||
report.put("stage", "verify_island_routes"); report.put("native_links", verifyLinks(helper, plan));
|
||||
int greatestSpan = plan.links().stream().mapToInt(Heritage21WorldGameTests::routeSpan).max().orElse(0);
|
||||
report.put("greatest_single_route_span", greatestSpan);
|
||||
var reachedIds = new HashSet<String>(); plan.links().forEach(l -> { reachedIds.add(l.fromId()); reachedIds.add(l.toId()); });
|
||||
report.put("connected_destination_ids", reachedIds.stream().sorted().toList());
|
||||
report.put("isolated_destination_ids", plan.sites().stream().map(HeritagePlan19.Site::id).filter(id -> !reachedIds.contains(id)).toList());
|
||||
report.put("connected_city_arrivals", plan.landmarks().stream().filter(l -> l.kind() == HeritagePlan19.LandmarkKind.CITY && reachedIds.contains(l.id())).map(HeritagePlan19.Landmark::id).toList());
|
||||
var located = generator.findNearestMapStructure(level, HolderSet.direct(structure), new BlockPos(0, 250, 0), 100, false);
|
||||
helper.assertTrue(located != null && located.getSecond().is(HeritageStructures19.KEY) && plan.sites().stream().anyMatch(s -> HeritagePiece21.locator(s).equals(located.getFirst())), "Locate must lead to a real exterior site entry");
|
||||
report.put("locate", coords(located.getFirst()));
|
||||
}
|
||||
void verifyRuins() {
|
||||
var context = StructurePieceSerializationContext.fromLevel(level);
|
||||
var registry = level.registryAccess().lookupOrThrow(Registries.STRUCTURE).getOrThrow(RuinsStructures17.KEY);
|
||||
var summaries = new ArrayList<Map<String, Object>>(); int count = 0, blockCount = 0, lootCount = 0;
|
||||
var connections = NativeConnections20.Stats.empty();
|
||||
for (var start : ruinsStarts) {
|
||||
var origin = start.getChunkPos(); var saved = start.createTag(context, origin); var digest = hash(saved.toString());
|
||||
var loaded = StructureStart.loadStaticStart(context, saved, level.getSeed());
|
||||
helper.assertTrue(loaded != null && loaded.createTag(context, origin).equals(saved), "Forgotten20 native start NBT changed");
|
||||
var expectedRooms = generator.ruinsPlan17().networks().stream().filter(n -> n.startChunkX() == origin.x() && n.startChunkZ() == origin.z()).flatMap(n -> n.rooms().stream()).toList();
|
||||
var actualRooms = start.getPieces().stream().map(RuinsPiece20.class::cast).map(RuinsPiece20::room).toList();
|
||||
helper.assertTrue(expectedRooms.size() == actualRooms.size() && new HashSet<>(expectedRooms).equals(new HashSet<>(actualRooms)), "Forgotten20 native rooms differ from plan");
|
||||
if (reload) {
|
||||
JsonObject prior = null;
|
||||
for (var value : previous.getAsJsonArray("ruins_starts")) { var item = value.getAsJsonObject(); var at = item.getAsJsonArray("start_chunk"); if (at.get(0).getAsInt() == origin.x() && at.get(1).getAsInt() == origin.z()) prior = item; }
|
||||
helper.assertTrue(prior != null && prior.get("native_start_sha256").getAsString().equals(digest), "Forgotten20 native start changed on a second JVM load");
|
||||
}
|
||||
for (var raw : start.getPieces()) {
|
||||
var piece = (RuinsPiece20) raw; var room = piece.room(); count++;
|
||||
var tag = piece.createTag(context); var roundtrip = new RuinsPiece20(context, tag);
|
||||
helper.assertTrue(roundtrip.room().equals(room) && roundtrip.createTag(context).equals(tag), "Forgotten20 piece lost saved parameters");
|
||||
piece.getBoundingBox().intersectingChunks().forEach(at -> helper.assertTrue(level.getChunk(at.x(), at.z(), ChunkStatus.FULL, true).getReferencesForStructure(registry.value()).contains(origin.pack()), "Forgotten20 chunk lost native references"));
|
||||
var expected = rendered(room); blockCount += expected.blocks().size();
|
||||
for (var entry : expected.blocks().entrySet()) {
|
||||
helper.assertTrue(piece.getBoundingBox().isInside(entry.getKey()), "Forgotten20 renderer escaped saved bounds");
|
||||
helper.assertTrue(level.getBlockState(entry.getKey()).is(entry.getValue().getBlock()), "Forgotten20 native geometry changed at " + entry.getKey());
|
||||
}
|
||||
connections = connections.add(NativeConnections20.verify(helper, expected.blocks(), Set.of()));
|
||||
for (var support : room.supports()) assertRock(helper, new BlockPos(support.x(), support.minY() - 1, support.z()));
|
||||
for (var chest : expected.chests()) {
|
||||
helper.assertTrue(level.getBlockEntity(chest.position()) instanceof RandomizableContainerBlockEntity, "Forgotten20 missing deferred chest");
|
||||
var entity = (RandomizableContainerBlockEntity) level.getBlockEntity(chest.position());
|
||||
helper.assertTrue(chest.table().equals(entity.getLootTable()) && chest.seed() == entity.getLootTableSeed(), "Forgotten20 consumed/changed saved loot"); lootCount++;
|
||||
}
|
||||
}
|
||||
summaries.add(Map.of("start_chunk", List.of(origin.x(), origin.z()), "native_start_sha256", digest, "pieces", start.getPieces().size()));
|
||||
}
|
||||
report.put("ruins_starts", summaries); report.put("ruins_native_pieces", count); report.put("ruins_native_blocks_checked", blockCount);
|
||||
report.put("ruins_unopened_deferred_chests", lootCount); report.put("ruins_connections", connections);
|
||||
report.put("ruins_access", generator.ruinsPlan17().networks().stream().map(n -> verifyAccess(helper, n)).toList());
|
||||
}
|
||||
}
|
||||
private record Chest(BlockPos position, ResourceKey<LootTable> table, long seed) {}
|
||||
private record Rendered(Map<BlockPos, BlockState> blocks, List<Chest> chests) {}
|
||||
private static Rendered rendered(HeritagePiece21 piece) {
|
||||
var blocks = new HashMap<BlockPos, BlockState>(); var chests = new ArrayList<Chest>();
|
||||
int x0 = piece.isSite() ? piece.site().minX() : piece.segment().minX();
|
||||
int y0 = piece.isSite() ? piece.site().floorY() : piece.segment().minY();
|
||||
int z0 = piece.isSite() ? piece.site().minZ() : piece.segment().minZ();
|
||||
var writer = new LostCityRenderer.BlockWriter() {
|
||||
@Override public void set(int x, int y, int z, BlockState state) { blocks.put(new BlockPos(x0 + x, y0 + y, z0 + z), state); }
|
||||
@Override public void chest(int x, int y, int z, ResourceKey<LootTable> table, long seed) {
|
||||
var at = new BlockPos(x0 + x, y0 + y, z0 + z); blocks.put(at, Blocks.CHEST.defaultBlockState()); chests.add(new Chest(at, table, RandomSource.create(seed).nextLong()));
|
||||
}
|
||||
};
|
||||
if (piece.isSite()) HeritageRenderer21.render(piece.site(), writer); else HeritageRenderer21.renderSegment(piece.segment(), writer);
|
||||
return new Rendered(blocks, chests);
|
||||
}
|
||||
private static Rendered rendered(RuinsPlan17.Room room) {
|
||||
var blocks = new HashMap<BlockPos, BlockState>(); var chests = new ArrayList<Chest>();
|
||||
RuinsRenderer20.render(room, new LostCityRenderer.BlockWriter() {
|
||||
@Override public void set(int x, int y, int z, BlockState state) { blocks.put(at(room, x, y, z), state); }
|
||||
@Override public void chest(int x, int y, int z, ResourceKey<LootTable> table, long seed) {
|
||||
var position = at(room, x, y, z); blocks.put(position, Blocks.CHEST.defaultBlockState()); chests.add(new Chest(position, table, RandomSource.create(seed).nextLong()));
|
||||
}
|
||||
});
|
||||
return new Rendered(blocks, chests);
|
||||
}
|
||||
private static Map<String, Object> verifyAccess(GameTestHelper helper, RuinsPlan17.Network network) {
|
||||
var level = helper.getLevel(); var access = network.rooms().stream().filter(r -> r.kind() == RuinsPlan17.Kind.ACCESS).findFirst().orElseThrow();
|
||||
var hatches = new HashMap<BlockPos, BlockState>();
|
||||
rendered(access).blocks().forEach((at, state) -> { if (state.is(Blocks.DARK_OAK_TRAPDOOR)) hatches.put(at, level.getBlockState(at)); });
|
||||
helper.assertTrue(hatches.size() == 1, "Each network must have one usable wooden surface hatch");
|
||||
hatches.forEach((at, state) -> {
|
||||
helper.assertTrue(state.is(Blocks.DARK_OAK_TRAPDOOR) && state.canSurvive(level, at), "Surface hatch is missing its native support");
|
||||
level.setBlock(at, state.setValue(BlockStateProperties.OPEN, true), 2);
|
||||
});
|
||||
try {
|
||||
Predicate<BlockPos> inside = pos -> network.rooms().stream().anyMatch(r -> r.contains(pos.getX(), pos.getY(), pos.getZ()));
|
||||
var start = RuinsPiece20.locator(access); var reached = walk(helper, start, inside);
|
||||
int targets = 0;
|
||||
for (var room : network.rooms()) for (var target : RuinsRenderer20.targets(room)) {
|
||||
var point = at(room, target.x(), target.y(), target.z());
|
||||
helper.assertTrue(reached.contains(point), "Native network " + network.id() + " cannot reach " + room.kind() + "/" + target.name() + " at " + point);
|
||||
targets++;
|
||||
}
|
||||
for (var hatch : hatches.keySet()) helper.assertTrue(reached.contains(hatch), "Surface approach cannot enter its ladder shaft");
|
||||
return Map.of("id", network.id(), "family", network.family().name(), "rooms", network.rooms().size(),
|
||||
"entrance", coords(start), "walkable_targets", targets, "standing_cells", reached.size());
|
||||
} finally { hatches.forEach((at, state) -> level.setBlock(at, state, 2)); }
|
||||
}
|
||||
private static BlockPos at(RuinsPlan17.Room room, int x, int y, int z) { return new BlockPos(room.minX() + x, room.minY() + y, room.minZ() + z); }
|
||||
private static boolean isOuterWall(HeritagePlan19.Site site, BlockPos pos) {
|
||||
return pos.getY() >= site.floorY() + 2 && pos.getY() <= site.floorY() + 3
|
||||
&& (pos.getX() == site.minX() + 2 || pos.getX() == site.maxX() - 2 || pos.getZ() == site.minZ() + 2 || pos.getZ() == site.maxZ() - 2)
|
||||
&& Math.abs(pos.getX() - site.entry().x()) + Math.abs(pos.getZ() - site.entry().z()) > 6;
|
||||
}
|
||||
private static Map<String, Object> verifyAccess(GameTestHelper helper, HeritagePlan19.Site site) {
|
||||
var level = helper.getLevel(); var expected = rendered(new HeritagePiece21(site)); var doors = new HashMap<BlockPos, BlockState>();
|
||||
expected.blocks().forEach((at, state) -> {
|
||||
if ((state.getBlock() instanceof DoorBlock || state.getBlock() instanceof TrapDoorBlock) && state.hasProperty(BlockStateProperties.OPEN)) doors.put(at, level.getBlockState(at));
|
||||
});
|
||||
doors.forEach((at, state) -> level.setBlock(at, state.setValue(BlockStateProperties.OPEN, true), 2));
|
||||
try {
|
||||
var entry = HeritagePiece21.locator(site);
|
||||
Predicate<BlockPos> inside = p -> p.equals(entry) || p.getX() >= site.minX() && p.getX() <= site.maxX()
|
||||
&& p.getZ() >= site.minZ() && p.getZ() <= site.maxZ() && p.getY() >= site.floorY() - 4 && p.getY() < site.maxY();
|
||||
var reached = walk(helper, entry, inside); int targets = 0;
|
||||
for (var target : HeritageRenderer21.targets(site)) {
|
||||
var at = new BlockPos(site.minX() + target.x(), site.floorY() + target.y(), site.minZ() + target.z());
|
||||
helper.assertTrue(reached.contains(at), "Site " + site.id() + " cannot reach " + target.name() + " at " + at); targets++;
|
||||
}
|
||||
return Map.of("id", site.id(), "kind", site.kind().name(), "entry", coords(entry), "standing_cells", reached.size(), "walkable_targets", targets);
|
||||
} finally { doors.forEach((at, state) -> level.setBlock(at, state, 2)); }
|
||||
}
|
||||
private static List<Map<String, Object>> verifyLinks(GameTestHelper helper, HeritagePlan19 plan) {
|
||||
helper.assertTrue(!plan.links().isEmpty(), "Reference island needs a real route between accepted destinations");
|
||||
var entries = new HashMap<String, HeritagePlan19.Entry>(); plan.sites().forEach(s -> entries.put(s.id(), s.entry())); plan.landmarks().forEach(s -> entries.put(s.id(), s.entry()));
|
||||
var cells = new HashMap<Long, HeritagePlan19.Cell>(); plan.segments().forEach(s -> s.cells().forEach(c -> cells.put(column(c.x(), c.z()), c)));
|
||||
var result = new ArrayList<Map<String, Object>>();
|
||||
for (var link : plan.links()) {
|
||||
var from = entries.get(link.fromId()); var to = entries.get(link.toId());
|
||||
helper.assertTrue(from != null && to != null, "Route points to an absent destination");
|
||||
var first = link.path().getFirst(); var last = link.path().getLast();
|
||||
helper.assertTrue(first.x() == from.x() && first.z() == from.z() && first.floorY() + 1 == from.y()
|
||||
&& last.x() == to.x() && last.z() == to.z() && last.floorY() + 1 == to.y(), "Route does not meet its real entrances");
|
||||
int present = 0, missing = 0;
|
||||
for (int i = 0; i < link.path().size(); i++) {
|
||||
var point = link.path().get(i); var at = new BlockPos(point.x(), point.floorY() + 1, point.z());
|
||||
helper.assertTrue(standable(helper.getLevel(), at), "Ballast route " + link.id() + " is blocked at " + at);
|
||||
if (i > 0) { var prior = link.path().get(i - 1); if (point.floorY() > prior.floorY()) helper.assertTrue(clearBody(helper.getLevel(), new BlockPos(prior.x(), prior.floorY() + 2, prior.z())), "Route slope cannot be climbed by a player"); }
|
||||
var cell = cells.get(column(point.x(), point.z()));
|
||||
if (cell != null && cell.rail() != HeritagePlan19.Rail.NONE) {
|
||||
var actual = helper.getLevel().getBlockState(at);
|
||||
if (cell.railPresent()) {
|
||||
helper.assertTrue(actual.is(Blocks.RAIL), "Saved existing rail disappeared");
|
||||
helper.assertTrue(actual.getValue(BlockStateProperties.RAIL_SHAPE).name().equals(cell.rail().name()), "Native rail update changed the intended slope or curve at " + at); present++;
|
||||
} else { helper.assertTrue(!actual.is(Blocks.RAIL), "An intentionally missing rail regenerated"); missing++; }
|
||||
}
|
||||
}
|
||||
int spanX = link.path().stream().mapToInt(HeritagePlan19.Point::x).max().orElseThrow() - link.path().stream().mapToInt(HeritagePlan19.Point::x).min().orElseThrow();
|
||||
int spanZ = link.path().stream().mapToInt(HeritagePlan19.Point::z).max().orElseThrow() - link.path().stream().mapToInt(HeritagePlan19.Point::z).min().orElseThrow();
|
||||
result.add(Map.of("id", link.id(), "from", link.fromId(), "to", link.toId(), "kind", link.kind().name(), "length", link.path().size(),
|
||||
"span_x", spanX, "span_z", spanZ, "existing_rails", present, "deliberately_missing_rails", missing, "path", pathCoords(link)));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private static int routeSpan(HeritagePlan19.Link link) {
|
||||
int spanX = link.path().stream().mapToInt(HeritagePlan19.Point::x).max().orElseThrow()
|
||||
- link.path().stream().mapToInt(HeritagePlan19.Point::x).min().orElseThrow();
|
||||
int spanZ = link.path().stream().mapToInt(HeritagePlan19.Point::z).max().orElseThrow()
|
||||
- link.path().stream().mapToInt(HeritagePlan19.Point::z).min().orElseThrow();
|
||||
return Math.max(spanX, spanZ);
|
||||
}
|
||||
private static List<List<Integer>> pathCoords(HeritagePlan19.Link link) {
|
||||
return link.path().stream().map(point -> List.of(point.x(), point.floorY(), point.z())).toList();
|
||||
}
|
||||
private static int verifySiteBearing(GameTestHelper helper, SanctuaryChunkGenerator generator, HeritagePlan19 plan, HeritagePlan19.Site site) {
|
||||
int checked = 0;
|
||||
// The planner certifies a nine-point bearing grid, either directly below its slab or below a saved short footing.
|
||||
for (int dx : new int[] {1, 8, 15}) for (int dz : new int[] {1, 8, 15}) {
|
||||
int x = site.minX() + dx, z = site.minZ() + dz;
|
||||
var support = site.supports().stream().filter(s -> s.x() == x && s.z() == z).findFirst();
|
||||
int bottom = support.map(HeritagePlan19.Support::minY).orElse(site.minY());
|
||||
for (int below = 1; below <= 2; below++) {
|
||||
var at = new BlockPos(x, bottom - below, z); assertRock(helper, at);
|
||||
helper.assertTrue(plan.protects(at.getX(), at.getY(), at.getZ()) && generator.protectsCityDecoration(at),
|
||||
"Site's certified bearing layer is not published in the decoration mask: " + site.id() + " at " + at);
|
||||
helper.assertTrue(!plan.contains(at.getX(), at.getY(), at.getZ()), "Original bearing rock became a writable heritage volume: " + at);
|
||||
checked++;
|
||||
}
|
||||
}
|
||||
return checked;
|
||||
}
|
||||
private static List<Map<String, Object>> verifyReadOnlyLandings(GameTestHelper helper, SanctuaryChunkGenerator generator, HeritagePlan19 plan) {
|
||||
var used = new HashSet<String>(); plan.links().forEach(link -> { used.add(link.fromId()); used.add(link.toId()); });
|
||||
var result = new ArrayList<Map<String, Object>>();
|
||||
for (var landmark : plan.landmarks()) if (used.contains(landmark.id())) {
|
||||
var e = landmark.entry(); int checked = 0;
|
||||
for (int side = -1; side <= 1; side++) {
|
||||
int x = e.x() + ((e.facing() & 1) == 0 ? side : 0), z = e.z() + ((e.facing() & 1) == 1 ? side : 0);
|
||||
for (int y = e.y() - 2; y <= e.y() + 2; y++) {
|
||||
var at = new BlockPos(x, y, z);
|
||||
helper.assertTrue(plan.protects(x, y, z) && generator.protectsCityDecoration(at), "Read-only arrival lost its decoration mask: " + landmark.id() + " at " + at);
|
||||
helper.assertTrue(!plan.contains(x, y, z), "Heritage gained write ownership of a historical arrival: " + landmark.id() + " at " + at);
|
||||
if (y == e.y() - 1) assertRock(helper, at);
|
||||
if (y >= e.y()) helper.assertTrue(helper.getLevel().getBlockState(at).isAir(), "Decoration obstructed a certified historical arrival: " + at);
|
||||
checked++;
|
||||
}
|
||||
}
|
||||
result.add(Map.of("id", landmark.id(), "entry", List.of(e.x(), e.y(), e.z()), "read_only_cells", checked));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private static void assertRock(GameTestHelper helper, BlockPos at) {
|
||||
helper.assertTrue(helper.getLevel().getBlockState(at).isSolid() && helper.getLevel().getFluidState(at).isEmpty(), "Lost original rock bearing at " + at);
|
||||
}
|
||||
private static void verifyLootTables(GameTestHelper helper, Map<String, Object> report) {
|
||||
var result = new ArrayList<Map<String, Object>>(); var level = helper.getLevel();
|
||||
var params = new LootParams.Builder(level).withParameter(LootContextParams.ORIGIN, new Vec3(0, 160, 0)).create(LootContextParamSets.CHEST);
|
||||
for (var kind : HeritagePlan19.Kind.values()) {
|
||||
var table = level.getServer().reloadableRegistries().getLootTable(lootKey(kind));
|
||||
helper.assertTrue(table != LootTable.EMPTY, "Heritage tool table did not load: " + kind);
|
||||
for (long seed : new long[] {0, 42, -1}) helper.assertTrue(table.getRandomItems(params, seed).stream().anyMatch(stack -> stack.is(tool(kind))), "Tool table is empty or lacks its expected primary tool: " + kind);
|
||||
result.add(Map.of("kind", kind.name(), "table", lootKey(kind).identifier().toString(), "sampled_seeds", List.of(0, 42, -1)));
|
||||
}
|
||||
report.put("tool_tables_sampled_separately", result);
|
||||
}
|
||||
private static ResourceKey<LootTable> lootKey(HeritagePlan19.Kind kind) { return ResourceKey.create(Registries.LOOT_TABLE, SanctuaryMod.id("chests/heritage19/" + kind.name().toLowerCase(Locale.ROOT))); }
|
||||
private static Item tool(HeritagePlan19.Kind kind) {
|
||||
return switch (kind) {
|
||||
case OBSERVATORY -> Items.SPYGLASS;
|
||||
case POST_OFFICE, EXPEDITION_OFFICE, RADIO_RELAY -> Items.COMPASS;
|
||||
case SUBSTATION, IMPOSSIBLE_SERVICE -> Items.CLOCK;
|
||||
case FREIGHT_STATION -> Items.MINECART;
|
||||
case COMMUNAL_DEPOT -> Items.IRON_AXE;
|
||||
case RAIL_WORKSHOP -> Items.IRON_PICKAXE;
|
||||
case PUMP_STATION -> Items.BUCKET;
|
||||
case GREENHOUSE -> Items.IRON_HOE;
|
||||
case VOID_DOCK -> Items.LEAD;
|
||||
case PHOTO_CLUB -> Items.BOOK;
|
||||
case CONSTRUCTION_REFUGE -> Items.IRON_SHOVEL;
|
||||
};
|
||||
}
|
||||
private static Set<BlockPos> walk(GameTestHelper helper, BlockPos start, Predicate<BlockPos> inside) {
|
||||
var level = helper.getLevel(); helper.assertTrue(inside.test(start) && standable(level, start), "Blocked or unsupported exterior entrance: " + start);
|
||||
var seen = new HashSet<BlockPos>(); var queue = new ArrayDeque<BlockPos>(); seen.add(start); queue.add(start);
|
||||
while (!queue.isEmpty()) {
|
||||
var pos = queue.removeFirst();
|
||||
for (var direction : HORIZONTAL) for (int dy = -1; dy <= 1; dy++) {
|
||||
var next = pos.relative(direction).offset(0, dy, 0);
|
||||
if (!inside.test(next) || dy > 0 && !clearBody(level, pos.above())) continue;
|
||||
if (standable(level, next) && seen.add(next)) queue.add(next);
|
||||
}
|
||||
for (int dy : new int[] {-1, 1}) {
|
||||
var next = pos.offset(0, dy, 0); if (!inside.test(next)) continue;
|
||||
if ((level.getBlockState(pos).is(Blocks.LADDER) || level.getBlockState(next).is(Blocks.LADDER) || level.getBlockState(pos.below()).is(Blocks.LADDER))
|
||||
&& standable(level, next) && seen.add(next)) queue.add(next);
|
||||
}
|
||||
helper.assertTrue(seen.size() <= 50_000, "Native site traversal escaped its bounds");
|
||||
}
|
||||
return seen;
|
||||
}
|
||||
private static boolean standable(ServerLevel level, BlockPos pos) {
|
||||
if (!clearBody(level, pos)) return false;
|
||||
if (level.getBlockState(pos).is(Blocks.LADDER) || level.getBlockState(pos.below()).is(Blocks.LADDER)) return true;
|
||||
var below = pos.below(); return level.getBlockState(below).getCollisionShape(level, below).toAabbs().stream()
|
||||
.anyMatch(b -> b.maxY >= .5 && b.minX <= .5 && b.maxX >= .5 && b.minZ <= .5 && b.maxZ >= .5);
|
||||
}
|
||||
private static boolean clearBody(ServerLevel level, BlockPos pos) {
|
||||
var body = new AABB(pos.getX() + .2, pos.getY(), pos.getZ() + .2, pos.getX() + .8, pos.getY() + 1.8, pos.getZ() + .8);
|
||||
for (var at : new BlockPos[] {pos, pos.above()}) {
|
||||
if (!level.getFluidState(at).isEmpty()) return false;
|
||||
for (var shape : level.getBlockState(at).getCollisionShape(level, at).toAabbs()) if (shape.move(at.getX(), at.getY(), at.getZ()).intersects(body)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private static long column(int x, int z) { return (long) x << 32 ^ z & 0xffffffffL; }
|
||||
private static List<Integer> coords(BlockPos pos) { return List.of(pos.getX(), pos.getY(), pos.getZ()); }
|
||||
private static BlockPos readPos(com.google.gson.JsonArray value) { return new BlockPos(value.get(0).getAsInt(), value.get(1).getAsInt(), value.get(2).getAsInt()); }
|
||||
private static Path world(ServerLevel level) { return level.getServer().getWorldPath(LevelResource.ROOT).toAbsolutePath().normalize(); }
|
||||
private static Path proof(ServerLevel level) { return world(level).resolve("heritage21-create-proof.json"); }
|
||||
private static String planHash(HeritagePlan19 plan) { return hash(plan.sites().toString() + plan.landmarks() + plan.links() + plan.segments()); }
|
||||
private static void write(ServerLevel level, Map<String, Object> report, boolean reload) throws IOException {
|
||||
var path = Path.of("diagnostics", "heritage21-" + (reload ? "reload" : "create") + ".json"); Files.createDirectories(path.getParent());
|
||||
var value = new GsonBuilder().setPrettyPrinting().create().toJson(report) + "\n"; Files.writeString(path, value); if (!reload) Files.writeString(proof(level), value);
|
||||
}
|
||||
private static String hash(String value) {
|
||||
try { return HexFormat.of().formatHex(MessageDigest.getInstance("SHA-256").digest(value.getBytes(StandardCharsets.UTF_8))); }
|
||||
catch (NoSuchAlgorithmException impossible) { throw new AssertionError(impossible); }
|
||||
}
|
||||
}
|
||||
+1034
File diff suppressed because it is too large
Load Diff
+1083
File diff suppressed because it is too large
Load Diff
+166
@@ -0,0 +1,166 @@
|
||||
package fr.koka.sanctuary.gametest;
|
||||
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import fr.koka.sanctuary.knowledge.BlockKnowledgeService;
|
||||
import fr.koka.sanctuary.knowledge.census.WorldCensusService;
|
||||
import fr.koka.sanctuary.knowledge.history.MaterialActivity;
|
||||
import fr.koka.sanctuary.knowledge.history.MaterialActivityHistory;
|
||||
import fr.koka.sanctuary.knowledge.history.MaterialActivityStore;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import net.fabricmc.fabric.api.gametest.v1.GameTest;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.gametest.framework.GameTestHelper;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.util.Prediction;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.storage.LevelResource;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
/** Activity uses native action callbacks and stays separate from current stock and discovery. */
|
||||
public final class MaterialActivityGameTests {
|
||||
@GameTest(maxTicks = 100)
|
||||
public void nativeActionsProduceDatedDeltasWhileObservationsProduceNone(GameTestHelper helper) throws IOException {
|
||||
var level = helper.getLevel();
|
||||
var server = level.getServer();
|
||||
LocalDate day = LocalDate.now(ZoneOffset.UTC);
|
||||
var before = MaterialActivityHistory.snapshot(server, day);
|
||||
var originalCounts = Map.copyOf(before.counts());
|
||||
ServerPlayer player = (ServerPlayer) helper.makeMockServerPlayer(GameType.SURVIVAL);
|
||||
player.setPos(helper.absoluteVec(new Vec3(5.5, 3, 5.5)));
|
||||
|
||||
// Giving inventory, restoring old vanilla totals and reading observations are not flows.
|
||||
player.setItemInHand(InteractionHand.MAIN_HAND, new ItemStack(Items.OAK_LOG, 5));
|
||||
player.getStats().setValue(player, Stats.BLOCK_MINED.get(Blocks.GOLD_BLOCK), 99);
|
||||
player.getStats().setValue(player, Stats.ITEM_DROPPED.get(Items.GOLD_INGOT), 999);
|
||||
BlockKnowledgeService.observeInventory(player);
|
||||
BlockKnowledgeService.snapshot(player);
|
||||
WorldCensusService.capture(server);
|
||||
helper.assertTrue(MaterialActivityHistory.snapshot(server, day).counts().equals(before.counts()),
|
||||
"Inventory grants, historical totals and census/discovery reads must not invent dated activity");
|
||||
|
||||
BlockPos minedPos = helper.absolutePos(new BlockPos(3, 1, 1));
|
||||
level.setBlockAndUpdate(minedPos, Blocks.STONE.defaultBlockState());
|
||||
player.setItemInHand(InteractionHand.MAIN_HAND, new ItemStack(Items.DIAMOND_PICKAXE));
|
||||
helper.assertTrue(player.gameMode.destroyBlock(minedPos), "The player must harvest stone with a suitable tool");
|
||||
level.setBlockAndUpdate(minedPos, Blocks.STONE.defaultBlockState());
|
||||
player.setItemInHand(InteractionHand.MAIN_HAND, ItemStack.EMPTY);
|
||||
player.gameMode.destroyBlock(minedPos);
|
||||
|
||||
BlockPos support = helper.absolutePos(new BlockPos(1, 1, 1));
|
||||
level.setBlockAndUpdate(support, Blocks.STONE.defaultBlockState());
|
||||
level.setBlockAndUpdate(support.above(), Blocks.AIR.defaultBlockState());
|
||||
helper.assertTrue(place(player, Items.COBBLESTONE, support), "The native cobblestone placement must succeed");
|
||||
BlockPos badSupport = helper.absolutePos(new BlockPos(1, 1, 3));
|
||||
level.setBlockAndUpdate(badSupport, Blocks.STONE.defaultBlockState());
|
||||
level.setBlockAndUpdate(badSupport.above(), Blocks.AIR.defaultBlockState());
|
||||
helper.assertTrue(!place(player, Items.OAK_SAPLING, badSupport), "Stone must refuse the native sapling placement");
|
||||
|
||||
// Non-block items exercise the general material history rather than the block-only codex.
|
||||
var item = new ItemEntity(level, player.getX(), player.getY(), player.getZ(), new ItemStack(Items.DIAMOND, 4));
|
||||
item.setNoPickUpDelay();
|
||||
level.addFreshEntity(item);
|
||||
item.playerTouch(player);
|
||||
helper.assertTrue(item.isRemoved(), "The native item pickup must consume the complete ground stack");
|
||||
int diamondSlot = player.getInventory().findSlotMatchingItem(new ItemStack(Items.DIAMOND));
|
||||
helper.assertTrue(diamondSlot >= 0, "The picked-up diamonds must now occupy a player inventory slot");
|
||||
ItemStack dropped = player.getInventory().removeItem(diamondSlot, 3);
|
||||
helper.assertTrue(dropped.getCount() == 3, "The native drop fixture must remove exactly three held items");
|
||||
player.drop(dropped, true, Prediction.PREDICTED);
|
||||
player.getInventory().dropAll();
|
||||
|
||||
// This is vanilla's successful craft-completion callback, not a simulated recipe match.
|
||||
new ItemStack(Items.BREAD, 3).onCraftedBy(player, 3);
|
||||
var after = MaterialActivityHistory.snapshot(server, day);
|
||||
helper.assertTrue(delta(before, after, "mined", "block", "minecraft:stone") == 1,
|
||||
"Only the successful vanilla harvest may add a mined-block activity");
|
||||
helper.assertTrue(delta(before, after, "placed", "block", "minecraft:cobblestone") == 1
|
||||
&& delta(before, after, "placed", "block", "minecraft:oak_sapling") == 0,
|
||||
"Only confirmed placement may contribute to the dated placement count");
|
||||
helper.assertTrue(delta(before, after, "picked_up", "item", "minecraft:diamond") == 4,
|
||||
"A native pickup must record non-block item units exactly once");
|
||||
helper.assertTrue(delta(before, after, "dropped", "item", "minecraft:diamond") == 3,
|
||||
"Voluntary drop units must be recorded without including the death-drop path");
|
||||
helper.assertTrue(delta(before, after, "crafted", "item", "minecraft:bread") == 3,
|
||||
"Vanilla's craft-completion callback must record its reported output quantity");
|
||||
helper.assertTrue(after.recorded() && after.unsaved(), "New activity must be identified as recorded and awaiting save");
|
||||
|
||||
WorldCensusService.capture(server);
|
||||
BlockKnowledgeService.snapshot(player);
|
||||
helper.assertTrue(MaterialActivityHistory.snapshot(server, day).counts().equals(after.counts()),
|
||||
"Subsequent stock and knowledge reads must not duplicate historical activity");
|
||||
boolean immutable = false;
|
||||
try { after.counts().clear(); }
|
||||
catch (UnsupportedOperationException expected) { immutable = true; }
|
||||
helper.assertTrue(immutable, "Activity consumers must receive immutable day snapshots");
|
||||
helper.assertTrue(before.counts().equals(originalCounts),
|
||||
"The earlier immutable snapshot must retain its original totals");
|
||||
|
||||
MaterialActivityHistory.flush(server);
|
||||
var stored = new MaterialActivityStore(server.getWorldPath(LevelResource.ROOT).resolve("data/sanctuary-activity"), day).load();
|
||||
helper.assertTrue(stored.equals(after.counts()), "A fresh store must read the exact flushed native activity totals");
|
||||
helper.assertTrue(!MaterialActivityHistory.snapshot(server, day).unsaved(), "Successful flush must clear the unsaved status");
|
||||
helper.succeed();
|
||||
}
|
||||
|
||||
@GameTest(maxTicks = 100)
|
||||
public void unrecordedDaysRemainUnknownRatherThanZeroActivity(GameTestHelper helper) throws IOException {
|
||||
LocalDate missingDay = LocalDate.now(ZoneOffset.UTC).minusYears(1000);
|
||||
var snapshot = MaterialActivityHistory.snapshot(helper.getLevel().getServer(), missingDay);
|
||||
helper.assertTrue(!snapshot.recorded() && !snapshot.unsaved() && snapshot.counts().isEmpty(),
|
||||
"An absent day must be explicitly unrecorded, without manufacturing a zero-activity record");
|
||||
helper.succeed();
|
||||
}
|
||||
|
||||
@GameTest(maxTicks = 100)
|
||||
public void registeredCensusAndHistoryCommandsAcceptNamespacedIdsAndDates(GameTestHelper helper) throws CommandSyntaxException {
|
||||
var server = helper.getLevel().getServer();
|
||||
var source = server.createCommandSourceStack().withLevel(helper.getLevel())
|
||||
.withSource(CommandSource.NULL).withSuppressedOutput();
|
||||
var dispatcher = server.getCommands().getDispatcher();
|
||||
String today = LocalDate.now(ZoneOffset.UTC).toString();
|
||||
String missing = LocalDate.now(ZoneOffset.UTC).minusYears(1000).toString();
|
||||
for (String command : List.of("sanctuary census", "sanctuary census block minecraft:stone",
|
||||
"sanctuary census item minecraft:diamond", "sanctuary history",
|
||||
"sanctuary history " + today, "sanctuary history " + missing)) {
|
||||
var parsed = dispatcher.parse(command, source);
|
||||
helper.assertTrue(!parsed.getReader().canRead(),
|
||||
"The registered dispatcher must consume the complete namespaced identifier or date: " + command);
|
||||
helper.assertTrue(dispatcher.execute(parsed) == 1,
|
||||
"The registered read-only census/history command must execute successfully: " + command);
|
||||
}
|
||||
helper.assertTrue(dispatcher.execute("sanctuary census block minecraft:missing_census_material", source) == 0,
|
||||
"An unknown material must fail explicitly instead of claiming a valid zero count");
|
||||
helper.assertTrue(dispatcher.execute("sanctuary history not-a-date", source) == 0,
|
||||
"An invalid history date must fail with the native command's validation result");
|
||||
helper.succeed();
|
||||
}
|
||||
|
||||
private static long delta(MaterialActivityHistory.Snapshot before, MaterialActivityHistory.Snapshot after,
|
||||
String action, String registry, String id) {
|
||||
var key = new MaterialActivity(action, registry, id);
|
||||
return after.counts().getOrDefault(key, 0L) - before.counts().getOrDefault(key, 0L);
|
||||
}
|
||||
|
||||
private static boolean place(ServerPlayer player, Item item, BlockPos support) {
|
||||
player.setItemInHand(InteractionHand.MAIN_HAND, new ItemStack(item));
|
||||
var hit = new BlockHitResult(Vec3.atCenterOf(support), Direction.UP, support, false);
|
||||
return ((BlockItem) item).place(new BlockPlaceContext(new UseOnContext(player, InteractionHand.MAIN_HAND, hit))).consumesAction();
|
||||
}
|
||||
}
|
||||
+314
@@ -0,0 +1,314 @@
|
||||
package fr.koka.sanctuary.gametest;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import fr.koka.sanctuary.expansion.*;
|
||||
import fr.koka.sanctuary.mixin.MonumentChildren23Accessor;
|
||||
import fr.koka.sanctuary.worldgen.SanctuaryChunkGenerator;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import net.fabricmc.fabric.api.gametest.v1.GameTest;
|
||||
import net.minecraft.core.HolderSet;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.gametest.framework.GameTestHelper;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
import net.minecraft.tags.StructureTags;
|
||||
import net.minecraft.world.level.chunk.PalettedContainerFactory;
|
||||
import net.minecraft.world.level.chunk.ProtoChunk;
|
||||
import net.minecraft.world.level.chunk.UpgradeData;
|
||||
import net.minecraft.world.level.levelgen.structure.Structure;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureStart;
|
||||
import net.minecraft.world.level.levelgen.structure.pieces.StructurePieceSerializationContext;
|
||||
import net.minecraft.world.level.levelgen.structure.structures.OceanMonumentPieces;
|
||||
|
||||
/** Exact native catalogue and pure admission, followed by real native start serialization in a disposable test world. */
|
||||
public final class Native23WorldGameTests {
|
||||
@GameTest(maxTicks = 18000)
|
||||
public void nativeCatalogueAdmissionAndPersistence(GameTestHelper helper) throws Exception {
|
||||
try { runNativeLifecycle(helper); }
|
||||
catch (Exception failure) { writeFailure(helper, Map.of(), failure); throw failure; }
|
||||
}
|
||||
|
||||
private void runNativeLifecycle(GameTestHelper helper) throws Exception {
|
||||
var level = helper.getLevel();
|
||||
var generator = (SanctuaryChunkGenerator) level.getChunkSource().getGenerator();
|
||||
helper.assertTrue(generator.rootGeneration() == 23, "Requires generation23 disposable development world");
|
||||
var registry = level.registryAccess().lookupOrThrow(Registries.STRUCTURE);
|
||||
var catalogue = ExpansionStructures23.catalogue();
|
||||
helper.assertTrue(catalogue.size() == 52 && catalogue.stream().map(ExpansionStructureCatalog23.Entry::id).distinct().count() == 52, "All52 distinct built-in structures are classified");
|
||||
helper.assertTrue(catalogue.stream().filter(e -> e.availability() == ExpansionStructureCatalog23.Availability.OVERWORLD).count() == 46, "46 admissible Overworld structures; ancient city awaits Cavernes");
|
||||
for (var entry : catalogue) helper.assertTrue(registry.get(Identifier.parse(entry.id())).isPresent(), "Exact26.3-pre2 registry contains " + entry.id());
|
||||
var nativeIds = new HashSet<String>();
|
||||
registry.listElements().forEach(h -> { if (h.key().identifier().getNamespace().equals("minecraft")) nativeIds.add(h.key().identifier().toString()); });
|
||||
helper.assertTrue(nativeIds.equals(catalogue.stream().map(ExpansionStructureCatalog23.Entry::id).collect(java.util.stream.Collectors.toSet())), "Catalogue exactly matches native registry, without omitted structures");
|
||||
helper.assertTrue(ExpansionStructures23.family("other:custom").equals("unknown"), "Modded structures stay independently identifiable");
|
||||
var ops = RegistryOps.create(JsonOps.INSTANCE, level.registryAccess());
|
||||
Structure trial = registry.getValue(Identifier.withDefaultNamespace("trial_chambers"));
|
||||
var original = Structure.DIRECT_CODEC.encodeStart(ops, trial).getOrThrow().getAsJsonObject();
|
||||
var moved = Structure.DIRECT_CODEC.encodeStart(ops, ExpansionStructures23.withStartHeight(trial, level.registryAccess(), 172)).getOrThrow().getAsJsonObject();
|
||||
var originalUnchanged = original.deepCopy(); originalUnchanged.remove("start_height"); moved.remove("start_height");
|
||||
helper.assertTrue(originalUnchanged.equals(moved), "Only absolute start_height changes; pools, processors, aliases, contents stay native");
|
||||
helper.assertTrue(original.equals(Structure.DIRECT_CODEC.encodeStart(ops, trial).getOrThrow()), "Registered trial structure is not mutated");
|
||||
var report = new LinkedHashMap<String, Object>();
|
||||
report.put("catalogue", catalogue); report.put("generation", generator.rootGeneration()); report.put("world_seed", level.getSeed());
|
||||
var prior = generator.source().islands();
|
||||
ExpansionIsland witness = null;
|
||||
for (int seed = 1; seed <= 8 && witness == null; seed++) {
|
||||
var candidate = island("admission", 512, seed, "natural").withStructurePriorities(List.of("camp"));
|
||||
try { ExpansionStructures23.verifyExpansion(level, candidate, deadline(45)); witness = candidate; }
|
||||
catch (ExpansionStructures23.NoSuitableStructureException refused) { /* Try a different immutable candidate. */ }
|
||||
}
|
||||
helper.assertTrue(witness != null, "At least one native structure can be admitted on a temperate expansion");
|
||||
helper.assertTrue(prior.equals(generator.source().islands()), "Preflight never activates or mutates the island snapshot");
|
||||
var nodes = ExpansionStructures23.candidates(witness);
|
||||
helper.assertTrue(nodes.equals(ExpansionStructures23.candidates(witness.ready())), "Candidate anchors do not depend on reserved/ready state");
|
||||
var emitted = new ArrayList<StructureStart>();
|
||||
try {
|
||||
var published = new ArrayList<>(prior); published.add(witness.ready()); generator.setIslands(published);
|
||||
for (var node : nodes) {
|
||||
var proto = new ProtoChunk(node.chunk(), UpgradeData.EMPTY, level, PalettedContainerFactory.create(level.registryAccess()), null);
|
||||
ExpansionStructures23.generate(generator, level.registryAccess(), null, level.structureManager(), proto,
|
||||
level.getStructureTemplateManager(), level.dimension());
|
||||
for (StructureStart start : proto.getAllStarts().values()) if (start.isValid()) emitted.add(start);
|
||||
if (!emitted.isEmpty()) break;
|
||||
}
|
||||
} finally { generator.setIslands(prior); }
|
||||
helper.assertTrue(!emitted.isEmpty(), "Accepted preflight replays as a native start through production generate");
|
||||
var serialization = StructurePieceSerializationContext.fromLevel(level);
|
||||
for (StructureStart start : emitted) assertRoundTrip(helper, start, serialization);
|
||||
report.put("guaranteed_island", witness); report.put("guaranteed_start", emitted.getFirst().createTag(serialization, emitted.getFirst().getChunkPos()).toString());
|
||||
// A not-yet-published Lost City already reserves its complete underground/support envelope.
|
||||
// Exact descriptor admitted by the separate cold Session.create1024 Lost City witness.
|
||||
var cityWitness = new ExpansionIsland("admission_23_0", "sanctuary", "east", "lost_city", 1024,
|
||||
2416, 304, -6422943410799146666L, "natural", "reserved", 23);
|
||||
ExpansionStructures23.verifyExpansion(level, cityWitness, ExpansionAdmission.searchDeadline());
|
||||
helper.assertTrue(!generator.lostCityPlan(cityWitness).isEmpty() && !generator.undergroundPlan16(cityWitness).networks().isEmpty(),
|
||||
"Unpublished witness has a real city district and underground network before native admission replay");
|
||||
boolean cityEmitted = false;
|
||||
try {
|
||||
var published = new ArrayList<>(prior); published.add(cityWitness.ready()); generator.setIslands(published);
|
||||
helper.assertTrue(!generator.lostCityPlan(cityWitness).isEmpty() && !generator.undergroundPlan16(cityWitness).networks().isEmpty(),
|
||||
"Publishing keeps the nonempty city and underground construction mask");
|
||||
for (var node : ExpansionStructures23.candidates(cityWitness)) {
|
||||
var proto = new ProtoChunk(node.chunk(), UpgradeData.EMPTY, level, PalettedContainerFactory.create(level.registryAccess()), null);
|
||||
ExpansionStructures23.generate(generator, level.registryAccess(), null, level.structureManager(), proto, level.getStructureTemplateManager(), level.dimension());
|
||||
if (proto.getAllStarts().values().stream().anyMatch(StructureStart::isValid)) { cityEmitted = true; break; }
|
||||
}
|
||||
} finally { generator.setIslands(prior); }
|
||||
helper.assertTrue(cityEmitted, "Lost City preflight remains valid after its full construction mask is published");
|
||||
report.put("lost_city_guaranteed_island", cityWitness);
|
||||
helper.assertTrue(registry.getOrThrow(StructureTags.EYE_OF_ENDER_LOCATED).contains(registry.get(Identifier.withDefaultNamespace("stronghold")).orElseThrow()), "Eye of Ender uses native stronghold tag");
|
||||
helper.assertTrue(registry.getOrThrow(StructureTags.ON_OCEAN_MONUMENT_MAPS).contains(registry.get(Identifier.withDefaultNamespace("monument")).orElseThrow()), "Explorer maps keep the native monument identity");
|
||||
var witnesses = new ArrayList<ExpansionIsland>();
|
||||
var selectedStarts = new ArrayList<ExpansionStructures23.Accepted>();
|
||||
Path proof = level.getServer().getWorldPath(net.minecraft.world.level.storage.LevelResource.ROOT).resolve("native23-full-create.json");
|
||||
boolean reload = Boolean.getBoolean("sanctuary.test.expansionReload");
|
||||
var previous = reload ? JsonParser.parseString(Files.readString(proof)).getAsJsonObject() : null;
|
||||
for (String id : List.of("stronghold", "trial_chambers", "monument", "igloo", "desert_pyramid")) {
|
||||
ExpansionStructures23.Accepted accepted = null;
|
||||
ExpansionIsland acceptedIsland = null;
|
||||
for (int seed = 1; seed <= 16 && accepted == null; seed++) {
|
||||
var candidate = reload ? new GsonBuilder().create().fromJson(previous.getAsJsonObject(id).get("island"), ExpansionIsland.class)
|
||||
: island("native_" + id, 1024, seed * 101L + 37, id.equals("monument") ? "ocean" : "natural")
|
||||
.withStructurePriorities(List.of(id));
|
||||
accepted = ExpansionStructures23.previewSelected(level, candidate, "minecraft:" + id, deadline(90));
|
||||
if (accepted != null && id.equals("igloo") && accepted.start().getPieces().size() == 1) accepted = null;
|
||||
if (accepted != null) acceptedIsland = candidate;
|
||||
if (reload) break;
|
||||
}
|
||||
helper.assertTrue(accepted != null, "Native " + id + " has an admissible site in floating terrain");
|
||||
assertRoundTrip(helper, accepted.start(), serialization);
|
||||
helper.assertTrue(accepted.start().getStructure() == registry.getValue(Identifier.withDefaultNamespace(id)), "Saved structure remains original registry object");
|
||||
if (id.equals("stronghold")) helper.assertTrue(accepted.start().getPieces().stream().anyMatch(p -> p.getClass().getSimpleName().equals("PortalRoom")), "Native stronghold retains its End portal room");
|
||||
if (id.equals("monument")) {
|
||||
helper.assertTrue(accepted.start().getBoundingBox().minY() != 39, "Monument moved to real expansion seabed");
|
||||
var loaded = StructureStart.loadStaticStart(serialization, accepted.start().createTag(serialization, accepted.start().getChunkPos()), level.getSeed());
|
||||
var before = ((MonumentChildren23Accessor) accepted.start().getPieces().getFirst()).sanctuary$children();
|
||||
var after = ((MonumentChildren23Accessor) loaded.getPieces().getFirst()).sanctuary$children();
|
||||
helper.assertTrue(before.size() == after.size(), "Monument room graph reconstructed with island seed, not world seed");
|
||||
for (int i = 0; i < before.size(); i++) helper.assertTrue(before.get(i).getBoundingBox().equals(after.get(i).getBoundingBox())
|
||||
&& before.get(i).getClass().equals(after.get(i).getClass()), "Internal monument pieces preserve altitude and layout on reload");
|
||||
}
|
||||
report.put(id, Map.of("island", acceptedIsland, "tag", accepted.start().createTag(serialization, accepted.start().getChunkPos()).toString()));
|
||||
witnesses.add(acceptedIsland.ready()); selectedStarts.add(accepted);
|
||||
}
|
||||
helper.assertTrue(NativeStructurePlacement23.seaLevel() == null, "No placement context leaks out of native generation");
|
||||
var output = Path.of("diagnostics", "native23"); Files.createDirectories(output);
|
||||
report.put("admission_passed", true);
|
||||
Files.writeString(output.resolve("admission.json"), new GsonBuilder().setPrettyPrinting().create().toJson(report));
|
||||
var published = new ArrayList<>(prior); published.addAll(witnesses); generator.setIslands(published);
|
||||
var fullChunks = new java.util.TreeSet<net.minecraft.world.level.ChunkPos>(java.util.Comparator.comparingInt(net.minecraft.world.level.ChunkPos::x).thenComparingInt(net.minecraft.world.level.ChunkPos::z));
|
||||
for (var selected : selectedStarts) selected.start().getBoundingBox().intersectingChunks().forEach(fullChunks::add);
|
||||
var iterator = fullChunks.iterator();
|
||||
var monument = selectedStarts.stream().filter(s -> s.structure().unwrapKey().orElseThrow().identifier().getPath().equals("monument")).findFirst().orElseThrow().start();
|
||||
var entityChunks = monument.getBoundingBox().intersectingChunks().toList();
|
||||
boolean[] entityTickets = {false};
|
||||
int[] entityWait = {0};
|
||||
Runnable releaseEntityTickets = () -> {
|
||||
if (!entityTickets[0]) return;
|
||||
for (var pos : entityChunks) level.getChunkSource().removeTicketWithRadius(net.minecraft.server.level.TicketType.DRAGON, pos, 2);
|
||||
entityTickets[0] = false;
|
||||
};
|
||||
Runnable[] step = new Runnable[1];
|
||||
step[0] = () -> {
|
||||
try {
|
||||
if (iterator.hasNext()) {
|
||||
var chunk = iterator.next(); level.getChunk(chunk.x(), chunk.z(), net.minecraft.world.level.chunk.status.ChunkStatus.FULL, true);
|
||||
// GameTest removes the executing Runnable from its map; enqueue a fresh callback.
|
||||
helper.runAtTickTime(helper.getTick() + 1, () -> step[0].run()); return;
|
||||
}
|
||||
if (!entityTickets[0]) {
|
||||
report.put("guardians_before_entity_tickets", guardianDiagnostics(level, monument, entityChunks, 0));
|
||||
// FULL's short loading ticket does not keep its saved entities visible. This native
|
||||
// ticket loads and simulates without persisting, and is released on every exit.
|
||||
for (var pos : entityChunks) level.getChunkSource().addTicketWithRadius(net.minecraft.server.level.TicketType.DRAGON, pos, 2);
|
||||
entityTickets[0] = true;
|
||||
}
|
||||
var guardianState = guardianDiagnostics(level, monument, entityChunks, entityWait[0]);
|
||||
report.put("guardian_diagnostics", guardianState);
|
||||
if (((Number) guardianState.get("count")).intValue() < 3 && entityWait[0]++ < 200) {
|
||||
helper.runAtTickTime(helper.getTick() + 1, () -> step[0].run()); return;
|
||||
}
|
||||
fr.koka.sanctuary.SanctuaryMod.LOGGER.info("Native23 guardian visibility: {}", guardianState);
|
||||
var fullTags = new LinkedHashMap<String, String>();
|
||||
var blocks = new LinkedHashMap<String, Map<String, Integer>>();
|
||||
report.put("full_chunks", fullChunks.size()); report.put("full_blocks", blocks);
|
||||
for (var selected : selectedStarts) {
|
||||
var expected = selected.start(); var position = expected.getChunkPos();
|
||||
var chunk = level.getChunk(position.x(), position.z(), net.minecraft.world.level.chunk.status.ChunkStatus.FULL, true);
|
||||
var actual = chunk.getStartForStructure(selected.structure().value());
|
||||
helper.assertTrue(actual != null && actual.isValid(), "FULL production preserves the naturally selected structure");
|
||||
helper.assertTrue(actual.getBoundingBox().equals(expected.getBoundingBox()), "FULL lifecycle preserves admitted geometry");
|
||||
assertRoundTrip(helper, actual, serialization);
|
||||
String id = selected.structure().unwrapKey().orElseThrow().identifier().getPath();
|
||||
String saved = actual.createTag(serialization, position).toString();
|
||||
if (reload) helper.assertTrue(previous.getAsJsonObject("full_tags").get(id).getAsString().equals(saved), "New JVM restores " + id + " with unchanged start and references");
|
||||
var counts = countImportantBlocks(level, actual); blocks.put(id, counts);
|
||||
if (id.equals("stronghold")) helper.assertTrue(counts.getOrDefault("end_portal_frame", 0) >= 12 && counts.getOrDefault("spawner", 0) >= 1 && counts.getOrDefault("chest", 0) >= 1,
|
||||
"Stronghold postProcess creates usable portal frames, spawner and unopened loot chests");
|
||||
if (id.equals("trial_chambers")) helper.assertTrue(counts.getOrDefault("trial_spawner", 0) > 0 && counts.getOrDefault("vault", 0) > 0,
|
||||
"Trial chambers keep native trial spawners and vaults");
|
||||
if (id.equals("igloo")) helper.assertTrue(counts.getOrDefault("ladder", 0) > 0 && counts.getOrDefault("chest", 0) > 0 && counts.getOrDefault("snow_block", 0) > 0,
|
||||
"Projected igloo retains aligned entrance, shaft and native laboratory chest");
|
||||
if (id.equals("desert_pyramid")) helper.assertTrue(counts.getOrDefault("sandstone", 0) > 50 && counts.getOrDefault("chest", 0) >= 4 && counts.getOrDefault("tnt", 0) >= 9,
|
||||
"Projected desert pyramid retains its four loot chests and buried native trap");
|
||||
if (id.equals("monument")) {
|
||||
helper.assertTrue(counts.getOrDefault("prismarine", 0) > 100 && counts.getOrDefault("water", 0) > 100, "Monument has real submerged rooms after FEATURES");
|
||||
int guardians = level.getEntitiesOfClass(net.minecraft.world.entity.monster.ElderGuardian.class,
|
||||
net.minecraft.world.phys.AABB.of(actual.getBoundingBox())).size();
|
||||
helper.assertTrue(guardians >= 3, "Native monument creates its three elder guardians");
|
||||
counts.put("elder_guardians", guardians);
|
||||
var oceanIsland = witnesses.stream().filter(i -> i.id().equals("native_monument")).findFirst().orElseThrow();
|
||||
var ocean = ExpansionOcean23.column(oceanIsland, oceanIsland.centerX(), oceanIsland.centerZ());
|
||||
helper.assertTrue(level.getBlockState(new net.minecraft.core.BlockPos(oceanIsland.centerX(), ocean.waterLevel(), oceanIsland.centerZ())).is(net.minecraft.world.level.block.Blocks.WATER), "Ocean surface remains water after features");
|
||||
helper.assertTrue(level.getBlockState(new net.minecraft.core.BlockPos(oceanIsland.centerX(), ocean.floorY() - 3, oceanIsland.centerZ())).isSolid(), "Ocean retains a sealed geological floor after features");
|
||||
}
|
||||
}
|
||||
verifyLocator(helper, generator, witnesses, selectedStarts, reload);
|
||||
for (var selected : selectedStarts) {
|
||||
var pos = selected.start().getChunkPos(); var actual = level.getChunk(pos.x(), pos.z(), net.minecraft.world.level.chunk.status.ChunkStatus.STRUCTURE_STARTS, true).getStartForStructure(selected.structure().value());
|
||||
fullTags.put(selected.structure().unwrapKey().orElseThrow().identifier().getPath(), actual.createTag(serialization, pos).toString());
|
||||
}
|
||||
report.put("process_id", ProcessHandle.current().pid()); report.put("full_chunks", fullChunks.size()); report.put("full_blocks", blocks); report.put("full_tags", fullTags);
|
||||
report.put("passed", true);
|
||||
if (reload) helper.assertTrue(previous.get("process_id").getAsLong() != ProcessHandle.current().pid(), "Reload is a different JVM");
|
||||
helper.assertTrue(level.getServer().saveEverything(true, true, true), "Persist disposable full chunks and native starts");
|
||||
var json = new GsonBuilder().setPrettyPrinting().create().toJson(report);
|
||||
Files.writeString(output.resolve(reload ? "reload.json" : "full.json"), json);
|
||||
if (!reload) Files.writeString(proof, json);
|
||||
releaseEntityTickets.run(); generator.setIslands(prior); helper.succeed();
|
||||
} catch (Exception failure) {
|
||||
writeFailure(helper, report, failure);
|
||||
releaseEntityTickets.run(); generator.setIslands(prior); throw new IllegalStateException(failure);
|
||||
}
|
||||
};
|
||||
helper.runAtTickTime(helper.getTick() + 1, () -> step[0].run());
|
||||
}
|
||||
|
||||
private static Map<String, Object> guardianDiagnostics(net.minecraft.server.level.ServerLevel level, StructureStart monument,
|
||||
List<net.minecraft.world.level.ChunkPos> chunks, int waitedTicks) {
|
||||
var guardians = level.getEntitiesOfClass(net.minecraft.world.entity.monster.ElderGuardian.class, net.minecraft.world.phys.AABB.of(monument.getBoundingBox()));
|
||||
var state = new LinkedHashMap<String, Object>();
|
||||
state.put("count", guardians.size()); state.put("difficulty", level.getDifficulty().toString()); state.put("waited_ticks", waitedTicks);
|
||||
state.put("positions", guardians.stream().map(e -> List.of(e.getX(), e.getY(), e.getZ())).toList());
|
||||
state.put("chunks", chunks.stream().map(p -> Map.of("x", p.x(), "z", p.z(),
|
||||
"full_loaded", level.getChunkSource().getChunkNow(p.x(), p.z()) != null,
|
||||
"entities_loaded", level.areEntitiesLoaded(p.pack()), "entities_ticking", level.areEntitiesActuallyLoadedAndTicking(p))).toList());
|
||||
return state;
|
||||
}
|
||||
|
||||
private static void writeFailure(GameTestHelper helper, Map<String, Object> partial, Exception failure) {
|
||||
try {
|
||||
var report = new LinkedHashMap<String, Object>(partial);
|
||||
report.put("passed", false); report.put("failure_class", failure.getClass().getName()); report.put("failure", String.valueOf(failure.getMessage()));
|
||||
report.put("difficulty", helper.getLevel().getDifficulty().toString()); report.put("process_id", ProcessHandle.current().pid());
|
||||
var output = Path.of("diagnostics", "native23"); Files.createDirectories(output);
|
||||
Files.writeString(output.resolve("failure.json"), new GsonBuilder().setPrettyPrinting().create().toJson(report));
|
||||
} catch (Exception diagnosticFailure) { failure.addSuppressed(diagnosticFailure); }
|
||||
}
|
||||
private static ExpansionIsland island(String id, int diameter, long seed, String relief) {
|
||||
int x = switch (id) { case "native_stronghold" -> 8192; case "native_trial_chambers" -> 12288; case "native_monument" -> 16384;
|
||||
case "native_igloo" -> 28672; case "native_desert_pyramid" -> 32768; default -> 4096; };
|
||||
String climate = id.equals("native_igloo") ? "glacial" : id.equals("native_desert_pyramid") ? "arid" : "temperate";
|
||||
return new ExpansionIsland(id, "sanctuary", "east", climate, diameter, x, 4096, seed, relief, "reserved", 23);
|
||||
}
|
||||
private static Map<String, Integer> countImportantBlocks(net.minecraft.server.level.ServerLevel level, StructureStart start) {
|
||||
var counts = new LinkedHashMap<String, Integer>();
|
||||
var important = java.util.Set.of("end_portal_frame", "spawner", "chest", "trial_spawner", "vault", "prismarine", "water", "wet_sponge", "ladder", "snow_block", "sandstone", "tnt");
|
||||
for (var piece : start.getPieces()) {
|
||||
var box = piece.getBoundingBox();
|
||||
var pos = new net.minecraft.core.BlockPos.MutableBlockPos();
|
||||
for (int z = box.minZ(); z <= box.maxZ(); z++) for (int x = box.minX(); x <= box.maxX(); x++) for (int y = box.minY() - (start.getStructure() instanceof net.minecraft.world.level.levelgen.structure.structures.DesertPyramidStructure ? 16 : 0); y <= box.maxY(); y++) {
|
||||
var state = level.getBlockState(pos.set(x, y, z));
|
||||
String id = net.minecraft.core.registries.BuiltInRegistries.BLOCK.getKey(state.getBlock()).getPath();
|
||||
if (important.contains(id)) counts.merge(id, 1, Integer::sum);
|
||||
}
|
||||
}
|
||||
return counts;
|
||||
}
|
||||
private static void verifyLocator(GameTestHelper helper, SanctuaryChunkGenerator generator, List<ExpansionIsland> islands,
|
||||
List<ExpansionStructures23.Accepted> selected, boolean reload) {
|
||||
var level = helper.getLevel(); var registry = level.registryAccess().lookupOrThrow(Registries.STRUCTURE);
|
||||
var beforeSnapshot = generator.source().islands();
|
||||
for (var chosen : selected) {
|
||||
var id = chosen.structure().unwrapKey().orElseThrow().identifier().getPath();
|
||||
if (id.equals("igloo")) continue; // No built-in igloo explorer-map tag.
|
||||
var tag = id.equals("desert_pyramid") ? StructureTags.ON_DESERT_PYRAMID_MAPS : id.equals("stronghold") ? StructureTags.EYE_OF_ENDER_LOCATED : id.equals("monument") ? StructureTags.ON_OCEAN_MONUMENT_MAPS : StructureTags.ON_BURIED_TRIAL_CHAMBERS_MAPS;
|
||||
var located = generator.findNearestMapStructure(level, registry.getOrThrow(tag), chosen.start().getPieces().getFirst().getLocatorPosition(), 8, false);
|
||||
helper.assertTrue(located != null && located.getSecond().equals(chosen.structure()), "Native tag locator finds actual " + id + " starts");
|
||||
}
|
||||
var tracked = new ArrayList<StructureStart>();
|
||||
for (var island : islands) for (var candidate : ExpansionStructures23.candidates(island)) {
|
||||
var chunk = level.getChunk(candidate.chunk().x(), candidate.chunk().z(), net.minecraft.world.level.chunk.status.ChunkStatus.STRUCTURE_STARTS, true);
|
||||
chunk.getAllStarts().values().stream().filter(StructureStart::isValid).forEach(tracked::add);
|
||||
}
|
||||
var counts = new java.util.IdentityHashMap<StructureStart, Integer>(); tracked.forEach(s -> counts.put(s, s.getReferences()));
|
||||
var wanted = HolderSet.direct(selected.stream().map(ExpansionStructures23.Accepted::structure).toList());
|
||||
var origin = selected.getFirst().start().getPieces().getFirst().getLocatorPosition();
|
||||
var found = generator.findNearestMapStructure(level, wanted, origin, 128, false);
|
||||
helper.assertTrue(found != null, "Mixed vanilla holder sets locate a real start");
|
||||
helper.assertTrue(tracked.stream().allMatch(s -> counts.get(s) == s.getReferences()), "Read-only locate consumes no references");
|
||||
if (!reload) {
|
||||
found = generator.findNearestMapStructure(level, wanted, origin, 128, true);
|
||||
helper.assertTrue(found != null, "skipReferenced locates an unreferenced winner");
|
||||
int changed = 0, increment = 0;
|
||||
for (var start : tracked) { int delta = start.getReferences() - counts.get(start); if (delta != 0) changed++; increment += delta; }
|
||||
helper.assertTrue(changed == 1 && increment == 1, "Exactly one winning start gains one reference");
|
||||
}
|
||||
helper.assertTrue(beforeSnapshot.equals(generator.source().islands()), "Tags, maps and locator never activate another expansion");
|
||||
}
|
||||
private static long deadline(int seconds) { return System.nanoTime() + java.util.concurrent.TimeUnit.SECONDS.toNanos(seconds); }
|
||||
private static void assertRoundTrip(GameTestHelper helper, StructureStart start, StructurePieceSerializationContext context) {
|
||||
var tag = start.createTag(context, start.getChunkPos());
|
||||
var loaded = StructureStart.loadStaticStart(context, tag, helper.getLevel().getSeed());
|
||||
helper.assertTrue(loaded != null && loaded.isValid() && loaded.getBoundingBox().equals(start.getBoundingBox()), "Native start bounds survive reload");
|
||||
helper.assertTrue(tag.equals(loaded.createTag(context, start.getChunkPos())), "Native start metadata and content survive reload");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package fr.koka.sanctuary.gametest;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.gametest.framework.GameTestHelper;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.level.block.FenceBlock;
|
||||
import net.minecraft.world.level.block.IronBarsBlock;
|
||||
import net.minecraft.world.level.block.StairBlock;
|
||||
import net.minecraft.world.level.block.WallBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
||||
/** Independent oracle: actual native neighbor-update rules, with datapack tags loaded by the test server. */
|
||||
public final class NativeConnections20 {
|
||||
private NativeConnections20() {}
|
||||
public record Stats(int panes, int fences, int walls, int stairs, int nativeOracles, int externalNeighbors,
|
||||
int crossChunkPaneLinks, int settledExternalStates, int unsettledExternalStates) {
|
||||
public Stats add(Stats other) { return new Stats(panes + other.panes, fences + other.fences, walls + other.walls,
|
||||
stairs + other.stairs, nativeOracles + other.nativeOracles, externalNeighbors + other.externalNeighbors,
|
||||
crossChunkPaneLinks + other.crossChunkPaneLinks, settledExternalStates + other.settledExternalStates,
|
||||
unsettledExternalStates + other.unsettledExternalStates); }
|
||||
public static Stats empty() { return new Stats(0, 0, 0, 0, 0, 0, 0, 0, 0); }
|
||||
}
|
||||
public static Stats verify(GameTestHelper helper, Map<BlockPos, BlockState> geometry, Set<BlockPos> edits) {
|
||||
var level = helper.getLevel(); int panes = 0, fences = 0, walls = 0, stairs = 0, oracles = 0, exterior = 0, cross = 0, settled = 0, unsettled = 0;
|
||||
for (var entry : geometry.entrySet()) {
|
||||
var pos = entry.getKey(); var wanted = entry.getValue(); if (edits.contains(pos)) continue;
|
||||
boolean pane = wanted.getBlock() instanceof IronBarsBlock, fence = wanted.getBlock() instanceof FenceBlock;
|
||||
boolean wall = wanted.getBlock() instanceof WallBlock, stair = wanted.getBlock() instanceof StairBlock;
|
||||
if (!pane && !fence && !wall && !stair) continue;
|
||||
if (pane) panes++; if (fence) fences++; if (wall) walls++; if (stair) stairs++;
|
||||
var actual = level.getBlockState(pos);
|
||||
helper.assertTrue(sameNonConnectionState(actual, wanted),
|
||||
"Material, orientation, half or waterlogging changed at " + pos + ": expected " + wanted + " got " + actual);
|
||||
boolean knownNeighborhood = true;
|
||||
for (var side : Direction.values()) {
|
||||
var at = pos.relative(side); var expectedNeighbor = geometry.get(at); var actualNeighbor = level.getBlockState(at);
|
||||
// A changed neighbor's shape can propagate a legitimate exterior connection, e.g. stacked walls.
|
||||
if (edits.contains(at) || (expectedNeighbor == null ? !actualNeighbor.isAir()
|
||||
: !expectedNeighbor.equals(actualNeighbor))) knownNeighborhood = false;
|
||||
}
|
||||
var updated = actual;
|
||||
for (var side : Direction.values()) {
|
||||
var at = pos.relative(side);
|
||||
updated = updated.updateShape(level, level, pos, side, at, level.getBlockState(at), RandomSource.create(20));
|
||||
}
|
||||
if (knownNeighborhood) {
|
||||
helper.assertTrue(actual.equals(wanted), "Native detailed state differs inside known geometry at " + pos
|
||||
+ ": expected " + wanted + " got " + actual);
|
||||
helper.assertTrue(updated.equals(actual), "Vanilla neighbor rules disagree with generation20 connections at " + pos
|
||||
+ ": saved " + actual + " native " + updated);
|
||||
oracles++;
|
||||
} else {
|
||||
exterior++;
|
||||
if (updated.equals(actual)) { settled++; oracles++; }
|
||||
else {
|
||||
// A fresh structure has not necessarily received an update from untouched surrounding rock.
|
||||
// Permit only its exact planned state until that update; a partially/wrongly changed state fails.
|
||||
helper.assertTrue(actual.equals(wanted) && sameNonConnectionState(updated, wanted),
|
||||
"Exterior connection is neither the untouched plan nor a vanilla fixed point at " + pos
|
||||
+ ": plan " + wanted + " saved " + actual + " native " + updated);
|
||||
unsettled++;
|
||||
}
|
||||
}
|
||||
if (pane) for (var side : new Direction[] {Direction.EAST, Direction.SOUTH}) {
|
||||
var at = pos.relative(side); var neighbor = level.getBlockState(at);
|
||||
if (neighbor.getBlock() instanceof IronBarsBlock && (pos.getX() >> 4 != at.getX() >> 4 || pos.getZ() >> 4 != at.getZ() >> 4)) {
|
||||
var property = side == Direction.EAST ? BlockStateProperties.EAST : BlockStateProperties.SOUTH;
|
||||
helper.assertTrue(actual.getValue(property), "Pane connection disappeared exactly at a native chunk boundary: " + pos);
|
||||
cross++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Stats(panes, fences, walls, stairs, oracles, exterior, cross, settled, unsettled);
|
||||
}
|
||||
/** Normalize only geometry-derived properties. Everything else, including fluids and facing, stays exact. */
|
||||
private static boolean sameNonConnectionState(BlockState actual, BlockState wanted) {
|
||||
if (!actual.is(wanted.getBlock())) return false;
|
||||
if (wanted.getBlock() instanceof IronBarsBlock || wanted.getBlock() instanceof FenceBlock) {
|
||||
for (var property : new net.minecraft.world.level.block.state.properties.BooleanProperty[] {
|
||||
BlockStateProperties.NORTH, BlockStateProperties.EAST, BlockStateProperties.SOUTH, BlockStateProperties.WEST})
|
||||
actual = actual.setValue(property, wanted.getValue(property));
|
||||
} else if (wanted.getBlock() instanceof WallBlock) {
|
||||
for (var property : WallBlock.PROPERTY_BY_DIRECTION.values()) actual = actual.setValue(property, wanted.getValue(property));
|
||||
actual = actual.setValue(WallBlock.UP, wanted.getValue(WallBlock.UP));
|
||||
} else if (wanted.getBlock() instanceof StairBlock) actual = actual.setValue(StairBlock.SHAPE, wanted.getValue(StairBlock.SHAPE));
|
||||
return actual.equals(wanted);
|
||||
}
|
||||
|
||||
}
|
||||
+243
@@ -0,0 +1,243 @@
|
||||
package fr.koka.sanctuary.gametest;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import fr.koka.sanctuary.expansion.ExpansionIsland;
|
||||
import fr.koka.sanctuary.expansion.ExpansionOcean23;
|
||||
import fr.koka.sanctuary.expansion.NativeStructurePlacement23;
|
||||
import fr.koka.sanctuary.worldgen.SanctuaryChunkGenerator;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import net.fabricmc.fabric.api.gametest.v1.GameTest;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.gametest.framework.GameTestHelper;
|
||||
import net.minecraft.server.level.GenerationChunkHolder;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.WorldGenRegion;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.util.StaticCache2D;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ImposterProtoChunk;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.chunk.status.ChunkPyramid;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
import net.minecraft.world.level.levelgen.feature.BlueIceFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.IcebergFeature;
|
||||
import net.minecraft.world.level.storage.LevelResource;
|
||||
|
||||
/** Full native decoration on six disposable ocean islands; this fixture never reserves an expansion. */
|
||||
public final class Ocean23WorldGameTests {
|
||||
private record Witness(ExpansionIsland island, BlockPos deep, BlockPos shore, BlockPos exterior) {}
|
||||
|
||||
@GameTest(maxTicks = 18000)
|
||||
public void oceanSizesClimatesAndNativeIce(GameTestHelper helper) throws Exception {
|
||||
var level = helper.getLevel();
|
||||
var generator = (SanctuaryChunkGenerator) level.getChunkSource().getGenerator();
|
||||
helper.assertTrue(generator.rootGeneration() == 23, "Ocean matrix requires a disposable generation23 world");
|
||||
var prior = generator.source().islands();
|
||||
var directory = level.getServer().getWorldPath(LevelResource.ROOT).resolve("data").resolve(generator.journalDirectory());
|
||||
var journalBefore = files(directory);
|
||||
var witnesses = new ArrayList<Witness>();
|
||||
int index = 0;
|
||||
for (int diameter : new int[]{512, 1024}) for (String climate : List.of("glacial", "temperate", "warm")) {
|
||||
var island = new ExpansionIsland("ocean_" + diameter + "_" + climate, "sanctuary", "east", climate,
|
||||
diameter, 8192 + index * 4096, 8192, 23042L + index * 101L, "ocean", "ready", 23);
|
||||
witnesses.add(witness(island)); index++;
|
||||
}
|
||||
var published = new ArrayList<>(prior); witnesses.forEach(w -> published.add(w.island()));
|
||||
var chunks = new TreeMap<Long, ChunkPos>();
|
||||
for (var w : witnesses) {
|
||||
for (var position : List.of(w.deep(), w.shore(), w.exterior())) {
|
||||
var chunk = ChunkPos.containing(position); chunks.put(chunk.pack(), chunk);
|
||||
}
|
||||
// Native icebergs can write eleven blocks to either side of their origin.
|
||||
if (w.island().climate().equals("glacial")) ChunkPos.rangeClosed(ChunkPos.containing(w.deep()), 1)
|
||||
.forEach(chunk -> chunks.put(chunk.pack(), chunk));
|
||||
}
|
||||
var iterator = chunks.values().iterator();
|
||||
var report = new LinkedHashMap<String, Object>();
|
||||
generator.setIslands(published);
|
||||
Runnable[] step = new Runnable[1];
|
||||
step[0] = () -> {
|
||||
try {
|
||||
if (iterator.hasNext()) {
|
||||
var chunk = iterator.next(); report.put("stage", "full " + chunk);
|
||||
level.getChunk(chunk.x(), chunk.z(), ChunkStatus.FULL, true);
|
||||
// Reusing the executing Runnable would discard its next scheduled step.
|
||||
helper.runAtTickTime(helper.getTick() + 1, () -> step[0].run()); return;
|
||||
}
|
||||
var profiles = new ArrayList<Map<String, Object>>();
|
||||
report.put("profiles", profiles);
|
||||
for (var w : witnesses) {
|
||||
report.put("stage", "inspect " + w.island().id()); profiles.add(inspect(helper, generator, w));
|
||||
}
|
||||
report.put("stage", "restore and verify journal");
|
||||
helper.assertTrue(ExpansionOcean23.decorationSeaLevel() == null && NativeStructurePlacement23.seaLevel() == null,
|
||||
"All ocean and structure scopes are restored after native decoration");
|
||||
helper.assertTrue(generator.getSeaLevel() == -64, "Local oceans do not replace the global void sea level");
|
||||
generator.setIslands(prior);
|
||||
helper.assertTrue(generator.source().islands().equals(prior), "The original activation snapshot is restored");
|
||||
helper.assertTrue(equalFiles(journalBefore, files(directory)), "Temporary test islands never alter the expansion journal or certificates");
|
||||
report.put("generation", 23); report.put("world_seed", level.getSeed()); report.put("profiles", profiles);
|
||||
report.put("full_chunks_requested", chunks.size()); report.put("process_id", ProcessHandle.current().pid());
|
||||
report.put("journal_unchanged", true); report.put("passed", true);
|
||||
Path output = Path.of("diagnostics", "ocean23"); Files.createDirectories(output);
|
||||
Files.writeString(output.resolve("full.json"), new GsonBuilder().setPrettyPrinting().create().toJson(report));
|
||||
helper.succeed();
|
||||
} catch (Exception error) {
|
||||
generator.setIslands(prior);
|
||||
report.put("passed", false); report.put("failure", error.toString());
|
||||
var stack = new java.io.StringWriter(); error.printStackTrace(new java.io.PrintWriter(stack));
|
||||
report.put("stacktrace", stack.toString());
|
||||
fr.koka.sanctuary.SanctuaryMod.LOGGER.error("Ocean23 matrix failed at {}", report.get("stage"), error);
|
||||
try {
|
||||
Path output = Path.of("diagnostics", "ocean23"); Files.createDirectories(output);
|
||||
Files.writeString(output.resolve("failure.json"), new GsonBuilder().setPrettyPrinting().create().toJson(report));
|
||||
} catch (java.io.IOException writeError) { error.addSuppressed(writeError); }
|
||||
throw new IllegalStateException("Ocean23 matrix failed: " + error.getMessage(), error);
|
||||
}
|
||||
};
|
||||
helper.runAtTickTime(helper.getTick() + 1, () -> step[0].run());
|
||||
}
|
||||
|
||||
private static Witness witness(ExpansionIsland island) {
|
||||
var deep = new BlockPos(island.centerX() + 8, ExpansionOcean23.seaLevel(island) - 8, island.centerZ() + 8);
|
||||
BlockPos shore = null;
|
||||
// Quart-aligned samples exercise the stored biome palette without biome-boundary jitter.
|
||||
for (int z = island.centerZ() - island.diameter() / 2; z <= island.centerZ() + island.diameter() / 2 && shore == null; z += 4)
|
||||
for (int x = island.centerX() - island.diameter() / 2; x <= island.centerX() + island.diameter() / 2; x += 4) {
|
||||
var c = ExpansionOcean23.column(island, x, z);
|
||||
if (!c.water() && c.influence() == 1 && c.floorY() <= c.waterLevel() + 8) {
|
||||
shore = new BlockPos(x, (c.floorY() + 4) & ~3, z); break;
|
||||
}
|
||||
}
|
||||
if (shore == null) throw new IllegalStateException("Ocean profile lacks a dry shoreline witness");
|
||||
var exterior = new BlockPos(island.centerX() + island.terrainRadius() + 96, deep.getY(), island.centerZ());
|
||||
return new Witness(island, deep, shore, exterior);
|
||||
}
|
||||
|
||||
private static Map<String, Object> inspect(GameTestHelper helper, SanctuaryChunkGenerator generator, Witness w) {
|
||||
var level = helper.getLevel(); var island = w.island();
|
||||
var c = ExpansionOcean23.column(island, w.deep().getX(), w.deep().getZ());
|
||||
helper.assertTrue(c.deep(), "Matrix sample lies in the deep ocean: " + island.id());
|
||||
var deepChunk = (LevelChunk) level.getChunk(w.deep().getX() >> 4, w.deep().getZ() >> 4, ChunkStatus.FULL, true);
|
||||
int solid = 0, submerged = 0;
|
||||
for (int z = deepChunk.getPos().getMinBlockZ(); z <= deepChunk.getPos().getMaxBlockZ(); z += 4)
|
||||
for (int x = deepChunk.getPos().getMinBlockX(); x <= deepChunk.getPos().getMaxBlockX(); x += 4) {
|
||||
var column = ExpansionOcean23.column(island, x, z);
|
||||
if (deepChunk.getBlockState(new BlockPos(x, column.floorY() - 3, z)).isSolid()) solid++;
|
||||
var state = deepChunk.getBlockState(new BlockPos(x, column.waterLevel() - 3, z));
|
||||
if (state.getFluidState().is(FluidTags.WATER) || state.is(Blocks.ICE) || state.is(Blocks.PACKED_ICE) || state.is(Blocks.BLUE_ICE)) submerged++;
|
||||
}
|
||||
helper.assertTrue(solid >= 12, "Native features retain a supported seabed: " + island.id() + " " + solid + "/16");
|
||||
helper.assertTrue(submerged >= 12, "The deep basin remains water or natural ice after FEATURES: " + island.id() + " " + submerged + "/16");
|
||||
String deepBiome = biome(level, w.deep());
|
||||
helper.assertTrue(deepBiome.equals("minecraft:" + ExpansionOcean23.biome(island, c)), "Stored deep-ocean biome matches climate: " + island.id());
|
||||
var shoreColumn = ExpansionOcean23.column(island, w.shore().getX(), w.shore().getZ());
|
||||
helper.assertTrue(level.getBlockState(w.shore().atY(shoreColumn.floorY() - 8)).isSolid(), "Dry shore has a real foundation: " + island.id());
|
||||
String shoreBiome = biome(level, w.shore());
|
||||
helper.assertTrue(shoreBiome.equals("minecraft:" + ExpansionOcean23.shoreBiome(island)), "Stored shoreline biome matches its profile: " + island.id());
|
||||
var outside = level.getChunk(w.exterior().getX() >> 4, w.exterior().getZ() >> 4, ChunkStatus.FULL, true);
|
||||
for (int y = level.getMinY(); y <= level.getMaxY(); y++)
|
||||
helper.assertTrue(outside.getBlockState(w.exterior().atY(y)).isAir(), "Ocean leaves exterior void empty: " + island.id() + " y=" + y);
|
||||
helper.assertTrue(biome(level, w.exterior()).equals("minecraft:the_void"), "Exterior biome remains void");
|
||||
var result = new LinkedHashMap<String, Object>();
|
||||
result.put("island", island); result.put("deep", w.deep().toShortString()); result.put("shore", w.shore().toShortString());
|
||||
result.put("water_level", c.waterLevel()); result.put("floor", c.floorY()); result.put("deep_biome", deepBiome);
|
||||
result.put("shore_biome", shoreBiome); result.put("solid_samples", solid); result.put("submerged_samples", submerged);
|
||||
if (island.climate().equals("glacial")) result.put("forced_native_ice_witness", ice(helper, generator, w));
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Map<String, Object> ice(GameTestHelper helper, SanctuaryChunkGenerator generator, Witness witness) {
|
||||
var level = helper.getLevel(); var origin = witness.deep(); var centre = ChunkPos.containing(origin);
|
||||
int sea = ExpansionOcean23.seaLevel(witness.island());
|
||||
var holders = StaticCache2D.<GenerationChunkHolder>create(centre.x(), centre.z(), 1, (x, z) -> {
|
||||
var full = (LevelChunk) level.getChunk(x, z, ChunkStatus.FULL, true);
|
||||
var writable = new ImposterProtoChunk(full, true);
|
||||
return new GenerationChunkHolder(full.getPos()) {
|
||||
@Override protected void addSaveDependency(java.util.concurrent.CompletableFuture<?> dependency) {}
|
||||
@Override public int getTicketLevel() { return 0; }
|
||||
@Override public int getQueueLevel() { return 0; }
|
||||
@Override public ChunkAccess getChunkIfPresentUnchecked(ChunkStatus status) { return writable; }
|
||||
};
|
||||
});
|
||||
var centreChunk = level.getChunk(centre.x(), centre.z(), ChunkStatus.FULL, true);
|
||||
var probe = new ScopeProbe(level, holders, centreChunk);
|
||||
probe.probing = true;
|
||||
boolean observed = false;
|
||||
try { generator.applyBiomeDecoration(probe, centreChunk, level.structureManager()); }
|
||||
catch (ScopeObserved stop) { observed = true; }
|
||||
helper.assertTrue(observed && probe.generatorSea == sea && probe.regionSea == sea && !probe.nativePlacement,
|
||||
"Production FEATURES scope sets both sea levels without bypassing water retention");
|
||||
helper.assertTrue(ExpansionOcean23.decorationSeaLevel() == null && generator.getSeaLevel() == -64,
|
||||
"Production FEATURES scope restores its level even when decoration fails");
|
||||
|
||||
var region = new WorldGenRegion(level, holders, ChunkPyramid.GENERATION_PYRAMID.getStepTo(ChunkStatus.FEATURES), centreChunk);
|
||||
Integer previous = ExpansionOcean23.enterDecoration(sea);
|
||||
int iceAbove = 0, highest = Integer.MIN_VALUE;
|
||||
try {
|
||||
// This native draw has height 9 / width 11. Seed 23042 instead yields
|
||||
// height 3 / width 2: vanilla may legitimately return true without ice.
|
||||
helper.assertTrue(new IcebergFeature(Blocks.PACKED_ICE.defaultBlockState()).place(region, generator,
|
||||
RandomSource.create(23041L), origin.atY(0)), "Native iceberg feature runs in the local ocean scope");
|
||||
for (int x = origin.getX() - 11; x <= origin.getX() + 11; x++)
|
||||
for (int z = origin.getZ() - 11; z <= origin.getZ() + 11; z++) for (int y = sea + 1; y <= sea + 48; y++) {
|
||||
var state = region.getBlockState(new BlockPos(x, y, z));
|
||||
if (state.is(Blocks.PACKED_ICE) || state.is(Blocks.BLUE_ICE)) { iceAbove++; highest = Math.max(highest, y); }
|
||||
}
|
||||
helper.assertTrue(iceAbove > 10 && highest > sea,
|
||||
"Native iceberg forms above the floating ocean: ice=" + iceAbove + ", highest=" + highest + ", sea=" + sea);
|
||||
var blue = origin.offset(5, 0, 5).atY(sea - 4);
|
||||
region.setBlock(blue, Blocks.WATER.defaultBlockState(), 2, 0);
|
||||
region.setBlock(blue.east(), Blocks.PACKED_ICE.defaultBlockState(), 2, 0);
|
||||
helper.assertTrue(new BlueIceFeature().place(region, generator, RandomSource.create(23043L), blue)
|
||||
&& region.getBlockState(blue).is(Blocks.BLUE_ICE), "Native blue ice accepts the same local sea level");
|
||||
var floor = ExpansionOcean23.column(witness.island(), origin.getX(), origin.getZ());
|
||||
var retained = origin.atY(floor.floorY() - 3);
|
||||
var before = region.getBlockState(retained);
|
||||
helper.assertTrue(!region.setBlock(retained, Blocks.AIR.defaultBlockState(), 2, 0)
|
||||
&& region.getBlockState(retained).equals(before), "Decoration sea-level scope cannot punch through the retaining shell");
|
||||
} finally { ExpansionOcean23.restoreDecoration(previous); }
|
||||
helper.assertTrue(NativeStructurePlacement23.seaLevel() == null && ExpansionOcean23.decorationSeaLevel() == null,
|
||||
"Native ice witnesses leave no thread-local state");
|
||||
return Map.of("iceberg_feature_seed", 23041L, "ice_above_sea", iceAbove, "highest_ice", highest, "sea_level", sea,
|
||||
"blue_ice", true, "production_scope_checked", true, "retention_preserved", true);
|
||||
}
|
||||
|
||||
/** Abort at the first random-seed read, before replaying any structures or features. */
|
||||
private static final class ScopeProbe extends WorldGenRegion {
|
||||
boolean probing, nativePlacement; int generatorSea, regionSea;
|
||||
ScopeProbe(ServerLevel level, StaticCache2D<GenerationChunkHolder> holders, ChunkAccess centre) {
|
||||
super(level, holders, ChunkPyramid.GENERATION_PYRAMID.getStepTo(ChunkStatus.FEATURES), centre);
|
||||
}
|
||||
@Override public long getSeed() {
|
||||
if (!probing) return super.getSeed();
|
||||
generatorSea = getLevel().getChunkSource().getGenerator().getSeaLevel(); regionSea = getSeaLevel();
|
||||
nativePlacement = NativeStructurePlacement23.seaLevel() != null;
|
||||
throw new ScopeObserved();
|
||||
}
|
||||
}
|
||||
private static final class ScopeObserved extends RuntimeException {}
|
||||
private static String biome(ServerLevel level, BlockPos pos) {
|
||||
return level.getNoiseBiome(pos.getX() >> 2, pos.getY() >> 2, pos.getZ() >> 2).unwrapKey().orElseThrow().identifier().toString();
|
||||
}
|
||||
private static Map<String, byte[]> files(Path directory) throws java.io.IOException {
|
||||
var files = new TreeMap<String, byte[]>();
|
||||
if (Files.exists(directory)) try (var paths = Files.walk(directory)) {
|
||||
for (var path : paths.filter(Files::isRegularFile).toList()) files.put(directory.relativize(path).toString(), Files.readAllBytes(path));
|
||||
}
|
||||
return files;
|
||||
}
|
||||
private static boolean equalFiles(Map<String, byte[]> before, Map<String, byte[]> after) {
|
||||
return before.keySet().equals(after.keySet()) && before.entrySet().stream().allMatch(e -> Arrays.equals(e.getValue(), after.get(e.getKey())));
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -23,7 +23,7 @@ import net.minecraft.world.level.levelgen.densityfunction.DensitySampler;
|
||||
import net.minecraft.world.level.levelgen.densityfunction.DensityVolume;
|
||||
import net.minecraft.world.level.levelgen.densityfunction.SamplerContext;
|
||||
|
||||
/** Compares production against the frozen alpha.10 implementation; no chunks are created. */
|
||||
/** Compares the explicit legacy27 mode against frozen alpha10, not the intentional alpha28 terrain changes. */
|
||||
final class PopulationDensityEquivalenceDiagnostics {
|
||||
private record Pair(int players, long seed, DensitySampler reference, DensitySampler actual) {}
|
||||
|
||||
@@ -39,7 +39,7 @@ final class PopulationDensityEquivalenceDiagnostics {
|
||||
var key = SanctuaryMod.id("population_" + players);
|
||||
var registered = densities.getOrThrow(ResourceKey.create(Registries.DENSITY_FUNCTION, key)).value();
|
||||
helper.assertTrue(registered instanceof PopulationIslandDensity, "Compare the real registered Population density");
|
||||
var density = (PopulationIslandDensity) registered;
|
||||
var density = ((PopulationIslandDensity) registered).legacy27();
|
||||
helper.assertTrue(ExactInterpolationSampler.supportsTerrain(density.terrain()),
|
||||
"The shipped coordinate-only terrain must actually use the exact cache, not the fallback");
|
||||
var reference = new Alpha10PopulationDensityReference(density.terrain(), density.distortion(), density.sculpt(),
|
||||
@@ -113,7 +113,7 @@ final class PopulationDensityEquivalenceDiagnostics {
|
||||
"reference_commit", "a26b72f", "reference_source_sha256", "fcc5a8a39b7c4d181d74ce4f9183a1ca93646137955ac64bab9d22e6db0752a1",
|
||||
"comparison", "Float.floatToRawIntBits; no tolerance", "profiles", reports, "adversarial", adversarial,
|
||||
"concurrent_comparisons", concurrentComparisons, "concurrent_workers", 3, "passed", true,
|
||||
"scope", "Real compiled scalar/bulk densities, 4 capacities x 3 seeds (5/20/100 compatibility and new10 using the same parameterized algorithm), signed coordinates, region/coast/height boundaries, context switches and concurrency; no block changes")) + "\n");
|
||||
"scope", "Explicit legacy27 mode versus frozen alpha10: real compiled scalar/bulk densities, 4 capacities x 3 seeds, signed coordinates, region/coast/height boundaries, context switches and concurrency. Geology28 is intentionally disabled only for this historical equivalence proof; no alpha28 generation claim.")) + "\n");
|
||||
}
|
||||
|
||||
private static List<DensityVolume> volumes(IslandCapacity capacity) {
|
||||
|
||||
+37
-7
@@ -58,11 +58,15 @@ public final class PopulationDiagnostics {
|
||||
helper.assertFalse(new PopulationDecorationsFeature().place(level, old, RandomSource.create(0), BlockPos.ZERO),
|
||||
"New cave decorations must refuse older saved worlds");
|
||||
}
|
||||
if (level.getChunkSource().getGenerator() instanceof SanctuaryChunkGenerator) {
|
||||
if (level.getChunkSource().getGenerator() instanceof SanctuaryChunkGenerator unified) {
|
||||
var expected = new java.util.HashSet<>(SanctuaryBiomeSource.REQUIRED_BIOMES);
|
||||
if (unified.source().citiesEnabled()) expected.add("sanctuary:lost_city");
|
||||
if (unified.rootGeneration() == 23 || unified.rootGeneration() == 24) fr.koka.sanctuary.expansion.ExpansionOcean23.BIOMES
|
||||
.forEach(name -> expected.add("minecraft:" + name));
|
||||
helper.assertTrue(generator.getBiomeSource() instanceof SanctuaryBiomeSource
|
||||
&& generator.getBiomeSource().possibleBiomes().size() == (((SanctuaryChunkGenerator) level.getChunkSource().getGenerator()).source().citiesEnabled() ? 45 : 44)
|
||||
&& generator.getBiomeSource().possibleBiomes().stream().map(b -> b.getRegisteredName()).collect(java.util.stream.Collectors.toSet()).containsAll(SanctuaryBiomeSource.REQUIRED_BIOMES),
|
||||
"The unified generator retains all 44 historical biome holders, with Lost City added in city-enabled generations");
|
||||
&& generator.getBiomeSource().possibleBiomes().stream().map(b -> b.getRegisteredName())
|
||||
.collect(java.util.stream.Collectors.toSet()).equals(expected),
|
||||
"Historical holders stay intact; generations23/24 add the expansion ocean and shore palette");
|
||||
helper.assertTrue(binding.random() != level.getChunkSource().randomState(),
|
||||
"The unified starter must use its real terrain state, never the expansion host fallback");
|
||||
} else {
|
||||
@@ -83,6 +87,7 @@ public final class PopulationDiagnostics {
|
||||
ResourceKey.create(Registries.DENSITY_FUNCTION, SanctuaryMod.id("population_" + capacity.players()))).value();
|
||||
helper.assertTrue(density instanceof PopulationIslandDensity, "Inspect the actual compiled population density");
|
||||
var island = (PopulationIslandDensity) density;
|
||||
var legacyEnvelope = island.legacy27();
|
||||
helper.assertTrue(island.capacity() == capacity, "Noise settings and density must agree on saved capacity");
|
||||
var random = binding.random();
|
||||
var replay = RandomState.create(level.registryAccess().lookupOrThrow(Registries.NOISE), random.seed(), generator.generatorSettings().value());
|
||||
@@ -98,7 +103,10 @@ public final class PopulationDiagnostics {
|
||||
float value = random.sampleBlockValueUncached(density, x, y, z);
|
||||
float raw = random.sampleBlockValueUncached(island.terrain(), x, y - 64, z);
|
||||
helper.assertTrue(Float.isFinite(value), "Density remains finite at every sampled position");
|
||||
helper.assertTrue(value <= 0 || raw > 0, "Enlarging the envelope must never invent terrain inside natural holes");
|
||||
float historical = island.geology28()
|
||||
? random.sampleBlockValueUncached(legacyEnvelope, x, y, z) : value;
|
||||
helper.assertTrue(historical <= 0 || raw > 0,
|
||||
"The explicit legacy27 envelope never fills its raw natural holes; alpha28 uplands change sample Y");
|
||||
if (value > 0) { if (bottom < 0) bottom = y; top = y; }
|
||||
if (x % (step * 8) == 0 && z % (step * 8) == 0)
|
||||
helper.assertTrue(Float.floatToIntBits(value) == Float.floatToIntBits(replay.sampleBlockValueUncached(density, x, y, z)),
|
||||
@@ -210,8 +218,30 @@ public final class PopulationDiagnostics {
|
||||
}
|
||||
|
||||
void prepare() throws IOException {
|
||||
helper.assertTrue(regionsAtInitialSpawn > 0 && regionsAtInitialSpawn <= 4,
|
||||
"Initial spawn must plan only nearby regions, not materialize the large island: " + regionsAtInitialSpawn);
|
||||
boolean heritage = level.getChunkSource().getGenerator() instanceof SanctuaryChunkGenerator sanctuary
|
||||
&& (sanctuary.rootGeneration() == 24 || sanctuary.rootGeneration() == 23 || sanctuary.rootGeneration() == 22 || (sanctuary.rootGeneration() == 19 || sanctuary.rootGeneration() == 20 || sanctuary.rootGeneration() == 21) && sanctuary.experimentalStructures());
|
||||
// Generation19 explicitly prospects destinations across the root island before publishing them.
|
||||
// A consulted hydrology region is a bounded immutable plan, not a loaded/generated chunk.
|
||||
// Historical generators retain their original near-spawn contract.
|
||||
int regionLimit = 4;
|
||||
if (heritage) {
|
||||
int extent = capacity.terrainLimit();
|
||||
var first = capacity.regionAt(-extent, -extent); var last = capacity.regionAt(extent, extent);
|
||||
regionLimit = 0;
|
||||
for (int x = first.x(); x <= last.x(); x++) for (int z = first.z(); z <= last.z(); z++) {
|
||||
var region = new IslandCapacity.Region(x, z);
|
||||
double nearestX = Math.max(0, Math.max(region.minX(), -region.maxX()));
|
||||
double nearestZ = Math.max(0, Math.max(region.minZ(), -region.maxZ()));
|
||||
if (Math.hypot(nearestX, nearestZ) < extent) regionLimit++;
|
||||
}
|
||||
helper.assertTrue(regionLimit <= 9, "Heritage starter hydrology must fit within nine local regions");
|
||||
var plan = ((SanctuaryChunkGenerator) level.getChunkSource().getGenerator()).heritagePlan19();
|
||||
helper.assertTrue(plan.columns() <= fr.koka.sanctuary.worldgen.heritage.HeritagePlan19.MAX_COLUMNS
|
||||
&& plan.samples() <= fr.koka.sanctuary.worldgen.heritage.HeritagePlan19.MAX_SAMPLES,
|
||||
"Island-wide heritage prospecting exceeded its independent column/probe budget");
|
||||
}
|
||||
helper.assertTrue(regionsAtInitialSpawn > 0 && regionsAtInitialSpawn <= regionLimit,
|
||||
"Initial hydrology exceeded its geographic planning scope (limit " + regionLimit + "): " + regionsAtInitialSpawn);
|
||||
List<IslandCapacity.Region> targets = new ArrayList<>();
|
||||
targets.add(new IslandCapacity.Region(0,0));
|
||||
if (capacity.players() == 20) targets.add(new IslandCapacity.Region(1,0));
|
||||
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
package fr.koka.sanctuary.gametest;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import fr.koka.sanctuary.worldgen.*;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import net.fabricmc.fabric.api.gametest.v1.GameTest;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.gametest.framework.GameTestHelper;
|
||||
import net.minecraft.server.level.TicketType;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
|
||||
public final class River30WorldGameTests {
|
||||
@GameTest(maxTicks=12000)
|
||||
public void riverAndOpenBanksUseRealTerrain(GameTestHelper helper) throws Exception {
|
||||
var level=helper.getLevel(); var generator=(SanctuaryChunkGenerator)level.getChunkSource().getGenerator();
|
||||
var binding=generator.starterContext();var plan=PopulationHydrologyRuntime.river30(binding.generator(),binding.random());
|
||||
var report=new LinkedHashMap<String,Object>();report.put("seed",level.getSeed());report.put("diameter",generator.initialDiameter());
|
||||
report.put("process_id",ProcessHandle.current().pid());report.put("river_cells",plan.cells().size());report.put("features",plan.features());report.put("spills",plan.spills());
|
||||
report.put("mineral",generator.mineralSanctuary23());
|
||||
helper.assertTrue(plan.features().stream().anyMatch(f->f.kind()==PopulationHydrology.Kind.RIVER),"An island-wide river must be present in the release witness");
|
||||
if(level.structureManager().shouldGenerateStructures()&&generator.experimentalStructures())
|
||||
helper.assertFalse(generator.mineralSanctuary23().isEmpty(),"The mineral sanctuary must be present in the release witness");
|
||||
var selected=plan.cells().stream().filter(PopulationHydrology.Cell::hasWater).toList();
|
||||
var witnesses=new ArrayList<PopulationHydrology.Cell>();
|
||||
for(int i=0;i<6;i++)witnesses.add(selected.get(i*(selected.size()-1)/5));
|
||||
var falls=plan.spills().stream().limit(2).toList();var chunks=new LinkedHashSet<ChunkPos>();
|
||||
witnesses.forEach(c->chunks.add(new ChunkPos(c.x()>>4,c.z()>>4)));
|
||||
for(var fall:falls){chunks.add(new ChunkPos(fall.source().x()>>4,fall.source().z()>>4));chunks.add(new ChunkPos(fall.outlet().x()>>4,fall.outlet().z()>>4));}
|
||||
var mineral=generator.mineralSanctuary23().chamber();
|
||||
if(mineral!=null){
|
||||
var key=fr.koka.sanctuary.worldgen.mineral.MineralSanctuaryStructures23.KEY;
|
||||
var structure=level.registryAccess().lookupOrThrow(net.minecraft.core.registries.Registries.STRUCTURE).getOrThrow(key).value();
|
||||
var cp=new ChunkPos(mineral.startChunkX(),mineral.startChunkZ());
|
||||
var start=level.getChunk(cp.x(),cp.z(),ChunkStatus.STRUCTURE_STARTS,true).getStartForStructure(structure);
|
||||
helper.assertTrue(start!=null&&start.isValid()&&start.getPieces().size()==1,"The mineral plan produces its actual native structure start");
|
||||
chunks.add(cp);
|
||||
}
|
||||
var iterator=chunks.iterator();Runnable[] step=new Runnable[1];
|
||||
step[0]=()->{
|
||||
if(iterator.hasNext()) {var c=iterator.next();level.getChunk(c.x(),c.z(),ChunkStatus.FULL,true);helper.runAtTickTime(helper.getTick()+1,()->step[0].run());return;}
|
||||
chunks.forEach(c->level.getChunkSource().addTicketWithRadius(TicketType.DRAGON,c,2));
|
||||
helper.runAtTickTime(helper.getTick()+120,()->{
|
||||
try {
|
||||
if(mineral!=null){
|
||||
var floor=new BlockPos(mineral.centerX(),mineral.minY()+2,mineral.centerZ());
|
||||
helper.assertTrue(level.getBlockState(floor).isSolid()&&level.getBlockState(floor.above()).isAir(),"The central mineral floor and guardian space are really generated");
|
||||
report.put("mineral_native_floor",List.of(floor.getX(),floor.getY(),floor.getZ()));
|
||||
}
|
||||
for(var c:witnesses)helper.assertTrue(!level.getFluidState(new BlockPos(c.x(),c.waterY(),c.z())).isEmpty(),"Generated river water remains at its supported local bed");
|
||||
int flowing=0;
|
||||
for(var fall:falls)for(int dx=-1;dx<=1;dx++)for(int dz=-1;dz<=1;dz++)
|
||||
if(!level.getFluidState(new BlockPos(fall.outlet().x()+dx,fall.outlet().y()-3,fall.outlet().z()+dz)).isEmpty()){flowing++;}
|
||||
if(!falls.isEmpty())helper.assertTrue(flowing>0,"Vanilla fluid ticks carry water below at least one opened bank");
|
||||
report.put("full_chunks",chunks.size());report.put("flowing_below_openings",flowing);report.put("passed",true);
|
||||
Path out=Path.of("diagnostics/alpha30/river.json");Files.createDirectories(out.getParent());Files.writeString(out,new GsonBuilder().setPrettyPrinting().create().toJson(report));helper.succeed();
|
||||
}catch(Exception error){throw new RuntimeException(error);}finally{chunks.forEach(c->level.getChunkSource().removeTicketWithRadius(TicketType.DRAGON,c,2));}
|
||||
});
|
||||
};step[0].run();
|
||||
}
|
||||
}
|
||||
+223
@@ -0,0 +1,223 @@
|
||||
package fr.koka.sanctuary.gametest;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import fr.koka.sanctuary.expansion.ExpansionIsland;
|
||||
import fr.koka.sanctuary.worldgen.PopulationGenerationContext;
|
||||
import fr.koka.sanctuary.worldgen.SanctuaryChunkGenerator;
|
||||
import fr.koka.sanctuary.worldgen.city.*;
|
||||
import fr.koka.sanctuary.worldgen.heritage.*;
|
||||
import fr.koka.sanctuary.worldgen.transit.*;
|
||||
import fr.koka.sanctuary.worldgen.ruins.*;
|
||||
import fr.koka.sanctuary.worldgen.mineral.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import net.fabricmc.fabric.api.gametest.v1.GameTest;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.gametest.framework.GameTestHelper;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
import net.minecraft.world.level.levelgen.structure.Structure;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureStart;
|
||||
import net.minecraft.world.level.levelgen.structure.pieces.StructurePieceSerializationContext;
|
||||
import net.minecraft.world.level.storage.LevelResource;
|
||||
|
||||
/** Read-only admission audit, then native starts and reload in the disposable development world. */
|
||||
public final class Secrets23WorldGameTests {
|
||||
@GameTest(maxTicks = 12000)
|
||||
public void naturalSecretsPersist(GameTestHelper helper) throws Exception {
|
||||
var level = helper.getLevel();
|
||||
var generator = (SanctuaryChunkGenerator) level.getChunkSource().getGenerator();
|
||||
helper.assertTrue(generator.rootGeneration() == 23, "Use a fresh23 development world");
|
||||
if (!level.structureManager().shouldGenerateStructures()) { verifyGlobalOff(helper, generator); return; }
|
||||
var root = ExpansionIsland.origin(generator.initialDiameter(), level.getSeed(), 23);
|
||||
var heritage = generator.heritagePlan19();
|
||||
var transit = generator.transitPlan21();
|
||||
var mineral = generator.mineralSanctuary23();
|
||||
var ruins = generator.ruinsPlan17();
|
||||
helper.assertTrue(generator.lostCityPlan(root).isEmpty(), "No surface city on the natural starter island");
|
||||
helper.assertTrue(heritage.sites().stream().allMatch(s -> s.kind() == HeritagePlan19.Kind.OBSERVATORY), "Only isolated observatory is selected");
|
||||
helper.assertTrue(ruins.networks().size() <= 1, "At most one hidden workshop network");
|
||||
for (var network : ruins.networks()) {
|
||||
helper.assertTrue(network.rooms().stream().anyMatch(r -> r.kind() == RuinsPlan17.Kind.WORKSHOP), "Secret network contains its workshop");
|
||||
helper.assertTrue(network.rooms().stream().allMatch(r -> r.kind() == RuinsPlan17.Kind.ACCESS
|
||||
|| r.kind() == RuinsPlan17.Kind.CORRIDOR || r.kind() == RuinsPlan17.Kind.WORKSHOP), "No unselected rooms");
|
||||
}
|
||||
for (var segment : heritage.segments()) for (var cell : segment.cells())
|
||||
helper.assertTrue(Math.hypot(cell.x(), cell.z()) >= 48, "Surface routes preserve natural arrival");
|
||||
if (generator.experimentalStructures()) helper.assertTrue(heritage.segments().stream()
|
||||
.anyMatch(s -> s.kind() == HeritagePlan19.RouteKind.FREIGHT && s.cells().stream().anyMatch(c -> c.railPresent())),
|
||||
"Reference island retains a real repairable rail run, not only endpoint markers");
|
||||
var binding = Objects.requireNonNull(PopulationGenerationContext.of(level));
|
||||
var terrain = new HeritageTerrain21(root, binding.generator(), binding.random(), level, p -> false);
|
||||
int columns = 0;
|
||||
// The three samplers have independent bounded caches, just like production planning.
|
||||
terrain = new HeritageTerrain21(root, binding.generator(), binding.random(), level, p -> false);
|
||||
for (var site : heritage.sites()) {
|
||||
helper.assertTrue(site.supports().isEmpty(), "No heritage rescue piers");
|
||||
for (int x = site.minX(); x <= site.maxX(); x++) for (int z = site.minZ(); z <= site.maxZ(); z++) {
|
||||
helper.assertTrue(Math.abs(site.floorY() - terrain.surfaceY(x, z)) <= 2, "Building cut/fill stays within two blocks");
|
||||
helper.assertTrue(terrain.solid(x, site.minY() - 1, z) && terrain.solid(x, site.minY() - 2, z), "Every foundation column rests on original rock"); columns++;
|
||||
}
|
||||
}
|
||||
helper.assertTrue(!transit.isEmpty(), "The reference island retains its core traversal");
|
||||
var hall = generator.undergroundHall22();
|
||||
helper.assertTrue(!hall.isEmpty(), "Core hall exists independently of a surface town");
|
||||
helper.assertTrue(hall.networks().stream().flatMap(n -> n.modules().stream()).noneMatch(m -> m.kind() == LostCityUnderground16.Kind.POOLROOM), "Pool rooms stay outside the active selection");
|
||||
for (var module : transit.modules()) for (var support : module.supports())
|
||||
helper.assertTrue(support.maxY() - support.minY() + 1 <= 16, "Core traversal retains bounded engineered supports");
|
||||
if (!generator.experimentalStructures()) helper.assertTrue(heritage.sites().isEmpty() && heritage.segments().isEmpty() && ruins.isEmpty() && mineral.isEmpty(), "OFF removes optional catalogue, not core hall and traversal");
|
||||
var gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
var encoded = ChunkGenerator.CODEC.encodeStart(RegistryOps.create(JsonOps.INSTANCE, level.registryAccess()), generator).getOrThrow();
|
||||
var geometry = gson.toJsonTree(Map.of("mineral", mineral.isEmpty() ? List.of() : List.of(mineral.chamber()), "ruins", ruins.networks(), "heritage_sites", heritage.sites(),
|
||||
"heritage_links", heritage.links(), "heritage_segments", heritage.segments(), "transit", transit.modules(), "independent_hall", hall.networks()));
|
||||
var report = new LinkedHashMap<String, Object>();
|
||||
report.put("seed", level.getSeed()); report.put("size", generator.initialDiameter());
|
||||
report.put("process_id", ProcessHandle.current().pid()); report.put("generator_codec", encoded); report.put("geometry", geometry);
|
||||
report.put("experimental", generator.experimentalStructures()); report.put("city_districts", 0); report.put("mineral_accepted", !mineral.isEmpty()); report.put("ruins_networks", ruins.networks().size());
|
||||
report.put("heritage_sites", heritage.sites().size()); report.put("heritage_links", heritage.links().size()); report.put("transit_modules", transit.modules().size());
|
||||
report.put("independent_hall_networks", hall.networks().size());
|
||||
report.put("core_entries", transit.modules().stream().filter(m -> m.kind() == TransitPlan21.Kind.ACCESS).map(m -> List.of(m.centerX(), m.surfaceY() + 1, m.minZ() - 2)).toList());
|
||||
report.put("hall_entries", hall.networks().stream().map(n -> { var at = LostCityUndergroundStructures22.locator(n); return List.of(at.getX(), at.getY(), at.getZ()); }).toList());
|
||||
report.put("natural_columns_audited", columns);
|
||||
report.put("mineral_diagnostics", mineral.diagnostic());
|
||||
report.put("heritage_diagnostics", heritage.diagnostics()); report.put("transit_diagnostics", transit.diagnostic());
|
||||
var starts = new ArrayList<StructureStart>();
|
||||
var origins = new LinkedHashMap<ResourceKey<Structure>, Set<ChunkPos>>();
|
||||
origins.put(LostCityStructures.KEY, new HashSet<>()); origins.put(HeritageStructures19.KEY, new HashSet<>()); origins.put(TransitStructures21.KEY, new HashSet<>()); origins.put(LostCityUndergroundStructures22.KEY, new HashSet<>());
|
||||
origins.put(RuinsStructures17.KEY, new HashSet<>()); origins.put(MineralSanctuaryStructures23.KEY, new HashSet<>());
|
||||
ruins.networks().forEach(n -> origins.get(RuinsStructures17.KEY).add(new ChunkPos(n.startChunkX(), n.startChunkZ())));
|
||||
if (!mineral.isEmpty()) origins.get(MineralSanctuaryStructures23.KEY).add(new ChunkPos(mineral.chamber().startChunkX(), mineral.chamber().startChunkZ()));
|
||||
heritage.sites().forEach(s -> origins.get(HeritageStructures19.KEY).add(new ChunkPos(s.startChunkX(), s.startChunkZ())));
|
||||
heritage.segments().forEach(s -> origins.get(HeritageStructures19.KEY).add(new ChunkPos(s.startChunkX(), s.startChunkZ())));
|
||||
transit.modules().forEach(m -> origins.get(TransitStructures21.KEY).add(new ChunkPos(m.startChunkX(), m.startChunkZ())));
|
||||
hall.networks().forEach(n -> origins.get(LostCityUndergroundStructures22.KEY).add(new ChunkPos(n.startChunkX(), n.startChunkZ())));
|
||||
var chunks = new TreeSet<ChunkPos>(Comparator.comparingInt(ChunkPos::x).thenComparingInt(ChunkPos::z));
|
||||
var nativeTags = new TreeMap<String, String>();
|
||||
var context = StructurePieceSerializationContext.fromLevel(level);
|
||||
for (var entry : origins.entrySet()) for (var origin : entry.getValue()) {
|
||||
var type = level.registryAccess().lookupOrThrow(Registries.STRUCTURE).getOrThrow(entry.getKey()).value();
|
||||
var start = level.getChunk(origin.x(), origin.z(), ChunkStatus.STRUCTURE_STARTS, true).getStartForStructure(type);
|
||||
helper.assertTrue(start != null && start.isValid(), "Accepted geometry must have a native start");
|
||||
for (var piece : start.getPieces()) {
|
||||
helper.assertTrue(!(piece instanceof LostCityFoundationPiece16), "No artificial city foundation emitted");
|
||||
if (entry.getKey().equals(HeritageStructures19.KEY)) helper.assertTrue(piece instanceof HeritagePiece21, "Use published21 architecture");
|
||||
if (entry.getKey().equals(LostCityUndergroundStructures22.KEY)) helper.assertTrue(piece instanceof LostCityUndergroundPiece20, "Independent hall keeps published20 room geometry");
|
||||
if (entry.getKey().equals(TransitStructures21.KEY)) helper.assertTrue(piece instanceof TransitPiece21 || piece instanceof TransitPiece22, "Published21 tunnel geometry with sealed22 corners");
|
||||
if (entry.getKey().equals(MineralSanctuaryStructures23.KEY)) helper.assertTrue(piece instanceof MineralSanctuaryPiece23, "Saved mineral23 geometry");
|
||||
if (entry.getKey().equals(RuinsStructures17.KEY)) helper.assertTrue(piece instanceof RuinsPiece20, "Saved workshop20 geometry");
|
||||
piece.getBoundingBox().intersectingChunks().forEach(chunks::add);
|
||||
}
|
||||
var tag = start.createTag(context, origin);
|
||||
var loaded = StructureStart.loadStaticStart(context, tag, level.getSeed());
|
||||
helper.assertTrue(loaded != null && tag.equals(loaded.createTag(context, origin)), "Native start round trip");
|
||||
nativeTags.put(entry.getKey().identifier() + "/" + origin.x() + "/" + origin.z(), tag.toString()); starts.add(start);
|
||||
}
|
||||
if (chunks.isEmpty()) chunks.add(new ChunkPos(0, 0));
|
||||
report.put("native_starts", nativeTags); report.put("full_chunks", chunks.size());
|
||||
Path world = level.getServer().getWorldPath(LevelResource.ROOT).toAbsolutePath().normalize();
|
||||
Path proof = world.resolve("secrets23-create.json");
|
||||
boolean reload = Boolean.getBoolean("sanctuary.test.expansionReload");
|
||||
JsonObject previous = reload ? JsonParser.parseString(Files.readString(proof)).getAsJsonObject() : null;
|
||||
if (reload) {
|
||||
helper.assertTrue(previous.get("passed").getAsBoolean() && previous.get("process_id").getAsLong() != ProcessHandle.current().pid(), "Reload follows a successful separate JVM");
|
||||
helper.assertTrue(previous.get("generator_codec").equals(encoded) && previous.get("geometry").equals(geometry), "Generation, options and accepted/refused placements survive reload");
|
||||
helper.assertTrue(previous.get("native_starts").equals(gson.toJsonTree(nativeTags)), "Native saved starts survive reload");
|
||||
}
|
||||
var iterator = chunks.iterator();
|
||||
Runnable finish = () -> {
|
||||
try {
|
||||
// Refresh already-generated transit chunks: the earlier short FULL tickets can expire
|
||||
// while the catalogue loads. The walk checks real native collision shapes, including turns.
|
||||
var transitChunks = new HashSet<ChunkPos>();
|
||||
transit.modules().forEach(m -> TransitPiece21.bounds(m).intersectingChunks().forEach(transitChunks::add));
|
||||
for (var pos : transitChunks) level.getChunk(pos.x(), pos.z(), ChunkStatus.FULL, true);
|
||||
int nativeRails = 0;
|
||||
for (var segment : heritage.segments()) {
|
||||
level.getChunk(segment.startChunkX(), segment.startChunkZ(), ChunkStatus.FULL, true);
|
||||
for (var cell : segment.cells()) if (cell.railPresent()) {
|
||||
var at = new BlockPos(cell.x(), cell.floorY() + 1, cell.z());
|
||||
helper.assertTrue(level.getBlockState(at).is(Blocks.RAIL), "Planned rail survives in actual FULL chunk");
|
||||
helper.assertTrue(level.getBlockState(at.below()).isSolid(), "Native rail remains supported by its ballast");
|
||||
nativeRails++;
|
||||
}
|
||||
}
|
||||
if (generator.experimentalStructures()) helper.assertTrue(nativeRails > 0, "Real repairable railway is present after chunk decoration");
|
||||
report.put("native_rail_blocks", nativeRails);
|
||||
report.put("transit_native_walk", Transit21WorldGameTests.verifyAccess(helper, transit));
|
||||
report.put("hall_native_access", Underground22NativeChecks.verify(helper, hall.isEmpty() ? generator.undergroundPlan16(root) : hall));
|
||||
if (!mineral.isEmpty()) {
|
||||
var c = mineral.chamber();
|
||||
for (var pos : c.bounds().intersectingChunks().toList()) level.getChunk(pos.x(), pos.z(), ChunkStatus.FULL, true);
|
||||
for (int dz = -19; dz <= 19; dz += 3) for (int dx = -19; dx <= 19; dx += 3) {
|
||||
var floor = new BlockPos(c.centerX() + dx, c.minY() + 2, c.centerZ() + dz);
|
||||
helper.assertTrue(level.getBlockState(floor).isSolid(), "Mineral native central floor remains walkable");
|
||||
helper.assertTrue(level.getBlockState(floor.above()).isAir() && level.getBlockState(floor.above(2)).isAir(), "Mineral native central room remains clear");
|
||||
}
|
||||
}
|
||||
if (!heritage.sites().isEmpty()) {
|
||||
var site = heritage.sites().getFirst();
|
||||
var witness = new BlockPos(site.centerX(), site.floorY() - 1, site.centerZ());
|
||||
if (reload) helper.assertTrue(level.getBlockState(witness).is(Blocks.GOLD_BLOCK), "Personal edit in disposable test survives reload");
|
||||
else {
|
||||
helper.assertTrue(level.getBlockState(witness).isSolid(), "Accepted building foundation generated in real FULL chunks");
|
||||
level.setBlock(witness, Blocks.GOLD_BLOCK.defaultBlockState(), 3);
|
||||
}
|
||||
report.put("saved_edit", List.of(witness.getX(), witness.getY(), witness.getZ()));
|
||||
}
|
||||
helper.assertTrue(level.getServer().saveEverything(true, true, true), "Flush native world before shutdown");
|
||||
report.put("passed", true);
|
||||
var directory = Path.of("diagnostics", "secrets23-" + level.getSeed() + "-" + generator.initialDiameter()); Files.createDirectories(directory);
|
||||
var text = gson.toJson(report) + "\n"; Files.writeString(directory.resolve(reload ? "reload.json" : "create.json"), text);
|
||||
if (!reload) Files.writeString(proof, text);
|
||||
helper.succeed();
|
||||
} catch (Exception failure) { throw new IllegalStateException(failure); }
|
||||
};
|
||||
Runnable[] load = new Runnable[1];
|
||||
load[0] = () -> {
|
||||
if (!iterator.hasNext()) { finish.run(); return; }
|
||||
var pos = iterator.next(); level.getChunk(pos.x(), pos.z(), ChunkStatus.FULL, true);
|
||||
helper.runAtTickTime(helper.getTick() + 1, () -> load[0].run());
|
||||
};
|
||||
load[0].run();
|
||||
}
|
||||
private static void verifyGlobalOff(GameTestHelper helper, SanctuaryChunkGenerator generator) throws Exception {
|
||||
var level = helper.getLevel();
|
||||
var chunks = new TreeSet<ChunkPos>(Comparator.comparingInt(ChunkPos::x).thenComparingInt(ChunkPos::z));
|
||||
chunks.add(new ChunkPos(0, 0)); chunks.add(new ChunkPos(4, 4)); chunks.add(new ChunkPos(-4, -4));
|
||||
generator.heritagePlan19().sites().forEach(s -> chunks.add(new ChunkPos(s.startChunkX(), s.startChunkZ())));
|
||||
generator.heritagePlan19().segments().forEach(s -> chunks.add(new ChunkPos(s.startChunkX(), s.startChunkZ())));
|
||||
generator.ruinsPlan17().networks().forEach(n -> chunks.add(new ChunkPos(n.startChunkX(), n.startChunkZ())));
|
||||
generator.transitPlan21().modules().forEach(m -> chunks.add(new ChunkPos(m.startChunkX(), m.startChunkZ())));
|
||||
generator.undergroundHall22().networks().forEach(n -> chunks.add(new ChunkPos(n.startChunkX(), n.startChunkZ())));
|
||||
var mineral = generator.mineralSanctuary23();
|
||||
if (!mineral.isEmpty()) chunks.add(new ChunkPos(mineral.chamber().startChunkX(), mineral.chamber().startChunkZ()));
|
||||
var manufactured = Set.of(Blocks.RAIL, Blocks.STONE_BRICKS, Blocks.STONE_BRICK_STAIRS, Blocks.CHISELED_STONE_BRICKS,
|
||||
Blocks.IRON_BARS, Blocks.SMOOTH_STONE);
|
||||
int checked = 0;
|
||||
for (var pos : chunks) {
|
||||
var chunk = level.getChunk(pos.x(), pos.z(), ChunkStatus.FULL, true);
|
||||
helper.assertTrue(chunk.getAllStarts().values().stream().noneMatch(StructureStart::isValid), "GlobalOFF emits no native structure start");
|
||||
var at = new BlockPos.MutableBlockPos();
|
||||
for (int z = pos.getMinBlockZ(); z <= pos.getMaxBlockZ(); z++) for (int x = pos.getMinBlockX(); x <= pos.getMaxBlockX(); x++)
|
||||
for (int y = 1; y < 383; y++) {
|
||||
at.set(x, y, z);
|
||||
helper.assertTrue(!manufactured.contains(chunk.getBlockState(at).getBlock()), "GlobalOFF leaves no generated secret architecture or rails");
|
||||
checked++;
|
||||
}
|
||||
}
|
||||
var directory = Path.of("diagnostics", "secrets23-" + level.getSeed() + "-" + generator.initialDiameter()); Files.createDirectories(directory);
|
||||
Files.writeString(directory.resolve("global-off.json"), new GsonBuilder().setPrettyPrinting().create().toJson(
|
||||
Map.of("passed", true, "structures_enabled", false, "chunks", chunks.size(), "blocks_checked", checked)) + "\n");
|
||||
helper.succeed();
|
||||
}
|
||||
|
||||
}
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
package fr.koka.sanctuary.gametest;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import fr.koka.sanctuary.expansion.ExpansionIsland;
|
||||
import fr.koka.sanctuary.worldgen.PopulationGenerationContext;
|
||||
import fr.koka.sanctuary.worldgen.SanctuaryChunkGenerator;
|
||||
import fr.koka.sanctuary.worldgen.city.*;
|
||||
import fr.koka.sanctuary.worldgen.heritage.*;
|
||||
import fr.koka.sanctuary.worldgen.transit.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import net.fabricmc.fabric.api.gametest.v1.GameTest;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.gametest.framework.GameTestHelper;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
import net.minecraft.world.level.levelgen.structure.Structure;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureStart;
|
||||
import net.minecraft.world.level.levelgen.structure.pieces.StructurePieceSerializationContext;
|
||||
import net.minecraft.world.level.storage.LevelResource;
|
||||
|
||||
/** Read-only admission audit, then native starts and reload in the disposable development world. */
|
||||
public final class Selective22WorldGameTests {
|
||||
@GameTest(maxTicks = 12000)
|
||||
public void naturalSitesAndRefusalsPersist(GameTestHelper helper) throws Exception {
|
||||
var level = helper.getLevel();
|
||||
var generator = (SanctuaryChunkGenerator) level.getChunkSource().getGenerator();
|
||||
helper.assertTrue(generator.rootGeneration() == 22, "Use a fresh22 development world");
|
||||
var root = ExpansionIsland.origin(generator.initialDiameter(), level.getSeed(), 22);
|
||||
var city = generator.cityPlacement21(root);
|
||||
var heritage = generator.heritagePlan19();
|
||||
var transit = generator.transitPlan21();
|
||||
helper.assertTrue(city != null && city.reservation() == null && city.supports().isEmpty(), "No forced city envelope or rescue piers");
|
||||
var binding = Objects.requireNonNull(PopulationGenerationContext.of(level));
|
||||
var terrain = new HeritageTerrain21(root, binding.generator(), binding.random(), level, p -> false);
|
||||
int columns = 0;
|
||||
for (var district : city.surface().districts()) for (var parcel : district.parcels()) {
|
||||
for (int x = parcel.minX(); x <= parcel.maxX(); x++) for (int z = parcel.minZ(); z <= parcel.maxZ(); z++) {
|
||||
int floor = parcel.surfaceY(x - parcel.minX(), z - parcel.minZ());
|
||||
helper.assertTrue(Math.abs(floor - terrain.surfaceY(x, z)) <= 2, "City must fit natural relief"); columns++;
|
||||
}
|
||||
}
|
||||
// The three samplers have independent bounded caches, just like production planning.
|
||||
terrain = new HeritageTerrain21(root, binding.generator(), binding.random(), level, p -> false);
|
||||
for (var site : heritage.sites()) {
|
||||
helper.assertTrue(site.supports().isEmpty(), "No heritage rescue piers");
|
||||
for (int x = site.minX(); x <= site.maxX(); x++) for (int z = site.minZ(); z <= site.maxZ(); z++) {
|
||||
helper.assertTrue(Math.abs(site.floorY() - terrain.surfaceY(x, z)) <= 2, "Building cut/fill stays within two blocks");
|
||||
helper.assertTrue(terrain.solid(x, site.minY() - 1, z) && terrain.solid(x, site.minY() - 2, z), "Every foundation column rests on original rock"); columns++;
|
||||
}
|
||||
}
|
||||
helper.assertTrue(!transit.isEmpty(), "The reference island retains its core traversal");
|
||||
var hall = generator.undergroundHall22();
|
||||
helper.assertTrue(!hall.isEmpty() || generator.undergroundPlan16(root).networks().stream().flatMap(n -> n.modules().stream())
|
||||
.anyMatch(m -> m.kind() == LostCityUnderground16.Kind.EXPANSION_HALL), "Core hall exists with or without a surface town");
|
||||
for (var module : transit.modules()) for (var support : module.supports())
|
||||
helper.assertTrue(support.maxY() - support.minY() + 1 <= 16, "Core traversal retains bounded engineered supports");
|
||||
if (!generator.experimentalStructures()) helper.assertTrue(heritage.isEmpty() && generator.ruinsPlan17().isEmpty(), "OFF removes optional catalogue, not core hall and traversal");
|
||||
var gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
var encoded = ChunkGenerator.CODEC.encodeStart(RegistryOps.create(JsonOps.INSTANCE, level.registryAccess()), generator).getOrThrow();
|
||||
var geometry = gson.toJsonTree(Map.of("city", city.surface().districts(), "heritage_sites", heritage.sites(),
|
||||
"heritage_links", heritage.links(), "heritage_segments", heritage.segments(), "transit", transit.modules(), "independent_hall", hall.networks()));
|
||||
var report = new LinkedHashMap<String, Object>();
|
||||
report.put("seed", level.getSeed()); report.put("size", generator.initialDiameter());
|
||||
report.put("process_id", ProcessHandle.current().pid()); report.put("generator_codec", encoded); report.put("geometry", geometry);
|
||||
report.put("experimental", generator.experimentalStructures()); report.put("city_districts", city.surface().districts().size());
|
||||
report.put("heritage_sites", heritage.sites().size()); report.put("heritage_links", heritage.links().size()); report.put("transit_modules", transit.modules().size());
|
||||
report.put("independent_hall_networks", hall.networks().size());
|
||||
report.put("core_entries", transit.modules().stream().filter(m -> m.kind() == TransitPlan21.Kind.ACCESS).map(m -> List.of(m.centerX(), m.surfaceY() + 1, m.minZ() - 2)).toList());
|
||||
report.put("hall_entries", hall.networks().stream().map(n -> { var at = LostCityUndergroundStructures22.locator(n); return List.of(at.getX(), at.getY(), at.getZ()); }).toList());
|
||||
report.put("natural_columns_audited", columns); report.put("city_diagnostics", city.diagnostics());
|
||||
report.put("heritage_diagnostics", heritage.diagnostics()); report.put("transit_diagnostics", transit.diagnostic());
|
||||
var starts = new ArrayList<StructureStart>();
|
||||
var origins = new LinkedHashMap<ResourceKey<Structure>, Set<ChunkPos>>();
|
||||
origins.put(LostCityStructures.KEY, new HashSet<>()); origins.put(HeritageStructures19.KEY, new HashSet<>()); origins.put(TransitStructures21.KEY, new HashSet<>()); origins.put(LostCityUndergroundStructures22.KEY, new HashSet<>());
|
||||
city.surface().districts().forEach(d -> origins.get(LostCityStructures.KEY).add(new ChunkPos(d.startChunkX(), d.startChunkZ())));
|
||||
heritage.sites().forEach(s -> origins.get(HeritageStructures19.KEY).add(new ChunkPos(s.startChunkX(), s.startChunkZ())));
|
||||
heritage.segments().forEach(s -> origins.get(HeritageStructures19.KEY).add(new ChunkPos(s.startChunkX(), s.startChunkZ())));
|
||||
transit.modules().forEach(m -> origins.get(TransitStructures21.KEY).add(new ChunkPos(m.startChunkX(), m.startChunkZ())));
|
||||
hall.networks().forEach(n -> origins.get(LostCityUndergroundStructures22.KEY).add(new ChunkPos(n.startChunkX(), n.startChunkZ())));
|
||||
var chunks = new TreeSet<ChunkPos>(Comparator.comparingInt(ChunkPos::x).thenComparingInt(ChunkPos::z));
|
||||
var nativeTags = new TreeMap<String, String>();
|
||||
var context = StructurePieceSerializationContext.fromLevel(level);
|
||||
for (var entry : origins.entrySet()) for (var origin : entry.getValue()) {
|
||||
var type = level.registryAccess().lookupOrThrow(Registries.STRUCTURE).getOrThrow(entry.getKey()).value();
|
||||
var start = level.getChunk(origin.x(), origin.z(), ChunkStatus.STRUCTURE_STARTS, true).getStartForStructure(type);
|
||||
helper.assertTrue(start != null && start.isValid(), "Accepted geometry must have a native start");
|
||||
for (var piece : start.getPieces()) {
|
||||
helper.assertTrue(!(piece instanceof LostCityFoundationPiece16), "No artificial city foundation emitted");
|
||||
if (entry.getKey().equals(HeritageStructures19.KEY)) helper.assertTrue(piece instanceof HeritagePiece21, "Use published21 architecture");
|
||||
if (entry.getKey().equals(LostCityUndergroundStructures22.KEY)) helper.assertTrue(piece instanceof LostCityUndergroundPiece20, "Independent hall keeps published20 room geometry");
|
||||
if (entry.getKey().equals(TransitStructures21.KEY)) helper.assertTrue(piece instanceof TransitPiece21 || piece instanceof TransitPiece22, "Published21 tunnel geometry with sealed22 corners");
|
||||
piece.getBoundingBox().intersectingChunks().forEach(chunks::add);
|
||||
}
|
||||
var tag = start.createTag(context, origin);
|
||||
var loaded = StructureStart.loadStaticStart(context, tag, level.getSeed());
|
||||
helper.assertTrue(loaded != null && tag.equals(loaded.createTag(context, origin)), "Native start round trip");
|
||||
nativeTags.put(entry.getKey().identifier() + "/" + origin.x() + "/" + origin.z(), tag.toString()); starts.add(start);
|
||||
}
|
||||
if (chunks.isEmpty()) chunks.add(new ChunkPos(0, 0));
|
||||
report.put("native_starts", nativeTags); report.put("full_chunks", chunks.size());
|
||||
Path world = level.getServer().getWorldPath(LevelResource.ROOT).toAbsolutePath().normalize();
|
||||
Path proof = world.resolve("selective22-create.json");
|
||||
boolean reload = Boolean.getBoolean("sanctuary.test.expansionReload");
|
||||
JsonObject previous = reload ? JsonParser.parseString(Files.readString(proof)).getAsJsonObject() : null;
|
||||
if (reload) {
|
||||
helper.assertTrue(previous.get("passed").getAsBoolean() && previous.get("process_id").getAsLong() != ProcessHandle.current().pid(), "Reload follows a successful separate JVM");
|
||||
helper.assertTrue(previous.get("generator_codec").equals(encoded) && previous.get("geometry").equals(geometry), "Generation, options and accepted/refused placements survive reload");
|
||||
helper.assertTrue(previous.get("native_starts").equals(gson.toJsonTree(nativeTags)), "Native saved starts survive reload");
|
||||
}
|
||||
var iterator = chunks.iterator();
|
||||
Runnable finish = () -> {
|
||||
try {
|
||||
// Refresh already-generated transit chunks: the earlier short FULL tickets can expire
|
||||
// while the catalogue loads. The walk checks real native collision shapes, including turns.
|
||||
var transitChunks = new HashSet<ChunkPos>();
|
||||
transit.modules().forEach(m -> TransitPiece21.bounds(m).intersectingChunks().forEach(transitChunks::add));
|
||||
for (var pos : transitChunks) level.getChunk(pos.x(), pos.z(), ChunkStatus.FULL, true);
|
||||
report.put("transit_native_walk", Transit21WorldGameTests.verifyAccess(helper, transit));
|
||||
report.put("hall_native_access", Underground22NativeChecks.verify(helper, hall.isEmpty() ? generator.undergroundPlan16(root) : hall));
|
||||
if (!heritage.sites().isEmpty()) {
|
||||
var site = heritage.sites().getFirst();
|
||||
var witness = new BlockPos(site.centerX(), site.floorY() - 1, site.centerZ());
|
||||
if (reload) helper.assertTrue(level.getBlockState(witness).is(Blocks.GOLD_BLOCK), "Personal edit in disposable test survives reload");
|
||||
else {
|
||||
helper.assertTrue(level.getBlockState(witness).isSolid(), "Accepted building foundation generated in real FULL chunks");
|
||||
level.setBlock(witness, Blocks.GOLD_BLOCK.defaultBlockState(), 3);
|
||||
}
|
||||
report.put("saved_edit", List.of(witness.getX(), witness.getY(), witness.getZ()));
|
||||
}
|
||||
helper.assertTrue(level.getServer().saveEverything(true, true, true), "Flush native world before shutdown");
|
||||
report.put("passed", true);
|
||||
var directory = Path.of("diagnostics", "selective22-" + level.getSeed() + "-" + generator.initialDiameter()); Files.createDirectories(directory);
|
||||
var text = gson.toJson(report) + "\n"; Files.writeString(directory.resolve(reload ? "reload.json" : "create.json"), text);
|
||||
if (!reload) Files.writeString(proof, text);
|
||||
helper.succeed();
|
||||
} catch (Exception failure) { throw new IllegalStateException(failure); }
|
||||
};
|
||||
Runnable[] load = new Runnable[1];
|
||||
load[0] = () -> {
|
||||
if (!iterator.hasNext()) { finish.run(); return; }
|
||||
var pos = iterator.next(); level.getChunk(pos.x(), pos.z(), ChunkStatus.FULL, true);
|
||||
helper.runAtTickTime(helper.getTick() + 1, () -> load[0].run());
|
||||
};
|
||||
load[0].run();
|
||||
}
|
||||
}
|
||||
+247
@@ -0,0 +1,247 @@
|
||||
package fr.koka.sanctuary.gametest;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import fr.koka.sanctuary.SanctuaryMod;
|
||||
import fr.koka.sanctuary.worldgen.PopulationGenerationContext;
|
||||
import fr.koka.sanctuary.worldgen.PopulationHydrology;
|
||||
import fr.koka.sanctuary.worldgen.PopulationHydrologyRuntime;
|
||||
import fr.koka.sanctuary.worldgen.IslandCapacity;
|
||||
import fr.koka.sanctuary.worldgen.SanctuaryBiomeSource;
|
||||
import fr.koka.sanctuary.worldgen.SanctuaryChunkGenerator;
|
||||
import fr.koka.sanctuary.worldgen.Swamp27Volumes;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import net.fabricmc.fabric.api.gametest.v1.GameTest;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.gametest.framework.GameTestHelper;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.NoiseColumn;
|
||||
import net.minecraft.world.level.biome.BiomeResolver;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
|
||||
/** One bounded native observation. Never places blocks, entities, or synthetic water. */
|
||||
public final class Swamp27WorldGameTests {
|
||||
private static final com.google.gson.Gson JSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
private static final Path OUT = Path.of("diagnostics/swamp27");
|
||||
private static final int MAX_COLUMNS = 256;
|
||||
private static final int MAX_FULL_CHUNKS = 8;
|
||||
|
||||
@GameTest(maxTicks = 2400)
|
||||
public void nativeUndergroundSwamp(GameTestHelper helper) throws Exception {
|
||||
var report = new LinkedHashMap<String, Object>();
|
||||
long started = System.nanoTime();
|
||||
try {
|
||||
ServerLevel level = helper.getLevel();
|
||||
var generator = (SanctuaryChunkGenerator) level.getChunkSource().getGenerator();
|
||||
report.put("seed", level.getSeed()); report.put("diameter", generator.initialDiameter());
|
||||
report.put("generator", generator.rootGeneration()); report.put("process_id", ProcessHandle.current().pid());
|
||||
report.put("generate_structures", level.structureManager().shouldGenerateStructures());
|
||||
report.put("experimental", generator.experimentalStructures());
|
||||
helper.assertTrue(generator.rootGeneration() == 24, "Alpha27 uses the restored24 terrain generator");
|
||||
var binding = Objects.requireNonNull(PopulationGenerationContext.of(level));
|
||||
var resolver = generator.source().createResolver(binding.random().createClimateSampler(net.minecraft.world.level.levelgen.densityfunction.SamplerContext.builder().enableCaches().build()));
|
||||
var candidates = waterCandidates(helper, binding, resolver, report);
|
||||
int columns = 0;
|
||||
// Deterministic rings visit the middle of distinct chunks, with a strict sampler budget.
|
||||
int radius = Math.min(8, generator.initialDiameter() / 48);
|
||||
search: for (int ring = 0; ring <= radius; ring++)
|
||||
for (int cx = -ring; cx <= ring; cx++) for (int cz = -ring; cz <= ring; cz++) {
|
||||
if (Math.max(Math.abs(cx), Math.abs(cz)) != ring) continue;
|
||||
if (columns++ >= MAX_COLUMNS) break search;
|
||||
int x = cx * 16 + 8, z = cz * 16 + 8;
|
||||
NoiseColumn column = binding.generator().getBaseColumn(x, z, level, binding.random());
|
||||
for (int y = Swamp27Volumes.MAX_Y - 2; y >= Swamp27Volumes.MIN_Y; y--) {
|
||||
if (!column.getBlock(y).isAir() || !column.getBlock(y + 1).isAir()
|
||||
|| !natural(column.getBlock(y - 1))) continue;
|
||||
if (!resolver.getNoiseBiome(x >> 2, y >> 2, z >> 2).is(SanctuaryBiomeSource.SWAMP27)) continue;
|
||||
int roof = roof(column, y);
|
||||
if (roof < 0) continue;
|
||||
candidates.putIfAbsent(new ChunkPos(cx, cz), new BlockPos(x, y, z));
|
||||
break;
|
||||
}
|
||||
if (candidates.size() == MAX_FULL_CHUNKS) break search;
|
||||
}
|
||||
report.put("sampled_columns", Math.min(columns, MAX_COLUMNS));
|
||||
report.put("candidate_positions", candidates.values().stream().map(Swamp27WorldGameTests::xyz).toList());
|
||||
helper.assertTrue(!candidates.isEmpty(), "The bounded biome/terrain scan finds a real cave floor below rock");
|
||||
var pending = candidates.keySet().iterator();
|
||||
var loaded = new ArrayList<ChunkPos>();
|
||||
Runnable[] step = new Runnable[1];
|
||||
step[0] = () -> {
|
||||
try {
|
||||
if (pending.hasNext()) {
|
||||
var chunk = pending.next(); report.put("stage", "FULL " + chunk);
|
||||
level.getChunk(chunk.x(), chunk.z(), ChunkStatus.FULL, true); loaded.add(chunk);
|
||||
helper.runAtTickTime(helper.getTick() + 1, () -> step[0].run()); return;
|
||||
}
|
||||
report.put("stage", "inspect actual cave floors and vegetation");
|
||||
inspect(helper, level, loaded, report);
|
||||
report.put("explicit_full_chunks", loaded.size());
|
||||
report.put("full_chunk_limit", MAX_FULL_CHUNKS);
|
||||
report.put("elapsed_seconds", (System.nanoTime() - started) / 1_000_000_000.0);
|
||||
report.put("passed", true); write(OUT.resolve("native.json"), report); helper.succeed();
|
||||
} catch (Exception error) {
|
||||
failure(report, error); throw new IllegalStateException("Swamp27 native witness failed", error);
|
||||
}
|
||||
};
|
||||
helper.runAtTickTime(helper.getTick() + 1, () -> step[0].run());
|
||||
} catch (Exception error) { failure(report, error); throw error; }
|
||||
}
|
||||
|
||||
private static LinkedHashMap<ChunkPos, BlockPos> waterCandidates(GameTestHelper helper,
|
||||
PopulationGenerationContext.Binding binding, BiomeResolver resolver, Map<String, Object> report) {
|
||||
int before = PopulationHydrologyRuntime.cachedRegionCount(binding.random());
|
||||
var plan = PopulationHydrologyRuntime.regionPlan(binding.generator(), binding.random(), new IslandCapacity.Region(0, 0)).water();
|
||||
int after = PopulationHydrologyRuntime.cachedRegionCount(binding.random());
|
||||
helper.assertTrue(before == after, "The water witness reuses the already cached central region");
|
||||
var undergroundIds = new HashSet<Long>();
|
||||
plan.features().stream().filter(feature -> feature.kind() == PopulationHydrology.Kind.TERRACE)
|
||||
.forEach(feature -> undergroundIds.add(feature.id()));
|
||||
var allY = new TreeMap<Integer, Integer>(); var lowerY = new TreeMap<Integer, Integer>();
|
||||
var byChunk = new HashMap<ChunkPos, Integer>(); var positions = new HashMap<ChunkPos, BlockPos>();
|
||||
int intersections = 0, lowerIntersections = 0, waterTopIntersections = 0;
|
||||
for (var cell : plan.cells()) {
|
||||
if (!cell.hasWater()) continue;
|
||||
allY.merge(cell.waterY(), 1, Integer::sum);
|
||||
boolean lower = undergroundIds.contains(cell.featureId());
|
||||
if (lower) lowerY.merge(cell.waterY(), 1, Integer::sum);
|
||||
boolean inWater = resolver.getNoiseBiome(cell.x() >> 2, cell.waterY() >> 2, cell.z() >> 2).is(SanctuaryBiomeSource.SWAMP27);
|
||||
boolean aboveWater = resolver.getNoiseBiome(cell.x() >> 2, (cell.waterY() + 1) >> 2, cell.z() >> 2).is(SanctuaryBiomeSource.SWAMP27);
|
||||
if (inWater) { intersections++; if (lower) lowerIntersections++; }
|
||||
if (aboveWater) waterTopIntersections++;
|
||||
if (!lower || !inWater && !aboveWater) continue;
|
||||
var chunk = new ChunkPos(cell.x() >> 4, cell.z() >> 4);
|
||||
byChunk.merge(chunk, 1, Integer::sum);
|
||||
positions.putIfAbsent(chunk, new BlockPos(cell.x(), cell.waterY() + 1, cell.z()));
|
||||
}
|
||||
var selected = new LinkedHashMap<ChunkPos, BlockPos>();
|
||||
byChunk.keySet().stream().sorted(Comparator.<ChunkPos>comparingInt(chunk -> byChunk.get(chunk)).reversed()
|
||||
.thenComparingInt(ChunkPos::x).thenComparingInt(ChunkPos::z)).limit(4)
|
||||
.forEach(chunk -> selected.put(chunk, positions.get(chunk)));
|
||||
var evidence = new LinkedHashMap<String, Object>();
|
||||
evidence.put("region", List.of(0, 0)); evidence.put("new_regions_planned", after - before);
|
||||
evidence.put("all_water_columns_by_surface_y", allY);
|
||||
evidence.put("underground_terrace_water_columns_by_surface_y", lowerY);
|
||||
evidence.put("swamp_band", List.of(Swamp27Volumes.MIN_Y, Swamp27Volumes.MAX_Y - 1));
|
||||
evidence.put("water_surface_biome_intersections", intersections);
|
||||
evidence.put("underground_water_surface_biome_intersections", lowerIntersections);
|
||||
evidence.put("above_water_biome_intersections", waterTopIntersections);
|
||||
evidence.put("prioritized_chunks", selected.keySet().stream().map(chunk -> List.of(chunk.x(), chunk.z())).toList());
|
||||
evidence.put("scope", "Existing central region only; zeros are observations, not a required water quota");
|
||||
report.put("cached_water_selection", evidence);
|
||||
return selected;
|
||||
}
|
||||
|
||||
private static void inspect(GameTestHelper helper, ServerLevel level, List<ChunkPos> chunks,
|
||||
Map<String, Object> report) throws Exception {
|
||||
int floors = 0, covered = 0, plants = 0, water = 0;
|
||||
BlockPos witness = null; int bestScore = -1, witnessRoof = -1;
|
||||
var counts = new TreeMap<String, Integer>();
|
||||
var byChunk = new ArrayList<Map<String, Object>>();
|
||||
for (var chunk : chunks) {
|
||||
int chunkFloors = 0, chunkPlants = 0, chunkWater = 0;
|
||||
for (int x = chunk.x() * 16; x < chunk.x() * 16 + 16; x++)
|
||||
for (int z = chunk.z() * 16; z < chunk.z() * 16 + 16; z++)
|
||||
for (int y = Swamp27Volumes.MIN_Y; y < Swamp27Volumes.MAX_Y; y++) {
|
||||
var at = new BlockPos(x, y, z);
|
||||
if (!level.getBiome(at).is(SanctuaryBiomeSource.SWAMP27)) continue;
|
||||
var state = level.getBlockState(at);
|
||||
if (state.getFluidState().is(FluidTags.WATER)) { water++; chunkWater++; }
|
||||
if (plant(state)) {
|
||||
// A feature must obey native placement; old vanilla vines elsewhere are irrelevant.
|
||||
if (!state.is(Blocks.VINE)) helper.assertTrue(state.canSurvive(level, at), "Native swamp plant retains its support: " + at + " " + state);
|
||||
plants++; chunkPlants++; counts.merge(id(state), 1, Integer::sum);
|
||||
}
|
||||
if ((!state.isAir() && !plant(state)) || !state.getFluidState().isEmpty()) continue;
|
||||
var ground = level.getBlockState(at.below());
|
||||
if (!natural(ground)) continue;
|
||||
int ceiling = roof(level, at);
|
||||
if (ceiling < 0 || !level.getBlockState(at.above()).getCollisionShape(level, at.above()).isEmpty()) continue;
|
||||
floors++; chunkFloors++;
|
||||
boolean soil = ground.is(Blocks.MOSS_BLOCK) || ground.is(Blocks.GRASS_BLOCK) || ground.is(Blocks.MUD);
|
||||
if (soil) covered++;
|
||||
int score = (waterNearby(level, at.below(), chunk) ? 40 : 0)
|
||||
+ (plant(state) ? 20 : 0) + (soil ? 5 : 0) - Math.max(0, ceiling - y - 24);
|
||||
// Keep the export within this already loaded chunk, without another request.
|
||||
if (score > bestScore && (x & 15) >= 3 && (x & 15) <= 12 && (z & 15) >= 3 && (z & 15) <= 12) {
|
||||
witness = at; bestScore = score; witnessRoof = ceiling;
|
||||
}
|
||||
}
|
||||
byChunk.add(Map.of("chunk", List.of(chunk.x(), chunk.z()), "cave_floors", chunkFloors,
|
||||
"plants", chunkPlants, "water_blocks", chunkWater));
|
||||
}
|
||||
report.put("native_cave_floors", floors); report.put("covered_floors", covered);
|
||||
report.put("plants", plants); report.put("plant_counts", counts); report.put("water_blocks", water);
|
||||
report.put("chunks", byChunk);
|
||||
helper.assertTrue(floors > 0 && covered > 0, "FULL contains the new swamp biome over actual grass/moss/mud cave floors with a rock ceiling");
|
||||
helper.assertTrue(plants > 0, "The bounded FULL witness contains naturally generated swamp vegetation");
|
||||
helper.assertTrue(witness != null, "A visitable cave witness exists inside the loaded footprint");
|
||||
report.put("visit", xyz(witness)); report.put("ceiling_y", witnessRoof);
|
||||
report.put("teleport", "/tp @s " + (witness.getX() + .5) + " " + witness.getY() + " " + (witness.getZ() + .5));
|
||||
export(level, witness, witnessRoof, report);
|
||||
}
|
||||
|
||||
private static void export(ServerLevel level, BlockPos witness, int ceiling, Map<String, Object> report) throws Exception {
|
||||
int minX = (witness.getX() >> 4) * 16, minZ = (witness.getZ() >> 4) * 16;
|
||||
int minY = Math.max(0, witness.getY() - 3), maxY = Math.min(ceiling + 1, witness.getY() + 32);
|
||||
var blocks = new ArrayList<List<Object>>(); var cutaway = new ArrayList<List<Object>>();
|
||||
for (int x = minX; x < minX + 16; x++) for (int z = minZ; z < minZ + 16; z++) for (int y = minY; y <= maxY; y++) {
|
||||
BlockState state = level.getBlockState(new BlockPos(x, y, z));
|
||||
if (state.isAir()) continue;
|
||||
List<Object> block = List.of(x - minX, y - minY, z - minZ, id(state)); blocks.add(block);
|
||||
// A documented display cut only; the actual world and the full export stay intact.
|
||||
if (y < witness.getY() || z >= witness.getZ() && y < ceiling) cutaway.add(block);
|
||||
}
|
||||
var origin = List.of(minX, minY, minZ); var size = List.of(16, maxY - minY + 1, 16);
|
||||
write(OUT.resolve("blocks.json"), List.of(
|
||||
Map.of("id", "swamp27_native_full", "size", size, "origin", origin, "blocks", blocks),
|
||||
Map.of("id", "swamp27_native_cutaway", "size", size, "origin", origin, "blocks", cutaway)));
|
||||
report.put("export", Map.of("path", "diagnostics/swamp27/blocks.json", "origin", origin, "size", size,
|
||||
"blocks", blocks.size(), "cutaway_blocks", cutaway.size(), "source", "actual FULL blocks; no test-authored terrain"));
|
||||
}
|
||||
|
||||
private static int roof(NoiseColumn column, int y) {
|
||||
for (int top = y + 3; top <= Math.min(280, y + 96); top++) if (natural(column.getBlock(top))) return top;
|
||||
return -1;
|
||||
}
|
||||
private static boolean waterNearby(ServerLevel level, BlockPos floor, ChunkPos chunk) {
|
||||
for (int dx = -2; dx <= 2; dx++) for (int dz = -2; dz <= 2; dz++) {
|
||||
var at = floor.offset(dx, 0, dz);
|
||||
if (at.getX() >> 4 != chunk.x() || at.getZ() >> 4 != chunk.z()) continue;
|
||||
if (level.getFluidState(at).is(FluidTags.WATER)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private static int roof(ServerLevel level, BlockPos at) {
|
||||
for (int y = at.getY() + 3; y <= Math.min(280, at.getY() + 96); y++)
|
||||
if (natural(level.getBlockState(at.atY(y)))) return y;
|
||||
return -1;
|
||||
}
|
||||
private static boolean plant(BlockState state) {
|
||||
return state.is(Blocks.SHORT_GRASS) || state.is(Blocks.FIREFLY_BUSH) || state.is(Blocks.SUGAR_CANE)
|
||||
|| state.is(Blocks.LILY_PAD) || state.is(Blocks.VINE);
|
||||
}
|
||||
private static boolean natural(BlockState state) {
|
||||
return state.is(Blocks.STONE) || state.is(Blocks.DEEPSLATE) || state.is(Blocks.TUFF) || state.is(Blocks.CALCITE)
|
||||
|| state.is(Blocks.ANDESITE) || state.is(Blocks.GRANITE) || state.is(Blocks.DIORITE) || state.is(Blocks.DIRT)
|
||||
|| state.is(Blocks.COARSE_DIRT) || state.is(Blocks.GRASS_BLOCK) || state.is(Blocks.ROOTED_DIRT)
|
||||
|| state.is(Blocks.PODZOL) || state.is(Blocks.MYCELIUM) || state.is(Blocks.MOSS_BLOCK)
|
||||
|| state.is(Blocks.MUD) || state.is(Blocks.PACKED_MUD) || state.is(Blocks.CLAY);
|
||||
}
|
||||
private static List<Integer> xyz(BlockPos at) { return List.of(at.getX(), at.getY(), at.getZ()); }
|
||||
private static String id(BlockState state) { return BuiltInRegistries.BLOCK.getKey(state.getBlock()).toString(); }
|
||||
private static void write(Path path, Object value) throws Exception {
|
||||
Files.createDirectories(path.getParent()); Files.writeString(path, JSON.toJson(value) + "\n");
|
||||
}
|
||||
private static void failure(Map<String, Object> report, Exception error) {
|
||||
report.put("passed", false); report.put("error", error.toString());
|
||||
try { write(OUT.resolve("failure.json"), report); } catch (Exception io) { error.addSuppressed(io); }
|
||||
SanctuaryMod.LOGGER.error("Swamp27 native witness failed", error);
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
package fr.koka.sanctuary.gametest;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import fr.koka.sanctuary.SanctuaryMod;
|
||||
import fr.koka.sanctuary.worldgen.PopulationIslandDensity;
|
||||
import fr.koka.sanctuary.worldgen.SanctuaryChunkGenerator;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import net.fabricmc.fabric.api.gametest.v1.GameTest;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.gametest.framework.GameTestHelper;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.levelgen.densityfunction.SamplerContext;
|
||||
|
||||
/** Compares registered native fields; does not place blocks or load additional chunks. */
|
||||
public final class Terraces29WorldGameTests {
|
||||
@GameTest(maxTicks = 2400)
|
||||
public void fineLedgesPreserveTheAcceptedMass(GameTestHelper helper) throws Exception {
|
||||
var level = helper.getLevel();
|
||||
var generator = (SanctuaryChunkGenerator) level.getChunkSource().getGenerator();
|
||||
var field = (PopulationIslandDensity) level.registryAccess().lookupOrThrow(Registries.DENSITY_FUNCTION)
|
||||
.getOrThrow(ResourceKey.create(Registries.DENSITY_FUNCTION,
|
||||
SanctuaryMod.id("population_" + generator.capacity().players()))).value();
|
||||
helper.assertTrue(field.relief30() && !field.terraces29(), "Alpha30 localizes deformation and disables periodic micro-ledges");
|
||||
var random = generator.starterContext().random();
|
||||
var current = random.getSampler(field); var previous = random.getSampler(field.legacy28());
|
||||
var context = SamplerContext.builder().enableCaches().build();
|
||||
var report = new LinkedHashMap<String, Object>();
|
||||
report.put("seed", level.getSeed()); report.put("diameter", generator.initialDiameter());
|
||||
report.put("process_id", ProcessHandle.current().pid());
|
||||
int radius = Math.min(400, generator.initialDiameter() / 2), lowerSamples = 0, unchanged = 0, changed = 0;
|
||||
for (int z = -radius; z <= radius; z += 32) for (int x = -radius; x <= radius; x += 32) {
|
||||
for (int y = 32; y <= 180; y += 13) {
|
||||
helper.assertTrue(Float.floatToIntBits(current.sampleValue(context, x, y, z))
|
||||
== Float.floatToIntBits(previous.sampleValue(context, x, y, z)), "Lower density is exactly alpha28");
|
||||
lowerSamples++;
|
||||
}
|
||||
for (int y = 181; y <= 320; y++) {
|
||||
boolean old = previous.sampleValue(context, x, y, z) > 0;
|
||||
boolean now = current.sampleValue(context, x, y, z) > 0;
|
||||
if (old == now) unchanged++; else changed++;
|
||||
if (Math.hypot(x, z) <= 48) helper.assertTrue(old == now, "Arrival silhouette is unchanged");
|
||||
}
|
||||
}
|
||||
helper.assertTrue(changed > 0 && unchanged > changed * 3L, "Localized relief retains most of the accepted upper mass");
|
||||
report.put("unchanged_lower_density_samples", lowerSamples);
|
||||
report.put("unchanged_upper_samples", unchanged); report.put("changed_upper_samples", changed);
|
||||
var sections = new LinkedHashMap<String, Object>();
|
||||
for (int z : new int[]{0, 96}) {
|
||||
var before = new ArrayList<String>(); var after = new ArrayList<String>();
|
||||
for (int y = 305; y >= 205; y--) {
|
||||
var a = new StringBuilder(); var b = new StringBuilder();
|
||||
for (int x = -radius; x <= radius; x++) {
|
||||
a.append(previous.sampleValue(context, x, y, z) > 0 ? '#' : '.');
|
||||
b.append(current.sampleValue(context, x, y, z) > 0 ? '#' : '.');
|
||||
}
|
||||
before.add(a.toString()); after.add(b.toString());
|
||||
}
|
||||
sections.put("z" + z, Map.of("before", before, "after", after, "min_x", -radius, "max_y", 305, "step", 1));
|
||||
}
|
||||
report.put("sections", sections); report.put("passed", true);
|
||||
Path path = Path.of("diagnostics/alpha30", "relief-" + generator.initialDiameter() + "-" + level.getSeed() + ".json");
|
||||
Files.createDirectories(path.getParent());
|
||||
Files.writeString(path, new GsonBuilder().setPrettyPrinting().create().toJson(report));
|
||||
helper.succeed();
|
||||
}
|
||||
}
|
||||
+457
@@ -0,0 +1,457 @@
|
||||
package fr.koka.sanctuary.gametest;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import fr.koka.sanctuary.SanctuaryMod;
|
||||
import fr.koka.sanctuary.worldgen.SanctuaryChunkGenerator;
|
||||
import fr.koka.sanctuary.worldgen.city.LostCityRenderer;
|
||||
import fr.koka.sanctuary.worldgen.transit.TransitPiece21;
|
||||
import fr.koka.sanctuary.worldgen.transit.TransitPlan21;
|
||||
import fr.koka.sanctuary.worldgen.transit.TransitRenderer21;
|
||||
import fr.koka.sanctuary.worldgen.transit.TransitStructures21;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.HexFormat;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import net.fabricmc.fabric.api.gametest.v1.GameTest;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.HolderSet;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.gametest.framework.GameTestHelper;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.StairBlock;
|
||||
import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureStart;
|
||||
import net.minecraft.world.level.levelgen.structure.pieces.StructurePieceSerializationContext;
|
||||
import net.minecraft.world.level.storage.LevelResource;
|
||||
import net.minecraft.world.level.storage.loot.LootTable;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
|
||||
/** Opt-in native proof confined to the new generation21 starter island in a disposable development world. */
|
||||
public final class Transit21WorldGameTests {
|
||||
private static final Direction[] HORIZONTAL = {Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST};
|
||||
|
||||
@GameTest(maxTicks = 12000)
|
||||
public void industrialTransitPersistsNatively(GameTestHelper helper) {
|
||||
helper.assertTrue(helper.getLevel().getChunkSource().getGenerator() instanceof SanctuaryChunkGenerator,
|
||||
"The industrial-transits proof requires a Sanctuary generator");
|
||||
var generator = (SanctuaryChunkGenerator) helper.getLevel().getChunkSource().getGenerator();
|
||||
helper.assertTrue(generator.rootGeneration() == 21, "Use a fresh generation21 test world; do not convert old saves");
|
||||
new Scenario(helper, generator, Boolean.getBoolean("sanctuary.test.expansionReload")).advance();
|
||||
}
|
||||
|
||||
private static final class Scenario {
|
||||
final GameTestHelper helper;
|
||||
final ServerLevel level;
|
||||
final SanctuaryChunkGenerator generator;
|
||||
final TransitPlan21 plan;
|
||||
final boolean reload;
|
||||
final Map<String, Object> report = new LinkedHashMap<>();
|
||||
final List<ChunkPos> chunks = new ArrayList<>();
|
||||
final List<StructureStart> starts = new ArrayList<>();
|
||||
final Map<BlockPos, BlockState> allGeometry = new HashMap<>();
|
||||
JsonObject previous;
|
||||
BlockPos gold;
|
||||
int nextChunk;
|
||||
boolean prepared;
|
||||
|
||||
Scenario(GameTestHelper helper, SanctuaryChunkGenerator generator, boolean reload) {
|
||||
this.helper = helper; this.level = helper.getLevel(); this.generator = generator; this.reload = reload;
|
||||
this.plan = generator.transitPlan21();
|
||||
report.put("seed", level.getSeed()); report.put("size", generator.initialDiameter());
|
||||
report.put("process_id", ProcessHandle.current().pid()); report.put("world_directory", world(level).toString());
|
||||
report.put("experimental_structures", generator.experimentalStructures());
|
||||
report.put("structures_enabled", level.structureManager().shouldGenerateStructures());
|
||||
report.put("planning_diagnostic", plan.diagnostic());
|
||||
report.put("scope", "Native starts, references, geometry, rock bearings, unopened loot and a player-sized stair walk between two surface gates. "
|
||||
+ "No expansion is created and no personal save is opened. A single outer-wall gold edit in this disposable world "
|
||||
+ "is saved and checked in a second JVM. Traversal remains inside the modules and certified portico approaches; underground one-block rises need real correctly oriented stairs. Only the certified natural portico approaches permit an ordinary one-block jump. No flight, ladder or external terrain shortcut is allowed. No fluid simulation is claimed.");
|
||||
}
|
||||
void advance() {
|
||||
try {
|
||||
if (!prepared) {
|
||||
prepare(); prepared = true;
|
||||
if (plan.isEmpty()) { finishDisabled(); return; }
|
||||
}
|
||||
if (nextChunk < chunks.size()) {
|
||||
var pos = chunks.get(nextChunk++);
|
||||
var loaded = level.getChunk(pos.x(), pos.z(), ChunkStatus.FULL, true);
|
||||
helper.assertTrue(loaded instanceof LevelChunk, "Every room footprint must reach native FULL: " + pos);
|
||||
if (nextChunk % 10 == 0) SanctuaryMod.LOGGER.info("Industrial transit21: loaded {}/{} footprint chunks", nextChunk, chunks.size());
|
||||
helper.runAtTickTime(helper.getTick() + 1, this::advance); return;
|
||||
}
|
||||
verifyPlaced();
|
||||
report.put("passed", true);
|
||||
if (!reload) {
|
||||
helper.assertTrue(gold != null && level.getBlockState(gold).isCollisionShapeFullBlock(level, gold),
|
||||
"Gameplay witness must replace a solid outer wall away from every doorway");
|
||||
level.setBlock(gold, Blocks.GOLD_BLOCK.defaultBlockState(), 3);
|
||||
report.put("gold_witness", coords(gold));
|
||||
helper.assertTrue(level.getServer().saveEverything(true, true, true), "Flush native structures, deferred loot and the gold edit");
|
||||
report.put("world_flushed_before_shutdown", true);
|
||||
} else {
|
||||
helper.assertTrue(level.getBlockState(gold).is(Blocks.GOLD_BLOCK), "Reload replaced the existing wall edit");
|
||||
report.put("gold_witness", coords(gold)); report.put("gold_witness_preserved", true);
|
||||
}
|
||||
write(level, report, reload); helper.succeed();
|
||||
} catch (Exception failure) {
|
||||
report.put("passed", false); report.put("failure", failure.toString());
|
||||
try { write(level, report, reload); } catch (IOException ignored) { }
|
||||
throw new IllegalStateException("Industrial transit21 native " + (reload ? "reload" : "creation") + " failed", failure);
|
||||
}
|
||||
}
|
||||
void prepare() throws IOException {
|
||||
var ops = RegistryOps.create(JsonOps.INSTANCE, level.registryAccess());
|
||||
var encoded = ChunkGenerator.CODEC.encodeStart(ops, generator).getOrThrow();
|
||||
var decoded = ChunkGenerator.CODEC.parse(ops, encoded).getOrThrow();
|
||||
helper.assertTrue(decoded instanceof SanctuaryChunkGenerator copy && copy.rootGeneration() == 21
|
||||
&& copy.experimentalStructures() == generator.experimentalStructures(), "The generation21 codec must preserve its experimental switch");
|
||||
report.put("generator_codec", encoded); report.put("plan_sha256", planHash(plan)); report.put("planning_samples", plan.samples());
|
||||
helper.assertTrue(plan.samples() <= TransitPlan21.MAX_SAMPLES, "Transit planning exceeded its budget");
|
||||
if (reload) {
|
||||
previous = JsonParser.parseString(Files.readString(proof(level))).getAsJsonObject();
|
||||
helper.assertTrue(previous.get("passed").getAsBoolean() && previous.get("world_flushed_before_shutdown").getAsBoolean(),
|
||||
"Reload requires the successful, flushed creation proof");
|
||||
helper.assertTrue(previous.get("process_id").getAsLong() != ProcessHandle.current().pid(), "Reload must run in a separate JVM");
|
||||
helper.assertTrue(previous.get("seed").getAsLong() == level.getSeed()
|
||||
&& previous.get("size").getAsInt() == generator.initialDiameter()
|
||||
&& previous.get("world_directory").getAsString().equals(world(level).toString()), "Reload used another world, seed or size");
|
||||
helper.assertTrue(previous.get("generator_codec").equals(encoded) && previous.get("plan_sha256").getAsString().equals(planHash(plan)),
|
||||
"Saved switch or planned generation21 room identities changed on reload");
|
||||
if (previous.has("gold_witness")) gold = readPos(previous.getAsJsonArray("gold_witness"));
|
||||
}
|
||||
boolean enabled = generator.experimentalStructures() && level.structureManager().shouldGenerateStructures();
|
||||
if (!enabled) {
|
||||
helper.assertTrue(plan.isEmpty(), "Experimental=false or generateStructures=false must publish no industrial transit");
|
||||
return;
|
||||
}
|
||||
helper.assertTrue(!plan.isEmpty(), "Enabled reference island has no experimental network");
|
||||
helper.assertTrue(plan.modules().stream().filter(m -> m.kind() == TransitPlan21.Kind.ACCESS).count() == 2,
|
||||
"A through-route needs two independent saved surface stairs");
|
||||
int spanX = plan.modules().stream().mapToInt(TransitPlan21.Module::maxX).max().orElseThrow()
|
||||
- plan.modules().stream().mapToInt(TransitPlan21.Module::minX).min().orElseThrow() + 1;
|
||||
int spanZ = plan.modules().stream().mapToInt(TransitPlan21.Module::maxZ).max().orElseThrow()
|
||||
- plan.modules().stream().mapToInt(TransitPlan21.Module::minZ).min().orElseThrow() + 1;
|
||||
report.put("span_x", spanX); report.put("span_z", spanZ);
|
||||
helper.assertTrue(Math.max(spanX, spanZ) >= generator.initialDiameter() * .4,
|
||||
"The native transit reference must cross at least40% of the island's nominal diameter");
|
||||
report.put("modules", plan.modules().size());
|
||||
report.put("halls", plan.modules().stream().filter(m -> m.kind() == TransitPlan21.Kind.HALL).count());
|
||||
var structure = level.registryAccess().lookupOrThrow(Registries.STRUCTURE).getOrThrow(TransitStructures21.KEY);
|
||||
var origins = new HashSet<Long>(); var uniqueChunks = new HashSet<ChunkPos>();
|
||||
for (var network : plan.modules()) {
|
||||
long origin = new ChunkPos(network.startChunkX(), network.startChunkZ()).pack();
|
||||
if (!origins.add(origin)) continue;
|
||||
var chunk = level.getChunk(network.startChunkX(), network.startChunkZ(), ChunkStatus.STRUCTURE_STARTS, true);
|
||||
var start = chunk.getStartForStructure(structure.value());
|
||||
helper.assertTrue(start != null && start.isValid(), "Accepted experimental network has no native start: " + network.kind() + " at " + network.centerX() + "," + network.centerZ());
|
||||
starts.add(start);
|
||||
for (var piece : start.getPieces()) {
|
||||
helper.assertTrue(piece instanceof TransitPiece21, "Industrial transit loaded a foreign or historical piece type");
|
||||
piece.getBoundingBox().intersectingChunks().forEach(at -> {
|
||||
helper.assertTrue(Math.abs(at.x() - network.startChunkX()) <= 7 && Math.abs(at.z() - network.startChunkZ()) <= 7,
|
||||
"Transit native start exceeds its local reference range");
|
||||
uniqueChunks.add(at);
|
||||
});
|
||||
}
|
||||
}
|
||||
helper.assertTrue(uniqueChunks.size() <= 256, "The bounded root-only proof unexpectedly covers more than256 chunks");
|
||||
chunks.addAll(uniqueChunks.stream().sorted(java.util.Comparator.comparingInt(ChunkPos::x).thenComparingInt(ChunkPos::z)).toList());
|
||||
}
|
||||
void finishDisabled() throws IOException {
|
||||
var structure = level.registryAccess().lookupOrThrow(Registries.STRUCTURE).getOrThrow(TransitStructures21.KEY);
|
||||
var chunk = level.getChunk(0, 0, ChunkStatus.STRUCTURE_STARTS, true);
|
||||
var start = chunk.getStartForStructure(structure.value());
|
||||
helper.assertTrue(start == null || !start.isValid(), "Disabled experimental generation emitted a native start");
|
||||
var located = generator.findNearestMapStructure(level, HolderSet.direct(structure), new BlockPos(0, 250, 0), 100, false);
|
||||
helper.assertTrue(located == null, "Disabled experimental structures must not be located or prepared");
|
||||
report.put("empty_plan_verified", true); report.put("passed", true);
|
||||
if (!reload) {
|
||||
helper.assertTrue(level.getServer().saveEverything(true, true, true), "Save the disabled experiment setting");
|
||||
report.put("world_flushed_before_shutdown", true);
|
||||
}
|
||||
write(level, report, reload); helper.succeed();
|
||||
}
|
||||
void verifyPlaced() {
|
||||
var structure = level.registryAccess().lookupOrThrow(Registries.STRUCTURE).getOrThrow(TransitStructures21.KEY);
|
||||
var context = StructurePieceSerializationContext.fromLevel(level);
|
||||
var sites = new ArrayList<Map<String, Object>>();
|
||||
var modules = new ArrayList<Map<String, Object>>();
|
||||
int blocks = 0, supports = 0, chests = 0, pieces = 0;
|
||||
var bearingMasks = new HashMap<TransitPlan21.Module, Integer>();
|
||||
for (var start : starts) {
|
||||
var origin = start.getChunkPos(); var saved = start.createTag(context, origin);
|
||||
var copy = StructureStart.loadStaticStart(context, saved, level.getSeed());
|
||||
helper.assertTrue(copy != null && copy.isValid() && copy.createTag(context, origin).equals(saved), "The native start changed on an NBT roundtrip");
|
||||
var expectedRooms = plan.modulesForChunk(origin.x(), origin.z());
|
||||
var actualRooms = start.getPieces().stream().map(TransitPiece21.class::cast).map(TransitPiece21::module).toList();
|
||||
helper.assertTrue(actualRooms.size() == expectedRooms.size() && new HashSet<>(actualRooms).equals(new HashSet<>(expectedRooms)),
|
||||
"Native start did not persist every planned room exactly once");
|
||||
String nativeHash = hash(saved.toString());
|
||||
if (reload) {
|
||||
JsonObject prior = null;
|
||||
for (var value : previous.getAsJsonArray("starts")) {
|
||||
var site = value.getAsJsonObject(); var at = site.getAsJsonArray("start_chunk");
|
||||
if (at.get(0).getAsInt() == origin.x() && at.get(1).getAsInt() == origin.z()) prior = site;
|
||||
}
|
||||
helper.assertTrue(prior != null && prior.get("native_start_sha256").getAsString().equals(nativeHash),
|
||||
"Reload altered native room parameters, supports or reference count");
|
||||
}
|
||||
var loot = new ArrayList<Map<String, Object>>();
|
||||
for (var piece : start.getPieces()) {
|
||||
var roomPiece = (TransitPiece21) piece; var room = roomPiece.module(); pieces++;
|
||||
piece.getBoundingBox().intersectingChunks().forEach(at -> {
|
||||
var full = level.getChunk(at.x(), at.z(), ChunkStatus.FULL, true);
|
||||
helper.assertTrue(full.getReferencesForStructure(structure.value()).contains(origin.pack()), "A saved FULL chunk lost the native structure reference");
|
||||
});
|
||||
var roomTag = roomPiece.createTag(context);
|
||||
var roundtrip = new TransitPiece21(context, roomTag);
|
||||
helper.assertTrue(roundtrip.module().equals(room) && roundtrip.createTag(context).equals(roomTag), "The native room failed its exact saved-field roundtrip");
|
||||
var corrupt = roomTag.copy(); var payload = corrupt.getCompound("SanctuaryModule").orElseThrow(); payload.putInt("Schema", 99);
|
||||
boolean rejected = false;
|
||||
try { new TransitPiece21(context, corrupt); } catch (IllegalArgumentException expected) { rejected = true; }
|
||||
helper.assertTrue(rejected, "An unknown generation21 piece schema must be refused");
|
||||
var expected = rendered(room); blocks += expected.blocks().size();
|
||||
expected.blocks().forEach((at, state) -> helper.assertTrue(allGeometry.putIfAbsent(at, state) == null,
|
||||
"Two saved transit modules paint the same position: " + at));
|
||||
modules.add(Map.of("kind", room.kind().name(), "min", List.of(room.minX(), room.minY(), room.minZ()),
|
||||
"max", List.of(room.maxX(), room.maxY(), room.maxZ()), "floor_y", room.floorY(),
|
||||
"surface_y", room.surfaceY(), "openings", room.openings(), "supports", room.supports().size(),
|
||||
"start_chunk", List.of(room.startChunkX(), room.startChunkZ())));
|
||||
for (var entry : expected.blocks().entrySet()) {
|
||||
var at = entry.getKey(); var wanted = entry.getValue();
|
||||
helper.assertTrue(TransitPiece21.bounds(room).isInside(at), "Renderer escaped its saved room/support bounds");
|
||||
helper.assertTrue(plan.protects(at.getX(), at.getY(), at.getZ()) && generator.protectsCityDecoration(at),
|
||||
"Transit construction/cleared air is missing its published decoration protection at " + at);
|
||||
if (reload && at.equals(gold)) continue;
|
||||
helper.assertTrue(level.getBlockState(at).is(wanted.getBlock()),
|
||||
"Native clipping or later decoration changed " + room.kind() + " at " + at + ": expected " + wanted + " got " + level.getBlockState(at));
|
||||
helper.assertTrue(!level.getBlockState(at).is(Blocks.SPAWNER), "Experimental architecture must not create a spawner");
|
||||
}
|
||||
supports += verifyBearings(helper, generator, room, bearingMasks);
|
||||
for (var entry : expected.blocks().entrySet()) if (entry.getValue().is(Blocks.LANTERN)) {
|
||||
var at = entry.getKey(); var state = level.getBlockState(at);
|
||||
helper.assertTrue(state.canSurvive(level, at) && level.getBlockState(at.above()).isFaceSturdy(level, at.above(), Direction.DOWN),
|
||||
"Transit lamp lost its complete ceiling bearing at " + at);
|
||||
}
|
||||
for (var chest : expected.chests()) {
|
||||
helper.assertTrue(level.getBlockEntity(chest.position()) instanceof RandomizableContainerBlockEntity, "Deferred native chest block entity is missing");
|
||||
var entity = (RandomizableContainerBlockEntity) level.getBlockEntity(chest.position());
|
||||
helper.assertTrue(chest.table().equals(entity.getLootTable()) && entity.getLootTableSeed() == chest.seed(),
|
||||
"Native chest loot must remain deferred with its exact table and seed");
|
||||
loot.add(Map.of("position", coords(chest.position()), "table", chest.table().identifier().toString(), "seed", chest.seed())); chests++;
|
||||
}
|
||||
if (!reload && gold == null && room.kind() != TransitPlan21.Kind.ACCESS && room.kind() != TransitPlan21.Kind.JUNCTION)
|
||||
gold = new BlockPos(room.minX(), room.floorY() + 1, room.minZ() + 1);
|
||||
}
|
||||
sites.add(Map.of("start_chunk", List.of(origin.x(), origin.z()), "native_start_sha256", nativeHash,
|
||||
"pieces", start.getPieces().size(), "unopened_chests", loot));
|
||||
}
|
||||
report.put("module_coordinates", modules);
|
||||
report.put("starts", sites);
|
||||
int weakSpan = 0, longestSpan = 0;
|
||||
for (var room : plan.modules()) {
|
||||
weakSpan = bearingMasks.get(room) == 15 ? 0 : weakSpan + 1;
|
||||
longestSpan = Math.max(longestSpan, weakSpan);
|
||||
helper.assertTrue(weakSpan <= 2, "Native deck spans more than 34 blocks without distributed rock bearings");
|
||||
}
|
||||
report.put("longest_span_without_full_bearings", longestSpan * 17);
|
||||
var ores = new java.util.TreeMap<String, Integer>();
|
||||
allGeometry.values().forEach(state -> {
|
||||
var id = net.minecraft.core.registries.BuiltInRegistries.BLOCK.getKey(state.getBlock()).toString();
|
||||
if (id.endsWith("_ore")) ores.merge(id, 1, Integer::sum);
|
||||
});
|
||||
report.put("finite_exposed_ores", ores);
|
||||
var traversal = verifyAccess(helper, plan);
|
||||
report.put("native_connections", NativeConnections20.verify(helper, allGeometry,
|
||||
reload && gold != null ? Set.of(gold) : Set.of()));
|
||||
report.put("module_coordinates", modules);
|
||||
var located = generator.findNearestMapStructure(level, HolderSet.direct(structure), new BlockPos(0, 250, 0), 100, false);
|
||||
helper.assertTrue(located != null && located.getSecond().is(TransitStructures21.KEY), "Native locate cannot find a saved industrial transit");
|
||||
helper.assertTrue(plan.modules().stream().filter(r -> r.kind() == TransitPlan21.Kind.ACCESS)
|
||||
.anyMatch(r -> TransitPiece21.locator(r).equals(located.getFirst())), "Locate must lead to a surface entrance rather than an underground floor");
|
||||
report.put("starts", sites); report.put("native_pieces", pieces); report.put("native_blocks_checked", blocks);
|
||||
report.put("full_chunks_checked", chunks.size()); report.put("rock_supports_checked", supports);
|
||||
report.put("unopened_deferred_chests", chests); report.put("native_routes", traversal); report.put("locate", coords(located.getFirst()));
|
||||
}
|
||||
}
|
||||
private record Chest(BlockPos position, ResourceKey<LootTable> table, long seed) {}
|
||||
private record Rendered(Map<BlockPos, BlockState> blocks, List<Chest> chests) {}
|
||||
private static Rendered rendered(TransitPlan21.Module room) {
|
||||
var blocks = new HashMap<BlockPos, BlockState>(); var chests = new ArrayList<Chest>();
|
||||
TransitRenderer21.render(room, new LostCityRenderer.BlockWriter() {
|
||||
@Override public void set(int x, int y, int z, BlockState state) { blocks.put(at(room, x, y, z), state); }
|
||||
@Override public void chest(int x, int y, int z, ResourceKey<LootTable> table, long seed) {
|
||||
var position = at(room, x, y, z); blocks.put(position, Blocks.CHEST.defaultBlockState()); chests.add(new Chest(position, table, RandomSource.create(seed).nextLong()));
|
||||
}
|
||||
});
|
||||
return new Rendered(blocks, chests);
|
||||
}
|
||||
private static int verifyBearings(GameTestHelper helper, SanctuaryChunkGenerator generator, TransitPlan21.Module room, Map<TransitPlan21.Module, Integer> masks) {
|
||||
var level = helper.getLevel(); int checked = 0, quarters = 0;
|
||||
for (int z = room.minZ();; z = Math.min(z + 4, room.maxZ())) {
|
||||
for (int x = room.minX();; x = Math.min(x + 4, room.maxX())) {
|
||||
int anchor = room.minY() - 1;
|
||||
for (var support : room.supports()) if (support.x() == x && support.z() == z) anchor = support.minY() - 1;
|
||||
var bearing = new BlockPos(x, anchor, z);
|
||||
boolean supported = level.getBlockState(bearing).isSolid() && level.getFluidState(bearing).isEmpty()
|
||||
&& level.getBlockState(bearing.below()).isSolid() && level.getFluidState(bearing.below()).isEmpty();
|
||||
if (supported) {
|
||||
quarters |= 1 << ((x < room.centerX() ? 0 : 1) + (z < room.centerZ() ? 0 : 2));
|
||||
for (int dy = 0; dy >= -1; dy--) {
|
||||
var at = new BlockPos(x, anchor + dy, z);
|
||||
helper.assertTrue(level.getBlockState(at).isSolid() && level.getFluidState(at).isEmpty(),
|
||||
"Transit bearing grid lost one of its two untouched rock layers at " + at);
|
||||
helper.assertTrue(generator.protectsCityDecoration(at), "A certified transit rock dependency is unprotected at " + at);
|
||||
checked++;
|
||||
}
|
||||
}
|
||||
if (x == room.maxX()) break;
|
||||
}
|
||||
if (z == room.maxZ()) break;
|
||||
}
|
||||
helper.assertTrue(room.kind() == TransitPlan21.Kind.GALLERY || room.kind() == TransitPlan21.Kind.JUNCTION || quarters == 15, "The continuous deck lost its distributed rock bearings");
|
||||
masks.put(room, quarters);
|
||||
return checked;
|
||||
}
|
||||
static Map<String, Object> verifyAccess(GameTestHelper helper, TransitPlan21 plan) {
|
||||
var level = helper.getLevel();
|
||||
var accesses = plan.modules().stream().filter(m -> m.kind() == TransitPlan21.Kind.ACCESS).toList();
|
||||
boolean fitted29 = plan.diagnostic().startsWith("accepted29");
|
||||
int approachHalfWidth = fitted29 ? 1 : 2;
|
||||
int approachDepth = fitted29 ? 1 : 3;
|
||||
helper.assertTrue(accesses.size() == 2, "Native transit requires exactly two surface gates");
|
||||
Predicate<BlockPos> inside = pos -> plan.contains(pos.getX(), pos.getY(), pos.getZ())
|
||||
|| accesses.stream().anyMatch(m -> pos.getX() >= m.centerX() - approachHalfWidth && pos.getX() <= m.centerX() + approachHalfWidth
|
||||
&& pos.getZ() >= m.minZ() - approachDepth && pos.getZ() < m.minZ()
|
||||
&& pos.getY() >= m.surfaceY() && pos.getY() <= m.surfaceY() + 2);
|
||||
var start = TransitPiece21.locator(accesses.getFirst());
|
||||
Predicate<BlockPos> naturalApproach = pos -> accesses.stream().anyMatch(m ->
|
||||
pos.getX() >= m.centerX() - approachHalfWidth && pos.getX() <= m.centerX() + approachHalfWidth
|
||||
&& pos.getZ() >= m.minZ() - approachDepth && pos.getZ() < m.minZ()
|
||||
&& pos.getY() >= m.surfaceY() && pos.getY() <= m.surfaceY() + 2);
|
||||
var reached = walk(helper, start, inside, naturalApproach); int targets = 0;
|
||||
var arrivals = new ArrayList<Map<String, Object>>();
|
||||
for (var module : plan.modules()) for (var target : TransitRenderer21.targets(module)) {
|
||||
var point = at(module, target.x(), target.y(), target.z());
|
||||
helper.assertTrue(reached.containsKey(Foot.at(point)), "Native transit cannot walk from its first portico to "
|
||||
+ module.kind() + "/" + target.name() + " at " + point);
|
||||
targets++;
|
||||
}
|
||||
for (var access : accesses) {
|
||||
var gate = TransitPiece21.locator(access);
|
||||
helper.assertTrue(reached.containsKey(Foot.at(gate)), "The second independent surface gate is not connected by real stairs");
|
||||
int approaches = 0;
|
||||
for (int x = access.centerX() - approachHalfWidth; x <= access.centerX() + approachHalfWidth; x++)
|
||||
for (int z = access.minZ() - approachDepth; z < access.minZ(); z++) {
|
||||
var high = new BlockPos(x, access.surfaceY() + 1, z);
|
||||
var low = high.below(); var position = standable(level, high) ? high : low;
|
||||
helper.assertTrue(standable(level, position) && reached.containsKey(Foot.at(position)),
|
||||
"The certified natural approach no longer joins its portico at " + position);
|
||||
helper.assertTrue(level.getBlockState(position.below()).isSolid()
|
||||
&& level.getFluidState(position.below()).isEmpty(), "A surface arrival is suspended above air or water");
|
||||
approaches++;
|
||||
}
|
||||
arrivals.add(Map.of("gate", coords(gate), "roadway", coords(at(access, 8, 2, 8)),
|
||||
"rise", access.surfaceY() - access.floorY(), "steps_from_first_gate", reached.get(Foot.at(gate)),
|
||||
"natural_approach_cells", approaches));
|
||||
}
|
||||
return Map.of("surface_accesses", arrivals, "walkable_targets", targets, "standing_cells", reached.size(),
|
||||
"surface_to_surface_steps", reached.get(Foot.at(TransitPiece21.locator(accesses.getLast()))),
|
||||
"traversal_policy", "0.6 by1.8 native collision volume, half-block sidewalk steps; underground rises require a real forward-facing stair; natural portico approaches alone permit a normal one-block jump; no vertical moves");
|
||||
}
|
||||
/** Half-block standing elevations retain real sidewalk slabs without pretending an integer cell can hover over them. */
|
||||
private record Foot(int x, int halfY, int z) {
|
||||
static Foot at(BlockPos pos) { return new Foot(pos.getX(), pos.getY() * 2, pos.getZ()); }
|
||||
double y() { return halfY / 2.0; }
|
||||
BlockPos block() { return new BlockPos(x, Math.floorDiv(halfY, 2), z); }
|
||||
BlockPos bearing() { return new BlockPos(x, Math.floorDiv(halfY - 1, 2), z); }
|
||||
Foot rise(int halves) { return new Foot(x, halfY + halves, z); }
|
||||
Foot move(Direction direction, int halves) { return new Foot(x + direction.getStepX(), halfY + halves, z + direction.getStepZ()); }
|
||||
}
|
||||
private static Map<Foot, Integer> walk(GameTestHelper helper, BlockPos start, Predicate<BlockPos> inside, Predicate<BlockPos> naturalApproach) {
|
||||
var level = helper.getLevel(); var first = Foot.at(start);
|
||||
helper.assertTrue(inside.test(start) && standable(level, first), "Blocked native surface portico: " + start);
|
||||
var seen = new HashMap<Foot, Integer>(); var queue = new ArrayDeque<Foot>(); seen.put(first, 0); queue.add(first);
|
||||
while (!queue.isEmpty()) {
|
||||
var pos = queue.removeFirst();
|
||||
for (var direction : HORIZONTAL) for (int dy = -2; dy <= 2; dy++) {
|
||||
var next = pos.move(direction, dy);
|
||||
if (!inside.test(next.block()) || seen.containsKey(next)) continue;
|
||||
boolean ordinaryThreshold = naturalApproach.test(pos.block()) || naturalApproach.test(next.block());
|
||||
// Native step height is enough for a half slab; a full block needs the two treads of a stair.
|
||||
if (dy > 0 && (!clearBody(level, pos.rise(dy))
|
||||
|| dy == 2 && !ordinaryThreshold && !ascendingStair(level, next.bearing(), direction))) continue;
|
||||
if (dy < 0 && (!clearBody(level, next.rise(-dy))
|
||||
|| dy == -2 && !ordinaryThreshold && !ascendingStair(level, pos.bearing(), direction.getOpposite()))) continue;
|
||||
if (standable(level, next)) { seen.put(next, seen.get(pos) + 1); queue.add(next); }
|
||||
}
|
||||
helper.assertTrue(seen.size() <= 120_000, "Native transit traversal exceeded its bounded room volumes");
|
||||
}
|
||||
return seen;
|
||||
}
|
||||
private static boolean ascendingStair(ServerLevel level, BlockPos pos, Direction direction) {
|
||||
var state = level.getBlockState(pos);
|
||||
return state.getBlock() instanceof StairBlock
|
||||
&& state.getValue(BlockStateProperties.HORIZONTAL_FACING) == direction
|
||||
&& state.getValue(BlockStateProperties.HALF) == net.minecraft.world.level.block.state.properties.Half.BOTTOM;
|
||||
}
|
||||
private static boolean standable(ServerLevel level, BlockPos pos) { return standable(level, Foot.at(pos)); }
|
||||
private static boolean standable(ServerLevel level, Foot pos) {
|
||||
if (!clearBody(level, pos)) return false;
|
||||
var below = pos.bearing(); double top = pos.y() - below.getY();
|
||||
return level.getBlockState(below).getCollisionShape(level, below).toAabbs().stream()
|
||||
.anyMatch(b -> Math.abs(b.maxY - top) < .0001 && b.minX <= .5 && b.maxX >= .5 && b.minZ <= .5 && b.maxZ >= .5);
|
||||
}
|
||||
private static boolean clearBody(ServerLevel level, Foot pos) {
|
||||
var body = new AABB(pos.x() + .2, pos.y(), pos.z() + .2, pos.x() + .8, pos.y() + 1.8, pos.z() + .8);
|
||||
for (int y = (int) Math.floor(pos.y()); y <= (int) Math.floor(pos.y() + 1.8 - .0001); y++) {
|
||||
var at = new BlockPos(pos.x(), y, pos.z());
|
||||
if (!level.getFluidState(at).isEmpty()) return false;
|
||||
for (var shape : level.getBlockState(at).getCollisionShape(level, at).toAabbs())
|
||||
if (shape.move(at.getX(), at.getY(), at.getZ()).intersects(body)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private static BlockPos at(TransitPlan21.Module room, int x, int y, int z) { return new BlockPos(room.minX() + x, room.minY() + y, room.minZ() + z); }
|
||||
private static List<Integer> coords(BlockPos pos) { return List.of(pos.getX(), pos.getY(), pos.getZ()); }
|
||||
private static BlockPos readPos(com.google.gson.JsonArray value) { return new BlockPos(value.get(0).getAsInt(), value.get(1).getAsInt(), value.get(2).getAsInt()); }
|
||||
private static Path world(ServerLevel level) { return level.getServer().getWorldPath(LevelResource.ROOT).toAbsolutePath().normalize(); }
|
||||
private static Path proof(ServerLevel level) { return world(level).resolve("transit21-create-proof.json"); }
|
||||
private static String planHash(TransitPlan21 plan) { return hash(plan.modules().toString()); }
|
||||
private static void write(ServerLevel level, Map<String, Object> report, boolean reload) throws IOException {
|
||||
var path = Path.of("diagnostics", "transit21-" + (reload ? "reload" : "create") + ".json"); Files.createDirectories(path.getParent());
|
||||
var value = new GsonBuilder().setPrettyPrinting().create().toJson(report) + "\n";
|
||||
Files.writeString(path, value);
|
||||
if (!reload) Files.writeString(proof(level), value);
|
||||
}
|
||||
private static String hash(String value) {
|
||||
try { return HexFormat.of().formatHex(MessageDigest.getInstance("SHA-256").digest(value.getBytes(StandardCharsets.UTF_8))); }
|
||||
catch (NoSuchAlgorithmException impossible) { throw new AssertionError(impossible); }
|
||||
}
|
||||
}
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
package fr.koka.sanctuary.gametest;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import fr.koka.sanctuary.SanctuaryMod;
|
||||
import fr.koka.sanctuary.worldgen.SanctuaryChunkGenerator;
|
||||
import fr.koka.sanctuary.worldgen.transit.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import net.fabricmc.fabric.api.gametest.v1.GameTest;
|
||||
import net.minecraft.core.HolderSet;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.gametest.framework.GameTestHelper;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureStart;
|
||||
import net.minecraft.world.level.levelgen.structure.pieces.StructurePieceSerializationContext;
|
||||
|
||||
/** One actual island and its published route. No injected starts, synthetic terrain or expansion. */
|
||||
public final class Transit29WorldGameTests {
|
||||
private static final Path OUT = Path.of("diagnostics/transit29");
|
||||
private static final com.google.gson.Gson JSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
|
||||
@GameTest(maxTicks = 12000)
|
||||
public void throughRouteHasTwoNativeAccesses(GameTestHelper helper) throws Exception {
|
||||
if (!Boolean.getBoolean("sanctuary.test.transit29")) { helper.succeed(); return; }
|
||||
var report = new LinkedHashMap<String, Object>();
|
||||
try {
|
||||
var level = helper.getLevel();
|
||||
var generator = (SanctuaryChunkGenerator) level.getChunkSource().getGenerator();
|
||||
var plan = generator.transitPlan21();
|
||||
report.put("seed", level.getSeed()); report.put("diameter", generator.initialDiameter());
|
||||
report.put("process_id", ProcessHandle.current().pid()); report.put("planner", plan.diagnostic());
|
||||
report.put("modules", plan.modules().size()); report.put("probes", plan.samples());
|
||||
report.put("generate_structures", level.structureManager().shouldGenerateStructures());
|
||||
if (!level.structureManager().shouldGenerateStructures()) {
|
||||
helper.assertTrue(plan.isEmpty(), "Structures OFF leaves no transit reservation");
|
||||
report.put("passed", true); write(report); helper.succeed(); return;
|
||||
}
|
||||
helper.assertFalse(plan.isEmpty(), "A structures-enabled Sanctuary world must retain its main traversal: " + plan.diagnostic());
|
||||
var accesses = plan.modules().stream().filter(m -> m.kind() == TransitPlan21.Kind.ACCESS).toList();
|
||||
helper.assertTrue(accesses.size() == 2, "The complete traversal has two independent surface accesses");
|
||||
int span = Math.max(Math.abs(accesses.getFirst().centerX() - accesses.getLast().centerX()),
|
||||
Math.abs(accesses.getFirst().centerZ() - accesses.getLast().centerZ()));
|
||||
helper.assertTrue(span >= generator.initialDiameter() / 4, "The main route spans at least a quarter of the island diameter");
|
||||
report.put("span", span);
|
||||
var holder = level.registryAccess().lookupOrThrow(Registries.STRUCTURE).getOrThrow(TransitStructures21.KEY);
|
||||
var starts = new LinkedHashMap<ChunkPos, Integer>();
|
||||
var context = StructurePieceSerializationContext.fromLevel(level);
|
||||
var biomes = new TreeMap<String, Integer>();
|
||||
var chunks = new LinkedHashSet<ChunkPos>();
|
||||
for (var module : plan.modules()) {
|
||||
var cp = new ChunkPos(module.startChunkX(), module.startChunkZ());
|
||||
if (!starts.containsKey(cp)) {
|
||||
var chunk = level.getChunk(cp.x(), cp.z(), ChunkStatus.STRUCTURE_STARTS, true);
|
||||
var start = chunk.getStartForStructure(holder.value());
|
||||
helper.assertTrue(start != null && start.isValid(), "Every planned local transit start exists: " + cp);
|
||||
int expected = plan.modulesForChunk(cp.x(), cp.z()).size();
|
||||
helper.assertTrue(start.getPieces().size() == expected, "No planned module was lost during native structure generation");
|
||||
var tag = start.createTag(context, cp);
|
||||
var restored = StructureStart.loadStaticStart(context, tag, level.getSeed());
|
||||
helper.assertTrue(restored != null && tag.equals(restored.createTag(context, cp)), "Every native transit start roundtrips its full saved geometry");
|
||||
for (var piece : start.getPieces())
|
||||
helper.assertFalse(piece instanceof TransitPiece21 transit
|
||||
&& transit.module().kind() == TransitPlan21.Kind.JUNCTION,
|
||||
"Junctions close their unopened walls with the corrected renderer");
|
||||
starts.put(cp, expected);
|
||||
}
|
||||
TransitPiece21.bounds(module).intersectingChunks().forEach(chunks::add);
|
||||
if (module.kind() == TransitPlan21.Kind.ACCESS) {
|
||||
for (int x = module.centerX() - 2; x <= module.centerX() + 2; x++)
|
||||
for (int z = module.minZ() - 3; z < module.minZ(); z++) chunks.add(new ChunkPos(x >> 4, z >> 4));
|
||||
}
|
||||
}
|
||||
helper.assertTrue(chunks.size() <= 160, "The native traversal witness stays inside its bounded footprint");
|
||||
report.put("local_starts", starts.size()); report.put("planned_footprint_chunks", chunks.size());
|
||||
boolean planOnly = Boolean.getBoolean("sanctuary.test.transit29.planOnly");
|
||||
report.put("plan_only", planOnly);
|
||||
if (planOnly) {
|
||||
report.put("full_chunks", 0);
|
||||
report.put("surface_accesses", accesses.stream().map(m -> TransitPiece21.locator(m).toShortString()).toList());
|
||||
report.put("scope", "Published native plan and all STRUCTURE_STARTS with saved-piece roundtrip; no FULL blocks or physical traversal checked in this case");
|
||||
report.put("passed", true); write(report); helper.succeed(); return;
|
||||
}
|
||||
report.put("full_chunks", chunks.size());
|
||||
var iterator = chunks.iterator(); Runnable[] step = new Runnable[1];
|
||||
step[0] = () -> {
|
||||
try {
|
||||
if (iterator.hasNext()) {
|
||||
var at = iterator.next(); report.put("stage", "FULL " + at);
|
||||
level.getChunk(at.x(), at.z(), ChunkStatus.FULL, true);
|
||||
helper.runAtTickTime(helper.getTick() + 1, () -> step[0].run()); return;
|
||||
}
|
||||
for (var module : plan.modules()) {
|
||||
var at = TransitPiece21.locator(module);
|
||||
biomes.merge(level.getBiome(at).getRegisteredName(), 1, Integer::sum);
|
||||
}
|
||||
int closedWallChecks = 0;
|
||||
for (var module : plan.modules()) if (module.kind() == TransitPlan21.Kind.JUNCTION)
|
||||
for (int direction = 0; direction < 4; direction++) if ((module.openings() & 1 << direction) == 0)
|
||||
for (int across = -2; across <= 2; across++) {
|
||||
int x = direction == 1 ? module.maxX() : direction == 3 ? module.minX() : module.centerX() + across;
|
||||
int z = direction == 0 ? module.minZ() : direction == 2 ? module.maxZ() : module.centerZ() + across;
|
||||
var at = new net.minecraft.core.BlockPos(x, module.minY() + 2, z);
|
||||
helper.assertTrue(level.getBlockState(at).isSolid(), "An unopened junction wall remains solid at " + at);
|
||||
closedWallChecks++;
|
||||
}
|
||||
report.put("closed_wall_checks", closedWallChecks);
|
||||
report.put("module_biomes", biomes);
|
||||
report.put("walk", Transit21WorldGameTests.verifyAccess(helper, plan));
|
||||
var nearest = TransitStructures21.findNearest(level, HolderSet.direct(holder), net.minecraft.core.BlockPos.ZERO, 128, false);
|
||||
helper.assertTrue(nearest != null && accesses.stream().anyMatch(m -> TransitPiece21.locator(m).equals(nearest.getFirst())),
|
||||
"The real structure locator returns one of the walkable surface gates");
|
||||
report.put("locate", nearest.getFirst().toShortString());
|
||||
report.put("passed", true); write(report); helper.succeed();
|
||||
} catch (Exception failure) { fail(report, failure); throw new IllegalStateException("Transit29 native traversal failed", failure); }
|
||||
};
|
||||
helper.runAtTickTime(helper.getTick() + 1, () -> step[0].run());
|
||||
} catch (Exception failure) { fail(report, failure); throw failure; }
|
||||
}
|
||||
private static void write(Map<String, Object> report) throws Exception {
|
||||
Files.createDirectories(OUT); Files.writeString(OUT.resolve("native.json"), JSON.toJson(report) + "\n");
|
||||
}
|
||||
private static void fail(Map<String, Object> report, Exception failure) {
|
||||
report.put("passed", false); report.put("error", failure.toString());
|
||||
try { Files.createDirectories(OUT); Files.writeString(OUT.resolve("failure.json"), JSON.toJson(report) + "\n"); }
|
||||
catch (Exception io) { failure.addSuppressed(io); }
|
||||
SanctuaryMod.LOGGER.error("Transit29 native traversal failed", failure);
|
||||
}
|
||||
}
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
package fr.koka.sanctuary.gametest;
|
||||
|
||||
import fr.koka.sanctuary.worldgen.city.LostCityUnderground16;
|
||||
import fr.koka.sanctuary.worldgen.city.LostCityUnderground16.Kind;
|
||||
import fr.koka.sanctuary.worldgen.city.LostCityUnderground16.Module;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.gametest.framework.GameTestHelper;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.StairBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
|
||||
/** Native circulation proof on the already generated piece footprint. */
|
||||
public final class Underground22NativeChecks {
|
||||
private static final Direction[] HORIZONTAL = {Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST};
|
||||
private Underground22NativeChecks() {}
|
||||
public static Map<String, Integer> verify(GameTestHelper helper, LostCityUnderground16.Plan plan) {
|
||||
var level = helper.getLevel(); var chunks = new HashSet<Long>();
|
||||
int halls = 0, ladders = 0, apertures = 0, walked = 0;
|
||||
helper.assertTrue(!plan.isEmpty(), "Independent underground hall plan must be present");
|
||||
for (var network : plan.networks()) {
|
||||
for (var m : network.modules()) {
|
||||
for (int cx = m.minX() >> 4; cx <= m.maxX() >> 4; cx++) for (int cz = m.minZ() >> 4; cz <= m.maxZ() >> 4; cz++) {
|
||||
long key = ((long) cx << 32) ^ (cz & 0xffffffffL);
|
||||
// Short-lived read tickets can expire during the caller’s asynchronous footprint load.
|
||||
// Refresh only these already generated chunks before inspecting their blocks.
|
||||
if (chunks.add(key)) helper.assertTrue(level.getChunk(cx, cz, ChunkStatus.FULL, true) instanceof LevelChunk,
|
||||
"Underground22 piece has no loaded FULL chunk at " + cx + "," + cz);
|
||||
}
|
||||
for (int d = 0; d < 4; d++) if ((m.openings() & 1 << d) != 0) {
|
||||
for (int side = -1; side <= 1; side++) for (int dy = 1; dy <= 3; dy++) {
|
||||
var at = mouth(m, d, side, dy);
|
||||
helper.assertTrue(passable(level.getBlockState(at)), "Native utility doorway blocked at " + at + " in " + m.kind());
|
||||
}
|
||||
apertures++;
|
||||
}
|
||||
}
|
||||
var access = network.modules().stream().filter(m -> m.kind() == Kind.ACCESS).findFirst().orElseThrow();
|
||||
BlockPos hatch = null;
|
||||
for (int x = access.minX(); x <= access.maxX(); x++) for (int z = access.minZ(); z <= access.maxZ(); z++) {
|
||||
var at = new BlockPos(x, access.maxY() - 1, z);
|
||||
if (level.getBlockState(at).is(Blocks.DARK_OAK_TRAPDOOR)) {
|
||||
helper.assertTrue(hatch == null, "The access has more than one surface hatch"); hatch = at;
|
||||
}
|
||||
}
|
||||
helper.assertTrue(hatch != null, "Independent access has no real wooden surface hatch");
|
||||
final BlockPos entrance = hatch;
|
||||
var closed = level.getBlockState(entrance);
|
||||
for (int y = access.floorY() + 1; y < entrance.getY(); y++) {
|
||||
var at = new BlockPos(entrance.getX(), y, entrance.getZ()); var ladder = level.getBlockState(at);
|
||||
helper.assertTrue(ladder.is(Blocks.LADDER), "Access ladder is interrupted at " + at);
|
||||
var wall = at.relative(ladder.getValue(BlockStateProperties.HORIZONTAL_FACING).getOpposite());
|
||||
helper.assertTrue(level.getBlockState(wall).isCollisionShapeFullBlock(level, wall), "Ladder has no real backing wall at " + at);
|
||||
ladders++;
|
||||
}
|
||||
level.setBlock(entrance, closed.setValue(BlockStateProperties.OPEN, true), 2);
|
||||
try {
|
||||
Predicate<BlockPos> inside = pos -> network.modules().stream().anyMatch(m -> m.contains(pos.getX(), pos.getY(), pos.getZ()));
|
||||
BlockPos approach = java.util.Arrays.stream(HORIZONTAL).map(entrance::relative)
|
||||
.filter(inside).filter(pos -> standable(level, pos)).findFirst().orElseThrow();
|
||||
var reached = walk(helper, approach, inside); walked += reached.size();
|
||||
helper.assertTrue(reached.contains(entrance), "Public deck cannot reach its hatch");
|
||||
for (var m : network.modules()) {
|
||||
helper.assertTrue(reached.stream().anyMatch(pos -> pos.getY() == m.floorY() + 1 && pos.getX() > m.minX()
|
||||
&& pos.getX() < m.maxX() && pos.getZ() > m.minZ() && pos.getZ() < m.maxZ()),
|
||||
"Surface access cannot reach emitted utility module " + m.kind() + " at " + m.centerX() + "," + m.centerZ());
|
||||
if (m.kind() != Kind.EXPANSION_HALL) continue;
|
||||
halls++;
|
||||
var plinth = new BlockPos(m.centerX(), m.minY() + 2, m.centerZ());
|
||||
helper.assertTrue(level.getBlockState(plinth).is(Blocks.SMOOTH_STONE) && reached.contains(plinth.above()),
|
||||
"Reserved expansion plinth must be emitted and reachable");
|
||||
for (int dx : new int[]{-6, 6}) for (int dz : new int[]{-6, 6})
|
||||
helper.assertTrue(reached.contains(new BlockPos(m.centerX() + dx, m.floorY() + 1, m.centerZ() + dz)),
|
||||
"Expansion hall has a blocked quarter");
|
||||
}
|
||||
} finally { level.setBlock(entrance, closed, 2); }
|
||||
}
|
||||
helper.assertTrue(halls > 0, "Native networks have no usable expansion hall");
|
||||
var report = new LinkedHashMap<String, Integer>(); report.put("full_chunks", chunks.size()); report.put("usable_halls", halls);
|
||||
report.put("ladder_blocks", ladders); report.put("clear_openings", apertures); report.put("reached_positions", walked);
|
||||
return Map.copyOf(report);
|
||||
}
|
||||
private static BlockPos mouth(Module m, int direction, int across, int dy) {
|
||||
return new BlockPos(direction == 1 ? m.maxX() : direction == 3 ? m.minX() : m.centerX() + across,
|
||||
m.floorY() + dy, direction == 0 ? m.minZ() : direction == 2 ? m.maxZ() : m.centerZ() + across);
|
||||
}
|
||||
/** Same finite walking/ladder rule used by the native city16/20/21 access proofs. */
|
||||
private static Set<BlockPos> walk(GameTestHelper helper, BlockPos start, Predicate<BlockPos> inside) {
|
||||
var level = helper.getLevel(); var reached = new HashSet<BlockPos>(); var queue = new ArrayDeque<BlockPos>();
|
||||
helper.assertTrue(inside.test(start) && standable(level, start), "Blocked utility approach"); reached.add(start); queue.add(start);
|
||||
while (!queue.isEmpty()) {
|
||||
var pos = queue.remove();
|
||||
for (var direction : HORIZONTAL) for (int dy = -1; dy <= 1; dy++) {
|
||||
var next = pos.relative(direction).offset(0, dy, 0);
|
||||
if (!inside.test(next) || dy > 0 && !passable(level.getBlockState(pos.above(2)))) continue;
|
||||
if (standable(level, next) && reached.add(next)) queue.add(next);
|
||||
}
|
||||
for (int dy : new int[]{-1, 1}) {
|
||||
var next = pos.offset(0, dy, 0);
|
||||
if (inside.test(next) && (level.getBlockState(pos).is(Blocks.LADDER) || level.getBlockState(next).is(Blocks.LADDER)
|
||||
|| level.getBlockState(pos.below()).is(Blocks.LADDER)) && standable(level, next) && reached.add(next)) queue.add(next);
|
||||
}
|
||||
helper.assertTrue(reached.size() < 100_000, "Utility traversal exceeded its bounded footprint");
|
||||
}
|
||||
return reached;
|
||||
}
|
||||
private static boolean standable(ServerLevel level, BlockPos pos) {
|
||||
var below = level.getBlockState(pos.below()); var at = level.getBlockState(pos);
|
||||
return passable(at) && passable(level.getBlockState(pos.above()))
|
||||
&& (below.isSolid() || below.getBlock() instanceof StairBlock || at.is(Blocks.LADDER) || below.is(Blocks.LADDER));
|
||||
}
|
||||
private static boolean passable(BlockState state) {
|
||||
return state.isAir() || state.is(Blocks.LADDER) || state.is(Blocks.REDSTONE_WALL_TORCH)
|
||||
|| state.is(Blocks.DARK_OAK_TRAPDOOR) && state.getValue(BlockStateProperties.OPEN);
|
||||
}
|
||||
}
|
||||
+55
-3
@@ -45,9 +45,28 @@ final class UnifiedWorldSettingsDiagnostics {
|
||||
var historical16 = presets.getOrThrow(ResourceKey.create(Registries.WORLD_PRESET, SanctuaryMod.id("sanctuary_v16"))).value().createWorldDimensions();
|
||||
helper.assertTrue(historical16.overworld() instanceof SanctuaryChunkGenerator old && old.rootGeneration() == 16
|
||||
&& old.source().generation() == 16 && !old.experimentalStructures(), "Historical16 never gains experimental structures");
|
||||
var historical17 = presets.getOrThrow(ResourceKey.create(Registries.WORLD_PRESET, SanctuaryMod.id("sanctuary_v17"))).value().createWorldDimensions();
|
||||
helper.assertTrue(historical17.overworld() instanceof SanctuaryChunkGenerator old && old.rootGeneration() == 17
|
||||
&& old.source().generation() == 17 && old.experimentalStructures(), "Historical17 keeps its original experimental generator");
|
||||
var historical19 = presets.getOrThrow(ResourceKey.create(Registries.WORLD_PRESET, SanctuaryMod.id("sanctuary_v19"))).value().createWorldDimensions();
|
||||
helper.assertTrue(historical19.overworld() instanceof SanctuaryChunkGenerator old && old.rootGeneration() == 19
|
||||
&& old.source().generation() == 19 && old.experimentalStructures(), "Historical19 keeps its original renderer and world settings");
|
||||
var generator = (SanctuaryChunkGenerator) standard.overworld();
|
||||
helper.assertTrue(generator.rootGeneration() == 17 && generator.source().generation() == 17 && generator.experimentalStructures(), "The public preset uses generation17 with its new-world option");
|
||||
var historical20 = presets.getOrThrow(ResourceKey.create(Registries.WORLD_PRESET, SanctuaryMod.id("sanctuary_v20")));
|
||||
helper.assertTrue(historical20.value().createWorldDimensions().overworld() instanceof SanctuaryChunkGenerator old && old.rootGeneration() == 20
|
||||
&& old.source().generation() == 20 && old.experimentalStructures(), "Historical20 keeps its original architecture");
|
||||
var historical21 = presets.getOrThrow(ResourceKey.create(Registries.WORLD_PRESET, SanctuaryMod.id("sanctuary_v21")));
|
||||
helper.assertTrue(historical21.value().createWorldDimensions().overworld() instanceof SanctuaryChunkGenerator old && old.rootGeneration() == 21
|
||||
&& old.source().generation() == 21 && old.experimentalStructures(), "Historical21 keeps its original placement rules");
|
||||
var historical22 = presets.getOrThrow(ResourceKey.create(Registries.WORLD_PRESET, SanctuaryMod.id("sanctuary_v22")));
|
||||
helper.assertTrue(historical22.value().createWorldDimensions().overworld() instanceof SanctuaryChunkGenerator old
|
||||
&& old.rootGeneration() == 22 && old.source().generation() == 22, "Historical22 remains separately readable");
|
||||
var historical23 = presets.getOrThrow(ResourceKey.create(Registries.WORLD_PRESET, SanctuaryMod.id("sanctuary_v23")));
|
||||
helper.assertTrue(historical23.value().createWorldDimensions().overworld() instanceof SanctuaryChunkGenerator old
|
||||
&& old.rootGeneration() == 23 && old.source().generation() == 23, "Historical23 remains separately readable");
|
||||
helper.assertTrue(generator.rootGeneration() == 24 && generator.source().generation() == 24 && generator.experimentalStructures(), "The public preset uses generation24 with its new-world option");
|
||||
helper.assertTrue(generator.initialDiameter() == 724, "The public preset defaults to Medium / 724 blocks");
|
||||
verifyConstructionMasks(helper, (SanctuaryChunkGenerator) historical21.value().createWorldDimensions().overworld(), generator);
|
||||
for (var tag : List.of(WorldPresetTags.NORMAL, WorldPresetTags.EXTENDED)) {
|
||||
var visible = presets.getOrThrow(tag).stream().map(holder -> holder.getRegisteredName())
|
||||
.filter(name -> name.startsWith("sanctuary:")).collect(Collectors.toSet());
|
||||
@@ -56,11 +75,11 @@ final class UnifiedWorldSettingsDiagnostics {
|
||||
}
|
||||
|
||||
var ops = RegistryOps.create(JsonOps.INSTANCE, access);
|
||||
var activeCodec = generator.rootGeneration() == 17 ? SanctuaryChunkGenerator.RUINS17_CODEC : generator.rootGeneration() == 16 ? SanctuaryChunkGenerator.CITY16_CODEC : generator.rootGeneration() == 15 ? SanctuaryChunkGenerator.CITY15_CODEC : generator.rootGeneration() == 14 ? SanctuaryChunkGenerator.CITY_CODEC : SanctuaryChunkGenerator.CODEC;
|
||||
var activeCodec = generator.rootGeneration() == 24 ? SanctuaryChunkGenerator.AERIAL24_CODEC : generator.rootGeneration() == 23 ? SanctuaryChunkGenerator.SECRETS23_CODEC : generator.rootGeneration() == 22 ? SanctuaryChunkGenerator.SELECTIVE22_CODEC : generator.rootGeneration() == 21 ? SanctuaryChunkGenerator.NETWORK21_CODEC : generator.rootGeneration() == 20 ? SanctuaryChunkGenerator.ARCHITECTURE20_CODEC : generator.rootGeneration() == 19 ? SanctuaryChunkGenerator.HERITAGE19_CODEC : generator.rootGeneration() == 17 ? SanctuaryChunkGenerator.RUINS17_CODEC : generator.rootGeneration() == 16 ? SanctuaryChunkGenerator.CITY16_CODEC : generator.rootGeneration() == 15 ? SanctuaryChunkGenerator.CITY15_CODEC : generator.rootGeneration() == 14 ? SanctuaryChunkGenerator.CITY_CODEC : SanctuaryChunkGenerator.CODEC;
|
||||
var serialized = activeCodec.codec().encodeStart(ops, generator).getOrThrow().getAsJsonObject();
|
||||
serialized.remove("experimental_structures");
|
||||
helper.assertTrue(activeCodec.codec().parse(ops, serialized).getOrThrow().experimentalStructures(),
|
||||
"Generation17 omitted experimental option defaults to enabled");
|
||||
"Generation24 omitted experimental option defaults to enabled");
|
||||
helper.assertTrue(!((SanctuaryChunkGenerator) historical16.overworld()).withExperimentalStructures(true).experimentalStructures(),
|
||||
"The new-world switch cannot activate experimental generation in a historical16 generator");
|
||||
serialized.remove("initial_diameter");
|
||||
@@ -103,4 +122,37 @@ final class UnifiedWorldSettingsDiagnostics {
|
||||
"public_presets", List.of("sanctuary:sanctuary"), "sizes", results,
|
||||
"invalid_diameters_rejected", true, "copied_biome_source", true, "passed", true)) + "\n");
|
||||
}
|
||||
|
||||
private static void verifyConstructionMasks(GameTestHelper helper, SanctuaryChunkGenerator historical21,
|
||||
SanctuaryChunkGenerator generation22) {
|
||||
var outside = new net.minecraft.core.BlockPos(200_000, 192, 200_000);
|
||||
// Decoding a generation must not reserve the world before any structures are planned.
|
||||
// These checks also cover the old OFF contract without initializing another island.
|
||||
for (var generator : List.of(historical21, historical21.withExperimentalStructures(false),
|
||||
generation22, generation22.withExperimentalStructures(false))) {
|
||||
helper.assertTrue(!generator.protectsCityDecoration(outside),
|
||||
"Unplanned generation" + generator.rootGeneration() + " does not protect arbitrary blocks");
|
||||
helper.assertTrue(!generator.intersectsExperimentalStructures(outside.getX(), outside.getY(), outside.getZ(),
|
||||
outside.getX() + 1, outside.getY() + 1, outside.getZ() + 1),
|
||||
"Unplanned generation" + generator.rootGeneration() + " does not reject arbitrary structure bounds");
|
||||
}
|
||||
// Reuse the attached world's real plans: no extra native-noise planning or chunk loads.
|
||||
if (!(helper.getLevel().getChunkSource().getGenerator() instanceof SanctuaryChunkGenerator active)
|
||||
|| active.rootGeneration() != 21 && active.rootGeneration() != 22 && active.rootGeneration() != 23 && active.rootGeneration() != 24) return;
|
||||
helper.assertTrue(!active.protectsCityDecoration(outside)
|
||||
&& !active.intersectsExperimentalStructures(outside.getX(), outside.getY(), outside.getZ(),
|
||||
outside.getX() + 1, outside.getY() + 1, outside.getZ() + 1),
|
||||
"Prepared construction masks remain local to their real structures");
|
||||
var interior = new ArrayList<net.minecraft.core.BlockPos>();
|
||||
for (var module : active.transitPlan21().modules())
|
||||
interior.add(new net.minecraft.core.BlockPos(module.centerX(), module.floorY(), module.centerZ()));
|
||||
for (var network : active.undergroundHall22().networks()) for (var module : network.modules())
|
||||
interior.add(new net.minecraft.core.BlockPos(module.centerX(), module.floorY(), module.centerZ()));
|
||||
if ((active.rootGeneration() == 22 || active.rootGeneration() == 23 || active.rootGeneration() == 24) && helper.getLevel().structureManager().shouldGenerateStructures())
|
||||
helper.assertTrue(!interior.isEmpty(), "The attached generation22 world has core construction to protect");
|
||||
for (var position : interior) helper.assertTrue(active.protectsCityDecoration(position)
|
||||
&& active.intersectsExperimentalStructures(position.getX(), position.getY(), position.getZ(),
|
||||
position.getX(), position.getY(), position.getZ()),
|
||||
"Real underground construction remains protected from decoration and overlapping native structures");
|
||||
}
|
||||
}
|
||||
|
||||
+6
-5
@@ -21,7 +21,8 @@ public abstract class SanctuaryGameTestServerMixin {
|
||||
// generation test's deadline before its IO/workers can complete. This is test-only pacing.
|
||||
@Inject(method = "waitUntilNextTick", at = @At("RETURN"))
|
||||
private void sanctuary$paceExpansionWorkers(CallbackInfo ci) {
|
||||
if (Boolean.getBoolean("sanctuary.test.ruins17") || Boolean.getBoolean("sanctuary.test.expansion") || Boolean.getBoolean("sanctuary.test.lostCity")
|
||||
if (Boolean.getBoolean("sanctuary.test.aerial24.flowAdmission") || Boolean.getBoolean("sanctuary.test.aerial24") || Boolean.getBoolean("sanctuary.test.admission23") || Boolean.getBoolean("sanctuary.test.ocean23") || Boolean.getBoolean("sanctuary.test.secrets23") || Boolean.getBoolean("sanctuary.test.native23") || Boolean.getBoolean("sanctuary.test.selective22") || (Boolean.getBoolean("sanctuary.test.heritage20") || Boolean.getBoolean("sanctuary.test.heritage21") || Boolean.getBoolean("sanctuary.test.lostCity21") || Boolean.getBoolean("sanctuary.test.transit21")) || Boolean.getBoolean("sanctuary.test.lostCity20")
|
||||
|| Boolean.getBoolean("sanctuary.test.heritage19") || Boolean.getBoolean("sanctuary.test.ruins17") || Boolean.getBoolean("sanctuary.test.expansion") || Boolean.getBoolean("sanctuary.test.lostCity")
|
||||
|| Boolean.getBoolean("sanctuary.test.lostCity16") || Boolean.getBoolean("sanctuary.test.lostCity15") || Boolean.getBoolean("sanctuary.test.voidReuse")) {
|
||||
long until = System.nanoTime() + 20_000_000L;
|
||||
long remaining;
|
||||
@@ -39,16 +40,16 @@ public abstract class SanctuaryGameTestServerMixin {
|
||||
@ModifyArg(method = "<clinit>", at = @At(value = "INVOKE", target =
|
||||
"Lnet/minecraft/world/level/levelgen/WorldOptions;<init>(JZZ)V"), index = 1)
|
||||
private static boolean sanctuary$enableStructureGeneration(boolean original) {
|
||||
return true;
|
||||
return Boolean.parseBoolean(System.getProperty("sanctuary.test.generateStructures", "true"));
|
||||
}
|
||||
|
||||
@Redirect(method = "lambda$create$1", at = @At(value = "FIELD", target =
|
||||
"Lnet/minecraft/world/level/levelgen/presets/WorldPresets;FLAT_ALL_DIMENSIONS:Lnet/minecraft/resources/ResourceKey;"))
|
||||
private static ResourceKey<WorldPreset> sanctuary$selectActualPreset() {
|
||||
if (Boolean.getBoolean("sanctuary.test.unified")) {
|
||||
int generation = Integer.getInteger("sanctuary.test.generation", 17);
|
||||
if (generation != 13 && generation != 14 && generation != 15 && generation != 16 && generation != 17) throw new IllegalArgumentException("Unsupported test generation");
|
||||
return ResourceKey.create(Registries.WORLD_PRESET, SanctuaryMod.id(generation == 17 ? "sanctuary" : "sanctuary_v" + generation));
|
||||
int generation = Integer.getInteger("sanctuary.test.generation", 24);
|
||||
if (generation != 13 && generation != 14 && generation != 15 && generation != 16 && generation != 17 && generation != 19 && generation != 20 && generation != 21 && generation != 22 && generation != 23 && generation != 24) throw new IllegalArgumentException("Unsupported test generation");
|
||||
return ResourceKey.create(Registries.WORLD_PRESET, SanctuaryMod.id(generation == 24 ? "sanctuary" : "sanctuary_v" + generation));
|
||||
}
|
||||
if (Boolean.getBoolean("sanctuary.test.expansion")) return ResourceKey.create(Registries.WORLD_PRESET, SanctuaryMod.id("expansion_lab"));
|
||||
int players = Integer.getInteger("sanctuary.test.players", 10);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"environment": "*",
|
||||
"license": "GPL-3.0-or-later",
|
||||
"entrypoints": {
|
||||
"fabric-gametest": ["${gametest_entrypoint}"],
|
||||
"fabric-gametest": ["${gametest_entrypoint}", "fr.koka.sanctuary.gametest.Swamp27WorldGameTests", "fr.koka.sanctuary.gametest.Caves28WorldGameTests", "fr.koka.sanctuary.gametest.Terraces29WorldGameTests", "fr.koka.sanctuary.gametest.River30WorldGameTests", "fr.koka.sanctuary.gametest.Transit29WorldGameTests", "fr.koka.sanctuary.gametest.Alpha28NativeStructuresGameTests", "fr.koka.sanctuary.gametest.BlockKnowledgeGameTests", "fr.koka.sanctuary.gametest.CensusGameTestsTerrain", "fr.koka.sanctuary.gametest.CensusStockGameTests", "fr.koka.sanctuary.gametest.MaterialActivityGameTests"],
|
||||
"fabric-client-gametest": ["fr.koka.sanctuary.gametest.SanctuaryClientRenderTests"]
|
||||
},
|
||||
"mixins": ["sanctuary-gametest.mixins.json"],
|
||||
|
||||
@@ -43,11 +43,17 @@ public final class SanctuaryMod implements ModInitializer {
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
fr.koka.sanctuary.knowledge.census.WorldCensusService.register();
|
||||
fr.koka.sanctuary.knowledge.structures.StructureCensusService.register();
|
||||
fr.koka.sanctuary.knowledge.history.MaterialActivityHistory.register();
|
||||
fr.koka.sanctuary.knowledge.BlockKnowledgeService.register();
|
||||
fr.koka.sanctuary.knowledge.BlockKnowledgeNetworking.register();
|
||||
Registry.register(BuiltInRegistries.CHUNK_GENERATOR, id("expansion_lab"), fr.koka.sanctuary.expansion.ExpansionChunkGenerator.CODEC);
|
||||
Registry.register(BuiltInRegistries.BIOME_SOURCE, id("expansion_lab"), fr.koka.sanctuary.expansion.ExpansionBiomeSource.CODEC);
|
||||
Registry.register(BuiltInRegistries.DENSITY_FUNCTION_TYPE, id("expansion_island"), fr.koka.sanctuary.expansion.ExpansionDensity.CODEC);
|
||||
fr.koka.sanctuary.expansion.ExpansionRuntime.register();
|
||||
fr.koka.sanctuary.expansion.ExpansionCommands.register();
|
||||
fr.koka.sanctuary.worldgen.heritage.HeritageCommands19.register();
|
||||
Registry.register(BuiltInRegistries.DENSITY_FUNCTION_TYPE, id("main_island"), MainIslandDensity.CODEC);
|
||||
Registry.register(BuiltInRegistries.CHUNK_GENERATOR, id("island_v13"), SanctuaryChunkGenerator.CODEC);
|
||||
Registry.register(BuiltInRegistries.BIOME_SOURCE, id("island_v13"), SanctuaryBiomeSource.CODEC);
|
||||
@@ -60,9 +66,27 @@ public final class SanctuaryMod implements ModInitializer {
|
||||
Registry.register(BuiltInRegistries.CHUNK_GENERATOR, id("island_v17"), SanctuaryChunkGenerator.RUINS17_CODEC);
|
||||
Registry.register(BuiltInRegistries.BIOME_SOURCE, id("island_v17"), SanctuaryBiomeSource.RUINS17_CODEC);
|
||||
fr.koka.sanctuary.worldgen.city.LostCityStructures.register();
|
||||
Registry.register(BuiltInRegistries.CHUNK_GENERATOR, id("island_v19"), SanctuaryChunkGenerator.HERITAGE19_CODEC);
|
||||
Registry.register(BuiltInRegistries.BIOME_SOURCE, id("island_v19"), SanctuaryBiomeSource.HERITAGE19_CODEC);
|
||||
Registry.register(BuiltInRegistries.CHUNK_GENERATOR, id("island_v20"), SanctuaryChunkGenerator.ARCHITECTURE20_CODEC);
|
||||
Registry.register(BuiltInRegistries.BIOME_SOURCE, id("island_v20"), SanctuaryBiomeSource.ARCHITECTURE20_CODEC);
|
||||
Registry.register(BuiltInRegistries.CHUNK_GENERATOR, id("island_v21"), SanctuaryChunkGenerator.NETWORK21_CODEC);
|
||||
Registry.register(BuiltInRegistries.BIOME_SOURCE, id("island_v21"), SanctuaryBiomeSource.NETWORK21_CODEC);
|
||||
Registry.register(BuiltInRegistries.CHUNK_GENERATOR, id("island_v22"), SanctuaryChunkGenerator.SELECTIVE22_CODEC);
|
||||
Registry.register(BuiltInRegistries.BIOME_SOURCE, id("island_v22"), SanctuaryBiomeSource.SELECTIVE22_CODEC);
|
||||
Registry.register(BuiltInRegistries.CHUNK_GENERATOR, id("island_v23"), SanctuaryChunkGenerator.SECRETS23_CODEC);
|
||||
Registry.register(BuiltInRegistries.BIOME_SOURCE, id("island_v23"), SanctuaryBiomeSource.SECRETS23_CODEC);
|
||||
Registry.register(BuiltInRegistries.CHUNK_GENERATOR, id("island_v24"), SanctuaryChunkGenerator.AERIAL24_CODEC);
|
||||
Registry.register(BuiltInRegistries.BIOME_SOURCE, id("island_v24"), SanctuaryBiomeSource.AERIAL24_CODEC);
|
||||
fr.koka.sanctuary.worldgen.aerial.AerialStructures24.register();
|
||||
fr.koka.sanctuary.worldgen.mineral.MineralSanctuaryStructures23.register();
|
||||
fr.koka.sanctuary.worldgen.transit.TransitStructures21.register();
|
||||
fr.koka.sanctuary.worldgen.city.LostCityUndergroundStructures22.register();
|
||||
fr.koka.sanctuary.worldgen.heritage.HeritageStructures19.register();
|
||||
fr.koka.sanctuary.worldgen.ruins.RuinsStructures17.register();
|
||||
Registry.register(BuiltInRegistries.DENSITY_FUNCTION_TYPE, id("population_island"), PopulationIslandDensity.CODEC);
|
||||
Registry.register(BuiltInRegistries.BIOME_SOURCE, id("population_island"), PopulationIslandBiomeSource.CODEC);
|
||||
Registry.register(BuiltInRegistries.FEATURE_TYPE, id("swamp27_decoration"), fr.koka.sanctuary.worldgen.Swamp27Decoration.CODEC);
|
||||
Registry.register(BuiltInRegistries.FEATURE_TYPE, id("population_groves"), PopulationGrovesFeature.CODEC);
|
||||
Registry.register(BuiltInRegistries.FEATURE_TYPE, id("population_decorations"), PopulationDecorationsFeature.CODEC);
|
||||
Registry.register(BuiltInRegistries.FEATURE_TYPE, id("population_shore_sugar_cane"), PopulationShoreSugarCaneFeature.CODEC);
|
||||
|
||||
@@ -0,0 +1,366 @@
|
||||
package fr.koka.sanctuary.client;
|
||||
|
||||
import fr.koka.sanctuary.knowledge.BlockKnowledge;
|
||||
import fr.koka.sanctuary.knowledge.BlockKnowledgePayloads;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
import net.minecraft.client.gui.GuiGraphicsExtractor;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.components.CycleButton;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
import net.minecraft.client.gui.components.MultiLineTextWidget;
|
||||
import net.minecraft.client.gui.components.ObjectSelectionList;
|
||||
import net.minecraft.client.gui.components.ScrollableLayout;
|
||||
import net.minecraft.client.gui.components.Tooltip;
|
||||
import net.minecraft.client.gui.layouts.LinearLayout;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.network.chat.CommonComponents;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
/** A personal server snapshot, with independent history facets and current carried stock. */
|
||||
public final class SanctuaryBlocodexScreen extends Screen {
|
||||
private static final AtomicInteger REQUEST_IDS = new AtomicInteger();
|
||||
private static final int ROW_HEIGHT = 44;
|
||||
private static final int LIST_TOP = 98;
|
||||
private static final int TEXT = 0xFFE6E6E6;
|
||||
private static final int MUTED = 0xFFAAAAAA;
|
||||
private List<Row> catalogue = List.of();
|
||||
private List<Row> filtered = List.of();
|
||||
private final List<BlockKnowledge> incoming = new ArrayList<>();
|
||||
private final Set<String> incomingIds = new HashSet<>();
|
||||
private EntryList list;
|
||||
private EditBox search;
|
||||
private Button previous;
|
||||
private Button next;
|
||||
private Button refresh;
|
||||
private Filter filter = Filter.ALL;
|
||||
private String query = "";
|
||||
private int page;
|
||||
private int pageSize = 1;
|
||||
private int activeRequest;
|
||||
private int nextPart;
|
||||
private int expectedParts;
|
||||
private int expectedTotal;
|
||||
private int ticks;
|
||||
private int lastRequestTick = -120;
|
||||
private boolean pending;
|
||||
private boolean loaded;
|
||||
private boolean available = true;
|
||||
|
||||
public SanctuaryBlocodexScreen() {
|
||||
super(label("title"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
int margin = 12;
|
||||
search = addRenderableWidget(new EditBox(font, margin, 44, Math.max(80, width - 126), 20, label("search")));
|
||||
search.setMaxLength(128);
|
||||
search.setHint(label("search"));
|
||||
search.setValue(query);
|
||||
search.setResponder(value -> {
|
||||
query = value;
|
||||
page = 0;
|
||||
filterRows();
|
||||
});
|
||||
refresh = addRenderableWidget(Button.builder(label("refresh"), button -> request())
|
||||
.bounds(width - 106, 44, 94, 20).build());
|
||||
addRenderableWidget(CycleButton.builder(Filter::label, filter).withValues(Filter.values())
|
||||
.create(margin, 70, Math.max(140, width - 126), 20, label("filter"), (button, value) -> {
|
||||
filter = value;
|
||||
page = 0;
|
||||
filterRows();
|
||||
}));
|
||||
addRenderableWidget(Button.builder(label("help"), button -> minecraft.gui.setScreen(new HelpScreen(this)))
|
||||
.bounds(width - 106, 70, 94, 20).tooltip(Tooltip.create(label("help_text"))).build());
|
||||
|
||||
int listHeight = Math.max(ROW_HEIGHT + 8, height - LIST_TOP - 42);
|
||||
pageSize = Math.max(1, (listHeight - 8) / ROW_HEIGHT);
|
||||
list = addRenderableWidget(new EntryList(width - 24, listHeight, LIST_TOP));
|
||||
list.setX(margin);
|
||||
previous = addRenderableWidget(Button.builder(Component.literal("<"), button -> turnPage(-1))
|
||||
.bounds(margin, height - 30, 26, 20).tooltip(Tooltip.create(label("previous"))).build());
|
||||
next = addRenderableWidget(Button.builder(Component.literal(">"), button -> turnPage(1))
|
||||
.bounds(margin + 32, height - 30, 26, 20).tooltip(Tooltip.create(label("next"))).build());
|
||||
addRenderableWidget(Button.builder(CommonComponents.GUI_DONE, button -> onClose())
|
||||
.bounds(width - 92, height - 30, 80, 20).build());
|
||||
filterRows();
|
||||
setInitialFocus(search);
|
||||
if (!loaded && !pending) request();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
ticks++;
|
||||
if (pending && ticks - lastRequestTick >= 120) fail();
|
||||
if (!pending && ticks - lastRequestTick >= 40) request();
|
||||
refresh.active = !pending && ticks - lastRequestTick >= 22;
|
||||
}
|
||||
|
||||
private void request() {
|
||||
if (pending || ticks - lastRequestTick < 22) return;
|
||||
lastRequestTick = ticks;
|
||||
if (minecraft.player == null || minecraft.getConnection() == null
|
||||
|| !ClientPlayNetworking.canSend(BlockKnowledgePayloads.Request.TYPE)) {
|
||||
fail();
|
||||
return;
|
||||
}
|
||||
activeRequest = REQUEST_IDS.incrementAndGet();
|
||||
nextPart = 0;
|
||||
expectedParts = -1;
|
||||
expectedTotal = -1;
|
||||
incoming.clear();
|
||||
incomingIds.clear();
|
||||
pending = true;
|
||||
refresh.active = false;
|
||||
ClientPlayNetworking.send(new BlockKnowledgePayloads.Request(activeRequest));
|
||||
}
|
||||
|
||||
/** Called on the client thread; nothing becomes visible until every fragment is validated. */
|
||||
public void accept(BlockKnowledgePayloads.SnapshotPart part) {
|
||||
if (!pending || part.requestId() != activeRequest) return;
|
||||
if (!part.healthy() || part.partIndex() != nextPart
|
||||
|| (expectedParts != -1 && (part.partCount() != expectedParts || part.totalEntries() != expectedTotal))) {
|
||||
fail();
|
||||
return;
|
||||
}
|
||||
expectedParts = part.partCount();
|
||||
expectedTotal = part.totalEntries();
|
||||
for (BlockKnowledge knowledge : part.entries()) {
|
||||
if (!incomingIds.add(knowledge.blockId())) {
|
||||
fail();
|
||||
return;
|
||||
}
|
||||
incoming.add(knowledge);
|
||||
}
|
||||
nextPart++;
|
||||
if (nextPart != expectedParts) return;
|
||||
if (incoming.size() != expectedTotal) {
|
||||
fail();
|
||||
return;
|
||||
}
|
||||
catalogue = incoming.stream().map(Row::new)
|
||||
.sorted(Comparator.comparing(Row::name, String.CASE_INSENSITIVE_ORDER).thenComparing(row -> row.knowledge().blockId()))
|
||||
.toList();
|
||||
incoming.clear();
|
||||
incomingIds.clear();
|
||||
loaded = true;
|
||||
available = true;
|
||||
pending = false;
|
||||
filterRows();
|
||||
}
|
||||
|
||||
private void fail() {
|
||||
pending = false;
|
||||
available = false;
|
||||
loaded = false;
|
||||
catalogue = List.of();
|
||||
incoming.clear();
|
||||
incomingIds.clear();
|
||||
filterRows();
|
||||
}
|
||||
|
||||
private void filterRows() {
|
||||
String normalized = query.strip().toLowerCase(Locale.ROOT);
|
||||
filtered = catalogue.stream().filter(row -> filter.matches(row.knowledge()))
|
||||
.filter(row -> normalized.isEmpty() || row.name().toLowerCase(Locale.ROOT).contains(normalized)
|
||||
|| row.knowledge().blockId().toLowerCase(Locale.ROOT).contains(normalized)).toList();
|
||||
showPage();
|
||||
}
|
||||
|
||||
private void showPage() {
|
||||
if (list == null) return;
|
||||
page = Math.max(0, Math.min(page, pageCount() - 1));
|
||||
int from = page * pageSize;
|
||||
String selected = list.getSelected() == null ? null : list.getSelected().row.knowledge().blockId();
|
||||
List<Entry> entries = filtered.subList(Math.min(from, filtered.size()), Math.min(from + pageSize, filtered.size()))
|
||||
.stream().map(Entry::new).toList();
|
||||
list.replaceEntries(entries);
|
||||
list.setSelected(entries.stream().filter(entry -> entry.row.knowledge().blockId().equals(selected)).findFirst().orElse(null));
|
||||
list.setScrollAmount(0);
|
||||
previous.active = page > 0;
|
||||
next.active = page + 1 < pageCount();
|
||||
}
|
||||
|
||||
private int pageCount() { return Math.max(1, (filtered.size() + pageSize - 1) / pageSize); }
|
||||
|
||||
private void turnPage(int delta) {
|
||||
page += delta;
|
||||
showPage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseScrolled(double mouseX, double mouseY, double horizontal, double vertical) {
|
||||
if (list.isMouseOver(mouseX, mouseY) && vertical != 0) {
|
||||
turnPage(vertical < 0 ? 1 : -1);
|
||||
return true;
|
||||
}
|
||||
return super.mouseScrolled(mouseX, mouseY, horizontal, vertical);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float partialTick) {
|
||||
super.extractRenderState(graphics, mouseX, mouseY, partialTick);
|
||||
graphics.centeredText(font, title, width / 2, 12, TEXT);
|
||||
Component summary = !available ? label("unavailable") : !loaded ? label("loading")
|
||||
: label("summary", catalogue.stream().filter(row -> row.knowledge().known()).count(), catalogue.size(), filtered.size());
|
||||
graphics.centeredText(font, font.plainSubstrByWidth(summary.getString(), width - 20), width / 2, 28, MUTED);
|
||||
graphics.centeredText(font, label("page", page + 1, pageCount()), width / 2, height - 24, MUTED);
|
||||
if (loaded && filtered.isEmpty()) graphics.centeredText(font, label("empty"), width / 2, LIST_TOP + 18, MUTED);
|
||||
if (!available) graphics.centeredText(font, label("unavailable_hint"), width / 2, LIST_TOP + 18, MUTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPauseScreen() { return false; }
|
||||
|
||||
@Override
|
||||
public void removed() {
|
||||
pending = false;
|
||||
incoming.clear();
|
||||
incomingIds.clear();
|
||||
}
|
||||
|
||||
private static Component label(String key, Object... arguments) {
|
||||
return Component.translatable("sanctuary.blocodex." + key, arguments);
|
||||
}
|
||||
|
||||
private static Component yesNo(boolean value) { return label(value ? "yes" : "no"); }
|
||||
|
||||
private static String compact(long value) {
|
||||
if (value < 10_000) return Long.toString(value);
|
||||
if (value < 1_000_000) return (value / 1_000) + "k";
|
||||
if (value < 1_000_000_000) return (value / 1_000_000) + "M";
|
||||
if (value < 1_000_000_000_000L) return (value / 1_000_000_000) + "G";
|
||||
return (value / 1_000_000_000_000L) + "T";
|
||||
}
|
||||
|
||||
private record Row(BlockKnowledge knowledge, String name, ItemStack icon) {
|
||||
Row(BlockKnowledge knowledge) {
|
||||
this(knowledge, block(knowledge).map(value -> value.getName().getString()).orElse(knowledge.blockId()),
|
||||
block(knowledge).map(value -> new ItemStack(value.asItem())).orElse(ItemStack.EMPTY));
|
||||
}
|
||||
|
||||
private static Optional<Block> block(BlockKnowledge knowledge) {
|
||||
return BuiltInRegistries.BLOCK.getOptional(Identifier.parse(knowledge.blockId()));
|
||||
}
|
||||
}
|
||||
|
||||
private final class EntryList extends ObjectSelectionList<Entry> {
|
||||
EntryList(int listWidth, int listHeight, int top) {
|
||||
super(SanctuaryBlocodexScreen.this.minecraft, listWidth, listHeight, top, ROW_HEIGHT);
|
||||
centerListVertically = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowWidth() { return getWidth() - 12; }
|
||||
}
|
||||
|
||||
private final class Entry extends ObjectSelectionList.Entry<Entry> {
|
||||
private final Row row;
|
||||
|
||||
Entry(Row row) { this.row = row; }
|
||||
|
||||
@Override
|
||||
public Component getNarration() {
|
||||
BlockKnowledge knowledge = row.knowledge();
|
||||
return label("narration", row.name(), label(knowledge.known() ? "known" : "unknown"),
|
||||
yesNo(knowledge.seen()), knowledge.mined(), yesNo(knowledge.possessed()),
|
||||
knowledge.dropped(), knowledge.placed(), knowledge.carried());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void extractContent(GuiGraphicsExtractor graphics, int mouseX, int mouseY, boolean hovered, float partialTick) {
|
||||
BlockKnowledge knowledge = row.knowledge();
|
||||
int x = getContentX();
|
||||
int y = getContentY();
|
||||
int contentWidth = getContentWidth();
|
||||
int color = knowledge.known() ? TEXT : MUTED;
|
||||
if (!row.icon().isEmpty()) graphics.item(row.icon(), x, y);
|
||||
Component state = label(knowledge.known() ? "known" : "unknown");
|
||||
int stateWidth = font.width(state);
|
||||
graphics.text(font, font.plainSubstrByWidth(row.name(), Math.max(24, contentWidth - stateWidth - 30)), x + 22, y + 3, color);
|
||||
graphics.text(font, state, x + contentWidth - stateWidth, y + 3, knowledge.known() ? 0xFF91CF9B : MUTED);
|
||||
int cellWidth = contentWidth / 3;
|
||||
drawCell(graphics, label("seen", yesNo(knowledge.seen())), x, y + 18, cellWidth, color);
|
||||
drawCell(graphics, label("mined", compact(knowledge.mined())), x + cellWidth, y + 18, cellWidth, color);
|
||||
drawCell(graphics, label("possessed", yesNo(knowledge.possessed())), x + cellWidth * 2, y + 18, cellWidth, color);
|
||||
drawCell(graphics, label("dropped", compact(knowledge.dropped())), x, y + 29, cellWidth, color);
|
||||
drawCell(graphics, label("placed", compact(knowledge.placed())), x + cellWidth, y + 29, cellWidth, color);
|
||||
drawCell(graphics, label("carried", compact(knowledge.carried())), x + cellWidth * 2, y + 29, cellWidth, color);
|
||||
if (hovered) graphics.setComponentTooltipForNextFrame(font, List.of(Component.literal(row.name()),
|
||||
Component.literal(knowledge.blockId()), label("seen", yesNo(knowledge.seen())),
|
||||
label("mined", knowledge.mined()), label("possessed", yesNo(knowledge.possessed())),
|
||||
label("dropped", knowledge.dropped()), label("placed", knowledge.placed()),
|
||||
label("carried", knowledge.carried())), mouseX, mouseY);
|
||||
}
|
||||
|
||||
private void drawCell(GuiGraphicsExtractor graphics, Component text, int x, int y, int cellWidth, int color) {
|
||||
graphics.text(font, font.plainSubstrByWidth(text.getString(), cellWidth - 3), x, y, color);
|
||||
}
|
||||
}
|
||||
|
||||
private enum Filter {
|
||||
ALL, UNKNOWN, KNOWN, SEEN, MINED, POSSESSED, DROPPED, PLACED, CARRIED;
|
||||
|
||||
Component label() { return SanctuaryBlocodexScreen.label("filter." + name().toLowerCase(Locale.ROOT)); }
|
||||
|
||||
boolean matches(BlockKnowledge knowledge) {
|
||||
return switch (this) {
|
||||
case ALL -> true;
|
||||
case UNKNOWN -> !knowledge.known();
|
||||
case KNOWN -> knowledge.known();
|
||||
case SEEN -> knowledge.seen();
|
||||
case MINED -> knowledge.mined() > 0;
|
||||
case POSSESSED -> knowledge.possessed();
|
||||
case DROPPED -> knowledge.dropped() > 0;
|
||||
case PLACED -> knowledge.placed() > 0;
|
||||
case CARRIED -> knowledge.carried() > 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private static final class HelpScreen extends Screen {
|
||||
private final Screen parent;
|
||||
|
||||
HelpScreen(Screen parent) {
|
||||
super(label("help"));
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
LinearLayout contents = LinearLayout.vertical();
|
||||
contents.addChild(new MultiLineTextWidget(label("help_text"), font).setMaxWidth(Math.min(450, width - 48)));
|
||||
ScrollableLayout scroll = new ScrollableLayout(minecraft, contents, Math.max(40, height - 80));
|
||||
scroll.arrangeElements();
|
||||
scroll.setX((width - scroll.getWidth()) / 2);
|
||||
scroll.setY(38);
|
||||
scroll.visitWidgets(this::addRenderableWidget);
|
||||
addRenderableWidget(Button.builder(CommonComponents.GUI_BACK, button -> onClose())
|
||||
.bounds(width / 2 - 75, height - 30, 150, 20).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float partialTick) {
|
||||
super.extractRenderState(graphics, mouseX, mouseY, partialTick);
|
||||
graphics.centeredText(font, title, width / 2, 14, TEXT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose() { minecraft.gui.setScreen(parent); }
|
||||
|
||||
@Override
|
||||
public boolean isPauseScreen() { return false; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package fr.koka.sanctuary.client;
|
||||
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import fr.koka.sanctuary.SanctuaryMod;
|
||||
import fr.koka.sanctuary.knowledge.BlockKnowledgePayloads;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import net.fabricmc.fabric.api.client.keymapping.v1.KeyMappingHelper;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
|
||||
/** Innate access: no recipe, item, operator permission or external mod. */
|
||||
public final class SanctuaryKnowledgeClient implements ClientModInitializer {
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
registerClient();
|
||||
}
|
||||
|
||||
public static void registerClient() {
|
||||
KeyMapping open = KeyMappingHelper.registerKeyMapping(new KeyMapping("sanctuary.blocodex.key",
|
||||
InputConstants.Type.KEYBOARD, InputConstants.KEY_B,
|
||||
KeyMapping.Category.register(SanctuaryMod.id("sanctuary"))));
|
||||
ClientPlayNetworking.registerGlobalReceiver(BlockKnowledgePayloads.SnapshotPart.TYPE, (part, context) ->
|
||||
context.client().execute(() -> {
|
||||
if (context.client().gui.screen() instanceof SanctuaryBlocodexScreen screen) screen.accept(part);
|
||||
}));
|
||||
ClientTickEvents.END_CLIENT_TICK.register(client -> {
|
||||
while (open.consumeClick()) {
|
||||
if (client.player != null && client.gui.screen() == null) {
|
||||
client.gui.setScreen(new SanctuaryBlocodexScreen());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -51,11 +51,11 @@ public final class SanctuaryWorldOptionsScreen extends Screen {
|
||||
contents.addChild(sizeButton);
|
||||
diameterHint = contents.addChild(new MultiLineTextWidget(diameterHint(), font)
|
||||
.setMaxWidth(310).setCentered(true));
|
||||
if (generator.rootGeneration() == 17) {
|
||||
if (generator.rootGeneration() == 17 || generator.rootGeneration() == 19 || generator.rootGeneration() == 20 || generator.rootGeneration() == 21 || generator.rootGeneration() == 22 || (generator.rootGeneration() == 23 || generator.rootGeneration() == 24)) {
|
||||
contents.addChild(CycleButton.builder((Boolean enabled) -> enabled ? CommonComponents.OPTION_ON : CommonComponents.OPTION_OFF, experimental)
|
||||
.withValues(true, false).create(0, 0, 280, 20, Component.translatable("sanctuary.world_options.experimental"),
|
||||
(button, value) -> experimental = value));
|
||||
contents.addChild(new MultiLineTextWidget(Component.translatable("sanctuary.world_options.experimental_hint"), font)
|
||||
contents.addChild(new MultiLineTextWidget(Component.translatable(generator.rootGeneration() == 24 ? "sanctuary.world_options.aerial24_hint" : generator.rootGeneration() == 23 ? "sanctuary.world_options.secrets23_hint" : generator.rootGeneration() == 22 ? "sanctuary.world_options.heritage22_hint" : (generator.rootGeneration() == 19 || generator.rootGeneration() == 20 || generator.rootGeneration() == 21 || generator.rootGeneration() == 22 || (generator.rootGeneration() == 23 || generator.rootGeneration() == 24)) ? "sanctuary.world_options.heritage_hint" : "sanctuary.world_options.experimental_hint"), font)
|
||||
.setMaxWidth(310).setCentered(true));
|
||||
}
|
||||
layout.addToContents(contents);
|
||||
|
||||
@@ -78,6 +78,12 @@ public class ExpansionBiomeSource extends BiomeSource {
|
||||
protected Holder<Biome> resolve(List<ExpansionIsland> snapshot, int x, int y, int z) {
|
||||
ExpansionIsland island = islandAt(snapshot, x, z);
|
||||
if (island == null || y < 0 || y >= 384) return biome("the_void");
|
||||
if (ExpansionOcean23.active(island)) {
|
||||
var ocean = ExpansionOcean23.column(island, x, z);
|
||||
if (ocean.water() && y >= ocean.floorY() - 8) return biome(ExpansionOcean23.biome(island, ocean));
|
||||
if (!ocean.water() && ocean.influence() > 0 && y >= ocean.floorY() - 8)
|
||||
return biome(ExpansionOcean23.shoreBiome(island));
|
||||
}
|
||||
double scale = Math.clamp(island.diameter() / 3.0, 24.0, 144.0);
|
||||
double localX = (x - island.centerX()) / scale, localZ = (z - island.centerZ()) / scale;
|
||||
double variation = noise(island.seed(), localX, localZ);
|
||||
|
||||
+45
-3
@@ -97,7 +97,10 @@ public class ExpansionChunkGenerator extends ChunkGenerator {
|
||||
return new Context(delegate, random);
|
||||
});
|
||||
}
|
||||
protected void afterTerrain(ExpansionIsland island, ChunkAccess chunk) { ExpansionTerrain.apply(island, chunk); }
|
||||
protected void afterTerrain(ExpansionIsland island, ChunkAccess chunk) {
|
||||
if (ExpansionOcean23.active(island)) ExpansionOcean23.apply(island, chunk);
|
||||
else ExpansionTerrain.apply(island, chunk);
|
||||
}
|
||||
public String journalDirectory() { return "sanctuary-expansion-v1"; }
|
||||
public int rootGeneration() { return ExpansionIsland.GENERATION; }
|
||||
public RandomState randomState(ExpansionIsland island) { return context(island).random(); }
|
||||
@@ -122,6 +125,11 @@ public class ExpansionChunkGenerator extends ChunkGenerator {
|
||||
ChunkAccess chunk, StructureTemplateManager templates, ResourceKey<Level> dimension) {
|
||||
fr.koka.sanctuary.worldgen.city.LostCityStructures.generate(this, registries, state, structures, chunk, templates, dimension);
|
||||
fr.koka.sanctuary.worldgen.ruins.RuinsStructures17.generate(this, registries, state, structures, chunk, templates, dimension);
|
||||
fr.koka.sanctuary.worldgen.heritage.HeritageStructures19.generate(this, registries, state, structures, chunk, templates, dimension);
|
||||
fr.koka.sanctuary.worldgen.transit.TransitStructures21.generate(this, registries, state, structures, chunk, templates, dimension);
|
||||
fr.koka.sanctuary.worldgen.city.LostCityUndergroundStructures22.generate(this, registries, state, structures, chunk, templates, dimension);
|
||||
fr.koka.sanctuary.worldgen.mineral.MineralSanctuaryStructures23.generate(this, registries, state, structures, chunk, templates, dimension);
|
||||
fr.koka.sanctuary.worldgen.aerial.AerialStructures24.generate(this, registries, state, structures, chunk, templates, dimension);
|
||||
ExpansionStructures.generate(this, registries, state, structures, chunk, templates, dimension);
|
||||
}
|
||||
@Override public void spawnOriginalMobs(WorldGenRegion region) {
|
||||
@@ -131,11 +139,35 @@ public class ExpansionChunkGenerator extends ChunkGenerator {
|
||||
}
|
||||
@Override public int getGenDepth() { return 384; }
|
||||
@Override public int getMinY() { return 0; }
|
||||
@Override public int getSeaLevel() { return -64; }
|
||||
@Override public int getSeaLevel() {
|
||||
Integer level = NativeStructurePlacement23.seaLevel();
|
||||
if (level == null) level = ExpansionOcean23.decorationSeaLevel();
|
||||
return level == null ? -64 : level;
|
||||
}
|
||||
@Override public void applyBiomeDecoration(net.minecraft.world.level.WorldGenLevel level, ChunkAccess chunk, StructureManager structures) {
|
||||
var island = islandAt(chunk.getPos().getMiddleBlockX(), chunk.getPos().getMiddleBlockZ());
|
||||
fr.koka.sanctuary.worldgen.IslandOres28.place(level, this, chunk, island);
|
||||
if (!ExpansionOcean23.active(island)) {
|
||||
super.applyBiomeDecoration(level, chunk, structures);
|
||||
fr.koka.sanctuary.worldgen.CavityMonsterRoom28.decorate(level, this, chunk);
|
||||
return;
|
||||
}
|
||||
Integer previous = ExpansionOcean23.enterDecoration(ExpansionOcean23.seaLevel(island));
|
||||
try {
|
||||
super.applyBiomeDecoration(level, chunk, structures);
|
||||
fr.koka.sanctuary.worldgen.CavityMonsterRoom28.decorate(level, this, chunk);
|
||||
}
|
||||
finally { ExpansionOcean23.restoreDecoration(previous); }
|
||||
}
|
||||
@Override public int getSpawnHeight(LevelHeightAccessor level) { return 220; }
|
||||
@Override public int getBaseHeight(int x, int z, Heightmap.Types type, LevelHeightAccessor level, RandomState ignored) {
|
||||
var island = islandAt(x, z);
|
||||
if (island == null) return getMinY();
|
||||
if (ExpansionOcean23.active(island)) {
|
||||
var ocean = ExpansionOcean23.column(island, x, z);
|
||||
if (ocean.water()) return (type == Heightmap.Types.OCEAN_FLOOR || type == Heightmap.Types.OCEAN_FLOOR_WG
|
||||
? ocean.floorY() : ocean.waterLevel()) + 1;
|
||||
}
|
||||
var context = context(island);
|
||||
return context.generator().getBaseHeight(x, z, type, level, context.random());
|
||||
}
|
||||
@@ -143,7 +175,17 @@ public class ExpansionChunkGenerator extends ChunkGenerator {
|
||||
var island = islandAt(x, z);
|
||||
if (island != null) {
|
||||
var context = context(island);
|
||||
return context.generator().getBaseColumn(x, z, level, context.random());
|
||||
var column = context.generator().getBaseColumn(x, z, level, context.random());
|
||||
if (ExpansionOcean23.active(island)) {
|
||||
var ocean = ExpansionOcean23.column(island, x, z);
|
||||
if (ocean.water()) {
|
||||
for (int y = ocean.bottomY(); y <= ocean.floorY(); y++)
|
||||
column.setBlock(y, Blocks.STONE.defaultBlockState());
|
||||
for (int y = ocean.floorY() + 1; y <= ocean.waterLevel(); y++)
|
||||
column.setBlock(y, Blocks.WATER.defaultBlockState());
|
||||
}
|
||||
}
|
||||
return column;
|
||||
}
|
||||
BlockState[] air = new BlockState[384];
|
||||
java.util.Arrays.fill(air, Blocks.AIR.defaultBlockState());
|
||||
|
||||
@@ -48,15 +48,15 @@ public final class ExpansionCommands {
|
||||
.then(createTree("create", false)).then(createTree("preview", true))
|
||||
.then(Commands.literal("quick").then(Commands.argument("direction", StringArgumentType.word())
|
||||
.suggests((c, b) -> SharedSuggestionProvider.suggest(ExpansionIsland.DIRECTIONS, b))
|
||||
.executes(c -> quick(c, null, 0, "natural"))
|
||||
.executes(c -> quick(c, null, 0, null))
|
||||
.then(Commands.argument("climate", StringArgumentType.word())
|
||||
.suggests((c, b) -> SharedSuggestionProvider.suggest(ExpansionIsland.CLIMATES, b))
|
||||
.executes(c -> quick(c, word(c, "climate"), 0, "natural"))
|
||||
.executes(c -> quick(c, word(c, "climate"), 0, null))
|
||||
.then(Commands.argument("diameter", IntegerArgumentType.integer(64, 1024))
|
||||
.suggests((c, b) -> SharedSuggestionProvider.suggest(List.of("64", "128", "256", "512", "1024"), b))
|
||||
.executes(c -> quick(c, word(c, "climate"), IntegerArgumentType.getInteger(c, "diameter"), "natural"))
|
||||
.executes(c -> quick(c, word(c, "climate"), IntegerArgumentType.getInteger(c, "diameter"), null))
|
||||
.then(Commands.argument("relief", StringArgumentType.word())
|
||||
.suggests((c, b) -> SharedSuggestionProvider.suggest(ExpansionIsland.RELIEFS, b))
|
||||
.suggests((c, b) -> SharedSuggestionProvider.suggest(ExpansionIsland.reliefs(c.getSource().getLevel().getChunkSource().getGenerator() instanceof ExpansionChunkGenerator g ? g.rootGeneration() : 12), b))
|
||||
.executes(c -> quick(c, word(c, "climate"), IntegerArgumentType.getInteger(c, "diameter"), word(c, "relief")))
|
||||
.then(distanceArgument().executes(c -> quick(c, word(c, "climate"), IntegerArgumentType.getInteger(c, "diameter"),
|
||||
word(c, "relief"), IntegerArgumentType.getInteger(c, "distance")))))))));
|
||||
@@ -80,7 +80,7 @@ public final class ExpansionCommands {
|
||||
.then(Commands.argument("climate", StringArgumentType.word()).suggests((c, b) -> SharedSuggestionProvider.suggest(ExpansionIsland.CLIMATES, b))
|
||||
.then(Commands.argument("diameter", IntegerArgumentType.integer(64, 1024))
|
||||
.suggests((c, b) -> SharedSuggestionProvider.suggest(List.of("64", "128", "256", "512", "1024"), b))
|
||||
.then(Commands.argument("relief", StringArgumentType.word()).suggests((c, b) -> SharedSuggestionProvider.suggest(ExpansionIsland.RELIEFS, b))
|
||||
.then(Commands.argument("relief", StringArgumentType.word()).suggests((c, b) -> SharedSuggestionProvider.suggest(ExpansionIsland.reliefs(c.getSource().getLevel().getChunkSource().getGenerator() instanceof ExpansionChunkGenerator g ? g.rootGeneration() : 12), b))
|
||||
.executes(c -> create(c, preview, 0))
|
||||
.then(distanceArgument().executes(c -> create(c, preview, IntegerArgumentType.getInteger(c, "distance"))))))))));
|
||||
}
|
||||
@@ -116,8 +116,10 @@ public final class ExpansionCommands {
|
||||
String id = "island_" + next;
|
||||
int chosenDiameter = diameter != 0 ? diameter : ExpansionIsland.spatialGeneration(session.islands().getFirst().generation())
|
||||
? ExpansionRandomSize.choose(c.getSource().getLevel().getSeed(), id) : 128;
|
||||
var island = session.create(id, "sanctuary", direction,
|
||||
climate == null ? ExpansionIsland.directionalClimate(direction) : climate, chosenDiameter, relief, minimumDistance);
|
||||
String chosenClimate = climate == null ? ExpansionIsland.directionalClimate(direction) : climate;
|
||||
String chosenRelief = relief == null ? ExpansionOcean23.quickRelief(c.getSource().getLevel().getSeed(), id,
|
||||
chosenDiameter, chosenClimate, session.islands().getFirst().generation()) : relief;
|
||||
var island = session.create(id, "sanctuary", direction, chosenClimate, chosenDiameter, chosenRelief, minimumDistance);
|
||||
describe(c, island, false);
|
||||
return Command.SINGLE_SUCCESS;
|
||||
});
|
||||
|
||||
@@ -37,7 +37,9 @@ public record ExpansionDensity(DensityFunction source, ExpansionIsland island) i
|
||||
// Fractional Y elsewhere is interpolated, avoiding one-block terraces from rounding.
|
||||
float density = fraction == 0.0 ? low : (float) (low
|
||||
+ (original.sampleValue(sample, sx, lowerY + 1, sz) - low) * fraction);
|
||||
return ExpansionRelief.sculpt(island, column, y, Math.clamp(density, -1.0F, 1.0F));
|
||||
float shaped = ExpansionRelief.sculpt(island, column, y, Math.clamp(density, -1.0F, 1.0F));
|
||||
return ExpansionOcean23.active(island)
|
||||
? ExpansionOcean23.density(COLUMNS.get().ocean(island, x, z), y, shaped) : shaped;
|
||||
}
|
||||
|
||||
@Override public void sampleVolume(SamplerContext sample, DensityBuffer buffer, DensityVolume volume) {
|
||||
@@ -58,6 +60,7 @@ public record ExpansionDensity(DensityFunction source, ExpansionIsland island) i
|
||||
private ExpansionIsland selected;
|
||||
private final int[] xs = new int[SIZE], zs = new int[SIZE];
|
||||
private final ExpansionRelief.Column[] columns = new ExpansionRelief.Column[SIZE];
|
||||
private final ExpansionOcean23.Column[] oceans = new ExpansionOcean23.Column[SIZE];
|
||||
|
||||
ExpansionRelief.Column get(ExpansionIsland island, int x, int z) {
|
||||
if (selected != island) {
|
||||
@@ -68,9 +71,15 @@ public record ExpansionDensity(DensityFunction source, ExpansionIsland island) i
|
||||
int slot = (hash ^ (hash >>> 16)) & (SIZE - 1);
|
||||
if (columns[slot] == null || xs[slot] != x || zs[slot] != z) {
|
||||
columns[slot] = ExpansionRelief.column(island, x, z);
|
||||
oceans[slot] = ExpansionOcean23.active(island) ? ExpansionOcean23.column(island, x, z) : null;
|
||||
xs[slot] = x; zs[slot] = z;
|
||||
}
|
||||
return columns[slot];
|
||||
}
|
||||
ExpansionOcean23.Column ocean(ExpansionIsland island, int x, int z) {
|
||||
get(island, x, z);
|
||||
int hash = x * 0x9e3779b9 ^ Integer.rotateLeft(z * 0x85ebca6b, 13);
|
||||
return oceans[(hash ^ (hash >>> 16)) & (SIZE - 1)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,11 +6,13 @@ import java.util.List;
|
||||
|
||||
/** Immutable alpha.12 region contract. Directions place islands; climate remains an explicit choice. */
|
||||
public record ExpansionIsland(String id, String parent, String direction, String climate,
|
||||
int diameter, int centerX, int centerZ, long seed, String relief, String status, int generation, String reuseToken) {
|
||||
int diameter, int centerX, int centerZ, long seed, String relief, String status, int generation, String reuseToken,
|
||||
List<String> structurePriorities) {
|
||||
public static final int GENERATION = 12;
|
||||
public static final List<String> DIRECTIONS = List.of("north", "northeast", "east", "southeast", "south", "southwest", "west", "northwest");
|
||||
public static final List<String> CLIMATES = List.of("temperate", "boreal", "glacial", "cold_humid", "humid", "tropical", "warm", "arid", "dry", "cold_dry", "autumn", "cherry", "lost_city");
|
||||
public static final List<String> RELIEFS = List.of("natural", "peaks", "canyon", "volcano");
|
||||
public static final List<String> RELIEFS23 = List.of("natural", "peaks", "canyon", "volcano", "ocean");
|
||||
public static final List<Integer> LEGACY_DIAMETERS = List.of(64, 128, 256, 512);
|
||||
public static final List<Integer> DIAMETERS = List.of(64, 128, 256, 512, 1024);
|
||||
public static final int DECORATION_MARGIN = 32;
|
||||
@@ -27,23 +29,38 @@ public record ExpansionIsland(String id, String parent, String direction, String
|
||||
Codec.STRING.fieldOf("relief").forGetter(ExpansionIsland::relief),
|
||||
Codec.STRING.fieldOf("status").forGetter(ExpansionIsland::status),
|
||||
Codec.INT.fieldOf("generation").forGetter(ExpansionIsland::generation),
|
||||
Codec.STRING.optionalFieldOf("reuse_token", "").forGetter(ExpansionIsland::reuseToken)
|
||||
Codec.STRING.optionalFieldOf("reuse_token", "").forGetter(ExpansionIsland::reuseToken),
|
||||
Codec.STRING.listOf().optionalFieldOf("structure_priorities", List.of()).forGetter(ExpansionIsland::structurePriorities)
|
||||
).apply(i, ExpansionIsland::new));
|
||||
|
||||
public ExpansionIsland(String id, String parent, String direction, String climate, int diameter,
|
||||
int centerX, int centerZ, long seed, String relief, String status, int generation) {
|
||||
this(id, parent, direction, climate, diameter, centerX, centerZ, seed, relief, status, generation, "");
|
||||
this(id, parent, direction, climate, diameter, centerX, centerZ, seed, relief, status, generation, "", List.of());
|
||||
}
|
||||
public ExpansionIsland(String id, String parent, String direction, String climate, int diameter,
|
||||
int centerX, int centerZ, long seed, String relief, String status, int generation, String reuseToken) {
|
||||
this(id, parent, direction, climate, diameter, centerX, centerZ, seed, relief, status, generation, reuseToken, List.of());
|
||||
}
|
||||
|
||||
public ExpansionIsland {
|
||||
if (!id.matches("[a-z][a-z0-9_]{0,31}") || !parent.matches("[a-z][a-z0-9_]{0,31}")) throw new IllegalArgumentException("Invalid island identifier");
|
||||
if (!DIRECTIONS.contains(direction) || !CLIMATES.contains(climate) || !RELIEFS.contains(relief)) throw new IllegalArgumentException("Unknown island profile");
|
||||
if (!DIRECTIONS.contains(direction) || !CLIMATES.contains(climate) || !reliefs(generation).contains(relief)) throw new IllegalArgumentException("Unknown island profile");
|
||||
if (relief.equals("ocean") && ((generation != 23 && generation != 24) || id.equals("sanctuary") || diameter != 512 && diameter != 1024))
|
||||
throw new IllegalArgumentException("Ocean relief requires a generation23 expansion of diameter512 or1024");
|
||||
if (!((spatialGeneration(generation) ? DIAMETERS : LEGACY_DIAMETERS).contains(diameter) || (id.equals("sanctuary") && (diameter == 724 || (generation == 13 || spatialGeneration(generation)) && diameter == 1024)))) throw new IllegalArgumentException("Unsupported nominal diameter");
|
||||
if (Math.abs((long) centerX) > 100_000 || Math.abs((long) centerZ) > 100_000 || (centerX & 15) != 0 || (centerZ & 15) != 0) throw new IllegalArgumentException("Invalid island centre");
|
||||
if (!List.of("reserved", "ready").contains(status) || (generation != GENERATION && !spatialGeneration(generation) && !(generation == 13 && id.equals("sanctuary")))) throw new IllegalArgumentException("Unsupported island state or generation");
|
||||
if (climate.equals("lost_city") && (!spatialGeneration(generation) || id.equals("sanctuary"))) throw new IllegalArgumentException("Lost City requires a generation 14, 15, 16 or 17 expansion");
|
||||
if (climate.equals("lost_city") && (!spatialGeneration(generation) || id.equals("sanctuary"))) throw new IllegalArgumentException("Lost City requires a generation 14, 15, 16, 17, 19, 20, 21 or 22 expansion");
|
||||
if (reuseToken == null || !reuseToken.isEmpty() && (!spatialGeneration(generation) || id.equals("sanctuary") || !reuseToken.matches("[0-9a-f]{64}")))
|
||||
throw new IllegalArgumentException("Invalid void reuse certificate token");
|
||||
if (structurePriorities == null || structurePriorities.size() > 64
|
||||
|| structurePriorities.stream().anyMatch(value -> value == null || !value.matches("[a-z0-9_./:-]{1,128}")))
|
||||
throw new IllegalArgumentException("Invalid structure priority profile");
|
||||
var priorities = new java.util.TreeSet<>(structurePriorities);
|
||||
if (priorities.size() != structurePriorities.size()) throw new IllegalArgumentException("Duplicate structure priority family");
|
||||
structurePriorities = List.copyOf(priorities);
|
||||
if (!structurePriorities.isEmpty() && ((generation != 23 && generation != 24) || id.equals("sanctuary")))
|
||||
throw new IllegalArgumentException("Structure priorities are only available for generation23 expansions");
|
||||
}
|
||||
|
||||
public static ExpansionIsland origin(int diameter, long seed) {
|
||||
@@ -53,7 +70,8 @@ public record ExpansionIsland(String id, String parent, String direction, String
|
||||
return new ExpansionIsland("sanctuary", "sanctuary", "north", "temperate", diameter, 0, 0, seed, "natural", "ready", generation);
|
||||
}
|
||||
|
||||
public static boolean spatialGeneration(int generation) { return generation == 14 || generation == 15 || generation == 16 || generation == 17; }
|
||||
public static boolean spatialGeneration(int generation) { return generation == 14 || generation == 15 || generation == 16 || generation == 17 || generation == 19 || generation == 20 || generation == 21 || generation == 22 || (generation == 23 || generation == 24); }
|
||||
public static List<String> reliefs(int generation) { return (generation == 23 || generation == 24) ? RELIEFS23 : RELIEFS; }
|
||||
public boolean origin() { return id.equals("sanctuary"); }
|
||||
public double referenceDiameter() { return origin() && diameter == 724 ? Math.sqrt(2) * 512 : 512; }
|
||||
public double horizontalScale() { return origin() ? 1.0 : diameter / referenceDiameter(); }
|
||||
@@ -71,8 +89,11 @@ public record ExpansionIsland(String id, String parent, String direction, String
|
||||
return Math.abs((long) centerX - other.centerX) <= reservedRadius() + other.reservedRadius()
|
||||
&& Math.abs((long) centerZ - other.centerZ) <= reservedRadius() + other.reservedRadius();
|
||||
}
|
||||
public ExpansionIsland ready() { return new ExpansionIsland(id, parent, direction, climate, diameter, centerX, centerZ, seed, relief, "ready", generation, reuseToken); }
|
||||
public ExpansionIsland withReuseToken(String token) { return new ExpansionIsland(id, parent, direction, climate, diameter, centerX, centerZ, seed, relief, status, generation, token); }
|
||||
public ExpansionIsland ready() { return new ExpansionIsland(id, parent, direction, climate, diameter, centerX, centerZ, seed, relief, "ready", generation, reuseToken, structurePriorities); }
|
||||
public ExpansionIsland withReuseToken(String token) { return new ExpansionIsland(id, parent, direction, climate, diameter, centerX, centerZ, seed, relief, status, generation, token, structurePriorities); }
|
||||
public ExpansionIsland withStructurePriorities(List<String> priorities) {
|
||||
return new ExpansionIsland(id, parent, direction, climate, diameter, centerX, centerZ, seed, relief, status, generation, reuseToken, priorities);
|
||||
}
|
||||
public static String directionalClimate(String direction) {
|
||||
return switch (direction) {
|
||||
case "north" -> "boreal"; case "northeast" -> "cold_humid"; case "east" -> "humid";
|
||||
|
||||
@@ -10,6 +10,8 @@ import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.Strictness;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonToken;
|
||||
import fr.koka.sanctuary.worldgen.aerial.AerialPlan24;
|
||||
import fr.koka.sanctuary.worldgen.aerial.AerialStore24;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.math.BigDecimal;
|
||||
@@ -41,6 +43,8 @@ public final class ExpansionJournal {
|
||||
private final int rootDiameter;
|
||||
private final int rootGeneration;
|
||||
private final DirectorySync directorySync;
|
||||
private String aerialToken = "";
|
||||
private AerialPlan24 aerialPlan24 = AerialPlan24.EMPTY;
|
||||
private List<ExpansionIsland> islands;
|
||||
private boolean failed;
|
||||
|
||||
@@ -52,7 +56,17 @@ public final class ExpansionJournal {
|
||||
directorySyncFor(directory.getFileSystem().getSeparator(), ExpansionJournal::forceDirectory));
|
||||
}
|
||||
|
||||
public ExpansionJournal(Path directory, long seed, int rootDiameter, int rootGeneration, String initialAerialToken) throws IOException {
|
||||
this(directory, seed, rootDiameter, rootGeneration,
|
||||
directorySyncFor(directory.getFileSystem().getSeparator(), ExpansionJournal::forceDirectory), initialAerialToken);
|
||||
}
|
||||
|
||||
ExpansionJournal(Path directory, long seed, int rootDiameter, int rootGeneration, DirectorySync directorySync) throws IOException {
|
||||
this(directory, seed, rootDiameter, rootGeneration, directorySync, "");
|
||||
}
|
||||
|
||||
private ExpansionJournal(Path directory, long seed, int rootDiameter, int rootGeneration, DirectorySync directorySync,
|
||||
String initialAerialToken) throws IOException {
|
||||
if (rootGeneration != 12 && rootGeneration != 13 && !ExpansionIsland.spatialGeneration(rootGeneration)) throw new IOException("Unsupported root generation");
|
||||
if (rootDiameter != 512 && rootDiameter != 724 && !((rootGeneration == 13 || ExpansionIsland.spatialGeneration(rootGeneration)) && rootDiameter == 1024))
|
||||
throw new IOException("Unsupported expansion root diameter");
|
||||
@@ -62,10 +76,13 @@ public final class ExpansionJournal {
|
||||
this.file = this.directory.resolve(FILE_NAME);
|
||||
this.seed = seed;
|
||||
this.rootDiameter = rootDiameter;
|
||||
if (rootGeneration == 24 && !initialAerialToken.isEmpty()) bindAerial(initialAerialToken);
|
||||
else if (rootGeneration != 24 && !initialAerialToken.isEmpty()) throw new IOException("Historical journals cannot bind aerial sites");
|
||||
if (Files.exists(this.directory, LinkOption.NOFOLLOW_LINKS)) {
|
||||
if (!Files.isDirectory(this.directory, LinkOption.NOFOLLOW_LINKS)) throw new IOException("Expansion journal path is not a directory");
|
||||
this.islands = read();
|
||||
} else {
|
||||
if (rootGeneration == 24 && aerialToken.isEmpty()) throw new IOException("New generation24 journal requires its immutable aerial manifest");
|
||||
// Creating the directory is the bootstrap marker. An interrupted bootstrap requires repair.
|
||||
Files.createDirectories(this.directory.getParent());
|
||||
Files.createDirectory(this.directory);
|
||||
@@ -75,6 +92,8 @@ public final class ExpansionJournal {
|
||||
}
|
||||
|
||||
public synchronized List<ExpansionIsland> islands() { return islands; }
|
||||
public synchronized AerialPlan24 aerialPlan24() { return aerialPlan24; }
|
||||
public synchronized String aerialToken() { return aerialToken; }
|
||||
|
||||
/** False after uncertain persistence or external damage; only a successful reload can recover. */
|
||||
public synchronized boolean healthy() { return !failed; }
|
||||
@@ -150,21 +169,26 @@ public final class ExpansionJournal {
|
||||
reader.setStrictness(Strictness.STRICT);
|
||||
JsonObject root = readJson(reader, 0).getAsJsonObject();
|
||||
if (reader.peek() != JsonToken.END_DOCUMENT) throw new IOException("Trailing data in expansion journal");
|
||||
requireFields(root, JOURNAL_FIELDS);
|
||||
if (integer(root, "schema") != 1 || number(root, "world_seed").longValueExact() != seed || integer(root, "root_diameter") != rootDiameter) {
|
||||
var journalFields = new java.util.HashSet<>(JOURNAL_FIELDS);
|
||||
if (rootGeneration == 24) journalFields.add("aerial_plan");
|
||||
requireFields(root, journalFields);
|
||||
if (integer(root, "schema") != (rootGeneration == 24 ? 2 : 1) || number(root, "world_seed").longValueExact() != seed || integer(root, "root_diameter") != rootDiameter) {
|
||||
throw new IOException("Expansion journal schema, world seed or root diameter does not match");
|
||||
}
|
||||
if (rootGeneration == 24) bindAerial(string(root, "aerial_plan"));
|
||||
JsonArray entries = root.getAsJsonArray("islands");
|
||||
List<ExpansionIsland> decoded = new ArrayList<>();
|
||||
for (JsonElement element : entries) {
|
||||
JsonObject entry = element.getAsJsonObject();
|
||||
var fields = new java.util.HashSet<>(ISLAND_FIELDS);
|
||||
if (ExpansionIsland.spatialGeneration(rootGeneration) && entry.has("reuse_token")) fields.add("reuse_token");
|
||||
if ((rootGeneration == 23 || rootGeneration == 24) && entry.has("structure_priorities")) fields.add("structure_priorities");
|
||||
requireFields(entry, fields);
|
||||
decoded.add(new ExpansionIsland(string(entry, "id"), string(entry, "parent"), string(entry, "direction"), string(entry, "climate"),
|
||||
integer(entry, "diameter"), integer(entry, "center_x"), integer(entry, "center_z"), number(entry, "seed").longValueExact(),
|
||||
string(entry, "relief"), string(entry, "status"), integer(entry, "generation"),
|
||||
entry.has("reuse_token") ? string(entry, "reuse_token") : ""));
|
||||
entry.has("reuse_token") ? string(entry, "reuse_token") : "",
|
||||
entry.has("structure_priorities") ? priorities(entry) : List.of()));
|
||||
}
|
||||
return validate(decoded);
|
||||
} catch (RuntimeException e) {
|
||||
@@ -189,6 +213,7 @@ public final class ExpansionJournal {
|
||||
long dx = (long) island.centerX() - parent.centerX(), dz = (long) island.centerZ() - parent.centerZ();
|
||||
if (!(ExpansionIsland.spatialGeneration(island.generation()) ? ExpansionSpatialPlacement14.followsDirection(island.direction(), dx, dz) : followsDirection(island.direction(), dx, dz))) throw new IOException("Expansion position does not follow its direction: " + island.id());
|
||||
for (ExpansionIsland other : previous.values()) if (island.conflicts(other)) throw new IOException("Expansion reservations overlap: " + island.id() + " / " + other.id());
|
||||
if (rootGeneration == 24 && aerialPlan24.conflicts(island)) throw new IOException("Expansion reservation overlaps a permanent aerial site: " + island.id());
|
||||
previous.put(island.id(), island);
|
||||
}
|
||||
return checked;
|
||||
@@ -210,7 +235,8 @@ public final class ExpansionJournal {
|
||||
|
||||
private JsonObject encode(List<ExpansionIsland> entries) {
|
||||
JsonObject root = new JsonObject();
|
||||
root.addProperty("schema", 1); root.addProperty("world_seed", seed); root.addProperty("root_diameter", rootDiameter);
|
||||
root.addProperty("schema", rootGeneration == 24 ? 2 : 1); root.addProperty("world_seed", seed); root.addProperty("root_diameter", rootDiameter);
|
||||
if (rootGeneration == 24) root.addProperty("aerial_plan", aerialToken);
|
||||
JsonArray array = new JsonArray();
|
||||
for (ExpansionIsland island : entries) {
|
||||
JsonObject entry = new JsonObject();
|
||||
@@ -220,12 +246,24 @@ public final class ExpansionJournal {
|
||||
entry.addProperty("seed", island.seed()); entry.addProperty("relief", island.relief()); entry.addProperty("status", island.status());
|
||||
entry.addProperty("generation", island.generation());
|
||||
if (!island.reuseToken().isEmpty()) entry.addProperty("reuse_token", island.reuseToken());
|
||||
if (!island.structurePriorities().isEmpty()) {
|
||||
var priorities = new JsonArray(); island.structurePriorities().forEach(priorities::add);
|
||||
entry.add("structure_priorities", priorities);
|
||||
}
|
||||
array.add(entry);
|
||||
}
|
||||
root.add("islands", array);
|
||||
return root;
|
||||
}
|
||||
|
||||
private void bindAerial(String token) throws IOException {
|
||||
if (!aerialToken.isEmpty() && !aerialToken.equals(token)) throw new IOException("Aerial manifest identity changed outside this journal");
|
||||
var stored = AerialStore24.load(AerialStore24.directory(directory), token, seed, rootDiameter);
|
||||
if (!aerialToken.isEmpty() && !aerialPlan24.sites().equals(stored.plan().sites())) throw new IOException("Aerial layout changed outside this journal");
|
||||
aerialToken = token;
|
||||
aerialPlan24 = stored.plan();
|
||||
}
|
||||
|
||||
private static JsonElement readJson(JsonReader reader, int depth) throws IOException {
|
||||
if (depth > 4) throw new IOException("Expansion journal nesting exceeds its schema");
|
||||
return switch (reader.peek()) {
|
||||
@@ -258,6 +296,17 @@ public final class ExpansionJournal {
|
||||
private static void requireFields(JsonObject value, Set<String> fields) throws IOException {
|
||||
if (!value.keySet().equals(fields)) throw new IOException("Missing or unknown expansion journal fields");
|
||||
}
|
||||
private static List<String> priorities(JsonObject value) throws IOException {
|
||||
var array = value.get("structure_priorities");
|
||||
if (!array.isJsonArray()) throw new IOException("Structure priorities must be an array");
|
||||
var values = new ArrayList<String>();
|
||||
for (var entry : array.getAsJsonArray()) {
|
||||
if (!entry.isJsonPrimitive() || !entry.getAsJsonPrimitive().isString())
|
||||
throw new IOException("Structure priority family must be a string");
|
||||
values.add(entry.getAsString());
|
||||
}
|
||||
return List.copyOf(values);
|
||||
}
|
||||
private static String string(JsonObject value, String name) throws IOException {
|
||||
JsonPrimitive primitive = value.getAsJsonPrimitive(name);
|
||||
if (!primitive.isString()) throw new IOException("Expected string field: " + name);
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
package fr.koka.sanctuary.expansion;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.levelgen.Heightmap;
|
||||
|
||||
/** One immutable geographic field for the rock, water, biomes and native ocean structures. */
|
||||
public final class ExpansionOcean23 {
|
||||
private static final ThreadLocal<Integer> DECORATION_SEA_LEVEL = new ThreadLocal<>();
|
||||
public static Integer decorationSeaLevel() { return DECORATION_SEA_LEVEL.get(); }
|
||||
public static Integer enterDecoration(int seaLevel) {
|
||||
Integer previous = DECORATION_SEA_LEVEL.get(); DECORATION_SEA_LEVEL.set(seaLevel); return previous;
|
||||
}
|
||||
public static void restoreDecoration(Integer previous) {
|
||||
if (previous == null) DECORATION_SEA_LEVEL.remove(); else DECORATION_SEA_LEVEL.set(previous);
|
||||
}
|
||||
public static final List<String> BIOMES = List.of("ocean", "deep_ocean", "cold_ocean", "deep_cold_ocean",
|
||||
"frozen_ocean", "deep_frozen_ocean", "warm_ocean", "lukewarm_ocean", "deep_lukewarm_ocean", "beach", "snowy_beach", "stony_shore");
|
||||
public record Column(int waterLevel, int floorY, boolean water, boolean deep, int bottomY, double influence) {
|
||||
public int depth() { return water ? waterLevel - floorY : 0; }
|
||||
}
|
||||
private ExpansionOcean23() {}
|
||||
public static boolean active(ExpansionIsland island) {
|
||||
return island != null && (island.generation() == 23 || island.generation() == 24) && !island.origin() && island.relief().equals("ocean");
|
||||
}
|
||||
public static int seaLevel(ExpansionIsland island) {
|
||||
return (int) Math.round(ExpansionRelief.worldY(island, 220));
|
||||
}
|
||||
/** Quick expansions retain their size/climate draw; only unspecified relief participates. */
|
||||
public static String quickRelief(long seed, String id, int diameter, String climate, int generation) {
|
||||
if ((generation != 23 && generation != 24) || diameter < 512 || climate.equals("lost_city")) return "natural";
|
||||
return Long.remainderUnsigned(ExpansionIsland.deriveSeed(seed ^ 0x0CEA231L, id), 3) == 0 ? "ocean" : "natural";
|
||||
}
|
||||
public static Column column(ExpansionIsland island, int x, int z) {
|
||||
int level = seaLevel(island);
|
||||
if (!active(island)) return new Column(level, level, false, false, level, 0);
|
||||
double radius = island.radius();
|
||||
double angle = unit(island.seed() ^ 0x2310CEAL) * Math.PI * 2;
|
||||
double dx = (x - island.centerX()) / radius, dz = (z - island.centerZ()) / radius;
|
||||
double u = dx * Math.cos(angle) + dz * Math.sin(angle) - .09;
|
||||
double v = -dx * Math.sin(angle) + dz * Math.cos(angle) + .035;
|
||||
double phase = unit(island.seed() ^ 0x231BA51L) * Math.PI * 2;
|
||||
double theta = Math.atan2(v, u);
|
||||
double coast = 1 + .08 * Math.sin(theta * 3 + phase) + .055 * Math.sin(theta * 5 - phase)
|
||||
+ .025 * Math.sin(theta * 9 + phase * 2);
|
||||
double radial = Math.hypot(u / .64, v / .59) / coast;
|
||||
double influence = 1 - smooth((radial - 1.08) / .14);
|
||||
if (influence <= 0 || !island.contains(x, z)) return new Column(level, level, false, false, level, 0);
|
||||
double depth = 48 * smooth((1 - radial) / .48)
|
||||
+ 6 * smooth((1 - radial) / .3) * Math.sin(u * 17 + phase) * Math.cos(v * 13 - phase);
|
||||
int floor = radial <= 1 ? level - Math.max(1, (int) Math.round(depth))
|
||||
: level + (int) Math.round(4 + 24 * smooth((radial - 1) / .18));
|
||||
int shell = 14 + (int) Math.round(3 * (1 + Math.sin(u * 11 + v * 7 + phase)));
|
||||
boolean water = radial <= 1;
|
||||
return new Column(level, floor, water, water && level - floor >= 32, floor - shell, influence);
|
||||
}
|
||||
public static float density(Column c, int y, float natural) {
|
||||
if (c.influence() <= 0 || y < c.bottomY() - 2) return natural;
|
||||
// Rock remains a bounded geological shell. The original lower caves survive below it.
|
||||
float shaped = y <= c.floorY() ? Math.min(1, (y - c.bottomY() + 2) / 2f) : -1;
|
||||
return (float) (natural + (shaped - natural) * c.influence());
|
||||
}
|
||||
public static boolean retains(Column c, int y) {
|
||||
return c.water() && y <= c.floorY() && y >= c.bottomY();
|
||||
}
|
||||
public static String shoreBiome(ExpansionIsland island) {
|
||||
return switch (island.climate()) {
|
||||
case "glacial", "cold_dry" -> "snowy_beach";
|
||||
case "dry" -> "stony_shore";
|
||||
default -> "beach";
|
||||
};
|
||||
}
|
||||
public static String biome(ExpansionIsland island, Column column) {
|
||||
return switch (island.climate()) {
|
||||
case "glacial" -> column.deep() ? "deep_frozen_ocean" : "frozen_ocean";
|
||||
case "boreal", "cold_humid", "cold_dry" -> column.deep() ? "deep_cold_ocean" : "cold_ocean";
|
||||
case "warm", "tropical", "arid" -> column.deep() ? "deep_lukewarm_ocean"
|
||||
: column.depth() < 16 ? "warm_ocean" : "lukewarm_ocean";
|
||||
default -> column.deep() ? "deep_ocean" : "ocean";
|
||||
};
|
||||
}
|
||||
/** Exactly one chunk-local fill, before features. Static source water does not schedule an ocean of ticks. */
|
||||
public static void apply(ExpansionIsland island, ChunkAccess chunk) {
|
||||
if (!active(island)) return;
|
||||
var pos = new BlockPos.MutableBlockPos();
|
||||
for (int x = chunk.getPos().getMinBlockX(); x <= chunk.getPos().getMaxBlockX(); x++)
|
||||
for (int z = chunk.getPos().getMinBlockZ(); z <= chunk.getPos().getMaxBlockZ(); z++) {
|
||||
Column c = column(island, x, z);
|
||||
if (!c.water()) continue;
|
||||
// Surface rules run before this pass. Pin the same floor used by admission and biomes.
|
||||
for (int y = c.bottomY(); y <= c.floorY(); y++) {
|
||||
pos.set(x, y, z);
|
||||
var rock = y >= c.floorY() - 1 ? (c.deep() ? Blocks.GRAVEL : Blocks.SAND) : Blocks.STONE;
|
||||
chunk.setBlockState(pos, rock.defaultBlockState(), 0);
|
||||
}
|
||||
for (int y = c.floorY() + 1; y <= c.waterLevel(); y++)
|
||||
chunk.setBlockState(pos.set(x, y, z), Blocks.WATER.defaultBlockState(), 0);
|
||||
}
|
||||
Heightmap.primeHeightmaps(chunk, EnumSet.of(Heightmap.Types.WORLD_SURFACE_WG,
|
||||
Heightmap.Types.OCEAN_FLOOR_WG, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES));
|
||||
}
|
||||
private static double smooth(double x) { x = Math.clamp(x, 0, 1); return x * x * (3 - 2 * x); }
|
||||
private static double unit(long v) {
|
||||
v = (v ^ v >>> 30) * 0xbf58476d1ce4e5b9L;
|
||||
v = (v ^ v >>> 27) * 0x94d049bb133111ebL;
|
||||
return ((v ^ v >>> 31) >>> 11) * 0x1.0p-53;
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public final class ExpansionPlacement {
|
||||
if (direction == null || !ExpansionIsland.DIRECTIONS.contains(direction)) throw new IllegalArgumentException("invalid_direction");
|
||||
if (climate == null || !ExpansionIsland.CLIMATES.contains(climate)) throw new IllegalArgumentException("invalid_climate");
|
||||
if (!ExpansionIsland.DIAMETERS.contains(diameter)) throw new IllegalArgumentException("invalid_diameter");
|
||||
if (relief == null || !ExpansionIsland.RELIEFS.contains(relief)) throw new IllegalArgumentException("invalid_relief");
|
||||
if (relief == null || !ExpansionIsland.reliefs(islands.getFirst().generation()).contains(relief)) throw new IllegalArgumentException("invalid_relief");
|
||||
validateDistance(minimumDistance);
|
||||
int rootGeneration = islands.getFirst().generation();
|
||||
int generation = ExpansionIsland.spatialGeneration(rootGeneration) ? rootGeneration : ExpansionIsland.GENERATION;
|
||||
|
||||
@@ -49,7 +49,11 @@ public final class ExpansionRelief {
|
||||
public static float sculpt(ExpansionIsland island, Column column, double y, float source) {
|
||||
if (source <= 0) return source;
|
||||
double reference = referenceY(island, y);
|
||||
double canyon = 2.1 * column.canyonWeight() * smoothstep((reference - 120.0) / 34.0);
|
||||
double canyonHeight = island.generation() == 24
|
||||
? smoothstep((reference - 126 - column.uplift() * .35) / 16)
|
||||
* smoothstep((226 + column.uplift() * .35 - reference) / 18)
|
||||
: smoothstep((reference - 120.0) / 34.0);
|
||||
double canyon = 2.1 * column.canyonWeight() * canyonHeight;
|
||||
double crater = 2.1 * column.craterWeight() * smoothstep((reference - CRATER_FLOOR) / 14.0);
|
||||
return (float) Math.clamp(source - Math.max(canyon, crater), -1.0, 1.0);
|
||||
}
|
||||
@@ -77,7 +81,7 @@ public final class ExpansionRelief {
|
||||
double uplift;
|
||||
double canyon = 0.0, crater = 0.0;
|
||||
switch (island.relief()) {
|
||||
case "natural" -> {
|
||||
case "natural", "ocean" -> {
|
||||
double ridge = Math.pow(1.0 - Math.abs(broad), 4.0);
|
||||
uplift = Math.clamp(12.0 * broad + 5.0 * detail + 10.0 * Math.max(0.0, ridge - 0.5), -20.0, 20.0);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package fr.koka.sanctuary.expansion;
|
||||
|
||||
import fr.koka.sanctuary.SanctuaryMod;
|
||||
import fr.koka.sanctuary.worldgen.SanctuaryChunkGenerator;
|
||||
import fr.koka.sanctuary.worldgen.aerial.AerialPlanner24;
|
||||
import fr.koka.sanctuary.worldgen.aerial.AerialStore24;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
@@ -37,7 +40,19 @@ public final class ExpansionRuntime {
|
||||
if (server.getWorldData().overworldData().isInitialized()
|
||||
&& !java.nio.file.Files.isDirectory(directory, java.nio.file.LinkOption.NOFOLLOW_LINKS))
|
||||
throw new IOException("Initialized laboratory world is missing its expansion journal directory");
|
||||
var journal = new ExpansionJournal(directory, level.getSeed(), generator.initialDiameter(), generator.rootGeneration());
|
||||
String initialAerialToken = "";
|
||||
if (generator.rootGeneration() == 24 && !java.nio.file.Files.exists(directory, java.nio.file.LinkOption.NOFOLLOW_LINKS)) {
|
||||
if (!(generator instanceof SanctuaryChunkGenerator sanctuary)) throw new IOException("Aerial world requires the Sanctuary generator");
|
||||
initialAerialToken = AerialStore24.create(AerialStore24.directory(directory), level.getSeed(), generator.initialDiameter(),
|
||||
() -> AerialPlanner24.forWorld(level, sanctuary)).token();
|
||||
}
|
||||
var journal = generator.rootGeneration() == 24
|
||||
? new ExpansionJournal(directory, level.getSeed(), generator.initialDiameter(), 24, initialAerialToken)
|
||||
: new ExpansionJournal(directory, level.getSeed(), generator.initialDiameter(), generator.rootGeneration());
|
||||
if (generator.rootGeneration() == 24) {
|
||||
if (!(generator instanceof SanctuaryChunkGenerator sanctuary)) throw new IOException("Aerial world requires the Sanctuary generator");
|
||||
sanctuary.setAerialPlan24(journal.aerialPlan24());
|
||||
}
|
||||
ExpansionVoidReuse.open(level, generator, journal.islands());
|
||||
generator.initialize(level, journal.islands());
|
||||
var session = new Session(level, generator, journal);
|
||||
@@ -87,7 +102,7 @@ public final class ExpansionRuntime {
|
||||
public ExpansionIsland candidate(String id, String parentId, String direction, String climate, int diameter, String relief,
|
||||
int minimumDistance) {
|
||||
return ExpansionPlacement.candidates(level.getSeed(), islands(), id, parentId, direction, climate, diameter, relief, minimumDistance)
|
||||
.stream().findFirst().orElseThrow(() -> new IllegalArgumentException("no_free_space"));
|
||||
.stream().filter(value -> !aerialConflicts(value)).findFirst().orElseThrow(() -> new IllegalArgumentException("no_free_space"));
|
||||
}
|
||||
public ExpansionIsland create(String id, String parent, String direction, String climate, int diameter, String relief) throws IOException {
|
||||
return create(id, parent, direction, climate, diameter, relief, 0);
|
||||
@@ -107,10 +122,17 @@ public final class ExpansionRuntime {
|
||||
return value;
|
||||
}
|
||||
if (islands().size() >= 64) throw new IllegalArgumentException("island_limit");
|
||||
var candidates = ExpansionPlacement.candidates(level.getSeed(), islands(), id, parent, direction, climate, diameter, relief, minimumDistance);
|
||||
// Capture one immutable decision before any candidate is probed or certified. A resumed
|
||||
// reservation uses its recorded profile even if the world's census has since changed.
|
||||
var priorities = generator.rootGeneration() == 23 || generator.rootGeneration() == 24
|
||||
? fr.koka.sanctuary.knowledge.structures.StructureCensusService.priorities(level) : List.<String>of();
|
||||
var candidates = ExpansionPlacement.candidates(level.getSeed(), islands(), id, parent, direction, climate, diameter, relief, minimumDistance)
|
||||
.stream().filter(value -> !aerialConflicts(value)).map(value -> value.withStructurePriorities(priorities)).toList();
|
||||
boolean nativeRefused = false;
|
||||
for (var value : candidates) {
|
||||
ExpansionAdmission.checkDeadline(deadline);
|
||||
try {
|
||||
if (value.generation() == 23 || value.generation() == 24) ExpansionStructures23.verifyExpansion(level, value, deadline);
|
||||
var inspection = ExpansionIsland.spatialGeneration(value.generation()) ? ExpansionVoidReuse.inspect(level, value, deadline) : null;
|
||||
if (inspection == null) ExpansionAdmission.verify(level, value, deadline);
|
||||
if (probe(value) == null) throw new IllegalArgumentException("no_ground");
|
||||
@@ -127,12 +149,18 @@ public final class ExpansionRuntime {
|
||||
return admitted;
|
||||
} catch (ExpansionAdmission.OccupiedException occupied) {
|
||||
// IO failures, timeouts and unsuitable terrain stop this request without a new draw.
|
||||
} catch (ExpansionStructures23.NoSuitableStructureException unsuitable) {
|
||||
nativeRefused = true; // Try another location with the same immutable priorities.
|
||||
} finally {
|
||||
generator.discardUnpublishedContext(value);
|
||||
}
|
||||
}
|
||||
ExpansionAdmission.checkDeadline(deadline);
|
||||
throw new IllegalArgumentException("no_free_space");
|
||||
throw new IllegalArgumentException(nativeRefused ? "native_structure_unavailable" : "no_free_space");
|
||||
}
|
||||
private boolean aerialConflicts(ExpansionIsland island) {
|
||||
return generator.rootGeneration() == 24 && generator instanceof SanctuaryChunkGenerator sanctuary
|
||||
&& sanctuary.aerialPlan24().conflicts(island);
|
||||
}
|
||||
public void resume(String id) {
|
||||
requireHealthyJournal();
|
||||
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package fr.koka.sanctuary.expansion;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/** Exact built-in 26.3-pre-2 catalogue. Other dimensions remain native and ancient cities await Cavernes. */
|
||||
public final class ExpansionStructureCatalog23 {
|
||||
public enum Availability { OVERWORLD, CAVERNS_ONLY, NETHER_ONLY, END_ONLY }
|
||||
public enum Habitat { SURFACE, UNDERGROUND, OCEAN, SHORE }
|
||||
public record Entry(String id, String family, Availability availability, Habitat habitat) {}
|
||||
private static final List<Entry> ENTRIES = create();
|
||||
private static final Map<String, Entry> BY_ID = ENTRIES.stream().collect(Collectors.toUnmodifiableMap(Entry::id, Function.identity()));
|
||||
private ExpansionStructureCatalog23() {}
|
||||
public static List<Entry> entries() { return ENTRIES; }
|
||||
public static Entry entry(String id) { return BY_ID.get(id); }
|
||||
public static String family(String id) { Entry entry = entry(id); return entry == null ? "unknown" : entry.family(); }
|
||||
private static List<Entry> create() {
|
||||
var entries = new ArrayList<Entry>();
|
||||
add(entries, "village", Habitat.SURFACE, "village_plains", "village_desert", "village_savanna", "village_snowy", "village_taiga");
|
||||
for (String biome : List.of("bamboo_jungle", "birch_forest", "cherry_grove", "dappled_forest", "flower_forest", "forest", "meadow",
|
||||
"old_growth_birch_forest", "old_growth_pine_taiga", "old_growth_spruce_taiga", "pale_garden", "savanna", "snowy_taiga",
|
||||
"sparse_jungle", "swamp", "taiga", "windswept_forest", "wooded_badlands"))
|
||||
add(entries, "camp", Habitat.SURFACE, "abandoned_camp_" + biome);
|
||||
add(entries, "ruined_portal", Habitat.SURFACE, "ruined_portal", "ruined_portal_desert", "ruined_portal_jungle", "ruined_portal_mountain", "ruined_portal_swamp");
|
||||
add(entries, "ruined_portal", Habitat.OCEAN, "ruined_portal_ocean");
|
||||
add(entries, "mineshaft", Habitat.UNDERGROUND, "mineshaft", "mineshaft_mesa");
|
||||
add(entries, "ocean_ruin", Habitat.OCEAN, "ocean_ruin_cold", "ocean_ruin_warm");
|
||||
add(entries, "shipwreck", Habitat.OCEAN, "shipwreck");
|
||||
add(entries, "shipwreck", Habitat.SHORE, "shipwreck_beached");
|
||||
add(entries, "buried_treasure", Habitat.SHORE, "buried_treasure");
|
||||
for (String name : List.of("desert_pyramid", "igloo", "jungle_pyramid", "mansion", "pillager_outpost", "swamp_hut", "trail_ruins"))
|
||||
add(entries, name, Habitat.SURFACE, name);
|
||||
add(entries, "monument", Habitat.OCEAN, "monument");
|
||||
add(entries, "stronghold", Habitat.UNDERGROUND, "stronghold");
|
||||
add(entries, "trial_chambers", Habitat.UNDERGROUND, "trial_chambers");
|
||||
entries.add(new Entry("minecraft:ancient_city", "ancient_city", Availability.CAVERNS_ONLY, Habitat.UNDERGROUND));
|
||||
for (String name : List.of("fortress", "bastion_remnant", "nether_fossil", "ruined_portal_nether"))
|
||||
entries.add(new Entry("minecraft:" + name, name.equals("ruined_portal_nether") ? "ruined_portal" : name, Availability.NETHER_ONLY, Habitat.UNDERGROUND));
|
||||
entries.add(new Entry("minecraft:end_city", "end_city", Availability.END_ONLY, Habitat.SURFACE));
|
||||
return List.copyOf(entries);
|
||||
}
|
||||
private static void add(List<Entry> entries, String family, Habitat habitat, String... names) {
|
||||
for (String name : names) entries.add(new Entry("minecraft:" + name, family, Availability.OVERWORLD, habitat));
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,10 @@ public final class ExpansionStructures {
|
||||
public static void generate(ExpansionChunkGenerator generator, RegistryAccess registries,
|
||||
ChunkGeneratorStructureState state, StructureManager manager, ChunkAccess chunk,
|
||||
StructureTemplateManager templates, ResourceKey<Level> level) {
|
||||
if ((generator.rootGeneration() == 23 || generator.rootGeneration() == 24)) {
|
||||
ExpansionStructures23.generate(generator, registries, state, manager, chunk, templates, level);
|
||||
return;
|
||||
}
|
||||
if (!manager.shouldGenerateStructures()) return;
|
||||
int blockX = chunk.getPos().getMiddleBlockX(), blockZ = chunk.getPos().getMiddleBlockZ();
|
||||
ExpansionIsland island = generator.islandAt(blockX, blockZ);
|
||||
|
||||
@@ -0,0 +1,640 @@
|
||||
package fr.koka.sanctuary.expansion;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import fr.koka.sanctuary.SanctuaryMod;
|
||||
import fr.koka.sanctuary.expansion.ExpansionStructureCatalog23.Availability;
|
||||
import fr.koka.sanctuary.expansion.ExpansionStructureCatalog23.Entry;
|
||||
import fr.koka.sanctuary.expansion.ExpansionStructureCatalog23.Habitat;
|
||||
import fr.koka.sanctuary.worldgen.SanctuaryChunkGenerator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.HolderSet;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelHeightAccessor;
|
||||
import net.minecraft.world.level.NoiseColumn;
|
||||
import net.minecraft.world.level.StructureManager;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ChunkGeneratorStructureState;
|
||||
import net.minecraft.world.level.chunk.PalettedContainerFactory;
|
||||
import net.minecraft.world.level.chunk.ProtoChunk;
|
||||
import net.minecraft.world.level.chunk.UpgradeData;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
import net.minecraft.world.level.levelgen.Heightmap;
|
||||
import net.minecraft.world.level.levelgen.RandomState;
|
||||
import net.minecraft.world.level.levelgen.densityfunction.SamplerContext;
|
||||
import net.minecraft.world.level.levelgen.structure.BoundingBox;
|
||||
import net.minecraft.world.level.levelgen.structure.Structure;
|
||||
import net.minecraft.world.level.levelgen.structure.StructurePiece;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureStart;
|
||||
import net.minecraft.world.level.levelgen.structure.pieces.PiecesContainer;
|
||||
import net.minecraft.world.level.levelgen.structure.structures.JigsawStructure;
|
||||
import net.minecraft.world.level.levelgen.structure.structures.StrongholdStructure;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager;
|
||||
|
||||
/** Native structures on generation23 islands: deterministic candidate cells, native pieces and native starts.
|
||||
* Nothing is placed or persisted by the preflight. A refused start is never published as a reference.
|
||||
*/
|
||||
public final class ExpansionStructures23 {
|
||||
public static final int CELL_CHUNKS = 8;
|
||||
private static final int MAX_NATIVE_ATTEMPTS_PER_SITE = 12;
|
||||
private static final int MAX_COLUMN_SAMPLES = 4096;
|
||||
private static final boolean DIAGNOSTICS = Boolean.getBoolean("sanctuary.expansion.structureDiagnostics")
|
||||
|| Boolean.getBoolean("sanctuary.test.expansion");
|
||||
private ExpansionStructures23() {}
|
||||
public static List<Entry> catalogue() { return ExpansionStructureCatalog23.entries(); }
|
||||
public static String family(String id) { return ExpansionStructureCatalog23.family(id); }
|
||||
public static boolean isPlacing() { return NativeStructurePlacement23.seaLevel() != null; }
|
||||
private static boolean nativeGeneration(int generation) { return generation == 23 || generation == 24; }
|
||||
public record Candidate(ChunkPos chunk, long roll) {}
|
||||
public record Accepted(Holder<Structure> structure, StructureStart start) {}
|
||||
public static final class NoSuitableStructureException extends IllegalArgumentException {
|
||||
public NoSuitableStructureException() { super("No suitable native structure fits this expansion; choose another seed, climate, relief or larger size"); }
|
||||
}
|
||||
private static final class SampleBudgetExceeded extends RuntimeException {}
|
||||
|
||||
/** Includes one deterministic central candidate even for a diameter64 island. Never draws from mutable server history. */
|
||||
public static List<Candidate> candidates(ExpansionIsland island) {
|
||||
var result = new LinkedHashMap<Long, Candidate>();
|
||||
int rootX = island.centerX() >> 4, rootZ = island.centerZ() >> 4;
|
||||
var central = new ChunkPos(rootX, rootZ);
|
||||
result.put(central.pack(), new Candidate(central, mix(island.seed() ^ 0xA2300C37L)));
|
||||
int cells = (island.terrainRadius() + 127) / 128;
|
||||
for (int cz = -cells; cz <= cells; cz++) for (int cx = -cells; cx <= cells; cx++) {
|
||||
long roll = mix(island.seed() ^ 0xA23CA7A10L ^ cx * 0x9e3779b97f4a7c15L ^ cz * 0xc2b2ae3d27d4eb4fL);
|
||||
if (Long.remainderUnsigned(roll, 100) >= 68) continue;
|
||||
var pos = new ChunkPos(rootX + cx * CELL_CHUNKS + (int) Long.remainderUnsigned(roll >>> 8, CELL_CHUNKS),
|
||||
rootZ + cz * CELL_CHUNKS + (int) Long.remainderUnsigned(roll >>> 17, CELL_CHUNKS));
|
||||
if (island.contains(pos.getMiddleBlockX(), pos.getMiddleBlockZ())) result.putIfAbsent(pos.pack(), new Candidate(pos, roll));
|
||||
}
|
||||
return List.copyOf(result.values());
|
||||
}
|
||||
|
||||
public static void generate(ExpansionChunkGenerator generator, RegistryAccess registries,
|
||||
ChunkGeneratorStructureState state, StructureManager manager, ChunkAccess chunk,
|
||||
StructureTemplateManager templates, ResourceKey<Level> dimension) {
|
||||
if (!Level.OVERWORLD.equals(dimension) || !manager.shouldGenerateStructures()) return;
|
||||
ExpansionIsland island = generator.islandAt(chunk.getPos().getMiddleBlockX(), chunk.getPos().getMiddleBlockZ());
|
||||
if (island == null || !nativeGeneration(island.generation())) return;
|
||||
Candidate candidate = candidates(island).stream().filter(c -> c.chunk().equals(chunk.getPos())).findFirst().orElse(null);
|
||||
if (candidate == null) return;
|
||||
for (var old : chunk.getAllStarts().values()) {
|
||||
if (old.isValid() && ((Object) old) instanceof NativeStructureMetadata23 metadata
|
||||
&& metadata.sanctuary$native23() != null) return;
|
||||
}
|
||||
var view = new NativeView(generator, island, generator.source(), registries);
|
||||
Accepted accepted = plan(generator, view, island, candidate, registries, templates, dimension, chunk, Long.MAX_VALUE);
|
||||
if (accepted != null) {
|
||||
manager.setStartForStructure(accepted.structure().value(), accepted.start(), chunk);
|
||||
diagnostic(island, candidate, "accepted", accepted.structure().unwrapKey().orElseThrow().identifier().toString());
|
||||
}
|
||||
}
|
||||
|
||||
/** Bounded, read-only native preflight used before reservation of a generation23 expansion.
|
||||
* The same descriptor, cell order, templates and support predicate are replayed by createStructures.
|
||||
* No active source snapshot is mutated and no real world chunk is requested.
|
||||
*/
|
||||
public static void verifyExpansion(ServerLevel level, ExpansionIsland island, long deadlineNanos) {
|
||||
if (!nativeGeneration(island.generation()) || island.origin() || !level.structureManager().shouldGenerateStructures()) return;
|
||||
if (!(level.getChunkSource().getGenerator() instanceof ExpansionChunkGenerator host))
|
||||
throw new IllegalArgumentException("Native structure preflight requires a Sanctuary world");
|
||||
ExpansionBiomeSource isolated = isolatedSource(host, island, level.registryAccess());
|
||||
NativeView view = new NativeView(host, island, isolated, level.registryAccess());
|
||||
var factory = PalettedContainerFactory.create(level.registryAccess());
|
||||
for (Candidate candidate : candidates(island)) {
|
||||
checkDeadline(deadlineNanos);
|
||||
var chunk = new ProtoChunk(candidate.chunk(), UpgradeData.EMPTY, level, factory, null);
|
||||
Accepted accepted = plan(host, view, island, candidate, level.registryAccess(), level.getStructureTemplateManager(), level.dimension(), chunk, deadlineNanos);
|
||||
if (accepted != null) return;
|
||||
}
|
||||
throw new NoSuitableStructureException();
|
||||
}
|
||||
|
||||
/** Public for native diagnostics: only accepted starts are returned; no registry or chunk mutation. */
|
||||
public static Accepted plan(ExpansionChunkGenerator host, ExpansionChunkGenerator view, ExpansionIsland island,
|
||||
Candidate candidate, RegistryAccess registries, StructureTemplateManager templates, ResourceKey<Level> dimension,
|
||||
ChunkAccess chunk, long deadlineNanos) {
|
||||
try { return planFiltered(host, view, island, candidate, registries, templates, dimension, chunk, deadlineNanos, entry -> true); }
|
||||
catch (SampleBudgetExceeded refused) { diagnostic(island, candidate, "terrain-budget-refused", ""); return null; }
|
||||
}
|
||||
|
||||
/** Pure type-specific diagnostic, using the production admission rules and no live chunk generation. */
|
||||
public static Accepted preview(ServerLevel level, ExpansionIsland island, String structureId, long deadlineNanos) {
|
||||
return preview(level, island, structureId, deadlineNanos, false);
|
||||
}
|
||||
/** Finds a site that the full production selection actually chooses, useful for full lifecycle diagnostics. */
|
||||
public static Accepted previewSelected(ServerLevel level, ExpansionIsland island, String structureId, long deadlineNanos) {
|
||||
return preview(level, island, structureId, deadlineNanos, true);
|
||||
}
|
||||
private static Accepted preview(ServerLevel level, ExpansionIsland island, String structureId, long deadlineNanos, boolean selectedOnly) {
|
||||
var host = (ExpansionChunkGenerator) level.getChunkSource().getGenerator();
|
||||
ExpansionBiomeSource source = isolatedSource(host, island, level.registryAccess());
|
||||
var view = new NativeView(host, island, source, level.registryAccess());
|
||||
var factory = PalettedContainerFactory.create(level.registryAccess());
|
||||
for (Candidate candidate : candidates(island)) {
|
||||
checkDeadline(deadlineNanos);
|
||||
var chunk = new ProtoChunk(candidate.chunk(), UpgradeData.EMPTY, level, factory, null);
|
||||
try {
|
||||
Accepted accepted = planFiltered(host, view, island, candidate, level.registryAccess(), level.getStructureTemplateManager(),
|
||||
level.dimension(), chunk, deadlineNanos, entry -> selectedOnly || entry.id().equals(structureId));
|
||||
if (accepted != null && accepted.structure().unwrapKey().orElseThrow().identifier().toString().equals(structureId)) return accepted;
|
||||
} catch (SampleBudgetExceeded refused) { /* An unsuitable candidate does not suppress the following sites. */ }
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Accepted planFiltered(ExpansionChunkGenerator host, ExpansionChunkGenerator view, ExpansionIsland island,
|
||||
Candidate candidate, RegistryAccess registries, StructureTemplateManager templates, ResourceKey<Level> dimension,
|
||||
ChunkAccess chunk, long deadlineNanos, Predicate<Entry> included) {
|
||||
RandomState random = view.randomState(island);
|
||||
GroundSampler ground = new GroundSampler(view, chunk, random, deadlineNanos);
|
||||
int x = candidate.chunk().getMiddleBlockX(), z = candidate.chunk().getMiddleBlockZ();
|
||||
Ground centre = ground.at(x, z);
|
||||
if (centre.top < 32) return null;
|
||||
var sampler = random.createClimateSampler(SamplerContext.builder().enableCaches().build());
|
||||
var resolver = view.getBiomeSource().createResolver(sampler);
|
||||
var hutHeights = new ArrayList<Integer>();
|
||||
// The biome is genuinely three dimensional: a swamp bank can be below another island floor.
|
||||
for (int y = Math.min(centre.top + 1, 280); y >= 48 && hutHeights.size() < 4; y--) {
|
||||
var floor = centre.column.getBlock(y - 1);
|
||||
if ((!floor.isSolid() && !floor.getFluidState().is(net.minecraft.tags.FluidTags.WATER))
|
||||
|| !centre.column.getBlock(y).isAir() || !centre.column.getBlock(y + 1).isAir()) continue;
|
||||
if (!host.structureBiome(resolver.getNoiseBiome(x >> 2, y >> 2, z >> 2)).is(net.minecraft.world.level.biome.Biomes.SWAMP)) continue;
|
||||
if (hutHeights.isEmpty() || hutHeights.getLast() - y >= 8) hutHeights.add(y);
|
||||
}
|
||||
int undergroundY = Math.clamp(centre.top - 60, 50, 210);
|
||||
Holder<Biome> surfaceBiome = host.structureBiome(resolver.getNoiseBiome(x >> 2, centre.top >> 2, z >> 2));
|
||||
Holder<Biome> undergroundBiome = host.structureBiome(resolver.getNoiseBiome(x >> 2, undergroundY >> 2, z >> 2));
|
||||
int seaLevel = ExpansionOcean23.active(island) ? ExpansionOcean23.seaLevel(island) : -64;
|
||||
Holder<Biome> waterBiome = host.structureBiome(resolver.getNoiseBiome(x >> 2, Math.max(0, seaLevel - 8) >> 2, z >> 2));
|
||||
var registry = registries.lookupOrThrow(Registries.STRUCTURE);
|
||||
var eligible = new ArrayList<Choice>();
|
||||
for (Entry entry : catalogue()) {
|
||||
if (entry.availability() != Availability.OVERWORLD || !sizeEligible(entry, island) || !included.test(entry)) continue;
|
||||
Holder<Structure> holder = registry.get(Identifier.parse(entry.id())).orElse(null);
|
||||
if (holder == null) continue;
|
||||
Holder<Biome> biome = entry.habitat() == Habitat.UNDERGROUND ? undergroundBiome
|
||||
: entry.habitat() == Habitat.OCEAN ? waterBiome : surfaceBiome;
|
||||
if (entry.family().equals("swamp_hut")) { if (hutHeights.isEmpty()) continue; }
|
||||
else if (!holder.value().biomes().contains(biome)) continue;
|
||||
if (entry.habitat() == Habitat.OCEAN && !ExpansionOcean23.column(island, x, z).water()) continue;
|
||||
long salt = mix(candidate.roll() ^ entry.id().hashCode() * 0x9e3779b97f4a7c15L);
|
||||
double unit = ((salt >>> 11) + 1.0) * 0x1.0p-53;
|
||||
int weight = weight(entry.family()) * (island.structurePriorities().contains(entry.family()) ? 4 : 1);
|
||||
eligible.add(new Choice(entry, holder, -Math.log(unit) / weight));
|
||||
}
|
||||
eligible.sort(Comparator.comparingDouble(Choice::score).thenComparing(choice -> choice.entry().id()));
|
||||
int attempts = 0;
|
||||
for (Choice choice : eligible) {
|
||||
if (++attempts > MAX_NATIVE_ATTEMPTS_PER_SITE) break;
|
||||
checkDeadline(deadlineNanos);
|
||||
Structure original = choice.holder().value();
|
||||
Entry entry = choice.entry();
|
||||
boolean hut = entry.family().equals("swamp_hut");
|
||||
boolean layeredMine = island.origin() && island.generation() == 24 && entry.family().equals("mineshaft");
|
||||
List<Integer> mineHeights = null;
|
||||
int variants = hut ? hutHeights.size() : entry.habitat() == Habitat.UNDERGROUND || entry.family().equals("ruined_portal") ? 3 : 1;
|
||||
for (int vertical = 0; vertical < variants; vertical++) {
|
||||
if (mineHeights != null && vertical >= mineHeights.size()) break;
|
||||
checkDeadline(deadlineNanos);
|
||||
int targetY = hut ? hutHeights.get(vertical) : undergroundY - vertical * 20;
|
||||
ExpansionChunkGenerator nativeView = hut && view instanceof NativeView local
|
||||
? local.atHeight(targetY + 1) : view;
|
||||
GroundSampler nativeGround = hut ? new GroundSampler(nativeView, chunk, random, deadlineNanos, targetY + 1) : ground;
|
||||
Structure generated = original;
|
||||
if (entry.family().equals("trial_chambers")) generated = withStartHeight(original, registries, targetY);
|
||||
Predicate<Holder<Biome>> valid = b -> original.biomes().contains(host.structureBiome(b));
|
||||
StructureStart start;
|
||||
if (original instanceof StrongholdStructure) {
|
||||
// Vanilla stronghold piece weights are static mutable state.
|
||||
synchronized (StrongholdStructure.class) {
|
||||
start = generated.generate(choice.holder(), dimension, registries, nativeView, view.getBiomeSource(), sampler,
|
||||
random, templates, island.seed(), candidate.chunk(), 0, chunk, valid);
|
||||
}
|
||||
} else {
|
||||
start = generated.generate(choice.holder(), dimension, registries, nativeView, view.getBiomeSource(), sampler,
|
||||
random, templates, island.seed(), candidate.chunk(), 0, chunk, valid);
|
||||
}
|
||||
if (!start.isValid()) { diagnostic(island, candidate, "native-refused", entry.id()); continue; }
|
||||
if (layeredMine) {
|
||||
if (mineHeights == null) {
|
||||
mineHeights = MineshaftHeights29.heights(start, undergroundY, ground.level.getMinY(), ground.level.getMaxY(),
|
||||
(px, pz) -> ground.at(px, pz).column);
|
||||
if (DIAGNOSTICS) SanctuaryMod.LOGGER.info("Native29 mine layers: seed {} chunk {} preferred {} chosen {} native pieces {}",
|
||||
island.seed(), candidate.chunk(), undergroundY, mineHeights, start.getPieces().size());
|
||||
}
|
||||
if (vertical >= mineHeights.size()) break;
|
||||
targetY = mineHeights.get(vertical);
|
||||
}
|
||||
// Only buried portal variants need the alternative underground elevations.
|
||||
if (vertical > 0 && entry.family().equals("ruined_portal") && !undergroundPortal(start)) break;
|
||||
start = adjustNativeStart(original, start, entry, island, targetY, nativeGround);
|
||||
String rejection = supportRejection(host, island, entry, start, nativeGround);
|
||||
if (rejection != null) { diagnostic(island, candidate, rejection, entry.id()); continue; }
|
||||
((NativeStructureMetadata23) (Object) start).sanctuary$native23(new NativeStructureMetadata23.Data(island.seed(), seaLevel));
|
||||
return new Accepted(choice.holder(), start);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Keep all pools, processors, aliases, loot, village logic and original registered identity. */
|
||||
public static Structure withStartHeight(Structure original, RegistryAccess registries, int y) {
|
||||
if (!(original instanceof JigsawStructure)) throw new IllegalArgumentException("Expected native jigsaw structure");
|
||||
var ops = RegistryOps.create(JsonOps.INSTANCE, registries);
|
||||
JsonObject json = Structure.DIRECT_CODEC.encodeStart(ops, original).getOrThrow().getAsJsonObject().deepCopy();
|
||||
JsonObject height = new JsonObject(); height.addProperty("absolute", y);
|
||||
json.add("start_height", height);
|
||||
return Structure.DIRECT_CODEC.parse(ops, json).getOrThrow();
|
||||
}
|
||||
|
||||
private static StructureStart adjustNativeStart(Structure original, StructureStart start, Entry entry, ExpansionIsland island,
|
||||
int targetY, GroundSampler ground) {
|
||||
var pieces = start.getPieces();
|
||||
if (entry.family().equals("stronghold") || entry.family().equals("mineshaft") || undergroundPortal(start)) {
|
||||
BoundingBox box = start.getBoundingBox();
|
||||
int dy = targetY - (box.minY() + box.maxY()) / 2;
|
||||
for (StructurePiece piece : pieces) NativeStructurePlacement23.move(piece, dy);
|
||||
} else if (entry.family().equals("igloo")) {
|
||||
// All shaft pieces share the surface entrance's projection. Save final template positions,
|
||||
// rather than the vanilla temporary Y90 restored after each postProcess invocation.
|
||||
var top = (net.minecraft.world.level.levelgen.structure.TemplateStructurePiece) pieces.getLast();
|
||||
var entrance = top.templatePosition().offset(net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate
|
||||
.calculateRelativePosition(top.placeSettings(), new BlockPos(3, 0, 0)));
|
||||
int dy = ground.at(entrance.getX(), entrance.getZ()).top - 90;
|
||||
for (StructurePiece piece : pieces) NativeStructurePlacement23.move(piece, dy);
|
||||
} else if (entry.family().equals("desert_pyramid") || entry.family().equals("jungle_pyramid") || entry.family().equals("swamp_hut")) {
|
||||
// Finalize vanilla's heightPosition before saving starts. Average the full footprint,
|
||||
// avoiding the native dependence on whichever decorating chunk happens to arrive first.
|
||||
for (StructurePiece piece : pieces) {
|
||||
var box = piece.getBoundingBox(); int sum = 0, count = 0, lowest = Integer.MAX_VALUE;
|
||||
for (int z = box.minZ(); z <= box.maxZ(); z++) for (int x = box.minX(); x <= box.maxX(); x++) {
|
||||
int height = ground.at(x, z).top + 1; sum += height; count++; lowest = Math.min(lowest, height);
|
||||
}
|
||||
int height = entry.family().equals("desert_pyramid") ? lowest : sum / count;
|
||||
int burial = entry.family().equals("desert_pyramid")
|
||||
? (int) Long.remainderUnsigned(mix(island.seed() ^ start.getChunkPos().pack() ^ 0x231D35E47L), 3) : 0;
|
||||
NativeStructurePlacement23.move(piece, height - burial - box.minY());
|
||||
((fr.koka.sanctuary.mixin.ScatteredHeight23Accessor) piece).sanctuary$heightPosition(height);
|
||||
}
|
||||
} else if (entry.family().equals("monument")) {
|
||||
int floor = Integer.MIN_VALUE;
|
||||
BoundingBox box = start.getBoundingBox();
|
||||
for (int z = box.minZ(); z <= box.maxZ(); z += 4) for (int x = box.minX(); x <= box.maxX(); x += 4)
|
||||
floor = Math.max(floor, ExpansionOcean23.column(island, x, z).floorY());
|
||||
int dy = floor + 1 - box.minY();
|
||||
for (StructurePiece piece : pieces) NativeStructurePlacement23.move(piece, dy);
|
||||
} else if (entry.family().equals("shipwreck") || entry.family().equals("ocean_ruin") || entry.family().equals("buried_treasure")) {
|
||||
// Vanilla adjusts these templates during decoration; use the same terrain floor now for valid starts/references.
|
||||
for (StructurePiece piece : pieces) {
|
||||
var box = piece.getBoundingBox();
|
||||
int x = box.getCenter().getX(), z = box.getCenter().getZ();
|
||||
int floor = entry.habitat() == Habitat.OCEAN ? ExpansionOcean23.column(island, x, z).floorY() : ground.at(x, z).top;
|
||||
if (piece instanceof net.minecraft.world.level.levelgen.structure.structures.ShipwreckPieces.ShipwreckPiece ship) {
|
||||
// Shipwreck.generate may already change templatePosition without refreshing its bounding box.
|
||||
// Set and certify the final height now instead of translating that stale Y90 box twice.
|
||||
int min = Integer.MAX_VALUE, sum = 0, count = 0;
|
||||
var size = ship.template().getSize();
|
||||
var at = ship.templatePosition();
|
||||
for (int dz = 0; dz < size.getZ(); dz++) for (int dx = 0; dx < size.getX(); dx++) {
|
||||
int height = entry.habitat() == Habitat.OCEAN
|
||||
? ExpansionOcean23.column(island, at.getX() + dx, at.getZ() + dz).floorY() + 1
|
||||
: ground.at(at.getX() + dx, at.getZ() + dz).top + 1;
|
||||
min = Math.min(min, height); sum += height; count++;
|
||||
}
|
||||
int height = count == 0 ? floor + 1 : entry.habitat() == Habitat.SHORE
|
||||
? ship.calculateBeachedPosition(min, net.minecraft.util.RandomSource.create(island.seed() ^ start.getChunkPos().pack())) : sum / count;
|
||||
ship.adjustPositionHeight(height);
|
||||
var actual = ship.template().getBoundingBox(ship.placeSettings(), ship.templatePosition());
|
||||
box.move(0, actual.minY() - box.minY(), 0);
|
||||
} else {
|
||||
NativeStructurePlacement23.move(piece, floor + 1 - box.minY());
|
||||
}
|
||||
}
|
||||
}
|
||||
// Cloned generators and moved bounding boxes must never escape as a saved registry identity or cached pre-move box.
|
||||
return new StructureStart(original, start.getChunkPos(), start.getReferences(), new PiecesContainer(pieces));
|
||||
}
|
||||
|
||||
private static String supportRejection(ExpansionChunkGenerator host, ExpansionIsland island, Entry entry,
|
||||
StructureStart start, GroundSampler ground) {
|
||||
BoundingBox total = start.getBoundingBox();
|
||||
boolean nativeMine = island.origin() && island.generation() == 24 && entry.family().equals("mineshaft");
|
||||
List<BoundingBox> occupied = nativeMine ? MineshaftAdmission29.volumes(start, (x, z) -> ground.at(x, z).column) : null;
|
||||
if (nativeMine && occupied == null) return "mineshaft-no-native-support";
|
||||
if (island.origin() && entry.habitat() != Habitat.UNDERGROUND && !undergroundPortal(start)) {
|
||||
int nearestX = Math.clamp(island.centerX(), total.minX(), total.maxX());
|
||||
int nearestZ = Math.clamp(island.centerZ(), total.minZ(), total.maxZ());
|
||||
if (Math.hypot((double) nearestX - island.centerX(), (double) nearestZ - island.centerZ()) < 56) return "natural-arrival-buffer";
|
||||
}
|
||||
if (total.minY() < ground.level.getMinY() + 3 || total.maxY() > ground.level.getMaxY() - 4) return "outside-height";
|
||||
for (BoundingBox footprint : nativeMine ? occupied : List.of(total))
|
||||
if (!inside(island, footprint.minX(), footprint.minZ(), 3) || !inside(island, footprint.maxX(), footprint.minZ(), 3)
|
||||
|| !inside(island, footprint.minX(), footprint.maxZ(), 3) || !inside(island, footprint.maxX(), footprint.maxZ(), 3)) return "outside-island";
|
||||
// Vanilla reference discovery scans eight chunks around the decorating chunk.
|
||||
if (total.minX() < start.getChunkPos().getMinBlockX() - 128 || total.maxX() > start.getChunkPos().getMaxBlockX() + 128
|
||||
|| total.minZ() < start.getChunkPos().getMinBlockZ() - 128 || total.maxZ() > start.getChunkPos().getMaxBlockZ() + 128) return "outside-native-reference-range";
|
||||
if (host instanceof SanctuaryChunkGenerator city) {
|
||||
for (BoundingBox volume : nativeMine ? occupied : List.of(total))
|
||||
if (city.lostCityPlan(island).intersects(volume.minX(), volume.minZ(), volume.maxX(), volume.maxZ())) return "occupied-city";
|
||||
if (ground.localCity == null) {
|
||||
var local = new fr.koka.sanctuary.worldgen.city.LostCityProtection16.Builder();
|
||||
local.add(city.lostCityPlan(island), city.undergroundPlan16(island));
|
||||
for (var support : city.citySupports16(island)) local.addViaductSupport(support);
|
||||
var reservation = city.cityReservation16(island);
|
||||
if (reservation != null) local.addReservation(reservation);
|
||||
ground.localCity = local.build();
|
||||
}
|
||||
var legacyProtection = new BoundingBox(total.minX() - 2, total.minY() - 12, total.minZ() - 2,
|
||||
total.maxX() + 2, total.maxY() + 4, total.maxZ() + 2);
|
||||
for (BoundingBox volume : nativeMine ? occupied : List.of(legacyProtection)) {
|
||||
if (ground.localCity.intersects(volume.minX(), volume.minY(), volume.minZ(), volume.maxX(), volume.maxY(), volume.maxZ())
|
||||
|| city.intersectsCityConstruction15(volume.minX(), volume.minY(), volume.minZ(), volume.maxX(), volume.maxY(), volume.maxZ())
|
||||
|| city.intersectsCityConstruction16(volume.minX(), volume.minY(), volume.minZ(), volume.maxX(), volume.maxY(), volume.maxZ())
|
||||
|| city.intersectsExperimentalStructures(volume.minX(), volume.minY(), volume.minZ(), volume.maxX(), volume.maxY(), volume.maxZ()))
|
||||
return "reserved-secret";
|
||||
}
|
||||
if (island.origin() && !entry.family().equals("swamp_hut")) {
|
||||
var binding = city.starterContext();
|
||||
if (nativeMine) {
|
||||
var regions = fr.koka.sanctuary.worldgen.PopulationHydrologyRuntime.plansIntersecting(binding.generator(), binding.random(),
|
||||
total.minX() - 16, total.minZ() - 16, total.maxX() + 16, total.maxZ() + 16);
|
||||
for (var volume : occupied) for (var region : regions)
|
||||
if (MineshaftAdmission29.hydrology(region, volume)) return "protected-hydrology";
|
||||
} else if (fr.koka.sanctuary.worldgen.PopulationHydrologyRuntime.protects(binding.generator(), binding.random(),
|
||||
total.getCenter().atY(total.minY()), Math.max(total.getXSpan(), total.getZSpan()) / 2 + 3, total.getYSpan() + 16, 26)) return "protected-hydrology";
|
||||
}
|
||||
}
|
||||
if (entry.family().equals("swamp_hut")) {
|
||||
if (host instanceof SanctuaryChunkGenerator sanctuary && island.origin()) {
|
||||
var binding = sanctuary.starterContext();
|
||||
var box = new BoundingBox(total.minX(), total.minY() - SwampHutPlacement28.MAX_PIER_DROP - 2,
|
||||
total.minZ(), total.maxX(), total.maxY(), total.maxZ());
|
||||
for (var region : fr.koka.sanctuary.worldgen.PopulationHydrologyRuntime.plansIntersecting(
|
||||
binding.generator(), binding.random(), total.minX() - 16, total.minZ() - 16, total.maxX() + 16, total.maxZ() + 16)) {
|
||||
String refusal = SwampHutPlacement28.hydrologyRejection(region, box);
|
||||
if (refusal != null) return refusal;
|
||||
}
|
||||
}
|
||||
return SwampHutPlacement28.rejection(start, (x, z) -> ground.at(x, z).column);
|
||||
}
|
||||
boolean underground = entry.habitat() == Habitat.UNDERGROUND || undergroundPortal(start);
|
||||
boolean aquatic = entry.habitat() == Habitat.OCEAN;
|
||||
int siteMin = Integer.MAX_VALUE, siteMax = Integer.MIN_VALUE;
|
||||
for (StructurePiece piece : start.getPieces()) {
|
||||
BoundingBox box = piece.getBoundingBox();
|
||||
if (entry.family().equals("mineshaft")
|
||||
&& piece instanceof net.minecraft.world.level.levelgen.structure.structures.MineshaftPieces.MineShaftCorridor) {
|
||||
if (!nativeMine && !MineshaftSupport28.anchored(piece, (x, z) -> ground.at(x, z).column)) return "mineshaft-no-native-support";
|
||||
continue;
|
||||
}
|
||||
if (nativeMine && piece instanceof net.minecraft.world.level.levelgen.structure.structures.MineshaftPieces.MineShaftCrossing) {
|
||||
String crossingRefusal = MineshaftCrossing29.rejection(piece, start.getPieces(), (x, z) -> ground.at(x, z).column, ground.level.getMaxY());
|
||||
if (crossingRefusal != null) return crossingRefusal;
|
||||
continue;
|
||||
}
|
||||
int low = Integer.MAX_VALUE, high = Integer.MIN_VALUE, supported = 0, sampled = 0;
|
||||
boolean buriedPiece = underground || !aquatic && box.maxY() < ground.at(box.getCenter().getX(), box.getCenter().getZ()).top - 6;
|
||||
int step = buriedPiece ? 8 : 4;
|
||||
for (int z : samples(box.minZ(), box.maxZ(), step)) for (int x : samples(box.minX(), box.maxX(), step)) {
|
||||
if (!inside(island, x, z, 3)) return "footprint-outside-island";
|
||||
sampled++;
|
||||
if (aquatic) {
|
||||
var ocean = ExpansionOcean23.column(island, x, z);
|
||||
if (!ocean.water() || ocean.depth() < (entry.family().equals("monument") ? 26 : 5)) return "insufficient-ocean";
|
||||
if (entry.family().equals("monument") && (box.maxY() >= ocean.waterLevel() - 1 || box.minY() - ocean.floorY() > 12)) return "monument-depth-or-foundation";
|
||||
if (!ground.at(x, z).solid(ocean.floorY() - 3)) return "ocean-floor-not-supported";
|
||||
continue;
|
||||
}
|
||||
Ground column = ground.at(x, z);
|
||||
if (buriedPiece) {
|
||||
boolean floor = column.solidNear(box.minY() - 1, 6);
|
||||
boolean roof = column.solidNear(box.maxY() + 1, 6);
|
||||
if (column.top >= box.maxY() + 5 && floor && roof) supported++;
|
||||
continue;
|
||||
}
|
||||
if (column.top < 40 || column.thickness < (entry.family().endsWith("pyramid") ? 18 : 8)) return "unsupported-foundation";
|
||||
if (entry.family().equals("trail_ruins") && !column.solidNear(box.minY() - 1, 4)) return "unsupported-buried-ruin";
|
||||
int maxBurial = entry.family().equals("trail_ruins") || entry.family().endsWith("pyramid") ? 32 : 12;
|
||||
int foundationY = entry.family().equals("mansion") ? total.minY() : box.minY();
|
||||
if (foundationY > column.top + 10 || foundationY < column.top - maxBurial) return "surface-height-mismatch";
|
||||
low = Math.min(low, column.top); high = Math.max(high, column.top);
|
||||
if (high - low > (entry.family().endsWith("pyramid") ? 5 : 9)) return "surface-slope";
|
||||
}
|
||||
if (buriedPiece && supported < Math.ceil(sampled * (entry.family().equals("mineshaft") ? 0.65 : 0.85))) {
|
||||
if (nativeMine && DIAGNOSTICS) SanctuaryMod.LOGGER.info(
|
||||
"Native29 mine enclosure: seed {} chunk {} piece {} box {} supported {}/{} required {}",
|
||||
island.seed(), start.getChunkPos(), piece.getClass().getSimpleName(), box, supported, sampled, (int) Math.ceil(sampled * 0.65));
|
||||
return "cavity-not-enclosed";
|
||||
}
|
||||
if (!buriedPiece && !aquatic) {
|
||||
siteMin = Math.min(siteMin, low); siteMax = Math.max(siteMax, high);
|
||||
if (siteMax - siteMin > 20) return "site-slope";
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** A real-start search for all vanilla keys/tags. No ring-grid fallback and no unactivated island probe. */
|
||||
public static Pair<BlockPos, Holder<Structure>> findNearest(ServerLevel level, HolderSet<Structure> wanted,
|
||||
BlockPos origin, int radius, boolean skipReferenced) {
|
||||
if (!(level.getChunkSource().getGenerator() instanceof ExpansionChunkGenerator generator)
|
||||
|| !nativeGeneration(generator.rootGeneration()) || !level.structureManager().shouldGenerateStructures()) return null;
|
||||
boolean nativeRequested = wanted.stream().anyMatch(h -> {
|
||||
var e = ExpansionStructureCatalog23.entry(h.unwrapKey().orElseThrow().identifier().toString());
|
||||
return e != null && e.availability() == Availability.OVERWORLD;
|
||||
});
|
||||
boolean sanctuaryRequested = wanted.stream().anyMatch(h -> h.unwrapKey().orElseThrow().identifier().getNamespace().equals("sanctuary"));
|
||||
var candidates = new ArrayList<Candidate>();
|
||||
for (ExpansionIsland island : generator.source().islands()) {
|
||||
if (!nativeRequested || !nativeGeneration(island.generation()) || !island.status().equals("ready")) continue;
|
||||
for (Candidate candidate : candidates(island)) {
|
||||
if (Math.abs((long) candidate.chunk().x() - (origin.getX() >> 4)) <= (long) radius * CELL_CHUNKS
|
||||
&& Math.abs((long) candidate.chunk().z() - (origin.getZ() >> 4)) <= (long) radius * CELL_CHUNKS) candidates.add(candidate);
|
||||
}
|
||||
}
|
||||
if (sanctuaryRequested && generator instanceof SanctuaryChunkGenerator sanctuary) addSanctuaryCandidates(sanctuary, candidates);
|
||||
candidates.removeIf(c -> Math.abs((long) c.chunk().x() - (origin.getX() >> 4)) > (long) radius * CELL_CHUNKS
|
||||
|| Math.abs((long) c.chunk().z() - (origin.getZ() >> 4)) > (long) radius * CELL_CHUNKS);
|
||||
candidates = new ArrayList<>(candidates.stream().collect(java.util.stream.Collectors.toMap(
|
||||
c -> c.chunk().pack(), c -> c, (first, second) -> first)).values());
|
||||
candidates.sort(Comparator.comparingDouble((Candidate c) -> horizontalDistanceSquared(origin, c.chunk().getMiddleBlockX(), c.chunk().getMiddleBlockZ()))
|
||||
.thenComparingInt(c -> c.chunk().x()).thenComparingInt(c -> c.chunk().z()));
|
||||
Holder<Structure> bestHolder = null; StructureStart best = null; BlockPos bestPos = null; double bestDistance = Double.POSITIVE_INFINITY;
|
||||
for (Candidate candidate : candidates) {
|
||||
// Every admitted start is within the native 128-block reference range of its start chunk.
|
||||
double minimumDistance = Math.max(0, Math.sqrt(horizontalDistanceSquared(origin, candidate.chunk().getMiddleBlockX(), candidate.chunk().getMiddleBlockZ())) - 192);
|
||||
if (!sanctuaryRequested && minimumDistance * minimumDistance > bestDistance) break;
|
||||
var chunk = level.getChunk(candidate.chunk().x(), candidate.chunk().z(), ChunkStatus.STRUCTURE_STARTS, true);
|
||||
for (Holder<Structure> holder : wanted) {
|
||||
Entry entry = ExpansionStructureCatalog23.entry(holder.unwrapKey().orElseThrow().identifier().toString());
|
||||
if (entry != null && entry.availability() != Availability.OVERWORLD) continue;
|
||||
StructureStart start = level.structureManager().getStartForStructure(holder.value(), chunk);
|
||||
if (start == null || !start.isValid() || skipReferenced && !start.canBeReferenced()) continue;
|
||||
BlockPos position = locator(start, origin);
|
||||
double distance = horizontalDistanceSquared(origin, position.getX(), position.getZ());
|
||||
if (distance < bestDistance) { best = start; bestPos = position; bestHolder = holder; bestDistance = distance; }
|
||||
}
|
||||
}
|
||||
if (best == null) return null;
|
||||
// Mutate only the final winner, including when the request is a tag containing several structures.
|
||||
if (skipReferenced) level.structureManager().addReference(best);
|
||||
return Pair.of(bestPos, bestHolder);
|
||||
}
|
||||
|
||||
private static void addSanctuaryCandidates(SanctuaryChunkGenerator generator, List<Candidate> positions) {
|
||||
for (ExpansionIsland island : generator.source().islands()) {
|
||||
if (!nativeGeneration(island.generation()) || !island.status().equals("ready")) continue;
|
||||
for (var district : generator.lostCityPlan(island).districts()) addPosition(positions, district.startChunkX(), district.startChunkZ());
|
||||
}
|
||||
generator.heritagePlan19().sites().forEach(s -> addPosition(positions, s.startChunkX(), s.startChunkZ()));
|
||||
generator.heritagePlan19().segments().forEach(s -> addPosition(positions, s.startChunkX(), s.startChunkZ()));
|
||||
generator.ruinsPlan17().networks().forEach(s -> addPosition(positions, s.startChunkX(), s.startChunkZ()));
|
||||
generator.transitPlan21().modules().forEach(s -> addPosition(positions, s.startChunkX(), s.startChunkZ()));
|
||||
generator.undergroundHall22().networks().forEach(s -> addPosition(positions, s.startChunkX(), s.startChunkZ()));
|
||||
var mineral = generator.mineralSanctuary23();
|
||||
if (!mineral.isEmpty()) addPosition(positions, mineral.chamber().startChunkX(), mineral.chamber().startChunkZ());
|
||||
if (generator.rootGeneration() == 24) generator.aerialPlan24().sites()
|
||||
.forEach(site -> addPosition(positions, site.startChunkX(), site.startChunkZ()));
|
||||
}
|
||||
private static void addPosition(List<Candidate> positions, int x, int z) { positions.add(new Candidate(new ChunkPos(x, z), 0)); }
|
||||
private static BlockPos locator(StructureStart start, BlockPos origin) {
|
||||
var entrances = new ArrayList<StructurePiece>();
|
||||
for (StructurePiece piece : start.getPieces()) {
|
||||
if (piece instanceof fr.koka.sanctuary.worldgen.city.LostCityUndergroundPiece20 room
|
||||
&& room.module().kind() == fr.koka.sanctuary.worldgen.city.LostCityUnderground16.Kind.ACCESS) entrances.add(piece);
|
||||
if (piece instanceof fr.koka.sanctuary.worldgen.transit.TransitPiece21 tunnel
|
||||
&& tunnel.module().kind() == fr.koka.sanctuary.worldgen.transit.TransitPlan21.Kind.ACCESS) entrances.add(piece);
|
||||
if (piece instanceof fr.koka.sanctuary.worldgen.ruins.RuinsPiece20 room
|
||||
&& room.room().kind() == fr.koka.sanctuary.worldgen.ruins.RuinsPlan17.Kind.ACCESS) entrances.add(piece);
|
||||
}
|
||||
return entrances.stream().map(StructurePiece::getLocatorPosition).min(Comparator.comparingDouble(origin::distSqr))
|
||||
.orElseGet(() -> start.getPieces().getFirst().getLocatorPosition());
|
||||
}
|
||||
|
||||
private static boolean undergroundPortal(StructureStart start) {
|
||||
if (!(start.getPieces().getFirst() instanceof net.minecraft.world.level.levelgen.structure.structures.RuinedPortalPiece portal)) return false;
|
||||
var placement = ((fr.koka.sanctuary.mixin.RuinedPortal23Accessor) portal).sanctuary$verticalPlacement();
|
||||
return placement == net.minecraft.world.level.levelgen.structure.structures.RuinedPortalPiece.VerticalPlacement.UNDERGROUND
|
||||
|| placement == net.minecraft.world.level.levelgen.structure.structures.RuinedPortalPiece.VerticalPlacement.IN_MOUNTAIN;
|
||||
}
|
||||
|
||||
private static boolean sizeEligible(Entry entry, ExpansionIsland island) {
|
||||
return switch (entry.family()) {
|
||||
case "mansion", "trial_chambers", "stronghold" -> island.diameter() >= 256;
|
||||
case "village", "monument" -> island.diameter() >= 256;
|
||||
default -> true;
|
||||
};
|
||||
}
|
||||
private static int weight(String family) {
|
||||
return switch (family) { case "camp" -> 6; case "ruined_portal", "mineshaft", "ocean_ruin" -> 3;
|
||||
case "village", "shipwreck", "trail_ruins", "buried_treasure", "swamp_hut" -> 2; default -> 1; };
|
||||
}
|
||||
private static int[] samples(int low, int high, int step) {
|
||||
var values = new java.util.TreeSet<Integer>(); values.add(low); values.add(high); values.add((low + high) / 2);
|
||||
for (int value = low; value <= high; value += step) values.add(value);
|
||||
return values.stream().mapToInt(Integer::intValue).toArray();
|
||||
}
|
||||
private static boolean inside(ExpansionIsland island, int x, int z, int margin) {
|
||||
return Math.hypot((double) x - island.centerX(), (double) z - island.centerZ()) < island.terrainRadius() - margin;
|
||||
}
|
||||
private static double horizontalDistanceSquared(BlockPos origin, int x, int z) { double dx = (double) x - origin.getX(), dz = (double) z - origin.getZ(); return dx * dx + dz * dz; }
|
||||
private static long mix(long value) { value = (value ^ value >>> 30) * 0xbf58476d1ce4e5b9L; value = (value ^ value >>> 27) * 0x94d049bb133111ebL; return value ^ value >>> 31; }
|
||||
private static void checkDeadline(long deadline) { if (System.nanoTime() > deadline) throw new IllegalArgumentException("search_timeout"); }
|
||||
private static void diagnostic(ExpansionIsland island, Candidate candidate, String reason, String id) {
|
||||
if (DIAGNOSTICS) SanctuaryMod.LOGGER.info("Native23 {} seed {} chunk {} {} {}", island.id(), island.seed(), candidate.chunk(), reason, id);
|
||||
}
|
||||
private record Choice(Entry entry, Holder<Structure> holder, double score) {}
|
||||
private static final class Ground {
|
||||
final NoiseColumn column; final int top; final int thickness;
|
||||
Ground(NoiseColumn column, int min, int max) { this(column, min, max, false); }
|
||||
Ground(NoiseColumn column, int min, int max, boolean waterSurface) {
|
||||
this.column = column; int y = max;
|
||||
while (y >= min && !column.getBlock(y).isSolid()
|
||||
&& !(waterSurface && column.getBlock(y).getFluidState().is(net.minecraft.tags.FluidTags.WATER))) y--;
|
||||
top = y;
|
||||
while (y >= min && top - y < 24 && solid(y)) y--;
|
||||
thickness = top - y;
|
||||
}
|
||||
boolean solid(int y) { var block = column.getBlock(y); return block.isSolid() && block.getFluidState().isEmpty(); }
|
||||
boolean solidNear(int y, int tolerance) { for (int dy = -tolerance; dy <= tolerance; dy++) if (solid(y + dy)) return true; return false; }
|
||||
}
|
||||
private static final class GroundSampler {
|
||||
final ExpansionChunkGenerator generator; final LevelHeightAccessor level; final RandomState random; final long deadline;
|
||||
final Integer localCeiling;
|
||||
final Map<Long, Ground> columns = new HashMap<>();
|
||||
fr.koka.sanctuary.worldgen.city.LostCityProtection16 localCity;
|
||||
GroundSampler(ExpansionChunkGenerator generator, LevelHeightAccessor level, RandomState random, long deadline) {
|
||||
this(generator, level, random, deadline, null);
|
||||
}
|
||||
GroundSampler(ExpansionChunkGenerator generator, LevelHeightAccessor level, RandomState random, long deadline, Integer localCeiling) {
|
||||
this.generator = generator; this.level = level; this.random = random; this.deadline = deadline;
|
||||
this.localCeiling = localCeiling;
|
||||
}
|
||||
Ground at(int x, int z) {
|
||||
long key = ((long) x << 32) ^ (z & 0xffffffffL);
|
||||
Ground old = columns.get(key); if (old != null) return old;
|
||||
checkDeadline(deadline);
|
||||
if (columns.size() >= MAX_COLUMN_SAMPLES) throw new SampleBudgetExceeded();
|
||||
Ground result = new Ground(generator.getBaseColumn(x, z, level, random), level.getMinY(),
|
||||
localCeiling == null ? level.getMaxY() : localCeiling, localCeiling != null);
|
||||
columns.put(key, result); return result;
|
||||
}
|
||||
}
|
||||
private static ExpansionBiomeSource isolatedSource(ExpansionChunkGenerator host, ExpansionIsland island, RegistryAccess registries) {
|
||||
ExpansionBiomeSource isolated;
|
||||
if (host.source() instanceof fr.koka.sanctuary.worldgen.SanctuaryBiomeSource source) {
|
||||
var copy = source.copy();
|
||||
if (host instanceof SanctuaryChunkGenerator sanctuary) copy.setCityPlans(Map.of(island.id(), sanctuary.lostCityPlan(island)));
|
||||
isolated = copy;
|
||||
} else {
|
||||
List<Holder<Biome>> biomes = registries.lookupOrThrow(Registries.BIOME).listElements().map(h -> (Holder<Biome>) h).toList();
|
||||
isolated = new ExpansionBiomeSource(biomes);
|
||||
}
|
||||
isolated.setIslands(List.of(island));
|
||||
return isolated;
|
||||
}
|
||||
|
||||
/** Isolated biome snapshot during preflight, per-island sea level during native generation. */
|
||||
private static final class NativeView extends ExpansionChunkGenerator {
|
||||
private final ExpansionChunkGenerator host; private final ExpansionIsland island;
|
||||
private Integer localCeiling;
|
||||
NativeView(ExpansionChunkGenerator host, ExpansionIsland island, ExpansionBiomeSource source, RegistryAccess registries) {
|
||||
super(source, host.initialDiameter(), true); this.host = host; this.island = island; this.registries = registries;
|
||||
}
|
||||
NativeView atHeight(int ceiling) {
|
||||
var result = new NativeView(host, island, source(), registries); result.localCeiling = ceiling; return result;
|
||||
}
|
||||
@Override public int rootGeneration() { return island.generation(); }
|
||||
@Override public Holder<Biome> structureBiome(Holder<Biome> biome) { return host.structureBiome(biome); }
|
||||
@Override public int getSeaLevel() { return ExpansionOcean23.active(island) ? ExpansionOcean23.seaLevel(island) : 192; }
|
||||
@Override public RandomState randomState(ExpansionIsland candidate) { return island.origin() ? host.randomState(candidate) : super.randomState(candidate); }
|
||||
@Override public int getBaseHeight(int x, int z, Heightmap.Types type, LevelHeightAccessor level, RandomState random) {
|
||||
if (localCeiling != null) {
|
||||
var column = getBaseColumn(x, z, level, random);
|
||||
for (int y = localCeiling; y >= level.getMinY(); y--) if (type.isOpaque().test(column.getBlock(y))) return y + 1;
|
||||
return level.getMinY();
|
||||
}
|
||||
return island.origin() ? host.getBaseHeight(x, z, type, level, random) : super.getBaseHeight(x, z, type, level, random);
|
||||
}
|
||||
@Override public NoiseColumn getBaseColumn(int x, int z, LevelHeightAccessor level, RandomState random) {
|
||||
return island.origin() ? host.getBaseColumn(x, z, level, random) : super.getBaseColumn(x, z, level, random);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,6 +86,9 @@ public final class ExpansionVoidReuse {
|
||||
if (!(level.getChunkSource().getGenerator() instanceof ExpansionChunkGenerator generator)
|
||||
|| !ExpansionIsland.spatialGeneration(generator.rootGeneration()) || island.generation() != generator.rootGeneration() || island.origin())
|
||||
throw new IOException("Void reuse is restricted to a matching generation-14/15 expansion");
|
||||
if (generator.rootGeneration() == 24 && generator instanceof fr.koka.sanctuary.worldgen.SanctuaryChunkGenerator sanctuary
|
||||
&& sanctuary.aerialPlan24().conflicts(island))
|
||||
throw new ExpansionAdmission.OccupiedException("aerial_reserved: expansion overlaps a permanent initial site");
|
||||
List<ChunkPos> positions = positions(island);
|
||||
var entityStorage = entityRegion(level);
|
||||
var poiStorage = ((ExpansionVoidPoiStorageAccess) level.getPoiManager()).sanctuary$simpleRegionStorage();
|
||||
@@ -173,6 +176,9 @@ public final class ExpansionVoidReuse {
|
||||
public static void open(ServerLevel level, ExpansionChunkGenerator generator, List<ExpansionIsland> islands) throws IOException {
|
||||
requireServerThread(level); close(level);
|
||||
if (!ExpansionIsland.spatialGeneration(generator.rootGeneration())) return;
|
||||
if (generator.rootGeneration() == 24 && generator instanceof fr.koka.sanctuary.worldgen.SanctuaryChunkGenerator sanctuary)
|
||||
for (var island : islands) if (sanctuary.aerialPlan24().conflicts(island))
|
||||
throw new IOException("Saved expansion overlaps a permanent aerial site: " + island.id());
|
||||
var state = new State();
|
||||
for (var island : islands) if (!island.reuseToken().isEmpty()) add(state, loadManifest(level, island));
|
||||
// Validate every transaction before writing even an EMPTY placeholder or publishing any island.
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package fr.koka.sanctuary.expansion;
|
||||
|
||||
import fr.koka.sanctuary.worldgen.PopulationHydrologyRuntime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.BiFunction;
|
||||
import net.minecraft.world.level.NoiseColumn;
|
||||
import net.minecraft.world.level.levelgen.structure.BoundingBox;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureStart;
|
||||
import net.minecraft.world.level.levelgen.structure.structures.MineshaftPieces;
|
||||
|
||||
/** Occupied native volumes, including potential wooden feet and suspension chains. No connecting-room infill. */
|
||||
public final class MineshaftAdmission29 {
|
||||
private MineshaftAdmission29() {}
|
||||
public static List<BoundingBox> volumes(StructureStart start, BiFunction<Integer, Integer, NoiseColumn> columns) {
|
||||
var result = new ArrayList<BoundingBox>();
|
||||
for (var piece : start.getPieces()) {
|
||||
var box = piece.getBoundingBox();
|
||||
result.add(body(box));
|
||||
if (piece instanceof MineshaftPieces.MineShaftCorridor) {
|
||||
var anchors = MineshaftSupport28.anchorVolumes(piece, columns);
|
||||
if (anchors == null) return null;
|
||||
result.addAll(anchors);
|
||||
}
|
||||
}
|
||||
return List.copyOf(result);
|
||||
}
|
||||
public static BoundingBox body(BoundingBox box) {
|
||||
return new BoundingBox(box.minX() - 2, box.minY() - 1, box.minZ() - 2,
|
||||
box.maxX() + 2, box.maxY() + 2, box.maxZ() + 2);
|
||||
}
|
||||
public static boolean intersects(List<BoundingBox> volumes, BoundingBox other) {
|
||||
return volumes.stream().anyMatch(box -> box.intersects(other));
|
||||
}
|
||||
/** Same protected beds, sources and flow margins as SanctuaryDecorationProtection, queried as a rectangle. */
|
||||
public static boolean hydrology(PopulationHydrologyRuntime.RegionPlan region, BoundingBox box) {
|
||||
var water = region.water(); var lava = region.lava();
|
||||
for (int x = box.minX() - 1; x <= box.maxX() + 1; x++) for (int z = box.minZ() - 1; z <= box.maxZ() + 1; z++)
|
||||
for (var cell : water.cellsAt(x, z))
|
||||
if (box.minY() <= cell.carveTop() + 1 && box.maxY() >= cell.bedY() - cell.sedimentDepth() - 2) return true;
|
||||
for (var spring : water.springs()) {
|
||||
var b = spring.flowBounds();
|
||||
if (intersects(box, b.minX()-2,b.minY()-2,b.minZ()-2,b.maxX()+2,b.maxY()+2,b.maxZ()+2)) return true;
|
||||
var p = spring.source();
|
||||
if (intersects(box,p.x()-3,p.y()-3,p.z()-3,p.x()+3,p.y()+3,p.z()+3)) return true;
|
||||
}
|
||||
for (var b : lava.flowBounds())
|
||||
if (intersects(box,b.minX()-8,b.minY()-8,b.minZ()-8,b.maxX()+8,b.maxY()+8,b.maxZ()+8)) return true;
|
||||
for (var spill : water.spills()) {
|
||||
var b = spill.flowBounds();
|
||||
if (intersects(box,b.minX()-3,b.minY()-3,b.minZ()-3,b.maxX()+3,b.maxY()+3,b.maxZ()+3)) return true;
|
||||
}
|
||||
for (var p : lava.cells()) if (intersects(box,p.x()-2,p.y()-2,p.z()-2,p.x()+2,p.y()+2,p.z()+2)) return true;
|
||||
for (var p : lava.supports()) if (intersects(box,p.x()-2,p.y()-2,p.z()-2,p.x()+2,p.y()+2,p.z()+2)) return true;
|
||||
return false;
|
||||
}
|
||||
private static boolean intersects(BoundingBox b, int minX,int minY,int minZ,int maxX,int maxY,int maxZ) {
|
||||
return b.minX()<=maxX && b.maxX()>=minX && b.minY()<=maxY && b.maxY()>=minY && b.minZ()<=maxZ && b.maxZ()>=minZ;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package fr.koka.sanctuary.expansion;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.BiFunction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.EmptyBlockGetter;
|
||||
import net.minecraft.world.level.NoiseColumn;
|
||||
import net.minecraft.world.level.levelgen.Heightmap;
|
||||
import net.minecraft.world.level.levelgen.structure.BoundingBox;
|
||||
import net.minecraft.world.level.levelgen.structure.StructurePiece;
|
||||
import net.minecraft.world.level.levelgen.structure.structures.MineshaftPieces;
|
||||
|
||||
/** Native crossings have a plank floor; their optional interior pillars do not require a close rock roof. */
|
||||
public final class MineshaftCrossing29 {
|
||||
private MineshaftCrossing29() {}
|
||||
public static String rejection(StructurePiece crossing, List<StructurePiece> pieces,
|
||||
BiFunction<Integer, Integer, NoiseColumn> columns, int maxY) {
|
||||
var box = crossing.getBoundingBox();
|
||||
boolean needsCarriedConnection = false;
|
||||
int floorY = box.minY() - 1;
|
||||
for (int x = box.minX(); x <= box.maxX(); x++) for (int z = box.minZ(); z <= box.maxZ(); z++) {
|
||||
var column = columns.apply(x, z); var floor = column.getBlock(floorY);
|
||||
if (!floor.getFluidState().isEmpty()) return "mineshaft-crossing-wet-floor";
|
||||
if (floor.isFaceSturdy(EmptyBlockGetter.INSTANCE, new BlockPos(x, floorY, z), Direction.UP)) continue;
|
||||
needsCarriedConnection = true;
|
||||
// StructurePiece.isInterior tests floorY+1 against OCEAN_FLOOR_WG. Only count
|
||||
// opaque terrain above the crossing's excavated body, so its own carving cannot remove it.
|
||||
boolean interior = false;
|
||||
for (int y = box.maxY() + 1; y < maxY; y++) if (Heightmap.Types.OCEAN_FLOOR_WG.isOpaque().test(column.getBlock(y))) {
|
||||
interior = true; break;
|
||||
}
|
||||
if (!interior) return "mineshaft-crossing-unplaceable-floor";
|
||||
}
|
||||
// A wholly natural floor already carries itself. A new plank bridge borrows an actual
|
||||
// adjacent corridor's certified support, never a distant or merely overlapping box.
|
||||
if (needsCarriedConnection && pieces.stream().noneMatch(piece -> piece instanceof MineshaftPieces.MineShaftCorridor
|
||||
&& joins(box, piece) && MineshaftSupport28.anchorVolumes(piece, columns) != null))
|
||||
return "mineshaft-crossing-no-carried-connection";
|
||||
return null;
|
||||
}
|
||||
private static boolean joins(BoundingBox crossing, StructurePiece corridor) {
|
||||
var box = corridor.getBoundingBox();
|
||||
if (box.minY() != crossing.minY()) return false;
|
||||
if (corridor.getOrientation().getAxis() == Direction.Axis.X)
|
||||
return (box.maxX() + 1 == crossing.minX() || crossing.maxX() + 1 == box.minX())
|
||||
&& Math.min(box.maxZ(), crossing.maxZ()) - Math.max(box.minZ(), crossing.minZ()) + 1 >= 3;
|
||||
return (box.maxZ() + 1 == crossing.minZ() || crossing.maxZ() + 1 == box.minZ())
|
||||
&& Math.min(box.maxX(), crossing.maxX()) - Math.max(box.minX(), crossing.minX()) + 1 >= 3;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package fr.koka.sanctuary.expansion;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.function.BiFunction;
|
||||
import net.minecraft.world.level.NoiseColumn;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureStart;
|
||||
import net.minecraft.world.level.levelgen.structure.structures.MineshaftPieces;
|
||||
|
||||
/** Coarse vertical search in the actual native graph, before unchanged detailed admission. */
|
||||
public final class MineshaftHeights29 {
|
||||
public static final int MAX_COLUMNS = 32;
|
||||
public record Probe(NoiseColumn column, int floorOffset, int roofOffset, boolean corridor) {}
|
||||
private record Score(int y, int covered, int direct, int distance) {}
|
||||
private MineshaftHeights29() {}
|
||||
|
||||
public static List<Integer> heights(StructureStart start, int preferred, int minY, int maxY,
|
||||
BiFunction<Integer, Integer, NoiseColumn> columns) {
|
||||
var pieces = start.getPieces(); var total = start.getBoundingBox();
|
||||
int originY = (total.minY() + total.maxY()) / 2;
|
||||
int count = Math.min(MAX_COLUMNS, pieces.size());
|
||||
var probes = new ArrayList<Probe>(count);
|
||||
for (int i = 0; i < count; i++) {
|
||||
var piece = pieces.get(count == 1 ? 0 : i * (pieces.size() - 1) / (count - 1));
|
||||
var box = piece.getBoundingBox(); var center = box.getCenter();
|
||||
probes.add(new Probe(columns.apply(center.getX(), center.getZ()), box.minY() - 1 - originY,
|
||||
box.maxY() + 1 - originY, piece instanceof MineshaftPieces.MineShaftCorridor));
|
||||
}
|
||||
return choose(probes, preferred, minY + 3 + originY - total.minY(), maxY - 4 - total.maxY() + originY);
|
||||
}
|
||||
|
||||
/** At most96 sampled levels in a384-block world; three native trials, not three new graphs per level. */
|
||||
public static List<Integer> choose(List<Probe> probes, int preferred, int minY, int maxY) {
|
||||
var scores = new ArrayList<Score>();
|
||||
for (int y = Math.floorDiv(minY + 3, 4) * 4; y <= maxY; y += 4) {
|
||||
int covered = 0, direct = 0;
|
||||
for (var probe : probes) {
|
||||
int floor = y + probe.floorOffset(), roof = y + probe.roofOffset();
|
||||
boolean floorMass = solid(probe.column(), floor), roofMass = solid(probe.column(), roof);
|
||||
boolean supported = probe.corridor()
|
||||
? floorMass || anchor(probe.column(), floor - 1, floor - 20, -1)
|
||||
|| anchor(probe.column(), roof, floor + 50, 1)
|
||||
: near(probe.column(), floor, 6) && near(probe.column(), roof, 6);
|
||||
if (supported) covered++;
|
||||
if (floorMass) direct++;
|
||||
if (roofMass) direct++;
|
||||
}
|
||||
if (covered > 0) scores.add(new Score(y, covered, direct, Math.abs(y - preferred)));
|
||||
}
|
||||
scores.sort(Comparator.comparingInt(Score::covered).reversed()
|
||||
.thenComparing(Comparator.comparingInt(Score::direct).reversed())
|
||||
.thenComparingInt(Score::distance).thenComparingInt(Score::y));
|
||||
var chosen = new ArrayList<Integer>(3);
|
||||
for (var score : scores) {
|
||||
if (chosen.stream().anyMatch(y -> Math.abs(y - score.y()) < 8)) continue;
|
||||
chosen.add(score.y()); if (chosen.size() == 3) break;
|
||||
}
|
||||
return List.copyOf(chosen);
|
||||
}
|
||||
private static boolean solid(NoiseColumn column, int y) {
|
||||
var state = column.getBlock(y); return state.isSolid() && state.getFluidState().isEmpty();
|
||||
}
|
||||
private static boolean near(NoiseColumn column, int y, int reach) {
|
||||
for (int offset = -reach; offset <= reach; offset++) if (solid(column, y + offset)) return true;
|
||||
return false;
|
||||
}
|
||||
private static boolean anchor(NoiseColumn column, int from, int to, int step) {
|
||||
for (int y = from; step > 0 ? y <= to : y >= to; y += step) {
|
||||
if (!column.getBlock(y).getFluidState().isEmpty()) return false;
|
||||
if (solid(column, y)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package fr.koka.sanctuary.expansion;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
import net.minecraft.world.level.NoiseColumn;
|
||||
import net.minecraft.world.level.levelgen.structure.StructurePiece;
|
||||
|
||||
/** Certifies the support positions actually used by vanilla MineShaftCorridor, not a percentage of nearby rock. */
|
||||
public final class MineshaftSupport28 {
|
||||
private MineshaftSupport28() {}
|
||||
public static boolean anchored(StructurePiece piece, BiFunction<Integer, Integer, NoiseColumn> columns) {
|
||||
return anchorVolumes(piece, columns, false) != null;
|
||||
}
|
||||
/** Protect the nearer usable native anchor; downward wins an equal-distance tie. */
|
||||
public static java.util.List<net.minecraft.world.level.levelgen.structure.BoundingBox> anchorVolumes(StructurePiece piece,
|
||||
BiFunction<Integer, Integer, NoiseColumn> columns) {
|
||||
return anchorVolumes(piece, columns, true);
|
||||
}
|
||||
private static java.util.List<net.minecraft.world.level.levelgen.structure.BoundingBox> anchorVolumes(StructurePiece piece,
|
||||
BiFunction<Integer, Integer, NoiseColumn> columns, boolean allowDirectFloor) {
|
||||
var volumes = new java.util.ArrayList<net.minecraft.world.level.levelgen.structure.BoundingBox>();
|
||||
var box = piece.getBoundingBox();
|
||||
int length = piece.getOrientation().getAxis() == net.minecraft.core.Direction.Axis.Z ? box.getZSpan() : box.getXSpan();
|
||||
for (int z : length > 5 ? new int[]{2, length - 3} : new int[]{2}) {
|
||||
int sectionAnchors = volumes.size();
|
||||
for (int x : new int[]{0, 2}) {
|
||||
var pier = SwampHutPlacement28.worldPosition(piece, x, -1, z);
|
||||
var column = columns.apply(pier.getX(), pier.getZ());
|
||||
var floor = column.getBlock(pier.getY());
|
||||
// Vanilla setPlanksBlock retains a sturdy natural floor. Only a floor plank subsequently
|
||||
// invokes placeDoubleLowerOrUpperSupport, so a rock ledge needs no distant anchor.
|
||||
if (allowDirectFloor && floor.getFluidState().isEmpty()
|
||||
&& !floor.is(net.minecraft.world.level.block.Blocks.OAK_PLANKS)
|
||||
&& !floor.is(net.minecraft.world.level.block.Blocks.DARK_OAK_PLANKS)
|
||||
&& floor.isFaceSturdy(net.minecraft.world.level.EmptyBlockGetter.INSTANCE, pier, net.minecraft.core.Direction.UP)) {
|
||||
volumes.add(new net.minecraft.world.level.levelgen.structure.BoundingBox(pier));
|
||||
continue;
|
||||
}
|
||||
Integer below = null, above = null;
|
||||
// Native wooden support searches at most20 below its floor plank.
|
||||
for (int y = pier.getY() - 1; y >= pier.getY() - 20; y--) {
|
||||
var state = column.getBlock(y);
|
||||
if (!state.getFluidState().isEmpty()) break;
|
||||
if (state.isSolid()) {
|
||||
below = y; break;
|
||||
}
|
||||
}
|
||||
// Its alternative is a chain up to50 blocks, anchored above the excavated corridor.
|
||||
for (int y = box.maxY() + 1; y <= pier.getY() + 50; y++) {
|
||||
var state = column.getBlock(y);
|
||||
if (!state.getFluidState().isEmpty()) break;
|
||||
if (state.isSolid()) {
|
||||
above = y; break;
|
||||
}
|
||||
}
|
||||
if (below == null && above == null) {
|
||||
if (!allowDirectFloor) return null;
|
||||
// Vanilla simply omits this optional pillar/chain. The other side of the same
|
||||
// transverse section can still carry the corridor; both ends must remain anchored.
|
||||
continue;
|
||||
}
|
||||
if (below != null && (above == null || pier.getY() - below <= above - pier.getY()))
|
||||
volumes.add(new net.minecraft.world.level.levelgen.structure.BoundingBox(pier.getX(), below, pier.getZ(), pier.getX(), pier.getY(), pier.getZ()));
|
||||
else volumes.add(new net.minecraft.world.level.levelgen.structure.BoundingBox(pier.getX(), pier.getY(), pier.getZ(), pier.getX(), above, pier.getZ()));
|
||||
}
|
||||
if (volumes.size() == sectionAnchors) {
|
||||
if (allowDirectFloor && Boolean.getBoolean("sanctuary.expansion.structureDiagnostics"))
|
||||
fr.koka.sanctuary.SanctuaryMod.LOGGER.info("Native29 mine unanchored section: piece {} facing {} localZ {} floorY {}",
|
||||
box, piece.getOrientation(), z, box.minY() - 1);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return java.util.List.copyOf(volumes);
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package fr.koka.sanctuary.expansion;
|
||||
|
||||
/** Optional metadata on native starts, absent on all historical and ordinary Minecraft starts. */
|
||||
public interface NativeStructureMetadata23 {
|
||||
record Data(long islandSeed, int seaLevel) {}
|
||||
Data sanctuary$native23();
|
||||
void sanctuary$native23(Data data);
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package fr.koka.sanctuary.expansion;
|
||||
|
||||
import fr.koka.sanctuary.mixin.MonumentChildren23Accessor;
|
||||
import net.minecraft.world.level.levelgen.structure.StructurePiece;
|
||||
import net.minecraft.world.level.levelgen.structure.structures.OceanMonumentPieces;
|
||||
|
||||
/** Scoped native placement parameters; never change the sea level of another dimension or start. */
|
||||
public final class NativeStructurePlacement23 {
|
||||
private static final ThreadLocal<Integer> SEA_LEVEL = new ThreadLocal<>();
|
||||
public record HutScope(java.util.List<net.minecraft.core.BlockPos> piers,
|
||||
java.util.List<net.minecraft.world.level.levelgen.structure.BoundingBox> bodies) {}
|
||||
private static final ThreadLocal<HutScope> HUT = new ThreadLocal<>();
|
||||
private NativeStructurePlacement23() {}
|
||||
public static Integer seaLevel() { return SEA_LEVEL.get(); }
|
||||
public static Integer enter(int seaLevel) { Integer previous = SEA_LEVEL.get(); SEA_LEVEL.set(seaLevel); return previous; }
|
||||
public static void restore(Integer previous) { if (previous == null) SEA_LEVEL.remove(); else SEA_LEVEL.set(previous); }
|
||||
public static HutScope enterHut(net.minecraft.world.level.levelgen.structure.StructureStart start) {
|
||||
var previous = HUT.get();
|
||||
var pieces = start.getPieces().stream().filter(net.minecraft.world.level.levelgen.structure.structures.SwampHutPiece.class::isInstance).toList();
|
||||
HUT.set(new HutScope(pieces.stream().flatMap(piece -> SwampHutPlacement28.piers(piece).stream()).toList(),
|
||||
pieces.stream().map(StructurePiece::getBoundingBox).toList()));
|
||||
return previous;
|
||||
}
|
||||
public static void restoreHut(HutScope previous) {
|
||||
if (previous == null) HUT.remove(); else HUT.set(previous);
|
||||
}
|
||||
public static boolean allowsHutWrite(net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state,
|
||||
net.minecraft.world.level.block.state.BlockState replaced) {
|
||||
var scope = HUT.get(); if (scope == null) return false;
|
||||
// Native construction in already empty air above a certified bank does not cut its retaining bed.
|
||||
if (replaced.isAir() && scope.bodies().stream().anyMatch(box -> box.isInside(pos))) return true;
|
||||
if (!state.is(net.minecraft.world.level.block.Blocks.OAK_LOG)
|
||||
|| !(replaced.isAir() || replaced.getFluidState().isSource()
|
||||
&& replaced.getFluidState().is(net.minecraft.tags.FluidTags.WATER))) return false;
|
||||
return scope.piers().stream().anyMatch(pier -> pier.getX() == pos.getX() && pier.getZ() == pos.getZ()
|
||||
&& pos.getY() <= pier.getY() && pos.getY() > pier.getY() - SwampHutPlacement28.MAX_PIER_DROP);
|
||||
}
|
||||
public static void move(StructurePiece piece, int dy) {
|
||||
if (piece instanceof OceanMonumentPieces.MonumentBuilding monument) {
|
||||
for (StructurePiece child : ((MonumentChildren23Accessor) monument).sanctuary$children()) child.move(0, dy, 0);
|
||||
}
|
||||
piece.move(0, dy, 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package fr.koka.sanctuary.expansion;
|
||||
|
||||
import fr.koka.sanctuary.worldgen.PopulationHydrology;
|
||||
import fr.koka.sanctuary.worldgen.PopulationHydrologyRuntime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.BiFunction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.NoiseColumn;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.levelgen.structure.BoundingBox;
|
||||
import net.minecraft.world.level.levelgen.structure.StructurePiece;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureStart;
|
||||
import net.minecraft.world.level.levelgen.structure.structures.SwampHutPiece;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
|
||||
/** Native hut geometry on a real shallow bank, including banks below another island floor. */
|
||||
public final class SwampHutPlacement28 {
|
||||
public static final int MAX_PIER_DROP = 8;
|
||||
private SwampHutPlacement28() {}
|
||||
|
||||
public static String rejection(StructureStart start, BiFunction<Integer, Integer, NoiseColumn> columns) {
|
||||
for (var piece : start.getPieces()) {
|
||||
if (!(piece instanceof SwampHutPiece)) return "hut-unexpected-piece";
|
||||
var box = piece.getBoundingBox();
|
||||
for (int x = box.minX(); x <= box.maxX(); x++) for (int z = box.minZ(); z <= box.maxZ(); z++) {
|
||||
var column = columns.apply(x, z);
|
||||
int waterTop = Integer.MIN_VALUE, waterBottom = Integer.MAX_VALUE;
|
||||
for (int y = box.minY() - MAX_PIER_DROP; y <= box.maxY(); y++) {
|
||||
var state = column.getBlock(y); var fluid = state.getFluidState();
|
||||
if (y >= box.minY() + 2 && !state.isAir()) return "hut-natural-headroom";
|
||||
if (fluid.isEmpty()) continue;
|
||||
if (fluid.getType() != Fluids.WATER || !fluid.isSource()) return "hut-flowing-or-nonwater";
|
||||
waterTop = Math.max(waterTop, y); waterBottom = Math.min(waterBottom, y);
|
||||
}
|
||||
if (waterTop != Integer.MIN_VALUE) {
|
||||
if (waterTop > box.minY() || waterTop - waterBottom + 1 > 4) return "hut-deep-water";
|
||||
if (!solid(column.getBlock(waterBottom - 1)) || !solid(column.getBlock(waterBottom - 2))) return "hut-unsealed-bed";
|
||||
}
|
||||
}
|
||||
for (var pier : piers(piece)) {
|
||||
var column = columns.apply(pier.getX(), pier.getZ()); int y = pier.getY(), depth = 0;
|
||||
while (replaceable(column.getBlock(y)) && depth <= MAX_PIER_DROP) { y--; depth++; }
|
||||
if (depth > MAX_PIER_DROP || !solid(column.getBlock(y)) || !solid(column.getBlock(y - 1))) return "hut-unsupported-pier";
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Still water is compatible; springs, spills, channels and lava keep their protection. */
|
||||
public static String hydrologyRejection(PopulationHydrologyRuntime.RegionPlan region, BoundingBox box) {
|
||||
for (var spring : region.water().springs()) if (intersects(box, spring.flowBounds(), 3)) return "hut-protected-spring";
|
||||
for (var spill : region.water().spills()) if (intersects(box, spill.flowBounds(), 3)) return "hut-protected-spill";
|
||||
for (var flow : region.lava().flowBounds()) if (intersects(box, flow, 4)) return "hut-protected-lava";
|
||||
var rivers = region.water().features().stream().filter(f -> f.kind() == PopulationHydrology.Kind.RIVER)
|
||||
.map(PopulationHydrology.Feature::id).collect(java.util.stream.Collectors.toSet());
|
||||
for (int x = box.minX(); x <= box.maxX(); x++) for (int z = box.minZ(); z <= box.maxZ(); z++)
|
||||
for (var cell : region.water().cellsAt(x, z)) if (rivers.contains(cell.featureId())
|
||||
&& box.minY() <= cell.carveTop() && box.maxY() >= cell.bedY() - cell.sedimentDepth() - 1) return "hut-protected-river";
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Exact four support origins used by SwampHutPiece.postProcess. */
|
||||
public static List<BlockPos> piers(StructurePiece piece) {
|
||||
var result = new ArrayList<BlockPos>(4);
|
||||
for (int z : new int[]{2, 7}) for (int x : new int[]{1, 5}) result.add(worldPosition(piece, x, -1, z));
|
||||
return List.copyOf(result);
|
||||
}
|
||||
public static BlockPos worldPosition(StructurePiece piece, int x, int y, int z) {
|
||||
var b = piece.getBoundingBox(); Direction facing = piece.getOrientation();
|
||||
if (facing == null || facing.getAxis().isVertical()) throw new IllegalArgumentException("A hut requires horizontal orientation");
|
||||
int wx = switch (facing) { case WEST -> b.maxX() - z; case EAST -> b.minX() + z; default -> b.minX() + x; };
|
||||
int wz = switch (facing) { case NORTH -> b.maxZ() - z; case SOUTH -> b.minZ() + z; default -> b.minZ() + x; };
|
||||
return new BlockPos(wx, b.minY() + y, wz);
|
||||
}
|
||||
private static boolean solid(BlockState state) { return state.isSolid() && state.getFluidState().isEmpty(); }
|
||||
private static boolean replaceable(BlockState state) {
|
||||
return state.isAir() || state.liquid() || state.is(Blocks.GLOW_LICHEN) || state.is(Blocks.SEAGRASS) || state.is(Blocks.TALL_SEAGRASS);
|
||||
}
|
||||
private static boolean intersects(BoundingBox b, PopulationHydrology.FlowBounds flow, int margin) {
|
||||
return b.minX() <= flow.maxX() + margin && b.maxX() >= flow.minX() - margin
|
||||
&& b.minY() <= flow.maxY() + margin && b.maxY() >= flow.minY() - margin
|
||||
&& b.minZ() <= flow.maxZ() + margin && b.maxZ() >= flow.minZ() - margin;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package fr.koka.sanctuary.knowledge;
|
||||
|
||||
/** A server-side snapshot; mined and dropped are read from vanilla statistics. */
|
||||
public record BlockKnowledge(String blockId, boolean seen, boolean possessed,
|
||||
long mined, long dropped, long placed, int carried) {
|
||||
public BlockKnowledge {
|
||||
BlockKnowledgeMemory.requireBlockId(blockId);
|
||||
if (mined < 0 || dropped < 0 || placed < 0 || carried < 0) {
|
||||
throw new IllegalArgumentException("Block knowledge counters cannot be negative");
|
||||
}
|
||||
}
|
||||
|
||||
/** Unknown is the absence of all evidence, rather than another persisted flag. */
|
||||
public boolean known() {
|
||||
return seen || possessed || mined > 0 || dropped > 0 || placed > 0 || carried > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package fr.koka.sanctuary.knowledge;
|
||||
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
import net.fabricmc.fabric.api.event.EventFactory;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
/** Server-thread notifications for future consumers; not a durable reward ledger. */
|
||||
public final class BlockKnowledgeEvents {
|
||||
public enum Activity { SEEN, POSSESSED, MINED, DROPPED, PLACED, INVENTORY }
|
||||
|
||||
@FunctionalInterface
|
||||
public interface Changed {
|
||||
void onChanged(ServerPlayer player, BlockKnowledge knowledge, Activity activity);
|
||||
}
|
||||
|
||||
public static final Event<Changed> CHANGED = EventFactory.createArrayBacked(Changed.class,
|
||||
listeners -> (player, knowledge, activity) -> {
|
||||
for (Changed listener : listeners) listener.onChanged(player, knowledge, activity);
|
||||
});
|
||||
|
||||
private BlockKnowledgeEvents() {}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package fr.koka.sanctuary.knowledge;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/** Independent evidence predicates, composable with {@link Predicate#and} and {@link Predicate#or}. */
|
||||
public enum BlockKnowledgeFacet implements Predicate<BlockKnowledge> {
|
||||
KNOWN(BlockKnowledge::known),
|
||||
SEEN(BlockKnowledge::seen),
|
||||
MINED(knowledge -> knowledge.mined() > 0),
|
||||
POSSESSED(BlockKnowledge::possessed),
|
||||
DROPPED(knowledge -> knowledge.dropped() > 0),
|
||||
PLACED(knowledge -> knowledge.placed() > 0),
|
||||
CARRIED(knowledge -> knowledge.carried() > 0);
|
||||
|
||||
private final Predicate<BlockKnowledge> evidence;
|
||||
|
||||
BlockKnowledgeFacet(Predicate<BlockKnowledge> evidence) {
|
||||
this.evidence = evidence;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(BlockKnowledge knowledge) {
|
||||
return evidence.test(knowledge);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package fr.koka.sanctuary.knowledge;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** Only Sanctuary's evidence is stored here; vanilla statistics keep their ownership. */
|
||||
public final class BlockKnowledgeMemory {
|
||||
private static final Pattern BLOCK_ID = Pattern.compile("[a-z0-9_.-]+:[a-z0-9/._-]+");
|
||||
private static final Entry UNKNOWN = new Entry(false, false, 0);
|
||||
private final Map<String, Entry> entries = new HashMap<>();
|
||||
|
||||
public BlockKnowledgeMemory() { }
|
||||
|
||||
/** Restores stable identifiers without requiring the corresponding mod to be installed. */
|
||||
public static BlockKnowledgeMemory restored(Map<String, Entry> saved) {
|
||||
Objects.requireNonNull(saved, "saved");
|
||||
BlockKnowledgeMemory memory = new BlockKnowledgeMemory();
|
||||
saved.forEach((id, entry) -> {
|
||||
requireBlockId(id);
|
||||
memory.entries.put(id, Objects.requireNonNull(entry, "entry"));
|
||||
});
|
||||
return memory;
|
||||
}
|
||||
|
||||
public synchronized boolean recordSeen(String blockId) {
|
||||
Entry previous = entry(blockId);
|
||||
if (previous.seen()) return false;
|
||||
entries.put(blockId, new Entry(true, previous.possessed(), previous.placed()));
|
||||
return true;
|
||||
}
|
||||
|
||||
public synchronized boolean recordPossessed(String blockId) {
|
||||
Entry previous = entry(blockId);
|
||||
if (previous.possessed()) return false;
|
||||
entries.put(blockId, new Entry(previous.seen(), true, previous.placed()));
|
||||
return true;
|
||||
}
|
||||
|
||||
public synchronized void recordPlaced(String blockId) {
|
||||
Entry previous = entry(blockId);
|
||||
long placed = previous.placed() == Long.MAX_VALUE ? Long.MAX_VALUE : previous.placed() + 1;
|
||||
entries.put(blockId, new Entry(previous.seen(), previous.possessed(), placed));
|
||||
}
|
||||
|
||||
public synchronized Entry entry(String blockId) {
|
||||
requireBlockId(blockId);
|
||||
return entries.getOrDefault(blockId, UNKNOWN);
|
||||
}
|
||||
|
||||
/** A stable immutable snapshot, safe to expose to other mechanics. */
|
||||
public synchronized Map<String, Entry> entries() {
|
||||
return Map.copyOf(entries);
|
||||
}
|
||||
|
||||
static void requireBlockId(String blockId) {
|
||||
if (blockId == null || !BLOCK_ID.matcher(blockId).matches()) {
|
||||
throw new IllegalArgumentException("Invalid namespaced block identifier: " + blockId);
|
||||
}
|
||||
}
|
||||
|
||||
public record Entry(boolean seen, boolean possessed, long placed) {
|
||||
public Entry {
|
||||
if (placed < 0) throw new IllegalArgumentException("Placed count cannot be negative");
|
||||
}
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
package fr.koka.sanctuary.knowledge;
|
||||
|
||||
import fr.koka.sanctuary.SanctuaryMod;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
/** The client can only ask for its own server-maintained state. */
|
||||
public final class BlockKnowledgeNetworking {
|
||||
private static final Map<ServerPlayer, Long> LAST_REQUEST = new WeakHashMap<>();
|
||||
private static final long REQUEST_INTERVAL_NANOS = 1_000_000_000L;
|
||||
|
||||
private BlockKnowledgeNetworking() { }
|
||||
|
||||
public static void register() {
|
||||
PayloadTypeRegistry.serverboundPlay().register(BlockKnowledgePayloads.Request.TYPE, BlockKnowledgePayloads.Request.CODEC);
|
||||
PayloadTypeRegistry.clientboundPlay().register(BlockKnowledgePayloads.SnapshotPart.TYPE, BlockKnowledgePayloads.SnapshotPart.CODEC);
|
||||
ServerPlayNetworking.registerGlobalReceiver(BlockKnowledgePayloads.Request.TYPE, (request, context) ->
|
||||
context.server().execute(() -> respond(context.player(), request.requestId())));
|
||||
}
|
||||
|
||||
private static void respond(ServerPlayer player, int requestId) {
|
||||
if (!ServerPlayNetworking.canSend(player, BlockKnowledgePayloads.SnapshotPart.TYPE)) return;
|
||||
long now = System.nanoTime();
|
||||
synchronized (LAST_REQUEST) {
|
||||
Long previous = LAST_REQUEST.get(player);
|
||||
if (previous != null && now - previous < REQUEST_INTERVAL_NANOS) return;
|
||||
LAST_REQUEST.put(player, now);
|
||||
}
|
||||
|
||||
try {
|
||||
if (!BlockKnowledgeService.healthy(player)) {
|
||||
unavailable(player, requestId);
|
||||
return;
|
||||
}
|
||||
List<BlockKnowledge> snapshot = List.copyOf(BlockKnowledgeService.snapshot(player));
|
||||
if (snapshot.size() > BlockKnowledgePayloads.MAX_ENTRIES) {
|
||||
unavailable(player, requestId);
|
||||
return;
|
||||
}
|
||||
// Validate before sending any fragment: a snapshot is all-or-nothing at the client.
|
||||
snapshot.forEach(BlockKnowledgePayloads::validateEntry);
|
||||
int parts = Math.max(1, (snapshot.size() + BlockKnowledgePayloads.FRAGMENT_SIZE - 1)
|
||||
/ BlockKnowledgePayloads.FRAGMENT_SIZE);
|
||||
for (int part = 0; part < parts; part++) {
|
||||
int start = part * BlockKnowledgePayloads.FRAGMENT_SIZE;
|
||||
int end = Math.min(start + BlockKnowledgePayloads.FRAGMENT_SIZE, snapshot.size());
|
||||
ServerPlayNetworking.send(player, new BlockKnowledgePayloads.SnapshotPart(requestId, part, parts,
|
||||
snapshot.size(), true, snapshot.subList(start, end)));
|
||||
}
|
||||
} catch (RuntimeException failure) {
|
||||
SanctuaryMod.LOGGER.error("Unable to send Blocodex snapshot", failure);
|
||||
unavailable(player, requestId);
|
||||
}
|
||||
}
|
||||
|
||||
private static void unavailable(ServerPlayer player, int requestId) {
|
||||
ServerPlayNetworking.send(player, new BlockKnowledgePayloads.SnapshotPart(requestId, 0, 1, 0, false, List.of()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package fr.koka.sanctuary.knowledge;
|
||||
|
||||
import fr.koka.sanctuary.SanctuaryMod;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.resources.Identifier;
|
||||
|
||||
/** Read-only requests and bounded fragments of a single server snapshot. */
|
||||
public final class BlockKnowledgePayloads {
|
||||
public static final int FRAGMENT_SIZE = 128;
|
||||
public static final int MAX_ENTRIES = 32_768;
|
||||
public static final int MAX_ID_LENGTH = 256;
|
||||
|
||||
private BlockKnowledgePayloads() { }
|
||||
|
||||
public record Request(int requestId) implements CustomPacketPayload {
|
||||
public static final Type<Request> TYPE = new Type<>(SanctuaryMod.id("blocodex_request"));
|
||||
public static final StreamCodec<RegistryFriendlyByteBuf, Request> CODEC =
|
||||
CustomPacketPayload.codec((request, buffer) -> buffer.writeVarInt(request.requestId()),
|
||||
buffer -> new Request(buffer.readVarInt()));
|
||||
|
||||
@Override
|
||||
public Type<Request> type() { return TYPE; }
|
||||
}
|
||||
|
||||
public record SnapshotPart(int requestId, int partIndex, int partCount, int totalEntries,
|
||||
boolean healthy, List<BlockKnowledge> entries) implements CustomPacketPayload {
|
||||
public static final Type<SnapshotPart> TYPE = new Type<>(SanctuaryMod.id("blocodex_snapshot"));
|
||||
public static final StreamCodec<RegistryFriendlyByteBuf, SnapshotPart> CODEC =
|
||||
CustomPacketPayload.codec(SnapshotPart::write, SnapshotPart::read);
|
||||
|
||||
public SnapshotPart {
|
||||
entries = List.copyOf(entries);
|
||||
if (totalEntries < 0 || totalEntries > MAX_ENTRIES
|
||||
|| partCount != Math.max(1, (totalEntries + FRAGMENT_SIZE - 1) / FRAGMENT_SIZE)
|
||||
|| partIndex < 0 || partIndex >= partCount
|
||||
|| entries.size() != Math.min(FRAGMENT_SIZE, totalEntries - partIndex * FRAGMENT_SIZE)
|
||||
|| (!healthy && totalEntries != 0)) {
|
||||
throw new IllegalArgumentException("Invalid Blocodex snapshot fragment");
|
||||
}
|
||||
for (BlockKnowledge entry : entries) validateEntry(entry);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type<SnapshotPart> type() { return TYPE; }
|
||||
|
||||
private void write(RegistryFriendlyByteBuf buffer) {
|
||||
buffer.writeVarInt(requestId);
|
||||
buffer.writeVarInt(partIndex);
|
||||
buffer.writeVarInt(partCount);
|
||||
buffer.writeVarInt(totalEntries);
|
||||
buffer.writeBoolean(healthy);
|
||||
buffer.writeVarInt(entries.size());
|
||||
for (BlockKnowledge entry : entries) {
|
||||
buffer.writeUtf(entry.blockId(), MAX_ID_LENGTH);
|
||||
buffer.writeBoolean(entry.seen());
|
||||
buffer.writeBoolean(entry.possessed());
|
||||
buffer.writeVarLong(entry.mined());
|
||||
buffer.writeVarLong(entry.dropped());
|
||||
buffer.writeVarLong(entry.placed());
|
||||
buffer.writeVarInt(entry.carried());
|
||||
}
|
||||
}
|
||||
|
||||
private static SnapshotPart read(RegistryFriendlyByteBuf buffer) {
|
||||
int request = buffer.readVarInt();
|
||||
int index = buffer.readVarInt();
|
||||
int parts = buffer.readVarInt();
|
||||
int total = buffer.readVarInt();
|
||||
boolean healthy = buffer.readBoolean();
|
||||
int size = buffer.readVarInt();
|
||||
if (size < 0 || size > FRAGMENT_SIZE) throw new IllegalArgumentException("Oversized Blocodex fragment");
|
||||
List<BlockKnowledge> entries = new ArrayList<>(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
entries.add(new BlockKnowledge(buffer.readUtf(MAX_ID_LENGTH), buffer.readBoolean(), buffer.readBoolean(),
|
||||
buffer.readVarLong(), buffer.readVarLong(), buffer.readVarLong(), buffer.readVarInt()));
|
||||
}
|
||||
return new SnapshotPart(request, index, parts, total, healthy, entries);
|
||||
}
|
||||
}
|
||||
|
||||
public static void validateEntry(BlockKnowledge entry) {
|
||||
if (entry.blockId().length() > MAX_ID_LENGTH || Identifier.tryParse(entry.blockId()) == null
|
||||
|| entry.mined() < 0 || entry.dropped() < 0 || entry.placed() < 0 || entry.carried() < 0) {
|
||||
throw new IllegalArgumentException("Invalid Blocodex entry");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,267 @@
|
||||
package fr.koka.sanctuary.knowledge;
|
||||
|
||||
import fr.koka.sanctuary.SanctuaryMod;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Predicate;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.stats.Stat;
|
||||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.ClipContext;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.storage.LevelResource;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
/**
|
||||
* Personal, world-local knowledge. All mutations and reads run on the server thread.
|
||||
* Vanilla owns mined/dropped counters; Sanctuary owns seen/possessed/placed history.
|
||||
*/
|
||||
public final class BlockKnowledgeService {
|
||||
public static final int OBSERVATION_INTERVAL = 5;
|
||||
public static final int SAVE_INTERVAL = 600;
|
||||
public static final double OBSERVATION_DISTANCE = 32;
|
||||
public static final TagKey<Block> NATURAL_STRUCTURE_MATERIALS = TagKey.create(Registries.BLOCK,
|
||||
SanctuaryMod.id("structure_palette/natural"));
|
||||
private static final Map<MinecraftServer, Map<UUID, Session>> SESSIONS = new IdentityHashMap<>();
|
||||
private static List<Block> catalog;
|
||||
|
||||
private BlockKnowledgeService() {}
|
||||
|
||||
public static void register() {
|
||||
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> observeInventory(handler.player));
|
||||
// Fabric also reaches DISCONNECT through Netty's channelInactive callback.
|
||||
ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> server.execute(() -> {
|
||||
Map<UUID, Session> sessions = SESSIONS.get(server);
|
||||
if (sessions == null) return;
|
||||
Session session = sessions.remove(handler.player.getUUID());
|
||||
if (session != null) save(session);
|
||||
}));
|
||||
ServerTickEvents.END_SERVER_TICK.register(server -> {
|
||||
for (ServerPlayer player : server.getPlayerList().getPlayers()) {
|
||||
observeInventory(player);
|
||||
if (Math.floorMod(server.getTickCount() + player.getId(), OBSERVATION_INTERVAL) == 0) observeLook(player);
|
||||
}
|
||||
if (server.getTickCount() % SAVE_INTERVAL == 0) flush(server);
|
||||
});
|
||||
ServerLifecycleEvents.BEFORE_SAVE.register((server, flush, force) -> flush(server));
|
||||
ServerLifecycleEvents.SERVER_STOPPING.register(BlockKnowledgeService::flush);
|
||||
ServerLifecycleEvents.SERVER_STOPPED.register(SESSIONS::remove);
|
||||
}
|
||||
|
||||
/** A failed history is explicitly unavailable, never an empty progression record. */
|
||||
public static boolean healthy(ServerPlayer player) { return !session(player).failed; }
|
||||
|
||||
public static List<BlockKnowledge> snapshot(ServerPlayer player) {
|
||||
observeInventory(player);
|
||||
Session session = requireHealthy(player);
|
||||
List<BlockKnowledge> result = new ArrayList<>(catalog().size());
|
||||
for (Block block : catalog()) result.add(value(player, block, session));
|
||||
return List.copyOf(result);
|
||||
}
|
||||
|
||||
public static BlockKnowledge knowledge(ServerPlayer player, Block block) {
|
||||
observeInventory(player);
|
||||
return value(player, block, requireHealthy(player));
|
||||
}
|
||||
|
||||
/**
|
||||
* Candidate materials for structures: combine knowledge facets with a data-pack material tag.
|
||||
* Retains current quantities but does not reserve/consume them or authorize world placement.
|
||||
*/
|
||||
public static List<BlockKnowledge> palette(ServerPlayer player, Predicate<BlockKnowledge> condition, TagKey<Block> materials) {
|
||||
Objects.requireNonNull(condition, "condition");
|
||||
Objects.requireNonNull(materials, "materials");
|
||||
return snapshot(player).stream().filter(condition)
|
||||
.filter(entry -> BuiltInRegistries.BLOCK.getValue(Identifier.parse(entry.blockId())).defaultBlockState().is(materials))
|
||||
.toList();
|
||||
}
|
||||
|
||||
public static void recordSeen(ServerPlayer player, Block block) {
|
||||
if (block.defaultBlockState().isAir() || player.isSpectator()) return;
|
||||
Session session = session(player);
|
||||
if (session.failed || !session.memory.recordSeen(id(block))) return;
|
||||
session.dirty = true;
|
||||
changed(player, block, session, BlockKnowledgeEvents.Activity.SEEN);
|
||||
}
|
||||
|
||||
/** Called after successful BlockItem placement, before its item is consumed. */
|
||||
public static void recordPlaced(ServerPlayer player, Block block) {
|
||||
if (block.defaultBlockState().isAir() || player.isSpectator()) return;
|
||||
observeInventory(player);
|
||||
Session session = session(player);
|
||||
if (session.failed) return;
|
||||
session.memory.recordPlaced(id(block));
|
||||
session.dirty = true;
|
||||
changed(player, block, session, BlockKnowledgeEvents.Activity.PLACED);
|
||||
}
|
||||
|
||||
/** Observes only personal slots and the carried cursor, never an open chest's contents. */
|
||||
public static void observeInventory(ServerPlayer player) {
|
||||
Session session = session(player);
|
||||
if (session.failed) return;
|
||||
Map<Block, Integer> current = inventory(player);
|
||||
Map<Block, Integer> previous = session.carried;
|
||||
session.carried = current;
|
||||
for (Block block : current.keySet()) {
|
||||
if (session.memory.recordPossessed(id(block))) {
|
||||
session.dirty = true;
|
||||
changed(player, block, session, BlockKnowledgeEvents.Activity.POSSESSED);
|
||||
}
|
||||
}
|
||||
if (!current.equals(previous)) {
|
||||
var changedBlocks = new HashSet<>(previous.keySet());
|
||||
changedBlocks.addAll(current.keySet());
|
||||
for (Block block : changedBlocks) {
|
||||
if (!current.getOrDefault(block, 0).equals(previous.getOrDefault(block, 0))) {
|
||||
changed(player, block, session, BlockKnowledgeEvents.Activity.INVENTORY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Called after vanilla updates a stat; does not award or mirror its counter. */
|
||||
public static void statChanged(ServerPlayer player, Stat<?> stat) {
|
||||
Block block;
|
||||
BlockKnowledgeEvents.Activity activity;
|
||||
if (stat.getType() == Stats.BLOCK_MINED && stat.getValue() instanceof Block mined) {
|
||||
block = mined;
|
||||
activity = BlockKnowledgeEvents.Activity.MINED;
|
||||
} else if ((stat.getType() == Stats.ITEM_DROPPED || stat.getType() == Stats.ITEM_PICKED_UP)
|
||||
&& stat.getValue() instanceof BlockItem item) {
|
||||
block = item.getBlock();
|
||||
activity = stat.getType() == Stats.ITEM_DROPPED ? BlockKnowledgeEvents.Activity.DROPPED : BlockKnowledgeEvents.Activity.POSSESSED;
|
||||
} else return;
|
||||
Session session = session(player);
|
||||
if (session.failed || block.defaultBlockState().isAir()) return;
|
||||
observeInventory(player);
|
||||
if (stat.getType() != Stats.BLOCK_MINED && player.getStats().getValue(stat) > 0
|
||||
&& session.memory.recordPossessed(id(block))) {
|
||||
session.dirty = true;
|
||||
changed(player, block, session, BlockKnowledgeEvents.Activity.POSSESSED);
|
||||
}
|
||||
if (activity != BlockKnowledgeEvents.Activity.POSSESSED) changed(player, block, session, activity);
|
||||
}
|
||||
|
||||
/** A single occluded gaze ray, with no requests for missing chunks. */
|
||||
public static void observeLook(ServerPlayer player) {
|
||||
if (player.isSpectator() || !player.isAlive() || !healthy(player)) return;
|
||||
Vec3 start = player.getEyePosition();
|
||||
Vec3 end = start.add(player.getLookAngle().scale(OBSERVATION_DISTANCE));
|
||||
if (!finite(start) || !finite(end)) return;
|
||||
// clip's shape queries may inspect neighbours. Reject absent neighbouring chunks too.
|
||||
int minX = ((int) Math.floor(Math.min(start.x, end.x) - 1)) >> 4;
|
||||
int maxX = ((int) Math.floor(Math.max(start.x, end.x) + 1)) >> 4;
|
||||
int minZ = ((int) Math.floor(Math.min(start.z, end.z) - 1)) >> 4;
|
||||
int maxZ = ((int) Math.floor(Math.max(start.z, end.z) + 1)) >> 4;
|
||||
for (int x = minX; x <= maxX; x++) for (int z = minZ; z <= maxZ; z++) {
|
||||
if (!player.level().getChunkSource().hasChunk(x, z)) return;
|
||||
}
|
||||
var hit = player.level().clip(new ClipContext(start, end, ClipContext.Block.OUTLINE, ClipContext.Fluid.ANY, player));
|
||||
if (hit.getType() == HitResult.Type.BLOCK) recordSeen(player, player.level().getBlockState(hit.getBlockPos()).getBlock());
|
||||
}
|
||||
|
||||
public static void flush(MinecraftServer server) {
|
||||
Map<UUID, Session> sessions = SESSIONS.get(server);
|
||||
if (sessions != null) sessions.values().forEach(BlockKnowledgeService::save);
|
||||
}
|
||||
|
||||
private static BlockKnowledge value(ServerPlayer player, Block block, Session session) {
|
||||
var history = session.memory.entry(id(block));
|
||||
var stats = player.getStats();
|
||||
long mined = Math.max(0, stats.getValue(Stats.BLOCK_MINED, block));
|
||||
long dropped = 0;
|
||||
boolean possessed = history.possessed();
|
||||
// Shared block items (e.g. wall/standing torch) must not duplicate possession/drop totals.
|
||||
if (block.asItem() instanceof BlockItem item && item.getBlock() == block) {
|
||||
dropped = Math.max(0, stats.getValue(Stats.ITEM_DROPPED, item));
|
||||
possessed |= dropped > 0 || stats.getValue(Stats.ITEM_PICKED_UP, item) > 0;
|
||||
}
|
||||
return new BlockKnowledge(id(block), history.seen(), possessed, mined, dropped, history.placed(), session.carried.getOrDefault(block, 0));
|
||||
}
|
||||
|
||||
private static Map<Block, Integer> inventory(ServerPlayer player) {
|
||||
Map<Block, Integer> result = new HashMap<>();
|
||||
for (int slot = 0; slot < player.getInventory().getContainerSize(); slot++) add(result, player.getInventory().getItem(slot));
|
||||
if (player.containerMenu != null) add(result, player.containerMenu.getCarried());
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void add(Map<Block, Integer> result, ItemStack stack) {
|
||||
if (!stack.isEmpty() && stack.getItem() instanceof BlockItem item && !item.getBlock().defaultBlockState().isAir()) {
|
||||
result.merge(item.getBlock(), stack.getCount(), (left, right) -> (int) Math.min(Integer.MAX_VALUE, (long) left + right));
|
||||
}
|
||||
}
|
||||
|
||||
private static void changed(ServerPlayer player, Block block, Session session, BlockKnowledgeEvents.Activity activity) {
|
||||
BlockKnowledgeEvents.CHANGED.invoker().onChanged(player, value(player, block, session), activity);
|
||||
}
|
||||
|
||||
private static Session requireHealthy(ServerPlayer player) {
|
||||
Session session = session(player);
|
||||
if (session.failed) throw new IllegalStateException("Sanctuary block knowledge is unavailable for " + player.getUUID());
|
||||
return session;
|
||||
}
|
||||
|
||||
private static Session session(ServerPlayer player) {
|
||||
MinecraftServer server = player.level().getServer();
|
||||
if (!server.isSameThread()) throw new IllegalStateException("Block knowledge must be accessed on the server thread");
|
||||
return SESSIONS.computeIfAbsent(server, ignored -> new HashMap<>()).computeIfAbsent(player.getUUID(), uuid -> {
|
||||
var store = new BlockKnowledgeStore(server.getWorldPath(LevelResource.ROOT).resolve("data/sanctuary-blocodex"), uuid);
|
||||
Session session = new Session(store);
|
||||
try { session.memory = store.load(); }
|
||||
catch (IOException exception) {
|
||||
session.failed = true;
|
||||
SanctuaryMod.LOGGER.error("Cannot load block knowledge for {}; existing history will not be replaced", uuid, exception);
|
||||
}
|
||||
return session;
|
||||
});
|
||||
}
|
||||
|
||||
private static void save(Session session) {
|
||||
if (!session.dirty || session.failed) return;
|
||||
try {
|
||||
session.store.save(session.memory);
|
||||
session.dirty = false;
|
||||
} catch (IOException exception) {
|
||||
session.failed = true;
|
||||
SanctuaryMod.LOGGER.error("Cannot save block knowledge; this history is unavailable until a successful reload", exception);
|
||||
}
|
||||
}
|
||||
|
||||
private static List<Block> catalog() {
|
||||
if (catalog == null) catalog = BuiltInRegistries.BLOCK.stream().filter(block -> !block.defaultBlockState().isAir())
|
||||
.sorted(Comparator.comparing(BlockKnowledgeService::id)).toList();
|
||||
return catalog;
|
||||
}
|
||||
|
||||
private static String id(Block block) { return BuiltInRegistries.BLOCK.getKey(block).toString(); }
|
||||
private static boolean finite(Vec3 vector) { return Double.isFinite(vector.x) && Double.isFinite(vector.y) && Double.isFinite(vector.z); }
|
||||
|
||||
private static final class Session {
|
||||
final BlockKnowledgeStore store;
|
||||
BlockKnowledgeMemory memory;
|
||||
Map<Block, Integer> carried = Map.of();
|
||||
boolean dirty;
|
||||
boolean failed;
|
||||
Session(BlockKnowledgeStore store) { this.store = store; }
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user