mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-07 16:26:14 +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.LZ4FrameOutputStream;
|
||||
import org.apache.commons.lang.RandomStringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Creeper;
|
||||
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"} )
|
||||
public void fixbiomes(
|
||||
@Param(description = "The IrisWorld to fix biomes at") World world) {
|
||||
|
||||
@@ -125,32 +125,19 @@ public class BoardSVC implements IrisService, BoardProvider {
|
||||
int y = player.getLocation().getBlockY() - player.getWorld().getMinHeight();
|
||||
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(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("&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 ");
|
||||
}
|
||||
|
||||
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("&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 ");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,37 +11,56 @@ import com.volmit.iris.util.context.ChunkContext;
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
import com.volmit.iris.util.format.Form;
|
||||
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 io.papermc.lib.PaperLib;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.bukkit.HeightMap;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Desc("Dimension Merging only supports 1 for now.")
|
||||
@Data
|
||||
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 Engine engine;
|
||||
|
||||
|
||||
@Desc("Selected Generator")
|
||||
private String generator;
|
||||
//
|
||||
|
||||
@Desc("Uses the generator as a datapack key")
|
||||
private boolean datapackMode;
|
||||
//
|
||||
|
||||
// @Desc("Merging strategy")
|
||||
// private IrisMergeStrategies mode;
|
||||
|
||||
@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.
|
||||
@@ -53,41 +72,70 @@ public class IrisMerger {
|
||||
if (engine.getWorld() == null)
|
||||
throw new IllegalStateException("World is null. Ensure that the world has been properly loaded.");
|
||||
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
Hunk<BlockData> vh = memoryWorldToHunk(engine.getMemoryWorld().getChunkData(x, z), engine);
|
||||
int totalHeight = engine.getMemoryWorld().getBukkit().getMaxHeight() - engine.getMemoryWorld().getBukkit().getMinHeight();
|
||||
int minHeight = Math.abs(engine.getMemoryWorld().getBukkit().getMinHeight());
|
||||
try {
|
||||
|
||||
ChunkContext context = new ChunkContext(x << 4, z << 4, engine.getComplex());
|
||||
for (int xx = 0; xx < 16; xx++) {
|
||||
for (int zz = 0; zz < 16; zz++) {
|
||||
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);
|
||||
if (y < height) {
|
||||
BlockData blockData = vh.get(xx, y, zz);
|
||||
if (blockData != null) {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
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);
|
||||
|
||||
INMS.get().setBlock(engine.getWorld().realWorld(), x * 16 + xx, y - minHeight , z * 16 + zz, blockData, 1042, 0);
|
||||
// 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 minHeight = Math.abs(engine.getMemoryWorld().getBukkit().getMinHeight());
|
||||
|
||||
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 zz = 0; zz < 16; zz++) {
|
||||
for (int y = 0; y < totalHeight; y++) {
|
||||
int height = (int) Math.ceil(context.getHeight().get(xx, zz) - depth);
|
||||
if (y < height || vanillaMode) {
|
||||
BlockData blockData = vh.get(xx, y, zz);
|
||||
Biome biome = vbh.get(xx, y, zz);
|
||||
if (blockData != null) {
|
||||
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());
|
||||
Iris.info("Vanilla merge average in: " + Form.duration(mergeDuration.getAverage(), 8));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
mergeDuration.put(p.getMilliseconds());
|
||||
Iris.info("Vanilla merge average in: " + Form.duration(mergeDuration.getAverage(), 8));
|
||||
}
|
||||
|
||||
private Hunk<BlockData> memoryWorldToHunk(ChunkGenerator.ChunkData data, Engine engine) {
|
||||
Hunk<BlockData> h = Hunk.newArrayHunk(16, engine.getMemoryWorld().getBukkit().getMaxHeight() - engine.getMemoryWorld().getBukkit().getMinHeight(), 16);
|
||||
for (int x = 0; x < 16; x++) {
|
||||
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, y, z);
|
||||
private void memoryWorldToHunk(ChunkGenerator.ChunkData data, Hunk<BlockData> h, Hunk<Biome> b, Engine engine) {
|
||||
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 z = 0; z < 16; z++) {
|
||||
BlockData block = data.getBlockData(x, dataY, z);
|
||||
Biome biome = data.getBiome(x, dataY, z);
|
||||
h.set(x, y, z, block);
|
||||
b.set(x, y, z, biome);
|
||||
}
|
||||
}
|
||||
}
|
||||
return h;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user