Skip to content

Commit 79ecbbf

Browse files
committed
Potentially fixed air storage for bobby
1 parent 37f61f5 commit 79ecbbf

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/main/java/com/sonicether/soundphysics/mixin/WorldChunkMixin.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import com.sonicether.soundphysics.performance.LiquidStorage;
44
import com.sonicether.soundphysics.performance.WorldChunkAccess;
5+
import net.fabricmc.api.EnvType;
6+
import net.fabricmc.api.Environment;
57
import net.minecraft.block.Block;
68
import net.minecraft.block.BlockState;
79
import net.minecraft.client.world.ClientChunkManager;
@@ -16,6 +18,7 @@
1618
import net.minecraft.world.biome.Biome;
1719
import net.minecraft.world.chunk.*;
1820
import net.minecraft.world.gen.chunk.BlendingData;
21+
import net.minecraft.world.tick.ChunkTickScheduler;
1922
import org.apache.commons.lang3.ArrayUtils;
2023
import org.jetbrains.annotations.Nullable;
2124
import org.spongepowered.asm.mixin.Final;
@@ -43,9 +46,15 @@ public abstract class WorldChunkMixin extends Chunk implements WorldChunkAccess
4346
public WorldChunkMixin(ChunkPos pos, UpgradeData upgradeData, HeightLimitView heightLimitView, Registry<Biome> biome, long inhabitedTime, @Nullable ChunkSection[] sectionArrayInitializer, @Nullable BlendingData blendingData) {
4447
super(pos, upgradeData, heightLimitView, biome, inhabitedTime, sectionArrayInitializer, blendingData);
4548
}
49+
4650
@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;
4958
ChunkSection[] chunkSections = getSectionArray();
5059
boolean[][] notAirSections = new boolean[512][]; AtomicInteger bottomNotAir = new AtomicInteger(-600); AtomicInteger topNotAir = new AtomicInteger(-600); boolean[] notAirFull = new boolean[512];
5160

0 commit comments

Comments
 (0)