From 87cce116af21e2cd43dcd7d0a14241946673144d Mon Sep 17 00:00:00 2001 From: Daniel Mills Date: Fri, 23 Oct 2020 19:15:41 -0400 Subject: [PATCH] f --- .../volmit/iris/gen/atomics/HeightHunk.java | 64 ---- .../volmit/iris/gen/atomics/TerrainHunk.java | 283 ------------------ .../volmit/iris/gen/atomics/TerrainNode.java | 61 ---- .../Hunk.java => v2/scaffold/ArrayHunk.java} | 212 ++++++------- .../volmit/iris/gen/v2/scaffold/GenStage.java | 10 + .../com/volmit/iris/gen/v2/scaffold/Hunk.java | 179 +++++++++++ .../volmit/iris/gen/v2/scaffold/HunkView.java | 125 ++++++++ 7 files changed, 405 insertions(+), 529 deletions(-) delete mode 100644 src/main/java/com/volmit/iris/gen/atomics/HeightHunk.java delete mode 100644 src/main/java/com/volmit/iris/gen/atomics/TerrainHunk.java delete mode 100644 src/main/java/com/volmit/iris/gen/atomics/TerrainNode.java rename src/main/java/com/volmit/iris/gen/{atomics/Hunk.java => v2/scaffold/ArrayHunk.java} (58%) create mode 100644 src/main/java/com/volmit/iris/gen/v2/scaffold/GenStage.java create mode 100644 src/main/java/com/volmit/iris/gen/v2/scaffold/Hunk.java create mode 100644 src/main/java/com/volmit/iris/gen/v2/scaffold/HunkView.java diff --git a/src/main/java/com/volmit/iris/gen/atomics/HeightHunk.java b/src/main/java/com/volmit/iris/gen/atomics/HeightHunk.java deleted file mode 100644 index 2f5d8d88d..000000000 --- a/src/main/java/com/volmit/iris/gen/atomics/HeightHunk.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.volmit.iris.gen.atomics; - -public class HeightHunk extends Hunk -{ - public HeightHunk(int w, int d) - { - super(w, 1, d); - } - - public void setHeight(int x, int y, int z) - { - set(x, 0, z, (byte) (y + Byte.MIN_VALUE)); - } - - public int getHeight(int x, int z) - { - return get(x, 0, z) - Byte.MIN_VALUE; - } - - @SafeVarargs - public static HeightHunk combined(Byte defaultNode, HeightHunk... hunks) - { - int w = 0; - int d = 0; - - for(HeightHunk i : hunks) - { - w = Math.max(w, i.getW()); - d = Math.max(d, i.getD()); - } - - HeightHunk b = new HeightHunk(w, d); - b.fill((byte) (defaultNode + Byte.MIN_VALUE)); - - for(HeightHunk i : hunks) - { - b.insert(i); - } - - return b; - } - - @SafeVarargs - public static HeightHunk combined(HeightHunk... hunks) - { - int w = 0; - int d = 0; - - for(HeightHunk i : hunks) - { - w = Math.max(w, i.getW()); - d = Math.max(d, i.getD()); - } - - HeightHunk b = new HeightHunk(w, d); - - for(HeightHunk i : hunks) - { - b.insert(i); - } - - return b; - } -} diff --git a/src/main/java/com/volmit/iris/gen/atomics/TerrainHunk.java b/src/main/java/com/volmit/iris/gen/atomics/TerrainHunk.java deleted file mode 100644 index 8ab9d6c49..000000000 --- a/src/main/java/com/volmit/iris/gen/atomics/TerrainHunk.java +++ /dev/null @@ -1,283 +0,0 @@ -package com.volmit.iris.gen.atomics; - -import org.bukkit.Material; -import org.bukkit.block.Biome; -import org.bukkit.block.data.BlockData; -import org.bukkit.generator.ChunkGenerator.BiomeGrid; -import org.bukkit.generator.ChunkGenerator.ChunkData; -import org.bukkit.material.MaterialData; - -import com.volmit.iris.object.IrisBiome; -import com.volmit.iris.util.KList; - -import lombok.Getter; - -@SuppressWarnings("deprecation") -public class TerrainHunk extends Hunk implements BiomeGrid, ChunkData -{ - @Getter - private HeightHunk height; - - @Getter - private Hunk biome; - - public TerrainHunk(int w, int h, int d) - { - super(w, h, d); - this.height = new HeightHunk(w, d); - this.biome = new Hunk(w, h, d); - } - - public TerrainHunk(int w, int h, int d, Hunk noise) - { - super(w, h, d); - this.height = new HeightHunk(w, d); - this.biome = new Hunk(w, h, d); - - for(int i = 0; i < w; i++) - { - for(int j = 0; j < d; j++) - { - height.setHeight(i, noise.highestNonNull(i, j), j); - } - } - } - - @Override - public int getMaxHeight() - { - return getH(); - } - - private void set(int x, int y, int z, BlockData block) - { - TerrainNode n = get(x, y, z); - - if(n == null) - { - n = new TerrainNode(Biome.THE_VOID, block); - } - - else - { - n = n.setBlockData(block); - } - - set(x, y, z, n); - } - - private void set(int x, int y, int z, Biome biome) - { - TerrainNode n = get(x, y, z); - - if(n == null) - { - n = new TerrainNode(biome, Material.AIR.createBlockData()); - } - - else - { - n = n.setBiome(biome); - } - - set(x, y, z, n); - } - - @Override - public void setBlock(int x, int y, int z, Material material) - { - set(x, y, z, material.createBlockData()); - } - - @Override - public void setBlock(int x, int y, int z, MaterialData material) - { - set(x, y, z, material.getItemType().createBlockData()); - } - - @Override - public void setBlock(int x, int y, int z, BlockData blockData) - { - set(x, y, z, blockData); - } - - @Override - public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, Material material) - { - throw new RuntimeException("Not Supported"); - } - - @Override - public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, MaterialData material) - { - throw new RuntimeException("Not Supported"); - } - - @Override - public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, BlockData blockData) - { - throw new RuntimeException("Not Supported"); - } - - @Override - public Material getType(int x, int y, int z) - { - return getBlockData(x, y, z).getMaterial(); - } - - @Override - public MaterialData getTypeAndData(int x, int y, int z) - { - return new MaterialData(getBlockData(x, y, z).getMaterial()); - } - - @Override - public BlockData getBlockData(int x, int y, int z) - { - TerrainNode n = get(x, y, z); - - if(n == null) - { - return Material.VOID_AIR.createBlockData(); - } - - return n.getBlockData(); - } - - public BlockData getBlockDataOrNull(int x, int y, int z) - { - TerrainNode n = get(x, y, z); - - if(n == null) - { - return null; - } - - return n.getBlockData(); - } - - @Override - public byte getData(int x, int y, int z) - { - throw new RuntimeException("Not Supported"); - } - - @Override - public Biome getBiome(int x, int z) - { - throw new RuntimeException("Not Supported"); - } - - @Override - public Biome getBiome(int x, int y, int z) - { - TerrainNode n = get(x, y, z); - - if(n == null) - { - return Biome.THE_VOID; - } - - return n.getBiome(); - } - - @Override - public void setBiome(int x, int z, Biome bio) - { - throw new RuntimeException("Not Supported"); - } - - @Override - public void setBiome(int x, int y, int z, Biome bio) - { - set(x, y, z, bio); - } - - @SuppressWarnings("unchecked") - @SafeVarargs - public static TerrainHunk combined(TerrainNode defaultNode, TerrainHunk... hunks) - { - KList hhunks = new KList<>(); - KList> bhunks = new KList<>(); - - int w = 0; - int h = 0; - int d = 0; - - for(TerrainHunk i : hunks) - { - hhunks.add(i.getHeight()); - bhunks.add(i.getBiome()); - w = Math.max(w, i.getW()); - h = Math.max(h, i.getH()); - d = Math.max(d, i.getD()); - } - - TerrainHunk b = new TerrainHunk(w, h, d); - b.fill(defaultNode); - - for(TerrainHunk i : hunks) - { - b.insert(i); - } - - b.height = HeightHunk.combined((byte) 0, hhunks.toArray(new HeightHunk[hhunks.size()])); - b.biome = Hunk.combined(null, hhunks.toArray(new Hunk[hhunks.size()])); - - return b; - } - - @SuppressWarnings("unchecked") - @SafeVarargs - public static TerrainHunk combined(TerrainHunk... hunks) - { - KList hhunks = new KList<>(); - KList> bhunks = new KList<>(); - int w = 0; - int h = 0; - int d = 0; - - for(TerrainHunk i : hunks) - { - hhunks.add(i.getHeight()); - bhunks.add(i.getBiome()); - w = Math.max(w, i.getW()); - h = Math.max(h, i.getH()); - d = Math.max(d, i.getD()); - } - - TerrainHunk b = new TerrainHunk(w, h, d); - - for(TerrainHunk i : hunks) - { - b.insert(i); - } - - b.height = HeightHunk.combined((byte) 0, hhunks.toArray(new HeightHunk[hhunks.size()])); - b.biome = Hunk.combined(null, hhunks.toArray(new Hunk[hhunks.size()])); - - return b; - } - - public void into(ChunkData c) - { - - for(int i = 0; i < w; i++) - { - for(int j = 0; j < h; j++) - { - for(int k = 0; k < d; k++) - { - BlockData n = getBlockData(i, j, k); - - if(n == null) - { - continue; - } - - c.setBlock(i, j, k, n); - } - } - } - } -} diff --git a/src/main/java/com/volmit/iris/gen/atomics/TerrainNode.java b/src/main/java/com/volmit/iris/gen/atomics/TerrainNode.java deleted file mode 100644 index 1062e027f..000000000 --- a/src/main/java/com/volmit/iris/gen/atomics/TerrainNode.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.volmit.iris.gen.atomics; - -import org.bukkit.block.Biome; -import org.bukkit.block.data.BlockData; - -import com.volmit.iris.util.KList; - -public class TerrainNode -{ - private static final KList blockDataPalette = new KList(); - - private final byte biome; - private final short block; - - private TerrainNode(byte biome, short block) - { - this.biome = biome; - this.block = block; - } - - public TerrainNode(Biome biome, BlockData block) - { - this((byte) (biome.ordinal()), (short) (paletteOf(block))); - } - - public TerrainNode setBlockData(BlockData block) - { - return new TerrainNode(biome, (short) (paletteOf(block))); - } - - public TerrainNode setBiome(Biome biome) - { - return new TerrainNode((byte) (biome.ordinal()), block); - } - - public BlockData getBlockData() - { - return blockDataPalette.get(block); - } - - public Biome getBiome() - { - return Biome.values()[biome]; - } - - private static int paletteOf(BlockData b) - { - synchronized(blockDataPalette) - { - int v = blockDataPalette.indexOf(b); - - if(v >= 0) - { - return v; - } - - blockDataPalette.add(b); - return blockDataPalette.size() - 1; - } - } -} diff --git a/src/main/java/com/volmit/iris/gen/atomics/Hunk.java b/src/main/java/com/volmit/iris/gen/v2/scaffold/ArrayHunk.java similarity index 58% rename from src/main/java/com/volmit/iris/gen/atomics/Hunk.java rename to src/main/java/com/volmit/iris/gen/v2/scaffold/ArrayHunk.java index cbd3ca35b..082202ecf 100644 --- a/src/main/java/com/volmit/iris/gen/atomics/Hunk.java +++ b/src/main/java/com/volmit/iris/gen/v2/scaffold/ArrayHunk.java @@ -1,28 +1,23 @@ -package com.volmit.iris.gen.atomics; +package com.volmit.iris.gen.v2.scaffold; import org.bouncycastle.util.Arrays; -import com.volmit.iris.Iris; -import com.volmit.iris.util.Function3; -import com.volmit.iris.util.Supplier2; -import com.volmit.iris.util.Supplier3; - import lombok.Data; @Data -public class Hunk +public class ArrayHunk implements Hunk { - protected final int w; - protected final int h; - protected final int d; - protected final T[] data; + private final int w; + private final int h; + private final int d; + private final T[] data; @SuppressWarnings("unchecked") - public Hunk(int w, int h, int d) + public ArrayHunk(int w, int h, int d) { if(w * h * d < 0) { - Iris.error(w + " " + h + " " + d + " is not valid!"); + throw new RuntimeException("Unsupported size " + w + " " + h + " " + d); } this.w = w; @@ -49,9 +44,10 @@ public class Hunk * The max z (exclusive) * @return the new hunk (x2-x1, y2-y1, z2-z1) */ - public Hunk crop(int x1, int y1, int z1, int x2, int y2, int z2) + @Override + public ArrayHunk crop(int x1, int y1, int z1, int x2, int y2, int z2) { - Hunk h = new Hunk(x2 - x1, y2 - y1, z2 - z1); + ArrayHunk h = new ArrayHunk(x2 - x1, y2 - y1, z2 - z1); for(int i = x1; i < x2; i++) { @@ -79,7 +75,8 @@ public class Hunk * @param hunk * the hunk to insert */ - public void insert(int offX, int offY, int offZ, Hunk hunk) + @Override + public void insert(int offX, int offY, int offZ, ArrayHunk hunk) { insert(offX, offY, offZ, hunk, false); } @@ -90,7 +87,8 @@ public class Hunk * @param hunk * the hunk to insert */ - public void insert(Hunk hunk) + @Override + public void insert(ArrayHunk hunk) { insert(0, 0, 0, hunk, false); } @@ -103,7 +101,8 @@ public class Hunk * @param inverted * invert the inserted hunk or not */ - public void insert(Hunk hunk, boolean inverted) + @Override + public void insert(ArrayHunk hunk, boolean inverted) { insert(0, 0, 0, hunk, inverted); } @@ -123,7 +122,8 @@ public class Hunk * @param invertY * should the inserted hunk be inverted */ - public void insert(int offX, int offY, int offZ, Hunk hunk, boolean invertY) + @Override + public void insert(int offX, int offY, int offZ, ArrayHunk hunk, boolean invertY) { if(offX + (hunk.getW() - 1) >= w || offY + (hunk.getH() - 1) >= h || offZ + (hunk.getD() - 1) >= d || offX < 0 || offY < 0 || offZ < 0) { @@ -142,14 +142,25 @@ public class Hunk } } - public void set(int x, int z, int y1, int y2, T t) - { - for(int i = y1; i <= y2; i++) - { - set(x, i, z, t); - } - } - + /** + * Set a region + * + * @param x1 + * inclusive 1st x + * @param y1 + * inclusive 1st y + * @param z1 + * inclusive 1st z + * @param x2 + * inclusive 2nd x + * @param y2 + * inclusive 2nd y + * @param z2 + * inclusive 2nd z + * @param t + * the value to set + */ + @Override public void set(int x1, int y1, int z1, int x2, int y2, int z2, T t) { for(int i = x1; i <= x2; i++) @@ -164,41 +175,58 @@ public class Hunk } } + /** + * Set a value at the given position + * + * @param x + * the x + * @param y + * the y + * @param z + * the z + * @param t + * the value + */ + @Override public void set(int x, int y, int z, T t) { data[index(x, y, z)] = t; } + /** + * Get a value at the given position + * + * @param x + * the x + * @param y + * the y + * @param z + * the z + * @return the value or null + */ + @Override public T get(int x, int y, int z) { return data[index(x, y, z)]; } - public T get(int x, int y, int z, T oob) - { - if(x >= w || y >= h || z >= d) - { - return oob; - } - - return data[index(x, y, z)]; - } - + /** + * Get the value to the closest valid position + * + * @param x + * the x + * @param y + * the y + * @param z + * the z + * @return the value closest to the border of the hunk + */ + @Override public T getClosest(int x, int y, int z) { return data[index(x >= w ? w - 1 : x, y >= h ? h - 1 : y, z >= d ? d - 1 : z)]; } - public void setInvertedY(int x, int y, int z, T t) - { - data[index(x, h - y, z)] = t; - } - - public T getInvertedY(int x, int y, int z) - { - return data[index(x, h - y, z)]; - } - protected int index(int x, int y, int z) { if(x >= w || y >= h || z >= d) @@ -209,68 +237,29 @@ public class Hunk return (z * w * h) + (y * w) + x; } - public void fill(int ox, int oy, int oz, Function3 f) - { - for(int i = ox; i < ox + getW(); i++) - { - for(int j = oy; j < oy + getH(); j++) - { - for(int k = oz; k < oz + getD(); k++) - { - set(i - ox, j - oy, k - oz, f.apply(i, j, k)); - } - } - } - } - - public void forEach(Supplier3 t) - { - for(int i = 0; i < getW(); i++) - { - for(int j = 0; j < getH(); j++) - { - for(int k = 0; k < getD(); k++) - { - t.get(i, j, k); - } - } - } - } - - public void forEachXZ(Supplier2 t) - { - for(int i = 0; i < getW(); i++) - { - for(int k = 0; k < getD(); k++) - { - t.get(i, k); - } - } - } - + @Override public void fill(T t) { Arrays.fill(data, t); } @SafeVarargs - public static Hunk combined(T defaultNode, Hunk... hunks) + public static ArrayHunk combined(ArrayHunk... hunks) { int w = 0; int h = 0; int d = 0; - for(Hunk i : hunks) + for(ArrayHunk i : hunks) { w = Math.max(w, i.getW()); h = Math.max(h, i.getH()); d = Math.max(d, i.getD()); } - Hunk b = new Hunk(w, h, d); - b.fill(defaultNode); + ArrayHunk b = new ArrayHunk(w, h, d); - for(Hunk i : hunks) + for(ArrayHunk i : hunks) { b.insert(i); } @@ -278,40 +267,21 @@ public class Hunk return b; } - @SafeVarargs - public static Hunk combined(Hunk... hunks) + @Override + public int getWidth() { - int w = 0; - int h = 0; - int d = 0; - - for(Hunk i : hunks) - { - w = Math.max(w, i.getW()); - h = Math.max(h, i.getH()); - d = Math.max(d, i.getD()); - } - - Hunk b = new Hunk(w, h, d); - - for(Hunk i : hunks) - { - b.insert(i); - } - - return b; + return w; } - public int highestNonNull(int x, int z) + @Override + public int getDepth() { - for(int i = h - 1; i >= 0; i--) - { - if(get(x, i, z) != null) - { - return i; - } - } + return h; + } - return 0; + @Override + public int getHeight() + { + return d; } } diff --git a/src/main/java/com/volmit/iris/gen/v2/scaffold/GenStage.java b/src/main/java/com/volmit/iris/gen/v2/scaffold/GenStage.java new file mode 100644 index 000000000..ee9ed07ea --- /dev/null +++ b/src/main/java/com/volmit/iris/gen/v2/scaffold/GenStage.java @@ -0,0 +1,10 @@ +package com.volmit.iris.gen.v2.scaffold; + +public enum GenStage +{ + NOISE, + CARVING, + TERRAIN, + DECORATION, + PARALLAX, +} diff --git a/src/main/java/com/volmit/iris/gen/v2/scaffold/Hunk.java b/src/main/java/com/volmit/iris/gen/v2/scaffold/Hunk.java new file mode 100644 index 000000000..ce9257068 --- /dev/null +++ b/src/main/java/com/volmit/iris/gen/v2/scaffold/Hunk.java @@ -0,0 +1,179 @@ +package com.volmit.iris.gen.v2.scaffold; + +public interface Hunk +{ + /** + * @return The X length + */ + public int getWidth(); + + /** + * @return The Z length + */ + public int getDepth(); + + /** + * @return The Y length + */ + public int getHeight(); + + /** + * Create a new view of this same hunk from a section of this hunk. + * Modifications are routed to this hunk! + * + * @param x1 + * The min x (inclusive) + * @param y1 + * The min y (inclusive) + * @param z1 + * The min z (inclusive) + * @param x2 + * The max x (exclusive) + * @param y2 + * The max y (exclusive) + * @param z2 + * The max z (exclusive) + * @return the new hunk (x2-x1, y2-y1, z2-z1) + */ + public Hunk croppedView(int x1, int y1, int z1, int x2, int y2, int z2); + + /** + * Create a new hunk from a section of this hunk. + * + * + * @param x1 + * The min x (inclusive) + * @param y1 + * The min y (inclusive) + * @param z1 + * The min z (inclusive) + * @param x2 + * The max x (exclusive) + * @param y2 + * The max y (exclusive) + * @param z2 + * The max z (exclusive) + * @return the new hunk (x2-x1, y2-y1, z2-z1) + */ + public Hunk crop(int x1, int y1, int z1, int x2, int y2, int z2); + + /** + * Insert a hunk into this one with an offset the inserted hunk + * + * @param offX + * the offset from zero for x + * @param offY + * the offset from zero for y + * @param offZ + * the offset from zero for z + * @param hunk + * the hunk to insert + */ + default void insert(int offX, int offY, int offZ, Hunk hunk) + { + insert(0, 0, 0, hunk, false); + } + + /** + * Insert a hunk into this one + * + * @param hunk + * the hunk to insert + */ + default void insert(Hunk hunk) + { + insert(hunk, false); + } + + /** + * Insert a hunk into this one + * + * @param hunk + * the hunk to insert + * @param inverted + * invert the inserted hunk or not + */ + default void insert(Hunk hunk, boolean inverted) + { + insert(0, 0, 0, hunk, inverted); + } + + /** + * Insert a hunk into this one with an offset and possibly inverting the y of + * the inserted hunk + * + * @param offX + * the offset from zero for x + * @param offY + * the offset from zero for y + * @param offZ + * the offset from zero for z + * @param hunk + * the hunk to insert + * @param invertY + * should the inserted hunk be inverted + */ + public void insert(int offX, int offY, int offZ, Hunk hunk, boolean invertY); + + /** + * Set a region + * + * @param x1 + * inclusive 1st x + * @param y1 + * inclusive 1st y + * @param z1 + * inclusive 1st z + * @param x2 + * inclusive 2nd x + * @param y2 + * inclusive 2nd y + * @param z2 + * inclusive 2nd z + * @param t + * the value to set + */ + public void set(int x1, int y1, int z1, int x2, int y2, int z2, T t); + + /** + * Set a value at the given position + * + * @param x + * the x + * @param y + * the y + * @param z + * the z + * @param t + * the value + */ + public void set(int x, int y, int z, T t); + + /** + * Get a value at the given position + * + * @param x + * the x + * @param y + * the y + * @param z + * the z + * @return the value or null + */ + public T get(int x, int y, int z); + + /** + * Get the value to the closest valid position + * + * @param x + * the x + * @param y + * the y + * @param z + * the z + * @return the value closest to the border of the hunk + */ + public T getClosest(int x, int y, int z); + + public void fill(T t); +} diff --git a/src/main/java/com/volmit/iris/gen/v2/scaffold/HunkView.java b/src/main/java/com/volmit/iris/gen/v2/scaffold/HunkView.java new file mode 100644 index 000000000..a2b06a378 --- /dev/null +++ b/src/main/java/com/volmit/iris/gen/v2/scaffold/HunkView.java @@ -0,0 +1,125 @@ +package com.volmit.iris.gen.v2.scaffold; + +public class HunkView implements Hunk +{ + private final int w; + private final int h; + private final int d; + private final Hunk src; + + public HunkView(Hunk src) + { + this(src, src.getWidth(), src.getHeight(), src.getDepth()); + } + + public HunkView(Hunk src, int w, int h, int d) + { + this.src = src; + this.w = w; + this.h = h; + this.d = d; + } + + @Override + public ArrayHunk crop(int x1, int y1, int z1, int x2, int y2, int z2) + { + ArrayHunk h = new ArrayHunk(x2 - x1, y2 - y1, z2 - z1); + + for(int i = x1; i < x2; i++) + { + for(int j = y1; j < y2; j++) + { + for(int k = z1; k < z2; k++) + { + h.set(i - x1, j - y1, k - z1, get(i, j, k)); + } + } + } + + return h; + } + + @Override + public void insert(int offX, int offY, int offZ, ArrayHunk hunk, boolean invertY) + { + if(offX + (hunk.getW() - 1) >= w || offY + (hunk.getH() - 1) >= h || offZ + (hunk.getD() - 1) >= d || offX < 0 || offY < 0 || offZ < 0) + { + throw new RuntimeException("Cannot insert hunk " + hunk.getW() + "," + hunk.getH() + "," + hunk.getD() + " into Hunk " + w + "," + h + "," + d + " with offset " + offZ + "," + offY + "," + offZ); + } + + for(int i = offX; i < offX + hunk.getW(); i++) + { + for(int j = offY; j < offY + hunk.getH(); j++) + { + for(int k = offZ; k < offZ + hunk.getD(); k++) + { + set(i, j, k, hunk.get(i - offX, j - offY, k - offZ)); + } + } + } + } + + @Override + public void set(int x1, int y1, int z1, int x2, int y2, int z2, T t) + { + if(x1 >= w || y1 >= h || z1 >= d || x2 >= w || y2 >= h || z2 >= d) + { + throw new RuntimeException(x1 + "-" + x2 + " " + y1 + "-" + y2 + " " + z1 + "-" + z2 + " is out of the bounds 0,0,0 - " + (w - 1) + "," + (h - 1) + "," + (d - 1)); + } + + src.set(x1, y1, z1, x2, y2, z2, t); + } + + @Override + public void set(int x, int y, int z, T t) + { + if(x >= w || y >= h || z >= d) + { + throw new RuntimeException(x + " " + y + " " + z + " is out of the bounds 0,0,0 - " + (w - 1) + "," + (h - 1) + "," + (d - 1)); + } + + src.set(x, y, z, t); + } + + @Override + public T get(int x, int y, int z) + { + if(x >= w || y >= h || z >= d) + { + throw new RuntimeException(x + " " + y + " " + z + " is out of the bounds 0,0,0 - " + (w - 1) + "," + (h - 1) + "," + (d - 1)); + } + + return src.get(x, y, z); + } + + @Override + public T getClosest(int x, int y, int z) + { + return src.get(x >= w ? w - 1 : x, y >= h ? h - 1 : y, z >= d ? d - 1 : z); + } + + @Override + public void fill(T t) + { + set(0, 0, 0, w - 1, h - 1, d - 1, t); + } + + @Override + public int getWidth() + { + return w; + } + + @Override + public int getDepth() + { + return d; + } + + @Override + public int getHeight() + { + return h; + } + +}