|
2 | 2 |
|
3 | 3 | import com.sonicether.soundphysics.performance.LiquidStorage;
|
4 | 4 | import com.sonicether.soundphysics.performance.WorldChunkAccess;
|
| 5 | +import net.fabricmc.api.EnvType; |
| 6 | +import net.fabricmc.api.Environment; |
5 | 7 | import net.minecraft.block.Block;
|
6 | 8 | import net.minecraft.block.BlockState;
|
7 | 9 | import net.minecraft.client.world.ClientChunkManager;
|
|
16 | 18 | import net.minecraft.world.biome.Biome;
|
17 | 19 | import net.minecraft.world.chunk.*;
|
18 | 20 | import net.minecraft.world.gen.chunk.BlendingData;
|
| 21 | +import net.minecraft.world.tick.ChunkTickScheduler; |
19 | 22 | import org.apache.commons.lang3.ArrayUtils;
|
20 | 23 | import org.jetbrains.annotations.Nullable;
|
21 | 24 | import org.spongepowered.asm.mixin.Final;
|
@@ -43,9 +46,15 @@ public abstract class WorldChunkMixin extends Chunk implements WorldChunkAccess
|
43 | 46 | public WorldChunkMixin(ChunkPos pos, UpgradeData upgradeData, HeightLimitView heightLimitView, Registry<Biome> biome, long inhabitedTime, @Nullable ChunkSection[] sectionArrayInitializer, @Nullable BlendingData blendingData) {
|
44 | 47 | super(pos, upgradeData, heightLimitView, biome, inhabitedTime, sectionArrayInitializer, blendingData);
|
45 | 48 | }
|
| 49 | + |
46 | 50 | @Inject(method = "loadFromPacket(Lnet/minecraft/network/PacketByteBuf;Lnet/minecraft/nbt/NbtCompound;Ljava/util/function/Consumer;)V", at = @At("RETURN"))
|
47 |
| - private void load(PacketByteBuf buf, NbtCompound nbt, Consumer<ChunkData.BlockEntityVisitor> consumer, CallbackInfo ci){ |
48 |
| - if (!world.isClient) return; |
| 51 | + private void load(PacketByteBuf buf, NbtCompound nbt, Consumer<ChunkData.BlockEntityVisitor> consumer, CallbackInfo ci){initStorage();} |
| 52 | + |
| 53 | + @Inject(method = "<init>(Lnet/minecraft/world/World;Lnet/minecraft/util/math/ChunkPos;Lnet/minecraft/world/chunk/UpgradeData;Lnet/minecraft/world/tick/ChunkTickScheduler;Lnet/minecraft/world/tick/ChunkTickScheduler;J[Lnet/minecraft/world/chunk/ChunkSection;Lnet/minecraft/world/chunk/WorldChunk$EntityLoader;Lnet/minecraft/world/gen/chunk/BlendingData;)V", at = @At("RETURN")) |
| 54 | + private void create(World world, ChunkPos pos, UpgradeData upgradeData, ChunkTickScheduler<?> blockTickScheduler, ChunkTickScheduler<?> fluidTickScheduler, long inhabitedTime, ChunkSection[] sectionArrayInitializer, WorldChunk.EntityLoader entityLoader, BlendingData blendingData, CallbackInfo ci){if (sectionArrayInitializer != null) initStorage();} |
| 55 | + |
| 56 | + private void initStorage() { |
| 57 | + if (world == null || !world.isClient) return; |
49 | 58 | ChunkSection[] chunkSections = getSectionArray();
|
50 | 59 | boolean[][] notAirSections = new boolean[512][]; AtomicInteger bottomNotAir = new AtomicInteger(-600); AtomicInteger topNotAir = new AtomicInteger(-600); boolean[] notAirFull = new boolean[512];
|
51 | 60 |
|
|
0 commit comments