mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-26 14:00:26 +00:00
deepslate variant support
This commit is contained in:
1 parent
412f592e1c
commit
b70c9fd4d8
1 file changed
+46
-6
@@ -31,9 +31,7 @@ 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.Arrays;
|
import java.util.*;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
@@ -73,6 +71,9 @@ public class IrisMerger {
|
|||||||
@Desc("Splits in the engine height")
|
@Desc("Splits in the engine height")
|
||||||
private int split = 0;
|
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.
|
* 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);
|
BlockData blockData = vh.get(xx, y, zz);
|
||||||
|
if (!blockData.getMaterial().isAir() && deepslateTranslator) {
|
||||||
if (chunkDataIris.getBlockData(xx, y - minHeight, zz).getMaterial() != FILLER.getMaterial() && blockData.getMaterial().isOccluding()) {
|
if (chunkDataIris.getBlockData(xx, y - minHeight, zz).getMaterial() != FILLER.getMaterial() && blockData.getMaterial().isOccluding()) {
|
||||||
blockData = chunkDataIris.getBlockData(xx, y - minHeight, zz);
|
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(
|
nms.setBlock(
|
||||||
@@ -243,6 +256,33 @@ public class IrisMerger {
|
|||||||
return chunkData;
|
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) {
|
public static <T> Hunk<T> copyHunkParallel(Hunk<T> original, Function<T, T> elementCopier) {
|
||||||
Hunk<T> copy = Hunk.newHunk(original.getWidth(), original.getHeight(), original.getDepth());
|
Hunk<T> copy = Hunk.newHunk(original.getWidth(), original.getHeight(), original.getDepth());
|
||||||
original.compute3D((ox, oy, oz, section) -> {
|
original.compute3D((ox, oy, oz, section) -> {
|
||||||
|
|||||||
Reference in new issue
Block a user