diff --git a/src/main/java/com/volmit/iris/util/hunk/storage/PaletteOrHunk.java b/src/main/java/com/volmit/iris/util/hunk/storage/PaletteOrHunk.java new file mode 100644 index 000000000..955d0c109 --- /dev/null +++ b/src/main/java/com/volmit/iris/util/hunk/storage/PaletteOrHunk.java @@ -0,0 +1,74 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2021 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.volmit.iris.util.hunk.storage; + +import com.volmit.iris.util.function.Consumer4; +import com.volmit.iris.util.function.Consumer4IO; +import com.volmit.iris.util.hunk.Hunk; + +import java.io.IOException; +import java.util.Map; +import java.util.function.Supplier; + +public class PaletteOrHunk extends StorageHunk implements Hunk { + private final Hunk hunk; + public PaletteOrHunk(int width, int height, int depth, Supplier> factory) { + super(width, height, depth); + hunk = width == 16 && height == 16 && depth == 16 ? new PaletteHunk<>() : factory.get(); + } + + @Override + public void setRaw(int x, int y, int z, T t) { + hunk.setRaw(x,y,z,t); + } + + @Override + public T getRaw(int x, int y, int z) { + return hunk.getRaw(x,y,z); + } + + public int getEntryCount() { + return hunk.getEntryCount(); + } + + public boolean isMapped() { + return hunk.isMapped(); + } + + public boolean isEmpty() { + return hunk.isMapped(); + } + + @Override + public synchronized Hunk iterateSync(Consumer4 c) { + hunk.iterateSync(c); + return this; + } + + @Override + public synchronized Hunk iterateSyncIO(Consumer4IO c) throws IOException { + hunk.iterateSyncIO(c); + return this; + } + + @Override + public void empty(T b) { + hunk.empty(b); + } +}