mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-19 10:43:14 +00:00
commit
8f019cd794
@ -22,6 +22,7 @@ import com.volmit.iris.Iris;
|
|||||||
import com.volmit.iris.core.loader.IrisData;
|
import com.volmit.iris.core.loader.IrisData;
|
||||||
import com.volmit.iris.core.nms.INMS;
|
import com.volmit.iris.core.nms.INMS;
|
||||||
import com.volmit.iris.core.nms.v1X.NMSBinding1X;
|
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.service.IrisEngineSVC;
|
||||||
import com.volmit.iris.core.tools.IrisPackBenchmarking;
|
import com.volmit.iris.core.tools.IrisPackBenchmarking;
|
||||||
import com.volmit.iris.core.tools.IrisToolbelt;
|
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.format.Form;
|
||||||
import com.volmit.iris.util.io.IO;
|
import com.volmit.iris.util.io.IO;
|
||||||
import com.volmit.iris.util.mantle.TectonicPlate;
|
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.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 com.volmit.iris.util.plugin.VolmitSender;
|
||||||
import io.lumine.mythic.bukkit.adapters.BukkitEntity;
|
import io.lumine.mythic.bukkit.adapters.BukkitEntity;
|
||||||
import net.jpountz.lz4.LZ4BlockInputStream;
|
import net.jpountz.lz4.LZ4BlockInputStream;
|
||||||
@ -61,6 +65,7 @@ import java.net.NetworkInterface;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
import java.util.zip.GZIPOutputStream;
|
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")
|
@Decree(description = "test")
|
||||||
public void test() throws NoSuchFieldException, IllegalAccessException {
|
public void mca (
|
||||||
IrisEngineSVC.instance.engineStatus();
|
@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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,6 @@ public class CommandIris implements DecreeExecutor {
|
|||||||
private CommandFind find;
|
private CommandFind find;
|
||||||
private CommandDeveloper developer;
|
private CommandDeveloper developer;
|
||||||
public static boolean worldCreation = false;
|
public static boolean worldCreation = false;
|
||||||
String WorldToLoad;
|
|
||||||
String WorldEngine;
|
String WorldEngine;
|
||||||
String worldNameToCheck = "YourWorldName";
|
String worldNameToCheck = "YourWorldName";
|
||||||
VolmitSender sender = Iris.getSender();
|
VolmitSender sender = Iris.getSender();
|
||||||
@ -477,7 +476,7 @@ public class CommandIris implements DecreeExecutor {
|
|||||||
sender().sendMessage(C.YELLOW + world + " Doesnt exist on the server.");
|
sender().sendMessage(C.YELLOW + world + " Doesnt exist on the server.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
WorldToLoad = world;
|
|
||||||
File BUKKIT_YML = new File("bukkit.yml");
|
File BUKKIT_YML = new File("bukkit.yml");
|
||||||
String pathtodim = world + File.separator +"iris"+File.separator +"pack"+File.separator +"dimensions"+File.separator;
|
String pathtodim = world + File.separator +"iris"+File.separator +"pack"+File.separator +"dimensions"+File.separator;
|
||||||
File directory = new File(Bukkit.getWorldContainer(), pathtodim);
|
File directory = new File(Bukkit.getWorldContainer(), pathtodim);
|
||||||
@ -515,7 +514,7 @@ public class CommandIris implements DecreeExecutor {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
checkForBukkitWorlds();
|
checkForBukkitWorlds(world);
|
||||||
sender().sendMessage(C.GREEN + world + " loaded successfully.");
|
sender().sendMessage(C.GREEN + world + " loaded successfully.");
|
||||||
}
|
}
|
||||||
@Decree(description = "Evacuate an iris world", origin = DecreeOrigin.PLAYER, sync = true)
|
@Decree(description = "Evacuate an iris world", origin = DecreeOrigin.PLAYER, sync = true)
|
||||||
@ -536,7 +535,7 @@ public class CommandIris implements DecreeExecutor {
|
|||||||
File worldDirectory = new File(worldContainer, worldName);
|
File worldDirectory = new File(worldContainer, worldName);
|
||||||
return worldDirectory.exists() && worldDirectory.isDirectory();
|
return worldDirectory.exists() && worldDirectory.isDirectory();
|
||||||
}
|
}
|
||||||
private void checkForBukkitWorlds() {
|
private void checkForBukkitWorlds(String world) {
|
||||||
FileConfiguration fc = new YamlConfiguration();
|
FileConfiguration fc = new YamlConfiguration();
|
||||||
try {
|
try {
|
||||||
fc.load(new File("bukkit.yml"));
|
fc.load(new File("bukkit.yml"));
|
||||||
@ -545,9 +544,9 @@ public class CommandIris implements DecreeExecutor {
|
|||||||
return;
|
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)) {
|
if (!worldsToLoad.contains(s)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2,23 +2,21 @@ package com.volmit.iris.core.pregenerator;
|
|||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
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.math.Position2;
|
|
||||||
import com.volmit.iris.util.math.RollingSequence;
|
import com.volmit.iris.util.math.RollingSequence;
|
||||||
import com.volmit.iris.util.math.Spiraler;
|
import com.volmit.iris.util.math.Spiraler;
|
||||||
import com.volmit.iris.util.nbt.mca.Chunk;
|
|
||||||
import com.volmit.iris.util.nbt.mca.MCAFile;
|
import com.volmit.iris.util.nbt.mca.MCAFile;
|
||||||
import com.volmit.iris.util.nbt.mca.MCAUtil;
|
import com.volmit.iris.util.nbt.mca.MCAUtil;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
public class ChunkUpdater {
|
public class ChunkUpdater {
|
||||||
private AtomicBoolean cancelled = new AtomicBoolean(false);
|
private AtomicBoolean cancelled;
|
||||||
private KList<Position2> cache;
|
private KList<int[]> chunkMap;
|
||||||
private final RollingSequence chunksPerSecond;
|
private final RollingSequence chunksPerSecond;
|
||||||
private final RollingSequence mcaregionsPerSecond;
|
private final RollingSequence mcaregionsPerSecond;
|
||||||
private final AtomicInteger worldheightsize;
|
private final AtomicInteger worldheightsize;
|
||||||
@ -27,49 +25,46 @@ public class ChunkUpdater {
|
|||||||
private final AtomicInteger totalMaxChunks;
|
private final AtomicInteger totalMaxChunks;
|
||||||
private final AtomicInteger totalMcaregions;
|
private final AtomicInteger totalMcaregions;
|
||||||
private final AtomicInteger position;
|
private final AtomicInteger position;
|
||||||
private final KMap<int[], Chunk> chunk;
|
|
||||||
private final File[] McaFiles;
|
private final File[] McaFiles;
|
||||||
private final World world;
|
private final World world;
|
||||||
|
|
||||||
public ChunkUpdater(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.chunksPerSecond = new RollingSequence(10);
|
||||||
this.mcaregionsPerSecond = new RollingSequence(10);
|
this.mcaregionsPerSecond = new RollingSequence(10);
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.chunk = new KMap<>();
|
this.chunkMap = new KList<>();
|
||||||
this.McaFiles = new File(world.getWorldFolder(), "region").listFiles((dir, name) -> name.endsWith(".mca"));
|
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.worldheightsize = new AtomicInteger(calculateWorldDimensions(new File(world.getWorldFolder(), "region"), 1));
|
||||||
this.worldwidthsize = new AtomicInteger(calculateWorldDimensions(new File(world.getWorldFolder(), "region"), 0));
|
this.worldwidthsize = new AtomicInteger(calculateWorldDimensions(new File(world.getWorldFolder(), "region"), 0));
|
||||||
this.totalMaxChunks = new AtomicInteger((worldheightsize.get() / 16 ) * (worldwidthsize.get() / 16));
|
this.totalMaxChunks = new AtomicInteger((worldheightsize.get() / 16 ) * (worldwidthsize.get() / 16));
|
||||||
this.position = new AtomicInteger(0);
|
this.position = new AtomicInteger(0);
|
||||||
this.cancelled = new AtomicBoolean(false);
|
this.cancelled = new AtomicBoolean(false);
|
||||||
this.cache = new KList<>();
|
|
||||||
this.totalChunks = new AtomicInteger(0);
|
this.totalChunks = new AtomicInteger(0);
|
||||||
this.totalMcaregions = new AtomicInteger(0);
|
this.totalMcaregions = new AtomicInteger(0);
|
||||||
Initialize();
|
}
|
||||||
|
|
||||||
|
public void start() {
|
||||||
|
Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize() {
|
public void Initialize() {
|
||||||
Iris.info("Initializing..");
|
Iris.info("Initializing..");
|
||||||
try {
|
try {
|
||||||
for (File file : McaFiles) {
|
for (File mca : McaFiles) {
|
||||||
MCAFile MCARegion = MCAUtil.read(file);
|
MCAFile MCARegion = MCAUtil.read(mca);
|
||||||
//MCARegion.hasChunk(x,z);
|
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) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cache() {
|
|
||||||
int position = this.position.get();
|
|
||||||
for(; position < this.totalMaxChunks.get(); position++) {
|
|
||||||
cache.add(getChunk(position));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int calculateWorldDimensions(File regionDir, Integer o) {
|
public int calculateWorldDimensions(File regionDir, Integer o) {
|
||||||
File[] files = regionDir.listFiles((dir, name) -> name.endsWith(".mca"));
|
File[] files = regionDir.listFiles((dir, name) -> name.endsWith(".mca"));
|
||||||
|
|
||||||
@ -101,7 +96,7 @@ public class ChunkUpdater {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Position2 getChunk(int position) {
|
public int[] getChunk(int position) {
|
||||||
int p = -1;
|
int p = -1;
|
||||||
AtomicInteger xx = new AtomicInteger();
|
AtomicInteger xx = new AtomicInteger();
|
||||||
AtomicInteger zz = new AtomicInteger();
|
AtomicInteger zz = new AtomicInteger();
|
||||||
@ -113,7 +108,10 @@ public class ChunkUpdater {
|
|||||||
while (s.hasNext() && p++ < position) {
|
while (s.hasNext() && p++ < position) {
|
||||||
s.next();
|
s.next();
|
||||||
}
|
}
|
||||||
|
int[] coords = new int[2];
|
||||||
|
coords[0] = xx.get();
|
||||||
|
coords[1] = zz.get();
|
||||||
|
|
||||||
return new Position2(xx.get(), zz.get());
|
return coords;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,13 +113,6 @@ public class IrisCreator {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public World create() throws IrisException {
|
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()) {
|
if (Bukkit.isPrimaryThread()) {
|
||||||
throw new IrisException("You cannot invoke create() on the main thread.");
|
throw new IrisException("You cannot invoke create() on the main thread.");
|
||||||
}
|
}
|
||||||
|
@ -90,8 +90,8 @@ public class IrisBiomeGeneratorLink {
|
|||||||
int gmx = heights[1];
|
int gmx = heights[1];
|
||||||
int gmn = heights[0];
|
int gmn = heights[0];
|
||||||
|
|
||||||
int mx = max;
|
int mx = getMaxRaw();
|
||||||
int mn = min;
|
int mn = getMinRaw();
|
||||||
if (engine.getDimension().isSmartVanillaHeight()) {
|
if (engine.getDimension().isSmartVanillaHeight()) {
|
||||||
if (mx > 0)
|
if (mx > 0)
|
||||||
mx = Math.min((int) (((float) mx / (float) gmx) * 300.0f), 300);
|
mx = Math.min((int) (((float) mx / (float) gmx) * 300.0f), 300);
|
||||||
|
@ -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.mca.palette.MCABiomeContainer;
|
||||||
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
||||||
import com.volmit.iris.util.nbt.tag.ListTag;
|
import com.volmit.iris.util.nbt.tag.ListTag;
|
||||||
|
import org.bukkit.World;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
import static com.volmit.iris.util.nbt.mca.LoadFlags.*;
|
import static com.volmit.iris.util.nbt.mca.LoadFlags.*;
|
||||||
|
import static org.bukkit.Bukkit.getServer;
|
||||||
|
|
||||||
public class Chunk {
|
public class Chunk {
|
||||||
public static final int DEFAULT_DATA_VERSION = 2730;
|
public static final int DEFAULT_DATA_VERSION = 2730;
|
||||||
@ -71,10 +73,11 @@ public class Chunk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Chunk newChunk() {
|
public static Chunk newChunk() {
|
||||||
|
World mainWorld = getServer().getWorlds().get(0);
|
||||||
Chunk c = new Chunk(0);
|
Chunk c = new Chunk(0);
|
||||||
c.dataVersion = DEFAULT_DATA_VERSION;
|
c.dataVersion = DEFAULT_DATA_VERSION;
|
||||||
c.data = new CompoundTag();
|
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.data.put("Level", defaultLevel());
|
||||||
c.status = "full";
|
c.status = "full";
|
||||||
return c;
|
return c;
|
||||||
@ -95,11 +98,12 @@ public class Chunk {
|
|||||||
if ((level = data.getCompoundTag("Level")) == null) {
|
if ((level = data.getCompoundTag("Level")) == null) {
|
||||||
throw new IllegalArgumentException("data does not contain \"Level\" tag");
|
throw new IllegalArgumentException("data does not contain \"Level\" tag");
|
||||||
}
|
}
|
||||||
|
World mainWorld = getServer().getWorlds().get(0);
|
||||||
dataVersion = data.getInt("DataVersion");
|
dataVersion = data.getInt("DataVersion");
|
||||||
inhabitedTime = level.getLong("InhabitedTime");
|
inhabitedTime = level.getLong("InhabitedTime");
|
||||||
lastUpdate = level.getLong("LastUpdate");
|
lastUpdate = level.getLong("LastUpdate");
|
||||||
if ((loadFlags & BIOMES) != 0) {
|
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) {
|
if ((loadFlags & HEIGHTMAPS) != 0) {
|
||||||
heightMaps = level.getCompoundTag("Heightmaps");
|
heightMaps = level.getCompoundTag("Heightmaps");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user