Skip to content

Commit ec0f274

Browse files
committed
build: 25w36a
1 parent 3f6fbfc commit ec0f274

File tree

3 files changed

+17
-132
lines changed

3 files changed

+17
-132
lines changed

c2me-rewrites-chunk-serializer/src/main/java/com/ishland/c2me/rewrites/chunk_serializer/common/ChunkDataSerializer.java

Lines changed: 12 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
package com.ishland.c2me.rewrites.chunk_serializer.common;
22

33
import com.ishland.c2me.base.mixin.access.IBelowZeroRetrogen;
4-
import com.ishland.c2me.base.mixin.access.IChunkTickScheduler;
5-
import com.ishland.c2me.base.mixin.access.ISimpleTickScheduler;
64
import com.ishland.c2me.base.mixin.access.IState;
75
import com.ishland.c2me.base.mixin.access.IStructurePiece;
86
import com.ishland.c2me.base.mixin.access.IStructureStart;
9-
import com.ishland.c2me.base.mixin.access.IUpgradeData;
10-
import com.ishland.c2me.rewrites.chunk_serializer.common.utils.LithiumUtil;
11-
import com.ishland.c2me.rewrites.chunk_serializer.common.utils.StarLightUtil;
127
import com.mojang.serialization.Codec;
138
import it.unimi.dsi.fastutil.longs.LongSet;
149
import it.unimi.dsi.fastutil.shorts.ShortList;
@@ -17,6 +12,7 @@
1712
import net.minecraft.block.Block;
1813
import net.minecraft.block.BlockState;
1914
import net.minecraft.block.Blocks;
15+
import net.minecraft.class_11897;
2016
import net.minecraft.nbt.NbtCompound;
2117
import net.minecraft.nbt.NbtElement;
2218
import net.minecraft.nbt.NbtList;
@@ -37,17 +33,14 @@
3733
import net.minecraft.util.math.BlockPos;
3834
import net.minecraft.util.math.ChunkPos;
3935
import net.minecraft.util.math.Direction;
40-
import net.minecraft.util.math.EightWayDirection;
4136
import net.minecraft.world.Heightmap;
4237
import net.minecraft.world.biome.Biome;
4338
import net.minecraft.world.biome.BiomeKeys;
4439
import net.minecraft.world.chunk.BelowZeroRetrogen;
4540
import net.minecraft.world.chunk.Chunk;
46-
import net.minecraft.world.chunk.ChunkStatus;
4741
import net.minecraft.world.chunk.ChunkType;
4842
import net.minecraft.world.chunk.PalettedContainer;
4943
import net.minecraft.world.chunk.ReadableContainer;
50-
import net.minecraft.world.chunk.ReadableContainer.Serialized;
5144
import net.minecraft.world.chunk.SerializedChunk;
5245
import net.minecraft.world.chunk.UpgradeData;
5346
import net.minecraft.world.gen.chunk.BlendingData;
@@ -60,13 +53,10 @@
6053
import org.apache.logging.log4j.LogManager;
6154
import org.apache.logging.log4j.Logger;
6255
import org.jetbrains.annotations.Contract;
63-
import org.jetbrains.annotations.Nullable;
6456

6557
import java.util.BitSet;
66-
import java.util.Collection;
6758
import java.util.List;
6859
import java.util.Map;
69-
import java.util.Map.Entry;
7060
import java.util.Optional;
7161
import java.util.function.Function;
7262
import java.util.stream.LongStream;
@@ -193,11 +183,11 @@ public static void write(SerializedChunk serializable, NbtWriter writer) {
193183

194184
List<SerializedChunk.SectionData> sectionData = serializable.sectionData();
195185

196-
Registry<Biome> biomeRegistry = serializable.biomeRegistry();
186+
class_11897 containerFactory = serializable.containerFactory();
197187

198188
checkLightFlag(serializable.lightCorrect(), writer);
199189

200-
writeSectionData(writer, chunkPos, sectionData, biomeRegistry);
190+
writeSectionData(writer, chunkPos, sectionData, containerFactory);
201191

202192

203193
writer.startFixedList(STRING_BLOCK_ENTITIES, serializable.blockEntities().size(), NbtElement.COMPOUND_TYPE);
@@ -271,13 +261,9 @@ private static void writeSectionData(
271261
NbtWriter writer,
272262
ChunkPos chunkPos,
273263
List<SerializedChunk.SectionData> sectionData,
274-
Registry<Biome> biomeRegistry
264+
class_11897 containerFactory
275265
) {
276-
// if (STARLIGHT) {
277-
// writeSectionDataStarlight(writer, chunkPos, sectionData, biomeRegistry);
278-
// } else {
279-
writeSectionDataVanilla(writer, chunkPos, sectionData, biomeRegistry);
280-
// }
266+
writeSectionDataVanilla(writer, chunkPos, sectionData, containerFactory);
281267
}
282268

283269
/**
@@ -287,7 +273,7 @@ private static void writeSectionDataVanilla(
287273
NbtWriter writer,
288274
ChunkPos chunkPos,
289275
List<SerializedChunk.SectionData> sectionData,
290-
Registry<Biome> biomeRegistry
276+
class_11897 containerFactory
291277
) {
292278
long sectionsStart = writer.startList(STRING_SECTIONS, NbtElement.COMPOUND_TYPE);
293279
int sectionCount = 0;
@@ -301,8 +287,8 @@ private static void writeSectionDataVanilla(
301287
writer.compoundEntryStart();
302288
}
303289

304-
writeBlockStates(writer, sectionDatum.chunkSection().getBlockStateContainer());
305-
writeBiomes(writer, sectionDatum.chunkSection().getBiomeContainer(), biomeRegistry);
290+
writeBlockStates(writer, sectionDatum.chunkSection().getBlockStateContainer(), containerFactory);
291+
writeBiomes(writer, sectionDatum.chunkSection().getBiomeContainer(), containerFactory);
306292
}
307293

308294
if (sectionDatum.blockLight() != null) {
@@ -333,103 +319,6 @@ private static void writeSectionDataVanilla(
333319
writer.finishList(sectionsStart, sectionCount);
334320
}
335321

336-
// /**
337-
// * Mirror section of {@link ChunkSerializer#serialize(ServerWorld, Chunk)}
338-
// * with the changes by StarLight applied inline
339-
// */
340-
// private static void writeSectionDataStarlight(
341-
// NbtWriter writer,
342-
// ChunkPos chunkPos,
343-
// List<ChunkSerializer.SectionData> sectionData,
344-
// Registry<Biome> biomeRegistry
345-
// ) {
346-
// // START DIFF
347-
// boolean lit = chunk.isLightOn();
348-
// ChunkStatus status = chunk.getStatus();
349-
// boolean shouldWrite = lit && status.isAtLeast(ChunkStatus.LIGHT);
350-
// var blockNibbles = StarLightUtil.getBlockNibbles(chunk);
351-
// var skyNibbles = StarLightUtil.getSkyNibbles(chunk);
352-
// int minSection;
353-
// // END DIFF
354-
//
355-
// long sectionsStart = writer.startList(STRING_SECTIONS, NbtElement.COMPOUND_TYPE);
356-
// int sectionCount = 0;
357-
//
358-
// for (int i = minSection = lightingProvider.getBottomY(); i < lightingProvider.getTopY(); ++i) {
359-
// int index = chunk.sectionCoordToIndex(i);
360-
// boolean bl2 = index >= 0 && index < chunkSections.length;
361-
//
362-
// // START DIFF
363-
////
364-
//// ChunkNibbleArray blockLight = lightingProvider.get(LightType.BLOCK)
365-
//// .getLightSection(ChunkSectionPos.from(chunkPos, i));
366-
//// ChunkNibbleArray skyLight = lightingProvider.get(LightType.SKY)
367-
//// .getLightSection(ChunkSectionPos.from(chunkPos, i));
368-
//
369-
// var blockNibble = shouldWrite ? StarLightUtil.getSaveState(blockNibbles[i - minSection]) : null;
370-
// var skyNibble = shouldWrite ? StarLightUtil.getSaveState(skyNibbles[i - minSection]) : null;
371-
//
372-
// if (bl2 || blockNibble != null || skyNibble != null) {
373-
// // END DIFF
374-
// boolean hasInner = false;
375-
// if (bl2) {
376-
// hasInner = true;
377-
// writer.compoundEntryStart();
378-
// IChunkSection chunkSection = chunkSections[index];
379-
//
380-
// writeBlockStates(writer, chunkSection.getBlockStateContainer());
381-
// writeBiomes(writer, chunkSection.getBiomeContainer(), biomeRegistry);
382-
// }
383-
//
384-
// // START DIFF
385-
//// if (blockLight != null && !blockLight.isUninitialized()) {
386-
//// if (!hasInner) {
387-
//// writer.compoundEntryStart();
388-
//// hasInner = true;
389-
//// }
390-
//// writer.putByteArray(STRING_BLOCK_LIGHT, blockLight.asByteArray());
391-
//// }
392-
//
393-
//// if (skyLight != null && !skyLight.isUninitialized()) {
394-
//// if (!hasInner) {
395-
//// writer.compoundEntryStart();
396-
//// hasInner = true;
397-
//// }
398-
//// writer.putByteArray(STRING_SKY_LIGHT, skyLight.asByteArray());
399-
//// }
400-
//
401-
// if (blockNibble != null) {
402-
// if (blockNibble.getData() != null) {
403-
// writer.putByteArray(STRING_BLOCK_LIGHT, blockNibble.getData());
404-
// }
405-
// writer.putInt(STRING_BLOCKLIGHT_STATE_TAG, blockNibble.getState());
406-
// }
407-
//
408-
// if (skyNibble != null) {
409-
// if (skyNibble.getData() != null) {
410-
// writer.putByteArray(STRING_SKY_LIGHT, skyNibble.getData());
411-
// }
412-
// writer.putInt(STRING_SKYLIGHT_STATE_TAG, skyNibble.getState());
413-
// }
414-
//
415-
// // END DIFF
416-
//
417-
//
418-
// if (hasInner) {
419-
// writer.putByte(STRING_CHAR_BIG_Y, (byte) i);
420-
// writer.finishCompound();
421-
// sectionCount++;
422-
// }
423-
// }
424-
// }
425-
//
426-
// writer.finishList(sectionsStart, sectionCount);
427-
//
428-
// if (lit) {
429-
// writer.putInt(STRING_STARLIGHT_VERSION_TAG, STARLIGHT_LIGHT_VERSION);
430-
// }
431-
// }
432-
433322
/**
434323
* mirror of {@link SerializedChunk#CODEC}
435324
* created by {@link PalettedContainer#createPalettedContainerCodec(IndexedIterable, Codec, PalettedContainer.PaletteProvider, Object)}
@@ -439,13 +328,11 @@ private static void writeSectionDataVanilla(
439328
* {@link Blocks#AIR}{@code .getDefaultState()} as defaultValue
440329
*/
441330
@SuppressWarnings("unchecked")
442-
private static void writeBlockStates(NbtWriter writer, PalettedContainer<BlockState> blockStateContainer) {
331+
private static void writeBlockStates(NbtWriter writer, PalettedContainer<BlockState> blockStateContainer, class_11897 containerFactory) {
443332
writer.startCompound(STRING_BLOCK_STATES);
444333
// todo can this be optimized?
445334
// todo: does this conflict with lithium by any chance?
446-
var data = blockStateContainer.serialize(
447-
Block.STATE_IDS,
448-
PalettedContainer.PaletteProvider.BLOCK_STATE);
335+
var data = blockStateContainer.serialize(containerFactory.blockStatesStrategy());
449336

450337
List<BlockState> paletteEntries = data.paletteEntries();
451338
writer.startFixedList(STRING_PALETTE, paletteEntries.size(), NbtElement.COMPOUND_TYPE);
@@ -478,13 +365,11 @@ private static void writeBlockStates(NbtWriter writer, PalettedContainer<BlockSt
478365
* {@link PalettedContainer.PaletteProvider#BIOME} as paletteProvider,
479366
* {@link BiomeKeys#PLAINS} as defaultValue
480367
*/
481-
private static void writeBiomes(NbtWriter writer, ReadableContainer<RegistryEntry<Biome>> biomeContainer, Registry<Biome> biomeRegistry) {
368+
private static void writeBiomes(NbtWriter writer, ReadableContainer<RegistryEntry<Biome>> biomeContainer, class_11897 containerFactory) {
482369
writer.startCompound(STRING_BIOMES);
483370
// todo can this be optimized?
484371
// todo: does this conflict with lithium by any chance?
485-
var data = biomeContainer.serialize(
486-
biomeRegistry.getIndexedEntries(),
487-
PalettedContainer.PaletteProvider.BIOME);
372+
var data = biomeContainer.serialize(containerFactory.biomeStrategy());
488373

489374
List<RegistryEntry<Biome>> paletteEntries = data.paletteEntries();
490375
writer.startFixedList(STRING_PALETTE, paletteEntries.size(), NbtElement.STRING_TYPE);

c2me-rewrites-chunk-system/src/main/java/com/ishland/c2me/rewrites/chunksystem/common/statuses/ReadFromDisk.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public CompletionStage<Void> upgradeToThis(ChunkLoadingContext context, Cancella
114114
final ServerWorld world = ((IThreadedAnvilChunkStorage) context.tacs()).getWorld();
115115
// blending
116116
final ChunkPos pos = context.holder().getKey();
117-
protoChunk = protoChunk != null ? protoChunk : new ProtoChunk(pos, UpgradeData.NO_UPGRADE_DATA, world, world.getRegistryManager().getOrThrow(RegistryKeys.BIOME), null);
117+
protoChunk = protoChunk != null ? protoChunk : new ProtoChunk(pos, UpgradeData.NO_UPGRADE_DATA, world, world.method_74142(), null);
118118
if (protoChunk.getBelowZeroRetrogen() != null || protoChunk.getStatus().getChunkType() == ChunkType.PROTOCHUNK) {
119119
ProtoChunk finalProtoChunk = protoChunk;
120120
return Single.defer(() -> Single.fromCompletionStage(BlendingInfoUtil.getBlendingInfos(((IVersionedChunkStorage) context.tacs()).getWorker(), pos)))
@@ -131,7 +131,7 @@ public CompletionStage<Void> upgradeToThis(ChunkLoadingContext context, Cancella
131131
.map(optional -> optional.map(nbtCompound -> {
132132
try (var ignored = ThreadInstrumentation.getCurrent().begin(new ChunkTaskWork(context, this, true))) {
133133
ServerWorld world = ((IThreadedAnvilChunkStorage) context.tacs()).getWorld();
134-
SerializedChunk chunkSerializer = SerializedChunk.fromNbt(world, world.getRegistryManager(), nbtCompound);
134+
SerializedChunk chunkSerializer = SerializedChunk.fromNbt(world, world.method_74142(), nbtCompound);
135135
if (chunkSerializer == null) {
136136
LOGGER.error("Chunk file at {} is missing level data, skipping", context.holder().getKey());
137137
}
@@ -148,7 +148,7 @@ public CompletionStage<Void> upgradeToThis(ChunkLoadingContext context, Cancella
148148
protected @NotNull ProtoChunk createEmptyProtoChunk(ChunkLoadingContext context) {
149149
try (var ignored = ThreadInstrumentation.getCurrent().begin(new ChunkTaskWork(context, this, true))) {
150150
final ServerWorld world = ((IThreadedAnvilChunkStorage) context.tacs()).getWorld();
151-
return new ProtoChunk(context.holder().getKey(), UpgradeData.NO_UPGRADE_DATA, world, world.getRegistryManager().getOrThrow(RegistryKeys.BIOME), null);
151+
return new ProtoChunk(context.holder().getKey(), UpgradeData.NO_UPGRADE_DATA, world, world.method_74142(), null);
152152
}
153153
}
154154

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ org.gradle.warning.mode=all
55
#org.gradle.configuration-cache=true
66
# Fabric Properties
77
# check these on https://fabricmc.net/versions.html
8-
minecraft_version=25w35a
9-
yarn_mappings=25w35a+build.1
8+
minecraft_version=25w36a
9+
yarn_mappings=25w36a+build.1
1010
loader_version=0.17.2
1111
fabric_version=0.132.0+1.21.9
1212
# Mod Properties

0 commit comments

Comments
 (0)