mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 16:54:04 +00:00
README: iris:loot, iris:spawn and the new services of iris:objects; tree species by name
This commit is contained in:
1 parent
8428da4f50
commit
4735477918
3 files changed
+16
-5
No files matched your search
@@ -26,6 +26,14 @@ provides `ObjectsAt` (the objects a chunk would get, for the object search and s
|
||||
provides `StructureLocator` (`StructureLocating`: the pack's structure keys for Iris's structure index, the ones a
|
||||
world places, and their nearest start for the find commands). `iris:structure` also has a lifecycle hook that drops a
|
||||
world's structure index when the world stops, which includes every reload of the pack's structure files.
|
||||
`iris:objects` also provides `SaplingGrowth` (`TreeGrowing`: the tree a sapling grows into, as placed blocks, and which
|
||||
objects are trees) and says which biomes and regions place an object (`ObjectLocating`, for the object search).
|
||||
`iris:loot` owns the loot table resource kind (`LootResources`, folder `loot`), checks the tables and the references to
|
||||
them (`LootValidator`), and provides `Loot` (`LootGiving`: which tables a container draws from and the `ItemDrop`s a
|
||||
table gives) and `BlockDrops` (`BlockDropping`). `iris:spawn` owns spawners, entities and markers (`SpawnResources`,
|
||||
folders `spawners`, `entities`, `markers`) and provides `EntitySpawns` (`EntitySpawning`: what to spawn in a chunk or at
|
||||
a marker, as `EntitySpec`s; `EntityResolution` makes the entity's random choices). Iris's Bukkit code creates the items
|
||||
and entities from those values (`BukkitItemStacks`, `BukkitEntitySpawner`).
|
||||
`iris:decorant` keeps its per-world `Decorating` in the world's state store (`context.world().state(...)`); the other
|
||||
built-ins still reach the same store through `IrisChunk.state(...)` / `engine.getGeneration().state(...)`.
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@ import com.volmit.placement.PlacedBlock;
|
||||
import com.volmit.service.SaplingGrowth;
|
||||
import com.volmit.world.BlockPosition;
|
||||
import com.volmit.world.PackWorld;
|
||||
import org.bukkit.TreeType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
@@ -100,19 +99,18 @@ public final class TreeGrowing implements SaplingGrowth {
|
||||
|
||||
/** One placement, picked at random, of the tree placements that grow {@code sapling}'s species; null for none. */
|
||||
private static IrisObjectPlacement pickPlacement(Engine engine, Sapling sapling) {
|
||||
TreeType species = TreeType.valueOf(sapling.species());
|
||||
KList<IrisObjectPlacement> placements = new KList<>();
|
||||
boolean useAll = engine.getDimension().getTreeSettings().getMode().equals(IrisTreeModes.ALL);
|
||||
|
||||
BlockPosition at = sapling.at();
|
||||
placements.addAll(matching(engine.getBiome(at.x(), at.y(), at.z()).getObjects(), species));
|
||||
placements.addAll(matching(engine.getBiome(at.x(), at.y(), at.z()).getObjects(), sapling.species()));
|
||||
if (useAll || placements.isEmpty()) {
|
||||
placements.addAll(matching(engine.getRegion(at.x(), at.z()).getObjects(), species));
|
||||
placements.addAll(matching(engine.getRegion(at.x(), at.z()).getObjects(), sapling.species()));
|
||||
}
|
||||
return placements.isNotEmpty() ? placements.getRandom() : null;
|
||||
}
|
||||
|
||||
private static KList<IrisObjectPlacement> matching(KList<IrisObjectPlacement> objects, TreeType species) {
|
||||
private static KList<IrisObjectPlacement> matching(KList<IrisObjectPlacement> objects, String species) {
|
||||
KList<IrisObjectPlacement> matches = new KList<>();
|
||||
for (IrisObjectPlacement placement : objects) {
|
||||
if (placement.matches(SAPLING_SIZE, species)) {
|
||||
|
||||
@@ -272,6 +272,11 @@ public class IrisObjectPlacement {
|
||||
return g.getData().getObjectLoader().load(place.get(random.nextInt(place.size())));
|
||||
}
|
||||
|
||||
/** Whether a tree placement grows the species the platform calls {@code species} for a sapling area of {@code size}. */
|
||||
public boolean matches(IrisTreeSize size, String species) {
|
||||
return matches(size, TreeType.valueOf(species));
|
||||
}
|
||||
|
||||
public boolean matches(IrisTreeSize size, TreeType type) {
|
||||
for (IrisTree i : getTrees()) {
|
||||
if (i.matches(size, type)) {
|
||||
|
||||
Reference in new issue
Block a user