mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-30 17:54:56 +00:00
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:
1 parent
0691753d21
commit
131f1575ae
3 files changed
+14
-4
No files matched your search
@@ -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
|
- `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.
|
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,
|
- `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`;
|
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
|
`RunningWorld.placementAt` reads it back later, such as for the loot of a placed object). A recorded placement is a
|
||||||
|
|||||||
@@ -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
|
* 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
|
* 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 {
|
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. */
|
/** 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);
|
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
|
* A copy of {@code object} with air in the rooms and pockets a placement should clear, found by casting rays through
|
||||||
* once per object; the object itself keeps the air, so later placements of it see it too.
|
* 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);
|
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
|
* 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
|
* ({@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 {
|
public interface PlaceableObject {
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in new issue
Block a user