mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-06-24 21:51:24 +00:00
merger!
This commit is contained in:
@@ -57,10 +57,7 @@ import net.jpountz.lz4.LZ4BlockOutputStream;
|
|||||||
import net.jpountz.lz4.LZ4FrameInputStream;
|
import net.jpountz.lz4.LZ4FrameInputStream;
|
||||||
import net.jpountz.lz4.LZ4FrameOutputStream;
|
import net.jpountz.lz4.LZ4FrameOutputStream;
|
||||||
import org.apache.commons.lang.RandomStringUtils;
|
import org.apache.commons.lang.RandomStringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.*;
|
||||||
import org.bukkit.Chunk;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Creeper;
|
import org.bukkit.entity.Creeper;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
@@ -161,6 +158,12 @@ public class CommandDeveloper implements DecreeExecutor {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Decree(description = "gets wg height")
|
||||||
|
public void whatHeight() {
|
||||||
|
Iris.info("test");
|
||||||
|
sender().sendMessage("Height: " + player().getWorld().getHighestBlockAt(player().getLocation(), HeightMap.MOTION_BLOCKING).getY());
|
||||||
|
}
|
||||||
|
|
||||||
@Decree(description = "Fix biomes in a iris world", aliases = {"fb"} )
|
@Decree(description = "Fix biomes in a iris world", aliases = {"fb"} )
|
||||||
public void fixbiomes(
|
public void fixbiomes(
|
||||||
@Param(description = "The IrisWorld to fix biomes at") World world) {
|
@Param(description = "The IrisWorld to fix biomes at") World world) {
|
||||||
|
|||||||
@@ -125,20 +125,7 @@ public class BoardSVC implements IrisService, BoardProvider {
|
|||||||
int y = player.getLocation().getBlockY() - player.getWorld().getMinHeight();
|
int y = player.getLocation().getBlockY() - player.getWorld().getMinHeight();
|
||||||
int z = player.getLocation().getBlockZ();
|
int z = player.getLocation().getBlockZ();
|
||||||
|
|
||||||
if(IrisSettings.get().getGeneral().debug){
|
|
||||||
lines.add("&7&m ");
|
|
||||||
lines.add(C.GREEN + "Speed" + C.GRAY + ": " + Form.f(engine.getGeneratedPerSecond(), 0) + "/s " + Form.duration(1000D / engine.getGeneratedPerSecond(), 0));
|
|
||||||
lines.add(C.AQUA + "Cache" + C.GRAY + ": " + Form.f(IrisData.cacheSize()));
|
|
||||||
lines.add(C.AQUA + "Mantle" + C.GRAY + ": " + engine.getMantle().getLoadedRegionCount());
|
|
||||||
lines.add(C.LIGHT_PURPLE + "Carving" + C.GRAY + ": " + engine.getMantle().isCarved(x,y,z));
|
|
||||||
lines.add("&7&m ");
|
|
||||||
lines.add(C.AQUA + "Region" + C.GRAY + ": " + engine.getRegion(x, z).getName());
|
|
||||||
lines.add(C.AQUA + "Biome" + C.GRAY + ": " + engine.getBiomeOrMantle(x, y, z).getName());
|
|
||||||
lines.add(C.AQUA + "Height" + C.GRAY + ": " + Math.round(engine.getHeight(x, z)));
|
|
||||||
lines.add(C.AQUA + "Slope" + C.GRAY + ": " + Form.f(engine.getComplex().getSlopeStream().get(x, z), 2));
|
|
||||||
lines.add(C.AQUA + "BUD/s" + C.GRAY + ": " + Form.f(engine.getBlockUpdatesPerSecond()));
|
|
||||||
lines.add("&7&m ");
|
|
||||||
} else {
|
|
||||||
lines.add("&7&m ");
|
lines.add("&7&m ");
|
||||||
lines.add(C.GREEN + "Speed" + C.GRAY + ": " + Form.f(engine.getGeneratedPerSecond(), 0) + "/s " + Form.duration(1000D / engine.getGeneratedPerSecond(), 0));
|
lines.add(C.GREEN + "Speed" + C.GRAY + ": " + Form.f(engine.getGeneratedPerSecond(), 0) + "/s " + Form.duration(1000D / engine.getGeneratedPerSecond(), 0));
|
||||||
lines.add(C.AQUA + "Cache" + C.GRAY + ": " + Form.f(IrisData.cacheSize()));
|
lines.add(C.AQUA + "Cache" + C.GRAY + ": " + Form.f(IrisData.cacheSize()));
|
||||||
@@ -150,7 +137,7 @@ public class BoardSVC implements IrisService, BoardProvider {
|
|||||||
lines.add(C.AQUA + "Slope" + C.GRAY + ": " + Form.f(engine.getComplex().getSlopeStream().get(x, z), 2));
|
lines.add(C.AQUA + "Slope" + C.GRAY + ": " + Form.f(engine.getComplex().getSlopeStream().get(x, z), 2));
|
||||||
lines.add(C.AQUA + "BUD/s" + C.GRAY + ": " + Form.f(engine.getBlockUpdatesPerSecond()));
|
lines.add(C.AQUA + "BUD/s" + C.GRAY + ": " + Form.f(engine.getBlockUpdatesPerSecond()));
|
||||||
lines.add("&7&m ");
|
lines.add("&7&m ");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,37 +11,56 @@ import com.volmit.iris.util.context.ChunkContext;
|
|||||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||||
import com.volmit.iris.util.format.Form;
|
import com.volmit.iris.util.format.Form;
|
||||||
import com.volmit.iris.util.hunk.Hunk;
|
import com.volmit.iris.util.hunk.Hunk;
|
||||||
import com.volmit.iris.util.math.RollingSequence;
|
import com.volmit.iris.util.math.*;
|
||||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
import org.bukkit.HeightMap;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Biome;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@Desc("Dimension Merging only supports 1 for now.")
|
@Desc("Dimension Merging only supports 1 for now.")
|
||||||
@Data
|
@Data
|
||||||
public class IrisMerger {
|
public class IrisMerger {
|
||||||
|
// todo
|
||||||
|
/**
|
||||||
|
* Filler approach:
|
||||||
|
* - To see and detect ravines and such use a method to see the dimensions of the 2d plate
|
||||||
|
* - If there is air on the border of the chunk generate the next one as well
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
private transient RollingSequence mergeDuration = new RollingSequence(20);
|
private transient RollingSequence mergeDuration = new RollingSequence(20);
|
||||||
private transient Engine engine;
|
private transient Engine engine;
|
||||||
|
|
||||||
|
|
||||||
@Desc("Selected Generator")
|
@Desc("Selected Generator")
|
||||||
private String generator;
|
private String generator;
|
||||||
//
|
|
||||||
@Desc("Uses the generator as a datapack key")
|
@Desc("Uses the generator as a datapack key")
|
||||||
private boolean datapackMode;
|
private boolean datapackMode;
|
||||||
//
|
|
||||||
// @Desc("Merging strategy")
|
// @Desc("Merging strategy")
|
||||||
// private IrisMergeStrategies mode;
|
// private IrisMergeStrategies mode;
|
||||||
|
|
||||||
@Desc("How deep till it should use vanilla terrain")
|
@Desc("How deep till it should use vanilla terrain")
|
||||||
private int depth = 10;
|
private int depth = 30;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merges underground from a selected chunk into the corresponding chunk in the outcome world.
|
* Merges underground from a selected chunk into the corresponding chunk in the outcome world.
|
||||||
@@ -53,41 +72,70 @@ public class IrisMerger {
|
|||||||
if (engine.getWorld() == null)
|
if (engine.getWorld() == null)
|
||||||
throw new IllegalStateException("World is null. Ensure that the world has been properly loaded.");
|
throw new IllegalStateException("World is null. Ensure that the world has been properly loaded.");
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||||
Hunk<BlockData> vh = memoryWorldToHunk(engine.getMemoryWorld().getChunkData(x, z), engine);
|
Hunk<BlockData> vh = Hunk.newArrayHunk(16, engine.getMemoryWorld().getBukkit().getMaxHeight() - engine.getMemoryWorld().getBukkit().getMinHeight(), 16);
|
||||||
|
Hunk<Biome> vbh = Hunk.newArrayHunk(16, engine.getMemoryWorld().getBukkit().getMaxHeight() - engine.getMemoryWorld().getBukkit().getMinHeight(), 16);
|
||||||
|
|
||||||
|
// PaperLib.getChunkAtAsync(engine.getMemoryWorld().getBukkit(), x, z, true).thenAccept((i) -> {
|
||||||
|
// memoryWorldToHunk(engine.getMemoryWorld().getChunkData(x, z), vh, vbh, engine);
|
||||||
|
// }).get();
|
||||||
|
memoryWorldToHunk(engine.getMemoryWorld().getChunkData(x, z), vh, vbh, engine);
|
||||||
|
|
||||||
|
//removeSurface(vh, x, z, engine);
|
||||||
|
|
||||||
int totalHeight = engine.getMemoryWorld().getBukkit().getMaxHeight() - engine.getMemoryWorld().getBukkit().getMinHeight();
|
int totalHeight = engine.getMemoryWorld().getBukkit().getMaxHeight() - engine.getMemoryWorld().getBukkit().getMinHeight();
|
||||||
int minHeight = Math.abs(engine.getMemoryWorld().getBukkit().getMinHeight());
|
int minHeight = Math.abs(engine.getMemoryWorld().getBukkit().getMinHeight());
|
||||||
|
|
||||||
ChunkContext context = new ChunkContext(x << 4, z << 4, engine.getComplex());
|
ChunkContext context = new ChunkContext(x << 4, z << 4, engine.getComplex());
|
||||||
|
boolean vanillaMode = false;
|
||||||
|
List<Biome> caveBiomes = Arrays.asList(
|
||||||
|
Biome.DRIPSTONE_CAVES,
|
||||||
|
Biome.LUSH_CAVES,
|
||||||
|
Biome.DEEP_DARK
|
||||||
|
);
|
||||||
for (int xx = 0; xx < 16; xx++) {
|
for (int xx = 0; xx < 16; xx++) {
|
||||||
for (int zz = 0; zz < 16; zz++) {
|
for (int zz = 0; zz < 16; zz++) {
|
||||||
for (int y = 0; y < totalHeight; y++) {
|
for (int y = 0; y < totalHeight; y++) {
|
||||||
//int height = engine.getHeight(x * 16 + xx, z * 16 + zz, true) - 10;
|
|
||||||
int height = (int) Math.ceil(context.getHeight().get(xx, zz) - depth);
|
int height = (int) Math.ceil(context.getHeight().get(xx, zz) - depth);
|
||||||
if (y < height) {
|
if (y < height || vanillaMode) {
|
||||||
BlockData blockData = vh.get(xx, y, zz);
|
BlockData blockData = vh.get(xx, y, zz);
|
||||||
|
Biome biome = vbh.get(xx, y, zz);
|
||||||
if (blockData != null) {
|
if (blockData != null) {
|
||||||
|
|
||||||
INMS.get().setBlock(engine.getWorld().realWorld(), x * 16 + xx, y - minHeight, z * 16 + zz, blockData, 1042, 0);
|
INMS.get().setBlock(engine.getWorld().realWorld(), x * 16 + xx, y - minHeight, z * 16 + zz, blockData, 1042, 0);
|
||||||
|
if (biome != null && caveBiomes.contains(biome)) {
|
||||||
|
engine.getWorld().realWorld().setBiome(x * 16 + xx, y - minHeight, z * 16 + zz, biome);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mergeDuration.put(p.getMilliseconds());
|
mergeDuration.put(p.getMilliseconds());
|
||||||
Iris.info("Vanilla merge average in: " + Form.duration(mergeDuration.getAverage(), 8));
|
Iris.info("Vanilla merge average in: " + Form.duration(mergeDuration.getAverage(), 8));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Hunk<BlockData> memoryWorldToHunk(ChunkGenerator.ChunkData data, Engine engine) {
|
private void memoryWorldToHunk(ChunkGenerator.ChunkData data, Hunk<BlockData> h, Hunk<Biome> b, Engine engine) {
|
||||||
Hunk<BlockData> h = Hunk.newArrayHunk(16, engine.getMemoryWorld().getBukkit().getMaxHeight() - engine.getMemoryWorld().getBukkit().getMinHeight(), 16);
|
int minHeight = engine.getMemoryWorld().getBukkit().getMinHeight();
|
||||||
|
int minHeightAbs = Math.abs(minHeight);
|
||||||
|
int height = engine.getMemoryWorld().getBukkit().getMaxHeight() - minHeight;
|
||||||
|
|
||||||
|
IntStream.range(0, height).parallel().forEach(y -> {
|
||||||
|
int dataY = y - minHeightAbs;
|
||||||
for (int x = 0; x < 16; x++) {
|
for (int x = 0; x < 16; x++) {
|
||||||
for (int z = 0; z < 16; z++) {
|
for (int z = 0; z < 16; z++) {
|
||||||
for (int y = 0; y < engine.getMemoryWorld().getBukkit().getMaxHeight() - engine.getMemoryWorld().getBukkit().getMinHeight(); y++) {
|
BlockData block = data.getBlockData(x, dataY, z);
|
||||||
BlockData block = data.getBlockData(x, y, z);
|
Biome biome = data.getBiome(x, dataY, z);
|
||||||
h.set(x, y, z, block);
|
h.set(x, y, z, block);
|
||||||
|
b.set(x, y, z, biome);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return h;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user