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