From e6d395cc83dd69e0557386a78ad9a21b25a38a81 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Sun, 12 Apr 2020 22:34:18 -0700 Subject: [PATCH] Port 04-Util.patch from Tuinity (#3136) --- Spigot-Server-Patches/0004-MC-Utils.patch | 638 ++++++++++++++---- ...to-current-Chunk-for-Entity-and-Bloc.patch | 18 +- ...ts-for-each-Entity-Block-Entity-Type.patch | 10 +- Spigot-Server-Patches/0009-Timings-v2.patch | 66 +- ...ve-invalid-mob-spawner-tile-entities.patch | 8 +- .../0054-Add-exception-reporting-event.patch | 28 +- ...Location-getType-and-getBlockData-fo.patch | 14 +- ...76-Configurable-Chunk-Inhabited-Time.patch | 10 +- ...tion-to-remove-corrupt-tile-entities.patch | 10 +- .../0135-String-based-Action-Bar-API.patch | 10 +- .../0156-Basic-PlayerProfile-API.patch | 24 +- ...-anytime-entities-change-to-guarante.patch | 10 +- ...dd-some-Debug-to-Chunk-Entity-slices.patch | 14 +- ...ead-Entities-in-entityList-iteration.patch | 12 +- ...arseException-in-Entity-and-TE-names.patch | 16 +- ...353-Add-LivingEntity-getTargetEntity.patch | 18 +- .../0371-Duplicate-UUID-Resolve-Option.patch | 16 +- .../0378-Chunk-debug-command.patch | 18 +- Spigot-Server-Patches/0385-Anti-Xray.patch | 8 +- ...opper-searches-if-there-are-no-items.patch | 14 +- ...91-Asynchronous-chunk-IO-and-loading.patch | 10 +- .../0436-Optimise-random-block-ticking.patch | 30 +- .../0446-Optimise-Chunk-getFluid.patch | 12 +- ...hunkMap-memory-use-for-visibleChunks.patch | 16 +- 24 files changed, 702 insertions(+), 328 deletions(-) diff --git a/Spigot-Server-Patches/0004-MC-Utils.patch b/Spigot-Server-Patches/0004-MC-Utils.patch index 5684a4e73..271a36bc8 100644 --- a/Spigot-Server-Patches/0004-MC-Utils.patch +++ b/Spigot-Server-Patches/0004-MC-Utils.patch @@ -1,4 +1,4 @@ -From 75ae35c120230e8fbc4a20f7472276d0f398e21a Mon Sep 17 00:00:00 2001 +From e7cd9720bd6b59020fbbee5d02854fe51087113e Mon Sep 17 00:00:00 2001 From: Aikar Date: Mon, 28 Mar 2016 20:55:47 -0400 Subject: [PATCH] MC Utils @@ -6,7 +6,7 @@ Subject: [PATCH] MC Utils diff --git a/src/main/java/com/destroystokyo/paper/util/concurrent/WeakSeqLock.java b/src/main/java/com/destroystokyo/paper/util/concurrent/WeakSeqLock.java new file mode 100644 -index 0000000000..4029dc68cf +index 000000000..4029dc68c --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/util/concurrent/WeakSeqLock.java @@ -0,0 +1,68 @@ @@ -80,10 +80,10 @@ index 0000000000..4029dc68cf +} diff --git a/src/main/java/com/destroystokyo/paper/util/map/QueuedChangesMapLong2Int.java b/src/main/java/com/destroystokyo/paper/util/map/QueuedChangesMapLong2Int.java new file mode 100644 -index 0000000000..968c9ed328 +index 000000000..59868f37d --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/util/map/QueuedChangesMapLong2Int.java -@@ -0,0 +1,156 @@ +@@ -0,0 +1,162 @@ +package com.destroystokyo.paper.util.map; + +import com.destroystokyo.paper.util.concurrent.WeakSeqLock; @@ -181,7 +181,7 @@ index 0000000000..968c9ed328 + while (iterator0.hasNext()) { + final Long2IntMap.Entry entry = iterator0.next(); + final long key = entry.getLongKey(); -+ final int val = entry.getValue(); ++ final int val = entry.getIntValue(); + + this.updatingMapSeqLock.acquireWrite(); + try { @@ -191,6 +191,8 @@ index 0000000000..968c9ed328 + } + } + ++ this.queuedPuts.clear(); ++ + final LongIterator iterator1 = this.queuedRemove.iterator(); + while (iterator1.hasNext()) { + final long key = iterator1.nextLong(); @@ -203,6 +205,7 @@ index 0000000000..968c9ed328 + } + } + ++ this.queuedRemove.clear(); + + return true; + } @@ -221,11 +224,13 @@ index 0000000000..968c9ed328 + while (iterator0.hasNext()) { + final Long2IntMap.Entry entry = iterator0.next(); + final long key = entry.getLongKey(); -+ final int val = entry.getValue(); ++ final int val = entry.getIntValue(); + + this.visibleMap.put(key, val); + } + ++ this.queuedPuts.clear(); ++ + final LongIterator iterator1 = this.queuedRemove.iterator(); + while (iterator1.hasNext()) { + final long key = iterator1.nextLong(); @@ -233,6 +238,7 @@ index 0000000000..968c9ed328 + this.visibleMap.remove(key); + } + ++ this.queuedRemove.clear(); + + return true; + } finally { @@ -242,7 +248,7 @@ index 0000000000..968c9ed328 +} diff --git a/src/main/java/com/destroystokyo/paper/util/map/QueuedChangesMapLong2Object.java b/src/main/java/com/destroystokyo/paper/util/map/QueuedChangesMapLong2Object.java new file mode 100644 -index 0000000000..07685b6bd5 +index 000000000..07685b6bd --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/util/map/QueuedChangesMapLong2Object.java @@ -0,0 +1,172 @@ @@ -420,10 +426,10 @@ index 0000000000..07685b6bd5 +} diff --git a/src/main/java/com/destroystokyo/paper/util/maplist/ChunkList.java b/src/main/java/com/destroystokyo/paper/util/maplist/ChunkList.java new file mode 100644 -index 0000000000..4ec248adb6 +index 000000000..4eac05778 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/util/maplist/ChunkList.java -@@ -0,0 +1,127 @@ +@@ -0,0 +1,129 @@ +package com.destroystokyo.paper.util.maplist; + +import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; @@ -439,12 +445,14 @@ index 0000000000..4ec248adb6 + */ +public final class ChunkList implements Iterable { + -+ protected final Long2IntOpenHashMap chunkToIndex = new Long2IntOpenHashMap(); ++ protected final Long2IntOpenHashMap chunkToIndex = new Long2IntOpenHashMap(2, 0.8f); + { + this.chunkToIndex.defaultReturnValue(Integer.MIN_VALUE); + } + -+ protected Chunk[] chunks = new Chunk[16]; ++ protected static final Chunk[] EMPTY_LIST = new Chunk[0]; ++ ++ protected Chunk[] chunks = EMPTY_LIST; + protected int count; + + public int size() { @@ -452,11 +460,11 @@ index 0000000000..4ec248adb6 + } + + public boolean contains(final Chunk chunk) { -+ return this.chunkToIndex.containsKey(MCUtil.getCoordinateKey(chunk.getPos())); ++ return this.chunkToIndex.containsKey(chunk.coordinateKey); + } + + public boolean remove(final Chunk chunk) { -+ final int index = this.chunkToIndex.remove(MCUtil.getCoordinateKey(chunk.getPos())); ++ final int index = this.chunkToIndex.remove(chunk.coordinateKey); + if (index == Integer.MIN_VALUE) { + return false; + } @@ -466,7 +474,7 @@ index 0000000000..4ec248adb6 + final Chunk end = this.chunks[endIndex]; + if (index != endIndex) { + // not empty after this call -+ this.chunkToIndex.put(MCUtil.getCoordinateKey(end.getPos()), index); // update index ++ this.chunkToIndex.put(end.coordinateKey, index); // update index + } + this.chunks[index] = end; + this.chunks[endIndex] = null; @@ -476,7 +484,7 @@ index 0000000000..4ec248adb6 + + public boolean add(final Chunk chunk) { + final int count = this.count; -+ final int currIndex = this.chunkToIndex.putIfAbsent(MCUtil.getCoordinateKey(chunk.getPos()), count); ++ final int currIndex = this.chunkToIndex.putIfAbsent(chunk.coordinateKey, count); + + if (currIndex != Integer.MIN_VALUE) { + return false; // already in this list @@ -486,7 +494,7 @@ index 0000000000..4ec248adb6 + + if (list.length == count) { + // resize required -+ list = this.chunks = Arrays.copyOf(list, count * 2); // overflow results in negative ++ list = this.chunks = Arrays.copyOf(list, (int)Math.max(4L, count * 2L)); // overflow results in negative + } + + list[count] = chunk; @@ -553,10 +561,10 @@ index 0000000000..4ec248adb6 +} diff --git a/src/main/java/com/destroystokyo/paper/util/maplist/EntityList.java b/src/main/java/com/destroystokyo/paper/util/maplist/EntityList.java new file mode 100644 -index 0000000000..f3cb346c9d +index 000000000..cdda74564 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/util/maplist/EntityList.java -@@ -0,0 +1,126 @@ +@@ -0,0 +1,128 @@ +package com.destroystokyo.paper.util.maplist; + +import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; @@ -571,12 +579,14 @@ index 0000000000..f3cb346c9d + */ +public final class EntityList implements Iterable { + -+ protected final Int2IntOpenHashMap entityToIndex = new Int2IntOpenHashMap(); ++ protected final Int2IntOpenHashMap entityToIndex = new Int2IntOpenHashMap(2, 0.8f); + { + this.entityToIndex.defaultReturnValue(Integer.MIN_VALUE); + } + -+ protected Entity[] entities = new Entity[16]; ++ protected static final Entity[] EMPTY_LIST = new Entity[0]; ++ ++ protected Entity[] entities = EMPTY_LIST; + protected int count; + + public int size() { @@ -618,7 +628,7 @@ index 0000000000..f3cb346c9d + + if (list.length == count) { + // resize required -+ list = this.entities = Arrays.copyOf(list, count * 2); // overflow results in negative ++ list = this.entities = Arrays.copyOf(list, (int)Math.max(4L, count * 2L)); // overflow results in negative + } + + list[count] = entity; @@ -685,10 +695,10 @@ index 0000000000..f3cb346c9d +} diff --git a/src/main/java/com/destroystokyo/paper/util/maplist/IBlockDataList.java b/src/main/java/com/destroystokyo/paper/util/maplist/IBlockDataList.java new file mode 100644 -index 0000000000..c2f7e4ca0f +index 000000000..84ef8d9ec --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/util/maplist/IBlockDataList.java -@@ -0,0 +1,126 @@ +@@ -0,0 +1,128 @@ +package com.destroystokyo.paper.util.maplist; + +import it.unimi.dsi.fastutil.longs.LongIterator; @@ -706,12 +716,14 @@ index 0000000000..c2f7e4ca0f + static final DataPaletteGlobal GLOBAL_PALETTE = (DataPaletteGlobal)ChunkSection.GLOBAL_PALETTE; + + // map of location -> (index | (location << 16) | (palette id << 32)) -+ private final Short2LongOpenHashMap map = new Short2LongOpenHashMap(16, 0.7f); ++ private final Short2LongOpenHashMap map = new Short2LongOpenHashMap(2, 0.8f); + { + this.map.defaultReturnValue(Long.MAX_VALUE); + } + -+ private long[] byIndex = new long[16]; ++ private static final long[] EMPTY_LIST = new long[0]; ++ ++ private long[] byIndex = EMPTY_LIST; + private int size; + + public static int getLocationKey(final int x, final int y, final int z) { @@ -751,7 +763,7 @@ index 0000000000..c2f7e4ca0f + this.map.put((short)location, raw); + + if (index >= this.byIndex.length) { -+ this.byIndex = Arrays.copyOf(this.byIndex, this.byIndex.length * 2); ++ this.byIndex = Arrays.copyOf(this.byIndex, (int)Math.max(4L, this.byIndex.length * 2L)); + } + + this.byIndex[index] = raw; @@ -817,7 +829,7 @@ index 0000000000..c2f7e4ca0f +} diff --git a/src/main/java/com/destroystokyo/paper/util/math/IntegerUtil.java b/src/main/java/com/destroystokyo/paper/util/math/IntegerUtil.java new file mode 100644 -index 0000000000..c3b936f54b +index 000000000..c3b936f54 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/util/math/IntegerUtil.java @@ -0,0 +1,230 @@ @@ -1053,12 +1065,13 @@ index 0000000000..c3b936f54b +} diff --git a/src/main/java/com/destroystokyo/paper/util/misc/AreaMap.java b/src/main/java/com/destroystokyo/paper/util/misc/AreaMap.java new file mode 100644 -index 0000000000..5a44bc644b +index 000000000..f625da9f0 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/util/misc/AreaMap.java -@@ -0,0 +1,389 @@ +@@ -0,0 +1,409 @@ +package com.destroystokyo.paper.util.misc; + ++import com.destroystokyo.paper.util.math.IntegerUtil; +import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap; +import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; +import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; @@ -1069,15 +1082,13 @@ index 0000000000..5a44bc644b +import javax.annotation.Nullable; +import java.util.Iterator; + -+/** -+ * @author Spottedleaf -+ */ ++/** @author Spottedleaf */ +public abstract class AreaMap { + + /* Tested via https://gist.github.com/Spottedleaf/520419c6f41ef348fe9926ce674b7217 */ + -+ private final Object2LongOpenHashMap objectToLastCoordinate = new Object2LongOpenHashMap<>(); -+ private final Object2IntOpenHashMap objectToViewDistance = new Object2IntOpenHashMap<>(); ++ protected final Object2LongOpenHashMap objectToLastCoordinate = new Object2LongOpenHashMap<>(); ++ protected final Object2IntOpenHashMap objectToViewDistance = new Object2IntOpenHashMap<>(); + + { + this.objectToViewDistance.defaultReturnValue(-1); @@ -1086,11 +1097,11 @@ index 0000000000..5a44bc644b + + // we use linked for better iteration. + // map of: coordinate to set of objects in coordinate -+ private final Long2ObjectOpenHashMap> areaMap = new Long2ObjectOpenHashMap<>(1024, 0.3f); -+ private final PooledLinkedHashSets pooledHashSets; ++ protected final Long2ObjectOpenHashMap> areaMap = new Long2ObjectOpenHashMap<>(1024, 0.7f); ++ protected final PooledLinkedHashSets pooledHashSets; + -+ private final ChangeCallback addCallback; -+ private final ChangeCallback removeCallback; ++ protected final ChangeCallback addCallback; ++ protected final ChangeCallback removeCallback; + + public AreaMap() { + this(new PooledLinkedHashSets<>()); @@ -1108,48 +1119,57 @@ index 0000000000..5a44bc644b + } + + @Nullable -+ public PooledLinkedHashSets.PooledObjectLinkedOpenHashSet getObjectsInRange(final long key) { ++ public final PooledLinkedHashSets.PooledObjectLinkedOpenHashSet getObjectsInRange(final long key) { + return this.areaMap.get(key); + } + + @Nullable -+ public PooledLinkedHashSets.PooledObjectLinkedOpenHashSet getObjectsInRange(final ChunkCoordIntPair chunkPos) { -+ return this.getObjectsInRange(chunkPos.x, chunkPos.z); ++ public final PooledLinkedHashSets.PooledObjectLinkedOpenHashSet getObjectsInRange(final ChunkCoordIntPair chunkPos) { ++ return this.areaMap.get(MCUtil.getCoordinateKey(chunkPos)); + } + + @Nullable -+ public PooledLinkedHashSets.PooledObjectLinkedOpenHashSet getObjectsInRange(final int chunkX, final int chunkZ) { -+ return this.getObjectsInRange(MCUtil.getCoordinateKey(chunkX, chunkZ)); ++ public final PooledLinkedHashSets.PooledObjectLinkedOpenHashSet getObjectsInRange(final int chunkX, final int chunkZ) { ++ return this.areaMap.get(MCUtil.getCoordinateKey(chunkX, chunkZ)); + } + + // Long.MIN_VALUE indicates the object is not mapped -+ public long getLastCoordinate(final E object) { ++ public final long getLastCoordinate(final E object) { + return this.objectToLastCoordinate.getOrDefault(object, Long.MIN_VALUE); + } + + // -1 indicates the object is not mapped -+ public int getLastViewDistance(final E object) { ++ public final int getLastViewDistance(final E object) { + return this.objectToViewDistance.getOrDefault(object, -1); + } + + // returns the total number of mapped chunks -+ public int size() { ++ public final int size() { + return this.areaMap.size(); + } + -+ public void update(final E object, final int chunkX, final int chunkZ, final int viewDistance) { -+ final int oldDistance = this.objectToViewDistance.put(object, viewDistance); ++ public final void update(final E object, final int chunkX, final int chunkZ, final int viewDistance) { ++ final int oldViewDistance = this.objectToViewDistance.put(object, viewDistance); + final long newPos = MCUtil.getCoordinateKey(chunkX, chunkZ); -+ if (oldDistance == -1) { ++ if (oldViewDistance == -1) { + this.objectToLastCoordinate.put(object, newPos); + this.addObject(object, chunkX, chunkZ, Integer.MIN_VALUE, Integer.MIN_VALUE, viewDistance); ++ this.addObjectCallback(object, chunkX, chunkZ, viewDistance); + } else { -+ this.updateObject(object, this.objectToLastCoordinate.put(object, newPos), newPos, oldDistance, viewDistance); ++ final long oldPos = this.objectToLastCoordinate.put(object, newPos); ++ this.updateObject(object, oldPos, newPos, oldViewDistance, viewDistance); ++ this.updateObjectCallback(object, oldPos, newPos, oldViewDistance, viewDistance); + } + //this.validate(object, viewDistance); + } + -+ public boolean remove(final E object) { ++ // called after the distance map updates ++ protected void addObjectCallback(final E object, final int chunkX, final int chunkZ, final int viewDistance) {} ++ ++ // called after the distance map updates ++ protected void updateObjectCallback(final E Object, final long oldPosition, final long newPosition, final int oldViewDistance, final int newViewDistance) {} ++ ++ public final boolean remove(final E object) { + final long position = this.objectToLastCoordinate.removeLong(object); + final int viewDistance = this.objectToViewDistance.removeInt(object); + @@ -1161,14 +1181,18 @@ index 0000000000..5a44bc644b + final int currentZ = MCUtil.getCoordinateZ(position); + + this.removeObject(object, currentX, currentZ, currentX, currentZ, viewDistance); ++ this.removeObjectCallback(object, currentX, currentZ, viewDistance); + //this.validate(object, -1); + return true; + } + ++ // called after the distance map updates ++ protected void removeObjectCallback(final E object, final int chunkX, final int chunkZ, final int viewDistance) {} ++ + protected abstract PooledLinkedHashSets.PooledObjectLinkedOpenHashSet getEmptySetFor(final E object); + + // expensive op, only for debug -+ private void validate(final E object, final int viewDistance) { ++ protected void validate(final E object, final int viewDistance) { + int entiesGot = 0; + int expectedEntries = (2 * viewDistance + 1); + expectedEntries *= expectedEntries; @@ -1198,7 +1222,7 @@ index 0000000000..5a44bc644b + final int chunkX = MCUtil.getCoordinateX(key); + final int chunkZ = MCUtil.getCoordinateZ(key); + -+ final int dist = Math.max(Math.abs(chunkX - centerX), Math.abs(chunkZ - centerZ)); ++ final int dist = Math.max(IntegerUtil.branchlessAbs(chunkX - centerX), IntegerUtil.branchlessAbs(chunkZ - centerZ)); + + if (dist > viewDistance) { + throw new IllegalStateException("Expected view distance " + viewDistance + ", got " + dist); @@ -1211,8 +1235,8 @@ index 0000000000..5a44bc644b + } + } + -+ protected final void addObjectTo(final E object, final int chunkX, final int chunkZ, final int currChunkX, -+ final int currChunkZ, final int prevChunkX, final int prevChunkZ) { ++ private void addObjectTo(final E object, final int chunkX, final int chunkZ, final int currChunkX, ++ final int currChunkZ, final int prevChunkX, final int prevChunkZ) { + final long key = MCUtil.getCoordinateKey(chunkX, chunkZ); + + PooledLinkedHashSets.PooledObjectLinkedOpenHashSet empty = this.getEmptySetFor(object); @@ -1243,8 +1267,8 @@ index 0000000000..5a44bc644b + } + } + -+ protected final void removeObjectFrom(final E object, final int chunkX, final int chunkZ, final int currChunkX, -+ final int currChunkZ, final int prevChunkX, final int prevChunkZ) { ++ private void removeObjectFrom(final E object, final int chunkX, final int chunkZ, final int currChunkX, ++ final int currChunkZ, final int prevChunkX, final int prevChunkZ) { + final long key = MCUtil.getCoordinateKey(chunkX, chunkZ); + + PooledLinkedHashSets.PooledObjectLinkedOpenHashSet current = this.areaMap.get(key); @@ -1280,8 +1304,10 @@ index 0000000000..5a44bc644b + private void addObject(final E object, final int chunkX, final int chunkZ, final int prevChunkX, final int prevChunkZ, final int viewDistance) { + final int maxX = chunkX + viewDistance; + final int maxZ = chunkZ + viewDistance; -+ for (int x = chunkX - viewDistance; x <= maxX; ++x) { -+ for (int z = chunkZ - viewDistance; z <= maxZ; ++z) { ++ final int minX = chunkX - viewDistance; ++ final int minZ = chunkZ - viewDistance; ++ for (int x = minX; x <= maxX; ++x) { ++ for (int z = minZ; z <= maxZ; ++z) { + this.addObjectTo(object, x, z, chunkX, chunkZ, prevChunkX, prevChunkZ); + } + } @@ -1290,8 +1316,10 @@ index 0000000000..5a44bc644b + private void removeObject(final E object, final int chunkX, final int chunkZ, final int currentChunkX, final int currentChunkZ, final int viewDistance) { + final int maxX = chunkX + viewDistance; + final int maxZ = chunkZ + viewDistance; -+ for (int x = chunkX - viewDistance; x <= maxX; ++x) { -+ for (int z = chunkZ - viewDistance; z <= maxZ; ++z) { ++ final int minX = chunkX - viewDistance; ++ final int minZ = chunkZ - viewDistance; ++ for (int x = minX; x <= maxX; ++x) { ++ for (int z = minZ; z <= maxZ; ++z) { + this.removeObjectFrom(object, x, z, currentChunkX, currentChunkZ, chunkX, chunkZ); + } + } @@ -1302,7 +1330,7 @@ index 0000000000..5a44bc644b + return 1 | (val >> (Integer.SIZE - 1)); + } + -+ protected final void updateObject(final E object, final long oldPosition, final long newPosition, final int oldViewDistance, final int newViewDistance) { ++ private void updateObject(final E object, final long oldPosition, final long newPosition, final int oldViewDistance, final int newViewDistance) { + final int toX = MCUtil.getCoordinateX(newPosition); + final int toZ = MCUtil.getCoordinateZ(newPosition); + final int fromX = MCUtil.getCoordinateX(oldPosition); @@ -1311,8 +1339,8 @@ index 0000000000..5a44bc644b + final int dx = toX - fromX; + final int dz = toZ - fromZ; + -+ final int totalX = Math.abs(fromX - toX); -+ final int totalZ = Math.abs(fromZ - toZ); ++ final int totalX = IntegerUtil.branchlessAbs(fromX - toX); ++ final int totalZ = IntegerUtil.branchlessAbs(fromZ - toZ); + + if (Math.max(totalX, totalZ) > (2 * Math.max(newViewDistance, oldViewDistance))) { + // teleported? @@ -1324,13 +1352,15 @@ index 0000000000..5a44bc644b + if (oldViewDistance != newViewDistance) { + // remove loop + ++ final int oldMinX = fromX - oldViewDistance; ++ final int oldMinZ = fromZ - oldViewDistance; + final int oldMaxX = fromX + oldViewDistance; + final int oldMaxZ = fromZ + oldViewDistance; -+ for (int currX = fromX - oldViewDistance; currX <= oldMaxX; ++currX) { -+ for (int currZ = fromZ - oldViewDistance; currZ <= oldMaxZ; ++currZ) { ++ for (int currX = oldMinX; currX <= oldMaxX; ++currX) { ++ for (int currZ = oldMinZ; currZ <= oldMaxZ; ++currZ) { + + // only remove if we're outside the new view distance... -+ if (Math.max(Math.abs(currX - toX), Math.abs(currZ - toZ)) > newViewDistance) { ++ if (Math.max(IntegerUtil.branchlessAbs(currX - toX), IntegerUtil.branchlessAbs(currZ - toZ)) > newViewDistance) { + this.removeObjectFrom(object, currX, currZ, toX, toZ, fromX, fromZ); + } + } @@ -1338,13 +1368,15 @@ index 0000000000..5a44bc644b + + // add loop + ++ final int newMinX = toX - newViewDistance; ++ final int newMinZ = toZ - newViewDistance; + final int newMaxX = toX + newViewDistance; + final int newMaxZ = toZ + newViewDistance; -+ for (int currX = toX - newViewDistance; currX <= newMaxX; ++currX) { -+ for (int currZ = toZ - newViewDistance; currZ <= newMaxZ; ++currZ) { ++ for (int currX = newMinX; currX <= newMaxX; ++currX) { ++ for (int currZ = newMinZ; currZ <= newMaxZ; ++currZ) { + + // only add if we're outside the old view distance... -+ if (Math.max(Math.abs(currX - fromX), Math.abs(currZ - fromZ)) > oldViewDistance) { ++ if (Math.max(IntegerUtil.branchlessAbs(currX - fromX), IntegerUtil.branchlessAbs(currZ - fromZ)) > oldViewDistance) { + this.addObjectTo(object, currX, currZ, toX, toZ, fromX, fromZ); + } + } @@ -1446,9 +1478,190 @@ index 0000000000..5a44bc644b + + } +} +diff --git a/src/main/java/com/destroystokyo/paper/util/misc/DistanceTrackingAreaMap.java b/src/main/java/com/destroystokyo/paper/util/misc/DistanceTrackingAreaMap.java +new file mode 100644 +index 000000000..3f86c1ad4 +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/util/misc/DistanceTrackingAreaMap.java +@@ -0,0 +1,175 @@ ++package com.destroystokyo.paper.util.misc; ++ ++import com.destroystokyo.paper.util.math.IntegerUtil; ++import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; ++import net.minecraft.server.ChunkCoordIntPair; ++import net.minecraft.server.MCUtil; ++ ++/** @author Spottedleaf */ ++public abstract class DistanceTrackingAreaMap extends AreaMap { ++ ++ // use this map only if you need distance tracking, the tracking here is obviously going to hit harder. ++ ++ protected final Long2IntOpenHashMap chunkToNearestDistance = new Long2IntOpenHashMap(1024, 0.7f); ++ { ++ this.chunkToNearestDistance.defaultReturnValue(-1); ++ } ++ ++ protected final DistanceChangeCallback distanceChangeCallback; ++ ++ public DistanceTrackingAreaMap() { ++ this(new PooledLinkedHashSets<>()); ++ } ++ ++ // let users define a "global" or "shared" pooled sets if they wish ++ public DistanceTrackingAreaMap(final PooledLinkedHashSets pooledHashSets) { ++ this(pooledHashSets, null, null, null); ++ } ++ ++ public DistanceTrackingAreaMap(final PooledLinkedHashSets pooledHashSets, final ChangeCallback addCallback, final ChangeCallback removeCallback, ++ final DistanceChangeCallback distanceChangeCallback) { ++ super(pooledHashSets, addCallback, removeCallback); ++ this.distanceChangeCallback = distanceChangeCallback; ++ } ++ ++ // ret -1 if there is nothing mapped ++ public final int getNearestObjectDistance(final long key) { ++ return this.chunkToNearestDistance.get(key); ++ } ++ ++ // ret -1 if there is nothing mapped ++ public final int getNearestObjectDistance(final ChunkCoordIntPair chunkPos) { ++ return this.chunkToNearestDistance.get(MCUtil.getCoordinateKey(chunkPos)); ++ } ++ ++ // ret -1 if there is nothing mapped ++ public final int getNearestObjectDistance(final int chunkX, final int chunkZ) { ++ return this.chunkToNearestDistance.get(MCUtil.getCoordinateKey(chunkX, chunkZ)); ++ } ++ ++ protected final void recalculateDistance(final int chunkX, final int chunkZ) { ++ final long key = MCUtil.getCoordinateKey(chunkX, chunkZ); ++ final PooledLinkedHashSets.PooledObjectLinkedOpenHashSet state = this.areaMap.get(key); ++ if (state == null) { ++ final int oldDistance = this.chunkToNearestDistance.remove(key); ++ // nothing here. ++ if (oldDistance == -1) { ++ // nothing was here previously ++ return; ++ } ++ if (this.distanceChangeCallback != null) { ++ this.distanceChangeCallback.accept(chunkX, chunkZ, oldDistance, -1, null); ++ } ++ return; ++ } ++ ++ int newDistance = Integer.MAX_VALUE; ++ ++ final Object[] rawData = state.getBackingSet(); ++ for (int i = 0, len = rawData.length; i < len; ++i) { ++ final Object raw = rawData[i]; ++ ++ if (raw == null) { ++ continue; ++ } ++ ++ final E object = (E)raw; ++ final long location = this.objectToLastCoordinate.getLong(object); ++ ++ final int distance = Math.max(IntegerUtil.branchlessAbs(chunkX - MCUtil.getCoordinateX(location)), IntegerUtil.branchlessAbs(chunkZ - MCUtil.getCoordinateZ(location))); ++ ++ if (distance < newDistance) { ++ newDistance = distance; ++ } ++ } ++ ++ final int oldDistance = this.chunkToNearestDistance.put(key, newDistance); ++ ++ if (oldDistance != newDistance) { ++ if (this.distanceChangeCallback != null) { ++ this.distanceChangeCallback.accept(chunkX, chunkZ, oldDistance, newDistance, state); ++ } ++ } ++ } ++ ++ @Override ++ protected void addObjectCallback(final E object, final int chunkX, final int chunkZ, final int viewDistance) { ++ final int maxX = chunkX + viewDistance; ++ final int maxZ = chunkZ + viewDistance; ++ final int minX = chunkX - viewDistance; ++ final int minZ = chunkZ - viewDistance; ++ for (int x = minX; x <= maxX; ++x) { ++ for (int z = minZ; z <= maxZ; ++z) { ++ this.recalculateDistance(x, z); ++ } ++ } ++ } ++ ++ @Override ++ protected void removeObjectCallback(final E object, final int chunkX, final int chunkZ, final int viewDistance) { ++ final int maxX = chunkX + viewDistance; ++ final int maxZ = chunkZ + viewDistance; ++ final int minX = chunkX - viewDistance; ++ final int minZ = chunkZ - viewDistance; ++ for (int x = minX; x <= maxX; ++x) { ++ for (int z = minZ; z <= maxZ; ++z) { ++ this.recalculateDistance(x, z); ++ } ++ } ++ } ++ ++ @Override ++ protected void updateObjectCallback(final E object, final long oldPosition, final long newPosition, final int oldViewDistance, final int newViewDistance) { ++ if (oldPosition == newPosition && newViewDistance == oldViewDistance) { ++ return; ++ } ++ ++ final int toX = MCUtil.getCoordinateX(newPosition); ++ final int toZ = MCUtil.getCoordinateZ(newPosition); ++ final int fromX = MCUtil.getCoordinateX(oldPosition); ++ final int fromZ = MCUtil.getCoordinateZ(oldPosition); ++ ++ final int totalX = IntegerUtil.branchlessAbs(fromX - toX); ++ final int totalZ = IntegerUtil.branchlessAbs(fromZ - toZ); ++ ++ if (Math.max(totalX, totalZ) > (2 * Math.max(newViewDistance, oldViewDistance))) { ++ // teleported? ++ this.removeObjectCallback(object, fromX, fromZ, oldViewDistance); ++ this.addObjectCallback(object, toX, toZ, newViewDistance); ++ return; ++ } ++ ++ final int minX = Math.min(fromX - oldViewDistance, toX - newViewDistance); ++ final int maxX = Math.max(fromX + oldViewDistance, toX + newViewDistance); ++ final int minZ = Math.min(fromZ - oldViewDistance, toZ - newViewDistance); ++ final int maxZ = Math.max(fromZ + oldViewDistance, toZ + newViewDistance); ++ ++ for (int x = minX; x <= maxX; ++x) { ++ for (int z = minZ; z <= maxZ; ++z) { ++ final int distXOld = IntegerUtil.branchlessAbs(x - fromX); ++ final int distZOld = IntegerUtil.branchlessAbs(z - fromZ); ++ ++ if (Math.max(distXOld, distZOld) <= oldViewDistance) { ++ this.recalculateDistance(x, z); ++ continue; ++ } ++ ++ final int distXNew = IntegerUtil.branchlessAbs(x - toX); ++ final int distZNew = IntegerUtil.branchlessAbs(z - toZ); ++ ++ if (Math.max(distXNew, distZNew) <= newViewDistance) { ++ this.recalculateDistance(x, z); ++ continue; ++ } ++ } ++ } ++ } ++ ++ @FunctionalInterface ++ public static interface DistanceChangeCallback { ++ ++ void accept(final int posX, final int posZ, final int oldNearestDistance, final int newNearestDistance, ++ final PooledLinkedHashSets.PooledObjectLinkedOpenHashSet state); ++ ++ } ++} diff --git a/src/main/java/com/destroystokyo/paper/util/misc/PlayerAreaMap.java b/src/main/java/com/destroystokyo/paper/util/misc/PlayerAreaMap.java new file mode 100644 -index 0000000000..8a552a87ab +index 000000000..8a552a87a --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/util/misc/PlayerAreaMap.java @@ -0,0 +1,27 @@ @@ -1479,21 +1692,49 @@ index 0000000000..8a552a87ab + return player.cachedSingleHashSet; + } +} +diff --git a/src/main/java/com/destroystokyo/paper/util/misc/PlayerDistanceTrackingAreaMap.java b/src/main/java/com/destroystokyo/paper/util/misc/PlayerDistanceTrackingAreaMap.java +new file mode 100644 +index 000000000..0292afc52 +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/util/misc/PlayerDistanceTrackingAreaMap.java +@@ -0,0 +1,24 @@ ++package com.destroystokyo.paper.util.misc; ++ ++import net.minecraft.server.EntityPlayer; ++ ++public class PlayerDistanceTrackingAreaMap extends DistanceTrackingAreaMap { ++ ++ public PlayerDistanceTrackingAreaMap() { ++ super(); ++ } ++ ++ public PlayerDistanceTrackingAreaMap(final PooledLinkedHashSets pooledHashSets) { ++ super(pooledHashSets); ++ } ++ ++ public PlayerDistanceTrackingAreaMap(final PooledLinkedHashSets pooledHashSets, final ChangeCallback addCallback, ++ final ChangeCallback removeCallback, final DistanceChangeCallback distanceChangeCallback) { ++ super(pooledHashSets, addCallback, removeCallback, distanceChangeCallback); ++ } ++ ++ @Override ++ protected PooledLinkedHashSets.PooledObjectLinkedOpenHashSet getEmptySetFor(final EntityPlayer player) { ++ return player.cachedSingleHashSet; ++ } ++} diff --git a/src/main/java/com/destroystokyo/paper/util/misc/PooledLinkedHashSets.java b/src/main/java/com/destroystokyo/paper/util/misc/PooledLinkedHashSets.java new file mode 100644 -index 0000000000..5f2d88797d +index 000000000..e51104e65 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/util/misc/PooledLinkedHashSets.java -@@ -0,0 +1,289 @@ +@@ -0,0 +1,287 @@ +package com.destroystokyo.paper.util.misc; + +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; +import java.lang.ref.WeakReference; + -+/** -+ * @author Spottedleaf -+ */ ++/** @author Spottedleaf */ +public class PooledLinkedHashSets { + + /* Tested via https://gist.github.com/Spottedleaf/a93bb7a8993d6ce142d3efc5932bf573 */ @@ -1776,7 +2017,7 @@ index 0000000000..5f2d88797d +} diff --git a/src/main/java/com/destroystokyo/paper/util/set/OptimizedSmallEnumSet.java b/src/main/java/com/destroystokyo/paper/util/set/OptimizedSmallEnumSet.java new file mode 100644 -index 0000000000..9df0006c1a +index 000000000..9df0006c1 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/util/set/OptimizedSmallEnumSet.java @@ -0,0 +1,67 @@ @@ -1847,8 +2088,20 @@ index 0000000000..9df0006c1a + return (other.backingSet & this.backingSet) != 0; + } +} +diff --git a/src/main/java/net/minecraft/server/AxisAlignedBB.java b/src/main/java/net/minecraft/server/AxisAlignedBB.java +index 4f60b931a..f427953a8 100644 +--- a/src/main/java/net/minecraft/server/AxisAlignedBB.java ++++ b/src/main/java/net/minecraft/server/AxisAlignedBB.java +@@ -186,6 +186,7 @@ public class AxisAlignedBB { + return this.d(vec3d.x, vec3d.y, vec3d.z); + } + ++ public final boolean intersects(AxisAlignedBB axisalignedbb) { return this.c(axisalignedbb); } // Paper - OBFHELPER + public boolean c(AxisAlignedBB axisalignedbb) { + return this.a(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.minZ, axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.maxZ); + } diff --git a/src/main/java/net/minecraft/server/BlockAccessAir.java b/src/main/java/net/minecraft/server/BlockAccessAir.java -index eff6ebcd30..30cbfc8eac 100644 +index eff6ebcd3..30cbfc8ea 100644 --- a/src/main/java/net/minecraft/server/BlockAccessAir.java +++ b/src/main/java/net/minecraft/server/BlockAccessAir.java @@ -14,6 +14,18 @@ public enum BlockAccessAir implements IBlockAccess { @@ -1871,7 +2124,7 @@ index eff6ebcd30..30cbfc8eac 100644 public IBlockData getType(BlockPosition blockposition) { return Blocks.AIR.getBlockData(); diff --git a/src/main/java/net/minecraft/server/BlockDataAbstract.java b/src/main/java/net/minecraft/server/BlockDataAbstract.java -index 1cf97cefc9..2040f18349 100644 +index 1cf97cefc..2040f1834 100644 --- a/src/main/java/net/minecraft/server/BlockDataAbstract.java +++ b/src/main/java/net/minecraft/server/BlockDataAbstract.java @@ -78,6 +78,7 @@ public abstract class BlockDataAbstract implements IBlockDataHolder { @@ -1883,7 +2136,7 @@ index 1cf97cefc9..2040f18349 100644 return this.d.containsKey(iblockstate); } diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java -index c88a62f6b7..5dbd3e60fe 100644 +index c88a62f6b..5dbd3e60f 100644 --- a/src/main/java/net/minecraft/server/BlockPosition.java +++ b/src/main/java/net/minecraft/server/BlockPosition.java @@ -120,6 +120,7 @@ public class BlockPosition extends BaseBlockPosition implements MinecraftSeriali @@ -1938,7 +2191,7 @@ index c88a62f6b7..5dbd3e60fe 100644 this.d = i; } diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 55373cae07..af10c18d44 100644 +index 55373cae0..c50fe1c24 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -25,7 +25,7 @@ import org.apache.logging.log4j.Logger; @@ -1968,19 +2221,101 @@ index 55373cae07..af10c18d44 100644 this.i = chunkconverter; HeightMap.Type[] aheightmap_type = HeightMap.Type.values(); int j = aheightmap_type.length; -@@ -108,6 +108,11 @@ public class Chunk implements IChunkAccess { +@@ -108,6 +108,93 @@ public class Chunk implements IChunkAccess { public boolean needsDecoration; // CraftBukkit end + // Paper start + public final com.destroystokyo.paper.util.maplist.EntityList entities = new com.destroystokyo.paper.util.maplist.EntityList(); + public PlayerChunk playerChunk; ++ ++ static final int NEIGHBOUR_CACHE_RADIUS = 3; ++ public static int getNeighbourCacheRadius() { ++ return NEIGHBOUR_CACHE_RADIUS; ++ } ++ ++ boolean loadedTicketLevel; ++ private long neighbourChunksLoadedBitset; ++ private final Chunk[] loadedNeighbourChunks = new Chunk[(NEIGHBOUR_CACHE_RADIUS * 2 + 1) * (NEIGHBOUR_CACHE_RADIUS * 2 + 1)]; ++ ++ private static int getNeighbourIndex(final int relativeX, final int relativeZ) { ++ // index = (relativeX + NEIGHBOUR_CACHE_RADIUS) + (relativeZ + NEIGHBOUR_CACHE_RADIUS) * (NEIGHBOUR_CACHE_RADIUS * 2 + 1) ++ // optimised variant of the above by moving some of the ops to compile time ++ return relativeX + (relativeZ * (NEIGHBOUR_CACHE_RADIUS * 2 + 1)) + (NEIGHBOUR_CACHE_RADIUS + NEIGHBOUR_CACHE_RADIUS * ((NEIGHBOUR_CACHE_RADIUS * 2 + 1))); ++ } ++ ++ public final Chunk getRelativeNeighbourIfLoaded(final int relativeX, final int relativeZ) { ++ return this.loadedNeighbourChunks[getNeighbourIndex(relativeX, relativeZ)]; ++ } ++ ++ public final boolean isNeighbourLoaded(final int relativeX, final int relativeZ) { ++ return (this.neighbourChunksLoadedBitset & (1L << getNeighbourIndex(relativeX, relativeZ))) != 0; ++ } ++ ++ public final void setNeighbourLoaded(final int relativeX, final int relativeZ, final Chunk chunk) { ++ if (chunk == null) { ++ throw new IllegalArgumentException("Chunk must be non-null, neighbour: (" + relativeX + "," + relativeZ + "), chunk: " + this.loc); ++ } ++ final int index = getNeighbourIndex(relativeX, relativeZ); ++ this.loadedNeighbourChunks[index] = chunk; ++ this.neighbourChunksLoadedBitset |= (1L << index); ++ } ++ ++ public final void setNeighbourUnloaded(final int relativeX, final int relativeZ) { ++ final int index = getNeighbourIndex(relativeX, relativeZ); ++ this.loadedNeighbourChunks[index] = null; ++ this.neighbourChunksLoadedBitset &= ~(1L << index); ++ } ++ ++ public final void resetNeighbours() { ++ this.neighbourChunksLoadedBitset = 0L; ++ java.util.Arrays.fill(this.loadedNeighbourChunks, null); ++ } ++ ++ public final boolean areNeighboursLoaded(final int radius) { ++ // index = relativeX + (relativeZ * (NEIGHBOUR_CACHE_RADIUS * 2 + 1)) + (NEIGHBOUR_CACHE_RADIUS + NEIGHBOUR_CACHE_RADIUS * ((NEIGHBOUR_CACHE_RADIUS * 2 + 1))) ++ switch (radius) { ++ case 0: { ++ return this.loadedTicketLevel; ++ } ++ case 1: { ++ long mask = 0L; ++ for (int dx = -1; dx <= 1; ++dx) { ++ for (int dz = -1; dz <= 1; ++dz) { ++ mask |= (1L << getNeighbourIndex(dx, dz)); ++ } ++ } ++ return (this.neighbourChunksLoadedBitset & mask) == mask; ++ } ++ case 2: { ++ long mask = 0L; ++ for (int dx = -2; dx <= 2; ++dx) { ++ for (int dz = -2; dz <= 2; ++dz) { ++ mask |= (1L << getNeighbourIndex(dx, dz)); ++ } ++ } ++ return (this.neighbourChunksLoadedBitset & mask) == mask; ++ } ++ case 3: { ++ long mask = 0L; ++ for (int dx = -3; dx <= 3; ++dx) { ++ for (int dz = -3; dz <= 3; ++dz) { ++ mask |= (1L << getNeighbourIndex(dx, dz)); ++ } ++ } ++ return (this.neighbourChunksLoadedBitset & mask) == mask; ++ } ++ ++ default: ++ throw new IllegalArgumentException("Radius not recognized: " + radius); ++ } ++ } + // Paper end + public Chunk(World world, ProtoChunk protochunk) { this(world, protochunk.getPos(), protochunk.getBiomeIndex(), protochunk.p(), protochunk.n(), protochunk.o(), protochunk.getInhabitedTime(), protochunk.getSections(), (Consumer) null); Iterator iterator = protochunk.y().iterator(); -@@ -213,6 +218,18 @@ public class Chunk implements IChunkAccess { +@@ -213,6 +300,18 @@ public class Chunk implements IChunkAccess { } } @@ -1999,7 +2334,7 @@ index 55373cae07..af10c18d44 100644 @Override public Fluid getFluid(BlockPosition blockposition) { return this.a(blockposition.getX(), blockposition.getY(), blockposition.getZ()); -@@ -352,6 +369,7 @@ public class Chunk implements IChunkAccess { +@@ -352,6 +451,7 @@ public class Chunk implements IChunkAccess { entity.chunkX = this.loc.x; entity.chunkY = k; entity.chunkZ = this.loc.z; @@ -2007,7 +2342,7 @@ index 55373cae07..af10c18d44 100644 this.entitySlices[k].add(entity); } -@@ -374,6 +392,7 @@ public class Chunk implements IChunkAccess { +@@ -374,6 +474,7 @@ public class Chunk implements IChunkAccess { } this.entitySlices[i].remove(entity); @@ -2015,7 +2350,7 @@ index 55373cae07..af10c18d44 100644 } @Override -@@ -395,6 +414,7 @@ public class Chunk implements IChunkAccess { +@@ -395,6 +496,7 @@ public class Chunk implements IChunkAccess { return this.a(blockposition, Chunk.EnumTileEntityState.CHECK); } @@ -2023,24 +2358,57 @@ index 55373cae07..af10c18d44 100644 @Nullable public TileEntity a(BlockPosition blockposition, Chunk.EnumTileEntityState chunk_enumtileentitystate) { // CraftBukkit start -@@ -507,6 +527,7 @@ public class Chunk implements IChunkAccess { +@@ -506,7 +608,25 @@ public class Chunk implements IChunkAccess { + // CraftBukkit start public void loadCallback() { ++ // Paper start - neighbour cache ++ int chunkX = this.loc.x; ++ int chunkZ = this.loc.z; ++ ChunkProviderServer chunkProvider = ((WorldServer)this.world).getChunkProvider(); ++ for (int dx = -NEIGHBOUR_CACHE_RADIUS; dx <= NEIGHBOUR_CACHE_RADIUS; ++dx) { ++ for (int dz = -NEIGHBOUR_CACHE_RADIUS; dz <= NEIGHBOUR_CACHE_RADIUS; ++dz) { ++ Chunk neighbour = chunkProvider.getChunkAtIfLoadedMainThreadNoCache(chunkX + dx, chunkZ + dz); ++ if (neighbour != null) { ++ neighbour.setNeighbourLoaded(-dx, -dz, this); ++ // should be in cached already ++ this.setNeighbourLoaded(dx, dz, neighbour); ++ } ++ } ++ } ++ this.setNeighbourLoaded(0, 0, this); ++ this.loadedTicketLevel = true; ++ // Paper end - neighbour cache org.bukkit.Server server = this.world.getServer(); + ((WorldServer)this.world).getChunkProvider().addLoadedChunk(this); // Paper if (server != null) { /* * If it's a new world, the first few chunks are generated inside -@@ -545,6 +566,7 @@ public class Chunk implements IChunkAccess { +@@ -545,6 +665,22 @@ public class Chunk implements IChunkAccess { server.getPluginManager().callEvent(unloadEvent); // note: saving can be prevented, but not forced if no saving is actually required this.mustNotSave = !unloadEvent.isSaveChunk(); + ((WorldServer)this.world).getChunkProvider().removeLoadedChunk(this); // Paper ++ // Paper start - neighbour cache ++ int chunkX = this.loc.x; ++ int chunkZ = this.loc.z; ++ ChunkProviderServer chunkProvider = ((WorldServer)this.world).getChunkProvider(); ++ for (int dx = -NEIGHBOUR_CACHE_RADIUS; dx <= NEIGHBOUR_CACHE_RADIUS; ++dx) { ++ for (int dz = -NEIGHBOUR_CACHE_RADIUS; dz <= NEIGHBOUR_CACHE_RADIUS; ++dz) { ++ Chunk neighbour = chunkProvider.getChunkAtIfLoadedMainThreadNoCache(chunkX + dx, chunkZ + dz); ++ if (neighbour != null) { ++ neighbour.setNeighbourUnloaded(-dx, -dz); ++ } ++ } ++ } ++ this.loadedTicketLevel = false; ++ this.resetNeighbours(); ++ // Paper end } // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/ChunkCache.java b/src/main/java/net/minecraft/server/ChunkCache.java -index 11c4d23ba9..53c15c1c0b 100644 +index 11c4d23ba..53c15c1c0 100644 --- a/src/main/java/net/minecraft/server/ChunkCache.java +++ b/src/main/java/net/minecraft/server/ChunkCache.java @@ -8,7 +8,7 @@ public class ChunkCache implements IBlockAccess, ICollisionAccess { @@ -2074,7 +2442,7 @@ index 11c4d23ba9..53c15c1c0b 100644 @Override public TileEntity getTileEntity(BlockPosition blockposition) { diff --git a/src/main/java/net/minecraft/server/ChunkCoordIntPair.java b/src/main/java/net/minecraft/server/ChunkCoordIntPair.java -index 260644bf0b..f2a19acd84 100644 +index 260644bf0..f2a19acd8 100644 --- a/src/main/java/net/minecraft/server/ChunkCoordIntPair.java +++ b/src/main/java/net/minecraft/server/ChunkCoordIntPair.java @@ -31,7 +31,9 @@ public class ChunkCoordIntPair { @@ -2089,7 +2457,7 @@ index 260644bf0b..f2a19acd84 100644 } diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java -index 32c496fa88..2b0ad4226e 100644 +index 32c496fa8..2b0ad4226 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java @@ -23,7 +23,7 @@ public class ChunkProviderServer extends IChunkProvider { @@ -2241,7 +2609,7 @@ index 32c496fa88..2b0ad4226e 100644 @Override public IChunkAccess getChunkAt(int i, int j, ChunkStatus chunkstatus, boolean flag) { diff --git a/src/main/java/net/minecraft/server/DataBits.java b/src/main/java/net/minecraft/server/DataBits.java -index 7ca3a1d0c5..2edd9b8714 100644 +index 7ca3a1d0c..2edd9b871 100644 --- a/src/main/java/net/minecraft/server/DataBits.java +++ b/src/main/java/net/minecraft/server/DataBits.java @@ -83,6 +83,7 @@ public class DataBits { @@ -2253,7 +2621,7 @@ index 7ca3a1d0c5..2edd9b8714 100644 return this.a; } diff --git a/src/main/java/net/minecraft/server/DataPalette.java b/src/main/java/net/minecraft/server/DataPalette.java -index 75ba698868..45403fbe30 100644 +index 75ba69886..45403fbe3 100644 --- a/src/main/java/net/minecraft/server/DataPalette.java +++ b/src/main/java/net/minecraft/server/DataPalette.java @@ -4,10 +4,12 @@ import javax.annotation.Nullable; @@ -2270,7 +2638,7 @@ index 75ba698868..45403fbe30 100644 T a(int i); diff --git a/src/main/java/net/minecraft/server/DataPaletteBlock.java b/src/main/java/net/minecraft/server/DataPaletteBlock.java -index 774a8f5434..d5f5a51872 100644 +index 774a8f543..d5f5a5187 100644 --- a/src/main/java/net/minecraft/server/DataPaletteBlock.java +++ b/src/main/java/net/minecraft/server/DataPaletteBlock.java @@ -11,7 +11,7 @@ import java.util.stream.Collectors; @@ -2312,7 +2680,7 @@ index 774a8f5434..d5f5a51872 100644 this.a(); packetdataserializer.writeByte(this.i); diff --git a/src/main/java/net/minecraft/server/EntityCreature.java b/src/main/java/net/minecraft/server/EntityCreature.java -index fe69161e5b..b40c8d2f83 100644 +index fe69161e5..b40c8d2f8 100644 --- a/src/main/java/net/minecraft/server/EntityCreature.java +++ b/src/main/java/net/minecraft/server/EntityCreature.java @@ -6,6 +6,8 @@ import org.bukkit.event.entity.EntityUnleashEvent; @@ -2325,7 +2693,7 @@ index fe69161e5b..b40c8d2f83 100644 super(entitytypes, world); } diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java -index bdfb173853..0b06fa2b66 100644 +index bdfb17385..0b06fa2b6 100644 --- a/src/main/java/net/minecraft/server/EntityInsentient.java +++ b/src/main/java/net/minecraft/server/EntityInsentient.java @@ -146,6 +146,7 @@ public abstract class EntityInsentient extends EntityLiving { @@ -2337,7 +2705,7 @@ index bdfb173853..0b06fa2b66 100644 // CraftBukkit start - fire event setGoalTarget(entityliving, EntityTargetEvent.TargetReason.UNKNOWN, true); diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java -index 3b1bcf3495..1f350e3352 100644 +index 3b1bcf349..1f350e335 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -129,6 +129,7 @@ public abstract class EntityLiving extends Entity { @@ -2349,7 +2717,7 @@ index 3b1bcf3495..1f350e3352 100644 @Override public float getBukkitYaw() { diff --git a/src/main/java/net/minecraft/server/EntityMonster.java b/src/main/java/net/minecraft/server/EntityMonster.java -index 00c3b666d7..e5322fbae5 100644 +index 00c3b666d..e5322fbae 100644 --- a/src/main/java/net/minecraft/server/EntityMonster.java +++ b/src/main/java/net/minecraft/server/EntityMonster.java @@ -5,6 +5,7 @@ import java.util.function.Predicate; @@ -2361,7 +2729,7 @@ index 00c3b666d7..e5322fbae5 100644 super(entitytypes, world); this.f = 5; diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index ce48210922..57ce9bde64 100644 +index ce4821092..57ce9bde6 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -87,6 +87,8 @@ public class EntityPlayer extends EntityHuman implements ICrafting { @@ -2383,7 +2751,7 @@ index ce48210922..57ce9bde64 100644 this.displayName = this.getName(); this.canPickUpLoot = true; diff --git a/src/main/java/net/minecraft/server/EntityTypes.java b/src/main/java/net/minecraft/server/EntityTypes.java -index 29e776ca19..4328273b1f 100644 +index 29e776ca1..4328273b1 100644 --- a/src/main/java/net/minecraft/server/EntityTypes.java +++ b/src/main/java/net/minecraft/server/EntityTypes.java @@ -4,6 +4,7 @@ import com.mojang.datafixers.DataFixUtils; @@ -2406,7 +2774,7 @@ index 29e776ca19..4328273b1f 100644 } diff --git a/src/main/java/net/minecraft/server/IAsyncTaskHandler.java b/src/main/java/net/minecraft/server/IAsyncTaskHandler.java -index 1890c760f9..7e5ece9d50 100644 +index 1890c760f..7e5ece9d5 100644 --- a/src/main/java/net/minecraft/server/IAsyncTaskHandler.java +++ b/src/main/java/net/minecraft/server/IAsyncTaskHandler.java @@ -68,6 +68,15 @@ public abstract class IAsyncTaskHandler implements Mailbox h = new CompletableFuture(); diff --git a/src/main/java/net/minecraft/server/IWorldReader.java b/src/main/java/net/minecraft/server/IWorldReader.java -index ba315131e1..cbe2aa4c0a 100644 +index ba315131e..cbe2aa4c0 100644 --- a/src/main/java/net/minecraft/server/IWorldReader.java +++ b/src/main/java/net/minecraft/server/IWorldReader.java @@ -4,6 +4,7 @@ import javax.annotation.Nullable; @@ -2480,7 +2848,7 @@ index ba315131e1..cbe2aa4c0a 100644 IChunkAccess getChunkAt(int i, int j, ChunkStatus chunkstatus, boolean flag); diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java -index 75308712d0..aa7501d366 100644 +index 75308712d..aa7501d36 100644 --- a/src/main/java/net/minecraft/server/ItemStack.java +++ b/src/main/java/net/minecraft/server/ItemStack.java @@ -37,10 +37,19 @@ import org.bukkit.event.world.StructureGrowEvent; @@ -2540,10 +2908,10 @@ index 75308712d0..aa7501d366 100644 // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java new file mode 100644 -index 0000000000..de2bc8f6a6 +index 000000000..54c34cc2d --- /dev/null +++ b/src/main/java/net/minecraft/server/MCUtil.java -@@ -0,0 +1,384 @@ +@@ -0,0 +1,390 @@ +package net.minecraft.server; + +import com.destroystokyo.paper.block.TargetBlockInfo; @@ -2570,12 +2938,18 @@ index 0000000000..de2bc8f6a6 + + public static final long INVALID_CHUNK_KEY = getCoordinateKey(Integer.MAX_VALUE, Integer.MAX_VALUE); + ++ public static void ensureTickThread(final String reason) { ++ if (MinecraftServer.getServer().serverThread != Thread.currentThread()) { ++ throw new IllegalStateException(reason); ++ } ++ } ++ + public static long getCoordinateKey(final BlockPosition blockPos) { -+ return getCoordinateKey(blockPos.getX() >> 4, blockPos.getZ() >> 4); ++ return ((long)(blockPos.getZ() >> 4) << 32) | ((blockPos.getX() >> 4) & 0xFFFFFFFFL); + } + + public static long getCoordinateKey(final Entity entity) { -+ return getCoordinateKey(getChunkCoordinate(entity.locX()), getChunkCoordinate(entity.locZ())); ++ return ((long)(MCUtil.fastFloor(entity.locZ()) >> 4) << 32) | ((MCUtil.fastFloor(entity.locX()) >> 4) & 0xFFFFFFFFL); + } + + public static int fastFloor(double x) { @@ -2589,7 +2963,7 @@ index 0000000000..de2bc8f6a6 + } + + public static long getCoordinateKey(final ChunkCoordIntPair pair) { -+ return getCoordinateKey(pair.x, pair.z); ++ return ((long)pair.z << 32) | (pair.x & 0xFFFFFFFFL); + } + + public static long getCoordinateKey(final int x, final int z) { @@ -2617,7 +2991,7 @@ index 0000000000..de2bc8f6a6 + } + + public static long getBlockKey(final BlockPosition pos) { -+ return getBlockKey(pos.getX(), pos.getY(), pos.getZ()); ++ return ((long)pos.getX() & 0x7FFFFFF) | (((long)pos.getZ() & 0x7FFFFFF) << 27) | ((long)pos.getY() << 54); + } + + public static long getBlockKey(final Entity entity) { @@ -2929,7 +3303,7 @@ index 0000000000..de2bc8f6a6 + } +} diff --git a/src/main/java/net/minecraft/server/NBTTagCompound.java b/src/main/java/net/minecraft/server/NBTTagCompound.java -index e85b24a327..75604dbc69 100644 +index e85b24a32..75604dbc6 100644 --- a/src/main/java/net/minecraft/server/NBTTagCompound.java +++ b/src/main/java/net/minecraft/server/NBTTagCompound.java @@ -60,7 +60,7 @@ public class NBTTagCompound implements NBTBase { @@ -2958,7 +3332,7 @@ index e85b24a327..75604dbc69 100644 return new UUID(this.getLong(s + "Most"), this.getLong(s + "Least")); } diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java -index 6700582e36..3ccf166366 100644 +index 6700582e3..3ccf16636 100644 --- a/src/main/java/net/minecraft/server/NetworkManager.java +++ b/src/main/java/net/minecraft/server/NetworkManager.java @@ -159,6 +159,7 @@ public class NetworkManager extends SimpleChannelInboundHandler> { @@ -2990,7 +3364,7 @@ index 6700582e36..3ccf166366 100644 public QueuedPacket(Packet packet, @Nullable GenericFutureListener> genericfuturelistener) { this.a = packet; diff --git a/src/main/java/net/minecraft/server/PacketDataSerializer.java b/src/main/java/net/minecraft/server/PacketDataSerializer.java -index 81b6f4581f..d9574a9ace 100644 +index 81b6f4581..d9574a9ac 100644 --- a/src/main/java/net/minecraft/server/PacketDataSerializer.java +++ b/src/main/java/net/minecraft/server/PacketDataSerializer.java @@ -33,6 +33,7 @@ public class PacketDataSerializer extends ByteBuf { @@ -3002,7 +3376,7 @@ index 81b6f4581f..d9574a9ace 100644 for (int j = 1; j < 5; ++j) { if ((i & -1 << j * 7) == 0) { diff --git a/src/main/java/net/minecraft/server/PacketEncoder.java b/src/main/java/net/minecraft/server/PacketEncoder.java -index 90223deae3..63c4dbd327 100644 +index 90223deae..63c4dbd32 100644 --- a/src/main/java/net/minecraft/server/PacketEncoder.java +++ b/src/main/java/net/minecraft/server/PacketEncoder.java @@ -42,6 +42,7 @@ public class PacketEncoder extends MessageToByteEncoder> { @@ -3014,7 +3388,7 @@ index 90223deae3..63c4dbd327 100644 throw new SkipEncodeException(throwable); } else { diff --git a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java -index 677e3e5f68..3a1d0deb0d 100644 +index 677e3e5f6..3a1d0deb0 100644 --- a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java +++ b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java @@ -17,7 +17,7 @@ public class PacketPlayOutMapChunk implements Packet { @@ -3035,7 +3409,7 @@ index 677e3e5f68..3a1d0deb0d 100644 int j = 0; ChunkSection[] achunksection = chunk.getSections(); diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java -index 5c5bf010d0..c4bbee7d6a 100644 +index 5c5bf010d..c4bbee7d6 100644 --- a/src/main/java/net/minecraft/server/PlayerChunk.java +++ b/src/main/java/net/minecraft/server/PlayerChunk.java @@ -19,9 +19,9 @@ public class PlayerChunk { @@ -3207,7 +3581,7 @@ index 5c5bf010d0..c4bbee7d6a 100644 } diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index 7ad30548e2..93d838ec2d 100644 +index 7ad30548e..93d838ec2 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java @@ -99,6 +99,35 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { @@ -3256,7 +3630,7 @@ index 7ad30548e2..93d838ec2d 100644 @Override diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java -index 0c496ee0a0..6a681d694e 100644 +index 0c496ee0a..6a681d694 100644 --- a/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/src/main/java/net/minecraft/server/PlayerConnection.java @@ -67,9 +67,9 @@ public class PlayerConnection implements PacketListenerPlayIn { @@ -3273,7 +3647,7 @@ index 0c496ee0a0..6a681d694e 100644 private volatile int chatThrottle; private static final AtomicIntegerFieldUpdater chatSpamField = AtomicIntegerFieldUpdater.newUpdater(PlayerConnection.class, "chatThrottle"); diff --git a/src/main/java/net/minecraft/server/PlayerInventory.java b/src/main/java/net/minecraft/server/PlayerInventory.java -index 08768a3c87..d103cfaace 100644 +index 08768a3c8..d103cfaac 100644 --- a/src/main/java/net/minecraft/server/PlayerInventory.java +++ b/src/main/java/net/minecraft/server/PlayerInventory.java @@ -17,7 +17,7 @@ public class PlayerInventory implements IInventory, INamableTileEntity { @@ -3286,7 +3660,7 @@ index 08768a3c87..d103cfaace 100644 public final EntityHuman player; private ItemStack carried; diff --git a/src/main/java/net/minecraft/server/PotionUtil.java b/src/main/java/net/minecraft/server/PotionUtil.java -index b3824898da..bf4172be52 100644 +index b3824898d..bf4172be5 100644 --- a/src/main/java/net/minecraft/server/PotionUtil.java +++ b/src/main/java/net/minecraft/server/PotionUtil.java @@ -110,6 +110,7 @@ public class PotionUtil { @@ -3298,7 +3672,7 @@ index b3824898da..bf4172be52 100644 MinecraftKey minecraftkey = IRegistry.POTION.getKey(potionregistry); diff --git a/src/main/java/net/minecraft/server/ProtoChunk.java b/src/main/java/net/minecraft/server/ProtoChunk.java -index 6e65306a27..39339fa275 100644 +index 6e65306a2..39339fa27 100644 --- a/src/main/java/net/minecraft/server/ProtoChunk.java +++ b/src/main/java/net/minecraft/server/ProtoChunk.java @@ -80,6 +80,18 @@ public class ProtoChunk implements IChunkAccess { @@ -3321,7 +3695,7 @@ index 6e65306a27..39339fa275 100644 public IBlockData getType(BlockPosition blockposition) { int i = blockposition.getY(); diff --git a/src/main/java/net/minecraft/server/RegionFile.java b/src/main/java/net/minecraft/server/RegionFile.java -index 7b6e0e86b0..187c4e0f58 100644 +index 7b6e0e86b..187c4e0f5 100644 --- a/src/main/java/net/minecraft/server/RegionFile.java +++ b/src/main/java/net/minecraft/server/RegionFile.java @@ -88,6 +88,7 @@ public class RegionFile implements AutoCloseable { @@ -3333,7 +3707,7 @@ index 7b6e0e86b0..187c4e0f58 100644 public synchronized DataInputStream a(ChunkCoordIntPair chunkcoordintpair) throws IOException { int i = this.getOffset(chunkcoordintpair); diff --git a/src/main/java/net/minecraft/server/RegionLimitedWorldAccess.java b/src/main/java/net/minecraft/server/RegionLimitedWorldAccess.java -index 8c123f265e..9d0e8c2d43 100644 +index 8c123f265..9d0e8c2d4 100644 --- a/src/main/java/net/minecraft/server/RegionLimitedWorldAccess.java +++ b/src/main/java/net/minecraft/server/RegionLimitedWorldAccess.java @@ -108,6 +108,26 @@ public class RegionLimitedWorldAccess implements GeneratorAccess { @@ -3364,7 +3738,7 @@ index 8c123f265e..9d0e8c2d43 100644 public IBlockData getType(BlockPosition blockposition) { return this.getChunkAt(blockposition.getX() >> 4, blockposition.getZ() >> 4).getType(blockposition); diff --git a/src/main/java/net/minecraft/server/RegistryBlockID.java b/src/main/java/net/minecraft/server/RegistryBlockID.java -index 4efcb8b595..60948afa4e 100644 +index 4efcb8b59..60948afa4 100644 --- a/src/main/java/net/minecraft/server/RegistryBlockID.java +++ b/src/main/java/net/minecraft/server/RegistryBlockID.java @@ -57,6 +57,7 @@ public class RegistryBlockID implements Registry { @@ -3376,7 +3750,7 @@ index 4efcb8b595..60948afa4e 100644 return this.b.size(); } diff --git a/src/main/java/net/minecraft/server/SystemUtils.java b/src/main/java/net/minecraft/server/SystemUtils.java -index 7b92ecfff9..7e224ebeff 100644 +index 7b92ecfff..7e224ebef 100644 --- a/src/main/java/net/minecraft/server/SystemUtils.java +++ b/src/main/java/net/minecraft/server/SystemUtils.java @@ -58,7 +58,7 @@ public class SystemUtils { @@ -3389,7 +3763,7 @@ index 7b92ecfff9..7e224ebeff 100644 public static long getTimeMillis() { diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index 2e1eabba14..2a4fa455ff 100644 +index 2e1eabba1..2a4fa455f 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -22,6 +22,7 @@ import org.bukkit.craftbukkit.SpigotTimings; // Spigot @@ -3453,7 +3827,7 @@ index 2e1eabba14..2a4fa455ff 100644 return this.setTypeAndData(blockposition, fluid.getBlockData(), 3 | (flag ? 64 : 0)); diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index d5014abc9d..8a5ac6f69b 100644 +index d5014abc9..8a5ac6f69 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -973,6 +973,7 @@ public class WorldServer extends World { @@ -3473,7 +3847,7 @@ index d5014abc9d..8a5ac6f69b 100644 this.getScoreboard().a(entity); diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java -index e181df6f4d..4a9132c701 100644 +index e181df6f4..4a9132c70 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java @@ -85,6 +85,7 @@ public final class CraftItemStack extends ItemStack { @@ -3485,7 +3859,7 @@ index e181df6f4d..4a9132c701 100644 /** * Mirror diff --git a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java -index d8358a0f03..d0b813008c 100644 +index d8358a0f0..d0b813008 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java +++ b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java @@ -196,4 +196,22 @@ public class DummyGeneratorAccess implements GeneratorAccess { @@ -3512,7 +3886,7 @@ index d8358a0f03..d0b813008c 100644 + // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/util/UnsafeList.java b/src/main/java/org/bukkit/craftbukkit/util/UnsafeList.java -index 1aec70a1f1..f72c13beda 100644 +index 1aec70a1f..f72c13bed 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/UnsafeList.java +++ b/src/main/java/org/bukkit/craftbukkit/util/UnsafeList.java @@ -17,7 +17,7 @@ import java.util.RandomAccess; @@ -3525,5 +3899,5 @@ index 1aec70a1f1..f72c13beda 100644 private int initialCapacity; -- -2.25.1 +2.26.0 diff --git a/Spigot-Server-Patches/0007-Store-reference-to-current-Chunk-for-Entity-and-Bloc.patch b/Spigot-Server-Patches/0007-Store-reference-to-current-Chunk-for-Entity-and-Bloc.patch index 65d996fdc..5800b8e61 100644 --- a/Spigot-Server-Patches/0007-Store-reference-to-current-Chunk-for-Entity-and-Bloc.patch +++ b/Spigot-Server-Patches/0007-Store-reference-to-current-Chunk-for-Entity-and-Bloc.patch @@ -1,4 +1,4 @@ -From 3cf32449e02bb6944e4ec14734cbc3f96f2e3168 Mon Sep 17 00:00:00 2001 +From 4f4068b7e3d12e9bd14bf1435449935da11ff9fb Mon Sep 17 00:00:00 2001 From: Aikar Date: Wed, 4 Jul 2018 02:10:36 -0400 Subject: [PATCH] Store reference to current Chunk for Entity and Block @@ -8,7 +8,7 @@ This enables us a fast reference to the entities current chunk instead of having to look it up by hashmap lookups. diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index af10c18d44..02b142fe8b 100644 +index c50fe1c24..061384b01 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -29,7 +29,7 @@ public class Chunk implements IChunkAccess { @@ -58,7 +58,7 @@ index af10c18d44..02b142fe8b 100644 this.l = Maps.newHashMap(); this.m = Maps.newHashMap(); this.n = new ShortList[16]; -@@ -366,6 +391,7 @@ public class Chunk implements IChunkAccess { +@@ -448,6 +473,7 @@ public class Chunk implements IChunkAccess { } entity.inChunk = true; @@ -66,7 +66,7 @@ index af10c18d44..02b142fe8b 100644 entity.chunkX = this.loc.x; entity.chunkY = k; entity.chunkZ = this.loc.z; -@@ -378,6 +404,7 @@ public class Chunk implements IChunkAccess { +@@ -460,6 +486,7 @@ public class Chunk implements IChunkAccess { ((HeightMap) this.heightMap.get(heightmap_type)).a(along); } @@ -74,7 +74,7 @@ index af10c18d44..02b142fe8b 100644 public void b(Entity entity) { this.a(entity, entity.chunkY); } -@@ -391,7 +418,12 @@ public class Chunk implements IChunkAccess { +@@ -473,7 +500,12 @@ public class Chunk implements IChunkAccess { i = this.entitySlices.length - 1; } @@ -89,7 +89,7 @@ index af10c18d44..02b142fe8b 100644 } diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 7899fd6d88..2890e8121d 100644 +index 7899fd6d8..2890e8121 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -134,7 +134,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke @@ -155,7 +155,7 @@ index 7899fd6d88..2890e8121d 100644 private String entityKeyString; diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java -index 9071bb7ece..820180ab3f 100644 +index 9071bb7ec..820180ab3 100644 --- a/src/main/java/net/minecraft/server/TileEntity.java +++ b/src/main/java/net/minecraft/server/TileEntity.java @@ -51,6 +51,15 @@ public abstract class TileEntity implements KeyedObject { // Paper @@ -175,7 +175,7 @@ index 9071bb7ece..820180ab3f 100644 @Nullable diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -index 63ecbcd47a..c82c213260 100644 +index 63ecbcd47..c82c21326 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -138,6 +138,7 @@ import net.minecraft.server.EntityZombieVillager; @@ -200,5 +200,5 @@ index 63ecbcd47a..c82c213260 100644 /** * Order is *EXTREMELY* important -- keep it right! =D -- -2.25.1 +2.26.0 diff --git a/Spigot-Server-Patches/0008-Store-counts-for-each-Entity-Block-Entity-Type.patch b/Spigot-Server-Patches/0008-Store-counts-for-each-Entity-Block-Entity-Type.patch index e2fdc80bb..66ba662fe 100644 --- a/Spigot-Server-Patches/0008-Store-counts-for-each-Entity-Block-Entity-Type.patch +++ b/Spigot-Server-Patches/0008-Store-counts-for-each-Entity-Block-Entity-Type.patch @@ -1,4 +1,4 @@ -From 89510d05fbcf1bfad15bd021c056c3822a5f9c88 Mon Sep 17 00:00:00 2001 +From 0943d0da18af92bd7cb5fe9c9143f01d2d282b30 Mon Sep 17 00:00:00 2001 From: Aikar Date: Wed, 4 Jul 2018 02:13:59 -0400 Subject: [PATCH] Store counts for each Entity/Block Entity Type @@ -6,7 +6,7 @@ Subject: [PATCH] Store counts for each Entity/Block Entity Type Opens door for future patches to optimize performance diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 02b142fe8b..e58dd3e6df 100644 +index 061384b01..2b6fe2e01 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -56,15 +56,19 @@ public class Chunk implements IChunkAccess { @@ -37,7 +37,7 @@ index 02b142fe8b..e58dd3e6df 100644 } return removed; } -@@ -390,6 +395,7 @@ public class Chunk implements IChunkAccess { +@@ -472,6 +477,7 @@ public class Chunk implements IChunkAccess { k = this.entitySlices.length - 1; } @@ -45,7 +45,7 @@ index 02b142fe8b..e58dd3e6df 100644 entity.inChunk = true; entity.setCurrentChunk(this); // Paper entity.chunkX = this.loc.x; -@@ -423,6 +429,7 @@ public class Chunk implements IChunkAccess { +@@ -505,6 +511,7 @@ public class Chunk implements IChunkAccess { if (!this.entitySlices[i].remove(entity)) { return; } @@ -54,5 +54,5 @@ index 02b142fe8b..e58dd3e6df 100644 this.entities.remove(entity); // Paper } -- -2.25.1 +2.26.0 diff --git a/Spigot-Server-Patches/0009-Timings-v2.patch b/Spigot-Server-Patches/0009-Timings-v2.patch index 8d7c2e033..1a98899f8 100644 --- a/Spigot-Server-Patches/0009-Timings-v2.patch +++ b/Spigot-Server-Patches/0009-Timings-v2.patch @@ -1,4 +1,4 @@ -From d399796575a146a7220fa73b00576640faac33df Mon Sep 17 00:00:00 2001 +From fb60ef200e888ae1e048b84dce79c1f3b74a937e Mon Sep 17 00:00:00 2001 From: Aikar Date: Thu, 3 Mar 2016 04:00:11 -0600 Subject: [PATCH] Timings v2 @@ -6,7 +6,7 @@ Subject: [PATCH] Timings v2 diff --git a/src/main/java/co/aikar/timings/MinecraftTimings.java b/src/main/java/co/aikar/timings/MinecraftTimings.java new file mode 100644 -index 0000000000..69e26a8267 +index 000000000..69e26a826 --- /dev/null +++ b/src/main/java/co/aikar/timings/MinecraftTimings.java @@ -0,0 +1,141 @@ @@ -153,7 +153,7 @@ index 0000000000..69e26a8267 +} diff --git a/src/main/java/co/aikar/timings/WorldTimingsHandler.java b/src/main/java/co/aikar/timings/WorldTimingsHandler.java new file mode 100644 -index 0000000000..27ce4a828e +index 000000000..27ce4a828 --- /dev/null +++ b/src/main/java/co/aikar/timings/WorldTimingsHandler.java @@ -0,0 +1,126 @@ @@ -284,7 +284,7 @@ index 0000000000..27ce4a828e + } +} diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java -index b6d470e594..f402a29b09 100644 +index b6d470e59..f402a29b0 100644 --- a/src/main/java/com/destroystokyo/paper/PaperConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java @@ -14,11 +14,14 @@ import java.util.concurrent.TimeUnit; @@ -331,7 +331,7 @@ index b6d470e594..f402a29b09 100644 + } } diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java -index cd72a9c845..5de881371a 100644 +index cd72a9c84..5de881371 100644 --- a/src/main/java/net/minecraft/server/Block.java +++ b/src/main/java/net/minecraft/server/Block.java @@ -31,6 +31,15 @@ public class Block implements IMaterial { @@ -351,10 +351,10 @@ index cd72a9c845..5de881371a 100644 private final float frictionFactor; private final float f; diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index e58dd3e6df..0b32179b79 100644 +index 2b6fe2e01..87c5e09a5 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java -@@ -576,6 +576,7 @@ public class Chunk implements IChunkAccess { +@@ -675,6 +675,7 @@ public class Chunk implements IChunkAccess { server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(this.bukkitChunk, this.needsDecoration)); if (this.needsDecoration) { @@ -362,7 +362,7 @@ index e58dd3e6df..0b32179b79 100644 this.needsDecoration = false; java.util.Random random = new java.util.Random(); random.setSeed(world.getSeed()); -@@ -595,6 +596,7 @@ public class Chunk implements IChunkAccess { +@@ -694,6 +695,7 @@ public class Chunk implements IChunkAccess { } } server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkPopulateEvent(bukkitChunk)); @@ -371,7 +371,7 @@ index e58dd3e6df..0b32179b79 100644 } } diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java -index 2b0ad4226e..a878f7c759 100644 +index 2b0ad4226..a878f7c75 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java @@ -227,11 +227,13 @@ public class ChunkProviderServer extends IChunkProvider { @@ -468,7 +468,7 @@ index 2b0ad4226e..a878f7c759 100644 @Override diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java -index e16d30f2ca..4af5a230ba 100644 +index e16d30f2c..4af5a230b 100644 --- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java +++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java @@ -1,5 +1,6 @@ @@ -506,7 +506,7 @@ index e16d30f2ca..4af5a230ba 100644 } diff --git a/src/main/java/net/minecraft/server/CustomFunction.java b/src/main/java/net/minecraft/server/CustomFunction.java -index 8d7a6d2403..707bd2600d 100644 +index 8d7a6d240..707bd2600 100644 --- a/src/main/java/net/minecraft/server/CustomFunction.java +++ b/src/main/java/net/minecraft/server/CustomFunction.java @@ -13,12 +13,22 @@ public class CustomFunction { @@ -533,7 +533,7 @@ index 8d7a6d2403..707bd2600d 100644 return this.b; } diff --git a/src/main/java/net/minecraft/server/CustomFunctionData.java b/src/main/java/net/minecraft/server/CustomFunctionData.java -index ba40d5fbb5..ee42e1dfa4 100644 +index ba40d5fbb..ee42e1dfa 100644 --- a/src/main/java/net/minecraft/server/CustomFunctionData.java +++ b/src/main/java/net/minecraft/server/CustomFunctionData.java @@ -103,7 +103,7 @@ public class CustomFunctionData implements IResourcePackListener { @@ -546,7 +546,7 @@ index ba40d5fbb5..ee42e1dfa4 100644 int k = 0; CustomFunction.c[] acustomfunction_c = customfunction.b(); diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java -index 9eed98e379..d6646d7e61 100644 +index 9eed98e37..d6646d7e6 100644 --- a/src/main/java/net/minecraft/server/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/DedicatedServer.java @@ -20,6 +20,8 @@ import java.util.List; @@ -634,7 +634,7 @@ index 9eed98e379..d6646d7e61 100644 } diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 2890e8121d..e9d0a4eb90 100644 +index 2890e8121..e9d0a4eb9 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -29,7 +29,8 @@ import org.bukkit.command.CommandSender; @@ -673,7 +673,7 @@ index 2890e8121d..e9d0a4eb90 100644 protected BlockPosition ag() { diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java -index 1f350e3352..35e3f1c78d 100644 +index 1f350e335..35e3f1c78 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -37,7 +37,7 @@ import org.bukkit.event.entity.EntityTeleportEvent; @@ -749,7 +749,7 @@ index 1f350e3352..35e3f1c78d 100644 } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index b4a0bd7951..4dc6917759 100644 +index b4a0bd795..4dc691775 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -63,7 +63,7 @@ import org.bukkit.craftbukkit.CraftServer; @@ -925,7 +925,7 @@ index b4a0bd7951..4dc6917759 100644 this.methodProfiler.exit(); } diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index 93d838ec2d..2a6955f855 100644 +index 93d838ec2..2a6955f85 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java @@ -1,7 +1,9 @@ @@ -1008,7 +1008,7 @@ index 93d838ec2d..2a6955f855 100644 protected void broadcast(Entity entity, Packet packet) { diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java -index 6a681d694e..914366afcd 100644 +index 6a681d694..914366afc 100644 --- a/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/src/main/java/net/minecraft/server/PlayerConnection.java @@ -58,6 +58,7 @@ import org.bukkit.inventory.CraftingInventory; @@ -1063,7 +1063,7 @@ index 6a681d694e..914366afcd 100644 // this.minecraftServer.getCommandDispatcher().a(this.player.getCommandListener(), s); // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/PlayerConnectionUtils.java b/src/main/java/net/minecraft/server/PlayerConnectionUtils.java -index 2c671629a4..eb3269e0ea 100644 +index 2c671629a..eb3269e0e 100644 --- a/src/main/java/net/minecraft/server/PlayerConnectionUtils.java +++ b/src/main/java/net/minecraft/server/PlayerConnectionUtils.java @@ -2,6 +2,8 @@ package net.minecraft.server; @@ -1090,7 +1090,7 @@ index 2c671629a4..eb3269e0ea 100644 PlayerConnectionUtils.LOGGER.debug("Ignoring packet due to disconnection: " + packet); } diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java -index 94ed83baf0..f28be11eee 100644 +index 94ed83baf..f28be11ee 100644 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -1,5 +1,6 @@ @@ -1114,7 +1114,7 @@ index 94ed83baf0..f28be11eee 100644 public WhiteList getWhitelist() { diff --git a/src/main/java/net/minecraft/server/TickListServer.java b/src/main/java/net/minecraft/server/TickListServer.java -index 00bbd34b6a..f533860bbe 100644 +index 00bbd34b6..f533860bb 100644 --- a/src/main/java/net/minecraft/server/TickListServer.java +++ b/src/main/java/net/minecraft/server/TickListServer.java @@ -28,13 +28,18 @@ public class TickListServer implements TickList { @@ -1164,7 +1164,7 @@ index 00bbd34b6a..f533860bbe 100644 this.g.clear(); } diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java -index 820180ab3f..fa6400dccd 100644 +index 820180ab3..fa6400dcc 100644 --- a/src/main/java/net/minecraft/server/TileEntity.java +++ b/src/main/java/net/minecraft/server/TileEntity.java @@ -9,11 +9,12 @@ import org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer; @@ -1183,7 +1183,7 @@ index 820180ab3f..fa6400dccd 100644 private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry(); public CraftPersistentDataContainer persistentDataContainer; diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index 2a4fa455ff..f572c5f227 100644 +index 2a4fa455f..f572c5f22 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -1,5 +1,7 @@ @@ -1239,7 +1239,7 @@ index 2a4fa455ff..f572c5f227 100644 CrashReport crashreport = CrashReport.a(throwable, "Ticking entity"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being ticked"); diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 8a5ac6f69b..6810d49b17 100644 +index 8a5ac6f69..6810d49b1 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -1,6 +1,8 @@ @@ -1384,7 +1384,7 @@ index 8a5ac6f69b..6810d49b17 100644 // CraftBukkit start - moved from MinecraftServer.saveChunks diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 8d1f066f00..f3eacb1819 100644 +index 8d1f066f0..f3eacb181 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -1973,12 +1973,31 @@ public final class CraftServer implements Server { @@ -1421,7 +1421,7 @@ index 8d1f066f00..f3eacb1819 100644 org.spigotmc.RestartCommand.restart(); diff --git a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java b/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java deleted file mode 100644 -index 2bd22a3698..0000000000 +index 2bd22a369..000000000 --- a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java +++ /dev/null @@ -1,162 +0,0 @@ @@ -1588,7 +1588,7 @@ index 2bd22a3698..0000000000 - } -} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 4fed5dc92f..d7a4e50f23 100644 +index 4fed5dc92..d7a4e50f2 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -1718,6 +1718,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -1607,7 +1607,7 @@ index 4fed5dc92f..d7a4e50f23 100644 public Player.Spigot spigot() diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java -index b90979c7ba..8823f94f7b 100644 +index b90979c7b..8823f94f7 100644 --- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java +++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java @@ -1,5 +1,6 @@ @@ -1673,7 +1673,7 @@ index b90979c7ba..8823f94f7b 100644 private boolean isReady(final int currentTick) { diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java -index 3f55381c15..0d9a466809 100644 +index 3f55381c1..0d9a46680 100644 --- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java +++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java @@ -1,9 +1,11 @@ @@ -1758,7 +1758,7 @@ index 3f55381c15..0d9a466809 100644 - // Spigot end } diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftIconCache.java b/src/main/java/org/bukkit/craftbukkit/util/CraftIconCache.java -index e52ef47b78..3d90b34268 100644 +index e52ef47b7..3d90b3426 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftIconCache.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftIconCache.java @@ -5,6 +5,7 @@ import org.bukkit.util.CachedServerIcon; @@ -1770,7 +1770,7 @@ index e52ef47b78..3d90b34268 100644 this.value = value; } diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index 68728b4d86..02f3300533 100644 +index 68728b4d8..02f330053 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -298,6 +298,13 @@ public final class CraftMagicNumbers implements UnsafeValues { @@ -1788,7 +1788,7 @@ index 68728b4d86..02f3300533 100644 * This helper class represents the different NBT Tags. *

diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java -index ca7789b5e0..4423839697 100644 +index ca7789b5e..442383969 100644 --- a/src/main/java/org/spigotmc/ActivationRange.java +++ b/src/main/java/org/spigotmc/ActivationRange.java @@ -31,7 +31,7 @@ import net.minecraft.server.EntityWither; @@ -1849,5 +1849,5 @@ index ca7789b5e0..4423839697 100644 } } -- -2.25.1 +2.26.0 diff --git a/Spigot-Server-Patches/0021-Remove-invalid-mob-spawner-tile-entities.patch b/Spigot-Server-Patches/0021-Remove-invalid-mob-spawner-tile-entities.patch index 000273373..bd7ad993d 100644 --- a/Spigot-Server-Patches/0021-Remove-invalid-mob-spawner-tile-entities.patch +++ b/Spigot-Server-Patches/0021-Remove-invalid-mob-spawner-tile-entities.patch @@ -1,14 +1,14 @@ -From a83cc296f887106ac4f9f510f9fd616b7ed2bac9 Mon Sep 17 00:00:00 2001 +From c91df8ae2fc7a6a054370eb8fef42fbb4d65333d Mon Sep 17 00:00:00 2001 From: Byteflux Date: Tue, 1 Mar 2016 15:08:03 -0600 Subject: [PATCH] Remove invalid mob spawner tile entities diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 0b32179b79..9adb212790 100644 +index 87c5e09a5..14097d40d 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java -@@ -508,6 +508,10 @@ public class Chunk implements IChunkAccess { +@@ -590,6 +590,10 @@ public class Chunk implements IChunkAccess { } // CraftBukkit start @@ -20,5 +20,5 @@ index 0b32179b79..9adb212790 100644 System.out.println("Attempted to place a tile entity (" + tileentity + ") at " + tileentity.position.getX() + "," + tileentity.position.getY() + "," + tileentity.position.getZ() + " (" + getType(blockposition) + ") where there was no entity tile!"); -- -2.25.1 +2.26.0 diff --git a/Spigot-Server-Patches/0054-Add-exception-reporting-event.patch b/Spigot-Server-Patches/0054-Add-exception-reporting-event.patch index 2ba9f1858..5ab2de912 100644 --- a/Spigot-Server-Patches/0054-Add-exception-reporting-event.patch +++ b/Spigot-Server-Patches/0054-Add-exception-reporting-event.patch @@ -1,4 +1,4 @@ -From 6a954ca055a4da758ea6442c0717d9b26fbf4776 Mon Sep 17 00:00:00 2001 +From 40a3ef84d5ce7daf39eb9cfb36cfd351c7c8d286 Mon Sep 17 00:00:00 2001 From: Joseph Hirschfeld Date: Thu, 3 Mar 2016 03:15:41 -0600 Subject: [PATCH] Add exception reporting event @@ -6,7 +6,7 @@ Subject: [PATCH] Add exception reporting event diff --git a/src/main/java/com/destroystokyo/paper/ServerSchedulerReportingWrapper.java b/src/main/java/com/destroystokyo/paper/ServerSchedulerReportingWrapper.java new file mode 100644 -index 0000000000..f699ce18ca +index 000000000..f699ce18c --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/ServerSchedulerReportingWrapper.java @@ -0,0 +1,38 @@ @@ -49,7 +49,7 @@ index 0000000000..f699ce18ca + } +} diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 9adb212790..f3d20f214d 100644 +index 14097d40d..ac11e214b 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -1,5 +1,6 @@ @@ -59,7 +59,7 @@ index 9adb212790..f3d20f214d 100644 import com.google.common.collect.Maps; import com.google.common.collect.Sets; import it.unimi.dsi.fastutil.longs.LongOpenHashSet; -@@ -513,10 +514,15 @@ public class Chunk implements IChunkAccess { +@@ -595,10 +596,15 @@ public class Chunk implements IChunkAccess { this.tileEntities.remove(blockposition); // Paper end } else { @@ -80,7 +80,7 @@ index 9adb212790..f3d20f214d 100644 } } diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java -index a878f7c759..e5d89299f6 100644 +index a878f7c75..e5d89299f 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java @@ -15,6 +15,9 @@ import java.util.function.BooleanSupplier; @@ -94,7 +94,7 @@ index a878f7c759..e5d89299f6 100644 public class ChunkProviderServer extends IChunkProvider { diff --git a/src/main/java/net/minecraft/server/NameReferencingFileConverter.java b/src/main/java/net/minecraft/server/NameReferencingFileConverter.java -index c9c2b00251..1422503e11 100644 +index c9c2b0025..1422503e1 100644 --- a/src/main/java/net/minecraft/server/NameReferencingFileConverter.java +++ b/src/main/java/net/minecraft/server/NameReferencingFileConverter.java @@ -1,5 +1,6 @@ @@ -121,7 +121,7 @@ index c9c2b00251..1422503e11 100644 } // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index 3dd72e0842..291c2a17bb 100644 +index 3dd72e084..291c2a17b 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java @@ -727,6 +727,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { @@ -141,7 +141,7 @@ index 3dd72e0842..291c2a17bb 100644 } } diff --git a/src/main/java/net/minecraft/server/RegionFile.java b/src/main/java/net/minecraft/server/RegionFile.java -index 187c4e0f58..c2312a227c 100644 +index 187c4e0f5..c2312a227 100644 --- a/src/main/java/net/minecraft/server/RegionFile.java +++ b/src/main/java/net/minecraft/server/RegionFile.java @@ -241,6 +241,7 @@ public class RegionFile implements AutoCloseable { @@ -161,7 +161,7 @@ index 187c4e0f58..c2312a227c 100644 } finally { if (filechannel != null) { diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java -index 8ba344df64..02157d051f 100644 +index 8ba344df6..02157d051 100644 --- a/src/main/java/net/minecraft/server/SpawnerCreature.java +++ b/src/main/java/net/minecraft/server/SpawnerCreature.java @@ -8,6 +8,7 @@ import org.apache.logging.log4j.LogManager; @@ -189,7 +189,7 @@ index 8ba344df64..02157d051f 100644 } diff --git a/src/main/java/net/minecraft/server/VillageSiege.java b/src/main/java/net/minecraft/server/VillageSiege.java -index d5e9bae709..1bcf01c09a 100644 +index d5e9bae70..1bcf01c09 100644 --- a/src/main/java/net/minecraft/server/VillageSiege.java +++ b/src/main/java/net/minecraft/server/VillageSiege.java @@ -1,5 +1,7 @@ @@ -209,7 +209,7 @@ index d5e9bae709..1bcf01c09a 100644 } diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index 6e8ac186c9..a6b2867094 100644 +index 6e8ac186c..a6b286709 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -2,6 +2,9 @@ package net.minecraft.server; @@ -248,7 +248,7 @@ index 6e8ac186c9..a6b2867094 100644 return; // Paper end diff --git a/src/main/java/net/minecraft/server/WorldPersistentData.java b/src/main/java/net/minecraft/server/WorldPersistentData.java -index 19e68a7831..a2a25cf6a4 100644 +index 19e68a783..a2a25cf6a 100644 --- a/src/main/java/net/minecraft/server/WorldPersistentData.java +++ b/src/main/java/net/minecraft/server/WorldPersistentData.java @@ -121,6 +121,7 @@ public class WorldPersistentData { @@ -260,7 +260,7 @@ index 19e68a7831..a2a25cf6a4 100644 } finally { if (pushbackinputstream != null) { diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java -index 8823f94f7b..552daf4376 100644 +index 8823f94f7..552daf437 100644 --- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java +++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java @@ -16,6 +16,9 @@ import java.util.concurrent.atomic.AtomicInteger; @@ -306,5 +306,5 @@ index 8823f94f7b..552daf4376 100644 // (async tasks must live with race-conditions if they attempt to cancel between these few lines of code) } -- -2.25.1 +2.26.0 diff --git a/Spigot-Server-Patches/0072-Optimize-isValidLocation-getType-and-getBlockData-fo.patch b/Spigot-Server-Patches/0072-Optimize-isValidLocation-getType-and-getBlockData-fo.patch index 8fd4118b1..8a4631f73 100644 --- a/Spigot-Server-Patches/0072-Optimize-isValidLocation-getType-and-getBlockData-fo.patch +++ b/Spigot-Server-Patches/0072-Optimize-isValidLocation-getType-and-getBlockData-fo.patch @@ -1,4 +1,4 @@ -From fd4126fd147f51c856b36c021edea2594bfd3458 Mon Sep 17 00:00:00 2001 +From 6e68c9fdd1c3e759ba521c5c6dfeedcead37fc40 Mon Sep 17 00:00:00 2001 From: Aikar Date: Thu, 3 Mar 2016 02:07:55 -0600 Subject: [PATCH] Optimize isValidLocation, getType and getBlockData for inling @@ -12,7 +12,7 @@ Replace all calls to the new place to the unnecessary forward. Optimize getType and getBlockData to manually inline and optimize the calls diff --git a/src/main/java/net/minecraft/server/BaseBlockPosition.java b/src/main/java/net/minecraft/server/BaseBlockPosition.java -index a3b5793e48..71089442c1 100644 +index a3b5793e4..71089442c 100644 --- a/src/main/java/net/minecraft/server/BaseBlockPosition.java +++ b/src/main/java/net/minecraft/server/BaseBlockPosition.java @@ -13,6 +13,14 @@ public class BaseBlockPosition implements Comparable { @@ -31,10 +31,10 @@ index a3b5793e48..71089442c1 100644 public BaseBlockPosition(int i, int j, int k) { this.a = i; diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index f3d20f214d..ee94f59e64 100644 +index ac11e214b..6e50efbf6 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java -@@ -208,12 +208,24 @@ public class Chunk implements IChunkAccess { +@@ -290,12 +290,24 @@ public class Chunk implements IChunkAccess { return this.sections; } @@ -64,7 +64,7 @@ index f3d20f214d..ee94f59e64 100644 IBlockData iblockdata = null; diff --git a/src/main/java/net/minecraft/server/ChunkSection.java b/src/main/java/net/minecraft/server/ChunkSection.java -index 652067757a..0d5deee365 100644 +index 652067757..0d5deee36 100644 --- a/src/main/java/net/minecraft/server/ChunkSection.java +++ b/src/main/java/net/minecraft/server/ChunkSection.java @@ -9,7 +9,7 @@ public class ChunkSection { @@ -77,7 +77,7 @@ index 652067757a..0d5deee365 100644 public ChunkSection(int i) { this(i, (short) 0, (short) 0, (short) 0); diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index c2039d0e46..502da7f52d 100644 +index e7337fc36..6b1ff8f64 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -171,11 +171,11 @@ public abstract class World implements GeneratorAccess, AutoCloseable { @@ -95,5 +95,5 @@ index c2039d0e46..502da7f52d 100644 public static boolean b(int i) { -- -2.25.1 +2.26.0 diff --git a/Spigot-Server-Patches/0076-Configurable-Chunk-Inhabited-Time.patch b/Spigot-Server-Patches/0076-Configurable-Chunk-Inhabited-Time.patch index fa335e91a..a6bfa18cc 100644 --- a/Spigot-Server-Patches/0076-Configurable-Chunk-Inhabited-Time.patch +++ b/Spigot-Server-Patches/0076-Configurable-Chunk-Inhabited-Time.patch @@ -1,4 +1,4 @@ -From 49a9b3de50816606bae0d2754c46d367f3df171d Mon Sep 17 00:00:00 2001 +From 79b3ec2ccd919bc721820a23bacec43279699d65 Mon Sep 17 00:00:00 2001 From: Aikar Date: Mon, 28 Mar 2016 20:46:14 -0400 Subject: [PATCH] Configurable Chunk Inhabited Time @@ -11,7 +11,7 @@ For people who want all chunks to be treated equally, you can chose a fixed valu This allows to fine-tune vanilla gameplay. diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 6ef0e1399e..5872e6b171 100644 +index 6ef0e1399..5872e6b17 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -236,4 +236,14 @@ public class PaperWorldConfig { @@ -30,10 +30,10 @@ index 6ef0e1399e..5872e6b171 100644 + } } diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index ee94f59e64..4fe36bb71d 100644 +index 6e50efbf6..8963acb9f 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java -@@ -842,7 +842,7 @@ public class Chunk implements IChunkAccess { +@@ -956,7 +956,7 @@ public class Chunk implements IChunkAccess { @Override public long getInhabitedTime() { @@ -43,5 +43,5 @@ index ee94f59e64..4fe36bb71d 100644 @Override -- -2.25.1 +2.26.0 diff --git a/Spigot-Server-Patches/0119-Option-to-remove-corrupt-tile-entities.patch b/Spigot-Server-Patches/0119-Option-to-remove-corrupt-tile-entities.patch index 416576a4d..dde3c745e 100644 --- a/Spigot-Server-Patches/0119-Option-to-remove-corrupt-tile-entities.patch +++ b/Spigot-Server-Patches/0119-Option-to-remove-corrupt-tile-entities.patch @@ -1,11 +1,11 @@ -From 56acf52ea2182eae565f88b637844dd0f12f5d17 Mon Sep 17 00:00:00 2001 +From 7d18db5d5b1c93da93819f4c984297cfae943e51 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Wed, 5 Oct 2016 16:27:36 -0500 Subject: [PATCH] Option to remove corrupt tile entities diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 8cf3076f4e..721eceeffc 100644 +index 8cf3076f4..721eceeff 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -298,4 +298,9 @@ public class PaperWorldConfig { @@ -19,10 +19,10 @@ index 8cf3076f4e..721eceeffc 100644 + } } diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 4fe36bb71d..3af311c6eb 100644 +index 8963acb9f..bb58fb796 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java -@@ -534,6 +534,12 @@ public class Chunk implements IChunkAccess { +@@ -616,6 +616,12 @@ public class Chunk implements IChunkAccess { "Chunk coordinates: " + (this.loc.x * 16) + "," + (this.loc.z * 16)); e.printStackTrace(); ServerInternalException.reportInternalException(e); @@ -36,5 +36,5 @@ index 4fe36bb71d..3af311c6eb 100644 // CraftBukkit end } -- -2.25.1 +2.26.0 diff --git a/Spigot-Server-Patches/0135-String-based-Action-Bar-API.patch b/Spigot-Server-Patches/0135-String-based-Action-Bar-API.patch index 06ee8e83d..655e60a84 100644 --- a/Spigot-Server-Patches/0135-String-based-Action-Bar-API.patch +++ b/Spigot-Server-Patches/0135-String-based-Action-Bar-API.patch @@ -1,11 +1,11 @@ -From 52daecb04e84accf7785b87a427e7ddeefffb3ba Mon Sep 17 00:00:00 2001 +From 1da9ef43c3a1ebb4c129002192e045467cb6c16a Mon Sep 17 00:00:00 2001 From: Aikar Date: Tue, 27 Dec 2016 15:02:42 -0500 Subject: [PATCH] String based Action Bar API diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java -index de2bc8f6a6..e42dc05504 100644 +index 54c34cc2d..cc495020e 100644 --- a/src/main/java/net/minecraft/server/MCUtil.java +++ b/src/main/java/net/minecraft/server/MCUtil.java @@ -2,6 +2,7 @@ package net.minecraft.server; @@ -16,7 +16,7 @@ index de2bc8f6a6..e42dc05504 100644 import org.bukkit.Location; import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.CraftWorld; -@@ -92,6 +93,24 @@ public final class MCUtil { +@@ -98,6 +99,24 @@ public final class MCUtil { private MCUtil() {} @@ -42,7 +42,7 @@ index de2bc8f6a6..e42dc05504 100644 public static boolean isMainThread() { return MinecraftServer.getServer().isMainThread(); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 060a21840f..d1745c4e93 100644 +index 060a21840..d1745c4e9 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -216,6 +216,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -65,5 +65,5 @@ index 060a21840f..d1745c4e93 100644 public void setPlayerListHeaderFooter(BaseComponent[] header, BaseComponent[] footer) { if (header != null) { -- -2.25.1 +2.26.0 diff --git a/Spigot-Server-Patches/0156-Basic-PlayerProfile-API.patch b/Spigot-Server-Patches/0156-Basic-PlayerProfile-API.patch index cf438bee2..30188bcc0 100644 --- a/Spigot-Server-Patches/0156-Basic-PlayerProfile-API.patch +++ b/Spigot-Server-Patches/0156-Basic-PlayerProfile-API.patch @@ -1,4 +1,4 @@ -From 449977d43ddf6112be1ed70200b24a6006396d48 Mon Sep 17 00:00:00 2001 +From fb720aecd1ee72dabbc49e34c4b1eab26925602a Mon Sep 17 00:00:00 2001 From: Aikar Date: Mon, 15 Jan 2018 22:11:48 -0500 Subject: [PATCH] Basic PlayerProfile API @@ -7,7 +7,7 @@ Establishes base extension of profile systems for future edits too diff --git a/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java new file mode 100644 -index 0000000000..b151a13c1b +index 000000000..b151a13c1 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java @@ -0,0 +1,280 @@ @@ -293,7 +293,7 @@ index 0000000000..b151a13c1b +} diff --git a/src/main/java/com/destroystokyo/paper/profile/PaperAuthenticationService.java b/src/main/java/com/destroystokyo/paper/profile/PaperAuthenticationService.java new file mode 100644 -index 0000000000..25836b975b +index 000000000..25836b975 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/profile/PaperAuthenticationService.java @@ -0,0 +1,30 @@ @@ -329,7 +329,7 @@ index 0000000000..25836b975b +} diff --git a/src/main/java/com/destroystokyo/paper/profile/PaperGameProfileRepository.java b/src/main/java/com/destroystokyo/paper/profile/PaperGameProfileRepository.java new file mode 100644 -index 0000000000..3bcdb8f93f +index 000000000..3bcdb8f93 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/profile/PaperGameProfileRepository.java @@ -0,0 +1,17 @@ @@ -352,7 +352,7 @@ index 0000000000..3bcdb8f93f +} diff --git a/src/main/java/com/destroystokyo/paper/profile/PaperMinecraftSessionService.java b/src/main/java/com/destroystokyo/paper/profile/PaperMinecraftSessionService.java new file mode 100644 -index 0000000000..4b2a67423f +index 000000000..4b2a67423 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/profile/PaperMinecraftSessionService.java @@ -0,0 +1,29 @@ @@ -387,7 +387,7 @@ index 0000000000..4b2a67423f +} diff --git a/src/main/java/com/destroystokyo/paper/profile/PaperUserAuthentication.java b/src/main/java/com/destroystokyo/paper/profile/PaperUserAuthentication.java new file mode 100644 -index 0000000000..3aceb0ea8a +index 000000000..3aceb0ea8 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/profile/PaperUserAuthentication.java @@ -0,0 +1,11 @@ @@ -403,7 +403,7 @@ index 0000000000..3aceb0ea8a + } +} diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java -index e42dc05504..ddd7277162 100644 +index cc495020e..dae1560be 100644 --- a/src/main/java/net/minecraft/server/MCUtil.java +++ b/src/main/java/net/minecraft/server/MCUtil.java @@ -1,7 +1,10 @@ @@ -417,7 +417,7 @@ index e42dc05504..ddd7277162 100644 import org.apache.commons.lang.exception.ExceptionUtils; import org.bukkit.Location; import org.bukkit.block.BlockFace; -@@ -226,6 +229,10 @@ public final class MCUtil { +@@ -232,6 +235,10 @@ public final class MCUtil { return run.get(); } @@ -429,7 +429,7 @@ index e42dc05504..ddd7277162 100644 * Calculates distance between 2 entities * @param e1 diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 7016dac2d7..c15ca642d0 100644 +index 7016dac2d..c15ca642d 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -1296,7 +1296,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant Date: Mon, 23 Jul 2018 22:18:31 -0400 Subject: [PATCH] Mark chunk dirty anytime entities change to guarantee it @@ -6,10 +6,10 @@ Subject: [PATCH] Mark chunk dirty anytime entities change to guarantee it diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 3af311c6eb..68cde33565 100644 +index bb58fb796..54d48ef5e 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java -@@ -416,6 +416,7 @@ public class Chunk implements IChunkAccess { +@@ -498,6 +498,7 @@ public class Chunk implements IChunkAccess { entity.chunkZ = this.loc.z; this.entities.add(entity); // Paper - per chunk entity list this.entitySlices[k].add(entity); @@ -17,7 +17,7 @@ index 3af311c6eb..68cde33565 100644 } @Override -@@ -443,6 +444,7 @@ public class Chunk implements IChunkAccess { +@@ -525,6 +526,7 @@ public class Chunk implements IChunkAccess { return; } entityCounts.decrement(entity.getMinecraftKeyString()); @@ -26,5 +26,5 @@ index 3af311c6eb..68cde33565 100644 this.entities.remove(entity); // Paper } -- -2.25.1 +2.26.0 diff --git a/Spigot-Server-Patches/0258-Add-some-Debug-to-Chunk-Entity-slices.patch b/Spigot-Server-Patches/0258-Add-some-Debug-to-Chunk-Entity-slices.patch index 1e8db78ea..72dc9b93a 100644 --- a/Spigot-Server-Patches/0258-Add-some-Debug-to-Chunk-Entity-slices.patch +++ b/Spigot-Server-Patches/0258-Add-some-Debug-to-Chunk-Entity-slices.patch @@ -1,4 +1,4 @@ -From 65393557682e7ac540e0feee2cae3b5c2bd14e89 Mon Sep 17 00:00:00 2001 +From 36fe8aa5205599e8be07f1b6ec98a6ae09ac3b9a Mon Sep 17 00:00:00 2001 From: Aikar Date: Mon, 23 Jul 2018 22:44:23 -0400 Subject: [PATCH] Add some Debug to Chunk Entity slices @@ -9,10 +9,10 @@ This should hopefully avoid duplicate entities ever being created if the entity was to end up in 2 different chunk slices diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 68cde33565..3267e87259 100644 +index 54d48ef5e..8d3c265cc 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java -@@ -407,6 +407,25 @@ public class Chunk implements IChunkAccess { +@@ -489,6 +489,25 @@ public class Chunk implements IChunkAccess { if (k >= this.entitySlices.length) { k = this.entitySlices.length - 1; } @@ -38,7 +38,7 @@ index 68cde33565..3267e87259 100644 if (!entity.inChunk || entity.getCurrentChunk() != this) entityCounts.increment(entity.getMinecraftKeyString()); // Paper entity.inChunk = true; -@@ -416,6 +435,7 @@ public class Chunk implements IChunkAccess { +@@ -498,6 +517,7 @@ public class Chunk implements IChunkAccess { entity.chunkZ = this.loc.z; this.entities.add(entity); // Paper - per chunk entity list this.entitySlices[k].add(entity); @@ -46,7 +46,7 @@ index 68cde33565..3267e87259 100644 this.markDirty(); // Paper } -@@ -440,6 +460,10 @@ public class Chunk implements IChunkAccess { +@@ -522,6 +542,10 @@ public class Chunk implements IChunkAccess { // Paper start if (entity.currentChunk != null && entity.currentChunk.get() == this) entity.setCurrentChunk(null); @@ -58,7 +58,7 @@ index 68cde33565..3267e87259 100644 return; } diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 7378d531b6..356de07dad 100644 +index 7378d531b..356de07da 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -71,6 +71,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke @@ -70,5 +70,5 @@ index 7378d531b6..356de07dad 100644 public com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData; // Paper -- -2.25.1 +2.26.0 diff --git a/Spigot-Server-Patches/0263-Ignore-Dead-Entities-in-entityList-iteration.patch b/Spigot-Server-Patches/0263-Ignore-Dead-Entities-in-entityList-iteration.patch index 2174c7cc0..7689f6ed5 100644 --- a/Spigot-Server-Patches/0263-Ignore-Dead-Entities-in-entityList-iteration.patch +++ b/Spigot-Server-Patches/0263-Ignore-Dead-Entities-in-entityList-iteration.patch @@ -1,4 +1,4 @@ -From b272e3ed56fcdff15a2ffd879ea937079936102e Mon Sep 17 00:00:00 2001 +From 2d63a1d0f55b60e2f1b461a14e1b4b77424c28f2 Mon Sep 17 00:00:00 2001 From: Aikar Date: Sat, 28 Jul 2018 12:18:27 -0400 Subject: [PATCH] Ignore Dead Entities in entityList iteration @@ -23,10 +23,10 @@ index b839769ce..5acad8e44 100644 MutablePair> info = list.computeIfAbsent(key, k -> MutablePair.of(0, Maps.newHashMap())); ChunkCoordIntPair chunk = new ChunkCoordIntPair(e.getChunkX(), e.getChunkZ()); diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 3267e8725..a51de83cf 100644 +index 8d3c265cc..8d6c5d18e 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java -@@ -682,6 +682,7 @@ public class Chunk implements IChunkAccess { +@@ -796,6 +796,7 @@ public class Chunk implements IChunkAccess { while (iterator.hasNext()) { Entity entity1 = (Entity) iterator.next(); @@ -34,7 +34,7 @@ index 3267e8725..a51de83cf 100644 if (entity1.getBoundingBox().c(axisalignedbb) && entity1 != entity) { if (predicate == null || predicate.test(entity1)) { -@@ -719,6 +720,7 @@ public class Chunk implements IChunkAccess { +@@ -833,6 +834,7 @@ public class Chunk implements IChunkAccess { while (iterator.hasNext()) { T entity = (T) iterator.next(); // CraftBukkit - decompile error @@ -42,7 +42,7 @@ index 3267e8725..a51de83cf 100644 if ((entitytypes == null || entity.getEntityType() == entitytypes) && entity.getBoundingBox().c(axisalignedbb) && predicate.test(entity)) { list.add(entity); -@@ -740,6 +742,7 @@ public class Chunk implements IChunkAccess { +@@ -854,6 +856,7 @@ public class Chunk implements IChunkAccess { while (iterator.hasNext()) { T t0 = (T) iterator.next(); // CraftBukkit - decompile error @@ -128,5 +128,5 @@ index 588c87119..e94ac028d 100644 if (bukkitEntity == null) { -- -2.25.1 +2.26.0 diff --git a/Spigot-Server-Patches/0303-Catch-JsonParseException-in-Entity-and-TE-names.patch b/Spigot-Server-Patches/0303-Catch-JsonParseException-in-Entity-and-TE-names.patch index d2379d0d9..3df21cd7f 100644 --- a/Spigot-Server-Patches/0303-Catch-JsonParseException-in-Entity-and-TE-names.patch +++ b/Spigot-Server-Patches/0303-Catch-JsonParseException-in-Entity-and-TE-names.patch @@ -1,4 +1,4 @@ -From 2cd049636d660c5856911661734574438c3c61e2 Mon Sep 17 00:00:00 2001 +From d83a93429d0994fe7f5c748f0ff7817fde378722 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Sat, 22 Sep 2018 15:56:59 -0400 Subject: [PATCH] Catch JsonParseException in Entity and TE names @@ -13,7 +13,7 @@ Shulkers) may need to be changed in order for it to re-save properly No more crashing though. diff --git a/src/main/java/net/minecraft/server/CommandBlockListenerAbstract.java b/src/main/java/net/minecraft/server/CommandBlockListenerAbstract.java -index 7867122974..ef2a496eda 100644 +index 786712297..ef2a496ed 100644 --- a/src/main/java/net/minecraft/server/CommandBlockListenerAbstract.java +++ b/src/main/java/net/minecraft/server/CommandBlockListenerAbstract.java @@ -59,7 +59,7 @@ public abstract class CommandBlockListenerAbstract implements ICommandListener { @@ -26,7 +26,7 @@ index 7867122974..ef2a496eda 100644 if (nbttagcompound.hasKeyOfType("TrackOutput", 1)) { diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 09c5760571..d1ab124fe1 100644 +index 09c576057..d1ab124fe 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -1679,7 +1679,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke @@ -39,10 +39,10 @@ index 09c5760571..d1ab124fe1 100644 this.setCustomNameVisible(nbttagcompound.getBoolean("CustomNameVisible")); diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java -index ddd7277162..bfddeb7cdb 100644 +index dae1560be..95024d6ee 100644 --- a/src/main/java/net/minecraft/server/MCUtil.java +++ b/src/main/java/net/minecraft/server/MCUtil.java -@@ -407,4 +407,19 @@ public final class MCUtil { +@@ -413,4 +413,19 @@ public final class MCUtil { return null; } } @@ -63,7 +63,7 @@ index ddd7277162..bfddeb7cdb 100644 + } } diff --git a/src/main/java/net/minecraft/server/TileEntityBanner.java b/src/main/java/net/minecraft/server/TileEntityBanner.java -index 93911a8251..d35604edb2 100644 +index 93911a825..d35604edb 100644 --- a/src/main/java/net/minecraft/server/TileEntityBanner.java +++ b/src/main/java/net/minecraft/server/TileEntityBanner.java @@ -60,7 +60,7 @@ public class TileEntityBanner extends TileEntity implements INamableTileEntity { @@ -76,7 +76,7 @@ index 93911a8251..d35604edb2 100644 if (this.hasWorld()) { diff --git a/src/main/java/net/minecraft/server/TileEntityContainer.java b/src/main/java/net/minecraft/server/TileEntityContainer.java -index 473ec2cbde..ab6b86e4e9 100644 +index 473ec2cbd..ab6b86e4e 100644 --- a/src/main/java/net/minecraft/server/TileEntityContainer.java +++ b/src/main/java/net/minecraft/server/TileEntityContainer.java @@ -17,7 +17,7 @@ public abstract class TileEntityContainer extends TileEntity implements IInvento @@ -89,5 +89,5 @@ index 473ec2cbde..ab6b86e4e9 100644 } -- -2.25.1 +2.26.0 diff --git a/Spigot-Server-Patches/0353-Add-LivingEntity-getTargetEntity.patch b/Spigot-Server-Patches/0353-Add-LivingEntity-getTargetEntity.patch index 73426216c..280c12702 100644 --- a/Spigot-Server-Patches/0353-Add-LivingEntity-getTargetEntity.patch +++ b/Spigot-Server-Patches/0353-Add-LivingEntity-getTargetEntity.patch @@ -1,11 +1,11 @@ -From 6cea97953487471b8053d2becf0061ed3ef30b34 Mon Sep 17 00:00:00 2001 +From e8a3c851fb314410e9040714cc6f447d11bee638 Mon Sep 17 00:00:00 2001 From: BillyGalbreath Date: Sat, 22 Sep 2018 00:33:08 -0500 Subject: [PATCH] Add LivingEntity#getTargetEntity diff --git a/src/main/java/net/minecraft/server/AxisAlignedBB.java b/src/main/java/net/minecraft/server/AxisAlignedBB.java -index 4f60b931a1..c950139c0f 100644 +index f427953a8..3fdb52007 100644 --- a/src/main/java/net/minecraft/server/AxisAlignedBB.java +++ b/src/main/java/net/minecraft/server/AxisAlignedBB.java @@ -108,6 +108,7 @@ public class AxisAlignedBB { @@ -29,7 +29,7 @@ index 4f60b931a1..c950139c0f 100644 public AxisAlignedBB grow(double d0, double d1, double d2) { double d3 = this.minX - d0; double d4 = this.minY - d1; -@@ -194,6 +201,7 @@ public class AxisAlignedBB { +@@ -195,6 +202,7 @@ public class AxisAlignedBB { return this.minX < d3 && this.maxX > d0 && this.minY < d4 && this.maxY > d1 && this.minZ < d5 && this.maxZ > d2; } @@ -37,7 +37,7 @@ index 4f60b931a1..c950139c0f 100644 public boolean c(Vec3D vec3d) { return this.e(vec3d.x, vec3d.y, vec3d.z); } -@@ -226,6 +234,7 @@ public class AxisAlignedBB { +@@ -227,6 +235,7 @@ public class AxisAlignedBB { return this.g(-d0); } @@ -46,7 +46,7 @@ index 4f60b931a1..c950139c0f 100644 double[] adouble = new double[]{1.0D}; double d0 = vec3d1.x - vec3d.x; diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 725fa9501a..427d66ed01 100644 +index 725fa9501..427d66ed0 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -1475,6 +1475,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke @@ -66,7 +66,7 @@ index 725fa9501a..427d66ed01 100644 return 0.0F; } diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java -index 4e64a80a8a..af79b6e378 100644 +index 4e64a80a8..af79b6e37 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -3307,6 +3307,37 @@ public abstract class EntityLiving extends Entity { @@ -108,7 +108,7 @@ index 4e64a80a8a..af79b6e378 100644 public int getShieldBlockingDelay() { diff --git a/src/main/java/net/minecraft/server/IEntitySelector.java b/src/main/java/net/minecraft/server/IEntitySelector.java -index c1f462d9d3..498f381099 100644 +index c1f462d9d..498f38109 100644 --- a/src/main/java/net/minecraft/server/IEntitySelector.java +++ b/src/main/java/net/minecraft/server/IEntitySelector.java @@ -18,6 +18,7 @@ public final class IEntitySelector { @@ -120,7 +120,7 @@ index c1f462d9d3..498f381099 100644 return !entity.isSpectator(); }; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java -index d197094f54..6de01e4f0e 100644 +index d197094f5..6de01e4f0 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -216,6 +216,33 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @@ -158,5 +158,5 @@ index d197094f54..6de01e4f0e 100644 @Override -- -2.25.1 +2.26.0 diff --git a/Spigot-Server-Patches/0371-Duplicate-UUID-Resolve-Option.patch b/Spigot-Server-Patches/0371-Duplicate-UUID-Resolve-Option.patch index 13ee58884..b63373790 100644 --- a/Spigot-Server-Patches/0371-Duplicate-UUID-Resolve-Option.patch +++ b/Spigot-Server-Patches/0371-Duplicate-UUID-Resolve-Option.patch @@ -1,4 +1,4 @@ -From 13d90986642ffb54bd12030747a85e3462c90f94 Mon Sep 17 00:00:00 2001 +From 7d7fb0beb9848e04b69115199bb267aff122cbd2 Mon Sep 17 00:00:00 2001 From: Aikar Date: Sat, 21 Jul 2018 14:27:34 -0400 Subject: [PATCH] Duplicate UUID Resolve Option @@ -33,7 +33,7 @@ But for those who are ok with leaving this inconsistent behavior, you may use WA It is recommended you regenerate the entities, as these were legit entities, and deserve your love. diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 4ba72275b9..572679e4d1 100644 +index 4ba72275b..572679e4d 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -442,4 +442,43 @@ public class PaperWorldConfig { @@ -81,10 +81,10 @@ index 4ba72275b9..572679e4d1 100644 + } } diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index a51de83cf5..c263a8250d 100644 +index 8d6c5d18e..23cc0c360 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java -@@ -396,6 +396,7 @@ public class Chunk implements IChunkAccess { +@@ -478,6 +478,7 @@ public class Chunk implements IChunkAccess { if (i != this.loc.x || j != this.loc.z) { Chunk.LOGGER.warn("Wrong location! ({}, {}) should be ({}, {}), {}", i, j, this.loc.x, this.loc.z, entity); entity.dead = true; @@ -93,7 +93,7 @@ index a51de83cf5..c263a8250d 100644 int k = MathHelper.floor(entity.locY() / 16.0D); diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index bb1fd6e46c..0900db052d 100644 +index bb1fd6e46..0900db052 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -2747,6 +2747,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke @@ -105,7 +105,7 @@ index bb1fd6e46c..0900db052d 100644 this.uniqueID = uuid; this.am = this.uniqueID.toString(); diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index f640d2ac76..863c47b761 100644 +index f640d2ac7..863c47b76 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java @@ -1,6 +1,7 @@ @@ -197,7 +197,7 @@ index f640d2ac76..863c47b761 100644 ChunkCoordIntPair chunkcoordintpair = playerchunk.i(); CompletableFuture, PlayerChunk.Failure>> completablefuture = this.a(chunkcoordintpair, 1, (i) -> { diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 1221c30a99..ff58e0190e 100644 +index e34ea3d09..f9ee9afe3 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -3,6 +3,8 @@ package net.minecraft.server; @@ -236,5 +236,5 @@ index 1221c30a99..ff58e0190e 100644 } } -- -2.25.1 +2.26.0 diff --git a/Spigot-Server-Patches/0378-Chunk-debug-command.patch b/Spigot-Server-Patches/0378-Chunk-debug-command.patch index adc08db36..347ed8fe0 100644 --- a/Spigot-Server-Patches/0378-Chunk-debug-command.patch +++ b/Spigot-Server-Patches/0378-Chunk-debug-command.patch @@ -1,4 +1,4 @@ -From e80674dfeb36acd8ef36c64f9f26c6ee636744d7 Mon Sep 17 00:00:00 2001 +From 58abf233efc1f05205bdbc681364dba7b5d77306 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Sat, 1 Jun 2019 13:00:55 -0700 Subject: [PATCH] Chunk debug command @@ -32,7 +32,7 @@ https://bugs.mojang.com/browse/MC-141484?focusedCommentId=528273&page=com.atlass https://bugs.mojang.com/browse/MC-141484?focusedCommentId=528577&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-528577 diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java -index 5acad8e44f..af81098784 100644 +index 5acad8e44..af8109878 100644 --- a/src/main/java/com/destroystokyo/paper/PaperCommand.java +++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java @@ -28,14 +28,14 @@ public class PaperCommand extends Command { @@ -185,7 +185,7 @@ index 5acad8e44f..af81098784 100644 * Ported from MinecraftForge - author: LexManos - License: LGPLv2.1 */ diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java -index 96ac76c134..0db7b88bdd 100644 +index 96ac76c13..0db7b88bd 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java @@ -22,7 +22,7 @@ import org.apache.logging.log4j.Logger; @@ -198,7 +198,7 @@ index 96ac76c134..0db7b88bdd 100644 public final ChunkGenerator chunkGenerator; private final WorldServer world; diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java -index bfddeb7cdb..047a0c6591 100644 +index 95024d6ee..4851b9fc5 100644 --- a/src/main/java/net/minecraft/server/MCUtil.java +++ b/src/main/java/net/minecraft/server/MCUtil.java @@ -4,7 +4,13 @@ import com.destroystokyo.paper.block.TargetBlockInfo; @@ -227,7 +227,7 @@ index bfddeb7cdb..047a0c6591 100644 import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executor; -@@ -422,4 +432,170 @@ public final class MCUtil { +@@ -428,4 +438,170 @@ public final class MCUtil { return null; } @@ -399,7 +399,7 @@ index bfddeb7cdb..047a0c6591 100644 + } } diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java -index c4bbee7d6a..b6d3870063 100644 +index c4bbee7d6..b6d387006 100644 --- a/src/main/java/net/minecraft/server/PlayerChunk.java +++ b/src/main/java/net/minecraft/server/PlayerChunk.java @@ -26,7 +26,7 @@ public class PlayerChunk { @@ -412,7 +412,7 @@ index c4bbee7d6a..b6d3870063 100644 private int dirtyCount; private int r; diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index 863c47b761..cdab5ab6be 100644 +index 863c47b76..cdab5ab6b 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java @@ -58,7 +58,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { @@ -434,7 +434,7 @@ index 863c47b761..cdab5ab6be 100644 private final DefinedStructureManager definedStructureManager; private final File w; diff --git a/src/main/java/net/minecraft/server/Ticket.java b/src/main/java/net/minecraft/server/Ticket.java -index 77bb6b092a..7a8397815a 100644 +index 77bb6b092..7a8397815 100644 --- a/src/main/java/net/minecraft/server/Ticket.java +++ b/src/main/java/net/minecraft/server/Ticket.java @@ -6,8 +6,8 @@ public final class Ticket implements Comparable> { @@ -457,5 +457,5 @@ index 77bb6b092a..7a8397815a 100644 return this.b; } -- -2.25.1 +2.26.0 diff --git a/Spigot-Server-Patches/0385-Anti-Xray.patch b/Spigot-Server-Patches/0385-Anti-Xray.patch index 31c95480e..615f8d1bc 100644 --- a/Spigot-Server-Patches/0385-Anti-Xray.patch +++ b/Spigot-Server-Patches/0385-Anti-Xray.patch @@ -1,4 +1,4 @@ -From 9057ed657effb5ccf49fd5d7452f496c2062d61a Mon Sep 17 00:00:00 2001 +From ad2c58d5fb63d550fe63fba39fc86e11b2504f8f Mon Sep 17 00:00:00 2001 From: stonar96 Date: Mon, 20 Aug 2018 03:03:58 +0200 Subject: [PATCH] Anti-Xray @@ -1181,10 +1181,10 @@ index 000000000..37093419c + } +} diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 1709f9b84..b6ba0cb79 100644 +index d6637f3dd..bdd04305f 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java -@@ -320,7 +320,7 @@ public class Chunk implements IChunkAccess { +@@ -402,7 +402,7 @@ public class Chunk implements IChunkAccess { return null; } @@ -1710,5 +1710,5 @@ index 8191e7c34..969d548de 100644 return section; } -- -2.25.1 +2.26.0 diff --git a/Spigot-Server-Patches/0390-Avoid-hopper-searches-if-there-are-no-items.patch b/Spigot-Server-Patches/0390-Avoid-hopper-searches-if-there-are-no-items.patch index bdda1e9a0..d52550f36 100644 --- a/Spigot-Server-Patches/0390-Avoid-hopper-searches-if-there-are-no-items.patch +++ b/Spigot-Server-Patches/0390-Avoid-hopper-searches-if-there-are-no-items.patch @@ -1,4 +1,4 @@ -From 7b9a7ead4ba22db5f1cc54426ecc22b63e05b4c4 Mon Sep 17 00:00:00 2001 +From 66d74d811391f575701465a31099b5d51b2d0a8b Mon Sep 17 00:00:00 2001 From: CullanP Date: Thu, 3 Mar 2016 02:13:38 -0600 Subject: [PATCH] Avoid hopper searches if there are no items @@ -14,7 +14,7 @@ And since minecart hoppers are used _very_ rarely near we can avoid alot of sear Combined, this adds up a lot. diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index b6ba0cb79e..38ab4197b2 100644 +index bdd04305f..03c25eae7 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -84,6 +84,10 @@ public class Chunk implements IChunkAccess { @@ -28,7 +28,7 @@ index b6ba0cb79e..38ab4197b2 100644 // Paper end public Chunk(World world, ChunkCoordIntPair chunkcoordintpair, BiomeStorage biomestorage, ChunkConverter chunkconverter, TickList ticklist, TickList ticklist1, long i, @Nullable ChunkSection[] achunksection, @Nullable Consumer consumer) { -@@ -436,6 +440,13 @@ public class Chunk implements IChunkAccess { +@@ -518,6 +522,13 @@ public class Chunk implements IChunkAccess { entity.chunkZ = this.loc.z; this.entities.add(entity); // Paper - per chunk entity list this.entitySlices[k].add(entity); @@ -42,7 +42,7 @@ index b6ba0cb79e..38ab4197b2 100644 entity.entitySlice = this.entitySlices[k]; // Paper this.markDirty(); // Paper } -@@ -468,6 +479,11 @@ public class Chunk implements IChunkAccess { +@@ -550,6 +561,11 @@ public class Chunk implements IChunkAccess { if (!this.entitySlices[i].remove(entity)) { return; } @@ -54,7 +54,7 @@ index b6ba0cb79e..38ab4197b2 100644 entityCounts.decrement(entity.getMinecraftKeyString()); this.markDirty(); // Paper // Paper end -@@ -738,9 +754,29 @@ public class Chunk implements IChunkAccess { +@@ -852,9 +868,29 @@ public class Chunk implements IChunkAccess { i = MathHelper.clamp(i, 0, this.entitySlices.length - 1); j = MathHelper.clamp(j, 0, this.entitySlices.length - 1); @@ -85,7 +85,7 @@ index b6ba0cb79e..38ab4197b2 100644 T t0 = (T) iterator.next(); // CraftBukkit - decompile error if (t0.shouldBeRemoved) continue; // Paper diff --git a/src/main/java/net/minecraft/server/IEntitySelector.java b/src/main/java/net/minecraft/server/IEntitySelector.java -index 498f381099..a2d1ef3602 100644 +index 498f38109..a2d1ef360 100644 --- a/src/main/java/net/minecraft/server/IEntitySelector.java +++ b/src/main/java/net/minecraft/server/IEntitySelector.java @@ -11,6 +11,7 @@ public final class IEntitySelector { @@ -97,5 +97,5 @@ index 498f381099..a2d1ef3602 100644 return entity instanceof IInventory && entity.isAlive(); }; -- -2.25.1 +2.26.0 diff --git a/Spigot-Server-Patches/0391-Asynchronous-chunk-IO-and-loading.patch b/Spigot-Server-Patches/0391-Asynchronous-chunk-IO-and-loading.patch index 534a1995e..9a5e39bfa 100644 --- a/Spigot-Server-Patches/0391-Asynchronous-chunk-IO-and-loading.patch +++ b/Spigot-Server-Patches/0391-Asynchronous-chunk-IO-and-loading.patch @@ -1,4 +1,4 @@ -From b11c11c4f13fe9c13a941bb25693801f935a5d69 Mon Sep 17 00:00:00 2001 +From 8bd81e609943d7056ee1bcd881521a4e54acb8b4 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Sat, 13 Jul 2019 09:23:10 -0700 Subject: [PATCH] Asynchronous chunk IO and loading @@ -3008,10 +3008,10 @@ index 2f95174fc..134c76065 100644 +// Paper end } diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java -index 047a0c659..b9d584452 100644 +index 4851b9fc5..786e6c976 100644 --- a/src/main/java/net/minecraft/server/MCUtil.java +++ b/src/main/java/net/minecraft/server/MCUtil.java -@@ -598,4 +598,9 @@ public final class MCUtil { +@@ -604,4 +604,9 @@ public final class MCUtil { out.print(fileData); } } @@ -3983,7 +3983,7 @@ index c999f8c9b..b59ef1a63 100644 HAS_SPACE(VillagePlaceRecord::d), IS_OCCUPIED(VillagePlaceRecord::e), ANY((villageplacerecord) -> { diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 4ddd8fd04..b5daebe51 100644 +index a79ccad0b..6634348e4 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -82,6 +82,79 @@ public class WorldServer extends World { @@ -4157,5 +4157,5 @@ index 07936eeba..5bdcdcf9e 100644 log.log( Level.SEVERE, "------------------------------" ); // -- -2.25.1 +2.26.0 diff --git a/Spigot-Server-Patches/0436-Optimise-random-block-ticking.patch b/Spigot-Server-Patches/0436-Optimise-random-block-ticking.patch index 0ce1dbf66..0238117bf 100644 --- a/Spigot-Server-Patches/0436-Optimise-random-block-ticking.patch +++ b/Spigot-Server-Patches/0436-Optimise-random-block-ticking.patch @@ -1,4 +1,4 @@ -From 792977fcd27894bf9917653289f4bce50b05da9a Mon Sep 17 00:00:00 2001 +From df3fcdaadbc825a7fcdec22805900feb109e25d6 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Mon, 27 Jan 2020 21:28:00 -0800 Subject: [PATCH] Optimise random block ticking @@ -20,7 +20,7 @@ remains the same. diff --git a/src/main/java/com/destroystokyo/paper/util/math/ThreadUnsafeRandom.java b/src/main/java/com/destroystokyo/paper/util/math/ThreadUnsafeRandom.java new file mode 100644 -index 0000000000..3edc8e52e0 +index 000000000..3edc8e52e --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/util/math/ThreadUnsafeRandom.java @@ -0,0 +1,46 @@ @@ -71,7 +71,7 @@ index 0000000000..3edc8e52e0 + } +} diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java -index e29ec958b3..e40375b67a 100644 +index e29ec958b..e40375b67 100644 --- a/src/main/java/net/minecraft/server/Block.java +++ b/src/main/java/net/minecraft/server/Block.java @@ -109,8 +109,8 @@ public class Block implements IMaterial { @@ -86,7 +86,7 @@ index e29ec958b3..e40375b67a 100644 } diff --git a/src/main/java/net/minecraft/server/BlockFluids.java b/src/main/java/net/minecraft/server/BlockFluids.java -index 6d351f0979..a44f65f40d 100644 +index 6d351f097..a44f65f40 100644 --- a/src/main/java/net/minecraft/server/BlockFluids.java +++ b/src/main/java/net/minecraft/server/BlockFluids.java @@ -27,7 +27,7 @@ public class BlockFluids extends Block implements IFluidSource { @@ -99,7 +99,7 @@ index 6d351f0979..a44f65f40d 100644 @Override diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java -index e76528f199..e650a2e48d 100644 +index e76528f19..e650a2e48 100644 --- a/src/main/java/net/minecraft/server/BlockPosition.java +++ b/src/main/java/net/minecraft/server/BlockPosition.java @@ -450,6 +450,7 @@ public class BlockPosition extends BaseBlockPosition implements MinecraftSeriali @@ -111,7 +111,7 @@ index e76528f199..e650a2e48d 100644 return this.d(baseblockposition.getX(), baseblockposition.getY(), baseblockposition.getZ()); } diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 38ab4197b2..971c0315d5 100644 +index 03c25eae7..92bb009b8 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -52,6 +52,8 @@ public class Chunk implements IChunkAccess { @@ -142,7 +142,7 @@ index 38ab4197b2..971c0315d5 100644 System.arraycopy(achunksection, 0, this.sections, 0, this.sections.length); } else { Chunk.LOGGER.warn("Could not set level chunk sections, array length is {} instead of {}", achunksection.length, this.sections.length); -@@ -490,8 +504,8 @@ public class Chunk implements IChunkAccess { +@@ -572,8 +586,8 @@ public class Chunk implements IChunkAccess { this.entities.remove(entity); // Paper } @@ -154,7 +154,7 @@ index 38ab4197b2..971c0315d5 100644 } diff --git a/src/main/java/net/minecraft/server/ChunkSection.java b/src/main/java/net/minecraft/server/ChunkSection.java -index 4526527aca..8b28fb5ee1 100644 +index 4526527ac..8b28fb5ee 100644 --- a/src/main/java/net/minecraft/server/ChunkSection.java +++ b/src/main/java/net/minecraft/server/ChunkSection.java @@ -5,12 +5,15 @@ import javax.annotation.Nullable; @@ -259,7 +259,7 @@ index 4526527aca..8b28fb5ee1 100644 } diff --git a/src/main/java/net/minecraft/server/DataBits.java b/src/main/java/net/minecraft/server/DataBits.java -index f9680b6830..a61cffa3f4 100644 +index f9680b683..a61cffa3f 100644 --- a/src/main/java/net/minecraft/server/DataBits.java +++ b/src/main/java/net/minecraft/server/DataBits.java @@ -127,4 +127,46 @@ public class DataBits { @@ -310,7 +310,7 @@ index f9680b6830..a61cffa3f4 100644 + // Paper end } diff --git a/src/main/java/net/minecraft/server/DataPaletteBlock.java b/src/main/java/net/minecraft/server/DataPaletteBlock.java -index 44aed67274..fa664897fb 100644 +index 44aed6727..fa664897f 100644 --- a/src/main/java/net/minecraft/server/DataPaletteBlock.java +++ b/src/main/java/net/minecraft/server/DataPaletteBlock.java @@ -287,6 +287,14 @@ public class DataPaletteBlock implements DataPaletteExpandable { @@ -329,7 +329,7 @@ index 44aed67274..fa664897fb 100644 public interface a { diff --git a/src/main/java/net/minecraft/server/EntityTurtle.java b/src/main/java/net/minecraft/server/EntityTurtle.java -index dd02cb3485..b24a5100b4 100644 +index dd02cb348..b24a5100b 100644 --- a/src/main/java/net/minecraft/server/EntityTurtle.java +++ b/src/main/java/net/minecraft/server/EntityTurtle.java @@ -29,7 +29,7 @@ public class EntityTurtle extends EntityAnimal { @@ -342,7 +342,7 @@ index dd02cb3485..b24a5100b4 100644 public final BlockPosition getHome() { return this.es(); } // Paper - OBFHELPER diff --git a/src/main/java/net/minecraft/server/IBlockData.java b/src/main/java/net/minecraft/server/IBlockData.java -index de43881653..e821c236b4 100644 +index de4388165..e821c236b 100644 --- a/src/main/java/net/minecraft/server/IBlockData.java +++ b/src/main/java/net/minecraft/server/IBlockData.java @@ -22,11 +22,15 @@ public class IBlockData extends BlockDataAbstract implements @@ -395,7 +395,7 @@ index de43881653..e821c236b4 100644 public final SoundEffectType getStepSound() { return this.r(); } // Paper - OBFHELPER diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index 28b6c9a083..d554d4cf0f 100644 +index 28b6c9a08..d554d4cf0 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -1557,10 +1557,19 @@ public abstract class World implements GeneratorAccess, AutoCloseable { @@ -420,7 +420,7 @@ index 28b6c9a083..d554d4cf0f 100644 public boolean isSavingDisabled() { diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 9211f996c0..eb99819e51 100644 +index dd4802095..b95dd3a92 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -531,6 +531,11 @@ public class WorldServer extends World { @@ -568,5 +568,5 @@ index 9211f996c0..eb99819e51 100644 protected BlockPosition a(BlockPosition blockposition) { -- -2.25.1 +2.26.0 diff --git a/Spigot-Server-Patches/0446-Optimise-Chunk-getFluid.patch b/Spigot-Server-Patches/0446-Optimise-Chunk-getFluid.patch index 225508c18..43d89ae8a 100644 --- a/Spigot-Server-Patches/0446-Optimise-Chunk-getFluid.patch +++ b/Spigot-Server-Patches/0446-Optimise-Chunk-getFluid.patch @@ -1,4 +1,4 @@ -From 417ce6b10c697730ddb86c920dadefa1f06b3796 Mon Sep 17 00:00:00 2001 +From 5cb95cd02fdc6574ec956ce2277aa7d13a00c279 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Tue, 14 Jan 2020 14:59:08 -0800 Subject: [PATCH] Optimise Chunk#getFluid @@ -8,10 +8,10 @@ faster on its own, however removing the try catch makes it easier to inline due to code size diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 971c0315d5..2b0e431874 100644 +index 92bb009b8..719c6f3e7 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java -@@ -297,17 +297,20 @@ public class Chunk implements IChunkAccess { +@@ -379,17 +379,20 @@ public class Chunk implements IChunkAccess { } public Fluid a(int i, int j, int k) { @@ -39,7 +39,7 @@ index 971c0315d5..2b0e431874 100644 CrashReport crashreport = CrashReport.a(throwable, "Getting fluid state"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Block being got"); -@@ -316,6 +319,7 @@ public class Chunk implements IChunkAccess { +@@ -398,6 +401,7 @@ public class Chunk implements IChunkAccess { }); throw new ReportedException(crashreport); } @@ -48,7 +48,7 @@ index 971c0315d5..2b0e431874 100644 // CraftBukkit start diff --git a/src/main/java/net/minecraft/server/ChunkSection.java b/src/main/java/net/minecraft/server/ChunkSection.java -index 8b28fb5ee1..426221f7c3 100644 +index 8b28fb5ee..426221f7c 100644 --- a/src/main/java/net/minecraft/server/ChunkSection.java +++ b/src/main/java/net/minecraft/server/ChunkSection.java @@ -46,7 +46,7 @@ public class ChunkSection { @@ -61,5 +61,5 @@ index 8b28fb5ee1..426221f7c3 100644 public void a() { -- -2.25.1 +2.26.0 diff --git a/Spigot-Server-Patches/0458-Optimize-PlayerChunkMap-memory-use-for-visibleChunks.patch b/Spigot-Server-Patches/0458-Optimize-PlayerChunkMap-memory-use-for-visibleChunks.patch index 501c1382c..ad1ccb839 100644 --- a/Spigot-Server-Patches/0458-Optimize-PlayerChunkMap-memory-use-for-visibleChunks.patch +++ b/Spigot-Server-Patches/0458-Optimize-PlayerChunkMap-memory-use-for-visibleChunks.patch @@ -1,4 +1,4 @@ -From 0334ff412d2daf9879c4bed4f7a948163a6e4de6 Mon Sep 17 00:00:00 2001 +From e9e28fe41d02473884b0e9b466c5ee7c5e6b3d03 Mon Sep 17 00:00:00 2001 From: Aikar Date: Wed, 8 Apr 2020 03:06:30 -0400 Subject: [PATCH] Optimize PlayerChunkMap memory use for visibleChunks @@ -13,7 +13,7 @@ This should result in siginificant memory use reduction and improved GC behavior diff --git a/src/main/java/com/destroystokyo/paper/util/map/Long2ObjectLinkedOpenHashMapFastCopy.java b/src/main/java/com/destroystokyo/paper/util/map/Long2ObjectLinkedOpenHashMapFastCopy.java new file mode 100644 -index 0000000000..e0ad725b2e +index 000000000..e0ad725b2 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/util/map/Long2ObjectLinkedOpenHashMapFastCopy.java @@ -0,0 +1,32 @@ @@ -50,7 +50,7 @@ index 0000000000..e0ad725b2e + } +} diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java -index 1dcd0980ec..e627440c41 100644 +index 1dcd0980e..e627440c4 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java @@ -669,7 +669,7 @@ public class ChunkProviderServer extends IChunkProvider { @@ -63,10 +63,10 @@ index 1dcd0980ec..e627440c41 100644 if (optional.isPresent()) { diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java -index b9d5844520..9980e4c277 100644 +index 786e6c976..ffaf496ee 100644 --- a/src/main/java/net/minecraft/server/MCUtil.java +++ b/src/main/java/net/minecraft/server/MCUtil.java -@@ -500,7 +500,7 @@ public final class MCUtil { +@@ -506,7 +506,7 @@ public final class MCUtil { WorldServer world = ((org.bukkit.craftbukkit.CraftWorld)bukkitWorld).getHandle(); PlayerChunkMap chunkMap = world.getChunkProvider().playerChunkMap; @@ -76,7 +76,7 @@ index b9d5844520..9980e4c277 100644 List allChunks = new ArrayList<>(visibleChunks.values()); List players = world.players; diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index e1e4ea793a..e61ddeb1ff 100644 +index e1e4ea793..e61ddeb1f 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java @@ -55,8 +55,10 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { @@ -213,7 +213,7 @@ index e1e4ea793a..e61ddeb1ff 100644 while (objectbidirectionaliterator.hasNext()) { Entry entry = (Entry) objectbidirectionaliterator.next(); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 051506fce8..630d6470a4 100644 +index 051506fce..630d6470a 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -74,6 +74,7 @@ import net.minecraft.server.GameRules; @@ -271,5 +271,5 @@ index 051506fce8..630d6470a4 100644 return chunks.values().stream().map(PlayerChunk::getFullChunk).filter(Objects::nonNull).map(net.minecraft.server.Chunk::getBukkitChunk).toArray(Chunk[]::new); } -- -2.25.1 +2.26.0