From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Thu, 11 Mar 2021 21:17:02 -0800
Subject: [PATCH] Use hash table for maintaing changed block set

When a lot of block changes occur the iteration for checking can
add up a bit and cause a small performance impact.

diff --git a/src/main/java/net/minecraft/server/level/PlayerChunk.java b/src/main/java/net/minecraft/server/level/PlayerChunk.java
index 41a9202fac9fce3bf8cf08682d0545484d46c41d..a8edac296cbdb053bca4b56a890c3e9e5544d3a6 100644
--- a/src/main/java/net/minecraft/server/level/PlayerChunk.java
+++ b/src/main/java/net/minecraft/server/level/PlayerChunk.java
@@ -3,6 +3,7 @@ package net.minecraft.server.level;
 import com.mojang.datafixers.util.Either;
 import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; // Paper
 import it.unimi.dsi.fastutil.shorts.ShortArraySet;
+import it.unimi.dsi.fastutil.shorts.ShortOpenHashSet; // Tuinity
 import it.unimi.dsi.fastutil.shorts.ShortSet;
 import java.util.List;
 import java.util.Optional;
@@ -404,7 +405,7 @@ public class PlayerChunk {
             if (b0 < 0 || b0 >= this.dirtyBlocks.length) return; // CraftBukkit - SPIGOT-6086, SPIGOT-6296
             if (this.dirtyBlocks[b0] == null) {
                 this.p = true;
-                this.dirtyBlocks[b0] = new ShortArraySet();
+                this.dirtyBlocks[b0] = new ShortOpenHashSet(); // Tuinity - use a set to make setting constant-time
             }
 
             this.dirtyBlocks[b0].add(SectionPosition.b(blockposition));
