Drop useless palette classes

This commit is contained in:
cyberpwn 2021-09-22 06:25:42 -04:00
parent 7186afda93
commit 125624b09e
3 changed files with 2 additions and 143 deletions

View File

@ -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 <https://www.gnu.org/licenses/>.
*/
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<T> {
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<T> biomeRegistry;
private final T[] biomes;
private final int quartMinY;
private final int quartHeight;
protected ChunkBiomeContainer(IdMap<T> 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<T> registry, int min, int max) {
this(registry, min, max, new int[(1 << WIDTH_BITS + WIDTH_BITS) * ceilDiv(max - min, 4)]);
}
public ChunkBiomeContainer(IdMap<T> 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;
}
}

View File

@ -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 <https://www.gnu.org/licenses/>.
*/
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<T> implements PaletteAccess {
private final PalettedContainer<T> container;
private final Function<T, CompoundTag> reader;
private final Function<CompoundTag, T> 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());
}
}

View File

@ -80,7 +80,9 @@ public class MCALinearPalette<T> implements MCAPalette<T> {
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();
}
}