mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-06-18 14:50:57 +00:00
Merge branch 'mca' of https://github.com/RePixelatedMC/Iris into PixelatedDev
# Conflicts: # core/src/main/java/com/volmit/iris/core/tools/IrisWorldDump.java
This commit is contained in:
@@ -173,7 +173,7 @@ public class CommandDeveloper implements DecreeExecutor {
|
|||||||
public void mca (
|
public void mca (
|
||||||
@Param(description = "String") World world) {
|
@Param(description = "String") World world) {
|
||||||
try {
|
try {
|
||||||
IrisWorldDump dump = new IrisWorldDump(world, sender(), IrisWorldDump.mode.PACKED);
|
IrisWorldDump dump = new IrisWorldDump(world, sender());
|
||||||
dump.start();
|
dump.start();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import com.volmit.iris.core.tools.IrisToolbelt;
|
|||||||
import com.volmit.iris.engine.framework.Engine;
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
import com.volmit.iris.engine.object.*;
|
import com.volmit.iris.engine.object.*;
|
||||||
import com.volmit.iris.engine.platform.PlatformChunkGenerator;
|
import com.volmit.iris.engine.platform.PlatformChunkGenerator;
|
||||||
|
import com.volmit.iris.engine.platform.studio.StudioGenerator;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.collection.KMap;
|
import com.volmit.iris.util.collection.KMap;
|
||||||
import com.volmit.iris.util.collection.KSet;
|
import com.volmit.iris.util.collection.KSet;
|
||||||
@@ -41,6 +42,7 @@ import com.volmit.iris.util.decree.DecreeExecutor;
|
|||||||
import com.volmit.iris.util.decree.DecreeOrigin;
|
import com.volmit.iris.util.decree.DecreeOrigin;
|
||||||
import com.volmit.iris.util.decree.annotations.Decree;
|
import com.volmit.iris.util.decree.annotations.Decree;
|
||||||
import com.volmit.iris.util.decree.annotations.Param;
|
import com.volmit.iris.util.decree.annotations.Param;
|
||||||
|
import com.volmit.iris.util.decree.specialhandlers.NullablePlayerHandler;
|
||||||
import com.volmit.iris.util.format.C;
|
import com.volmit.iris.util.format.C;
|
||||||
import com.volmit.iris.util.format.Form;
|
import com.volmit.iris.util.format.Form;
|
||||||
import com.volmit.iris.util.function.Function2;
|
import com.volmit.iris.util.function.Function2;
|
||||||
@@ -63,6 +65,7 @@ import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
|||||||
import com.volmit.iris.util.scheduling.jobs.QueueJob;
|
import com.volmit.iris.util.scheduling.jobs.QueueJob;
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.InventoryType;
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.util.BlockVector;
|
import org.bukkit.util.BlockVector;
|
||||||
@@ -344,18 +347,10 @@ public class CommandStudio implements DecreeExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Decree(description = "Render a world map (External GUI)", aliases = "render")
|
@Decree(description = "Render a world map (External GUI)", aliases = "render")
|
||||||
public void map(
|
public void map() {
|
||||||
@Param(name = "world", description = "The world to open the generator for", contextual = true)
|
|
||||||
World world
|
|
||||||
) {
|
|
||||||
if (noGUI()) return;
|
if (noGUI()) return;
|
||||||
|
if (noStudio()) return;
|
||||||
if (!IrisToolbelt.isIrisWorld(world)) {
|
VisionGUI.launch(IrisToolbelt.access(player().getWorld()).getEngine(), 0);
|
||||||
sender().sendMessage(C.RED + "You need to be in or specify an Iris-generated world!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
VisionGUI.launch(IrisToolbelt.access(world).getEngine(), 0);
|
|
||||||
sender().sendMessage(C.GREEN + "Opening map!");
|
sender().sendMessage(C.GREEN + "Opening map!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,219 @@
|
|||||||
|
package com.volmit.iris.core.tools;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.core.loader.IrisData;
|
||||||
|
import com.volmit.iris.core.project.IrisProject;
|
||||||
|
import com.volmit.iris.engine.object.*;
|
||||||
|
import com.volmit.iris.util.collection.KList;
|
||||||
|
import com.volmit.iris.util.collection.KMap;
|
||||||
|
import com.volmit.iris.util.decree.DecreeOrigin;
|
||||||
|
import com.volmit.iris.util.decree.annotations.Decree;
|
||||||
|
import com.volmit.iris.util.decree.annotations.Param;
|
||||||
|
import com.volmit.iris.util.format.C;
|
||||||
|
import com.volmit.iris.util.format.Form;
|
||||||
|
import com.volmit.iris.util.function.NoiseProvider;
|
||||||
|
import com.volmit.iris.util.interpolation.InterpolationMethod;
|
||||||
|
import com.volmit.iris.util.io.IO;
|
||||||
|
import com.volmit.iris.util.math.RNG;
|
||||||
|
import com.volmit.iris.util.noise.CNG;
|
||||||
|
import com.volmit.iris.util.plugin.VolmitSender;
|
||||||
|
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class IrisNoiseBenchmark {
|
||||||
|
private IrisDimension dimension;
|
||||||
|
private VolmitSender sender;
|
||||||
|
|
||||||
|
public IrisNoiseBenchmark(IrisDimension dimension, VolmitSender sender) {
|
||||||
|
this.dimension = dimension;
|
||||||
|
this.sender = sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void runAll() {
|
||||||
|
// Todo: Make this more accurate
|
||||||
|
File pack = dimension.getLoadFile().getParentFile().getParentFile();
|
||||||
|
File report = Iris.instance.getDataFile("profile.txt");
|
||||||
|
IrisProject project = new IrisProject(pack);
|
||||||
|
IrisData data = IrisData.get(pack);
|
||||||
|
|
||||||
|
KList<String> fileText = new KList<>();
|
||||||
|
|
||||||
|
KMap<NoiseStyle, Double> styleTimings = new KMap<>();
|
||||||
|
KMap<InterpolationMethod, Double> interpolatorTimings = new KMap<>();
|
||||||
|
KMap<String, Double> generatorTimings = new KMap<>();
|
||||||
|
KMap<String, Double> biomeTimings = new KMap<>();
|
||||||
|
KMap<String, Double> regionTimings = new KMap<>();
|
||||||
|
|
||||||
|
sender.sendMessage("Calculating Performance Metrics for Noise generators");
|
||||||
|
|
||||||
|
for (NoiseStyle i : NoiseStyle.values()) {
|
||||||
|
CNG c = i.create(new RNG(i.hashCode()));
|
||||||
|
|
||||||
|
for (int j = 0; j < 3000; j++) {
|
||||||
|
c.noise(j, j + 1000, j * j);
|
||||||
|
c.noise(j, -j);
|
||||||
|
}
|
||||||
|
|
||||||
|
PrecisionStopwatch px = PrecisionStopwatch.start();
|
||||||
|
|
||||||
|
for (int j = 0; j < 100000; j++) {
|
||||||
|
c.noise(j, j + 1000, j * j);
|
||||||
|
c.noise(j, -j);
|
||||||
|
}
|
||||||
|
|
||||||
|
styleTimings.put(i, px.getMilliseconds());
|
||||||
|
}
|
||||||
|
|
||||||
|
fileText.add("Noise Style Performance Impacts: ");
|
||||||
|
|
||||||
|
for (NoiseStyle i : styleTimings.sortKNumber()) {
|
||||||
|
fileText.add(i.name() + ": " + styleTimings.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
fileText.add("");
|
||||||
|
|
||||||
|
sender.sendMessage("Calculating Interpolator Timings...");
|
||||||
|
|
||||||
|
for (InterpolationMethod i : InterpolationMethod.values()) {
|
||||||
|
IrisInterpolator in = new IrisInterpolator();
|
||||||
|
in.setFunction(i);
|
||||||
|
in.setHorizontalScale(8);
|
||||||
|
|
||||||
|
NoiseProvider np = (x, z) -> Math.random();
|
||||||
|
|
||||||
|
for (int j = 0; j < 3000; j++) {
|
||||||
|
in.interpolate(j, -j, np);
|
||||||
|
}
|
||||||
|
|
||||||
|
PrecisionStopwatch px = PrecisionStopwatch.start();
|
||||||
|
|
||||||
|
for (int j = 0; j < 100000; j++) {
|
||||||
|
in.interpolate(j + 10000, -j - 100000, np);
|
||||||
|
}
|
||||||
|
|
||||||
|
interpolatorTimings.put(i, px.getMilliseconds());
|
||||||
|
}
|
||||||
|
|
||||||
|
fileText.add("Noise Interpolator Performance Impacts: ");
|
||||||
|
|
||||||
|
for (InterpolationMethod i : interpolatorTimings.sortKNumber()) {
|
||||||
|
fileText.add(i.name() + ": " + interpolatorTimings.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
fileText.add("");
|
||||||
|
|
||||||
|
sender.sendMessage("Processing Generator Scores: ");
|
||||||
|
|
||||||
|
KMap<String, KList<String>> btx = new KMap<>();
|
||||||
|
|
||||||
|
for (String i : data.getGeneratorLoader().getPossibleKeys()) {
|
||||||
|
KList<String> vv = new KList<>();
|
||||||
|
IrisGenerator g = data.getGeneratorLoader().load(i);
|
||||||
|
KList<IrisNoiseGenerator> composites = g.getAllComposites();
|
||||||
|
double score = 0;
|
||||||
|
int m = 0;
|
||||||
|
for (IrisNoiseGenerator j : composites) {
|
||||||
|
m++;
|
||||||
|
score += styleTimings.get(j.getStyle().getStyle());
|
||||||
|
vv.add("Composite Noise Style " + m + " " + j.getStyle().getStyle().name() + ": " + styleTimings.get(j.getStyle().getStyle()));
|
||||||
|
}
|
||||||
|
|
||||||
|
score += interpolatorTimings.get(g.getInterpolator().getFunction());
|
||||||
|
vv.add("Interpolator " + g.getInterpolator().getFunction().name() + ": " + interpolatorTimings.get(g.getInterpolator().getFunction()));
|
||||||
|
generatorTimings.put(i, score);
|
||||||
|
btx.put(i, vv);
|
||||||
|
}
|
||||||
|
|
||||||
|
fileText.add("Project Generator Performance Impacts: ");
|
||||||
|
|
||||||
|
for (String i : generatorTimings.sortKNumber()) {
|
||||||
|
fileText.add(i + ": " + generatorTimings.get(i));
|
||||||
|
|
||||||
|
btx.get(i).forEach((ii) -> fileText.add(" " + ii));
|
||||||
|
}
|
||||||
|
|
||||||
|
fileText.add("");
|
||||||
|
|
||||||
|
KMap<String, KList<String>> bt = new KMap<>();
|
||||||
|
|
||||||
|
for (String i : data.getBiomeLoader().getPossibleKeys()) {
|
||||||
|
KList<String> vv = new KList<>();
|
||||||
|
IrisBiome b = data.getBiomeLoader().load(i);
|
||||||
|
double score = 0;
|
||||||
|
|
||||||
|
int m = 0;
|
||||||
|
for (IrisBiomePaletteLayer j : b.getLayers()) {
|
||||||
|
m++;
|
||||||
|
score += styleTimings.get(j.getStyle().getStyle());
|
||||||
|
vv.add("Palette Layer " + m + ": " + styleTimings.get(j.getStyle().getStyle()));
|
||||||
|
}
|
||||||
|
|
||||||
|
score += styleTimings.get(b.getBiomeStyle().getStyle());
|
||||||
|
vv.add("Biome Style: " + styleTimings.get(b.getBiomeStyle().getStyle()));
|
||||||
|
score += styleTimings.get(b.getChildStyle().getStyle());
|
||||||
|
vv.add("Child Style: " + styleTimings.get(b.getChildStyle().getStyle()));
|
||||||
|
biomeTimings.put(i, score);
|
||||||
|
bt.put(i, vv);
|
||||||
|
}
|
||||||
|
|
||||||
|
fileText.add("Project Biome Performance Impacts: ");
|
||||||
|
|
||||||
|
for (String i : biomeTimings.sortKNumber()) {
|
||||||
|
fileText.add(i + ": " + biomeTimings.get(i));
|
||||||
|
|
||||||
|
bt.get(i).forEach((ff) -> fileText.add(" " + ff));
|
||||||
|
}
|
||||||
|
|
||||||
|
fileText.add("");
|
||||||
|
|
||||||
|
for (String i : data.getRegionLoader().getPossibleKeys()) {
|
||||||
|
IrisRegion b = data.getRegionLoader().load(i);
|
||||||
|
double score = 0;
|
||||||
|
|
||||||
|
score += styleTimings.get(b.getLakeStyle().getStyle());
|
||||||
|
score += styleTimings.get(b.getRiverStyle().getStyle());
|
||||||
|
regionTimings.put(i, score);
|
||||||
|
}
|
||||||
|
|
||||||
|
fileText.add("Project Region Performance Impacts: ");
|
||||||
|
|
||||||
|
for (String i : regionTimings.sortKNumber()) {
|
||||||
|
fileText.add(i + ": " + regionTimings.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
fileText.add("");
|
||||||
|
|
||||||
|
double m = 0;
|
||||||
|
for (double i : biomeTimings.v()) {
|
||||||
|
m += i;
|
||||||
|
}
|
||||||
|
m /= biomeTimings.size();
|
||||||
|
double mm = 0;
|
||||||
|
for (double i : generatorTimings.v()) {
|
||||||
|
mm += i;
|
||||||
|
}
|
||||||
|
mm /= generatorTimings.size();
|
||||||
|
m += mm;
|
||||||
|
double mmm = 0;
|
||||||
|
for (double i : regionTimings.v()) {
|
||||||
|
mmm += i;
|
||||||
|
}
|
||||||
|
mmm /= regionTimings.size();
|
||||||
|
m += mmm;
|
||||||
|
|
||||||
|
fileText.add("Average Score: " + m);
|
||||||
|
sender.sendMessage("Score: " + Form.duration(m, 0));
|
||||||
|
|
||||||
|
try {
|
||||||
|
IO.writeAll(report, fileText.toString("\n"));
|
||||||
|
} catch (IOException e) {
|
||||||
|
Iris.reportError(e);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(C.GREEN + "Done! " + report.getPath());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,6 @@ import com.volmit.iris.core.IrisSettings;
|
|||||||
import com.volmit.iris.engine.framework.Engine;
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.collection.KMap;
|
import com.volmit.iris.util.collection.KMap;
|
||||||
import com.volmit.iris.util.format.C;
|
|
||||||
import com.volmit.iris.util.format.Form;
|
import com.volmit.iris.util.format.Form;
|
||||||
import com.volmit.iris.util.math.M;
|
import com.volmit.iris.util.math.M;
|
||||||
import com.volmit.iris.util.math.RollingSequence;
|
import com.volmit.iris.util.math.RollingSequence;
|
||||||
@@ -15,23 +14,25 @@ import com.volmit.iris.util.nbt.mca.MCAUtil;
|
|||||||
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
||||||
import com.volmit.iris.util.nbt.tag.StringTag;
|
import com.volmit.iris.util.nbt.tag.StringTag;
|
||||||
import com.volmit.iris.util.plugin.VolmitSender;
|
import com.volmit.iris.util.plugin.VolmitSender;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||||
|
|
||||||
public class IrisWorldDump {
|
public class IrisWorldDump {
|
||||||
private KList<MCAFile> mcaList;
|
private KMap<blockData, Long> storage;
|
||||||
private KMap<String, Long> storage;
|
|
||||||
private AtomicLong airStorage;
|
private AtomicLong airStorage;
|
||||||
private World world;
|
private World world;
|
||||||
private File MCADirectory;
|
private File MCADirectory;
|
||||||
|
private AtomicInteger threads;
|
||||||
private AtomicInteger regionsProcessed;
|
private AtomicInteger regionsProcessed;
|
||||||
private AtomicInteger chunksProcessed;
|
private AtomicInteger chunksProcessed;
|
||||||
|
private AtomicInteger totalToProcess;
|
||||||
private AtomicInteger totalMaxChunks;
|
private AtomicInteger totalMaxChunks;
|
||||||
private AtomicInteger totalMCAFiles;
|
private AtomicInteger totalMCAFiles;
|
||||||
private RollingSequence chunksPerSecond;
|
private RollingSequence chunksPerSecond;
|
||||||
@@ -49,16 +50,16 @@ public class IrisWorldDump {
|
|||||||
private File structures;
|
private File structures;
|
||||||
|
|
||||||
public IrisWorldDump(World world, VolmitSender sender) {
|
public IrisWorldDump(World world, VolmitSender sender) {
|
||||||
sender.sendMessage("Building IrisWorldDump...");
|
sender.sendMessage("Initializing IrisWorldDump...");
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
this.MCADirectory = new File(world.getWorldFolder(), "region");
|
this.MCADirectory = new File(world.getWorldFolder(), "region");
|
||||||
this.totalMCAFiles = new AtomicInteger(MCACount());
|
|
||||||
this.dumps = new File("plugins" + File.separator + "iris", "dumps");
|
this.dumps = new File("plugins" + File.separator + "iris", "dumps");
|
||||||
this.worldDump = new File(dumps, world.getName());
|
this.worldDump = new File(dumps, world.getName());
|
||||||
this.mcaCacheSize = IrisSettings.get().getWorldDump().mcaCacheSize;
|
this.mcaCacheSize = IrisSettings.get().getWorldDump().mcaCacheSize;
|
||||||
this.regionsProcessed = new AtomicInteger(0);
|
this.regionsProcessed = new AtomicInteger(0);
|
||||||
this.chunksProcessed = new AtomicInteger(0);
|
this.chunksProcessed = new AtomicInteger(0);
|
||||||
|
this.totalToProcess = new AtomicInteger(0);
|
||||||
this.chunksPerSecond = new RollingSequence(10);
|
this.chunksPerSecond = new RollingSequence(10);
|
||||||
this.temp = new File(worldDump, "temp");
|
this.temp = new File(worldDump, "temp");
|
||||||
this.executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() - 1);
|
this.executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() - 1);
|
||||||
@@ -66,33 +67,36 @@ public class IrisWorldDump {
|
|||||||
this.startTime = new AtomicLong();
|
this.startTime = new AtomicLong();
|
||||||
this.storage = new KMap<>();
|
this.storage = new KMap<>();
|
||||||
this.airStorage = new AtomicLong(0);
|
this.airStorage = new AtomicLong(0);
|
||||||
|
|
||||||
|
this.blocks = new File(worldDump, "blocks");
|
||||||
|
this.structures = new File(worldDump, "structures");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.engine = IrisToolbelt.access(world).getEngine();
|
this.engine = IrisToolbelt.access(world).getEngine();
|
||||||
this.IrisWorld = true;
|
this.IrisWorld = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
this.IrisWorld = false;
|
this.IrisWorld = false;
|
||||||
}
|
}
|
||||||
CompletableFuture<Void> setupFuture = CompletableFuture.runAsync(this::initialize, executor);
|
|
||||||
setupFuture.join();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initialize() {
|
|
||||||
try {
|
|
||||||
this.blocks = new File(worldDump, "blocks");
|
|
||||||
this.structures = new File(worldDump, "structures");
|
|
||||||
if (worldDump.exists()) {
|
|
||||||
deleteFileOrDirectory(worldDump);
|
|
||||||
}
|
|
||||||
this.totalMaxChunks = new AtomicInteger(getChunkCount().get());
|
|
||||||
this.totalMCAFiles = new AtomicInteger(getMCACount().get());
|
|
||||||
sender.sendMessage("Finished Building!");
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
|
|
||||||
|
if (!dumps.exists()) {
|
||||||
|
if (!dumps.mkdirs()) {
|
||||||
|
System.err.println("Failed to create dump directory.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
CompletableFuture<Integer> mcaCount = CompletableFuture.supplyAsync(this::totalMcaFiles);
|
||||||
|
CompletableFuture<Integer> chunkCount = CompletableFuture.supplyAsync(this::totalMCAChunks);
|
||||||
|
this.totalMCAFiles = new AtomicInteger(mcaCount.get());
|
||||||
|
this.totalMaxChunks = new AtomicInteger(chunkCount.get());
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
dump();
|
dump();
|
||||||
updater();
|
updater();
|
||||||
}
|
}
|
||||||
@@ -112,9 +116,24 @@ public class IrisWorldDump {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class blockData {
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private String block;
|
||||||
|
private int biome;
|
||||||
|
private int height;
|
||||||
|
|
||||||
|
public blockData(String b, int bm, int h) {
|
||||||
|
this.block = b;
|
||||||
|
this.height = h;
|
||||||
|
this.biome = bm;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void dump() {
|
private void dump() {
|
||||||
Iris.info("Starting the dump process.");
|
Iris.info("Starting the dump process.");
|
||||||
CompletableFuture<Void> dump = CompletableFuture.runAsync(() -> {
|
int threads = Runtime.getRuntime().availableProcessors();
|
||||||
AtomicInteger f = new AtomicInteger();
|
AtomicInteger f = new AtomicInteger();
|
||||||
for (File mcaFile : MCADirectory.listFiles()) {
|
for (File mcaFile : MCADirectory.listFiles()) {
|
||||||
if (mcaFile.getName().endsWith(".mca")) {
|
if (mcaFile.getName().endsWith(".mca")) {
|
||||||
@@ -129,62 +148,6 @@ public class IrisWorldDump {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}).thenRun(() -> {
|
|
||||||
try {
|
|
||||||
executor.shutdown();
|
|
||||||
executor.awaitTermination(Integer.MAX_VALUE, TimeUnit.MILLISECONDS);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
dump.join();
|
|
||||||
Iris.info("Dump process completed.");
|
|
||||||
} catch (Exception e) {
|
|
||||||
Iris.error("An error occurred during the dump process: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private AtomicInteger getChunkCount() {
|
|
||||||
AtomicInteger count = new AtomicInteger();
|
|
||||||
CompletableFuture.runAsync(() -> {
|
|
||||||
for (File mcaFile : MCADirectory.listFiles()) {
|
|
||||||
executor.submit(() -> {
|
|
||||||
try {
|
|
||||||
if (mcaFile.getName().endsWith(".mca")) {
|
|
||||||
MCAFile mca = MCAUtil.read(mcaFile);
|
|
||||||
for (int x = 0; x < 32; x++) {
|
|
||||||
for (int z = 0; z < 32; z++) {
|
|
||||||
if (mca.hasChunk(x, z)) count.getAndIncrement();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}).thenRunAsync(() -> {
|
|
||||||
try {
|
|
||||||
executor.shutdown();
|
|
||||||
executor.awaitTermination(4, TimeUnit.SECONDS);
|
|
||||||
} catch (Exception e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
private AtomicInteger getMCACount() {
|
|
||||||
AtomicInteger i = new AtomicInteger(0);
|
|
||||||
for (File mca : MCADirectory.listFiles()) {
|
|
||||||
if (mca.toPath().endsWith(".mca")) {
|
|
||||||
i.getAndIncrement();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processMCARegion(MCAFile mca) {
|
private void processMCARegion(MCAFile mca) {
|
||||||
@@ -200,6 +163,7 @@ public class IrisWorldDump {
|
|||||||
for (int z = 0; z < 16; z++) {
|
for (int z = 0; z < 16; z++) {
|
||||||
for (int y = 0; y < CHUNK_HEIGHT; y++) {
|
for (int y = 0; y < CHUNK_HEIGHT; y++) {
|
||||||
CompoundTag tag = chunk.getBlockStateAt(x, y, z);
|
CompoundTag tag = chunk.getBlockStateAt(x, y, z);
|
||||||
|
int biome = chunk.getBiomeAt(x, y, z);
|
||||||
if (tag == null) {
|
if (tag == null) {
|
||||||
String blockName = "minecraft:air";
|
String blockName = "minecraft:air";
|
||||||
//storage.compute(blockName, (key, count) -> (count == null) ? 1 : count + 1);
|
//storage.compute(blockName, (key, count) -> (count == null) ? 1 : count + 1);
|
||||||
@@ -208,7 +172,8 @@ public class IrisWorldDump {
|
|||||||
} else {
|
} else {
|
||||||
StringTag nameTag = tag.getStringTag("Name");
|
StringTag nameTag = tag.getStringTag("Name");
|
||||||
String blockName = nameTag.getValue();
|
String blockName = nameTag.getValue();
|
||||||
storage.compute(blockName, (key, count) -> (count == null) ? 1 : count + 1);
|
blockData data = new blockData(blockName, biome, y);
|
||||||
|
storage.compute(data, (key, count) -> (count == null) ? 1 : count + 1);
|
||||||
int ii = 0;
|
int ii = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -220,7 +185,41 @@ public class IrisWorldDump {
|
|||||||
regionsProcessed.getAndIncrement();
|
regionsProcessed.getAndIncrement();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int MCACount() {
|
private int totalMCAChunks() {
|
||||||
|
AtomicInteger chunks = new AtomicInteger();
|
||||||
|
CountDownLatch latch = new CountDownLatch(totalMcaFiles() * 1024);
|
||||||
|
for (File mcafile : MCADirectory.listFiles()) {
|
||||||
|
executor.submit(() -> {
|
||||||
|
try {
|
||||||
|
if (mcafile.getName().endsWith(".mca")) {
|
||||||
|
MCAFile mca = MCAUtil.read(mcafile);
|
||||||
|
for (int width = 0; width < 32; width++) {
|
||||||
|
for (int depth = 0; depth < 32; depth++) {
|
||||||
|
Chunk chunk = mca.getChunk(width, depth);
|
||||||
|
if (chunk != null) {
|
||||||
|
chunks.getAndIncrement();
|
||||||
|
}
|
||||||
|
latch.countDown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Iris.error("Failed to read mca file");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
latch.await();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return chunks.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
private int totalMcaFiles() {
|
||||||
int size = 0;
|
int size = 0;
|
||||||
for (File mca : MCADirectory.listFiles()) {
|
for (File mca : MCADirectory.listFiles()) {
|
||||||
if (mca.getName().endsWith(".mca")) {
|
if (mca.getName().endsWith(".mca")) {
|
||||||
@@ -239,17 +238,4 @@ public class IrisWorldDump {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void deleteFileOrDirectory(File file) throws IOException {
|
|
||||||
if (file.isDirectory()) {
|
|
||||||
File[] entries = file.listFiles();
|
|
||||||
if (entries != null) {
|
|
||||||
for (File entry : entries) {
|
|
||||||
deleteFileOrDirectory(entry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!file.delete()) {
|
|
||||||
throw new IOException("Failed to delete " + file.getAbsolutePath());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,7 +170,6 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
|||||||
@Desc("Collection of ores to be generated")
|
@Desc("Collection of ores to be generated")
|
||||||
@ArrayType(type = IrisOreGenerator.class, min = 1)
|
@ArrayType(type = IrisOreGenerator.class, min = 1)
|
||||||
private KList<IrisOreGenerator> ores = new KList<>();
|
private KList<IrisOreGenerator> ores = new KList<>();
|
||||||
|
|
||||||
public BlockData generateOres(int x, int y, int z, RNG rng, IrisData data) {
|
public BlockData generateOres(int x, int y, int z, RNG rng, IrisData data) {
|
||||||
if (ores.isEmpty()) {
|
if (ores.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user