Skip to content

Commit

Permalink
fix new-chunks crash with sodium (#366)
Browse files Browse the repository at this point in the history
  • Loading branch information
cqb13 authored Jul 1, 2024
1 parent 164b6a1 commit f5c8bdc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/anticope/rejects/modules/NewChunks.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

/*
Ported from: https://github.com/BleachDrinker420/BleachHack/blob/master/BleachHack-Fabric-1.16/src/main/java/bleach/hack/module/mods/NewChunks.java
Expand Down Expand Up @@ -93,6 +95,7 @@ public class NewChunks extends Module {
private final Set<ChunkPos> newChunks = Collections.synchronizedSet(new HashSet<>());
private final Set<ChunkPos> oldChunks = Collections.synchronizedSet(new HashSet<>());
private static final Direction[] searchDirs = new Direction[] { Direction.EAST, Direction.NORTH, Direction.WEST, Direction.SOUTH, Direction.UP };
private final Executor taskExecutor = Executors.newSingleThreadExecutor();

public NewChunks() {
super(MeteorRejectsAddon.CATEGORY,"new-chunks", "Detects completely new chunks using certain traits of them");
Expand Down Expand Up @@ -177,7 +180,7 @@ else if (event.packet instanceof ChunkDataS2CPacket && mc.world != null) {
if (!newChunks.contains(pos) && mc.world.getChunkManager().getChunk(packet.getChunkX(), packet.getChunkZ()) == null) {
WorldChunk chunk = new WorldChunk(mc.world, pos);
try {
chunk.loadFromPacket(packet.getChunkData().getSectionsDataBuf(), new NbtCompound(), packet.getChunkData().getBlockEntities(packet.getChunkX(), packet.getChunkZ()));
taskExecutor.execute(() -> chunk.loadFromPacket(packet.getChunkData().getSectionsDataBuf(), new NbtCompound(), packet.getChunkData().getBlockEntities(packet.getChunkX(), packet.getChunkZ())));
} catch (ArrayIndexOutOfBoundsException e) {
return;
}
Expand Down

0 comments on commit f5c8bdc

Please sign in to comment.