mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-05 23:36:12 +00:00
Integrate markers with world mgr (initial spawns only so far)
This commit is contained in:
@@ -18,6 +18,8 @@
|
||||
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
|
||||
public interface IRare {
|
||||
static int get(Object v) {
|
||||
return v instanceof IRare ? Math.max(1, ((IRare) v).getRarity()) : 1;
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.volmit.iris.engine.object.annotations.RegistryListResource;
|
||||
import com.volmit.iris.engine.object.annotations.Required;
|
||||
import com.volmit.iris.engine.object.annotations.Snippet;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.math.BlockPosition;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.matter.slices.MarkerMatter;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -35,6 +36,7 @@ import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
@Snippet("entity-spawn")
|
||||
@@ -99,6 +101,40 @@ public class IrisEntitySpawn implements IRare {
|
||||
return s;
|
||||
}
|
||||
|
||||
public int spawn(Engine gen, IrisPosition c, RNG rng) {
|
||||
int spawns = minSpawns == maxSpawns ? minSpawns : rng.i(Math.min(minSpawns, maxSpawns), Math.max(minSpawns, maxSpawns));
|
||||
int s = 0;
|
||||
|
||||
if(!gen.getWorld().tryGetRealWorld())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
World world = gen.getWorld().realWorld();
|
||||
if (spawns > 0) {
|
||||
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);
|
||||
|
||||
if (referenceSpawner.getAllowedLightLevels().getMin() > 0 || referenceSpawner.getAllowedLightLevels().getMax() < 15) {
|
||||
if (referenceSpawner.getAllowedLightLevels().contains(l.getBlock().getLightLevel())) {
|
||||
if (spawn100(gen, l) != null) {
|
||||
s++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (spawn100(gen, l) != null) {
|
||||
s++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
public IrisEntity getRealEntity(Engine g) {
|
||||
return ent.aquire(() -> g.getData().getEntityLoader().load(getEntity()));
|
||||
}
|
||||
|
||||
@@ -41,11 +41,14 @@ import lombok.experimental.Accessors;
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class IrisMarker extends IrisRegistrant {
|
||||
@Desc("A list of spawners to add to anywhere this marker is. Note markers can only support initial spawns!")
|
||||
@Desc("A list of spawners to add to anywhere this marker is.")
|
||||
@RegistryListResource(IrisSpawner.class)
|
||||
@ArrayType(type = String.class, min = 1)
|
||||
private KList<String> spawners = new KList<>();
|
||||
|
||||
@Desc("Remove this marker when the block it's assigned to is changed.")
|
||||
private boolean removeOnChange = true;
|
||||
|
||||
@Override
|
||||
public String getFolderName() {
|
||||
return "markers";
|
||||
|
||||
Reference in New Issue
Block a user