mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Cleanup
This commit is contained in:
parent
ca035f9447
commit
eb82b44726
@ -133,14 +133,13 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setupPapi() {
|
private void setupPapi() {
|
||||||
if(Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||||
new IrisPapiExpansion().register();
|
new IrisPapiExpansion().register();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getDatapacksFolder() {
|
public File getDatapacksFolder() {
|
||||||
if(!IrisSettings.get().getGeneral().forceMainWorld.isEmpty())
|
if (!IrisSettings.get().getGeneral().forceMainWorld.isEmpty()) {
|
||||||
{
|
|
||||||
return new File(IrisSettings.get().getGeneral().forceMainWorld + "/datapacks");
|
return new File(IrisSettings.get().getGeneral().forceMainWorld + "/datapacks");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,12 +30,9 @@ import com.volmit.iris.util.board.ScoreDirection;
|
|||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.format.C;
|
import com.volmit.iris.util.format.C;
|
||||||
import com.volmit.iris.util.format.Form;
|
import com.volmit.iris.util.format.Form;
|
||||||
import com.volmit.iris.util.math.RNG;
|
|
||||||
import com.volmit.iris.util.math.RollingSequence;
|
import com.volmit.iris.util.math.RollingSequence;
|
||||||
import com.volmit.iris.util.scheduling.ChronoLatch;
|
import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||||
import com.volmit.iris.util.scheduling.J;
|
import com.volmit.iris.util.scheduling.J;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Particle;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
@ -250,10 +250,8 @@ public class TreeManager implements Listener {
|
|||||||
|
|
||||||
KList<IrisObjectPlacement> p = new KList<>();
|
KList<IrisObjectPlacement> p = new KList<>();
|
||||||
|
|
||||||
for(IrisObjectPlacement i : objects)
|
for (IrisObjectPlacement i : objects) {
|
||||||
{
|
if (i.matches(size, type)) {
|
||||||
if(i.matches(size, type))
|
|
||||||
{
|
|
||||||
p.add(i);
|
p.add(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,8 @@ package com.volmit.iris.core.command.studio;
|
|||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.core.IrisDataManager;
|
import com.volmit.iris.core.IrisDataManager;
|
||||||
import com.volmit.iris.core.project.IrisProject;
|
|
||||||
import com.volmit.iris.core.IrisSettings;
|
import com.volmit.iris.core.IrisSettings;
|
||||||
|
import com.volmit.iris.core.project.IrisProject;
|
||||||
import com.volmit.iris.engine.interpolation.InterpolationMethod;
|
import com.volmit.iris.engine.interpolation.InterpolationMethod;
|
||||||
import com.volmit.iris.engine.noise.CNG;
|
import com.volmit.iris.engine.noise.CNG;
|
||||||
import com.volmit.iris.engine.object.*;
|
import com.volmit.iris.engine.object.*;
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
package com.volmit.iris.core.command.studio;
|
package com.volmit.iris.core.command.studio;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.core.project.IrisProject;
|
|
||||||
import com.volmit.iris.core.IrisSettings;
|
import com.volmit.iris.core.IrisSettings;
|
||||||
|
import com.volmit.iris.core.project.IrisProject;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.plugin.MortarCommand;
|
import com.volmit.iris.util.plugin.MortarCommand;
|
||||||
import com.volmit.iris.util.plugin.VolmitSender;
|
import com.volmit.iris.util.plugin.VolmitSender;
|
||||||
|
@ -22,7 +22,6 @@ import com.volmit.iris.Iris;
|
|||||||
import com.volmit.iris.core.tools.IrisWorlds;
|
import com.volmit.iris.core.tools.IrisWorlds;
|
||||||
import com.volmit.iris.engine.framework.Engine;
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
import com.volmit.iris.engine.framework.IrisAccess;
|
import com.volmit.iris.engine.framework.IrisAccess;
|
||||||
import com.volmit.iris.engine.object.common.IrisWorld;
|
|
||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
@ -31,17 +30,20 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
// See/update https://app.gitbook.com/@volmitsoftware/s/iris/compatability/papi/
|
// See/update https://app.gitbook.com/@volmitsoftware/s/iris/compatability/papi/
|
||||||
public class IrisPapiExpansion extends PlaceholderExpansion {
|
public class IrisPapiExpansion extends PlaceholderExpansion {
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getIdentifier() {
|
public @NotNull
|
||||||
|
String getIdentifier() {
|
||||||
return "iris";
|
return "iris";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getAuthor() {
|
public @NotNull
|
||||||
|
String getAuthor() {
|
||||||
return "Volmit Software";
|
return "Volmit Software";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getVersion() {
|
public @NotNull
|
||||||
|
String getVersion() {
|
||||||
return Iris.instance.getDescription().getVersion();
|
return Iris.instance.getDescription().getVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,98 +57,55 @@ public class IrisPapiExpansion extends PlaceholderExpansion {
|
|||||||
Location l = null;
|
Location l = null;
|
||||||
IrisAccess a = null;
|
IrisAccess a = null;
|
||||||
|
|
||||||
if(player.isOnline())
|
if (player.isOnline()) {
|
||||||
{
|
|
||||||
l = player.getPlayer().getLocation();
|
l = player.getPlayer().getLocation();
|
||||||
a = IrisWorlds.access(l.getWorld());
|
a = IrisWorlds.access(l.getWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p.equalsIgnoreCase("biome_name"))
|
if (p.equalsIgnoreCase("biome_name")) {
|
||||||
{
|
if (a != null) {
|
||||||
if(a != null)
|
|
||||||
{
|
|
||||||
return a.getBiome(l).getName();
|
return a.getBiome(l).getName();
|
||||||
}
|
}
|
||||||
}
|
} else if (p.equalsIgnoreCase("biome_id")) {
|
||||||
|
if (a != null) {
|
||||||
else if (p.equalsIgnoreCase("biome_id"))
|
|
||||||
{
|
|
||||||
if(a != null)
|
|
||||||
{
|
|
||||||
return a.getBiome(l).getLoadKey();
|
return a.getBiome(l).getLoadKey();
|
||||||
}
|
}
|
||||||
}
|
} else if (p.equalsIgnoreCase("biome_file")) {
|
||||||
|
if (a != null) {
|
||||||
else if (p.equalsIgnoreCase("biome_file"))
|
|
||||||
{
|
|
||||||
if(a != null)
|
|
||||||
{
|
|
||||||
return a.getBiome(l).getLoadFile().getPath();
|
return a.getBiome(l).getLoadFile().getPath();
|
||||||
}
|
}
|
||||||
}
|
} else if (p.equalsIgnoreCase("region_name")) {
|
||||||
|
if (a != null) {
|
||||||
else if (p.equalsIgnoreCase("region_name"))
|
|
||||||
{
|
|
||||||
if(a != null)
|
|
||||||
{
|
|
||||||
return a.getRegion(l).getName();
|
return a.getRegion(l).getName();
|
||||||
}
|
}
|
||||||
}
|
} else if (p.equalsIgnoreCase("region_id")) {
|
||||||
|
if (a != null) {
|
||||||
else if (p.equalsIgnoreCase("region_id"))
|
|
||||||
{
|
|
||||||
if(a != null)
|
|
||||||
{
|
|
||||||
return a.getRegion(l).getLoadKey();
|
return a.getRegion(l).getLoadKey();
|
||||||
}
|
}
|
||||||
}
|
} else if (p.equalsIgnoreCase("region_file")) {
|
||||||
|
if (a != null) {
|
||||||
else if (p.equalsIgnoreCase("region_file"))
|
|
||||||
{
|
|
||||||
if(a != null)
|
|
||||||
{
|
|
||||||
return a.getRegion(l).getLoadFile().getPath();
|
return a.getRegion(l).getLoadFile().getPath();
|
||||||
}
|
}
|
||||||
}
|
} else if (p.equalsIgnoreCase("terrain_slope")) {
|
||||||
|
if (a != null) {
|
||||||
else if (p.equalsIgnoreCase("terrain_slope"))
|
return ((Engine) a.getEngineAccess(l.getBlockY()))
|
||||||
{
|
|
||||||
if(a != null)
|
|
||||||
{
|
|
||||||
return ((Engine)a.getEngineAccess(l.getBlockY()))
|
|
||||||
.getFramework().getComplex().getSlopeStream()
|
.getFramework().getComplex().getSlopeStream()
|
||||||
.get(l.getX(), l.getZ()) + "";
|
.get(l.getX(), l.getZ()) + "";
|
||||||
}
|
}
|
||||||
}
|
} else if (p.equalsIgnoreCase("terrain_height")) {
|
||||||
|
if (a != null) {
|
||||||
else if (p.equalsIgnoreCase("terrain_height"))
|
return (int) Math.round(a.getHeight(l)) + "";
|
||||||
{
|
|
||||||
if(a != null)
|
|
||||||
{
|
|
||||||
return (int)Math.round(a.getHeight(l)) + "";
|
|
||||||
}
|
}
|
||||||
}
|
} else if (p.equalsIgnoreCase("world_mode")) {
|
||||||
|
if (a != null) {
|
||||||
else if (p.equalsIgnoreCase("world_mode"))
|
|
||||||
{
|
|
||||||
if(a != null)
|
|
||||||
{
|
|
||||||
return a.isStudio() ? "Studio" : "Production";
|
return a.isStudio() ? "Studio" : "Production";
|
||||||
}
|
}
|
||||||
}
|
} else if (p.equalsIgnoreCase("world_seed")) {
|
||||||
|
if (a != null) {
|
||||||
else if (p.equalsIgnoreCase("world_seed"))
|
|
||||||
{
|
|
||||||
if(a != null)
|
|
||||||
{
|
|
||||||
return a.getTarget().getWorld().seed() + "";
|
return a.getTarget().getWorld().seed() + "";
|
||||||
}
|
}
|
||||||
}
|
} else if (p.equalsIgnoreCase("world_speed")) {
|
||||||
|
if (a != null) {
|
||||||
else if (p.equalsIgnoreCase("world_speed"))
|
|
||||||
{
|
|
||||||
if(a != null)
|
|
||||||
{
|
|
||||||
return a.getGeneratedPerSecond() + "/s";
|
return a.getGeneratedPerSecond() + "/s";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,14 +29,12 @@ public class OraxenLink {
|
|||||||
return getOraxen() != null;
|
return getOraxen() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockData getBlockDataFor(String id)
|
public BlockData getBlockDataFor(String id) {
|
||||||
{
|
|
||||||
// TODO: Unimplemented
|
// TODO: Unimplemented
|
||||||
return B.get("AIR");
|
return B.get("AIR");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getItemStackForType(String item)
|
public ItemStack getItemStackForType(String item) {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
Object itemBuilder = Class.forName("io.th0rgal.oraxen.items.OraxenItems").getDeclaredMethod("getItemById", String.class).invoke(null, item);
|
Object itemBuilder = Class.forName("io.th0rgal.oraxen.items.OraxenItems").getDeclaredMethod("getItemById", String.class).invoke(null, item);
|
||||||
return (ItemStack) itemBuilder.getClass().getDeclaredMethod("getReferenceClone").invoke(itemBuilder);
|
return (ItemStack) itemBuilder.getClass().getDeclaredMethod("getReferenceClone").invoke(itemBuilder);
|
||||||
|
@ -20,7 +20,6 @@ package com.volmit.iris.core.pregenerator;
|
|||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.util.collection.KSet;
|
import com.volmit.iris.util.collection.KSet;
|
||||||
import com.volmit.iris.util.format.C;
|
|
||||||
import com.volmit.iris.util.format.Form;
|
import com.volmit.iris.util.format.Form;
|
||||||
import com.volmit.iris.util.math.M;
|
import com.volmit.iris.util.math.M;
|
||||||
import com.volmit.iris.util.math.Position2;
|
import com.volmit.iris.util.math.Position2;
|
||||||
@ -99,9 +98,8 @@ public class IrisPregenerator {
|
|||||||
totalChunks.get() - generated.get(),
|
totalChunks.get() - generated.get(),
|
||||||
eta, M.ms() - startTime.get(), currentGeneratorMethod.get());
|
eta, M.ms() - startTime.get(), currentGeneratorMethod.get());
|
||||||
|
|
||||||
if(cl.flip())
|
if (cl.flip()) {
|
||||||
{
|
Iris.info("Pregen: " + Form.f(generated.get()) + " of " + Form.f(totalChunks.get()) + " (" + Form.pc((double) generated.get() / (double) totalChunks.get(), 0) + ") " + Form.f((int) chunksPerSecond.getAverage()) + "/s ETA: " + Form.duration((double) eta, 2));
|
||||||
Iris.info("Pregen: " + Form.f(generated.get()) + " of " + Form.f(totalChunks.get()) + " (" + Form.pc((double) generated.get() / (double) totalChunks.get(), 0) + ") " + Form.f((int) chunksPerSecond.getAverage()) + "/s ETA: " + Form.duration((double)eta, 2));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1000;
|
return 1000;
|
||||||
|
@ -189,8 +189,7 @@ public class SchemaBuilder {
|
|||||||
fancyType = "Mythic Mob Type";
|
fancyType = "Mythic Mob Type";
|
||||||
prop.put("$ref", "#/definitions/" + key);
|
prop.put("$ref", "#/definitions/" + key);
|
||||||
description.add(SYMBOL_TYPE__N + " Must be a valid Mythic Mob Type (use ctrl+space for auto complete!) Define mythic mobs with the mythic mobs plugin configuration files.");
|
description.add(SYMBOL_TYPE__N + " Must be a valid Mythic Mob Type (use ctrl+space for auto complete!) Define mythic mobs with the mythic mobs plugin configuration files.");
|
||||||
}
|
} else if (k.isAnnotationPresent(RegistryListSpawner.class)) {
|
||||||
else if (k.isAnnotationPresent(RegistryListSpawner.class)) {
|
|
||||||
String key = "enum-reg-spawner";
|
String key = "enum-reg-spawner";
|
||||||
|
|
||||||
if (!definitions.containsKey(key)) {
|
if (!definitions.containsKey(key)) {
|
||||||
@ -202,8 +201,7 @@ public class SchemaBuilder {
|
|||||||
fancyType = "Iris Spawner";
|
fancyType = "Iris Spawner";
|
||||||
prop.put("$ref", "#/definitions/" + key);
|
prop.put("$ref", "#/definitions/" + key);
|
||||||
description.add(SYMBOL_TYPE__N + " Must be a valid Spawner (use ctrl+space for auto complete!)");
|
description.add(SYMBOL_TYPE__N + " Must be a valid Spawner (use ctrl+space for auto complete!)");
|
||||||
}
|
} else if (k.isAnnotationPresent(RegistryListBlockType.class)) {
|
||||||
else if (k.isAnnotationPresent(RegistryListBlockType.class)) {
|
|
||||||
String key = "enum-block-type";
|
String key = "enum-block-type";
|
||||||
|
|
||||||
if (!definitions.containsKey(key)) {
|
if (!definitions.containsKey(key)) {
|
||||||
@ -479,8 +477,7 @@ public class SchemaBuilder {
|
|||||||
items.put("$ref", "#/definitions/" + key);
|
items.put("$ref", "#/definitions/" + key);
|
||||||
prop.put("items", items);
|
prop.put("items", items);
|
||||||
description.add(SYMBOL_TYPE__N + " Must be a valid Biome (use ctrl+space for auto complete!)");
|
description.add(SYMBOL_TYPE__N + " Must be a valid Biome (use ctrl+space for auto complete!)");
|
||||||
}
|
} else if (k.isAnnotationPresent(RegistryListSpawner.class)) {
|
||||||
else if (k.isAnnotationPresent(RegistryListSpawner.class)) {
|
|
||||||
fancyType = "List of Iris Spawners";
|
fancyType = "List of Iris Spawners";
|
||||||
String key = "enum-reg-spawner";
|
String key = "enum-reg-spawner";
|
||||||
|
|
||||||
@ -494,8 +491,7 @@ public class SchemaBuilder {
|
|||||||
items.put("$ref", "#/definitions/" + key);
|
items.put("$ref", "#/definitions/" + key);
|
||||||
prop.put("items", items);
|
prop.put("items", items);
|
||||||
description.add(SYMBOL_TYPE__N + " Must be a valid Spawner (use ctrl+space for auto complete!)");
|
description.add(SYMBOL_TYPE__N + " Must be a valid Spawner (use ctrl+space for auto complete!)");
|
||||||
}
|
} else if (k.isAnnotationPresent(RegistryListMythical.class)) {
|
||||||
else if (k.isAnnotationPresent(RegistryListMythical.class)) {
|
|
||||||
fancyType = "List of Mythic Mob Types";
|
fancyType = "List of Mythic Mob Types";
|
||||||
String key = "enum-reg-mythical";
|
String key = "enum-reg-mythical";
|
||||||
|
|
||||||
|
@ -24,8 +24,6 @@ import com.volmit.iris.core.IrisDataManager;
|
|||||||
import com.volmit.iris.engine.actuator.IrisTerrainNormalActuator;
|
import com.volmit.iris.engine.actuator.IrisTerrainNormalActuator;
|
||||||
import com.volmit.iris.engine.data.DataProvider;
|
import com.volmit.iris.engine.data.DataProvider;
|
||||||
import com.volmit.iris.engine.framework.Engine;
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
import com.volmit.iris.engine.interpolation.InterpolationMethod;
|
|
||||||
import com.volmit.iris.engine.interpolation.IrisInterpolation;
|
|
||||||
import com.volmit.iris.engine.modifier.IrisCaveModifier;
|
import com.volmit.iris.engine.modifier.IrisCaveModifier;
|
||||||
import com.volmit.iris.engine.noise.CNG;
|
import com.volmit.iris.engine.noise.CNG;
|
||||||
import com.volmit.iris.engine.object.*;
|
import com.volmit.iris.engine.object.*;
|
||||||
@ -36,7 +34,6 @@ import com.volmit.iris.util.collection.KList;
|
|||||||
import com.volmit.iris.util.collection.KMap;
|
import com.volmit.iris.util.collection.KMap;
|
||||||
import com.volmit.iris.util.math.M;
|
import com.volmit.iris.util.math.M;
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
import com.volmit.iris.util.scheduling.J;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
@ -159,13 +156,13 @@ public class IrisComplex implements DataProvider {
|
|||||||
: regionStyleStream
|
: regionStyleStream
|
||||||
.selectRarity(engine.getDimension().getRegions(), (i) -> data.getRegionLoader().load(i))
|
.selectRarity(engine.getDimension().getRegions(), (i) -> data.getRegionLoader().load(i))
|
||||||
.convertCached((s) -> data.getRegionLoader().load(s)).cache2D(cacheSize);
|
.convertCached((s) -> data.getRegionLoader().load(s)).cache2D(cacheSize);
|
||||||
islandStream = regionStyleStream
|
islandStream = regionStyleStream
|
||||||
.seededChance(rng.nextParallelRNG(29349), 23968888888L,
|
.seededChance(rng.nextParallelRNG(29349), 23968888888L,
|
||||||
1D/engine.getDimension().getIslandMode().getIslandChance());
|
1D / engine.getDimension().getIslandMode().getIslandChance());
|
||||||
islandHeightStream = regionIdentityStream.style(rng.nextParallelRNG(330466), engine.getDimension().getIslandMode().getHeight());
|
islandHeightStream = regionIdentityStream.style(rng.nextParallelRNG(330466), engine.getDimension().getIslandMode().getHeight());
|
||||||
islandDepthStream = engine.getDimension().getIslandMode().getIslandDepth().stream(rng.nextParallelRNG(-39578888));
|
islandDepthStream = engine.getDimension().getIslandMode().getIslandDepth().stream(rng.nextParallelRNG(-39578888));
|
||||||
regionIDStream = regionIdentityStream.convertCached((i) -> new UUID(Double.doubleToLongBits(i), String.valueOf(i * 38445).hashCode() * 3245556666L));
|
regionIDStream = regionIdentityStream.convertCached((i) -> new UUID(Double.doubleToLongBits(i), String.valueOf(i * 38445).hashCode() * 3245556666L));
|
||||||
caveBiomeStream = regionStream.convert((r)
|
caveBiomeStream = regionStream.convert((r)
|
||||||
-> engine.getDimension().getCaveBiomeStyle().create(rng.nextParallelRNG(InferredType.CAVE.ordinal())).stream()
|
-> engine.getDimension().getCaveBiomeStyle().create(rng.nextParallelRNG(InferredType.CAVE.ordinal())).stream()
|
||||||
.zoom(r.getCaveBiomeZoom())
|
.zoom(r.getCaveBiomeZoom())
|
||||||
.selectRarity(r.getCaveBiomes(), (i) -> data.getBiomeLoader().load(i))
|
.selectRarity(r.getCaveBiomes(), (i) -> data.getBiomeLoader().load(i))
|
||||||
@ -227,8 +224,7 @@ public class IrisComplex implements DataProvider {
|
|||||||
objectChanceStream = ProceduralStream.ofDouble((x, z) -> {
|
objectChanceStream = ProceduralStream.ofDouble((x, z) -> {
|
||||||
if (engine.getDimension().hasFeatures(engine)) {
|
if (engine.getDimension().hasFeatures(engine)) {
|
||||||
AtomicDouble str = new AtomicDouble(1D);
|
AtomicDouble str = new AtomicDouble(1D);
|
||||||
for(IrisFeaturePositional i : engine.getFramework().getEngineParallax().forEachFeature(x, z))
|
for (IrisFeaturePositional i : engine.getFramework().getEngineParallax().forEachFeature(x, z)) {
|
||||||
{
|
|
||||||
str.set(Math.min(str.get(), i.getObjectChanceModifier(x, z, rng)));
|
str.set(Math.min(str.get(), i.getObjectChanceModifier(x, z, rng)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -354,28 +350,26 @@ public class IrisComplex implements DataProvider {
|
|||||||
|
|
||||||
return m;
|
return m;
|
||||||
}, Interpolated.INT).cache2D(cacheSize);
|
}, Interpolated.INT).cache2D(cacheSize);
|
||||||
baseBiomeIDStream = trueBiomeStream.convertAware2D((b,x,z) ->{
|
baseBiomeIDStream = trueBiomeStream.convertAware2D((b, x, z) -> {
|
||||||
UUID d = regionIDStream.get(x, z);
|
UUID d = regionIDStream.get(x, z);
|
||||||
return new UUID(b.getLoadKey().hashCode() * 818223L,
|
return new UUID(b.getLoadKey().hashCode() * 818223L,
|
||||||
d.hashCode());
|
d.hashCode());
|
||||||
})
|
})
|
||||||
.cache2D(cacheSize);
|
.cache2D(cacheSize);
|
||||||
islandTopStream = islandStream.convertAware2D((i, x, z) ->
|
islandTopStream = islandStream.convertAware2D((i, x, z) ->
|
||||||
i ? heightStream.round()
|
i ? heightStream.round()
|
||||||
.subtract(fluidHeight)
|
.subtract(fluidHeight)
|
||||||
.add((xx, zz) -> getIslandHeight(xx.intValue(), zz.intValue(), engine.getDimension()
|
.add((xx, zz) -> getIslandHeight(xx.intValue(), zz.intValue(), engine.getDimension()
|
||||||
.getIslandMode().getIslandEdgeInterpolator()))
|
.getIslandMode().getIslandEdgeInterpolator()))
|
||||||
.get(x, z) : 0);
|
.get(x, z) : 0);
|
||||||
islandBottomStream = islandStream.convertAware2D((i, x, z) ->
|
islandBottomStream = islandStream.convertAware2D((i, x, z) ->
|
||||||
i ? islandHeightStream.subtract(islandDepthStream).round().get(x, z) : 0);
|
i ? islandHeightStream.subtract(islandDepthStream).round().get(x, z) : 0);
|
||||||
//@done
|
//@done
|
||||||
}
|
}
|
||||||
|
|
||||||
private double getIslandHeight(int x, int z, IrisInterpolator interp)
|
private double getIslandHeight(int x, int z, IrisInterpolator interp) {
|
||||||
{
|
|
||||||
return interp.interpolate(x, z, (xx, zz) -> {
|
return interp.interpolate(x, z, (xx, zz) -> {
|
||||||
if(getIslandStream().get(xx, zz))
|
if (getIslandStream().get(xx, zz)) {
|
||||||
{
|
|
||||||
return getIslandHeightStream().get(xx, zz);
|
return getIslandHeightStream().get(xx, zz);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -472,12 +466,10 @@ public class IrisComplex implements DataProvider {
|
|||||||
|
|
||||||
AtomicDouble noise = new AtomicDouble(h + fluidHeight + overlayStream.get(x, z));
|
AtomicDouble noise = new AtomicDouble(h + fluidHeight + overlayStream.get(x, z));
|
||||||
|
|
||||||
if(features)
|
if (features) {
|
||||||
{
|
|
||||||
List<IrisFeaturePositional> p = engine.getFramework().getEngineParallax().forEachFeature(x, z);
|
List<IrisFeaturePositional> p = engine.getFramework().getEngineParallax().forEachFeature(x, z);
|
||||||
|
|
||||||
for(IrisFeaturePositional i : p)
|
for (IrisFeaturePositional i : p) {
|
||||||
{
|
|
||||||
noise.set(i.filter(x, z, noise.get(), rng));
|
noise.set(i.filter(x, z, noise.get(), rng));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,10 @@ import com.volmit.iris.core.IrisSettings;
|
|||||||
import com.volmit.iris.engine.cache.AtomicCache;
|
import com.volmit.iris.engine.cache.AtomicCache;
|
||||||
import com.volmit.iris.engine.framework.*;
|
import com.volmit.iris.engine.framework.*;
|
||||||
import com.volmit.iris.engine.hunk.Hunk;
|
import com.volmit.iris.engine.hunk.Hunk;
|
||||||
import com.volmit.iris.engine.object.*;
|
import com.volmit.iris.engine.object.IrisBiome;
|
||||||
|
import com.volmit.iris.engine.object.IrisBiomePaletteLayer;
|
||||||
|
import com.volmit.iris.engine.object.IrisDecorator;
|
||||||
|
import com.volmit.iris.engine.object.IrisObjectPlacement;
|
||||||
import com.volmit.iris.engine.object.engine.IrisEngineData;
|
import com.volmit.iris.engine.object.engine.IrisEngineData;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.collection.KMap;
|
import com.volmit.iris.util.collection.KMap;
|
||||||
@ -92,7 +95,7 @@ public class IrisEngine extends BlockPopulator implements Engine {
|
|||||||
@Getter
|
@Getter
|
||||||
private double maxBiomeDecoratorDensity;
|
private double maxBiomeDecoratorDensity;
|
||||||
|
|
||||||
private AtomicCache<IrisEngineData> engineData = new AtomicCache<>();
|
private final AtomicCache<IrisEngineData> engineData = new AtomicCache<>();
|
||||||
|
|
||||||
public IrisEngine(EngineTarget target, EngineCompound compound, int index) {
|
public IrisEngine(EngineTarget target, EngineCompound compound, int index) {
|
||||||
Iris.info("Initializing Engine: " + target.getWorld().name() + "/" + target.getDimension().getLoadKey() + " (" + target.getHeight() + " height)");
|
Iris.info("Initializing Engine: " + target.getWorld().name() + "/" + target.getDimension().getLoadKey() + " (" + target.getHeight() + " height)");
|
||||||
@ -117,8 +120,7 @@ public class IrisEngine extends BlockPopulator implements Engine {
|
|||||||
return engineData.aquire(() -> {
|
return engineData.aquire(() -> {
|
||||||
File f = new File(getWorld().worldFolder(), "iris/engine-data/" + getDimension().getLoadKey() + "-" + getIndex() + ".json");
|
File f = new File(getWorld().worldFolder(), "iris/engine-data/" + getDimension().getLoadKey() + "-" + getIndex() + ".json");
|
||||||
|
|
||||||
if(!f.exists())
|
if (!f.exists()) {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
f.getParentFile().mkdirs();
|
f.getParentFile().mkdirs();
|
||||||
IO.writeAll(f, new Gson().toJson(new IrisEngineData()));
|
IO.writeAll(f, new Gson().toJson(new IrisEngineData()));
|
||||||
@ -127,13 +129,9 @@ public class IrisEngine extends BlockPopulator implements Engine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
return new Gson().fromJson(IO.readAll(f), IrisEngineData.class);
|
return new Gson().fromJson(IO.readAll(f), IrisEngineData.class);
|
||||||
}
|
} catch (Throwable e) {
|
||||||
|
|
||||||
catch(Throwable e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,32 +18,26 @@
|
|||||||
|
|
||||||
package com.volmit.iris.engine;
|
package com.volmit.iris.engine;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
|
||||||
import com.volmit.iris.engine.framework.Engine;
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
import com.volmit.iris.engine.framework.EngineAssignedWorldManager;
|
import com.volmit.iris.engine.framework.EngineAssignedWorldManager;
|
||||||
import com.volmit.iris.engine.object.*;
|
import com.volmit.iris.engine.object.*;
|
||||||
import com.volmit.iris.engine.object.common.IRare;
|
import com.volmit.iris.engine.object.common.IRare;
|
||||||
import com.volmit.iris.engine.object.engine.IrisEngineData;
|
import com.volmit.iris.engine.object.engine.IrisEngineData;
|
||||||
import com.volmit.iris.engine.object.engine.IrisEngineSpawnerCooldown;
|
import com.volmit.iris.engine.object.engine.IrisEngineSpawnerCooldown;
|
||||||
import com.volmit.iris.engine.stream.convert.SelectionStream;
|
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.collection.KMap;
|
import com.volmit.iris.util.collection.KMap;
|
||||||
import com.volmit.iris.util.documentation.ChunkCoordinates;
|
|
||||||
import com.volmit.iris.util.math.M;
|
import com.volmit.iris.util.math.M;
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
import com.volmit.iris.util.reflect.V;
|
|
||||||
import com.volmit.iris.util.scheduling.ChronoLatch;
|
import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||||
import com.volmit.iris.util.scheduling.J;
|
import com.volmit.iris.util.scheduling.J;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.Supplier;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@ -67,23 +61,19 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((double) entityCount / (getEngine().getWorld().realWorld().getLoadedChunks().length+1) > 1)
|
if ((double) entityCount / (getEngine().getWorld().realWorld().getLoadedChunks().length + 1) > 1) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cl.flip())
|
if (cl.flip()) {
|
||||||
{
|
|
||||||
J.s(() -> entityCount = getEngine().getWorld().realWorld().getEntities().size());
|
J.s(() -> entityCount = getEngine().getWorld().realWorld().getEntities().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
int maxGroups = 3;
|
int maxGroups = 3;
|
||||||
int biomeBaseCooldownSeconds = 15;
|
int biomeBaseCooldownSeconds = 15;
|
||||||
|
|
||||||
for(UUID i : spawnCooldowns.k())
|
for (UUID i : spawnCooldowns.k()) {
|
||||||
{
|
if (M.ms() - spawnCooldowns.get(i) > TimeUnit.SECONDS.toMillis(biomeBaseCooldownSeconds)) {
|
||||||
if(M.ms() - spawnCooldowns.get(i) > TimeUnit.SECONDS.toMillis(biomeBaseCooldownSeconds))
|
|
||||||
{
|
|
||||||
spawnCooldowns.remove(i);
|
spawnCooldowns.remove(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,74 +81,64 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
KMap<UUID, KList<Chunk>> data = mapChunkBiomes();
|
KMap<UUID, KList<Chunk>> data = mapChunkBiomes();
|
||||||
int spawnBuffer = 32;
|
int spawnBuffer = 32;
|
||||||
|
|
||||||
for(UUID i : data.k().shuffleCopy(RNG.r))
|
for (UUID i : data.k().shuffleCopy(RNG.r)) {
|
||||||
{
|
if (spawnCooldowns.containsKey(i)) {
|
||||||
if(spawnCooldowns.containsKey(i))
|
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(spawnBuffer-- < 0)
|
if (spawnBuffer-- < 0) {
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int ig = 0; ig < data.get(i).size() / 8; ig++)
|
for (int ig = 0; ig < data.get(i).size() / 8; ig++) {
|
||||||
{
|
|
||||||
spawnIn(data.get(i).getRandom(), i, maxGroups);
|
spawnIn(data.get(i).getRandom(), i, maxGroups);
|
||||||
spawnCooldowns.put(i, M.ms());
|
spawnCooldowns.put(i, M.ms());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(actuallySpawned <= 0)
|
if (actuallySpawned <= 0) {
|
||||||
{
|
|
||||||
J.sleep(5000);
|
J.sleep(5000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void spawnIn(Chunk c, UUID id, int max) {
|
private void spawnIn(Chunk c, UUID id, int max) {
|
||||||
if(c.getEntities().length > 2)
|
if (c.getEntities().length > 2) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//@builder
|
//@builder
|
||||||
puffen(Stream.concat(getData().getSpawnerLoader().loadAll(getDimension().getEntitySpawners())
|
puffen(Stream.concat(getData().getSpawnerLoader().loadAll(getDimension().getEntitySpawners())
|
||||||
.shuffleCopy(RNG.r).stream().filter(this::canSpawn)
|
.shuffleCopy(RNG.r).stream().filter(this::canSpawn)
|
||||||
.flatMap(this::stream),
|
|
||||||
Stream.concat(getData().getSpawnerLoader()
|
|
||||||
.loadAll(getEngine().getRegion(c.getX() << 4, c.getZ() << 4).getEntitySpawners())
|
|
||||||
.shuffleCopy(RNG.r).stream().filter(this::canSpawn)
|
|
||||||
.flatMap(this::stream),
|
.flatMap(this::stream),
|
||||||
|
Stream.concat(getData().getSpawnerLoader()
|
||||||
|
.loadAll(getEngine().getRegion(c.getX() << 4, c.getZ() << 4).getEntitySpawners())
|
||||||
|
.shuffleCopy(RNG.r).stream().filter(this::canSpawn)
|
||||||
|
.flatMap(this::stream),
|
||||||
getData().getSpawnerLoader()
|
getData().getSpawnerLoader()
|
||||||
.loadAll(getEngine().getSurfaceBiome(c.getX() << 4, c.getZ() << 4).getEntitySpawners())
|
.loadAll(getEngine().getSurfaceBiome(c.getX() << 4, c.getZ() << 4).getEntitySpawners())
|
||||||
.shuffleCopy(RNG.r).stream().filter(this::canSpawn)
|
.shuffleCopy(RNG.r).stream().filter(this::canSpawn)
|
||||||
.flatMap(this::stream)))
|
.flatMap(this::stream)))
|
||||||
.collect(Collectors.toList()))
|
.collect(Collectors.toList()))
|
||||||
.popRandom(RNG.r, max).forEach((i) -> spawn(c, id, i));
|
.popRandom(RNG.r, max).forEach((i) -> spawn(c, id, i));
|
||||||
//@done
|
//@done
|
||||||
}
|
}
|
||||||
|
|
||||||
private void spawn(Chunk c, UUID id, IrisEntitySpawn i) {
|
private void spawn(Chunk c, UUID id, IrisEntitySpawn i) {
|
||||||
if(i.spawn(getEngine(), c, RNG.r))
|
if (i.spawn(getEngine(), c, RNG.r)) {
|
||||||
{
|
|
||||||
actuallySpawned++;
|
actuallySpawned++;
|
||||||
getCooldown(i.getReferenceSpawner()).spawn(getEngine());
|
getCooldown(i.getReferenceSpawner()).spawn(getEngine());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Stream<IrisEntitySpawn> stream(IrisSpawner s)
|
private Stream<IrisEntitySpawn> stream(IrisSpawner s) {
|
||||||
{
|
for (IrisEntitySpawn i : s.getSpawns()) {
|
||||||
for(IrisEntitySpawn i : s.getSpawns())
|
|
||||||
{
|
|
||||||
i.setReferenceSpawner(s);
|
i.setReferenceSpawner(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
return s.getSpawns().stream();
|
return s.getSpawns().stream();
|
||||||
}
|
}
|
||||||
|
|
||||||
private KList<IrisEntitySpawn> puffen(List<IrisEntitySpawn> types)
|
private KList<IrisEntitySpawn> puffen(List<IrisEntitySpawn> types) {
|
||||||
{
|
|
||||||
KList<IrisEntitySpawn> rarityTypes = new KList<>();
|
KList<IrisEntitySpawn> rarityTypes = new KList<>();
|
||||||
int totalRarity = 0;
|
int totalRarity = 0;
|
||||||
for (IrisEntitySpawn i : types) {
|
for (IrisEntitySpawn i : types) {
|
||||||
@ -172,25 +152,21 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
return rarityTypes;
|
return rarityTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canSpawn(IrisSpawner i)
|
public boolean canSpawn(IrisSpawner i) {
|
||||||
{
|
|
||||||
return i.isValid(getEngine().getWorld().realWorld()) && getCooldown(i).canSpawn(i.getMaximumRate());
|
return i.isValid(getEngine().getWorld().realWorld()) && getCooldown(i).canSpawn(i.getMaximumRate());
|
||||||
}
|
}
|
||||||
|
|
||||||
private IrisEngineSpawnerCooldown getCooldown(IrisSpawner i)
|
private IrisEngineSpawnerCooldown getCooldown(IrisSpawner i) {
|
||||||
{
|
|
||||||
IrisEngineData ed = getEngine().getEngineData();
|
IrisEngineData ed = getEngine().getEngineData();
|
||||||
IrisEngineSpawnerCooldown cd = null;
|
IrisEngineSpawnerCooldown cd = null;
|
||||||
|
|
||||||
for (IrisEngineSpawnerCooldown j : ed.getSpawnerCooldowns()) {
|
for (IrisEngineSpawnerCooldown j : ed.getSpawnerCooldowns()) {
|
||||||
if (j.getSpawner().equals(i.getLoadKey()))
|
if (j.getSpawner().equals(i.getLoadKey())) {
|
||||||
{
|
|
||||||
cd = j;
|
cd = j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cd == null)
|
if (cd == null) {
|
||||||
{
|
|
||||||
cd = new IrisEngineSpawnerCooldown();
|
cd = new IrisEngineSpawnerCooldown();
|
||||||
cd.setSpawner(i.getLoadKey());
|
cd.setSpawner(i.getLoadKey());
|
||||||
cd.setLastSpawn(M.ms() - i.getMaximumRate().getInterval());
|
cd.setLastSpawn(M.ms() - i.getMaximumRate().getInterval());
|
||||||
@ -200,14 +176,12 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
return cd;
|
return cd;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KMap<UUID, KList<Chunk>> mapChunkBiomes()
|
public KMap<UUID, KList<Chunk>> mapChunkBiomes() {
|
||||||
{
|
|
||||||
KMap<UUID, KList<Chunk>> data = new KMap<>();
|
KMap<UUID, KList<Chunk>> data = new KMap<>();
|
||||||
|
|
||||||
for(Chunk i : getEngine().getWorld().realWorld().getLoadedChunks())
|
for (Chunk i : getEngine().getWorld().realWorld().getLoadedChunks()) {
|
||||||
{
|
|
||||||
data.compute(getEngine().getBiomeID(i.getX() << 4, i.getZ() << 4),
|
data.compute(getEngine().getBiomeID(i.getX() << 4, i.getZ() << 4),
|
||||||
(k,v) -> v != null ? v : new KList<>()).add(i);
|
(k, v) -> v != null ? v : new KList<>()).add(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
@ -225,25 +199,20 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockBreak(BlockBreakEvent e) {
|
public void onBlockBreak(BlockBreakEvent e) {
|
||||||
if(e.getBlock().getWorld().equals(getTarget().getWorld().realWorld()) && getEngine().contains(e.getBlock().getLocation()))
|
if (e.getBlock().getWorld().equals(getTarget().getWorld().realWorld()) && getEngine().contains(e.getBlock().getLocation())) {
|
||||||
{
|
|
||||||
KList<ItemStack> d = new KList<>();
|
KList<ItemStack> d = new KList<>();
|
||||||
Runnable drop = () -> J.s(() -> d.forEach((i) -> e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation().clone().add(0.5, 0.5, 0.5), i)));
|
Runnable drop = () -> J.s(() -> d.forEach((i) -> e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation().clone().add(0.5, 0.5, 0.5), i)));
|
||||||
IrisBiome b = getEngine().getBiome(e.getBlock().getLocation());
|
IrisBiome b = getEngine().getBiome(e.getBlock().getLocation());
|
||||||
|
|
||||||
for(IrisBlockDrops i : b.getBlockDrops())
|
for (IrisBlockDrops i : b.getBlockDrops()) {
|
||||||
{
|
if (i.shouldDropFor(e.getBlock().getBlockData(), getData())) {
|
||||||
if(i.shouldDropFor(e.getBlock().getBlockData(), getData()))
|
if (i.isReplaceVanillaDrops()) {
|
||||||
{
|
|
||||||
if(i.isReplaceVanillaDrops())
|
|
||||||
{
|
|
||||||
e.setDropItems(false);
|
e.setDropItems(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
i.fillDrops(false, d);
|
i.fillDrops(false, d);
|
||||||
|
|
||||||
if(i.isSkipParents())
|
if (i.isSkipParents()) {
|
||||||
{
|
|
||||||
drop.run();
|
drop.run();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -252,38 +221,30 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
|
|
||||||
IrisRegion r = getEngine().getRegion(e.getBlock().getLocation());
|
IrisRegion r = getEngine().getRegion(e.getBlock().getLocation());
|
||||||
|
|
||||||
for(IrisBlockDrops i : r.getBlockDrops())
|
for (IrisBlockDrops i : r.getBlockDrops()) {
|
||||||
{
|
if (i.shouldDropFor(e.getBlock().getBlockData(), getData())) {
|
||||||
if(i.shouldDropFor(e.getBlock().getBlockData(), getData()))
|
if (i.isReplaceVanillaDrops()) {
|
||||||
{
|
|
||||||
if(i.isReplaceVanillaDrops())
|
|
||||||
{
|
|
||||||
e.setDropItems(false);
|
e.setDropItems(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
i.fillDrops(false, d);
|
i.fillDrops(false, d);
|
||||||
|
|
||||||
if(i.isSkipParents())
|
if (i.isSkipParents()) {
|
||||||
{
|
|
||||||
drop.run();
|
drop.run();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(IrisBlockDrops i : getEngine().getDimension().getBlockDrops())
|
for (IrisBlockDrops i : getEngine().getDimension().getBlockDrops()) {
|
||||||
{
|
if (i.shouldDropFor(e.getBlock().getBlockData(), getData())) {
|
||||||
if(i.shouldDropFor(e.getBlock().getBlockData(), getData()))
|
if (i.isReplaceVanillaDrops()) {
|
||||||
{
|
|
||||||
if(i.isReplaceVanillaDrops())
|
|
||||||
{
|
|
||||||
e.setDropItems(false);
|
e.setDropItems(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
i.fillDrops(false, d);
|
i.fillDrops(false, d);
|
||||||
|
|
||||||
if(i.isSkipParents())
|
if (i.isSkipParents()) {
|
||||||
{
|
|
||||||
drop.run();
|
drop.run();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -298,8 +259,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close()
|
public void close() {
|
||||||
{
|
|
||||||
super.close();
|
super.close();
|
||||||
J.car(art);
|
J.car(art);
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,6 @@ package com.volmit.iris.engine.actuator;
|
|||||||
import com.volmit.iris.engine.framework.Engine;
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
import com.volmit.iris.engine.framework.EngineAssignedActuator;
|
import com.volmit.iris.engine.framework.EngineAssignedActuator;
|
||||||
import com.volmit.iris.engine.hunk.Hunk;
|
import com.volmit.iris.engine.hunk.Hunk;
|
||||||
import com.volmit.iris.engine.interpolation.InterpolationMethod;
|
|
||||||
import com.volmit.iris.engine.interpolation.IrisInterpolation;
|
|
||||||
import com.volmit.iris.engine.object.IrisBiome;
|
import com.volmit.iris.engine.object.IrisBiome;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||||
@ -60,7 +58,7 @@ public class IrisTerrainIslandActuator extends EngineAssignedActuator<BlockData>
|
|||||||
int i, zf, depth, surface, realX, realZ;
|
int i, zf, depth, surface, realX, realZ;
|
||||||
IrisBiome biome;
|
IrisBiome biome;
|
||||||
KList<BlockData> blocks, fblocks;
|
KList<BlockData> blocks, fblocks;
|
||||||
int hi,lo;
|
int hi, lo;
|
||||||
double hh;
|
double hh;
|
||||||
|
|
||||||
for (int xf = 0; xf < h.getWidth(); xf++) {
|
for (int xf = 0; xf < h.getWidth(); xf++) {
|
||||||
@ -69,7 +67,7 @@ public class IrisTerrainIslandActuator extends EngineAssignedActuator<BlockData>
|
|||||||
realZ = (int) modZ(zf + z);
|
realZ = (int) modZ(zf + z);
|
||||||
|
|
||||||
if (getComplex().getIslandStream().get(realX, realZ)) {
|
if (getComplex().getIslandStream().get(realX, realZ)) {
|
||||||
biome = getComplex().getTrueBiomeStream().get(realX, realZ);
|
biome = getComplex().getTrueBiomeStream().get(realX, realZ);
|
||||||
hh = getComplex().getTrueHeightStream().get(realX, realZ) - getComplex().getFluidHeight();
|
hh = getComplex().getTrueHeightStream().get(realX, realZ) - getComplex().getFluidHeight();
|
||||||
depth = (int) (getComplex().getIslandDepthStream().get(realX, realZ).intValue() + hh);
|
depth = (int) (getComplex().getIslandDepthStream().get(realX, realZ).intValue() + hh);
|
||||||
blocks = biome.generateLayers(realX, realZ, rng, depth, depth, getData(), getComplex());
|
blocks = biome.generateLayers(realX, realZ, rng, depth, depth, getData(), getComplex());
|
||||||
|
@ -23,7 +23,6 @@ import com.volmit.iris.engine.framework.EngineAssignedActuator;
|
|||||||
import com.volmit.iris.engine.hunk.Hunk;
|
import com.volmit.iris.engine.hunk.Hunk;
|
||||||
import com.volmit.iris.engine.object.IrisBiome;
|
import com.volmit.iris.engine.object.IrisBiome;
|
||||||
import com.volmit.iris.engine.parallel.BurstExecutor;
|
import com.volmit.iris.engine.parallel.BurstExecutor;
|
||||||
import com.volmit.iris.engine.stream.ProceduralStream;
|
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
@ -117,8 +116,7 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getDimension().getCaverns() != null && getDimension().getCaverns().isCavern(rng, realX, i, realZ, he))
|
if (getDimension().getCaverns() != null && getDimension().getCaverns().isCavern(rng, realX, i, realZ, he)) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,13 +143,11 @@ public class B {
|
|||||||
}
|
}
|
||||||
BlockData bx = null;
|
BlockData bx = null;
|
||||||
|
|
||||||
if(ix.startsWith("oraxen:") && Iris.linkOraxen.supported())
|
if (ix.startsWith("oraxen:") && Iris.linkOraxen.supported()) {
|
||||||
{
|
|
||||||
bx = Iris.linkOraxen.getBlockDataFor(ix.split("\\Q:\\E")[1]);
|
bx = Iris.linkOraxen.getBlockDataFor(ix.split("\\Q:\\E")[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bx == null)
|
if (bx == null) {
|
||||||
{
|
|
||||||
bx = Bukkit.createBlockData(ix);
|
bx = Bukkit.createBlockData(ix);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -540,10 +538,8 @@ public class B {
|
|||||||
bt.add(v);
|
bt.add(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Iris.linkOraxen.supported())
|
if (Iris.linkOraxen.supported()) {
|
||||||
{
|
for (String i : Iris.linkOraxen.getItemTypes()) {
|
||||||
for(String i : Iris.linkOraxen.getItemTypes())
|
|
||||||
{
|
|
||||||
bt.add("oraxen:" + i);
|
bt.add("oraxen:" + i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,8 +67,7 @@ public interface Engine extends DataProvider, Fallible, GeneratorAccess, LootPro
|
|||||||
|
|
||||||
void setParallelism(int parallelism);
|
void setParallelism(int parallelism);
|
||||||
|
|
||||||
default UUID getBiomeID(int x, int z)
|
default UUID getBiomeID(int x, int z) {
|
||||||
{
|
|
||||||
return getFramework().getComplex().getBaseBiomeIDStream().get(x, z);
|
return getFramework().getComplex().getBaseBiomeIDStream().get(x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
|
||||||
import org.bukkit.event.world.WorldSaveEvent;
|
import org.bukkit.event.world.WorldSaveEvent;
|
||||||
import org.bukkit.event.world.WorldUnloadEvent;
|
import org.bukkit.event.world.WorldUnloadEvent;
|
||||||
|
|
||||||
|
@ -133,8 +133,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
|||||||
getComposite().close();
|
getComposite().close();
|
||||||
initialized.lazySet(false);
|
initialized.lazySet(false);
|
||||||
|
|
||||||
if(cworld != null)
|
if (cworld != null) {
|
||||||
{
|
|
||||||
initialize(cworld);
|
initialize(cworld);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,6 @@ import org.bukkit.ChunkSnapshot;
|
|||||||
import org.bukkit.block.TileState;
|
import org.bukkit.block.TileState;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.util.BlockVector;
|
import org.bukkit.util.BlockVector;
|
||||||
import org.bukkit.util.Consumer;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -215,8 +214,8 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
|||||||
int s = (int) Math.ceil(getParallaxSize() / 2D);
|
int s = (int) Math.ceil(getParallaxSize() / 2D);
|
||||||
|
|
||||||
int i, j;
|
int i, j;
|
||||||
int cx = (int)x >> 4;
|
int cx = (int) x >> 4;
|
||||||
int cz = (int)z >> 4;
|
int cz = (int) z >> 4;
|
||||||
|
|
||||||
for (i = -s; i <= s; i++) {
|
for (i = -s; i <= s; i++) {
|
||||||
for (j = -s; j <= s; j++) {
|
for (j = -s; j <= s; j++) {
|
||||||
|
@ -26,8 +26,6 @@ import com.volmit.iris.engine.object.IrisObjectPlacement;
|
|||||||
import com.volmit.iris.engine.object.IrisRegion;
|
import com.volmit.iris.engine.object.IrisRegion;
|
||||||
import com.volmit.iris.engine.parallax.ParallaxAccess;
|
import com.volmit.iris.engine.parallax.ParallaxAccess;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public interface GeneratorAccess extends DataProvider, Renderer {
|
public interface GeneratorAccess extends DataProvider, Renderer {
|
||||||
IrisRegion getRegion(int x, int z);
|
IrisRegion getRegion(int x, int z);
|
||||||
|
|
||||||
|
@ -68,26 +68,23 @@ public interface IrisAccess extends Hotloadable, DataProvider {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Ignores the world, just uses the position
|
* Ignores the world, just uses the position
|
||||||
|
*
|
||||||
* @param l the location
|
* @param l the location
|
||||||
* @return the biome
|
* @return the biome
|
||||||
*/
|
*/
|
||||||
default IrisBiome getBiome(Location l)
|
default IrisBiome getBiome(Location l) {
|
||||||
{
|
|
||||||
return getBiome(l.toVector());
|
return getBiome(l.toVector());
|
||||||
}
|
}
|
||||||
|
|
||||||
default IrisRegion getRegion(int x, int y, int z)
|
default IrisRegion getRegion(int x, int y, int z) {
|
||||||
{
|
|
||||||
return getEngineAccess(y).getRegion(x, z);
|
return getEngineAccess(y).getRegion(x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
default IrisRegion getRegion(Location l)
|
default IrisRegion getRegion(Location l) {
|
||||||
{
|
|
||||||
return getRegion(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
return getRegion(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
default IrisBiome getBiome(Vector l)
|
default IrisBiome getBiome(Vector l) {
|
||||||
{
|
|
||||||
return getBiome(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
return getBiome(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,8 +290,7 @@ public interface IrisAccess extends Hotloadable, DataProvider {
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
default double getHeight(Location l)
|
default double getHeight(Location l) {
|
||||||
{
|
|
||||||
return getHeight(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
return getHeight(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,9 +30,8 @@ public class HeightmapObjectPlacer implements IObjectPlacer {
|
|||||||
private final IrisObjectPlacement config;
|
private final IrisObjectPlacement config;
|
||||||
private final IObjectPlacer oplacer;
|
private final IObjectPlacer oplacer;
|
||||||
|
|
||||||
public HeightmapObjectPlacer(RNG rng, int x, int yv, int z, IrisObjectPlacement config, IObjectPlacer oplacer)
|
public HeightmapObjectPlacer(RNG rng, int x, int yv, int z, IrisObjectPlacement config, IObjectPlacer oplacer) {
|
||||||
{
|
s = rng.nextLong() + yv + z - x;
|
||||||
s = rng.nextLong() + yv + z - x;
|
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.oplacer = oplacer;
|
this.oplacer = oplacer;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
package com.volmit.iris.engine.hunk;
|
package com.volmit.iris.engine.hunk;
|
||||||
|
|
||||||
import com.volmit.iris.engine.data.B;
|
|
||||||
import com.volmit.iris.engine.hunk.io.HunkIOAdapter;
|
import com.volmit.iris.engine.hunk.io.HunkIOAdapter;
|
||||||
import com.volmit.iris.engine.hunk.storage.*;
|
import com.volmit.iris.engine.hunk.storage.*;
|
||||||
import com.volmit.iris.engine.hunk.view.*;
|
import com.volmit.iris.engine.hunk.view.*;
|
||||||
@ -60,18 +59,15 @@ public interface Hunk<T> {
|
|||||||
return new HunkView<T>(src);
|
return new HunkView<T>(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
static <A,B> Hunk<B> convertedReadView(Hunk<A> src, Function<A, B> reader)
|
static <A, B> Hunk<B> convertedReadView(Hunk<A> src, Function<A, B> reader) {
|
||||||
{
|
|
||||||
return new FunctionalHunkView<A, B>(src, reader, null);
|
return new FunctionalHunkView<A, B>(src, reader, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
static <A,B> Hunk<B> convertedWriteView(Hunk<A> src, Function<B, A> writer)
|
static <A, B> Hunk<B> convertedWriteView(Hunk<A> src, Function<B, A> writer) {
|
||||||
{
|
|
||||||
return new FunctionalHunkView<A, B>(src, null, writer);
|
return new FunctionalHunkView<A, B>(src, null, writer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static <A,B> Hunk<B> convertedReadWriteView(Hunk<A> src, Function<A, B> reader, Function<B, A> writer)
|
static <A, B> Hunk<B> convertedReadWriteView(Hunk<A> src, Function<A, B> reader, Function<B, A> writer) {
|
||||||
{
|
|
||||||
return new FunctionalHunkView<A, B>(src, reader, writer);
|
return new FunctionalHunkView<A, B>(src, reader, writer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1206,26 +1202,23 @@ public interface Hunk<T> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Take a hunk and scale it up using interpolation
|
* Take a hunk and scale it up using interpolation
|
||||||
* @param scale the scale
|
*
|
||||||
* @param d the interpolation method
|
* @param scale the scale
|
||||||
|
* @param d the interpolation method
|
||||||
* @param interpolated the interpolated value converter
|
* @param interpolated the interpolated value converter
|
||||||
* @return the new hunk
|
* @return the new hunk
|
||||||
*/
|
*/
|
||||||
default Hunk<T> interpolate3D(double scale, InterpolationMethod3D d, Interpolated<T> interpolated)
|
default Hunk<T> interpolate3D(double scale, InterpolationMethod3D d, Interpolated<T> interpolated) {
|
||||||
{
|
Hunk<T> t = Hunk.newArrayHunk((int) (getWidth() * scale), (int) (getHeight() * scale), (int) (getDepth() * scale));
|
||||||
Hunk<T> t = Hunk.newArrayHunk((int)(getWidth() * scale), (int)(getHeight() * scale), (int)(getDepth() * scale));
|
NoiseProvider3 n3 = (x, y, z) -> interpolated.toDouble(
|
||||||
NoiseProvider3 n3 = (x,y,z) -> interpolated.toDouble(
|
t.get((int) (x / scale),
|
||||||
t.get((int)(x/scale),
|
(int) (y / scale),
|
||||||
(int)(y/scale),
|
(int) (z / scale)));
|
||||||
(int)(z/scale)));
|
|
||||||
|
|
||||||
for(int i = 0; i < t.getWidth(); i++)
|
for (int i = 0; i < t.getWidth(); i++) {
|
||||||
{
|
for (int j = 0; j < t.getHeight(); j++) {
|
||||||
for(int j = 0; j < t.getHeight(); j++)
|
for (int k = 0; k < t.getDepth(); k++) {
|
||||||
{
|
t.set(i, j, k, interpolated.fromDouble(IrisInterpolation.getNoise3D(d, i, j, k, scale, n3)));
|
||||||
for(int k = 0; k < t.getDepth(); k++)
|
|
||||||
{
|
|
||||||
t.set(i, j, k, interpolated.fromDouble(IrisInterpolation.getNoise3D(d, i,j,k,scale, n3)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1236,24 +1229,22 @@ public interface Hunk<T> {
|
|||||||
/**
|
/**
|
||||||
* Take a hunk and scale it up using interpolation
|
* Take a hunk and scale it up using interpolation
|
||||||
* 2D, (using only x and z) assumes the height is 1
|
* 2D, (using only x and z) assumes the height is 1
|
||||||
* @param scale the scale
|
*
|
||||||
* @param d the interpolation method
|
* @param scale the scale
|
||||||
|
* @param d the interpolation method
|
||||||
* @param interpolated the interpolated value converter
|
* @param interpolated the interpolated value converter
|
||||||
* @return the new hunk
|
* @return the new hunk
|
||||||
*/
|
*/
|
||||||
default Hunk<T> interpolate2D(double scale, InterpolationMethod d, Interpolated<T> interpolated)
|
default Hunk<T> interpolate2D(double scale, InterpolationMethod d, Interpolated<T> interpolated) {
|
||||||
{
|
Hunk<T> t = Hunk.newArrayHunk((int) (getWidth() * scale), 1, (int) (getDepth() * scale));
|
||||||
Hunk<T> t = Hunk.newArrayHunk((int)(getWidth() * scale), 1, (int)(getDepth() * scale));
|
NoiseProvider n2 = (x, z) -> interpolated.toDouble(
|
||||||
NoiseProvider n2 = (x,z) -> interpolated.toDouble(
|
t.get((int) (x / scale),
|
||||||
t.get((int)(x/scale),
|
|
||||||
0,
|
0,
|
||||||
(int)(z/scale)));
|
(int) (z / scale)));
|
||||||
|
|
||||||
for(int i = 0; i < t.getWidth(); i++)
|
for (int i = 0; i < t.getWidth(); i++) {
|
||||||
{
|
for (int j = 0; j < t.getDepth(); j++) {
|
||||||
for(int j = 0; j < t.getDepth(); j++)
|
t.set(i, 0, j, interpolated.fromDouble(IrisInterpolation.getNoise(d, i, j, scale, n2)));
|
||||||
{
|
|
||||||
t.set(i, 0, j, interpolated.fromDouble(IrisInterpolation.getNoise(d, i,j,scale, n2)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,18 +35,16 @@ public class FunctionalHunkView<R, T> implements Hunk<T> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRaw(int x, int y, int z, T t) {
|
public void setRaw(int x, int y, int z, T t) {
|
||||||
if(backConverter == null)
|
if (backConverter == null) {
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException("You cannot write to this hunk (Read Only)");
|
throw new UnsupportedOperationException("You cannot write to this hunk (Read Only)");
|
||||||
}
|
}
|
||||||
|
|
||||||
src.setRaw(x,y,z,backConverter.apply(t));
|
src.setRaw(x, y, z, backConverter.apply(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T getRaw(int x, int y, int z) {
|
public T getRaw(int x, int y, int z) {
|
||||||
if(converter == null)
|
if (converter == null) {
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException("You cannot read this hunk (Write Only)");
|
throw new UnsupportedOperationException("You cannot read this hunk (Write Only)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,9 +21,7 @@ package com.volmit.iris.engine.interpolation;
|
|||||||
import com.google.common.util.concurrent.AtomicDouble;
|
import com.google.common.util.concurrent.AtomicDouble;
|
||||||
import com.volmit.iris.engine.hunk.Hunk;
|
import com.volmit.iris.engine.hunk.Hunk;
|
||||||
import com.volmit.iris.engine.noise.CNG;
|
import com.volmit.iris.engine.noise.CNG;
|
||||||
import com.volmit.iris.engine.object.IrisInterpolator3D;
|
|
||||||
import com.volmit.iris.engine.object.NoiseStyle;
|
import com.volmit.iris.engine.object.NoiseStyle;
|
||||||
import com.volmit.iris.engine.parallel.MultiBurst;
|
|
||||||
import com.volmit.iris.util.function.NoiseProvider;
|
import com.volmit.iris.util.function.NoiseProvider;
|
||||||
import com.volmit.iris.util.function.NoiseProvider3;
|
import com.volmit.iris.util.function.NoiseProvider3;
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
@ -318,9 +316,9 @@ public class IrisInterpolation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static double getStarcast3D(int x, int y, int z, double rad, double checks, NoiseProvider3 n) {
|
public static double getStarcast3D(int x, int y, int z, double rad, double checks, NoiseProvider3 n) {
|
||||||
return (getStarcast(x, z, rad, checks, (xx,zz) -> n.noise(xx, y, zz))
|
return (getStarcast(x, z, rad, checks, (xx, zz) -> n.noise(xx, y, zz))
|
||||||
+ getStarcast(x, y, rad, checks, (xx,yy) -> n.noise(xx, yy, z))
|
+ getStarcast(x, y, rad, checks, (xx, yy) -> n.noise(xx, yy, z))
|
||||||
+ getStarcast(y, z, rad, checks, (yy,zz) -> n.noise(x, yy, zz)))/3D;
|
+ getStarcast(y, z, rad, checks, (yy, zz) -> n.noise(x, yy, zz))) / 3D;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getBilinearBezierNoise(int x, int z, double rad, NoiseProvider n) {
|
public static double getBilinearBezierNoise(int x, int z, double rad, NoiseProvider n) {
|
||||||
@ -851,52 +849,48 @@ public class IrisInterpolation {
|
|||||||
case TRILINEAR -> getTrilinear(x, y, z, radx, rady, radz, n);
|
case TRILINEAR -> getTrilinear(x, y, z, radx, rady, radz, n);
|
||||||
case TRICUBIC -> getTricubic(x, y, z, radx, rady, radz, n);
|
case TRICUBIC -> getTricubic(x, y, z, radx, rady, radz, n);
|
||||||
case TRIHERMITE -> getTrihermite(x, y, z, radx, rady, radz, n);
|
case TRIHERMITE -> getTrihermite(x, y, z, radx, rady, radz, n);
|
||||||
case TRISTARCAST_3 -> getStarcast3D(x,y,z,radx,3D,n);
|
case TRISTARCAST_3 -> getStarcast3D(x, y, z, radx, 3D, n);
|
||||||
case TRISTARCAST_6 -> getStarcast3D(x,y,z,radx,6D,n);
|
case TRISTARCAST_6 -> getStarcast3D(x, y, z, radx, 6D, n);
|
||||||
case TRISTARCAST_9 -> getStarcast3D(x,y,z,radx,9D,n);
|
case TRISTARCAST_9 -> getStarcast3D(x, y, z, radx, 9D, n);
|
||||||
case TRISTARCAST_12 -> getStarcast3D(x,y,z,radx,12D,n);
|
case TRISTARCAST_12 -> getStarcast3D(x, y, z, radx, 12D, n);
|
||||||
case TRILINEAR_TRISTARCAST_3 -> getStarcast3D(x,y,z,radx,3D, (xx,yy,zz) -> getTrilinear((int)xx,(int)yy,(int)zz,radx, rady,radz,n));
|
case TRILINEAR_TRISTARCAST_3 -> getStarcast3D(x, y, z, radx, 3D, (xx, yy, zz) -> getTrilinear((int) xx, (int) yy, (int) zz, radx, rady, radz, n));
|
||||||
case TRILINEAR_TRISTARCAST_6 -> getStarcast3D(x,y,z,radx,6D, (xx,yy,zz) -> getTrilinear((int)xx,(int)yy,(int)zz,radx, rady,radz,n));
|
case TRILINEAR_TRISTARCAST_6 -> getStarcast3D(x, y, z, radx, 6D, (xx, yy, zz) -> getTrilinear((int) xx, (int) yy, (int) zz, radx, rady, radz, n));
|
||||||
case TRILINEAR_TRISTARCAST_9 -> getStarcast3D(x,y,z,radx,9D, (xx,yy,zz) -> getTrilinear((int)xx,(int)yy,(int)zz,radx, rady,radz,n));
|
case TRILINEAR_TRISTARCAST_9 -> getStarcast3D(x, y, z, radx, 9D, (xx, yy, zz) -> getTrilinear((int) xx, (int) yy, (int) zz, radx, rady, radz, n));
|
||||||
case TRILINEAR_TRISTARCAST_12 -> getStarcast3D(x,y,z,radx,12D, (xx,yy,zz) -> getTrilinear((int)xx,(int)yy,(int)zz,radx, rady,radz,n));
|
case TRILINEAR_TRISTARCAST_12 -> getStarcast3D(x, y, z, radx, 12D, (xx, yy, zz) -> getTrilinear((int) xx, (int) yy, (int) zz, radx, rady, radz, n));
|
||||||
case NONE -> n.noise(x,y,z);
|
case NONE -> n.noise(x, y, z);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Hunk<Double> getNoise3D(InterpolationMethod3D method, int xo, int yo, int zo, int w, int h, int d, double rad, NoiseProvider3 n)
|
public static Hunk<Double> getNoise3D(InterpolationMethod3D method, int xo, int yo, int zo, int w, int h, int d, double rad, NoiseProvider3 n) {
|
||||||
{
|
return getNoise3D(method, xo, yo, zo, w, h, d, rad, rad, rad, n);
|
||||||
return getNoise3D(method, xo, yo, zo, w,h,d,rad,rad,rad,n);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the interpolated 3D noise within a given cuboid size with offsets
|
* Get the interpolated 3D noise within a given cuboid size with offsets
|
||||||
|
*
|
||||||
* @param method the interpolation method to use
|
* @param method the interpolation method to use
|
||||||
* @param xo the x offset for noise
|
* @param xo the x offset for noise
|
||||||
* @param yo the y offset for noise
|
* @param yo the y offset for noise
|
||||||
* @param zo the z offset for noise
|
* @param zo the z offset for noise
|
||||||
* @param w the width of the result
|
* @param w the width of the result
|
||||||
* @param h the height of the result
|
* @param h the height of the result
|
||||||
* @param d the depth of the result
|
* @param d the depth of the result
|
||||||
* @param radX the interpolation radius for the x axis
|
* @param radX the interpolation radius for the x axis
|
||||||
* @param radY the interpolation radius for the y axis
|
* @param radY the interpolation radius for the y axis
|
||||||
* @param radZ the interpolation radius for the z axis
|
* @param radZ the interpolation radius for the z axis
|
||||||
* @param n the noise provider
|
* @param n the noise provider
|
||||||
* @return the resulting hunk of noise
|
* @return the resulting hunk of noise
|
||||||
*/
|
*/
|
||||||
public static Hunk<Double> getNoise3D(InterpolationMethod3D method, int xo, int yo, int zo, int w, int h, int d, double radX, double radY, double radZ, NoiseProvider3 n)
|
public static Hunk<Double> getNoise3D(InterpolationMethod3D method, int xo, int yo, int zo, int w, int h, int d, double radX, double radY, double radZ, NoiseProvider3 n) {
|
||||||
{
|
Hunk<Double> hunk = Hunk.newAtomicDoubleHunk(w, h, d);
|
||||||
Hunk<Double> hunk = Hunk.newAtomicDoubleHunk(w,h,d);
|
|
||||||
HashMap<Integer, Double> cache = new HashMap<>();
|
HashMap<Integer, Double> cache = new HashMap<>();
|
||||||
int i,j,k;
|
int i, j, k;
|
||||||
|
|
||||||
for(i = 0; i < w; i++)
|
for (i = 0; i < w; i++) {
|
||||||
{
|
|
||||||
int fi = i;
|
int fi = i;
|
||||||
for(j = 0; j < h; j++)
|
for (j = 0; j < h; j++) {
|
||||||
{
|
|
||||||
int fj = j;
|
int fj = j;
|
||||||
for(k = 0; k < d; k++)
|
for (k = 0; k < d; k++) {
|
||||||
{
|
|
||||||
int fk = k;
|
int fk = k;
|
||||||
hunk.set(i, j, k, cache.compute((k * w * h) + (j * w) + i, (p, v)
|
hunk.set(i, j, k, cache.compute((k * w * h) + (j * w) + i, (p, v)
|
||||||
-> getNoise3D(method, fi + xo, fj + yo, fk + zo,
|
-> getNoise3D(method, fi + xo, fj + yo, fk + zo,
|
||||||
@ -909,7 +903,7 @@ public class IrisInterpolation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static double getNoise3D(InterpolationMethod3D method, int x, int y, int z, double rad, NoiseProvider3 n) {
|
public static double getNoise3D(InterpolationMethod3D method, int x, int y, int z, double rad, NoiseProvider3 n) {
|
||||||
return getNoise3D(method, x,y,z,rad,rad,rad,n);
|
return getNoise3D(method, x, y, z, rad, rad, rad, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getNoise(InterpolationMethod method, int x, int z, double h, NoiseProvider n) {
|
public static double getNoise(InterpolationMethod method, int x, int z, double h, NoiseProvider n) {
|
||||||
|
@ -23,18 +23,13 @@ import com.volmit.iris.engine.framework.Engine;
|
|||||||
import com.volmit.iris.engine.framework.EngineAssignedModifier;
|
import com.volmit.iris.engine.framework.EngineAssignedModifier;
|
||||||
import com.volmit.iris.engine.hunk.Hunk;
|
import com.volmit.iris.engine.hunk.Hunk;
|
||||||
import com.volmit.iris.engine.noise.FastNoiseDouble;
|
import com.volmit.iris.engine.noise.FastNoiseDouble;
|
||||||
import com.volmit.iris.engine.object.IrisBiome;
|
|
||||||
import com.volmit.iris.engine.object.IrisCaveLayer;
|
|
||||||
import com.volmit.iris.engine.object.common.CaveResult;
|
import com.volmit.iris.engine.object.common.CaveResult;
|
||||||
import com.volmit.iris.engine.parallel.BurstExecutor;
|
import com.volmit.iris.engine.parallel.BurstExecutor;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
public class IrisCaveModifier2 extends EngineAssignedModifier<BlockData> {
|
public class IrisCaveModifier2 extends EngineAssignedModifier<BlockData> {
|
||||||
public static final BlockData CAVE_AIR = B.get("CAVE_AIR");
|
public static final BlockData CAVE_AIR = B.get("CAVE_AIR");
|
||||||
public static final BlockData AIR = B.get("AIR");
|
public static final BlockData AIR = B.get("AIR");
|
||||||
|
@ -77,20 +77,17 @@ public class IrisCarveLayer {
|
|||||||
return getCng(rng).fitDouble(0D, 1D, x, y, z) * opacity > getThreshold();
|
return getCng(rng).fitDouble(0D, 1D, x, y, z) * opacity > getThreshold();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProceduralStream<Boolean> stream(RNG rng)
|
public ProceduralStream<Boolean> stream(RNG rng) {
|
||||||
{
|
return streamCache.aquire(() -> ProceduralStream.of((x, y, z) -> isCarved(rng, x, y, z), Interpolated.BOOLEAN));
|
||||||
return streamCache.aquire(() -> ProceduralStream.of((x,y,z) -> isCarved(rng, x,y,z), Interpolated.BOOLEAN));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProceduralStream<Double> rawStream(RNG rng)
|
public ProceduralStream<Double> rawStream(RNG rng) {
|
||||||
{
|
return rawStreamCache.aquire(() -> ProceduralStream.of((x, y, z) -> {
|
||||||
return rawStreamCache.aquire(() -> ProceduralStream.of((x,y,z) -> {
|
|
||||||
return getCng(rng).fitDouble(0D, 1D, x, y, z) * Math.pow(IrisInterpolation.sinCenter(M.lerpInverse(getMinHeight(), getMaxHeight(), y)), 4);
|
return getCng(rng).fitDouble(0D, 1D, x, y, z) * Math.pow(IrisInterpolation.sinCenter(M.lerpInverse(getMinHeight(), getMaxHeight(), y)), 4);
|
||||||
}, Interpolated.DOUBLE));
|
}, Interpolated.DOUBLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG getCng(RNG rng)
|
public CNG getCng(RNG rng) {
|
||||||
{
|
|
||||||
return cng.aquire(() -> getStyle().create(rng.nextParallelRNG(-2340 * getMaxHeight() * getMinHeight())));
|
return cng.aquire(() -> getStyle().create(rng.nextParallelRNG(-2340 * getMaxHeight() * getMinHeight())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
package com.volmit.iris.engine.object;
|
package com.volmit.iris.engine.object;
|
||||||
|
|
||||||
import com.volmit.iris.engine.cache.AtomicCache;
|
import com.volmit.iris.engine.cache.AtomicCache;
|
||||||
import com.volmit.iris.engine.hunk.Hunk;
|
|
||||||
import com.volmit.iris.engine.object.annotations.Desc;
|
import com.volmit.iris.engine.object.annotations.Desc;
|
||||||
import com.volmit.iris.engine.object.annotations.MaxNumber;
|
import com.volmit.iris.engine.object.annotations.MaxNumber;
|
||||||
import com.volmit.iris.engine.object.annotations.MinNumber;
|
import com.volmit.iris.engine.object.annotations.MinNumber;
|
||||||
@ -31,9 +30,6 @@ import lombok.Data;
|
|||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@ -53,18 +49,16 @@ public class IrisCavernZone implements IRare {
|
|||||||
private AtomicCache<ProceduralStream<Boolean>> carveCache = new AtomicCache<>();
|
private AtomicCache<ProceduralStream<Boolean>> carveCache = new AtomicCache<>();
|
||||||
|
|
||||||
public boolean isCarved(RNG rng, double xx, double yy, double zz) {
|
public boolean isCarved(RNG rng, double xx, double yy, double zz) {
|
||||||
if(carver != null)
|
if (carver != null) {
|
||||||
{
|
return carver.isCarved(rng, xx, yy, zz);
|
||||||
return carver.isCarved(rng, xx,yy,zz);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getCarved(RNG rng, double xx, double yy, double zz) {
|
public double getCarved(RNG rng, double xx, double yy, double zz) {
|
||||||
if(carver != null)
|
if (carver != null) {
|
||||||
{
|
return carver.rawStream(rng).get(xx, yy, zz) / (carver.getThreshold() * 2);
|
||||||
return carver.rawStream(rng).get(xx,yy,zz) / (carver.getThreshold() * 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -19,9 +19,8 @@
|
|||||||
package com.volmit.iris.engine.object;
|
package com.volmit.iris.engine.object;
|
||||||
|
|
||||||
import com.volmit.iris.engine.cache.AtomicCache;
|
import com.volmit.iris.engine.cache.AtomicCache;
|
||||||
import com.volmit.iris.engine.hunk.Hunk;
|
import com.volmit.iris.engine.object.annotations.ArrayType;
|
||||||
import com.volmit.iris.engine.interpolation.IrisInterpolation;
|
import com.volmit.iris.engine.object.annotations.Desc;
|
||||||
import com.volmit.iris.engine.object.annotations.*;
|
|
||||||
import com.volmit.iris.engine.stream.ProceduralStream;
|
import com.volmit.iris.engine.stream.ProceduralStream;
|
||||||
import com.volmit.iris.engine.stream.interpolation.Interpolated;
|
import com.volmit.iris.engine.stream.interpolation.Interpolated;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
@ -59,40 +58,35 @@ public class IrisCaverns {
|
|||||||
private transient AtomicCache<ProceduralStream<IrisCavernZone>> zonesRarity = new AtomicCache<>();
|
private transient AtomicCache<ProceduralStream<IrisCavernZone>> zonesRarity = new AtomicCache<>();
|
||||||
private transient AtomicCache<ProceduralStream<Double>> streamCache = new AtomicCache<>();
|
private transient AtomicCache<ProceduralStream<Double>> streamCache = new AtomicCache<>();
|
||||||
|
|
||||||
public IrisCavernZone getZone(double x, double y, double z, RNG rng)
|
public IrisCavernZone getZone(double x, double y, double z, RNG rng) {
|
||||||
{
|
|
||||||
return zonesRarity.aquire(() -> zoneStyle.create(rng)
|
return zonesRarity.aquire(() -> zoneStyle.create(rng)
|
||||||
.stream().selectRarity(getZones())).get(x,y,z);
|
.stream().selectRarity(getZones())).get(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
private double threshold(double y)
|
private double threshold(double y) {
|
||||||
{
|
|
||||||
return 0.5;
|
return 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProceduralStream<Double> stream(RNG rng)
|
public ProceduralStream<Double> stream(RNG rng) {
|
||||||
{
|
if (preThresholdInterpolation) {
|
||||||
if(preThresholdInterpolation)
|
return streamCache.aquire(() -> ProceduralStream.of((xx, yy, zz)
|
||||||
{
|
|
||||||
return streamCache.aquire(() -> ProceduralStream.of((xx,yy,zz)
|
|
||||||
-> (getZone(xx, yy, zz, rng)
|
-> (getZone(xx, yy, zz, rng)
|
||||||
.getCarved(rng, xx,yy,zz)), Interpolated.DOUBLE)
|
.getCarved(rng, xx, yy, zz)), Interpolated.DOUBLE)
|
||||||
.cache3D(65535));
|
.cache3D(65535));
|
||||||
}
|
}
|
||||||
|
|
||||||
return streamCache.aquire(() -> ProceduralStream.of((xx,yy,zz)
|
return streamCache.aquire(() -> ProceduralStream.of((xx, yy, zz)
|
||||||
-> (getZone(xx, yy, zz, rng)
|
-> (getZone(xx, yy, zz, rng)
|
||||||
.isCarved(rng, xx,yy,zz) ? 1D : 0D), Interpolated.DOUBLE)
|
.isCarved(rng, xx, yy, zz) ? 1D : 0D), Interpolated.DOUBLE)
|
||||||
.cache3D(65535));
|
.cache3D(65535));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCavern(RNG rng, double x, double y, double z, double height) {
|
public boolean isCavern(RNG rng, double x, double y, double z, double height) {
|
||||||
if(zones.isEmpty())
|
if (zones.isEmpty()) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return getInterpolator().interpolate(x, y, z, (xx, yy, zz)
|
return getInterpolator().interpolate(x, y, z, (xx, yy, zz)
|
||||||
-> stream(rng).get(xx,yy,zz)) > threshold(height);
|
-> stream(rng).get(xx, yy, zz)) > threshold(height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ package com.volmit.iris.engine.object;
|
|||||||
import com.volmit.iris.engine.object.annotations.Desc;
|
import com.volmit.iris.engine.object.annotations.Desc;
|
||||||
import com.volmit.iris.util.format.Form;
|
import com.volmit.iris.util.format.Form;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.bukkit.World;
|
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@ -58,13 +57,11 @@ public class IrisDuration {
|
|||||||
@Desc("REAL (not minecraft) Days")
|
@Desc("REAL (not minecraft) Days")
|
||||||
private int days = 0;
|
private int days = 0;
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
|
||||||
return Form.duration((double) toMilliseconds(), 2);
|
return Form.duration((double) toMilliseconds(), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long toMilliseconds()
|
public long toMilliseconds() {
|
||||||
{
|
|
||||||
return getMilliseconds()
|
return getMilliseconds()
|
||||||
+ TimeUnit.SECONDS.toMillis(getSeconds())
|
+ TimeUnit.SECONDS.toMillis(getSeconds())
|
||||||
+ TimeUnit.MINUTES.toMillis(getMinutes())
|
+ TimeUnit.MINUTES.toMillis(getMinutes())
|
||||||
|
@ -273,7 +273,7 @@ public class IrisEffect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (particleEffect != null) {
|
if (particleEffect != null) {
|
||||||
Location part = p.getLocation().clone().add(0, 0.25, 0).add(new Vector(1,1,1).multiply(RNG.r.d())).subtract(new Vector(1,1,1).multiply(RNG.r.d()));
|
Location part = p.getLocation().clone().add(0, 0.25, 0).add(new Vector(1, 1, 1).multiply(RNG.r.d())).subtract(new Vector(1, 1, 1).multiply(RNG.r.d()));
|
||||||
part.add(RNG.r.d(), 0, RNG.r.d());
|
part.add(RNG.r.d(), 0, RNG.r.d());
|
||||||
if (extra != 0) {
|
if (extra != 0) {
|
||||||
J.s(() -> p.getWorld().spawnParticle(particleEffect, part.getX(), part.getY() + RNG.r.i(particleOffset),
|
J.s(() -> p.getWorld().spawnParticle(particleEffect, part.getX(), part.getY() + RNG.r.i(particleOffset),
|
||||||
|
@ -259,8 +259,7 @@ public class IrisEntity extends IrisRegistrant {
|
|||||||
m.setAware(isAware());
|
m.setAware(isAware());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(spawnEffect != null)
|
if (spawnEffect != null) {
|
||||||
{
|
|
||||||
spawnEffect.apply(e);
|
spawnEffect.apply(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
package com.volmit.iris.engine.object;
|
package com.volmit.iris.engine.object;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.core.IrisSettings;
|
|
||||||
import com.volmit.iris.engine.cache.AtomicCache;
|
import com.volmit.iris.engine.cache.AtomicCache;
|
||||||
import com.volmit.iris.engine.framework.Engine;
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
import com.volmit.iris.engine.object.annotations.Desc;
|
import com.volmit.iris.engine.object.annotations.Desc;
|
||||||
@ -29,7 +28,6 @@ import com.volmit.iris.engine.object.annotations.Required;
|
|||||||
import com.volmit.iris.engine.object.common.IRare;
|
import com.volmit.iris.engine.object.common.IRare;
|
||||||
import com.volmit.iris.util.format.C;
|
import com.volmit.iris.util.format.C;
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
import com.volmit.iris.util.scheduling.J;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
@ -102,8 +100,7 @@ public class IrisEntitySpawn implements IRare {
|
|||||||
try {
|
try {
|
||||||
Location l = at.clone().add(0.5, 1, 0.5);
|
Location l = at.clone().add(0.5, 1, 0.5);
|
||||||
Entity e = getRealEntity(g).spawn(g, l, rng.aquire(() -> new RNG(g.getTarget().getWorld().seed() + 4)));
|
Entity e = getRealEntity(g).spawn(g, l, rng.aquire(() -> new RNG(g.getTarget().getWorld().seed() + 4)));
|
||||||
if(e != null)
|
if (e != null) {
|
||||||
{
|
|
||||||
Iris.debug("Spawned " + C.DARK_AQUA + "Entity<" + getEntity() + "> " + C.GREEN + e.getType() + C.LIGHT_PURPLE + " @ " + C.GRAY + e.getLocation().getX() + ", " + e.getLocation().getY() + ", " + e.getLocation().getZ());
|
Iris.debug("Spawned " + C.DARK_AQUA + "Entity<" + getEntity() + "> " + C.GREEN + e.getType() + C.LIGHT_PURPLE + " @ " + C.GRAY + e.getLocation().getX() + ", " + e.getLocation().getY() + ", " + e.getLocation().getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,13 +22,10 @@ import com.dfsek.paralithic.Expression;
|
|||||||
import com.dfsek.paralithic.eval.parser.Parser;
|
import com.dfsek.paralithic.eval.parser.Parser;
|
||||||
import com.dfsek.paralithic.eval.parser.Scope;
|
import com.dfsek.paralithic.eval.parser.Scope;
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.engine.IrisComplex;
|
|
||||||
import com.volmit.iris.engine.IrisEngine;
|
|
||||||
import com.volmit.iris.engine.cache.AtomicCache;
|
import com.volmit.iris.engine.cache.AtomicCache;
|
||||||
import com.volmit.iris.engine.framework.Engine;
|
import com.volmit.iris.engine.object.annotations.ArrayType;
|
||||||
import com.volmit.iris.engine.object.annotations.*;
|
import com.volmit.iris.engine.object.annotations.Desc;
|
||||||
import com.volmit.iris.engine.object.common.IRare;
|
import com.volmit.iris.engine.object.annotations.Required;
|
||||||
import com.volmit.iris.engine.stream.ProceduralStream;
|
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@ -57,36 +54,26 @@ public class IrisExpressionGenerator extends IrisRegistrant {
|
|||||||
|
|
||||||
private transient AtomicCache<Expression> expressionCache = new AtomicCache<>();
|
private transient AtomicCache<Expression> expressionCache = new AtomicCache<>();
|
||||||
|
|
||||||
private Expression expression()
|
private Expression expression() {
|
||||||
{
|
|
||||||
return expressionCache.aquire(() -> {
|
return expressionCache.aquire(() -> {
|
||||||
Scope scope = new Scope(); // Create variable scope. This scope can hold both constants and invocation variables.
|
Scope scope = new Scope(); // Create variable scope. This scope can hold both constants and invocation variables.
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
for (IrisExpressionLoad i : variables) {
|
||||||
for(IrisExpressionLoad i : variables)
|
|
||||||
{
|
|
||||||
scope.addInvocationVariable(i.getName());
|
scope.addInvocationVariable(i.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.addInvocationVariable("x");
|
scope.addInvocationVariable("x");
|
||||||
scope.addInvocationVariable("y");
|
scope.addInvocationVariable("y");
|
||||||
scope.addInvocationVariable("z");
|
scope.addInvocationVariable("z");
|
||||||
}
|
} catch (Throwable e) {
|
||||||
|
|
||||||
catch(Throwable e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Iris.error("Script Variable load error in " + getLoadFile().getPath());
|
Iris.error("Script Variable load error in " + getLoadFile().getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
return parser.parse(getExpression(), scope);
|
return parser.parse(getExpression(), scope);
|
||||||
}
|
} catch (Throwable e) {
|
||||||
|
|
||||||
catch(Throwable e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Iris.error("Script load error in " + getLoadFile().getPath());
|
Iris.error("Script load error in " + getLoadFile().getPath());
|
||||||
}
|
}
|
||||||
@ -95,12 +82,10 @@ public class IrisExpressionGenerator extends IrisRegistrant {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public double evaluate(RNG rng, double x, double z)
|
public double evaluate(RNG rng, double x, double z) {
|
||||||
{
|
|
||||||
double[] g = new double[3 + getVariables().size()];
|
double[] g = new double[3 + getVariables().size()];
|
||||||
int m = 0;
|
int m = 0;
|
||||||
for(IrisExpressionLoad i : getVariables())
|
for (IrisExpressionLoad i : getVariables()) {
|
||||||
{
|
|
||||||
g[m++] = i.getValue(rng, x, z);
|
g[m++] = i.getValue(rng, x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,12 +96,10 @@ public class IrisExpressionGenerator extends IrisRegistrant {
|
|||||||
return expression().evaluate(g);
|
return expression().evaluate(g);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double evaluate(RNG rng, double x, double y, double z)
|
public double evaluate(RNG rng, double x, double y, double z) {
|
||||||
{
|
|
||||||
double[] g = new double[3 + getVariables().size()];
|
double[] g = new double[3 + getVariables().size()];
|
||||||
int m = 0;
|
int m = 0;
|
||||||
for(IrisExpressionLoad i : getVariables())
|
for (IrisExpressionLoad i : getVariables()) {
|
||||||
{
|
|
||||||
g[m++] = i.getValue(rng, x, y, z);
|
g[m++] = i.getValue(rng, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,8 +46,7 @@ public class IrisExpressionLoad {
|
|||||||
private IrisGeneratorStyle styleValue = null;
|
private IrisGeneratorStyle styleValue = null;
|
||||||
|
|
||||||
public double getValue(RNG rng, double x, double z) {
|
public double getValue(RNG rng, double x, double z) {
|
||||||
if(styleValue != null)
|
if (styleValue != null) {
|
||||||
{
|
|
||||||
return styleValue.create(rng).noise(x, z);
|
return styleValue.create(rng).noise(x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,8 +54,7 @@ public class IrisExpressionLoad {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public double getValue(RNG rng, double x, double y, double z) {
|
public double getValue(RNG rng, double x, double y, double z) {
|
||||||
if(styleValue != null)
|
if (styleValue != null) {
|
||||||
{
|
|
||||||
return styleValue.create(rng).noise(x, y, z);
|
return styleValue.create(rng).noise(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
package com.volmit.iris.engine.object;
|
package com.volmit.iris.engine.object;
|
||||||
|
|
||||||
import com.volmit.iris.engine.hunk.Hunk;
|
|
||||||
import com.volmit.iris.engine.interpolation.InterpolationMethod3D;
|
import com.volmit.iris.engine.interpolation.InterpolationMethod3D;
|
||||||
import com.volmit.iris.engine.interpolation.IrisInterpolation;
|
import com.volmit.iris.engine.interpolation.IrisInterpolation;
|
||||||
import com.volmit.iris.engine.object.annotations.Desc;
|
import com.volmit.iris.engine.object.annotations.Desc;
|
||||||
@ -52,6 +51,6 @@ public class IrisInterpolator3D {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public double interpolate(int x, int y, int z, NoiseProvider3 provider) {
|
public double interpolate(int x, int y, int z, NoiseProvider3 provider) {
|
||||||
return IrisInterpolation.getNoise3D(getFunction(), x,y, z, getScale(), provider);
|
return IrisInterpolation.getNoise3D(getFunction(), x, y, z, getScale(), provider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,10 +216,8 @@ public class IrisObjectPlacement {
|
|||||||
private transient AtomicCache<TableCache> cache = new AtomicCache<>();
|
private transient AtomicCache<TableCache> cache = new AtomicCache<>();
|
||||||
|
|
||||||
public boolean matches(IrisTreeSize size, TreeType type) {
|
public boolean matches(IrisTreeSize size, TreeType type) {
|
||||||
for(IrisTree i : getTrees())
|
for (IrisTree i : getTrees()) {
|
||||||
{
|
if (i.matches(size, type)) {
|
||||||
if(i.matches(size, type))
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,19 +36,16 @@ public class IrisRate {
|
|||||||
@Desc("The time interval. Leave blank for infinite 0 (meaning always spawn all the time)")
|
@Desc("The time interval. Leave blank for infinite 0 (meaning always spawn all the time)")
|
||||||
private IrisDuration per = new IrisDuration();
|
private IrisDuration per = new IrisDuration();
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
|
||||||
return Form.f(amount) + "/" + per;
|
return Form.f(amount) + "/" + per;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getInterval()
|
public long getInterval() {
|
||||||
{
|
|
||||||
long t = per.getMilliseconds() / (amount == 0 ? 1 : amount);
|
long t = per.getMilliseconds() / (amount == 0 ? 1 : amount);
|
||||||
return Math.abs(t <= 0 ? 1 : t);
|
return Math.abs(t <= 0 ? 1 : t);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChronoLatch toChronoLatch()
|
public ChronoLatch toChronoLatch() {
|
||||||
{
|
|
||||||
return new ChronoLatch(getInterval());
|
return new ChronoLatch(getInterval());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,22 +18,14 @@
|
|||||||
|
|
||||||
package com.volmit.iris.engine.object;
|
package com.volmit.iris.engine.object;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.engine.object.annotations.ArrayType;
|
||||||
import com.volmit.iris.engine.cache.AtomicCache;
|
import com.volmit.iris.engine.object.annotations.Desc;
|
||||||
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.collection.KList;
|
||||||
import com.volmit.iris.util.math.RNG;
|
|
||||||
import com.volmit.iris.util.reflect.V;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
import org.bukkit.Chunk;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@ -56,8 +48,7 @@ public class IrisSpawner extends IrisRegistrant {
|
|||||||
@Desc("The maximum rate this spawner can fire")
|
@Desc("The maximum rate this spawner can fire")
|
||||||
private IrisRate maximumRate = new IrisRate();
|
private IrisRate maximumRate = new IrisRate();
|
||||||
|
|
||||||
public boolean isValid(World world)
|
public boolean isValid(World world) {
|
||||||
{
|
|
||||||
return timeBlock.isWithin(world) && weather.is(world);
|
return timeBlock.isWithin(world) && weather.is(world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,7 @@
|
|||||||
|
|
||||||
package com.volmit.iris.engine.object;
|
package com.volmit.iris.engine.object;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
|
||||||
import com.volmit.iris.engine.object.annotations.Desc;
|
import com.volmit.iris.engine.object.annotations.Desc;
|
||||||
import com.volmit.iris.util.math.CDou;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
@ -33,20 +31,16 @@ public class IrisTimeBlock {
|
|||||||
@Desc("The ending hour. Set both to the same number for any time. If they are both set to -1, it will always be not allowed.")
|
@Desc("The ending hour. Set both to the same number for any time. If they are both set to -1, it will always be not allowed.")
|
||||||
private double endHour = 0;
|
private double endHour = 0;
|
||||||
|
|
||||||
public boolean isWithin(World world)
|
public boolean isWithin(World world) {
|
||||||
{
|
return isWithin(((world.getTime() / 1000D) + 6) % 24);
|
||||||
return isWithin(((world.getTime() / 1000D)+6)%24);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isWithin(double hour)
|
public boolean isWithin(double hour) {
|
||||||
{
|
if (startHour == endHour) {
|
||||||
if(startHour == endHour)
|
|
||||||
{
|
|
||||||
return endHour != -1;
|
return endHour != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(startHour > endHour)
|
if (startHour > endHour) {
|
||||||
{
|
|
||||||
return hour >= startHour || hour <= endHour;
|
return hour >= startHour || hour <= endHour;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,8 +52,7 @@ public class IrisTree {
|
|||||||
private boolean anySize;
|
private boolean anySize;
|
||||||
|
|
||||||
public boolean matches(IrisTreeSize size, TreeType type) {
|
public boolean matches(IrisTreeSize size, TreeType type) {
|
||||||
if(!matchesSize(size))
|
if (!matchesSize(size)) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,10 +60,8 @@ public class IrisTree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean matchesSize(IrisTreeSize size) {
|
private boolean matchesSize(IrisTreeSize size) {
|
||||||
for(IrisTreeSize i : getSizes())
|
for (IrisTreeSize i : getSizes()) {
|
||||||
{
|
if ((i.getDepth() == size.getDepth() && i.getWidth() == size.getWidth()) || (i.getDepth() == size.getWidth() && i.getWidth() == size.getDepth())) {
|
||||||
if((i.getDepth() == size.getDepth() && i.getWidth() == size.getWidth()) || (i.getDepth() == size.getWidth() && i.getWidth() == size.getDepth()))
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
package com.volmit.iris.engine.object;
|
package com.volmit.iris.engine.object;
|
||||||
|
|
||||||
import com.volmit.iris.engine.object.annotations.Desc;
|
import com.volmit.iris.engine.object.annotations.Desc;
|
||||||
import lombok.Data;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
@Desc("Represents a weather type")
|
@Desc("Represents a weather type")
|
||||||
@ -36,10 +35,8 @@ public enum IrisWeather {
|
|||||||
@Desc("Any weather")
|
@Desc("Any weather")
|
||||||
ANY;
|
ANY;
|
||||||
|
|
||||||
public boolean is(World world)
|
public boolean is(World world) {
|
||||||
{
|
return switch (this) {
|
||||||
return switch(this)
|
|
||||||
{
|
|
||||||
case NONE -> world.isClearWeather();
|
case NONE -> world.isClearWeather();
|
||||||
case DOWNFALL -> world.hasStorm();
|
case DOWNFALL -> world.hasStorm();
|
||||||
case DOWNFALL_WITH_THUNDER -> world.hasStorm() && world.isThundering();
|
case DOWNFALL_WITH_THUNDER -> world.hasStorm() && world.isThundering();
|
||||||
|
@ -22,8 +22,7 @@ import com.volmit.iris.util.collection.KList;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class IrisEngineData
|
public class IrisEngineData {
|
||||||
{
|
|
||||||
private IrisEngineStatistics statistics = new IrisEngineStatistics();
|
private IrisEngineStatistics statistics = new IrisEngineStatistics();
|
||||||
private KList<IrisEngineSpawnerCooldown> spawnerCooldowns = new KList<>();
|
private KList<IrisEngineSpawnerCooldown> spawnerCooldowns = new KList<>();
|
||||||
}
|
}
|
||||||
|
@ -24,18 +24,15 @@ import com.volmit.iris.util.math.M;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class IrisEngineSpawnerCooldown
|
public class IrisEngineSpawnerCooldown {
|
||||||
{
|
|
||||||
private long lastSpawn;
|
private long lastSpawn;
|
||||||
private String spawner;
|
private String spawner;
|
||||||
|
|
||||||
public void spawn(Engine engine)
|
public void spawn(Engine engine) {
|
||||||
{
|
|
||||||
lastSpawn = M.ms();
|
lastSpawn = M.ms();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canSpawn(IrisRate s)
|
public boolean canSpawn(IrisRate s) {
|
||||||
{
|
|
||||||
return M.ms() - lastSpawn > s.getInterval();
|
return M.ms() - lastSpawn > s.getInterval();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ import com.google.gson.Gson;
|
|||||||
import com.volmit.iris.engine.hunk.io.HunkIOAdapter;
|
import com.volmit.iris.engine.hunk.io.HunkIOAdapter;
|
||||||
import com.volmit.iris.engine.hunk.io.PaletteHunkIOAdapter;
|
import com.volmit.iris.engine.hunk.io.PaletteHunkIOAdapter;
|
||||||
import com.volmit.iris.engine.object.IrisFeaturePositional;
|
import com.volmit.iris.engine.object.IrisFeaturePositional;
|
||||||
import com.volmit.iris.util.collection.KList;
|
|
||||||
import com.volmit.iris.util.oldnbt.CompoundTag;
|
import com.volmit.iris.util.oldnbt.CompoundTag;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -30,7 +29,6 @@ import lombok.Data;
|
|||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@ -92,8 +90,7 @@ public class ParallaxChunkMeta {
|
|||||||
private int count;
|
private int count;
|
||||||
private List<IrisFeaturePositional> features;
|
private List<IrisFeaturePositional> features;
|
||||||
|
|
||||||
private static List<IrisFeaturePositional> newList()
|
private static List<IrisFeaturePositional> newList() {
|
||||||
{
|
|
||||||
return new CopyOnWriteArrayList<>();
|
return new CopyOnWriteArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,14 +47,13 @@ public class HyperLock {
|
|||||||
.initialCapacity(capacity)
|
.initialCapacity(capacity)
|
||||||
.maximumWeightedCapacity(capacity)
|
.maximumWeightedCapacity(capacity)
|
||||||
.listener((k, v) -> {
|
.listener((k, v) -> {
|
||||||
if(v.isLocked() || v.isHeldByCurrentThread())
|
if (v.isLocked() || v.isHeldByCurrentThread()) {
|
||||||
{
|
|
||||||
Iris.warn("InfiniLock Eviction of " + k + " still has locks on it!");
|
Iris.warn("InfiniLock Eviction of " + k + " still has locks on it!");
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.concurrencyLevel(32)
|
.concurrencyLevel(32)
|
||||||
.build();
|
.build();
|
||||||
accessor = (k,v) -> v == null ? new ReentrantLock(fair) : v;
|
accessor = (k, v) -> v == null ? new ReentrantLock(fair) : v;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void with(int x, int z, Runnable r) {
|
public void with(int x, int z, Runnable r) {
|
||||||
@ -96,8 +95,7 @@ public class HyperLock {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ReentrantLock getLock(int x, int z)
|
private ReentrantLock getLock(int x, int z) {
|
||||||
{
|
|
||||||
return locks.compute(Cache.key(x, z), accessor);
|
return locks.compute(Cache.key(x, z), accessor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,8 +50,7 @@ public class MultiBurst {
|
|||||||
heartbeat = new Looper() {
|
heartbeat = new Looper() {
|
||||||
@Override
|
@Override
|
||||||
protected long loop() {
|
protected long loop() {
|
||||||
if(M.ms() - last.get() > TimeUnit.MINUTES.toMillis(1) && service != null)
|
if (M.ms() - last.get() > TimeUnit.MINUTES.toMillis(1) && service != null) {
|
||||||
{
|
|
||||||
service.shutdown();
|
service.shutdown();
|
||||||
service = null;
|
service = null;
|
||||||
Iris.debug("Shutting down MultiBurst Pool " + getName() + " to conserve resource.");
|
Iris.debug("Shutting down MultiBurst Pool " + getName() + " to conserve resource.");
|
||||||
@ -64,11 +63,9 @@ public class MultiBurst {
|
|||||||
heartbeat.start();
|
heartbeat.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized ExecutorService getService()
|
private synchronized ExecutorService getService() {
|
||||||
{
|
|
||||||
last.set(M.ms());
|
last.set(M.ms());
|
||||||
if(service == null || service.isShutdown())
|
if (service == null || service.isShutdown()) {
|
||||||
{
|
|
||||||
service = Executors.newFixedThreadPool(Math.max(tc, 1), r -> {
|
service = Executors.newFixedThreadPool(Math.max(tc, 1), r -> {
|
||||||
tid++;
|
tid++;
|
||||||
Thread t = new Thread(r);
|
Thread t = new Thread(r);
|
||||||
@ -130,8 +127,7 @@ public class MultiBurst {
|
|||||||
Iris.debug("Shutting down MultiBurst Pool " + heartbeat.getName() + ".");
|
Iris.debug("Shutting down MultiBurst Pool " + heartbeat.getName() + ".");
|
||||||
heartbeat.interrupt();
|
heartbeat.interrupt();
|
||||||
|
|
||||||
if(service != null)
|
if (service != null) {
|
||||||
{
|
|
||||||
service.shutdownNow().forEach(Runnable::run);
|
service.shutdownNow().forEach(Runnable::run);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,34 +136,30 @@ public class MultiBurst {
|
|||||||
Iris.debug("Shutting down MultiBurst Pool " + heartbeat.getName() + ".");
|
Iris.debug("Shutting down MultiBurst Pool " + heartbeat.getName() + ".");
|
||||||
heartbeat.interrupt();
|
heartbeat.interrupt();
|
||||||
|
|
||||||
if(service != null)
|
if (service != null) {
|
||||||
{
|
|
||||||
service.shutdown();
|
service.shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shutdownLater() {
|
public void shutdownLater() {
|
||||||
if(service != null)
|
if (service != null) {
|
||||||
{
|
service.submit(() -> {
|
||||||
service.submit(() -> {
|
J.sleep(3000);
|
||||||
J.sleep(3000);
|
Iris.debug("Shutting down MultiBurst Pool " + heartbeat.getName() + ".");
|
||||||
Iris.debug("Shutting down MultiBurst Pool " + heartbeat.getName() + ".");
|
|
||||||
|
|
||||||
if(service != null)
|
if (service != null) {
|
||||||
{
|
service.shutdown();
|
||||||
service.shutdown();
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
|
||||||
heartbeat.interrupt();
|
heartbeat.interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shutdownAndAwait() {
|
public void shutdownAndAwait() {
|
||||||
Iris.debug("Shutting down MultiBurst Pool " + heartbeat.getName() + ".");
|
Iris.debug("Shutting down MultiBurst Pool " + heartbeat.getName() + ".");
|
||||||
heartbeat.interrupt();
|
heartbeat.interrupt();
|
||||||
if(service != null)
|
if (service != null) {
|
||||||
{
|
|
||||||
service.shutdown();
|
service.shutdown();
|
||||||
try {
|
try {
|
||||||
while (!service.awaitTermination(10, TimeUnit.SECONDS)) {
|
while (!service.awaitTermination(10, TimeUnit.SECONDS)) {
|
||||||
|
@ -24,7 +24,7 @@ import com.volmit.iris.util.io.IORunnable;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class NOOPGridLock extends GridLock{
|
public class NOOPGridLock extends GridLock {
|
||||||
public NOOPGridLock(int x, int z) {
|
public NOOPGridLock(int x, int z) {
|
||||||
super(x, z);
|
super(x, z);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
package com.volmit.iris.engine.stream.utility;
|
package com.volmit.iris.engine.stream.utility;
|
||||||
|
|
||||||
import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap;
|
import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap;
|
||||||
import com.volmit.iris.engine.cache.Cache;
|
|
||||||
import com.volmit.iris.engine.stream.BasicStream;
|
import com.volmit.iris.engine.stream.BasicStream;
|
||||||
import com.volmit.iris.engine.stream.ProceduralStream;
|
import com.volmit.iris.engine.stream.ProceduralStream;
|
||||||
import com.volmit.iris.util.math.BlockPosition;
|
import com.volmit.iris.util.math.BlockPosition;
|
||||||
@ -50,11 +49,11 @@ public class CachedStream3D<T> extends BasicStream<T> implements ProceduralStrea
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T get(double x, double z) {
|
public T get(double x, double z) {
|
||||||
return cache.compute(new BlockPosition((int)x, -1, (int)z), (k, v) -> v != null ? v : stream.get((int) x, (int) z));
|
return cache.compute(new BlockPosition((int) x, -1, (int) z), (k, v) -> v != null ? v : stream.get((int) x, (int) z));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T get(double x, double y, double z) {
|
public T get(double x, double y, double z) {
|
||||||
return cache.compute(new BlockPosition((int)x, (int)y, (int)z), (k, v) -> v != null ? v : stream.get((int) x, (int) y, (int) z));
|
return cache.compute(new BlockPosition((int) x, (int) y, (int) z), (k, v) -> v != null ? v : stream.get((int) x, (int) y, (int) z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -625,14 +625,11 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
|||||||
return get(M.irand(0, last()));
|
return get(M.irand(0, last()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<T> popRandom(RNG rng, int c)
|
public KList<T> popRandom(RNG rng, int c) {
|
||||||
{
|
|
||||||
KList<T> m = new KList<>();
|
KList<T> m = new KList<>();
|
||||||
|
|
||||||
for(int i = 0; i < c; i++)
|
for (int i = 0; i < c; i++) {
|
||||||
{
|
if (isEmpty()) {
|
||||||
if(isEmpty())
|
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@ public class BlockPosition {
|
|||||||
private int y;
|
private int y;
|
||||||
private int z;
|
private int z;
|
||||||
|
|
||||||
|
|
||||||
//Magic numbers
|
//Magic numbers
|
||||||
private static final int m1 = 1 + MathHelper.f(MathHelper.c(30000000));
|
private static final int m1 = 1 + MathHelper.f(MathHelper.c(30000000));
|
||||||
private static final int m2 = 64 - (m1 * 2);
|
private static final int m2 = 64 - (m1 * 2);
|
||||||
@ -39,7 +38,6 @@ public class BlockPosition {
|
|||||||
private static final long m5 = (1L << m2) - 1L;
|
private static final long m5 = (1L << m2) - 1L;
|
||||||
private static final long m6 = (1L << m1) - 1L;
|
private static final long m6 = (1L << m1) - 1L;
|
||||||
|
|
||||||
|
|
||||||
public BlockPosition(int x, int y, int z) {
|
public BlockPosition(int x, int y, int z) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user