9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2026-01-04 15:41:30 +00:00

deepslate variant support

This commit is contained in:
RePixelatedMC
2024-10-23 13:50:24 +02:00
parent 412f592e1c
commit b70c9fd4d8

View File

@@ -31,9 +31,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.generator.ChunkGenerator;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.*;
import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Function;
@@ -73,6 +71,9 @@ public class IrisMerger {
@Desc("Splits in the engine height")
private int split = 0;
@Desc("If it should translate iris deposits/ores to their deepslate variant")
private boolean deepslateTranslator = true;
/**
* Merges underground from a selected chunk into the corresponding chunk in the outcome world.
@@ -136,9 +137,21 @@ public class IrisMerger {
}
BlockData blockData = vh.get(xx, y, zz);
if (chunkDataIris.getBlockData(xx, y - minHeight, zz).getMaterial() != FILLER.getMaterial() && blockData.getMaterial().isOccluding()) {
blockData = chunkDataIris.getBlockData(xx, y - minHeight, zz);
if (!blockData.getMaterial().isAir() && deepslateTranslator) {
if (chunkDataIris.getBlockData(xx, y - minHeight, zz).getMaterial() != FILLER.getMaterial() && blockData.getMaterial().isOccluding()) {
try {
BlockData newBlockData = chunkDataIris.getBlockData(xx, y - minHeight, zz);
if (hasAround(vh, xx, y, zz, Material.DEEPSLATE)) {
String id = newBlockData.getMaterial().getItemTranslationKey().replaceFirst("^block\\.[^.]+\\.", "").toUpperCase();
id = "DEEPSLATE_" + id;
Material dps = Material.getMaterial(id);
if (dps != null)
blockData = dps.createBlockData();
}
} catch (Exception e) {
Iris.error(e.getMessage());
}
}
}
nms.setBlock(
@@ -243,6 +256,33 @@ public class IrisMerger {
return chunkData;
}
private boolean hasAround(Hunk<BlockData> hunk, int x, int y, int z, Material material) {
int[] d = {-1, 0, 1};
for (int dx : d) {
for (int dy : d) {
for (int dz : d) {
if (dx == 0 && dy == 0 && dz == 0) continue;
int nx = x + dx;
int ny = y + dy;
int nz = z + dz;
if (nx >= 0 && nx < hunk.getWidth() && nz >= 0 && nz < hunk.getDepth() && ny >= 0 && ny < hunk.getHeight()) {
BlockData neighborBlock = hunk.get(nx, ny, nz);
if (neighborBlock.getMaterial() == material) {
return true;
}
}
}
}
}
return false;
}
public static <T> Hunk<T> copyHunkParallel(Hunk<T> original, Function<T, T> elementCopier) {
Hunk<T> copy = Hunk.newHunk(original.getWidth(), original.getHeight(), original.getDepth());
original.compute3D((ox, oy, oz, section) -> {