diff --git a/src/main/java/com/volmit/iris/util/data/palette/ChunkBiomeContainer.java b/src/main/java/com/volmit/iris/util/data/palette/ChunkBiomeContainer.java deleted file mode 100644 index 1a25208b7..000000000 --- a/src/main/java/com/volmit/iris/util/data/palette/ChunkBiomeContainer.java +++ /dev/null @@ -1,96 +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; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.util.Arrays; - -public class ChunkBiomeContainer { - private static final Logger LOGGER = LogManager.getLogger(); - private static final int WIDTH_BITS = Mth.ceillog2(16) - 2; - private static final int HORIZONTAL_MASK = (1 << WIDTH_BITS) - 1; - private static final int PACKED_X_LENGTH = 1 + Mth.log2(Mth.smallestEncompassingPowerOfTwo(30000000)); - private static final int PACKED_Z_LENGTH = PACKED_X_LENGTH; - public static final int PACKED_Y_LENGTH = 64 - PACKED_X_LENGTH - PACKED_Z_LENGTH; - public static final int MAX_SIZE = 1 << WIDTH_BITS + WIDTH_BITS + PACKED_Y_LENGTH - 2; - - public final IdMap biomeRegistry; - - private final T[] biomes; - - private final int quartMinY; - - private final int quartHeight; - - protected ChunkBiomeContainer(IdMap registry, int minHeight, int maxHeight, T[] abiomebase) { - this.biomeRegistry = registry; - this.biomes = abiomebase; - this.quartMinY = QuartPos.fromBlock(minHeight); - this.quartHeight = QuartPos.fromBlock(maxHeight) - 1; - } - - public ChunkBiomeContainer(IdMap registry, int min, int max) { - this(registry, min, max, new int[(1 << WIDTH_BITS + WIDTH_BITS) * ceilDiv(max - min, 4)]); - } - - public ChunkBiomeContainer(IdMap registry, int minHeight, int maxHeight, int[] aint) { - this(registry, minHeight, maxHeight, (T[]) new Object[aint.length]); - int i = -1; - for (int j = 0; j < this.biomes.length; j++) { - int k = aint[j]; - T biomebase = registry.byId(k); - if (biomebase == null) { - if (i == -1) - i = j; - this.biomes[j] = registry.byId(0); - } else { - this.biomes[j] = biomebase; - } - } - if (i != -1) - LOGGER.warn("Invalid biome data received, starting from {}: {}", Integer.valueOf(i), Arrays.toString(aint)); - } - - private static int ceilDiv(int i, int j) { - return (i + j - 1) / j; - } - - public int[] writeBiomes() { - int[] aint = new int[this.biomes.length]; - for (int i = 0; i < this.biomes.length; i++) - aint[i] = this.biomeRegistry.getId(this.biomes[i]); - return aint; - } - - public T getBiome(int i, int j, int k) { - int l = i & HORIZONTAL_MASK; - int i1 = Mth.clamp(j - this.quartMinY, 0, this.quartHeight); - int j1 = k & HORIZONTAL_MASK; - return this.biomes[i1 << WIDTH_BITS + WIDTH_BITS | j1 << WIDTH_BITS | l]; - } - - public void setBiome(int i, int j, int k, T biome) { - int l = i & HORIZONTAL_MASK; - int i1 = Mth.clamp(j - this.quartMinY, 0, this.quartHeight); - int j1 = k & HORIZONTAL_MASK; - this.biomes[i1 << WIDTH_BITS + WIDTH_BITS | j1 << WIDTH_BITS | l] = biome; - } -} \ No newline at end of file diff --git a/src/main/java/com/volmit/iris/util/data/palette/WrappedPalettedContainer.java b/src/main/java/com/volmit/iris/util/data/palette/WrappedPalettedContainer.java deleted file mode 100644 index be57b3aaf..000000000 --- a/src/main/java/com/volmit/iris/util/data/palette/WrappedPalettedContainer.java +++ /dev/null @@ -1,47 +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; - -import com.volmit.iris.util.nbt.tag.CompoundTag; -import lombok.RequiredArgsConstructor; - -import java.util.function.Function; - -@RequiredArgsConstructor -public class WrappedPalettedContainer implements PaletteAccess { - private final PalettedContainer container; - private final Function reader; - private final Function writer; - - public void setBlock(int x, int y, int z, CompoundTag data) { - container.set(x, y, z, writer.apply(data)); - } - - public CompoundTag getBlock(int x, int y, int z) { - return reader.apply(container.get(x, y, z)); - } - - public void writeToSection(CompoundTag tag) { - container.write(tag, "Palette", "BlockStates"); - } - - public void readFromSection(CompoundTag tag) { - container.read(tag.getListTag("Palette"), tag.getLongArrayTag("BlockStates").getValue()); - } -} diff --git a/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCALinearPalette.java b/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCALinearPalette.java index 9433910a1..836daf3e5 100644 --- a/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCALinearPalette.java +++ b/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCALinearPalette.java @@ -80,7 +80,9 @@ public class MCALinearPalette implements MCAPalette { public void read(ListTag var0) { for (int var1 = 0; var1 < var0.size(); var1++) + { this.values[var1] = this.reader.apply((CompoundTag) var0.get(var1)); + } this.size = var0.size(); } }