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.
This commit is contained in:
piexel committed 2026-11-06 12:59:35 +01:00
1 parent 0691753d21
commit 131f1575ae
3 files changed
+14 -4

No files matched your search

@@ -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);
@@ -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.
*
* <p>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 {
/**