Lightmap importing + change to view distance fetching
This commit is contained in:
@@ -28,7 +28,7 @@ public class DistanceTracker {
|
||||
this.minYSection = MinecraftClient.getInstance().world.getBottomSectionCoord()/2;
|
||||
this.maxYSection = MinecraftClient.getInstance().world.getTopSectionCoord()/2;
|
||||
|
||||
this.rings[0] = new TransitionRing2D(5, MinecraftClient.getInstance().options.getClampedViewDistance()/2, (x, z)->{
|
||||
this.rings[0] = new TransitionRing2D(5, MinecraftClient.getInstance().options.getViewDistance().getValue()/2, (x, z)->{
|
||||
for (int y = this.minYSection; y <= this.maxYSection; y++) {
|
||||
this.tracker.remLvl0(x, y, z);
|
||||
}
|
||||
|
||||
@@ -8,15 +8,13 @@ import me.cortex.zenith.common.world.WorldEngine;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.nbt.NbtElement;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
import net.minecraft.nbt.NbtOps;
|
||||
import net.minecraft.nbt.*;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.BiomeKeys;
|
||||
import net.minecraft.world.chunk.ChunkNibbleArray;
|
||||
import net.minecraft.world.chunk.PalettedContainer;
|
||||
import net.minecraft.world.chunk.ReadableContainer;
|
||||
import net.minecraft.world.storage.ChunkStreamVersion;
|
||||
@@ -182,6 +180,10 @@ public class WorldImporter {
|
||||
}
|
||||
}
|
||||
|
||||
private static int getIndex(int x, int y, int z) {
|
||||
return y << 8 | z << 4 | x;
|
||||
}
|
||||
|
||||
|
||||
private static final Codec<PalettedContainer<BlockState>> BLOCK_STATE_CODEC = PalettedContainer.createPalettedContainerCodec(Block.STATE_IDS, BlockState.CODEC, PalettedContainer.PaletteProvider.BLOCK_STATE, Blocks.AIR.getDefaultState());
|
||||
private void importSectionNBT(int x, int y, int z, NbtCompound section) {
|
||||
@@ -189,13 +191,41 @@ public class WorldImporter {
|
||||
return;
|
||||
}
|
||||
|
||||
byte[] blockLightData = section.getByteArray("BlockLight");
|
||||
byte[] skyLightData = section.getByteArray("SkyLight");
|
||||
|
||||
ChunkNibbleArray blockLight;
|
||||
if (blockLightData.length != 0) {
|
||||
blockLight = new ChunkNibbleArray(blockLightData);
|
||||
} else {
|
||||
blockLight = null;
|
||||
}
|
||||
|
||||
ChunkNibbleArray skyLight;
|
||||
if (skyLightData.length != 0) {
|
||||
skyLight = new ChunkNibbleArray(skyLightData);
|
||||
} else {
|
||||
skyLight = null;
|
||||
}
|
||||
|
||||
var blockStates = BLOCK_STATE_CODEC.parse(NbtOps.INSTANCE, section.getCompound("block_states")).result().get();
|
||||
var biomes = this.biomeCodec.parse(NbtOps.INSTANCE, section.getCompound("biomes")).result().orElse(null);
|
||||
VoxelizedSection csec = WorldConversionFactory.convert(
|
||||
this.world.getMapper(),
|
||||
blockStates,
|
||||
biomes,
|
||||
(bx, by, bz, state) -> (byte) 0,
|
||||
(bx, by, bz, state) -> {
|
||||
int block = 0;
|
||||
int sky = 0;
|
||||
if (blockLight != null) {
|
||||
block = blockLight.get(bx, by, bz);
|
||||
}
|
||||
if (skyLight != null) {
|
||||
sky = skyLight.get(bx, by, bz);
|
||||
}
|
||||
sky = 15-sky;
|
||||
return (byte) (sky|(block<<4));
|
||||
},
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
|
||||
Reference in New Issue
Block a user