mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-07 16:26:14 +00:00
Spawners
This commit is contained in:
@@ -64,17 +64,15 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
@Desc("If the biome type custom is defined, specify this")
|
||||
private KList<IrisBiomeCustom> customDerivitives;
|
||||
|
||||
@Desc("Entity spawns to override or add to this biome. Anytime an entity spawns, it has a chance to be replaced as one of these overrides.")
|
||||
@ArrayType(min = 1, type = IrisEntitySpawnOverride.class)
|
||||
private KList<IrisEntitySpawnOverride> entitySpawnOverrides = new KList<>();
|
||||
@Desc("Spawn Entities in this area over time. Iris will continually replenish these mobs just like vanilla does.")
|
||||
@ArrayType(min = 1, type = String.class)
|
||||
@RegistryListSpawner
|
||||
private KList<String> entitySpawners = new KList<>();
|
||||
|
||||
@Desc("Add random chances for terrain features")
|
||||
@ArrayType(min = 1, type = IrisFeaturePotential.class)
|
||||
private KList<IrisFeaturePotential> features = new KList<>();
|
||||
|
||||
@Desc("Entity spawns during generation")
|
||||
@ArrayType(min = 1, type = IrisEntityInitialSpawn.class)
|
||||
private KList<IrisEntityInitialSpawn> entityInitialSpawns = new KList<>();
|
||||
|
||||
@ArrayType(min = 1, type = IrisEffect.class)
|
||||
@Desc("Effects are ambient effects such as potion effects, random sounds, or even particles around each player. All of these effects are played via packets so two players won't see/hear each others effects.\nDue to performance reasons, effects will play around the player even if where the effect was played is no longer in the biome the player is in.")
|
||||
|
||||
@@ -80,18 +80,15 @@ public class IrisDimension extends IrisRegistrant {
|
||||
@Desc("Upon joining this world, Iris will send a resource pack request to the client. If they have previously selected yes, it will auto-switch depending on which dimension they go to.")
|
||||
private String resourcePack = "";
|
||||
|
||||
@Desc("Entity spawns to override or add to this dimension")
|
||||
@ArrayType(min = 1, type = IrisEntitySpawnOverride.class)
|
||||
private KList<IrisEntitySpawnOverride> entitySpawnOverrides = new KList<>();
|
||||
@Desc("Spawn Entities in this dimension over time. Iris will continually replenish these mobs just like vanilla does.")
|
||||
@ArrayType(min = 1, type = String.class)
|
||||
@RegistryListSpawner
|
||||
private KList<String> entitySpawners = new KList<>();
|
||||
|
||||
@Desc("Add specific features in exact positions")
|
||||
@ArrayType(min = 1, type = IrisFeaturePositional.class)
|
||||
private KList<IrisFeaturePositional> specificFeatures = new KList<>();
|
||||
|
||||
@Desc("Entity spawns during generation")
|
||||
@ArrayType(min = 1, type = IrisEntityInitialSpawn.class)
|
||||
private KList<IrisEntityInitialSpawn> entityInitialSpawns = new KList<>();
|
||||
|
||||
@Desc("Add random chances for terrain features")
|
||||
@ArrayType(min = 1, type = IrisFeaturePotential.class)
|
||||
private KList<IrisFeaturePotential> features = new KList<>();
|
||||
|
||||
@@ -39,7 +39,7 @@ import org.bukkit.entity.Entity;
|
||||
@AllArgsConstructor
|
||||
@Desc("Represents an entity spawn during initial chunk generation")
|
||||
@Data
|
||||
public class IrisEntityInitialSpawn {
|
||||
public class IrisEntitySpawn {
|
||||
@RegistryListEntity
|
||||
@Required
|
||||
@Desc("The entity")
|
||||
@@ -60,7 +60,7 @@ public class IrisEntityInitialSpawn {
|
||||
private final transient AtomicCache<RNG> rng = new AtomicCache<>();
|
||||
private final transient AtomicCache<IrisEntity> ent = new AtomicCache<>();
|
||||
|
||||
public void spawn(Engine gen, Chunk c, RNG rng) {
|
||||
public boolean spawn(Engine gen, Chunk c, RNG rng) {
|
||||
int spawns = rng.i(1, rarity) == 1 ? rng.i(minSpawns, maxSpawns) : 0;
|
||||
|
||||
if (spawns > 0) {
|
||||
@@ -70,7 +70,11 @@ public class IrisEntityInitialSpawn {
|
||||
int h = gen.getHeight(x, z) + gen.getMinHeight();
|
||||
spawn100(gen, new Location(c.getWorld(), x, h, z));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public IrisEntity getRealEntity(Engine g) {
|
||||
@@ -91,10 +95,12 @@ public class IrisEntityInitialSpawn {
|
||||
|
||||
private Entity spawn100(Engine g, Location at) {
|
||||
try {
|
||||
return getRealEntity(g).spawn(g, at.clone().add(0.5, 1, 0.5), rng.aquire(() -> new RNG(g.getTarget().getWorld().seed() + 4)));
|
||||
Location l = at.clone().add(0.5, 1, 0.5);
|
||||
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.debug("Failed to retrieve real entity @ " + at);
|
||||
Iris.error("Failed to retrieve real entity @ " + at);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -67,13 +67,10 @@ public class IrisRegion extends IrisRegistrant implements IRare {
|
||||
@Desc("Effects are ambient effects such as potion effects, random sounds, or even particles around each player. All of these effects are played via packets so two players won't see/hear each others effects.\nDue to performance reasons, effects will play arround the player even if where the effect was played is no longer in the biome the player is in.")
|
||||
private KList<IrisEffect> effects = new KList<>();
|
||||
|
||||
@Desc("Entity spawns to override or add to this region")
|
||||
@ArrayType(min = 1, type = IrisEntitySpawnOverride.class)
|
||||
private KList<IrisEntitySpawnOverride> entitySpawnOverrides = new KList<>();
|
||||
|
||||
@Desc("Entity spawns during generation")
|
||||
@ArrayType(min = 1, type = IrisEntityInitialSpawn.class)
|
||||
private KList<IrisEntityInitialSpawn> entityInitialSpawns = new KList<>();
|
||||
@Desc("Spawn Entities in this region over time. Iris will continually replenish these mobs just like vanilla does.")
|
||||
@ArrayType(min = 1, type = String.class)
|
||||
@RegistryListSpawner
|
||||
private KList<String> entitySpawners = new KList<>();
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(128)
|
||||
|
||||
51
src/main/java/com/volmit/iris/engine/object/IrisSpawner.java
Normal file
51
src/main/java/com/volmit/iris/engine/object/IrisSpawner.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.framework.Engine;
|
||||
import com.volmit.iris.engine.object.annotations.*;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.bukkit.Chunk;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("Represents an entity spawn during initial chunk generation")
|
||||
@Data
|
||||
public class IrisSpawner extends IrisRegistrant {
|
||||
@ArrayType(min = 1, type = IrisEntitySpawn.class)
|
||||
@Desc("The entity spawns to add")
|
||||
private KList<IrisEntitySpawn> spawns = new KList<>();
|
||||
|
||||
public boolean spawnInChunk(Engine engine, Chunk c) {
|
||||
if(spawns.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return spawns.getRandom().spawn(engine, c, RNG.r);
|
||||
}
|
||||
}
|
||||
@@ -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.annotations;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
@Retention(RUNTIME)
|
||||
@Target({PARAMETER, TYPE, FIELD})
|
||||
public @interface RegistryListSpawner {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user