From 131f1575ae746f2fcbc2f8dc5fe097fddba07c58 Mon Sep 17 00:00:00 2001 From: piexel Date: Fri, 6 Nov 2026 12:59:35 +0100 Subject: [PATCH] Document that only the host makes PlaceableObjects PlaceableObject was described as immutable and implementable. The host rejects foreign implementations, and smartBored now returns a copy instead of changing the shared object. The javadoc and README say so. --- README.md | 2 ++ api/src/main/java/com/volmit/object/PackObjects.java | 9 ++++++--- api/src/main/java/com/volmit/object/PlaceableObject.java | 7 ++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d266e476e..3ee93d6de 100644 --- a/README.md +++ b/README.md @@ -286,6 +286,8 @@ if (!outcome.isPlaced()) { - `PackObjects` gives an object of the pack by id, its size without loading it (`sizeOf`, for a reach), a scaled or smart-bored copy, and objects a module builds block by block (`build`). The host keeps them per pack snapshot. + Only `PackObjects` makes a `PlaceableObject`; a module does not implement it, and the host rejects one it did not + make. `scaled` and `smartBored` return other objects and leave the original as it was. - `PlacementTerrain` is the world the placement reads and the host writes into once it commits: heights, blocks, carved space, fluid, the structures nearby and the placement recorded at a block (`recordPlacement`, `placementAt`; `RunningWorld.placementAt` reads it back later, such as for the loot of a placed object). A recorded placement is a diff --git a/api/src/main/java/com/volmit/object/PackObjects.java b/api/src/main/java/com/volmit/object/PackObjects.java index 4d39cae7b..fd0a69f3d 100644 --- a/api/src/main/java/com/volmit/object/PackObjects.java +++ b/api/src/main/java/com/volmit/object/PackObjects.java @@ -9,7 +9,9 @@ import java.util.Optional; /** * The pack's objects, ready to place, and the objects made from them: scaled variants and objects a module builds block * by block. The host loads, scales and keeps them for the pack snapshot, so asking again is cheap. Reached through - * {@link com.volmit.resource.PackResources#objects()}; safe for concurrent calls. + * {@link com.volmit.resource.PackResources#objects()}; safe for concurrent calls. This is the only source of + * {@link PlaceableObject}s: {@link #scaled} and {@link #smartBored} throw IllegalArgumentException for an object that + * did not come from here. */ public interface PackObjects { /** The pack object {@code id} names, as {@link com.volmit.resource.PackResources#idOf} gives it for the key; empty when the pack has none. */ @@ -25,8 +27,9 @@ public interface PackObjects { PlaceableObject scaled(PlaceableObject object, double factor, ScaleMethod method); /** - * {@code object} with air in the rooms and pockets a placement should clear, found by casting rays through it. Done - * once per object; the object itself keeps the air, so later placements of it see it too. + * A copy of {@code object} with air in the rooms and pockets a placement should clear, found by casting rays through + * it; {@code object} itself is not changed. Done once per object, so asking again returns the same copy, and boring + * the copy returns the copy. */ PlaceableObject smartBored(PlaceableObject object); diff --git a/api/src/main/java/com/volmit/object/PlaceableObject.java b/api/src/main/java/com/volmit/object/PlaceableObject.java index 1fca2658f..6ee5c4445 100644 --- a/api/src/main/java/com/volmit/object/PlaceableObject.java +++ b/api/src/main/java/com/volmit/object/PlaceableObject.java @@ -5,7 +5,12 @@ import com.volmit.geometry.BlockPosition; /** * An object ready to be placed: one of the pack's, a scaled variant of one, or one a module built * ({@link PackObjects}). Its size is the size it was declared with, which boring and terrain bends cover even where it - * has no block. Immutable; safe to share between threads. + * has no block. + * + *

Only the host makes a {@code PlaceableObject}, and only through {@link PackObjects}: a module reads this interface + * and does not implement it. {@link PackObjects} rejects an object it did not make with IllegalArgumentException. The + * host never changes an object it handed out (scaling or boring one returns another object), so it is safe to share + * between threads. */ public interface PlaceableObject { /**