9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2026-01-04 15:41:30 +00:00

Compare commits

...

18 Commits

Author SHA1 Message Date
Brian Neumann-Fopiano
768fa7beb5 v+ 2024-04-19 02:47:02 -04:00
Brian Fopiano
8f019cd794 Merge pull request #1088 from RePixelatedMC/PixelatedDev
3.2.5 iris
2024-04-18 07:13:52 -04:00
RePixelatedMC
72ed312654 wops 2024-04-16 18:09:03 +02:00
RePixelatedMC
c7fe4723f7 Merge remote-tracking branch 'origin/master' into PixelatedDev 2024-04-16 17:18:51 +02:00
RePixelatedMC
bfbea83a4a - Fixed NMS biome height.
- Improved /iris load
- Improved Vanilla height converter
- Removed WorldCreation unstable message
2024-04-16 17:18:02 +02:00
RePixelatedMC
55c58fe896 Merge pull request #1087 from RePixelatedMC/PixelatedDev
Should work
2024-04-16 16:34:12 +02:00
RePixelatedMC
72949e0950 Update IrisSettings.java 2024-04-16 16:32:52 +02:00
RePixelatedMC
7fb2a51a33 sync 2024-04-12 17:08:13 +02:00
RePixelatedMC
5b7c0b2bc3 Merge branch 'PixelatedDev' of https://github.com/RePixelatedMC/Iris into PixelatedDev
# Conflicts:
#	core/src/main/java/com/volmit/iris/engine/object/IrisBiome.java
#	core/src/main/java/com/volmit/iris/engine/object/IrisBiomeGeneratorLink.java
2024-04-09 20:07:50 +02:00
RePixelatedMC
fc15175ff9 Improved? 2024-04-09 20:06:32 +02:00
RePixelatedMC
1eec3a09c1 now it should work 2024-04-09 18:05:27 +02:00
RePixelatedMC
60d349dd8b test 2024-04-09 17:05:43 +02:00
RePixelatedMC
0c8d144ffb Merge remote-tracking branch 'VolmitDev/smartHeight' into PixelatedDev 2024-04-09 17:04:45 +02:00
RePixelatedMC
b898f73a05 Fixed another potential mem leak
Added the base of smart320height
2024-04-09 17:04:32 +02:00
CrazyDev22
c2b9b0ba0e add smartVanillaHeight 2024-04-09 16:52:14 +02:00
RePixelatedMC
206a4e9057 Revert "sync laptop"
This reverts commit 63b8a935ae.
2024-04-06 17:07:14 +02:00
RePixelatedMC
83a0a7dd54 sync laptop 2024-04-06 17:06:06 +02:00
RePixelatedMC
63b8a935ae sync laptop 2024-04-05 18:43:30 +02:00
17 changed files with 375 additions and 146 deletions

View File

@@ -25,7 +25,7 @@ plugins {
id "de.undercouch.download" version "5.0.1"
}
version '3.2.3-1.19.2-1.20.4'
version '3.2.4-1.19.2-1.20.4'
def specialSourceVersion = '1.11.0' //[NMS]
// ADD YOURSELF AS A NEW LINE IF YOU WANT YOUR OWN BUILD TASK GENERATED
@@ -37,7 +37,7 @@ registerCustomOutputTask('Coco', 'D://mcsm/plugins')
registerCustomOutputTask('Strange', 'D://Servers/1.17 Test Server/plugins')
registerCustomOutputTask('Vatuu', 'D://Minecraft/Servers/1.19.4/plugins')
registerCustomOutputTask('CrazyDev22', 'C://Users/Julian/Desktop/server/plugins')
registerCustomOutputTask('Pixel', 'C://Users/repix/Iris Dimension Engine/1.20.4 - Iris Development/plugins')
registerCustomOutputTask('Pixel', 'C://Users/repix/Iris Dimension Engine/1.20.4 - Development/plugins')
// ========================== UNIX ==============================
registerCustomOutputTaskUnix('CyberpwnLT', '/Users/danielmills/development/server/plugins')
registerCustomOutputTaskUnix('PsychoLT', '/Volumes/PRO-G40/Minecraft/MinecraftDevelopment/Server/plugins')

View File

@@ -739,7 +739,7 @@ public class Iris extends VolmitPlugin implements Listener {
service(StudioSVC.class).installIntoWorld(getSender(), dim.getLoadKey(), w.worldFolder());
}
return new BukkitChunkGenerator(w, false, ff, dim.getLoadKey());
return new BukkitChunkGenerator(w, false, ff, dim.getLoadKey(), false);
}
public void splash() {

View File

@@ -177,7 +177,6 @@ public class IrisSettings {
public static class IrisSettingsGenerator {
public String defaultWorldType = "overworld";
public int maxBiomeChildDepth = 4;
// public boolean forceConvertTo320Height = false;
public boolean preventLeafDecay = true;
}

View File

@@ -22,6 +22,7 @@ import com.volmit.iris.Iris;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.core.nms.v1X.NMSBinding1X;
import com.volmit.iris.core.pregenerator.ChunkUpdater;
import com.volmit.iris.core.service.IrisEngineSVC;
import com.volmit.iris.core.tools.IrisPackBenchmarking;
import com.volmit.iris.core.tools.IrisToolbelt;
@@ -40,7 +41,10 @@ import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.io.IO;
import com.volmit.iris.util.mantle.TectonicPlate;
import com.volmit.iris.util.math.Spiraler;
import com.volmit.iris.util.math.Vector3d;
import com.volmit.iris.util.nbt.mca.MCAFile;
import com.volmit.iris.util.nbt.mca.MCAUtil;
import com.volmit.iris.util.plugin.VolmitSender;
import io.lumine.mythic.bukkit.adapters.BukkitEntity;
import net.jpountz.lz4.LZ4BlockInputStream;
@@ -61,6 +65,7 @@ import java.net.NetworkInterface;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
@@ -150,9 +155,29 @@ public class CommandDeveloper implements DecreeExecutor {
}
@Decree(description = "Test")
public void updater(
@Param(description = "Updater for chunks")
World world
) {
Iris.info("test");
ChunkUpdater updater = new ChunkUpdater(world);
updater.start();
}
@Decree(description = "test")
public void test() throws NoSuchFieldException, IllegalAccessException {
IrisEngineSVC.instance.engineStatus();
public void mca (
@Param(description = "String") String world) {
try {
File[] McaFiles = new File(world, "region").listFiles((dir, name) -> name.endsWith(".mca"));
for (File mca : McaFiles) {
MCAFile MCARegion = MCAUtil.read(mca);
}
} catch (Exception e) {
e.printStackTrace();
}
}

View File

@@ -30,6 +30,7 @@ import com.volmit.iris.core.safeguard.UtilsSFG;
import com.volmit.iris.engine.object.IrisWorld;
import com.volmit.iris.engine.platform.BukkitChunkGenerator;
import com.volmit.iris.engine.platform.DummyChunkGenerator;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.decree.DecreeExecutor;
import com.volmit.iris.util.decree.DecreeOrigin;
import com.volmit.iris.util.decree.annotations.Decree;
@@ -77,7 +78,6 @@ public class CommandIris implements DecreeExecutor {
private CommandFind find;
private CommandDeveloper developer;
public static boolean worldCreation = false;
String WorldToLoad;
String WorldEngine;
String worldNameToCheck = "YourWorldName";
VolmitSender sender = Iris.getSender();
@@ -89,7 +89,9 @@ public class CommandIris implements DecreeExecutor {
@Param(aliases = "dimension", description = "The dimension type to create the world with", defaultValue = "default")
IrisDimension type,
@Param(description = "The seed to generate the world with", defaultValue = "1337")
long seed
long seed,
@Param(description = "If it should convert the dimension to match the vanilla height system.", defaultValue = "false")
boolean vanillaheight
) {
if(sender() instanceof Player) {
if (incompatibilities.get("Multiverse-Core")) {
@@ -133,6 +135,7 @@ public class CommandIris implements DecreeExecutor {
.seed(seed)
.sender(sender())
.studio(false)
.smartVanillaHeight(vanillaheight)
.create();
} catch (Throwable e) {
sender().sendMessage(C.RED + "Exception raised during creation. See the console for more details.");
@@ -216,41 +219,41 @@ public class CommandIris implements DecreeExecutor {
Iris.service(StudioSVC.class).open(sender(), 1337, "overworld");
}
@Decree(description = "Check if iris has access to that specific world")
public void hasAccess(
@Param(description = "The world to access", aliases = {"world"})
World world
) {
Engine engine = IrisToolbelt.access(world).getEngine();
if (engine != null) {
sender().sendMessage("Access granted successfully.");
} else {
sender().sendMessage(C.RED + "Failed to grant access.");
}
}
@Decree(description = "Check access of all worlds.", aliases = {"accesslist"})
public void worlds() {
KList<World> IrisWorlds = new KList<>();
KList<World> BukkitWorlds = new KList<>();
@Decree(description = "All Iris Worlds on the server.", aliases = {"worlds"})
public void irisworlds() {
List<World> IrisWorlds = new ArrayList<>();
for (World world : Bukkit.getWorlds()) {
for (World w : Bukkit.getServer().getWorlds()) {
try {
if (IrisToolbelt.access(world).getEngine() != null) {
IrisWorlds.add(world);
Engine engine = IrisToolbelt.access(w).getEngine();
if (engine != null) {
IrisWorlds.add(w);
}
} catch (Exception e) {
// no
BukkitWorlds.add(w);
}
}
if (sender().isPlayer()) {
sender.sendMessage(C.IRIS + "Iris Worlds:");
for (World world : IrisWorlds) {
sender.sendMessage(C.GREEN + "- " + world.getName());
sender().sendMessage(C.BLUE + "Iris Worlds: ");
for (World IrisWorld : IrisWorlds.copy()) {
sender().sendMessage(C.IRIS + "- " +IrisWorld.getName());
}
sender().sendMessage(C.GOLD + "Bukkit Worlds: ");
for (World BukkitWorld : BukkitWorlds.copy()) {
sender().sendMessage(C.GRAY + "- " +BukkitWorld.getName());
}
} else {
Iris.info(C.IRIS + "Iris Worlds:");
for (World world : IrisWorlds) {
sender.sendMessage(C.GREEN + "- " + world.getName());
Iris.info(C.BLUE + "Iris Worlds: ");
for (World IrisWorld : IrisWorlds.copy()) {
Iris.info(C.IRIS + "- " +IrisWorld.getName());
}
Iris.info(C.GOLD + "Bukkit Worlds: ");
for (World BukkitWorld : BukkitWorlds.copy()) {
Iris.info(C.GRAY + "- " +BukkitWorld.getName());
}
}
}
@@ -473,7 +476,7 @@ public class CommandIris implements DecreeExecutor {
sender().sendMessage(C.YELLOW + world + " Doesnt exist on the server.");
return;
}
WorldToLoad = world;
File BUKKIT_YML = new File("bukkit.yml");
String pathtodim = world + File.separator +"iris"+File.separator +"pack"+File.separator +"dimensions"+File.separator;
File directory = new File(Bukkit.getWorldContainer(), pathtodim);
@@ -511,7 +514,7 @@ public class CommandIris implements DecreeExecutor {
e.printStackTrace();
}
}
checkForBukkitWorlds();
checkForBukkitWorlds(world);
sender().sendMessage(C.GREEN + world + " loaded successfully.");
}
@Decree(description = "Evacuate an iris world", origin = DecreeOrigin.PLAYER, sync = true)
@@ -532,7 +535,7 @@ public class CommandIris implements DecreeExecutor {
File worldDirectory = new File(worldContainer, worldName);
return worldDirectory.exists() && worldDirectory.isDirectory();
}
private void checkForBukkitWorlds() {
private void checkForBukkitWorlds(String world) {
FileConfiguration fc = new YamlConfiguration();
try {
fc.load(new File("bukkit.yml"));
@@ -541,9 +544,9 @@ public class CommandIris implements DecreeExecutor {
return;
}
List<String> worldsToLoad = Collections.singletonList(WorldToLoad);
List<String> worldsToLoad = Collections.singletonList(world);
for (String s : section.getKeys(false)) {
for (String s : section.getKeys(false)) {
if (!worldsToLoad.contains(s)) {
continue;
}
@@ -622,6 +625,6 @@ public class CommandIris implements DecreeExecutor {
ff.mkdirs();
service(StudioSVC.class).installIntoWorld(sender, dim.getLoadKey(), ff.getParentFile());
}
return new BukkitChunkGenerator(w, false, ff, dim.getLoadKey());
return new BukkitChunkGenerator(w, false, ff, dim.getLoadKey(), false);
}
}

View File

@@ -85,7 +85,7 @@ import java.util.function.Supplier;
public class CommandStudio implements DecreeExecutor {
private CommandFind find;
private CommandEdit edit;
private CommandDeepSearch deepSearch;
//private CommandDeepSearch deepSearch;
public static String hrf(Duration duration) {
return duration.toString().substring(2).replaceAll("(\\d[HMS])(?!$)", "$1 ").toLowerCase();

View File

@@ -55,10 +55,10 @@ public class IrisRenderer {
IrisBiome b = renderer.getBiome((int) Math.round(x), renderer.getMaxHeight() - 1, (int) Math.round(z));
IrisBiomeGeneratorLink g = b.getGenerators().get(0);
Color c;
if (g.getMax() <= 0) {
if (g.getMax(renderer) <= 0) {
// Max is below water level, so it is most likely an ocean biome
c = Color.BLUE;
} else if (g.getMin() < 0) {
} else if (g.getMin(renderer) < 0) {
// Min is below water level, but max is not, so it is most likely a shore biome
c = Color.YELLOW;
} else {

View File

@@ -0,0 +1,117 @@
package com.volmit.iris.core.pregenerator;
import com.volmit.iris.Iris;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.math.RollingSequence;
import com.volmit.iris.util.math.Spiraler;
import com.volmit.iris.util.nbt.mca.MCAFile;
import com.volmit.iris.util.nbt.mca.MCAUtil;
import org.bukkit.World;
import java.io.File;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
public class ChunkUpdater {
private AtomicBoolean cancelled;
private KList<int[]> chunkMap;
private final RollingSequence chunksPerSecond;
private final RollingSequence mcaregionsPerSecond;
private final AtomicInteger worldheightsize;
private final AtomicInteger worldwidthsize;
private final AtomicInteger totalChunks;
private final AtomicInteger totalMaxChunks;
private final AtomicInteger totalMcaregions;
private final AtomicInteger position;
private final File[] McaFiles;
private final World world;
public ChunkUpdater(World world) {
File cacheDir = new File("plugins" + File.separator + "iris" + File.separator + "cache");
File chunkCacheDir = new File("plugins" + File.separator + "iris" + File.separator + "cache" + File.separator + "spiral");
this.chunksPerSecond = new RollingSequence(10);
this.mcaregionsPerSecond = new RollingSequence(10);
this.world = world;
this.chunkMap = new KList<>();
this.McaFiles = new File(world.getWorldFolder(), "region").listFiles((dir, name) -> name.endsWith(".mca"));
this.worldheightsize = new AtomicInteger(calculateWorldDimensions(new File(world.getWorldFolder(), "region"), 1));
this.worldwidthsize = new AtomicInteger(calculateWorldDimensions(new File(world.getWorldFolder(), "region"), 0));
this.totalMaxChunks = new AtomicInteger((worldheightsize.get() / 16 ) * (worldwidthsize.get() / 16));
this.position = new AtomicInteger(0);
this.cancelled = new AtomicBoolean(false);
this.totalChunks = new AtomicInteger(0);
this.totalMcaregions = new AtomicInteger(0);
}
public void start() {
Initialize();
}
public void Initialize() {
Iris.info("Initializing..");
try {
for (File mca : McaFiles) {
MCAFile MCARegion = MCAUtil.read(mca);
for (int pos = 0; pos != totalMaxChunks.get(); pos++) {
int[] coords = getChunk(pos);
if(MCARegion.hasChunk(coords[0], coords[1])) chunkMap.add(coords);
}
}
Iris.info("Finished Initializing..");
} catch (Exception e) {
e.printStackTrace();
}
}
public int calculateWorldDimensions(File regionDir, Integer o) {
File[] files = regionDir.listFiles((dir, name) -> name.endsWith(".mca"));
int minX = Integer.MAX_VALUE;
int maxX = Integer.MIN_VALUE;
int minZ = Integer.MAX_VALUE;
int maxZ = Integer.MIN_VALUE;
for (File file : files) {
String[] parts = file.getName().split("\\.");
int x = Integer.parseInt(parts[1]);
int z = Integer.parseInt(parts[2]);
if (x < minX) minX = x;
if (x > maxX) maxX = x;
if (z < minZ) minZ = z;
if (z > maxZ) maxZ = z;
}
int height = (maxX - minX + 1) * 32 * 16;
int width = (maxZ - minZ + 1) * 32 * 16;
if (o == 1) {
return height;
}
if (o == 0) {
return width;
}
return 0;
}
public int[] getChunk(int position) {
int p = -1;
AtomicInteger xx = new AtomicInteger();
AtomicInteger zz = new AtomicInteger();
Spiraler s = new Spiraler(worldheightsize.get() * 2, worldwidthsize.get() * 2, (x, z) -> {
xx.set(x);
zz.set(z);
});
while (s.hasNext() && p++ < position) {
s.next();
}
int[] coords = new int[2];
coords[0] = xx.get();
coords[1] = zz.get();
return coords;
}
}

View File

@@ -78,6 +78,9 @@ public class IrisEngineSVC implements IrisService {
t = t - 200;
}
this.setup();
this.TrimLogic();
this.UnloadLogic();
trimAlive.begin();
unloadAlive.begin();
trimActiveAlive.begin();
@@ -85,8 +88,8 @@ public class IrisEngineSVC implements IrisService {
updateTicker.start();
cacheTicker.start();
trimTicker.start();
unloadTicker.start();
//trimTicker.start();
//unloadTicker.start();
instance = this;
}
@@ -104,10 +107,6 @@ public class IrisEngineSVC implements IrisService {
return tectonicLimit.get();
}
public void EngineReport() {
Iris.info(C.RED + "CRITICAL ENGINE FAILURE! The Tectonic Trim subsystem has not responded for: " + Form.duration(trimAlive.getMillis()) + ".");
}
@EventHandler
public void onWorldUnload(WorldUnloadEvent event) {
updateWorlds();
@@ -179,9 +178,9 @@ public class IrisEngineSVC implements IrisService {
}
if (!isServerShuttingDown && isServerLoaded) {
if (!trimTicker.isAlive()) {
Iris.info(C.IRIS + "TrimTicker found dead! Booting it up!");
Iris.info(C.RED + "TrimTicker found dead! Booting it up!");
try {
trimTicker.start();
TrimLogic();
} catch (Exception e) {
Iris.error("What happened?");
e.printStackTrace();
@@ -189,9 +188,9 @@ public class IrisEngineSVC implements IrisService {
}
if (!unloadTicker.isAlive()) {
Iris.info(C.IRIS + "UnloadTicker found dead! Booting it up!");
Iris.info(C.RED + "UnloadTicker found dead! Booting it up!");
try {
unloadTicker.start();
UnloadLogic();
} catch (Exception e) {
Iris.error("What happened?");
e.printStackTrace();
@@ -205,63 +204,72 @@ public class IrisEngineSVC implements IrisService {
return 1000;
}
};
}
public void TrimLogic() {
if (trimTicker == null || !trimTicker.isAlive()) {
trimTicker = new Looper() {
private final Supplier<Engine> supplier = createSupplier();
trimTicker = new Looper() {
private final Supplier<Engine> supplier = createSupplier();
@Override
protected long loop() {
long start = System.currentTimeMillis();
trimAlive.reset();
try {
Engine engine = supplier.get();
if (engine != null) {
engine.getMantle().trim(tectonicLimit.get() / lastUse.size());
}
} catch (Throwable e) {
Iris.reportError(e);
Iris.info(C.RED + "EngineSVC: Failed to trim. Please contact support!");
e.printStackTrace();
return -1;
}
int size = lastUse.size();
long time = (size > 0 ? 1000/size : 1000) - (System.currentTimeMillis() - start);
if (time <= 0)
return 0;
return time;
}
};
unloadTicker = new Looper() {
private final Supplier<Engine> supplier = createSupplier();
@Override
protected long loop() {
long start = System.currentTimeMillis();
unloadAlive.reset();
try {
Engine engine = supplier.get();
if (engine != null) {
long unloadStart = System.currentTimeMillis();
int count = engine.getMantle().unloadTectonicPlate(tectonicLimit.get() / lastUse.size());
if (count > 0) {
Iris.debug(C.GOLD + "Unloaded " + C.YELLOW + count + " TectonicPlates in " + C.RED + Form.duration(System.currentTimeMillis() - unloadStart, 2));
@Override
protected long loop() {
long start = System.currentTimeMillis();
trimAlive.reset();
try {
Engine engine = supplier.get();
if (engine != null) {
engine.getMantle().trim(tectonicLimit.get() / lastUse.size());
}
} catch (Throwable e) {
Iris.reportError(e);
Iris.info(C.RED + "EngineSVC: Failed to trim.");
e.printStackTrace();
return -1;
}
} catch (Throwable e) {
Iris.reportError(e);
Iris.info(C.RED + "EngineSVC: Failed to unload.");
e.printStackTrace();
return -1;
}
int size = lastUse.size();
long time = (size > 0 ? 1000/size : 1000) - (System.currentTimeMillis() - start);
if (time <= 0)
return 0;
return time;
}
};
int size = lastUse.size();
long time = (size > 0 ? 1000 / size : 1000) - (System.currentTimeMillis() - start);
if (time <= 0)
return 0;
return time;
}
};
trimTicker.start();
}
}
public void UnloadLogic() {
if (unloadTicker == null || !unloadTicker.isAlive()) {
unloadTicker = new Looper() {
private final Supplier<Engine> supplier = createSupplier();
@Override
protected long loop() {
long start = System.currentTimeMillis();
unloadAlive.reset();
try {
Engine engine = supplier.get();
if (engine != null) {
long unloadStart = System.currentTimeMillis();
int count = engine.getMantle().unloadTectonicPlate(tectonicLimit.get() / lastUse.size());
if (count > 0) {
Iris.debug(C.GOLD + "Unloaded " + C.YELLOW + count + " TectonicPlates in " + C.RED + Form.duration(System.currentTimeMillis() - unloadStart, 2));
}
}
} catch (Throwable e) {
Iris.reportError(e);
Iris.info(C.RED + "EngineSVC: Failed to unload.");
e.printStackTrace();
return -1;
}
int size = lastUse.size();
long time = (size > 0 ? 1000 / size : 1000) - (System.currentTimeMillis() - start);
if (time <= 0)
return 0;
return time;
}
};
unloadTicker.start();
}
}
private Supplier<Engine> createSupplier() {
@@ -281,7 +289,8 @@ public class IrisEngineSVC implements IrisService {
if (generator != null) {
Engine engine = generator.getEngine();
if (engine != null && !engine.isStudio()) {
boolean closed = engine.getMantle().getData().isClosed();
if (engine != null && !engine.isStudio() && !closed) {
lastUseLock.lock();
lastUse.put(world, System.currentTimeMillis());
lastUseLock.unlock();

View File

@@ -86,6 +86,7 @@ public class IrisCreator {
* Benchmark mode
*/
private boolean benchmark = false;
private boolean smartVanillaHeight = false;
public static boolean removeFromBukkitYml(String name) throws IOException {
YamlConfiguration yml = YamlConfiguration.loadConfiguration(BUKKIT_YML);
@@ -112,13 +113,6 @@ public class IrisCreator {
*/
public World create() throws IrisException {
if (unstablemode){
Iris.info(C.RED + "Your server is experiencing an incompatibility with the Iris plugin. Please rectify this problem to avoid further complications.");
Iris.info(C.RED + "----------------------------------------------------------------");
Iris.info(C.RED + "Operation ran: Loading Iris World..");
UtilsSFG.printIncompatibleWarnings();
Iris.info(C.RED + "----------------------------------------------------------------");
}
if (Bukkit.isPrimaryThread()) {
throw new IrisException("You cannot invoke create() on the main thread.");
}
@@ -149,6 +143,7 @@ public class IrisCreator {
.name(name)
.seed(seed)
.studio(studio)
.smartVanillaHeight(smartVanillaHeight)
.create();
ServerConfigurator.installDataPacks(false);

View File

@@ -32,6 +32,7 @@ public class IrisWorldCreator {
private String name;
private boolean studio = false;
private String dimensionName = null;
private boolean smartVanillaHeight = false;
private long seed = 1337;
public IrisWorldCreator() {
@@ -63,6 +64,11 @@ public class IrisWorldCreator {
return this;
}
public IrisWorldCreator smartVanillaHeight(boolean smartVanillaHeight) {
this.smartVanillaHeight = smartVanillaHeight;
return this;
}
public WorldCreator create() {
IrisDimension dim = IrisData.loadAnyDimension(dimensionName);
@@ -76,7 +82,7 @@ public class IrisWorldCreator {
.build();
ChunkGenerator g = new BukkitChunkGenerator(w, studio, studio
? dim.getLoader().getDataFolder() :
new File(w.worldFolder(), "iris/pack"), dimensionName);
new File(w.worldFolder(), "iris/pack"), dimensionName, smartVanillaHeight);
return new WorldCreator(name)

View File

@@ -292,7 +292,7 @@ public class IrisComplex implements DataProvider {
double b = 0;
for (IrisGenerator gen : generators) {
b += bx.getGenLinkMax(gen.getLoadKey());
b += bx.getGenLinkMax(gen.getLoadKey(), engine);
}
return b;
@@ -311,7 +311,7 @@ public class IrisComplex implements DataProvider {
double b = 0;
for (IrisGenerator gen : generators) {
b += bx.getGenLinkMin(gen.getLoadKey());
b += bx.getGenLinkMin(gen.getLoadKey(), engine);
}
return b;

View File

@@ -194,13 +194,14 @@ public class IrisBiome extends IrisRegistrant implements IRare {
return getCustomDerivitives() != null && getCustomDerivitives().isNotEmpty();
}
public double getGenLinkMax(String loadKey) {
public double getGenLinkMax(String loadKey, Engine engine) {
Integer v = genCacheMax.aquire(() ->
{
KMap<String, Integer> l = new KMap<>();
for (IrisBiomeGeneratorLink i : getGenerators()) {
l.put(i.getGenerator(), i.getMax());
l.put(i.getGenerator(), i.getMax(engine));
}
return l;
@@ -209,13 +210,13 @@ public class IrisBiome extends IrisRegistrant implements IRare {
return v == null ? 0 : v;
}
public double getGenLinkMin(String loadKey) {
public double getGenLinkMin(String loadKey, Engine engine) {
Integer v = genCacheMin.aquire(() ->
{
KMap<String, Integer> l = new KMap<>();
for (IrisBiomeGeneratorLink i : getGenerators()) {
l.put(i.getGenerator(), i.getMin());
l.put(i.getGenerator(), i.getMin(engine));
}
return l;
@@ -450,26 +451,26 @@ public class IrisBiome extends IrisRegistrant implements IRare {
return real;
}
public int getMaxHeight() {
public int getMaxHeight(Engine engine) {
return maxHeight.aquire(() ->
{
int maxHeight = 0;
for (IrisBiomeGeneratorLink i : getGenerators()) {
maxHeight += i.getMax();
maxHeight += i.getMax(engine);
}
return maxHeight;
});
}
public int getMaxWithObjectHeight(IrisData data) {
public int getMaxWithObjectHeight(IrisData data, Engine engine) {
return maxWithObjectHeight.aquire(() ->
{
int maxHeight = 0;
for (IrisBiomeGeneratorLink i : getGenerators()) {
maxHeight += i.getMax();
maxHeight += i.getMax(engine);
}
int gg = 0;

View File

@@ -18,14 +18,13 @@
package com.volmit.iris.engine.object;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.Iris;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.annotations.*;
import com.volmit.iris.util.data.DataProvider;
import com.volmit.iris.util.interpolation.IrisInterpolation;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.*;
import lombok.experimental.Accessors;
@Snippet("generator-layer")
@@ -40,22 +39,23 @@ public class IrisBiomeGeneratorLink {
@RegistryListResource(IrisGenerator.class)
@Desc("The generator id")
private String generator = "default";
@DependsOn({"min", "max"})
@DependsOn({ "min", "max" })
@Required
@MinNumber(-2032) // TODO: WARNING HEIGHT
@MaxNumber(2032) // TODO: WARNING HEIGHT
@Desc("The min block value (value + fluidHeight)")
@Getter(AccessLevel.NONE)
private int min = 0;
@DependsOn({"min", "max"})
@DependsOn({ "min", "max" })
@Required
@MinNumber(-2032) // TODO: WARNING HEIGHT
@MaxNumber(2032) // TODO: WARNING HEIGHT
@Getter(AccessLevel.NONE)
@Desc("The max block value (value + fluidHeight)")
private int max = 0;
public IrisGenerator getCachedGenerator(DataProvider g) {
return gen.aquire(() ->
{
return gen.aquire(() -> {
IrisGenerator gen = g.getData().getGeneratorLoader().load(getGenerator());
if (gen == null) {
@@ -66,21 +66,74 @@ public class IrisBiomeGeneratorLink {
});
}
private int[] getBiomeGeneratorsRaw(Engine engine) {
int max = engine.getDimension().getMinHeight();
int min = engine.getDimension().getMaxHeight();
for (IrisBiome biome : engine.getAllBiomes()) {
for (IrisBiomeGeneratorLink i : biome.getGenerators()) {
int biomeRawMax = i.getMaxRaw();
int biomeRawMin = i.getMinRaw();
if (max < biomeRawMax)
max = biomeRawMax;
if (min > biomeRawMin)
min = biomeRawMin;
}
}
return new int[] { min, max };
}
private int calculateHeight(Engine engine, int option) {
int dmx = engine.getDimension().getMaxHeight();
int dmn = engine.getDimension().getMinHeight();
int[] heights = getBiomeGeneratorsRaw(engine);
int gmx = heights[1];
int gmn = heights[0];
int mx = getMaxRaw();
int mn = getMinRaw();
if (engine.getDimension().isSmartVanillaHeight()) {
if (mx > 0)
mx = Math.min((int) (((float) mx / (float) gmx) * 300.0f), 300);
if (mx < 0)
mx = Math.min((int) (((float) mx / (float) gmn) * 300.0f), 56);
if (mn > 0)
mn = Math.min((int) (((float) mn / (float) gmx) * 300.0f), 300);
if (mn < 0)
mn = Math.min((int) (((float) mn / (float) gmn) * 300.0f), 56);
}
if (option == 1) {
return mx;
}
if (option == 0) {
return mn;
}
Iris.error("Fatal Generator error!");
return 0;
}
public int getMax(Engine engine) {
return calculateHeight(engine, 1);
}
public int getMin(Engine engine) {
return calculateHeight(engine, 0);
}
private int getMaxRaw() {
return max;
}
private int getMinRaw() {
return min;
}
public double getHeight(DataProvider xg, double x, double z, long seed) {
double g = getCachedGenerator(xg).getHeight(x, z, seed);
g = g < 0 ? 0 : g;
g = g > 1 ? 1 : g;
// if (IrisSettings.get().getGenerator().forceConvertTo320Height) {
// if (max > 320 || min > 320) {
// double scaleFactor = 320.0 / Math.max(max, min);
// min *= (int) scaleFactor;
// max *= (int) scaleFactor;
// if (min < 0) {
//
// }
// }
// }
// todo This
return IrisInterpolation.lerp(min, max, g);
}

View File

@@ -19,6 +19,7 @@
package com.volmit.iris.engine.object;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.loader.IrisRegistrant;
import com.volmit.iris.engine.data.cache.AtomicCache;
@@ -210,6 +211,8 @@ public class IrisDimension extends IrisRegistrant {
private IrisCarving carving = new IrisCarving();
@Desc("Configuration of fluid bodies such as rivers & lakes")
private IrisFluidBodies fluidBodies = new IrisFluidBodies();
@Desc("forceConvertTo320Height")
private Boolean forceConvertTo320Height = false;
@Desc("The world environment")
private Environment environment = Environment.NORMAL;
@RegistryListResource(IrisRegion.class)
@@ -231,6 +234,8 @@ public class IrisDimension extends IrisRegistrant {
private IrisRange dimensionHeightEnd = new IrisRange(-64, 320);
@Desc("Define the min and max Y bounds of this dimension. Please keep in mind that Iris internally generates from 0 to (max - min). \n\nFor example at -64 to 320, Iris is internally generating to 0 to 384, then on outputting chunks, it shifts it down by the min height (64 blocks). The default is -64 to 320. \n\nThe fluid height is placed at (fluid height + min height). So a fluid height of 63 would actually show up in the world at 1.")
private IrisRange dimensionHeightNether = new IrisRange(-64, 320);
@Desc("Enable smart vanilla height")
private boolean smartVanillaHeight = false;
@RegistryListResource(IrisBiome.class)
@Desc("Keep this either undefined or empty. Setting any biome name into this will force iris to only generate the specified biome. Great for testing.")
private String focus = "";

View File

@@ -58,6 +58,8 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.List;
import java.util.Random;
@@ -82,6 +84,7 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
private final AtomicBoolean setup;
private final boolean studio;
private final AtomicInteger a = new AtomicInteger(0);
private final boolean smartVanillaHeight;
private Engine engine;
private Looper hotloader;
private StudioMode lastMode;
@@ -91,7 +94,7 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
private boolean initialized = false;
public BukkitChunkGenerator(IrisWorld world, boolean studio, File dataLocation, String dimensionKey) {
public BukkitChunkGenerator(IrisWorld world, boolean studio, File dataLocation, String dimensionKey, boolean smartVanillaHeight) {
setup = new AtomicBoolean(false);
studioGenerator = null;
dummyBiomeProvider = new DummyBiomeProvider();
@@ -103,6 +106,7 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
this.dataLocation = dataLocation;
this.dimensionKey = dimensionKey;
this.folder = new ReactiveFolder(dataLocation, (_a, _b, _c) -> hotload());
this.smartVanillaHeight = smartVanillaHeight;
Bukkit.getServer().getPluginManager().registerEvents(this, Iris.instance);
}
@@ -181,6 +185,14 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
throw new RuntimeException("Missing Dimension: " + dimensionKey);
}
}
if (smartVanillaHeight) {
dimension.setSmartVanillaHeight(true);
try (FileWriter writer = new FileWriter(data.getDimensionLoader().fileFor(dimension))) {
writer.write(data.getGson().toJson(dimension));
} catch (IOException e) {
e.printStackTrace();
}
}
lastMode = StudioMode.NORMAL;
engine = new IrisEngine(new EngineTarget(world, dimension, data), studio);

View File

@@ -27,10 +27,12 @@ import com.volmit.iris.util.nbt.io.NamedTag;
import com.volmit.iris.util.nbt.mca.palette.MCABiomeContainer;
import com.volmit.iris.util.nbt.tag.CompoundTag;
import com.volmit.iris.util.nbt.tag.ListTag;
import org.bukkit.World;
import java.io.*;
import static com.volmit.iris.util.nbt.mca.LoadFlags.*;
import static org.bukkit.Bukkit.getServer;
public class Chunk {
public static final int DEFAULT_DATA_VERSION = 2730;
@@ -71,10 +73,11 @@ public class Chunk {
}
public static Chunk newChunk() {
World mainWorld = getServer().getWorlds().get(0);
Chunk c = new Chunk(0);
c.dataVersion = DEFAULT_DATA_VERSION;
c.data = new CompoundTag();
c.biomes = INMS.get().newBiomeContainer(0, 256);
c.biomes = INMS.get().newBiomeContainer(mainWorld.getMinHeight(), mainWorld.getMaxHeight());
c.data.put("Level", defaultLevel());
c.status = "full";
return c;
@@ -95,11 +98,12 @@ public class Chunk {
if ((level = data.getCompoundTag("Level")) == null) {
throw new IllegalArgumentException("data does not contain \"Level\" tag");
}
World mainWorld = getServer().getWorlds().get(0);
dataVersion = data.getInt("DataVersion");
inhabitedTime = level.getLong("InhabitedTime");
lastUpdate = level.getLong("LastUpdate");
if ((loadFlags & BIOMES) != 0) {
biomes = INMS.get().newBiomeContainer(0, 256, level.getIntArray("Biomes"));
biomes = INMS.get().newBiomeContainer(mainWorld.getMinHeight(), mainWorld.getMaxHeight(), level.getIntArray("Biomes"));
}
if ((loadFlags & HEIGHTMAPS) != 0) {
heightMaps = level.getCompoundTag("Heightmaps");