From 33f5772ecd3120c1ffee3953264ba741d1e8d412 Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Tue, 25 Mar 2025 00:16:16 +1000 Subject: [PATCH] Add global index pallet --- .../voxelization/WorldConversionFactory.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/me/cortex/voxy/common/voxelization/WorldConversionFactory.java b/src/main/java/me/cortex/voxy/common/voxelization/WorldConversionFactory.java index 7d378785..099e359e 100644 --- a/src/main/java/me/cortex/voxy/common/voxelization/WorldConversionFactory.java +++ b/src/main/java/me/cortex/voxy/common/voxelization/WorldConversionFactory.java @@ -123,9 +123,13 @@ public class WorldConversionFactory { var vp = blockContainer.data.palette; var pc = cache.getPaletteCache(vp.getSize()); + IdListPalette bps = null; - setupLocalPalette(vp, blockCache, stateMapper, pc); - + if (blockContainer.data.palette instanceof IdListPalette _bps) { + bps = _bps; + } else { + setupLocalPalette(vp, blockCache, stateMapper, pc); + } { int i = 0; @@ -138,7 +142,8 @@ public class WorldConversionFactory { } } - //TODO: EmptyPaletteStorage (it only refs idx 0) + + if (blockContainer.data.storage instanceof PackedIntegerArray bStor) { var bDat = bStor.getData(); int iterPerLong = (64 / bStor.getElementBits()) - 1; @@ -156,7 +161,12 @@ public class WorldConversionFactory { sample = bDat[c++]; dec = iterPerLong; } - int bId = pc[(int) (sample & MSK)]; + int bId; + if (bps == null) { + bId = pc[(int) (sample & MSK)]; + } else { + bId = stateMapper.getIdForBlockState(bps.get((int) (sample&MSK))); + } sample >>>= eBits; byte light = lightSupplier.supply(x, y, z);