Merge branch 'master' into fixes

This commit is contained in:
CocoTheOwner 2021-09-20 16:40:37 +02:00
commit f01b3caeb1
18 changed files with 791 additions and 206 deletions

View File

@ -22,7 +22,7 @@ plugins {
} }
group 'com.volmit.iris' group 'com.volmit.iris'
version '1.8.11' version '1.8.12'
def apiVersion = '1.17' def apiVersion = '1.17'
def name = getRootProject().getName() // Defined in settings.gradle def name = getRootProject().getName() // Defined in settings.gradle
def main = 'com.volmit.iris.Iris' def main = 'com.volmit.iris.Iris'

View File

@ -19,6 +19,7 @@
package com.volmit.iris; package com.volmit.iris;
import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.ServerConfigurator;
import com.volmit.iris.core.link.IrisPapiExpansion; import com.volmit.iris.core.link.IrisPapiExpansion;
import com.volmit.iris.core.link.MultiverseCoreLink; import com.volmit.iris.core.link.MultiverseCoreLink;
import com.volmit.iris.core.link.MythicMobsLink; import com.volmit.iris.core.link.MythicMobsLink;
@ -237,6 +238,8 @@ public class Iris extends VolmitPlugin implements Listener {
while ((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) { while ((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) {
fileOutputStream.write(dataBuffer, 0, bytesRead); fileOutputStream.write(dataBuffer, 0, bytesRead);
} }
fileOutputStream.flush();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
Iris.reportError(e); Iris.reportError(e);
@ -405,7 +408,6 @@ public class Iris extends VolmitPlugin implements Listener {
initialize("com.volmit.iris.core.service").forEach((i) -> services.put((Class<? extends IrisService>) i.getClass(), (IrisService) i)); initialize("com.volmit.iris.core.service").forEach((i) -> services.put((Class<? extends IrisService>) i.getClass(), (IrisService) i));
INMS.get(); INMS.get();
IO.delete(new File("iris")); IO.delete(new File("iris"));
installDataPacks();
fixShading(); fixShading();
} }
@ -445,7 +447,7 @@ public class Iris extends VolmitPlugin implements Listener {
J.ar(this::checkConfigHotload, 60); J.ar(this::checkConfigHotload, 60);
J.sr(this::tickQueue, 0); J.sr(this::tickQueue, 0);
J.s(this::setupPapi); J.s(this::setupPapi);
J.a(this::verifyDataPacksPost, 20); J.a(ServerConfigurator::configure, 20);
splash(); splash();
if (IrisSettings.get().getStudio().isAutoStartDefaultStudio()) { if (IrisSettings.get().getStudio().isAutoStartDefaultStudio()) {
@ -494,72 +496,6 @@ public class Iris extends VolmitPlugin implements Listener {
} }
} }
public File getDatapacksFolder() {
if (!IrisSettings.get().getGeneral().forceMainWorld.isEmpty()) {
return new File(IrisSettings.get().getGeneral().forceMainWorld + "/datapacks");
}
File props = new File("server.properties");
if (props.exists()) {
try {
KList<String> m = new KList<>(IO.readAll(props).split("\\Q\n\\E"));
for (String i : m) {
if (i.trim().startsWith("level-name=")) {
return new File(i.trim().split("\\Q=\\E")[1] + "/datapacks");
}
}
} catch (IOException e) {
Iris.reportError(e);
e.printStackTrace();
}
}
return null;
}
public void installDataPacks() {
Iris.info("Checking Data Packs...");
boolean reboot = false;
File packs = new File("plugins/Iris/packs");
File dpacks = getDatapacksFolder();
if (dpacks == null) {
Iris.error("Cannot find the datapacks folder! Please try generating a default world first maybe? Is this a new server?");
return;
}
if (packs.exists()) {
for (File i : packs.listFiles()) {
if (i.isDirectory()) {
Iris.verbose("Checking Pack: " + i.getPath());
IrisData data = IrisData.get(i);
File dims = new File(i, "dimensions");
if (dims.exists()) {
for (File j : dims.listFiles()) {
if (j.getName().endsWith(".json")) {
IrisDimension dim = data.getDimensionLoader().load(j.getName().split("\\Q.\\E")[0]);
if (dim == null) {
continue;
}
Iris.verbose(" Checking Dimension " + dim.getLoadFile().getPath());
if (dim.installDataPack(() -> data, dpacks)) {
reboot = true;
}
}
}
}
}
}
}
Iris.info("Data Packs Setup!");
}
@Override @Override
public void start() { public void start() {
@ -609,104 +545,6 @@ public class Iris extends VolmitPlugin implements Listener {
} }
} }
public void verifyDataPacksPost() {
File packs = new File("plugins/Iris/packs");
File dpacks = getDatapacksFolder();
if (dpacks == null) {
Iris.error("Cannot find the datapacks folder! Please try generating a default world first maybe? Is this a new server?");
return;
}
boolean bad = false;
if (packs.exists()) {
for (File i : packs.listFiles()) {
if (i.isDirectory()) {
Iris.verbose("Checking Pack: " + i.getPath());
IrisData data = IrisData.get(i);
File dims = new File(i, "dimensions");
if (dims.exists()) {
for (File j : dims.listFiles()) {
if (j.getName().endsWith(".json")) {
IrisDimension dim = data.getDimensionLoader().load(j.getName().split("\\Q.\\E")[0]);
if (dim == null) {
Iris.error("Failed to load " + j.getPath() + " ");
continue;
}
if (!verifyDataPackInstalled(dim)) {
bad = true;
}
}
}
}
}
}
}
if (bad && INMS.get().supportsDataPacks()) {
Iris.error("============================================================================");
Iris.error(C.ITALIC + "You need to restart your server to properly generate custom biomes.");
Iris.error(C.ITALIC + "By continuing, Iris will use backup biomes in place of the custom biomes.");
Iris.error("----------------------------------------------------------------------------");
Iris.error(C.UNDERLINE + "IT IS HIGHLY RECOMMENDED YOU RESTART THE SERVER BEFORE GENERATING!");
Iris.error("============================================================================");
for (Player i : Bukkit.getOnlinePlayers()) {
if (i.isOp() || i.hasPermission("iris.all")) {
VolmitSender sender = new VolmitSender(i, getTag("WARNING"));
sender.sendMessage("There are some Iris Packs that have custom biomes in them");
sender.sendMessage("You need to restart your server to use these packs.");
}
}
J.sleep(3000);
}
}
public boolean verifyDataPackInstalled(IrisDimension dimension) {
IrisData idm = IrisData.get(getDataFolder("packs", dimension.getLoadKey()));
KSet<String> keys = new KSet<>();
boolean warn = false;
for (IrisBiome i : dimension.getAllBiomes(() -> idm)) {
if (i.isCustom()) {
for (IrisBiomeCustom j : i.getCustomDerivitives()) {
keys.add(dimension.getLoadKey() + ":" + j.getId());
}
}
}
if (!INMS.get().supportsDataPacks()) {
if (!keys.isEmpty()) {
Iris.warn("===================================================================================");
Iris.warn("Pack " + dimension.getLoadKey() + " has " + keys.size() + " custom biome(s). ");
Iris.warn("Your server version does not yet support datapacks for iris.");
Iris.warn("The world will generate these biomes as backup biomes.");
Iris.warn("====================================================================================");
}
return true;
}
for (String i : keys) {
Object o = INMS.get().getCustomBiomeBaseFor(i);
if (o == null) {
Iris.warn("The Biome " + i + " is not registered on the server.");
warn = true;
}
}
if (warn) {
Iris.error("The Pack " + dimension.getLoadKey() + " is INCAPABLE of generating custom biomes, restart your server before generating with this pack!");
}
return !warn;
}
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
return super.onCommand(sender, command, label, args); return super.onCommand(sender, command, label, args);

View File

@ -35,6 +35,7 @@ public class IrisSettings {
public static transient IrisSettings settings; public static transient IrisSettings settings;
private IrisSettingsGeneral general = new IrisSettingsGeneral(); private IrisSettingsGeneral general = new IrisSettingsGeneral();
private IrisSettingsGUI gui = new IrisSettingsGUI(); private IrisSettingsGUI gui = new IrisSettingsGUI();
private IrisSettingsAutoconfiguration autoConfiguration = new IrisSettingsAutoconfiguration();
private IrisSettingsGenerator generator = new IrisSettingsGenerator(); private IrisSettingsGenerator generator = new IrisSettingsGenerator();
private IrisSettingsConcurrency concurrency = new IrisSettingsConcurrency(); private IrisSettingsConcurrency concurrency = new IrisSettingsConcurrency();
private IrisSettingsStudio studio = new IrisSettingsStudio(); private IrisSettingsStudio studio = new IrisSettingsStudio();
@ -48,6 +49,13 @@ public class IrisSettings {
}; };
} }
@Data
public static class IrisSettingsAutoconfiguration {
public boolean configureSpigotTimeoutTime = true;
public boolean configurePaperWatchdogDelay = true;
public boolean autoRestartOnCustomBiomeInstall = true;
}
@Data @Data
public static class IrisSettingsConcurrency { public static class IrisSettingsConcurrency {
public int parallelism = -1; public int parallelism = -1;

View File

@ -0,0 +1,276 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.core;
import com.volmit.iris.Iris;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisBiomeCustom;
import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KSet;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.io.IO;
import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.J;
import org.bukkit.Bukkit;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
public class ServerConfigurator {
public static void configure()
{
IrisSettings.IrisSettingsAutoconfiguration s = IrisSettings.get().getAutoConfiguration();
if(s.isConfigureSpigotTimeoutTime())
{
J.attempt(ServerConfigurator::increaseKeepAliveSpigot);
}
if(s.isConfigurePaperWatchdogDelay())
{
J.attempt(ServerConfigurator::increasePaperWatchdog);
}
installDataPacks(true);
}
private static void increaseKeepAliveSpigot() throws IOException, InvalidConfigurationException {
File spigotConfig = new File("spigot.yml");
FileConfiguration f = new YamlConfiguration();
f.load(spigotConfig);
long tt = f.getLong("settings.timeout-time");
if(tt < TimeUnit.MINUTES.toSeconds(5))
{
Iris.warn("Updating spigot.yml timeout-time: " + tt + " -> " + TimeUnit.MINUTES.toSeconds(5) + " (5 minutes). You can disable this change (autoconfigureServer) in Iris settings, then change back the value.");
f.set("settings.timeout-time", TimeUnit.MINUTES.toSeconds(5));
f.save(spigotConfig);
}
}
private static void increasePaperWatchdog() throws IOException, InvalidConfigurationException {
File spigotConfig = new File("paper.yml");
FileConfiguration f = new YamlConfiguration();
f.load(spigotConfig);
long tt = f.getLong("settings.watchdog.early-warning-delay");
if(tt < TimeUnit.MINUTES.toMillis(3))
{
Iris.warn("Updating paper.yml watchdog early-warning-delay: " + tt + " -> " + TimeUnit.MINUTES.toMillis(3) + " (3 minutes). You can disable this change (autoconfigureServer) in Iris settings, then change back the value.");
f.set("settings.watchdog.early-warning-delay", TimeUnit.MINUTES.toMillis(3));
f.save(spigotConfig);
}
}
private static File getDatapacksFolder() {
if (!IrisSettings.get().getGeneral().forceMainWorld.isEmpty()) {
return new File(IrisSettings.get().getGeneral().forceMainWorld + "/datapacks");
}
File props = new File("server.properties");
if (props.exists()) {
try {
KList<String> m = new KList<>(IO.readAll(props).split("\\Q\n\\E"));
for (String i : m) {
if (i.trim().startsWith("level-name=")) {
return new File(i.trim().split("\\Q=\\E")[1] + "/datapacks");
}
}
} catch (IOException e) {
Iris.reportError(e);
e.printStackTrace();
}
}
return null;
}
public static void installDataPacks(boolean fullInstall)
{
Iris.info("Checking Data Packs...");
boolean reboot = false;
File packs = new File("plugins/Iris/packs");
File dpacks = getDatapacksFolder();
if (dpacks == null) {
Iris.error("Cannot find the datapacks folder! Please try generating a default world first maybe? Is this a new server?");
return;
}
if (packs.exists()) {
for (File i : packs.listFiles()) {
if (i.isDirectory()) {
Iris.verbose("Checking Pack: " + i.getPath());
IrisData data = IrisData.get(i);
File dims = new File(i, "dimensions");
if (dims.exists()) {
for (File j : dims.listFiles()) {
if (j.getName().endsWith(".json")) {
IrisDimension dim = data.getDimensionLoader().load(j.getName().split("\\Q.\\E")[0]);
if (dim == null) {
continue;
}
Iris.verbose(" Checking Dimension " + dim.getLoadFile().getPath());
if (dim.installDataPack(() -> data, dpacks)) {
reboot = true;
}
}
}
}
}
}
}
Iris.info("Data Packs Setup!");
if(fullInstall)
{
verifyDataPacksPost(IrisSettings.get().getAutoConfiguration().isAutoRestartOnCustomBiomeInstall());
}
}
private static void verifyDataPacksPost(boolean allowRestarting) {
File packs = new File("plugins/Iris/packs");
File dpacks = getDatapacksFolder();
if (dpacks == null) {
Iris.error("Cannot find the datapacks folder! Please try generating a default world first maybe? Is this a new server?");
return;
}
boolean bad = false;
if (packs.exists()) {
for (File i : packs.listFiles()) {
if (i.isDirectory()) {
Iris.verbose("Checking Pack: " + i.getPath());
IrisData data = IrisData.get(i);
File dims = new File(i, "dimensions");
if (dims.exists()) {
for (File j : dims.listFiles()) {
if (j.getName().endsWith(".json")) {
IrisDimension dim = data.getDimensionLoader().load(j.getName().split("\\Q.\\E")[0]);
if (dim == null) {
Iris.error("Failed to load " + j.getPath() + " ");
continue;
}
if (!verifyDataPackInstalled(dim)) {
bad = true;
}
}
}
}
}
}
}
if(bad)
{
if(allowRestarting)
{
restart();
}
else if (INMS.get().supportsDataPacks()) {
Iris.error("============================================================================");
Iris.error(C.ITALIC + "You need to restart your server to properly generate custom biomes.");
Iris.error(C.ITALIC + "By continuing, Iris will use backup biomes in place of the custom biomes.");
Iris.error("----------------------------------------------------------------------------");
Iris.error(C.UNDERLINE + "IT IS HIGHLY RECOMMENDED YOU RESTART THE SERVER BEFORE GENERATING!");
Iris.error("============================================================================");
for (Player i : Bukkit.getOnlinePlayers()) {
if (i.isOp() || i.hasPermission("iris.all")) {
VolmitSender sender = new VolmitSender(i, Iris.instance.getTag("WARNING"));
sender.sendMessage("There are some Iris Packs that have custom biomes in them");
sender.sendMessage("You need to restart your server to use these packs.");
}
}
J.sleep(3000);
}
}
}
public static void restart() {
J.s(() -> {
Iris.warn("New data pack entries have been installed in Iris! Restarting server! (You can disable this auto restart in iris settings). This will only happen when your pack changes (updates/first time setup)");
J.s(() -> {
Iris.warn("Looks like the restart command diddn't work. Stopping the server instead!");
Bukkit.shutdown();
}, 100);
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "restart");
});
}
public static boolean verifyDataPackInstalled(IrisDimension dimension) {
IrisData idm = IrisData.get(Iris.instance.getDataFolder("packs", dimension.getLoadKey()));
KSet<String> keys = new KSet<>();
boolean warn = false;
for (IrisBiome i : dimension.getAllBiomes(() -> idm)) {
if (i.isCustom()) {
for (IrisBiomeCustom j : i.getCustomDerivitives()) {
keys.add(dimension.getLoadKey() + ":" + j.getId());
}
}
}
if (!INMS.get().supportsDataPacks()) {
if (!keys.isEmpty()) {
Iris.warn("===================================================================================");
Iris.warn("Pack " + dimension.getLoadKey() + " has " + keys.size() + " custom biome(s). ");
Iris.warn("Your server version does not yet support datapacks for iris.");
Iris.warn("The world will generate these biomes as backup biomes.");
Iris.warn("====================================================================================");
}
return true;
}
for (String i : keys) {
Object o = INMS.get().getCustomBiomeBaseFor(i);
if (o == null) {
Iris.warn("The Biome " + i + " is not registered on the server.");
warn = true;
}
}
if (warn) {
Iris.error("The Pack " + dimension.getLoadKey() + " is INCAPABLE of generating custom biomes, restart your server before generating with this pack!");
}
return !warn;
}
}

View File

@ -22,6 +22,7 @@ import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException; import com.google.gson.JsonSyntaxException;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.ServerConfigurator;
import com.volmit.iris.core.loader.IrisData; import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.pack.IrisPack; import com.volmit.iris.core.pack.IrisPack;
import com.volmit.iris.core.project.IrisProject; import com.volmit.iris.core.project.IrisProject;
@ -285,8 +286,7 @@ public class StudioSVC implements IrisService {
} }
sender.sendMessage("Successfully Aquired " + d.getName()); sender.sendMessage("Successfully Aquired " + d.getName());
Iris.instance.installDataPacks(); ServerConfigurator.installDataPacks(true);
Iris.instance.verifyDataPacksPost();
} }
public KMap<String, String> getListing(boolean cached) { public KMap<String, String> getListing(boolean cached) {

View File

@ -31,12 +31,14 @@ import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.EngineEffects; import com.volmit.iris.engine.framework.EngineEffects;
import com.volmit.iris.engine.framework.EngineMetrics; import com.volmit.iris.engine.framework.EngineMetrics;
import com.volmit.iris.engine.framework.EngineMode;
import com.volmit.iris.engine.framework.EngineStage; import com.volmit.iris.engine.framework.EngineStage;
import com.volmit.iris.engine.framework.EngineTarget; import com.volmit.iris.engine.framework.EngineTarget;
import com.volmit.iris.engine.framework.EngineWorldManager; import com.volmit.iris.engine.framework.EngineWorldManager;
import com.volmit.iris.engine.framework.SeedManager; import com.volmit.iris.engine.framework.SeedManager;
import com.volmit.iris.engine.framework.WrongEngineBroException; import com.volmit.iris.engine.framework.WrongEngineBroException;
import com.volmit.iris.engine.mantle.EngineMantle; import com.volmit.iris.engine.mantle.EngineMantle;
import com.volmit.iris.engine.mode.ModeOverworld;
import com.volmit.iris.engine.modifier.IrisCarveModifier; import com.volmit.iris.engine.modifier.IrisCarveModifier;
import com.volmit.iris.engine.modifier.IrisDepositModifier; import com.volmit.iris.engine.modifier.IrisDepositModifier;
import com.volmit.iris.engine.modifier.IrisPerfectionModifier; import com.volmit.iris.engine.modifier.IrisPerfectionModifier;
@ -91,9 +93,9 @@ public class IrisEngine implements Engine {
private final ChronoLatch perSecondBudLatch; private final ChronoLatch perSecondBudLatch;
private final EngineMetrics metrics; private final EngineMetrics metrics;
private final boolean studio; private final boolean studio;
private final KList<EngineStage> stages;
private final AtomicRollingSequence wallClock; private final AtomicRollingSequence wallClock;
private final int art; private final int art;
private EngineMode mode;
private final AtomicCache<IrisEngineData> engineData = new AtomicCache<>(); private final AtomicCache<IrisEngineData> engineData = new AtomicCache<>();
private final AtomicBoolean cleaning; private final AtomicBoolean cleaning;
private final ChronoLatch cleanLatch; private final ChronoLatch cleanLatch;
@ -114,7 +116,6 @@ public class IrisEngine implements Engine {
public IrisEngine(EngineTarget target, boolean studio) { public IrisEngine(EngineTarget target, boolean studio) {
this.studio = studio; this.studio = studio;
this.target = target; this.target = target;
stages = new KList<>();
getEngineData(); getEngineData();
verifySeed(); verifySeed();
this.seedManager = new SeedManager(target.getWorld().getRawWorldSeed()); this.seedManager = new SeedManager(target.getWorld().getRawWorldSeed());
@ -164,9 +165,9 @@ public class IrisEngine implements Engine {
worldManager.close(); worldManager.close();
complex.close(); complex.close();
execution.close(); execution.close();
stages.forEach(EngineStage::close);
stages.clear();
effects.close(); effects.close();
mode.close();
J.a(() -> new IrisProject(getData().getDataFolder()).updateWorkspace()); J.a(() -> new IrisProject(getData().getDataFolder()).updateWorkspace());
} }
@ -178,7 +179,7 @@ public class IrisEngine implements Engine {
complex = new IrisComplex(this); complex = new IrisComplex(this);
execution = new IrisExecutionEnvironment(this); execution = new IrisExecutionEnvironment(this);
effects = new IrisEngineEffects(this); effects = new IrisEngineEffects(this);
setupStages(); setupMode();
J.a(this::computeBiomeMaxes); J.a(this::computeBiomeMaxes);
} catch (Throwable e) { } catch (Throwable e) {
Iris.error("FAILED TO SETUP ENGINE!"); Iris.error("FAILED TO SETUP ENGINE!");
@ -188,25 +189,13 @@ public class IrisEngine implements Engine {
Iris.debug("Engine Setup Complete " + getCacheID()); Iris.debug("Engine Setup Complete " + getCacheID());
} }
private void setupStages() { private void setupMode() {
var terrain = new IrisTerrainNormalActuator(this); if(mode != null)
var biome = new IrisBiomeActuator(this); {
var decorant = new IrisDecorantActuator(this); mode.close();
var cave = new IrisCarveModifier(this); }
var post = new IrisPostModifier(this);
var deposit = new IrisDepositModifier(this);
var perfection = new IrisPerfectionModifier(this);
registerStage((x, z, k, p, m) -> warmupChunk(x >> 4, z >> 4)); mode = getDimension().getMode().getType().create(this);
registerStage((x, z, k, p, m) -> generateMatter(x >> 4, z >> 4, m));
registerStage((x, z, k, p, m) -> terrain.actuate(x, z, k, m));
registerStage((x, z, k, p, m) -> biome.actuate(x, z, p, m));
registerStage((x, z, k, p, m) -> cave.modify(x >> 4, z >> 4, k, m));
registerStage((x, z, k, p, m) -> decorant.actuate(x, z, k, m));
registerStage((x, z, k, p, m) -> post.modify(x, z, k, m));
registerStage((x, z, k, p, m) -> deposit.modify(x, z, k, m));
registerStage((x, z, K, p, m) -> getMantle().insertMatter(x >> 4, z >> 4, BlockData.class, K, m));
registerStage((x, z, k, p, m) -> perfection.modify(x, z, k, m));
} }
@Override @Override
@ -335,11 +324,6 @@ public class IrisEngine implements Engine {
} }
} }
@Override
public void registerStage(EngineStage stage) {
stages.add(stage);
}
@Override @Override
public int getBlockUpdatesPerSecond() { public int getBlockUpdatesPerSecond() {
return buds.get(); return buds.get();
@ -407,10 +391,9 @@ public class IrisEngine implements Engine {
getWorldManager().close(); getWorldManager().close();
getTarget().close(); getTarget().close();
saveEngineData(); saveEngineData();
stages.forEach(EngineStage::close);
stages.clear();
getMantle().close(); getMantle().close();
getComplex().close(); getComplex().close();
mode.close();
getData().dump(); getData().dump();
getData().clearLists(); getData().clearLists();
Iris.service(PreservationSVC.class).dereference(); Iris.service(PreservationSVC.class).dereference();
@ -469,9 +452,7 @@ public class IrisEngine implements Engine {
} }
} }
} else { } else {
for (EngineStage i : stages) { mode.generate(x, z, blocks, vbiomes, multicore);
i.generate(x, z, blocks, vbiomes, multicore);
}
} }
getMetrics().getTotal().put(p.getMilliseconds()); getMetrics().getTotal().put(p.getMilliseconds());

View File

@ -24,6 +24,7 @@ import com.volmit.iris.core.gui.components.Renderer;
import com.volmit.iris.core.loader.IrisData; import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.loader.IrisRegistrant; import com.volmit.iris.core.loader.IrisRegistrant;
import com.volmit.iris.engine.IrisComplex; import com.volmit.iris.engine.IrisComplex;
import com.volmit.iris.engine.IrisWorldManager;
import com.volmit.iris.engine.data.cache.Cache; import com.volmit.iris.engine.data.cache.Cache;
import com.volmit.iris.engine.data.chunk.TerrainChunk; import com.volmit.iris.engine.data.chunk.TerrainChunk;
import com.volmit.iris.engine.mantle.EngineMantle; import com.volmit.iris.engine.mantle.EngineMantle;
@ -56,6 +57,7 @@ import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.mantle.MantleFlag; import com.volmit.iris.util.mantle.MantleFlag;
import com.volmit.iris.util.math.BlockPosition; import com.volmit.iris.util.math.BlockPosition;
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.RNG; import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.matter.MatterCavern; import com.volmit.iris.util.matter.MatterCavern;
import com.volmit.iris.util.matter.MatterUpdate; import com.volmit.iris.util.matter.MatterUpdate;
@ -70,11 +72,13 @@ import org.bukkit.Bukkit;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.EnderSignal;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.ChunkGenerator;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
@ -93,12 +97,10 @@ import java.util.function.Consumer;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdater, Renderer, Hotloadable { public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdater, Renderer, Hotloadable {
KList<EngineStage> getStages();
void registerStage(EngineStage stage);
IrisComplex getComplex(); IrisComplex getComplex();
EngineMode getMode();
int getBlockUpdatesPerSecond(); int getBlockUpdatesPerSecond();
void printMetrics(CommandSender sender); void printMetrics(CommandSender sender);
@ -790,6 +792,41 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
} }
default void gotoJigsaw(IrisJigsawStructure s, Player player) { default void gotoJigsaw(IrisJigsawStructure s, Player player) {
if(s.getLoadKey().equals(getDimension().getStronghold()))
{
KList<Position2> p = getDimension().getStrongholds(getSeedManager().getSpawn());
if(p.isEmpty())
{
player.sendMessage(C.GOLD + "No strongholds in world.");
}
Position2 px = new Position2(player.getLocation().getBlockX(), player.getLocation().getBlockZ());
Position2 pr = null;
double d = Double.MAX_VALUE;
Iris.debug("Ps: " + p.size());
for (Position2 i : p) {
Iris.debug("- " + i.getX() + " " + i.getZ());
}
for (Position2 i : p) {
double dx = i.distance(px);
if (dx < d) {
d = dx;
pr = i;
}
}
if (pr != null) {
Location ll = new Location(player.getWorld(), pr.getX(), 40, pr.getZ());
J.s(() -> player.teleport(ll));
}
return;
}
if (getDimension().getJigsawStructures().stream() if (getDimension().getJigsawStructures().stream()
.map(IrisJigsawStructurePlacement::getStructure) .map(IrisJigsawStructurePlacement::getStructure)
.collect(Collectors.toSet()).contains(s.getLoadKey())) { .collect(Collectors.toSet()).contains(s.getLoadKey())) {

View File

@ -0,0 +1,76 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.engine.framework;
import com.volmit.iris.engine.IrisComplex;
import com.volmit.iris.engine.mantle.EngineMantle;
import com.volmit.iris.util.documentation.BlockCoordinates;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.parallel.BurstExecutor;
import com.volmit.iris.util.parallel.MultiBurst;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
public interface EngineMode extends Staged {
void close();
Engine getEngine();
default MultiBurst burst()
{
return getEngine().burst();
}
default EngineStage burst(EngineStage... stages)
{
return (x, z, blocks, biomes, multicore) -> {
BurstExecutor e = burst().burst(stages.length);
e.setMulticore(multicore);
for(EngineStage i : stages)
{
e.queue(() -> i.generate(x, z, blocks, biomes, multicore));
}
e.complete();
};
}
default IrisComplex getComplex()
{
return getEngine().getComplex();
}
default EngineMantle getMantle()
{
return getEngine().getMantle();
}
default void generateMatter(int x, int z, boolean multicore) {
getMantle().generateMatter(x, z, multicore);
}
@BlockCoordinates
default void generate(int x, int z, Hunk<BlockData> blocks, Hunk<Biome> biomes, boolean multicore)
{
for (EngineStage i : getStages()) {
i.generate(x, z, blocks, biomes, multicore);
}
}
}

View File

@ -0,0 +1,61 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.engine.framework;
import com.volmit.iris.util.collection.KList;
public abstract class IrisEngineMode implements EngineMode {
private final Engine engine;
private final KList<EngineStage> stages;
private boolean closed;
public IrisEngineMode(Engine engine)
{
this.engine = engine;
this.stages = new KList<>();
this.closed = false;
}
@Override
public synchronized void close()
{
if(closed)
{
return;
}
closed = true;
dump();
}
@Override
public Engine getEngine() {
return engine;
}
@Override
public KList<EngineStage> getStages() {
return stages;
}
@Override
public void registerStage(EngineStage stage) {
stages.add(stage);
}
}

View File

@ -51,6 +51,7 @@ public class SeedManager {
private final long deposit; private final long deposit;
private final long post; private final long post;
private final long bodies; private final long bodies;
private final long mode;
@Setter(AccessLevel.NONE) @Setter(AccessLevel.NONE)
private long fullMixedSeed; private long fullMixedSeed;
@ -75,6 +76,7 @@ public class SeedManager {
deposit = of("deposit"); deposit = of("deposit");
post = of("post"); post = of("post");
bodies = of("bodies"); bodies = of("bodies");
mode = of("mode");
} }
private long of(String name) { private long of(String name) {

View File

@ -0,0 +1,33 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.engine.framework;
import com.volmit.iris.util.collection.KList;
public interface Staged {
KList<EngineStage> getStages();
void registerStage(EngineStage stage);
default void dump()
{
getStages().forEach(EngineStage::close);
getStages().clear();
}
}

View File

@ -0,0 +1,39 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.engine.mode;
import com.volmit.iris.engine.actuator.IrisBiomeActuator;
import com.volmit.iris.engine.actuator.IrisTerrainNormalActuator;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.EngineMode;
import com.volmit.iris.engine.framework.IrisEngineMode;
public class ModeEnclosure extends IrisEngineMode implements EngineMode {
public ModeEnclosure(Engine engine)
{
super(engine);
var terrain = new IrisTerrainNormalActuator(getEngine());
var biome = new IrisBiomeActuator(getEngine());
registerStage(burst(
(x, z, k, p, m) -> terrain.actuate(x, z, k, m),
(x, z, k, p, m) -> biome.actuate(x, z, p, m)
));
}
}

View File

@ -0,0 +1,39 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.engine.mode;
import com.volmit.iris.engine.actuator.IrisBiomeActuator;
import com.volmit.iris.engine.actuator.IrisTerrainNormalActuator;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.EngineMode;
import com.volmit.iris.engine.framework.IrisEngineMode;
public class ModeIslands extends IrisEngineMode implements EngineMode {
public ModeIslands(Engine engine)
{
super(engine);
var terrain = new IrisTerrainNormalActuator(getEngine());
var biome = new IrisBiomeActuator(getEngine());
registerStage(burst(
(x, z, k, p, m) -> terrain.actuate(x, z, k, m),
(x, z, k, p, m) -> biome.actuate(x, z, p, m)
));
}
}

View File

@ -0,0 +1,59 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.engine.mode;
import com.volmit.iris.engine.actuator.IrisBiomeActuator;
import com.volmit.iris.engine.actuator.IrisDecorantActuator;
import com.volmit.iris.engine.actuator.IrisTerrainNormalActuator;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.EngineMode;
import com.volmit.iris.engine.framework.IrisEngineMode;
import com.volmit.iris.engine.modifier.IrisCarveModifier;
import com.volmit.iris.engine.modifier.IrisDepositModifier;
import com.volmit.iris.engine.modifier.IrisPerfectionModifier;
import com.volmit.iris.engine.modifier.IrisPostModifier;
import org.bukkit.block.data.BlockData;
public class ModeOverworld extends IrisEngineMode implements EngineMode {
public ModeOverworld(Engine engine)
{
super(engine);
var terrain = new IrisTerrainNormalActuator(getEngine());
var biome = new IrisBiomeActuator(getEngine());
var decorant = new IrisDecorantActuator(getEngine());
var cave = new IrisCarveModifier(getEngine());
var post = new IrisPostModifier(getEngine());
var deposit = new IrisDepositModifier(getEngine());
var perfection = new IrisPerfectionModifier(getEngine());
registerStage(burst(
(x, z, k, p, m) -> generateMatter(x >> 4, z >> 4, m),
(x, z, k, p, m) -> terrain.actuate(x, z, k, m),
(x, z, k, p, m) -> biome.actuate(x, z, p, m)
));
registerStage((x, z, k, p, m) -> cave.modify(x >> 4, z >> 4, k, m));
registerStage(burst(
(x, z, k, p, m) -> decorant.actuate(x, z, k, m),
(x, z, k, p, m) -> post.modify(x, z, k, m),
(x, z, k, p, m) -> deposit.modify(x, z, k, m),
(x, z, K, p, m) -> getMantle().insertMatter(x >> 4, z >> 4, BlockData.class, K, m)
));
registerStage((x, z, k, p, m) -> perfection.modify(x, z, k, m));
}
}

View File

@ -0,0 +1,39 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.engine.mode;
import com.volmit.iris.engine.actuator.IrisBiomeActuator;
import com.volmit.iris.engine.actuator.IrisTerrainNormalActuator;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.EngineMode;
import com.volmit.iris.engine.framework.IrisEngineMode;
public class ModeSuperFlat extends IrisEngineMode implements EngineMode {
public ModeSuperFlat(Engine engine)
{
super(engine);
var terrain = new IrisTerrainNormalActuator(getEngine());
var biome = new IrisBiomeActuator(getEngine());
registerStage(burst(
(x, z, k, p, m) -> terrain.actuate(x, z, k, m),
(x, z, k, p, m) -> biome.actuate(x, z, p, m)
));
}
}

View File

@ -171,6 +171,9 @@ public class IrisDimension extends IrisRegistrant {
@MaxNumber(360) @MaxNumber(360)
@Desc("You can rotate the input coordinates by an angle. This can make terrain appear more natural (less sharp corners and lines). This literally rotates the entire dimension by an angle. Hint: Try 12 degrees or something not on a 90 or 45 degree angle.") @Desc("You can rotate the input coordinates by an angle. This can make terrain appear more natural (less sharp corners and lines). This literally rotates the entire dimension by an angle. Hint: Try 12 degrees or something not on a 90 or 45 degree angle.")
private double dimensionAngleDeg = 0; private double dimensionAngleDeg = 0;
@Required
@Desc("Define the mode of this dimension (required!)")
private IrisDimensionMode mode = new IrisDimensionMode();
@MinNumber(0) @MinNumber(0)
@MaxNumber(8192) @MaxNumber(8192)
@Desc("Coordinate fracturing applies noise to the input coordinates. This creates the 'iris swirls' and wavy features. The distance pushes these waves further into places they shouldnt be. This is a block value multiplier.") @Desc("Coordinate fracturing applies noise to the input coordinates. This creates the 'iris swirls' and wavy features. The distance pushes these waves further into places they shouldnt be. This is a block value multiplier.")

View File

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

View File

@ -0,0 +1,56 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.engine.object;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.EngineMode;
import com.volmit.iris.engine.mode.ModeEnclosure;
import com.volmit.iris.engine.mode.ModeIslands;
import com.volmit.iris.engine.mode.ModeOverworld;
import com.volmit.iris.engine.mode.ModeSuperFlat;
import com.volmit.iris.engine.object.annotations.Desc;
import java.util.function.Function;
@Desc("The type of dimension this is")
public enum IrisDimensionModeType {
@Desc("Typical dimensions. Has a fluid height, and all features of a biome based world")
OVERWORLD(ModeOverworld::new),
@Desc("Ultra fast, but very limited in features. Only supports terrain & biomes. No decorations, mobs, objects, or anything of the sort!")
SUPERFLAT(ModeSuperFlat::new),
@Desc("Like the nether, a ceiling & floor carved out")
ENCLOSURE(ModeEnclosure::new),
@Desc("Floating islands of terrain")
ISLANDS(ModeIslands::new),
;
private final Function<Engine, EngineMode> factory;
IrisDimensionModeType(Function<Engine, EngineMode> factory)
{
this.factory = factory;
}
public EngineMode create(Engine e)
{
return factory.apply(e);
}
}