mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-06 15:56:27 +00:00
Merge remote-tracking branch 'upstream/master' into compatbug
This commit is contained in:
@@ -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.common;
|
||||
|
||||
import com.volmit.iris.core.project.loader.IrisRegistrant;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class IrisScript extends IrisRegistrant {
|
||||
private final String source;
|
||||
|
||||
public IrisScript() {
|
||||
this("");
|
||||
}
|
||||
|
||||
public IrisScript(String source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFolderName() {
|
||||
return "scripts";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return "Script";
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return source;
|
||||
}
|
||||
}
|
||||
@@ -316,6 +316,9 @@ public class IrisDimension extends IrisRegistrant {
|
||||
@Desc("Define carve layers")
|
||||
private KList<IrisCarveLayer> carveLayers = new KList<>();
|
||||
|
||||
@Desc("If true, the spawner system has infinite energy. This is NOT recommended because it would allow for mobs to keep spawning over and over without a rate limit")
|
||||
private boolean infiniteEnergy = false;
|
||||
|
||||
@MinNumber(0.0001)
|
||||
@MaxNumber(512)
|
||||
@Desc("The rock zoom mostly for zooming in on a wispy palette")
|
||||
|
||||
@@ -21,10 +21,8 @@ package com.volmit.iris.engine.object.entity;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.project.loader.IrisRegistrant;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.object.annotations.ArrayType;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.engine.object.annotations.RegistryListSpecialEntity;
|
||||
import com.volmit.iris.engine.object.annotations.Required;
|
||||
import com.volmit.iris.engine.object.annotations.*;
|
||||
import com.volmit.iris.engine.object.common.IrisScript;
|
||||
import com.volmit.iris.engine.object.loot.IrisLoot;
|
||||
import com.volmit.iris.engine.object.loot.IrisLootReference;
|
||||
import com.volmit.iris.engine.object.loot.IrisLootTable;
|
||||
@@ -155,17 +153,39 @@ public class IrisEntity extends IrisRegistrant {
|
||||
@Desc("Create a mob from another plugin, such as Mythic Mobs. Should be in the format of a namespace of PluginName:MobName")
|
||||
private String specialType = "";
|
||||
|
||||
@Desc("Set the entity type to UNKNOWN, then define a script here which ends with the entity variable (the result). You can use Iris.getLocation() to find the target location. You can spawn any entity this way.")
|
||||
@RegistryListResource(IrisScript.class)
|
||||
private String spawnerScript = "";
|
||||
|
||||
@ArrayType(min = 1, type = String.class)
|
||||
@Desc("Set the entity type to UNKNOWN, then define a script here. You can use Iris.getLocation() to find the target location. You can spawn any entity this way.")
|
||||
@RegistryListResource(IrisScript.class)
|
||||
private KList<String> postSpawnScripts = new KList<>();
|
||||
|
||||
public Entity spawn(Engine gen, Location at) {
|
||||
return spawn(gen, at, new RNG(at.hashCode()));
|
||||
}
|
||||
|
||||
public Entity spawn(Engine gen, Location at, RNG rng) {
|
||||
Entity e = doSpawn(at);
|
||||
Entity ee = doSpawn(at);
|
||||
|
||||
if (e == null) {
|
||||
if (!spawnerScript.isEmpty() && ee == null) {
|
||||
synchronized (this) {
|
||||
gen.getExecution().getAPI().setLocation(at);
|
||||
try {
|
||||
ee = (Entity) gen.getExecution().evaluate(spawnerScript);
|
||||
} catch (Throwable ex) {
|
||||
Iris.error("You must return an Entity in your scripts to use entity scripts!");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ee == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Entity e = ee;
|
||||
e.setCustomName(getCustomName() != null ? C.translateAlternateColorCodes('&', getCustomName()) : null);
|
||||
e.setCustomNameVisible(isCustomNameVisible());
|
||||
e.setGlowing(isGlowing());
|
||||
@@ -286,10 +306,25 @@ public class IrisEntity extends IrisRegistrant {
|
||||
spawnEffect.apply(e);
|
||||
}
|
||||
|
||||
if (postSpawnScripts.isNotEmpty()) {
|
||||
synchronized (this) {
|
||||
gen.getExecution().getAPI().setLocation(at);
|
||||
gen.getExecution().getAPI().setEntity(ee);
|
||||
|
||||
for (String i : postSpawnScripts) {
|
||||
gen.getExecution().execute(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
private Entity doSpawn(Location at) {
|
||||
if (type.equals(EntityType.UNKNOWN)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!Bukkit.isPrimaryThread()) {
|
||||
// Someone called spawn (worldedit maybe?) on a non server thread
|
||||
// Due to the structure of iris, we will call it sync and busy wait until it's done.
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.engine.IrisComplex;
|
||||
import com.volmit.iris.engine.data.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.framework.EngineFramework;
|
||||
import com.volmit.iris.engine.modifier.IrisCaveModifier;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.engine.object.annotations.MinNumber;
|
||||
@@ -86,12 +85,11 @@ public class IrisEntitySpawn implements IRare {
|
||||
Location l = switch (getReferenceSpawner().getGroup()) {
|
||||
case NORMAL -> new Location(c.getWorld(), x, hf + 1, z);
|
||||
case CAVE -> {
|
||||
IrisComplex comp = gen.getFramework().getComplex();
|
||||
EngineFramework frame = gen.getFramework();
|
||||
IrisComplex comp = gen.getComplex();
|
||||
IrisBiome cave = comp.getCaveBiomeStream().get(x, z);
|
||||
KList<Location> r = new KList<>();
|
||||
if (cave != null) {
|
||||
for (CaveResult i : ((IrisCaveModifier) frame.getCaveModifier()).genCaves(x, z)) {
|
||||
for (CaveResult i : ((IrisCaveModifier) gen.getCaveModifier()).genCaves(x, z)) {
|
||||
if (i.getCeiling() >= gen.getHeight() || i.getFloor() < 0 || i.getCeiling() - 2 <= i.getFloor()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package com.volmit.iris.engine.object.noise;
|
||||
|
||||
import com.volmit.iris.engine.framework.EngineFramework;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.util.stream.ProceduralStream;
|
||||
|
||||
@@ -56,13 +56,13 @@ public enum IrisEngineStreamType {
|
||||
@Desc("Represents the identity of regions. Each region has a unique number (very large numbers)")
|
||||
REGION_IDENTITY((f) -> f.getComplex().getRegionIdentityStream());
|
||||
|
||||
private final Function<EngineFramework, ProceduralStream<Double>> getter;
|
||||
private final Function<Engine, ProceduralStream<Double>> getter;
|
||||
|
||||
IrisEngineStreamType(Function<EngineFramework, ProceduralStream<Double>> getter) {
|
||||
IrisEngineStreamType(Function<Engine, ProceduralStream<Double>> getter) {
|
||||
this.getter = getter;
|
||||
}
|
||||
|
||||
public ProceduralStream<Double> get(EngineFramework engine) {
|
||||
public ProceduralStream<Double> get(Engine engine) {
|
||||
return getter.apply(engine);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package com.volmit.iris.engine.object.noise;
|
||||
|
||||
import com.volmit.iris.engine.framework.EngineFramework;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
|
||||
import java.util.function.Function;
|
||||
@@ -26,28 +26,28 @@ import java.util.function.Function;
|
||||
@Desc("Represents a value from the engine")
|
||||
public enum IrisEngineValueType {
|
||||
@Desc("Represents actual height of the engine")
|
||||
ENGINE_HEIGHT((f) -> Double.valueOf(f.getEngine().getHeight())),
|
||||
ENGINE_HEIGHT((f) -> Double.valueOf(f.getHeight())),
|
||||
|
||||
@Desc("Represents virtual bottom of the engine in the compound. If this engine is on top of another engine, it's min height would be at the maxHeight of the previous engine + 1")
|
||||
ENGINE_MIN_HEIGHT((f) -> Double.valueOf(f.getEngine().getMinHeight())),
|
||||
ENGINE_MIN_HEIGHT((f) -> Double.valueOf(f.getMinHeight())),
|
||||
|
||||
@Desc("Represents virtual top of the engine in the compound. If this engine is below another engine, it's max height would be at the minHeight of the next engine - 1")
|
||||
ENGINE_MAX_HEIGHT((f) -> Double.valueOf(f.getEngine().getMaxHeight())),
|
||||
ENGINE_MAX_HEIGHT((f) -> Double.valueOf(f.getMaxHeight())),
|
||||
|
||||
@Desc("Represents the position of the engine in the dimensional compound. The bottom (first) dimension stasts at 0. Each new dimension added stacks on top with n+1 for the id.")
|
||||
ENGINE_INDEX((f) -> Double.valueOf(f.getEngine().getIndex())),
|
||||
ENGINE_INDEX((f) -> Double.valueOf(f.getIndex())),
|
||||
|
||||
@Desc("The fluid height defined in the dimension file")
|
||||
FLUID_HEIGHT((f) -> Double.valueOf(f.getComplex().getFluidHeight())),
|
||||
;
|
||||
|
||||
private final Function<EngineFramework, Double> getter;
|
||||
private final Function<Engine, Double> getter;
|
||||
|
||||
IrisEngineValueType(Function<EngineFramework, Double> getter) {
|
||||
IrisEngineValueType(Function<Engine, Double> getter) {
|
||||
this.getter = getter;
|
||||
}
|
||||
|
||||
public Double get(EngineFramework engine) {
|
||||
public Double get(Engine engine) {
|
||||
return getter.apply(engine);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,11 +59,11 @@ public class IrisExpressionLoad {
|
||||
|
||||
public double getValue(RNG rng, IrisData data, double x, double z) {
|
||||
if (engineValue != null) {
|
||||
return valueCache.aquire(() -> engineValue.get(data.getEngine().getFramework()));
|
||||
return valueCache.aquire(() -> engineValue.get(data.getEngine()));
|
||||
}
|
||||
|
||||
if (engineStreamValue != null) {
|
||||
return streamCache.aquire(() -> engineStreamValue.get(data.getEngine().getFramework())).get(x, z);
|
||||
return streamCache.aquire(() -> engineStreamValue.get(data.getEngine())).get(x, z);
|
||||
}
|
||||
|
||||
if (styleValue != null) {
|
||||
@@ -75,11 +75,11 @@ public class IrisExpressionLoad {
|
||||
|
||||
public double getValue(RNG rng, IrisData data, double x, double y, double z) {
|
||||
if (engineValue != null) {
|
||||
return valueCache.aquire(() -> engineValue.get(data.getEngine().getFramework()));
|
||||
return valueCache.aquire(() -> engineValue.get(data.getEngine()));
|
||||
}
|
||||
|
||||
if (engineStreamValue != null) {
|
||||
return streamCache.aquire(() -> engineStreamValue.get(data.getEngine().getFramework())).get(x, z);
|
||||
return streamCache.aquire(() -> engineStreamValue.get(data.getEngine())).get(x, z);
|
||||
}
|
||||
|
||||
if (styleValue != null) {
|
||||
|
||||
Reference in New Issue
Block a user