mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-19 10:43:14 +00:00
Old crap removed
This commit is contained in:
parent
0dd45cdfa2
commit
1306a5bca1
@ -1,323 +0,0 @@
|
|||||||
package com.volmit.iris.gen.v2.scaffold;
|
|
||||||
|
|
||||||
import org.bouncycastle.util.Arrays;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class ArrayHunk<T> implements Hunk<T>
|
|
||||||
{
|
|
||||||
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<T> croppedView(int x1, int y1, int z1, int x2, int y2, int z2)
|
|
||||||
{
|
|
||||||
return new HunkView<T>(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<T> crop(int x1, int y1, int z1, int x2, int y2, int z2)
|
|
||||||
{
|
|
||||||
ArrayHunk<T> h = new ArrayHunk<T>(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<T> hunk)
|
|
||||||
{
|
|
||||||
insert(offX, offY, offZ, hunk, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Insert a hunk into this one
|
|
||||||
*
|
|
||||||
* @param hunk
|
|
||||||
* the hunk to insert
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void insert(Hunk<T> 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<T> 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<T> 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 <T> ArrayHunk<T> combined(ArrayHunk<T>... hunks)
|
|
||||||
{
|
|
||||||
int w = 0;
|
|
||||||
int h = 0;
|
|
||||||
int d = 0;
|
|
||||||
|
|
||||||
for(ArrayHunk<T> i : hunks)
|
|
||||||
{
|
|
||||||
w = Math.max(w, i.getW());
|
|
||||||
h = Math.max(h, i.getH());
|
|
||||||
d = Math.max(d, i.getD());
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayHunk<T> b = new ArrayHunk<T>(w, h, d);
|
|
||||||
|
|
||||||
for(ArrayHunk<T> 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<T> 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<T> getSource()
|
|
||||||
{
|
|
||||||
return 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<Biome>
|
|
||||||
{
|
|
||||||
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<Biome> croppedView(int x1, int y1, int z1, int x2, int y2, int z2)
|
|
||||||
{
|
|
||||||
return new HunkView<Biome>(this, x2 - x1, y2 - y1, z2 - z1, x1, y1, z1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ArrayHunk<Biome> crop(int x1, int y1, int z1, int x2, int y2, int z2)
|
|
||||||
{
|
|
||||||
ArrayHunk<Biome> h = new ArrayHunk<Biome>(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<Biome> 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<Biome> 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<Biome> 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<BlockData>
|
|
||||||
{
|
|
||||||
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<BlockData> croppedView(int x1, int y1, int z1, int x2, int y2, int z2)
|
|
||||||
{
|
|
||||||
return new HunkView<BlockData>(this, x2 - x1, y2 - y1, z2 - z1, x1, y1, z1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ArrayHunk<BlockData> crop(int x1, int y1, int z1, int x2, int y2, int z2)
|
|
||||||
{
|
|
||||||
ArrayHunk<BlockData> h = new ArrayHunk<BlockData>(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<BlockData> 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<BlockData> 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<BlockData> getSource()
|
|
||||||
{
|
|
||||||
return 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<T>
|
|
||||||
{
|
|
||||||
public static <T> Hunk<T> create(int w, int h, int d)
|
|
||||||
{
|
|
||||||
return new ArrayHunk<>(w, h, d);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> Hunk<T> view(Hunk<T> src)
|
|
||||||
{
|
|
||||||
return new HunkView<T>(src);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Hunk<Biome> view(BiomeGrid biome)
|
|
||||||
{
|
|
||||||
return new BiomeGridHunkView(biome);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Hunk<BlockData> view(ChunkData src)
|
|
||||||
{
|
|
||||||
return new ChunkDataHunkView(src);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Hunk<T> getSource();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return The X length
|
|
||||||
*/
|
|
||||||
public int getWidth();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return The Z length
|
|
||||||
*/
|
|
||||||
public int getDepth();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return The Y length
|
|
||||||
*/
|
|
||||||
public int getHeight();
|
|
||||||
|
|
||||||
public Hunk<T> 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<T> 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<T> 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<T> hunk)
|
|
||||||
{
|
|
||||||
insert(offX, offY, offZ, hunk, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Insert a hunk into this one
|
|
||||||
*
|
|
||||||
* @param hunk
|
|
||||||
* the hunk to insert
|
|
||||||
*/
|
|
||||||
default void insert(Hunk<T> 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<T> 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<T> 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);
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user