Compare commits

..
Author SHA1 Message Date
koka 27b29c1340 Merge remote-tracking branch 'origin/main' into fix/trophy-panel-display
Verification 26.2 / check (pull_request) Canceled after 0s
# Conflicts:
#	CHANGELOG.md
#	build.gradle
2026-09-02 17:35:58 +02:00
koka f217bb3661 Merge pull request 'feat(sanctuary): rendre les coffres et lits Backroom trouvables' (#149) from feature/backroom-visible-loot into main
Verification 26.2 / check (push) Canceled after 0s
Reviewed-on: #149
2026-09-02 12:52:54 +00:00
koka 5100091b17 fix(sanctuary): rendre les lits Backroom trouvables
Verification 26.2 / check (pull_request) Canceled after 0s
2026-09-02 14:36:04 +02:00
koka 398d94e7d1 feat(sanctuary): densifier le butin des Backrooms 2026-09-02 14:26:51 +02:00
koka 0743ff33a6 fix(redstoner): rendre les panneaux de trophées lisibles
Verification 26.2 / check (pull_request) Canceled after 0s
2026-09-02 14:18:20 +02:00
koka bfda90f4f4 Merge pull request 'release: prepare Sanctuary 26.2.0-alpha.230' (#148) from release/26.2.0-alpha.230 into main
Verification 26.2 / check (push) Canceled after 0s
Reviewed-on: #148
2026-09-02 07:18:29 +00:00
koka a698140963 release: prepare Sanctuary 26.2.0-alpha.230
Verification 26.2 / check (pull_request) Canceled after 0s
2026-09-02 09:14:55 +02:00
koka 88ec91e9f4 Merge pull request 'feat(sanctuary): corriger les capes et armer les poules' (#147) from feature/final-sanctuary-tickets into main
Verification 26.2 / check (push) Canceled after 0s
Reviewed-on: #147
2026-09-02 06:57:22 +00:00
koka e1d48e9017 feat(sanctuary): resolve final cape and chicken tickets
Verification 26.2 / check (pull_request) Canceled after 0s
2026-09-02 08:52:53 +02:00
koka cce58c27c8 Merge pull request 'feat(ranking): ajouter les panneaux de trophées automatiques' (#144) from feature/automatic-trophy-panel into main
Verification 26.2 / check (push) Canceled after 0s
Reviewed-on: #144
2026-09-02 06:28:41 +00:00
koka 1a9263d273 Merge remote-tracking branch 'origin/main' into feature/automatic-trophy-panel
Verification 26.2 / check (pull_request) Canceled after 0s
# Conflicts:
#	build.gradle
2026-09-01 21:26:08 +02:00
koka 4a74b6dfed feat(ranking): add automatic trophy panels 2026-09-01 21:24:27 +02:00
koka 06da8fbd2b Merge pull request 'feat(backroom): générer des lits de sortie sur chaque niveau' (#143) from feature/backroom-beds-every-floor into main
Verification 26.2 / check (push) Canceled after 0s
Reviewed-on: #143
2026-09-01 19:18:22 +00:00
koka bd747afbe0 Merge origin/main into feature/backroom-beds-every-floor
Verification 26.2 / check (pull_request) Canceled after 0s
2026-09-01 21:01:18 +02:00
koka 7e459e3615 Merge pull request 'feat(sanctuary): afficher le joueur ayant complété une quête' (#142) from feature/quest-board-completed-by into main
Verification 26.2 / check (push) Canceled after 0s
Reviewed-on: #142
2026-09-01 18:57:19 +00:00
koka 67220fa0c7 feat(backroom): spawn exit beds on every level
Verification 26.2 / check (pull_request) Canceled after 0s
2026-09-01 20:43:57 +02:00
koka a345db5aeb Merge remote-tracking branch 'origin/main' into feature/quest-board-completed-by
Verification 26.2 / check (pull_request) Canceled after 0s
# Conflicts:
#	build.gradle
2026-09-01 18:59:37 +02:00
koka 0bd60d01cc feat(sanctuary): attribuer les quêtes terminées 2026-09-01 18:56:29 +02:00
koka 94e6cf380d Merge pull request 'release(packwiz): publier Sanctuary 26.2.0-alpha.229' (#141) from release/26.2.0-alpha.229 into main
Verification 26.2 / check (push) Canceled after 0s
Reviewed-on: #141
2026-09-01 16:56:02 +00:00
koka 43962f4857 release: prepare Sanctuary 26.2.0-alpha.229
Verification 26.2 / check (pull_request) Canceled after 0s
2026-09-01 18:53:37 +02:00
koka 5af573deb4 Merge pull request 'feat(redstoner): ajouter les tris du terminal' (#139) from feature/storage-terminal-sorting into main
Verification 26.2 / check (push) Canceled after 0s
Reviewed-on: #139
2026-09-01 16:47:18 +00:00
koka e552bd68fd Merge remote-tracking branch 'origin/main' into integration/storage-terminal-sorting-alpha228
Verification 26.2 / check (pull_request) Canceled after 0s
# Conflicts:
#	build.gradle
2026-09-01 18:41:49 +02:00
koka 69dd9f919d Merge pull request 'release: publier Sanctuary 26.2.0-alpha.228' (#140) from release/26.2.0-alpha.228 into main
Verification 26.2 / check (push) Canceled after 0s
Reviewed-on: #140
2026-09-01 16:36:46 +00:00
koka 2d212ae6a1 release: prepare Sanctuary 26.2.0-alpha.228
Verification 26.2 / check (pull_request) Canceled after 0s
2026-09-01 18:33:28 +02:00
koka 2b614ce5a8 Merge remote-tracking branch 'origin/main' into feature/storage-terminal-sorting
Verification 26.2 / check (pull_request) Canceled after 0s
# Conflicts:
#	CHANGELOG.md
#	build.gradle
2026-09-01 18:31:32 +02:00
koka 99ac5fc3a7 Add terminal sorting modes 2026-09-01 18:30:53 +02:00
koka ab82c3929e Merge pull request 'feat: reconstruire la Backroom sur cinq niveaux' (#137) from feature/backroom-five-level-generation into main
Verification 26.2 / check (push) Canceled after 0s
Reviewed-on: #137
2026-09-01 16:23:25 +00:00
koka 4820c736f4 Merge remote-tracking branch 'origin/main' into feature/backroom-five-level-generation
Verification 26.2 / check (pull_request) Canceled after 0s
# Conflicts:
#	CHANGELOG.md
#	build.gradle
2026-09-01 18:16:37 +02:00
koka a16347140a Merge pull request 'feat(redstoner): rechercher dans les boîtes de Shulker' (#138) from feature/storage-terminal-shulker-search into main
Verification 26.2 / check (push) Canceled after 0s
Reviewed-on: #138
2026-09-01 16:14:20 +00:00
koka 75fa88cfc5 Add Shulker contents to terminal search
Verification 26.2 / check (pull_request) Canceled after 0s
2026-09-01 18:11:05 +02:00
koka f04aeb02b2 Merge remote-tracking branch 'origin/main' into feature/backroom-five-level-generation
Verification 26.2 / check (pull_request) Canceled after 0s
# Conflicts:
#	CHANGELOG.md
#	build.gradle
2026-09-01 18:09:41 +02:00
koka 4ca42cb18a Merge pull request 'fix(redstoner): rendre la recherche du terminal cliquable' (#135) from fix/storage-terminal-search-focus into main
Verification 26.2 / check (push) Canceled after 0s
Reviewed-on: #135
2026-09-01 15:57:57 +00:00
koka 985e8b9192 feat(backroom): stack five dark generation levels
Verification 26.2 / check (pull_request) Canceled after 0s
2026-09-01 17:55:40 +02:00
koka 1d8ab0b30a Merge remote-tracking branch 'origin/main' into fix/storage-terminal-search-focus
Verification 26.2 / check (pull_request) Canceled after 0s
# Conflicts:
#	build.gradle
2026-09-01 17:19:44 +02:00
koka 083c3449d5 Merge pull request 'release: publier Sanctuary 26.2.0-alpha.227' (#134) from release/26.2.0-alpha.227 into main
Verification 26.2 / check (push) Canceled after 0s
Reviewed-on: #134
2026-09-01 15:10:06 +00:00
koka 51d630037d fix(redstoner): make terminal search focus clickable
Verification 26.2 / check (pull_request) Canceled after 0s
2026-09-01 17:04:01 +02:00
koka 341f1eb8e5 release: prepare Sanctuary 26.2.0-alpha.227
Verification 26.2 / check (pull_request) Canceled after 0s
2026-09-01 17:00:02 +02:00
koka 10b606d01d Merge pull request 'feat: ajouter la dimension persistante Backroom' (#133) from feature/backroom into main
Verification 26.2 / check (push) Canceled after 0s
Reviewed-on: #133
2026-09-01 14:50:33 +00:00
koka b39c271c96 feat(backroom): add persistent lost-item dimension
Verification 26.2 / check (pull_request) Canceled after 0s
2026-09-01 14:30:42 +02:00
koka a16156b005 Merge pull request 'feat: ajouter une cape craftable décorée par bannière' (#126) from feature/craftable-banner-cape into main
Verification 26.2 / check (push) Canceled after 0s
Reviewed-on: #126
2026-08-31 11:44:49 +00:00
koka 2518c20071 feat(sanctuary): add craftable banner cape
Verification 26.2 / check (pull_request) Canceled after 0s
2026-08-31 13:25:27 +02:00
koka b7497c81d1 Merge pull request 'release: publier Sanctuary 26.2.0-alpha.225' (#125) from release/26.2.0-alpha.225 into main
Verification 26.2 / check (push) Canceled after 0s
Reviewed-on: #125
2026-08-31 09:50:25 +00:00
koka 97638e0fa2 release: prepare Sanctuary 26.2.0-alpha.225
Verification 26.2 / check (pull_request) Canceled after 0s
2026-08-31 11:46:39 +02:00
koka a071a0b746 fix(magic-carpet): restore the Notch Totem texture 2026-08-31 11:46:24 +02:00
koka 6fcc56552c fix(canaplia): preserve crop variants through growth 2026-08-31 11:46:17 +02:00
koka 66944ec492 fix(companions): suppress loot and quest progress 2026-08-31 11:46:02 +02:00
koka b513ab1262 fix(anotherworld): require a vault before raids 2026-08-31 11:45:46 +02:00
koka b2222c5d33 Merge pull request 'release: publier Sanctuary 26.2.0-alpha.224' (#122) from release/26.2.0-alpha.224 into main
Verification 26.2 / check (push) Canceled after 0s
Reviewed-on: #122
2026-08-31 05:17:01 +00:00
koka 2d0be21c5b release: prepare Sanctuary 26.2.0-alpha.224
Verification 26.2 / check (pull_request) Canceled after 0s
2026-08-31 07:13:29 +02:00
koka a0b0788869 Merge pull request 'feat: livrer et migrer le Magic Carpet après Notch' (#121) from integration/magic-carpet-reward into main
Verification 26.2 / check (push) Canceled after 0s
Reviewed-on: #121
2026-08-31 04:59:18 +00:00
koka 106d730dd8 feat: deliver and migrate the Magic Carpet
Verification 26.2 / check (pull_request) Canceled after 0s
2026-08-31 06:45:28 +02:00
koka 21dd089486 Merge pull request 'feat: ajouter Notch et son combat dans Alpha' (#119) from integration/notch-encounter into main
Verification 26.2 / check (push) Canceled after 0s
Reviewed-on: #119
2026-08-31 04:15:54 +00:00
koka e3b6c6ed01 Merge pull request 'fix(sanctuary): trier coffres et barrels et garder la hotbar en bas' (#120) from fix/issue-118-container-sort into main
Verification 26.2 / check (push) Canceled after 0s
Reviewed-on: #120
2026-08-31 04:15:42 +00:00
ChrisM-PekandCursor 7387096d98 chore(sanctuary): aligner la verif alpha.223 sur le tri des conteneurs
Verification 26.2 / check (pull_request) Canceled after 0s
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-31 05:54:43 +02:00
ChrisM-PekandCursor 457f91b92e fix(sanctuary): trier coffres et barrels et garder la hotbar en bas
Le clic molette range aussi les conteneurs de stockage, et la hotbar reste sur la derniere ligne a la connexion.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-31 05:52:17 +02:00
173 changed files with 7957 additions and 557 deletions
+85 -4
View File
@@ -6,16 +6,97 @@ Ce journal suit les **versions du modpack**. Lorsqu'un seul module change, sa ve
- Depuis `26.2.0-alpha.6`, le pack et les modules ont des versions indépendantes. I Like To Move It et Only Fun deviennent les cinquième et sixième modules actifs dans l'alpha 46.
- Les versions ci-dessous ont été reconstituées à partir des JAR archivés, des packs locaux et du code source actuel. Les dates n'étant pas enregistrées de manière fiable, elles ne sont pas inventées.
## Non distribué
## Non publié
Modules modifiés : **It's Alive `0.0.0-alpha.37`**, **Ouch `0.0.0-alpha.11`**, **Sanctuary `0.0.0-alpha.126`** et **MasterKey `0.0.0-alpha.9`**. Le pack public reste temporairement en `26.2.0-alpha.223` jusqu'à la publication.
Modules modifiés : **Sanctuary `0.0.0-alpha.137`** et **Red-Stoner `0.0.0-alpha.18`**.
- transforme le panneau de trophées en plaque verticale de chêne, corrige le texte auparavant masqué et utilise les quatre lignes pour le titre paginé ainsi que les trois places du podium ;
- permet de passer à la page suivante dun clic droit et de revenir à la précédente avec `Maj` + clic droit, sans changer les IDs, les sauvegardes Red-Stoner v4 ni le protocole réseau 7.
- garantit sur chaque niveau de la Backroom un coffre par cellule de 3 × 3 chunks dans les nouveaux chunks, au lieu dun coffre aléatoire réparti entre les cinq niveaux ;
- resserre aussi la grille des lits de sortie de 10 × 10 à 3 × 3 chunks sur chacun des cinq niveaux afin quils soient réellement trouvables ;
- ne change ni le butin ordinaire des coffres, ni les données Sanctuary v15, ni le protocole réseau 24 ; les nouveaux coffres et lits apparaissent dans les chunks qui nont pas encore été générés.
## `26.2.0-alpha.230`
Modules modifiés : **Sanctuary `0.0.0-alpha.136`** et **Red-Stoner `0.0.0-alpha.17`**.
- attribue les demandes de quêtes personnalisées terminées à leur preneur directement sur le panneau et dans les détails au clic, avec son pseudonyme et sa couleur conservés ;
- répartit les lits de sortie rares sur chacun des cinq niveaux de la Backroom, avec exactement un lit par cellule de 10 × 10 chunks et par niveau dans les nouveaux chunks ;
- conserve les IDs, les données Sanctuary v14 et le protocole réseau 24 ; les chunks Backroom déjà générés restent inchangés.
- ajoute lAPI publique Sanctuary de métriques et de classements persistants par UUID, avec import monotone des statistiques vanilla, podium borné et exclusion des actions créatives, spectateur ou simulées ;
- ajoute `redstoner:trophy_panel`, panneau mural configurable par son propriétaire avec un item non consommé, pages publiques, rendu en monde et rafraîchissement serveur limité à une fois par seconde ;
- passe Sanctuary aux données v15 et Red-Stoner aux données v4 sans nouveau payload ni changement de leurs protocoles réseau 24 et 7.
- corrige la cape blanche décorée en projetant sa couleur et ses motifs avec les sprites de bouclier, aux proportions exactes de la cape ;
- permet d’équiper une poule adulte avec larmure de loup vanilla en écailles de tatou, de la réparer avec des écailles et de la retirer aux cisailles ; larmure absorbe les dégâts et conserve son usure, ses teintures et ses enchantements ;
- conserve les sauvegardes Sanctuary v15 et le protocole réseau 24 : larmure utilise exclusivement le slot d’équipement vanilla de la poule.
## `26.2.0-alpha.229`
Module modifié : **Red-Stoner `0.0.0-alpha.16`**.
- ajoute au terminal les tris alphabétique, par quantité croissante et par quantité décroissante, appliqués explicitement sans déplacer les objets sous le curseur lors des rafraîchissements périodiques ;
## `26.2.0-alpha.228`
Modules modifiés : **Sanctuary `0.0.0-alpha.132`** et **Red-Stoner `0.0.0-alpha.15`**.
- étend `sanctuary:backroom` à toute la hauteur Y -64 → 383 et empile cinq niveaux thématiques de haut en bas : seuil modulaire, archives, ville, services et glitch ;
- remplace les volumes ouverts par des pièces et couloirs raccordés, quatre angles de salle déclinés en cinq matériaux, des bibliothèques immenses, des tours plus serrées, des autoroutes continues et de rares parcs ;
- ajoute au niveau inférieur une grille de prismes 3D et un labyrinthe déterministe connecté, avec portes physiquement ouvertes, salles fusionnées et trous volontaires vers le vide ;
- fait correspondre exactement chaque ouverture entre le sol supérieur et le plafond inférieur, place une torche récupérable à chaque arrivée et raréfie fortement les lits de sortie ;
- supprime le ciel, les astres, la lumière ambiante et tous les monstres, y compris ceux injectés par un autre système ;
- conserve les IDs, les données Sanctuary v14 et le protocole réseau 24 ; seuls les nouveaux chunks Backroom utilisent la nouvelle architecture complète ;
- rend le champ de recherche du terminal inactif à louverture puis focalisable au clic, libère le focus au clic extérieur et laisse toujours la touche dinventaire fermer le terminal ;
- permet à la recherche du terminal de retrouver une boîte de Shulker par le nom ou lidentifiant dun objet quelle contient, tout en conservant la boîte comme résultat afin que son aperçu vanilla reste directement consultable ;
## `26.2.0-alpha.227`
Modules modifiés : **Sanctuary `0.0.0-alpha.131`** et **Another World `0.0.0-alpha.57`**.
- ajoute la dimension persistante `sanctuary:backroom`, accessible en saccroupissant devant un lit et quittée uniquement par un lit, avec arrivées variées dans une zone architecturale de 2 000 blocs ;
- transfère atomiquement vers la Mailbox tout l’équipement dentrée, y compris les rangées étendues, l’œuf compagnon et la cape, avec reprise idempotente après interruption ;
- conserve les objets perdus au dépop, dans le vide et lors des morts en Backroom dans un registre borné et non duplicable ;
- transforme tous les coffres de la dimension en butin renouvelable, pauvre la plupart du temps, qui privilégie les pertes personnelles dans les premiers coffres avant les pertes anciennes partagées ;
- génère des villes, bureaux, plaines, agrégats flottants et pièces visuellement retournées à partir de palettes composées, en réservant les matériaux dAnother World aux anomalies et les blocs précieux à de rares cachettes ;
- fait enregistrer la mousse turquoise par Another World via lAPI publique de matériaux Backroom, sans dépendance circulaire ;
- actualise Fabric API vers `0.159.0+26.2` et JEI vers `30.29.0.199`, avec empreintes Packwiz et Prism synchronisées ;
- migre Sanctuary vers les données v14 sans changer le protocole réseau 24, sans réinitialiser les sauvegardes ni effacer les constructions.
## `26.2.0-alpha.226`
Module modifié : **Sanctuary `0.0.0-alpha.130`**. Les neuf autres modules conservent leur version issue de l'alpha.225.
- ajoute `sanctuary:white_cape`, une cape blanche craftable avec six laines blanches disposées comme une porte, en deux colonnes de trois ;
- permet d'associer simplement la cape et n'importe quelle bannière dans l'établi afin d'en conserver la couleur de fond et jusqu'à six motifs ;
- affiche les motifs dans l'inventaire et sur la cape équipée, avec la physique native des capes, y compris en multijoueur ;
- conserve les sauvegardes Sanctuary en data v13 ; le payload d'apparence transporte désormais la couleur et les motifs bornés, donc le protocole Sanctuary passe de 23 à 24 et client comme serveur doivent être mis à jour, sans nouveau monde ni réinitialisation.
## `26.2.0-alpha.225`
Modules modifiés : **Another World `0.0.0-alpha.56`**, **It's Alive `0.0.0-alpha.38`**, **I Like To Move It `0.0.0-alpha.18`**, **Only Fun `0.0.0-alpha.27`** et **Sanctuary `0.0.0-alpha.129`**. Les cinq autres modules conservent leur version issue de l'alpha.224.
- exige que lattaquant possède son propre coffre-fort actif avant de commencer un braquage, revalide cette condition pendant le forage et refuse défensivement tout transfert si le coffre disparaît entre-temps ;
- empêche les familiers temporaires Sanctuary de produire du butin vanilla, de lexpérience ou une lootbox Only Fun, et les exclut des contrats de panneau comme des demandes communautaires ;
- conserve la variante Canaplia des seize graines historiques pendant le placement, la croissance naturelle, la poudre dos, la création de la partie haute, le rechargement et la récolte, ce qui réactive notamment lhybridation Tendre + Olive vers Dorée ;
- remplace la laine violette du Magic Carpet par la texture historique 16 × 16 du Totem de Notch, utilisée par lobjet canonique et son alias hérité sans modifier la plateforme 3 × 3 ;
- conserve tous les IDs, sauvegardes et formats de données ; les protocoles réseau restent Another World 2, It's Alive 4, I Like To Move It 5, Only Fun 3 et Sanctuary 23, sans nouveau monde ni réinitialisation.
## `26.2.0-alpha.224`
Modules modifiés : **It's Alive `0.0.0-alpha.37`**, **Ouch `0.0.0-alpha.11`**, **I Like To Move It `0.0.0-alpha.17`**, **Only Fun `0.0.0-alpha.26`**, **Sanctuary `0.0.0-alpha.128`** et **MasterKey `0.0.0-alpha.9`**.
- étend le clic molette aux coffres, barils, boîtes de Shulker, entonnoirs et distributeurs, tout en excluant les fours, le Shop et le terminal Red-Stoner ;
- trie l'inventaire du joueur lorsque le curseur survole l'une de ses cases dans un conteneur, sans toucher à la hotbar, et replace la hotbar en bas après connexion ou achat d'une rangée ;
- ajoute Notch comme résident unique et persistant de la maison Indev, avec restauration automatique, déduplication et lecture des anciennes entités `portals:notch` ;
- transforme Notch en Titan au premier coup volontaire, avec santé bornée selon les participants, poursuite, attaques télégraphiées, boules de feu renvoyables et réinitialisation si le combat est abandonné ;
- limite la destruction de blocs à l'explosion initiale de transformation ; les attaques suivantes utilisent uniquement dégâts, poussée, particules et explosions non destructrices ;
- enregistre la première victoire comme jalon mondial monotone, crédite les participants, inscrit un marqueur de boss dans leur Atlas déjà découvert et réserve un drapeau de récompense unique pour la suite ;
- enregistre la première victoire comme jalon mondial monotone, crédite les participants, inscrit un marqueur de boss dans leur Atlas déjà découvert et réserve une récompense physique unique ;
- place le Magic Carpet de Notch dans un coffre déterministe signalé par feu d'artifice, avec réservation et livraison persistées séparément pour récupérer une interruption sans duplication ;
- conserve `portals:notch_totem` comme alias caché et convertit inventaires, conteneurs et items au sol vers `iliketomoveit:magic_carpet` en gardant quantité, composants et nom personnalisé ;
- maintient la plateforme temporaire 3 × 3 sous autorité serveur, sans écraser le terrain et avec un suivi par propriétaire qui protège les tapis superposés pendant les nettoyages ;
- rend l'offre Magic Carpet visible et achetable uniquement après `sanctuary:notch_defeated`, au prix exceptionnel existant, avec paiement normal, livraison Mailbox, provenance et journal de remplacement ;
- ajoute les diagnostics `/masterkey notch inspect` et `/masterkey notch restore`, les traductions FR/EN/RU et les contrats de test déterministes associés ;
- migre les données It's Alive de v3 à v4 et Sanctuary de v11 à v12, sans changer les protocoles réseau ni le pack public.
- migre les données It's Alive de v3 à v4, I Like To Move It de v3 à v4 et Sanctuary de v11 à v13 ; le payload de tri ayant gagné un booléen borné, le protocole Sanctuary passe de 22 à 23 et client comme serveur doivent être mis à jour, sans nouveau monde ni réinitialisation.
## `26.2.0-alpha.223`
+24 -8
View File
@@ -1,6 +1,6 @@
# Sanctuary 26.2
Workspace Fabric multi-projet de Sanctuary 2.0. Il construit dix JAR indépendants sur Minecraft 26.2, Fabric Loader 0.19.3, Fabric API 0.158.0+26.2, Loom 1.17, Gradle 9.5.1 et Java 25.
Workspace Fabric multi-projet de Sanctuary 2.0. Il construit dix JAR indépendants sur Minecraft 26.2, Fabric Loader 0.19.3, Fabric API 0.159.0+26.2, Loom 1.17, Gradle 9.5.1 et Java 25.
Auteur : **KOKA99CAB**
Licence : **GNU GPL 3.0 or Later** (`GPL-3.0-or-later`)
@@ -12,33 +12,45 @@ Licence : **GNU GPL 3.0 or Later** (`GPL-3.0-or-later`)
| `anotherworld` | Another World | choses matérielles | matière, photographie, instruments météo et 108 biomes natifs |
| `itsalive` | It's Alive ! | vivant | Creepers, créatures, agriculture et gameplay serveur complet de Canaplia |
| `ambiance` | Ambiance | perception | atmosphère, météo, lumières dynamiques, audio positionnel, calendrier et composition visuelle accessible |
| `redstoner` | Red-Stoner | calcul et signaux | ordinateurs, identité serveur, terminal de stockage, Drawer et Particuleur |
| `redstoner` | Red-Stoner | calcul et signaux | ordinateurs, identité serveur, terminal de stockage, panneau de trophées, Drawer et Particuleur |
| `iliketomoveit` | I Like To Move It | déplacement | portails, véhicules, grappin, poulies et waystones locaux |
| `ouch` | Ouch | combat et destruction | arsenal actif (6 armes) et TNT météo |
| `onlyfun` | Only Fun | règles ludiques absurdes | lootboxes, Lucky Block, raretés et règles absurdes |
| `sanctuary` | Sanctuary | progression et aventure | progression globale, Atlas et monde principal flottant |
| `sanctuary` | Sanctuary | progression et aventure | progression globale, classements publics, Atlas et monde principal flottant |
| `events` | Events | événements serveur | socle vide |
| `masterkey` | MasterKey | administration et diagnostic | laboratoire minimal |
Les descriptions FR/EN/RU sont déclarées dans chaque `fabric.mod.json` et dans les fichiers de langue. Les images fournies servent d'icônes Fabric de leur module.
Version courante du pack distribué : **`26.2.0-alpha.223`**. Cette release distribue Sanctuary **`0.0.0-alpha.125`** ; les neuf autres modules conservent leur version issue de l'alpha.222.
Version courante du pack distribué : **`26.2.0-alpha.230`**. Cette release distribue Sanctuary **`0.0.0-alpha.136`** et Red-Stoner **`0.0.0-alpha.17`** ; les huit autres modules conservent leur version issue de l'alpha.229.
Le prochain Red-Stoner **`0.0.0-alpha.18`** présente le panneau de trophées comme une plaque verticale de chêne et rend enfin ses quatre lignes lisibles : titre et numéro de page, puis les trois places du podium. Un clic droit avance dune page et `Maj` + clic droit revient à la précédente ; les données v4 et le protocole réseau 7 restent inchangés.
Lalpha.230 attribue les quêtes communautaires terminées à leur preneur et répartit les lits de sortie rares sur chacun des cinq niveaux de la Backroom. Elle ajoute aussi les classements publics et le panneau mural `redstoner:trophy_panel`, corrige la projection des couleurs et motifs de la cape blanche avec les sprites de bouclier, et permet d’équiper une poule adulte avec larmure de loup vanilla en écailles de tatou. Les sauvegardes restent compatibles ; Sanctuary passe aux données v15 et Red-Stoner aux données v4 sans changer leurs protocoles réseau 24 et 7.
Lalpha.229 ajoute au terminal les tris alphabétique, par quantité croissante et par quantité décroissante. Le tri ne change que sur demande explicite et les rafraîchissements périodiques conservent lordre ainsi que les objets sous le curseur. Les sauvegardes, les données Red-Stoner v3 et le protocole réseau 7 restent compatibles.
Lalpha.228 reconstruit la Backroom sur cinq niveaux empilés entre Y -64 et Y 383. Le monde devient entièrement noir et sans monstres ; larrivée est signalée par une torche récupérable. Les nouveaux chunks composent seuils modulaires, bibliothèques et bureaux, ville dense avec autoroutes et parcs, couloirs techniques, puis une grille 3D et un labyrinthe connecté dont certains trous mènent au vide. Red-Stoner corrige aussi le focus du terminal et permet de retrouver une boîte de Shulker par son contenu. Les chunks déjà générés et les sauvegardes existantes restent compatibles.
Lalpha.227 ajoute la dimension persistante `sanctuary:backroom`. On y entre accroupi devant un lit et on nen ressort que par un lit. L’équipement dentrée est transféré atomiquement vers la Mailbox, tandis que les objets perdus ou abandonnés dans la dimension alimentent des coffres renouvelables sans duplication. Les anciennes sauvegardes sont migrées vers Sanctuary data v14 sans réinitialisation ; le protocole réseau reste en version 24.
Lalpha.225 corrige quatre tickets : posséder un coffre-fort devient obligatoire pour en braquer un autre, les familiers temporaires ne donnent plus de butin, dexpérience, de lootbox ni de progression de quête, les seize variantes Canaplia survivent à tout leur cycle de culture, et le Magic Carpet retrouve la texture historique du Totem de Notch à la place de la laine violette. Les IDs, sauvegardes, formats de données et protocoles restent compatibles.
La migration [CANA-01 à CANA-09](CANAPLIA.md) porte Canaplia vers Minecraft 26.2. It's Alive **`0.0.0-alpha.35`** enregistre les seize familles, les découvertes, hybridations, résines, effets serveur et le Livre interdit personnel, partageable temporairement sur un pupitre. Ambiance **`0.0.0-alpha.14`** compose les profils visuels bornés avec ses réglages d'accessibilité, et Only Fun **`0.0.0-alpha.21`** exclut explicitement Canaplia et les raccourcis de progression du Shop.
Lalpha.224 ajoute Notch comme résident unique de la maison Indev et son combat de Titan. It's Alive possède l'entité persistante, Ouch les attaques et dégâts, Sanctuary le jalon mondial de victoire et l'Atlas, tandis que MasterKey fournit les commandes d'inspection et de restauration. Les anciennes entités `portals:notch` restent chargeables. La première victoire réserve maintenant un unique `iliketomoveit:magic_carpet` dans un coffre signalé par feu d'artifice. L'ancien `portals:notch_totem` est migré sans perte ; après Notch, Only Fun ouvre l'offre de remplacement au Shop avec paiement serveur et livraison par Mailbox. Le clic molette trie aussi les coffres, barils, boîtes de Shulker, entonnoirs et distributeurs, ou l'inventaire du joueur lorsqu'il est survolé, sans déplacer la hotbar. Le protocole Sanctuary passe à 23 : client et serveur doivent utiliser l'alpha.224.
Lalpha.223 ajoute le tri natif des rangées de stockage par clic molette sans déplacer la hotbar ni les emplacements spéciaux. Le suivi des quêtes propose désormais le texte transparent aligné sous la colonne gauche du F3 ou le panneau original de Chris, avec bascule configurable sur `N` et contrats ordonnés par récompense. JEI passe à la bêta Fabric 26.2 `30.29.0.198`.
Lalpha.222 améliore le terminal de stockage avec une recherche Unicode, des quantités compactes et des emplacements qui ne glissent plus lorsqu'une pile est vidée. Elle ajoute aussi le suivi textuel des quêtes actives en haut à gauche, masquable avec une touche configurable, ainsi que des suggestions dIDs ditems et de mobs dans l’éditeur de demandes. JEI passe à la bêta Fabric 26.2 `30.29.0.196`.
Le lot non distribué ajoute Notch comme résident unique de la maison Indev et son combat de Titan. It's Alive possède l'entité persistante, Ouch les attaques et dégâts, Sanctuary le jalon mondial de victoire et l'Atlas, tandis que MasterKey fournit les commandes d'inspection et de restauration. Les anciennes entités `portals:notch` restent chargeables.
Lalpha.221 corrige la cause réelle du disque blanc ralenti et trop grave : Ambiance décode désormais la source AAC en stéréo native à 48 kHz, puis moyenne explicitement chaque paire gauche/droite vers le flux mono positionnel de Minecraft. OpenAL reste à sa hauteur normale `1.0`, sans compensation artificielle ni changement de durée.
Lalpha.220 transforme le terminal de stockage en véritable menu de conteneur, sans bouton de fermeture propriétaire. Les clics gauche/droit et shift-clic permettent maintenant de retirer ou déposer des piles depuis toutes les rangées dinventaire débloquées par Sanctuary, jusqu’à six ; la grille agrégée reste non réorganisable et remplit chaque coffre ou baril dans lordre de découverte avant de passer au suivant.
Lalpha.219 porte l'île finie Minecraft Indev dans `sanctuary:alpha` : 128 × 128 × 64 blocs déterministes, plages, cavernes, minerais, fluides, végétation et maison historique, le tout borné sans chunks parasites. Le cadre 4 × 5 en cobblestone moussue est maintenant actif et crée une paire persistante à une arrivée sûre hors de la maison. Ambiance peut enfin composer localement Golden Days Base puis Alpha uniquement dans cette dimension, sans redistribuer leurs textures et en restaurant exactement la pile précédente. Voir le [contrat Alpha](sanctuary/ALPHA.md), le [contrat des portails](iliketomoveit/PORTALS.md) et le [guide Golden Days](ambiance/GOLDEN_DAYS.md).
Lalpha.218 ajoute le terminal de stockage Red-Stoner : cette demi-dalle verticale se fixe sur un coffre, un coffre piégé ou un baril et donne accès, par pages défilantes de 54 types, à un réseau contigu borné à 128 conteneurs chargés. Les retraits et dépôts sont validés par le serveur, les composants ditems restent strictement séparés et le terminal endgame est exclu du Shop, du Black Market et des récompenses Only Fun.
Lalpha.218 ajoute le terminal de stockage Red-Stoner : cette demi-dalle verticale se fixe sur un coffre, un coffre piégé ou un baril et donne accès, par pages défilantes de 54 types, à un réseau contigu borné à 128 conteneurs chargés. Les retraits et dépôts sont validés par le serveur, les composants ditems restent strictement séparés et le terminal endgame est exclu du Shop, du Black Market et des récompenses Only Fun. La recherche retrouve aussi une boîte de Shulker daprès son contenu direct ; la boîte reste affichée dans la grille afin que son aperçu vanilla soit consultable sans modifier les règles de retrait. Un bouton permet enfin de trier explicitement les résultats par nom, quantité croissante ou quantité décroissante.
Lalpha.217 tentait de compenser la hauteur trop grave du disque blanc par un facteur OpenAL de `4/3`. Cette compensation est retirée par lalpha.221, qui corrige directement la conversion stéréo vers mono.
@@ -114,6 +126,8 @@ Lalpha.173 centralise laudio du Miner : une seule boucle de frappe sur le
Lalpha.171 rassemble les **46 capes** dans un onglet créatif dédié « Capes ». Elles ne sont plus mélangées à longlet vanilla Tools & Utilities et ne sont donc affichées quune seule fois.
Lalpha.226 ajoute une 47e cape, `sanctuary:white_cape`, distincte de la collection Only Fun. Elle se fabrique avec six laines blanches en deux colonnes de trois, puis accepte une bannière dans une recette simple pour en conserver la couleur et jusqu’à six motifs ; les motifs saffichent dans linventaire comme une fois la cape équipée.
Lalpha.170 ajoute les pictogrammes fournis aux emplacements vides de la cape et du familier. Ils disparaissent dès quune cape ou un œuf est équipé, sans modifier les objets, la persistance ni le protocole.
Lalpha.169 agrandit la collection de 13 à **46 capes équipables**. Les 33 nouvelles textures 64×32 fournies sont conservées telles quelles, avec une icône dinventaire, un modèle et des traductions FR/EN/RU pour chaque cape. Elles utilisent le slot, la persistance et le rendu multijoueur déjà existants, restent sans recette et rejoignent toutes la lootbox de capes Only Fun. Les caméras Canon restent accessibles dans la lootbox normale et peuvent désormais aussi apparaître directement, très rarement, dans les coffres dexploration et du donjon de cobblestone.
@@ -309,7 +323,9 @@ Le guide détaillé est dans [`masterkey/tools/PANORAMA.md`](masterkey/tools/PAN
## Red-Stoner et photographie
Red-Stoner possède quatre blocs actifs sous son namespace : `eight_bit_computer`, `controller`, `personal_computer` et `drawer`. Son onglet créatif expose aussi les trois appareils Canon et les seize styles de pellicule.
Red-Stoner possède sept blocs actifs sous son namespace : `eight_bit_computer`, `controller`, `personal_computer`, `drawer`, `particuleur`, `storage_terminal` et `trophy_panel`. Son onglet créatif expose aussi les trois appareils Canon et les seize styles de pellicule.
Le panneau mural `redstoner:trophy_panel` consomme lAPI publique de classement de Sanctuary sans conserver les scores. Le joueur qui le pose peut ajouter des pages statistiques en cliquant avec un item, tandis que tous les visiteurs peuvent faire défiler les pages. Sanctuary importe une fois les statistiques vanilla existantes, garde les classements par UUID — champion déconnecté compris — et fournit seulement un podium borné à trois entrées. Les composants privés de litem servant dicône et la base complète des joueurs ne sont jamais synchronisés au client.
L'ordinateur 8 bits et le contrôleur exécutent la machine virtuelle historique : programme assembleur borné à 4096 caractères, RAM, inventaire, six ports redstone directionnels, impulsions et sortie comparateur. Le contrôleur dispose de 1024 cellules de RAM contre 256 pour l'ordinateur. L'instruction destinée à la matrice d'affichage renvoie volontairement une erreur claire tant que ce périphérique reste différé.
+35 -2
View File
@@ -1647,6 +1647,7 @@ tasks.register("generateAnotherWorldResources") {
"message.anotherworld.safe_vault.empty_before_break": "Videz le coffre-fort et attendez la fin du forage avant de le démonter.",
"message.anotherworld.safe_vault.drill_own": "Vous ne pouvez pas forer votre propre coffre-fort.",
"message.anotherworld.safe_vault.inactive": "Ce coffre-fort nest pas actif.",
"message.anotherworld.safe_vault.raid_requires_vault": "Vous devez posséder un coffre-fort actif avant den braquer un autre.",
"message.anotherworld.safe_vault.empty": "Ce coffre-fort est vide.",
"message.anotherworld.safe_vault.owner_offline": "Le propriétaire doit être connecté pour que le coffre-fort soit attaquable.",
"message.anotherworld.safe_vault.protected": "Ce coffre-fort reste protégé pendant environ %s minute(s).",
@@ -1671,6 +1672,7 @@ tasks.register("generateAnotherWorldResources") {
"message.anotherworld.safe_vault.empty_before_break": "Опустошите сейф и дождитесь окончания сверления перед разборкой.",
"message.anotherworld.safe_vault.drill_own": "Нельзя сверлить собственный сейф.",
"message.anotherworld.safe_vault.inactive": "Этот сейф не активен.",
"message.anotherworld.safe_vault.raid_requires_vault": "Для ограбления чужого сейфа нужен собственный активный сейф.",
"message.anotherworld.safe_vault.empty": "Этот сейф пуст.",
"message.anotherworld.safe_vault.owner_offline": "Владелец должен быть в сети, чтобы атаковать сейф.",
"message.anotherworld.safe_vault.protected": "Сейф защищён ещё примерно %s минут(ы).",
@@ -1695,6 +1697,7 @@ tasks.register("generateAnotherWorldResources") {
"message.anotherworld.safe_vault.empty_before_break": "Empty the safe and wait for drilling to end before dismantling it.",
"message.anotherworld.safe_vault.drill_own": "You cannot drill your own safe.",
"message.anotherworld.safe_vault.inactive": "This safe is not active.",
"message.anotherworld.safe_vault.raid_requires_vault": "You need an active safe of your own before raiding another one.",
"message.anotherworld.safe_vault.empty": "This safe is empty.",
"message.anotherworld.safe_vault.owner_offline": "The owner must be online before the safe can be raided.",
"message.anotherworld.safe_vault.protected": "This safe remains protected for about %s minute(s).",
@@ -1953,7 +1956,7 @@ tasks.register("verifyAnotherWorldCatalog") {
"src/main/resources/assets/redstoner/textures/item/weather_gauge.png",
"src/main/resources/data/redstoner/recipe/weather_gauge.json"
]
if (project.version.toString() != "0.0.0-alpha.55"
if (project.version.toString() != "0.0.0-alpha.57"
|| sulfurMigration.target?.modules?.anotherworld != "0.0.0-alpha.44"
|| sulfurMigration.sulfur_caves?.sanctuary?.dripstone_cell_period != 2
|| !javaText.contains('Identifier.parse("sanctuary:sulfur_caves")')
@@ -3270,7 +3273,7 @@ tasks.register("verifyClimateBiomeMixer") {
"pack/migrations/26.2.0-alpha.188-beta-climate-provinces-to-alpha.189.json"))
def mixer = file(
"src/main/java/fr/koka99cab/sanctuary26/anotherworld/mixin/MultiNoiseBiomeSourceParameterListPresetMixin.java").text
if (project.version.toString() != "0.0.0-alpha.55"
if (project.version.toString() != "0.0.0-alpha.57"
|| migration.source?.pack_version != "26.2.0-alpha.188"
|| migration.target?.pack_version != "26.2.0-alpha.189"
|| migration.target?.modules?.anotherworld != "0.0.0-alpha.48"
@@ -3297,3 +3300,33 @@ tasks.register("verifyClimateBiomeMixer") {
tasks.named("check") {
dependsOn tasks.named("verifyClimateBiomeMixer")
}
tasks.register("verifyBackroomMaterialIntegration") {
group = "verification"
description = "Checks the one-way Another World material integration with Sanctuary Backroom."
inputs.file(file("src/main/java/fr/koka99cab/sanctuary26/anotherworld/AnotherWorldMod.java"))
inputs.file(file("src/main/java/fr/koka99cab/sanctuary26/anotherworld/registry/AnotherWorldBlocks.java"))
inputs.file(rootProject.file(
"sanctuary/src/main/java/fr/koka99cab/sanctuary26/sanctuary/api/backroom/BackroomMaterialApi.java"))
doLast {
def initializer = file("src/main/java/fr/koka99cab/sanctuary26/anotherworld/AnotherWorldMod.java").text
def blocks = file("src/main/java/fr/koka99cab/sanctuary26/anotherworld/registry/AnotherWorldBlocks.java").text
def api = rootProject.file(
"sanctuary/src/main/java/fr/koka99cab/sanctuary26/sanctuary/api/backroom/BackroomMaterialApi.java").text
def rootBuild = rootProject.file("build.gradle").text
def manifest = new JsonSlurper().parse(file("src/main/resources/fabric.mod.json"))
if (project.version.toString() != "0.0.0-alpha.57"
|| !initializer.contains("BackroomMaterialApi.registerAnomalyMaterial(AnotherWorldBlocks.TURQUOISE_MOSS)")
|| !blocks.contains('"turquoise_moss"')
|| !api.contains("public static void registerAnomalyMaterial")
|| manifest.depends?.sanctuary != ">=0.0.0-alpha.131"
|| !rootBuild.contains('project(":anotherworld")')
|| !rootBuild.contains('implementation project(":sanctuary")')) {
throw new GradleException("Another World alpha.57 Backroom material integration is incomplete")
}
}
}
tasks.named("check") {
dependsOn tasks.named("verifyBackroomMaterialIntegration")
}
@@ -4,7 +4,9 @@ import fr.koka99cab.canon.CanonMod;
import fr.koka99cab.sanctuary26.anotherworld.item.WeatherCompassItem;
import fr.koka99cab.sanctuary26.anotherworld.network.AnotherWorldNetworking;
import fr.koka99cab.sanctuary26.anotherworld.registry.AnotherWorldRegistries;
import fr.koka99cab.sanctuary26.anotherworld.registry.AnotherWorldBlocks;
import fr.koka99cab.sanctuary26.anotherworld.vault.VaultService;
import fr.koka99cab.sanctuary26.sanctuary.api.backroom.BackroomMaterialApi;
import net.fabricmc.api.ModInitializer;
import net.minecraft.resources.Identifier;
import org.slf4j.Logger;
@@ -26,6 +28,7 @@ public final class AnotherWorldMod implements ModInitializer {
@Override
public void onInitialize() {
AnotherWorldRegistries.initialize();
BackroomMaterialApi.registerAnomalyMaterial(AnotherWorldBlocks.TURQUOISE_MOSS);
VaultService.initialize();
WeatherCompassItem.registerFrameInteraction();
CanonMod.initialize();
@@ -113,6 +113,12 @@ public final class VaultData extends SavedData {
&& address.pos() == center.asLong() && address.owner().equals(ownerId));
}
public boolean hasRegisteredVault(UUID owner) {
if (owner == null) return false;
String ownerId = owner.toString();
return vaults.stream().anyMatch(address -> address.owner().equals(ownerId));
}
public void unregisterNear(ServerLevel level, BlockPos member) {
String dimension = dimension(level);
boolean changed = vaults.removeIf(address -> {
@@ -163,7 +169,7 @@ public final class VaultData extends SavedData {
/** Transfers the exact 20% raid share into the attacker's unlimited balances without item spam. */
public long transferRaid(UUID owner, UUID attacker) {
if (owner == null || attacker == null || owner.equals(attacker)) return 0L;
if (!canReceiveRaidLoot(owner, attacker, hasRegisteredVault(attacker))) return 0L;
Account source = accounts.get(owner);
if (source == null) return 0L;
Account target = accounts.computeIfAbsent(attacker, ignored -> new Account());
@@ -180,6 +186,10 @@ public final class VaultData extends SavedData {
return total;
}
static boolean canReceiveRaidLoot(UUID owner, UUID attacker, boolean attackerHasRegisteredVault) {
return owner != null && attacker != null && !owner.equals(attacker) && attackerHasRegisteredVault;
}
public long protectionRemaining(UUID owner, long gameTime) {
Account account = accounts.get(owner);
return account == null ? 0L : Math.max(0L, account.protectedUntil - gameTime);
@@ -48,6 +48,10 @@ public final class VaultDrillingService {
attacker.sendSystemMessage(Component.translatable("message.anotherworld.safe_vault.inactive"));
return false;
}
if (!data.hasRegisteredVault(attacker.getUUID())) {
attacker.sendSystemMessage(Component.translatable("message.anotherworld.safe_vault.raid_requires_vault"));
return false;
}
if (!data.hasContents(formed.owner())) {
attacker.sendSystemMessage(Component.translatable("message.anotherworld.safe_vault.empty"));
return false;
@@ -104,6 +108,13 @@ public final class VaultDrillingService {
attacker.stopUsingItem();
return;
}
if (!VaultData.get(level.getServer()).hasRegisteredVault(attacker.getUUID())) {
cancel(attacker, false);
attacker.sendOverlayMessage(Component.translatable(
"message.anotherworld.safe_vault.raid_requires_vault"));
attacker.stopUsingItem();
return;
}
int elapsed = session.elapsedTicks() + 1;
Session progressed = session.withElapsed(elapsed);
@@ -31,7 +31,7 @@
"java": ">=25",
"fabric-api": ">=0.154.2+26.2",
"ambiance": "*",
"sanctuary": ">=0.0.0-alpha.117"
"sanctuary": ">=0.0.0-alpha.131"
},
"custom": {
"sanctuary26": {
@@ -1,5 +1,7 @@
package fr.koka99cab.sanctuary26.anotherworld.vault;
import java.util.UUID;
public final class VaultRulesSmoke {
private VaultRulesSmoke() {
}
@@ -55,6 +57,14 @@ public final class VaultRulesSmoke {
require(VaultRules.raidLoot(Integer.MAX_VALUE) == 429_496_730L, "32-bit balance raid");
require(VaultRules.raidLoot(Long.MAX_VALUE) == 1_844_674_407_370_955_162L,
"64-bit balance raid without overflow");
UUID owner = UUID.fromString("00000000-0000-0000-0000-000000000001");
UUID attacker = UUID.fromString("00000000-0000-0000-0000-000000000002");
require(!VaultData.canReceiveRaidLoot(owner, attacker, false),
"an attacker without a registered vault cannot receive raid loot");
require(VaultData.canReceiveRaidLoot(owner, attacker, true),
"an attacker with a registered vault can receive raid loot");
require(!VaultData.canReceiveRaidLoot(owner, owner, true),
"a vault owner cannot receive loot from their own vault");
require(VaultRules.saturatingAdd(Long.MAX_VALUE - 2L, 10L) == Long.MAX_VALUE,
"balance saturation without overflow");
for (long balance : new long[] {0L, Integer.MAX_VALUE, (long) Integer.MAX_VALUE + 1L, Long.MAX_VALUE}) {
+1369 -293
View File
File diff suppressed because it is too large Load Diff
+8 -8
View File
@@ -6,7 +6,7 @@ org.gradle.configuration-cache=false
minecraft_version=26.2
loader_version=0.19.3
loom_version=1.17-SNAPSHOT
fabric_api_version=0.158.0+26.2
fabric_api_version=0.159.0+26.2
# Sanctuary 26.2
# Standby modules stay at zero until their migration really begins.
@@ -14,21 +14,21 @@ mod_version=0.0.0-alpha.0
module_lifecycle=standby
ambiance_version=0.0.0-alpha.22
ambiance_lifecycle=active
redstoner_version=0.0.0-alpha.13
redstoner_version=0.0.0-alpha.18
redstoner_lifecycle=active
anotherworld_version=0.0.0-alpha.55
anotherworld_version=0.0.0-alpha.57
anotherworld_lifecycle=active
itsalive_version=0.0.0-alpha.37
itsalive_version=0.0.0-alpha.38
itsalive_lifecycle=active
ouch_version=0.0.0-alpha.11
ouch_lifecycle=active
masterkey_version=0.0.0-alpha.9
masterkey_lifecycle=active
iliketomoveit_version=0.0.0-alpha.16
iliketomoveit_version=0.0.0-alpha.18
iliketomoveit_lifecycle=active
onlyfun_version=0.0.0-alpha.25
onlyfun_version=0.0.0-alpha.27
onlyfun_lifecycle=active
sanctuary_version=0.0.0-alpha.126
sanctuary_version=0.0.0-alpha.137
sanctuary_lifecycle=active
pack_version=26.2.0-alpha.223
pack_version=26.2.0-alpha.230
maven_group=fr.koka99cab.sanctuary26
+66
View File
@@ -0,0 +1,66 @@
# Magic Carpet et Totem de Notch
I Like To Move It possède l'objet, la plateforme temporaire, la remise physique
de la récompense et la compatibilité de l'ancien Totem. Sanctuary reste
propriétaire du jalon mondial et de la réservation unique ; Only Fun possède le
catalogue et applique le jalon avant d'exposer l'offre.
## Identités et provenance
| Rôle | ID | Statut |
|---|---|---|
| objet canonique | `iliketomoveit:magic_carpet` | distribué après Notch puis achetable au Shop |
| Totem historique | `portals:notch_totem` | alias caché, lisible et converti vers l'objet canonique |
| jalon mondial | `sanctuary:notch_defeated` | autorité serveur Sanctuary |
La conversion utilise `ItemStack.transmuteCopy` : quantité, composants et nom
personnalisé sont conservés. Les inventaires joueurs sont traités à la connexion,
les conteneurs vanilla lors de leur chargement et les entités d'item dès leur
tick serveur. Un Totem produit exactement un tapis et les nouveaux mondes ne
distribuent jamais l'ancien ID. La donnée I Like To Move It passe en v4 ; une
pile déjà convertie ne correspond plus à l'alias et ne peut donc pas être
convertie une seconde fois.
Chaque tapis porte une provenance Sanctuary sans autorité de gameplay :
`notch_reward`, `shop_purchase` ou `legacy_notch_totem`. Le serveur ne se fie
jamais à cette étiquette pour autoriser un achat ; elle sert à l'historique, au
diagnostic et à l'infobulle.
## Première récompense
Après la première victoire mondiale, Sanctuary réserve atomiquement la
récompense puis I Like To Move It crée un coffre déterministe près de la maison
de Notch. Le tapis unique est placé au centre et un feu d'artifice signale le
coffre. Sanctuary ne marque la livraison terminée qu'après avoir retrouvé ou
créé ce coffre.
Les états `initial_reward_claimed` et `initial_reward_delivered` sont distincts.
Une reprise entre les deux relance la création de façon idempotente ; un coffre
déjà créé et marqué est reconnu sans recevoir de second tapis. Les anciennes
sauvegardes v1 dont la récompense était déjà déclarée remise sont migrées vers
l'état livré afin de ne rien dupliquer.
## Plateforme temporaire
Tenir le tapis en main principale ou secondaire maintient neuf blocs de verre
sous le joueur. Seul l'air est remplacé : terrain, liquides, plantes et blocs
construits restent intacts. Le joueur conserve ses capacités normales ; seul le
dégât de chute est réinitialisé tant que la plateforme est active.
Chaque position possède un ensemble implicite de propriétaires. Deux tapis
peuvent se chevaucher et le verre ne disparaît qu'après le départ du dernier.
Le nettoyage est effectué côté serveur au relâchement, à la déconnexion, au
changement de dimension et pendant l'arrêt normal du serveur.
## Remplacement au Shop
Only Fun associe le Magic Carpet au resolver public
`SanctuaryWorldMilestones`. Avant `sanctuary:notch_defeated`, l'offre est
absente des snapshots et toute tentative réseau est rejetée par Sanctuary.
Après la victoire, elle rejoint la rotation normale au prix configuré de
1 536 rubis et 128 saphirs : les saphirs débloquent le catalogue, les rubis
paient chaque remplacement et la Mailbox effectue la livraison différée.
Un achat porte la provenance `shop_purchase`, est journalisé comme remplacement
et ne touche jamais aux états de réservation ou de coffre de la récompense
initiale.
+19 -10
View File
@@ -32,6 +32,14 @@ tasks.register("alphaPortalContractSmoke", JavaExec) {
dependsOn tasks.named("testClasses")
}
tasks.register("magicCarpetLedgerSmoke", JavaExec) {
group = "verification"
description = "Checks Magic Carpet overlap, dimension-change and shutdown cleanup ownership."
classpath = sourceSets.test.runtimeClasspath
mainClass = "fr.koka99cab.sanctuary26.iliketomoveit.transport.MagicCarpetLedgerSmoke"
dependsOn tasks.named("testClasses")
}
tasks.named("test") {
// Runtime contracts are executable smoke tasks, not JUnit engine tests.
failOnNoDiscoveredTests = false
@@ -100,11 +108,11 @@ tasks.register("verifyWaystones") {
if (!missingResources.isEmpty()) throw new GradleException("Missing Waystone resources: ${missingResources}")
def manifest = new JsonSlurper().parse(file("src/main/resources/fabric.mod.json"))
if (manifest.custom?.sanctuary26?.data_version != 3
if (manifest.custom?.sanctuary26?.data_version != 4
|| manifest.custom?.sanctuary26?.network_protocol != 5
|| manifest.depends?.anotherworld != ">=0.0.0-alpha.46"
|| manifest.depends?.sanctuary != ">=0.0.0-alpha.21") {
throw new GradleException("I Like To Move It must expose data v3, protocol 5 and its Another World alpha.46/Sanctuary alpha.21 dependencies")
|| manifest.depends?.sanctuary != ">=0.0.0-alpha.127") {
throw new GradleException("I Like To Move It must expose data v4, protocol 5 and its Another World alpha.46/Sanctuary alpha.127 dependencies")
}
["fr_fr", "en_us", "ru_ru"].each { language ->
def translations = new JsonSlurper().parse(file("src/main/resources/assets/iliketomoveit/lang/${language}.json"))
@@ -203,9 +211,9 @@ tasks.register("verifyGrappling") {
def manifest = new JsonSlurper().parse(file("src/main/resources/fabric.mod.json"))
if (!manifest.mixins?.any { it.config == "iliketomoveit.mixins.json" }
|| !manifest.mixins?.any { it.config == "iliketomoveit.client.mixins.json" && it.environment == "client" }
|| manifest.custom?.sanctuary26?.data_version != 3
|| manifest.custom?.sanctuary26?.data_version != 4
|| manifest.custom?.sanctuary26?.network_protocol != 5) {
throw new GradleException("I Like To Move It must keep aggregate data v3/protocol 5 and register its common/client mixins")
throw new GradleException("I Like To Move It must expose aggregate data v4/protocol 5 and register its common/client mixins")
}
["fr_fr", "en_us", "ru_ru"].each { language ->
def translations = new JsonSlurper().parse(file("src/main/resources/assets/iliketomoveit/lang/${language}.json"))
@@ -313,7 +321,7 @@ tasks.register("verifyPortals") {
}
def atlasCavernsMigration = new JsonSlurper().parse(rootProject.file(
"pack/migrations/26.2.0-alpha.149-atlas-caverns-to-alpha.150.json"))
if (project.version.toString() != "0.0.0-alpha.16"
if (project.version.toString() != "0.0.0-alpha.18"
|| atlasCavernsMigration.target?.pack_version != "26.2.0-alpha.150"
|| atlasCavernsMigration.target?.modules?.iliketomoveit != "0.0.0-alpha.9"
|| atlasCavernsMigration.portals?.active_routes != [
@@ -349,7 +357,7 @@ tasks.register("verifySilverAircraft") {
def manifest = new JsonSlurper().parse(file("src/main/resources/fabric.mod.json"))
def migration = new JsonSlurper().parse(rootProject.file(
"pack/migrations/26.2.0-alpha.184-silver-engineering-to-alpha.185.json"))
if (project.version.toString() != "0.0.0-alpha.16"
if (project.version.toString() != "0.0.0-alpha.18"
|| recipe.pattern != ["PGP", "GCG", "PBP"]
|| recipe.key != [B: "anotherworld:silver_block", C: "anotherworld:aircraft_cockpit",
G: "anotherworld:silver_gear", P: "anotherworld:silver_plate"]
@@ -378,7 +386,7 @@ tasks.register("verifyGrapplePrediction") {
def payload = file("src/main/java/fr/koka99cab/sanctuary26/iliketomoveit/network/GrappleStatePayload.java").text
def controller = file("src/main/java/fr/koka99cab/sanctuary26/iliketomoveit/grapple/GrappleController.java").text
def prediction = file("src/main/java/fr/koka99cab/sanctuary26/iliketomoveit/client/grapple/ClientGrapplePrediction.java").text
if (project.version.toString() != "0.0.0-alpha.16"
if (project.version.toString() != "0.0.0-alpha.18"
|| migration.target?.modules?.iliketomoveit != "0.0.0-alpha.13"
|| migration.grappling?.owner_prediction_payload != "iliketomoveit:s2c/grapple_state"
|| migration.compatibility?.iliketomoveit_source_network_protocol != 4
@@ -410,7 +418,7 @@ tasks.register("verifyWaystoneDescendingRelease") {
"src/main/java/fr/koka99cab/sanctuary26/iliketomoveit/waystone/WaystoneElevatorRules.java").text
def teleportation = file(
"src/main/java/fr/koka99cab/sanctuary26/iliketomoveit/network/WaystoneTeleportation.java").text
if (project.version.toString() != "0.0.0-alpha.16"
if (project.version.toString() != "0.0.0-alpha.18"
|| migration.target?.modules?.iliketomoveit != "0.0.0-alpha.14"
|| migration.waystone_elevator?.undiscovered_downward_destination_allowed != true
|| migration.waystone_elevator?.destination_discovered_after_arrival != true
@@ -444,7 +452,7 @@ tasks.register("verifyAlphaPortal") {
def locales = ["fr_fr", "en_us", "ru_ru"].collect {
new JsonSlurper().parse(file("src/main/resources/assets/iliketomoveit/lang/${it}.json"))
}
if (project.version.toString() != "0.0.0-alpha.16"
if (project.version.toString() != "0.0.0-alpha.18"
|| route.schema_version != 2 || route.source_dimension != "minecraft:overworld"
|| route.destination_dimension != "sanctuary:alpha"
|| route.destination_resolver != "fixed"
@@ -466,6 +474,7 @@ tasks.register("verifyAlphaPortal") {
tasks.named("check") {
dependsOn tasks.named("grapplePhysicsSmoke")
dependsOn tasks.named("magicCarpetLedgerSmoke")
dependsOn tasks.named("waystoneElevatorRulesSmoke")
dependsOn tasks.named("happyGhastCruiseSpeedSmoke")
dependsOn tasks.named("verifyWaystones")
@@ -8,6 +8,8 @@ import fr.koka99cab.sanctuary26.iliketomoveit.pulley.PulleyHeadController;
import fr.koka99cab.sanctuary26.iliketomoveit.registry.GrapplingLootTables;
import fr.koka99cab.sanctuary26.iliketomoveit.registry.ILikeToMoveItRegistries;
import fr.koka99cab.sanctuary26.iliketomoveit.transport.MagicCarpetController;
import fr.koka99cab.sanctuary26.iliketomoveit.transport.MagicCarpetMigrationService;
import fr.koka99cab.sanctuary26.iliketomoveit.transport.NotchCarpetRewardService;
import fr.koka99cab.sanctuary26.iliketomoveit.waystone.WaystoneElevatorController;
import net.fabricmc.api.ModInitializer;
import net.minecraft.resources.Identifier;
@@ -17,7 +19,7 @@ import org.slf4j.LoggerFactory;
public final class ILikeToMoveItMod implements ModInitializer {
public static final String MOD_ID = "iliketomoveit";
public static final String DISPLAY_NAME = "I Like To Move It";
public static final int CURRENT_DATA_VERSION = 3;
public static final int CURRENT_DATA_VERSION = 4;
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
public ILikeToMoveItMod() {
@@ -37,6 +39,8 @@ public final class ILikeToMoveItMod implements ModInitializer {
GrappleController.register();
PulleyHeadController.register();
MagicCarpetController.register();
MagicCarpetMigrationService.register();
NotchCarpetRewardService.register();
WaystoneElevatorController.initialize();
LOGGER.info("[{}] Portals, vehicles, grappling, pulleys, Magic Carpet and dimension-local Waystones ready (data v{}, network v{}).",
DISPLAY_NAME, CURRENT_DATA_VERSION, ILikeToMoveItNetworking.PROTOCOL_VERSION);
@@ -0,0 +1,41 @@
package fr.koka99cab.sanctuary26.iliketomoveit.item;
import fr.koka99cab.sanctuary26.sanctuary.api.item.SanctuaryItemProvenance;
import java.util.function.Consumer;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.item.component.TooltipDisplay;
/** Epic carpet with explicit behaviour and provenance in its tooltip. */
public final class MagicCarpetItem extends Item {
public MagicCarpetItem(Properties properties) {
super(properties);
}
@Override
public void appendHoverText(ItemStack stack, TooltipContext context, TooltipDisplay display,
Consumer<Component> tooltip, TooltipFlag flag) {
tooltip.accept(Component.translatable("item.iliketomoveit.magic_carpet.description")
.withStyle(ChatFormatting.GRAY));
var origin = SanctuaryItemProvenance.origin(stack);
if (SanctuaryItemProvenance.NOTCH_REWARD.equals(origin)) {
tooltip.accept(Component.translatable("item.iliketomoveit.magic_carpet.origin.notch")
.withStyle(ChatFormatting.GOLD));
} else if (SanctuaryItemProvenance.SHOP_PURCHASE.equals(origin)) {
tooltip.accept(Component.translatable("item.iliketomoveit.magic_carpet.origin.shop")
.withStyle(ChatFormatting.AQUA));
} else if (SanctuaryItemProvenance.LEGACY_NOTCH_TOTEM.equals(origin)) {
tooltip.accept(Component.translatable("item.iliketomoveit.magic_carpet.origin.legacy")
.withStyle(ChatFormatting.DARK_PURPLE));
}
}
@Override
public boolean isFoil(ItemStack stack) {
return SanctuaryItemProvenance.hasOrigin(stack, SanctuaryItemProvenance.NOTCH_REWARD)
|| super.isFoil(stack);
}
}
@@ -0,0 +1,19 @@
package fr.koka99cab.sanctuary26.iliketomoveit.mixin;
import fr.koka99cab.sanctuary26.iliketomoveit.transport.MagicCarpetMigration;
import net.minecraft.world.Container;
import net.minecraft.world.level.block.entity.BaseContainerBlockEntity;
import net.minecraft.world.level.storage.ValueInput;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
/** Converts historical Totems as loaded chests and other vanilla containers are decoded. */
@Mixin(BaseContainerBlockEntity.class)
abstract class MagicCarpetContainerMixin {
@Inject(method = "loadAdditional", at = @At("TAIL"))
private void sanctuary26$migrateNotchTotem(ValueInput input, CallbackInfo ci) {
MagicCarpetMigration.migrateContainer((Container) (Object) this);
}
}
@@ -0,0 +1,21 @@
package fr.koka99cab.sanctuary26.iliketomoveit.mixin;
import fr.koka99cab.sanctuary26.iliketomoveit.transport.MagicCarpetMigration;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
/** Converts historical Totems already present as loaded item entities. */
@Mixin(ItemEntity.class)
abstract class MagicCarpetItemEntityMixin {
@Inject(method = "tick", at = @At("HEAD"))
private void sanctuary26$migrateNotchTotem(CallbackInfo ci) {
ItemEntity self = (ItemEntity) (Object) this;
ItemStack current = self.getItem();
ItemStack replacement = MagicCarpetMigration.migrateStack(current);
if (replacement != current) self.setItem(replacement);
}
}
@@ -3,6 +3,7 @@ package fr.koka99cab.sanctuary26.iliketomoveit.registry;
import fr.koka99cab.sanctuary26.iliketomoveit.ILikeToMoveItMod;
import fr.koka99cab.sanctuary26.iliketomoveit.item.AircraftItem;
import fr.koka99cab.sanctuary26.iliketomoveit.item.GrapplingRodItem;
import fr.koka99cab.sanctuary26.iliketomoveit.item.MagicCarpetItem;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
@@ -25,7 +26,11 @@ public final class ILikeToMoveItItems {
key -> new BoatItem(ILikeToMoveItEntityTypes.MAGIC_CLOUD,
new Item.Properties().stacksTo(1).rarity(Rarity.UNCOMMON).setId(key)));
public static final Item MAGIC_CARPET = register("magic_carpet",
key -> new Item(new Item.Properties().stacksTo(1).rarity(Rarity.EPIC).setId(key)));
key -> new MagicCarpetItem(new Item.Properties().stacksTo(1).rarity(Rarity.EPIC).setId(key)));
/** Hidden read-preserving alias for inventories saved by the historical MagicCarpet mod. */
public static final Item LEGACY_NOTCH_TOTEM = register(
Identifier.fromNamespaceAndPath("portals", "notch_totem"),
key -> new MagicCarpetItem(new Item.Properties().stacksTo(1).rarity(Rarity.EPIC).setId(key)));
public static final Item GRAPPLING_HAND = register("grappling_hand",
key -> new Item(new Item.Properties().setId(key)));
public static final Item GRAPPLING_ROD = register("grappling_rod",
@@ -1,10 +1,7 @@
package fr.koka99cab.sanctuary26.iliketomoveit.transport;
import fr.koka99cab.sanctuary26.iliketomoveit.ILikeToMoveItMod;
import fr.koka99cab.sanctuary26.iliketomoveit.registry.ILikeToMoveItItems;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
@@ -27,7 +24,7 @@ public final class MagicCarpetController {
private static final int RADIUS = 1;
private static final Block CARPET_BLOCK = Blocks.GLASS;
private static final BlockState CARPET_STATE = CARPET_BLOCK.defaultBlockState();
private static final Map<UUID, CarpetState> ACTIVE_CARPETS = new HashMap<>();
private static final MagicCarpetLedger ACTIVE_CARPETS = new MagicCarpetLedger();
private MagicCarpetController() {
}
@@ -45,8 +42,8 @@ public final class MagicCarpetController {
connected.add(id);
boolean active = !player.isSpectator() && (isMagicCarpet(player.getMainHandItem()) || isMagicCarpet(player.getOffhandItem()));
if (active) {
if (!ACTIVE_CARPETS.containsKey(id)) {
ACTIVE_CARPETS.put(id, CarpetState.empty(player.level().dimension()));
if (!ACTIVE_CARPETS.contains(id)) {
ACTIVE_CARPETS.track(id, player.level().dimension(), Set.of());
player.sendOverlayMessage(Component.translatable("message.iliketomoveit.magic_carpet.enabled"));
}
updateCarpet(id, player);
@@ -54,27 +51,26 @@ public final class MagicCarpetController {
deactivate(server, id, true);
}
}
Iterator<Map.Entry<UUID, CarpetState>> iterator = ACTIVE_CARPETS.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<UUID, CarpetState> entry = iterator.next();
if (!connected.contains(entry.getKey())) {
removePositions(server, entry.getKey(), entry.getValue(), entry.getValue().positions());
iterator.remove();
for (UUID owner : ACTIVE_CARPETS.owners()) {
if (!connected.contains(owner)) {
MagicCarpetLedger.State state = ACTIVE_CARPETS.remove(owner);
if (state != null) removePositions(server, owner, state, state.positions());
}
}
}
private static boolean isMagicCarpet(ItemStack stack) {
return !stack.isEmpty() && stack.is(ILikeToMoveItItems.MAGIC_CARPET);
return MagicCarpetMigration.isAnyCarpet(stack);
}
private static void updateCarpet(UUID owner, ServerPlayer player) {
ServerLevel level = player.level();
CarpetState previous = ACTIVE_CARPETS.getOrDefault(owner, CarpetState.empty(level.dimension()));
MagicCarpetLedger.State previous = ACTIVE_CARPETS.state(owner, level.dimension());
Set<BlockPos> target = carpetPositions(player.blockPosition().below(player.isCrouching() ? 2 : 1));
if (!previous.dimension().equals(level.dimension())) {
removePositions(level.getServer(), owner, previous, previous.positions());
previous = CarpetState.empty(level.dimension());
ACTIVE_CARPETS.remove(owner);
previous = ACTIVE_CARPETS.state(owner, level.dimension());
} else {
Set<BlockPos> stale = new HashSet<>(previous.positions());
stale.removeAll(target);
@@ -91,7 +87,7 @@ public final class MagicCarpetController {
placed.add(pos);
}
}
ACTIVE_CARPETS.put(owner, new CarpetState(level.dimension(), Set.copyOf(placed)));
ACTIVE_CARPETS.track(owner, level.dimension(), placed);
player.resetFallDistance();
}
@@ -104,14 +100,14 @@ public final class MagicCarpetController {
}
private static void deactivate(MinecraftServer server, UUID owner, boolean notify) {
CarpetState state = ACTIVE_CARPETS.remove(owner);
MagicCarpetLedger.State state = ACTIVE_CARPETS.remove(owner);
if (state == null) return;
removePositions(server, owner, state, state.positions());
ServerPlayer player = server.getPlayerList().getPlayer(owner);
if (notify && player != null) player.sendOverlayMessage(Component.translatable("message.iliketomoveit.magic_carpet.disabled"));
}
private static void removePositions(MinecraftServer server, UUID owner, CarpetState state, Set<BlockPos> positions) {
private static void removePositions(MinecraftServer server, UUID owner, MagicCarpetLedger.State state, Set<BlockPos> positions) {
ServerLevel level = server.getLevel(state.dimension());
if (level == null) return;
for (BlockPos pos : positions) {
@@ -122,18 +118,13 @@ public final class MagicCarpetController {
}
private static boolean isTrackedByAnother(UUID owner, ResourceKey<Level> dimension, BlockPos pos) {
return ACTIVE_CARPETS.entrySet().stream().anyMatch(entry -> !entry.getKey().equals(owner)
&& entry.getValue().dimension().equals(dimension) && entry.getValue().positions().contains(pos));
return ACTIVE_CARPETS.trackedByAnother(owner, dimension, pos);
}
private static void reset(MinecraftServer server) {
Map<UUID, CarpetState> copy = new HashMap<>(ACTIVE_CARPETS);
ACTIVE_CARPETS.clear();
Map<UUID, MagicCarpetLedger.State> copy = ACTIVE_CARPETS.drain();
copy.forEach((owner, state) -> removePositions(server, owner, state, state.positions()));
ILikeToMoveItMod.LOGGER.debug("Magic Carpet temporary platforms cleaned.");
}
private record CarpetState(ResourceKey<Level> dimension, Set<BlockPos> positions) {
private static CarpetState empty(ResourceKey<Level> dimension) { return new CarpetState(dimension, Set.of()); }
}
}
@@ -0,0 +1,56 @@
package fr.koka99cab.sanctuary26.iliketomoveit.transport;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.Level;
/** Pure ownership ledger preventing overlapping temporary platforms from deleting each other. */
public final class MagicCarpetLedger {
private final Map<UUID, State> carpets = new HashMap<>();
public boolean contains(UUID owner) {
return carpets.containsKey(owner);
}
public State state(UUID owner, ResourceKey<Level> dimension) {
return carpets.getOrDefault(owner, State.empty(dimension));
}
public void track(UUID owner, ResourceKey<Level> dimension, Set<BlockPos> positions) {
carpets.put(owner, new State(dimension, Set.copyOf(positions)));
}
public State remove(UUID owner) {
return carpets.remove(owner);
}
public Set<UUID> owners() {
return Set.copyOf(carpets.keySet());
}
public boolean trackedByAnother(UUID owner, ResourceKey<Level> dimension, BlockPos pos) {
return carpets.entrySet().stream().anyMatch(entry -> !entry.getKey().equals(owner)
&& entry.getValue().dimension().equals(dimension)
&& entry.getValue().positions().contains(pos));
}
public Map<UUID, State> drain() {
Map<UUID, State> copy = Map.copyOf(carpets);
carpets.clear();
return copy;
}
public record State(ResourceKey<Level> dimension, Set<BlockPos> positions) {
public State {
positions = Set.copyOf(positions);
}
private static State empty(ResourceKey<Level> dimension) {
return new State(dimension, Set.of());
}
}
}
@@ -0,0 +1,39 @@
package fr.koka99cab.sanctuary26.iliketomoveit.transport;
import fr.koka99cab.sanctuary26.iliketomoveit.registry.ILikeToMoveItItems;
import fr.koka99cab.sanctuary26.sanctuary.api.item.SanctuaryItemProvenance;
import net.minecraft.world.Container;
import net.minecraft.world.item.ItemStack;
/** Read-preserving conversion from the historical Totem identity to the canonical carpet. */
public final class MagicCarpetMigration {
private MagicCarpetMigration() {
}
public static boolean isAnyCarpet(ItemStack stack) {
return stack != null && !stack.isEmpty()
&& (stack.is(ILikeToMoveItItems.MAGIC_CARPET)
|| stack.is(ILikeToMoveItItems.LEGACY_NOTCH_TOTEM));
}
public static ItemStack migrateStack(ItemStack stack) {
if (stack == null || stack.isEmpty() || !stack.is(ILikeToMoveItItems.LEGACY_NOTCH_TOTEM)) return stack;
ItemStack migrated = stack.transmuteCopy(ILikeToMoveItItems.MAGIC_CARPET, stack.getCount());
SanctuaryItemProvenance.stampIfAbsent(migrated, SanctuaryItemProvenance.LEGACY_NOTCH_TOTEM);
return migrated;
}
public static int migrateContainer(Container container) {
if (container == null) return 0;
int migrated = 0;
for (int slot = 0; slot < container.getContainerSize(); slot++) {
ItemStack current = container.getItem(slot);
ItemStack replacement = migrateStack(current);
if (replacement == current) continue;
container.setItem(slot, replacement);
migrated++;
}
if (migrated > 0) container.setChanged();
return migrated;
}
}
@@ -0,0 +1,34 @@
package fr.koka99cab.sanctuary26.iliketomoveit.transport;
import fr.koka99cab.sanctuary26.iliketomoveit.ILikeToMoveItMod;
import fr.koka99cab.sanctuary26.iliketomoveit.data.ILikeToMoveItData;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
/** Converts online inventories once their historical alias has been decoded. */
public final class MagicCarpetMigrationService {
private MagicCarpetMigrationService() {
}
public static void register() {
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> migrate(handler.player));
ServerTickEvents.END_SERVER_TICK.register(MagicCarpetMigrationService::tick);
}
private static void tick(MinecraftServer server) {
ILikeToMoveItData.get(server);
if (server.overworld().getGameTime() % 20L != 0L) return;
for (ServerPlayer player : server.getPlayerList().getPlayers()) migrate(player);
}
private static void migrate(ServerPlayer player) {
int migrated = MagicCarpetMigration.migrateContainer(player.getInventory());
migrated += MagicCarpetMigration.migrateContainer(player.getEnderChestInventory());
if (migrated > 0) {
ILikeToMoveItMod.LOGGER.info("[Magic Carpet] Migrated {} historical Totem stack(s) for {}.",
migrated, player.getGameProfile().name());
}
}
}
@@ -0,0 +1,124 @@
package fr.koka99cab.sanctuary26.iliketomoveit.transport;
import fr.koka99cab.sanctuary26.iliketomoveit.ILikeToMoveItMod;
import fr.koka99cab.sanctuary26.iliketomoveit.registry.ILikeToMoveItItems;
import fr.koka99cab.sanctuary26.sanctuary.api.item.SanctuaryItemProvenance;
import fr.koka99cab.sanctuary26.sanctuary.api.notch.SanctuaryNotchMilestone;
import fr.koka99cab.sanctuary26.sanctuary.api.world.SanctuaryAlphaWorld;
import fr.koka99cab.sanctuary26.sanctuary.world.SanctuaryDimensions;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import java.util.ArrayList;
import java.util.List;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.minecraft.core.BlockPos;
import net.minecraft.core.component.DataComponents;
import net.minecraft.network.chat.Component;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.Container;
import net.minecraft.world.entity.projectile.FireworkRocketEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.component.FireworkExplosion;
import net.minecraft.world.item.component.Fireworks;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.ChestBlockEntity;
/** Idempotently materializes the globally reserved Magic Carpet in Alpha. */
public final class NotchCarpetRewardService {
private static final int REWARD_SLOT = 13;
private NotchCarpetRewardService() {
}
public static void register() {
ServerTickEvents.END_SERVER_TICK.register(NotchCarpetRewardService::tick);
}
private static void tick(MinecraftServer server) {
if (server.overworld().getGameTime() % 20L != 0L) return;
var state = SanctuaryNotchMilestone.snapshot(server);
if (!state.defeated() || state.initialRewardDelivered()) return;
if (!state.initialRewardClaimed() && !SanctuaryNotchMilestone.claimInitialReward(server)) return;
ServerLevel alpha = server.getLevel(SanctuaryDimensions.ALPHA);
if (alpha == null) return;
BlockPos home = SanctuaryAlphaWorld.residence(alpha.getSeed());
if (!alpha.isLoaded(home)) return;
RewardChest result = ensureRewardChest(alpha, home);
if (result == null || !SanctuaryNotchMilestone.completeInitialReward(server)) return;
if (result.created()) {
launchFirework(alpha, result.pos());
server.getPlayerList().broadcastSystemMessage(
Component.translatable("message.iliketomoveit.magic_carpet.reward_created"), false);
}
ILikeToMoveItMod.LOGGER.info(
"[Magic Carpet] Completed unique Notch reward at {} (origin=notch_reward, recovered={}).",
result.pos().toShortString(), !result.created());
}
private static RewardChest ensureRewardChest(ServerLevel level, BlockPos home) {
List<BlockPos> candidates = candidates(home);
for (BlockPos pos : candidates) {
if (containsInitialReward(level, pos)) return new RewardChest(pos, false);
}
for (BlockPos pos : candidates) {
if (!level.getBlockState(pos).isAir() || !level.getBlockState(pos.above()).isAir()
|| level.getBlockState(pos.below()).isAir()) continue;
if (!level.setBlock(pos, Blocks.CHEST.defaultBlockState(), Block.UPDATE_ALL)) continue;
if (level.getBlockEntity(pos) instanceof ChestBlockEntity chest) {
chest.setItem(REWARD_SLOT, rewardStack());
chest.setChanged();
level.sendBlockUpdated(pos, level.getBlockState(pos), level.getBlockState(pos), Block.UPDATE_ALL);
return new RewardChest(pos, true);
}
level.setBlock(pos, Blocks.AIR.defaultBlockState(), Block.UPDATE_ALL);
}
return null;
}
private static boolean containsInitialReward(ServerLevel level, BlockPos pos) {
if (level.getBlockState(pos).getBlock() != Blocks.CHEST
|| !(level.getBlockEntity(pos) instanceof Container container)) return false;
for (ItemStack stack : container) {
if (stack.is(ILikeToMoveItItems.MAGIC_CARPET)
&& SanctuaryItemProvenance.hasOrigin(stack, SanctuaryItemProvenance.NOTCH_REWARD)) return true;
}
return false;
}
private static ItemStack rewardStack() {
ItemStack reward = new ItemStack(ILikeToMoveItItems.MAGIC_CARPET);
reward.set(DataComponents.CUSTOM_NAME,
Component.translatable("item.iliketomoveit.magic_carpet.notch_reward_name"));
SanctuaryItemProvenance.stamp(reward, SanctuaryItemProvenance.NOTCH_REWARD);
return reward;
}
private static List<BlockPos> candidates(BlockPos home) {
ArrayList<BlockPos> positions = new ArrayList<>();
for (int y : new int[] {0, 1, -1, 2}) {
for (int radius = 2; radius <= 7; radius++) {
for (int x = -radius; x <= radius; x++) for (int z = -radius; z <= radius; z++) {
if (Math.max(Math.abs(x), Math.abs(z)) != radius) continue;
BlockPos candidate = home.offset(x, y, z).immutable();
if (SanctuaryAlphaWorld.containsHorizontal(candidate)) positions.add(candidate);
}
}
}
return List.copyOf(positions);
}
private static void launchFirework(ServerLevel level, BlockPos pos) {
ItemStack rocket = new ItemStack(Items.FIREWORK_ROCKET);
FireworkExplosion explosion = new FireworkExplosion(FireworkExplosion.Shape.STAR,
new IntArrayList(new int[] {0xE8B923, 0xF1F1F1}),
new IntArrayList(new int[] {0x9B59B6}), true, true);
rocket.set(DataComponents.FIREWORKS, new Fireworks(1, List.of(explosion)));
level.addFreshEntity(new FireworkRocketEntity(level, pos.getX() + 0.5D,
pos.getY() + 1.2D, pos.getZ() + 0.5D, rocket));
}
private record RewardChest(BlockPos pos, boolean created) {
}
}
@@ -3,7 +3,13 @@
"itemGroup.iliketomoveit.transport": "I Like To Move It",
"item.iliketomoveit.aircraft": "Aircraft",
"item.iliketomoveit.magic_cloud": "Magic Cloud",
"item.iliketomoveit.magic_carpet": "Magic Carpet (laboratory)",
"item.iliketomoveit.magic_carpet": "Magic Carpet",
"item.portals.notch_totem": "Notch Totem (legacy)",
"item.iliketomoveit.magic_carpet.notch_reward_name": "Notch's Magic Carpet",
"item.iliketomoveit.magic_carpet.description": "Hold it to maintain a temporary 3 × 3 platform beneath your feet.",
"item.iliketomoveit.magic_carpet.origin.notch": "Unique world reward from Notch",
"item.iliketomoveit.magic_carpet.origin.shop": "Replacement purchased from the Shop",
"item.iliketomoveit.magic_carpet.origin.legacy": "Converted from the historical Notch Totem",
"block.iliketomoveit.waystone": "Waystone",
"block.waystone.waystone": "Waystone (legacy)",
"entity.iliketomoveit.aircraft": "Aircraft",
@@ -11,6 +17,7 @@
"container.iliketomoveit.aircraft_engine": "Aircraft Engine",
"message.iliketomoveit.magic_carpet.enabled": "Magic Carpet enabled",
"message.iliketomoveit.magic_carpet.disabled": "Magic Carpet disabled",
"message.iliketomoveit.magic_carpet.reward_created": "Notch's unique Magic Carpet appeared in a chest near his house.",
"subtitles.iliketomoveit.magic_cloud.fly": "Magic Cloud flies",
"screen.iliketomoveit.waystone.title": "Waystones",
"screen.iliketomoveit.waystone.empty": "No other waystone in this dimension",
@@ -3,7 +3,13 @@
"itemGroup.iliketomoveit.transport": "I Like To Move It",
"item.iliketomoveit.aircraft": "Avion",
"item.iliketomoveit.magic_cloud": "Nuage magique",
"item.iliketomoveit.magic_carpet": "Tapis magique (laboratoire)",
"item.iliketomoveit.magic_carpet": "Tapis magique",
"item.portals.notch_totem": "Totem de Notch (hérité)",
"item.iliketomoveit.magic_carpet.notch_reward_name": "Tapis magique de Notch",
"item.iliketomoveit.magic_carpet.description": "Tenu en main, il maintient une plateforme temporaire 3 × 3 sous vos pieds.",
"item.iliketomoveit.magic_carpet.origin.notch": "Récompense mondiale unique de Notch",
"item.iliketomoveit.magic_carpet.origin.shop": "Remplacement acheté au Shop",
"item.iliketomoveit.magic_carpet.origin.legacy": "Converti depuis le Totem de Notch historique",
"block.iliketomoveit.waystone": "Pierre de voyage",
"block.waystone.waystone": "Pierre de voyage (héritée)",
"entity.iliketomoveit.aircraft": "Avion",
@@ -11,6 +17,7 @@
"container.iliketomoveit.aircraft_engine": "Moteur de l'avion",
"message.iliketomoveit.magic_carpet.enabled": "Tapis magique activé",
"message.iliketomoveit.magic_carpet.disabled": "Tapis magique désactivé",
"message.iliketomoveit.magic_carpet.reward_created": "Le Tapis magique unique de Notch est apparu dans un coffre près de sa maison.",
"subtitles.iliketomoveit.magic_cloud.fly": "Le nuage magique vole",
"screen.iliketomoveit.waystone.title": "Pierres de voyage",
"screen.iliketomoveit.waystone.empty": "Aucune autre pierre dans cette dimension",
@@ -3,7 +3,13 @@
"itemGroup.iliketomoveit.transport": "I Like To Move It",
"item.iliketomoveit.aircraft": "Самолёт",
"item.iliketomoveit.magic_cloud": "Волшебное облако",
"item.iliketomoveit.magic_carpet": "Ковёр-самолёт (лаборатория)",
"item.iliketomoveit.magic_carpet": "Ковёр-самолёт",
"item.portals.notch_totem": "Тотем Нотча (старый)",
"item.iliketomoveit.magic_carpet.notch_reward_name": "Ковёр-самолёт Нотча",
"item.iliketomoveit.magic_carpet.description": "В руке поддерживает временную платформу 3 × 3 под ногами.",
"item.iliketomoveit.magic_carpet.origin.notch": "Уникальная мировая награда за Нотча",
"item.iliketomoveit.magic_carpet.origin.shop": "Замена, купленная в Магазине",
"item.iliketomoveit.magic_carpet.origin.legacy": "Преобразован из исторического Тотема Нотча",
"block.iliketomoveit.waystone": "Камень пути",
"block.waystone.waystone": "Камень пути (старый)",
"entity.iliketomoveit.aircraft": "Самолёт",
@@ -11,6 +17,7 @@
"container.iliketomoveit.aircraft_engine": "Двигатель самолёта",
"message.iliketomoveit.magic_carpet.enabled": "Ковёр-самолёт включён",
"message.iliketomoveit.magic_carpet.disabled": "Ковёр-самолёт выключен",
"message.iliketomoveit.magic_carpet.reward_created": "Уникальный ковёр-самолёт Нотча появился в сундуке возле его дома.",
"subtitles.iliketomoveit.magic_cloud.fly": "Волшебное облако летит",
"screen.iliketomoveit.waystone.title": "Камни пути",
"screen.iliketomoveit.waystone.empty": "В этом измерении нет других камней",
@@ -1,6 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "minecraft:block/purple_wool"
"layer0": "iliketomoveit:item/magic_carpet"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 366 B

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "iliketomoveit:item/magic_carpet"
}
}
@@ -33,13 +33,13 @@
"java": ">=25",
"fabric-api": ">=0.154.2+26.2",
"anotherworld": ">=0.0.0-alpha.46",
"sanctuary": ">=0.0.0-alpha.21"
"sanctuary": ">=0.0.0-alpha.127"
},
"custom": {
"sanctuary26": {
"system_type": "gameplay-system",
"namespace": "iliketomoveit",
"data_version": 3,
"data_version": 4,
"network_protocol": 5,
"lifecycle": "${lifecycle}",
"pack_version": "${pack_version}",
@@ -3,7 +3,9 @@
"package": "fr.koka99cab.sanctuary26.iliketomoveit.mixin",
"compatibilityLevel": "JAVA_25",
"mixins": [
"HappyGhastMixin"
"HappyGhastMixin",
"MagicCarpetContainerMixin",
"MagicCarpetItemEntityMixin"
],
"injectors": {
"defaultRequire": 1
@@ -0,0 +1,45 @@
package fr.koka99cab.sanctuary26.iliketomoveit.transport;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import net.minecraft.core.BlockPos;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.Identifier;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.Level;
/** Regression checks for overlap, world changes and shutdown cleanup ownership. */
public final class MagicCarpetLedgerSmoke {
private MagicCarpetLedgerSmoke() {
}
public static void main(String[] args) {
MagicCarpetLedger ledger = new MagicCarpetLedger();
UUID first = UUID.fromString("00000000-0000-0000-0000-000000000001");
UUID second = UUID.fromString("00000000-0000-0000-0000-000000000002");
ResourceKey<Level> firstWorld = ResourceKey.create(Registries.DIMENSION,
Identifier.fromNamespaceAndPath("test", "first"));
ResourceKey<Level> secondWorld = ResourceKey.create(Registries.DIMENSION,
Identifier.fromNamespaceAndPath("test", "second"));
BlockPos shared = new BlockPos(4, 70, 4);
ledger.track(first, firstWorld, Set.of(shared));
ledger.track(second, firstWorld, Set.of(shared));
if (!ledger.trackedByAnother(first, firstWorld, shared)) {
throw new AssertionError("Overlapping carpets lost their second owner");
}
ledger.remove(first);
if (ledger.trackedByAnother(second, firstWorld, shared)) {
throw new AssertionError("Removed owner still controls the shared glass");
}
ledger.track(second, secondWorld, Set.of(new BlockPos(0, 64, 0)));
if (!ledger.state(second, secondWorld).dimension().equals(secondWorld)
|| !ledger.state(second, firstWorld).dimension().equals(secondWorld)) {
throw new AssertionError("Dimension change did not replace the tracked world");
}
Map<UUID, MagicCarpetLedger.State> shutdown = ledger.drain();
if (shutdown.size() != 1 || !ledger.owners().isEmpty()) {
throw new AssertionError("Server shutdown did not atomically drain temporary platforms");
}
}
}
+6 -6
View File
@@ -565,7 +565,7 @@ tasks.register("verifyItsAlive") {
def climateSource = file("src/main/java/fr/koka99cab/sanctuary26/itsalive/agriculture/ClimateCropForaging.java").text
def pineappleSource = file("src/main/java/fr/koka99cab/sanctuary26/itsalive/agriculture/PineappleItem.java").text
def worldgenSource = file("src/main/java/fr/koka99cab/sanctuary26/itsalive/agriculture/ItsAliveAgricultureWorldGeneration.java").text
if (project.version.toString() != "0.0.0-alpha.37"
if (project.version.toString() != "0.0.0-alpha.38"
|| climateMigration.target?.pack_version != "26.2.0-alpha.157"
|| climateMigration.target?.modules?.itsalive != "0.0.0-alpha.24"
|| !climateSource.contains("PlayerBlockBreakEvents.AFTER.register")
@@ -1322,7 +1322,7 @@ tasks.register("verifyCulinaryReliability") {
}
}
}
if (project.version.toString() != "0.0.0-alpha.37"
if (project.version.toString() != "0.0.0-alpha.38"
|| migration.target?.modules?.itsalive != "0.0.0-alpha.28"
|| migration.culinary_fixes?.food_press_contents_destroyed_on_break != true
|| migration.culinary_fixes?.comparator_contract?.blocks?.size() != 6
@@ -1360,7 +1360,7 @@ tasks.register("verifyCauldronBatching") {
def recipe = file("src/main/java/fr/koka99cab/sanctuary26/itsalive/culinary/recipe/CulinaryProcessRecipe.java").text
def cauldron = file("src/main/java/fr/koka99cab/sanctuary26/itsalive/culinary/block/entity/CookingCauldronBlockEntity.java").text
def timed = file("src/main/java/fr/koka99cab/sanctuary26/itsalive/culinary/block/entity/AbstractTimedCulinaryBlockEntity.java").text
if (project.version.toString() != "0.0.0-alpha.37"
if (project.version.toString() != "0.0.0-alpha.38"
|| migration.target?.modules?.itsalive != "0.0.0-alpha.29"
|| migration.cauldron_batches?.logical_stack_limit != 64
|| migration.cauldron_batches?.identity != "same_item_same_components"
@@ -1398,7 +1398,7 @@ tasks.register("verifyFermentationBarrelAutomation") {
def partialMatching = file("src/main/java/fr/koka99cab/sanctuary26/itsalive/culinary/recipe/CulinaryPartialMatching.java").text
def blockstate = new JsonSlurper().parse(
file("src/main/resources/assets/itsalive/blockstates/fermentation_barrel.json"))
if (project.version.toString() != "0.0.0-alpha.37"
if (project.version.toString() != "0.0.0-alpha.38"
|| migration.source?.modules?.itsalive != "0.0.0-alpha.29"
|| migration.target?.modules?.itsalive != "0.0.0-alpha.30"
|| migration.fermentation_barrel?.maximum_units_per_input_slot != 1
@@ -1446,7 +1446,7 @@ tasks.register("verifyCulinaryLecternRelease") {
[(locale): new JsonSlurper().parse(file(
"src/main/resources/assets/itsalive/lang/${locale}.json"))]
}
if (project.version.toString() != "0.0.0-alpha.37"
if (project.version.toString() != "0.0.0-alpha.38"
|| migration.target?.modules?.itsalive != "0.0.0-alpha.31"
|| migration.culinary_lectern?.book_tag != "minecraft:lectern_books"
|| migration.culinary_lectern?.owner_catalog_shared_while_placed != true
@@ -1509,7 +1509,7 @@ tasks.register("verifyCanapliaForbiddenBook") {
fr_fr: "Livre interdit",
en_us: "Forbidden Book",
ru_ru: "Запретная книга"]
if (project.version.toString() != "0.0.0-alpha.37"
if (project.version.toString() != "0.0.0-alpha.38"
|| !pageItem.contains("CanapliaKnowledge.learnRandomUnknown(serverPlayer)")
|| !knowledge.contains("unknownVariants(data.personal(player.getUUID()))")
|| !knowledge.contains("data.personal(inscription.ownerId())")
@@ -34,7 +34,8 @@ public final class CanapliaHarvestService {
public static void onMatureHarvest(ServerLevel level, ServerPlayer player, BlockPos pos, BlockState state) {
if (!state.is(CanapliaContent.HEMP_CROP) || !CanapliaContent.HEMP_CROP.isMaxAge(state)) return;
CanapliaVariantKey parent = state.getValue(CanapliaHempCropBlock.VARIANT);
CanapliaVariantKey parent = CanapliaVariantLifecycle.harvestedFromPlant(
state.getValue(CanapliaHempCropBlock.VARIANT));
CanapliaKnowledge.discover(player, parent, "harvest");
ClimateCropForaging.CropClimate climate = ClimateCropForaging.climate(level.getBiome(pos));
AmbianceLunarHarvestApi.Conditions lunar = AmbianceLunarHarvestApi.evaluate(level, pos);
@@ -65,7 +66,8 @@ public final class CanapliaHarvestService {
if (pos.equals(center)) continue;
BlockState state = level.getBlockState(pos);
if (state.is(CanapliaContent.HEMP_CROP) && CanapliaContent.HEMP_CROP.isMaxAge(state)) {
variants.add(state.getValue(CanapliaHempCropBlock.VARIANT));
variants.add(CanapliaVariantLifecycle.harvestedFromPlant(
state.getValue(CanapliaHempCropBlock.VARIANT)));
}
}
return Set.copyOf(variants);
@@ -0,0 +1,36 @@
package fr.koka99cab.sanctuary26.itsalive.canaplia;
/** Stable variant hand-off across placement, growth, block-state persistence and harvest. */
public final class CanapliaVariantLifecycle {
private CanapliaVariantLifecycle() {
}
public static CanapliaVariantKey plantedFromSeed(CanapliaVariantKey seedVariant) {
return require(seedVariant);
}
public static CanapliaVariantKey afterGrowth(CanapliaVariantKey currentVariant) {
return require(currentVariant);
}
public static CanapliaVariantKey upperFromLower(CanapliaVariantKey lowerVariant) {
return require(lowerVariant);
}
public static CanapliaVariantKey harvestedFromPlant(CanapliaVariantKey plantVariant) {
return require(plantVariant);
}
public static String persistedKey(CanapliaVariantKey variant) {
return require(variant).key();
}
public static CanapliaVariantKey fromPersistedKey(String key) {
return CanapliaVariantKey.byKey(key).orElse(CanapliaVariantKey.COMMON);
}
private static CanapliaVariantKey require(CanapliaVariantKey variant) {
if (variant == null) throw new IllegalArgumentException("Canaplia variant cannot be null");
return variant;
}
}
@@ -2,6 +2,7 @@ package fr.koka99cab.sanctuary26.itsalive.canaplia.block;
import fr.koka99cab.sanctuary26.itsalive.canaplia.CanapliaContent;
import fr.koka99cab.sanctuary26.itsalive.canaplia.CanapliaHarvestService;
import fr.koka99cab.sanctuary26.itsalive.canaplia.CanapliaVariantLifecycle;
import fr.koka99cab.sanctuary26.itsalive.canaplia.CanapliaVariantKey;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
@@ -43,19 +44,28 @@ public final class CanapliaHempCropBlock extends CropBlock {
@Override
protected ItemStack getCloneItemStack(LevelReader level, BlockPos pos, BlockState state, boolean includeData) {
return new ItemStack(CanapliaContent.family(state.getValue(VARIANT)).seeds());
CanapliaVariantKey variant = CanapliaVariantLifecycle.harvestedFromPlant(state.getValue(VARIANT));
return new ItemStack(CanapliaContent.family(variant).seeds());
}
@Override
protected void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) {
super.randomTick(state, level, pos, random);
synchronizeUpper(level, pos, level.getBlockState(pos));
if (level.getRawBrightness(pos, 0) < 9) return;
int age = getAge(state);
if (age >= getMaxAge()) return;
float speed = getGrowthSpeed(this, level, pos);
if (random.nextInt((int) (25.0F / speed) + 1) != 0) return;
BlockState grown = state.setValue(AGE, age + 1).setValue(VARIANT,
CanapliaVariantLifecycle.afterGrowth(state.getValue(VARIANT)));
level.setBlock(pos, grown, Block.UPDATE_CLIENTS);
synchronizeUpper(level, pos, grown);
}
@Override
public void growCrops(Level level, BlockPos pos, BlockState state) {
int age = Math.min(getMaxAge(), getAge(state) + getBonemealAgeIncrease(level));
BlockState grown = state.setValue(AGE, age);
BlockState grown = state.setValue(AGE, age).setValue(VARIANT,
CanapliaVariantLifecycle.afterGrowth(state.getValue(VARIANT)));
level.setBlock(pos, grown, Block.UPDATE_CLIENTS);
synchronizeUpper(level, pos, grown);
}
@@ -78,7 +88,7 @@ public final class CanapliaHempCropBlock extends CropBlock {
if (!(level instanceof ServerLevel serverLevel) || !(player instanceof ServerPlayer serverPlayer)) {
return InteractionResult.FAIL;
}
CanapliaVariantKey variant = state.getValue(VARIANT);
CanapliaVariantKey variant = CanapliaVariantLifecycle.harvestedFromPlant(state.getValue(VARIANT));
Block.popResource(serverLevel, pos,
new ItemStack(CanapliaContent.family(variant).bud(), 1 + serverLevel.getRandom().nextInt(3)));
CanapliaHarvestService.onMatureHarvest(serverLevel, serverPlayer, pos, state);
@@ -97,7 +107,8 @@ public final class CanapliaHempCropBlock extends CropBlock {
if (getAge(state) >= UPPER_START_AGE) {
if (aboveState.isAir() || aboveState.is(CanapliaContent.HEMP_TOP)) {
level.setBlock(above, CanapliaContent.HEMP_TOP.defaultBlockState()
.setValue(AGE, getAge(state)).setValue(VARIANT, state.getValue(VARIANT)), Block.UPDATE_CLIENTS);
.setValue(AGE, getAge(state)).setValue(VARIANT,
CanapliaVariantLifecycle.upperFromLower(state.getValue(VARIANT))), Block.UPDATE_CLIENTS);
}
} else if (aboveState.is(CanapliaContent.HEMP_TOP)) {
level.removeBlock(above, false);
@@ -1,6 +1,7 @@
package fr.koka99cab.sanctuary26.itsalive.canaplia.block;
import fr.koka99cab.sanctuary26.itsalive.canaplia.CanapliaContent;
import fr.koka99cab.sanctuary26.itsalive.canaplia.CanapliaVariantLifecycle;
import fr.koka99cab.sanctuary26.itsalive.canaplia.CanapliaVariantKey;
import net.minecraft.core.BlockPos;
import net.minecraft.world.item.ItemStack;
@@ -26,7 +27,9 @@ public final class CanapliaHempTopBlock extends CropBlock {
@Override
protected ItemStack getCloneItemStack(LevelReader level, BlockPos pos, BlockState state, boolean includeData) {
return new ItemStack(CanapliaContent.family(state.getValue(CanapliaHempCropBlock.VARIANT)).seeds());
CanapliaVariantKey variant = CanapliaVariantLifecycle.harvestedFromPlant(
state.getValue(CanapliaHempCropBlock.VARIANT));
return new ItemStack(CanapliaContent.family(variant).seeds());
}
@Override
@@ -1,5 +1,6 @@
package fr.koka99cab.sanctuary26.itsalive.canaplia.item;
import fr.koka99cab.sanctuary26.itsalive.canaplia.CanapliaVariantLifecycle;
import fr.koka99cab.sanctuary26.itsalive.canaplia.CanapliaVariantKey;
import fr.koka99cab.sanctuary26.itsalive.canaplia.block.CanapliaHempCropBlock;
import fr.koka99cab.sanctuary26.itsalive.canaplia.block.CanapliaResinBlock;
@@ -24,12 +25,17 @@ public final class CanapliaVariantBlockItem extends BlockItem {
@Override
protected BlockState getPlacementState(BlockPlaceContext context) {
BlockState state = super.getPlacementState(context);
if (state == null) return null;
return applyVariant(state, variant);
}
public static BlockState applyVariant(BlockState state, CanapliaVariantKey variant) {
if (state == null || variant == null) return state;
CanapliaVariantKey placed = CanapliaVariantLifecycle.plantedFromSeed(variant);
if (state.hasProperty(CanapliaHempCropBlock.VARIANT)) {
return state.setValue(CanapliaHempCropBlock.VARIANT, variant);
return state.setValue(CanapliaHempCropBlock.VARIANT, placed);
}
if (state.hasProperty(CanapliaResinBlock.VARIANT)) {
return state.setValue(CanapliaResinBlock.VARIANT, variant);
return state.setValue(CanapliaResinBlock.VARIANT, placed);
}
return state;
}
@@ -61,6 +61,22 @@ public final class CanapliaGameplaySmoke {
Set.of(), Temperature.COLD, Humidity.BALANCED, 12, false, false, true, true, false)).isEmpty(),
"lunar harvest requires a sky dimension");
for (CanapliaVariantKey variant : CanapliaVariantKey.values()) {
CanapliaVariantKey placed = CanapliaVariantLifecycle.plantedFromSeed(variant);
assertEquals(variant, placed,
"historical seed placement variant " + variant.key());
CanapliaVariantKey grown = CanapliaVariantLifecycle.afterGrowth(placed);
assertEquals(variant, grown,
"natural growth variant " + variant.key());
CanapliaVariantKey persisted = CanapliaVariantLifecycle.fromPersistedKey(
CanapliaVariantLifecycle.persistedKey(grown));
assertEquals(variant, persisted, "persisted variant " + variant.key());
assertEquals(variant, CanapliaVariantLifecycle.upperFromLower(persisted),
"upper crop variant " + variant.key());
assertEquals(variant, CanapliaVariantLifecycle.harvestedFromPlant(persisted),
"harvest variant " + variant.key());
}
CanapliaEffectRules.Plan minimum = CanapliaEffectRules.plan(0, 1, 0, 0);
assertEquals(CanapliaEffectRules.MIN_PRIMARY_TICKS, minimum.primaryTicks(), "minimum primary duration");
assertTrue(!minimum.badTrip(), "nonzero bad-trip roll");
@@ -48,7 +48,7 @@ public final class OnlyFunMod implements ModInitializer {
OnlyFunCommands.register();
AbjectionActions.initialize();
AbjectionCommands.register();
LOGGER.info("[{}] Loot generator, natural Lucky Blocks, mob lootboxes and chicken rules ready (data v{}, network v{}).",
LOGGER.info("[{}] Loot generator, boss-gated Shop, natural Lucky Blocks, mob lootboxes and chicken rules ready (data v{}, network v{}).",
DISPLAY_NAME, CURRENT_DATA_VERSION, OnlyFunNetworking.PROTOCOL_VERSION);
}
}
@@ -2,6 +2,7 @@ package fr.koka99cab.sanctuary26.onlyfun.loot;
import fr.koka99cab.sanctuary26.onlyfun.OnlyFunMod;
import fr.koka99cab.sanctuary26.onlyfun.registry.OnlyFunRegistries;
import fr.koka99cab.sanctuary26.sanctuary.api.entity.SanctuaryEntityPolicy;
import net.fabricmc.fabric.api.entity.event.v1.ServerLivingEntityEvents;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
@@ -38,7 +39,8 @@ public final class OnlyFunLootboxDrops {
}
private static void afterDeath(LivingEntity entity, DamageSource source) {
if (!(entity instanceof Mob mob) || !(entity.level() instanceof ServerLevel level)) return;
if (SanctuaryEntityPolicy.isTemporaryCompanion(entity)
|| !(entity instanceof Mob mob) || !(entity.level() instanceof ServerLevel level)) return;
ServerPlayer killer = playerKiller(entity, source);
if (killer == null || killer.isSpectator()) return;
@@ -1,29 +1,22 @@
package fr.koka99cab.sanctuary26.onlyfun.shop;
import java.util.Objects;
import fr.koka99cab.sanctuary26.sanctuary.api.notch.SanctuaryNotchMilestone;
import fr.koka99cab.sanctuary26.sanctuary.api.progression.SanctuaryWorldMilestones;
import java.util.Map;
import java.util.Set;
import net.minecraft.resources.Identifier;
import net.minecraft.server.MinecraftServer;
/** Keeps exceptional boss rewards out of the Shop until their future boss owner unlocks them. */
/** Keeps exceptional boss rewards out of the Shop until their public world milestone is reached. */
public final class OnlyFunBossShopGate {
public static final Identifier MAGIC_CLOUD = Identifier.fromNamespaceAndPath("iliketomoveit", "magic_cloud");
public static final Identifier MAGIC_CARPET = Identifier.fromNamespaceAndPath("iliketomoveit", "magic_carpet");
private static final Set<Identifier> BOSS_REWARDS = Set.of(MAGIC_CLOUD, MAGIC_CARPET);
private static final BossUnlockResolver LOCKED = (server, reward) -> false;
private static volatile BossUnlockResolver resolver = LOCKED;
private static final Map<Identifier, Identifier> IMPLEMENTED_MILESTONES = Map.of(
MAGIC_CARPET, SanctuaryNotchMilestone.NOTCH_DEFEATED);
private OnlyFunBossShopGate() {}
/** Called later by the module that owns the bosses and their persistent defeat state. */
public static synchronized void registerUnlockResolver(BossUnlockResolver value) {
Objects.requireNonNull(value, "value");
if (resolver != LOCKED && resolver != value) {
throw new IllegalStateException("A boss Shop unlock resolver is already registered");
}
resolver = value;
}
public static boolean requiresBoss(String itemId) {
Identifier id = Identifier.tryParse(itemId);
return id != null && BOSS_REWARDS.contains(id);
@@ -31,11 +24,13 @@ public final class OnlyFunBossShopGate {
public static boolean isAvailable(MinecraftServer server, String itemId) {
Identifier id = Identifier.tryParse(itemId);
return id == null || !BOSS_REWARDS.contains(id) || resolver.isUnlocked(server, id);
if (id == null || !BOSS_REWARDS.contains(id)) return true;
Identifier milestone = requiredMilestone(id);
return milestone != null && SanctuaryWorldMilestones.isReached(server, milestone);
}
@FunctionalInterface
public interface BossUnlockResolver {
boolean isUnlocked(MinecraftServer server, Identifier rewardItem);
/** Returns null while the corresponding boss contract is not implemented. */
public static Identifier requiredMilestone(Identifier rewardItem) {
return IMPLEMENTED_MILESTONES.get(rewardItem);
}
}
+2 -2
View File
@@ -26,8 +26,8 @@
"minecraft": "~26.2",
"java": ">=25",
"fabric-api": ">=0.154.2+26.2",
"iliketomoveit": "*",
"sanctuary": "*"
"iliketomoveit": ">=0.0.0-alpha.17",
"sanctuary": ">=0.0.0-alpha.129"
},
"custom": {
"sanctuary26": {
@@ -3,6 +3,7 @@ package fr.koka99cab.sanctuary26.onlyfun.shop;
import fr.koka99cab.sanctuary26.onlyfun.policy.OnlyFunItemPolicy;
import fr.koka99cab.sanctuary26.sanctuary.shop.ShopOffer;
import fr.koka99cab.sanctuary26.sanctuary.shop.ShopOfferCatalog;
import fr.koka99cab.sanctuary26.sanctuary.api.notch.SanctuaryNotchMilestone;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -94,12 +95,12 @@ public final class OnlyFunShopCatalogSmoke {
"Magic Cloud must remain boss-gated");
require(!OnlyFunBossShopGate.isAvailable(null, "iliketomoveit:magic_carpet")
&& !OnlyFunBossShopGate.isAvailable(null, "iliketomoveit:magic_cloud"),
"Boss rewards must be unavailable while their bosses do not exist");
OnlyFunBossShopGate.registerUnlockResolver((server, reward) ->
reward.equals(OnlyFunBossShopGate.MAGIC_CARPET));
require(OnlyFunBossShopGate.isAvailable(null, "iliketomoveit:magic_carpet")
&& !OnlyFunBossShopGate.isAvailable(null, "iliketomoveit:magic_cloud"),
"Each future boss must unlock only its corresponding reward");
"Boss rewards must reject lookups without authoritative server state");
require(SanctuaryNotchMilestone.NOTCH_DEFEATED.equals(
OnlyFunBossShopGate.requiredMilestone(OnlyFunBossShopGate.MAGIC_CARPET)),
"Magic Carpet must resolve the public Notch milestone");
require(OnlyFunBossShopGate.requiredMilestone(OnlyFunBossShopGate.MAGIC_CLOUD) == null,
"Magic Cloud must stay locked until its own boss is implemented");
for (String protectedId : List.of(
"anotherworld:ruby", "anotherworld:ruby_block", "anotherworld:deepslate_ruby_ore",
@@ -0,0 +1,129 @@
{
"schema_version": 1,
"status": "released",
"source": {
"pack_version": "26.2.0-alpha.223",
"modules": {
"itsalive": "0.0.0-alpha.36",
"ouch": "0.0.0-alpha.10",
"masterkey": "0.0.0-alpha.8",
"iliketomoveit": "0.0.0-alpha.16",
"onlyfun": "0.0.0-alpha.25",
"sanctuary": "0.0.0-alpha.125"
}
},
"target": {
"pack_version": "26.2.0-alpha.224",
"modules": {
"itsalive": "0.0.0-alpha.37",
"ouch": "0.0.0-alpha.11",
"masterkey": "0.0.0-alpha.9",
"iliketomoveit": "0.0.0-alpha.17",
"onlyfun": "0.0.0-alpha.26",
"sanctuary": "0.0.0-alpha.128"
}
},
"inventory_sort": {
"owner": "sanctuary",
"payload_container_flag": "bounded_boolean",
"sortable_storage_menus": ["chest", "barrel", "shulker_box", "hopper", "dispenser"],
"player_inventory_when_hovered": true,
"hotbar_unchanged": true,
"hotbar_restored_to_bottom_on_login": true,
"hotbar_restored_to_bottom_after_row_purchase": true,
"excluded_menus": ["furnace", "shop", "redstoner_storage_terminal"],
"server_authoritative": true,
"server_validates_open_menu": true
},
"notch_encounter": {
"entity_owner": "itsalive",
"combat_owner": "ouch",
"milestone_owner": "sanctuary",
"diagnostics_owner": "masterkey",
"dimension": "sanctuary:alpha",
"unique_persistent_resident": true,
"legacy_entity": "portals:notch",
"legacy_entity_migrated": true,
"maximum_participants": 8,
"first_transformation_breaks_blocks": true,
"later_attacks_break_blocks": false,
"returned_fireballs_supported": true,
"abandoned_fight_resets": true,
"global_victory_monotonic": true,
"atlas_boss_marker_for_participants": true,
"commands": ["/masterkey notch inspect", "/masterkey notch restore"]
},
"magic_carpet": {
"owner": "iliketomoveit",
"canonical_item": "iliketomoveit:magic_carpet",
"legacy_item": "portals:notch_totem",
"legacy_alias_hidden": true,
"legacy_components_preserved": true,
"legacy_custom_name_preserved": true,
"legacy_locations": ["player_inventory", "container", "item_entity"],
"one_legacy_stack_becomes_one_canonical_stack": true,
"new_worlds_distribute_legacy_item": false,
"temporary_platform": {
"size": [3, 1, 3],
"block": "minecraft:glass",
"air_only_placement": true,
"creative_flight_granted": false,
"overlap_owner_tracking": true,
"cleanup": ["deactivation", "disconnect", "dimension_change", "server_stop"]
}
},
"notch_reward": {
"milestone_owner": "sanctuary",
"milestone": "sanctuary:notch_defeated",
"reservation": "initial_reward_claimed",
"completion": "initial_reward_delivered",
"delivery_owner": "iliketomoveit",
"delivery": "deterministic_chest_near_notch_residence",
"firework_signal": true,
"idempotent_recovery": true,
"maximum_canonical_initial_rewards": 1,
"provenance": "sanctuary:notch_reward"
},
"shop_replacement": {
"catalog_owner": "onlyfun",
"transaction_owner": "sanctuary",
"unlock_resolver": "SanctuaryWorldMilestones",
"hidden_before_notch": true,
"server_authoritative_gate": true,
"configured_ruby_price": 1536,
"configured_sapphire_price": 128,
"daily_rotation_rules_preserved": true,
"mailbox_delivery": true,
"recreates_initial_reward": false,
"provenance": "sanctuary:shop_purchase",
"replacement_logged": true
},
"compatibility": {
"existing_saves_supported": true,
"new_world_required": false,
"save_reset_required": false,
"registry_ids_preserved_or_migrated": true,
"client_server_update_required": true,
"itsalive_data_version": 4,
"itsalive_network_protocol": 4,
"ouch_data_version": 1,
"ouch_network_protocol": 1,
"masterkey_data_version": 1,
"masterkey_network_protocol": 2,
"iliketomoveit_data_version": 4,
"iliketomoveit_network_protocol": 5,
"onlyfun_data_version": 2,
"onlyfun_network_protocol": 3,
"sanctuary_data_version": 13,
"sanctuary_notch_state_data_version": 2,
"sanctuary_source_network_protocol": 22,
"sanctuary_target_network_protocol": 23,
"sanctuary_network_protocol_changed": true
},
"distribution": {
"pack_release_updated": true,
"packwiz_index_refreshed": true,
"prism_modrinth_index_updated": true,
"shared_client_server_mrpack": true
}
}
@@ -0,0 +1,87 @@
{
"schema_version": 1,
"status": "released",
"source": {
"pack_version": "26.2.0-alpha.224",
"modules": {
"anotherworld": "0.0.0-alpha.55",
"itsalive": "0.0.0-alpha.37",
"iliketomoveit": "0.0.0-alpha.17",
"onlyfun": "0.0.0-alpha.26",
"sanctuary": "0.0.0-alpha.128"
}
},
"target": {
"pack_version": "26.2.0-alpha.225",
"modules": {
"anotherworld": "0.0.0-alpha.56",
"itsalive": "0.0.0-alpha.38",
"iliketomoveit": "0.0.0-alpha.18",
"onlyfun": "0.0.0-alpha.27",
"sanctuary": "0.0.0-alpha.129"
}
},
"fixed_issues": [105, 116, 123, 124],
"safe_vault_raid": {
"owner": "anotherworld",
"attacker_requires_registered_vault": true,
"validated_when_drilling_starts": true,
"revalidated_during_drilling": true,
"revalidated_before_balance_transfer": true
},
"temporary_companions": {
"owner": "sanctuary",
"public_policy_api": "SanctuaryEntityPolicy",
"vanilla_loot_suppressed": true,
"experience_suppressed": true,
"quest_board_progress_suppressed": true,
"community_request_progress_suppressed": true,
"onlyfun_lootboxes_suppressed": true
},
"canaplia_variants": {
"owner": "itsalive",
"historical_seed_ids_preserved": 16,
"placement_preserves_variant": true,
"natural_growth_preserves_variant": true,
"bonemeal_preserves_variant": true,
"upper_crop_preserves_variant": true,
"block_state_persistence_preserves_variant": true,
"harvest_and_break_drops_preserve_variant": true,
"mature_neighbors_preserve_variant": true,
"tender_plus_olive_can_produce_gold": true
},
"magic_carpet_texture": {
"owner": "iliketomoveit",
"canonical_item": "iliketomoveit:magic_carpet",
"legacy_item": "portals:notch_totem",
"texture": "iliketomoveit:item/magic_carpet",
"historical_totem_art_restored": true,
"purple_wool_reference_removed": true,
"platform_behavior_changed": false
},
"compatibility": {
"existing_saves_supported": true,
"new_world_required": false,
"save_reset_required": false,
"registry_ids_changed": false,
"persistent_data_formats_changed": false,
"network_protocols_changed": false,
"client_server_update_required": true,
"anotherworld_data_version": 5,
"anotherworld_network_protocol": 2,
"itsalive_data_version": 4,
"itsalive_network_protocol": 4,
"iliketomoveit_data_version": 4,
"iliketomoveit_network_protocol": 5,
"onlyfun_data_version": 2,
"onlyfun_network_protocol": 3,
"sanctuary_data_version": 13,
"sanctuary_network_protocol": 23
},
"distribution": {
"pack_release_updated": true,
"packwiz_index_refreshed": true,
"prism_modrinth_index_updated": true,
"shared_client_server_mrpack": true
}
}
@@ -0,0 +1,49 @@
{
"schema_version": 1,
"status": "released",
"source": {
"pack_version": "26.2.0-alpha.225",
"modules": {
"sanctuary": "0.0.0-alpha.129"
}
},
"target": {
"pack_version": "26.2.0-alpha.226",
"modules": {
"sanctuary": "0.0.0-alpha.130"
}
},
"white_cape": {
"owner": "sanctuary",
"item_id": "sanctuary:white_cape",
"crafting_material": "minecraft:white_wool",
"crafting_material_count": 6,
"crafting_pattern": ["WW", "WW", "WW"],
"banner_decoration_recipe": "cape_plus_banner",
"accepted_banners": "#minecraft:banners",
"base_color_preserved": true,
"maximum_pattern_layers": 6,
"inventory_pattern_rendering": true,
"equipped_pattern_rendering": true,
"vanilla_cape_physics": true,
"included_in_onlyfun_lootbox": false
},
"compatibility": {
"existing_saves_supported": true,
"new_world_required": false,
"save_reset_required": false,
"registry_ids_added": ["sanctuary:white_cape"],
"persistent_data_formats_changed": false,
"sanctuary_data_version": 13,
"sanctuary_source_network_protocol": 23,
"sanctuary_target_network_protocol": 24,
"sanctuary_network_protocol_changed": true,
"client_server_update_required": true
},
"distribution": {
"pack_release_updated": true,
"packwiz_index_refreshed": true,
"prism_modrinth_index_updated": true,
"shared_client_server_mrpack": true
}
}
@@ -0,0 +1,60 @@
{
"schema_version": 1,
"status": "released",
"source": {
"pack_version": "26.2.0-alpha.226",
"modules": {
"anotherworld": "0.0.0-alpha.56",
"sanctuary": "0.0.0-alpha.130"
}
},
"target": {
"pack_version": "26.2.0-alpha.227",
"modules": {
"anotherworld": "0.0.0-alpha.57",
"sanctuary": "0.0.0-alpha.131"
}
},
"backroom": {
"owner": "sanctuary",
"dimension": "sanctuary:backroom",
"entry_requires_sneaking_at_bed": true,
"exit_requires_bed": true,
"arrival_radius_blocks": 2000,
"entry_inventory_to_mailbox": true,
"entry_transfer_atomic": true,
"entry_transfer_idempotent": true,
"lost_items_persisted": true,
"lost_item_registry_bounded": true,
"renewable_chests": true,
"personal_losses_prioritized": true,
"shared_old_losses_supported": true,
"anotherworld_material_api": "BackroomMaterialApi"
},
"compatibility": {
"existing_saves_supported": true,
"new_world_required": false,
"save_reset_required": false,
"sanctuary_source_data_version": 13,
"sanctuary_target_data_version": 14,
"sanctuary_network_protocol": 24,
"network_protocol_changed": false,
"client_server_update_required": true
},
"distribution": {
"pack_release_updated": true,
"packwiz_index_refreshed": true,
"prism_modrinth_index_updated": true,
"shared_client_server_mrpack": true,
"fabric_api": {
"source": "0.158.0+26.2",
"target": "0.159.0+26.2",
"modrinth_version_id": "BgeCGgGZ"
},
"jei": {
"source": "30.29.0.198",
"target": "30.29.0.199",
"modrinth_version_id": "astSvyl6"
}
}
}
@@ -0,0 +1,58 @@
{
"schema_version": 1,
"status": "released",
"source": {
"pack_version": "26.2.0-alpha.227",
"modules": {
"redstoner": "0.0.0-alpha.13",
"sanctuary": "0.0.0-alpha.131"
}
},
"target": {
"pack_version": "26.2.0-alpha.228",
"modules": {
"redstoner": "0.0.0-alpha.15",
"sanctuary": "0.0.0-alpha.132"
}
},
"backroom": {
"level_count": 5,
"minimum_y": -64,
"maximum_y_exclusive": 384,
"entry_floor_y": 367,
"monsters_disabled": true,
"arrival_torch": true,
"matching_vertical_transitions": true,
"connected_maze": true,
"dense_city_and_highways": true,
"three_dimensional_brick_grid": true,
"intentional_void_holes": true
},
"storage_terminal": {
"click_to_focus": true,
"inventory_key_closes": true,
"shulker_contents_searchable": true,
"shulker_remains_result": true,
"vanilla_shulker_preview_preserved": true
},
"compatibility": {
"existing_saves_supported": true,
"new_world_required": false,
"save_reset_required": false,
"persistent_data_formats_changed": false,
"network_protocols_changed": false,
"redstoner_data_version": 3,
"redstoner_network_protocol": 7,
"sanctuary_data_version": 14,
"sanctuary_network_protocol": 24,
"client_server_update_required": true,
"existing_backroom_chunks_preserved": true,
"new_backroom_generation_applies_to_new_chunks": true
},
"distribution": {
"pack_release_updated": true,
"packwiz_index_refreshed": true,
"prism_modrinth_index_updated": true,
"shared_client_server_mrpack": true
}
}
@@ -0,0 +1,45 @@
{
"schema_version": 1,
"status": "released",
"source": {
"pack_version": "26.2.0-alpha.228",
"modules": {
"redstoner": "0.0.0-alpha.15"
}
},
"target": {
"pack_version": "26.2.0-alpha.229",
"modules": {
"redstoner": "0.0.0-alpha.16"
}
},
"storage_terminal_sorting": {
"owner": "redstoner",
"modes": [
"alphabetical",
"count_ascending",
"count_descending"
],
"server_authoritative": true,
"explicit_user_action": true,
"returns_to_first_page": true,
"periodic_refresh_preserves_order": true,
"periodic_refresh_preserves_hovered_stack": true
},
"compatibility": {
"existing_saves_supported": true,
"new_world_required": false,
"save_reset_required": false,
"persistent_data_formats_changed": false,
"network_protocols_changed": false,
"redstoner_data_version": 3,
"redstoner_network_protocol": 7,
"client_server_update_required": true
},
"distribution": {
"pack_release_updated": true,
"packwiz_index_refreshed": true,
"prism_modrinth_index_updated": true,
"shared_client_server_mrpack": true
}
}
@@ -0,0 +1,44 @@
{
"schema_version": 1,
"status": "released",
"source": {
"pack_version": "26.2.0-alpha.229",
"modules": {
"sanctuary": "0.0.0-alpha.132",
"redstoner": "0.0.0-alpha.16"
}
},
"target": {
"pack_version": "26.2.0-alpha.230",
"modules": {
"sanctuary": "0.0.0-alpha.136",
"redstoner": "0.0.0-alpha.17"
}
},
"sanctuary_polish": {
"quest_completion_attribution": true,
"backroom_exit_beds_on_every_level": true,
"persistent_public_rankings": true,
"redstoner_trophy_panel": true,
"white_cape_shield_pattern_projection": true,
"adult_chicken_wolf_armor": true
},
"compatibility": {
"existing_saves_supported": true,
"new_world_required": false,
"save_reset_required": false,
"persistent_data_formats_changed": true,
"network_protocols_changed": false,
"sanctuary_data_version": 15,
"sanctuary_network_protocol": 24,
"redstoner_data_version": 4,
"redstoner_network_protocol": 7,
"client_server_update_required": true
},
"distribution": {
"pack_release_updated": true,
"packwiz_index_refreshed": true,
"prism_modrinth_index_updated": true,
"shared_client_server_mrpack": true
}
}
@@ -0,0 +1,38 @@
{
"schema_version": 1,
"status": "released",
"module": "sanctuary",
"source_module_version": "0.0.0-alpha.130",
"target_module_version": "0.0.0-alpha.131",
"integration_modules": {
"anotherworld": {
"source": "0.0.0-alpha.56",
"target": "0.0.0-alpha.57",
"data_version_changed": false,
"network_protocol_changed": false
}
},
"source_data_version": 13,
"target_data_version": 14,
"migration": {
"kind": "monotone_addition",
"save_key": "sanctuary:backroom",
"existing_player_progress_preserved": true,
"existing_shop_data_preserved": true,
"existing_mailboxes_preserved": true,
"mailbox_transaction_history_default": [],
"backroom_loss_registry_default": [],
"backroom_chest_registry_default": []
},
"compatibility": {
"existing_saves_supported": true,
"new_world_required": false,
"save_reset_required": false,
"network_protocol_changed": false,
"registry_ids_added": [
"sanctuary:backroom",
"sanctuary:backroom_loss_id",
"sanctuary:backroom_architecture"
]
}
}
@@ -0,0 +1,36 @@
{
"schema_version": 1,
"status": "released",
"modules": {
"sanctuary": {
"source_module_version": "0.0.0-alpha.134",
"target_module_version": "0.0.0-alpha.135",
"source_data_version": 14,
"target_data_version": 15
},
"redstoner": {
"source_module_version": "0.0.0-alpha.16",
"target_module_version": "0.0.0-alpha.17",
"source_data_version": 3,
"target_data_version": 4
}
},
"migration": {
"kind": "monotone_addition",
"ranking_save_key": "sanctuary:rankings",
"vanilla_statistics_imported_once": true,
"player_identity": "uuid",
"ranking_metric_index_version": 1,
"trophy_panel_id": "redstoner:trophy_panel",
"trophy_panel_data_version": 1,
"existing_redstoner_block_entities_unchanged": true
},
"compatibility": {
"existing_saves_supported": true,
"new_world_required": false,
"save_reset_required": false,
"network_protocols_changed": false,
"newer_ranking_data_is_read_only": true,
"newer_panel_data_is_read_only": true
}
}
+20 -20
View File
@@ -14,24 +14,24 @@ hash = "41f4f4c88c71d0a23446d5014f7407d55ad477441847099cad24492b032335a0"
[[files]]
file = "mods/ambiance-0.0.0-alpha.22.jar"
hash = "34aa79ab54ba2506b0ffef062662917de8b29f6f3f9b8d7a920a664d01185641"
hash = "cdc60ed8f15ca910f41954d9acb6a74ac103e85c73f665fd1bc67be7eab1f15a"
[[files]]
file = "mods/anotherworld-0.0.0-alpha.55.jar"
hash = "2c93c364af7f617a488a8ef5c64d584041eeb24b93e4ea727570c042bd73fe2d"
file = "mods/anotherworld-0.0.0-alpha.57.jar"
hash = "634a122b406bd7206fd19947687fd7cb37e4cc4098822eecf3f0b7d1fea79d90"
[[files]]
file = "mods/events-0.0.0-alpha.0.jar"
hash = "6c94ba89f6daf64d7144e9ea2283a98a609a01a20b7913bd51821034ee8a26fd"
hash = "09bd8dfccca004de46ad3237728ef532de50d04c31b88f1e33721204d3c70cd8"
[[files]]
file = "mods/fabric-api.pw.toml"
hash = "df032a6b051d0262cf24945c43e0e6b915e8cc1d62af62fe933932e7f35960c4"
hash = "b8ea5f403a0cdfbfd5ab1704bb61278e8dcf31b525db9c242b22047852d34f85"
metafile = true
[[files]]
file = "mods/iliketomoveit-0.0.0-alpha.16.jar"
hash = "f0f54b9746977b085abb74fea61e8cd230f3dda905cc337866e7950fb2ee9293"
file = "mods/iliketomoveit-0.0.0-alpha.18.jar"
hash = "cd026c4735e945ec6cc19261165033dc10bcbbba75af412f4145e54437a61854"
[[files]]
file = "mods/iris.pw.toml"
@@ -39,33 +39,33 @@ hash = "84a3cef87679c0d21dceb4641167dc0368b9a3593698f6a3632485e9b3a8d5da"
metafile = true
[[files]]
file = "mods/itsalive-0.0.0-alpha.36.jar"
hash = "ae2201e91e4ab2eaf09f32ea41c920d460cf3cf426e71bd76be5241b7e81e1a0"
file = "mods/itsalive-0.0.0-alpha.38.jar"
hash = "d905a05edbcb841b173ef5b0090fe7a117ec06e119fba7e184338fec7671fde6"
[[files]]
file = "mods/jei.pw.toml"
hash = "cffb13bae33cd8df605c62e7fa66089428dc684e0ab973f662a8a710c45c306d"
hash = "9cc4a91f57effc48b94f6acc1f43067bb8eb99fd1df3397612c55761de9ec2c2"
metafile = true
[[files]]
file = "mods/masterkey-0.0.0-alpha.8.jar"
hash = "60de65566b1434709cdfb4c915d5bc6a7f9019dd48ebeaa04fe474f0ec7fd3b4"
file = "mods/masterkey-0.0.0-alpha.9.jar"
hash = "cef973db96c7523fe828a2ca57ce1283ed1da3b1ae3c646a88ea601ecfe4e825"
[[files]]
file = "mods/onlyfun-0.0.0-alpha.25.jar"
hash = "165ffe713b09db64484cceb6c508ac5e53b5d7e69e86ea6658c3e8ea04ee1ccf"
file = "mods/onlyfun-0.0.0-alpha.27.jar"
hash = "1ff5b8853c5a813bbb6c6cf5787c8311d8e72760ed0e9c2adb1da897241e4e1e"
[[files]]
file = "mods/ouch-0.0.0-alpha.10.jar"
hash = "3f66a1b0657c40b653ec9e7a7aa92e4edf72475af7e372a49d9254743696f0a5"
file = "mods/ouch-0.0.0-alpha.11.jar"
hash = "fd609cfe5f96ae1d2b41b2da7faf077047514772b56bbe130251db3bf72c2ac8"
[[files]]
file = "mods/redstoner-0.0.0-alpha.13.jar"
hash = "226c000f5febd841d69420316af2c14dd4ec0ef1c774c21d5926f7120f44b7e6"
file = "mods/redstoner-0.0.0-alpha.17.jar"
hash = "d7bef2bdf533d2c83f7b05549c01a77028dd5edc60418c7244447ca61160f216"
[[files]]
file = "mods/sanctuary-0.0.0-alpha.125.jar"
hash = "f0826d9be66f6498bc0455ea8075bfbaefc97c1f6a7b0d21b225003fe71ad958"
file = "mods/sanctuary-0.0.0-alpha.136.jar"
hash = "973c12a3f26eb516bc1a053ebd18dab3f845645807448ff5638a1e9b26ba28bd"
[[files]]
file = "mods/simple-voice-chat.pw.toml"
+4 -4
View File
@@ -1,14 +1,14 @@
name = "Fabric API"
filename = "fabric-api-0.158.0+26.2.jar"
filename = "fabric-api-0.159.0+26.2.jar"
side = "both"
pin = true
[download]
url = "https://cdn.modrinth.com/data/P7dR8mSH/versions/NqwNSxwA/fabric-api-0.158.0%2B26.2.jar"
url = "https://cdn.modrinth.com/data/P7dR8mSH/versions/BgeCGgGZ/fabric-api-0.159.0%2B26.2.jar"
hash-format = "sha512"
hash = "4c2c1ebe74ffd54875a01ff371b53ba3d8674ac98d561f7dae02a96d3d37fbdbc5f5abc6e820f73b6154d6f873ddd05a442b0998ed2d456863dc0ad972e040a6"
hash = "4d5d9c3daafe19be187f638f2d6de3db26420b8720ef5a266cfa81f79d9019cab8c86e6d47478bbb0b0ee0b8f769204b72c843caa2e4aabd94adc41f3dafb518"
[update]
[update.modrinth]
mod-id = "P7dR8mSH"
version = "NqwNSxwA"
version = "BgeCGgGZ"
+4 -4
View File
@@ -1,14 +1,14 @@
name = "Just Enough Items (JEI)"
filename = "jei-26.2-fabric-30.29.0.198.jar"
filename = "jei-26.2-fabric-30.29.0.199.jar"
side = "both"
pin = true
[download]
url = "https://cdn.modrinth.com/data/u6dRKJwZ/versions/67Dvn8sL/jei-26.2-fabric-30.29.0.198.jar"
url = "https://cdn.modrinth.com/data/u6dRKJwZ/versions/astSvyl6/jei-26.2-fabric-30.29.0.199.jar"
hash-format = "sha512"
hash = "06131c9528549840e07ddc9634e23454cd454380d7749a23d818f0efe0dacc02874e967ceb74a24ee82efb13e0fe2df4026f988a68f54f890586967e91dcaa5b"
hash = "2849ff6a4cc91822798f0c70e7749c298b911c1037fc74e9ab0881734b8d5cb6507fb3169b4a240ef6c37eb6f7c573794c46073ff352f160feee245233b2abe5"
[update]
[update.modrinth]
mod-id = "u6dRKJwZ"
version = "67Dvn8sL"
version = "astSvyl6"
+2 -2
View File
@@ -1,12 +1,12 @@
name = "Sanctuary 26.2"
author = "KOKA99CAB"
version = "26.2.0-alpha.223"
version = "26.2.0-alpha.230"
pack-format = "packwiz:1.1.0"
[index]
file = "index.toml"
hash-format = "sha256"
hash = "9e06da88d562c7a2ed5fbcd56a06779a37715d4f9cf26479ee1a664758ada599"
hash = "a78df91699f1ffa661e1bf59101891a217bd74334ee338b96824f5a9b745e443"
[versions]
fabric = "0.19.3"
+11 -11
View File
@@ -3,37 +3,37 @@
"game": "minecraft",
"name": "Sanctuary 26.2",
"summary": "Sanctuary 26.2 — progression, exploration, worldgen and multiplayer systems by KOKA99CAB.",
"versionId": "26.2.0-alpha.223",
"versionId": "26.2.0-alpha.230",
"files": [
{
"path": "mods/fabric-api-0.158.0+26.2.jar",
"path": "mods/fabric-api-0.159.0+26.2.jar",
"hashes": {
"sha1": "7d0fb560579d28b933bdbc36b47449efe78d3bda",
"sha512": "4c2c1ebe74ffd54875a01ff371b53ba3d8674ac98d561f7dae02a96d3d37fbdbc5f5abc6e820f73b6154d6f873ddd05a442b0998ed2d456863dc0ad972e040a6"
"sha1": "5307b87f8336f27e8f963263ac514f4bc6175d90",
"sha512": "4d5d9c3daafe19be187f638f2d6de3db26420b8720ef5a266cfa81f79d9019cab8c86e6d47478bbb0b0ee0b8f769204b72c843caa2e4aabd94adc41f3dafb518"
},
"env": {
"client": "required",
"server": "required"
},
"downloads": [
"https://cdn.modrinth.com/data/P7dR8mSH/versions/NqwNSxwA/fabric-api-0.158.0%2B26.2.jar"
"https://cdn.modrinth.com/data/P7dR8mSH/versions/BgeCGgGZ/fabric-api-0.159.0%2B26.2.jar"
],
"fileSize": 2535765
"fileSize": 2535793
},
{
"path": "mods/jei-26.2-fabric-30.29.0.198.jar",
"path": "mods/jei-26.2-fabric-30.29.0.199.jar",
"hashes": {
"sha1": "652e964c71a699fdfdd96cda265ea703b13c6ef4",
"sha512": "06131c9528549840e07ddc9634e23454cd454380d7749a23d818f0efe0dacc02874e967ceb74a24ee82efb13e0fe2df4026f988a68f54f890586967e91dcaa5b"
"sha1": "1d6ab9269be16f85fb13a34a36b34ad07a9b32a7",
"sha512": "2849ff6a4cc91822798f0c70e7749c298b911c1037fc74e9ab0881734b8d5cb6507fb3169b4a240ef6c37eb6f7c573794c46073ff352f160feee245233b2abe5"
},
"env": {
"client": "required",
"server": "required"
},
"downloads": [
"https://cdn.modrinth.com/data/u6dRKJwZ/versions/67Dvn8sL/jei-26.2-fabric-30.29.0.198.jar"
"https://cdn.modrinth.com/data/u6dRKJwZ/versions/astSvyl6/jei-26.2-fabric-30.29.0.199.jar"
],
"fileSize": 1839279
"fileSize": 1849188
},
{
"path": "mods/voicechat-fabric-2.6.22+26.2.jar",
+2 -2
View File
@@ -1,6 +1,6 @@
{
"schema_version": 1,
"pack_version": "26.2.0-alpha.223",
"pack_version": "26.2.0-alpha.230",
"release_channel": "alpha",
"minecraft_version": "26.2",
"fabric_loader_version": "0.19.3",
@@ -9,7 +9,7 @@
"project_id": "FgOqyAXd",
"project_slug": "sanctuary-koka99",
"project_url": "https://modrinth.com/modpack/sanctuary-koka99",
"primary_file": "sanctuary-26.2.0-alpha.223.mrpack",
"primary_file": "sanctuary-26.2.0-alpha.230.mrpack",
"shared_client_server_pack": true,
"update_owner": "packwiz-installer",
"check_on_launch": true,
@@ -13,7 +13,7 @@ import org.slf4j.LoggerFactory;
public final class RedStonerMod implements ModInitializer {
public static final String MOD_ID = "redstoner";
public static final String DISPLAY_NAME = "Red-Stoner";
public static final int CURRENT_DATA_VERSION = 3;
public static final int CURRENT_DATA_VERSION = 4;
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
public RedStonerMod() {
@@ -29,7 +29,7 @@ public final class RedStonerMod implements ModInitializer {
RedStonerRegistries.initialize();
RedStonerMenus.initialize();
RedStonerNetworking.initialize();
LOGGER.info("[{}] Computers, Drawer, Particuleur and Storage Terminal ready (data v{}, network v{}).",
LOGGER.info("[{}] Computers, Drawer, Particuleur, Storage Terminal and Trophy Panel ready (data v{}, network v{}).",
DISPLAY_NAME, CURRENT_DATA_VERSION, RedStonerNetworking.PROTOCOL_VERSION);
}
}
@@ -0,0 +1,176 @@
package fr.koka99cab.sanctuary26.redstoner.block;
import com.mojang.serialization.MapCodec;
import fr.koka99cab.sanctuary26.redstoner.block.entity.TrophyPanelBlockEntity;
import fr.koka99cab.sanctuary26.redstoner.registry.RedStonerRegistries;
import java.util.Map;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.permissions.Permissions;
import net.minecraft.util.RandomSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.ScheduledTickAccess;
import net.minecraft.world.level.block.BaseEntityBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
/** Wall-mounted, server-authoritative trophy and ranking panel. */
public final class TrophyPanelBlock extends BaseEntityBlock {
public static final MapCodec<TrophyPanelBlock> CODEC = simpleCodec(TrophyPanelBlock::new);
public static final EnumProperty<Direction> FACING = BlockStateProperties.HORIZONTAL_FACING;
private static final Map<Direction, VoxelShape> SHAPES = Map.of(
Direction.NORTH, Block.box(0.0D, 0.0D, 14.0D, 16.0D, 16.0D, 16.0D),
Direction.SOUTH, Block.box(0.0D, 0.0D, 0.0D, 16.0D, 16.0D, 2.0D),
Direction.WEST, Block.box(14.0D, 0.0D, 0.0D, 16.0D, 16.0D, 16.0D),
Direction.EAST, Block.box(0.0D, 0.0D, 0.0D, 2.0D, 16.0D, 16.0D)
);
public TrophyPanelBlock(BlockBehaviour.Properties properties) {
super(properties);
registerDefaultState(stateDefinition.any().setValue(FACING, Direction.NORTH));
}
@Override
public MapCodec<TrophyPanelBlock> codec() {
return CODEC;
}
@Override
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
return new TrophyPanelBlockEntity(pos, state);
}
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state,
BlockEntityType<T> type) {
if (level.isClientSide()) return null;
return createTickerHelper(type, RedStonerRegistries.TROPHY_PANEL_BLOCK_ENTITY,
TrophyPanelBlockEntity::serverTick);
}
@Override
protected RenderShape getRenderShape(BlockState state) {
return RenderShape.MODEL;
}
@Override
public BlockState getStateForPlacement(BlockPlaceContext context) {
Direction facing = context.getClickedFace();
if (!facing.getAxis().isHorizontal()) return null;
BlockState state = defaultBlockState().setValue(FACING, facing);
return state.canSurvive(context.getLevel(), context.getClickedPos()) ? state : null;
}
@Override
protected boolean canSurvive(BlockState state, LevelReader level, BlockPos pos) {
Direction facing = state.getValue(FACING);
BlockPos support = pos.relative(facing.getOpposite());
return level.getBlockState(support).isFaceSturdy(level, support, facing);
}
@Override
protected BlockState updateShape(BlockState state, LevelReader level, ScheduledTickAccess ticks,
BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, RandomSource random) {
return direction == state.getValue(FACING).getOpposite() && !state.canSurvive(level, pos)
? Blocks.AIR.defaultBlockState()
: super.updateShape(state, level, ticks, pos, direction, neighborPos, neighborState, random);
}
@Override
protected VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
return SHAPES.get(state.getValue(FACING));
}
@Override
public void setPlacedBy(Level level, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) {
super.setPlacedBy(level, pos, state, placer, stack);
if (placer instanceof ServerPlayer player
&& level.getBlockEntity(pos) instanceof TrophyPanelBlockEntity panel) panel.claim(player);
}
@Override
protected InteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos,
Player player, InteractionHand hand, BlockHitResult hit) {
if (level.isClientSide()) return InteractionResult.SUCCESS;
if (!(player instanceof ServerPlayer serverPlayer)
|| !(level.getBlockEntity(pos) instanceof TrophyPanelBlockEntity panel)) return InteractionResult.CONSUME;
if (player.isSecondaryUseActive()) return cycle(panel, serverPlayer, true);
boolean operator = serverPlayer.createCommandSourceStack().permissions()
.hasPermission(Permissions.COMMANDS_GAMEMASTER);
if (!panel.canConfigure(serverPlayer, operator)) {
return cycle(panel, serverPlayer, false);
}
TrophyPanelBlockEntity.ConfigureResult result = panel.configure(serverPlayer, stack);
if (result == TrophyPanelBlockEntity.ConfigureResult.NO_METRIC) {
return cycle(panel, serverPlayer, false);
}
String key = switch (result) {
case SUCCESS -> "configured";
case NO_METRIC -> throw new IllegalStateException("Handled above");
case NEWER_DATA -> "newer_data";
};
serverPlayer.sendSystemMessage(Component.translatable("message.redstoner.trophy_panel." + key));
return InteractionResult.SUCCESS_SERVER;
}
@Override
protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos,
Player player, BlockHitResult hit) {
if (level.isClientSide()) return InteractionResult.SUCCESS;
if (!(player instanceof ServerPlayer serverPlayer)
|| !(level.getBlockEntity(pos) instanceof TrophyPanelBlockEntity panel)) return InteractionResult.CONSUME;
return cycle(panel, serverPlayer, player.isSecondaryUseActive());
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(FACING);
}
@Override
protected BlockState rotate(BlockState state, Rotation rotation) {
return state.setValue(FACING, rotation.rotate(state.getValue(FACING)));
}
@Override
protected BlockState mirror(BlockState state, Mirror mirror) {
return state.rotate(mirror.getRotation(state.getValue(FACING)));
}
private static InteractionResult cycle(TrophyPanelBlockEntity panel, ServerPlayer player, boolean backwards) {
boolean changed = backwards ? panel.previousPage() : panel.nextPage();
if (!changed) {
player.sendSystemMessage(Component.translatable("message.redstoner.trophy_panel.newer_data"));
return InteractionResult.CONSUME;
}
player.sendSystemMessage(Component.translatable("message.redstoner.trophy_panel.page",
panel.pageNumber(), panel.pageCount()));
return InteractionResult.SUCCESS_SERVER;
}
}
@@ -0,0 +1,282 @@
package fr.koka99cab.sanctuary26.redstoner.block.entity;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import fr.koka99cab.sanctuary26.redstoner.block.TrophyPanelBlock;
import fr.koka99cab.sanctuary26.redstoner.registry.RedStonerRegistries;
import fr.koka99cab.sanctuary26.redstoner.trophy.TrophyPanelRules;
import fr.koka99cab.sanctuary26.sanctuary.api.ranking.RankingMetric;
import fr.koka99cab.sanctuary26.sanctuary.api.ranking.RankingSnapshot;
import fr.koka99cab.sanctuary26.sanctuary.api.ranking.RankingUnit;
import fr.koka99cab.sanctuary26.sanctuary.api.ranking.SanctuaryRankingApi;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import net.minecraft.core.BlockPos;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.UUIDUtil;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
import net.minecraft.resources.Identifier;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.ItemOwner;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.storage.ValueInput;
import net.minecraft.world.level.storage.ValueOutput;
import net.minecraft.world.phys.Vec3;
/** Persistent panel configuration plus a transient, bounded client-visible ranking snapshot. */
public final class TrophyPanelBlockEntity extends BlockEntity implements ItemOwner {
private static final int DATA_VERSION = 1;
private static final int REFRESH_INTERVAL_TICKS = 20;
private static final String CLIENT_SNAPSHOT_TAG = "VisibleSnapshot";
private static final Codec<Page> PAGE_CODEC = RecordCodecBuilder.create(instance -> instance.group(
Identifier.CODEC.fieldOf("metric").forGetter(Page::metricId),
ItemStack.OPTIONAL_CODEC.fieldOf("icon").forGetter(Page::icon)
).apply(instance, Page::new));
private static final Codec<ClientEntry> CLIENT_ENTRY_CODEC = RecordCodecBuilder.create(instance -> instance.group(
Codec.STRING.fieldOf("name").forGetter(ClientEntry::name),
Codec.LONG.fieldOf("value").forGetter(ClientEntry::value),
Codec.INT.fieldOf("rank").forGetter(ClientEntry::rank)
).apply(instance, ClientEntry::new));
private static final Codec<ClientSnapshot> CLIENT_SNAPSHOT_CODEC = RecordCodecBuilder.create(instance -> instance.group(
Identifier.CODEC.fieldOf("metric").forGetter(ClientSnapshot::metricId),
Codec.STRING.fieldOf("translation_key").forGetter(ClientSnapshot::translationKey),
Codec.STRING.fieldOf("unit").forGetter(ClientSnapshot::unitKey),
CLIENT_ENTRY_CODEC.listOf(0, RankingSnapshot.MAX_PODIUM_SIZE).fieldOf("podium")
.forGetter(ClientSnapshot::podium),
Codec.LONG.fieldOf("owner_value").forGetter(ClientSnapshot::ownerValue),
Codec.INT.fieldOf("owner_rank").forGetter(ClientSnapshot::ownerRank)
).apply(instance, ClientSnapshot::new));
private int dataVersion = DATA_VERSION;
private UUID owner;
private String ownerName = "?";
private List<Page> pages = List.of(defaultPage());
private int currentPage;
private long lastRefreshTick = Long.MIN_VALUE;
private ClientSnapshot visibleSnapshot = ClientSnapshot.empty(SanctuaryRankingApi.defaultMetric());
public TrophyPanelBlockEntity(BlockPos pos, BlockState state) {
super(RedStonerRegistries.TROPHY_PANEL_BLOCK_ENTITY, pos, state);
}
public static void serverTick(net.minecraft.world.level.Level level, BlockPos pos, BlockState state,
TrophyPanelBlockEntity panel) {
if (!(level instanceof ServerLevel serverLevel)) return;
long now = level.getGameTime();
if (panel.lastRefreshTick != Long.MIN_VALUE && now - panel.lastRefreshTick < REFRESH_INTERVAL_TICKS) return;
panel.lastRefreshTick = now;
panel.refresh(serverLevel);
}
public void claim(ServerPlayer player) {
if (!writable() || owner != null) return;
owner = player.getUUID();
ownerName = cleanName(player.getGameProfile().name());
syncPersistent();
}
public boolean canConfigure(ServerPlayer player, boolean operator) {
return writable() && TrophyPanelRules.canConfigure(owner, player.getUUID(), operator);
}
public ConfigureResult configure(ServerPlayer player, ItemStack stack) {
if (!writable()) return ConfigureResult.NEWER_DATA;
List<RankingMetric> offered = SanctuaryRankingApi.itemMetrics(stack);
if (offered.isEmpty()) return ConfigureResult.NO_METRIC;
List<Identifier> currentIds = pages.stream().map(Page::metricId).toList();
List<Identifier> mergedIds = TrophyPanelRules.mergeMetricIds(currentIds,
offered.stream().map(RankingMetric::id).toList());
List<Page> next = new ArrayList<>();
for (Identifier id : mergedIds) {
Page existing = pages.stream().filter(page -> page.metricId().equals(id)).findFirst().orElse(null);
next.add(existing == null ? new Page(id, stack.copyWithCount(1)) : existing);
}
pages = List.copyOf(next);
currentPage = Math.max(0, pages.indexOf(pages.stream()
.filter(page -> offered.stream().anyMatch(metric -> metric.id().equals(page.metricId())))
.findFirst().orElse(pages.getFirst())));
ownerName = cleanName(player.getGameProfile().name());
syncPersistent();
if (level instanceof ServerLevel serverLevel) refresh(serverLevel);
return ConfigureResult.SUCCESS;
}
public boolean nextPage() {
return movePage(1);
}
public boolean previousPage() {
return movePage(-1);
}
private boolean movePage(int offset) {
if (!writable() || pages.isEmpty()) return false;
currentPage = TrophyPanelRules.pageByOffset(currentPage, pages.size(), offset);
syncPersistent();
if (level instanceof ServerLevel serverLevel) refresh(serverLevel);
return true;
}
public Page currentPage() {
return pages.get(Math.clamp(currentPage, 0, pages.size() - 1));
}
public int pageNumber() {
return currentPage + 1;
}
public int pageCount() {
return pages.size();
}
public String ownerName() {
return ownerName;
}
public ClientSnapshot visibleSnapshot() {
return visibleSnapshot;
}
private void refresh(ServerLevel level) {
Page page = currentPage();
RankingSnapshot snapshot = SanctuaryRankingApi.snapshot(level.getServer(), page.metricId(), owner);
ClientSnapshot next = ClientSnapshot.from(snapshot);
if (next.equals(visibleSnapshot)) return;
visibleSnapshot = next;
level.sendBlockUpdated(worldPosition, getBlockState(), getBlockState(), Block.UPDATE_CLIENTS);
}
@Override
protected void saveAdditional(ValueOutput output) {
super.saveAdditional(output);
output.putInt("DataVersion", dataVersion);
if (owner != null) output.store("Owner", UUIDUtil.CODEC, owner);
output.putString("OwnerName", ownerName);
output.store("Pages", PAGE_CODEC.listOf(0, TrophyPanelRules.MAX_PAGES), pages);
output.putInt("CurrentPage", currentPage);
}
@Override
protected void loadAdditional(ValueInput input) {
super.loadAdditional(input);
dataVersion = Math.max(DATA_VERSION, input.getIntOr("DataVersion", 0));
owner = input.read("Owner", UUIDUtil.CODEC).orElse(null);
ownerName = cleanName(input.getStringOr("OwnerName", "?"));
pages = input.read("Pages", PAGE_CODEC.listOf(0, TrophyPanelRules.MAX_PAGES))
.map(TrophyPanelBlockEntity::sanitizePages).orElseGet(() -> List.of(defaultPage()));
currentPage = Math.clamp(input.getIntOr("CurrentPage", 0), 0, pages.size() - 1);
visibleSnapshot = input.read(CLIENT_SNAPSHOT_TAG, CLIENT_SNAPSHOT_CODEC)
.orElseGet(() -> ClientSnapshot.empty(metricFor(currentPage().metricId())));
}
@Override
public Packet<ClientGamePacketListener> getUpdatePacket() {
return ClientboundBlockEntityDataPacket.create(this);
}
@Override
public CompoundTag getUpdateTag(HolderLookup.Provider lookup) {
CompoundTag tag = saveCustomOnly(lookup);
tag.store(CLIENT_SNAPSHOT_TAG, CLIENT_SNAPSHOT_CODEC, visibleSnapshot);
return tag;
}
@Override
public net.minecraft.world.level.Level level() {
return level;
}
@Override
public Vec3 position() {
return Vec3.atCenterOf(worldPosition);
}
@Override
public float getVisualRotationYInDegrees() {
return getBlockState().getValue(TrophyPanelBlock.FACING).toYRot();
}
private void syncPersistent() {
setChanged();
if (level != null) level.sendBlockUpdated(worldPosition, getBlockState(), getBlockState(), Block.UPDATE_CLIENTS);
}
private boolean writable() {
return dataVersion <= DATA_VERSION;
}
private static List<Page> sanitizePages(List<Page> loaded) {
List<Page> valid = loaded.stream().filter(page -> SanctuaryRankingApi.metric(page.metricId()).isPresent())
.limit(TrophyPanelRules.MAX_PAGES).toList();
return valid.isEmpty() ? List.of(defaultPage()) : List.copyOf(valid);
}
private static Page defaultPage() {
return new Page(SanctuaryRankingApi.defaultMetric().id(), ItemStack.EMPTY);
}
private static RankingMetric metricFor(Identifier id) {
return SanctuaryRankingApi.metric(id).orElse(SanctuaryRankingApi.defaultMetric());
}
private static String cleanName(String name) {
if (name == null || name.isBlank()) return "?";
String clean = name.strip();
return clean.length() > 32 ? clean.substring(0, 32) : clean;
}
public enum ConfigureResult { SUCCESS, NO_METRIC, NEWER_DATA }
public record Page(Identifier metricId, ItemStack icon) {
public Page {
metricId = metricId == null ? SanctuaryRankingApi.defaultMetric().id() : metricId;
// The registry item is enough for an icon. Player components (containers, names, lore) never persist or sync.
icon = icon == null || icon.isEmpty() ? ItemStack.EMPTY : new ItemStack(icon.getItem());
}
}
public record ClientEntry(String name, long value, int rank) {
public ClientEntry {
name = cleanName(name);
value = Math.max(0L, value);
rank = Math.max(0, rank);
}
}
public record ClientSnapshot(Identifier metricId, String translationKey, String unitKey,
List<ClientEntry> podium, long ownerValue, int ownerRank) {
public ClientSnapshot {
translationKey = translationKey == null || translationKey.isBlank()
? "metric.sanctuary.ranking.unknown" : translationKey;
unitKey = RankingUnit.byKey(unitKey).key();
podium = podium == null ? List.of() : List.copyOf(podium.stream()
.limit(RankingSnapshot.MAX_PODIUM_SIZE).toList());
ownerValue = Math.max(0L, ownerValue);
ownerRank = Math.max(0, ownerRank);
}
static ClientSnapshot from(RankingSnapshot snapshot) {
return new ClientSnapshot(snapshot.metric().id(), snapshot.metric().translationKey(),
snapshot.metric().unit().key(), snapshot.podium().stream()
.map(entry -> new ClientEntry(entry.playerName(), entry.value(), entry.rank())).toList(),
snapshot.owner().value(), snapshot.owner().rank());
}
static ClientSnapshot empty(RankingMetric metric) {
return new ClientSnapshot(metric.id(), metric.translationKey(), metric.unit().key(), List.of(), 0L, 0);
}
public RankingUnit unit() {
return RankingUnit.byKey(unitKey);
}
}
}
@@ -5,6 +5,7 @@ import fr.koka99cab.sanctuary26.redstoner.client.gui.ComputerScreen;
import fr.koka99cab.sanctuary26.redstoner.client.gui.PersonalComputerScreen;
import fr.koka99cab.sanctuary26.redstoner.client.gui.StorageTerminalScreen;
import fr.koka99cab.sanctuary26.redstoner.client.renderer.DrawerBlockEntityRenderer;
import fr.koka99cab.sanctuary26.redstoner.client.renderer.TrophyPanelBlockEntityRenderer;
import fr.koka99cab.sanctuary26.redstoner.network.OpenComputerPayload;
import fr.koka99cab.sanctuary26.redstoner.network.OpenPersonalComputerPayload;
import fr.koka99cab.sanctuary26.redstoner.registry.RedStonerMenus;
@@ -19,6 +20,8 @@ public final class RedStonerClient implements ClientModInitializer {
public void onInitializeClient() {
BlockEntityRendererRegistry.register(RedStonerRegistries.DRAWER_BLOCK_ENTITY, DrawerBlockEntityRenderer::new);
BlockEntityRendererRegistry.register(RedStonerRegistries.LEGACY_DRAWER_BLOCK_ENTITY, DrawerBlockEntityRenderer::new);
BlockEntityRendererRegistry.register(RedStonerRegistries.TROPHY_PANEL_BLOCK_ENTITY,
TrophyPanelBlockEntityRenderer::new);
MenuScreens.register(RedStonerMenus.STORAGE_TERMINAL, StorageTerminalScreen::new);
ClientPlayNetworking.registerGlobalReceiver(OpenComputerPayload.TYPE, (payload, context) ->
context.client().execute(() -> context.client().gui.setScreen(new ComputerScreen(payload))));
@@ -2,12 +2,15 @@ package fr.koka99cab.sanctuary26.redstoner.client.gui;
import fr.koka99cab.sanctuary26.redstoner.storage.StorageTerminalMenu;
import fr.koka99cab.sanctuary26.redstoner.storage.StorageTerminalRules;
import fr.koka99cab.sanctuary26.redstoner.storage.StorageTerminalSort;
import fr.koka99cab.sanctuary26.redstoner.storage.StorageTerminalStatus;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.EditBox;
import net.minecraft.client.gui.components.Tooltip;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.client.input.KeyEvent;
import net.minecraft.client.input.MouseButtonEvent;
@@ -28,8 +31,10 @@ public final class StorageTerminalScreen extends AbstractContainerScreen<Storage
private static final int SCROLL_WIDTH = 4;
private int requestedPage;
private EditBox searchBox;
private Button sortButton;
private String searchValue = "";
private String sentSearchValue = "";
private StorageTerminalSort sortMode = StorageTerminalSort.ALPHABETICAL;
public StorageTerminalScreen(StorageTerminalMenu menu, Inventory inventory, Component title) {
super(menu, inventory, title, 176, 222);
@@ -40,13 +45,16 @@ public final class StorageTerminalScreen extends AbstractContainerScreen<Storage
protected void init() {
super.init();
titleLabelY = 6;
searchBox = addRenderableWidget(new EditBox(font, leftPos + 8, topPos + 2, 126, 14,
searchBox = addRenderableWidget(new EditBox(font, leftPos + 8, topPos + 2, 96, 14,
Component.translatable("screen.redstoner.storage_terminal.search")));
searchBox.setMaxLength(StorageTerminalRules.MAX_SEARCH_LENGTH);
searchBox.setHint(Component.translatable("screen.redstoner.storage_terminal.search"));
searchBox.setValue(searchValue);
searchBox.setResponder(this::searchChanged);
setInitialFocus(searchBox);
sortButton = addRenderableWidget(Button.builder(sortButtonLabel(), button -> requestSort())
.bounds(leftPos + 108, topPos + 2, 34, 14)
.tooltip(Tooltip.create(sortTooltip()))
.build());
}
@Override
@@ -114,6 +122,10 @@ public final class StorageTerminalScreen extends AbstractContainerScreen<Storage
@Override
public boolean mouseClicked(MouseButtonEvent event, boolean doubleClick) {
if (searchBox != null && searchBox.isFocused()
&& !searchBox.isMouseOver(event.x(), event.y())) {
clearSearchFocus();
}
if (event.button() == 0
&& isHovering(SCROLL_X - 2, TERMINAL_TOP, SCROLL_WIDTH + 4, TERMINAL_HEIGHT,
event.x(), event.y())) {
@@ -127,9 +139,9 @@ public final class StorageTerminalScreen extends AbstractContainerScreen<Storage
@Override
public boolean keyPressed(KeyEvent event) {
if (searchBox != null && searchBox.isFocused() && event.key() != 256) {
searchBox.keyPressed(event);
return true;
if (searchBox != null && searchBox.isFocused() && minecraft != null
&& minecraft.options.keyInventory.matches(event)) {
clearSearchFocus();
}
return super.keyPressed(event);
}
@@ -148,6 +160,28 @@ public final class StorageTerminalScreen extends AbstractContainerScreen<Storage
}
}
private void requestSort() {
sortMode = sortMode.next();
requestedPage = 0;
sortButton.setMessage(sortButtonLabel());
sortButton.setTooltip(Tooltip.create(sortTooltip()));
sendMenuButton(StorageTerminalMenu.SORT_BUTTON_BASE + sortMode.ordinal());
}
private Component sortButtonLabel() {
return Component.literal(switch (sortMode) {
case ALPHABETICAL -> "A→Z";
case COUNT_ASCENDING -> "1↑";
case COUNT_DESCENDING -> "1↓";
});
}
private Component sortTooltip() {
return Component.translatable("screen.redstoner.storage_terminal.sort",
Component.translatable("screen.redstoner.storage_terminal.sort."
+ sortMode.translationSuffix()));
}
private void searchChanged(String value) {
String previous = sentSearchValue;
searchValue = value;
@@ -173,6 +207,11 @@ public final class StorageTerminalScreen extends AbstractContainerScreen<Storage
}
}
private void clearSearchFocus() {
searchBox.setFocused(false);
setFocused(null);
}
private void extractScrollBar(GuiGraphicsExtractor graphics) {
int x = leftPos + SCROLL_X;
int y = topPos + TERMINAL_TOP;
@@ -0,0 +1,89 @@
package fr.koka99cab.sanctuary26.redstoner.client.renderer;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Axis;
import fr.koka99cab.sanctuary26.redstoner.block.TrophyPanelBlock;
import fr.koka99cab.sanctuary26.redstoner.block.entity.TrophyPanelBlockEntity;
import fr.koka99cab.sanctuary26.redstoner.client.renderer.state.TrophyPanelRenderState;
import fr.koka99cab.sanctuary26.sanctuary.api.ranking.RankingUnit;
import net.minecraft.client.gui.Font;
import net.minecraft.client.renderer.SubmitNodeCollector;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.client.renderer.feature.ModelFeatureRenderer;
import net.minecraft.client.renderer.state.level.CameraRenderState;
import net.minecraft.network.chat.Component;
import net.minecraft.util.FormattedCharSequence;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.phys.Vec3;
public final class TrophyPanelBlockEntityRenderer
implements BlockEntityRenderer<TrophyPanelBlockEntity, TrophyPanelRenderState> {
private static final int MAX_TEXT_WIDTH = 90;
private static final float TEXT_SCALE = 0.010416667F;
private static final float[] LINE_HEIGHTS = {0.70F, 0.59F, 0.48F, 0.37F};
private static final int TEXT_COLOR = 0xFF3D281A;
private final Font font;
public TrophyPanelBlockEntityRenderer(BlockEntityRendererProvider.Context context) {
font = context.font();
}
@Override
public TrophyPanelRenderState createRenderState() {
return new TrophyPanelRenderState();
}
@Override
public void extractRenderState(TrophyPanelBlockEntity panel, TrophyPanelRenderState state,
float tickProgress, Vec3 cameraPos, ModelFeatureRenderer.CrumblingOverlay crumblingOverlay) {
BlockEntityRenderer.super.extractRenderState(panel, state, tickProgress, cameraPos, crumblingOverlay);
state.facing = panel.getBlockState().getValue(TrophyPanelBlock.FACING);
ItemStack icon = panel.currentPage().icon();
TrophyPanelBlockEntity.ClientSnapshot snapshot = panel.visibleSnapshot();
RankingUnit unit = snapshot.unit();
Component metric = !icon.isEmpty() ? Component.translatable(snapshot.translationKey(), icon.getHoverName())
: Component.translatable(snapshot.translationKey());
state.lines[0] = Component.translatable("block.redstoner.trophy_panel.page_title",
panel.pageNumber(), panel.pageCount(), metric);
if (snapshot.podium().isEmpty()) {
state.lines[1] = Component.translatable("block.redstoner.trophy_panel.no_score");
state.lines[2] = Component.empty();
state.lines[3] = Component.empty();
} else {
for (int index = 0; index < 3; index++) {
if (index >= snapshot.podium().size()) {
state.lines[index + 1] = Component.empty();
continue;
}
TrophyPanelBlockEntity.ClientEntry entry = snapshot.podium().get(index);
state.lines[index + 1] = Component.translatable("block.redstoner.trophy_panel.podium",
entry.rank(), entry.name(), unit.format(entry.value()));
}
}
}
@Override
public void submit(TrophyPanelRenderState state, PoseStack poseStack,
SubmitNodeCollector submitNodeCollector, CameraRenderState cameraRenderState) {
float yRotation = -state.facing.toYRot();
for (int index = 0; index < TrophyPanelRenderState.LINE_COUNT; index++) {
submitText(state.lines[index], LINE_HEIGHTS[index], state, poseStack, submitNodeCollector, yRotation);
}
}
private void submitText(Component component, float y, TrophyPanelRenderState state,
PoseStack poseStack, SubmitNodeCollector submitNodeCollector, float yRotation) {
FormattedCharSequence text = font.split(component, MAX_TEXT_WIDTH).stream().findFirst()
.orElse(FormattedCharSequence.EMPTY);
float x = -font.width(text) / 2.0F;
poseStack.pushPose();
poseStack.translate(0.5F, y, 0.5F);
poseStack.mulPose(Axis.YP.rotationDegrees(yRotation));
poseStack.translate(0.0F, 0.0F, -0.331F);
poseStack.scale(TEXT_SCALE, -TEXT_SCALE, TEXT_SCALE);
submitNodeCollector.submitText(poseStack, x, 0.0F, text, false, Font.DisplayMode.POLYGON_OFFSET,
state.lightCoords, TEXT_COLOR, 0, 0);
poseStack.popPose();
}
}
@@ -0,0 +1,13 @@
package fr.koka99cab.sanctuary26.redstoner.client.renderer.state;
import net.minecraft.client.renderer.blockentity.state.BlockEntityRenderState;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
public final class TrophyPanelRenderState extends BlockEntityRenderState {
public static final int LINE_COUNT = 4;
public final Component[] lines = {
Component.empty(), Component.empty(), Component.empty(), Component.empty()
};
public Direction facing = Direction.NORTH;
}
@@ -6,10 +6,12 @@ import fr.koka99cab.sanctuary26.redstoner.block.DrawerBlock;
import fr.koka99cab.sanctuary26.redstoner.block.PersonalComputerBlock;
import fr.koka99cab.sanctuary26.redstoner.block.ParticuleurBlock;
import fr.koka99cab.sanctuary26.redstoner.block.StorageTerminalBlock;
import fr.koka99cab.sanctuary26.redstoner.block.TrophyPanelBlock;
import fr.koka99cab.sanctuary26.redstoner.block.entity.ComputerBlockEntity;
import fr.koka99cab.sanctuary26.redstoner.block.entity.DrawerBlockEntity;
import fr.koka99cab.sanctuary26.redstoner.block.entity.PersonalComputerBlockEntity;
import fr.koka99cab.sanctuary26.redstoner.block.entity.ParticuleurBlockEntity;
import fr.koka99cab.sanctuary26.redstoner.block.entity.TrophyPanelBlockEntity;
import java.util.function.Function;
import net.fabricmc.fabric.api.event.player.AttackBlockCallback;
import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
@@ -71,6 +73,12 @@ public final class RedStonerRegistries {
BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_GRAY).strength(4.0F, 6.0F).sound(SoundType.METAL)
.requiresCorrectToolForDrops().noOcclusion().setId(blockKey(RedStonerMod.id("storage_terminal")))
);
public static final TrophyPanelBlock TROPHY_PANEL = registerBlock(
RedStonerMod.id("trophy_panel"),
TrophyPanelBlock::new,
BlockBehaviour.Properties.of().mapColor(MapColor.WOOD).strength(2.0F).sound(SoundType.WOOD)
.requiresCorrectToolForDrops().noOcclusion().setId(blockKey(RedStonerMod.id("trophy_panel")))
);
public static final ComputerBlock LEGACY_EIGHT_BIT_COMPUTER = registerBlock(
LEGACY_COMPUTER_ID, ComputerBlock::new, computerProperties(LEGACY_COMPUTER_ID, MapColor.COLOR_RED));
@@ -92,6 +100,7 @@ public final class RedStonerRegistries {
public static final Item PARTICULEUR_ITEM = registerBlockItem(RedStonerMod.id("particuleur"), PARTICULEUR);
public static final Item STORAGE_TERMINAL_ITEM = registerBlockItem(
RedStonerMod.id("storage_terminal"), STORAGE_TERMINAL);
public static final Item TROPHY_PANEL_ITEM = registerBlockItem(RedStonerMod.id("trophy_panel"), TROPHY_PANEL);
public static final Item LEGACY_EIGHT_BIT_COMPUTER_ITEM = registerBlockItem(LEGACY_COMPUTER_ID, LEGACY_EIGHT_BIT_COMPUTER);
public static final Item LEGACY_CONTROLLER_ITEM = registerBlockItem(LEGACY_CONTROLLER_ID, LEGACY_CONTROLLER);
@@ -115,6 +124,8 @@ public final class RedStonerRegistries {
RedStonerMod.id("particuleur"), ParticuleurBlockEntity::new, PARTICULEUR);
public static final BlockEntityType<ParticuleurBlockEntity> LEGACY_PARTICULEUR_BLOCK_ENTITY = registerBlockEntity(
LEGACY_PARTICULEUR_ID, ParticuleurBlockEntity::new, LEGACY_PARTICULEUR);
public static final BlockEntityType<TrophyPanelBlockEntity> TROPHY_PANEL_BLOCK_ENTITY = registerBlockEntity(
RedStonerMod.id("trophy_panel"), TrophyPanelBlockEntity::new, TROPHY_PANEL);
public static final CreativeModeTab CREATIVE_TAB = Registry.register(
BuiltInRegistries.CREATIVE_MODE_TAB,
@@ -127,6 +138,7 @@ public final class RedStonerRegistries {
output.accept(CONTROLLER_ITEM);
output.accept(PARTICULEUR_ITEM);
output.accept(STORAGE_TERMINAL_ITEM);
output.accept(TROPHY_PANEL_ITEM);
})
.build()
);
@@ -142,7 +154,7 @@ public final class RedStonerRegistries {
}
initialized = true;
registerDrawerAttack();
RedStonerMod.LOGGER.info("[{}] Registered six active blocks and five legacy block aliases.", RedStonerMod.DISPLAY_NAME);
RedStonerMod.LOGGER.info("[{}] Registered seven active blocks and five legacy block aliases.", RedStonerMod.DISPLAY_NAME);
}
public static boolean isController(BlockState state) {
@@ -27,6 +27,7 @@ public final class StorageTerminalMenu extends AbstractContainerMenu {
public static final int PAGE_BUTTON_BASE = 10;
public static final int SEARCH_CLEAR_BUTTON = 100;
public static final int SEARCH_BACKSPACE_BUTTON = 101;
public static final int SORT_BUTTON_BASE = 200;
public static final int SEARCH_CODEPOINT_BUTTON_BASE = 1_000;
private static final int PLAYER_INVENTORY_Y = 140;
private static final int REFRESH_INTERVAL = 20;
@@ -49,6 +50,7 @@ public final class StorageTerminalMenu extends AbstractContainerMenu {
private final StorageTerminalLayout layout = new StorageTerminalLayout();
private List<StorageTerminalInventory.Entry> entries = List.of();
private String searchQuery = "";
private StorageTerminalSort sortMode = StorageTerminalSort.ALPHABETICAL;
private int refreshCooldown = REFRESH_INTERVAL;
public StorageTerminalMenu(int containerId, Inventory inventory) {
@@ -131,6 +133,9 @@ public final class StorageTerminalMenu extends AbstractContainerMenu {
if (searchQuery.isEmpty()) return true;
searchQuery = searchQuery.substring(0,
searchQuery.offsetByCodePoints(searchQuery.length(), -1));
} else if (buttonId >= SORT_BUTTON_BASE
&& buttonId < SORT_BUTTON_BASE + StorageTerminalSort.values().length) {
sortMode = StorageTerminalSort.values()[buttonId - SORT_BUTTON_BASE];
} else {
int codePoint = buttonId - SEARCH_CODEPOINT_BUTTON_BASE;
if (!isSearchCodePoint(codePoint)) return false;
@@ -211,7 +216,7 @@ public final class StorageTerminalMenu extends AbstractContainerMenu {
if (serverPlayer == null || terminalPos == null) return;
discovery = StorageTerminalNetwork.discover(serverPlayer, terminalPos);
List<StorageTerminalInventory.Entry> liveEntries =
StorageTerminalNetwork.filteredEntries(discovery, searchQuery);
sortMode.order(StorageTerminalNetwork.filteredEntries(discovery, searchQuery));
layout.update(liveEntries, resetOrder);
int page = discovery.status() == StorageTerminalStatus.READY
@@ -5,12 +5,16 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.regex.Pattern;
import net.minecraft.core.component.DataComponents;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.Identifier;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.ShulkerBoxBlock;
/** Server-side matching for the bounded terminal search field. */
public final class StorageTerminalSearch {
private static final int SHULKER_SLOT_COUNT = 27;
private static final Pattern COMBINING_MARKS = Pattern.compile("\\p{M}+");
private static final Pattern NON_ALPHANUMERIC = Pattern.compile("[^\\p{L}\\p{N}]+");
@@ -38,14 +42,27 @@ public final class StorageTerminalSearch {
}
private static boolean matches(ItemStack stack, String[] terms) {
StringBuilder searchable = new StringBuilder(stack.getHoverName().getString());
Identifier id = BuiltInRegistries.ITEM.getKey(stack.getItem());
if (id != null) searchable.append(' ').append(id);
searchable.append(' ').append(stack.getItem().getDescriptionId());
StringBuilder searchable = new StringBuilder();
appendSearchableText(searchable, stack);
if (stack.getItem() instanceof BlockItem blockItem
&& blockItem.getBlock() instanceof ShulkerBoxBlock) {
var contents = stack.get(DataComponents.CONTAINER);
if (contents != null) {
contents.nonEmptyItemCopyStream().limit(SHULKER_SLOT_COUNT).forEach(contained ->
appendSearchableText(searchable, contained));
}
}
String normalized = normalize(searchable.toString());
for (String term : terms) {
if (!normalized.contains(term)) return false;
}
return true;
}
private static void appendSearchableText(StringBuilder searchable, ItemStack stack) {
searchable.append(' ').append(stack.getHoverName().getString());
Identifier id = BuiltInRegistries.ITEM.getKey(stack.getItem());
if (id != null) searchable.append(' ').append(id);
searchable.append(' ').append(stack.getItem().getDescriptionId());
}
}
@@ -0,0 +1,59 @@
package fr.koka99cab.sanctuary26.redstoner.storage;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.Identifier;
import net.minecraft.world.item.ItemStack;
/** Explicit server-side ordering modes for terminal entries. */
public enum StorageTerminalSort {
ALPHABETICAL("alphabetical"),
COUNT_ASCENDING("count_ascending"),
COUNT_DESCENDING("count_descending");
private final String translationSuffix;
StorageTerminalSort(String translationSuffix) {
this.translationSuffix = translationSuffix;
}
public String translationSuffix() {
return translationSuffix;
}
public StorageTerminalSort next() {
StorageTerminalSort[] values = values();
return values[(ordinal() + 1) % values.length];
}
public List<StorageTerminalInventory.Entry> order(
List<StorageTerminalInventory.Entry> entries) {
List<StorageTerminalInventory.Entry> ordered = new ArrayList<>(entries);
ordered.sort(comparator());
return List.copyOf(ordered);
}
private Comparator<StorageTerminalInventory.Entry> comparator() {
Comparator<StorageTerminalInventory.Entry> alphabetical = Comparator
.comparing((StorageTerminalInventory.Entry entry) -> alphabeticalName(entry.stack()))
.thenComparing(entry -> itemId(entry.stack()));
return switch (this) {
case ALPHABETICAL -> alphabetical;
case COUNT_ASCENDING -> Comparator
.comparingInt(StorageTerminalInventory.Entry::total).thenComparing(alphabetical);
case COUNT_DESCENDING -> Comparator
.comparingInt(StorageTerminalInventory.Entry::total).reversed().thenComparing(alphabetical);
};
}
private static String alphabeticalName(ItemStack stack) {
return StorageTerminalSearch.normalize(stack.getHoverName().getString());
}
private static String itemId(ItemStack stack) {
Identifier id = BuiltInRegistries.ITEM.getKey(stack.getItem());
return id == null ? "" : id.toString();
}
}
@@ -0,0 +1,37 @@
package fr.koka99cab.sanctuary26.redstoner.trophy;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.UUID;
import net.minecraft.resources.Identifier;
/** Pure bounded rules shared by the trophy panel and its smoke tests. */
public final class TrophyPanelRules {
public static final int MAX_PAGES = 16;
private TrophyPanelRules() {}
public static boolean canConfigure(UUID owner, UUID actor, boolean operator) {
return operator || owner != null && owner.equals(actor);
}
public static int nextPage(int currentPage, int pageCount) {
return pageByOffset(currentPage, pageCount, 1);
}
public static int previousPage(int currentPage, int pageCount) {
return pageByOffset(currentPage, pageCount, -1);
}
public static int pageByOffset(int currentPage, int pageCount, int offset) {
return pageCount <= 0 ? 0 : Math.floorMod(currentPage + offset, pageCount);
}
public static List<Identifier> mergeMetricIds(List<Identifier> current, List<Identifier> offered) {
LinkedHashSet<Identifier> merged = new LinkedHashSet<>();
if (current != null) merged.addAll(current);
if (offered != null) merged.addAll(offered);
return List.copyOf(new ArrayList<>(merged).subList(0, Math.min(MAX_PAGES, merged.size())));
}
}
@@ -0,0 +1,8 @@
{
"variants": {
"facing=north": { "model": "redstoner:block/trophy_panel" },
"facing=east": { "model": "redstoner:block/trophy_panel", "y": 90 },
"facing=south": { "model": "redstoner:block/trophy_panel", "y": 180 },
"facing=west": { "model": "redstoner:block/trophy_panel", "y": 270 }
}
}
@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "redstoner:block/trophy_panel"
}
}
@@ -55,8 +55,28 @@
"screen.redstoner.storage_terminal.search": "Search…",
"screen.redstoner.storage_terminal.no_results": "No items found.",
"screen.redstoner.storage_terminal.summary": "%s/%s · %s blocks · %s types",
"screen.redstoner.storage_terminal.sort": "Sort: %s",
"screen.redstoner.storage_terminal.sort.alphabetical": "alphabetical",
"screen.redstoner.storage_terminal.sort.count_ascending": "quantity, ascending",
"screen.redstoner.storage_terminal.sort.count_descending": "quantity, descending",
"screen.redstoner.storage_terminal.error.invalid_terminal": "The terminal is no longer accessible.",
"screen.redstoner.storage_terminal.error.disconnected": "No connected chest or barrel.",
"screen.redstoner.storage_terminal.error.too_large": "Network too large (maximum 128 storage blocks).",
"screen.redstoner.storage_terminal.error.locked": "The network contains a locked storage block."
"screen.redstoner.storage_terminal.error.locked": "The network contains a locked storage block.",
"block.redstoner.trophy_panel": "Trophy Panel",
"block.redstoner.trophy_panel.page_title": "[%s/%s] %s",
"block.redstoner.trophy_panel.podium": "#%s %s · %s",
"block.redstoner.trophy_panel.no_score": "No score yet",
"block.redstoner.trophy_panel.champion": "#1 %s · %s",
"block.redstoner.trophy_panel.owner_rank": "%s · #%s · %s",
"block.redstoner.trophy_panel.owner_unranked": "%s · unranked",
"message.redstoner.trophy_panel.not_owner": "Only the owner or an operator can configure this panel.",
"message.redstoner.trophy_panel.configured": "Compatible pages added; the item was not consumed.",
"message.redstoner.trophy_panel.no_metric": "This item has no compatible statistic.",
"message.redstoner.trophy_panel.newer_data": "This panel uses a newer data format and remains read-only.",
"message.redstoner.trophy_panel.page": "Page %s/%s",
"message.redstoner.trophy_panel.header": "%s · page %s/%s",
"message.redstoner.trophy_panel.podium": "#%s %s · %s",
"message.redstoner.trophy_panel.owner_rank": "%s: rank #%s · %s",
"message.redstoner.trophy_panel.owner_unranked": "%s: no score"
}
@@ -55,8 +55,28 @@
"screen.redstoner.storage_terminal.search": "Rechercher…",
"screen.redstoner.storage_terminal.no_results": "Aucun objet trouvé.",
"screen.redstoner.storage_terminal.summary": "%s/%s · %s blocs · %s types",
"screen.redstoner.storage_terminal.sort": "Tri : %s",
"screen.redstoner.storage_terminal.sort.alphabetical": "alphabétique",
"screen.redstoner.storage_terminal.sort.count_ascending": "quantité croissante",
"screen.redstoner.storage_terminal.sort.count_descending": "quantité décroissante",
"screen.redstoner.storage_terminal.error.invalid_terminal": "Le terminal n'est plus accessible.",
"screen.redstoner.storage_terminal.error.disconnected": "Aucun coffre ou baril connecté.",
"screen.redstoner.storage_terminal.error.too_large": "Réseau trop grand (128 stockages maximum).",
"screen.redstoner.storage_terminal.error.locked": "Le réseau contient un stockage verrouillé."
"screen.redstoner.storage_terminal.error.locked": "Le réseau contient un stockage verrouillé.",
"block.redstoner.trophy_panel": "Panneau de trophées",
"block.redstoner.trophy_panel.page_title": "[%s/%s] %s",
"block.redstoner.trophy_panel.podium": "#%s %s · %s",
"block.redstoner.trophy_panel.no_score": "Aucun score",
"block.redstoner.trophy_panel.champion": "#1 %s · %s",
"block.redstoner.trophy_panel.owner_rank": "%s · #%s · %s",
"block.redstoner.trophy_panel.owner_unranked": "%s · non classé",
"message.redstoner.trophy_panel.not_owner": "Seul le propriétaire ou un opérateur peut configurer ce panneau.",
"message.redstoner.trophy_panel.configured": "Pages compatibles ajoutées ; lobjet na pas été consommé.",
"message.redstoner.trophy_panel.no_metric": "Cet objet ne fournit aucune statistique compatible.",
"message.redstoner.trophy_panel.newer_data": "Ce panneau utilise un format de données plus récent et reste en lecture seule.",
"message.redstoner.trophy_panel.page": "Page %s/%s",
"message.redstoner.trophy_panel.header": "%s · page %s/%s",
"message.redstoner.trophy_panel.podium": "#%s %s · %s",
"message.redstoner.trophy_panel.owner_rank": "%s : rang #%s · %s",
"message.redstoner.trophy_panel.owner_unranked": "%s : aucun score"
}
@@ -55,8 +55,28 @@
"screen.redstoner.storage_terminal.search": "Поиск…",
"screen.redstoner.storage_terminal.no_results": "Предметы не найдены.",
"screen.redstoner.storage_terminal.summary": "%s/%s · блоков: %s · типов: %s",
"screen.redstoner.storage_terminal.sort": "Сортировка: %s",
"screen.redstoner.storage_terminal.sort.alphabetical": "по алфавиту",
"screen.redstoner.storage_terminal.sort.count_ascending": "по возрастанию количества",
"screen.redstoner.storage_terminal.sort.count_descending": "по убыванию количества",
"screen.redstoner.storage_terminal.error.invalid_terminal": "Терминал больше недоступен.",
"screen.redstoner.storage_terminal.error.disconnected": "Нет подключённых сундуков или бочек.",
"screen.redstoner.storage_terminal.error.too_large": "Сеть слишком велика (не более 128 хранилищ).",
"screen.redstoner.storage_terminal.error.locked": "В сети есть запертое хранилище."
"screen.redstoner.storage_terminal.error.locked": "В сети есть запертое хранилище.",
"block.redstoner.trophy_panel": "Панель трофеев",
"block.redstoner.trophy_panel.page_title": "[%s/%s] %s",
"block.redstoner.trophy_panel.podium": "#%s %s · %s",
"block.redstoner.trophy_panel.no_score": "Результатов пока нет",
"block.redstoner.trophy_panel.champion": "#1 %s · %s",
"block.redstoner.trophy_panel.owner_rank": "%s · #%s · %s",
"block.redstoner.trophy_panel.owner_unranked": "%s · без места",
"message.redstoner.trophy_panel.not_owner": "Настраивать эту панель может только владелец или оператор.",
"message.redstoner.trophy_panel.configured": "Совместимые страницы добавлены; предмет не был израсходован.",
"message.redstoner.trophy_panel.no_metric": "У этого предмета нет совместимой статистики.",
"message.redstoner.trophy_panel.newer_data": "Панель использует более новый формат данных и доступна только для чтения.",
"message.redstoner.trophy_panel.page": "Страница %s/%s",
"message.redstoner.trophy_panel.header": "%s · страница %s/%s",
"message.redstoner.trophy_panel.podium": "#%s %s · %s",
"message.redstoner.trophy_panel.owner_rank": "%s: место #%s · %s",
"message.redstoner.trophy_panel.owner_unranked": "%s: результата нет"
}
@@ -0,0 +1,21 @@
{
"parent": "minecraft:block/block",
"textures": {
"particle": "minecraft:block/oak_planks",
"wood": "minecraft:block/oak_planks"
},
"elements": [
{
"from": [0, 0, 14],
"to": [16, 16, 16],
"faces": {
"north": { "texture": "#wood" },
"south": { "texture": "#wood" },
"west": { "texture": "#wood" },
"east": { "texture": "#wood" },
"up": { "texture": "#wood" },
"down": { "texture": "#wood" }
}
}
]
}
@@ -1 +1 @@
{"replace":false,"values":["redstoner:eight_bit_computer","redstoner:controller","redstoner:personal_computer","redstoner:particuleur","redstoner:storage_terminal","redstone_computer:redstone_computer","redstone_computer:redstone_controller","redstone_computer:personal_computer","particuleur:particuleur"]}
{"replace":false,"values":["redstoner:eight_bit_computer","redstoner:controller","redstoner:personal_computer","redstoner:particuleur","redstoner:storage_terminal","redstoner:trophy_panel","redstone_computer:redstone_computer","redstone_computer:redstone_controller","redstone_computer:personal_computer","particuleur:particuleur"]}
@@ -1 +1 @@
{"replace":false,"values":["redstoner:eight_bit_computer","redstoner:controller","redstoner:personal_computer","redstoner:particuleur","redstoner:storage_terminal","redstone_computer:redstone_computer","redstone_computer:redstone_controller","redstone_computer:personal_computer","particuleur:particuleur"]}
{"replace":false,"values":["redstoner:eight_bit_computer","redstoner:controller","redstoner:personal_computer","redstoner:particuleur","redstoner:storage_terminal","redstoner:trophy_panel","redstone_computer:redstone_computer","redstone_computer:redstone_controller","redstone_computer:personal_computer","particuleur:particuleur"]}
@@ -0,0 +1,15 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{ "type": "minecraft:item", "name": "redstoner:trophy_panel" }
],
"conditions": [
{ "condition": "minecraft:survives_explosion" }
]
}
],
"random_sequence": "redstoner:blocks/trophy_panel"
}
@@ -0,0 +1,19 @@
{
"type": "minecraft:crafting_shaped",
"category": "redstone",
"pattern": [
"NGN",
"GRG",
"NSN"
],
"key": {
"N": "minecraft:gold_nugget",
"G": "minecraft:black_stained_glass_pane",
"R": "minecraft:redstone_lamp",
"S": "minecraft:oak_sign"
},
"result": {
"id": "redstoner:trophy_panel",
"count": 1
}
}
+1 -1
View File
@@ -30,7 +30,7 @@
"sanctuary26": {
"system_type": "gameplay-system",
"namespace": "redstoner",
"data_version": 3,
"data_version": 4,
"network_protocol": 7,
"lifecycle": "${lifecycle}",
"pack_version": "${pack_version}",
@@ -14,6 +14,7 @@ import net.minecraft.world.SimpleContainer;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.component.ItemContainerContents;
public final class StorageTerminalSmoke {
private StorageTerminalSmoke() {
@@ -26,6 +27,7 @@ public final class StorageTerminalSmoke {
verifyPagination();
verifyAggregationAndTransfers();
verifySearch();
verifySorting();
verifyStableLayout();
}
@@ -115,6 +117,14 @@ public final class StorageTerminalSmoke {
ItemStack russian = new ItemStack(stackable(Items.REDSTONE), 3);
russian.set(DataComponents.CUSTOM_NAME, Component.literal("Красный камень"));
container.setItem(2, russian);
Holder<Item> shulkerItem = new Holder.Direct<>(Items.SHULKER_BOX, DataComponentMap.builder()
.set(DataComponents.MAX_STACK_SIZE, 1).build());
ItemStack shulker = new ItemStack(shulkerItem);
ItemStack nestedDiamond = new ItemStack(stackable(Items.DIAMOND), 7);
nestedDiamond.set(DataComponents.CUSTOM_NAME, Component.literal("Trésor intérieur"));
shulker.set(DataComponents.CONTAINER, ItemContainerContents.fromItems(List.of(
nestedDiamond, new ItemStack(stackable(Items.OAK_LOG), 32))));
container.setItem(3, shulker);
List<StorageTerminalInventory.Entry> entries = StorageTerminalInventory.aggregate(List.of(container));
require(StorageTerminalSearch.filter(entries, "minecraft:cobblestone").size() == 1,
@@ -125,6 +135,12 @@ public final class StorageTerminalSmoke {
"Terminal search did not ignore accents in a custom name");
require(StorageTerminalSearch.filter(entries, "красный камень").size() == 1,
"Terminal search did not preserve non-Latin keyboard input");
require(StorageTerminalSearch.filter(entries, "minecraft:oak_log").size() == 1,
"Terminal search did not find an item id inside a Shulker box");
require(StorageTerminalSearch.filter(entries, "tresor interieur oak log").size() == 1,
"Terminal search did not index the composed contents of a Shulker box");
require(StorageTerminalSearch.filter(entries, "shulker box").size() == 1,
"Searching Shulker contents broke matching against the box itself");
require(StorageTerminalSearch.filter(entries, "missing").isEmpty(),
"Terminal search retained an unrelated item");
}
@@ -134,6 +150,47 @@ public final class StorageTerminalSmoke {
.set(DataComponents.MAX_STACK_SIZE, 64).build());
}
private static void verifySorting() {
ItemStack eclair = new ItemStack(stackable(Items.STONE));
eclair.set(DataComponents.CUSTOM_NAME, Component.literal("Éclair"));
ItemStack banana = new ItemStack(stackable(Items.DIRT));
banana.set(DataComponents.CUSTOM_NAME, Component.literal("Banane"));
ItemStack zebra = new ItemStack(stackable(Items.DIAMOND));
zebra.set(DataComponents.CUSTOM_NAME, Component.literal("Zèbre"));
List<StorageTerminalInventory.Entry> entries = List.of(
new StorageTerminalInventory.Entry(eclair, 64),
new StorageTerminalInventory.Entry(banana, 8),
new StorageTerminalInventory.Entry(zebra, 2));
require(names(StorageTerminalSort.ALPHABETICAL.order(entries))
.equals(List.of("Banane", "Éclair", "Zèbre")),
"Alphabetical terminal sorting ignored names or accent folding");
require(names(StorageTerminalSort.COUNT_ASCENDING.order(entries))
.equals(List.of("Zèbre", "Banane", "Éclair")),
"Ascending terminal quantity sorting is incorrect");
require(names(StorageTerminalSort.COUNT_DESCENDING.order(entries))
.equals(List.of("Éclair", "Banane", "Zèbre")),
"Descending terminal quantity sorting is incorrect");
require(StorageTerminalSort.ALPHABETICAL.next() == StorageTerminalSort.COUNT_ASCENDING
&& StorageTerminalSort.COUNT_ASCENDING.next() == StorageTerminalSort.COUNT_DESCENDING
&& StorageTerminalSort.COUNT_DESCENDING.next() == StorageTerminalSort.ALPHABETICAL,
"Terminal sorting modes do not cycle deterministically");
StorageTerminalLayout stable = new StorageTerminalLayout();
stable.update(StorageTerminalSort.COUNT_DESCENDING.order(entries), true);
List<StorageTerminalInventory.Entry> changedCounts = List.of(
new StorageTerminalInventory.Entry(eclair, 1),
new StorageTerminalInventory.Entry(banana, 80),
new StorageTerminalInventory.Entry(zebra, 2));
stable.update(StorageTerminalSort.COUNT_DESCENDING.order(changedCounts), false);
require(names(stable.page(0).subList(0, 3)).equals(List.of("Éclair", "Banane", "Zèbre")),
"A periodic quantity refresh moved terminal entries under the cursor");
}
private static List<String> names(List<StorageTerminalInventory.Entry> entries) {
return entries.stream().map(entry -> entry.stack().getHoverName().getString()).toList();
}
private static void verifyStableLayout() {
StorageTerminalInventory.Entry stone = new StorageTerminalInventory.Entry(
new ItemStack(stackable(Items.STONE)), 64);
@@ -0,0 +1,37 @@
package fr.koka99cab.sanctuary26.redstoner.trophy;
import java.util.List;
import java.util.UUID;
import net.minecraft.resources.Identifier;
public final class TrophyPanelRulesSmoke {
private TrophyPanelRulesSmoke() {}
public static void main(String[] args) {
UUID owner = UUID.randomUUID();
UUID visitor = UUID.randomUUID();
require(TrophyPanelRules.canConfigure(owner, owner, false), "The owner cannot configure their panel");
require(!TrophyPanelRules.canConfigure(owner, visitor, false), "A visitor can configure another panel");
require(TrophyPanelRules.canConfigure(owner, visitor, true), "An operator cannot repair a panel");
require(TrophyPanelRules.nextPage(0, 3) == 1 && TrophyPanelRules.nextPage(2, 3) == 0,
"Public page cycling does not wrap");
require(TrophyPanelRules.previousPage(0, 3) == 2 && TrophyPanelRules.previousPage(2, 3) == 1,
"Reverse public page cycling does not wrap");
require(TrophyPanelRules.pageByOffset(4, 0, 1) == 0,
"An empty panel produced an invalid page index");
Identifier first = Identifier.parse("sanctuary:first");
Identifier second = Identifier.parse("sanctuary:second");
List<Identifier> offered = java.util.stream.IntStream.range(0, TrophyPanelRules.MAX_PAGES + 5)
.mapToObj(index -> Identifier.parse("sanctuary:metric_" + index)).toList();
List<Identifier> merged = TrophyPanelRules.mergeMetricIds(List.of(first, second, first), offered);
require(merged.size() == TrophyPanelRules.MAX_PAGES, "Panel pages are not bounded");
require(merged.get(0).equals(first) && merged.get(1).equals(second),
"Existing page order was not preserved");
require(merged.stream().distinct().count() == merged.size(), "Duplicate metric pages were retained");
}
private static void require(boolean condition, String message) {
if (!condition) throw new IllegalStateException(message);
}
}
+12 -2
View File
@@ -49,5 +49,15 @@ Ouch possède les attaques et les dégâts ; seule l'explosion de transformation
peut casser des blocs. La victoire est enregistrée une seule fois dans les
données globales Sanctuary, même après redémarrage ou restauration de l'entité.
Les participants reçoivent le jalon `sanctuary:notch_defeated` et un marqueur
de boss dans leur Atlas si Alpha y était déjà découverte. Le drapeau de
récompense initiale reste séparé et monotone pour la future étape CARPET-01.
de boss dans leur Atlas si Alpha y était déjà découverte. Sanctuary réserve
ensuite une récompense mondiale unique : I Like To Move It place le
`iliketomoveit:magic_carpet` dans un coffre près de la maison et le signale par
un feu d'artifice. La réservation et la livraison sont persistées séparément
afin qu'une reprise serveur termine le coffre sans créer un second tapis.
L'ancien `portals:notch_totem` reste lisible et devient un Magic Carpet en
conservant ses composants et son nom. Après la victoire, Only Fun autorise
l'offre exceptionnelle dans la rotation normale du Shop ; les remplacements
sont payés et livrés par la Mailbox sans recréer la récompense initiale. Le
contrat détaillé est dans
[`iliketomoveit/MAGIC_CARPET.md`](../iliketomoveit/MAGIC_CARPET.md).
+93
View File
@@ -0,0 +1,93 @@
# Backroom
La Backroom est une dimension persistante de récupération et de construction. Elle nest jamais
réinitialisée : routes, bases, coffres et bâtiments posés par les habitants restent dans le monde.
Sa zone architecturale forme un disque de 2 000 blocs autour de lorigine.
## Entrer et sortir
- Saccroupir et utiliser un lit hors de la Backroom déclenche lentrée, sans remplacer lusage
normal du lit.
- Avant toute téléportation, le serveur transfère atomiquement vers la Mailbox enregistrée les
43 emplacements vanilla, les 18 emplacements étendus, l’œuf compagnon et la cape équipée.
- Si aucune Mailbox extérieure nest chargée, ou si elle ne peut pas recevoir lintégralité du
colis, rien ne bouge et lentrée est refusée. Une Mailbox construite dans la Backroom nest jamais
une destination dentrée et ne permet donc pas dimporter du matériel.
- Lidentifiant de transaction est conservé par la Mailbox. Après une interruption, la connexion
suivante termine exactement une fois le vidage correspondant ou annule une transaction qui na
jamais atteint la Mailbox.
- Dans la Backroom, tout lit — généré ou posé par un joueur — ramène au lit de réapparition normal,
ou au point dapparition global sil nexiste plus. Le joueur conserve alors ses trouvailles.
- Aucun autre usage de lit ne définit un point de réapparition dans la dimension.
- Toute autre téléportation vers la Backroom est refusée. Une téléportation forcée vers lextérieur
reste possible pour ladministration, mais replace dabord le butin porté dans le registre : elle
ne constitue jamais une extraction réussie.
- Chaque arrivée se fait sur le dernier plancher du niveau 0. Le serveur libère exactement les deux
blocs nécessaires au joueur et pose une torche adjacente : elle peut être récupérée et devient le
premier outil dexploration dans une dimension autrement noire.
## Objets perdus et coffres
Les piles qui disparaissent naturellement ou tombent dans le vide rejoignent un registre mondial
borné. Une mort de joueur dans la Backroom y replace aussi tout ce quil transportait. Chaque pile
réelle matérialisée reçoit un identifiant persistant : elle peut passer du registre à un coffre, puis
à un joueur et revenir au registre, mais elle ne peut jamais exister deux fois.
Une perte associée à un joueur lui reste réservée pendant 24 000 ticks avant de pouvoir rejoindre
les tirages historiques partagés ; une perte sans propriétaire est immédiatement partagée.
Chaque niveau génère exactement un coffre par cellule de 3 × 3 chunks dans les nouveaux chunks.
Tous les coffres vanilla de la Backroom, générés ou posés, deviennent des nœuds de butin renouvelés
toutes les 12 000 ticks lors de leur prochaine ouverture. Le renouvellement rend au registre les
objets perdus non pris, efface le contenu ordinaire et produit le plus souvent du vide ou des
ressources pauvres : terre, pierre, planches, torches, nourriture et outils simples. Le butin ancien
partagé et les objets de valeur restent rares. Reposer un coffre au même emplacement pendant le
même cycle ne crée pas un nouveau tirage ; multiplier les emplacements donne en revanche bien des
tirages indépendants, au prix des ressources trouvées ou produites sur place.
Pendant une expédition, chaque coffre distinct est un essai personnel. Le premier a 75 % de chance
de proposer une perte récente du joueur, le deuxième 90 %, le troisième 100 %, puis les suivants
65 %. Sans perte personnelle disponible, le coffre suit simplement son tirage général.
## Architecture verticale
La liste [Normal Levels I](https://backrooms-wiki.wikidot.com/normal-levels-i) sert uniquement de
référence dambiance et de vocabulaire. Les plans, palettes et règles ci-dessous sont originaux au
pack ; aucun texte ni visuel du wiki nest embarqué.
La dimension couvre maintenant toute la hauteur de **Y = -64 à Y = 383**. Ses cinq niveaux sont
numérotés de haut en bas afin quune chute fasse toujours avancer vers le niveau suivant :
- **niveau 0 — Seuil, Y 295 à 383** : cinq plans de pièces jaunes et sableuses, avec couloirs,
cloisons à 90°, colonnes et quatre angles de salle. Chaque angle possède cinq variantes de
matériaux ; des trous rares relient les plans superposés ;
- **niveau 1 — Archives, Y 206 à 294** : quatre étages de bureaux et de bibliothèques pouvant
couvrir plusieurs chunks, avec longues rangées de rayonnages, grandes fenêtres intérieures,
salles de lecture et cloisons ouvertes ;
- **niveau 2 — Ville, Y 117 à 205** : bâtiments rapprochés séparés par de petites ruelles,
autoroutes orthogonales continues, tours à plusieurs étages et rares parcs enfermés sous le
plafond de la dimension ;
- **niveau 3 — Services, Y 28 à 116** : cinq plans de couloirs techniques en briques, grilles et
béton, dont toutes les jonctions de portes restent physiquement ouvertes ;
- **niveau 4 — Glitch, Y -64 à 27** : prismes de briques en grille 3D autour dun toit où lon peut
tomber, puis réseau déterministe de salles et couloirs. Chaque cellule du labyrinthe conserve une
route ouverte vers son origine ; certaines cloisons disparaissent pour fusionner des salles de
tailles différentes. De rares trous dans le dernier plancher mènent au vrai vide.
Les ouvertures entre deux niveaux sont calculées une seule fois puis appliquées à la fois au sol
supérieur et au plafond inférieur : une chute annoncée ne débouche donc pas sur un bloc fermé. Les
imperfections, morceaux suspendus et raccords volontairement cassés font partie de lesthétique,
mais les portes des couloirs restent traversables. Chacun des cinq niveaux génère exactement un lit
de sortie par cellule de 3 × 3 chunks, sur un plancher praticable propre à sa zone. Il nest donc
plus nécessaire de parcourir une centaine de chunks ou de remonter jusquaux Archives pour ressortir.
La Backroom ne possède ni ciel, ni soleil, ni lune, ni étoiles, ni lumière ambiante. Son biome ne
déclare aucune créature et le serveur retire aussi toute entité de catégorie monstre qui y serait
injectée par un autre système. Les matériaux très marqués dAnother World napparaissent que
ponctuellement aux anomalies. Aucun bloc précieux ne sert de matériau structurel ; de très rares
blocs de diamant restent cachés dans les fondations.
## Exploitation
Les données `sanctuary:backroom` utilisent leur propre `data_version`, ainsi que des limites pour les
transactions, pertes, coffres suivis, visites et arrivées récentes. Les opérateurs disposent de
`/backroom status` et `/backroom inspect <joueur>` pour contrôler les registres sans les modifier.
+259 -20
View File
@@ -116,6 +116,22 @@ tasks.register("capeJoinSyncSmoke", JavaExec) {
mainClass = "fr.koka99cab.sanctuary26.sanctuary.gameplay.CapeJoinSyncQueueSmoke"
}
tasks.register("capeSyncPayloadSmoke", JavaExec) {
group = "verification"
description = "Checks banner cape colors and the six-pattern network bound."
dependsOn tasks.named("testClasses")
classpath = sourceSets.test.runtimeClasspath
mainClass = "fr.koka99cab.sanctuary26.sanctuary.network.CapeSyncPayloadSmoke"
}
tasks.register("chickenArmorSmoke", JavaExec) {
group = "verification"
description = "Checks that only adult unarmored chickens accept armadillo-scute armor."
dependsOn tasks.named("testClasses")
classpath = sourceSets.test.runtimeClasspath
mainClass = "fr.koka99cab.sanctuary26.sanctuary.gameplay.SanctuaryChickenArmorSmoke"
}
tasks.register("inventorySortSmoke", JavaExec) {
group = "verification"
description = "Checks that storage stacks merge and sort while the hotbar row stays out of the sort."
@@ -124,6 +140,14 @@ tasks.register("inventorySortSmoke", JavaExec) {
mainClass = "fr.koka99cab.sanctuary26.sanctuary.gameplay.SanctuaryInventorySortSmoke"
}
tasks.register("entityPolicySmoke", JavaExec) {
group = "verification"
description = "Checks that only tagged temporary companions are excluded from loot and quests."
dependsOn tasks.named("testClasses")
classpath = sourceSets.test.runtimeClasspath
mainClass = "fr.koka99cab.sanctuary26.sanctuary.api.entity.SanctuaryEntityPolicySmoke"
}
tasks.register("alphaIndevGeneratorSmoke", JavaExec) {
group = "verification"
description = "Checks deterministic finite Indev islands, residences and safe portal arrivals."
@@ -140,6 +164,14 @@ tasks.register("notchVictoryStateSmoke", JavaExec) {
mainClass = "fr.koka99cab.sanctuary26.sanctuary.data.NotchVictoryStateSmoke"
}
tasks.register("backroomModelSmoke", JavaExec) {
group = "verification"
description = "Checks bounded Backroom entry data, personal loot priority and composed architecture zones."
dependsOn tasks.named("testClasses")
classpath = sourceSets.test.runtimeClasspath
mainClass = "fr.koka99cab.sanctuary26.sanctuary.backroom.BackroomModelSmoke"
}
tasks.register("verifyBlackMarket") {
group = "verification"
description = "Checks the physical sign market, flash Shop, escrow ledger and mailbox delivery."
@@ -175,7 +207,7 @@ tasks.register("verifyBlackMarket") {
def questData = file("src/main/java/fr/koka99cab/sanctuary26/sanctuary/shop/QuestBoardData.java").text
def quests = file("src/main/java/fr/koka99cab/sanctuary26/sanctuary/shop/QuestBoardService.java").text
def inventoryView = file("src/main/java/fr/koka99cab/sanctuary26/sanctuary/api/inventory/SanctuaryPlayerInventoryView.java").text
if (project.version.toString() != "0.0.0-alpha.126"
if (project.version.toString() != "0.0.0-alpha.137"
|| !data.contains('SAVE_KEY = "black_market"') || !data.contains("DATA_VERSION = 2")
|| !data.contains("ItemStack.CODEC.fieldOf(\"item\")") || !data.contains("replaceListing")
|| !service.contains("LISTING_FEE_RUBIES = 1") || !service.contains("COMMISSION_PERCENT = 5")
@@ -189,7 +221,7 @@ tasks.register("verifyBlackMarket") {
|| !minecraftMixin.contains('method = "pickBlockOrEntity"')
|| !middleClickPayload.contains('SanctuaryMod.id("c2s/black_market_interact")')
|| !middleClickPayload.contains("No client position, listing ID, item or price is trusted")
|| !network.contains("PROTOCOL_VERSION = 22")
|| !network.contains("PROTOCOL_VERSION = 24")
|| !network.contains("BlackMarketService.middleClick(context.player())")
|| !service.contains("loadedDeliveryBox") || !service.contains("PARCEL_RETENTION_MILLIS")
|| !policy.contains("DataComponents.CONTAINER") || !policy.contains("DataComponents.BUNDLE_CONTENTS")
@@ -647,6 +679,14 @@ tasks.register("verifySanctuary") {
,'matchesMouse'
,'int bankIndex(int visualRow, int visibleRows)'
,'playButtonClickSound'
,'requestVisualRow(client, 0, currentRows)'
,'isSortableStorageMenu'
,'instanceof ChestMenu'
,'instanceof ShulkerBoxMenu'
,'instanceof HopperMenu'
,'instanceof DispenserMenu'
,'buffer.writeBoolean(container)'
,'sortOpenContainer'
,'GLFW.GLFW_KEY_TAB'
,'HOTBAR_TEXTURE'
,'0.0F, 0.0F, 182, 22, 182, 22'
@@ -1176,13 +1216,13 @@ tasks.register("verifySanctuary") {
}
def manifest = new JsonSlurper().parse(file("src/main/resources/fabric.mod.json"))
if (manifest.custom?.sanctuary26?.data_version != 12
|| manifest.custom?.sanctuary26?.network_protocol != 22
if (manifest.custom?.sanctuary26?.data_version != 15
|| manifest.custom?.sanctuary26?.network_protocol != 24
|| manifest.depends?.jei != ">=30.24.0.176"
|| manifest.depends?."fabric-api" != ">=0.155.0+26.2"
|| !manifest.entrypoints?.client?.contains("fr.koka99cab.sanctuary26.sanctuary.client.SanctuaryClient")
|| !manifest.mixins?.contains("sanctuary.mixins.json")) {
throw new GradleException("Sanctuary must expose data v11, protocol 22, JEI and the client entrypoint")
throw new GradleException("Sanctuary must expose data v14, protocol 24, JEI and the client entrypoint")
}
def capeMigration = new JsonSlurper().parse(rootProject.file(
"pack/migrations/26.2.0-alpha.155-cape-equipment-to-alpha.156.json"))
@@ -1667,8 +1707,8 @@ tasks.register("verifySanctuary") {
def worldgenRoot = file("src/main/resources/data/sanctuary/worldgen")
def worldgenCounts = [
density_function: 12, biome: 6, configured_feature: 13, configured_carver: 1,
placed_feature: 19, noise_settings: 3, world_preset: 2
density_function: 12, biome: 7, configured_feature: 14, configured_carver: 1,
placed_feature: 20, noise_settings: 4, world_preset: 2
]
worldgenCounts.each { type, expected ->
def actual = fileTree(new File(worldgenRoot, type.toString())).matching { include "**/*.json" }.files.size()
@@ -2883,7 +2923,7 @@ tasks.register("verifyShopCurrencyRowsRelease") {
"src/main/java/fr/koka99cab/sanctuary26/sanctuary/shop/BlackMarketService.java").text
def shop = file(
"src/main/java/fr/koka99cab/sanctuary26/sanctuary/shop/ShopService.java").text
if (project.version.toString() != "0.0.0-alpha.126"
if (project.version.toString() != "0.0.0-alpha.137"
|| migration.target?.modules?.sanctuary != "0.0.0-alpha.117"
|| migration.shop_currency_inventory?.all_unlocked_rows_counted != true
|| migration.shop_currency_inventory?.overflow_rows_counted != true
@@ -3049,7 +3089,7 @@ tasks.register("verifyProgressivePauseMenu") {
"pack/migrations/26.2.0-alpha.190-progressive-pause-menu-to-alpha.191.json"))
def pauseMenu = file("src/main/java/fr/koka99cab/sanctuary26/sanctuary/mixin/client/PauseScreenMixin.java").text
def costs = file("src/main/java/fr/koka99cab/sanctuary26/sanctuary/progression/SanctuaryProgressionCosts.java").text
if (project.version.toString() != "0.0.0-alpha.126"
if (project.version.toString() != "0.0.0-alpha.137"
|| migration.target?.pack_version != "26.2.0-alpha.191"
|| migration.target?.modules?.sanctuary != "0.0.0-alpha.109"
|| migration.pause_menu?.progression_full_width != true
@@ -3087,7 +3127,7 @@ tasks.register("verifyShopPricingLayout") {
"pack/migrations/26.2.0-alpha.192-shop-pricing-layout-to-alpha.193.json"))
def screen = file("src/main/java/fr/koka99cab/sanctuary26/sanctuary/client/SanctuaryShopScreen.java").text
def progression = file("src/main/java/fr/koka99cab/sanctuary26/sanctuary/shop/ShopProgression.java").text
if (project.version.toString() != "0.0.0-alpha.126"
if (project.version.toString() != "0.0.0-alpha.137"
|| migration.target?.modules?.sanctuary != "0.0.0-alpha.110"
|| migration.shop_layout?.locked_offer_buttons != 6
|| migration.shop_layout?.button_slots != [4, 5, 6, 7, 8, 9]
@@ -3118,7 +3158,7 @@ tasks.register("verifyShopCsvBossGates") {
"pack/migrations/26.2.0-alpha.194-shop-csv-boss-gates-to-alpha.195.json"))
def provider = file("src/main/java/fr/koka99cab/sanctuary26/sanctuary/shop/ShopCatalogProvider.java").text
def catalog = file("src/main/java/fr/koka99cab/sanctuary26/sanctuary/shop/ShopOfferCatalog.java").text
if (project.version.toString() != "0.0.0-alpha.126"
if (project.version.toString() != "0.0.0-alpha.137"
|| migration.target?.pack_version != "26.2.0-alpha.195"
|| migration.target?.modules?.sanctuary != "0.0.0-alpha.111"
|| migration.compatibility?.sanctuary_data_version != 11
@@ -3149,7 +3189,7 @@ tasks.register("verifyDeliveryBoxOrientation") {
def blockstate = new JsonSlurper().parse(
file("src/main/resources/assets/sanctuary/blockstates/delivery_box.json"))
def expectedVariants = ["facing=north", "facing=east", "facing=south", "facing=west"].toSet()
if (project.version.toString() != "0.0.0-alpha.126"
if (project.version.toString() != "0.0.0-alpha.137"
|| migration.target?.modules?.sanctuary != "0.0.0-alpha.112"
|| migration.mailbox?.id != "sanctuary:delivery_box"
|| migration.mailbox?.horizontal_facing != true
@@ -3177,7 +3217,7 @@ tasks.register("verifyInventoryShiftClick") {
def mixin = file("src/main/java/fr/koka99cab/sanctuary26/sanctuary/mixin/AbstractContainerMenuMixin.java").text
def screen = file("src/main/java/fr/koka99cab/sanctuary26/sanctuary/mixin/client/AbstractContainerScreenMixin.java").text
def gui = file("INVENTORY_GUI.md").text
if (project.version.toString() != "0.0.0-alpha.126"
if (project.version.toString() != "0.0.0-alpha.137"
|| !transfer.contains("shouldAppendOverflow")
|| !transfer.contains("isVanillaStorageRange")
|| !transfer.contains("hotbarStart")
@@ -3223,7 +3263,7 @@ tasks.register("verifyQuestRequests") {
new JsonSlurper().parse(file("src/main/resources/data/sanctuary/loot_table/blocks/${path}.json"))
.pools[0].entries[0].name
}
if (project.version.toString() != "0.0.0-alpha.126"
if (project.version.toString() != "0.0.0-alpha.137"
|| migration.target?.modules?.sanctuary != "0.0.0-alpha.113"
|| migration.quest_requests?.save_key != "quest_requests"
|| migration.quest_requests?.data_version != 1
@@ -3235,7 +3275,9 @@ tasks.register("verifyQuestRequests") {
|| !data.contains('SAVE_KEY = "quest_requests"') || !data.contains("DATA_VERSION = 3")
|| !service.contains("PlayerBlockBreakEvents.BEFORE")
|| !service.contains("player.blockPosition().distSqr(payload.pos()) > 64.0D")
|| !network.contains("PROTOCOL_VERSION = 22")
|| !service.contains('"sign.sanctuary.quest_request.completed_by"')
|| !service.contains('"message.sanctuary.quest_request.details.completed_by"')
|| !network.contains("PROTOCOL_VERSION = 24")
|| !network.contains("QuestRequestSubmitPayload.ID")
|| !network.contains("QuestRequestAcceptPayload.ID")
|| !registry.contains('SanctuaryMod.id("quest_request_sign")')
@@ -3244,6 +3286,8 @@ tasks.register("verifyQuestRequests") {
!values.containsKey("block.sanctuary.quest_request_sign")
|| !values.containsKey("screen.sanctuary.quest_request.title")
|| !values.containsKey("message.sanctuary.quest_request.claimed")
|| !values.containsKey("message.sanctuary.quest_request.details.completed_by")
|| !values.containsKey("sign.sanctuary.quest_request.completed_by")
}) {
throw new GradleException("Sanctuary alpha.113 quest-request contract is incomplete")
}
@@ -3281,7 +3325,7 @@ tasks.register("verifyQuestRequestContracts") {
def locales = ["fr_fr", "en_us", "ru_ru"].collectEntries { locale ->
[(locale): new JsonSlurper().parse(file("src/main/resources/assets/sanctuary/lang/${locale}.json"))]
}
if (project.version.toString() != "0.0.0-alpha.126"
if (project.version.toString() != "0.0.0-alpha.137"
|| migration.source?.pack_version != "26.2.0-alpha.198"
|| migration.source?.modules?.sanctuary != "0.0.0-alpha.114"
|| migration.target?.pack_version != "26.2.0-alpha.199"
@@ -3301,7 +3345,7 @@ tasks.register("verifyQuestRequestContracts") {
|| !service.contains('REWARD_LOAN = "loan"')
|| !service.contains('PLAYER.equals(targetKind)')
|| !screen.contains("rewardQuantity") || !screen.contains("killTargetIndex")
|| !network.contains("PROTOCOL_VERSION = 22")
|| !network.contains("PROTOCOL_VERSION = 24")
|| standingModel.textures?.all != "sanctuary:block/pink_quest_request_sign"
|| itemModel.textures?.layer0 != "sanctuary:item/pink_quest_request_sign"
|| blockTexture == null || blockTexture.width != 32 || blockTexture.height != 32
@@ -3350,7 +3394,7 @@ tasks.register("verifyQuestRequestEscrow") {
def locales = ["fr_fr", "en_us", "ru_ru"].collectEntries { locale ->
[(locale): new JsonSlurper().parse(file("src/main/resources/assets/sanctuary/lang/${locale}.json"))]
}
if (project.version.toString() != "0.0.0-alpha.126"
if (project.version.toString() != "0.0.0-alpha.137"
|| migration.source?.pack_version != "26.2.0-alpha.200"
|| migration.source?.modules?.sanctuary != "0.0.0-alpha.115"
|| migration.target?.pack_version != "26.2.0-alpha.201"
@@ -3371,7 +3415,7 @@ tasks.register("verifyQuestRequestEscrow") {
|| !service.contains('"quest_request_reward"')
|| !service.contains('"quest_request_delivery"')
|| service.contains("sanctuary_quest_accept")
|| !network.contains("PROTOCOL_VERSION = 22")
|| !network.contains("PROTOCOL_VERSION = 24")
|| !network.contains("QuestRequestAcceptPayload.ID")
|| !network.contains("QuestRequestConfirmPayload.ID")
|| !acceptPayload.contains("readUtf(36)")
@@ -3395,6 +3439,114 @@ tasks.named("verifySanctuary") {
dependsOn tasks.named("verifyInventoryShiftClick")
}
tasks.register("verifyCraftableBannerCape") {
group = "verification"
description = "Checks the white wool recipe, banner decoration and equipped pattern rendering."
inputs.file(rootProject.file(
"pack/migrations/26.2.0-alpha.225-craftable-banner-cape-to-alpha.226.json"))
inputs.file(file("src/main/resources/data/sanctuary/recipe/white_cape.json"))
inputs.file(file("src/main/resources/data/sanctuary/recipe/white_cape_banner.json"))
inputs.file(file("src/main/resources/assets/sanctuary/items/white_cape.json"))
inputs.files(fileTree("src/main/resources/assets/sanctuary/lang") { include "*.json" })
inputs.files(
file("src/main/java/fr/koka99cab/sanctuary26/sanctuary/gameplay/SanctuaryCapes.java"),
file("src/main/java/fr/koka99cab/sanctuary26/sanctuary/network/CapeSyncPayload.java"),
file("src/main/java/fr/koka99cab/sanctuary26/sanctuary/network/SanctuaryNetworking.java"),
file("src/main/java/fr/koka99cab/sanctuary26/sanctuary/client/SanctuaryBannerCapeLayer.java"))
doLast {
def migration = new JsonSlurper().parse(rootProject.file(
"pack/migrations/26.2.0-alpha.225-craftable-banner-cape-to-alpha.226.json"))
def baseRecipe = new JsonSlurper().parse(file(
"src/main/resources/data/sanctuary/recipe/white_cape.json"))
def bannerRecipe = new JsonSlurper().parse(file(
"src/main/resources/data/sanctuary/recipe/white_cape_banner.json"))
def itemDefinition = new JsonSlurper().parse(file(
"src/main/resources/assets/sanctuary/items/white_cape.json"))
def capes = file(
"src/main/java/fr/koka99cab/sanctuary26/sanctuary/gameplay/SanctuaryCapes.java").text
def payload = file(
"src/main/java/fr/koka99cab/sanctuary26/sanctuary/network/CapeSyncPayload.java").text
def networking = file(
"src/main/java/fr/koka99cab/sanctuary26/sanctuary/network/SanctuaryNetworking.java").text
def renderer = file(
"src/main/java/fr/koka99cab/sanctuary26/sanctuary/client/SanctuaryBannerCapeLayer.java").text
def locales = ["fr_fr", "en_us", "ru_ru"].collect {
new JsonSlurper().parse(file("src/main/resources/assets/sanctuary/lang/${it}.json"))
}
if (project.version.toString() != "0.0.0-alpha.137"
|| migration.target?.modules?.sanctuary != "0.0.0-alpha.130"
|| migration.white_cape?.crafting_material_count != 6
|| migration.white_cape?.maximum_pattern_layers != 6
|| baseRecipe.pattern != ["WW", "WW", "WW"]
|| baseRecipe.key?.W != "minecraft:white_wool"
|| baseRecipe.result?.id != "sanctuary:white_cape"
|| bannerRecipe.type != "minecraft:crafting_special_shielddecoration"
|| bannerRecipe.banner != "#minecraft:banners"
|| bannerRecipe.target != "sanctuary:white_cape"
|| itemDefinition.model?.type != "minecraft:special"
|| itemDefinition.model?.model?.type != "minecraft:banner"
|| locales.any { !it.containsKey("item.sanctuary.white_cape") }
|| !capes.contains('WHITE_CAPE_PATH = "white_cape"')
|| !payload.contains("MAX_PATTERN_LAYERS = 6")
|| !payload.contains("DataComponents.BASE_COLOR")
|| !payload.contains("DataComponents.BANNER_PATTERNS")
|| !networking.contains("PROTOCOL_VERSION = 24")
|| !renderer.contains("BannerRenderer.submitPatterns")) {
throw new GradleException("Sanctuary alpha.130 craftable banner cape is incomplete")
}
}
}
tasks.named("verifySanctuary") {
dependsOn tasks.named("verifyCraftableBannerCape")
}
tasks.register("verifyFinalSanctuaryTickets") {
group = "verification"
description = "Checks the shield-mapped banner cape and armadillo-scute chicken armor contracts."
inputs.files(
file("src/main/java/fr/koka99cab/sanctuary26/sanctuary/client/SanctuaryBannerCapeLayer.java"),
file("src/main/java/fr/koka99cab/sanctuary26/sanctuary/client/SanctuaryChickenArmorLayer.java"),
file("src/main/java/fr/koka99cab/sanctuary26/sanctuary/gameplay/SanctuaryChickenArmor.java"),
file("src/main/java/fr/koka99cab/sanctuary26/sanctuary/mixin/AnimalChickenArmorMixin.java"),
file("src/main/java/fr/koka99cab/sanctuary26/sanctuary/mixin/LivingEntityChickenArmorMixin.java"),
file("src/main/resources/sanctuary.mixins.json"))
inputs.files(fileTree("src/main/resources/assets/sanctuary/lang") { include "*.json" })
doLast {
def capeRenderer = file(
"src/main/java/fr/koka99cab/sanctuary26/sanctuary/client/SanctuaryBannerCapeLayer.java").text
def armorLayer = file(
"src/main/java/fr/koka99cab/sanctuary26/sanctuary/client/SanctuaryChickenArmorLayer.java").text
def armorRules = file(
"src/main/java/fr/koka99cab/sanctuary26/sanctuary/gameplay/SanctuaryChickenArmor.java").text
def armorDamage = file(
"src/main/java/fr/koka99cab/sanctuary26/sanctuary/mixin/LivingEntityChickenArmorMixin.java").text
def mixins = new JsonSlurper().parse(file("src/main/resources/sanctuary.mixins.json"))
def locales = ["fr_fr", "en_us", "ru_ru"].collect {
new JsonSlurper().parse(file("src/main/resources/assets/sanctuary/lang/${it}.json"))
}
if (project.version.toString() != "0.0.0-alpha.137"
|| !capeRenderer.contains("SHIELD_PATTERN_X_SCALE = 1.2F")
|| !capeRenderer.contains("SHIELD_PATTERN_Y_SCALE = 1.375F")
|| !capeRenderer.contains("model, state, false, appearance.baseColor()")
|| !armorLayer.contains("EquipmentClientInfo.LayerType.WOLF_BODY")
|| !armorRules.contains("held.is(Items.WOLF_ARMOR)")
|| !armorRules.contains("DamageTypeTags.BYPASSES_WOLF_ARMOR")
|| !armorDamage.contains("armor.hurtAndBreak")
|| !mixins.mixins.contains("AnimalChickenArmorMixin")
|| !mixins.mixins.contains("LivingEntityChickenArmorMixin")
|| !mixins.client.contains("client.ChickenRendererMixin")
|| !mixins.client.contains("client.ChickenRenderStateMixin")
|| locales.any { !it.containsKey("tooltip.sanctuary.chicken_armor") }) {
throw new GradleException("Sanctuary alpha.136 final-ticket contract is incomplete")
}
}
}
tasks.named("verifySanctuary") {
dependsOn tasks.named("verifyFinalSanctuaryTickets")
}
tasks.register("verifyAlphaIndev") {
group = "verification"
description = "Checks the alpha.122 finite Indev world, migration and attribution contract."
@@ -3422,7 +3574,7 @@ tasks.register("verifyAlphaIndev") {
def locales = ["fr_fr", "en_us", "ru_ru"].collect {
new JsonSlurper().parse(file("src/main/resources/assets/sanctuary/lang/${it}.json"))
}
if (project.version.toString() != "0.0.0-alpha.126"
if (project.version.toString() != "0.0.0-alpha.137"
|| migration.target?.modules?.sanctuary != "0.0.0-alpha.122"
|| migration.alpha_world?.dimension != "sanctuary:alpha"
|| migration.alpha_world?.legacy_dimension != "portals:alpha"
@@ -3444,7 +3596,91 @@ tasks.register("verifyAlphaIndev") {
}
}
tasks.register("verifyBackroom") {
group = "verification"
description = "Checks Backroom dimension, migration, Mailbox boundary, loss registry and translations."
inputs.file(file("BACKROOM.md"))
inputs.file(rootProject.file("pack/migrations/sanctuary-backroom-data-v14.json"))
inputs.files(fileTree("src/main/java/fr/koka99cab/sanctuary26/sanctuary/backroom"))
inputs.files(fileTree("src/main/resources/data/sanctuary") { include "**/*backroom*.json" })
inputs.files(fileTree("src/main/resources/assets/sanctuary/lang") { include "*.json" })
inputs.files(
file("src/main/java/fr/koka99cab/sanctuary26/sanctuary/api/backroom/BackroomMaterialApi.java"),
file("src/main/java/fr/koka99cab/sanctuary26/sanctuary/shop/DeliveryBoxBlockEntity.java"),
file("src/main/java/fr/koka99cab/sanctuary26/sanctuary/worldgen/feature/BackroomArchitectureFeature.java"),
file("src/main/java/fr/koka99cab/sanctuary26/sanctuary/worldgen/feature/BackroomLayout.java"),
file("src/main/resources/data/minecraft/worldgen/world_preset/normal.json"),
file("src/main/resources/data/sanctuary/worldgen/world_preset/overworld.json"),
file("src/main/resources/data/sanctuary/worldgen/world_preset/sanctuary.json"))
doLast {
def migration = new JsonSlurper().parse(rootProject.file("pack/migrations/sanctuary-backroom-data-v14.json"))
def dimensionType = new JsonSlurper().parse(file("src/main/resources/data/sanctuary/dimension_type/backroom.json"))
def noiseSettings = new JsonSlurper().parse(file("src/main/resources/data/sanctuary/worldgen/noise_settings/backroom.json"))
def biome = new JsonSlurper().parse(file("src/main/resources/data/sanctuary/worldgen/biome/backroom.json"))
def presets = [
file("src/main/resources/data/minecraft/worldgen/world_preset/normal.json"),
file("src/main/resources/data/sanctuary/worldgen/world_preset/overworld.json"),
file("src/main/resources/data/sanctuary/worldgen/world_preset/sanctuary.json")
].collect { new JsonSlurper().parse(it) }
def data = file("src/main/java/fr/koka99cab/sanctuary26/sanctuary/backroom/BackroomData.java").text
def inventory = file("src/main/java/fr/koka99cab/sanctuary26/sanctuary/backroom/BackroomInventory.java").text
def service = file("src/main/java/fr/koka99cab/sanctuary26/sanctuary/backroom/BackroomService.java").text
def chest = file("src/main/java/fr/koka99cab/sanctuary26/sanctuary/backroom/BackroomChestService.java").text
def mailbox = file("src/main/java/fr/koka99cab/sanctuary26/sanctuary/shop/DeliveryBoxBlockEntity.java").text
def architecture = file("src/main/java/fr/koka99cab/sanctuary26/sanctuary/worldgen/feature/BackroomArchitectureFeature.java").text
def layout = file("src/main/java/fr/koka99cab/sanctuary26/sanctuary/worldgen/feature/BackroomLayout.java").text
def materialApi = file(
"src/main/java/fr/koka99cab/sanctuary26/sanctuary/api/backroom/BackroomMaterialApi.java").text
def locales = ["fr_fr", "en_us", "ru_ru"].collect {
new JsonSlurper().parse(file("src/main/resources/assets/sanctuary/lang/${it}.json"))
}
if (project.version.toString() != "0.0.0-alpha.137"
|| migration.source_data_version != 13 || migration.target_data_version != 14
|| migration.integration_modules?.anotherworld?.source != "0.0.0-alpha.56"
|| migration.integration_modules?.anotherworld?.target != "0.0.0-alpha.57"
|| migration.compatibility?.network_protocol_changed != false
|| presets.any { it.dimensions?.get("sanctuary:backroom") == null }
|| dimensionType.attributes?.get("minecraft:gameplay/bed_rule")?.can_set_spawn != "never"
|| dimensionType.attributes?.get("minecraft:gameplay/bed_rule")?.can_sleep != "never"
|| dimensionType.min_y != -64 || dimensionType.height != 448 || dimensionType.logical_height != 448
|| dimensionType.ambient_light != 0.0 || dimensionType.has_ceiling != true
|| dimensionType.attributes?.get("minecraft:visual/fog_color") != "#000000"
|| noiseSettings.noise?.min_y != -64 || noiseSettings.noise?.height != 448
|| noiseSettings.disable_mob_generation != true
|| biome.creature_spawn_probability != 0.0 || !biome.spawners?.monster?.isEmpty()
|| !data.contains("MAX_LOST_ITEMS = 16_384") || !data.contains("MAX_CHEST_STATES = 65_536")
|| !data.contains("PERSONAL_RESERVATION_TICKS = 24_000L")
|| !data.contains("indexOfLoss(marker)") || !data.contains("BACKROOM_LOSS_COMPONENT")
|| !inventory.contains("companionEgg") || !inventory.contains("equippedCape")
|| !service.contains("ARRIVAL_RADIUS = 2_000") || !service.contains("insertTransaction")
|| !service.contains("AUTHORIZED_TRANSITIONS")
|| !service.contains("level -> !isBackroom(level)")
|| !service.contains("MobCategory.MONSTER") || !service.contains("Blocks.TORCH")
|| !mailbox.contains("MAX_PROCESSED_TRANSACTIONS = 128")
|| !chest.contains("REFRESH_TICKS = 12_000L") || !chest.contains("ordinal == 3")
|| !architecture.contains("PLAYABLE_RADIUS = 2_000")
|| !architecture.contains("BackroomMaterialApi.anomalyMaterial()")
|| !architecture.contains("placeLootLandmark")
|| !layout.contains("WORLD_MIN_Y = -64") || !layout.contains("WORLD_MAX_Y_EXCLUSIVE = 384")
|| !layout.contains("LEVEL_0(295, 383)") || !layout.contains("LEVEL_4(-64, 27)")
|| !layout.contains("mazeConnected") || !layout.contains("RoomCorner")
|| !layout.contains("LOOT_CHEST_CELL_SIZE_CHUNKS = 3") || !layout.contains("lootChestChunk")
|| !layout.contains("EXIT_BED_CELL_SIZE_CHUNKS = 3")
|| !layout.contains("exitBedChunk") || !layout.contains("exitBedFloor")
|| !materialApi.contains("registerAnomalyMaterial")
|| locales.any { !it.containsKey("dimension.sanctuary.backroom")
|| !it.containsKey("message.sanctuary.backroom.bed_entry_only")
|| !it.containsKey("message.sanctuary.backroom.registry_busy")
|| !it.containsKey("message.sanctuary.backroom.mailbox_full")
|| !it.containsKey("message.sanctuary.backroom.exited_with_losses") }) {
throw new GradleException("Sanctuary alpha.134 Backroom contract is incomplete")
}
}
}
tasks.named("check") {
dependsOn tasks.named("backroomModelSmoke")
dependsOn tasks.named("verifyBackroom")
dependsOn tasks.named("notchVictoryStateSmoke")
dependsOn tasks.named("verifySanctuary")
dependsOn tasks.named("verifyDeliveryBoxOrientation")
@@ -3459,6 +3695,9 @@ tasks.named("check") {
dependsOn tasks.named("questIdSuggestionsSmoke")
dependsOn tasks.named("alphaIndevGeneratorSmoke")
dependsOn tasks.named("capeJoinSyncSmoke")
dependsOn tasks.named("capeSyncPayloadSmoke")
dependsOn tasks.named("chickenArmorSmoke")
dependsOn tasks.named("inventorySortSmoke")
dependsOn tasks.named("entityPolicySmoke")
dependsOn tasks.named("verifyAlphaIndev")
}
@@ -2,6 +2,7 @@ package fr.koka99cab.sanctuary26.sanctuary;
import fr.koka99cab.sanctuary26.sanctuary.api.atlas.SanctuaryAtlasLandmarks;
import fr.koka99cab.sanctuary26.sanctuary.api.server.SanctuaryServerIdentity;
import fr.koka99cab.sanctuary26.sanctuary.api.ranking.SanctuaryRankingApi;
import fr.koka99cab.sanctuary26.sanctuary.network.SanctuaryNetworking;
import fr.koka99cab.sanctuary26.sanctuary.gameplay.SanctuaryBulkActions;
import fr.koka99cab.sanctuary26.sanctuary.gameplay.SanctuaryInventoryCapacity;
@@ -26,6 +27,7 @@ import fr.koka99cab.sanctuary26.sanctuary.shop.ShopService;
import fr.koka99cab.sanctuary26.sanctuary.shop.BlackMarketService;
import fr.koka99cab.sanctuary26.sanctuary.shop.QuestBoardService;
import fr.koka99cab.sanctuary26.sanctuary.shop.QuestRequestService;
import fr.koka99cab.sanctuary26.sanctuary.backroom.BackroomService;
import net.fabricmc.api.ModInitializer;
import net.minecraft.resources.Identifier;
import org.slf4j.Logger;
@@ -34,7 +36,7 @@ import org.slf4j.LoggerFactory;
public final class SanctuaryMod implements ModInitializer {
public static final String MOD_ID = "sanctuary";
public static final String DISPLAY_NAME = "Sanctuary";
public static final int CURRENT_DATA_VERSION = 12;
public static final int CURRENT_DATA_VERSION = 15;
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
public SanctuaryMod() {
@@ -47,12 +49,14 @@ public final class SanctuaryMod implements ModInitializer {
@Override
public void onInitialize() {
SanctuaryServerIdentity.register();
SanctuaryRankingApi.initialize();
SanctuaryDimensions.initialize();
SanctuaryDensityFunctions.register();
SanctuaryFeatures.register();
SanctuarySpawn.register();
SanctuaryWorldProfileData.register();
SanctuaryRegistries.initialize();
BackroomService.initialize();
SanctuaryBulkActions.initialize();
SanctuaryInventoryCapacity.initialize();
SanctuaryHotbarRows.initialize();
@@ -0,0 +1,20 @@
package fr.koka99cab.sanctuary26.sanctuary.api.backroom;
import java.util.Objects;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
/** Public, one-way integration point for rare materials owned by other modules. */
public final class BackroomMaterialApi {
private static Block anomalyMaterial = Blocks.WARPED_WART_BLOCK;
private BackroomMaterialApi() {}
public static void registerAnomalyMaterial(Block material) {
anomalyMaterial = Objects.requireNonNull(material, "Backroom anomaly material");
}
public static Block anomalyMaterial() {
return anomalyMaterial;
}
}
@@ -0,0 +1,21 @@
package fr.koka99cab.sanctuary26.sanctuary.api.entity;
import java.util.Set;
import net.minecraft.world.entity.Entity;
/** Public cross-module policy for Sanctuary-owned temporary gameplay entities. */
public final class SanctuaryEntityPolicy {
public static final String TEMPORARY_COMPANION_TAG = "sanctuary_companion";
private SanctuaryEntityPolicy() {
}
/** Temporary companions must never yield loot, experience or quest progress. */
public static boolean isTemporaryCompanion(Entity entity) {
return entity != null && containsTemporaryCompanionTag(entity.entityTags());
}
static boolean containsTemporaryCompanionTag(Set<String> tags) {
return tags != null && tags.contains(TEMPORARY_COMPANION_TAG);
}
}
@@ -0,0 +1,42 @@
package fr.koka99cab.sanctuary26.sanctuary.api.item;
import fr.koka99cab.sanctuary26.sanctuary.SanctuaryMod;
import net.minecraft.core.component.DataComponents;
import net.minecraft.resources.Identifier;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.component.CustomData;
/** Stable item metadata used to distinguish boss rewards, migrations and Shop replacements. */
public final class SanctuaryItemProvenance {
public static final Identifier NOTCH_REWARD = SanctuaryMod.id("notch_reward");
public static final Identifier SHOP_PURCHASE = SanctuaryMod.id("shop_purchase");
public static final Identifier LEGACY_NOTCH_TOTEM = SanctuaryMod.id("legacy_notch_totem");
private static final String ORIGIN_KEY = "sanctuary_origin";
private static final String VERSION_KEY = "sanctuary_origin_version";
private SanctuaryItemProvenance() {
}
public static void stamp(ItemStack stack, Identifier origin) {
if (stack == null || stack.isEmpty() || origin == null) return;
CustomData.update(DataComponents.CUSTOM_DATA, stack, tag -> {
tag.putString(ORIGIN_KEY, origin.toString());
tag.putInt(VERSION_KEY, 1);
});
}
public static void stampIfAbsent(ItemStack stack, Identifier origin) {
if (origin(stack) == null) stamp(stack, origin);
}
public static Identifier origin(ItemStack stack) {
if (stack == null || stack.isEmpty()) return null;
CustomData data = stack.get(DataComponents.CUSTOM_DATA);
if (data == null) return null;
return Identifier.tryParse(data.copyTag().getStringOr(ORIGIN_KEY, ""));
}
public static boolean hasOrigin(ItemStack stack, Identifier origin) {
return origin != null && origin.equals(origin(stack));
}
}
@@ -57,6 +57,11 @@ public final class SanctuaryNotchMilestone {
return NotchVictoryData.get(server).claimInitialReward();
}
/** Completes the reservation only after the physical reward chest exists. */
public static boolean completeInitialReward(MinecraftServer server) {
return NotchVictoryData.get(server).completeInitialReward();
}
private static VictoryResult record(ServerLevel alphaLevel, List<UUID> participants,
boolean rewardAlreadyClaimed, boolean announce) {
NotchVictoryData data = NotchVictoryData.get(alphaLevel.getServer());
@@ -73,7 +78,8 @@ public final class SanctuaryNotchMilestone {
alphaLevel.getServer().getPlayerList().broadcastSystemMessage(
Component.translatable("message.sanctuary.notch_defeated").withStyle(ChatFormatting.GOLD), false);
}
return new VictoryResult(newlyDefeated, state.participants(), state.initialRewardClaimed());
return new VictoryResult(newlyDefeated, state.participants(), state.initialRewardClaimed(),
state.initialRewardDelivered());
}
private static List<UUID> sanitizeParticipants(ServerLevel level, Collection<UUID> candidates) {
@@ -91,7 +97,7 @@ public final class SanctuaryNotchMilestone {
}
public record VictoryResult(boolean newlyDefeated, List<UUID> participants,
boolean initialRewardClaimed) {
boolean initialRewardClaimed, boolean initialRewardDelivered) {
public VictoryResult {
participants = List.copyOf(participants);
}
@@ -0,0 +1,17 @@
package fr.koka99cab.sanctuary26.sanctuary.api.progression;
import fr.koka99cab.sanctuary26.sanctuary.api.notch.SanctuaryNotchMilestone;
import net.minecraft.resources.Identifier;
import net.minecraft.server.MinecraftServer;
/** Public, server-authoritative resolver for world-wide progression milestones. */
public final class SanctuaryWorldMilestones {
private SanctuaryWorldMilestones() {
}
public static boolean isReached(MinecraftServer server, Identifier milestone) {
if (server == null || milestone == null) return false;
return milestone.equals(SanctuaryNotchMilestone.NOTCH_DEFEATED)
&& SanctuaryNotchMilestone.isDefeated(server);
}
}
@@ -0,0 +1,22 @@
package fr.koka99cab.sanctuary26.sanctuary.api.ranking;
import java.util.Objects;
import net.minecraft.resources.Identifier;
/** Stable public description registered by gameplay modules, independent from SanctuaryStat ranks. */
public record RankingMetric(Identifier id, String translationKey, RankingUnit unit) {
public static final int MAX_IDENTIFIER_LENGTH = 256;
public static final int MAX_TRANSLATION_KEY_LENGTH = 128;
public RankingMetric {
Objects.requireNonNull(id, "id");
Objects.requireNonNull(unit, "unit");
if (id.toString().length() > MAX_IDENTIFIER_LENGTH) {
throw new IllegalArgumentException("Ranking identifier must contain at most 256 characters");
}
translationKey = translationKey == null ? "" : translationKey.trim();
if (translationKey.isEmpty() || translationKey.length() > MAX_TRANSLATION_KEY_LENGTH) {
throw new IllegalArgumentException("Ranking translation key must contain 1-128 characters");
}
}
}
@@ -0,0 +1,44 @@
package fr.koka99cab.sanctuary26.sanctuary.api.ranking;
import java.util.List;
import java.util.UUID;
import net.minecraft.resources.Identifier;
/** Server snapshot intentionally bounded to one visible metric and three podium entries. */
public record RankingSnapshot(RankingMetric metric, List<Entry> podium, Placement owner) {
public static final int MAX_PODIUM_SIZE = 3;
public RankingSnapshot {
podium = podium == null ? List.of() : List.copyOf(podium.stream().limit(MAX_PODIUM_SIZE).toList());
owner = owner == null ? Placement.unranked() : owner;
}
public static RankingSnapshot empty(RankingMetric metric) {
return new RankingSnapshot(metric, List.of(), Placement.unranked());
}
public record Entry(UUID playerId, String playerName, long value, int rank) {
public Entry {
playerName = sanitizeName(playerName);
value = Math.max(0L, value);
rank = Math.max(0, rank);
}
}
public record Placement(long value, int rank) {
public Placement {
value = Math.max(0L, value);
rank = Math.max(0, rank);
}
public static Placement unranked() {
return new Placement(0L, 0);
}
}
private static String sanitizeName(String value) {
if (value == null || value.isBlank()) return "?";
String clean = value.strip();
return clean.length() > 32 ? clean.substring(0, 32) : clean;
}
}
@@ -0,0 +1,49 @@
package fr.koka99cab.sanctuary26.sanctuary.api.ranking;
/** Public, bounded display formats accepted by server ranking metrics. */
public enum RankingUnit {
COUNT("count"),
TICKS("ticks"),
CENTIMETERS("centimeters");
private final String key;
RankingUnit(String key) {
this.key = key;
}
public String key() {
return key;
}
public static RankingUnit byKey(String key) {
for (RankingUnit unit : values()) {
if (unit.key.equals(key)) return unit;
}
return COUNT;
}
/** Compact, locale-neutral representation suitable for signs and chat snapshots. */
public String format(long rawValue) {
long value = Math.max(0L, rawValue);
return switch (this) {
case TICKS -> formatDuration(value / 20L);
case CENTIMETERS -> value >= 100_000L ? (value / 100_000L) + " km" : (value / 100L) + " m";
case COUNT -> compact(value);
};
}
private static String formatDuration(long seconds) {
long hours = seconds / 3_600L;
long minutes = seconds % 3_600L / 60L;
if (hours > 0L) return hours + " h " + minutes + " min";
return minutes + " min";
}
private static String compact(long value) {
if (value >= 1_000_000_000L) return value / 1_000_000_000L + "G";
if (value >= 1_000_000L) return value / 1_000_000L + "M";
if (value >= 1_000L) return value / 1_000L + "K";
return Long.toString(value);
}
}
@@ -0,0 +1,102 @@
package fr.koka99cab.sanctuary26.sanctuary.api.ranking;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
import net.minecraft.resources.Identifier;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.item.ItemStack;
/**
* Public server-authoritative ranking API. Gameplay modules may register stable metric descriptions and
* increment them for real survival/adventure players; Red-Stoner only consumes bounded snapshots.
*/
public final class SanctuaryRankingApi {
private static final Map<Identifier, RankingMetric> METRICS = new ConcurrentHashMap<>();
private static final RankingMetric DEFAULT_METRIC = VanillaRankingMetric.descriptor(
VanillaRankingMetric.playTimeId());
private static boolean initialized;
private SanctuaryRankingApi() {}
public static void initialize() {
if (initialized) return;
initialized = true;
register(DEFAULT_METRIC);
ServerLifecycleEvents.SERVER_STARTED.register(server ->
SanctuaryRankingData.get(server).importVanillaStats(server));
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
SanctuaryRankingData data = SanctuaryRankingData.get(server);
data.updateName(handler.player.getUUID(), handler.player.getGameProfile().name());
synchronizeObserved(server, METRICS.keySet());
});
}
public static RankingMetric register(RankingMetric metric) {
RankingMetric previous = METRICS.putIfAbsent(metric.id(), metric);
if (previous != null && !previous.equals(metric)) {
throw new IllegalStateException("Ranking metric already registered with another contract: " + metric.id());
}
return previous == null ? metric : previous;
}
public static RankingMetric defaultMetric() {
return DEFAULT_METRIC;
}
public static Optional<RankingMetric> metric(Identifier id) {
RankingMetric registered = METRICS.get(id);
if (registered != null) return Optional.of(registered);
return VanillaRankingMetric.parse(id).map(source -> {
RankingMetric descriptor = VanillaRankingMetric.descriptor(id);
METRICS.putIfAbsent(id, descriptor);
return descriptor;
});
}
public static List<RankingMetric> itemMetrics(ItemStack icon) {
List<RankingMetric> metrics = VanillaRankingMetric.itemMetrics(icon);
metrics.forEach(SanctuaryRankingApi::register);
return metrics;
}
public static boolean eligible(ServerPlayer player) {
return isRealOnlinePlayer(player) && !player.isCreative() && !player.isSpectator();
}
public static void increment(ServerPlayer player, Identifier metricId, long amount) {
if (!eligible(player) || amount <= 0L || metric(metricId).isEmpty()) return;
SanctuaryRankingData.get(player.level().getServer()).increment(player.getUUID(),
player.getGameProfile().name(), metricId, amount);
}
public static RankingSnapshot snapshot(MinecraftServer server, Identifier metricId, UUID ownerId) {
RankingMetric metric = metric(metricId).orElse(DEFAULT_METRIC);
synchronizeObserved(server, List.of(metric.id()));
return SanctuaryRankingData.get(server).snapshot(metric, ownerId);
}
public static void synchronizeObserved(MinecraftServer server, Collection<Identifier> metricIds) {
if (server == null || metricIds == null || metricIds.isEmpty()) return;
SanctuaryRankingData data = SanctuaryRankingData.get(server);
for (ServerPlayer player : server.getPlayerList().getPlayers()) {
for (Identifier metricId : metricIds) {
VanillaRankingMetric.Source source = VanillaRankingMetric.parse(metricId).orElse(null);
if (source == null) continue;
data.observeVanilla(player.getUUID(), player.getGameProfile().name(), metricId,
VanillaRankingMetric.read(player, source), eligible(player));
}
}
}
private static boolean isRealOnlinePlayer(ServerPlayer player) {
return player != null && player.getClass() == ServerPlayer.class
&& player.level().getServer().getPlayerList().getPlayer(player.getUUID()) == player;
}
}
@@ -0,0 +1,292 @@
package fr.koka99cab.sanctuary26.sanctuary.api.ranking;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import fr.koka99cab.sanctuary26.sanctuary.SanctuaryMod;
import java.io.IOException;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Stream;
import net.minecraft.resources.Identifier;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.saveddata.SavedData;
import net.minecraft.world.level.saveddata.SavedDataType;
import net.minecraft.world.level.storage.LevelResource;
/** Versioned UUID/metric index; Red-Stoner never owns or duplicates these scores. */
final class SanctuaryRankingData extends SavedData {
static final String SAVE_KEY = "rankings";
static final int DATA_VERSION = 1;
static final long MAX_VALUE = Long.MAX_VALUE / 4L;
private static final int MAX_METRICS_PER_PLAYER = 16_384;
private static final Codec<Score> SCORE_CODEC = RecordCodecBuilder.create(instance -> instance.group(
Codec.LONG.fieldOf("value").forGetter(Score::value),
Codec.LONG.fieldOf("reached_order").forGetter(Score::reachedOrder)
).apply(instance, Score::new));
private static final Codec<Profile> PROFILE_CODEC = RecordCodecBuilder.create(instance -> instance.group(
Codec.STRING.optionalFieldOf("last_name", "?").forGetter(Profile::lastName),
Codec.unboundedMap(Codec.STRING, SCORE_CODEC).optionalFieldOf("metrics", Map.of())
.forGetter(Profile::metrics),
Codec.unboundedMap(Codec.STRING, Codec.LONG).optionalFieldOf("vanilla_observed", Map.of())
.forGetter(Profile::vanillaObserved)
).apply(instance, Profile::new));
private static final Codec<SanctuaryRankingData> CODEC = RecordCodecBuilder.create(instance -> instance.group(
Codec.INT.optionalFieldOf("data_version", DATA_VERSION).forGetter(data -> data.dataVersion),
Codec.BOOL.optionalFieldOf("vanilla_stats_imported", false).forGetter(data -> data.vanillaStatsImported),
Codec.LONG.optionalFieldOf("next_reached_order", 1L).forGetter(data -> data.nextReachedOrder),
Codec.unboundedMap(Codec.STRING, PROFILE_CODEC).optionalFieldOf("players", Map.of())
.forGetter(data -> data.players)
).apply(instance, SanctuaryRankingData::new));
private static final SavedDataType<SanctuaryRankingData> TYPE = new SavedDataType<>(
SanctuaryMod.id(SAVE_KEY), SanctuaryRankingData::new, CODEC, null);
private int dataVersion;
private boolean vanillaStatsImported;
private long nextReachedOrder;
private final Map<String, Profile> players;
SanctuaryRankingData() {
this(DATA_VERSION, false, 1L, Map.of());
}
SanctuaryRankingData(int dataVersion, boolean vanillaStatsImported, long nextReachedOrder,
Map<String, Profile> players) {
this.dataVersion = dataVersion;
this.vanillaStatsImported = vanillaStatsImported;
this.nextReachedOrder = Math.max(1L, nextReachedOrder);
this.players = new HashMap<>();
players.forEach((player, profile) -> {
try {
UUID.fromString(player);
this.players.put(player, sanitize(profile));
} catch (IllegalArgumentException ignored) {
// A malformed external key is ignored rather than poisoning the complete save.
}
});
}
static SanctuaryRankingData get(MinecraftServer server) {
ServerLevel overworld = server.getLevel(Level.OVERWORLD);
if (overworld == null) throw new IllegalStateException("Overworld unavailable for ranking data");
SanctuaryRankingData data = overworld.getDataStorage().computeIfAbsent(TYPE);
if (data.dataVersion < DATA_VERSION) {
data.dataVersion = DATA_VERSION;
data.setDirty();
} else if (data.dataVersion > DATA_VERSION) {
SanctuaryMod.LOGGER.warn("[{}] Ranking data v{} is newer than supported v{}; writes are disabled.",
SanctuaryMod.DISPLAY_NAME, data.dataVersion, DATA_VERSION);
}
return data;
}
boolean writable() {
return dataVersion <= DATA_VERSION;
}
void updateName(UUID playerId, String name) {
if (!writable()) return;
String key = playerId.toString();
Profile current = players.getOrDefault(key, new Profile(cleanName(name), Map.of(), Map.of()));
String clean = cleanName(name);
if (current.lastName().equals(clean)) return;
players.put(key, new Profile(clean, current.metrics(), current.vanillaObserved()));
setDirty();
}
void recordValue(UUID playerId, String name, Identifier metricId, long rawValue) {
if (!writable() || rawValue < 0L) return;
String key = playerId.toString();
Profile current = players.getOrDefault(key, new Profile(cleanName(name), Map.of(), Map.of()));
Map<String, Score> metrics = new HashMap<>(current.metrics());
String metricKey = metricId.toString();
Score previous = metrics.get(metricKey);
long value = Math.min(MAX_VALUE, rawValue);
if (previous != null && previous.value() >= value) {
updateName(playerId, name);
return;
}
if (previous == null && metrics.size() >= MAX_METRICS_PER_PLAYER) return;
metrics.put(metricKey, new Score(value, takeReachedOrder()));
players.put(key, new Profile(cleanName(name), metrics, current.vanillaObserved()));
setDirty();
}
void observeVanilla(UUID playerId, String name, Identifier metricId, long rawValue, boolean credited) {
if (!writable() || rawValue < 0L) return;
String key = playerId.toString();
Profile current = players.getOrDefault(key, new Profile(cleanName(name), Map.of(), Map.of()));
Map<String, Long> observed = new HashMap<>(current.vanillaObserved());
String metricKey = metricId.toString();
Long previous = observed.get(metricKey);
if (previous == null && observed.size() >= MAX_METRICS_PER_PLAYER) return;
long value = Math.min(MAX_VALUE, rawValue);
if (previous == null || previous.longValue() != value || !current.lastName().equals(cleanName(name))) {
observed.put(metricKey, value);
players.put(key, new Profile(cleanName(name), current.metrics(), observed));
setDirty();
}
long creditedDelta = previous == null ? value : Math.max(0L, value - previous);
if (credited && creditedDelta > 0L) {
increment(playerId, name, metricId, creditedDelta);
}
}
void increment(UUID playerId, String name, Identifier metricId, long amount) {
if (!writable() || amount <= 0L) return;
long current = score(playerId, metricId);
long value = current >= MAX_VALUE - amount ? MAX_VALUE : current + amount;
recordValue(playerId, name, metricId, value);
}
long score(UUID playerId, Identifier metricId) {
Profile profile = players.get(playerId.toString());
Score score = profile == null ? null : profile.metrics().get(metricId.toString());
return score == null ? 0L : score.value();
}
RankingSnapshot snapshot(RankingMetric metric, UUID ownerId) {
List<Candidate> candidates = new ArrayList<>();
players.forEach((player, profile) -> {
Score score = profile.metrics().get(metric.id().toString());
if (score == null || score.value() <= 0L) return;
try {
candidates.add(new Candidate(UUID.fromString(player), profile.lastName(), score));
} catch (IllegalArgumentException ignored) {
// Already filtered during load, retained as defensive parsing.
}
});
candidates.sort(Comparator.comparingLong((Candidate candidate) -> candidate.score().value()).reversed()
.thenComparingLong(candidate -> candidate.score().reachedOrder())
.thenComparing(candidate -> candidate.playerId().toString()));
List<RankingSnapshot.Entry> podium = new ArrayList<>();
RankingSnapshot.Placement owner = RankingSnapshot.Placement.unranked();
long previousValue = -1L;
int rank = 0;
for (int index = 0; index < candidates.size(); index++) {
Candidate candidate = candidates.get(index);
if (candidate.score().value() != previousValue) {
rank = index + 1;
previousValue = candidate.score().value();
}
if (podium.size() < RankingSnapshot.MAX_PODIUM_SIZE) {
podium.add(new RankingSnapshot.Entry(candidate.playerId(), candidate.name(),
candidate.score().value(), rank));
}
if (candidate.playerId().equals(ownerId)) {
owner = new RankingSnapshot.Placement(candidate.score().value(), rank);
}
}
return new RankingSnapshot(metric, podium, owner);
}
void importVanillaStats(MinecraftServer server) {
if (!writable() || vanillaStatsImported) return;
Path statsDirectory = server.getWorldPath(LevelResource.PLAYER_STATS_DIR);
if (Files.isDirectory(statsDirectory)) {
try (Stream<Path> files = Files.list(statsDirectory)) {
files.filter(path -> path.getFileName().toString().endsWith(".json"))
.sorted().forEach(this::importVanillaFile);
} catch (IOException exception) {
SanctuaryMod.LOGGER.warn("[{}] Could not import existing vanilla statistics.",
SanctuaryMod.DISPLAY_NAME, exception);
return;
}
}
vanillaStatsImported = true;
setDirty();
}
void importVanillaFile(Path file) {
String fileName = file.getFileName().toString();
String idText = fileName.substring(0, fileName.length() - ".json".length());
UUID playerId;
try {
playerId = UUID.fromString(idText);
} catch (IllegalArgumentException ignored) {
return;
}
try (Reader reader = Files.newBufferedReader(file, StandardCharsets.UTF_8)) {
JsonObject root = JsonParser.parseReader(reader).getAsJsonObject();
JsonObject stats = root.has("stats") && root.get("stats").isJsonObject()
? root.getAsJsonObject("stats") : new JsonObject();
for (Map.Entry<String, JsonElement> typeEntry : stats.entrySet()) {
Identifier type = Identifier.tryParse(typeEntry.getKey());
if (type == null || !typeEntry.getValue().isJsonObject()) continue;
for (Map.Entry<String, JsonElement> valueEntry : typeEntry.getValue().getAsJsonObject().entrySet()) {
Identifier target = Identifier.tryParse(valueEntry.getKey());
if (target == null || !valueEntry.getValue().isJsonPrimitive()
|| !valueEntry.getValue().getAsJsonPrimitive().isNumber()) continue;
Identifier metricId = VanillaRankingMetric.id(type, target);
long value = Math.max(0L, valueEntry.getValue().getAsLong());
recordValue(playerId, shortFallbackName(playerId), metricId, value);
observeVanilla(playerId, shortFallbackName(playerId), metricId, value, false);
}
}
} catch (RuntimeException | IOException exception) {
SanctuaryMod.LOGGER.warn("[{}] Ignoring unreadable vanilla statistic file {}.",
SanctuaryMod.DISPLAY_NAME, file.getFileName(), exception);
}
}
private long takeReachedOrder() {
long current = nextReachedOrder;
if (nextReachedOrder < Long.MAX_VALUE) nextReachedOrder++;
return current;
}
private static Profile sanitize(Profile profile) {
Map<String, Score> metrics = new HashMap<>();
profile.metrics().entrySet().stream().limit(MAX_METRICS_PER_PLAYER).forEach(entry -> {
if (Identifier.tryParse(entry.getKey()) != null) metrics.put(entry.getKey(), entry.getValue());
});
Map<String, Long> observed = new HashMap<>();
profile.vanillaObserved().entrySet().stream().limit(MAX_METRICS_PER_PLAYER).forEach(entry -> {
if (Identifier.tryParse(entry.getKey()) != null) {
observed.put(entry.getKey(), Math.clamp(entry.getValue(), 0L, MAX_VALUE));
}
});
return new Profile(cleanName(profile.lastName()), metrics, observed);
}
private static String cleanName(String value) {
if (value == null || value.isBlank()) return "?";
String clean = value.strip();
return clean.length() > 32 ? clean.substring(0, 32) : clean;
}
private static String shortFallbackName(UUID playerId) {
return playerId.toString().substring(0, 8);
}
record Score(long value, long reachedOrder) {
Score {
value = Math.clamp(value, 0L, MAX_VALUE);
reachedOrder = Math.max(1L, reachedOrder);
}
}
record Profile(String lastName, Map<String, Score> metrics, Map<String, Long> vanillaObserved) {
Profile {
lastName = cleanName(lastName);
metrics = metrics == null ? Map.of() : Map.copyOf(metrics);
vanillaObserved = vanillaObserved == null ? Map.of() : Map.copyOf(vanillaObserved);
}
}
private record Candidate(UUID playerId, String name, Score score) {}
}
@@ -0,0 +1,88 @@
package fr.koka99cab.sanctuary26.sanctuary.api.ranking;
import fr.koka99cab.sanctuary26.sanctuary.SanctuaryMod;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.Identifier;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.stats.Stats;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
/** Stable encoding and server reader for persisted vanilla statistic identifiers. */
final class VanillaRankingMetric {
private static final String PREFIX = "vanilla/";
private static final List<String> ITEM_FAMILIES = List.of(
"mined", "crafted", "used", "broken", "picked_up", "dropped");
private VanillaRankingMetric() {}
static Identifier id(Identifier type, Identifier target) {
return SanctuaryMod.id(PREFIX + type.getNamespace() + "/" + type.getPath() + "/"
+ target.getNamespace() + "/" + target.getPath());
}
static Identifier playTimeId() {
return id(Identifier.withDefaultNamespace("custom"), Stats.PLAY_TIME);
}
static RankingMetric descriptor(Identifier id) {
Source source = parse(id).orElse(null);
if (source == null) {
return new RankingMetric(id, "metric.sanctuary.ranking.unknown", RankingUnit.COUNT);
}
boolean playTime = source.type().getPath().equals("custom") && source.target().equals(Stats.PLAY_TIME);
RankingUnit unit = playTime ? RankingUnit.TICKS : RankingUnit.COUNT;
return new RankingMetric(id, "metric.sanctuary.ranking."
+ (playTime ? "play_time" : source.type().getPath()), unit);
}
static List<RankingMetric> itemMetrics(ItemStack icon) {
if (icon == null || icon.isEmpty()) return List.of();
Item item = icon.getItem();
Identifier itemId = BuiltInRegistries.ITEM.getKey(item);
List<RankingMetric> metrics = new ArrayList<>();
for (String family : ITEM_FAMILIES) {
if (family.equals("mined") && !(item instanceof BlockItem)) continue;
Identifier metricId = id(Identifier.withDefaultNamespace(family), itemId);
metrics.add(new RankingMetric(metricId, "metric.sanctuary.ranking." + family, RankingUnit.COUNT));
}
return List.copyOf(metrics);
}
static Optional<Source> parse(Identifier metricId) {
if (!metricId.getNamespace().equals(SanctuaryMod.MOD_ID)
|| !metricId.getPath().startsWith(PREFIX)) return Optional.empty();
String[] parts = metricId.getPath().split("/", 5);
if (parts.length != 5) return Optional.empty();
Identifier type = Identifier.tryParse(parts[1] + ":" + parts[2]);
Identifier target = Identifier.tryParse(parts[3] + ":" + parts[4]);
return type == null || target == null ? Optional.empty() : Optional.of(new Source(type, target));
}
static long read(ServerPlayer player, Source source) {
String family = source.type().getPath();
Identifier target = source.target();
return switch (family) {
case "mined" -> BuiltInRegistries.BLOCK.getOptional(target)
.map(block -> (long) player.getStats().getValue(Stats.BLOCK_MINED, block)).orElse(0L);
case "crafted" -> BuiltInRegistries.ITEM.getOptional(target)
.map(item -> (long) player.getStats().getValue(Stats.ITEM_CRAFTED, item)).orElse(0L);
case "used" -> BuiltInRegistries.ITEM.getOptional(target)
.map(item -> (long) player.getStats().getValue(Stats.ITEM_USED, item)).orElse(0L);
case "broken" -> BuiltInRegistries.ITEM.getOptional(target)
.map(item -> (long) player.getStats().getValue(Stats.ITEM_BROKEN, item)).orElse(0L);
case "picked_up" -> BuiltInRegistries.ITEM.getOptional(target)
.map(item -> (long) player.getStats().getValue(Stats.ITEM_PICKED_UP, item)).orElse(0L);
case "dropped" -> BuiltInRegistries.ITEM.getOptional(target)
.map(item -> (long) player.getStats().getValue(Stats.ITEM_DROPPED, item)).orElse(0L);
case "custom" -> (long) player.getStats().getValue(Stats.CUSTOM, target);
default -> 0L;
};
}
record Source(Identifier type, Identifier target) {}
}
@@ -0,0 +1,149 @@
package fr.koka99cab.sanctuary26.sanctuary.backroom;
import fr.koka99cab.sanctuary26.sanctuary.registry.SanctuaryRegistries;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.util.RandomSource;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.ChestBlock;
import net.minecraft.world.level.block.entity.ChestBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.ChestType;
/** Renewable loot nodes backed by the non-duplicating real-item registry. */
public final class BackroomChestService {
public static final long REFRESH_TICKS = 12_000L;
private BackroomChestService() {}
public static void open(ChestBlockEntity opened, ServerPlayer player) {
if (!(opened.getLevel() instanceof ServerLevel level) || !BackroomService.isBackroom(level)) return;
ChestGroup group = group(level, opened);
BackroomData data = BackroomData.get(level.getServer());
long cycle = Math.floorDiv(level.getGameTime(), REFRESH_TICKS);
BackroomData.ChestState state = data.chest(group.anchor).orElse(null);
ArrayList<UUID> assigned = state == null ? new ArrayList<>() : new ArrayList<>(state.assignedIds());
boolean refreshed = state == null || state.cycle() != cycle;
if (refreshed) {
data.reconcileChest(group.anchor, markers(group));
group.clear();
assigned.clear();
}
BackroomData.ChestVisit visit = data.visitChest(player.getUUID(), group.anchor);
boolean personalInserted = false;
if (visit.firstVisit() && personalRoll(player.getRandom(), visit.ordinal())) {
BackroomData.MaterializedLoss loss = data.takePersonal(player.getUUID(), group.anchor).orElse(null);
if (loss != null && group.insertLoss(loss.stack())) {
assigned.add(loss.id());
personalInserted = true;
} else if (loss != null) {
data.capture(loss.stack(), player.getUUID(), "chest_full", level.getGameTime());
}
}
if (refreshed) rollGeneralLoot(level, group, data, assigned, cycle);
if (refreshed || personalInserted) data.updateChest(group.anchor, cycle, assigned);
}
public static boolean personalRoll(RandomSource random, int ordinal) {
if (ordinal <= 0) return false;
if (ordinal == 1) return random.nextFloat() < 0.75F;
if (ordinal == 2) return random.nextFloat() < 0.90F;
if (ordinal == 3) return true;
return random.nextFloat() < 0.65F;
}
private static void rollGeneralLoot(ServerLevel level, ChestGroup group, BackroomData data,
List<UUID> assigned, long cycle) {
RandomSource random = RandomSource.create(level.getSeed() ^ group.anchor ^ cycle * 0x9E3779B97F4A7C15L);
int roll = random.nextInt(100);
if (roll < 55) return;
if (roll < 74) {
insert(group, random, Items.DIRT, 4, 20);
if (random.nextBoolean()) insert(group, random, Items.OAK_PLANKS, 2, 10);
return;
}
if (roll < 90) {
insert(group, random, Items.COBBLESTONE, 6, 24);
insert(group, random, random.nextBoolean() ? Items.TORCH : Items.BREAD, 2, 7);
if (random.nextInt(3) == 0) group.insert(new ItemStack(Items.WOODEN_PICKAXE));
return;
}
if (roll < 97) {
data.takeShared(group.anchor, level.getGameTime()).ifPresent(loss -> {
if (group.insertLoss(loss.stack())) assigned.add(loss.id());
else data.capture(loss.stack(), null, "chest_full", level.getGameTime());
});
return;
}
if (roll < 99) {
group.insert(new ItemStack(Items.IRON_PICKAXE));
insert(group, random, Items.ENDER_PEARL, 1, 2);
} else {
group.insert(new ItemStack(Items.DIAMOND));
}
}
private static void insert(ChestGroup group, RandomSource random, Item item, int minimum, int maximum) {
group.insert(new ItemStack(item, minimum + random.nextInt(maximum - minimum + 1)));
}
private static List<UUID> markers(ChestGroup group) {
ArrayList<UUID> result = new ArrayList<>();
for (ChestBlockEntity chest : group.chests) for (int slot = 0; slot < chest.getContainerSize(); slot++) {
UUID marker = chest.getItem(slot).get(SanctuaryRegistries.BACKROOM_LOSS_COMPONENT);
if (marker != null) result.add(marker);
}
return result;
}
private static ChestGroup group(ServerLevel level, ChestBlockEntity opened) {
BlockPos pos = opened.getBlockPos();
BlockState state = opened.getBlockState();
if (!(state.getBlock() instanceof ChestBlock) || state.getValue(ChestBlock.TYPE) == ChestType.SINGLE) {
return new ChestGroup(pos.asLong(), List.of(opened));
}
BlockPos connectedPos = ChestBlock.getConnectedBlockPos(pos, state);
if (!(level.getBlockEntity(connectedPos) instanceof ChestBlockEntity connected)) {
return new ChestGroup(pos.asLong(), List.of(opened));
}
long anchor = Math.min(pos.asLong(), connectedPos.asLong());
return pos.asLong() == anchor
? new ChestGroup(anchor, List.of(opened, connected))
: new ChestGroup(anchor, List.of(connected, opened));
}
private record ChestGroup(long anchor, List<ChestBlockEntity> chests) {
private void clear() {
chests.forEach(chest -> { chest.clearContent(); chest.setChanged(); });
}
private boolean insert(ItemStack offered) {
if (offered == null || offered.isEmpty()) return false;
for (ChestBlockEntity chest : chests) if (insertInto(chest, offered)) return true;
return false;
}
/** Keeps every real loss in the physical anchor chest tracked by the persisted state. */
private boolean insertLoss(ItemStack offered) {
return offered != null && !offered.isEmpty() && insertInto(chests.getFirst(), offered);
}
private static boolean insertInto(ChestBlockEntity chest, ItemStack offered) {
for (int slot = 0; slot < chest.getContainerSize(); slot++) {
if (!chest.getItem(slot).isEmpty()) continue;
chest.setItem(slot, offered.copy());
chest.setChanged();
return true;
}
return false;
}
}
}
@@ -0,0 +1,316 @@
package fr.koka99cab.sanctuary26.sanctuary.backroom;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import fr.koka99cab.sanctuary26.sanctuary.SanctuaryMod;
import fr.koka99cab.sanctuary26.sanctuary.registry.SanctuaryRegistries;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.saveddata.SavedData;
import net.minecraft.world.level.saveddata.SavedDataType;
/** Persistent, bounded state for Backroom entries and the real-item loss pool. */
public final class BackroomData extends SavedData {
public static final String SAVE_KEY = "backroom";
public static final int DATA_VERSION = 1;
public static final int MAX_PENDING_ENTRIES = 256;
public static final int MAX_ENTRY_SLOTS = 64;
public static final int MAX_LOST_ITEMS = 16_384;
public static final int MAX_CHEST_STATES = 65_536;
public static final int MAX_PLAYER_STATES = 4_096;
public static final int MAX_VISITED_CHESTS = 128;
public static final int MAX_RECENT_ARRIVALS = 8;
public static final long PERSONAL_RESERVATION_TICKS = 24_000L;
public static final String LOST_POOL = "pool";
public static final String LOST_CHEST = "chest";
public static final Codec<EntrySlot> ENTRY_SLOT_CODEC = RecordCodecBuilder.create(instance -> instance.group(
Codec.STRING.fieldOf("location").forGetter(EntrySlot::location),
Codec.INT.fieldOf("index").forGetter(EntrySlot::index),
ItemStack.CODEC.fieldOf("item").forGetter(EntrySlot::item)
).apply(instance, EntrySlot::new));
private static final Codec<PendingEntry> PENDING_CODEC = RecordCodecBuilder.create(instance -> instance.group(
Codec.STRING.fieldOf("player").forGetter(PendingEntry::player),
Codec.STRING.fieldOf("transaction").forGetter(PendingEntry::transaction),
ENTRY_SLOT_CODEC.listOf(0, MAX_ENTRY_SLOTS).fieldOf("slots").forGetter(PendingEntry::slots)
).apply(instance, PendingEntry::new));
private static final Codec<LostItem> LOST_CODEC = RecordCodecBuilder.create(instance -> instance.group(
Codec.STRING.fieldOf("id").forGetter(LostItem::id),
Codec.STRING.optionalFieldOf("owner", "").forGetter(LostItem::owner),
Codec.STRING.fieldOf("cause").forGetter(LostItem::cause),
Codec.LONG.fieldOf("lost_at").forGetter(LostItem::lostAt),
ItemStack.CODEC.fieldOf("item").forGetter(LostItem::item),
Codec.STRING.optionalFieldOf("state", LOST_POOL).forGetter(LostItem::state),
Codec.LONG.optionalFieldOf("chest", Long.MIN_VALUE).forGetter(LostItem::chest)
).apply(instance, LostItem::new));
private static final Codec<ChestState> CHEST_CODEC = RecordCodecBuilder.create(instance -> instance.group(
Codec.LONG.fieldOf("pos").forGetter(ChestState::pos),
Codec.LONG.fieldOf("cycle").forGetter(ChestState::cycle),
Codec.STRING.listOf(0, 54).optionalFieldOf("assigned", List.of()).forGetter(ChestState::assigned)
).apply(instance, ChestState::new));
private static final Codec<PlayerState> PLAYER_CODEC = RecordCodecBuilder.create(instance -> instance.group(
Codec.STRING.fieldOf("player").forGetter(PlayerState::player),
Codec.INT.optionalFieldOf("personal_attempts", 0).forGetter(PlayerState::personalAttempts),
Codec.LONG.listOf(0, MAX_VISITED_CHESTS).optionalFieldOf("visited_chests", List.of()).forGetter(PlayerState::visitedChests),
Codec.LONG.listOf(0, MAX_RECENT_ARRIVALS).optionalFieldOf("recent_arrivals", List.of()).forGetter(PlayerState::recentArrivals)
).apply(instance, PlayerState::new));
private static final Codec<BackroomData> CODEC = RecordCodecBuilder.create(instance -> instance.group(
Codec.INT.optionalFieldOf("data_version", DATA_VERSION).forGetter(data -> data.dataVersion),
PENDING_CODEC.listOf(0, MAX_PENDING_ENTRIES).optionalFieldOf("pending_entries", List.of()).forGetter(data -> data.pendingEntries),
LOST_CODEC.listOf(0, MAX_LOST_ITEMS).optionalFieldOf("lost_items", List.of()).forGetter(data -> data.lostItems),
CHEST_CODEC.listOf(0, MAX_CHEST_STATES).optionalFieldOf("chests", List.of()).forGetter(data -> data.chests),
PLAYER_CODEC.listOf(0, MAX_PLAYER_STATES).optionalFieldOf("players", List.of()).forGetter(data -> data.players)
).apply(instance, BackroomData::new));
private static final SavedDataType<BackroomData> TYPE = new SavedDataType<>(
SanctuaryMod.id(SAVE_KEY), BackroomData::new, CODEC, null);
private int dataVersion;
private final List<PendingEntry> pendingEntries;
private final List<LostItem> lostItems;
private final List<ChestState> chests;
private final Map<Long, Integer> chestIndices;
private final List<PlayerState> players;
public BackroomData() {
this(DATA_VERSION, List.of(), List.of(), List.of(), List.of());
}
private BackroomData(int dataVersion, List<PendingEntry> pendingEntries, List<LostItem> lostItems,
List<ChestState> chests, List<PlayerState> players) {
this.dataVersion = Math.max(DATA_VERSION, dataVersion);
this.pendingEntries = bounded(pendingEntries, MAX_PENDING_ENTRIES);
this.lostItems = bounded(lostItems, MAX_LOST_ITEMS);
this.chests = bounded(chests, MAX_CHEST_STATES);
this.chestIndices = new HashMap<>();
for (int index = 0; index < this.chests.size(); index++) chestIndices.put(this.chests.get(index).pos, index);
this.players = bounded(players, MAX_PLAYER_STATES);
}
public static BackroomData get(MinecraftServer server) {
ServerLevel overworld = server.getLevel(Level.OVERWORLD);
if (overworld == null) throw new IllegalStateException("Overworld unavailable for Backroom data");
BackroomData data = overworld.getDataStorage().computeIfAbsent(TYPE);
if (data.dataVersion < DATA_VERSION) {
data.dataVersion = DATA_VERSION;
data.setDirty();
}
return data;
}
public Optional<PendingEntry> pendingEntry(UUID player) {
String id = player.toString();
return pendingEntries.stream().filter(entry -> entry.player.equals(id)).findFirst();
}
public Optional<PendingEntry> prepareEntry(UUID player, List<EntrySlot> slots) {
pendingEntries.removeIf(entry -> entry.player.equals(player.toString()));
if (pendingEntries.size() >= MAX_PENDING_ENTRIES) return Optional.empty();
PendingEntry entry = new PendingEntry(player.toString(), UUID.randomUUID().toString(), copySlots(slots));
pendingEntries.add(entry);
setDirty();
return Optional.of(entry);
}
public void finishEntry(UUID player) {
if (pendingEntries.removeIf(entry -> entry.player.equals(player.toString()))) setDirty();
}
/** Adds a new loss or returns a previously materialized loss to the pool. */
public Optional<UUID> capture(ItemStack source, UUID owner, String cause, long gameTime) {
if (source == null || source.isEmpty()) return Optional.empty();
ItemStack clean = source.copy();
UUID marker = clean.get(SanctuaryRegistries.BACKROOM_LOSS_COMPONENT);
clean.remove(SanctuaryRegistries.BACKROOM_LOSS_COMPONENT);
if (marker != null) {
int existing = indexOfLoss(marker);
if (existing >= 0) {
LostItem previous = lostItems.get(existing);
lostItems.set(existing, new LostItem(previous.id, owner == null ? previous.owner : owner.toString(),
cause, gameTime, clean, LOST_POOL, Long.MIN_VALUE));
setDirty();
return Optional.of(marker);
}
}
if (lostItems.size() >= MAX_LOST_ITEMS) return Optional.empty();
UUID id = marker == null ? UUID.randomUUID() : marker;
lostItems.add(new LostItem(id.toString(), owner == null ? "" : owner.toString(), cause,
gameTime, clean, LOST_POOL, Long.MIN_VALUE));
setDirty();
return Optional.of(id);
}
public Optional<MaterializedLoss> takePersonal(UUID owner, long chestPos) {
String player = owner.toString();
return lostItems.stream()
.filter(loss -> loss.state.equals(LOST_POOL) && loss.owner.equals(player))
.max(Comparator.comparingLong(LostItem::lostAt))
.flatMap(loss -> materialize(loss, chestPos));
}
public Optional<MaterializedLoss> takeShared(long chestPos, long gameTime) {
return lostItems.stream()
.filter(loss -> loss.state.equals(LOST_POOL)
&& sharedEligible(loss.owner, loss.lostAt, gameTime))
.min(Comparator.comparingLong(LostItem::lostAt))
.flatMap(loss -> materialize(loss, chestPos));
}
static boolean sharedEligible(String owner, long lostAt, long gameTime) {
return owner == null || owner.isEmpty()
|| gameTime >= lostAt && gameTime - lostAt >= PERSONAL_RESERVATION_TICKS;
}
private Optional<MaterializedLoss> materialize(LostItem loss, long chestPos) {
int index = lostItems.indexOf(loss);
if (index < 0) return Optional.empty();
ItemStack marked = loss.item.copy();
UUID id = loss.uuid();
marked.set(SanctuaryRegistries.BACKROOM_LOSS_COMPONENT, id);
lostItems.set(index, new LostItem(loss.id, loss.owner, loss.cause, loss.lostAt,
loss.item.copy(), LOST_CHEST, chestPos));
setDirty();
return Optional.of(new MaterializedLoss(id, marked));
}
/** Reconciles real items allocated during the chest's previous loot cycle. */
public void reconcileChest(long chestPos, List<UUID> markersStillPresent) {
List<String> present = markersStillPresent.stream().map(UUID::toString).toList();
boolean changed = false;
for (int index = lostItems.size() - 1; index >= 0; index--) {
LostItem loss = lostItems.get(index);
if (!loss.state.equals(LOST_CHEST) || loss.chest != chestPos) continue;
if (present.contains(loss.id)) {
lostItems.set(index, new LostItem(loss.id, loss.owner, loss.cause, loss.lostAt,
loss.item.copy(), LOST_POOL, Long.MIN_VALUE));
} else {
lostItems.remove(index);
}
changed = true;
}
if (changed) setDirty();
}
/** Settles a marked item that successfully left the Backroom. */
public void settle(UUID lossId) {
if (lossId != null && lostItems.removeIf(loss -> loss.id.equals(lossId.toString()))) setDirty();
}
public Optional<ChestState> chest(long pos) {
Integer index = chestIndices.get(pos);
return index == null ? Optional.empty() : Optional.of(chests.get(index));
}
public void updateChest(long pos, long cycle, List<UUID> assigned) {
ChestState replacement = new ChestState(pos, cycle, assigned.stream().limit(54).map(UUID::toString).toList());
Integer existing = chestIndices.get(pos);
if (existing != null) {
chests.set(existing, replacement);
} else {
if (chests.size() >= MAX_CHEST_STATES) {
chests.removeFirst();
chestIndices.clear();
for (int index = 0; index < chests.size(); index++) chestIndices.put(chests.get(index).pos, index);
}
chestIndices.put(pos, chests.size());
chests.add(replacement);
}
setDirty();
}
/** Marks a chest and returns whether it is a new personal-recovery attempt. */
public ChestVisit visitChest(UUID player, long chestPos) {
PlayerState state = playerState(player);
ArrayList<Long> visited = new ArrayList<>(state.visitedChests);
boolean firstVisit = !visited.contains(chestPos);
if (firstVisit) {
if (visited.size() >= MAX_VISITED_CHESTS) visited.removeFirst();
visited.add(chestPos);
state = replacePlayer(state, state.personalAttempts + 1, visited, state.recentArrivals);
}
return new ChestVisit(firstVisit, state.personalAttempts);
}
public void beginExpedition(UUID player, long packedArrival) {
PlayerState state = playerState(player);
ArrayList<Long> arrivals = new ArrayList<>(state.recentArrivals);
arrivals.remove(packedArrival);
arrivals.addFirst(packedArrival);
while (arrivals.size() > MAX_RECENT_ARRIVALS) arrivals.removeLast();
replacePlayer(state, 0, List.of(), arrivals);
}
public List<Long> recentArrivals(UUID player) {
return List.copyOf(playerState(player).recentArrivals);
}
public int lostItemCount() { return lostItems.size(); }
public long pooledItemCount() { return lostItems.stream().filter(loss -> loss.state.equals(LOST_POOL)).count(); }
public long pooledItemCount(UUID owner) {
String id = owner.toString();
return lostItems.stream().filter(loss -> loss.state.equals(LOST_POOL) && loss.owner.equals(id)).count();
}
public int trackedChestCount() { return chests.size(); }
private PlayerState playerState(UUID player) {
String id = player.toString();
return players.stream().filter(state -> state.player.equals(id)).findFirst().orElseGet(() -> {
if (players.size() >= MAX_PLAYER_STATES) players.removeFirst();
PlayerState state = new PlayerState(id, 0, List.of(), List.of());
players.add(state);
setDirty();
return state;
});
}
private PlayerState replacePlayer(PlayerState old, int attempts, List<Long> visited, List<Long> arrivals) {
PlayerState replacement = new PlayerState(old.player, Math.max(0, attempts),
bounded(visited, MAX_VISITED_CHESTS), bounded(arrivals, MAX_RECENT_ARRIVALS));
players.set(players.indexOf(old), replacement);
setDirty();
return replacement;
}
private int indexOfLoss(UUID id) {
String value = id.toString();
for (int index = 0; index < lostItems.size(); index++) if (lostItems.get(index).id.equals(value)) return index;
return -1;
}
private static List<EntrySlot> copySlots(List<EntrySlot> slots) {
return slots.stream().filter(slot -> slot != null && !slot.item.isEmpty()).limit(MAX_ENTRY_SLOTS)
.map(slot -> new EntrySlot(slot.location, slot.index, slot.item.copy())).toList();
}
private static <T> ArrayList<T> bounded(List<T> source, int maximum) {
List<T> safe = source == null ? List.of() : source;
int start = Math.max(0, safe.size() - maximum);
return new ArrayList<>(safe.subList(start, safe.size()));
}
public record EntrySlot(String location, int index, ItemStack item) {
public EntrySlot { item = item == null ? ItemStack.EMPTY : item.copy(); }
}
public record PendingEntry(String player, String transaction, List<EntrySlot> slots) {
public UUID transactionId() { return UUID.fromString(transaction); }
}
public record LostItem(String id, String owner, String cause, long lostAt, ItemStack item,
String state, long chest) {
public UUID uuid() { return UUID.fromString(id); }
}
public record ChestState(long pos, long cycle, List<String> assigned) {
public List<UUID> assignedIds() { return assigned.stream().map(UUID::fromString).toList(); }
}
private record PlayerState(String player, int personalAttempts, List<Long> visitedChests,
List<Long> recentArrivals) {}
public record MaterializedLoss(UUID id, ItemStack stack) {}
public record ChestVisit(boolean firstVisit, int ordinal) {}
}

Some files were not shown because too many files have changed in this diff Show More