diff --git a/src/main/java/com/volmit/iris/util/data/palette/BiomeContainer.java b/src/main/java/com/volmit/iris/util/data/palette/BiomeContainer.java deleted file mode 100644 index c34b667e4..000000000 --- a/src/main/java/com/volmit/iris/util/data/palette/BiomeContainer.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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.data.palette; - -public interface BiomeContainer { - int[] getData(); - - void setBiome(int x, int y, int z, int id); - - int getBiome(int x, int y, int z); -} diff --git a/src/main/java/com/volmit/iris/util/data/palette/PaletteType.java b/src/main/java/com/volmit/iris/util/data/palette/PaletteType.java new file mode 100644 index 000000000..cd908e021 --- /dev/null +++ b/src/main/java/com/volmit/iris/util/data/palette/PaletteType.java @@ -0,0 +1,52 @@ +/* + * 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.data.palette; + +import com.volmit.iris.util.data.Varint; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +public interface PaletteType { + void writePaletteNode(DataOutputStream dos, T t) throws IOException; + + T readPaletteNode(DataInputStream din) throws IOException; + + default void writeList(DataOutputStream dos, List list) throws IOException { + Varint.writeUnsignedVarInt(list.size(), dos); + for (T i : list) { + writePaletteNode(dos, i); + } + } + + default List readList(DataInputStream din) throws IOException { + int v = Varint.readUnsignedVarInt(din); + List t = new ArrayList<>(); + + for(int i = 0; i < v; i++) + { + t.add(readPaletteNode(din)); + } + + return t; + } +}