mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 10:12:53 +00:00
Marker spawning
This commit is contained in:
parent
03bc1e722e
commit
6daf0861c9
@ -171,13 +171,28 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
|
|
||||||
private void updateChunks() {
|
private void updateChunks() {
|
||||||
for (Player i : getEngine().getWorld().realWorld().getPlayers()) {
|
for (Player i : getEngine().getWorld().realWorld().getPlayers()) {
|
||||||
int r = 1;
|
int r = 2;
|
||||||
|
|
||||||
Chunk c = i.getLocation().getChunk();
|
Chunk c = i.getLocation().getChunk();
|
||||||
for (int x = -r; x <= r; x++) {
|
for (int x = -r; x <= r; x++) {
|
||||||
for (int z = -r; z <= r; z++) {
|
for (int z = -r; z <= r; z++) {
|
||||||
if (c.getWorld().isChunkLoaded(c.getX() + x, c.getZ() + z)) {
|
if (c.getWorld().isChunkLoaded(c.getX() + x, c.getZ() + z) && Chunks.isSafe(getEngine().getWorld().realWorld(), c.getX() + x, c.getZ() + z)) {
|
||||||
getEngine().updateChunk(c.getWorld().getChunkAt(c.getX() + x, c.getZ() + z));
|
getEngine().updateChunk(c.getWorld().getChunkAt(c.getX() + x, c.getZ() + z));
|
||||||
|
Chunk cx = getEngine().getWorld().realWorld().getChunkAt(c.getX() + x, c.getZ() + z);
|
||||||
|
int finalX = c.getX() + x;
|
||||||
|
int finalZ = c.getZ() + z;
|
||||||
|
J.a(() -> getMantle().raiseFlag(finalX, finalZ, MantleFlag.INITIAL_SPAWNED_MARKER,
|
||||||
|
() -> {
|
||||||
|
J.a(() -> spawnIn(cx, true), RNG.r.i(5, 200));
|
||||||
|
getSpawnersFromMarkers(cx).forEach((block, spawners) -> {
|
||||||
|
if (spawners.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
IrisSpawner s = new KList<>(spawners).getRandom();
|
||||||
|
spawn(block, s, true);
|
||||||
|
});
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -438,18 +453,6 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChunkLoad(Chunk e, boolean generated) {
|
public void onChunkLoad(Chunk e, boolean generated) {
|
||||||
J.a(() -> getMantle().raiseFlag(e.getX(), e.getZ(), MantleFlag.INITIAL_SPAWNED,
|
|
||||||
() -> {
|
|
||||||
J.a(() -> spawnIn(e, true), RNG.r.i(5, 200));
|
|
||||||
getSpawnersFromMarkers(e).forEach((block, spawners) -> {
|
|
||||||
if (spawners.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
IrisSpawner s = new KList<>(spawners).getRandom();
|
|
||||||
spawn(block, s, true);
|
|
||||||
});
|
|
||||||
}));
|
|
||||||
energy += 0.3;
|
energy += 0.3;
|
||||||
fixEnergy();
|
fixEnergy();
|
||||||
}
|
}
|
||||||
@ -464,7 +467,9 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
spawn(block, spawnRandomly(s).getRandom());
|
IrisEntitySpawn ss = spawnRandomly(s).getRandom();
|
||||||
|
ss.setReferenceSpawner(spawner);
|
||||||
|
spawn(block, ss);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Mantle getMantle() {
|
public Mantle getMantle() {
|
||||||
|
@ -111,19 +111,16 @@ public class IrisEntitySpawn implements IRare {
|
|||||||
World world = gen.getWorld().realWorld();
|
World world = gen.getWorld().realWorld();
|
||||||
if (spawns > 0) {
|
if (spawns > 0) {
|
||||||
for (int id = 0; id < spawns; id++) {
|
for (int id = 0; id < spawns; id++) {
|
||||||
int x = c.getX();
|
|
||||||
int z = c.getZ();
|
|
||||||
int h = c.getY();
|
|
||||||
Location l = c.toLocation(world).add(0, 1, 0);
|
Location l = c.toLocation(world).add(0, 1, 0);
|
||||||
|
|
||||||
if (referenceSpawner.getAllowedLightLevels().getMin() > 0 || referenceSpawner.getAllowedLightLevels().getMax() < 15) {
|
if (referenceSpawner.getAllowedLightLevels().getMin() > 0 || referenceSpawner.getAllowedLightLevels().getMax() < 15) {
|
||||||
if (referenceSpawner.getAllowedLightLevels().contains(l.getBlock().getLightLevel())) {
|
if (referenceSpawner.getAllowedLightLevels().contains(l.getBlock().getLightLevel())) {
|
||||||
if (spawn100(gen, l) != null) {
|
if (spawn100(gen, l, true) != null) {
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (spawn100(gen, l) != null) {
|
if (spawn100(gen, l, true) != null) {
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -150,11 +147,16 @@ public class IrisEntitySpawn implements IRare {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Entity spawn100(Engine g, Location at) {
|
private Entity spawn100(Engine g, Location at) {
|
||||||
|
return spawn100(g, at, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Entity spawn100(Engine g, Location at, boolean ignoreSurfaces) {
|
||||||
try {
|
try {
|
||||||
IrisEntity irisEntity = getRealEntity(g);
|
IrisEntity irisEntity = getRealEntity(g);
|
||||||
|
|
||||||
if (!irisEntity.getSurface().matches(at.clone().subtract(0, 1, 0).getBlock()))
|
if (!ignoreSurfaces && !irisEntity.getSurface().matches(at.clone().subtract(0, 1, 0).getBlock())) {
|
||||||
return null; //Make sure it can spawn on the block
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
Entity e = irisEntity.spawn(g, at.add(0.5, 0, 0.5), rng.aquire(() -> new RNG(g.getSeedManager().getEntity())));
|
Entity e = irisEntity.spawn(g, at.add(0.5, 0, 0.5), rng.aquire(() -> new RNG(g.getSeedManager().getEntity())));
|
||||||
if (e != null) {
|
if (e != null) {
|
||||||
|
@ -28,7 +28,8 @@ public enum MantleFlag {
|
|||||||
INITIAL_SPAWNED,
|
INITIAL_SPAWNED,
|
||||||
REAL,
|
REAL,
|
||||||
CARVED,
|
CARVED,
|
||||||
FLUID_BODIES;
|
FLUID_BODIES,
|
||||||
|
INITIAL_SPAWNED_MARKER;
|
||||||
|
|
||||||
static StateList getStateList() {
|
static StateList getStateList() {
|
||||||
return new StateList(MantleFlag.values());
|
return new StateList(MantleFlag.values());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user