mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-01 23:47:21 +00:00
fixes seed inconsistency and a huge performance bump
This commit is contained in:
parent
288e556f2a
commit
dbe9f81091
@ -216,8 +216,8 @@ public class IrisEngine implements Engine {
|
||||
}
|
||||
memoryWorld = getMerger().isDatapackMode() ? Failable.get(() ->
|
||||
getMerger().getGenerator() == null ?
|
||||
INMS.get().createMemoryWorld(new WorldCreator("memoryworld")) :
|
||||
INMS.get().createMemoryWorld(NamespacedKey.minecraft(getMerger().getGenerator()), new WorldCreator("memoryworld"))
|
||||
INMS.get().createMemoryWorld(new WorldCreator("memoryworld").seed(getSeedManager().getSeed())) :
|
||||
INMS.get().createMemoryWorld(NamespacedKey.minecraft(getMerger().getGenerator()), new WorldCreator("memoryworld").seed(getSeedManager().getSeed()))
|
||||
) : null; // todo: experimental
|
||||
per = memoryWorld.getBukkit().getPersistentDataContainer();
|
||||
per.set(dk, PersistentDataType.STRING, getMerger().getGenerator());
|
||||
|
@ -3,34 +3,23 @@ package com.volmit.iris.engine.object;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.nms.INMS;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.object.annotations.ArrayType;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.engine.platform.BukkitChunkGenerator;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.context.ChunkContext;
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
import com.volmit.iris.util.data.palette.QuartPos;
|
||||
import com.volmit.iris.util.format.Form;
|
||||
import com.volmit.iris.util.hunk.Hunk;
|
||||
import com.volmit.iris.util.math.*;
|
||||
import com.volmit.iris.util.math.RollingSequence;
|
||||
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.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
@AllArgsConstructor
|
||||
@ -38,27 +27,15 @@ import java.util.stream.IntStream;
|
||||
@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 = 30;
|
||||
|
||||
@ -73,10 +50,17 @@ public class IrisMerger {
|
||||
throw new IllegalStateException("World is null. Ensure that the world has been properly loaded.");
|
||||
|
||||
try {
|
||||
|
||||
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);
|
||||
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
|
||||
);
|
||||
|
||||
memoryWorldToHunk(engine.getMemoryWorld().getChunkData(x, z), vh, vbh, engine);
|
||||
|
||||
@ -85,11 +69,13 @@ public class IrisMerger {
|
||||
|
||||
ChunkContext context = new ChunkContext(x << 4, z << 4, engine.getComplex());
|
||||
boolean vanillaMode = false;
|
||||
List<Biome> caveBiomes = Arrays.asList(
|
||||
|
||||
Set<Biome> caveBiomes = new HashSet<>(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++) {
|
||||
@ -98,9 +84,23 @@ public class IrisMerger {
|
||||
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, new Flags(false, false, true, false, false).value(), 0);
|
||||
INMS.get().setBlock(
|
||||
engine.getWorld().realWorld(),
|
||||
x * 16 + xx,
|
||||
y - minHeight,
|
||||
z * 16 + zz,
|
||||
blockData,
|
||||
new Flags(false, false, true, false, false).value(),
|
||||
0
|
||||
);
|
||||
|
||||
if (biome != null && caveBiomes.contains(biome)) {
|
||||
engine.getWorld().realWorld().setBiome(x * 16 + xx, y - minHeight, z * 16 + zz, biome);
|
||||
engine.getWorld().realWorld().setBiome(
|
||||
x * 16 + xx,
|
||||
y - minHeight,
|
||||
z * 16 + zz,
|
||||
biome
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -117,25 +117,42 @@ public class IrisMerger {
|
||||
|
||||
private void memoryWorldToHunk(ChunkGenerator.ChunkData data, Hunk<BlockData> h, Hunk<Biome> b, Engine engine) {
|
||||
int minHeight = engine.getMemoryWorld().getBukkit().getMinHeight();
|
||||
int maxHeight = engine.getMemoryWorld().getBukkit().getMaxHeight();
|
||||
int minHeightAbs = Math.abs(minHeight);
|
||||
int height = engine.getMemoryWorld().getBukkit().getMaxHeight() - minHeight;
|
||||
int height = maxHeight - minHeight;
|
||||
int minSection = minHeight >> 4;
|
||||
int maxSection = (maxHeight - 1) >> 4;
|
||||
|
||||
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);
|
||||
for (int sectionY = minSection; sectionY <= maxSection; sectionY++) {
|
||||
int qY = QuartPos.fromSection(sectionY);
|
||||
for (int sX = 0; sX < 4; sX++) {
|
||||
for (int sZ = 0; sZ < 4; sZ++) {
|
||||
for (int sY = 0; sY < 4; sY++) {
|
||||
int localX = sX << 2;
|
||||
int localY = (qY << 2) + (sY << 2) - minHeight;
|
||||
int adjustedY = localY + minHeightAbs;
|
||||
int localZ = sZ << 2;
|
||||
if (localY < 0 || adjustedY >= height) {
|
||||
continue;
|
||||
}
|
||||
|
||||
h.set(localX, adjustedY, localZ, data.getBlockData(localX, localY, localZ));
|
||||
b.set(localX, adjustedY, localZ, data.getBiome(localX, localY, localZ));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public record Flags(boolean listener, boolean flag, boolean client, boolean update, boolean physics) {
|
||||
public static Flags fromValue(int value) {
|
||||
return new Flags((value & 1024) != 0, (value & 64) != 0, (value & 2) != 0, (value & 1) != 0, (value & 16) == 0);
|
||||
return new Flags(
|
||||
(value & 1024) != 0,
|
||||
(value & 64) != 0,
|
||||
(value & 2) != 0,
|
||||
(value & 1) != 0,
|
||||
(value & 16) == 0
|
||||
);
|
||||
}
|
||||
|
||||
public int value() {
|
||||
@ -148,5 +165,4 @@ public class IrisMerger {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user