mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-08-27 12:41:43 +00:00
few more changes
This commit is contained in:
-82
@@ -859,88 +859,6 @@ public class NMSBinding implements INMSBinding {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean writeChunkNbtDirect(NBTWorld nbtWorld, int chunkX, int chunkZ, Hunk<PlatformBlockState> blocks, Hunk<PlatformBiome> biomes) {
|
||||
try {
|
||||
art.arcane.iris.util.nbt.common.mca.MCAFile mca = nbtWorld.getMCA(chunkX >> 5, chunkZ >> 5);
|
||||
if (mca == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
art.arcane.iris.util.nbt.common.mca.Chunk chunk = art.arcane.iris.util.nbt.common.mca.Chunk.newChunk();
|
||||
art.arcane.iris.util.nbt.common.mca.Chunk.injectIrisData(chunk);
|
||||
|
||||
int blockHeight = blocks.getHeight();
|
||||
java.util.IdentityHashMap<BlockData, CompoundTag> encodeCache = new java.util.IdentityHashMap<>(64);
|
||||
for (int y = 0; y < blockHeight; y++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
for (int x = 0; x < 16; x++) {
|
||||
PlatformBlockState platformState = blocks.getRaw(x, y, z);
|
||||
if (platformState == null) {
|
||||
continue;
|
||||
}
|
||||
Object nativeHandle = platformState.nativeHandle();
|
||||
if (!(nativeHandle instanceof BlockData blockData)) {
|
||||
continue;
|
||||
}
|
||||
if (blockData instanceof IrisCustomData customData) {
|
||||
blockData = customData.getBase();
|
||||
}
|
||||
if (blockData.getMaterial().isAir()) {
|
||||
continue;
|
||||
}
|
||||
CompoundTag nbtState = encodeCache.get(blockData);
|
||||
if (nbtState == null) {
|
||||
nbtState = NBTWorld.getCompound(blockData);
|
||||
if (nbtState == null) {
|
||||
continue;
|
||||
}
|
||||
encodeCache.put(blockData, nbtState);
|
||||
}
|
||||
chunk.setBlockStateAt(x, y, z, nbtState, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int biomeHeight = biomes.getHeight();
|
||||
for (int by = 0; by < biomeHeight; by += 4) {
|
||||
int quartY = by >> 2;
|
||||
for (int bz = 0; bz < 16; bz += 4) {
|
||||
int quartZ = bz >> 2;
|
||||
for (int bx = 0; bx < 16; bx += 4) {
|
||||
int quartX = bx >> 2;
|
||||
PlatformBiome platformBiome = biomes.getRaw(bx, by, bz);
|
||||
if (platformBiome == null) {
|
||||
continue;
|
||||
}
|
||||
String biomeKey = platformBiome.key();
|
||||
if (biomeKey == null || biomeKey.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
int biomeId = getBiomeBaseIdForKey(biomeKey);
|
||||
if (biomeId < 0) {
|
||||
continue;
|
||||
}
|
||||
chunk.setBiomeAt(quartX, quartY, quartZ, biomeId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
chunk.cleanupPalettesAndBlockStates();
|
||||
|
||||
synchronized (mca) {
|
||||
mca.setChunk(chunkX & 31, chunkZ & 31, chunk);
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (Throwable e) {
|
||||
IrisLogging.warn("writeChunkNbtDirect failed at " + chunkX + "," + chunkZ + ": " + e.getClass().getSimpleName() + ": " + e.getMessage());
|
||||
e.printStackTrace(System.err);
|
||||
IrisLogging.reportError(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean forceEvictChunk(World world, int chunkX, int chunkZ) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user