mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-27 02:59:06 +00:00
Support initial spawns
This commit is contained in:
@@ -189,9 +189,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
}
|
||||
|
||||
Chunk c = cc[RNG.r.nextInt(cc.length)];
|
||||
IrisBiome biome = getEngine().getSurfaceBiome(c);
|
||||
IrisRegion region = getEngine().getRegion(c);
|
||||
spawnIn(c, biome, region);
|
||||
spawnIn(c, false);
|
||||
chunkCooldowns.put(Cache.key(c), M.ms());
|
||||
}
|
||||
|
||||
@@ -203,26 +201,29 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
energy = M.clip(energy, 1D, 1000D);
|
||||
}
|
||||
|
||||
private void spawnIn(Chunk c, IrisBiome biome, IrisRegion region) {
|
||||
private void spawnIn(Chunk c, boolean initial) {
|
||||
IrisBiome biome = getEngine().getSurfaceBiome(c);
|
||||
IrisRegion region = getEngine().getRegion(c);
|
||||
//@builder
|
||||
IrisEntitySpawn v = spawnRandomly(Stream.concat(Stream.concat(
|
||||
getData().getSpawnerLoader()
|
||||
.loadAll(getDimension().getEntitySpawners())
|
||||
.shuffleCopy(RNG.r).stream().filter(this::canSpawn),
|
||||
.shuffleCopy(RNG.r).stream()
|
||||
.filter(this::canSpawn),
|
||||
getData().getSpawnerLoader().streamAll(getEngine().getMantle()
|
||||
.getFeaturesInChunk(c).stream()
|
||||
.flatMap((o) -> o.getFeature().getEntitySpawners().stream()))
|
||||
.filter(this::canSpawn))
|
||||
.filter((i) -> i.isValid(biome))
|
||||
.flatMap(this::stream),
|
||||
.flatMap((i) -> stream(i, initial)),
|
||||
Stream.concat(getData().getSpawnerLoader()
|
||||
.loadAll(getEngine().getRegion(c.getX() << 4, c.getZ() << 4).getEntitySpawners())
|
||||
.shuffleCopy(RNG.r).stream().filter(this::canSpawn)
|
||||
.flatMap(this::stream),
|
||||
.flatMap((i) -> stream(i, initial)),
|
||||
getData().getSpawnerLoader()
|
||||
.loadAll(getEngine().getSurfaceBiome(c.getX() << 4, c.getZ() << 4).getEntitySpawners())
|
||||
.shuffleCopy(RNG.r).stream().filter(this::canSpawn)
|
||||
.flatMap(this::stream)))
|
||||
.flatMap((i) -> stream(i, initial))))
|
||||
.collect(Collectors.toList()))
|
||||
.popRandom(RNG.r);
|
||||
|
||||
@@ -282,8 +283,8 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
}
|
||||
}
|
||||
|
||||
private Stream<IrisEntitySpawn> stream(IrisSpawner s) {
|
||||
for (IrisEntitySpawn i : s.getSpawns()) {
|
||||
private Stream<IrisEntitySpawn> stream(IrisSpawner s, boolean initial) {
|
||||
for (IrisEntitySpawn i : initial ? s.getInitialSpawns() : s.getSpawns()) {
|
||||
i.setReferenceSpawner(s);
|
||||
}
|
||||
|
||||
@@ -343,6 +344,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
public void onChunkLoad(Chunk e, boolean generated) {
|
||||
if (generated) {
|
||||
energy += 1.2;
|
||||
spawnIn(e, true);
|
||||
} else {
|
||||
energy += 0.3;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,10 @@ public class IrisSpawner extends IrisRegistrant {
|
||||
@Desc("The entity spawns to add")
|
||||
private KList<IrisEntitySpawn> spawns = new KList<>();
|
||||
|
||||
@ArrayType(min = 1, type = IrisEntitySpawn.class)
|
||||
@Desc("The entity spawns to add initially. EXECUTES PER CHUNK!")
|
||||
private KList<IrisEntitySpawn> initialSpawns = new KList<>();
|
||||
|
||||
@Desc("The energy multiplier when calculating spawn energy usage")
|
||||
private double energyMultiplier = 1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user