mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 08:44:50 +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
@@ -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