This commit is contained in:
Daniel Mills
2021-07-31 19:41:12 -04:00
parent 16de60f82d
commit ee18217520
9 changed files with 257 additions and 58 deletions

View File

@@ -19,13 +19,16 @@
package com.volmit.iris.engine.object;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.engine.cache.AtomicCache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.annotations.Desc;
import com.volmit.iris.engine.object.annotations.MinNumber;
import com.volmit.iris.engine.object.annotations.RegistryListEntity;
import com.volmit.iris.engine.object.annotations.Required;
import com.volmit.iris.engine.object.common.IRare;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.scheduling.J;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -39,7 +42,7 @@ import org.bukkit.entity.Entity;
@AllArgsConstructor
@Desc("Represents an entity spawn during initial chunk generation")
@Data
public class IrisEntitySpawn {
public class IrisEntitySpawn implements IRare {
@RegistryListEntity
@Required
@Desc("The entity")
@@ -61,13 +64,13 @@ public class IrisEntitySpawn {
private final transient AtomicCache<IrisEntity> ent = new AtomicCache<>();
public boolean spawn(Engine gen, Chunk c, RNG rng) {
int spawns = rng.i(1, rarity) == 1 ? rng.i(minSpawns, maxSpawns) : 0;
int spawns = minSpawns == maxSpawns ? minSpawns : rng.i(Math.min(minSpawns, maxSpawns), Math.max(minSpawns, maxSpawns));
if (spawns > 0) {
for (int i = 0; i < spawns; i++) {
int x = (c.getX() * 16) + rng.i(15);
int z = (c.getZ() * 16) + rng.i(15);
int h = gen.getHeight(x, z) + gen.getMinHeight();
int h = c.getWorld().getHighestBlockYAt(x, z);
spawn100(gen, new Location(c.getWorld(), x, h, z));
}
@@ -96,11 +99,11 @@ public class IrisEntitySpawn {
private Entity spawn100(Engine g, Location at) {
try {
Location l = at.clone().add(0.5, 1, 0.5);
Iris.debug(" Spawned " + "Entity<" + getEntity() + "> at " + l.getBlockX() + "," + l.getBlockY() + "," + l.getBlockZ());
Iris.debug(" Spawned " + "Entity<" + getEntity() + "> at " + l.getBlockX() + "," + l.getBlockY() + "," + l.getBlockZ());
return getRealEntity(g).spawn(g, l, rng.aquire(() -> new RNG(g.getTarget().getWorld().seed() + 4)));
} catch (Throwable e) {
Iris.reportError(e);
Iris.error("Failed to retrieve real entity @ " + at);
Iris.error(" Failed to retrieve real entity @ " + at);
return null;
}
}

View File

@@ -18,10 +18,16 @@
package com.volmit.iris.engine.object;
import com.volmit.iris.Iris;
import com.volmit.iris.engine.cache.AtomicCache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.annotations.*;
import com.volmit.iris.engine.object.common.IRare;
import com.volmit.iris.engine.stream.ProceduralStream;
import com.volmit.iris.engine.stream.convert.SelectionStream;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.reflect.V;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -40,12 +46,23 @@ public class IrisSpawner extends IrisRegistrant {
@Desc("The entity spawns to add")
private KList<IrisEntitySpawn> spawns = new KList<>();
private AtomicCache<KList<IrisEntitySpawn>> selection = new AtomicCache<>();
public boolean spawnInChunk(Engine engine, Chunk c) {
if(spawns.isEmpty())
{
Iris.warn(" Spawner " + getLoadKey() + " has an empty spawn list! (" + getLoadFile().getPath() + ")");
return false;
}
return spawns.getRandom().spawn(engine, c, RNG.r);
return selection.aquire(() -> {
KList<IrisEntitySpawn> rarityTypes = new KList<>();
for (IrisEntitySpawn i : spawns) {
rarityTypes.addMultiple(i, IRare.get(i));
}
return rarityTypes;
}).getRandom(RNG.r).spawn(engine, c, RNG.r);
}
}

View File

@@ -0,0 +1,37 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.engine.object;
import com.volmit.iris.engine.object.annotations.Desc;
import lombok.Data;
@Data
@Desc("Represents a time of day (24h time, not 12h am/pm)")
public class IrisTime {
@Desc("The beginning hour")
private double startHour = 0;
@Desc("The ending hour")
private double endHour = 24;
public boolean isWithin(double hour)
{
}
}

View File

@@ -0,0 +1,31 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.engine.object;
import com.volmit.iris.engine.object.annotations.Desc;
import lombok.Data;
@Desc("Represents a weather type")
public enum IrisWeather {
@Desc("Represents when weather is not causing downfall")
NONE,
@Desc("Represents rain or snow")
DOWNFALL
}