9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-26 18:49:06 +00:00

Light level for spawns closes #558

This commit is contained in:
cyberpwn
2021-08-18 14:24:03 -04:00
parent 5286a69c34
commit 4396ca9420
3 changed files with 27 additions and 2 deletions

View File

@@ -44,4 +44,8 @@ public class IrisRange {
return rng.d(min, max);
}
public boolean contains(int v) {
return v >= min && v <= max;
}
}

View File

@@ -105,8 +105,24 @@ public class IrisEntitySpawn implements IRare {
};
if (l != null) {
if (spawn100(gen, l) != null)
s++;
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++;
}
}
}
}
}

View File

@@ -21,6 +21,7 @@ package com.volmit.iris.engine.object.spawners;
import com.volmit.iris.core.project.loader.IrisRegistrant;
import com.volmit.iris.engine.object.annotations.ArrayType;
import com.volmit.iris.engine.object.annotations.Desc;
import com.volmit.iris.engine.object.basic.IrisRange;
import com.volmit.iris.engine.object.basic.IrisRate;
import com.volmit.iris.engine.object.basic.IrisTimeBlock;
import com.volmit.iris.engine.object.basic.IrisWeather;
@@ -32,6 +33,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.bukkit.Bukkit;
import org.bukkit.World;
@EqualsAndHashCode(callSuper = true)
@@ -67,6 +69,9 @@ public class IrisSpawner extends IrisRegistrant {
@Desc("The maximum rate this spawner can fire on a specific chunk")
private IrisRate maximumRatePerChunk = new IrisRate();
@Desc("The light levels this spawn is allowed to run in (0-15 inclusive)")
private IrisRange allowedLightLevels = new IrisRange(0, 15);
@Desc("Where should these spawns be placed")
private IrisSpawnGroup group = IrisSpawnGroup.NORMAL;