|
12 | 12 | import com.ishland.c2me.rewrites.chunksystem.common.fapi.LifecycleEventInvoker; |
13 | 13 | import com.ishland.flowsched.scheduler.ItemHolder; |
14 | 14 | import com.ishland.flowsched.scheduler.KeyStatusPair; |
| 15 | +import it.unimi.dsi.fastutil.shorts.ShortList; |
| 16 | +import it.unimi.dsi.fastutil.shorts.ShortListIterator; |
| 17 | +import net.minecraft.block.BlockState; |
| 18 | +import net.minecraft.block.Blocks; |
15 | 19 | import net.minecraft.entity.EntityType; |
16 | 20 | import net.minecraft.nbt.NbtCompound; |
17 | 21 | import net.minecraft.server.world.ChunkLevels; |
18 | 22 | import net.minecraft.server.world.ServerChunkLoadingManager; |
19 | 23 | import net.minecraft.server.world.ServerWorld; |
| 24 | +import net.minecraft.util.math.BlockPos; |
20 | 25 | import net.minecraft.util.math.ChunkPos; |
| 26 | +import net.minecraft.world.ChunkRegion; |
21 | 27 | import net.minecraft.world.chunk.Chunk; |
| 28 | +import net.minecraft.world.chunk.ChunkGenerationStep; |
| 29 | +import net.minecraft.world.chunk.ChunkGenerationSteps; |
22 | 30 | import net.minecraft.world.chunk.ChunkStatus; |
23 | 31 | import net.minecraft.world.chunk.ProtoChunk; |
24 | 32 | import net.minecraft.world.chunk.WorldChunk; |
@@ -55,6 +63,30 @@ public CompletionStage<Void> upgradeToThis(ChunkLoadingContext context) { |
55 | 63 | final Chunk chunk = context.holder().getItem().get().chunk(); |
56 | 64 | Preconditions.checkState(chunk instanceof ProtoChunk, "Chunk must be a proto chunk"); |
57 | 65 | ProtoChunk protoChunk = (ProtoChunk) chunk; |
| 66 | + { |
| 67 | + ServerWorld serverWorld = ((IThreadedAnvilChunkStorage) context.tacs()).getWorld(); |
| 68 | + ChunkRegion chunkRegion = new ChunkRegion(serverWorld, context.chunks(), ChunkGenerationSteps.GENERATION.get(ChunkStatus.FULL), chunk); |
| 69 | + |
| 70 | + ChunkPos chunkPos = context.holder().getKey(); |
| 71 | + |
| 72 | + ShortList[] postProcessingLists = protoChunk.getPostProcessingLists(); |
| 73 | + for (int i = 0; i < postProcessingLists.length; i++) { |
| 74 | + if (postProcessingLists[i] != null) { |
| 75 | + for (ShortListIterator iterator = postProcessingLists[i].iterator(); iterator.hasNext(); ) { |
| 76 | + short short_ = iterator.nextShort(); |
| 77 | + BlockPos blockPos = ProtoChunk.joinBlockPos(short_, protoChunk.sectionIndexToCoord(i), chunkPos); |
| 78 | + BlockState blockState = protoChunk.getBlockState(blockPos); |
| 79 | + |
| 80 | + if (blockState.getBlock() == Blocks.BROWN_MUSHROOM || blockState.getBlock() == Blocks.RED_MUSHROOM) { |
| 81 | + if (!blockState.canPlaceAt(chunkRegion, blockPos)) { |
| 82 | + protoChunk.setBlockState(blockPos, Blocks.AIR.getDefaultState(), false); // TODO depends on the fact that the chunk system always locks the current chunk |
| 83 | + } |
| 84 | + } |
| 85 | + } |
| 86 | + } |
| 87 | + } |
| 88 | + } |
| 89 | + |
58 | 90 | return CompletableFuture.runAsync(() -> { |
59 | 91 | ServerWorld serverWorld = ((IThreadedAnvilChunkStorage) context.tacs()).getWorld(); |
60 | 92 | final WorldChunk worldChunk = toFullChunk(protoChunk, serverWorld); |
|
0 commit comments