From a707b237cfe25021a1815837e426659a295a2a53 Mon Sep 17 00:00:00 2001 From: piexel Date: Sat, 10 Oct 2026 14:25:14 +0200 Subject: [PATCH] StructureFit.log(): a vanilla structure fit knows the log of the module it was handed to; each provider gets its own fit --- README.md | 4 ++-- src/main/java/com/volmit/vanilla/StructureFit.java | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e70b738a6..7bcb65f44 100644 --- a/README.md +++ b/README.md @@ -289,8 +289,8 @@ private static void decorate(ChunkStageContext context) { | `error(message, cause)` | A failure the module caught and cannot recover from. The host logs it and reports `cause` like its own failures. A null `cause` only logs. | - A message is plain text, never a format string. -- `context.log()` (stage bodies, object generators), `world.log()` (services and lifecycle hooks, which get a world as - their argument) and `registry.log()` (while `register` runs) are the same module's log. Keep the registry's log in a +- `context.log()` (stage bodies, object generators), `fit.log()` (vanilla structure fits), `world.log()` (services and + lifecycle hooks, which get a world as their argument) and `registry.log()` (while `register` runs) are the same module's log. Keep the registry's log in a field when `packLoaded`, which has no world, needs to log. `registry.log()` outside `register` throws. - Do not use `System.out`, `System.getLogger` or a logging library of your own: the host cannot label or report them. diff --git a/src/main/java/com/volmit/vanilla/StructureFit.java b/src/main/java/com/volmit/vanilla/StructureFit.java index 16954ab1d..fa58bfa21 100644 --- a/src/main/java/com/volmit/vanilla/StructureFit.java +++ b/src/main/java/com/volmit/vanilla/StructureFit.java @@ -1,5 +1,6 @@ package com.volmit.vanilla; +import com.volmit.ModuleLog; import com.volmit.block.BlockState; import com.volmit.mantle.BlockBox; import com.volmit.resource.ResourceId; @@ -13,12 +14,17 @@ import java.util.function.Supplier; /** The starts the platform places in one chunk while it decorates it, and the chunk's blocks, for modules that fit * those starts into the terrain ({@link com.volmit.service.VanillaStructures#beforePieces}, * {@link com.volmit.service.VanillaStructures#afterPieces}). Heights are above the dimension's bottom (0 = bottom) unless - * a method says otherwise. One fit is handed to every provider for the chunk; it is valid only while they run, on one - * thread. + * a method says otherwise. Each provider gets its own fit of the chunk, over the same blocks and scoped to its module, which + * is valid only while the providers run, on one thread. */ public interface StructureFit { PackWorld world(); + /** The log of the module this fit was handed to; the same as {@code world().log()}, which a host overrides where a fit has no world. */ + default ModuleLog log() { + return world().log(); + } + /** The seed of the platform's world, which the platform's own structure randomness derives from. */ long seed();