diff --git a/server/src/main/java/org/allaymc/server/world/chunk/AllayChunk.java b/server/src/main/java/org/allaymc/server/world/chunk/AllayChunk.java index 307a44eee..c2a3438e8 100644 --- a/server/src/main/java/org/allaymc/server/world/chunk/AllayChunk.java +++ b/server/src/main/java/org/allaymc/server/world/chunk/AllayChunk.java @@ -1,12 +1,12 @@ package org.allaymc.server.world.chunk; import com.google.common.base.Preconditions; +import com.google.common.collect.Sets; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufAllocator; import io.netty.buffer.ByteBufOutputStream; import io.netty.buffer.Unpooled; import io.netty.util.internal.PlatformDependent; -import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; @@ -39,7 +39,6 @@ public class AllayChunk implements Chunk { protected final StampedLock blockLock; protected final StampedLock heightAndBiomeLock; - // No need to use concurrent-safe set as addChunkLoader() & removeChunkLoader() are only used in AllayChunkService which is single-thread protected final Set chunkLoaders; protected final Queue chunkPacketQueue; @@ -67,7 +66,7 @@ private static void checkXYZ(int x, int y, int z) { this.unsafeChunk = unsafeChunk; this.blockLock = new StampedLock(); this.heightAndBiomeLock = new StampedLock(); - this.chunkLoaders = new ObjectOpenHashSet<>(); + this.chunkLoaders = Sets.newConcurrentHashSet(); this.chunkPacketQueue = PlatformDependent.newMpscQueue(); } diff --git a/server/src/main/java/org/allaymc/server/world/service/AllayBlockUpdateService.java b/server/src/main/java/org/allaymc/server/world/service/AllayBlockUpdateService.java index 77b20aa6d..56c14d0e4 100644 --- a/server/src/main/java/org/allaymc/server/world/service/AllayBlockUpdateService.java +++ b/server/src/main/java/org/allaymc/server/world/service/AllayBlockUpdateService.java @@ -1,5 +1,6 @@ package org.allaymc.server.world.service; +import io.netty.util.internal.PlatformDependent; import lombok.RequiredArgsConstructor; import org.allaymc.api.block.data.BlockFace; import org.allaymc.api.block.dto.BlockStateWithPos; @@ -11,7 +12,10 @@ import org.allaymc.api.world.service.BlockUpdateService; import org.joml.Vector3ic; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Queue; import java.util.concurrent.ConcurrentHashMap; /** @@ -23,7 +27,7 @@ public class AllayBlockUpdateService implements BlockUpdateService { protected final Dimension dimension; protected final Map scheduledUpdates = new ConcurrentHashMap<>(); - protected final Queue neighborUpdates = new LinkedList<>(); + protected final Queue neighborUpdates = PlatformDependent.newMpscQueue(); public void tick(long tick) { tickScheduledUpdates(tick);