From 1306a5bca138005ea987d5d2421f251fefcf60bf Mon Sep 17 00:00:00 2001 From: Daniel Mills Date: Mon, 26 Oct 2020 03:50:45 -0400 Subject: [PATCH] Old crap removed --- .../iris/gen/v2/scaffold/ArrayHunk.java | 323 ------------------ .../gen/v2/scaffold/BiomeGridHunkView.java | 156 --------- .../gen/v2/scaffold/ChunkDataHunkView.java | 152 --------- .../com/volmit/iris/gen/v2/scaffold/Hunk.java | 208 ----------- 4 files changed, 839 deletions(-) delete mode 100644 src/main/java/com/volmit/iris/gen/v2/scaffold/ArrayHunk.java delete mode 100644 src/main/java/com/volmit/iris/gen/v2/scaffold/BiomeGridHunkView.java delete mode 100644 src/main/java/com/volmit/iris/gen/v2/scaffold/ChunkDataHunkView.java delete mode 100644 src/main/java/com/volmit/iris/gen/v2/scaffold/Hunk.java diff --git a/src/main/java/com/volmit/iris/gen/v2/scaffold/ArrayHunk.java b/src/main/java/com/volmit/iris/gen/v2/scaffold/ArrayHunk.java deleted file mode 100644 index 1b0d9a4b6..000000000 --- a/src/main/java/com/volmit/iris/gen/v2/scaffold/ArrayHunk.java +++ /dev/null @@ -1,323 +0,0 @@ -package com.volmit.iris.gen.v2.scaffold; - -import org.bouncycastle.util.Arrays; - -import lombok.Data; - -@Data -public class ArrayHunk implements Hunk -{ - private final int w; - private final int h; - private final int d; - private final T[] data; - - @SuppressWarnings("unchecked") - public ArrayHunk(int w, int h, int d) - { - if(w * h * d < 0) - { - throw new RuntimeException("Unsupported size " + w + " " + h + " " + d); - } - - this.w = w; - this.h = h; - this.d = d; - data = (T[]) new Object[w * h * d]; - } - - @Override - public Hunk croppedView(int x1, int y1, int z1, int x2, int y2, int z2) - { - return new HunkView(this, x2 - x1, y2 - y1, z2 - z1, x1, y1, z1); - } - - /** - * 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) - */ - @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; - } - - /** - * 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 - */ - @Override - public void insert(int offX, int offY, int offZ, Hunk hunk) - { - insert(offX, offY, offZ, hunk, false); - } - - /** - * Insert a hunk into this one - * - * @param hunk - * the hunk to insert - */ - @Override - public void insert(Hunk hunk) - { - insert(0, 0, 0, hunk, false); - } - - /** - * Insert a hunk into this one - * - * @param hunk - * the hunk to insert - * @param inverted - * invert the inserted hunk or not - */ - @Override - public 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 - */ - @Override - public void insert(int offX, int offY, int offZ, Hunk hunk, boolean invertY) - { - if(offX + (hunk.getWidth() - 1) >= w || offY + (hunk.getHeight() - 1) >= h || offZ + (hunk.getDepth() - 1) >= d || offX < 0 || offY < 0 || offZ < 0) - { - throw new RuntimeException("Cannot insert hunk " + hunk.getWidth() + "," + hunk.getHeight() + "," + hunk.getDepth() + " into Hunk " + w + "," + h + "," + d + " with offset " + offZ + "," + offY + "," + offZ); - } - - for(int i = offX; i < offX + hunk.getWidth(); i++) - { - for(int j = offY; j < offY + hunk.getHeight(); j++) - { - for(int k = offZ; k < offZ + hunk.getDepth(); k++) - { - set(i, j, k, hunk.get(i - offX, j - offY, k - offZ)); - } - } - } - } - - /** - * 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++) - { - for(int j = y1; j <= y2; j++) - { - for(int k = z1; k <= z2; k++) - { - set(i, j, k, t); - } - } - } - } - - /** - * 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)]; - } - - /** - * 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)]; - } - - protected int index(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 (z * w * h) + (y * w) + x; - } - - @Override - public void fill(T t) - { - Arrays.fill(data, t); - } - - @SafeVarargs - public static ArrayHunk combined(ArrayHunk... hunks) - { - int w = 0; - int h = 0; - int d = 0; - - for(ArrayHunk i : hunks) - { - w = Math.max(w, i.getW()); - h = Math.max(h, i.getH()); - d = Math.max(d, i.getD()); - } - - ArrayHunk b = new ArrayHunk(w, h, d); - - for(ArrayHunk i : hunks) - { - b.insert(i); - } - - return b; - } - - @Override - public int getWidth() - { - return w; - } - - @Override - public int getDepth() - { - return d; - } - - @Override - public int getHeight() - { - return h; - } - - @Override - public Hunk getFace(HunkFace f) - { - switch(f) - { - case BOTTOM: - return croppedView(0, 0, 0, getWidth() - 1, 0, getDepth() - 1); - case EAST: - return croppedView(getWidth() - 1, 0, 0, getWidth() - 1, getHeight() - 1, getDepth() - 1); - case NORTH: - return croppedView(0, 0, 0, getWidth() - 1, getHeight() - 1, 0); - case SOUTH: - return croppedView(0, 0, 0, 0, getHeight() - 1, getDepth() - 1); - case TOP: - return croppedView(0, getHeight() - 1, 0, getWidth() - 1, getHeight() - 1, getDepth() - 1); - case WEST: - return croppedView(0, 0, getDepth() - 1, getWidth() - 1, getHeight() - 1, getDepth() - 1); - default: - break; - } - - return null; - } - - @Override - public Hunk getSource() - { - return null; - } -} diff --git a/src/main/java/com/volmit/iris/gen/v2/scaffold/BiomeGridHunkView.java b/src/main/java/com/volmit/iris/gen/v2/scaffold/BiomeGridHunkView.java deleted file mode 100644 index 22ea5bbed..000000000 --- a/src/main/java/com/volmit/iris/gen/v2/scaffold/BiomeGridHunkView.java +++ /dev/null @@ -1,156 +0,0 @@ -package com.volmit.iris.gen.v2.scaffold; - -import org.bukkit.block.Biome; -import org.bukkit.generator.ChunkGenerator.BiomeGrid; - -public class BiomeGridHunkView implements Hunk -{ - private final BiomeGrid chunk; - - public BiomeGridHunkView(BiomeGrid chunk) - { - this.chunk = chunk; - } - - @Override - public int getWidth() - { - return 16; - } - - @Override - public int getDepth() - { - return 16; - } - - @Override - public int getHeight() - { - return 256; - } - - @Override - public Hunk croppedView(int x1, int y1, int z1, int x2, int y2, int z2) - { - return new HunkView(this, x2 - x1, y2 - y1, z2 - z1, x1, y1, z1); - } - - @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, Hunk hunk, boolean invertY) - { - if(offX + (hunk.getWidth() - 1) >= getWidth() || offY + (hunk.getHeight() - 1) >= getHeight() || offZ + (hunk.getDepth() - 1) >= getDepth() || offX < 0 || offY < 0 || offZ < 0) - { - throw new RuntimeException("Cannot insert hunk " + hunk.getWidth() + "," + hunk.getHeight() + "," + hunk.getDepth() + " into Hunk " + getWidth() + "," + getHeight() + "," + getDepth() + " with offset " + offZ + "," + offY + "," + offZ); - } - - for(int i = offX; i < offX + hunk.getWidth(); i++) - { - for(int j = offY; j < offY + hunk.getHeight(); j++) - { - for(int k = offZ; k < offZ + hunk.getDepth(); k++) - { - set(i, j, k, hunk.get(i - offX, j - offY, k - offZ)); - } - } - } - } - - @Override - public void set(int x, int y, int z, Biome t) - { - if(x >= getWidth() || y >= getHeight() || z >= getDepth()) - { - throw new RuntimeException(x + " " + y + " " + z + " is out of the bounds 0,0,0 - " + (getWidth() - 1) + "," + (getHeight() - 1) + "," + (getDepth() - 1)); - } - - chunk.setBiome(x, y, z, t); - } - - @Override - public Biome get(int x, int y, int z) - { - if(x >= getWidth() || y >= getHeight() || z >= getDepth()) - { - throw new RuntimeException(x + " " + y + " " + z + " is out of the bounds 0,0,0 - " + (getWidth() - 1) + "," + (getHeight() - 1) + "," + (getDepth() - 1)); - } - - return chunk.getBiome(x, y, z); - } - - @Override - public Biome getClosest(int x, int y, int z) - { - return chunk.getBiome(x >= getWidth() ? getWidth() + 1 : x, y >= getHeight() ? getHeight() - 1 : y, z >= getDepth() ? getDepth() - 1 : z); - } - - @Override - public void fill(Biome t) - { - set(0, 0, 0, getWidth(), getHeight(), getDepth(), t); - } - - @Override - public Hunk getFace(HunkFace f) - { - switch(f) - { - case BOTTOM: - return croppedView(0, 0, 0, getWidth() - 1, 0, getDepth() - 1); - case EAST: - return croppedView(getWidth() - 1, 0, 0, getWidth() - 1, getHeight() - 1, getDepth() - 1); - case NORTH: - return croppedView(0, 0, 0, getWidth() - 1, getHeight() - 1, 0); - case SOUTH: - return croppedView(0, 0, 0, 0, getHeight() - 1, getDepth() - 1); - case TOP: - return croppedView(0, getHeight() - 1, 0, getWidth() - 1, getHeight() - 1, getDepth() - 1); - case WEST: - return croppedView(0, 0, getDepth() - 1, getWidth() - 1, getHeight() - 1, getDepth() - 1); - default: - break; - } - - return null; - } - - @Override - public Hunk getSource() - { - return null; - } - - @Override - public void set(int x1, int y1, int z1, int x2, int y2, int z2, Biome t) - { - for(int i = x1; i <= x2; i++) - { - for(int j = y1; j <= y2; j++) - { - for(int k = z1; k <= z2; k++) - { - set(i, j, k, t); - } - } - } - } -} diff --git a/src/main/java/com/volmit/iris/gen/v2/scaffold/ChunkDataHunkView.java b/src/main/java/com/volmit/iris/gen/v2/scaffold/ChunkDataHunkView.java deleted file mode 100644 index 22c317b69..000000000 --- a/src/main/java/com/volmit/iris/gen/v2/scaffold/ChunkDataHunkView.java +++ /dev/null @@ -1,152 +0,0 @@ -package com.volmit.iris.gen.v2.scaffold; - -import org.bukkit.block.data.BlockData; -import org.bukkit.generator.ChunkGenerator.ChunkData; - -public class ChunkDataHunkView implements Hunk -{ - private final ChunkData chunk; - - public ChunkDataHunkView(ChunkData chunk) - { - this.chunk = chunk; - } - - @Override - public int getWidth() - { - return 16; - } - - @Override - public int getDepth() - { - return 16; - } - - @Override - public int getHeight() - { - return chunk.getMaxHeight(); - } - - @Override - public Hunk croppedView(int x1, int y1, int z1, int x2, int y2, int z2) - { - return new HunkView(this, x2 - x1, y2 - y1, z2 - z1, x1, y1, z1); - } - - @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, Hunk hunk, boolean invertY) - { - if(offX + (hunk.getWidth() - 1) >= getWidth() || offY + (hunk.getHeight() - 1) >= getHeight() || offZ + (hunk.getDepth() - 1) >= getDepth() || offX < 0 || offY < 0 || offZ < 0) - { - throw new RuntimeException("Cannot insert hunk " + hunk.getWidth() + "," + hunk.getHeight() + "," + hunk.getDepth() + " into Hunk " + getWidth() + "," + getHeight() + "," + getDepth() + " with offset " + offZ + "," + offY + "," + offZ); - } - - for(int i = offX; i < offX + hunk.getWidth(); i++) - { - for(int j = offY; j < offY + hunk.getHeight(); j++) - { - for(int k = offZ; k < offZ + hunk.getDepth(); 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, BlockData t) - { - if(x1 >= getWidth() || y1 >= getHeight() || z1 >= getDepth() || x2 >= getWidth() || y2 >= getHeight() || z2 >= getDepth()) - { - throw new RuntimeException(x1 + "-" + x2 + " " + y1 + "-" + y2 + " " + z1 + "-" + z2 + " is out of the bounds 0,0,0 - " + (getWidth() - 1) + "," + (getHeight() - 1) + "," + (getDepth() - 1)); - } - - chunk.setRegion(x1, y1, z1, x2, y2, z2, t); - } - - @Override - public void set(int x, int y, int z, BlockData t) - { - if(x >= getWidth() || y >= getHeight() || z >= getDepth()) - { - throw new RuntimeException(x + " " + y + " " + z + " is out of the bounds 0,0,0 - " + (getWidth() - 1) + "," + (getHeight() - 1) + "," + (getDepth() - 1)); - } - - chunk.setBlock(x, y, z, t); - } - - @Override - public BlockData get(int x, int y, int z) - { - if(x >= getWidth() || y >= getHeight() || z >= getDepth()) - { - throw new RuntimeException(x + " " + y + " " + z + " is out of the bounds 0,0,0 - " + (getWidth() - 1) + "," + (getHeight() - 1) + "," + (getDepth() - 1)); - } - - return chunk.getBlockData(x, y, z); - } - - @Override - public BlockData getClosest(int x, int y, int z) - { - return chunk.getBlockData(x >= getWidth() ? getWidth() + 1 : x, y >= getHeight() ? getHeight() - 1 : y, z >= getDepth() ? getDepth() - 1 : z); - } - - @Override - public void fill(BlockData t) - { - set(0, 0, 0, getWidth(), getHeight(), getDepth(), t); - } - - @Override - public Hunk getFace(HunkFace f) - { - switch(f) - { - case BOTTOM: - return croppedView(0, 0, 0, getWidth() - 1, 0, getDepth() - 1); - case EAST: - return croppedView(getWidth() - 1, 0, 0, getWidth() - 1, getHeight() - 1, getDepth() - 1); - case NORTH: - return croppedView(0, 0, 0, getWidth() - 1, getHeight() - 1, 0); - case SOUTH: - return croppedView(0, 0, 0, 0, getHeight() - 1, getDepth() - 1); - case TOP: - return croppedView(0, getHeight() - 1, 0, getWidth() - 1, getHeight() - 1, getDepth() - 1); - case WEST: - return croppedView(0, 0, getDepth() - 1, getWidth() - 1, getHeight() - 1, getDepth() - 1); - default: - break; - } - - return null; - } - - @Override - public Hunk getSource() - { - return null; - } -} 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 deleted file mode 100644 index ad50c87d4..000000000 --- a/src/main/java/com/volmit/iris/gen/v2/scaffold/Hunk.java +++ /dev/null @@ -1,208 +0,0 @@ -package com.volmit.iris.gen.v2.scaffold; - -import org.bukkit.block.Biome; -import org.bukkit.block.data.BlockData; -import org.bukkit.generator.ChunkGenerator.BiomeGrid; -import org.bukkit.generator.ChunkGenerator.ChunkData; - -public interface Hunk -{ - public static Hunk create(int w, int h, int d) - { - return new ArrayHunk<>(w, h, d); - } - - public static Hunk view(Hunk src) - { - return new HunkView(src); - } - - public static Hunk view(BiomeGrid biome) - { - return new BiomeGridHunkView(biome); - } - - public static Hunk view(ChunkData src) - { - return new ChunkDataHunkView(src); - } - - public Hunk getSource(); - - /** - * @return The X length - */ - public int getWidth(); - - /** - * @return The Z length - */ - public int getDepth(); - - /** - * @return The Y length - */ - public int getHeight(); - - public Hunk getFace(HunkFace f); - - /** - * 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 cropped view of this 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(offX, offY, offZ, 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); -}