Compare commits
23
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ad9763666 | ||
|
|
0196b6efa5 | ||
|
|
3bdc5fe241 | ||
|
|
789faeb708 | ||
|
|
3491158785 | ||
|
|
c0229d4ea9 | ||
|
|
ddaf71c7cd | ||
|
|
7e1ed85307 | ||
|
|
5840621acf | ||
|
|
974cea20b5 | ||
|
|
81a98ed197 | ||
|
|
b022be5739 | ||
|
|
27b29c1340 | ||
|
|
274d4c1ffa | ||
|
|
f217bb3661 | ||
|
|
5100091b17 | ||
|
|
398d94e7d1 | ||
|
|
0743ff33a6 | ||
|
|
bfda90f4f4 | ||
|
|
a698140963 | ||
|
|
88ec91e9f4 | ||
|
|
e1d48e9017 | ||
|
|
cce58c27c8 |
+44
-1
@@ -8,7 +8,47 @@ Ce journal suit les **versions du modpack**. Lorsqu'un seul module change, sa ve
|
||||
|
||||
## Non publié
|
||||
|
||||
Modules modifiés : **Sanctuary `0.0.0-alpha.135`** et **Red-Stoner `0.0.0-alpha.17`**.
|
||||
Aucun changement non publié.
|
||||
|
||||
## `26.2.0-alpha.233`
|
||||
|
||||
Modules modifiés : **Sanctuary `0.0.0-alpha.139`** et **Red-Stoner `0.0.0-alpha.20`**.
|
||||
|
||||
- remplace le bloc-écran `redstoner:trophy_panel` par un vrai panneau Vanilla en chêne pâle, posable au sol ou au mur, sans changer l’ID de l’item déjà présent dans les inventaires et recettes ;
|
||||
- ouvre à la première pose un éditeur blanc permettant de rechercher une statistique Vanilla, composer et réordonner jusqu’à seize pages, puis choisir entre noms et valeurs, noms seuls ou valeurs seules ;
|
||||
- verrouille la configuration et la destruction au créateur ou à un opérateur, tout en laissant le clic droit public faire défiler les pages ;
|
||||
- conserve l’ancien bloc uniquement comme alias de migration : chaque plaque déjà posée devient automatiquement un panneau mural en gardant propriétaire, statistiques et page courante ;
|
||||
- répare les classements importés qui montraient les huit premiers caractères de l’UUID : Sanctuary récupère désormais le vrai pseudo depuis le cache local du serveur et utilise `?` plutôt qu’un fragment d’UUID si aucun nom n’est connu ;
|
||||
- ajoute les payloads bornés de l’éditeur, fait passer Red-Stoner aux données v5 et au protocole réseau 9, sans changer les données v15 ni le protocole 24 de Sanctuary. Client et serveur Red-Stoner doivent être mis à jour ensemble.
|
||||
|
||||
## `26.2.0-alpha.232`
|
||||
|
||||
Modules modifiés : **Another World `0.0.0-alpha.58`**, **Sanctuary `0.0.0-alpha.138`** et **Red-Stoner `0.0.0-alpha.19`**.
|
||||
|
||||
- ferme le ticket #146 en enregistrant chaque cliché pris avec un appareil Canon dans le dossier `screenshots` de l’instance, à côté des captures F2 ;
|
||||
- exporte le carré cadré à sa résolution native avec le filtre de la pellicule, sans le réduire aux 128 × 128 pixels de la carte en jeu ;
|
||||
- écrit le PNG hors du thread de rendu et réserve un nom horodaté unique afin d’éviter les freezes comme les écrasements lors de plusieurs clichés rapprochés ;
|
||||
|
||||
- remplace le volume de la cape à motifs par les deux faces opposées de l’îlot UV exact du bouclier, redimensionnées aux proportions 10 × 16 de la cape, afin de corriger la projection et le culling sans afficher le manche ni l’épaisseur du bouclier ;
|
||||
- laisse la touche d’inventaire fermer le terminal tant que la recherche n’est pas focalisée, mais la traite comme du texte dans le champ de recherche afin que la lettre `E` ne ferme plus l’écran ;
|
||||
- utilise les huit lignes du panneau de trophées pour afficher le titre et jusqu’à sept rangs, avec une page de noms suivie d’une page de valeurs pour chaque statistique afin que les longues durées de jeu restent lisibles ;
|
||||
- fait configurer par un œuf d’apparition le classement vanilla des créatures correspondantes tuées, par exemple les zombies tués avec l’œuf de zombie ;
|
||||
- conserve les IDs et les sauvegardes Sanctuary v15/Red-Stoner v4 ; le snapshot client du panneau passant de trois à sept entrées, le protocole Red-Stoner passe de 7 à 8 et exige la mise à jour du client et du serveur.
|
||||
|
||||
## `26.2.0-alpha.231`
|
||||
|
||||
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 d’un 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 d’un 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 qu’ils soient réellement trouvables ;
|
||||
- actualise JEI vers la bêta Fabric `30.29.0.201`, qui corrige un crash avec les mods utilisant l’atlas de textures ;
|
||||
- ne change ni le butin ordinaire des coffres, ni les données Sanctuary v15/Red-Stoner v4, ni leurs protocoles réseau 24/7 ; les nouveaux coffres et lits apparaissent dans les chunks qui n’ont 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 ;
|
||||
@@ -16,6 +56,9 @@ Modules modifiés : **Sanctuary `0.0.0-alpha.135`** et **Red-Stoner `0.0.0-alpha
|
||||
- ajoute l’API 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 l’armure de loup vanilla en écailles de tatou, de la réparer avec des écailles et de la retirer aux cisailles ; l’armure 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 : l’armure utilise exclusivement le slot d’équipement vanilla de la poule.
|
||||
|
||||
## `26.2.0-alpha.229`
|
||||
|
||||
|
||||
@@ -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.159.0+26.2, Loom 1.17, Gradle 9.5.1 et Java 25.
|
||||
Workspace Fabric multi-projet de Sanctuary 2.0. Il construit les dix JAR du pack et le mod événementiel ZEVENT distribué à part, 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`)
|
||||
@@ -19,14 +19,19 @@ Licence : **GNU GPL 3.0 or Later** (`GPL-3.0-or-later`)
|
||||
| `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 |
|
||||
| `zevent` | ZEVENT | diffusion Twitch temporaire | écran mural 9×5, hors pack principal |
|
||||
|
||||
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.229`**. Cette release distribue Red-Stoner **`0.0.0-alpha.16`** ; les neuf autres modules conservent leur version issue de l'alpha.228.
|
||||
Version courante du pack distribué : **`26.2.0-alpha.233`**. Cette release distribue Another World **`0.0.0-alpha.58`**, Sanctuary **`0.0.0-alpha.139`** et Red-Stoner **`0.0.0-alpha.20`** ; les sept autres modules conservent leur version issue de l'alpha.231.
|
||||
|
||||
Le prochain module Sanctuary **`0.0.0-alpha.134`** 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. Chaque niveau garantit désormais un lit par cellule de 10 × 10 chunks dans les nouveaux chunks, sans modifier les sauvegardes, les données v14 ni le protocole réseau 24.
|
||||
L’alpha.233 remplace le bloc-écran des trophées par un véritable panneau Vanilla en chêne pâle, posable au sol ou au mur. Son éditeur permet de rechercher une statistique, composer jusqu’à seize pages et choisir l’affichage des noms et valeurs ; le propriétaire ou un opérateur garde le contrôle de sa configuration tandis que le changement de page reste public. L’item `redstoner:trophy_panel` conserve son ID et les anciens panneaux posés sont migrés automatiquement. Les classements affichent désormais le vrai pseudo connu du joueur au lieu d’un fragment d’UUID. Les sauvegardes Sanctuary restent en données v15/protocole 24 ; Red-Stoner passe aux données v5 et au protocole 9, ce qui exige la même version côté client et serveur.
|
||||
|
||||
Sanctuary **`0.0.0-alpha.135`** et Red-Stoner **`0.0.0-alpha.17`** ajoutent les classements publics et le panneau mural `redstoner:trophy_panel`. Les statistiques vanilla des anciens joueurs sont importées une fois, les scores restent dans Sanctuary et le panneau ne reçoit que sa page visible ainsi qu’un podium de trois noms maximum. Les données passent respectivement à v15 et v4 sans changer les protocoles réseau 24 et 7.
|
||||
L’alpha.232 enregistre automatiquement chaque cliché Canon dans le dossier `screenshots` de l’instance, à côté des captures F2. Le PNG conserve le carré réellement cadré, sa résolution et le filtre de la pellicule ; l’écriture asynchrone et les noms uniques évitent les freezes et les écrasements. Cette release corrige aussi la cape blanche décorée, la touche `E` du terminal et étend le panneau de trophées à huit lignes. Chaque statistique y possède une page de noms puis une page de valeurs ; un œuf d’apparition ajoute directement le classement des créatures correspondantes tuées. Les sauvegardes restent en données Another World v5, Sanctuary v15 et Red-Stoner v4 ; le snapshot du panneau passant à sept entrées, le protocole Red-Stoner passe à 8.
|
||||
|
||||
L’alpha.231 rend les sorties et le butin de la Backroom réellement trouvables sur ses cinq niveaux. Chaque niveau garantit désormais un coffre et un lit de sortie par cellule de 3 × 3 chunks dans les nouveaux chunks, sans ajouter de livres au butin. Le panneau de trophées devient une plaque verticale de chêne avec quatre lignes lisibles : titre et numéro de page, puis les trois places du podium. Un clic droit avance d’une page et `Maj` + clic droit revient à la précédente. JEI passe à la bêta Fabric `30.29.0.201`, qui corrige un crash lié à l’atlas de textures. Les sauvegardes et les chunks déjà générés restent compatibles ; Sanctuary conserve les données v15/protocole 24 et Red-Stoner les données v4/protocole 7.
|
||||
|
||||
L’alpha.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 l’armure 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.
|
||||
|
||||
L’alpha.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 l’ordre ainsi que les objets sous le curseur. Les sauvegardes, les données Red-Stoner v3 et le protocole réseau 7 restent compatibles.
|
||||
|
||||
@@ -323,9 +328,9 @@ Le guide détaillé est dans [`masterkey/tools/PANORAMA.md`](masterkey/tools/PAN
|
||||
|
||||
## Red-Stoner et photographie
|
||||
|
||||
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.
|
||||
Red-Stoner possède ses appareils sous son namespace ainsi que la paire de panneaux Vanilla `trophy_sign`/`trophy_wall_sign`. L’item historique `redstoner:trophy_panel` est conservé afin que les inventaires et recettes existants restent valides ; il place désormais cette paire, tandis que l’ancien bloc mural du même ID ne subsiste que le temps de sa migration automatique. Son onglet créatif expose le panneau de trophées avec les ordinateurs, le Particuleur et le terminal de stockage.
|
||||
|
||||
Le panneau mural `redstoner:trophy_panel` consomme l’API 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 l’item servant d’icône et la base complète des joueurs ne sont jamais synchronisés au client.
|
||||
Le panneau de trophées consomme l’API publique de classement de Sanctuary sans conserver les scores. Sa première pose ouvre un éditeur blanc : le créateur choisit dans le catalogue Vanilla jusqu’à seize statistiques, leur ordre et un affichage noms+valeurs, noms seuls ou valeurs seules. `Maj` + clic droit rouvre ensuite cet éditeur pour le créateur ou un opérateur ; le clic droit ordinaire fait défiler publiquement les pages. La configuration et la destruction sont protégées par UUID. Chaque page utilise les quatre lignes natives du panneau — titre puis trois rangs — et se rafraîchit côté serveur. Sanctuary importe une fois les statistiques Vanilla existantes, conserve les classements par UUID — champion déconnecté compris — et résout les vrais pseudos depuis le cache du serveur au lieu d’afficher un début d’UUID.
|
||||
|
||||
L'ordinateur 8 bits et le contrôleur exécutent la machine virtuelle historique : programme assembleur borné à 4 096 caractères, RAM, inventaire, six ports redstone directionnels, impulsions et sortie comparateur. Le contrôleur dispose de 1 024 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é.
|
||||
|
||||
@@ -414,7 +419,7 @@ Le menu pause est lui aussi possédé par Sanctuary. Il ne conserve que Retour a
|
||||
|
||||
## Versions du modpack et mises à jour Modrinth
|
||||
|
||||
`pack_version` dans `gradle.properties` est la version du pack complet. `mod_version=0.0.0-alpha.0` et `module_lifecycle=standby` sont les valeurs par défaut des modules en veille ; les propriétés `<module>_version` et `<module>_lifecycle` n’activent et ne font avancer que le module concerné. Le contrat de distribution est dans `pack/release.json`.
|
||||
`pack_version` dans `gradle.properties` est la version du pack complet. `mod_version=0.0.0-alpha.0` et `module_lifecycle=standby` sont les valeurs par défaut des modules en veille ; les propriétés `<module>_version` et `<module>_lifecycle` n’activent et ne font avancer que le module concerné. Le contrat de distribution est dans `pack/release.json`. Le sous-projet `zevent` reste volontairement hors de `moduleIds` et des archives du pack : son JAR et sa dépendance cliente MCEF sont distribués séparément pour l’événement.
|
||||
|
||||
La version globale du pack n’est pas injectée dans les JAR inchangés : leur contenu et leur numéro restent immuables. Le lanceur possède la composition exacte du pack, tandis que chaque manifest conserve la version effective de son module.
|
||||
|
||||
|
||||
@@ -15,6 +15,14 @@ tasks.register("vaultRulesSmoke", JavaExec) {
|
||||
mainClass = "fr.koka99cab.sanctuary26.anotherworld.vault.VaultRulesSmoke"
|
||||
}
|
||||
|
||||
tasks.register("canonScreenshotFilesSmoke", JavaExec) {
|
||||
group = "verification"
|
||||
description = "Checks Canon photo exports use the vanilla screenshots directory and collision-safe names."
|
||||
dependsOn tasks.named("testClasses")
|
||||
classpath = sourceSets.test.runtimeClasspath
|
||||
mainClass = "fr.koka99cab.canon.client.CanonScreenshotFilesSmoke"
|
||||
}
|
||||
|
||||
tasks.named("test") {
|
||||
failOnNoDiscoveredTests = false
|
||||
}
|
||||
@@ -1956,7 +1964,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.57"
|
||||
if (project.version.toString() != "0.0.0-alpha.58"
|
||||
|| sulfurMigration.target?.modules?.anotherworld != "0.0.0-alpha.44"
|
||||
|| sulfurMigration.sulfur_caves?.sanctuary?.dripstone_cell_period != 2
|
||||
|| !javaText.contains('Identifier.parse("sanctuary:sulfur_caves")')
|
||||
@@ -3261,6 +3269,7 @@ tasks.register("verifyAnotherWorldCatalog") {
|
||||
tasks.named("check") {
|
||||
dependsOn tasks.named("verifyAnotherWorldCatalog")
|
||||
dependsOn tasks.named("vaultRulesSmoke")
|
||||
dependsOn tasks.named("canonScreenshotFilesSmoke")
|
||||
}
|
||||
|
||||
tasks.register("verifyClimateBiomeMixer") {
|
||||
@@ -3273,7 +3282,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.57"
|
||||
if (project.version.toString() != "0.0.0-alpha.58"
|
||||
|| 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"
|
||||
@@ -3315,7 +3324,7 @@ tasks.register("verifyBackroomMaterialIntegration") {
|
||||
"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"
|
||||
if (project.version.toString() != "0.0.0-alpha.58"
|
||||
|| !initializer.contains("BackroomMaterialApi.registerAnomalyMaterial(AnotherWorldBlocks.TURQUOISE_MOSS)")
|
||||
|| !blocks.contains('"turquoise_moss"')
|
||||
|| !api.contains("public static void registerAnomalyMaterial")
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package fr.koka99cab.canon.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.FileAlreadyExistsException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
final class CanonScreenshotFiles {
|
||||
private static final String SCREENSHOT_DIRECTORY = "screenshots";
|
||||
private static final int MAX_SUFFIX = 10_000;
|
||||
|
||||
private CanonScreenshotFiles() {
|
||||
}
|
||||
|
||||
static Path reserve(Path gameDirectory, String timestamp) throws IOException {
|
||||
Path screenshots = gameDirectory.resolve(SCREENSHOT_DIRECTORY);
|
||||
Files.createDirectories(screenshots);
|
||||
for (int suffix = 1; suffix <= MAX_SUFFIX; suffix++) {
|
||||
Path candidate = screenshots.resolve(fileName(timestamp, suffix));
|
||||
try {
|
||||
return Files.createFile(candidate);
|
||||
} catch (FileAlreadyExistsException ignored) {
|
||||
// Keep the vanilla timestamp readable while avoiding same-second collisions.
|
||||
}
|
||||
}
|
||||
throw new IOException("Could not reserve a unique Canon screenshot filename");
|
||||
}
|
||||
|
||||
static String fileName(String timestamp, int suffix) {
|
||||
if (timestamp == null || timestamp.isBlank()) {
|
||||
throw new IllegalArgumentException("timestamp must not be blank");
|
||||
}
|
||||
if (suffix < 1) {
|
||||
throw new IllegalArgumentException("suffix must be positive");
|
||||
}
|
||||
return timestamp + "-canon" + (suffix == 1 ? "" : "_" + suffix) + ".png";
|
||||
}
|
||||
}
|
||||
@@ -8,12 +8,15 @@ import fr.koka99cab.canon.network.CapturePhotoPayload;
|
||||
import fr.koka99cab.canon.photo.PhotoMapPalette;
|
||||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
import com.mojang.blaze3d.platform.Window;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.Screenshot;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.util.ARGB;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public final class ClientPhotoCapture {
|
||||
@@ -65,6 +68,7 @@ public final class ClientPhotoCapture {
|
||||
ClientPlayNetworking.send(new CapturePhotoPayload(colors));
|
||||
client.player.getCooldowns().addCooldown(capture.cameraStack(), CanonConstants.CAMERA_COOLDOWN_TICKS);
|
||||
client.player.playSound(SoundEvents.SPYGLASS_USE, 0.7F, 1.35F);
|
||||
exportScreenshot(client, screenshot, capture.style(), offsetX, offsetY, cropWidth, cropHeight);
|
||||
} catch (Exception exception) {
|
||||
CanonMod.LOGGER.warn("Failed to capture photo", exception);
|
||||
if (client.player != null) {
|
||||
@@ -74,6 +78,72 @@ public final class ClientPhotoCapture {
|
||||
});
|
||||
}
|
||||
|
||||
private static void exportScreenshot(
|
||||
Minecraft client,
|
||||
NativeImage screenshot,
|
||||
PhotoStyle style,
|
||||
int offsetX,
|
||||
int offsetY,
|
||||
int cropWidth,
|
||||
int cropHeight
|
||||
) {
|
||||
NativeImage exported = null;
|
||||
Path target = null;
|
||||
try {
|
||||
exported = new NativeImage(cropWidth, cropHeight, false);
|
||||
screenshot.copyRect(exported, offsetX, offsetY, 0, 0, cropWidth, cropHeight, false, false);
|
||||
target = CanonScreenshotFiles.reserve(client.gameDirectory.toPath(), Util.getFilenameFormattedDateTime());
|
||||
} catch (Exception exception) {
|
||||
if (exported != null) exported.close();
|
||||
if (target != null) deleteReservedFile(target);
|
||||
notifyScreenshotFailure(client, exception);
|
||||
return;
|
||||
}
|
||||
|
||||
NativeImage image = exported;
|
||||
Path output = target;
|
||||
Util.ioPool().execute(() -> {
|
||||
try (image) {
|
||||
applyStyle(image, style);
|
||||
image.writeToFile(output);
|
||||
client.execute(() -> {
|
||||
if (client.player != null) {
|
||||
client.player.sendSystemMessage(Component.translatable(
|
||||
"message.canon.camera.screenshot_saved", output.getFileName().toString()));
|
||||
}
|
||||
});
|
||||
} catch (Exception exception) {
|
||||
deleteReservedFile(output);
|
||||
notifyScreenshotFailure(client, exception);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void applyStyle(NativeImage image, PhotoStyle style) {
|
||||
for (int y = 0; y < image.getHeight(); y++) {
|
||||
for (int x = 0; x < image.getWidth(); x++) {
|
||||
image.setPixel(x, y, style.applyFilter(image.getPixel(x, y)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void notifyScreenshotFailure(Minecraft client, Exception exception) {
|
||||
CanonMod.LOGGER.warn("Failed to save Canon photo in the screenshots directory", exception);
|
||||
client.execute(() -> {
|
||||
if (client.player != null) {
|
||||
client.player.sendSystemMessage(Component.translatable("message.canon.camera.screenshot_failed"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void deleteReservedFile(Path target) {
|
||||
try {
|
||||
Files.deleteIfExists(target);
|
||||
} catch (Exception cleanupException) {
|
||||
CanonMod.LOGGER.debug("Could not remove incomplete Canon screenshot {}", target, cleanupException);
|
||||
}
|
||||
}
|
||||
|
||||
private static int clamp(int value, int min, int max) {
|
||||
return Math.max(min, Math.min(max, value));
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
"message.canon.camera.full": "The camera is already full.",
|
||||
"message.canon.camera.captured": "Photo captured.",
|
||||
"message.canon.camera.capture_failed": "Could not capture the current frame.",
|
||||
"message.canon.camera.screenshot_saved": "Photo saved to screenshots: %s",
|
||||
"message.canon.camera.screenshot_failed": "The in-game photo was captured, but its PNG could not be saved to screenshots.",
|
||||
"style.canon.white": "Neutral",
|
||||
"style.canon.white.effect": "Neutral stock with soft paper whites.",
|
||||
"style.canon.light_gray": "Matte",
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
"message.canon.camera.full": "L'appareil photo est deja plein.",
|
||||
"message.canon.camera.captured": "Photo prise.",
|
||||
"message.canon.camera.capture_failed": "Impossible de capturer l'image actuelle.",
|
||||
"message.canon.camera.screenshot_saved": "Photo sauvegardee dans screenshots : %s",
|
||||
"message.canon.camera.screenshot_failed": "La photo en jeu est prise, mais son PNG n'a pas pu etre sauvegarde dans screenshots.",
|
||||
"style.canon.white": "Neutre",
|
||||
"style.canon.white.effect": "Rendu neutre avec des blancs doux.",
|
||||
"style.canon.light_gray": "Mat",
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
"message.canon.camera.full": "Фотоаппарат уже полностью заряжен.",
|
||||
"message.canon.camera.captured": "Фотография сделана.",
|
||||
"message.canon.camera.capture_failed": "Не удалось снять текущий кадр.",
|
||||
"message.canon.camera.screenshot_saved": "Фотография сохранена в screenshots: %s",
|
||||
"message.canon.camera.screenshot_failed": "Снимок в игре сделан, но PNG не удалось сохранить в screenshots.",
|
||||
"style.canon.white": "Нейтральный",
|
||||
"style.canon.white.effect": "Нейтральная плёнка с мягкими белыми тонами.",
|
||||
"style.canon.light_gray": "Матовый",
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package fr.koka99cab.canon.client;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public final class CanonScreenshotFilesSmoke {
|
||||
private CanonScreenshotFilesSmoke() {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
String timestamp = "2026-09-03_01.23.45";
|
||||
require(CanonScreenshotFiles.fileName(timestamp, 1).equals("2026-09-03_01.23.45-canon.png"),
|
||||
"first screenshot filename");
|
||||
require(CanonScreenshotFiles.fileName(timestamp, 2).equals("2026-09-03_01.23.45-canon_2.png"),
|
||||
"same-second screenshot filename");
|
||||
|
||||
Path gameDirectory = Files.createTempDirectory("canon-screenshot-smoke-");
|
||||
Path first = CanonScreenshotFiles.reserve(gameDirectory, timestamp);
|
||||
Path second = CanonScreenshotFiles.reserve(gameDirectory, timestamp);
|
||||
require(first.getParent().equals(gameDirectory.resolve("screenshots")),
|
||||
"screenshots directory");
|
||||
require(first.getFileName().toString().equals("2026-09-03_01.23.45-canon.png"),
|
||||
"first reserved screenshot");
|
||||
require(second.getFileName().toString().equals("2026-09-03_01.23.45-canon_2.png"),
|
||||
"collision-safe screenshot");
|
||||
require(Files.isRegularFile(first) && Files.isRegularFile(second),
|
||||
"reserved screenshot files");
|
||||
}
|
||||
|
||||
private static void require(boolean condition, String contract) {
|
||||
if (!condition) throw new IllegalStateException("Invalid Canon screenshot contract: " + contract);
|
||||
}
|
||||
}
|
||||
+865
-313
File diff suppressed because it is too large
Load Diff
+6
-4
@@ -14,9 +14,9 @@ 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.17
|
||||
redstoner_version=0.0.0-alpha.20
|
||||
redstoner_lifecycle=active
|
||||
anotherworld_version=0.0.0-alpha.57
|
||||
anotherworld_version=0.0.0-alpha.58
|
||||
anotherworld_lifecycle=active
|
||||
itsalive_version=0.0.0-alpha.38
|
||||
itsalive_lifecycle=active
|
||||
@@ -28,7 +28,9 @@ iliketomoveit_version=0.0.0-alpha.18
|
||||
iliketomoveit_lifecycle=active
|
||||
onlyfun_version=0.0.0-alpha.27
|
||||
onlyfun_lifecycle=active
|
||||
sanctuary_version=0.0.0-alpha.135
|
||||
sanctuary_version=0.0.0-alpha.139
|
||||
sanctuary_lifecycle=active
|
||||
pack_version=26.2.0-alpha.229
|
||||
zevent_version=0.0.0-alpha.1
|
||||
zevent_lifecycle=active
|
||||
pack_version=26.2.0-alpha.233
|
||||
maven_group=fr.koka99cab.sanctuary26
|
||||
|
||||
@@ -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,56 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"status": "released",
|
||||
"source": {
|
||||
"pack_version": "26.2.0-alpha.230",
|
||||
"modules": {
|
||||
"sanctuary": "0.0.0-alpha.136",
|
||||
"redstoner": "0.0.0-alpha.17"
|
||||
}
|
||||
},
|
||||
"target": {
|
||||
"pack_version": "26.2.0-alpha.231",
|
||||
"modules": {
|
||||
"sanctuary": "0.0.0-alpha.137",
|
||||
"redstoner": "0.0.0-alpha.18"
|
||||
}
|
||||
},
|
||||
"backroom_landmarks": {
|
||||
"level_count": 5,
|
||||
"loot_chest_cell_size_chunks": 3,
|
||||
"exit_bed_source_cell_size_chunks": 10,
|
||||
"exit_bed_target_cell_size_chunks": 3,
|
||||
"books_added_to_loot": false,
|
||||
"new_chunks_only": true
|
||||
},
|
||||
"trophy_panel": {
|
||||
"wall_plate_model": "oak",
|
||||
"readable_line_count": 4,
|
||||
"page_title_and_three_podium_rows": true,
|
||||
"right_click_next_page": true,
|
||||
"sneak_right_click_previous_page": true
|
||||
},
|
||||
"compatibility": {
|
||||
"existing_saves_supported": true,
|
||||
"new_world_required": false,
|
||||
"save_reset_required": false,
|
||||
"persistent_data_formats_changed": false,
|
||||
"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,
|
||||
"jei": {
|
||||
"source": "30.29.0.199",
|
||||
"target": "30.29.0.201",
|
||||
"packwiz_and_prism_synchronized": true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"status": "released",
|
||||
"source": {
|
||||
"pack_version": "26.2.0-alpha.231",
|
||||
"modules": {
|
||||
"anotherworld": "0.0.0-alpha.57",
|
||||
"sanctuary": "0.0.0-alpha.137",
|
||||
"redstoner": "0.0.0-alpha.18"
|
||||
}
|
||||
},
|
||||
"target": {
|
||||
"pack_version": "26.2.0-alpha.232",
|
||||
"modules": {
|
||||
"anotherworld": "0.0.0-alpha.58",
|
||||
"sanctuary": "0.0.0-alpha.138",
|
||||
"redstoner": "0.0.0-alpha.19"
|
||||
}
|
||||
},
|
||||
"fixed_issues": [146],
|
||||
"canon_photo_screenshots": {
|
||||
"directory": "screenshots",
|
||||
"viewfinder_crop_only": true,
|
||||
"film_filter_preserved": true,
|
||||
"full_crop_resolution": true,
|
||||
"asynchronous_png_write": true,
|
||||
"collision_safe_names": true
|
||||
},
|
||||
"alpha231_follow_up": {
|
||||
"migration": "alpha231-follow-up-cape-terminal-trophy.json",
|
||||
"banner_cape_fixed": true,
|
||||
"terminal_inventory_key_fixed": true,
|
||||
"trophy_panel_visible_lines": 8,
|
||||
"trophy_panel_entries_per_view": 7,
|
||||
"spawn_egg_kill_ranking": true
|
||||
},
|
||||
"compatibility": {
|
||||
"existing_saves_supported": true,
|
||||
"new_world_required": false,
|
||||
"save_reset_required": false,
|
||||
"persistent_data_formats_changed": false,
|
||||
"network_protocols_changed": true,
|
||||
"anotherworld_data_version": 5,
|
||||
"anotherworld_network_protocol": 2,
|
||||
"sanctuary_data_version": 15,
|
||||
"sanctuary_network_protocol": 24,
|
||||
"redstoner_data_version": 4,
|
||||
"redstoner_source_network_protocol": 7,
|
||||
"redstoner_target_network_protocol": 8,
|
||||
"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,37 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"status": "released",
|
||||
"released_in": "26.2.0-alpha.232",
|
||||
"modules": {
|
||||
"sanctuary": {
|
||||
"source_module_version": "0.0.0-alpha.137",
|
||||
"target_module_version": "0.0.0-alpha.138",
|
||||
"data_version": 15,
|
||||
"network_protocol": 24
|
||||
},
|
||||
"redstoner": {
|
||||
"source_module_version": "0.0.0-alpha.18",
|
||||
"target_module_version": "0.0.0-alpha.19",
|
||||
"data_version": 4,
|
||||
"source_network_protocol": 7,
|
||||
"target_network_protocol": 8
|
||||
}
|
||||
},
|
||||
"fixes": {
|
||||
"banner_cape_flat_shield_uv_faces": true,
|
||||
"banner_cape_double_sided_culling": true,
|
||||
"terminal_inventory_key_captured_while_searching": true,
|
||||
"trophy_panel_visible_lines": 8,
|
||||
"trophy_panel_entries_per_view": 7,
|
||||
"trophy_panel_names_then_values": true,
|
||||
"spawn_egg_maps_to_entity_killed_statistic": true
|
||||
},
|
||||
"compatibility": {
|
||||
"existing_saves_supported": true,
|
||||
"new_world_required": false,
|
||||
"save_reset_required": false,
|
||||
"persistent_data_formats_changed": false,
|
||||
"network_protocols_changed": true,
|
||||
"client_server_update_required": true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"status": "released",
|
||||
"released_in": "26.2.0-alpha.233",
|
||||
"pack": {
|
||||
"source_version": "26.2.0-alpha.232",
|
||||
"target_version": "26.2.0-alpha.233"
|
||||
},
|
||||
"modules": {
|
||||
"sanctuary": {
|
||||
"source_module_version": "0.0.0-alpha.138",
|
||||
"target_module_version": "0.0.0-alpha.139",
|
||||
"data_version": 15,
|
||||
"network_protocol": 24
|
||||
},
|
||||
"redstoner": {
|
||||
"source_module_version": "0.0.0-alpha.19",
|
||||
"target_module_version": "0.0.0-alpha.20",
|
||||
"source_data_version": 4,
|
||||
"target_data_version": 5,
|
||||
"source_network_protocol": 8,
|
||||
"target_network_protocol": 9
|
||||
}
|
||||
},
|
||||
"trophy_sign": {
|
||||
"owner": "redstoner",
|
||||
"item_id_preserved": "redstoner:trophy_panel",
|
||||
"standing_block_id": "redstoner:trophy_sign",
|
||||
"wall_block_id": "redstoner:trophy_wall_sign",
|
||||
"legacy_block_id": "redstoner:trophy_panel",
|
||||
"legacy_blocks_migrate_on_load": true,
|
||||
"vanilla_sign_block_entity": true,
|
||||
"vanilla_wood_type": "pale_oak",
|
||||
"save_key": "redstoner:trophy_signs",
|
||||
"save_data_version": 1,
|
||||
"maximum_signs": 16384,
|
||||
"maximum_pages_per_sign": 16,
|
||||
"editor_opens_on_first_placement": true,
|
||||
"owner_or_operator_configuration": true,
|
||||
"owner_or_operator_breaking": true,
|
||||
"public_right_click_page_cycle": true,
|
||||
"display_modes": ["names_and_values", "names", "values"],
|
||||
"server_revalidates_distance_owner_block_and_metrics": true
|
||||
},
|
||||
"ranking_api": {
|
||||
"client_catalog_built_from_synchronized_registries": true,
|
||||
"catalog_sent_over_network": false,
|
||||
"cached_player_names_repair_uuid_prefix_placeholders": true,
|
||||
"uuid_prefixes_never_used_as_display_fallback": true
|
||||
},
|
||||
"compatibility": {
|
||||
"existing_saves_supported": true,
|
||||
"existing_item_stacks_supported": true,
|
||||
"new_world_required": false,
|
||||
"save_reset_required": false,
|
||||
"monotone_data_migration": true,
|
||||
"client_server_update_required": true
|
||||
},
|
||||
"distribution": {
|
||||
"packwiz_index_refreshed": true,
|
||||
"prism_modrinth_index_updated": true,
|
||||
"shared_client_server_mrpack": true
|
||||
}
|
||||
}
|
||||
+14
-14
@@ -14,15 +14,15 @@ hash = "41f4f4c88c71d0a23446d5014f7407d55ad477441847099cad24492b032335a0"
|
||||
|
||||
[[files]]
|
||||
file = "mods/ambiance-0.0.0-alpha.22.jar"
|
||||
hash = "b4ba14b9ada5b4c1d97b039ee632a158ae266eba2faefee690e710cc5f0f993e"
|
||||
hash = "c72a87d3ea187e65f3d459d18954bfc557deeb741deea143e610604a3af5985f"
|
||||
|
||||
[[files]]
|
||||
file = "mods/anotherworld-0.0.0-alpha.57.jar"
|
||||
hash = "4c8a3315ba9db6799fb0f046b45d702d56fba65173abccbd81ab995f56690407"
|
||||
file = "mods/anotherworld-0.0.0-alpha.58.jar"
|
||||
hash = "51f0122c222317fd65a642f8568a3d822732a874ecd5e4433592ae96e2a535a8"
|
||||
|
||||
[[files]]
|
||||
file = "mods/events-0.0.0-alpha.0.jar"
|
||||
hash = "e7304da48379eb39737b126431316644250ecbc5b6ec8a439cc12e96a9477fa4"
|
||||
hash = "1c1623d4d40973346d3143657461e916e38142a867e7a6cf0da054ad998dbb0e"
|
||||
|
||||
[[files]]
|
||||
file = "mods/fabric-api.pw.toml"
|
||||
@@ -31,7 +31,7 @@ metafile = true
|
||||
|
||||
[[files]]
|
||||
file = "mods/iliketomoveit-0.0.0-alpha.18.jar"
|
||||
hash = "bd0467d186737b59996a8b1589a7c1837c990890f1b21154aaca614fb042c556"
|
||||
hash = "6a38653f4898e2fe2df6f8935b516073185f7c0d3913164e769ebafcc487b318"
|
||||
|
||||
[[files]]
|
||||
file = "mods/iris.pw.toml"
|
||||
@@ -40,32 +40,32 @@ metafile = true
|
||||
|
||||
[[files]]
|
||||
file = "mods/itsalive-0.0.0-alpha.38.jar"
|
||||
hash = "dd1869166cfeeb36b19b7e243e7ece32c925d362aa80782076d493decc6e2871"
|
||||
hash = "0e40259acf98cf3d64dfdebe3441ffb3a09aa64de6cf1b2c8dcaa4af7c8d0e82"
|
||||
|
||||
[[files]]
|
||||
file = "mods/jei.pw.toml"
|
||||
hash = "9cc4a91f57effc48b94f6acc1f43067bb8eb99fd1df3397612c55761de9ec2c2"
|
||||
hash = "80d0fa55c1bbc0659e792b047c2bb64c446c2bf92557d9d74777333a8a68a318"
|
||||
metafile = true
|
||||
|
||||
[[files]]
|
||||
file = "mods/masterkey-0.0.0-alpha.9.jar"
|
||||
hash = "46ef9947e82368fbe60d696174b3a3c99960be29432f3ccd7daf2714927b5c12"
|
||||
hash = "b42b25f1eabc0b1e7660f0071e8f105d82ceb078b4bd9b7c570df8ce2c59601c"
|
||||
|
||||
[[files]]
|
||||
file = "mods/onlyfun-0.0.0-alpha.27.jar"
|
||||
hash = "d01271cbccef9c3c5f66e3d56748cd69d953f9eb53d21c8a1575523d40e77c56"
|
||||
hash = "4e2c95c54fa3f591d3e1b6f7454211caaa4fb5f7ef31cd5b6aa477d03be18e2e"
|
||||
|
||||
[[files]]
|
||||
file = "mods/ouch-0.0.0-alpha.11.jar"
|
||||
hash = "ca612f8e660744af81d5a2612f78f8ad61dacf746a22474837e8b52a22bb3204"
|
||||
hash = "8dcec6870fba091adda5df2a2f719e97d0f5dcf86f14c5f99035c7aebaf6c119"
|
||||
|
||||
[[files]]
|
||||
file = "mods/redstoner-0.0.0-alpha.16.jar"
|
||||
hash = "e273042c0f7b12ed0a13da3f75f41903a741a29399da353ecd5144e67dcb680e"
|
||||
file = "mods/redstoner-0.0.0-alpha.20.jar"
|
||||
hash = "669ca9a357874448c68ca45fdf26d827d5094b1ef1ee07f948a564b33cc1a79c"
|
||||
|
||||
[[files]]
|
||||
file = "mods/sanctuary-0.0.0-alpha.132.jar"
|
||||
hash = "72a946358be6039c706cf52563ffe61ec70477ffb4e7db80e71116758f5bd519"
|
||||
file = "mods/sanctuary-0.0.0-alpha.139.jar"
|
||||
hash = "62d06cfe57badc5295fdcaf1ad9d0eb6d7ba67345bdc5fc8ca6d689817f70c01"
|
||||
|
||||
[[files]]
|
||||
file = "mods/simple-voice-chat.pw.toml"
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
name = "Just Enough Items (JEI)"
|
||||
filename = "jei-26.2-fabric-30.29.0.199.jar"
|
||||
filename = "jei-26.2-fabric-30.29.0.201.jar"
|
||||
side = "both"
|
||||
pin = true
|
||||
|
||||
[download]
|
||||
url = "https://cdn.modrinth.com/data/u6dRKJwZ/versions/astSvyl6/jei-26.2-fabric-30.29.0.199.jar"
|
||||
url = "https://cdn.modrinth.com/data/u6dRKJwZ/versions/d3HeviSL/jei-26.2-fabric-30.29.0.201.jar"
|
||||
hash-format = "sha512"
|
||||
hash = "2849ff6a4cc91822798f0c70e7749c298b911c1037fc74e9ab0881734b8d5cb6507fb3169b4a240ef6c37eb6f7c573794c46073ff352f160feee245233b2abe5"
|
||||
hash = "2279cb0ec4e41d9eebad80c2ecac76d19c8bc8e5aac69ba13f35b77494625c70d66edc74d59959116012bfb2f464b55806dd69fbf6387f25679b1553953e329a"
|
||||
|
||||
[update]
|
||||
[update.modrinth]
|
||||
mod-id = "u6dRKJwZ"
|
||||
version = "astSvyl6"
|
||||
version = "d3HeviSL"
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
name = "Sanctuary 26.2"
|
||||
author = "KOKA99CAB"
|
||||
version = "26.2.0-alpha.229"
|
||||
version = "26.2.0-alpha.233"
|
||||
pack-format = "packwiz:1.1.0"
|
||||
|
||||
[index]
|
||||
file = "index.toml"
|
||||
hash-format = "sha256"
|
||||
hash = "6a5b1811c2dd2b905a67cd817b8e377a8b68589431650775e1d8aabe04ff32e9"
|
||||
hash = "c666b031c2ac27a8f01cc4d12d6e471ea7471e9e5e7ce02567ee8a6649f9142a"
|
||||
|
||||
[versions]
|
||||
fabric = "0.19.3"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"game": "minecraft",
|
||||
"name": "Sanctuary 26.2",
|
||||
"summary": "Sanctuary 26.2 — progression, exploration, worldgen and multiplayer systems by KOKA99CAB.",
|
||||
"versionId": "26.2.0-alpha.229",
|
||||
"versionId": "26.2.0-alpha.233",
|
||||
"files": [
|
||||
{
|
||||
"path": "mods/fabric-api-0.159.0+26.2.jar",
|
||||
@@ -21,19 +21,19 @@
|
||||
"fileSize": 2535793
|
||||
},
|
||||
{
|
||||
"path": "mods/jei-26.2-fabric-30.29.0.199.jar",
|
||||
"path": "mods/jei-26.2-fabric-30.29.0.201.jar",
|
||||
"hashes": {
|
||||
"sha1": "1d6ab9269be16f85fb13a34a36b34ad07a9b32a7",
|
||||
"sha512": "2849ff6a4cc91822798f0c70e7749c298b911c1037fc74e9ab0881734b8d5cb6507fb3169b4a240ef6c37eb6f7c573794c46073ff352f160feee245233b2abe5"
|
||||
"sha1": "e82447aff07e87a372cf817bc9c28b0d77b6f55c",
|
||||
"sha512": "2279cb0ec4e41d9eebad80c2ecac76d19c8bc8e5aac69ba13f35b77494625c70d66edc74d59959116012bfb2f464b55806dd69fbf6387f25679b1553953e329a"
|
||||
},
|
||||
"env": {
|
||||
"client": "required",
|
||||
"server": "required"
|
||||
},
|
||||
"downloads": [
|
||||
"https://cdn.modrinth.com/data/u6dRKJwZ/versions/astSvyl6/jei-26.2-fabric-30.29.0.199.jar"
|
||||
"https://cdn.modrinth.com/data/u6dRKJwZ/versions/d3HeviSL/jei-26.2-fabric-30.29.0.201.jar"
|
||||
],
|
||||
"fileSize": 1849188
|
||||
"fileSize": 1860103
|
||||
},
|
||||
{
|
||||
"path": "mods/voicechat-fabric-2.6.22+26.2.jar",
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"pack_version": "26.2.0-alpha.229",
|
||||
"pack_version": "26.2.0-alpha.233",
|
||||
"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.229.mrpack",
|
||||
"primary_file": "sanctuary-26.2.0-alpha.233.mrpack",
|
||||
"shared_client_server_pack": true,
|
||||
"update_owner": "packwiz-installer",
|
||||
"check_on_launch": true,
|
||||
|
||||
@@ -4,6 +4,7 @@ import fr.koka99cab.sanctuary26.redstoner.api.RedStonerApi;
|
||||
import fr.koka99cab.sanctuary26.redstoner.network.RedStonerNetworking;
|
||||
import fr.koka99cab.sanctuary26.redstoner.registry.RedStonerRegistries;
|
||||
import fr.koka99cab.sanctuary26.redstoner.registry.RedStonerMenus;
|
||||
import fr.koka99cab.sanctuary26.redstoner.trophy.TrophySignService;
|
||||
import fr.koka99cab.sanctuary26.sanctuary.api.server.SanctuaryServerIdentity;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.minecraft.resources.Identifier;
|
||||
@@ -13,7 +14,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 = 4;
|
||||
public static final int CURRENT_DATA_VERSION = 5;
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||
|
||||
public RedStonerMod() {
|
||||
@@ -27,6 +28,7 @@ public final class RedStonerMod implements ModInitializer {
|
||||
public void onInitialize() {
|
||||
RedStonerApi.registerServerIdentityProvider(SanctuaryServerIdentity::get);
|
||||
RedStonerRegistries.initialize();
|
||||
TrophySignService.initialize();
|
||||
RedStonerMenus.initialize();
|
||||
RedStonerNetworking.initialize();
|
||||
LOGGER.info("[{}] Computers, Drawer, Particuleur, Storage Terminal and Trophy Panel ready (data v{}, network v{}).",
|
||||
|
||||
+14
-35
@@ -3,7 +3,6 @@ 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 fr.koka99cab.sanctuary26.sanctuary.api.ranking.RankingUnit;
|
||||
import java.util.Map;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -45,10 +44,10 @@ 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, 13.0D, 16.0D, 16.0D, 16.0D),
|
||||
Direction.SOUTH, Block.box(0.0D, 0.0D, 0.0D, 16.0D, 16.0D, 3.0D),
|
||||
Direction.WEST, Block.box(13.0D, 0.0D, 0.0D, 16.0D, 16.0D, 16.0D),
|
||||
Direction.EAST, Block.box(0.0D, 0.0D, 0.0D, 3.0D, 16.0D, 16.0D)
|
||||
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) {
|
||||
@@ -120,18 +119,20 @@ public final class TrophyPanelBlock extends BaseEntityBlock {
|
||||
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);
|
||||
if (player.isSecondaryUseActive()) return cycle(panel, serverPlayer, true);
|
||||
|
||||
boolean operator = serverPlayer.createCommandSourceStack().permissions()
|
||||
.hasPermission(Permissions.COMMANDS_GAMEMASTER);
|
||||
if (!panel.canConfigure(serverPlayer, operator)) {
|
||||
serverPlayer.sendSystemMessage(Component.translatable("message.redstoner.trophy_panel.not_owner"));
|
||||
return InteractionResult.CONSUME;
|
||||
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 -> "no_metric";
|
||||
case NO_METRIC -> throw new IllegalStateException("Handled above");
|
||||
case NEWER_DATA -> "newer_data";
|
||||
};
|
||||
serverPlayer.sendSystemMessage(Component.translatable("message.redstoner.trophy_panel." + key));
|
||||
@@ -144,9 +145,7 @@ public final class TrophyPanelBlock extends BaseEntityBlock {
|
||||
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);
|
||||
showDetails(panel, serverPlayer);
|
||||
return InteractionResult.SUCCESS_SERVER;
|
||||
return cycle(panel, serverPlayer, player.isSecondaryUseActive());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -164,8 +163,9 @@ public final class TrophyPanelBlock extends BaseEntityBlock {
|
||||
return state.rotate(mirror.getRotation(state.getValue(FACING)));
|
||||
}
|
||||
|
||||
private static InteractionResult cycle(TrophyPanelBlockEntity panel, ServerPlayer player) {
|
||||
if (!panel.cyclePage()) {
|
||||
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;
|
||||
}
|
||||
@@ -173,25 +173,4 @@ public final class TrophyPanelBlock extends BaseEntityBlock {
|
||||
panel.pageNumber(), panel.pageCount()));
|
||||
return InteractionResult.SUCCESS_SERVER;
|
||||
}
|
||||
|
||||
private static void showDetails(TrophyPanelBlockEntity panel, ServerPlayer player) {
|
||||
TrophyPanelBlockEntity.ClientSnapshot snapshot = panel.visibleSnapshot();
|
||||
RankingUnit unit = snapshot.unit();
|
||||
ItemStack icon = panel.currentPage().icon();
|
||||
Component metric = icon.isEmpty() ? Component.translatable(snapshot.translationKey())
|
||||
: Component.translatable(snapshot.translationKey(), icon.getHoverName());
|
||||
player.sendSystemMessage(Component.translatable("message.redstoner.trophy_panel.header", metric,
|
||||
panel.pageNumber(), panel.pageCount()));
|
||||
for (TrophyPanelBlockEntity.ClientEntry entry : snapshot.podium()) {
|
||||
player.sendSystemMessage(Component.translatable("message.redstoner.trophy_panel.podium",
|
||||
entry.rank(), entry.name(), unit.format(entry.value())));
|
||||
}
|
||||
if (snapshot.ownerRank() > 0) {
|
||||
player.sendSystemMessage(Component.translatable("message.redstoner.trophy_panel.owner_rank",
|
||||
panel.ownerName(), snapshot.ownerRank(), unit.format(snapshot.ownerValue())));
|
||||
} else {
|
||||
player.sendSystemMessage(Component.translatable("message.redstoner.trophy_panel.owner_unranked",
|
||||
panel.ownerName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+33
-4
@@ -5,6 +5,7 @@ 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.redstoner.trophy.TrophySignService;
|
||||
import fr.koka99cab.sanctuary26.sanctuary.api.ranking.RankingMetric;
|
||||
import fr.koka99cab.sanctuary26.sanctuary.api.ranking.RankingSnapshot;
|
||||
import fr.koka99cab.sanctuary26.sanctuary.api.ranking.RankingUnit;
|
||||
@@ -36,6 +37,7 @@ public final class TrophyPanelBlockEntity extends BlockEntity implements ItemOwn
|
||||
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 String CLIENT_VALUES_VIEW_TAG = "ValuesView";
|
||||
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)
|
||||
@@ -60,7 +62,9 @@ public final class TrophyPanelBlockEntity extends BlockEntity implements ItemOwn
|
||||
private String ownerName = "?";
|
||||
private List<Page> pages = List.of(defaultPage());
|
||||
private int currentPage;
|
||||
private boolean valuesView;
|
||||
private long lastRefreshTick = Long.MIN_VALUE;
|
||||
private boolean migrationAttempted;
|
||||
private ClientSnapshot visibleSnapshot = ClientSnapshot.empty(SanctuaryRankingApi.defaultMetric());
|
||||
|
||||
public TrophyPanelBlockEntity(BlockPos pos, BlockState state) {
|
||||
@@ -70,6 +74,13 @@ public final class TrophyPanelBlockEntity extends BlockEntity implements ItemOwn
|
||||
public static void serverTick(net.minecraft.world.level.Level level, BlockPos pos, BlockState state,
|
||||
TrophyPanelBlockEntity panel) {
|
||||
if (!(level instanceof ServerLevel serverLevel)) return;
|
||||
if (!panel.migrationAttempted) {
|
||||
panel.migrationAttempted = true;
|
||||
if (TrophySignService.migrateLegacy(serverLevel, pos, state.getValue(TrophyPanelBlock.FACING),
|
||||
panel.owner, panel.ownerName, panel.pages.stream().map(Page::metricId).toList(), panel.currentPage)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
long now = level.getGameTime();
|
||||
if (panel.lastRefreshTick != Long.MIN_VALUE && now - panel.lastRefreshTick < REFRESH_INTERVAL_TICKS) return;
|
||||
panel.lastRefreshTick = now;
|
||||
@@ -104,15 +115,27 @@ public final class TrophyPanelBlockEntity extends BlockEntity implements ItemOwn
|
||||
currentPage = Math.max(0, pages.indexOf(pages.stream()
|
||||
.filter(page -> offered.stream().anyMatch(metric -> metric.id().equals(page.metricId())))
|
||||
.findFirst().orElse(pages.getFirst())));
|
||||
valuesView = false;
|
||||
ownerName = cleanName(player.getGameProfile().name());
|
||||
syncPersistent();
|
||||
if (level instanceof ServerLevel serverLevel) refresh(serverLevel);
|
||||
return ConfigureResult.SUCCESS;
|
||||
}
|
||||
|
||||
public boolean cyclePage() {
|
||||
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.nextPage(currentPage, pages.size());
|
||||
TrophyPanelRules.DisplayPage displayPage = TrophyPanelRules.displayPageByOffset(
|
||||
currentPage, valuesView, pages.size(), offset);
|
||||
currentPage = displayPage.metricPage();
|
||||
valuesView = displayPage.valuesView();
|
||||
syncPersistent();
|
||||
if (level instanceof ServerLevel serverLevel) refresh(serverLevel);
|
||||
return true;
|
||||
@@ -123,11 +146,15 @@ public final class TrophyPanelBlockEntity extends BlockEntity implements ItemOwn
|
||||
}
|
||||
|
||||
public int pageNumber() {
|
||||
return currentPage + 1;
|
||||
return TrophyPanelRules.displayPageNumber(currentPage, valuesView, pages.size());
|
||||
}
|
||||
|
||||
public int pageCount() {
|
||||
return pages.size();
|
||||
return TrophyPanelRules.displayPageCount(pages.size());
|
||||
}
|
||||
|
||||
public boolean valuesView() {
|
||||
return valuesView;
|
||||
}
|
||||
|
||||
public String ownerName() {
|
||||
@@ -166,6 +193,7 @@ public final class TrophyPanelBlockEntity extends BlockEntity implements ItemOwn
|
||||
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);
|
||||
valuesView = input.getBooleanOr(CLIENT_VALUES_VIEW_TAG, false);
|
||||
visibleSnapshot = input.read(CLIENT_SNAPSHOT_TAG, CLIENT_SNAPSHOT_CODEC)
|
||||
.orElseGet(() -> ClientSnapshot.empty(metricFor(currentPage().metricId())));
|
||||
}
|
||||
@@ -179,6 +207,7 @@ public final class TrophyPanelBlockEntity extends BlockEntity implements ItemOwn
|
||||
public CompoundTag getUpdateTag(HolderLookup.Provider lookup) {
|
||||
CompoundTag tag = saveCustomOnly(lookup);
|
||||
tag.store(CLIENT_SNAPSHOT_TAG, CLIENT_SNAPSHOT_CODEC, visibleSnapshot);
|
||||
tag.putBoolean(CLIENT_VALUES_VIEW_TAG, valuesView);
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,12 @@ import fr.koka99cab.sanctuary26.redstoner.RedStonerMod;
|
||||
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.gui.TrophySignEditorScreen;
|
||||
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.network.OpenTrophySignEditorPayload;
|
||||
import fr.koka99cab.sanctuary26.redstoner.registry.RedStonerMenus;
|
||||
import fr.koka99cab.sanctuary26.redstoner.registry.RedStonerRegistries;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
@@ -33,6 +35,9 @@ public final class RedStonerClient implements ClientModInitializer {
|
||||
context.client().gui.setScreen(new PersonalComputerScreen(payload));
|
||||
}
|
||||
}));
|
||||
ClientPlayNetworking.registerGlobalReceiver(OpenTrophySignEditorPayload.TYPE, (payload, context) ->
|
||||
context.client().execute(() -> context.client().gui.setScreen(
|
||||
new TrophySignEditorScreen(context.client().gui.screen(), payload))));
|
||||
RedStonerMod.LOGGER.info("[{}] Client renderers and laboratory screens ready.", RedStonerMod.DISPLAY_NAME);
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -1,5 +1,6 @@
|
||||
package fr.koka99cab.sanctuary26.redstoner.client.gui;
|
||||
|
||||
import fr.koka99cab.sanctuary26.redstoner.storage.StorageTerminalKeyRules;
|
||||
import fr.koka99cab.sanctuary26.redstoner.storage.StorageTerminalMenu;
|
||||
import fr.koka99cab.sanctuary26.redstoner.storage.StorageTerminalRules;
|
||||
import fr.koka99cab.sanctuary26.redstoner.storage.StorageTerminalSort;
|
||||
@@ -139,10 +140,9 @@ public final class StorageTerminalScreen extends AbstractContainerScreen<Storage
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(KeyEvent event) {
|
||||
if (searchBox != null && searchBox.isFocused() && minecraft != null
|
||||
&& minecraft.options.keyInventory.matches(event)) {
|
||||
clearSearchFocus();
|
||||
}
|
||||
if (StorageTerminalKeyRules.capturesInventoryKey(
|
||||
searchBox != null && searchBox.isFocused(), minecraft != null
|
||||
&& minecraft.options.keyInventory.matches(event))) return true;
|
||||
return super.keyPressed(event);
|
||||
}
|
||||
|
||||
|
||||
+265
@@ -0,0 +1,265 @@
|
||||
package fr.koka99cab.sanctuary26.redstoner.client.gui;
|
||||
|
||||
import fr.koka99cab.sanctuary26.redstoner.network.OpenTrophySignEditorPayload;
|
||||
import fr.koka99cab.sanctuary26.redstoner.network.SaveTrophySignPayload;
|
||||
import fr.koka99cab.sanctuary26.redstoner.trophy.TrophyDisplayMode;
|
||||
import fr.koka99cab.sanctuary26.redstoner.trophy.TrophyPanelRules;
|
||||
import fr.koka99cab.sanctuary26.sanctuary.api.ranking.RankingMetric;
|
||||
import fr.koka99cab.sanctuary26.sanctuary.api.ranking.RankingUnit;
|
||||
import fr.koka99cab.sanctuary26.sanctuary.api.ranking.SanctuaryRankingApi;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
import net.minecraft.client.gui.GuiGraphicsExtractor;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.Identifier;
|
||||
|
||||
/** White, bounded editor inspired by the community quest-sign screen. */
|
||||
public final class TrophySignEditorScreen extends Screen {
|
||||
private static final int VISIBLE_ROWS = 5;
|
||||
private static final int PANEL_WIDTH = 328;
|
||||
private static final int PANEL_HEIGHT = 250;
|
||||
private static final int COLUMN_WIDTH = 148;
|
||||
private static final int GAP = 8;
|
||||
private static final int BACKDROP = 0xD0F1F0EC;
|
||||
private static final int BORDER = 0xFFFFFFFF;
|
||||
private static final int TITLE = 0xFF343434;
|
||||
private static final int MUTED = 0xFF6A6A6A;
|
||||
|
||||
private final Screen parent;
|
||||
private final OpenTrophySignEditorPayload payload;
|
||||
private final List<Identifier> pages;
|
||||
private final List<MetricOption> catalog = new ArrayList<>();
|
||||
private final List<MetricOption> filtered = new ArrayList<>();
|
||||
private final Button[] resultButtons = new Button[VISIBLE_ROWS];
|
||||
private final Button[] pageButtons = new Button[VISIBLE_ROWS];
|
||||
private EditBox search;
|
||||
private Button previousResults;
|
||||
private Button nextResults;
|
||||
private Button previousPages;
|
||||
private Button nextPages;
|
||||
private Button moveUp;
|
||||
private Button moveDown;
|
||||
private Button remove;
|
||||
private Button displayMode;
|
||||
private Button save;
|
||||
private TrophyDisplayMode mode;
|
||||
private int catalogOffset;
|
||||
private int pageOffset;
|
||||
private int selectedPage = -1;
|
||||
|
||||
public TrophySignEditorScreen(Screen parent, OpenTrophySignEditorPayload payload) {
|
||||
super(Component.translatable("screen.redstoner.trophy_sign.title"));
|
||||
this.parent = parent;
|
||||
this.payload = payload;
|
||||
this.pages = new ArrayList<>(payload.pages());
|
||||
this.mode = TrophyDisplayMode.byKey(payload.display());
|
||||
if (!pages.isEmpty()) selectedPage = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
int x = panelX() + 12;
|
||||
int y = panelY();
|
||||
buildCatalog();
|
||||
search = addRenderableWidget(new EditBox(font, x, y + 38, COLUMN_WIDTH, 20,
|
||||
Component.translatable("screen.redstoner.trophy_sign.search")));
|
||||
search.setMaxLength(64);
|
||||
search.setHint(Component.translatable("screen.redstoner.trophy_sign.search"));
|
||||
search.setResponder(value -> filterCatalog());
|
||||
|
||||
for (int slot = 0; slot < VISIBLE_ROWS; slot++) {
|
||||
int resultSlot = slot;
|
||||
resultButtons[slot] = addRenderableWidget(Button.builder(Component.empty(),
|
||||
button -> addResult(resultSlot)).bounds(x, y + 62 + slot * 22, COLUMN_WIDTH, 20).build());
|
||||
int pageSlot = slot;
|
||||
pageButtons[slot] = addRenderableWidget(Button.builder(Component.empty(),
|
||||
button -> selectPage(pageSlot)).bounds(x + COLUMN_WIDTH + GAP, y + 38 + slot * 22,
|
||||
COLUMN_WIDTH, 20).build());
|
||||
}
|
||||
|
||||
previousResults = addRenderableWidget(Button.builder(Component.literal("‹"), button -> moveCatalog(-VISIBLE_ROWS))
|
||||
.bounds(x, y + 174, 72, 20).build());
|
||||
nextResults = addRenderableWidget(Button.builder(Component.literal("›"), button -> moveCatalog(VISIBLE_ROWS))
|
||||
.bounds(x + 76, y + 174, 72, 20).build());
|
||||
previousPages = addRenderableWidget(Button.builder(Component.literal("‹"), button -> movePageWindow(-VISIBLE_ROWS))
|
||||
.bounds(x + COLUMN_WIDTH + GAP, y + 174, 72, 20).build());
|
||||
nextPages = addRenderableWidget(Button.builder(Component.literal("›"), button -> movePageWindow(VISIBLE_ROWS))
|
||||
.bounds(x + COLUMN_WIDTH + GAP + 76, y + 174, 72, 20).build());
|
||||
|
||||
moveUp = addRenderableWidget(Button.builder(Component.literal("↑"), button -> moveSelected(-1))
|
||||
.bounds(x + COLUMN_WIDTH + GAP, y + 150, 46, 20).build());
|
||||
moveDown = addRenderableWidget(Button.builder(Component.literal("↓"), button -> moveSelected(1))
|
||||
.bounds(x + COLUMN_WIDTH + GAP + 50, y + 150, 46, 20).build());
|
||||
remove = addRenderableWidget(Button.builder(Component.translatable("screen.redstoner.trophy_sign.remove"),
|
||||
button -> removeSelected()).bounds(x + COLUMN_WIDTH + GAP + 100, y + 150, 48, 20).build());
|
||||
|
||||
displayMode = addRenderableWidget(Button.builder(displayLabel(), button -> {
|
||||
mode = mode.next();
|
||||
button.setMessage(displayLabel());
|
||||
}).bounds(x, y + 198, COLUMN_WIDTH * 2 + GAP, 20).build());
|
||||
save = addRenderableWidget(Button.builder(Component.translatable("gui.done"), button -> submit())
|
||||
.bounds(x, y + 224, COLUMN_WIDTH, 20).build());
|
||||
addRenderableWidget(Button.builder(Component.translatable("gui.cancel"), button -> onClose())
|
||||
.bounds(x + COLUMN_WIDTH + GAP, y + 224, COLUMN_WIDTH, 20).build());
|
||||
|
||||
filterCatalog();
|
||||
refreshWidgets();
|
||||
setInitialFocus(search);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
refreshWidgets();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float tickDelta) {
|
||||
int x = panelX();
|
||||
int y = panelY();
|
||||
graphics.fill(x, y, x + PANEL_WIDTH, y + PANEL_HEIGHT, BACKDROP);
|
||||
graphics.outline(x, y, PANEL_WIDTH, PANEL_HEIGHT, BORDER);
|
||||
graphics.centeredText(font, title, width / 2, y + 10, TITLE);
|
||||
graphics.text(font, Component.translatable("screen.redstoner.trophy_sign.available"),
|
||||
x + 12, y + 27, MUTED);
|
||||
graphics.text(font, Component.translatable("screen.redstoner.trophy_sign.pages",
|
||||
pages.size(), TrophyPanelRules.MAX_PAGES), x + 12 + COLUMN_WIDTH + GAP, y + 27, MUTED);
|
||||
super.extractRenderState(graphics, mouseX, mouseY, tickDelta);
|
||||
}
|
||||
|
||||
private void buildCatalog() {
|
||||
catalog.clear();
|
||||
for (RankingMetric metric : SanctuaryRankingApi.configurableMetrics()) {
|
||||
Component label = SanctuaryRankingApi.displayName(metric);
|
||||
catalog.add(new MetricOption(metric, label, (label.getString() + " " + metric.id())
|
||||
.toLowerCase(Locale.ROOT)));
|
||||
}
|
||||
catalog.sort(Comparator.comparing(option -> option.label().getString(), String.CASE_INSENSITIVE_ORDER));
|
||||
}
|
||||
|
||||
private void filterCatalog() {
|
||||
if (search == null) return;
|
||||
String query = search.getValue().strip().toLowerCase(Locale.ROOT);
|
||||
filtered.clear();
|
||||
for (MetricOption option : catalog) if (query.isEmpty() || option.searchText().contains(query)) filtered.add(option);
|
||||
catalogOffset = 0;
|
||||
refreshWidgets();
|
||||
}
|
||||
|
||||
private void addResult(int slot) {
|
||||
int index = catalogOffset + slot;
|
||||
if (index < 0 || index >= filtered.size()) return;
|
||||
Identifier id = filtered.get(index).metric().id();
|
||||
int existing = pages.indexOf(id);
|
||||
if (existing >= 0) {
|
||||
selectedPage = existing;
|
||||
ensureSelectedVisible();
|
||||
} else if (pages.size() < TrophyPanelRules.MAX_PAGES) {
|
||||
pages.add(id);
|
||||
selectedPage = pages.size() - 1;
|
||||
ensureSelectedVisible();
|
||||
}
|
||||
refreshWidgets();
|
||||
}
|
||||
|
||||
private void selectPage(int slot) {
|
||||
int index = pageOffset + slot;
|
||||
if (index >= 0 && index < pages.size()) selectedPage = index;
|
||||
refreshWidgets();
|
||||
}
|
||||
|
||||
private void moveSelected(int offset) {
|
||||
int target = selectedPage + offset;
|
||||
if (selectedPage < 0 || target < 0 || target >= pages.size()) return;
|
||||
Identifier page = pages.remove(selectedPage);
|
||||
pages.add(target, page);
|
||||
selectedPage = target;
|
||||
ensureSelectedVisible();
|
||||
refreshWidgets();
|
||||
}
|
||||
|
||||
private void removeSelected() {
|
||||
if (selectedPage < 0 || selectedPage >= pages.size()) return;
|
||||
pages.remove(selectedPage);
|
||||
selectedPage = pages.isEmpty() ? -1 : Math.min(selectedPage, pages.size() - 1);
|
||||
ensureSelectedVisible();
|
||||
refreshWidgets();
|
||||
}
|
||||
|
||||
private void moveCatalog(int amount) {
|
||||
int maximum = Math.max(0, filtered.size() - VISIBLE_ROWS);
|
||||
catalogOffset = Math.clamp(catalogOffset + amount, 0, maximum);
|
||||
refreshWidgets();
|
||||
}
|
||||
|
||||
private void movePageWindow(int amount) {
|
||||
int maximum = Math.max(0, pages.size() - VISIBLE_ROWS);
|
||||
pageOffset = Math.clamp(pageOffset + amount, 0, maximum);
|
||||
refreshWidgets();
|
||||
}
|
||||
|
||||
private void ensureSelectedVisible() {
|
||||
if (selectedPage < pageOffset) pageOffset = selectedPage;
|
||||
if (selectedPage >= pageOffset + VISIBLE_ROWS) pageOffset = selectedPage - VISIBLE_ROWS + 1;
|
||||
pageOffset = Math.max(0, pageOffset);
|
||||
}
|
||||
|
||||
private void refreshWidgets() {
|
||||
if (save == null) return;
|
||||
for (int slot = 0; slot < VISIBLE_ROWS; slot++) {
|
||||
int resultIndex = catalogOffset + slot;
|
||||
Button result = resultButtons[slot];
|
||||
result.visible = resultIndex < filtered.size();
|
||||
if (result.visible) {
|
||||
MetricOption option = filtered.get(resultIndex);
|
||||
result.setMessage(Component.literal(pages.contains(option.metric().id()) ? "✓ " : "+ ")
|
||||
.append(option.label()));
|
||||
result.active = pages.contains(option.metric().id()) || pages.size() < TrophyPanelRules.MAX_PAGES;
|
||||
}
|
||||
|
||||
int pageIndex = pageOffset + slot;
|
||||
Button page = pageButtons[slot];
|
||||
page.visible = pageIndex < pages.size();
|
||||
if (page.visible) page.setMessage(Component.literal(pageIndex == selectedPage ? "▶ " : "")
|
||||
.append(Component.literal((pageIndex + 1) + ". ")).append(metricLabel(pages.get(pageIndex))));
|
||||
}
|
||||
previousResults.active = catalogOffset > 0;
|
||||
nextResults.active = catalogOffset + VISIBLE_ROWS < filtered.size();
|
||||
previousPages.active = pageOffset > 0;
|
||||
nextPages.active = pageOffset + VISIBLE_ROWS < pages.size();
|
||||
moveUp.active = selectedPage > 0;
|
||||
moveDown.active = selectedPage >= 0 && selectedPage + 1 < pages.size();
|
||||
remove.active = selectedPage >= 0;
|
||||
save.active = !pages.isEmpty() && ClientPlayNetworking.canSend(SaveTrophySignPayload.TYPE);
|
||||
}
|
||||
|
||||
private Component metricLabel(Identifier id) {
|
||||
RankingMetric metric = SanctuaryRankingApi.metric(id).orElseGet(() ->
|
||||
new RankingMetric(id, "metric.sanctuary.ranking.unknown", RankingUnit.COUNT));
|
||||
return SanctuaryRankingApi.displayName(metric);
|
||||
}
|
||||
|
||||
private Component displayLabel() {
|
||||
return Component.translatable("screen.redstoner.trophy_sign.display",
|
||||
Component.translatable("screen.redstoner.trophy_sign.display." + mode.key()));
|
||||
}
|
||||
|
||||
private void submit() {
|
||||
if (pages.isEmpty() || !ClientPlayNetworking.canSend(SaveTrophySignPayload.TYPE)) return;
|
||||
ClientPlayNetworking.send(new SaveTrophySignPayload(payload.pos(), pages, mode.key()));
|
||||
onClose();
|
||||
}
|
||||
|
||||
private int panelX() { return (width - PANEL_WIDTH) / 2; }
|
||||
private int panelY() { return Math.max(2, (height - PANEL_HEIGHT) / 2); }
|
||||
|
||||
@Override public void onClose() { if (minecraft != null) minecraft.gui.setScreen(parent); }
|
||||
@Override public boolean isPauseScreen() { return false; }
|
||||
|
||||
private record MetricOption(RankingMetric metric, Component label, String searchText) {}
|
||||
}
|
||||
+34
-44
@@ -5,28 +5,31 @@ 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.redstoner.trophy.TrophyPanelRules;
|
||||
import fr.koka99cab.sanctuary26.sanctuary.api.ranking.RankingMetric;
|
||||
import fr.koka99cab.sanctuary26.sanctuary.api.ranking.RankingUnit;
|
||||
import fr.koka99cab.sanctuary26.sanctuary.api.ranking.SanctuaryRankingApi;
|
||||
import java.util.Arrays;
|
||||
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.item.ItemModelResolver;
|
||||
import net.minecraft.client.renderer.state.level.CameraRenderState;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.util.FormattedCharSequence;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public final class TrophyPanelBlockEntityRenderer
|
||||
implements BlockEntityRenderer<TrophyPanelBlockEntity, TrophyPanelRenderState> {
|
||||
private final ItemModelResolver itemModelResolver;
|
||||
private static final int MAX_TEXT_WIDTH = 90;
|
||||
private static final float TEXT_SCALE = 0.010416667F;
|
||||
private static final float[] LINE_HEIGHTS = {0.86F, 0.75F, 0.64F, 0.53F, 0.42F, 0.31F, 0.20F, 0.09F};
|
||||
private static final int TEXT_COLOR = 0xFF3D281A;
|
||||
private final Font font;
|
||||
|
||||
public TrophyPanelBlockEntityRenderer(BlockEntityRendererProvider.Context context) {
|
||||
itemModelResolver = context.itemModelResolver();
|
||||
font = context.font();
|
||||
}
|
||||
|
||||
@@ -40,65 +43,52 @@ public final class TrophyPanelBlockEntityRenderer
|
||||
float tickProgress, Vec3 cameraPos, ModelFeatureRenderer.CrumblingOverlay crumblingOverlay) {
|
||||
BlockEntityRenderer.super.extractRenderState(panel, state, tickProgress, cameraPos, crumblingOverlay);
|
||||
state.facing = panel.getBlockState().getValue(TrophyPanelBlock.FACING);
|
||||
state.icon.clear();
|
||||
Arrays.fill(state.lines, Component.empty());
|
||||
ItemStack icon = panel.currentPage().icon();
|
||||
state.hasIcon = !icon.isEmpty();
|
||||
if (state.hasIcon) {
|
||||
itemModelResolver.updateForTopItem(state.icon, icon, ItemDisplayContext.FIXED,
|
||||
panel.level(), panel, (int) panel.getBlockPos().asLong());
|
||||
}
|
||||
|
||||
TrophyPanelBlockEntity.ClientSnapshot snapshot = panel.visibleSnapshot();
|
||||
RankingUnit unit = snapshot.unit();
|
||||
state.metric = state.hasIcon ? Component.translatable(snapshot.translationKey(), icon.getHoverName())
|
||||
: Component.translatable(snapshot.translationKey());
|
||||
Component metric = SanctuaryRankingApi.displayName(
|
||||
new RankingMetric(snapshot.metricId(), snapshot.translationKey(), unit), icon);
|
||||
state.lines[0] = Component.translatable("block.redstoner.trophy_panel.page_title",
|
||||
panel.pageNumber(), panel.pageCount(), metric);
|
||||
if (snapshot.podium().isEmpty()) {
|
||||
state.champion = Component.translatable("block.redstoner.trophy_panel.no_score");
|
||||
state.lines[1] = Component.translatable("block.redstoner.trophy_panel.no_score");
|
||||
} else {
|
||||
TrophyPanelBlockEntity.ClientEntry champion = snapshot.podium().getFirst();
|
||||
state.champion = Component.translatable("block.redstoner.trophy_panel.champion",
|
||||
champion.name(), unit.format(champion.value()));
|
||||
for (int index = 0; index < TrophyPanelRules.ENTRIES_PER_VIEW; index++) {
|
||||
if (index >= snapshot.podium().size()) {
|
||||
break;
|
||||
}
|
||||
TrophyPanelBlockEntity.ClientEntry entry = snapshot.podium().get(index);
|
||||
state.lines[index + 1] = panel.valuesView()
|
||||
? Component.translatable("block.redstoner.trophy_panel.value",
|
||||
entry.rank(), unit.format(entry.value()))
|
||||
: Component.translatable("block.redstoner.trophy_panel.player",
|
||||
entry.rank(), entry.name());
|
||||
}
|
||||
}
|
||||
state.owner = snapshot.ownerRank() > 0
|
||||
? Component.translatable("block.redstoner.trophy_panel.owner_rank", panel.ownerName(),
|
||||
snapshot.ownerRank(), unit.format(snapshot.ownerValue()))
|
||||
: Component.translatable("block.redstoner.trophy_panel.owner_unranked", panel.ownerName());
|
||||
state.page = Component.literal(panel.pageNumber() + "/" + panel.pageCount());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submit(TrophyPanelRenderState state, PoseStack poseStack,
|
||||
SubmitNodeCollector submitNodeCollector, CameraRenderState cameraRenderState) {
|
||||
float yRotation = -state.facing.toYRot();
|
||||
if (state.hasIcon) submitIcon(state, poseStack, submitNodeCollector, yRotation);
|
||||
submitText(state.metric, 0.72F, 0.0065F, state, poseStack, submitNodeCollector, yRotation, 0xFFE8B4);
|
||||
submitText(state.champion, 0.52F, 0.0060F, state, poseStack, submitNodeCollector, yRotation, 0xFFFFFF);
|
||||
submitText(state.owner, 0.36F, 0.0055F, state, poseStack, submitNodeCollector, yRotation, 0xB8D9FF);
|
||||
submitText(state.page, 0.20F, 0.0050F, state, poseStack, submitNodeCollector, yRotation, 0xA0A0A0);
|
||||
for (int index = 0; index < TrophyPanelRenderState.LINE_COUNT; index++) {
|
||||
submitText(state.lines[index], LINE_HEIGHTS[index], state, poseStack, submitNodeCollector, yRotation);
|
||||
}
|
||||
}
|
||||
|
||||
private void submitIcon(TrophyPanelRenderState state, PoseStack poseStack,
|
||||
SubmitNodeCollector submitNodeCollector, float yRotation) {
|
||||
poseStack.pushPose();
|
||||
poseStack.translate(0.5F, 0.89F, 0.5F);
|
||||
poseStack.mulPose(Axis.YP.rotationDegrees(yRotation));
|
||||
poseStack.translate(0.0F, 0.0F, -0.33F);
|
||||
poseStack.scale(0.18F, 0.18F, 0.18F);
|
||||
state.icon.submit(poseStack, submitNodeCollector, state.lightCoords, OverlayTexture.NO_OVERLAY, 0);
|
||||
poseStack.popPose();
|
||||
}
|
||||
|
||||
private void submitText(Component component, float y, float scale, TrophyPanelRenderState state,
|
||||
PoseStack poseStack, SubmitNodeCollector submitNodeCollector, float yRotation, int color) {
|
||||
FormattedCharSequence text = component.getVisualOrderText();
|
||||
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(scale, -scale, scale);
|
||||
poseStack.scale(TEXT_SCALE, -TEXT_SCALE, TEXT_SCALE);
|
||||
submitNodeCollector.submitText(poseStack, x, 0.0F, text, false, Font.DisplayMode.POLYGON_OFFSET,
|
||||
color, state.lightCoords, 0, 0x30181818);
|
||||
state.lightCoords, TEXT_COLOR, 0, 0);
|
||||
poseStack.popPose();
|
||||
}
|
||||
}
|
||||
|
||||
+7
-7
@@ -1,16 +1,16 @@
|
||||
package fr.koka99cab.sanctuary26.redstoner.client.renderer.state;
|
||||
|
||||
import fr.koka99cab.sanctuary26.redstoner.trophy.TrophyPanelRules;
|
||||
import net.minecraft.client.renderer.blockentity.state.BlockEntityRenderState;
|
||||
import net.minecraft.client.renderer.item.ItemStackRenderState;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
public final class TrophyPanelRenderState extends BlockEntityRenderState {
|
||||
public final ItemStackRenderState icon = new ItemStackRenderState();
|
||||
public static final int LINE_COUNT = TrophyPanelRules.LINE_COUNT;
|
||||
public final Component[] lines = new Component[LINE_COUNT];
|
||||
public Direction facing = Direction.NORTH;
|
||||
public boolean hasIcon;
|
||||
public Component metric = Component.empty();
|
||||
public Component champion = Component.empty();
|
||||
public Component owner = Component.empty();
|
||||
public Component page = Component.empty();
|
||||
|
||||
public TrophyPanelRenderState() {
|
||||
java.util.Arrays.fill(lines, Component.empty());
|
||||
}
|
||||
}
|
||||
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package fr.koka99cab.sanctuary26.redstoner.network;
|
||||
|
||||
import fr.koka99cab.sanctuary26.redstoner.RedStonerMod;
|
||||
import fr.koka99cab.sanctuary26.redstoner.trophy.TrophyDisplayMode;
|
||||
import fr.koka99cab.sanctuary26.redstoner.trophy.TrophyPanelRules;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.resources.Identifier;
|
||||
|
||||
/** Opens the white trophy-sign editor with only its small current configuration. */
|
||||
public record OpenTrophySignEditorPayload(BlockPos pos, List<Identifier> pages, String display)
|
||||
implements CustomPacketPayload {
|
||||
public static final Type<OpenTrophySignEditorPayload> TYPE =
|
||||
new Type<>(RedStonerMod.id("s2c/open_trophy_sign_editor"));
|
||||
public static final StreamCodec<RegistryFriendlyByteBuf, OpenTrophySignEditorPayload> STREAM_CODEC =
|
||||
StreamCodec.of(OpenTrophySignEditorPayload::write, OpenTrophySignEditorPayload::read);
|
||||
|
||||
public OpenTrophySignEditorPayload {
|
||||
pos = pos == null ? BlockPos.ZERO : pos.immutable();
|
||||
pages = TrophyPanelRules.sanitizeMetricIds(pages);
|
||||
display = TrophyDisplayMode.byKey(display).key();
|
||||
}
|
||||
|
||||
private static OpenTrophySignEditorPayload read(RegistryFriendlyByteBuf buffer) {
|
||||
BlockPos pos = buffer.readBlockPos();
|
||||
int count = boundedCount(buffer.readVarInt());
|
||||
List<Identifier> pages = new ArrayList<>(count);
|
||||
for (int index = 0; index < count; index++) pages.add(Identifier.parse(buffer.readUtf(256)));
|
||||
return new OpenTrophySignEditorPayload(pos, pages, buffer.readUtf(24));
|
||||
}
|
||||
|
||||
private static void write(RegistryFriendlyByteBuf buffer, OpenTrophySignEditorPayload payload) {
|
||||
buffer.writeBlockPos(payload.pos);
|
||||
buffer.writeVarInt(payload.pages.size());
|
||||
for (Identifier page : payload.pages) buffer.writeUtf(page.toString(), 256);
|
||||
buffer.writeUtf(payload.display, 24);
|
||||
}
|
||||
|
||||
private static int boundedCount(int count) {
|
||||
if (count < 0 || count > TrophyPanelRules.MAX_PAGES) {
|
||||
throw new IllegalArgumentException("Invalid trophy-sign page count: " + count);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override public Type<? extends CustomPacketPayload> type() { return TYPE; }
|
||||
}
|
||||
+8
-1
@@ -4,6 +4,7 @@ import fr.koka99cab.sanctuary26.redstoner.RedStonerMod;
|
||||
import fr.koka99cab.sanctuary26.redstoner.block.entity.ComputerBlockEntity;
|
||||
import fr.koka99cab.sanctuary26.redstoner.block.entity.PersonalComputerBlockEntity;
|
||||
import fr.koka99cab.sanctuary26.redstoner.registry.RedStonerRegistries;
|
||||
import fr.koka99cab.sanctuary26.redstoner.trophy.TrophySignService;
|
||||
import fr.koka99cab.sanctuary26.sanctuary.api.atlas.SanctuaryAtlasLandmarks;
|
||||
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
||||
@@ -12,7 +13,7 @@ import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public final class RedStonerNetworking {
|
||||
public static final int PROTOCOL_VERSION = 7;
|
||||
public static final int PROTOCOL_VERSION = 9;
|
||||
private static boolean initialized;
|
||||
|
||||
private RedStonerNetworking() {
|
||||
@@ -25,6 +26,8 @@ public final class RedStonerNetworking {
|
||||
initialized = true;
|
||||
PayloadTypeRegistry.clientboundPlay().register(OpenComputerPayload.TYPE, OpenComputerPayload.STREAM_CODEC);
|
||||
PayloadTypeRegistry.clientboundPlay().register(OpenPersonalComputerPayload.TYPE, OpenPersonalComputerPayload.STREAM_CODEC);
|
||||
PayloadTypeRegistry.clientboundPlay().register(OpenTrophySignEditorPayload.TYPE,
|
||||
OpenTrophySignEditorPayload.STREAM_CODEC);
|
||||
PayloadTypeRegistry.serverboundPlay().register(SaveComputerProgramPayload.TYPE, SaveComputerProgramPayload.STREAM_CODEC);
|
||||
PayloadTypeRegistry.serverboundPlay().register(PlaceAtlasLandmarkPayload.TYPE, PlaceAtlasLandmarkPayload.STREAM_CODEC);
|
||||
PayloadTypeRegistry.serverboundPlay().register(RequestPersonalComputerSnapshotPayload.TYPE,
|
||||
@@ -33,6 +36,8 @@ public final class RedStonerNetworking {
|
||||
AcknowledgePersonalComputerIntroPayload.STREAM_CODEC);
|
||||
PayloadTypeRegistry.serverboundPlay().register(ShutdownPersonalComputerPayload.TYPE,
|
||||
ShutdownPersonalComputerPayload.STREAM_CODEC);
|
||||
PayloadTypeRegistry.serverboundPlay().register(SaveTrophySignPayload.TYPE,
|
||||
SaveTrophySignPayload.STREAM_CODEC);
|
||||
ServerPlayNetworking.registerGlobalReceiver(SaveComputerProgramPayload.TYPE, (payload, context) ->
|
||||
context.server().execute(() -> saveProgram(context.player(), payload)));
|
||||
ServerPlayNetworking.registerGlobalReceiver(PlaceAtlasLandmarkPayload.TYPE, (payload, context) ->
|
||||
@@ -43,6 +48,8 @@ public final class RedStonerNetworking {
|
||||
context.server().execute(() -> acknowledgePersonalComputerIntro(context.player(), payload)));
|
||||
ServerPlayNetworking.registerGlobalReceiver(ShutdownPersonalComputerPayload.TYPE, (payload, context) ->
|
||||
context.server().execute(() -> shutdownPersonalComputer(context.player(), payload)));
|
||||
ServerPlayNetworking.registerGlobalReceiver(SaveTrophySignPayload.TYPE, (payload, context) ->
|
||||
context.server().execute(() -> TrophySignService.save(context.player(), payload)));
|
||||
RedStonerMod.LOGGER.debug("[{}] Networking contract v{} registered.", RedStonerMod.DISPLAY_NAME, PROTOCOL_VERSION);
|
||||
}
|
||||
|
||||
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package fr.koka99cab.sanctuary26.redstoner.network;
|
||||
|
||||
import fr.koka99cab.sanctuary26.redstoner.RedStonerMod;
|
||||
import fr.koka99cab.sanctuary26.redstoner.trophy.TrophyDisplayMode;
|
||||
import fr.koka99cab.sanctuary26.redstoner.trophy.TrophyPanelRules;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.resources.Identifier;
|
||||
|
||||
/** Bounded editor submission; ownership, distance, block and metrics are all revalidated server-side. */
|
||||
public record SaveTrophySignPayload(BlockPos pos, List<Identifier> pages, String display)
|
||||
implements CustomPacketPayload {
|
||||
public static final Type<SaveTrophySignPayload> TYPE =
|
||||
new Type<>(RedStonerMod.id("c2s/save_trophy_sign"));
|
||||
public static final StreamCodec<RegistryFriendlyByteBuf, SaveTrophySignPayload> STREAM_CODEC =
|
||||
StreamCodec.of(SaveTrophySignPayload::write, SaveTrophySignPayload::read);
|
||||
|
||||
public SaveTrophySignPayload {
|
||||
pos = pos == null ? BlockPos.ZERO : pos.immutable();
|
||||
pages = TrophyPanelRules.sanitizeMetricIds(pages);
|
||||
display = TrophyDisplayMode.byKey(display).key();
|
||||
}
|
||||
|
||||
private static SaveTrophySignPayload read(RegistryFriendlyByteBuf buffer) {
|
||||
BlockPos pos = buffer.readBlockPos();
|
||||
int count = boundedCount(buffer.readVarInt());
|
||||
List<Identifier> pages = new ArrayList<>(count);
|
||||
for (int index = 0; index < count; index++) pages.add(Identifier.parse(buffer.readUtf(256)));
|
||||
return new SaveTrophySignPayload(pos, pages, buffer.readUtf(24));
|
||||
}
|
||||
|
||||
private static void write(RegistryFriendlyByteBuf buffer, SaveTrophySignPayload payload) {
|
||||
buffer.writeBlockPos(payload.pos);
|
||||
buffer.writeVarInt(payload.pages.size());
|
||||
for (Identifier page : payload.pages) buffer.writeUtf(page.toString(), 256);
|
||||
buffer.writeUtf(payload.display, 24);
|
||||
}
|
||||
|
||||
private static int boundedCount(int count) {
|
||||
if (count < 0 || count > TrophyPanelRules.MAX_PAGES) {
|
||||
throw new IllegalArgumentException("Invalid trophy-sign page count: " + count);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override public Type<? extends CustomPacketPayload> type() { return TYPE; }
|
||||
}
|
||||
+37
-2
@@ -12,8 +12,10 @@ 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 fr.koka99cab.sanctuary26.redstoner.trophy.TrophySignItem;
|
||||
import java.util.function.Function;
|
||||
import net.fabricmc.fabric.api.event.player.AttackBlockCallback;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityType;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
@@ -28,10 +30,15 @@ import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.StandingSignBlock;
|
||||
import net.minecraft.world.level.block.WallSignBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTypes;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.WoodType;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
|
||||
public final class RedStonerRegistries {
|
||||
@@ -79,6 +86,18 @@ public final class RedStonerRegistries {
|
||||
BlockBehaviour.Properties.of().mapColor(MapColor.WOOD).strength(2.0F).sound(SoundType.WOOD)
|
||||
.requiresCorrectToolForDrops().noOcclusion().setId(blockKey(RedStonerMod.id("trophy_panel")))
|
||||
);
|
||||
public static final StandingSignBlock TROPHY_SIGN = registerBlock(
|
||||
RedStonerMod.id("trophy_sign"),
|
||||
properties -> new StandingSignBlock(WoodType.PALE_OAK, properties),
|
||||
BlockBehaviour.Properties.ofFullCopy(Blocks.PALE_OAK_SIGN).mapColor(MapColor.SNOW)
|
||||
.setId(blockKey(RedStonerMod.id("trophy_sign")))
|
||||
);
|
||||
public static final WallSignBlock TROPHY_WALL_SIGN = registerBlock(
|
||||
RedStonerMod.id("trophy_wall_sign"),
|
||||
properties -> new WallSignBlock(WoodType.PALE_OAK, properties),
|
||||
BlockBehaviour.Properties.ofFullCopy(Blocks.PALE_OAK_WALL_SIGN).mapColor(MapColor.SNOW)
|
||||
.setId(blockKey(RedStonerMod.id("trophy_wall_sign")))
|
||||
);
|
||||
|
||||
public static final ComputerBlock LEGACY_EIGHT_BIT_COMPUTER = registerBlock(
|
||||
LEGACY_COMPUTER_ID, ComputerBlock::new, computerProperties(LEGACY_COMPUTER_ID, MapColor.COLOR_RED));
|
||||
@@ -100,7 +119,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 TROPHY_PANEL_ITEM = registerTrophySignItem();
|
||||
|
||||
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);
|
||||
@@ -153,8 +172,16 @@ public final class RedStonerRegistries {
|
||||
return;
|
||||
}
|
||||
initialized = true;
|
||||
FabricBlockEntityType signType = (FabricBlockEntityType) (Object) BlockEntityTypes.SIGN;
|
||||
signType.addValidBlock(TROPHY_SIGN);
|
||||
signType.addValidBlock(TROPHY_WALL_SIGN);
|
||||
registerDrawerAttack();
|
||||
RedStonerMod.LOGGER.info("[{}] Registered seven active blocks and five legacy block aliases.", RedStonerMod.DISPLAY_NAME);
|
||||
RedStonerMod.LOGGER.info("[{}] Registered the vanilla trophy-sign pair and retained the old panel for migration.",
|
||||
RedStonerMod.DISPLAY_NAME);
|
||||
}
|
||||
|
||||
public static boolean isTrophySign(Block block) {
|
||||
return block == TROPHY_SIGN || block == TROPHY_WALL_SIGN;
|
||||
}
|
||||
|
||||
public static boolean isController(BlockState state) {
|
||||
@@ -199,6 +226,14 @@ public final class RedStonerRegistries {
|
||||
new BlockItem(block, new Item.Properties().useBlockDescriptionPrefix().setId(key)));
|
||||
}
|
||||
|
||||
private static Item registerTrophySignItem() {
|
||||
Identifier id = RedStonerMod.id("trophy_panel");
|
||||
ResourceKey<Item> key = ResourceKey.create(Registries.ITEM, id);
|
||||
return Registry.register(BuiltInRegistries.ITEM, key,
|
||||
new TrophySignItem(TROPHY_SIGN, TROPHY_WALL_SIGN,
|
||||
new Item.Properties().useBlockDescriptionPrefix().setId(key)));
|
||||
}
|
||||
|
||||
private static ResourceKey<Block> blockKey(Identifier id) {
|
||||
return ResourceKey.create(Registries.BLOCK, id);
|
||||
}
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package fr.koka99cab.sanctuary26.redstoner.storage;
|
||||
|
||||
/** Keyboard routing shared by the terminal screen and its deterministic smoke test. */
|
||||
public final class StorageTerminalKeyRules {
|
||||
private StorageTerminalKeyRules() {}
|
||||
|
||||
public static boolean capturesInventoryKey(boolean searchFocused, boolean inventoryKey) {
|
||||
return searchFocused && inventoryKey;
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package fr.koka99cab.sanctuary26.redstoner.trophy;
|
||||
|
||||
/** Stable, persisted choice for the three ranking rows of a vanilla trophy sign. */
|
||||
public enum TrophyDisplayMode {
|
||||
NAMES_AND_VALUES("names_and_values"),
|
||||
NAMES("names"),
|
||||
VALUES("values");
|
||||
|
||||
private final String key;
|
||||
|
||||
TrophyDisplayMode(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String key() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public TrophyDisplayMode next() {
|
||||
TrophyDisplayMode[] modes = values();
|
||||
return modes[(ordinal() + 1) % modes.length];
|
||||
}
|
||||
|
||||
public static TrophyDisplayMode byKey(String key) {
|
||||
for (TrophyDisplayMode mode : values()) if (mode.key.equals(key)) return mode;
|
||||
return NAMES_AND_VALUES;
|
||||
}
|
||||
}
|
||||
+46
-1
@@ -9,6 +9,12 @@ 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;
|
||||
public static final int SIGN_LINE_COUNT = 4;
|
||||
public static final int SIGN_ENTRIES_PER_PAGE = SIGN_LINE_COUNT - 1;
|
||||
/** Legacy plate dimensions kept only while old block entities migrate. */
|
||||
public static final int LINE_COUNT = 8;
|
||||
public static final int ENTRIES_PER_VIEW = LINE_COUNT - 1;
|
||||
private static final int VIEWS_PER_METRIC = 2;
|
||||
|
||||
private TrophyPanelRules() {}
|
||||
|
||||
@@ -17,7 +23,36 @@ public final class TrophyPanelRules {
|
||||
}
|
||||
|
||||
public static int nextPage(int currentPage, int pageCount) {
|
||||
return pageCount <= 0 ? 0 : Math.floorMod(currentPage + 1, 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 DisplayPage displayPageByOffset(int metricPage, boolean valuesView,
|
||||
int metricCount, int offset) {
|
||||
int safeMetricCount = Math.max(1, metricCount);
|
||||
int safeMetricPage = Math.clamp(metricPage, 0, safeMetricCount - 1);
|
||||
int currentDisplayPage = safeMetricPage * VIEWS_PER_METRIC + (valuesView ? 1 : 0);
|
||||
int displayPage = Math.floorMod(currentDisplayPage + offset,
|
||||
safeMetricCount * VIEWS_PER_METRIC);
|
||||
return new DisplayPage(displayPage / VIEWS_PER_METRIC,
|
||||
displayPage % VIEWS_PER_METRIC == 1);
|
||||
}
|
||||
|
||||
public static int displayPageNumber(int metricPage, boolean valuesView, int metricCount) {
|
||||
int safeMetricCount = Math.max(1, metricCount);
|
||||
return Math.clamp(metricPage, 0, safeMetricCount - 1) * VIEWS_PER_METRIC
|
||||
+ (valuesView ? 2 : 1);
|
||||
}
|
||||
|
||||
public static int displayPageCount(int metricCount) {
|
||||
return Math.max(1, metricCount) * VIEWS_PER_METRIC;
|
||||
}
|
||||
|
||||
public static List<Identifier> mergeMetricIds(List<Identifier> current, List<Identifier> offered) {
|
||||
@@ -26,4 +61,14 @@ public final class TrophyPanelRules {
|
||||
if (offered != null) merged.addAll(offered);
|
||||
return List.copyOf(new ArrayList<>(merged).subList(0, Math.min(MAX_PAGES, merged.size())));
|
||||
}
|
||||
|
||||
public static List<Identifier> sanitizeMetricIds(List<Identifier> requested) {
|
||||
LinkedHashSet<Identifier> unique = new LinkedHashSet<>();
|
||||
if (requested != null) {
|
||||
requested.stream().filter(java.util.Objects::nonNull).limit(MAX_PAGES).forEach(unique::add);
|
||||
}
|
||||
return List.copyOf(unique);
|
||||
}
|
||||
|
||||
public record DisplayPage(int metricPage, boolean valuesView) {}
|
||||
}
|
||||
|
||||
+180
@@ -0,0 +1,180 @@
|
||||
package fr.koka99cab.sanctuary26.redstoner.trophy;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import fr.koka99cab.sanctuary26.redstoner.RedStonerMod;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import net.minecraft.core.BlockPos;
|
||||
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;
|
||||
|
||||
/** Versioned, server-owned configurations for the vanilla block entities used by trophy signs. */
|
||||
public final class TrophySignData extends SavedData {
|
||||
public static final int DATA_VERSION = 1;
|
||||
public static final String SAVE_KEY = "trophy_signs";
|
||||
public static final int MAX_SIGNS = 16_384;
|
||||
|
||||
private static final Codec<Config> CONFIG_CODEC = RecordCodecBuilder.create(instance -> instance.group(
|
||||
Codec.STRING.fieldOf("dimension").forGetter(Config::dimension),
|
||||
Codec.LONG.fieldOf("pos").forGetter(Config::pos),
|
||||
Codec.STRING.fieldOf("owner").forGetter(Config::owner),
|
||||
Codec.STRING.optionalFieldOf("owner_name", "?").forGetter(Config::ownerName),
|
||||
Identifier.CODEC.listOf(0, TrophyPanelRules.MAX_PAGES).optionalFieldOf("pages", List.of())
|
||||
.forGetter(Config::pages),
|
||||
Codec.INT.optionalFieldOf("current_page", 0).forGetter(Config::currentPage),
|
||||
Codec.STRING.optionalFieldOf("display", TrophyDisplayMode.NAMES_AND_VALUES.key())
|
||||
.forGetter(Config::display),
|
||||
Codec.BOOL.optionalFieldOf("configured", false).forGetter(Config::configured)
|
||||
).apply(instance, Config::new));
|
||||
private static final Codec<TrophySignData> CODEC = RecordCodecBuilder.create(instance -> instance.group(
|
||||
Codec.INT.optionalFieldOf("data_version", DATA_VERSION).forGetter(data -> data.dataVersion),
|
||||
CONFIG_CODEC.listOf().optionalFieldOf("signs", List.of()).forGetter(TrophySignData::entriesForCodec)
|
||||
).apply(instance, TrophySignData::new));
|
||||
private static final SavedDataType<TrophySignData> TYPE = new SavedDataType<>(
|
||||
RedStonerMod.id(SAVE_KEY), TrophySignData::new, CODEC, null);
|
||||
|
||||
private int dataVersion;
|
||||
private final List<Config> signs;
|
||||
|
||||
public TrophySignData() {
|
||||
this(DATA_VERSION, List.of());
|
||||
}
|
||||
|
||||
private TrophySignData(int dataVersion, List<Config> signs) {
|
||||
this.dataVersion = dataVersion;
|
||||
this.signs = new ArrayList<>(signs == null ? List.of()
|
||||
: signs.stream().limit(MAX_SIGNS).toList());
|
||||
}
|
||||
|
||||
public static TrophySignData get(MinecraftServer server) {
|
||||
ServerLevel overworld = server.getLevel(Level.OVERWORLD);
|
||||
if (overworld == null) throw new IllegalStateException("Overworld unavailable for trophy-sign data");
|
||||
TrophySignData data = overworld.getDataStorage().computeIfAbsent(TYPE);
|
||||
data.upgradeIfRequired();
|
||||
return data;
|
||||
}
|
||||
|
||||
public boolean writable() {
|
||||
return dataVersion <= DATA_VERSION;
|
||||
}
|
||||
|
||||
public List<Config> signs() {
|
||||
return List.copyOf(signs);
|
||||
}
|
||||
|
||||
public Optional<Config> signAt(ServerLevel level, BlockPos pos) {
|
||||
return signAt(dimension(level), pos.asLong());
|
||||
}
|
||||
|
||||
public Optional<Config> signAt(String dimension, long pos) {
|
||||
return signs.stream().filter(sign -> sign.dimension().equals(dimension) && sign.pos() == pos).findFirst();
|
||||
}
|
||||
|
||||
public boolean add(Config config) {
|
||||
if (!writable() || signs.size() >= MAX_SIGNS
|
||||
|| signAt(config.dimension(), config.pos()).isPresent()) return false;
|
||||
signs.add(config);
|
||||
setDirty();
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean replace(Config replacement) {
|
||||
if (!writable()) return false;
|
||||
for (int index = 0; index < signs.size(); index++) {
|
||||
Config current = signs.get(index);
|
||||
if (!current.dimension().equals(replacement.dimension()) || current.pos() != replacement.pos()) continue;
|
||||
signs.set(index, replacement);
|
||||
setDirty();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean remove(Config config) {
|
||||
if (!writable()) return false;
|
||||
boolean removed = signs.remove(config);
|
||||
if (removed) setDirty();
|
||||
return removed;
|
||||
}
|
||||
|
||||
private List<Config> entriesForCodec() {
|
||||
return List.copyOf(signs);
|
||||
}
|
||||
|
||||
private void upgradeIfRequired() {
|
||||
if (dataVersion < DATA_VERSION) {
|
||||
int previous = dataVersion;
|
||||
dataVersion = DATA_VERSION;
|
||||
setDirty();
|
||||
RedStonerMod.LOGGER.info("[{}] Migrated trophy-sign data from v{} to v{}.",
|
||||
RedStonerMod.DISPLAY_NAME, previous, dataVersion);
|
||||
} else if (dataVersion > DATA_VERSION) {
|
||||
RedStonerMod.LOGGER.warn("[{}] Trophy-sign data v{} is newer than supported v{}.",
|
||||
RedStonerMod.DISPLAY_NAME, dataVersion, DATA_VERSION);
|
||||
}
|
||||
}
|
||||
|
||||
public static String dimension(ServerLevel level) {
|
||||
return level.dimension().identifier().toString();
|
||||
}
|
||||
|
||||
public record Config(String dimension, long pos, String owner, String ownerName,
|
||||
List<Identifier> pages, int currentPage, String display, boolean configured) {
|
||||
public Config {
|
||||
dimension = clean(dimension, 128, "minecraft:overworld");
|
||||
owner = cleanUuid(owner);
|
||||
ownerName = clean(ownerName, 32, "?");
|
||||
pages = TrophyPanelRules.sanitizeMetricIds(pages);
|
||||
currentPage = pages.isEmpty() ? 0 : Math.clamp(currentPage, 0, pages.size() - 1);
|
||||
display = TrophyDisplayMode.byKey(display).key();
|
||||
configured = configured && !pages.isEmpty();
|
||||
}
|
||||
|
||||
public static Config draft(ServerLevel level, BlockPos pos, UUID ownerId, String ownerName) {
|
||||
return new Config(TrophySignData.dimension(level), pos.asLong(), ownerId.toString(), ownerName,
|
||||
List.of(), 0, TrophyDisplayMode.NAMES_AND_VALUES.key(), false);
|
||||
}
|
||||
|
||||
public UUID ownerId() {
|
||||
return UUID.fromString(owner);
|
||||
}
|
||||
|
||||
public TrophyDisplayMode displayMode() {
|
||||
return TrophyDisplayMode.byKey(display);
|
||||
}
|
||||
|
||||
public Identifier currentMetric() {
|
||||
return pages.get(Math.clamp(currentPage, 0, pages.size() - 1));
|
||||
}
|
||||
|
||||
public Config withConfiguration(List<Identifier> requestedPages, TrophyDisplayMode mode,
|
||||
String retainedOwnerName) {
|
||||
List<Identifier> sanitized = TrophyPanelRules.sanitizeMetricIds(requestedPages);
|
||||
return new Config(dimension, pos, owner, retainedOwnerName, sanitized, 0, mode.key(), true);
|
||||
}
|
||||
|
||||
public Config withCurrentPage(int page) {
|
||||
return new Config(dimension, pos, owner, ownerName, pages, page, display, configured);
|
||||
}
|
||||
}
|
||||
|
||||
private static String clean(String value, int maximum, String fallback) {
|
||||
String clean = value == null || value.isBlank() ? fallback : value.strip();
|
||||
return clean.substring(0, Math.min(maximum, clean.length()));
|
||||
}
|
||||
|
||||
private static String cleanUuid(String value) {
|
||||
try {
|
||||
return UUID.fromString(value).toString();
|
||||
} catch (IllegalArgumentException | NullPointerException ignored) {
|
||||
return new UUID(0L, 0L).toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package fr.koka99cab.sanctuary26.redstoner.trophy;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.SignItem;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.SignBlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
/** The historical trophy-panel item now places an ordinary standing or wall sign. */
|
||||
public final class TrophySignItem extends SignItem {
|
||||
public TrophySignItem(Block standing, Block wall, Properties properties) {
|
||||
super(standing, wall, properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean updateCustomBlockEntityTag(BlockPos pos, Level level, Player player,
|
||||
ItemStack stack, BlockState state) {
|
||||
if (level instanceof ServerLevel serverLevel && player instanceof ServerPlayer serverPlayer
|
||||
&& level.getBlockEntity(pos) instanceof SignBlockEntity sign) {
|
||||
TrophySignService.activatePlacedSign(serverPlayer, serverLevel, pos, sign);
|
||||
}
|
||||
// The bounded trophy editor replaces the vanilla text editor.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+271
@@ -0,0 +1,271 @@
|
||||
package fr.koka99cab.sanctuary26.redstoner.trophy;
|
||||
|
||||
import fr.koka99cab.sanctuary26.redstoner.network.OpenTrophySignEditorPayload;
|
||||
import fr.koka99cab.sanctuary26.redstoner.network.SaveTrophySignPayload;
|
||||
import fr.koka99cab.sanctuary26.redstoner.registry.RedStonerRegistries;
|
||||
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.List;
|
||||
import java.util.UUID;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
||||
import net.fabricmc.fabric.api.event.player.PlayerBlockBreakEvents;
|
||||
import net.fabricmc.fabric.api.event.player.UseBlockCallback;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.permissions.Permissions;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.SignBlock;
|
||||
import net.minecraft.world.level.block.WallSignBlock;
|
||||
import net.minecraft.world.level.block.entity.SignBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.SignText;
|
||||
|
||||
/** Server-authoritative ownership, paging, editing and refresh behavior for white vanilla trophy signs. */
|
||||
public final class TrophySignService {
|
||||
private static final int REFRESH_INTERVAL_TICKS = 20;
|
||||
private static final int MAX_INSPECTIONS_PER_REFRESH = 128;
|
||||
private static int tickCounter;
|
||||
private static int refreshCursor;
|
||||
private static boolean initialized;
|
||||
|
||||
private TrophySignService() {}
|
||||
|
||||
public static void initialize() {
|
||||
if (initialized) return;
|
||||
initialized = true;
|
||||
UseBlockCallback.EVENT.register((player, level, hand, hit) -> {
|
||||
BlockPos pos = hit.getBlockPos();
|
||||
if (hand != InteractionHand.MAIN_HAND
|
||||
|| !RedStonerRegistries.isTrophySign(level.getBlockState(pos).getBlock())
|
||||
|| !(level.getBlockEntity(pos) instanceof SignBlockEntity sign)) {
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
if (level.isClientSide()) return InteractionResult.SUCCESS;
|
||||
return player instanceof ServerPlayer serverPlayer
|
||||
? interact(serverPlayer, (ServerLevel) level, pos, sign)
|
||||
: InteractionResult.PASS;
|
||||
});
|
||||
PlayerBlockBreakEvents.BEFORE.register((level, player, pos, state, blockEntity) -> {
|
||||
if (!(level instanceof ServerLevel serverLevel) || !RedStonerRegistries.isTrophySign(state.getBlock())) {
|
||||
return true;
|
||||
}
|
||||
TrophySignData.Config config = TrophySignData.get(serverLevel.getServer())
|
||||
.signAt(serverLevel, pos).orElse(null);
|
||||
if (config == null || config.ownerId().equals(player.getUUID())) return true;
|
||||
if (player instanceof ServerPlayer serverPlayer && isOperator(serverPlayer)) return true;
|
||||
if (player instanceof ServerPlayer serverPlayer) message(serverPlayer, "protected");
|
||||
return false;
|
||||
});
|
||||
PlayerBlockBreakEvents.AFTER.register((level, player, pos, state, blockEntity) -> {
|
||||
if (!(level instanceof ServerLevel serverLevel) || !RedStonerRegistries.isTrophySign(state.getBlock())) {
|
||||
return;
|
||||
}
|
||||
TrophySignData data = TrophySignData.get(serverLevel.getServer());
|
||||
data.signAt(serverLevel, pos).ifPresent(data::remove);
|
||||
});
|
||||
ServerTickEvents.END_SERVER_TICK.register(TrophySignService::tick);
|
||||
}
|
||||
|
||||
/** Creates a blank owned sign and immediately opens its custom editor. */
|
||||
public static void activatePlacedSign(ServerPlayer player, ServerLevel level, BlockPos pos,
|
||||
SignBlockEntity sign) {
|
||||
TrophySignData data = TrophySignData.get(level.getServer());
|
||||
TrophySignData.Config existing = data.signAt(level, pos).orElse(null);
|
||||
if (existing == null) {
|
||||
TrophySignData.Config draft = TrophySignData.Config.draft(level, pos, player.getUUID(),
|
||||
player.getGameProfile().name());
|
||||
if (!data.add(draft)) {
|
||||
message(player, data.writable() ? "registry_full" : "newer_data");
|
||||
return;
|
||||
}
|
||||
existing = draft;
|
||||
}
|
||||
writeBlankSign(level, sign);
|
||||
openEditor(player, existing);
|
||||
}
|
||||
|
||||
private static InteractionResult interact(ServerPlayer player, ServerLevel level, BlockPos pos,
|
||||
SignBlockEntity sign) {
|
||||
TrophySignData data = TrophySignData.get(level.getServer());
|
||||
TrophySignData.Config config = data.signAt(level, pos).orElse(null);
|
||||
if (config == null) {
|
||||
activatePlacedSign(player, level, pos, sign);
|
||||
return InteractionResult.SUCCESS_SERVER;
|
||||
}
|
||||
boolean canConfigure = TrophyPanelRules.canConfigure(config.ownerId(), player.getUUID(), isOperator(player));
|
||||
if (!config.configured() || player.isSecondaryUseActive()) {
|
||||
if (canConfigure) openEditor(player, config);
|
||||
else message(player, "not_owner");
|
||||
return InteractionResult.SUCCESS_SERVER;
|
||||
}
|
||||
int page = TrophyPanelRules.nextPage(config.currentPage(), config.pages().size());
|
||||
TrophySignData.Config advanced = config.withCurrentPage(page);
|
||||
if (!data.replace(advanced)) {
|
||||
message(player, "newer_data");
|
||||
return InteractionResult.CONSUME;
|
||||
}
|
||||
writeSign(level, sign, advanced);
|
||||
message(player, "page", advanced.currentPage() + 1, advanced.pages().size());
|
||||
return InteractionResult.SUCCESS_SERVER;
|
||||
}
|
||||
|
||||
public static void save(ServerPlayer player, SaveTrophySignPayload payload) {
|
||||
if (player.distanceToSqr(net.minecraft.world.phys.Vec3.atCenterOf(payload.pos())) > 64.0D) {
|
||||
message(player, "too_far");
|
||||
return;
|
||||
}
|
||||
ServerLevel level = player.level();
|
||||
if (!RedStonerRegistries.isTrophySign(level.getBlockState(payload.pos()).getBlock())
|
||||
|| !(level.getBlockEntity(payload.pos()) instanceof SignBlockEntity sign)) {
|
||||
message(player, "missing");
|
||||
return;
|
||||
}
|
||||
TrophySignData data = TrophySignData.get(level.getServer());
|
||||
TrophySignData.Config config = data.signAt(level, payload.pos()).orElse(null);
|
||||
if (config == null || !TrophyPanelRules.canConfigure(config.ownerId(), player.getUUID(), isOperator(player))) {
|
||||
message(player, "not_owner");
|
||||
return;
|
||||
}
|
||||
List<Identifier> pages = TrophyPanelRules.sanitizeMetricIds(payload.pages()).stream()
|
||||
.filter(SanctuaryRankingApi::isConfigurableMetric).toList();
|
||||
if (pages.isEmpty() || pages.size() != payload.pages().size()) {
|
||||
message(player, "invalid");
|
||||
return;
|
||||
}
|
||||
TrophySignData.Config configured = config.withConfiguration(pages,
|
||||
TrophyDisplayMode.byKey(payload.display()), config.ownerName());
|
||||
if (!data.replace(configured)) {
|
||||
message(player, "newer_data");
|
||||
return;
|
||||
}
|
||||
writeSign(level, sign, configured);
|
||||
message(player, "saved");
|
||||
}
|
||||
|
||||
public static boolean migrateLegacy(ServerLevel level, BlockPos pos, Direction facing, UUID owner,
|
||||
String ownerName, List<Identifier> requestedPages, int currentPage) {
|
||||
TrophySignData data = TrophySignData.get(level.getServer());
|
||||
if (!data.writable()) return false;
|
||||
UUID retainedOwner = owner == null ? new UUID(0L, 0L) : owner;
|
||||
TrophySignData.Config previous = data.signAt(level, pos).orElse(null);
|
||||
if (previous == null && data.signs().size() >= TrophySignData.MAX_SIGNS) return false;
|
||||
List<Identifier> pages = TrophyPanelRules.sanitizeMetricIds(requestedPages).stream()
|
||||
.filter(SanctuaryRankingApi::isConfigurableMetric).toList();
|
||||
if (pages.isEmpty()) pages = List.of(SanctuaryRankingApi.defaultMetric().id());
|
||||
var state = RedStonerRegistries.TROPHY_WALL_SIGN.defaultBlockState()
|
||||
.setValue(WallSignBlock.FACING, facing)
|
||||
.setValue(SignBlock.WATERLOGGED, false);
|
||||
if (!state.canSurvive(level, pos) || !level.setBlock(pos, state, Block.UPDATE_ALL)) return false;
|
||||
TrophySignData.Config migrated = new TrophySignData.Config(TrophySignData.dimension(level), pos.asLong(),
|
||||
retainedOwner.toString(), ownerName, pages, currentPage, TrophyDisplayMode.NAMES_AND_VALUES.key(), true);
|
||||
boolean stored = previous == null ? data.add(migrated) : data.replace(migrated);
|
||||
if (!stored) return false;
|
||||
if (level.getBlockEntity(pos) instanceof SignBlockEntity sign) writeSign(level, sign, migrated);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void openEditor(ServerPlayer player, TrophySignData.Config config) {
|
||||
if (!ServerPlayNetworking.canSend(player, OpenTrophySignEditorPayload.TYPE)) {
|
||||
message(player, "client_required");
|
||||
return;
|
||||
}
|
||||
ServerPlayNetworking.send(player, new OpenTrophySignEditorPayload(
|
||||
BlockPos.of(config.pos()), config.pages(), config.display()));
|
||||
}
|
||||
|
||||
private static void tick(MinecraftServer server) {
|
||||
if (++tickCounter < REFRESH_INTERVAL_TICKS) return;
|
||||
tickCounter = 0;
|
||||
TrophySignData data = TrophySignData.get(server);
|
||||
List<TrophySignData.Config> signs = data.signs();
|
||||
if (signs.isEmpty()) {
|
||||
refreshCursor = 0;
|
||||
return;
|
||||
}
|
||||
int inspections = Math.min(MAX_INSPECTIONS_PER_REFRESH, signs.size());
|
||||
for (int offset = 0; offset < inspections; offset++) {
|
||||
TrophySignData.Config config = signs.get(Math.floorMod(refreshCursor + offset, signs.size()));
|
||||
ServerLevel level = level(server, config.dimension());
|
||||
BlockPos pos = BlockPos.of(config.pos());
|
||||
if (level == null || !level.isLoaded(pos)) continue;
|
||||
if (!RedStonerRegistries.isTrophySign(level.getBlockState(pos).getBlock())
|
||||
|| !(level.getBlockEntity(pos) instanceof SignBlockEntity sign)) {
|
||||
data.remove(config);
|
||||
continue;
|
||||
}
|
||||
if (config.configured()) writeSign(level, sign, config);
|
||||
else writeBlankSign(level, sign);
|
||||
}
|
||||
refreshCursor = Math.floorMod(refreshCursor + inspections, Math.max(1, signs.size()));
|
||||
}
|
||||
|
||||
private static void writeBlankSign(ServerLevel level, SignBlockEntity sign) {
|
||||
writeText(level, sign, new SignText());
|
||||
}
|
||||
|
||||
private static void writeSign(ServerLevel level, SignBlockEntity sign, TrophySignData.Config config) {
|
||||
Identifier metricId = config.currentMetric();
|
||||
RankingSnapshot snapshot = SanctuaryRankingApi.snapshot(level.getServer(), metricId, config.ownerId());
|
||||
RankingMetric metric = snapshot.metric();
|
||||
RankingUnit unit = metric.unit();
|
||||
SignText text = new SignText().setMessage(0,
|
||||
Component.translatable("block.redstoner.trophy_sign.page_title",
|
||||
config.currentPage() + 1, config.pages().size(), SanctuaryRankingApi.displayName(metric))
|
||||
.withStyle(ChatFormatting.DARK_GRAY, ChatFormatting.BOLD));
|
||||
if (snapshot.podium().isEmpty()) {
|
||||
text = text.setMessage(1, Component.translatable("block.redstoner.trophy_sign.no_score")
|
||||
.withStyle(ChatFormatting.GRAY));
|
||||
} else {
|
||||
for (int index = 0; index < TrophyPanelRules.SIGN_ENTRIES_PER_PAGE
|
||||
&& index < snapshot.podium().size(); index++) {
|
||||
RankingSnapshot.Entry entry = snapshot.podium().get(index);
|
||||
text = text.setMessage(index + 1, rankingLine(config.displayMode(), entry, unit));
|
||||
}
|
||||
}
|
||||
writeText(level, sign, text);
|
||||
}
|
||||
|
||||
private static Component rankingLine(TrophyDisplayMode mode, RankingSnapshot.Entry entry, RankingUnit unit) {
|
||||
return switch (mode) {
|
||||
case NAMES_AND_VALUES -> Component.translatable("block.redstoner.trophy_sign.names_and_values",
|
||||
entry.rank(), entry.playerName(), unit.format(entry.value()));
|
||||
case NAMES -> Component.translatable("block.redstoner.trophy_sign.names",
|
||||
entry.rank(), entry.playerName());
|
||||
case VALUES -> Component.translatable("block.redstoner.trophy_sign.values",
|
||||
entry.rank(), unit.format(entry.value()));
|
||||
};
|
||||
}
|
||||
|
||||
private static void writeText(ServerLevel level, SignBlockEntity sign, SignText text) {
|
||||
sign.setText(text, true);
|
||||
sign.setText(text, false);
|
||||
sign.setWaxed(true);
|
||||
sign.setChanged();
|
||||
level.sendBlockUpdated(sign.getBlockPos(), sign.getBlockState(), sign.getBlockState(), 3);
|
||||
}
|
||||
|
||||
private static ServerLevel level(MinecraftServer server, String dimension) {
|
||||
for (ServerLevel level : server.getAllLevels()) {
|
||||
if (TrophySignData.dimension(level).equals(dimension)) return level;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean isOperator(ServerPlayer player) {
|
||||
return player.createCommandSourceStack().permissions().hasPermission(Permissions.COMMANDS_GAMEMASTER);
|
||||
}
|
||||
|
||||
private static void message(ServerPlayer player, String key, Object... args) {
|
||||
player.sendSystemMessage(Component.translatable("message.redstoner.trophy_sign." + key, args));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"variants": {
|
||||
"rotation=0": { "model": "redstoner:block/trophy_sign_rot_0" },
|
||||
"rotation=1": { "model": "redstoner:block/trophy_sign_rot_1" },
|
||||
"rotation=2": { "model": "redstoner:block/trophy_sign_rot_2" },
|
||||
"rotation=3": { "model": "redstoner:block/trophy_sign_rot_3" },
|
||||
"rotation=4": { "model": "redstoner:block/trophy_sign_rot_0", "y": 90 },
|
||||
"rotation=5": { "model": "redstoner:block/trophy_sign_rot_1", "y": 90 },
|
||||
"rotation=6": { "model": "redstoner:block/trophy_sign_rot_2", "y": 90 },
|
||||
"rotation=7": { "model": "redstoner:block/trophy_sign_rot_3", "y": 90 },
|
||||
"rotation=8": { "model": "redstoner:block/trophy_sign_rot_0", "y": 180 },
|
||||
"rotation=9": { "model": "redstoner:block/trophy_sign_rot_1", "y": 180 },
|
||||
"rotation=10": { "model": "redstoner:block/trophy_sign_rot_2", "y": 180 },
|
||||
"rotation=11": { "model": "redstoner:block/trophy_sign_rot_3", "y": 180 },
|
||||
"rotation=12": { "model": "redstoner:block/trophy_sign_rot_0", "y": 270 },
|
||||
"rotation=13": { "model": "redstoner:block/trophy_sign_rot_1", "y": 270 },
|
||||
"rotation=14": { "model": "redstoner:block/trophy_sign_rot_2", "y": 270 },
|
||||
"rotation=15": { "model": "redstoner:block/trophy_sign_rot_3", "y": 270 }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"variants": {
|
||||
"facing=east": { "model": "redstoner:block/trophy_wall_sign", "y": 270 },
|
||||
"facing=north": { "model": "redstoner:block/trophy_wall_sign", "y": 180 },
|
||||
"facing=south": { "model": "redstoner:block/trophy_wall_sign" },
|
||||
"facing=west": { "model": "redstoner:block/trophy_wall_sign", "y": 90 }
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "redstoner:block/trophy_panel"
|
||||
"model": "redstoner:item/trophy_sign"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,36 @@
|
||||
"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.",
|
||||
"block.redstoner.trophy_panel": "Trophy Panel",
|
||||
"block.redstoner.trophy_sign": "Trophy Sign",
|
||||
"block.redstoner.trophy_wall_sign": "Wall Trophy Sign",
|
||||
"block.redstoner.trophy_sign.page_title": "[%s/%s] %s",
|
||||
"block.redstoner.trophy_sign.names_and_values": "#%s %s · %s",
|
||||
"block.redstoner.trophy_sign.names": "#%s %s",
|
||||
"block.redstoner.trophy_sign.values": "#%s %s",
|
||||
"block.redstoner.trophy_sign.no_score": "No score yet",
|
||||
"screen.redstoner.trophy_sign.title": "Configure Trophy Sign",
|
||||
"screen.redstoner.trophy_sign.search": "Search for a statistic…",
|
||||
"screen.redstoner.trophy_sign.available": "Available statistics",
|
||||
"screen.redstoner.trophy_sign.pages": "Pages %s/%s",
|
||||
"screen.redstoner.trophy_sign.remove": "Remove",
|
||||
"screen.redstoner.trophy_sign.display": "Display: %s",
|
||||
"screen.redstoner.trophy_sign.display.names_and_values": "names and values",
|
||||
"screen.redstoner.trophy_sign.display.names": "names only",
|
||||
"screen.redstoner.trophy_sign.display.values": "values only",
|
||||
"message.redstoner.trophy_sign.not_owner": "Only the creator or an operator can configure this sign.",
|
||||
"message.redstoner.trophy_sign.protected": "Only the creator or an operator can break this sign.",
|
||||
"message.redstoner.trophy_sign.saved": "Trophy sign configured.",
|
||||
"message.redstoner.trophy_sign.page": "Page %s/%s",
|
||||
"message.redstoner.trophy_sign.invalid": "The configuration contains an invalid statistic.",
|
||||
"message.redstoner.trophy_sign.missing": "This trophy sign no longer exists.",
|
||||
"message.redstoner.trophy_sign.too_far": "You are too far away from this sign.",
|
||||
"message.redstoner.trophy_sign.client_required": "An up-to-date Red-Stoner client is required to configure this sign.",
|
||||
"message.redstoner.trophy_sign.registry_full": "This world has reached its trophy-sign limit.",
|
||||
"message.redstoner.trophy_sign.newer_data": "This sign data comes from a newer version and remains read-only.",
|
||||
"block.redstoner.trophy_panel.page_title": "[%s/%s] %s",
|
||||
"block.redstoner.trophy_panel.podium": "#%s %s · %s",
|
||||
"block.redstoner.trophy_panel.player": "#%s %s",
|
||||
"block.redstoner.trophy_panel.value": "#%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",
|
||||
|
||||
@@ -64,6 +64,36 @@
|
||||
"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é.",
|
||||
"block.redstoner.trophy_panel": "Panneau de trophées",
|
||||
"block.redstoner.trophy_sign": "Panneau de trophées",
|
||||
"block.redstoner.trophy_wall_sign": "Panneau mural de trophées",
|
||||
"block.redstoner.trophy_sign.page_title": "[%s/%s] %s",
|
||||
"block.redstoner.trophy_sign.names_and_values": "#%s %s · %s",
|
||||
"block.redstoner.trophy_sign.names": "#%s %s",
|
||||
"block.redstoner.trophy_sign.values": "#%s %s",
|
||||
"block.redstoner.trophy_sign.no_score": "Aucun score",
|
||||
"screen.redstoner.trophy_sign.title": "Configurer le panneau de trophées",
|
||||
"screen.redstoner.trophy_sign.search": "Rechercher une statistique…",
|
||||
"screen.redstoner.trophy_sign.available": "Statistiques disponibles",
|
||||
"screen.redstoner.trophy_sign.pages": "Pages %s/%s",
|
||||
"screen.redstoner.trophy_sign.remove": "Retirer",
|
||||
"screen.redstoner.trophy_sign.display": "Affichage : %s",
|
||||
"screen.redstoner.trophy_sign.display.names_and_values": "noms et valeurs",
|
||||
"screen.redstoner.trophy_sign.display.names": "noms seulement",
|
||||
"screen.redstoner.trophy_sign.display.values": "valeurs seulement",
|
||||
"message.redstoner.trophy_sign.not_owner": "Seul le créateur ou un opérateur peut configurer ce panneau.",
|
||||
"message.redstoner.trophy_sign.protected": "Seul le créateur ou un opérateur peut casser ce panneau.",
|
||||
"message.redstoner.trophy_sign.saved": "Panneau de trophées configuré.",
|
||||
"message.redstoner.trophy_sign.page": "Page %s/%s",
|
||||
"message.redstoner.trophy_sign.invalid": "La configuration contient une statistique invalide.",
|
||||
"message.redstoner.trophy_sign.missing": "Ce panneau de trophées n’existe plus.",
|
||||
"message.redstoner.trophy_sign.too_far": "Tu es trop loin de ce panneau.",
|
||||
"message.redstoner.trophy_sign.client_required": "Un client Red-Stoner à jour est requis pour configurer ce panneau.",
|
||||
"message.redstoner.trophy_sign.registry_full": "La limite de panneaux de trophées du monde est atteinte.",
|
||||
"message.redstoner.trophy_sign.newer_data": "Ces données de panneau proviennent d’une version plus récente et restent en lecture seule.",
|
||||
"block.redstoner.trophy_panel.page_title": "[%s/%s] %s",
|
||||
"block.redstoner.trophy_panel.podium": "#%s %s · %s",
|
||||
"block.redstoner.trophy_panel.player": "#%s %s",
|
||||
"block.redstoner.trophy_panel.value": "#%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",
|
||||
|
||||
@@ -64,6 +64,36 @@
|
||||
"screen.redstoner.storage_terminal.error.too_large": "Сеть слишком велика (не более 128 хранилищ).",
|
||||
"screen.redstoner.storage_terminal.error.locked": "В сети есть запертое хранилище.",
|
||||
"block.redstoner.trophy_panel": "Панель трофеев",
|
||||
"block.redstoner.trophy_sign": "Табличка трофеев",
|
||||
"block.redstoner.trophy_wall_sign": "Настенная табличка трофеев",
|
||||
"block.redstoner.trophy_sign.page_title": "[%s/%s] %s",
|
||||
"block.redstoner.trophy_sign.names_and_values": "#%s %s · %s",
|
||||
"block.redstoner.trophy_sign.names": "#%s %s",
|
||||
"block.redstoner.trophy_sign.values": "#%s %s",
|
||||
"block.redstoner.trophy_sign.no_score": "Результатов пока нет",
|
||||
"screen.redstoner.trophy_sign.title": "Настройка таблички трофеев",
|
||||
"screen.redstoner.trophy_sign.search": "Найти статистику…",
|
||||
"screen.redstoner.trophy_sign.available": "Доступная статистика",
|
||||
"screen.redstoner.trophy_sign.pages": "Страницы %s/%s",
|
||||
"screen.redstoner.trophy_sign.remove": "Удалить",
|
||||
"screen.redstoner.trophy_sign.display": "Отображение: %s",
|
||||
"screen.redstoner.trophy_sign.display.names_and_values": "имена и значения",
|
||||
"screen.redstoner.trophy_sign.display.names": "только имена",
|
||||
"screen.redstoner.trophy_sign.display.values": "только значения",
|
||||
"message.redstoner.trophy_sign.not_owner": "Настраивать эту табличку может только создатель или оператор.",
|
||||
"message.redstoner.trophy_sign.protected": "Сломать эту табличку может только создатель или оператор.",
|
||||
"message.redstoner.trophy_sign.saved": "Табличка трофеев настроена.",
|
||||
"message.redstoner.trophy_sign.page": "Страница %s/%s",
|
||||
"message.redstoner.trophy_sign.invalid": "Настройка содержит недопустимую статистику.",
|
||||
"message.redstoner.trophy_sign.missing": "Этой таблички трофеев больше нет.",
|
||||
"message.redstoner.trophy_sign.too_far": "Вы слишком далеко от этой таблички.",
|
||||
"message.redstoner.trophy_sign.client_required": "Для настройки нужен обновлённый клиент Red-Stoner.",
|
||||
"message.redstoner.trophy_sign.registry_full": "Достигнут предел табличек трофеев для этого мира.",
|
||||
"message.redstoner.trophy_sign.newer_data": "Данные таблички созданы более новой версией и доступны только для чтения.",
|
||||
"block.redstoner.trophy_panel.page_title": "[%s/%s] %s",
|
||||
"block.redstoner.trophy_panel.podium": "#%s %s · %s",
|
||||
"block.redstoner.trophy_panel.player": "#%s %s",
|
||||
"block.redstoner.trophy_panel.value": "#%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",
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
{
|
||||
"parent": "minecraft:block/block",
|
||||
"textures": {
|
||||
"particle": "minecraft:block/dark_oak_planks",
|
||||
"wood": "minecraft:block/dark_oak_planks",
|
||||
"frame": "minecraft:block/gold_block",
|
||||
"screen": "minecraft:block/black_concrete"
|
||||
"particle": "minecraft:block/oak_planks",
|
||||
"wood": "minecraft:block/oak_planks"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"from": [0, 0, 13],
|
||||
"from": [0, 0, 14],
|
||||
"to": [16, 16, 16],
|
||||
"faces": {
|
||||
"north": { "texture": "#wood" },
|
||||
@@ -18,31 +16,6 @@
|
||||
"up": { "texture": "#wood" },
|
||||
"down": { "texture": "#wood" }
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [1.5, 1.5, 12.5],
|
||||
"to": [14.5, 14.5, 13],
|
||||
"faces": { "north": { "texture": "#screen" } }
|
||||
},
|
||||
{
|
||||
"from": [0.5, 0.5, 12.25],
|
||||
"to": [15.5, 1.5, 13],
|
||||
"faces": { "north": { "texture": "#frame" } }
|
||||
},
|
||||
{
|
||||
"from": [0.5, 14.5, 12.25],
|
||||
"to": [15.5, 15.5, 13],
|
||||
"faces": { "north": { "texture": "#frame" } }
|
||||
},
|
||||
{
|
||||
"from": [0.5, 1.5, 12.25],
|
||||
"to": [1.5, 14.5, 13],
|
||||
"faces": { "north": { "texture": "#frame" } }
|
||||
},
|
||||
{
|
||||
"from": [14.5, 1.5, 12.25],
|
||||
"to": [15.5, 14.5, 13],
|
||||
"faces": { "north": { "texture": "#frame" } }
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"parent": "minecraft:block/template_sign_rot_0",
|
||||
"textures": {
|
||||
"all": "minecraft:block/pale_oak_sign",
|
||||
"particle": "minecraft:block/pale_oak_planks"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"parent": "minecraft:block/template_sign_rot_1",
|
||||
"textures": {
|
||||
"all": "minecraft:block/pale_oak_sign",
|
||||
"particle": "minecraft:block/pale_oak_planks"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"parent": "minecraft:block/template_sign_rot_2",
|
||||
"textures": {
|
||||
"all": "minecraft:block/pale_oak_sign",
|
||||
"particle": "minecraft:block/pale_oak_planks"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"parent": "minecraft:block/template_sign_rot_3",
|
||||
"textures": {
|
||||
"all": "minecraft:block/pale_oak_sign",
|
||||
"particle": "minecraft:block/pale_oak_planks"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"parent": "minecraft:block/template_wall_sign",
|
||||
"textures": {
|
||||
"all": "minecraft:block/pale_oak_sign",
|
||||
"particle": "minecraft:block/pale_oak_planks"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "minecraft:item/pale_oak_sign"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"replace": false,
|
||||
"values": ["redstoner:trophy_sign", "redstoner:trophy_wall_sign"]
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"replace": false,
|
||||
"values": ["redstoner:trophy_sign"]
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"replace": false,
|
||||
"values": ["redstoner:trophy_wall_sign"]
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"replace": false,
|
||||
"values": ["redstoner:trophy_panel"]
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"type": "minecraft:block",
|
||||
"pools": [
|
||||
{
|
||||
"conditions": [
|
||||
{ "condition": "minecraft:survives_explosion" }
|
||||
],
|
||||
"entries": [
|
||||
{ "type": "minecraft:item", "name": "redstoner:trophy_panel" }
|
||||
],
|
||||
"rolls": 1
|
||||
}
|
||||
],
|
||||
"random_sequence": "redstoner:blocks/trophy_sign"
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"type": "minecraft:block",
|
||||
"pools": [
|
||||
{
|
||||
"conditions": [
|
||||
{ "condition": "minecraft:survives_explosion" }
|
||||
],
|
||||
"entries": [
|
||||
{ "type": "minecraft:item", "name": "redstoner:trophy_panel" }
|
||||
],
|
||||
"rolls": 1
|
||||
}
|
||||
],
|
||||
"random_sequence": "redstoner:blocks/trophy_wall_sign"
|
||||
}
|
||||
@@ -1,17 +1,10 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"category": "redstone",
|
||||
"pattern": [
|
||||
"NGN",
|
||||
"GRG",
|
||||
"NSN"
|
||||
"type": "minecraft:crafting_shapeless",
|
||||
"category": "building",
|
||||
"ingredients": [
|
||||
"#minecraft:signs",
|
||||
"minecraft:white_dye"
|
||||
],
|
||||
"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
|
||||
|
||||
@@ -24,14 +24,14 @@
|
||||
"java": ">=25",
|
||||
"fabric-api": ">=0.154.2+26.2",
|
||||
"anotherworld": "*",
|
||||
"sanctuary": "*"
|
||||
"sanctuary": ">=0.0.0-alpha.139"
|
||||
},
|
||||
"custom": {
|
||||
"sanctuary26": {
|
||||
"system_type": "gameplay-system",
|
||||
"namespace": "redstoner",
|
||||
"data_version": 4,
|
||||
"network_protocol": 7,
|
||||
"data_version": 5,
|
||||
"network_protocol": 9,
|
||||
"lifecycle": "${lifecycle}",
|
||||
"pack_version": "${pack_version}",
|
||||
"descriptions": {
|
||||
|
||||
+10
@@ -27,6 +27,7 @@ public final class StorageTerminalSmoke {
|
||||
verifyPagination();
|
||||
verifyAggregationAndTransfers();
|
||||
verifySearch();
|
||||
verifySearchKeyboardRouting();
|
||||
verifySorting();
|
||||
verifyStableLayout();
|
||||
}
|
||||
@@ -145,6 +146,15 @@ public final class StorageTerminalSmoke {
|
||||
"Terminal search retained an unrelated item");
|
||||
}
|
||||
|
||||
private static void verifySearchKeyboardRouting() {
|
||||
require(StorageTerminalKeyRules.capturesInventoryKey(true, true),
|
||||
"The inventory key escaped the focused terminal search field");
|
||||
require(!StorageTerminalKeyRules.capturesInventoryKey(false, true),
|
||||
"The inventory key no longer closes an unfocused terminal");
|
||||
require(!StorageTerminalKeyRules.capturesInventoryKey(true, false),
|
||||
"The terminal captured an unrelated search-field key");
|
||||
}
|
||||
|
||||
private static Holder<Item> stackable(Item item) {
|
||||
return new Holder.Direct<>(item, DataComponentMap.builder()
|
||||
.set(DataComponents.MAX_STACK_SIZE, 64).build());
|
||||
|
||||
+25
@@ -15,6 +15,28 @@ public final class TrophyPanelRulesSmoke {
|
||||
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");
|
||||
TrophyPanelRules.DisplayPage values = TrophyPanelRules.displayPageByOffset(0, false, 2, 1);
|
||||
TrophyPanelRules.DisplayPage secondMetric = TrophyPanelRules.displayPageByOffset(
|
||||
values.metricPage(), values.valuesView(), 2, 1);
|
||||
TrophyPanelRules.DisplayPage wrapped = TrophyPanelRules.displayPageByOffset(0, false, 2, -1);
|
||||
require(values.metricPage() == 0 && values.valuesView()
|
||||
&& secondMetric.metricPage() == 1 && !secondMetric.valuesView()
|
||||
&& wrapped.metricPage() == 1 && wrapped.valuesView(),
|
||||
"Name and value views do not cycle as consecutive public pages");
|
||||
require(TrophyPanelRules.LINE_COUNT == 8 && TrophyPanelRules.ENTRIES_PER_VIEW == 7
|
||||
&& TrophyPanelRules.displayPageNumber(1, true, 2) == 4
|
||||
&& TrophyPanelRules.displayPageCount(2) == 4,
|
||||
"The panel does not use eight lines or number both metric views correctly");
|
||||
require(TrophyPanelRules.SIGN_LINE_COUNT == 4 && TrophyPanelRules.SIGN_ENTRIES_PER_PAGE == 3,
|
||||
"The vanilla trophy sign must reserve one title line and three ranking lines");
|
||||
require(TrophyDisplayMode.byKey("names") == TrophyDisplayMode.NAMES
|
||||
&& TrophyDisplayMode.NAMES.next() == TrophyDisplayMode.VALUES
|
||||
&& TrophyDisplayMode.byKey("invalid") == TrophyDisplayMode.NAMES_AND_VALUES,
|
||||
"Persisted trophy-sign display modes are not stable or safely defaulted");
|
||||
|
||||
Identifier first = Identifier.parse("sanctuary:first");
|
||||
Identifier second = Identifier.parse("sanctuary:second");
|
||||
@@ -25,6 +47,9 @@ public final class TrophyPanelRulesSmoke {
|
||||
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");
|
||||
List<Identifier> sanitized = TrophyPanelRules.sanitizeMetricIds(List.of(first, second, first));
|
||||
require(sanitized.equals(List.of(first, second)),
|
||||
"The trophy editor did not preserve page order while removing duplicates");
|
||||
}
|
||||
|
||||
private static void require(boolean condition, String message) {
|
||||
|
||||
@@ -35,6 +35,7 @@ réelle matérialisée reçoit un identifiant persistant : elle peut passer du r
|
||||
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
|
||||
@@ -75,9 +76,9 @@ numérotés de haut en bas afin qu’une chute fasse toujours avancer vers le ni
|
||||
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 l’esthétique,
|
||||
mais les portes des couloirs restent traversables. Les lits de sortie restent rares, mais chacun
|
||||
des cinq niveaux en génère exactement un par cellule de 10 × 10 chunks, sur un plancher praticable
|
||||
propre à sa zone. Il n’est donc plus nécessaire de remonter jusqu’aux Archives pour ressortir.
|
||||
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 n’est donc
|
||||
plus nécessaire de parcourir une centaine de chunks ou de remonter jusqu’aux 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
|
||||
|
||||
+85
-14
@@ -124,6 +124,22 @@ tasks.register("capeSyncPayloadSmoke", JavaExec) {
|
||||
mainClass = "fr.koka99cab.sanctuary26.sanctuary.network.CapeSyncPayloadSmoke"
|
||||
}
|
||||
|
||||
tasks.register("capeModelSmoke", JavaExec) {
|
||||
group = "verification"
|
||||
description = "Checks the double-sided shield-pattern plane used by banner capes."
|
||||
dependsOn tasks.named("testClasses")
|
||||
classpath = sourceSets.test.runtimeClasspath
|
||||
mainClass = "fr.koka99cab.sanctuary26.sanctuary.client.SanctuaryBannerCapeModelSmoke"
|
||||
}
|
||||
|
||||
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."
|
||||
@@ -199,7 +215,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.135"
|
||||
if (project.version.toString() != "0.0.0-alpha.139"
|
||||
|| !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")
|
||||
@@ -2915,7 +2931,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.135"
|
||||
if (project.version.toString() != "0.0.0-alpha.139"
|
||||
|| 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
|
||||
@@ -3081,7 +3097,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.135"
|
||||
if (project.version.toString() != "0.0.0-alpha.139"
|
||||
|| 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
|
||||
@@ -3119,7 +3135,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.135"
|
||||
if (project.version.toString() != "0.0.0-alpha.139"
|
||||
|| 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]
|
||||
@@ -3150,7 +3166,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.135"
|
||||
if (project.version.toString() != "0.0.0-alpha.139"
|
||||
|| migration.target?.pack_version != "26.2.0-alpha.195"
|
||||
|| migration.target?.modules?.sanctuary != "0.0.0-alpha.111"
|
||||
|| migration.compatibility?.sanctuary_data_version != 11
|
||||
@@ -3181,7 +3197,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.135"
|
||||
if (project.version.toString() != "0.0.0-alpha.139"
|
||||
|| migration.target?.modules?.sanctuary != "0.0.0-alpha.112"
|
||||
|| migration.mailbox?.id != "sanctuary:delivery_box"
|
||||
|| migration.mailbox?.horizontal_facing != true
|
||||
@@ -3209,7 +3225,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.135"
|
||||
if (project.version.toString() != "0.0.0-alpha.139"
|
||||
|| !transfer.contains("shouldAppendOverflow")
|
||||
|| !transfer.contains("isVanillaStorageRange")
|
||||
|| !transfer.contains("hotbarStart")
|
||||
@@ -3255,7 +3271,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.135"
|
||||
if (project.version.toString() != "0.0.0-alpha.139"
|
||||
|| migration.target?.modules?.sanctuary != "0.0.0-alpha.113"
|
||||
|| migration.quest_requests?.save_key != "quest_requests"
|
||||
|| migration.quest_requests?.data_version != 1
|
||||
@@ -3317,7 +3333,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.135"
|
||||
if (project.version.toString() != "0.0.0-alpha.139"
|
||||
|| 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"
|
||||
@@ -3386,7 +3402,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.135"
|
||||
if (project.version.toString() != "0.0.0-alpha.139"
|
||||
|| 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"
|
||||
@@ -3465,7 +3481,7 @@ tasks.register("verifyCraftableBannerCape") {
|
||||
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.135"
|
||||
if (project.version.toString() != "0.0.0-alpha.139"
|
||||
|| migration.target?.modules?.sanctuary != "0.0.0-alpha.130"
|
||||
|| migration.white_cape?.crafting_material_count != 6
|
||||
|| migration.white_cape?.maximum_pattern_layers != 6
|
||||
@@ -3493,6 +3509,57 @@ 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.139"
|
||||
|| !capeRenderer.contains("SHIELD_FACE_WIDTH = 12.0F")
|
||||
|| !capeRenderer.contains("SHIELD_FACE_HEIGHT = 22.0F")
|
||||
|| !capeRenderer.contains("CAPE_WIDTH / SHIELD_FACE_WIDTH")
|
||||
|| !capeRenderer.contains("CAPE_HEIGHT / SHIELD_FACE_HEIGHT")
|
||||
|| !capeRenderer.contains('addOrReplaceChild("front"')
|
||||
|| !capeRenderer.contains('addOrReplaceChild("back"')
|
||||
|| !capeRenderer.contains("Set.of(Direction.NORTH)")
|
||||
|| !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."
|
||||
@@ -3520,7 +3587,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.135"
|
||||
if (project.version.toString() != "0.0.0-alpha.139"
|
||||
|| migration.target?.modules?.sanctuary != "0.0.0-alpha.122"
|
||||
|| migration.alpha_world?.dimension != "sanctuary:alpha"
|
||||
|| migration.alpha_world?.legacy_dimension != "portals:alpha"
|
||||
@@ -3580,7 +3647,7 @@ tasks.register("verifyBackroom") {
|
||||
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.135"
|
||||
if (project.version.toString() != "0.0.0-alpha.139"
|
||||
|| 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"
|
||||
@@ -3606,10 +3673,12 @@ tasks.register("verifyBackroom") {
|
||||
|| !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("EXIT_BED_CELL_SIZE_CHUNKS = 10")
|
||||
|| !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")
|
||||
@@ -3640,6 +3709,8 @@ tasks.named("check") {
|
||||
dependsOn tasks.named("alphaIndevGeneratorSmoke")
|
||||
dependsOn tasks.named("capeJoinSyncSmoke")
|
||||
dependsOn tasks.named("capeSyncPayloadSmoke")
|
||||
dependsOn tasks.named("capeModelSmoke")
|
||||
dependsOn tasks.named("chickenArmorSmoke")
|
||||
dependsOn tasks.named("inventorySortSmoke")
|
||||
dependsOn tasks.named("entityPolicySmoke")
|
||||
dependsOn tasks.named("verifyAlphaIndev")
|
||||
|
||||
+2
-2
@@ -4,9 +4,9 @@ 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. */
|
||||
/** Server snapshot intentionally bounded to one visible metric and seven panel rows. */
|
||||
public record RankingSnapshot(RankingMetric metric, List<Entry> podium, Placement owner) {
|
||||
public static final int MAX_PODIUM_SIZE = 3;
|
||||
public static final int MAX_PODIUM_SIZE = 7;
|
||||
|
||||
public RankingSnapshot {
|
||||
podium = podium == null ? List.of() : List.copyOf(podium.stream().limit(MAX_PODIUM_SIZE).toList());
|
||||
|
||||
+29
-2
@@ -8,6 +8,7 @@ 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.network.chat.Component;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -29,8 +30,11 @@ public final class SanctuaryRankingApi {
|
||||
if (initialized) return;
|
||||
initialized = true;
|
||||
register(DEFAULT_METRIC);
|
||||
ServerLifecycleEvents.SERVER_STARTED.register(server ->
|
||||
SanctuaryRankingData.get(server).importVanillaStats(server));
|
||||
ServerLifecycleEvents.SERVER_STARTED.register(server -> {
|
||||
SanctuaryRankingData data = SanctuaryRankingData.get(server);
|
||||
data.importVanillaStats(server);
|
||||
data.resolveCachedNames(server);
|
||||
});
|
||||
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
|
||||
SanctuaryRankingData data = SanctuaryRankingData.get(server);
|
||||
data.updateName(handler.player.getUUID(), handler.player.getGameProfile().name());
|
||||
@@ -66,6 +70,29 @@ public final class SanctuaryRankingApi {
|
||||
return metrics;
|
||||
}
|
||||
|
||||
/**
|
||||
* Complete client-safe catalog used by configuration screens. The catalog is rebuilt from
|
||||
* synchronized vanilla registries, so it never has to be transferred in one large payload.
|
||||
*/
|
||||
public static List<RankingMetric> configurableMetrics() {
|
||||
return VanillaRankingMetric.configurableMetrics(METRICS.values());
|
||||
}
|
||||
|
||||
/** True when a submitted identifier resolves to a registered or existing vanilla statistic. */
|
||||
public static boolean isConfigurableMetric(Identifier id) {
|
||||
return id != null && (METRICS.containsKey(id) || VanillaRankingMetric.isAvailable(id));
|
||||
}
|
||||
|
||||
/** Localized label for a metric configured from its representative item. */
|
||||
public static Component displayName(RankingMetric metric, ItemStack icon) {
|
||||
return VanillaRankingMetric.displayName(metric, icon);
|
||||
}
|
||||
|
||||
/** Localized label resolved directly from the metric target, without requiring a representative item. */
|
||||
public static Component displayName(RankingMetric metric) {
|
||||
return VanillaRankingMetric.displayName(metric, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
public static boolean eligible(ServerPlayer player) {
|
||||
return isRealOnlinePlayer(player) && !player.isCreative() && !player.isSpectator();
|
||||
}
|
||||
|
||||
+34
-5
@@ -200,7 +200,7 @@ final class SanctuaryRankingData extends SavedData {
|
||||
if (Files.isDirectory(statsDirectory)) {
|
||||
try (Stream<Path> files = Files.list(statsDirectory)) {
|
||||
files.filter(path -> path.getFileName().toString().endsWith(".json"))
|
||||
.sorted().forEach(this::importVanillaFile);
|
||||
.sorted().forEach(path -> importVanillaFile(server, path));
|
||||
} catch (IOException exception) {
|
||||
SanctuaryMod.LOGGER.warn("[{}] Could not import existing vanilla statistics.",
|
||||
SanctuaryMod.DISPLAY_NAME, exception);
|
||||
@@ -212,6 +212,10 @@ final class SanctuaryRankingData extends SavedData {
|
||||
}
|
||||
|
||||
void importVanillaFile(Path file) {
|
||||
importVanillaFile(null, file);
|
||||
}
|
||||
|
||||
private void importVanillaFile(MinecraftServer server, Path file) {
|
||||
String fileName = file.getFileName().toString();
|
||||
String idText = fileName.substring(0, fileName.length() - ".json".length());
|
||||
UUID playerId;
|
||||
@@ -221,6 +225,7 @@ final class SanctuaryRankingData extends SavedData {
|
||||
return;
|
||||
}
|
||||
try (Reader reader = Files.newBufferedReader(file, StandardCharsets.UTF_8)) {
|
||||
String resolvedName = cachedName(server, playerId);
|
||||
JsonObject root = JsonParser.parseReader(reader).getAsJsonObject();
|
||||
JsonObject stats = root.has("stats") && root.get("stats").isJsonObject()
|
||||
? root.getAsJsonObject("stats") : new JsonObject();
|
||||
@@ -233,8 +238,8 @@ final class SanctuaryRankingData extends SavedData {
|
||||
|| !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);
|
||||
recordValue(playerId, resolvedName, metricId, value);
|
||||
observeVanilla(playerId, resolvedName, metricId, value, false);
|
||||
}
|
||||
}
|
||||
} catch (RuntimeException | IOException exception) {
|
||||
@@ -243,6 +248,21 @@ final class SanctuaryRankingData extends SavedData {
|
||||
}
|
||||
}
|
||||
|
||||
/** Repairs the old eight-character UUID placeholders from the server's local profile cache. */
|
||||
void resolveCachedNames(MinecraftServer server) {
|
||||
if (!writable() || server == null) return;
|
||||
boolean changed = false;
|
||||
for (Map.Entry<String, Profile> entry : new ArrayList<>(players.entrySet())) {
|
||||
UUID playerId = UUID.fromString(entry.getKey());
|
||||
Profile profile = entry.getValue();
|
||||
if (!isUuidFallback(profile.lastName(), playerId)) continue;
|
||||
String resolved = cachedName(server, playerId);
|
||||
players.put(entry.getKey(), new Profile(resolved, profile.metrics(), profile.vanillaObserved()));
|
||||
changed = true;
|
||||
}
|
||||
if (changed) setDirty();
|
||||
}
|
||||
|
||||
private long takeReachedOrder() {
|
||||
long current = nextReachedOrder;
|
||||
if (nextReachedOrder < Long.MAX_VALUE) nextReachedOrder++;
|
||||
@@ -269,8 +289,17 @@ final class SanctuaryRankingData extends SavedData {
|
||||
return clean.length() > 32 ? clean.substring(0, 32) : clean;
|
||||
}
|
||||
|
||||
private static String shortFallbackName(UUID playerId) {
|
||||
return playerId.toString().substring(0, 8);
|
||||
private static String cachedName(MinecraftServer server, UUID playerId) {
|
||||
if (server == null) return "?";
|
||||
return server.services().nameToIdCache().get(playerId)
|
||||
.map(profile -> cleanName(profile.name())).orElse("?");
|
||||
}
|
||||
|
||||
private static boolean isUuidFallback(String name, UUID playerId) {
|
||||
if (name == null || name.isBlank() || name.equals("?")) return true;
|
||||
String uuid = playerId.toString();
|
||||
return (name.length() == 8 || name.length() == 32)
|
||||
&& uuid.regionMatches(true, 0, name, 0, name.length());
|
||||
}
|
||||
|
||||
record Score(long value, long reachedOrder) {
|
||||
|
||||
+100
-2
@@ -2,21 +2,37 @@ package fr.koka99cab.sanctuary26.sanctuary.api.ranking;
|
||||
|
||||
import fr.koka99cab.sanctuary26.sanctuary.SanctuaryMod;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
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;
|
||||
import net.minecraft.world.item.SpawnEggItem;
|
||||
|
||||
/** 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 static final List<String> ENTITY_FAMILIES = List.of("killed", "killed_by");
|
||||
private static final List<Identifier> TIME_STATISTICS = List.of(
|
||||
Stats.PLAY_TIME, Stats.TOTAL_WORLD_TIME, Stats.TIME_SINCE_DEATH,
|
||||
Stats.TIME_SINCE_REST, Stats.CROUCH_TIME);
|
||||
private static final List<Identifier> DISTANCE_STATISTICS = List.of(
|
||||
Stats.WALK_ONE_CM, Stats.CROUCH_ONE_CM, Stats.SPRINT_ONE_CM,
|
||||
Stats.WALK_ON_WATER_ONE_CM, Stats.FALL_ONE_CM, Stats.CLIMB_ONE_CM,
|
||||
Stats.FLY_ONE_CM, Stats.WALK_UNDER_WATER_ONE_CM, Stats.MINECART_ONE_CM,
|
||||
Stats.BOAT_ONE_CM, Stats.PIG_ONE_CM, Stats.HAPPY_GHAST_ONE_CM,
|
||||
Stats.HORSE_ONE_CM, Stats.AVIATE_ONE_CM, Stats.SWIM_ONE_CM,
|
||||
Stats.STRIDER_ONE_CM, Stats.NAUTILUS_ONE_CM);
|
||||
|
||||
private VanillaRankingMetric() {}
|
||||
|
||||
@@ -34,15 +50,56 @@ final class VanillaRankingMetric {
|
||||
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;
|
||||
boolean custom = source.type().getPath().equals("custom");
|
||||
boolean playTime = custom && source.target().equals(Stats.PLAY_TIME);
|
||||
RankingUnit unit = custom && TIME_STATISTICS.contains(source.target()) ? RankingUnit.TICKS
|
||||
: custom && DISTANCE_STATISTICS.contains(source.target()) ? RankingUnit.CENTIMETERS
|
||||
: RankingUnit.COUNT;
|
||||
return new RankingMetric(id, "metric.sanctuary.ranking."
|
||||
+ (playTime ? "play_time" : source.type().getPath()), unit);
|
||||
}
|
||||
|
||||
static List<RankingMetric> configurableMetrics(Collection<RankingMetric> registered) {
|
||||
Map<Identifier, RankingMetric> metrics = new LinkedHashMap<>();
|
||||
if (registered != null) registered.forEach(metric -> metrics.put(metric.id(), metric));
|
||||
for (Identifier target : BuiltInRegistries.CUSTOM_STAT) {
|
||||
RankingMetric metric = descriptor(id(Identifier.withDefaultNamespace("custom"), target));
|
||||
metrics.putIfAbsent(metric.id(), metric);
|
||||
}
|
||||
for (BlockItem blockItem : BuiltInRegistries.ITEM.stream()
|
||||
.filter(BlockItem.class::isInstance).map(BlockItem.class::cast).toList()) {
|
||||
Identifier target = BuiltInRegistries.BLOCK.getKey(blockItem.getBlock());
|
||||
RankingMetric metric = descriptor(id(Identifier.withDefaultNamespace("mined"), target));
|
||||
metrics.putIfAbsent(metric.id(), metric);
|
||||
}
|
||||
for (Item item : BuiltInRegistries.ITEM) {
|
||||
Identifier target = BuiltInRegistries.ITEM.getKey(item);
|
||||
for (String family : ITEM_FAMILIES) {
|
||||
if (family.equals("mined")) continue;
|
||||
RankingMetric metric = descriptor(id(Identifier.withDefaultNamespace(family), target));
|
||||
metrics.putIfAbsent(metric.id(), metric);
|
||||
}
|
||||
}
|
||||
for (var entityType : BuiltInRegistries.ENTITY_TYPE) {
|
||||
Identifier target = BuiltInRegistries.ENTITY_TYPE.getKey(entityType);
|
||||
for (String family : ENTITY_FAMILIES) {
|
||||
RankingMetric metric = descriptor(id(Identifier.withDefaultNamespace(family), target));
|
||||
metrics.putIfAbsent(metric.id(), metric);
|
||||
}
|
||||
}
|
||||
return List.copyOf(metrics.values());
|
||||
}
|
||||
|
||||
static List<RankingMetric> itemMetrics(ItemStack icon) {
|
||||
if (icon == null || icon.isEmpty()) return List.of();
|
||||
Item item = icon.getItem();
|
||||
if (item instanceof SpawnEggItem) {
|
||||
var entityType = SpawnEggItem.getType(icon);
|
||||
if (entityType == null) return List.of();
|
||||
Identifier entityId = BuiltInRegistries.ENTITY_TYPE.getKey(entityType);
|
||||
return List.of(new RankingMetric(id(Identifier.withDefaultNamespace("killed"), entityId),
|
||||
"metric.sanctuary.ranking.killed", RankingUnit.COUNT));
|
||||
}
|
||||
Identifier itemId = BuiltInRegistries.ITEM.getKey(item);
|
||||
List<RankingMetric> metrics = new ArrayList<>();
|
||||
for (String family : ITEM_FAMILIES) {
|
||||
@@ -53,6 +110,39 @@ final class VanillaRankingMetric {
|
||||
return List.copyOf(metrics);
|
||||
}
|
||||
|
||||
static Component displayName(RankingMetric metric, ItemStack icon) {
|
||||
Source source = parse(metric.id()).orElse(null);
|
||||
if (source == null) return Component.translatable(metric.translationKey());
|
||||
String family = source.type().getPath();
|
||||
if (family.equals("custom")) {
|
||||
return source.target().equals(Stats.PLAY_TIME)
|
||||
? Component.translatable(metric.translationKey())
|
||||
: Component.translatable(source.target().toLanguageKey("stat"));
|
||||
}
|
||||
Component target = switch (family) {
|
||||
case "mined" -> BuiltInRegistries.BLOCK.getOptional(source.target())
|
||||
.<Component>map(block -> block.getName()).orElseGet(() -> iconName(icon));
|
||||
case "killed", "killed_by" -> BuiltInRegistries.ENTITY_TYPE.getOptional(source.target())
|
||||
.<Component>map(type -> type.getDescription()).orElseGet(() -> iconName(icon));
|
||||
default -> BuiltInRegistries.ITEM.getOptional(source.target())
|
||||
.<Component>map(item -> new ItemStack(item).getHoverName()).orElseGet(() -> iconName(icon));
|
||||
};
|
||||
return Component.translatable(metric.translationKey(), target);
|
||||
}
|
||||
|
||||
static boolean isAvailable(Identifier metricId) {
|
||||
Source source = parse(metricId).orElse(null);
|
||||
if (source == null) return false;
|
||||
return switch (source.type().getPath()) {
|
||||
case "custom" -> BuiltInRegistries.CUSTOM_STAT.getOptional(source.target()).isPresent();
|
||||
case "mined" -> BuiltInRegistries.BLOCK.getOptional(source.target()).isPresent();
|
||||
case "crafted", "used", "broken", "picked_up", "dropped" ->
|
||||
BuiltInRegistries.ITEM.getOptional(source.target()).isPresent();
|
||||
case "killed", "killed_by" -> BuiltInRegistries.ENTITY_TYPE.getOptional(source.target()).isPresent();
|
||||
default -> false;
|
||||
};
|
||||
}
|
||||
|
||||
static Optional<Source> parse(Identifier metricId) {
|
||||
if (!metricId.getNamespace().equals(SanctuaryMod.MOD_ID)
|
||||
|| !metricId.getPath().startsWith(PREFIX)) return Optional.empty();
|
||||
@@ -79,10 +169,18 @@ final class VanillaRankingMetric {
|
||||
.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 "killed" -> BuiltInRegistries.ENTITY_TYPE.getOptional(target)
|
||||
.map(type -> (long) player.getStats().getValue(Stats.ENTITY_KILLED, type)).orElse(0L);
|
||||
case "killed_by" -> BuiltInRegistries.ENTITY_TYPE.getOptional(target)
|
||||
.map(type -> (long) player.getStats().getValue(Stats.ENTITY_KILLED_BY, type)).orElse(0L);
|
||||
case "custom" -> (long) player.getStats().getValue(Stats.CUSTOM, target);
|
||||
default -> 0L;
|
||||
};
|
||||
}
|
||||
|
||||
private static Component iconName(ItemStack icon) {
|
||||
return icon == null || icon.isEmpty() ? Component.literal("?") : icon.getHoverName();
|
||||
}
|
||||
|
||||
record Source(Identifier type, Identifier target) {}
|
||||
}
|
||||
|
||||
+22
-6
@@ -2,6 +2,7 @@ package fr.koka99cab.sanctuary26.sanctuary.client;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import fr.koka99cab.sanctuary26.sanctuary.SanctuaryMod;
|
||||
import java.util.Set;
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.LivingEntityRenderLayerRegistrationCallback;
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.ModelLayerRegistry;
|
||||
import net.minecraft.client.model.geom.ModelLayerLocation;
|
||||
@@ -23,6 +24,7 @@ import net.minecraft.client.renderer.entity.state.AvatarRenderState;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.client.resources.model.EquipmentAssetManager;
|
||||
import net.minecraft.client.resources.model.EquipmentClientInfo;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.world.entity.EntityTypes;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -30,6 +32,10 @@ import net.minecraft.world.item.equipment.Equippable;
|
||||
|
||||
/** Renders a banner-decorated cape with vanilla cape physics and banner pattern sprites. */
|
||||
public final class SanctuaryBannerCapeLayer extends RenderLayer<AvatarRenderState, PlayerModel> {
|
||||
private static final float SHIELD_FACE_WIDTH = 12.0F;
|
||||
private static final float SHIELD_FACE_HEIGHT = 22.0F;
|
||||
private static final float CAPE_WIDTH = 10.0F;
|
||||
private static final float CAPE_HEIGHT = 16.0F;
|
||||
private static final ModelLayerLocation MODEL_LAYER =
|
||||
new ModelLayerLocation(SanctuaryMod.id("banner_cape"), "main");
|
||||
private final PlayerCapeModel model;
|
||||
@@ -61,17 +67,27 @@ public final class SanctuaryBannerCapeLayer extends RenderLayer<AvatarRenderStat
|
||||
helper.register(new SanctuaryBannerCapeLayer(parent, context));
|
||||
}
|
||||
|
||||
private static LayerDefinition createLayer() {
|
||||
static LayerDefinition createLayer() {
|
||||
MeshDefinition mesh = PlayerModel.createMesh(CubeDeformation.NONE, false);
|
||||
PartDefinition root = mesh.getRoot().clearRecursively();
|
||||
PartDefinition body = root.getChild("body");
|
||||
body.addOrReplaceChild("cape", CubeListBuilder.create().texOffs(0, 0)
|
||||
.addBox(-5.0F, 0.0F, -1.0F, 10.0F, 16.0F, 1.0F,
|
||||
CubeDeformation.NONE, 2.0F, 2.5F),
|
||||
PartPose.offsetAndRotation(0.0F, 0.0F, 2.0F, 0.0F, (float) Math.PI, 0.0F));
|
||||
PartDefinition cape = body.addOrReplaceChild("cape", CubeListBuilder.create(),
|
||||
PartPose.offsetAndRotation(0.0F, 0.0F, 2.0F, 0.0F, (float) Math.PI, 0.0F)
|
||||
.scaled(CAPE_WIDTH / SHIELD_FACE_WIDTH, CAPE_HEIGHT / SHIELD_FACE_HEIGHT, 1.0F));
|
||||
cape.addOrReplaceChild("front", shieldPatternFace(), PartPose.offset(0.0F, 0.0F, -1.0F));
|
||||
cape.addOrReplaceChild("back", shieldPatternFace(),
|
||||
PartPose.offsetAndRotation(0.0F, 0.0F, -1.0F, 0.0F, (float) Math.PI, 0.0F));
|
||||
return LayerDefinition.create(mesh, 64, 64);
|
||||
}
|
||||
|
||||
private static CubeListBuilder shieldPatternFace() {
|
||||
// Shield patterns paint this exact 12x22 UV island. Two opposed planes keep
|
||||
// the cloth visible from both sides without rendering the shield thickness or handle.
|
||||
return CubeListBuilder.create().texOffs(1, 1)
|
||||
.addBox(-6.0F, 0.0F, 0.0F, SHIELD_FACE_WIDTH, SHIELD_FACE_HEIGHT, 0.0F,
|
||||
Set.of(Direction.NORTH));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submit(PoseStack poseStack, SubmitNodeCollector collector, int packedLight,
|
||||
AvatarRenderState state, float yRot, float xRot) {
|
||||
@@ -85,7 +101,7 @@ public final class SanctuaryBannerCapeLayer extends RenderLayer<AvatarRenderStat
|
||||
poseStack.translate(0.0F, -0.053125F, 0.06875F);
|
||||
}
|
||||
BannerRenderer.submitPatterns(context.getSprites(), poseStack, collector, packedLight,
|
||||
OverlayTexture.NO_OVERLAY, model, state, true, appearance.baseColor(),
|
||||
OverlayTexture.NO_OVERLAY, model, state, false, appearance.baseColor(),
|
||||
appearance.patterns(), null);
|
||||
poseStack.popPose();
|
||||
}
|
||||
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
package fr.koka99cab.sanctuary26.sanctuary.client;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import fr.koka99cab.sanctuary26.sanctuary.SanctuaryMod;
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.LivingEntityRenderLayerRegistrationCallback;
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.ModelLayerRegistry;
|
||||
import net.minecraft.client.model.animal.chicken.ChickenModel;
|
||||
import net.minecraft.client.model.geom.ModelLayerLocation;
|
||||
import net.minecraft.client.renderer.SubmitNodeCollector;
|
||||
import net.minecraft.client.renderer.entity.ChickenRenderer;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||
import net.minecraft.client.renderer.entity.RenderLayerParent;
|
||||
import net.minecraft.client.renderer.entity.layers.EquipmentLayerRenderer;
|
||||
import net.minecraft.client.renderer.entity.layers.RenderLayer;
|
||||
import net.minecraft.client.renderer.entity.state.ChickenRenderState;
|
||||
import net.minecraft.client.resources.model.EquipmentClientInfo;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.world.entity.EntityTypes;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.equipment.Equippable;
|
||||
|
||||
/** Renders vanilla armadillo-scute equipment around an adult chicken's torso. */
|
||||
public final class SanctuaryChickenArmorLayer extends RenderLayer<ChickenRenderState, ChickenModel> {
|
||||
private static final ModelLayerLocation MODEL_LAYER =
|
||||
new ModelLayerLocation(SanctuaryMod.id("chicken_armor"), "main");
|
||||
private final SanctuaryChickenArmorModel model;
|
||||
private final EquipmentLayerRenderer equipmentRenderer;
|
||||
|
||||
private SanctuaryChickenArmorLayer(RenderLayerParent<ChickenRenderState, ChickenModel> parent,
|
||||
EntityRendererProvider.Context context) {
|
||||
super(parent);
|
||||
model = SanctuaryChickenArmorModel.bake(context.bakeLayer(MODEL_LAYER));
|
||||
equipmentRenderer = context.getEquipmentRenderer();
|
||||
}
|
||||
|
||||
public static void initialize() {
|
||||
ModelLayerRegistry.registerModelLayer(MODEL_LAYER, SanctuaryChickenArmorModel::createLayer);
|
||||
LivingEntityRenderLayerRegistrationCallback.EVENT.register((entityType, renderer, helper, context) -> {
|
||||
if (entityType == EntityTypes.CHICKEN && renderer instanceof ChickenRenderer chickenRenderer) {
|
||||
register(helper, chickenRenderer, context);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
private static void register(LivingEntityRenderLayerRegistrationCallback.RegistrationHelper helper,
|
||||
ChickenRenderer renderer, EntityRendererProvider.Context context) {
|
||||
RenderLayerParent<ChickenRenderState, ChickenModel> parent =
|
||||
(RenderLayerParent<ChickenRenderState, ChickenModel>) (RenderLayerParent) renderer;
|
||||
helper.register(new SanctuaryChickenArmorLayer(parent, context));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submit(PoseStack poseStack, SubmitNodeCollector collector, int packedLight,
|
||||
ChickenRenderState state, float yRot, float xRot) {
|
||||
if (state.isBaby || state.isInvisibleToPlayer) return;
|
||||
ItemStack armor = ((SanctuaryChickenArmorRenderState) state).sanctuary$chickenArmor();
|
||||
Equippable equippable = armor.get(DataComponents.EQUIPPABLE);
|
||||
if (equippable == null || equippable.assetId().isEmpty()) return;
|
||||
equipmentRenderer.renderLayers(EquipmentClientInfo.LayerType.WOLF_BODY,
|
||||
equippable.assetId().get(), model, state, armor, poseStack, collector,
|
||||
packedLight, state.outlineColor);
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package fr.koka99cab.sanctuary26.sanctuary.client;
|
||||
|
||||
import net.minecraft.client.model.EntityModel;
|
||||
import net.minecraft.client.model.geom.ModelPart;
|
||||
import net.minecraft.client.model.geom.PartPose;
|
||||
import net.minecraft.client.model.geom.builders.CubeDeformation;
|
||||
import net.minecraft.client.model.geom.builders.CubeListBuilder;
|
||||
import net.minecraft.client.model.geom.builders.LayerDefinition;
|
||||
import net.minecraft.client.model.geom.builders.MeshDefinition;
|
||||
import net.minecraft.client.renderer.entity.state.ChickenRenderState;
|
||||
|
||||
/** A thin torso shell using the vanilla armadillo-scute equipment UVs. */
|
||||
public final class SanctuaryChickenArmorModel extends EntityModel<ChickenRenderState> {
|
||||
private SanctuaryChickenArmorModel(ModelPart root) {
|
||||
super(root);
|
||||
}
|
||||
|
||||
public static SanctuaryChickenArmorModel bake(ModelPart root) {
|
||||
return new SanctuaryChickenArmorModel(root);
|
||||
}
|
||||
|
||||
public static LayerDefinition createLayer() {
|
||||
MeshDefinition mesh = new MeshDefinition();
|
||||
mesh.getRoot().addOrReplaceChild("body",
|
||||
CubeListBuilder.create().texOffs(18, 14)
|
||||
.addBox(-3.0F, -4.0F, -3.0F, 6.0F, 8.0F, 6.0F,
|
||||
new CubeDeformation(0.45F)),
|
||||
PartPose.offsetAndRotation(0.0F, 16.0F, 0.0F,
|
||||
(float) (Math.PI / 2.0D), 0.0F, 0.0F));
|
||||
return LayerDefinition.create(mesh, 64, 32);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package fr.koka99cab.sanctuary26.sanctuary.client;
|
||||
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
/** Mixin-backed bridge carrying chicken body armor into the extracted render state. */
|
||||
public interface SanctuaryChickenArmorRenderState {
|
||||
ItemStack sanctuary$chickenArmor();
|
||||
|
||||
void sanctuary$setChickenArmor(ItemStack armor);
|
||||
}
|
||||
@@ -120,6 +120,7 @@ public final class SanctuaryClient implements ClientModInitializer {
|
||||
SanctuaryHealthPreview.register();
|
||||
CelestialSpyglassSelection.register();
|
||||
SanctuaryBannerCapeLayer.initialize();
|
||||
SanctuaryChickenArmorLayer.initialize();
|
||||
EntityRendererRegistry.register(SanctuaryRegistries.SEAT, NoopRenderer::new);
|
||||
ClientTickEvents.END_CLIENT_TICK.register(SanctuaryClient::tick);
|
||||
ClientPlayNetworking.registerGlobalReceiver(ProgressionSnapshotPayload.ID, (payload, context) ->
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package fr.koka99cab.sanctuary26.sanctuary.gameplay;
|
||||
|
||||
import net.minecraft.tags.DamageTypeTags;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
|
||||
/** Shared server rules for fitting vanilla armadillo-scute armor to adult chickens. */
|
||||
public final class SanctuaryChickenArmor {
|
||||
private SanctuaryChickenArmor() {
|
||||
}
|
||||
|
||||
public static boolean canEquip(ItemStack equipped, ItemStack held, boolean baby) {
|
||||
return !baby && equipped.isEmpty() && held.is(Items.WOLF_ARMOR);
|
||||
}
|
||||
|
||||
public static boolean canRepair(ItemStack equipped, ItemStack held) {
|
||||
return equipped.is(Items.WOLF_ARMOR) && equipped.isDamaged()
|
||||
&& equipped.isValidRepairItem(held);
|
||||
}
|
||||
|
||||
public static boolean absorbs(ItemStack equipped, DamageSource source) {
|
||||
return equipped.is(Items.WOLF_ARMOR) && !source.is(DamageTypeTags.BYPASSES_WOLF_ARMOR);
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package fr.koka99cab.sanctuary26.sanctuary.mixin;
|
||||
|
||||
import fr.koka99cab.sanctuary26.sanctuary.gameplay.SanctuaryChickenArmor;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.animal.Animal;
|
||||
import net.minecraft.world.entity.animal.chicken.Chicken;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
/** Lets adult chickens wear and repair the vanilla armadillo-scute wolf armor. */
|
||||
@Mixin(Animal.class)
|
||||
abstract class AnimalChickenArmorMixin {
|
||||
@Inject(method = "mobInteract", at = @At("HEAD"), cancellable = true)
|
||||
private void sanctuary$handleChickenArmor(Player player, InteractionHand hand,
|
||||
CallbackInfoReturnable<InteractionResult> cir) {
|
||||
if (!((Object) this instanceof Chicken chicken)) return;
|
||||
ItemStack held = player.getItemInHand(hand);
|
||||
ItemStack equipped = chicken.getItemBySlot(EquipmentSlot.BODY);
|
||||
if (SanctuaryChickenArmor.canEquip(equipped, held, chicken.isBaby())) {
|
||||
chicken.setItemSlot(EquipmentSlot.BODY, held.copyWithCount(1));
|
||||
chicken.setGuaranteedDrop(EquipmentSlot.BODY);
|
||||
held.consume(1, player);
|
||||
chicken.playSound(SoundEvents.ARMOR_EQUIP_WOLF.value());
|
||||
cir.setReturnValue(InteractionResult.SUCCESS);
|
||||
return;
|
||||
}
|
||||
if (SanctuaryChickenArmor.canRepair(equipped, held)) {
|
||||
held.consume(1, player);
|
||||
int repairUnit = Mth.ceil(equipped.getMaxDamage() * 0.125F);
|
||||
equipped.setDamageValue(Math.max(0, equipped.getDamageValue() - repairUnit));
|
||||
chicken.playSound(SoundEvents.WOLF_ARMOR_REPAIR);
|
||||
cir.setReturnValue(InteractionResult.SUCCESS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,11 @@ package fr.koka99cab.sanctuary26.sanctuary.mixin;
|
||||
|
||||
import fr.koka99cab.sanctuary26.sanctuary.gameplay.SanctuaryCompanionPowers;
|
||||
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.Items;
|
||||
import net.minecraft.world.item.SpawnEggItem;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.item.component.TooltipDisplay;
|
||||
@@ -21,5 +23,9 @@ abstract class ItemTooltipMixin {
|
||||
if (stack.getItem() instanceof SpawnEggItem) {
|
||||
SanctuaryCompanionPowers.appendPowerTooltip(stack, tooltip);
|
||||
}
|
||||
if (stack.is(Items.WOLF_ARMOR)) {
|
||||
tooltip.accept(Component.translatable("tooltip.sanctuary.chicken_armor")
|
||||
.withStyle(ChatFormatting.GRAY));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package fr.koka99cab.sanctuary26.sanctuary.mixin;
|
||||
|
||||
import fr.koka99cab.sanctuary26.sanctuary.gameplay.SanctuaryChickenArmor;
|
||||
import net.minecraft.core.particles.ItemParticleOption;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Crackiness;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.animal.chicken.Chicken;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
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;
|
||||
|
||||
/** Gives armored chickens the same damage-absorption contract as armored wolves. */
|
||||
@Mixin(LivingEntity.class)
|
||||
abstract class LivingEntityChickenArmorMixin {
|
||||
@Inject(method = "actuallyHurt", at = @At("HEAD"), cancellable = true)
|
||||
private void sanctuary$absorbChickenDamage(ServerLevel level, DamageSource source,
|
||||
float damage, CallbackInfo ci) {
|
||||
if (!((Object) this instanceof Chicken chicken)) return;
|
||||
ItemStack armor = chicken.getItemBySlot(EquipmentSlot.BODY);
|
||||
if (!SanctuaryChickenArmor.absorbs(armor, source)) return;
|
||||
|
||||
int damageBefore = armor.getDamageValue();
|
||||
int maxDamage = armor.getMaxDamage();
|
||||
armor.hurtAndBreak(Mth.ceil(damage), chicken, EquipmentSlot.BODY);
|
||||
chicken.playSound(SoundEvents.WOLF_ARMOR_DAMAGE);
|
||||
if (Crackiness.WOLF_ARMOR.byDamage(damageBefore, maxDamage)
|
||||
!= Crackiness.WOLF_ARMOR.byDamage(chicken.getItemBySlot(EquipmentSlot.BODY))) {
|
||||
chicken.playSound(SoundEvents.WOLF_ARMOR_CRACK);
|
||||
level.sendParticles(new ItemParticleOption(ParticleTypes.ITEM,
|
||||
Items.ARMADILLO_SCUTE), chicken.getX(), chicken.getY() + 0.5D,
|
||||
chicken.getZ(), 12, 0.2D, 0.15D, 0.2D, 0.08D);
|
||||
}
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package fr.koka99cab.sanctuary26.sanctuary.mixin.client;
|
||||
|
||||
import fr.koka99cab.sanctuary26.sanctuary.client.SanctuaryChickenArmorRenderState;
|
||||
import net.minecraft.client.renderer.entity.state.ChickenRenderState;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
/** Stores synchronized chicken body armor on the client render state. */
|
||||
@Mixin(ChickenRenderState.class)
|
||||
abstract class ChickenRenderStateMixin implements SanctuaryChickenArmorRenderState {
|
||||
@Unique private ItemStack sanctuary$chickenArmor = ItemStack.EMPTY;
|
||||
|
||||
@Override
|
||||
public ItemStack sanctuary$chickenArmor() {
|
||||
return sanctuary$chickenArmor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sanctuary$setChickenArmor(ItemStack armor) {
|
||||
sanctuary$chickenArmor = armor == null ? ItemStack.EMPTY : armor;
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package fr.koka99cab.sanctuary26.sanctuary.mixin.client;
|
||||
|
||||
import fr.koka99cab.sanctuary26.sanctuary.client.SanctuaryChickenArmorRenderState;
|
||||
import net.minecraft.client.renderer.entity.ChickenRenderer;
|
||||
import net.minecraft.client.renderer.entity.state.ChickenRenderState;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.animal.chicken.Chicken;
|
||||
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;
|
||||
|
||||
/** Copies vanilla-synchronized body equipment into each chicken render state. */
|
||||
@Mixin(ChickenRenderer.class)
|
||||
abstract class ChickenRendererMixin {
|
||||
@Inject(method = "extractRenderState", at = @At("TAIL"))
|
||||
private void sanctuary$extractChickenArmor(Chicken chicken, ChickenRenderState state,
|
||||
float partialTick, CallbackInfo ci) {
|
||||
((SanctuaryChickenArmorRenderState) state).sanctuary$setChickenArmor(
|
||||
chicken.getItemBySlot(EquipmentSlot.BODY).copy());
|
||||
}
|
||||
}
|
||||
+16
-9
@@ -77,7 +77,7 @@ public final class BackroomArchitectureFeature extends Feature<NoneFeatureConfig
|
||||
buildCity(level, worldSeed, startX, startZ, chunkX, chunkZ);
|
||||
buildUtilities(level, worldSeed, startX, startZ);
|
||||
buildGlitchMaze(level, worldSeed, startX, startZ);
|
||||
placeLootLandmarks(level, worldSeed, startX, startZ, chunkX, chunkZ, random);
|
||||
placeLootLandmarks(level, worldSeed, startX, startZ, chunkX, chunkZ);
|
||||
placeRareAnomaly(level, startX, startZ, random);
|
||||
return true;
|
||||
}
|
||||
@@ -416,14 +416,11 @@ public final class BackroomArchitectureFeature extends Feature<NoneFeatureConfig
|
||||
}
|
||||
|
||||
private static void placeLootLandmarks(WorldGenLevel level, long seed, int x0, int z0,
|
||||
int chunkX, int chunkZ, Random random) {
|
||||
if (random.nextInt(5) == 0) {
|
||||
BackroomLevel zone = BackroomLevel.values()[random.nextInt(BackroomLevel.values().length)];
|
||||
int floorY = BackroomLayout.exitBedFloor(zone);
|
||||
int x = x0 + 7, y = floorY + 1, z = z0 + 7;
|
||||
set(level, x, floorY, z, floorMaterial(zone));
|
||||
set(level, x, y, z, Blocks.CHEST.defaultBlockState());
|
||||
set(level, x, y + 1, z, Blocks.AIR.defaultBlockState());
|
||||
int chunkX, int chunkZ) {
|
||||
for (BackroomLevel zone : BackroomLevel.values()) {
|
||||
if (BackroomLayout.lootChestChunk(seed, zone, chunkX, chunkZ)) {
|
||||
placeLootLandmark(level, zone, x0 + 7, z0 + 7);
|
||||
}
|
||||
}
|
||||
for (BackroomLevel zone : BackroomLevel.values()) {
|
||||
if (!BackroomLayout.exitBedChunk(seed, zone, chunkX, chunkZ)) continue;
|
||||
@@ -438,6 +435,16 @@ public final class BackroomArchitectureFeature extends Feature<NoneFeatureConfig
|
||||
}
|
||||
}
|
||||
|
||||
private static void placeLootLandmark(WorldGenLevel level, BackroomLevel zone, int x, int z) {
|
||||
int floorY = BackroomLayout.exitBedFloor(zone);
|
||||
for (int dx = -1; dx <= 1; dx++) for (int dz = -1; dz <= 1; dz++) {
|
||||
set(level, x + dx, floorY, z + dz, floorMaterial(zone));
|
||||
for (int dy = 1; dy <= 2; dy++) set(level, x + dx, floorY + dy, z + dz,
|
||||
Blocks.AIR.defaultBlockState());
|
||||
}
|
||||
set(level, x, floorY + 1, z, Blocks.CHEST.defaultBlockState());
|
||||
}
|
||||
|
||||
private static void placeRareAnomaly(WorldGenLevel level, int x0, int z0, Random random) {
|
||||
if (random.nextInt(96) == 0) {
|
||||
Block anomaly = BackroomMaterialApi.anomalyMaterial();
|
||||
|
||||
+17
-2
@@ -13,7 +13,8 @@ public final class BackroomLayout {
|
||||
public static final int ROOM_SIZE = 16;
|
||||
public static final int MAZE_FLOOR_Y = 8;
|
||||
public static final int MAZE_ROOF_Y = 18;
|
||||
public static final int EXIT_BED_CELL_SIZE_CHUNKS = 10;
|
||||
public static final int EXIT_BED_CELL_SIZE_CHUNKS = 3;
|
||||
public static final int LOOT_CHEST_CELL_SIZE_CHUNKS = 3;
|
||||
private static final int HOLE_CELL_SIZE = 64;
|
||||
|
||||
private BackroomLayout() {}
|
||||
@@ -91,7 +92,21 @@ public final class BackroomLayout {
|
||||
return Math.floorMod((int) mix(seed ^ 0x43c2a1769f0e85bdL, chunkX, chunkZ), 11) == 0;
|
||||
}
|
||||
|
||||
/** One deterministic, rare exit-bed chunk per grid cell and per vertical level. */
|
||||
/** One easy-to-find loot landmark per three-by-three chunk cell and per vertical level. */
|
||||
public static boolean lootChestChunk(long seed, BackroomLevel level, int chunkX, int chunkZ) {
|
||||
Objects.requireNonNull(level, "level");
|
||||
int cellX = Math.floorDiv(chunkX, LOOT_CHEST_CELL_SIZE_CHUNKS);
|
||||
int cellZ = Math.floorDiv(chunkZ, LOOT_CHEST_CELL_SIZE_CHUNKS);
|
||||
long hash = mix(seed ^ 0x354c6f3a82d9e107L ^ (long) level.ordinal() * 0x9e3779b97f4a7c15L,
|
||||
cellX, cellZ);
|
||||
int targetX = cellX * LOOT_CHEST_CELL_SIZE_CHUNKS
|
||||
+ Math.floorMod((int) hash, LOOT_CHEST_CELL_SIZE_CHUNKS);
|
||||
int targetZ = cellZ * LOOT_CHEST_CELL_SIZE_CHUNKS
|
||||
+ Math.floorMod((int) (hash >>> 32), LOOT_CHEST_CELL_SIZE_CHUNKS);
|
||||
return chunkX == targetX && chunkZ == targetZ;
|
||||
}
|
||||
|
||||
/** One deterministic exit-bed chunk per three-by-three grid cell and per vertical level. */
|
||||
public static boolean exitBedChunk(long seed, BackroomLevel level, int chunkX, int chunkZ) {
|
||||
Objects.requireNonNull(level, "level");
|
||||
int cellX = Math.floorDiv(chunkX, EXIT_BED_CELL_SIZE_CHUNKS);
|
||||
|
||||
@@ -517,6 +517,7 @@
|
||||
"item.sanctuary.mojang_classic_cape": "Mojang Classic Cape",
|
||||
"item.sanctuary.blue_scroll_cape": "Blue Scroll Cape",
|
||||
"item.sanctuary.white_cape": "White Cape",
|
||||
"tooltip.sanctuary.chicken_armor": "Can also equip and protect an adult chicken.",
|
||||
"dimension.sanctuary.alpha": "Alpha / Indev Island",
|
||||
"dimension.sanctuary.backroom": "Backroom",
|
||||
"message.sanctuary.backroom.unavailable": "The Backroom is unavailable in this world.",
|
||||
@@ -537,6 +538,8 @@
|
||||
"metric.sanctuary.ranking.broken": "%s broken",
|
||||
"metric.sanctuary.ranking.picked_up": "%s picked up",
|
||||
"metric.sanctuary.ranking.dropped": "%s dropped",
|
||||
"metric.sanctuary.ranking.killed": "Killed: %s",
|
||||
"metric.sanctuary.ranking.killed_by": "Killed by: %s",
|
||||
"metric.sanctuary.ranking.custom": "Custom statistic",
|
||||
"metric.sanctuary.ranking.unknown": "Unknown statistic"
|
||||
}
|
||||
|
||||
@@ -517,6 +517,7 @@
|
||||
"item.sanctuary.mojang_classic_cape": "Cape Mojang classique",
|
||||
"item.sanctuary.blue_scroll_cape": "Cape parchemin bleu",
|
||||
"item.sanctuary.white_cape": "Cape blanche",
|
||||
"tooltip.sanctuary.chicken_armor": "Peut aussi équiper et protéger une poule adulte.",
|
||||
"dimension.sanctuary.alpha": "Île Alpha / Indev",
|
||||
"dimension.sanctuary.backroom": "Backroom",
|
||||
"message.sanctuary.backroom.unavailable": "La Backroom n’est pas disponible dans ce monde.",
|
||||
@@ -537,6 +538,8 @@
|
||||
"metric.sanctuary.ranking.broken": "%s cassé",
|
||||
"metric.sanctuary.ranking.picked_up": "%s ramassé",
|
||||
"metric.sanctuary.ranking.dropped": "%s jeté",
|
||||
"metric.sanctuary.ranking.killed": "Tués : %s",
|
||||
"metric.sanctuary.ranking.killed_by": "Tué par : %s",
|
||||
"metric.sanctuary.ranking.custom": "Statistique personnalisée",
|
||||
"metric.sanctuary.ranking.unknown": "Statistique inconnue"
|
||||
}
|
||||
|
||||
@@ -473,6 +473,7 @@
|
||||
"item.sanctuary.mojang_classic_cape": "Классический плащ Mojang",
|
||||
"item.sanctuary.blue_scroll_cape": "Плащ синего свитка",
|
||||
"item.sanctuary.white_cape": "Белый плащ",
|
||||
"tooltip.sanctuary.chicken_armor": "Также надевается на взрослую курицу и защищает её.",
|
||||
"dimension.sanctuary.alpha": "Остров Альфа / Indev",
|
||||
"dimension.sanctuary.backroom": "Бэкрум",
|
||||
"message.sanctuary.backroom.unavailable": "Бэкрум недоступен в этом мире.",
|
||||
@@ -493,6 +494,8 @@
|
||||
"metric.sanctuary.ranking.broken": "Сломано: %s",
|
||||
"metric.sanctuary.ranking.picked_up": "Подобрано: %s",
|
||||
"metric.sanctuary.ranking.dropped": "Выброшено: %s",
|
||||
"metric.sanctuary.ranking.killed": "Убито: %s",
|
||||
"metric.sanctuary.ranking.killed_by": "Убит существом: %s",
|
||||
"metric.sanctuary.ranking.custom": "Пользовательская статистика",
|
||||
"metric.sanctuary.ranking.unknown": "Неизвестная статистика"
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"compatibilityLevel": "JAVA_25",
|
||||
"mixins": [
|
||||
"AbstractContainerMenuMixin",
|
||||
"AnimalChickenArmorMixin",
|
||||
"BedBlockMixin",
|
||||
"ChestBlockEntityMixin",
|
||||
"ConsumableMixin",
|
||||
@@ -15,6 +16,7 @@
|
||||
"ItemEntityMixin",
|
||||
"ItemTooltipMixin",
|
||||
"LivingEntityCompanionMixin",
|
||||
"LivingEntityChickenArmorMixin",
|
||||
"PlayerOverflowMixin",
|
||||
"SlotMixin",
|
||||
"ServerGamePacketListenerMixin",
|
||||
@@ -28,6 +30,8 @@
|
||||
"client.AbstractContainerScreenMixin",
|
||||
"client.AbstractRecipeBookScreenMixin",
|
||||
"client.CameraMixin",
|
||||
"client.ChickenRendererMixin",
|
||||
"client.ChickenRenderStateMixin",
|
||||
"client.CreativeModeInventoryScreenMixin",
|
||||
"client.CreativeSlotWrapperAccessor",
|
||||
"client.CreateWorldScreenWorldTabMixin",
|
||||
|
||||
+29
@@ -3,12 +3,22 @@ package fr.koka99cab.sanctuary26.sanctuary.api.ranking;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.component.DataComponentMap;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.server.Bootstrap;
|
||||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.world.entity.EntityTypes;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.component.TypedEntityData;
|
||||
|
||||
/** Pure ranking smoke for ordering, tied ranks, saturation and newer-save protection. */
|
||||
public final class SanctuaryRankingModelSmoke {
|
||||
@@ -36,6 +46,12 @@ public final class SanctuaryRankingModelSmoke {
|
||||
&& tied.podium().get(2).rank() == 3, "Equal values must retain the same competition rank");
|
||||
require(tied.owner().rank() == 1 && tied.owner().value() == 10L,
|
||||
"Panel owner placement must reflect the real tied rank");
|
||||
for (int index = 4; index <= 9; index++) {
|
||||
UUID player = UUID.fromString("00000000-0000-0000-0000-" + String.format("%012d", index));
|
||||
data.recordValue(player, "Player" + index, metricId, 10L - index);
|
||||
}
|
||||
require(data.snapshot(metric, bob).podium().size() == RankingSnapshot.MAX_PODIUM_SIZE,
|
||||
"The eight-line panel must expose exactly seven bounded ranking rows");
|
||||
|
||||
data.increment(chris, "Chris", metricId, Long.MAX_VALUE);
|
||||
require(data.score(chris, metricId) == SanctuaryRankingData.MAX_VALUE,
|
||||
@@ -57,6 +73,16 @@ public final class SanctuaryRankingModelSmoke {
|
||||
require(VanillaRankingMetric.parse(vanillaId).orElseThrow().target().equals(Stats.PLAY_TIME)
|
||||
&& VanillaRankingMetric.descriptor(vanillaId).unit() == RankingUnit.TICKS,
|
||||
"Vanilla metric IDs and units must round-trip stably");
|
||||
List<RankingMetric> zombieMetrics = VanillaRankingMetric.itemMetrics(
|
||||
new ItemStack(new Holder.Direct<Item>(Items.ZOMBIE_SPAWN_EGG, DataComponentMap.builder()
|
||||
.set(DataComponents.MAX_STACK_SIZE, 64)
|
||||
.set(DataComponents.ENTITY_DATA, TypedEntityData.of(EntityTypes.ZOMBIE, new CompoundTag()))
|
||||
.build())));
|
||||
VanillaRankingMetric.Source zombieSource = VanillaRankingMetric.parse(
|
||||
zombieMetrics.getFirst().id()).orElseThrow();
|
||||
require(zombieMetrics.size() == 1 && zombieSource.type().getPath().equals("killed")
|
||||
&& zombieSource.target().equals(Identifier.withDefaultNamespace("zombie")),
|
||||
"A zombie spawn egg must configure the zombies-killed ranking");
|
||||
|
||||
Path temporary = Files.createTempDirectory("sanctuary-ranking-migration-");
|
||||
Path oldStats = temporary.resolve(alex + ".json");
|
||||
@@ -67,6 +93,9 @@ public final class SanctuaryRankingModelSmoke {
|
||||
imported.importVanillaFile(oldStats);
|
||||
require(imported.score(alex, usedStick) == 12L,
|
||||
"Existing vanilla statistics were not imported monotonically exactly once");
|
||||
require(imported.snapshot(VanillaRankingMetric.descriptor(usedStick), alex).podium().getFirst()
|
||||
.playerName().equals("?"),
|
||||
"An import without a cached profile must use '?' rather than exposing a shortened UUID");
|
||||
Files.deleteIfExists(oldStats);
|
||||
Files.deleteIfExists(temporary);
|
||||
|
||||
|
||||
+21
-1
@@ -25,6 +25,7 @@ public final class BackroomModelSmoke {
|
||||
personalRecoveryIsPrioritized();
|
||||
recentLossesRemainPersonal();
|
||||
architectureIsDeterministicAndStacked();
|
||||
lootLandmarksCoverEveryLevel();
|
||||
exitBedsCoverEveryLevel();
|
||||
roomCornersReachEveryVariant();
|
||||
mazeDoorsStayConnected();
|
||||
@@ -130,6 +131,7 @@ public final class BackroomModelSmoke {
|
||||
private static void exitBedsCoverEveryLevel() {
|
||||
long seed = 26_200_133L;
|
||||
int cellSize = BackroomLayout.EXIT_BED_CELL_SIZE_CHUNKS;
|
||||
require(cellSize == 3, "Backroom exit beds are no longer spaced three chunks apart");
|
||||
for (BackroomLevel level : BackroomLevel.values()) {
|
||||
int floorY = BackroomLayout.exitBedFloor(level);
|
||||
require(BackroomLayout.levelAt(floorY) == level,
|
||||
@@ -142,7 +144,25 @@ public final class BackroomModelSmoke {
|
||||
}
|
||||
}
|
||||
require(candidates == 1,
|
||||
"A Backroom level lost its single rare exit bed in a generation cell: " + level);
|
||||
"A Backroom level lost its exit bed in a three-by-three chunk cell: " + level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void lootLandmarksCoverEveryLevel() {
|
||||
long seed = 26_200_137L;
|
||||
int cellSize = BackroomLayout.LOOT_CHEST_CELL_SIZE_CHUNKS;
|
||||
require(cellSize == 3, "Backroom loot landmarks are no longer spaced three chunks apart");
|
||||
for (BackroomLevel level : BackroomLevel.values()) {
|
||||
for (int cellX = -4; cellX <= 4; cellX++) for (int cellZ = -4; cellZ <= 4; cellZ++) {
|
||||
int candidates = 0;
|
||||
for (int chunkX = cellX * cellSize; chunkX < (cellX + 1) * cellSize; chunkX++) {
|
||||
for (int chunkZ = cellZ * cellSize; chunkZ < (cellZ + 1) * cellSize; chunkZ++) {
|
||||
if (BackroomLayout.lootChestChunk(seed, level, chunkX, chunkZ)) candidates++;
|
||||
}
|
||||
}
|
||||
require(candidates == 1,
|
||||
"A Backroom level lost its loot landmark in a three-by-three chunk cell: " + level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
package fr.koka99cab.sanctuary26.sanctuary.client;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.client.model.geom.ModelPart;
|
||||
import org.joml.Vector3f;
|
||||
import org.joml.Vector3fc;
|
||||
|
||||
/** Verifies the shield-pattern UV island, cape proportions and double-sided plane. */
|
||||
public final class SanctuaryBannerCapeModelSmoke {
|
||||
private static final float EPSILON = 0.0001F;
|
||||
|
||||
private SanctuaryBannerCapeModelSmoke() {}
|
||||
|
||||
public static void main(String[] args) {
|
||||
ModelPart cape = SanctuaryBannerCapeLayer.createLayer().bakeRoot()
|
||||
.getChild("body").getChild("cape");
|
||||
List<Float> normalZ = new ArrayList<>();
|
||||
List<ModelPart.Vertex> vertices = new ArrayList<>();
|
||||
cape.visit(new PoseStack(), (pose, path, cubeIndex, cube) -> {
|
||||
for (ModelPart.Polygon polygon : cube.polygons) {
|
||||
normalZ.add(pose.transformNormal(polygon.normal(), new Vector3f()).z());
|
||||
vertices.addAll(List.of(polygon.vertices()));
|
||||
}
|
||||
});
|
||||
require(normalZ.size() == 2 && normalZ.stream().anyMatch(value -> value < -0.99F)
|
||||
&& normalZ.stream().anyMatch(value -> value > 0.99F),
|
||||
"The banner cape must contain one visible plane for each culling direction");
|
||||
require(close(minU(vertices), 1.0F / 64.0F) && close(maxU(vertices), 13.0F / 64.0F)
|
||||
&& close(minV(vertices), 1.0F / 64.0F) && close(maxV(vertices), 23.0F / 64.0F),
|
||||
"The cape no longer samples the shield plate's exact pattern UV island");
|
||||
|
||||
List<Vector3fc> extents = new ArrayList<>();
|
||||
cape.getExtentsForGui(new PoseStack(), extents::add);
|
||||
require(close(minX(extents), -5.0F / 16.0F) && close(maxX(extents), 5.0F / 16.0F)
|
||||
&& close(minY(extents), 0.0F) && close(maxY(extents), 1.0F),
|
||||
"The shield-pattern plane does not retain the vanilla 10x16 cape proportions");
|
||||
}
|
||||
|
||||
private static float minU(List<ModelPart.Vertex> vertices) {
|
||||
return (float) vertices.stream().mapToDouble(ModelPart.Vertex::u).min().orElseThrow();
|
||||
}
|
||||
|
||||
private static float maxU(List<ModelPart.Vertex> vertices) {
|
||||
return (float) vertices.stream().mapToDouble(ModelPart.Vertex::u).max().orElseThrow();
|
||||
}
|
||||
|
||||
private static float minV(List<ModelPart.Vertex> vertices) {
|
||||
return (float) vertices.stream().mapToDouble(ModelPart.Vertex::v).min().orElseThrow();
|
||||
}
|
||||
|
||||
private static float maxV(List<ModelPart.Vertex> vertices) {
|
||||
return (float) vertices.stream().mapToDouble(ModelPart.Vertex::v).max().orElseThrow();
|
||||
}
|
||||
|
||||
private static float minX(List<Vector3fc> vertices) {
|
||||
return (float) vertices.stream().mapToDouble(Vector3fc::x).min().orElseThrow();
|
||||
}
|
||||
|
||||
private static float maxX(List<Vector3fc> vertices) {
|
||||
return (float) vertices.stream().mapToDouble(Vector3fc::x).max().orElseThrow();
|
||||
}
|
||||
|
||||
private static float minY(List<Vector3fc> vertices) {
|
||||
return (float) vertices.stream().mapToDouble(Vector3fc::y).min().orElseThrow();
|
||||
}
|
||||
|
||||
private static float maxY(List<Vector3fc> vertices) {
|
||||
return (float) vertices.stream().mapToDouble(Vector3fc::y).max().orElseThrow();
|
||||
}
|
||||
|
||||
private static boolean close(float actual, float expected) {
|
||||
return Math.abs(actual - expected) <= EPSILON;
|
||||
}
|
||||
|
||||
private static void require(boolean condition, String message) {
|
||||
if (!condition) throw new AssertionError(message);
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package fr.koka99cab.sanctuary26.sanctuary.gameplay;
|
||||
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.server.Bootstrap;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.component.DataComponentMap;
|
||||
|
||||
/** Executable coverage for the bounded adult-chicken armor equip policy. */
|
||||
public final class SanctuaryChickenArmorSmoke {
|
||||
private SanctuaryChickenArmorSmoke() {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SharedConstants.tryDetectVersion();
|
||||
Bootstrap.bootStrap();
|
||||
ItemStack armor = stack(Items.WOLF_ARMOR);
|
||||
require(SanctuaryChickenArmor.canEquip(ItemStack.EMPTY, armor, false),
|
||||
"Adult chickens must accept unused armadillo-scute armor");
|
||||
require(!SanctuaryChickenArmor.canEquip(ItemStack.EMPTY, armor, true),
|
||||
"Baby chickens must not accept body armor");
|
||||
require(!SanctuaryChickenArmor.canEquip(armor.copy(), armor, false),
|
||||
"Equipping must not replace an existing chicken armor stack");
|
||||
require(!SanctuaryChickenArmor.canEquip(ItemStack.EMPTY,
|
||||
stack(Items.IRON_CHESTPLATE), false),
|
||||
"Chicken armor must stay limited to the armadillo-scute item");
|
||||
}
|
||||
|
||||
private static ItemStack stack(net.minecraft.world.item.Item item) {
|
||||
return new ItemStack(new Holder.Direct<>(item, DataComponentMap.EMPTY), 1);
|
||||
}
|
||||
|
||||
private static void require(boolean condition, String message) {
|
||||
if (!condition) throw new IllegalStateException(message);
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -21,5 +21,6 @@ include(
|
||||
"onlyfun",
|
||||
"sanctuary",
|
||||
"events",
|
||||
"masterkey"
|
||||
"masterkey",
|
||||
"zevent"
|
||||
)
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# ZEVENT
|
||||
|
||||
Mod Fabric événementiel distribué séparément du pack Sanctuary. Il ajoute un écran mural multibloc de 9×5 blocs qui lit une chaîne Twitch en direct.
|
||||
|
||||
## Utilisation
|
||||
|
||||
1. Poser l'écran contre un mur libre de 9×5 blocs. Le bloc visé devient le centre de l'écran.
|
||||
2. Faire un clic droit sur n'importe laquelle de ses 45 cases.
|
||||
3. Saisir un nom de chaîne (`zeventfr`) ou coller une URL Twitch, puis valider.
|
||||
|
||||
La chaîne est enregistrée par le serveur et synchronisée aux joueurs. Le client rend le lecteur Twitch officiel dans la surface. Son volume utilise la catégorie **Disques** de Minecraft et diminue jusqu'au silence à 64 blocs. Seul l'écran le plus proche est audible et deux flux visibles au maximum sont décodés par client.
|
||||
|
||||
## Dépendance et limites
|
||||
|
||||
Le client exige [MCEF Modern](https://modrinth.com/mod/mcef-modern) `0.3.3+mc26.2.jcef146.0.10`. MCEF télécharge son runtime Chromium natif lors de la première utilisation ; une connexion Internet est donc nécessaire. Le lecteur utilise le backend OpenGL pris en charge par cette version de MCEF.
|
||||
|
||||
Le serveur ne reçoit jamais d'URL arbitraire : les entrées sont ramenées à un identifiant Twitch de 1 à 25 caractères (`a-z`, `0-9`, `_`). La page locale est liée uniquement à l'interface loopback et n'expose que le lecteur officiel `player.twitch.tv`.
|
||||
|
||||
Documentation du lecteur : [Twitch Embedded Video & Clips](https://dev.twitch.tv/docs/embed/video-and-clips/).
|
||||
@@ -0,0 +1,19 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1024" viewBox="0 0 1024 1024">
|
||||
<defs>
|
||||
<linearGradient id="screen" x1="0" y1="0" x2="1" y2="1">
|
||||
<stop offset="0" stop-color="#18221d"/>
|
||||
<stop offset="1" stop-color="#060807"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="live" x1="0" y1="1" x2="1" y2="0">
|
||||
<stop offset="0" stop-color="#1bdc7a"/>
|
||||
<stop offset="1" stop-color="#b7ff39"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect width="1024" height="1024" rx="176" fill="#090d0b"/>
|
||||
<rect x="94" y="168" width="836" height="520" rx="54" fill="url(#screen)" stroke="url(#live)" stroke-width="28"/>
|
||||
<path d="M364 300h330L458 556h252" fill="none" stroke="#f5fff8" stroke-width="74" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M292 807h440" stroke="#314139" stroke-width="42" stroke-linecap="round"/>
|
||||
<path d="M512 688v119" stroke="#314139" stroke-width="42"/>
|
||||
<circle cx="829" cy="258" r="42" fill="#ff405f"/>
|
||||
<circle cx="829" cy="258" r="77" fill="none" stroke="#ff405f" stroke-width="14" opacity=".32"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
@@ -0,0 +1,14 @@
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "maven.modrinth:mcef-modern:FOXbUPNd"
|
||||
compileOnly "me.friwi:jcef-api:jcef-d3de827+cef-146.0.10+g8219561+chromium-146.0.7680.179"
|
||||
testImplementation "org.junit.jupiter:junit-jupiter:5.11.4"
|
||||
testRuntimeOnly "org.junit.platform:junit-platform-launcher:1.11.4"
|
||||
}
|
||||
|
||||
tasks.named("test") {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package fr.koka99cab.sanctuary26.zevent;
|
||||
|
||||
import fr.koka99cab.sanctuary26.zevent.network.ZeventNetworking;
|
||||
import fr.koka99cab.sanctuary26.zevent.registry.ZeventRegistries;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public final class ZeventMod implements ModInitializer {
|
||||
public static final String MOD_ID = "zevent";
|
||||
public static final String DISPLAY_NAME = "ZEVENT";
|
||||
public static final int CURRENT_DATA_VERSION = 1;
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||
|
||||
public ZeventMod() {
|
||||
}
|
||||
|
||||
public static Identifier id(String path) {
|
||||
return Identifier.fromNamespaceAndPath(MOD_ID, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
ZeventRegistries.initialize();
|
||||
ZeventNetworking.initialize();
|
||||
LOGGER.info("[{}] 9x5 Twitch screen ready (data v{}, network v{}).",
|
||||
DISPLAY_NAME, CURRENT_DATA_VERSION, ZeventNetworking.PROTOCOL_VERSION);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
package fr.koka99cab.sanctuary26.zevent.block;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import fr.koka99cab.sanctuary26.zevent.block.entity.ZeventScreenBlockEntity;
|
||||
import fr.koka99cab.sanctuary26.zevent.network.ZeventNetworking;
|
||||
import java.util.Map;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
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.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.level.block.state.properties.IntegerProperty;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
/** One block type represents all 45 cells; only its central cell owns playback state. */
|
||||
public final class ZeventScreenBlock extends BaseEntityBlock {
|
||||
public static final MapCodec<ZeventScreenBlock> CODEC = simpleCodec(ZeventScreenBlock::new);
|
||||
public static final EnumProperty<Direction> FACING = BlockStateProperties.HORIZONTAL_FACING;
|
||||
public static final IntegerProperty COLUMN = IntegerProperty.create("column", 0, ZeventScreenLayout.WIDTH - 1);
|
||||
public static final IntegerProperty ROW = IntegerProperty.create("row", 0, ZeventScreenLayout.HEIGHT - 1);
|
||||
private static final ThreadLocal<Boolean> REMOVING_STRUCTURE = ThreadLocal.withInitial(() -> false);
|
||||
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 ZeventScreenBlock(BlockBehaviour.Properties properties) {
|
||||
super(properties);
|
||||
registerDefaultState(stateDefinition.any()
|
||||
.setValue(FACING, Direction.NORTH)
|
||||
.setValue(COLUMN, ZeventScreenLayout.CONTROLLER_COLUMN)
|
||||
.setValue(ROW, ZeventScreenLayout.CONTROLLER_ROW));
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapCodec<ZeventScreenBlock> codec() {
|
||||
return CODEC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
||||
return new ZeventScreenBlockEntity(pos, state);
|
||||
}
|
||||
|
||||
@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;
|
||||
BlockPos controller = context.getClickedPos();
|
||||
if (!canPlaceScreen(context.getLevel(), controller, facing)) return null;
|
||||
return defaultBlockState().setValue(FACING, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlacedBy(Level level, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) {
|
||||
super.setPlacedBy(level, pos, state, placer, stack);
|
||||
if (level.isClientSide() || !ZeventScreenLayout.isController(state)) return;
|
||||
Direction facing = state.getValue(FACING);
|
||||
for (int row = 0; row < ZeventScreenLayout.HEIGHT; row++) {
|
||||
for (int column = 0; column < ZeventScreenLayout.WIDTH; column++) {
|
||||
if (column == ZeventScreenLayout.CONTROLLER_COLUMN
|
||||
&& row == ZeventScreenLayout.CONTROLLER_ROW) continue;
|
||||
BlockPos part = ZeventScreenLayout.partPos(pos, facing, column, row);
|
||||
level.setBlock(part, defaultBlockState().setValue(FACING, facing)
|
||||
.setValue(COLUMN, column).setValue(ROW, row), Block.UPDATE_ALL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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
|
||||
protected InteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos,
|
||||
Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
return openOptions(state, level, pos, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos,
|
||||
Player player, BlockHitResult hit) {
|
||||
return openOptions(state, level, pos, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState playerWillDestroy(Level level, BlockPos pos, BlockState state, Player player) {
|
||||
if (!level.isClientSide()) removeOtherParts(level, pos, state);
|
||||
return super.playerWillDestroy(level, pos, state, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos,
|
||||
boolean movedByPiston) {
|
||||
if (!REMOVING_STRUCTURE.get()) removeOtherParts(level, pos, state);
|
||||
super.affectNeighborsAfterRemoval(state, level, pos, movedByPiston);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
builder.add(FACING, COLUMN, ROW);
|
||||
}
|
||||
|
||||
@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 boolean canPlaceScreen(LevelReader level, BlockPos controller, Direction facing) {
|
||||
for (int row = 0; row < ZeventScreenLayout.HEIGHT; row++) {
|
||||
for (int column = 0; column < ZeventScreenLayout.WIDTH; column++) {
|
||||
BlockPos part = ZeventScreenLayout.partPos(controller, facing, column, row);
|
||||
if (level.isOutsideBuildHeight(part) || !level.getBlockState(part).isAir()) return false;
|
||||
BlockPos support = part.relative(facing.getOpposite());
|
||||
if (!level.getBlockState(support).isFaceSturdy(level, support, facing)) return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static InteractionResult openOptions(BlockState state, Level level, BlockPos pos, Player player) {
|
||||
if (level.isClientSide()) return InteractionResult.SUCCESS;
|
||||
BlockPos controller = ZeventScreenLayout.controllerPos(pos, state);
|
||||
if (player instanceof ServerPlayer serverPlayer
|
||||
&& level.getBlockEntity(controller) instanceof ZeventScreenBlockEntity screen) {
|
||||
ZeventNetworking.openOptions(serverPlayer, screen);
|
||||
return InteractionResult.SUCCESS_SERVER;
|
||||
}
|
||||
return InteractionResult.CONSUME;
|
||||
}
|
||||
|
||||
private static void removeOtherParts(Level level, BlockPos brokenPos, BlockState brokenState) {
|
||||
if (!(brokenState.getBlock() instanceof ZeventScreenBlock)) return;
|
||||
BlockPos controller = ZeventScreenLayout.controllerPos(brokenPos, brokenState);
|
||||
Direction facing = brokenState.getValue(FACING);
|
||||
REMOVING_STRUCTURE.set(true);
|
||||
try {
|
||||
for (int row = 0; row < ZeventScreenLayout.HEIGHT; row++) {
|
||||
for (int column = 0; column < ZeventScreenLayout.WIDTH; column++) {
|
||||
BlockPos part = ZeventScreenLayout.partPos(controller, facing, column, row);
|
||||
if (part.equals(brokenPos)) continue;
|
||||
BlockState candidate = level.getBlockState(part);
|
||||
if (candidate.getBlock() instanceof ZeventScreenBlock
|
||||
&& ZeventScreenLayout.controllerPos(part, candidate).equals(controller)) {
|
||||
level.setBlock(part, Blocks.AIR.defaultBlockState(),
|
||||
Block.UPDATE_ALL | Block.UPDATE_SUPPRESS_DROPS);
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
REMOVING_STRUCTURE.set(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package fr.koka99cab.sanctuary26.zevent.block;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
/** Pure 9x5 layout math shared by placement, interaction and teardown. */
|
||||
public final class ZeventScreenLayout {
|
||||
public static final int WIDTH = 9;
|
||||
public static final int HEIGHT = 5;
|
||||
public static final int CONTROLLER_COLUMN = WIDTH / 2;
|
||||
public static final int CONTROLLER_ROW = HEIGHT / 2;
|
||||
|
||||
private ZeventScreenLayout() {
|
||||
}
|
||||
|
||||
public static Direction right(Direction facing) {
|
||||
if (!facing.getAxis().isHorizontal()) throw new IllegalArgumentException("Horizontal facing required");
|
||||
return facing.getCounterClockWise();
|
||||
}
|
||||
|
||||
public static BlockPos partPos(BlockPos controller, Direction facing, int column, int row) {
|
||||
validateCell(column, row);
|
||||
Direction right = right(facing);
|
||||
return controller.offset(
|
||||
right.getStepX() * (column - CONTROLLER_COLUMN),
|
||||
row - CONTROLLER_ROW,
|
||||
right.getStepZ() * (column - CONTROLLER_COLUMN)
|
||||
);
|
||||
}
|
||||
|
||||
public static BlockPos controllerPos(BlockPos part, BlockState state) {
|
||||
Direction facing = state.getValue(ZeventScreenBlock.FACING);
|
||||
int column = state.getValue(ZeventScreenBlock.COLUMN);
|
||||
int row = state.getValue(ZeventScreenBlock.ROW);
|
||||
Direction right = right(facing);
|
||||
return part.offset(
|
||||
-right.getStepX() * (column - CONTROLLER_COLUMN),
|
||||
-(row - CONTROLLER_ROW),
|
||||
-right.getStepZ() * (column - CONTROLLER_COLUMN)
|
||||
);
|
||||
}
|
||||
|
||||
public static boolean isController(BlockState state) {
|
||||
return state.getValue(ZeventScreenBlock.COLUMN) == CONTROLLER_COLUMN
|
||||
&& state.getValue(ZeventScreenBlock.ROW) == CONTROLLER_ROW;
|
||||
}
|
||||
|
||||
private static void validateCell(int column, int row) {
|
||||
if (column < 0 || column >= WIDTH || row < 0 || row >= HEIGHT) {
|
||||
throw new IllegalArgumentException("Invalid ZEVENT screen cell " + column + "," + row);
|
||||
}
|
||||
}
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
package fr.koka99cab.sanctuary26.zevent.block.entity;
|
||||
|
||||
import fr.koka99cab.sanctuary26.zevent.ZeventMod;
|
||||
import fr.koka99cab.sanctuary26.zevent.registry.ZeventRegistries;
|
||||
import fr.koka99cab.sanctuary26.zevent.twitch.TwitchChannel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
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.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;
|
||||
|
||||
/** The central cell persists one bounded Twitch channel; all other cells are stateless mirrors. */
|
||||
public final class ZeventScreenBlockEntity extends BlockEntity {
|
||||
private static final String DATA_VERSION_KEY = "DataVersion";
|
||||
private static final String CHANNEL_KEY = "Channel";
|
||||
private int dataVersion = ZeventMod.CURRENT_DATA_VERSION;
|
||||
private String channel = TwitchChannel.DEFAULT;
|
||||
|
||||
public ZeventScreenBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(ZeventRegistries.ZEVENT_SCREEN_BLOCK_ENTITY, pos, state);
|
||||
}
|
||||
|
||||
public String channel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
public boolean setChannel(String requested) {
|
||||
if (dataVersion > ZeventMod.CURRENT_DATA_VERSION) return false;
|
||||
String normalized = TwitchChannel.normalize(requested).orElse(null);
|
||||
if (normalized == null) return false;
|
||||
if (normalized.equals(channel)) return true;
|
||||
channel = normalized;
|
||||
setChanged();
|
||||
if (level != null) {
|
||||
BlockState state = getBlockState();
|
||||
level.sendBlockUpdated(worldPosition, state, state, Block.UPDATE_CLIENTS);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean writable() {
|
||||
return dataVersion <= ZeventMod.CURRENT_DATA_VERSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void saveAdditional(ValueOutput output) {
|
||||
super.saveAdditional(output);
|
||||
output.putInt(DATA_VERSION_KEY, dataVersion);
|
||||
output.putString(CHANNEL_KEY, channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadAdditional(ValueInput input) {
|
||||
super.loadAdditional(input);
|
||||
dataVersion = input.getIntOr(DATA_VERSION_KEY, 1);
|
||||
channel = TwitchChannel.normalize(input.getStringOr(CHANNEL_KEY, TwitchChannel.DEFAULT))
|
||||
.orElse(TwitchChannel.DEFAULT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet<ClientGamePacketListener> getUpdatePacket() {
|
||||
return ClientboundBlockEntityDataPacket.create(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag getUpdateTag(HolderLookup.Provider lookup) {
|
||||
return saveWithoutMetadata(lookup);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package fr.koka99cab.sanctuary26.zevent.client;
|
||||
|
||||
import fr.koka99cab.sanctuary26.zevent.ZeventMod;
|
||||
import fr.koka99cab.sanctuary26.zevent.client.gui.ZeventScreenOptionsScreen;
|
||||
import fr.koka99cab.sanctuary26.zevent.client.render.ZeventScreenBlockEntityRenderer;
|
||||
import fr.koka99cab.sanctuary26.zevent.client.twitch.TwitchBrowserManager;
|
||||
import fr.koka99cab.sanctuary26.zevent.network.OpenScreenOptionsPayload;
|
||||
import fr.koka99cab.sanctuary26.zevent.registry.ZeventRegistries;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.BlockEntityRendererRegistry;
|
||||
|
||||
public final class ZeventClient implements ClientModInitializer {
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
BlockEntityRendererRegistry.register(ZeventRegistries.ZEVENT_SCREEN_BLOCK_ENTITY,
|
||||
ZeventScreenBlockEntityRenderer::new);
|
||||
ClientPlayNetworking.registerGlobalReceiver(OpenScreenOptionsPayload.TYPE, (payload, context) ->
|
||||
context.client().execute(() -> context.client().gui.setScreen(
|
||||
new ZeventScreenOptionsScreen(context.client().gui.screen(), payload))));
|
||||
ClientTickEvents.END_CLIENT_TICK.register(TwitchBrowserManager::tick);
|
||||
ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> TwitchBrowserManager.clear(client));
|
||||
ClientLifecycleEvents.CLIENT_STOPPING.register(TwitchBrowserManager::shutdown);
|
||||
ZeventMod.LOGGER.info("[{}] Twitch browser renderer registered.", ZeventMod.DISPLAY_NAME);
|
||||
}
|
||||
}
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
package fr.koka99cab.sanctuary26.zevent.client.gui;
|
||||
|
||||
import fr.koka99cab.sanctuary26.zevent.network.OpenScreenOptionsPayload;
|
||||
import fr.koka99cab.sanctuary26.zevent.network.SaveScreenChannelPayload;
|
||||
import fr.koka99cab.sanctuary26.zevent.twitch.TwitchChannel;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
import net.minecraft.client.gui.GuiGraphicsExtractor;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
/** Small in-game configuration surface opened by right-clicking any screen cell. */
|
||||
public final class ZeventScreenOptionsScreen extends Screen {
|
||||
private static final int PANEL_WIDTH = 340;
|
||||
private static final int PANEL_HEIGHT = 184;
|
||||
private static final int BACKDROP = 0xE0121715;
|
||||
private static final int BORDER = 0xFF3BEA8C;
|
||||
private static final int TITLE = 0xFFF5FFF9;
|
||||
private static final int TEXT = 0xFFC7D7CE;
|
||||
private static final int ERROR = 0xFFFF6B78;
|
||||
private final Screen parent;
|
||||
private final OpenScreenOptionsPayload payload;
|
||||
private EditBox channel;
|
||||
private Button save;
|
||||
private Component validation = Component.empty();
|
||||
|
||||
public ZeventScreenOptionsScreen(Screen parent, OpenScreenOptionsPayload payload) {
|
||||
super(Component.translatable("screen.zevent.options.title"));
|
||||
this.parent = parent;
|
||||
this.payload = payload;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
int x = panelX() + 16;
|
||||
int y = panelY();
|
||||
channel = addRenderableWidget(new EditBox(font, x, y + 54, PANEL_WIDTH - 32, 20,
|
||||
Component.translatable("screen.zevent.options.channel")));
|
||||
channel.setMaxLength(TwitchChannel.MAX_INPUT_LENGTH);
|
||||
channel.setValue(payload.channel());
|
||||
channel.setHint(Component.translatable("screen.zevent.options.hint"));
|
||||
channel.setEditable(payload.writable());
|
||||
channel.setResponder(value -> refreshValidation());
|
||||
|
||||
Button official = addRenderableWidget(Button.builder(
|
||||
Component.translatable("screen.zevent.options.official"), button -> select("zeventfr"))
|
||||
.bounds(x, y + 82, 150, 20).build());
|
||||
Button zerator = addRenderableWidget(Button.builder(
|
||||
Component.translatable("screen.zevent.options.zerator"), button -> select("zerator"))
|
||||
.bounds(x + 158, y + 82, 150, 20).build());
|
||||
official.active = payload.writable();
|
||||
zerator.active = payload.writable();
|
||||
|
||||
save = addRenderableWidget(Button.builder(Component.translatable("gui.done"), button -> submit())
|
||||
.bounds(x, y + 142, 150, 20).build());
|
||||
addRenderableWidget(Button.builder(Component.translatable("gui.cancel"), button -> onClose())
|
||||
.bounds(x + 158, y + 142, 150, 20).build());
|
||||
refreshValidation();
|
||||
setInitialFocus(channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
refreshValidation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float tickDelta) {
|
||||
int x = panelX();
|
||||
int y = panelY();
|
||||
graphics.fill(x, y, x + PANEL_WIDTH, y + PANEL_HEIGHT, BACKDROP);
|
||||
graphics.outline(x, y, PANEL_WIDTH, PANEL_HEIGHT, BORDER);
|
||||
graphics.centeredText(font, title, width / 2, y + 12, TITLE);
|
||||
graphics.text(font, Component.translatable("screen.zevent.options.current", payload.channel()),
|
||||
x + 16, y + 31, TEXT);
|
||||
graphics.text(font, Component.translatable("screen.zevent.options.channel"), x + 16, y + 43, TEXT);
|
||||
if (!validation.getString().isEmpty()) graphics.text(font, validation, x + 16, y + 113, ERROR);
|
||||
super.extractRenderState(graphics, mouseX, mouseY, tickDelta);
|
||||
}
|
||||
|
||||
private void select(String selected) {
|
||||
if (payload.writable()) channel.setValue(selected);
|
||||
}
|
||||
|
||||
private void refreshValidation() {
|
||||
if (channel == null || save == null) return;
|
||||
boolean valid = TwitchChannel.normalize(channel.getValue()).isPresent();
|
||||
validation = valid ? Component.empty() : Component.translatable("screen.zevent.options.invalid");
|
||||
save.active = payload.writable() && valid && ClientPlayNetworking.canSend(SaveScreenChannelPayload.TYPE);
|
||||
}
|
||||
|
||||
private void submit() {
|
||||
String normalized = TwitchChannel.normalize(channel.getValue()).orElse(null);
|
||||
if (normalized == null || !save.active) return;
|
||||
ClientPlayNetworking.send(new SaveScreenChannelPayload(payload.pos(), normalized));
|
||||
onClose();
|
||||
}
|
||||
|
||||
private int panelX() {
|
||||
return (width - PANEL_WIDTH) / 2;
|
||||
}
|
||||
|
||||
private int panelY() {
|
||||
return Math.max(2, (height - PANEL_HEIGHT) / 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose() {
|
||||
if (minecraft != null) minecraft.gui.setScreen(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPauseScreen() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
package fr.koka99cab.sanctuary26.zevent.client.render;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import fr.koka99cab.sanctuary26.zevent.block.ZeventScreenBlock;
|
||||
import fr.koka99cab.sanctuary26.zevent.block.ZeventScreenLayout;
|
||||
import fr.koka99cab.sanctuary26.zevent.block.entity.ZeventScreenBlockEntity;
|
||||
import fr.koka99cab.sanctuary26.zevent.client.render.state.ZeventScreenRenderState;
|
||||
import fr.koka99cab.sanctuary26.zevent.client.twitch.TwitchBrowserManager;
|
||||
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.rendertype.RenderTypes;
|
||||
import net.minecraft.client.renderer.state.level.CameraRenderState;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.util.LightCoordsUtil;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
/** Projects one browser texture over the central block entity's complete 9x5 surface. */
|
||||
public final class ZeventScreenBlockEntityRenderer
|
||||
implements BlockEntityRenderer<ZeventScreenBlockEntity, ZeventScreenRenderState> {
|
||||
private static final int VIEW_DISTANCE = 128;
|
||||
private static final double VIEW_DISTANCE_SQR = VIEW_DISTANCE * VIEW_DISTANCE;
|
||||
private static final float HALF_WIDTH = 4.42F;
|
||||
private static final float HALF_HEIGHT = 2.42F;
|
||||
private static final float CENTER_TO_FRONT = 0.369F;
|
||||
|
||||
public ZeventScreenBlockEntityRenderer(BlockEntityRendererProvider.Context context) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ZeventScreenRenderState createRenderState() {
|
||||
return new ZeventScreenRenderState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void extractRenderState(ZeventScreenBlockEntity screen, ZeventScreenRenderState state,
|
||||
float tickProgress, Vec3 cameraPos, ModelFeatureRenderer.CrumblingOverlay crumblingOverlay) {
|
||||
BlockEntityRenderer.super.extractRenderState(screen, state, tickProgress, cameraPos, crumblingOverlay);
|
||||
state.texture = null;
|
||||
if (!ZeventScreenLayout.isController(screen.getBlockState()) || screen.getLevel() == null) return;
|
||||
state.facing = screen.getBlockState().getValue(ZeventScreenBlock.FACING);
|
||||
state.texture = TwitchBrowserManager.markVisible(screen.getLevel(), screen.getBlockPos(), screen.channel());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submit(ZeventScreenRenderState state, PoseStack poseStack,
|
||||
SubmitNodeCollector submitNodeCollector, CameraRenderState cameraRenderState) {
|
||||
if (state.texture == null) return;
|
||||
submitNodeCollector.submitCustomGeometry(poseStack,
|
||||
RenderTypes.entityTranslucentEmissive(state.texture),
|
||||
(pose, consumer) -> drawScreen(pose, consumer, state.facing));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRenderOffScreen() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViewDistance() {
|
||||
return VIEW_DISTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender(ZeventScreenBlockEntity screen, Vec3 cameraPos) {
|
||||
return ZeventScreenLayout.isController(screen.getBlockState())
|
||||
&& Vec3.atCenterOf(screen.getBlockPos()).distanceToSqr(cameraPos) <= VIEW_DISTANCE_SQR;
|
||||
}
|
||||
|
||||
private static void drawScreen(PoseStack.Pose pose, VertexConsumer consumer, Direction facing) {
|
||||
Direction right = ZeventScreenLayout.right(facing);
|
||||
float centerX = 0.5F - facing.getStepX() * CENTER_TO_FRONT;
|
||||
float centerZ = 0.5F - facing.getStepZ() * CENTER_TO_FRONT;
|
||||
vertex(consumer, pose, centerX, centerZ, right, facing, -HALF_WIDTH, -HALF_HEIGHT, 0.0F, 1.0F);
|
||||
vertex(consumer, pose, centerX, centerZ, right, facing, HALF_WIDTH, -HALF_HEIGHT, 1.0F, 1.0F);
|
||||
vertex(consumer, pose, centerX, centerZ, right, facing, HALF_WIDTH, HALF_HEIGHT, 1.0F, 0.0F);
|
||||
vertex(consumer, pose, centerX, centerZ, right, facing, -HALF_WIDTH, HALF_HEIGHT, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
private static void vertex(VertexConsumer consumer, PoseStack.Pose pose, float centerX, float centerZ,
|
||||
Direction right, Direction normal, float horizontal, float vertical, float u, float v) {
|
||||
consumer.addVertex(pose,
|
||||
centerX + right.getStepX() * horizontal,
|
||||
0.5F + vertical,
|
||||
centerZ + right.getStepZ() * horizontal)
|
||||
.setColor(0xFFFFFFFF)
|
||||
.setUv(u, v)
|
||||
.setOverlay(OverlayTexture.NO_OVERLAY)
|
||||
.setLight(LightCoordsUtil.FULL_BRIGHT)
|
||||
.setNormal(pose, normal.getStepX(), 0.0F, normal.getStepZ());
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user