Not worth,

This commit is contained in:
cyberpwn
2021-09-22 08:54:38 -04:00
parent 3c256ddc5d
commit 7f58e0413c
12 changed files with 223 additions and 7 deletions

View File

@@ -44,6 +44,44 @@ public class PaletteHunk<T> extends StorageHunk<T> implements Hunk<T> {
return false;
}
@Override
public synchronized Hunk<T> iterateSync(Consumer4<Integer, Integer, Integer, T> c) {
for(int i = 0; i < getWidth(); i++)
{
for(int j = 0; j < getHeight(); j++)
{
for(int k = 0; k < getDepth(); k++)
{
T t = getRaw(i,j,k);
if(t != null)
{
c.accept(i,j,k,t);
}
}
}
}
return this;
}
@Override
public synchronized Hunk<T> iterateSyncIO(Consumer4IO<Integer, Integer, Integer, T> c) throws IOException {
for(int i = 0; i < getWidth(); i++)
{
for(int j = 0; j < getHeight(); j++)
{
for(int k = 0; k < getDepth(); k++)
{
T t = getRaw(i,j,k);
if(t != null)
{
c.accept(i,j,k,t);
}
}
}
}
return this;
}
@Override
public void setRaw(int x, int y, int z, T t) {
data.set(x,y,z,t);

View File

@@ -18,6 +18,7 @@
package com.volmit.iris.util.hunk.storage;
import com.volmit.iris.util.data.palette.PalettedContainer;
import com.volmit.iris.util.function.Consumer4;
import com.volmit.iris.util.function.Consumer4IO;
import com.volmit.iris.util.hunk.Hunk;
@@ -33,6 +34,23 @@ public class PaletteOrHunk<T> extends StorageHunk<T> implements Hunk<T> {
hunk = width == 16 && height == 16 && depth == 16 ? new PaletteHunk<>() : factory.get();
}
public PalettedContainer<T> palette()
{
return isPalette() ? ((PaletteHunk<T>)hunk).getData() : null;
}
public void palette(PalettedContainer<T> t)
{
if(isPalette()){
((PaletteHunk<T>)hunk).setData(t);
}
}
public boolean isPalette()
{
return getWidth() == 16 && getHeight() == 16 && getDepth() == 16;
}
@Override
public void setRaw(int x, int y, int z, T t) {
hunk.setRaw(x,y,z,t);