From d16a5d8813465b1b03c50adb756b9d324062f1f6 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Mon, 27 Jan 2020 16:16:53 -0800 Subject: [PATCH] Performance patches prerequisite (#2802) Prereq changes for the coming storm of performance patches. Includes optimising incremental saving --- Spigot-Server-Patches/0003-MC-Dev-fixes.patch | 153 +- Spigot-Server-Patches/0004-MC-Utils.patch | 2216 ++++++++++++++++- ...to-current-Chunk-for-Entity-and-Bloc.patch | 16 +- ...ts-for-each-Entity-Block-Entity-Type.patch | 8 +- Spigot-Server-Patches/0009-Timings-v2.patch | 90 +- ...ve-invalid-mob-spawner-tile-entities.patch | 6 +- .../0025-Entity-Origin-API.patch | 16 +- .../0030-Configurable-end-credits.patch | 8 +- ...sition-the-first-time-an-entity-is-s.patch | 10 +- ...figurable-container-update-tick-rate.patch | 8 +- ...dd-configurable-portal-search-radius.patch | 12 +- .../0054-Add-exception-reporting-event.patch | 30 +- ...Location-getType-and-getBlockData-fo.patch | 12 +- ...Entity-AddTo-RemoveFrom-World-Events.patch | 8 +- ...76-Configurable-Chunk-Inhabited-Time.patch | 8 +- ...Remove-unused-World-Tile-Entity-List.patch | 10 +- ...93-Implement-PlayerLocaleChangeEvent.patch | 8 +- ...item-frames-performance-and-bug-fixe.patch | 12 +- .../0107-Fix-Double-World-Add-issues.patch | 6 +- ...ers-that-dismount-from-other-players.patch | 8 +- ...uto-fix-bad-Y-levels-on-player-login.patch | 6 +- ...tion-to-remove-corrupt-tile-entities.patch | 8 +- ...122-Cache-user-authenticator-threads.patch | 8 +- ...34-Properly-fix-item-duplication-bug.patch | 8 +- .../0135-String-based-Action-Bar-API.patch | 8 +- ...more-aggressive-in-the-chunk-unload-.patch | 10 +- .../0156-Basic-PlayerProfile-API.patch | 22 +- ...2-PlayerNaturallySpawnCreaturesEvent.patch | 6 +- ...ld.spawnParticle-API-and-add-Builder.patch | 8 +- .../0242-InventoryCloseEvent-Reason-API.patch | 32 +- ...nilla-entity-warnings-for-duplicates.patch | 6 +- ...ies-option-to-debug-dupe-uuid-issues.patch | 18 +- ...-Speedup-BlockPos-by-fixing-inlining.patch | 11 +- ...-anytime-entities-change-to-guarante.patch | 10 +- ...dd-some-Debug-to-Chunk-Entity-slices.patch | 14 +- ...ead-Entities-in-entityList-iteration.patch | 22 +- ...ets-from-world-player-list-not-serve.patch | 12 +- .../0293-Improve-death-events.patch | 26 +- ...arseException-in-Entity-and-TE-names.patch | 14 +- ...mit-lightning-strike-effect-distance.patch | 10 +- ...-Call-player-spectator-target-events.patch | 8 +- ...22-Reset-players-airTicks-on-respawn.patch | 8 +- ...entity-dismount-during-teleportation.patch | 12 +- ...vehicle-tracking-issue-on-disconnect.patch | 6 +- .../0358-Entity-getEntitySpawnReason.patch | 12 +- ...0365-PlayerDeathEvent-getItemsToKeep.patch | 8 +- ...h-entity-loss-due-to-unloaded-chunks.patch | 6 +- .../0374-Duplicate-UUID-Resolve-Option.patch | 22 +- ...le-Keep-Spawn-Loaded-range-per-world.patch | 16 +- .../0381-Chunk-debug-command.patch | 16 +- .../0382-incremental-chunk-saving.patch | 166 +- ...384-Fix-World-isChunkGenerated-calls.patch | 37 +- ...Status-cache-when-saving-protochunks.patch | 6 +- Spigot-Server-Patches/0388-Anti-Xray.patch | 52 +- ...-being-ticked-when-notifying-navigat.patch | 8 +- ...opper-searches-if-there-are-no-items.patch | 14 +- ...95-Asynchronous-chunk-IO-and-loading.patch | 138 +- .../0397-Reduce-sync-loads.patch | 14 +- ...ement-optional-per-player-mob-spawns.patch | 32 +- ...-sneak-when-changing-worlds-MC-10657.patch | 8 +- ...-Fix-spawn-radius-being-treated-as-0.patch | 6 +- ...layerDeathEvent-shouldDropExperience.patch | 6 +- ...e-getChunkAt-calls-for-loaded-chunks.patch | 88 + scripts/importmcdev.sh | 1 + 64 files changed, 2997 insertions(+), 597 deletions(-) create mode 100644 Spigot-Server-Patches/0435-Optimise-getChunkAt-calls-for-loaded-chunks.patch diff --git a/Spigot-Server-Patches/0003-MC-Dev-fixes.patch b/Spigot-Server-Patches/0003-MC-Dev-fixes.patch index aede2fdc7..9d567e612 100644 --- a/Spigot-Server-Patches/0003-MC-Dev-fixes.patch +++ b/Spigot-Server-Patches/0003-MC-Dev-fixes.patch @@ -1,11 +1,56 @@ -From b094d235e668b63afb13e4d01a9b14c45fa4363f Mon Sep 17 00:00:00 2001 +From e1f1e03c209bac8c167db7e56d5859d3777e484d Mon Sep 17 00:00:00 2001 From: Aikar Date: Wed, 30 Mar 2016 19:36:20 -0400 Subject: [PATCH] MC Dev fixes +diff --git a/src/main/java/net/minecraft/server/ArraySetSorted.java b/src/main/java/net/minecraft/server/ArraySetSorted.java +index a3afe60b0d..85f799a713 100644 +--- a/src/main/java/net/minecraft/server/ArraySetSorted.java ++++ b/src/main/java/net/minecraft/server/ArraySetSorted.java +@@ -23,11 +23,11 @@ public class ArraySetSorted extends AbstractSet { + } + + public static > ArraySetSorted a(int i) { +- return new ArraySetSorted<>(i, Comparator.naturalOrder()); ++ return new ArraySetSorted<>(i, (Comparator)Comparator.naturalOrder()); // Paper - decompile fix + } + + private static T[] a(Object[] aobject) { +- return (Object[]) aobject; ++ return (T[])aobject; // Paper - decompile fix + } + + private int c(T t0) { +@@ -101,7 +101,7 @@ public class ArraySetSorted extends AbstractSet { + } + + public boolean remove(Object object) { +- int i = this.c(object); ++ int i = this.c((T)object); // Paper - decompile fix + + if (i >= 0) { + this.d(i); +@@ -116,7 +116,7 @@ public class ArraySetSorted extends AbstractSet { + } + + public boolean contains(Object object) { +- int i = this.c(object); ++ int i = this.c((T)object); // Paper - decompile fix + + return i >= 0; + } +@@ -135,7 +135,7 @@ public class ArraySetSorted extends AbstractSet { + + public U[] toArray(U[] au) { + if (au.length < this.c) { +- return (Object[]) Arrays.copyOf(this.b, this.c, au.getClass()); ++ return (U[])Arrays.copyOf(this.b, this.c, au.getClass()); // Paper - decompile fix + } else { + System.arraycopy(this.b, 0, au, 0, this.c); + if (au.length > this.c) { diff --git a/src/main/java/net/minecraft/server/BiomeBase.java b/src/main/java/net/minecraft/server/BiomeBase.java -index 960dce230..253890e53 100644 +index 960dce2307..253890e537 100644 --- a/src/main/java/net/minecraft/server/BiomeBase.java +++ b/src/main/java/net/minecraft/server/BiomeBase.java @@ -54,7 +54,7 @@ public abstract class BiomeBase { @@ -27,7 +72,7 @@ index 960dce230..253890e53 100644 public List> g() { diff --git a/src/main/java/net/minecraft/server/BlockDataAbstract.java b/src/main/java/net/minecraft/server/BlockDataAbstract.java -index ab03b5568..1cf97cefc 100644 +index ab03b55682..1cf97cefc9 100644 --- a/src/main/java/net/minecraft/server/BlockDataAbstract.java +++ b/src/main/java/net/minecraft/server/BlockDataAbstract.java @@ -29,7 +29,7 @@ public abstract class BlockDataAbstract implements IBlockDataHolder { @@ -72,7 +117,7 @@ index ab03b5568..1cf97cefc 100644 S s0 = this.e.get(iblockstate, v0); diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java -index e40f9c153..c88a62f6b 100644 +index e40f9c153b..c88a62f6b7 100644 --- a/src/main/java/net/minecraft/server/BlockPosition.java +++ b/src/main/java/net/minecraft/server/BlockPosition.java @@ -57,12 +57,12 @@ public class BlockPosition extends BaseBlockPosition implements MinecraftSeriali @@ -92,7 +137,7 @@ index e40f9c153..c88a62f6b 100644 }); } diff --git a/src/main/java/net/minecraft/server/BlockStateEnum.java b/src/main/java/net/minecraft/server/BlockStateEnum.java -index 28cfbaae2..1486d460c 100644 +index 28cfbaae28..1486d460c8 100644 --- a/src/main/java/net/minecraft/server/BlockStateEnum.java +++ b/src/main/java/net/minecraft/server/BlockStateEnum.java @@ -20,10 +20,10 @@ public class BlockStateEnum & INamable> extends BlockState @@ -109,7 +154,7 @@ index 28cfbaae2..1486d460c 100644 if (this.b.containsKey(s1)) { diff --git a/src/main/java/net/minecraft/server/ChunkStatus.java b/src/main/java/net/minecraft/server/ChunkStatus.java -index 68a601bac..efdf611e6 100644 +index 68a601bac5..efdf611e66 100644 --- a/src/main/java/net/minecraft/server/ChunkStatus.java +++ b/src/main/java/net/minecraft/server/ChunkStatus.java @@ -84,7 +84,7 @@ public class ChunkStatus { @@ -122,7 +167,7 @@ index 68a601bac..efdf611e6 100644 for (int j = a().size() - 1; j >= 0; --j) { diff --git a/src/main/java/net/minecraft/server/CraftingManager.java b/src/main/java/net/minecraft/server/CraftingManager.java -index 2dd27edc8..6def3616e 100644 +index 2dd27edc83..6def3616ef 100644 --- a/src/main/java/net/minecraft/server/CraftingManager.java +++ b/src/main/java/net/minecraft/server/CraftingManager.java @@ -58,7 +58,7 @@ public class CraftingManager extends ResourceDataJson { @@ -135,7 +180,7 @@ index 2dd27edc8..6def3616e 100644 CraftingManager.LOGGER.info("Loaded {} recipes", map1.size()); } diff --git a/src/main/java/net/minecraft/server/EnderDragonBattle.java b/src/main/java/net/minecraft/server/EnderDragonBattle.java -index f2c0e06ba..909d13c42 100644 +index f2c0e06bab..909d13c427 100644 --- a/src/main/java/net/minecraft/server/EnderDragonBattle.java +++ b/src/main/java/net/minecraft/server/EnderDragonBattle.java @@ -376,7 +376,7 @@ public class EnderDragonBattle { @@ -157,7 +202,7 @@ index f2c0e06ba..909d13c42 100644 private EntityEnderDragon o() { diff --git a/src/main/java/net/minecraft/server/EntityVindicator.java b/src/main/java/net/minecraft/server/EntityVindicator.java -index 7d44348c7..73ecdd22e 100644 +index 7d44348c78..73ecdd22ea 100644 --- a/src/main/java/net/minecraft/server/EntityVindicator.java +++ b/src/main/java/net/minecraft/server/EntityVindicator.java @@ -25,7 +25,7 @@ public class EntityVindicator extends EntityIllagerAbstract { @@ -169,8 +214,21 @@ index 7d44348c7..73ecdd22e 100644 this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true)); this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget<>(this, EntityVillagerAbstract.class, true)); this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget<>(this, EntityIronGolem.class, true)); +diff --git a/src/main/java/net/minecraft/server/Fluid.java b/src/main/java/net/minecraft/server/Fluid.java +index 035f05e827..7c9ba12862 100644 +--- a/src/main/java/net/minecraft/server/Fluid.java ++++ b/src/main/java/net/minecraft/server/Fluid.java +@@ -74,7 +74,7 @@ public interface Fluid extends IBlockDataHolder { + if (immutablemap.isEmpty()) { + object = dynamicops.createMap(ImmutableMap.of(dynamicops.createString("Name"), dynamicops.createString(IRegistry.FLUID.getKey(fluid.getType()).toString()))); + } else { +- object = dynamicops.createMap(ImmutableMap.of(dynamicops.createString("Name"), dynamicops.createString(IRegistry.FLUID.getKey(fluid.getType()).toString()), dynamicops.createString("Properties"), dynamicops.createMap((Map) immutablemap.entrySet().stream().map((entry) -> { ++ object = dynamicops.createMap(ImmutableMap.of(dynamicops.createString("Name"), dynamicops.createString(IRegistry.FLUID.getKey(fluid.getType()).toString()), dynamicops.createString("Properties"), dynamicops.createMap(immutablemap.entrySet().stream().map((entry) -> { // Paper - decompile fix + return Pair.of(dynamicops.createString(((IBlockState) entry.getKey()).a()), dynamicops.createString(IBlockDataHolder.b((IBlockState) entry.getKey(), (Comparable) entry.getValue()))); + }).collect(Collectors.toMap(Pair::getFirst, Pair::getSecond))))); + } diff --git a/src/main/java/net/minecraft/server/IAsyncTaskHandler.java b/src/main/java/net/minecraft/server/IAsyncTaskHandler.java -index 447f6a55b..1890c760f 100644 +index 447f6a55b6..1890c760f9 100644 --- a/src/main/java/net/minecraft/server/IAsyncTaskHandler.java +++ b/src/main/java/net/minecraft/server/IAsyncTaskHandler.java @@ -55,7 +55,7 @@ public abstract class IAsyncTaskHandler implements Mailbox implements @@ -240,7 +298,7 @@ index 3be9efd22..3a1ad2346 100644 for (i = 0; i < k; ++i) { diff --git a/src/main/java/net/minecraft/server/IEntityAccess.java b/src/main/java/net/minecraft/server/IEntityAccess.java -index 534e70671..d5c284cdd 100644 +index 534e70671a..d5c284cdd1 100644 --- a/src/main/java/net/minecraft/server/IEntityAccess.java +++ b/src/main/java/net/minecraft/server/IEntityAccess.java @@ -47,7 +47,7 @@ public interface IEntityAccess { @@ -301,7 +359,7 @@ index 534e70671..d5c284cdd 100644 if (pathfindertargetcondition.a(entityliving, t0)) { list1.add(t0); diff --git a/src/main/java/net/minecraft/server/IOWorker.java b/src/main/java/net/minecraft/server/IOWorker.java -index a986f2912..c5658c077 100644 +index a986f2912f..c5658c0779 100644 --- a/src/main/java/net/minecraft/server/IOWorker.java +++ b/src/main/java/net/minecraft/server/IOWorker.java @@ -46,7 +46,7 @@ public class IOWorker implements AutoCloseable { @@ -340,8 +398,25 @@ index a986f2912..c5658c077 100644 } catch (Exception exception) { IOWorker.LOGGER.error("Failed to close storage", exception); this.h.completeExceptionally(exception); +diff --git a/src/main/java/net/minecraft/server/LightEngineStorageSky.java b/src/main/java/net/minecraft/server/LightEngineStorageSky.java +index 1e1f7ec6e6..75d9065b32 100644 +--- a/src/main/java/net/minecraft/server/LightEngineStorageSky.java ++++ b/src/main/java/net/minecraft/server/LightEngineStorageSky.java +@@ -28,10 +28,10 @@ public class LightEngineStorageSky extends LightEngineStorage= l) { diff --git a/src/main/java/net/minecraft/server/LootSelectorEntry.java b/src/main/java/net/minecraft/server/LootSelectorEntry.java -index 59bb53543..3ed6a1e78 100644 +index 59bb535431..3ed6a1e785 100644 --- a/src/main/java/net/minecraft/server/LootSelectorEntry.java +++ b/src/main/java/net/minecraft/server/LootSelectorEntry.java @@ -125,7 +125,7 @@ public abstract class LootSelectorEntry extends LootEntryAbstract { @@ -369,7 +444,7 @@ index 59bb53543..3ed6a1e78 100644 } diff --git a/src/main/java/net/minecraft/server/NBTBase.java b/src/main/java/net/minecraft/server/NBTBase.java -index 829a7ae0a..8b9e47b4c 100644 +index 829a7ae0a2..8b9e47b4c7 100644 --- a/src/main/java/net/minecraft/server/NBTBase.java +++ b/src/main/java/net/minecraft/server/NBTBase.java @@ -18,7 +18,7 @@ public interface NBTBase { @@ -382,7 +457,7 @@ index 829a7ae0a..8b9e47b4c 100644 default String asString() { return this.toString(); diff --git a/src/main/java/net/minecraft/server/NBTTagList.java b/src/main/java/net/minecraft/server/NBTTagList.java -index 22035b6c0..5406f4c40 100644 +index 22035b6c0b..5406f4c40f 100644 --- a/src/main/java/net/minecraft/server/NBTTagList.java +++ b/src/main/java/net/minecraft/server/NBTTagList.java @@ -51,7 +51,7 @@ public class NBTTagList extends NBTList { @@ -395,7 +470,7 @@ index 22035b6c0..5406f4c40 100644 private byte type; diff --git a/src/main/java/net/minecraft/server/NextTickListEntry.java b/src/main/java/net/minecraft/server/NextTickListEntry.java -index 8471920b8..e9c405fb5 100644 +index 8471920b8b..e9c405fb53 100644 --- a/src/main/java/net/minecraft/server/NextTickListEntry.java +++ b/src/main/java/net/minecraft/server/NextTickListEntry.java @@ -37,13 +37,13 @@ public class NextTickListEntry { @@ -417,7 +492,7 @@ index 8471920b8..e9c405fb5 100644 } diff --git a/src/main/java/net/minecraft/server/RegionFileSection.java b/src/main/java/net/minecraft/server/RegionFileSection.java -index 737afc7d7..db9f0196b 100644 +index 737afc7d71..db9f0196bd 100644 --- a/src/main/java/net/minecraft/server/RegionFileSection.java +++ b/src/main/java/net/minecraft/server/RegionFileSection.java @@ -83,9 +83,9 @@ public class RegionFileSection implements AutoC @@ -442,7 +517,7 @@ index 737afc7d7..db9f0196b 100644 }, dynamic2); }); diff --git a/src/main/java/net/minecraft/server/RegistryBlockID.java b/src/main/java/net/minecraft/server/RegistryBlockID.java -index 7f89562e9..4efcb8b59 100644 +index 7f89562e90..4efcb8b595 100644 --- a/src/main/java/net/minecraft/server/RegistryBlockID.java +++ b/src/main/java/net/minecraft/server/RegistryBlockID.java @@ -27,7 +27,7 @@ public class RegistryBlockID implements Registry { @@ -455,7 +530,7 @@ index 7f89562e9..4efcb8b59 100644 this.c.set(i, t0); diff --git a/src/main/java/net/minecraft/server/RegistryID.java b/src/main/java/net/minecraft/server/RegistryID.java -index 4cb78c6a3..e15d28671 100644 +index 4cb78c6a3f..e15d286710 100644 --- a/src/main/java/net/minecraft/server/RegistryID.java +++ b/src/main/java/net/minecraft/server/RegistryID.java @@ -17,9 +17,9 @@ public class RegistryID implements Registry { @@ -483,7 +558,7 @@ index 4cb78c6a3..e15d28671 100644 this.f = 0; diff --git a/src/main/java/net/minecraft/server/SystemUtils.java b/src/main/java/net/minecraft/server/SystemUtils.java -index 8534585eb..7b92ecfff 100644 +index 8534585eb1..7b92ecfff9 100644 --- a/src/main/java/net/minecraft/server/SystemUtils.java +++ b/src/main/java/net/minecraft/server/SystemUtils.java @@ -45,8 +45,8 @@ public class SystemUtils { @@ -526,8 +601,21 @@ index 8534585eb..7b92ecfff 100644 acompletablefuture[i] = completablefuture1.whenComplete((object, throwable) -> { if (throwable != null) { completablefuture.completeExceptionally(throwable); +diff --git a/src/main/java/net/minecraft/server/ThreadedMailbox.java b/src/main/java/net/minecraft/server/ThreadedMailbox.java +index 8dbb33e749..8082569022 100644 +--- a/src/main/java/net/minecraft/server/ThreadedMailbox.java ++++ b/src/main/java/net/minecraft/server/ThreadedMailbox.java +@@ -83,7 +83,7 @@ public class ThreadedMailbox implements Mailbox, AutoCloseable, Runnable { + + public void run() { + try { +- this.a((i) -> { ++ this.a((int i) -> { // Paper - decompile fix + return i == 0; + }); + } finally { diff --git a/src/main/java/net/minecraft/server/Ticket.java b/src/main/java/net/minecraft/server/Ticket.java -index ee2059cf8..77bb6b092 100644 +index ee2059cf8e..77bb6b092a 100644 --- a/src/main/java/net/minecraft/server/Ticket.java +++ b/src/main/java/net/minecraft/server/Ticket.java @@ -23,7 +23,7 @@ public final class Ticket implements Comparable> { @@ -540,7 +628,7 @@ index ee2059cf8..77bb6b092 100644 } diff --git a/src/main/java/net/minecraft/server/VillagePlace.java b/src/main/java/net/minecraft/server/VillagePlace.java -index c137484f6..c999f8c9b 100644 +index c137484f66..c999f8c9bf 100644 --- a/src/main/java/net/minecraft/server/VillagePlace.java +++ b/src/main/java/net/minecraft/server/VillagePlace.java @@ -165,7 +165,7 @@ public class VillagePlace extends RegionFileSection { @@ -571,7 +659,7 @@ index c137484f6..c999f8c9b 100644 } diff --git a/src/main/java/net/minecraft/server/VillagerTrades.java b/src/main/java/net/minecraft/server/VillagerTrades.java -index a06a31534..3bcf0b385 100644 +index a06a31534e..3bcf0b385d 100644 --- a/src/main/java/net/minecraft/server/VillagerTrades.java +++ b/src/main/java/net/minecraft/server/VillagerTrades.java @@ -15,12 +15,12 @@ import javax.annotation.Nullable; @@ -590,8 +678,21 @@ index a06a31534..3bcf0b385 100644 hashmap.put(VillagerProfession.CARTOGRAPHER, a(ImmutableMap.of(1, new VillagerTrades.IMerchantRecipeOption[]{new VillagerTrades.b(Items.PAPER, 24, 16, 2), new VillagerTrades.h(Items.MAP, 7, 1, 1)}, 2, new VillagerTrades.IMerchantRecipeOption[]{new VillagerTrades.b(Items.df, 11, 16, 10), new VillagerTrades.k(13, "Monument", MapIcon.Type.MONUMENT, 12, 5)}, 3, new VillagerTrades.IMerchantRecipeOption[]{new VillagerTrades.b(Items.COMPASS, 1, 12, 20), new VillagerTrades.k(14, "Mansion", MapIcon.Type.MANSION, 12, 10)}, 4, new VillagerTrades.IMerchantRecipeOption[]{new VillagerTrades.h(Items.ITEM_FRAME, 7, 1, 15), new VillagerTrades.h(Items.WHITE_BANNER, 3, 1, 15), new VillagerTrades.h(Items.BLUE_BANNER, 3, 1, 15), new VillagerTrades.h(Items.LIGHT_BLUE_BANNER, 3, 1, 15), new VillagerTrades.h(Items.RED_BANNER, 3, 1, 15), new VillagerTrades.h(Items.PINK_BANNER, 3, 1, 15), new VillagerTrades.h(Items.GREEN_BANNER, 3, 1, 15), new VillagerTrades.h(Items.LIME_BANNER, 3, 1, 15), new VillagerTrades.h(Items.GRAY_BANNER, 3, 1, 15), new VillagerTrades.h(Items.BLACK_BANNER, 3, 1, 15), new VillagerTrades.h(Items.PURPLE_BANNER, 3, 1, 15), new VillagerTrades.h(Items.MAGENTA_BANNER, 3, 1, 15), new VillagerTrades.h(Items.CYAN_BANNER, 3, 1, 15), new VillagerTrades.h(Items.BROWN_BANNER, 3, 1, 15), new VillagerTrades.h(Items.YELLOW_BANNER, 3, 1, 15), new VillagerTrades.h(Items.ORANGE_BANNER, 3, 1, 15), new VillagerTrades.h(Items.LIGHT_GRAY_BANNER, 3, 1, 15)}, 5, new VillagerTrades.IMerchantRecipeOption[]{new VillagerTrades.h(Items.GLOBE_BANNER_PATTERN, 8, 1, 30)}))); hashmap.put(VillagerProfession.CLERIC, a(ImmutableMap.of(1, new VillagerTrades.IMerchantRecipeOption[]{new VillagerTrades.b(Items.ROTTEN_FLESH, 32, 16, 2), new VillagerTrades.h(Items.REDSTONE, 1, 2, 1)}, 2, new VillagerTrades.IMerchantRecipeOption[]{new VillagerTrades.b(Items.GOLD_INGOT, 3, 12, 10), new VillagerTrades.h(Items.LAPIS_LAZULI, 1, 1, 5)}, 3, new VillagerTrades.IMerchantRecipeOption[]{new VillagerTrades.b(Items.RABBIT_FOOT, 2, 12, 20), new VillagerTrades.h(Blocks.GLOWSTONE, 4, 1, 12, 10)}, 4, new VillagerTrades.IMerchantRecipeOption[]{new VillagerTrades.b(Items.SCUTE, 4, 12, 30), new VillagerTrades.b(Items.GLASS_BOTTLE, 9, 12, 30), new VillagerTrades.h(Items.ENDER_PEARL, 5, 1, 15)}, 5, new VillagerTrades.IMerchantRecipeOption[]{new VillagerTrades.b(Items.NETHER_WART, 22, 12, 30), new VillagerTrades.h(Items.EXPERIENCE_BOTTLE, 3, 1, 30)}))); hashmap.put(VillagerProfession.ARMORER, a(ImmutableMap.of(1, new VillagerTrades.IMerchantRecipeOption[]{new VillagerTrades.b(Items.COAL, 15, 16, 2), new VillagerTrades.h(new ItemStack(Items.IRON_LEGGINGS), 7, 1, 12, 1, 0.2F), new VillagerTrades.h(new ItemStack(Items.IRON_BOOTS), 4, 1, 12, 1, 0.2F), new VillagerTrades.h(new ItemStack(Items.IRON_HELMET), 5, 1, 12, 1, 0.2F), new VillagerTrades.h(new ItemStack(Items.IRON_CHESTPLATE), 9, 1, 12, 1, 0.2F)}, 2, new VillagerTrades.IMerchantRecipeOption[]{new VillagerTrades.b(Items.IRON_INGOT, 4, 12, 10), new VillagerTrades.h(new ItemStack(Items.pQ), 36, 1, 12, 5, 0.2F), new VillagerTrades.h(new ItemStack(Items.CHAINMAIL_BOOTS), 1, 1, 12, 5, 0.2F), new VillagerTrades.h(new ItemStack(Items.CHAINMAIL_LEGGINGS), 3, 1, 12, 5, 0.2F)}, 3, new VillagerTrades.IMerchantRecipeOption[]{new VillagerTrades.b(Items.LAVA_BUCKET, 1, 12, 20), new VillagerTrades.b(Items.DIAMOND, 1, 12, 20), new VillagerTrades.h(new ItemStack(Items.CHAINMAIL_HELMET), 1, 1, 12, 10, 0.2F), new VillagerTrades.h(new ItemStack(Items.CHAINMAIL_CHESTPLATE), 4, 1, 12, 10, 0.2F), new VillagerTrades.h(new ItemStack(Items.SHIELD), 5, 1, 12, 10, 0.2F)}, 4, new VillagerTrades.IMerchantRecipeOption[]{new VillagerTrades.e(Items.DIAMOND_LEGGINGS, 14, 3, 15, 0.2F), new VillagerTrades.e(Items.DIAMOND_BOOTS, 8, 3, 15, 0.2F)}, 5, new VillagerTrades.IMerchantRecipeOption[]{new VillagerTrades.e(Items.DIAMOND_HELMET, 8, 3, 30, 0.2F), new VillagerTrades.e(Items.DIAMOND_CHESTPLATE, 16, 3, 30, 0.2F)}))); +diff --git a/src/main/java/net/minecraft/server/VoxelShapeMergerList.java b/src/main/java/net/minecraft/server/VoxelShapeMergerList.java +index e8daa74986..71d2ae2a9c 100644 +--- a/src/main/java/net/minecraft/server/VoxelShapeMergerList.java ++++ b/src/main/java/net/minecraft/server/VoxelShapeMergerList.java +@@ -38,7 +38,7 @@ public final class VoxelShapeMergerList implements VoxelShapeMerger { + double d1 = flag4 ? doublelist.getDouble(i++) : doublelist1.getDouble(j++); + + if ((i != 0 && flag2 || flag4 || flag1) && (j != 0 && flag3 || !flag4 || flag)) { +- if (d0 < d1 - 1.0E-7D) { ++ if (!(d0 >= d1 - 1.0E-7D)) { // Paper - decompile error - welcome to hell + this.b.add(i - 1); + this.c.add(j - 1); + this.a.add(d1); diff --git a/src/main/java/net/minecraft/server/WorldGenFeatureStateProviderWeighted.java b/src/main/java/net/minecraft/server/WorldGenFeatureStateProviderWeighted.java -index 555cf6be7..22e14fe1e 100644 +index 555cf6be79..22e14fe1e9 100644 --- a/src/main/java/net/minecraft/server/WorldGenFeatureStateProviderWeighted.java +++ b/src/main/java/net/minecraft/server/WorldGenFeatureStateProviderWeighted.java @@ -40,6 +40,6 @@ public class WorldGenFeatureStateProviderWeighted extends WorldGenFeatureStatePr @@ -603,7 +704,7 @@ index 555cf6be7..22e14fe1e 100644 } } diff --git a/src/main/java/net/minecraft/server/WorldPersistentData.java b/src/main/java/net/minecraft/server/WorldPersistentData.java -index 55fe7625a..19e68a783 100644 +index 55fe7625af..19e68a7831 100644 --- a/src/main/java/net/minecraft/server/WorldPersistentData.java +++ b/src/main/java/net/minecraft/server/WorldPersistentData.java @@ -37,7 +37,7 @@ public class WorldPersistentData { diff --git a/Spigot-Server-Patches/0004-MC-Utils.patch b/Spigot-Server-Patches/0004-MC-Utils.patch index 0be36afc1..b32312c00 100644 --- a/Spigot-Server-Patches/0004-MC-Utils.patch +++ b/Spigot-Server-Patches/0004-MC-Utils.patch @@ -1,11 +1,1616 @@ -From 23bf7ede3aac2e0054dcdc6301da047f0918a09b Mon Sep 17 00:00:00 2001 +From 8e4c5038f8c176fa625f4b32082042fb790494c5 Mon Sep 17 00:00:00 2001 From: Aikar Date: Mon, 28 Mar 2016 20:55:47 -0400 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 +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/util/concurrent/WeakSeqLock.java +@@ -0,0 +1,68 @@ ++package com.destroystokyo.paper.util.concurrent; ++ ++import java.util.concurrent.atomic.AtomicLong; ++ ++/** ++ * copied from https://github.com/Spottedleaf/ConcurrentUtil/blob/master/src/main/java/ca/spottedleaf/concurrentutil/lock/WeakSeqLock.java ++ * @author Spottedleaf ++ */ ++public final class WeakSeqLock { ++ // TODO when the switch to J11 is made, nuke this class from orbit ++ ++ protected final AtomicLong lock = new AtomicLong(); ++ ++ public WeakSeqLock() { ++ //VarHandle.storeStoreFence(); // warn: usages must be checked to ensure this behaviour isn't needed ++ } ++ ++ public void acquireWrite() { ++ // must be release-type write ++ this.lock.lazySet(this.lock.get() + 1); ++ } ++ ++ public boolean canRead(final long read) { ++ return (read & 1) == 0; ++ } ++ ++ public boolean tryAcquireWrite() { ++ this.acquireWrite(); ++ return true; ++ } ++ ++ public void releaseWrite() { ++ // must be acquire-type write ++ final long lock = this.lock.get(); // volatile here acts as store-store ++ this.lock.lazySet(lock + 1); ++ } ++ ++ public void abortWrite() { ++ // must be acquire-type write ++ final long lock = this.lock.get(); // volatile here acts as store-store ++ this.lock.lazySet(lock ^ 1); ++ } ++ ++ public long acquireRead() { ++ int failures = 0; ++ long curr; ++ ++ for (curr = this.lock.get(); !this.canRead(curr); curr = this.lock.get()) { ++ // without j11, our only backoff is the yield() call... ++ ++ if (++failures > 5_000) { /* TODO determine a threshold */ ++ Thread.yield(); ++ } ++ /* Better waiting is beyond the scope of this lock; if it is needed the lock is being misused */ ++ } ++ ++ //VarHandle.loadLoadFence(); // volatile acts as the load-load barrier ++ return curr; ++ } ++ ++ public boolean tryReleaseRead(final long read) { ++ return this.lock.get() == read; // volatile acts as the load-load barrier ++ } ++ ++ public long getSequentialCounter() { ++ return this.lock.get(); ++ } ++} +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 +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/util/map/QueuedChangesMapLong2Int.java +@@ -0,0 +1,156 @@ ++package com.destroystokyo.paper.util.map; ++ ++import com.destroystokyo.paper.util.concurrent.WeakSeqLock; ++import it.unimi.dsi.fastutil.longs.Long2IntMap; ++import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; ++import it.unimi.dsi.fastutil.longs.LongIterator; ++import it.unimi.dsi.fastutil.longs.LongOpenHashSet; ++import it.unimi.dsi.fastutil.objects.ObjectIterator; ++ ++/** ++ * @author Spottedleaf ++ */ ++public class QueuedChangesMapLong2Int { ++ ++ protected final Long2IntOpenHashMap updatingMap; ++ protected final Long2IntOpenHashMap visibleMap; ++ protected final Long2IntOpenHashMap queuedPuts; ++ protected final LongOpenHashSet queuedRemove; ++ ++ protected int queuedDefaultReturnValue; ++ ++ // we use a seqlock as writes are not common. ++ protected final WeakSeqLock updatingMapSeqLock = new WeakSeqLock(); ++ ++ public QueuedChangesMapLong2Int() { ++ this(16, 0.75f); ++ } ++ ++ public QueuedChangesMapLong2Int(final int capacity, final float loadFactor) { ++ this.updatingMap = new Long2IntOpenHashMap(capacity, loadFactor); ++ this.visibleMap = new Long2IntOpenHashMap(capacity, loadFactor); ++ this.queuedPuts = new Long2IntOpenHashMap(); ++ this.queuedRemove = new LongOpenHashSet(); ++ } ++ ++ public void queueDefaultReturnValue(final int dfl) { ++ this.queuedDefaultReturnValue = dfl; ++ this.updatingMap.defaultReturnValue(dfl); ++ } ++ ++ public int queueUpdate(final long k, final int v) { ++ this.queuedRemove.remove(k); ++ this.queuedPuts.put(k, v); ++ ++ return this.updatingMap.put(k, v); ++ } ++ ++ public int queueRemove(final long k) { ++ this.queuedPuts.remove(k); ++ this.queuedRemove.add(k); ++ ++ return this.updatingMap.remove(k); ++ } ++ ++ public int getUpdating(final long k) { ++ return this.updatingMap.get(k); ++ } ++ ++ public int getVisible(final long k) { ++ return this.visibleMap.get(k); ++ } ++ ++ public int getVisibleAsync(final long k) { ++ long readlock; ++ int ret = 0; ++ ++ do { ++ readlock = this.updatingMapSeqLock.acquireRead(); ++ try { ++ ret = this.visibleMap.get(k); ++ } catch (final Throwable thr) { ++ if (thr instanceof ThreadDeath) { ++ throw (ThreadDeath)thr; ++ } ++ // ignore... ++ continue; ++ } ++ ++ } while (!this.updatingMapSeqLock.tryReleaseRead(readlock)); ++ ++ return ret; ++ } ++ ++ public boolean performUpdates() { ++ this.updatingMapSeqLock.acquireWrite(); ++ this.visibleMap.defaultReturnValue(this.queuedDefaultReturnValue); ++ this.updatingMapSeqLock.releaseWrite(); ++ ++ if (this.queuedPuts.isEmpty() && this.queuedRemove.isEmpty()) { ++ return false; ++ } ++ ++ // update puts ++ final ObjectIterator iterator0 = this.queuedPuts.long2IntEntrySet().fastIterator(); ++ while (iterator0.hasNext()) { ++ final Long2IntMap.Entry entry = iterator0.next(); ++ final long key = entry.getLongKey(); ++ final int val = entry.getValue(); ++ ++ this.updatingMapSeqLock.acquireWrite(); ++ try { ++ this.visibleMap.put(key, val); ++ } finally { ++ this.updatingMapSeqLock.releaseWrite(); ++ } ++ } ++ ++ final LongIterator iterator1 = this.queuedRemove.iterator(); ++ while (iterator1.hasNext()) { ++ final long key = iterator1.nextLong(); ++ ++ this.updatingMapSeqLock.acquireWrite(); ++ try { ++ this.visibleMap.remove(key); ++ } finally { ++ this.updatingMapSeqLock.releaseWrite(); ++ } ++ } ++ ++ ++ return true; ++ } ++ ++ public boolean performUpdatesLockMap() { ++ this.updatingMapSeqLock.acquireWrite(); ++ try { ++ this.visibleMap.defaultReturnValue(this.queuedDefaultReturnValue); ++ ++ if (this.queuedPuts.isEmpty() && this.queuedRemove.isEmpty()) { ++ return false; ++ } ++ ++ // update puts ++ final ObjectIterator iterator0 = this.queuedPuts.long2IntEntrySet().fastIterator(); ++ while (iterator0.hasNext()) { ++ final Long2IntMap.Entry entry = iterator0.next(); ++ final long key = entry.getLongKey(); ++ final int val = entry.getValue(); ++ ++ this.visibleMap.put(key, val); ++ } ++ ++ final LongIterator iterator1 = this.queuedRemove.iterator(); ++ while (iterator1.hasNext()) { ++ final long key = iterator1.nextLong(); ++ ++ this.visibleMap.remove(key); ++ } ++ ++ ++ return true; ++ } finally { ++ this.updatingMapSeqLock.releaseWrite(); ++ } ++ } ++} +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 +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/util/map/QueuedChangesMapLong2Object.java +@@ -0,0 +1,172 @@ ++package com.destroystokyo.paper.util.map; ++ ++import com.destroystokyo.paper.util.concurrent.WeakSeqLock; ++import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap; ++import it.unimi.dsi.fastutil.longs.Long2ObjectMap; ++import it.unimi.dsi.fastutil.objects.ObjectBidirectionalIterator; ++import java.util.ArrayList; ++import java.util.Collection; ++import java.util.List; ++ ++/** ++ * @author Spottedleaf ++ */ ++public class QueuedChangesMapLong2Object { ++ ++ protected static final Object REMOVED = new Object(); ++ ++ protected final Long2ObjectLinkedOpenHashMap updatingMap; ++ protected final Long2ObjectLinkedOpenHashMap visibleMap; ++ protected final Long2ObjectLinkedOpenHashMap queuedChanges; ++ ++ // we use a seqlock as writes are not common. ++ protected final WeakSeqLock updatingMapSeqLock = new WeakSeqLock(); ++ ++ public QueuedChangesMapLong2Object() { ++ this(16, 0.75f); // dfl for fastutil ++ } ++ ++ public QueuedChangesMapLong2Object(final int capacity, final float loadFactor) { ++ this.updatingMap = new Long2ObjectLinkedOpenHashMap<>(capacity, loadFactor); ++ this.visibleMap = new Long2ObjectLinkedOpenHashMap<>(capacity, loadFactor); ++ this.queuedChanges = new Long2ObjectLinkedOpenHashMap<>(); ++ } ++ ++ public V queueUpdate(final long k, final V value) { ++ this.queuedChanges.put(k, value); ++ return this.updatingMap.put(k, value); ++ } ++ ++ public V queueRemove(final long k) { ++ this.queuedChanges.put(k, REMOVED); ++ return this.updatingMap.remove(k); ++ } ++ ++ public V getUpdating(final long k) { ++ return this.updatingMap.get(k); ++ } ++ ++ public V getVisible(final long k) { ++ return this.visibleMap.get(k); ++ } ++ ++ public V getVisibleAsync(final long k) { ++ long readlock; ++ V ret = null; ++ ++ do { ++ readlock = this.updatingMapSeqLock.acquireRead(); ++ ++ try { ++ ret = this.visibleMap.get(k); ++ } catch (final Throwable thr) { ++ if (thr instanceof ThreadDeath) { ++ throw (ThreadDeath)thr; ++ } ++ // ignore... ++ continue; ++ } ++ ++ } while (!this.updatingMapSeqLock.tryReleaseRead(readlock)); ++ ++ return ret; ++ } ++ ++ public Long2ObjectLinkedOpenHashMap getVisibleMap() { ++ return this.visibleMap; ++ } ++ ++ public Long2ObjectLinkedOpenHashMap getUpdatingMap() { ++ return this.updatingMap; ++ } ++ ++ public int getVisibleSize() { ++ return this.visibleMap.size(); ++ } ++ ++ public int getVisibleSizeAsync() { ++ long readlock; ++ int ret; ++ ++ do { ++ readlock = this.updatingMapSeqLock.acquireRead(); ++ ret = this.visibleMap.size(); ++ } while (!this.updatingMapSeqLock.tryReleaseRead(readlock)); ++ ++ return ret; ++ } ++ ++ // unlike mojang's impl this cannot be used async since it's not a view of an immutable map ++ public Collection getUpdatingValues() { ++ return this.updatingMap.values(); ++ } ++ ++ public List getUpdatingValuesCopy() { ++ return new ArrayList<>(this.updatingMap.values()); ++ } ++ ++ // unlike mojang's impl this cannot be used async since it's not a view of an immutable map ++ public Collection getVisibleValues() { ++ return this.visibleMap.values(); ++ } ++ ++ public List getVisibleValuesCopy() { ++ return new ArrayList<>(this.visibleMap.values()); ++ } ++ ++ public boolean performUpdates() { ++ if (this.queuedChanges.isEmpty()) { ++ return false; ++ } ++ ++ final ObjectBidirectionalIterator> iterator = this.queuedChanges.long2ObjectEntrySet().fastIterator(); ++ while (iterator.hasNext()) { ++ final Long2ObjectMap.Entry entry = iterator.next(); ++ final long key = entry.getLongKey(); ++ final Object val = entry.getValue(); ++ ++ this.updatingMapSeqLock.acquireWrite(); ++ try { ++ if (val == REMOVED) { ++ this.visibleMap.remove(key); ++ } else { ++ this.visibleMap.put(key, (V)val); ++ } ++ } finally { ++ this.updatingMapSeqLock.releaseWrite(); ++ } ++ } ++ ++ this.queuedChanges.clear(); ++ return true; ++ } ++ ++ public boolean performUpdatesLockMap() { ++ if (this.queuedChanges.isEmpty()) { ++ return false; ++ } ++ ++ final ObjectBidirectionalIterator> iterator = this.queuedChanges.long2ObjectEntrySet().fastIterator(); ++ ++ try { ++ this.updatingMapSeqLock.acquireWrite(); ++ ++ while (iterator.hasNext()) { ++ final Long2ObjectMap.Entry entry = iterator.next(); ++ final long key = entry.getLongKey(); ++ final Object val = entry.getValue(); ++ ++ if (val == REMOVED) { ++ this.visibleMap.remove(key); ++ } else { ++ this.visibleMap.put(key, (V)val); ++ } ++ } ++ } finally { ++ this.updatingMapSeqLock.releaseWrite(); ++ } ++ ++ this.queuedChanges.clear(); ++ return true; ++ } ++} +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 +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/util/maplist/ChunkList.java +@@ -0,0 +1,127 @@ ++package com.destroystokyo.paper.util.maplist; ++ ++import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; ++import net.minecraft.server.Chunk; ++import net.minecraft.server.MCUtil; ++import java.util.Arrays; ++import java.util.Iterator; ++import java.util.NoSuchElementException; ++ ++// list with O(1) remove & contains ++/** ++ * @author Spottedleaf ++ */ ++public final class ChunkList implements Iterable { ++ ++ protected final Long2IntOpenHashMap chunkToIndex = new Long2IntOpenHashMap(); ++ { ++ this.chunkToIndex.defaultReturnValue(Integer.MIN_VALUE); ++ } ++ ++ protected Chunk[] chunks = new Chunk[16]; ++ protected int count; ++ ++ public int size() { ++ return this.count; ++ } ++ ++ public boolean contains(final Chunk chunk) { ++ return this.chunkToIndex.containsKey(MCUtil.getCoordinateKey(chunk.getPos())); ++ } ++ ++ public boolean remove(final Chunk chunk) { ++ final int index = this.chunkToIndex.remove(MCUtil.getCoordinateKey(chunk.getPos())); ++ if (index == Integer.MIN_VALUE) { ++ return false; ++ } ++ ++ // move the entity at the end to this index ++ final int endIndex = --this.count; ++ 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.chunks[index] = end; ++ this.chunks[endIndex] = null; ++ ++ return true; ++ } ++ ++ public boolean add(final Chunk chunk) { ++ final int count = this.count; ++ final int currIndex = this.chunkToIndex.putIfAbsent(MCUtil.getCoordinateKey(chunk.getPos()), count); ++ ++ if (currIndex != Integer.MIN_VALUE) { ++ return false; // already in this list ++ } ++ ++ Chunk[] list = this.chunks; ++ ++ if (list.length == count) { ++ // resize required ++ list = this.chunks = Arrays.copyOf(list, count * 2); // overflow results in negative ++ } ++ ++ list[count] = chunk; ++ this.count = count + 1; ++ ++ return true; ++ } ++ ++ public Chunk getChecked(final int index) { ++ if (index < 0 || index >= this.count) { ++ throw new IndexOutOfBoundsException("Index: " + index + " is out of bounds, size: " + this.count); ++ } ++ return this.chunks[index]; ++ } ++ ++ public Chunk getUnchecked(final int index) { ++ return this.chunks[index]; ++ } ++ ++ public Chunk[] getRawData() { ++ return this.chunks; ++ } ++ ++ public void clear() { ++ this.chunkToIndex.clear(); ++ Arrays.fill(this.chunks, 0, this.count, null); ++ this.count = 0; ++ } ++ ++ @Override ++ public Iterator iterator() { ++ return new Iterator() { ++ ++ Chunk lastRet; ++ int current; ++ ++ @Override ++ public boolean hasNext() { ++ return this.current < ChunkList.this.count; ++ } ++ ++ @Override ++ public Chunk next() { ++ if (this.current >= ChunkList.this.count) { ++ throw new NoSuchElementException(); ++ } ++ return this.lastRet = ChunkList.this.chunks[this.current++]; ++ } ++ ++ @Override ++ public void remove() { ++ final Chunk lastRet = this.lastRet; ++ ++ if (lastRet == null) { ++ throw new IllegalStateException(); ++ } ++ this.lastRet = null; ++ ++ ChunkList.this.remove(lastRet); ++ --this.current; ++ } ++ }; ++ } ++} +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 +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/util/maplist/EntityList.java +@@ -0,0 +1,126 @@ ++package com.destroystokyo.paper.util.maplist; ++ ++import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; ++import net.minecraft.server.Entity; ++import java.util.Arrays; ++import java.util.Iterator; ++import java.util.NoSuchElementException; ++ ++// list with O(1) remove & contains ++/** ++ * @author Spottedleaf ++ */ ++public final class EntityList implements Iterable { ++ ++ protected final Int2IntOpenHashMap entityToIndex = new Int2IntOpenHashMap(); ++ { ++ this.entityToIndex.defaultReturnValue(Integer.MIN_VALUE); ++ } ++ ++ protected Entity[] entities = new Entity[16]; ++ protected int count; ++ ++ public int size() { ++ return this.count; ++ } ++ ++ public boolean contains(final Entity entity) { ++ return this.entityToIndex.containsKey(entity.getId()); ++ } ++ ++ public boolean remove(final Entity entity) { ++ final int index = this.entityToIndex.remove(entity.getId()); ++ if (index == Integer.MIN_VALUE) { ++ return false; ++ } ++ ++ // move the entity at the end to this index ++ final int endIndex = --this.count; ++ final Entity end = this.entities[endIndex]; ++ if (index != endIndex) { ++ // not empty after this call ++ this.entityToIndex.put(end.getId(), index); // update index ++ } ++ this.entities[index] = end; ++ this.entities[endIndex] = null; ++ ++ return true; ++ } ++ ++ public boolean add(final Entity entity) { ++ final int count = this.count; ++ final int currIndex = this.entityToIndex.putIfAbsent(entity.getId(), count); ++ ++ if (currIndex != Integer.MIN_VALUE) { ++ return false; // already in this list ++ } ++ ++ Entity[] list = this.entities; ++ ++ if (list.length == count) { ++ // resize required ++ list = this.entities = Arrays.copyOf(list, count * 2); // overflow results in negative ++ } ++ ++ list[count] = entity; ++ this.count = count + 1; ++ ++ return true; ++ } ++ ++ public Entity getChecked(final int index) { ++ if (index < 0 || index >= this.count) { ++ throw new IndexOutOfBoundsException("Index: " + index + " is out of bounds, size: " + this.count); ++ } ++ return this.entities[index]; ++ } ++ ++ public Entity getUnchecked(final int index) { ++ return this.entities[index]; ++ } ++ ++ public Entity[] getRawData() { ++ return this.entities; ++ } ++ ++ public void clear() { ++ this.entityToIndex.clear(); ++ Arrays.fill(this.entities, 0, this.count, null); ++ this.count = 0; ++ } ++ ++ @Override ++ public Iterator iterator() { ++ return new Iterator() { ++ ++ Entity lastRet; ++ int current; ++ ++ @Override ++ public boolean hasNext() { ++ return this.current < EntityList.this.count; ++ } ++ ++ @Override ++ public Entity next() { ++ if (this.current >= EntityList.this.count) { ++ throw new NoSuchElementException(); ++ } ++ return this.lastRet = EntityList.this.entities[this.current++]; ++ } ++ ++ @Override ++ public void remove() { ++ final Entity lastRet = this.lastRet; ++ ++ if (lastRet == null) { ++ throw new IllegalStateException(); ++ } ++ this.lastRet = null; ++ ++ EntityList.this.remove(lastRet); ++ --this.current; ++ } ++ }; ++ } ++} +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 +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/util/maplist/IBlockDataList.java +@@ -0,0 +1,126 @@ ++package com.destroystokyo.paper.util.maplist; ++ ++import it.unimi.dsi.fastutil.longs.LongIterator; ++import it.unimi.dsi.fastutil.shorts.Short2LongOpenHashMap; ++import net.minecraft.server.ChunkSection; ++import net.minecraft.server.DataPaletteGlobal; ++import net.minecraft.server.IBlockData; ++import java.util.Arrays; ++ ++/** ++ * @author Spottedleaf ++ */ ++public final class IBlockDataList { ++ ++ 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); ++ { ++ this.map.defaultReturnValue(Long.MAX_VALUE); ++ } ++ ++ private long[] byIndex = new long[16]; ++ private int size; ++ ++ public static int getLocationKey(final int x, final int y, final int z) { ++ return (x & 15) | (((z & 15) << 4)) | ((y & 255) << (4 + 4)); ++ } ++ ++ public static IBlockData getBlockDataFromRaw(final long raw) { ++ return GLOBAL_PALETTE.getObject((int)(raw >>> 32)); ++ } ++ ++ public static int getIndexFromRaw(final long raw) { ++ return (int)(raw & 0xFFFF); ++ } ++ ++ public static int getLocationFromRaw(final long raw) { ++ return (int)((raw >>> 16) & 0xFFFF); ++ } ++ ++ public static long getRawFromValues(final int index, final int location, final IBlockData data) { ++ return (long)index | ((long)location << 16) | (((long)GLOBAL_PALETTE.getOrCreateIdFor(data)) << 32); ++ } ++ ++ public static long setIndexRawValues(final long value, final int index) { ++ return value & ~(0xFFFF) | (index); ++ } ++ ++ public long add(final int x, final int y, final int z, final IBlockData data) { ++ return this.add(getLocationKey(x, y, z), data); ++ } ++ ++ public long add(final int location, final IBlockData data) { ++ final long curr = this.map.get((short)location); ++ ++ if (curr == Long.MAX_VALUE) { ++ final int index = this.size++; ++ final long raw = getRawFromValues(index, location, data); ++ this.map.put((short)location, raw); ++ ++ if (index >= this.byIndex.length) { ++ this.byIndex = Arrays.copyOf(this.byIndex, this.byIndex.length * 2); ++ } ++ ++ this.byIndex[index] = raw; ++ return raw; ++ } else { ++ final int index = getIndexFromRaw(curr); ++ final long raw = this.byIndex[index] = getRawFromValues(index, location, data); ++ ++ this.map.put((short)location, raw); ++ ++ return raw; ++ } ++ } ++ ++ public long remove(final int x, final int y, final int z) { ++ return this.remove(getLocationKey(x, y, z)); ++ } ++ ++ public long remove(final int location) { ++ final long ret = this.map.remove((short)location); ++ final int index = getIndexFromRaw(ret); ++ if (ret == Long.MAX_VALUE) { ++ return ret; ++ } ++ ++ // move the entry at the end to this index ++ final int endIndex = --this.size; ++ final long end = this.byIndex[endIndex]; ++ if (index != endIndex) { ++ // not empty after this call ++ this.map.put((short)getLocationFromRaw(end), setIndexRawValues(end, index)); ++ } ++ this.byIndex[index] = end; ++ this.byIndex[endIndex] = 0L; ++ ++ return ret; ++ } ++ ++ public int size() { ++ return this.size; ++ } ++ ++ public long getRaw(final int index) { ++ return this.byIndex[index]; ++ } ++ ++ public int getLocation(final int index) { ++ return getLocationFromRaw(this.getRaw(index)); ++ } ++ ++ public IBlockData getData(final int index) { ++ return getBlockDataFromRaw(this.getRaw(index)); ++ } ++ ++ public void clear() { ++ this.size = 0; ++ this.map.clear(); ++ } ++ ++ public LongIterator getRawIterator() { ++ return this.map.values().iterator(); ++ } ++} +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 +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/util/misc/AreaMap.java +@@ -0,0 +1,389 @@ ++package com.destroystokyo.paper.util.misc; ++ ++import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap; ++import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; ++import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; ++import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap; ++import net.minecraft.server.ChunkCoordIntPair; ++import net.minecraft.server.MCUtil; ++import net.minecraft.server.MinecraftServer; ++import javax.annotation.Nullable; ++import java.util.Iterator; ++ ++/** ++ * @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<>(); ++ ++ { ++ this.objectToViewDistance.defaultReturnValue(-1); ++ this.objectToLastCoordinate.defaultReturnValue(Long.MIN_VALUE); ++ } ++ ++ // 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; ++ ++ private final ChangeCallback addCallback; ++ private final ChangeCallback removeCallback; ++ ++ public AreaMap() { ++ this(new PooledLinkedHashSets<>()); ++ } ++ ++ // let users define a "global" or "shared" pooled sets if they wish ++ public AreaMap(final PooledLinkedHashSets pooledHashSets) { ++ this(pooledHashSets, null, null); ++ } ++ ++ public AreaMap(final PooledLinkedHashSets pooledHashSets, final ChangeCallback addCallback, final ChangeCallback removeCallback) { ++ this.pooledHashSets = pooledHashSets; ++ this.addCallback = addCallback; ++ this.removeCallback = removeCallback; ++ } ++ ++ @Nullable ++ public 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); ++ } ++ ++ @Nullable ++ public PooledLinkedHashSets.PooledObjectLinkedOpenHashSet getObjectsInRange(final int chunkX, final int chunkZ) { ++ return this.getObjectsInRange(MCUtil.getCoordinateKey(chunkX, chunkZ)); ++ } ++ ++ // Long.MIN_VALUE indicates the object is not mapped ++ public 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) { ++ return this.objectToViewDistance.getOrDefault(object, -1); ++ } ++ ++ // returns the total number of mapped chunks ++ public 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); ++ final long newPos = MCUtil.getCoordinateKey(chunkX, chunkZ); ++ if (oldDistance == -1) { ++ this.objectToLastCoordinate.put(object, newPos); ++ this.addObject(object, chunkX, chunkZ, Integer.MIN_VALUE, Integer.MIN_VALUE, viewDistance); ++ } else { ++ this.updateObject(object, this.objectToLastCoordinate.put(object, newPos), newPos, oldDistance, viewDistance); ++ } ++ //this.validate(object, viewDistance); ++ } ++ ++ public boolean remove(final E object) { ++ final long position = this.objectToLastCoordinate.removeLong(object); ++ final int viewDistance = this.objectToViewDistance.removeInt(object); ++ ++ if (viewDistance == -1) { ++ return false; ++ } ++ ++ final int currentX = MCUtil.getCoordinateX(position); ++ final int currentZ = MCUtil.getCoordinateZ(position); ++ ++ this.removeObject(object, currentX, currentZ, currentX, currentZ, viewDistance); ++ //this.validate(object, -1); ++ return true; ++ } ++ ++ protected abstract PooledLinkedHashSets.PooledObjectLinkedOpenHashSet getEmptySetFor(final E object); ++ ++ // expensive op, only for debug ++ private void validate(final E object, final int viewDistance) { ++ int entiesGot = 0; ++ int expectedEntries = (2 * viewDistance + 1); ++ expectedEntries *= expectedEntries; ++ if (viewDistance < 0) { ++ expectedEntries = 0; ++ } ++ ++ final long currPosition = this.objectToLastCoordinate.getLong(object); ++ ++ final int centerX = MCUtil.getCoordinateX(currPosition); ++ final int centerZ = MCUtil.getCoordinateZ(currPosition); ++ ++ for (Iterator>> iterator = this.areaMap.long2ObjectEntrySet().fastIterator(); ++ iterator.hasNext();) { ++ ++ final Long2ObjectLinkedOpenHashMap.Entry> entry = iterator.next(); ++ final long key = entry.getLongKey(); ++ final PooledLinkedHashSets.PooledObjectLinkedOpenHashSet map = entry.getValue(); ++ ++ if (map.referenceCount == 0) { ++ throw new IllegalStateException("Invalid map"); ++ } ++ ++ if (map.contains(object)) { ++ ++entiesGot; ++ ++ 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)); ++ ++ if (dist > viewDistance) { ++ throw new IllegalStateException("Expected view distance " + viewDistance + ", got " + dist); ++ } ++ } ++ } ++ ++ if (entiesGot != expectedEntries) { ++ throw new IllegalStateException("Expected " + expectedEntries + ", got " + entiesGot); ++ } ++ } ++ ++ 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) { ++ final long key = MCUtil.getCoordinateKey(chunkX, chunkZ); ++ ++ PooledLinkedHashSets.PooledObjectLinkedOpenHashSet empty = this.getEmptySetFor(object); ++ PooledLinkedHashSets.PooledObjectLinkedOpenHashSet current = this.areaMap.putIfAbsent(key, empty); ++ ++ if (current != null) { ++ PooledLinkedHashSets.PooledObjectLinkedOpenHashSet next = this.pooledHashSets.findMapWith(current, object); ++ if (next == current) { ++ throw new IllegalStateException("Expected different map: got " + next.toString()); ++ } ++ this.areaMap.put(key, next); ++ ++ current = next; ++ // fall through to callback ++ } else { ++ current = empty; ++ } ++ ++ if (this.addCallback != null) { ++ try { ++ this.addCallback.accept(object, chunkX, chunkZ, currChunkX, currChunkZ, prevChunkX, prevChunkZ, current); ++ } catch (final Throwable ex) { ++ if (ex instanceof ThreadDeath) { ++ throw (ThreadDeath)ex; ++ } ++ MinecraftServer.LOGGER.error("Add callback for map threw exception ", ex); ++ } ++ } ++ } ++ ++ 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) { ++ final long key = MCUtil.getCoordinateKey(chunkX, chunkZ); ++ ++ PooledLinkedHashSets.PooledObjectLinkedOpenHashSet current = this.areaMap.get(key); ++ ++ if (current == null) { ++ throw new IllegalStateException("Current map may not be null for " + object + ", (" + chunkX + "," + chunkZ + ")"); ++ } ++ ++ PooledLinkedHashSets.PooledObjectLinkedOpenHashSet next = this.pooledHashSets.findMapWithout(current, object); ++ ++ if (next == current) { ++ throw new IllegalStateException("Current map [" + next.toString() + "] should have contained " + object + ", (" + chunkX + "," + chunkZ + ")"); ++ } ++ ++ if (next != null) { ++ this.areaMap.put(key, next); ++ } else { ++ this.areaMap.remove(key); ++ } ++ ++ if (this.removeCallback != null) { ++ try { ++ this.removeCallback.accept(object, chunkX, chunkZ, currChunkX, currChunkZ, prevChunkX, prevChunkZ, next); ++ } catch (final Throwable ex) { ++ if (ex instanceof ThreadDeath) { ++ throw (ThreadDeath)ex; ++ } ++ MinecraftServer.LOGGER.error("Remove callback for map threw exception ", ex); ++ } ++ } ++ } ++ ++ 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) { ++ this.addObjectTo(object, x, z, chunkX, chunkZ, prevChunkX, prevChunkZ); ++ } ++ } ++ } ++ ++ 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) { ++ this.removeObjectFrom(object, x, z, currentChunkX, currentChunkZ, chunkX, chunkZ); ++ } ++ } ++ } ++ ++ /* math sign function except 0 returns 1 */ ++ protected static int sign(int val) { ++ 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) { ++ 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 dx = toX - fromX; ++ final int dz = toZ - fromZ; ++ ++ final int totalX = Math.abs(fromX - toX); ++ final int totalZ = Math.abs(fromZ - toZ); ++ ++ if (Math.max(totalX, totalZ) > (2 * Math.max(newViewDistance, oldViewDistance))) { ++ // teleported? ++ this.removeObject(object, fromX, fromZ, fromX, fromZ, oldViewDistance); ++ this.addObject(object, toX, toZ, fromX, fromZ, newViewDistance); ++ return; ++ } ++ ++ if (oldViewDistance != newViewDistance) { ++ // remove loop ++ ++ 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) { ++ ++ // only remove if we're outside the new view distance... ++ if (Math.max(Math.abs(currX - toX), Math.abs(currZ - toZ)) > newViewDistance) { ++ this.removeObjectFrom(object, currX, currZ, toX, toZ, fromX, fromZ); ++ } ++ } ++ } ++ ++ // add loop ++ ++ 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) { ++ ++ // only add if we're outside the old view distance... ++ if (Math.max(Math.abs(currX - fromX), Math.abs(currZ - fromZ)) > oldViewDistance) { ++ this.addObjectTo(object, currX, currZ, toX, toZ, fromX, fromZ); ++ } ++ } ++ } ++ ++ return; ++ } ++ ++ // x axis is width ++ // z axis is height ++ // right refers to the x axis of where we moved ++ // top refers to the z axis of where we moved ++ ++ // same view distance ++ ++ // used for relative positioning ++ final int up = sign(dz); // 1 if dz >= 0, -1 otherwise ++ final int right = sign(dx); // 1 if dx >= 0, -1 otherwise ++ ++ // The area excluded by overlapping the two view distance squares creates four rectangles: ++ // Two on the left, and two on the right. The ones on the left we consider the "removed" section ++ // and on the right the "added" section. ++ // https://i.imgur.com/MrnOBgI.png is a reference image. Note that the outside border is not actually ++ // exclusive to the regions they surround. ++ ++ // 4 points of the rectangle ++ int maxX; // exclusive ++ int minX; // inclusive ++ int maxZ; // exclusive ++ int minZ; // inclusive ++ ++ if (dx != 0) { ++ // handle right addition ++ ++ maxX = toX + (oldViewDistance * right) + right; // exclusive ++ minX = fromX + (oldViewDistance * right) + right; // inclusive ++ maxZ = fromZ + (oldViewDistance * up) + up; // exclusive ++ minZ = toZ - (oldViewDistance * up); // inclusive ++ ++ for (int currX = minX; currX != maxX; currX += right) { ++ for (int currZ = minZ; currZ != maxZ; currZ += up) { ++ this.addObjectTo(object, currX, currZ, toX, toZ, fromX, fromZ); ++ } ++ } ++ } ++ ++ if (dz != 0) { ++ // handle up addition ++ ++ maxX = toX + (oldViewDistance * right) + right; // exclusive ++ minX = toX - (oldViewDistance * right); // inclusive ++ maxZ = toZ + (oldViewDistance * up) + up; // exclusive ++ minZ = fromZ + (oldViewDistance * up) + up; // inclusive ++ ++ for (int currX = minX; currX != maxX; currX += right) { ++ for (int currZ = minZ; currZ != maxZ; currZ += up) { ++ this.addObjectTo(object, currX, currZ, toX, toZ, fromX, fromZ); ++ } ++ } ++ } ++ ++ if (dx != 0) { ++ // handle left removal ++ ++ maxX = toX - (oldViewDistance * right); // exclusive ++ minX = fromX - (oldViewDistance * right); // inclusive ++ maxZ = fromZ + (oldViewDistance * up) + up; // exclusive ++ minZ = toZ - (oldViewDistance * up); // inclusive ++ ++ for (int currX = minX; currX != maxX; currX += right) { ++ for (int currZ = minZ; currZ != maxZ; currZ += up) { ++ this.removeObjectFrom(object, currX, currZ, toX, toZ, fromX, fromZ); ++ } ++ } ++ } ++ ++ if (dz != 0) { ++ // handle down removal ++ ++ maxX = fromX + (oldViewDistance * right) + right; // exclusive ++ minX = fromX - (oldViewDistance * right); // inclusive ++ maxZ = toZ - (oldViewDistance * up); // exclusive ++ minZ = fromZ - (oldViewDistance * up); // inclusive ++ ++ for (int currX = minX; currX != maxX; currX += right) { ++ for (int currZ = minZ; currZ != maxZ; currZ += up) { ++ this.removeObjectFrom(object, currX, currZ, toX, toZ, fromX, fromZ); ++ } ++ } ++ } ++ } ++ ++ @FunctionalInterface ++ public static interface ChangeCallback { ++ ++ // if there is no previous position, then prevPos = Integer.MIN_VALUE ++ void accept(final E object, final int rangeX, final int rangeZ, final int currPosX, final int currPosZ, final int prevPosX, final int prevPosZ, ++ final PooledLinkedHashSets.PooledObjectLinkedOpenHashSet newState); ++ ++ } ++} +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 +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/util/misc/PlayerAreaMap.java +@@ -0,0 +1,27 @@ ++package com.destroystokyo.paper.util.misc; ++ ++import net.minecraft.server.EntityPlayer; ++ ++/** ++ * @author Spottedleaf ++ */ ++public final class PlayerAreaMap extends AreaMap { ++ ++ public PlayerAreaMap() { ++ super(); ++ } ++ ++ public PlayerAreaMap(final PooledLinkedHashSets pooledHashSets) { ++ super(pooledHashSets); ++ } ++ ++ public PlayerAreaMap(final PooledLinkedHashSets pooledHashSets, final ChangeCallback addCallback, ++ final ChangeCallback removeCallback) { ++ super(pooledHashSets, addCallback, removeCallback); ++ } ++ ++ @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 +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/util/misc/PooledLinkedHashSets.java +@@ -0,0 +1,289 @@ ++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 ++ */ ++public class PooledLinkedHashSets { ++ ++ /* Tested via https://gist.github.com/Spottedleaf/a93bb7a8993d6ce142d3efc5932bf573 */ ++ ++ // we really want to avoid that equals() check as much as possible... ++ protected final Object2ObjectOpenHashMap, PooledObjectLinkedOpenHashSet> mapPool = new Object2ObjectOpenHashMap<>(128, 0.25f); ++ ++ protected void decrementReferenceCount(final PooledObjectLinkedOpenHashSet current) { ++ if (current.referenceCount == 0) { ++ throw new IllegalStateException("Cannot decrement reference count for " + current); ++ } ++ if (current.referenceCount == -1 || --current.referenceCount > 0) { ++ return; ++ } ++ ++ this.mapPool.remove(current); ++ return; ++ } ++ ++ public PooledObjectLinkedOpenHashSet findMapWith(final PooledObjectLinkedOpenHashSet current, final E object) { ++ final PooledObjectLinkedOpenHashSet cached = current.getAddCache(object); ++ ++ if (cached != null) { ++ decrementReferenceCount(current); ++ ++ if (cached.referenceCount == 0) { ++ // bring the map back from the dead ++ PooledObjectLinkedOpenHashSet contending = this.mapPool.putIfAbsent(cached, cached); ++ if (contending != null) { ++ // a map already exists with the elements we want ++ if (contending.referenceCount != -1) { ++ ++contending.referenceCount; ++ } ++ current.updateAddCache(object, contending); ++ return contending; ++ } ++ ++ cached.referenceCount = 1; ++ } else if (cached.referenceCount != -1) { ++ ++cached.referenceCount; ++ } ++ ++ return cached; ++ } ++ ++ if (!current.add(object)) { ++ return current; ++ } ++ ++ // we use get/put since we use a different key on put ++ PooledObjectLinkedOpenHashSet ret = this.mapPool.get(current); ++ ++ if (ret == null) { ++ ret = new PooledObjectLinkedOpenHashSet<>(current); ++ current.remove(object); ++ this.mapPool.put(ret, ret); ++ ret.referenceCount = 1; ++ } else { ++ if (ret.referenceCount != -1) { ++ ++ret.referenceCount; ++ } ++ current.remove(object); ++ } ++ ++ current.updateAddCache(object, ret); ++ ++ decrementReferenceCount(current); ++ return ret; ++ } ++ ++ // rets null if current.size() == 1 ++ public PooledObjectLinkedOpenHashSet findMapWithout(final PooledObjectLinkedOpenHashSet current, final E object) { ++ if (current.set.size() == 1) { ++ decrementReferenceCount(current); ++ return null; ++ } ++ ++ final PooledObjectLinkedOpenHashSet cached = current.getRemoveCache(object); ++ ++ if (cached != null) { ++ decrementReferenceCount(current); ++ ++ if (cached.referenceCount == 0) { ++ // bring the map back from the dead ++ PooledObjectLinkedOpenHashSet contending = this.mapPool.putIfAbsent(cached, cached); ++ if (contending != null) { ++ // a map already exists with the elements we want ++ if (contending.referenceCount != -1) { ++ ++contending.referenceCount; ++ } ++ current.updateRemoveCache(object, contending); ++ return contending; ++ } ++ ++ cached.referenceCount = 1; ++ } else if (cached.referenceCount != -1) { ++ ++cached.referenceCount; ++ } ++ ++ return cached; ++ } ++ ++ if (!current.remove(object)) { ++ return current; ++ } ++ ++ // we use get/put since we use a different key on put ++ PooledObjectLinkedOpenHashSet ret = this.mapPool.get(current); ++ ++ if (ret == null) { ++ ret = new PooledObjectLinkedOpenHashSet<>(current); ++ current.add(object); ++ this.mapPool.put(ret, ret); ++ ret.referenceCount = 1; ++ } else { ++ if (ret.referenceCount != -1) { ++ ++ret.referenceCount; ++ } ++ current.add(object); ++ } ++ ++ current.updateRemoveCache(object, ret); ++ ++ decrementReferenceCount(current); ++ return ret; ++ } ++ ++ static final class RawSetObjectLinkedOpenHashSet extends ObjectOpenHashSet { ++ ++ public RawSetObjectLinkedOpenHashSet() { ++ super(); ++ } ++ ++ public RawSetObjectLinkedOpenHashSet(final int capacity) { ++ super(capacity); ++ } ++ ++ public RawSetObjectLinkedOpenHashSet(final int capacity, final float loadFactor) { ++ super(capacity, loadFactor); ++ } ++ ++ @Override ++ public RawSetObjectLinkedOpenHashSet clone() { ++ return (RawSetObjectLinkedOpenHashSet)super.clone(); ++ } ++ ++ public E[] getRawSet() { ++ return this.key; ++ } ++ } ++ ++ public static final class PooledObjectLinkedOpenHashSet { ++ ++ private static final WeakReference NULL_REFERENCE = new WeakReference<>(null); ++ ++ final RawSetObjectLinkedOpenHashSet set; ++ int referenceCount; // -1 if special ++ int hash; // optimize hashcode ++ ++ // add cache ++ WeakReference lastAddObject = NULL_REFERENCE; ++ WeakReference> lastAddMap = NULL_REFERENCE; ++ ++ // remove cache ++ WeakReference lastRemoveObject = NULL_REFERENCE; ++ WeakReference> lastRemoveMap = NULL_REFERENCE; ++ ++ public PooledObjectLinkedOpenHashSet(final PooledLinkedHashSets pooledSets) { ++ this.set = new RawSetObjectLinkedOpenHashSet<>(2, 0.8f); ++ } ++ ++ public PooledObjectLinkedOpenHashSet(final E single) { ++ this((PooledLinkedHashSets)null); ++ this.referenceCount = -1; ++ this.add(single); ++ } ++ ++ public PooledObjectLinkedOpenHashSet(final PooledObjectLinkedOpenHashSet other) { ++ this.set = other.set.clone(); ++ this.hash = other.hash; ++ } ++ ++ // from https://github.com/Spottedleaf/ConcurrentUtil/blob/master/src/main/java/ca/spottedleaf/concurrentutil/util/IntegerUtil.java ++ // generated by https://github.com/skeeto/hash-prospector ++ private static int hash0(int x) { ++ x *= 0x36935555; ++ x ^= x >>> 16; ++ return x; ++ } ++ ++ PooledObjectLinkedOpenHashSet getAddCache(final E element) { ++ final E currentAdd = this.lastAddObject.get(); ++ ++ if (currentAdd == null || !(currentAdd == element || currentAdd.equals(element))) { ++ return null; ++ } ++ ++ return this.lastAddMap.get(); ++ } ++ ++ PooledObjectLinkedOpenHashSet getRemoveCache(final E element) { ++ final E currentRemove = this.lastRemoveObject.get(); ++ ++ if (currentRemove == null || !(currentRemove == element || currentRemove.equals(element))) { ++ return null; ++ } ++ ++ return this.lastRemoveMap.get(); ++ } ++ ++ void updateAddCache(final E element, final PooledObjectLinkedOpenHashSet map) { ++ this.lastAddObject = new WeakReference<>(element); ++ this.lastAddMap = new WeakReference<>(map); ++ } ++ ++ void updateRemoveCache(final E element, final PooledObjectLinkedOpenHashSet map) { ++ this.lastRemoveObject = new WeakReference<>(element); ++ this.lastRemoveMap = new WeakReference<>(map); ++ } ++ ++ boolean add(final E element) { ++ boolean added = this.set.add(element); ++ ++ if (added) { ++ this.hash += hash0(element.hashCode()); ++ } ++ ++ return added; ++ } ++ ++ boolean remove(Object element) { ++ boolean removed = this.set.remove(element); ++ ++ if (removed) { ++ this.hash -= hash0(element.hashCode()); ++ } ++ ++ return removed; ++ } ++ ++ public boolean contains(final Object element) { ++ return this.set.contains(element); ++ } ++ ++ public E[] getBackingSet() { ++ return this.set.getRawSet(); ++ } ++ ++ public int size() { ++ return this.set.size(); ++ } ++ ++ @Override ++ public int hashCode() { ++ return this.hash; ++ } ++ ++ @Override ++ public boolean equals(final Object other) { ++ if (!(other instanceof PooledObjectLinkedOpenHashSet)) { ++ return false; ++ } ++ if (this.referenceCount == 0) { ++ return other == this; ++ } else { ++ if (other == this) { ++ // Unfortunately we are never equal to our own instance while in use! ++ return false; ++ } ++ return this.hash == ((PooledObjectLinkedOpenHashSet)other).hash && this.set.equals(((PooledObjectLinkedOpenHashSet)other).set); ++ } ++ } ++ ++ @Override ++ public String toString() { ++ return "PooledHashSet: size: " + this.set.size() + ", reference count: " + this.referenceCount + ", hash: " + ++ this.hashCode() + ", identity: " + System.identityHashCode(this) + " map: " + this.set.toString(); ++ } ++ } ++} +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..4d74a7a908 +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/util/set/OptimizedSmallEnumSet.java +@@ -0,0 +1,65 @@ ++package com.destroystokyo.paper.util.set; ++ ++import java.util.Collection; ++ ++// containing utils to work on small numbers of enums ++public final class OptimizedSmallEnumSet> { ++ ++ private final Class enumClass; ++ private long backingSet; ++ ++ public OptimizedSmallEnumSet(final Class clazz) { ++ if (clazz == null) { ++ throw new IllegalArgumentException("Null class"); ++ } ++ if (!clazz.isEnum()) { ++ throw new IllegalArgumentException("Class must be enum, not " + clazz.getCanonicalName()); ++ } ++ this.enumClass = clazz; ++ } ++ ++ public boolean addUnchecked(final E element) { ++ final int ordinal = element.ordinal(); ++ final long key = 1L << ordinal; ++ ++ final long prev = this.backingSet; ++ this.backingSet = prev | key; ++ ++ return (prev & key) == 0; ++ } ++ ++ public boolean removeUnchecked(final E element) { ++ final int ordinal = element.ordinal(); ++ final long key = 1L << ordinal; ++ ++ final long prev = this.backingSet; ++ this.backingSet = prev & ~key; ++ ++ return (prev & key) != 0; ++ } ++ ++ public void clear() { ++ this.backingSet = 0L; ++ } ++ ++ public int size() { ++ return Long.bitCount(this.backingSet); ++ } ++ ++ public void addAllUnchecked(final Collection enums) { ++ for (final E element : enums) { ++ if (element == null) { ++ throw new NullPointerException("Null element"); ++ } ++ this.backingSet |= (1L << element.ordinal()); ++ } ++ } ++ ++ public long getBackingSet() { ++ return this.backingSet; ++ } ++ ++ public boolean hasCommonElements(final OptimizedSmallEnumSet other) { ++ return (other.backingSet & this.backingSet) != 0; ++ } ++} diff --git a/src/main/java/net/minecraft/server/BlockAccessAir.java b/src/main/java/net/minecraft/server/BlockAccessAir.java -index eff6ebcd3..30cbfc8ea 100644 +index eff6ebcd30..30cbfc8eac 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 { @@ -28,7 +1633,7 @@ index eff6ebcd3..30cbfc8ea 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 1cf97cefc..2040f1834 100644 +index 1cf97cefc9..2040f18349 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 { @@ -40,7 +1645,7 @@ index 1cf97cefc..2040f1834 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 c88a62f6b..1cdf0346f 100644 +index c88a62f6b7..5dbd3e60fe 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 @@ -76,8 +1681,26 @@ index c88a62f6b..1cdf0346f 100644 public BlockPosition.MutableBlockPosition c(double d0, double d1, double d2) { return this.d(MathHelper.floor(d0), MathHelper.floor(d1), MathHelper.floor(d2)); } +@@ -441,14 +446,17 @@ public class BlockPosition extends BaseBlockPosition implements MinecraftSeriali + return this.d(this.b + i, this.c + j, this.d + k); + } + ++ public final void setX(final int x) { this.o(x); } // Paper - OBFHELPER + public void o(int i) { + this.b = i; + } + ++ public final void setY(final int y) { this.p(y); } // Paper - OBFHELPER + public void p(int i) { + this.c = i; + } + ++ public final void setZ(final int z) { this.q(z); } // Paper - OBFHELPER + public void q(int i) { + this.d = i; + } diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 55373cae0..cfffbd031 100644 +index 55373cae07..a263f60d49 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; @@ -89,7 +1712,37 @@ index 55373cae0..cfffbd031 100644 private final ChunkSection[] sections; private BiomeStorage d; private final Map e; -@@ -213,6 +213,18 @@ public class Chunk implements IChunkAccess { +@@ -48,7 +48,7 @@ public class Chunk implements IChunkAccess { + private Supplier u; + @Nullable + private Consumer v; +- private final ChunkCoordIntPair loc; ++ private final ChunkCoordIntPair loc; public final long coordinateKey; // Paper - cache coordinate key + private volatile boolean x; + + public Chunk(World world, ChunkCoordIntPair chunkcoordintpair, BiomeStorage biomestorage) { +@@ -65,7 +65,7 @@ public class Chunk implements IChunkAccess { + this.n = new ShortList[16]; + this.entitySlices = (List[]) (new List[16]); // Spigot + this.world = world; +- this.loc = chunkcoordintpair; ++ this.loc = chunkcoordintpair; this.coordinateKey = MCUtil.getCoordinateKey(chunkcoordintpair); // Paper - cache coordinate key + this.i = chunkconverter; + HeightMap.Type[] aheightmap_type = HeightMap.Type.values(); + int j = aheightmap_type.length; +@@ -108,6 +108,11 @@ 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; ++ // 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 { } } @@ -108,7 +1761,15 @@ index 55373cae0..cfffbd031 100644 @Override public Fluid getFluid(BlockPosition blockposition) { return this.a(blockposition.getX(), blockposition.getY(), blockposition.getZ()); -@@ -395,6 +407,7 @@ public class Chunk implements IChunkAccess { +@@ -352,6 +369,7 @@ public class Chunk implements IChunkAccess { + entity.chunkX = this.loc.x; + entity.chunkY = k; + entity.chunkZ = this.loc.z; ++ this.entities.add(entity); // Paper - per chunk entity list + this.entitySlices[k].add(entity); + } + +@@ -395,6 +413,7 @@ public class Chunk implements IChunkAccess { return this.a(blockposition, Chunk.EnumTileEntityState.CHECK); } @@ -116,8 +1777,24 @@ index 55373cae0..cfffbd031 100644 @Nullable public TileEntity a(BlockPosition blockposition, Chunk.EnumTileEntityState chunk_enumtileentitystate) { // CraftBukkit start +@@ -507,6 +526,7 @@ public class Chunk implements IChunkAccess { + // CraftBukkit start + public void loadCallback() { + 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 +@@ -540,6 +560,7 @@ public class Chunk implements IChunkAccess { + } + + public void unloadCallback() { ++ ((WorldServer)this.world).getChunkProvider().removeLoadedChunk(this); // Paper + org.bukkit.Server server = this.world.getServer(); + org.bukkit.event.world.ChunkUnloadEvent unloadEvent = new org.bukkit.event.world.ChunkUnloadEvent(this.bukkitChunk, this.isNeedsSaving()); + server.getPluginManager().callEvent(unloadEvent); diff --git a/src/main/java/net/minecraft/server/ChunkCache.java b/src/main/java/net/minecraft/server/ChunkCache.java -index 11c4d23ba..53c15c1c0 100644 +index 11c4d23ba9..53c15c1c0b 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 { @@ -151,7 +1828,7 @@ index 11c4d23ba..53c15c1c0 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 260644bf0..f2a19acd8 100644 +index 260644bf0b..f2a19acd84 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 { @@ -166,10 +1843,108 @@ index 260644bf0..f2a19acd8 100644 } diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java -index e8b7cc06c..9cd21b1ff 100644 +index e8b7cc06c2..d24c8070f4 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java -@@ -77,6 +77,37 @@ public class ChunkProviderServer extends IChunkProvider { +@@ -23,7 +23,7 @@ public class ChunkProviderServer extends IChunkProvider { + private final ChunkMapDistance chunkMapDistance; + public final ChunkGenerator chunkGenerator; + private final WorldServer world; +- private final Thread serverThread; ++ public final Thread serverThread; // Paper - private -> public + private final LightEngineThreaded lightEngine; + private final ChunkProviderServer.a serverThreadQueue; + public final PlayerChunkMap playerChunkMap; +@@ -35,6 +35,88 @@ public class ChunkProviderServer extends IChunkProvider { + private final ChunkStatus[] cacheStatus = new ChunkStatus[4]; + private final IChunkAccess[] cacheChunk = new IChunkAccess[4]; + ++ // Paper start ++ final com.destroystokyo.paper.util.concurrent.WeakSeqLock loadedChunkMapSeqLock = new com.destroystokyo.paper.util.concurrent.WeakSeqLock(); ++ final it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap loadedChunkMap = new it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<>(8192, 0.5f); ++ ++ private final Chunk[] lastLoadedChunks = new Chunk[4 * 4]; ++ private final long[] lastLoadedChunkKeys = new long[4 * 4]; ++ ++ { ++ java.util.Arrays.fill(this.lastLoadedChunkKeys, MCUtil.INVALID_CHUNK_KEY); ++ } ++ ++ private static int getCacheKey(int x, int z) { ++ return x & 3 | ((z & 3) << 2); ++ } ++ ++ void addLoadedChunk(Chunk chunk) { ++ this.loadedChunkMapSeqLock.acquireWrite(); ++ try { ++ this.loadedChunkMap.put(chunk.coordinateKey, chunk); ++ } finally { ++ this.loadedChunkMapSeqLock.releaseWrite(); ++ } ++ ++ // rewrite cache if we have to ++ // we do this since we also cache null chunks ++ int cacheKey = getCacheKey(chunk.getPos().x, chunk.getPos().z); ++ ++ long cachedKey = this.lastLoadedChunkKeys[cacheKey]; ++ if (cachedKey == chunk.coordinateKey) { ++ this.lastLoadedChunks[cacheKey] = chunk; ++ } ++ } ++ ++ void removeLoadedChunk(Chunk chunk) { ++ this.loadedChunkMapSeqLock.acquireWrite(); ++ try { ++ this.loadedChunkMap.remove(chunk.coordinateKey); ++ } finally { ++ this.loadedChunkMapSeqLock.releaseWrite(); ++ } ++ ++ // rewrite cache if we have to ++ // we do this since we also cache null chunks ++ int cacheKey = getCacheKey(chunk.getPos().x, chunk.getPos().z); ++ ++ long cachedKey = this.lastLoadedChunkKeys[cacheKey]; ++ if (cachedKey == chunk.coordinateKey) { ++ this.lastLoadedChunks[cacheKey] = null; ++ } ++ } ++ ++ public Chunk getChunkAtIfLoadedMainThread(int x, int z) { ++ int cacheKey = getCacheKey(x, z); ++ long chunkKey = MCUtil.getCoordinateKey(x, z); ++ ++ long cachedKey = this.lastLoadedChunkKeys[cacheKey]; ++ if (cachedKey == chunkKey) { ++ return this.lastLoadedChunks[cacheKey]; ++ } ++ ++ Chunk ret = this.loadedChunkMap.get(chunkKey); ++ ++ this.lastLoadedChunkKeys[cacheKey] = chunkKey; ++ this.lastLoadedChunks[cacheKey] = ret; ++ ++ return ret; ++ } ++ ++ public Chunk getChunkAtIfLoadedMainThreadNoCache(int x, int z) { ++ return this.loadedChunkMap.get(MCUtil.getCoordinateKey(x, z)); ++ } ++ ++ public Chunk getChunkAtMainThread(int x, int z) { ++ Chunk ret = this.getChunkAtIfLoadedMainThread(x, z); ++ if (ret != null) { ++ return ret; ++ } ++ return (Chunk)this.getChunkAt(x, z, ChunkStatus.FULL, true); ++ } ++ // Paper ++ ++ + public ChunkProviderServer(WorldServer worldserver, File file, DataFixer datafixer, DefinedStructureManager definedstructuremanager, Executor executor, ChunkGenerator chunkgenerator, int i, WorldLoadListener worldloadlistener, Supplier supplier) { + this.world = worldserver; + this.serverThreadQueue = new ChunkProviderServer.a(worldserver); +@@ -77,6 +159,51 @@ public class ChunkProviderServer extends IChunkProvider { this.cacheChunk[0] = ichunkaccess; } @@ -179,14 +1954,28 @@ index e8b7cc06c..9cd21b1ff 100644 + public Chunk getChunkAtIfCachedImmediately(int x, int z) { + long k = ChunkCoordIntPair.pair(x, z); + -+ // Note: Bypass cache to make this MT-Safe -+ -+ PlayerChunk playerChunk = this.getChunk(k); -+ if (playerChunk == null) { -+ return null; ++ // Paper start - Optimize getIfLoaded type calls ++ if (Thread.currentThread() == this.serverThread) { ++ return this.getChunkAtIfLoadedMainThread(x, z); + } + -+ return playerChunk.getFullChunkIfCached(); ++ Chunk ret = null; ++ long readlock; ++ do { ++ readlock = this.loadedChunkMapSeqLock.acquireRead(); ++ try { ++ ret = this.loadedChunkMap.get(k); ++ } catch (Throwable thr) { ++ if (thr instanceof ThreadDeath) { ++ throw (ThreadDeath)thr; ++ } ++ // re-try, this means a CME occurred... ++ continue; ++ } ++ } while (!this.loadedChunkMapSeqLock.tryReleaseRead(readlock)); ++ ++ return ret; ++ // Paper end + } + + @Nullable @@ -208,7 +1997,7 @@ index e8b7cc06c..9cd21b1ff 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 7ca3a1d0c..2edd9b871 100644 +index 7ca3a1d0c5..2edd9b8714 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 { @@ -220,7 +2009,7 @@ index 7ca3a1d0c..2edd9b871 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 75ba69886..45403fbe3 100644 +index 75ba698868..45403fbe30 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; @@ -237,7 +2026,7 @@ index 75ba69886..45403fbe3 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 774a8f543..d5f5a5187 100644 +index 774a8f5434..d5f5a51872 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; @@ -279,7 +2068,7 @@ index 774a8f543..d5f5a5187 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 fe69161e5..b40c8d2f8 100644 +index fe69161e5b..b40c8d2f83 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; @@ -292,7 +2081,7 @@ index fe69161e5..b40c8d2f8 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 e1398652a..7ee5eb987 100644 +index e1398652a0..7ee5eb987a 100644 --- a/src/main/java/net/minecraft/server/EntityInsentient.java +++ b/src/main/java/net/minecraft/server/EntityInsentient.java @@ -144,6 +144,7 @@ public abstract class EntityInsentient extends EntityLiving { @@ -304,7 +2093,7 @@ index e1398652a..7ee5eb987 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 3b1bcf349..1f350e335 100644 +index 3b1bcf3495..1f350e3352 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 { @@ -316,7 +2105,7 @@ index 3b1bcf349..1f350e335 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 00c3b666d..e5322fbae 100644 +index 00c3b666d7..e5322fbae5 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; @@ -327,8 +2116,30 @@ index 00c3b666d..e5322fbae 100644 protected EntityMonster(EntityTypes entitytypes, World world) { 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 +--- 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 { + public Integer clientViewDistance; + // CraftBukkit end + ++ public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet cachedSingleHashSet; // Paper ++ + public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) { + super((World) worldserver, gameprofile); + playerinteractmanager.player = this; +@@ -98,6 +100,8 @@ public class EntityPlayer extends EntityHuman implements ICrafting { + this.H = 1.0F; + this.a(worldserver); + ++ this.cachedSingleHashSet = new com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<>(this); // Paper ++ + // CraftBukkit start + 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 f937b7294..cbf0c2f25 100644 +index f937b72945..cbf0c2f25d 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; @@ -351,7 +2162,7 @@ index f937b7294..cbf0c2f25 100644 } diff --git a/src/main/java/net/minecraft/server/IAsyncTaskHandler.java b/src/main/java/net/minecraft/server/IAsyncTaskHandler.java -index 1890c760f..7e5ece9d5 100644 +index 1890c760f9..7e5ece9d50 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 ba315131e..cbe2aa4c0 100644 +index ba315131e1..cbe2aa4c0a 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; @@ -425,7 +2236,7 @@ index ba315131e..cbe2aa4c0 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 b5d45b43c..766b1fe13 100644 +index b5d45b43ce..766b1fe13c 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; @@ -485,10 +2296,10 @@ index b5d45b43c..766b1fe13 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 000000000..628b73a12 +index 0000000000..9fa88d79d8 --- /dev/null +++ b/src/main/java/net/minecraft/server/MCUtil.java -@@ -0,0 +1,316 @@ +@@ -0,0 +1,386 @@ +package net.minecraft.server; + +import com.destroystokyo.paper.block.TargetBlockInfo; @@ -513,6 +2324,76 @@ index 000000000..628b73a12 +public final class MCUtil { + private static final Executor asyncExecutor = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat("Paper Async Task Handler Thread - %1$d").build()); + ++ public static final long INVALID_CHUNK_KEY = getCoordinateKey(Integer.MAX_VALUE, Integer.MAX_VALUE); ++ ++ public static long getCoordinateKey(final BlockPosition blockPos) { ++ return getCoordinateKey(blockPos.getX() >> 4, blockPos.getZ() >> 4); ++ } ++ ++ public static long getCoordinateKey(final Entity entity) { ++ return getCoordinateKey(getChunkCoordinate(entity.locX()), getChunkCoordinate(entity.locZ())); ++ } ++ ++ public static int fastFloor(double x) { ++ int truncated = (int)x; ++ return x < (double)truncated ? truncated - 1 : truncated; ++ } ++ ++ public static int fastFloor(float x) { ++ int truncated = (int)x; ++ return x < (double)truncated ? truncated - 1 : truncated; ++ } ++ ++ public static long getCoordinateKey(final ChunkCoordIntPair pair) { ++ return getCoordinateKey(pair.x, pair.z); ++ } ++ ++ public static long getCoordinateKey(final int x, final int z) { ++ return ((long)z << 32) | (x & 0xFFFFFFFFL); ++ } ++ ++ public static int getCoordinateX(final long key) { ++ return (int)key; ++ } ++ ++ public static int getCoordinateZ(final long key) { ++ return (int)(key >>> 32); ++ } ++ ++ public static int getChunkCoordinate(final double coordinate) { ++ return MCUtil.fastFloor(coordinate) >> 4; ++ } ++ ++ public static int getBlockCoordinate(final double coordinate) { ++ return MCUtil.fastFloor(coordinate); ++ } ++ ++ public static long getBlockKey(final int x, final int y, final int z) { ++ return ((long)x & 0x7FFFFFF) | (((long)z & 0x7FFFFFF) << 27) | ((long)y << 54); ++ } ++ ++ public static long getBlockKey(final BlockPosition pos) { ++ return getBlockKey(pos.getX(), pos.getY(), pos.getZ()); ++ } ++ ++ public static long getBlockKey(final Entity entity) { ++ return getBlockKey(getBlockCoordinate(entity.locX()), getBlockCoordinate(entity.locY()), getBlockCoordinate(entity.locZ())); ++ } ++ ++ // assumes the sets have the same comparator, and if this comparator is null then assume T is Comparable ++ public static void mergeSortedSets(final java.util.function.Consumer consumer, final java.util.SortedSet...sets) { ++ java.util.Comparator comparator = sets[0].comparator(); ++ if (comparator == null) { ++ comparator = (java.util.Comparator)java.util.Comparator.naturalOrder(); ++ } ++ final it.unimi.dsi.fastutil.objects.ObjectRBTreeSet all = new it.unimi.dsi.fastutil.objects.ObjectRBTreeSet<>(comparator); ++ // note: this is done in log(n!) ~ nlogn time. It could be improved if it were to mimic what mergesort does. ++ for (java.util.SortedSet set : sets) { ++ all.addAll(all); ++ } ++ all.forEach(consumer); ++ } ++ + private MCUtil() {} + + @@ -806,7 +2687,7 @@ index 000000000..628b73a12 + } +} diff --git a/src/main/java/net/minecraft/server/NBTTagCompound.java b/src/main/java/net/minecraft/server/NBTTagCompound.java -index e85b24a32..75604dbc6 100644 +index e85b24a327..75604dbc69 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 { @@ -835,7 +2716,7 @@ index e85b24a32..75604dbc6 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 6700582e3..3ccf16636 100644 +index 6700582e36..3ccf166366 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> { @@ -867,7 +2748,7 @@ index 6700582e3..3ccf16636 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 81b6f4581..d9574a9ac 100644 +index 81b6f4581f..d9574a9ace 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 { @@ -879,7 +2760,7 @@ index 81b6f4581..d9574a9ac 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 90223deae..63c4dbd32 100644 +index 90223deae3..63c4dbd327 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> { @@ -891,7 +2772,7 @@ index 90223deae..63c4dbd32 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 677e3e5f6..3a1d0deb0 100644 +index 677e3e5f68..3a1d0deb0d 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 { @@ -912,10 +2793,80 @@ index 677e3e5f6..3a1d0deb0 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 775359146..3c6fe0596 100644 +index 775359146f..3093154bb7 100644 --- a/src/main/java/net/minecraft/server/PlayerChunk.java +++ b/src/main/java/net/minecraft/server/PlayerChunk.java -@@ -63,6 +63,14 @@ public class PlayerChunk { +@@ -19,9 +19,9 @@ public class PlayerChunk { + private static final List CHUNK_STATUSES = ChunkStatus.a(); + private static final PlayerChunk.State[] CHUNK_STATES = PlayerChunk.State.values(); + private final AtomicReferenceArray>> statusFutures; +- private volatile CompletableFuture> fullChunkFuture; +- private volatile CompletableFuture> tickingFuture; +- private volatile CompletableFuture> entityTickingFuture; ++ private volatile CompletableFuture> fullChunkFuture; private int fullChunkCreateCount; private volatile boolean isFullChunkReady; // Paper - cache chunk ticking stage ++ private volatile CompletableFuture> tickingFuture; private volatile boolean isTickingReady; // Paper - cache chunk ticking stage ++ private volatile CompletableFuture> entityTickingFuture; private volatile boolean isEntityTickingReady; // Paper - cache chunk ticking stage + private CompletableFuture chunkSave; + public int oldTicketLevel; + private int ticketLevel; +@@ -38,6 +38,8 @@ public class PlayerChunk { + public final PlayerChunk.d players; + private boolean hasBeenLoaded; + ++ private final PlayerChunkMap chunkMap; // Paper ++ + public PlayerChunk(ChunkCoordIntPair chunkcoordintpair, int i, LightEngine lightengine, PlayerChunk.c playerchunk_c, PlayerChunk.d playerchunk_d) { + this.statusFutures = new AtomicReferenceArray(PlayerChunk.CHUNK_STATUSES.size()); + this.fullChunkFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE; +@@ -53,8 +55,47 @@ public class PlayerChunk { + this.ticketLevel = this.oldTicketLevel; + this.n = this.oldTicketLevel; + this.a(i); ++ this.chunkMap = (PlayerChunkMap)playerchunk_d; // Paper ++ } ++ ++ // Paper start ++ @Nullable ++ public final Chunk getEntityTickingChunk() { ++ CompletableFuture> completablefuture = this.entityTickingFuture; ++ Either either = completablefuture.getNow(null); ++ ++ return either == null ? null : either.left().orElse(null); ++ } ++ ++ @Nullable ++ public final Chunk getTickingChunk() { ++ CompletableFuture> completablefuture = this.tickingFuture; ++ Either either = completablefuture.getNow(null); ++ ++ return either == null ? null : either.left().orElse(null); ++ } ++ ++ @Nullable ++ public final Chunk getFullReadyChunk() { ++ CompletableFuture> completablefuture = this.fullChunkFuture; ++ Either either = completablefuture.getNow(null); ++ ++ return either == null ? null : either.left().orElse(null); ++ } ++ ++ public final boolean isEntityTickingReady() { ++ return this.isEntityTickingReady; + } + ++ public final boolean isTickingReady() { ++ return this.isTickingReady; ++ } ++ ++ public final boolean isFullChunkReady() { ++ return this.isFullChunkReady; ++ } ++ // Paper end ++ + // CraftBukkit start + public Chunk getFullChunk() { + if (!getChunkState(this.oldTicketLevel).isAtLeast(PlayerChunk.State.BORDER)) return null; // note: using oldTicketLevel for isLoaded checks +@@ -63,6 +104,14 @@ public class PlayerChunk { return either == null ? null : (Chunk) either.left().orElse(null); } // CraftBukkit end @@ -930,8 +2881,140 @@ index 775359146..3c6fe0596 100644 public CompletableFuture> getStatusFutureUnchecked(ChunkStatus chunkstatus) { CompletableFuture> completablefuture = (CompletableFuture) this.statusFutures.get(chunkstatus.c()); +@@ -329,13 +378,27 @@ public class PlayerChunk { + + this.hasBeenLoaded |= flag3; + if (!flag2 && flag3) { +- this.fullChunkFuture = playerchunkmap.b(this); ++ // Paper start - cache ticking ready status ++ int expectCreateCount = ++this.fullChunkCreateCount; ++ this.fullChunkFuture = playerchunkmap.b(this); this.fullChunkFuture.thenAccept((either) -> { ++ if (either.left().isPresent() && PlayerChunk.this.fullChunkCreateCount == expectCreateCount) { ++ // note: Here is a very good place to add callbacks to logic waiting on this. ++ Chunk fullChunk = either.left().get(); ++ PlayerChunk.this.isFullChunkReady = true; ++ fullChunk.playerChunk = PlayerChunk.this; ++ ++ ++ } ++ }); ++ // Paper end + this.a(this.fullChunkFuture); + } + + if (flag2 && !flag3) { + completablefuture = this.fullChunkFuture; + this.fullChunkFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE; ++ ++this.fullChunkCreateCount; // Paper - cache ticking ready status ++ this.isFullChunkReady = false; // Paper - cache ticking ready status + this.a(((CompletableFuture>) completablefuture).thenApply((either1) -> { // CraftBukkit - decompile error + playerchunkmap.getClass(); + return either1.ifLeft(playerchunkmap::a); +@@ -346,12 +409,24 @@ public class PlayerChunk { + boolean flag5 = playerchunk_state1.isAtLeast(PlayerChunk.State.TICKING); + + if (!flag4 && flag5) { +- this.tickingFuture = playerchunkmap.a(this); ++ // Paper start - cache ticking ready status ++ this.tickingFuture = playerchunkmap.a(this); this.tickingFuture.thenAccept((either) -> { ++ if (either.left().isPresent()) { ++ // note: Here is a very good place to add callbacks to logic waiting on this. ++ Chunk tickingChunk = either.left().get(); ++ PlayerChunk.this.isTickingReady = true; ++ ++ ++ ++ ++ } ++ }); ++ // Paper end + this.a(this.tickingFuture); + } + + if (flag4 && !flag5) { +- this.tickingFuture.complete(PlayerChunk.UNLOADED_CHUNK); ++ this.tickingFuture.complete(PlayerChunk.UNLOADED_CHUNK); this.isTickingReady = false; // Paper - cache chunk ticking stage + this.tickingFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE; + } + +@@ -363,12 +438,24 @@ public class PlayerChunk { + throw (IllegalStateException) SystemUtils.c(new IllegalStateException()); + } + +- this.entityTickingFuture = playerchunkmap.b(this.location); ++ // Paper start - cache ticking ready status ++ this.entityTickingFuture = playerchunkmap.b(this.location); this.entityTickingFuture.thenAccept((either) -> { ++ if (either.left().isPresent()) { ++ // note: Here is a very good place to add callbacks to logic waiting on this. ++ Chunk entityTickingChunk = either.left().get(); ++ PlayerChunk.this.isEntityTickingReady = true; ++ ++ ++ ++ ++ } ++ }); ++ // Paper end + this.a(this.entityTickingFuture); + } + + if (flag6 && !flag7) { +- this.entityTickingFuture.complete(PlayerChunk.UNLOADED_CHUNK); ++ this.entityTickingFuture.complete(PlayerChunk.UNLOADED_CHUNK); this.isEntityTickingReady = false; // Paper - cache chunk ticking stage + this.entityTickingFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE; + } + +diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java +index b5a3b10012..e248893717 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 { + }; + // CraftBukkit end + ++ // Paper start - distance maps ++ private final com.destroystokyo.paper.util.misc.PooledLinkedHashSets pooledLinkedPlayerHashSets = new com.destroystokyo.paper.util.misc.PooledLinkedHashSets<>(); ++ ++ void addPlayerToDistanceMaps(EntityPlayer player) { ++ this.updateMaps(player); ++ ++ ++ ++ } ++ ++ void removePlayerFromDistanceMaps(EntityPlayer player) { ++ ++ ++ ++ ++ } ++ ++ void updateMaps(EntityPlayer player) { ++ int chunkX = MCUtil.getChunkCoordinate(player.locX()); ++ int chunkZ = MCUtil.getChunkCoordinate(player.locZ()); ++ ++ ++ ++ ++ } ++ ++ ++ // Paper end ++ + public PlayerChunkMap(WorldServer worldserver, File file, DataFixer datafixer, DefinedStructureManager definedstructuremanager, Executor executor, IAsyncTaskHandler iasynctaskhandler, ILightAccess ilightaccess, ChunkGenerator chunkgenerator, WorldLoadListener worldloadlistener, Supplier supplier, int i) { + super(new File(worldserver.getWorldProvider().getDimensionManager().a(file), "region"), datafixer); + this.visibleChunks = this.updatingChunks.clone(); +@@ -984,6 +1013,8 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { + } + } + ++ this.updateMaps(entityplayer); // Paper - distance maps ++ + } + + @Override diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java -index ba0293512..b257e1c4e 100644 +index ba02935128..b257e1c4e9 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 { @@ -948,7 +3031,7 @@ index ba0293512..b257e1c4e 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 08768a3c8..d103cfaac 100644 +index 08768a3c87..d103cfaace 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 { @@ -961,7 +3044,7 @@ index 08768a3c8..d103cfaac 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 b3824898d..bf4172be5 100644 +index b3824898da..bf4172be52 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 { @@ -973,7 +3056,7 @@ index b3824898d..bf4172be5 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 6e65306a2..39339fa27 100644 +index 6e65306a27..39339fa275 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 { @@ -996,7 +3079,7 @@ index 6e65306a2..39339fa27 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 7b6e0e86b..187c4e0f5 100644 +index 7b6e0e86b0..187c4e0f58 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 { @@ -1008,7 +3091,7 @@ index 7b6e0e86b..187c4e0f5 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 8c123f265..9d0e8c2d4 100644 +index 8c123f265e..9d0e8c2d43 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 { @@ -1039,7 +3122,7 @@ index 8c123f265..9d0e8c2d4 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 4efcb8b59..60948afa4 100644 +index 4efcb8b595..60948afa4e 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 { @@ -1051,7 +3134,7 @@ index 4efcb8b59..60948afa4 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 7b92ecfff..7e224ebef 100644 +index 7b92ecfff9..7e224ebeff 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 { @@ -1064,7 +3147,7 @@ index 7b92ecfff..7e224ebef 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 692f8e4b7..8fc88f162 100644 +index 692f8e4b71..8fc88f162c 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -196,6 +196,40 @@ public abstract class World implements GeneratorAccess, AutoCloseable { @@ -1120,8 +3203,28 @@ index 692f8e4b7..8fc88f162 100644 Fluid fluid = this.getFluid(blockposition); 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 32f8f2aed5..2aaf679df4 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 { + } + + this.registerEntity(entityplayer); ++ this.getChunkProvider().playerChunkMap.addPlayerToDistanceMaps(entityplayer); // Paper - distance maps + } + + // CraftBukkit start +@@ -1115,6 +1116,7 @@ public class WorldServer extends World { + EntityPlayer entityplayer = (EntityPlayer) entity; + + this.players.remove(entityplayer); ++ this.getChunkProvider().playerChunkMap.removePlayerFromDistanceMaps(entityplayer); // Paper - distance maps + } + + 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 e181df6f4..4a9132c70 100644 +index e181df6f4d..4a9132c701 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 { @@ -1133,7 +3236,7 @@ index e181df6f4..4a9132c70 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 d8358a0f0..d0b813008 100644 +index d8358a0f03..d0b813008c 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 { @@ -1159,6 +3262,19 @@ index d8358a0f0..d0b813008 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 +--- 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; + public class UnsafeList extends AbstractList implements List, RandomAccess, Cloneable, Serializable { + private static final long serialVersionUID = 8683452581112892191L; + +- private transient Object[] data; ++ private transient Object[] data; public final Object[] getRawDataArray() { return this.data; } // Paper - expose for raw get + private int size; + private int initialCapacity; + -- 2.25.0.windows.1 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 0382f9816..3668a3f48 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 7f6a88f275bf307644ba5a8a0507c1eee3507d37 Mon Sep 17 00:00:00 2001 +From 0fb24c3112ee195e65b308f168e3bca44fa4edab 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 cfffbd031..125d3acdc 100644 +index a263f60d49..8627365923 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 cfffbd031..125d3acdc 100644 this.l = Maps.newHashMap(); this.m = Maps.newHashMap(); this.n = new ShortList[16]; -@@ -361,6 +386,7 @@ public class Chunk implements IChunkAccess { +@@ -366,6 +391,7 @@ public class Chunk implements IChunkAccess { } entity.inChunk = true; @@ -66,7 +66,7 @@ index cfffbd031..125d3acdc 100644 entity.chunkX = this.loc.x; entity.chunkY = k; entity.chunkZ = this.loc.z; -@@ -372,6 +398,7 @@ public class Chunk implements IChunkAccess { +@@ -378,6 +404,7 @@ public class Chunk implements IChunkAccess { ((HeightMap) this.heightMap.get(heightmap_type)).a(along); } @@ -74,7 +74,7 @@ index cfffbd031..125d3acdc 100644 public void b(Entity entity) { this.a(entity, entity.chunkY); } -@@ -384,8 +411,12 @@ public class Chunk implements IChunkAccess { +@@ -390,8 +417,12 @@ public class Chunk implements IChunkAccess { if (i >= this.entitySlices.length) { i = this.entitySlices.length - 1; } @@ -90,7 +90,7 @@ index cfffbd031..125d3acdc 100644 @Override diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index a8ea70b36..3a969d92e 100644 +index a8ea70b36b..3a969d92e0 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 @@ -143,7 +143,7 @@ index a8ea70b36..3a969d92e 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 9071bb7ec..820180ab3 100644 +index 9071bb7ece..820180ab3f 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 @@ -163,7 +163,7 @@ index 9071bb7ec..820180ab3 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 63ecbcd47..c82c21326 100644 +index 63ecbcd47a..c82c213260 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; 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 687531918..0df50f2d1 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 50eee3a1fb88960217779354b20dd20daae7c7b6 Mon Sep 17 00:00:00 2001 +From 109173e7396da82ee8dcef2df5036d1dda99b0f2 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 125d3acdc..dcaf3a509 100644 +index 8627365923..4110b6fa39 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 125d3acdc..dcaf3a509 100644 } return removed; } -@@ -385,6 +390,7 @@ public class Chunk implements IChunkAccess { +@@ -390,6 +395,7 @@ public class Chunk implements IChunkAccess { k = this.entitySlices.length - 1; } @@ -45,7 +45,7 @@ index 125d3acdc..dcaf3a509 100644 entity.inChunk = true; entity.setCurrentChunk(this); // Paper entity.chunkX = this.loc.x; -@@ -416,6 +422,7 @@ public class Chunk implements IChunkAccess { +@@ -422,6 +428,7 @@ public class Chunk implements IChunkAccess { if (!this.entitySlices[i].remove(entity)) { return; } diff --git a/Spigot-Server-Patches/0009-Timings-v2.patch b/Spigot-Server-Patches/0009-Timings-v2.patch index 325df1567..269c81a25 100644 --- a/Spigot-Server-Patches/0009-Timings-v2.patch +++ b/Spigot-Server-Patches/0009-Timings-v2.patch @@ -1,4 +1,4 @@ -From ce5ca10c801e990f0f814a775ff9f8d35b82bb1b Mon Sep 17 00:00:00 2001 +From 0bc5c16d73d2e593416aef85336d9d001a29c0e7 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 000000000..69e26a826 +index 0000000000..69e26a8267 --- /dev/null +++ b/src/main/java/co/aikar/timings/MinecraftTimings.java @@ -0,0 +1,141 @@ @@ -153,7 +153,7 @@ index 000000000..69e26a826 +} 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 000000000..3a79cde59 +index 0000000000..3a79cde595 --- /dev/null +++ b/src/main/java/co/aikar/timings/WorldTimingsHandler.java @@ -0,0 +1,130 @@ @@ -288,7 +288,7 @@ index 000000000..3a79cde59 + } +} diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java -index b6d470e59..f402a29b0 100644 +index b6d470e594..f402a29b09 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; @@ -335,7 +335,7 @@ index b6d470e59..f402a29b0 100644 + } } diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java -index cd72a9c84..5de881371 100644 +index cd72a9c845..5de881371a 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 { @@ -355,10 +355,10 @@ index cd72a9c84..5de881371 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 dcaf3a509..5f9031257 100644 +index 4110b6fa39..2ebbcc6958 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java -@@ -567,6 +567,7 @@ public class Chunk implements IChunkAccess { +@@ -574,6 +574,7 @@ public class Chunk implements IChunkAccess { server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(this.bukkitChunk, this.needsDecoration)); if (this.needsDecoration) { @@ -366,7 +366,7 @@ index dcaf3a509..5f9031257 100644 this.needsDecoration = false; java.util.Random random = new java.util.Random(); random.setSeed(world.getSeed()); -@@ -586,6 +587,7 @@ public class Chunk implements IChunkAccess { +@@ -593,6 +594,7 @@ public class Chunk implements IChunkAccess { } } server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkPopulateEvent(bukkitChunk)); @@ -375,10 +375,10 @@ index dcaf3a509..5f9031257 100644 } } diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java -index 9cd21b1ff..99afce39a 100644 +index d24c8070f4..1ba34cfaa9 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java -@@ -133,11 +133,13 @@ public class ChunkProviderServer extends IChunkProvider { +@@ -229,11 +229,13 @@ public class ChunkProviderServer extends IChunkProvider { } gameprofilerfiller.c("getChunkCacheMiss"); @@ -394,7 +394,7 @@ index 9cd21b1ff..99afce39a 100644 ichunkaccess = (IChunkAccess) ((Either) completablefuture.join()).map((ichunkaccess1) -> { return ichunkaccess1; }, (playerchunk_failure) -> { -@@ -330,7 +332,9 @@ public class ChunkProviderServer extends IChunkProvider { +@@ -426,7 +428,9 @@ public class ChunkProviderServer extends IChunkProvider { public void save(boolean flag) { this.tickDistanceManager(); @@ -404,7 +404,7 @@ index 9cd21b1ff..99afce39a 100644 } @Override -@@ -367,7 +371,9 @@ public class ChunkProviderServer extends IChunkProvider { +@@ -463,7 +467,9 @@ public class ChunkProviderServer extends IChunkProvider { this.tickDistanceManager(); this.world.timings.doChunkMap.stopTiming(); // Spigot this.world.getMethodProfiler().exitEnter("chunks"); @@ -414,7 +414,7 @@ index 9cd21b1ff..99afce39a 100644 this.world.timings.doChunkUnload.startTiming(); // Spigot this.world.getMethodProfiler().exitEnter("unload"); this.playerChunkMap.unloadChunks(booleansupplier); -@@ -392,10 +398,12 @@ public class ChunkProviderServer extends IChunkProvider { +@@ -488,10 +494,12 @@ public class ChunkProviderServer extends IChunkProvider { boolean flag2 = world.ticksPerAnimalSpawns != 0L && worlddata.getTime() % world.ticksPerAnimalSpawns == 0L; // CraftBukkit // PAIL: TODO monster ticks this.world.getMethodProfiler().enter("naturalSpawnCount"); @@ -427,7 +427,7 @@ index 9cd21b1ff..99afce39a 100644 this.world.getMethodProfiler().exit(); this.playerChunkMap.f().forEach((playerchunk) -> { Optional optional = ((Either) playerchunk.b().getNow(PlayerChunk.UNLOADED_CHUNK)).left(); -@@ -404,13 +412,27 @@ public class ChunkProviderServer extends IChunkProvider { +@@ -500,13 +508,27 @@ public class ChunkProviderServer extends IChunkProvider { Chunk chunk = (Chunk) optional.get(); this.world.getMethodProfiler().enter("broadcast"); @@ -457,7 +457,7 @@ index 9cd21b1ff..99afce39a 100644 this.world.getMethodProfiler().enter("spawner"); this.world.timings.mobSpawn.startTiming(); // Spigot EnumCreatureType[] aenumcreaturetype1 = aenumcreaturetype; -@@ -454,24 +476,24 @@ public class ChunkProviderServer extends IChunkProvider { +@@ -550,24 +572,24 @@ public class ChunkProviderServer extends IChunkProvider { this.world.getMethodProfiler().exit(); } @@ -487,7 +487,7 @@ index 9cd21b1ff..99afce39a 100644 @Override diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java -index e16d30f2c..4af5a230b 100644 +index e16d30f2ca..4af5a230ba 100644 --- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java +++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java @@ -1,5 +1,6 @@ @@ -525,7 +525,7 @@ index e16d30f2c..4af5a230b 100644 } diff --git a/src/main/java/net/minecraft/server/CustomFunction.java b/src/main/java/net/minecraft/server/CustomFunction.java -index 8d7a6d240..707bd2600 100644 +index 8d7a6d2403..707bd2600d 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 { @@ -552,7 +552,7 @@ index 8d7a6d240..707bd2600 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 ba40d5fbb..ee42e1dfa 100644 +index ba40d5fbb5..ee42e1dfa4 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 { @@ -565,7 +565,7 @@ index ba40d5fbb..ee42e1dfa 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 1cde6fc9c..e636433b1 100644 +index 1cde6fc9c1..e636433b11 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; @@ -653,7 +653,7 @@ index 1cde6fc9c..e636433b1 100644 } diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 3a969d92e..2d8c37d73 100644 +index 3a969d92e0..2d8c37d73b 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; @@ -692,7 +692,7 @@ index 3a969d92e..2d8c37d73 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 1f350e335..35e3f1c78 100644 +index 1f350e3352..35e3f1c78d 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; @@ -768,7 +768,7 @@ index 1f350e335..35e3f1c78 100644 } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index b4a0bd795..4dc691775 100644 +index b4a0bd7951..4dc6917759 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; @@ -944,7 +944,7 @@ index b4a0bd795..4dc691775 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 b5a3b1001..dcfb37004 100644 +index e248893717..1f289047fa 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java @@ -1,7 +1,9 @@ @@ -957,7 +957,7 @@ index b5a3b1001..dcfb37004 100644 import com.google.common.collect.Lists; import com.google.common.collect.Queues; import com.google.common.collect.Sets; -@@ -477,9 +479,12 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -506,9 +508,12 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { private CompletableFuture> f(ChunkCoordIntPair chunkcoordintpair) { return CompletableFuture.supplyAsync(() -> { @@ -972,7 +972,7 @@ index b5a3b1001..dcfb37004 100644 if (nbttagcompound != null) { boolean flag = nbttagcompound.hasKeyOfType("Level", 10) && nbttagcompound.getCompound("Level").hasKeyOfType("Status", 8); -@@ -519,7 +524,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -548,7 +553,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { return "chunkGenerate " + chunkstatus.d(); }); return completablefuture.thenComposeAsync((either) -> { @@ -981,7 +981,7 @@ index b5a3b1001..dcfb37004 100644 try { CompletableFuture> completablefuture1 = chunkstatus.a(this.world, this.chunkGenerator, this.definedStructureManager, this.lightEngine, (ichunkaccess) -> { return this.c(playerchunk); -@@ -572,6 +577,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -601,6 +606,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { ChunkStatus chunkstatus = PlayerChunk.getChunkStatus(playerchunk.getTicketLevel()); return !chunkstatus.b(ChunkStatus.FULL) ? PlayerChunk.UNLOADED_CHUNK_ACCESS : either.mapLeft((ichunkaccess) -> { @@ -989,7 +989,7 @@ index b5a3b1001..dcfb37004 100644 ChunkCoordIntPair chunkcoordintpair = playerchunk.i(); Chunk chunk; -@@ -623,6 +629,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -652,6 +658,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { } return chunk; @@ -997,7 +997,7 @@ index b5a3b1001..dcfb37004 100644 }); }, (runnable) -> { Mailbox mailbox = this.mailboxMain; -@@ -1060,6 +1067,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -1091,6 +1098,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { PlayerChunkMap.EntityTracker playerchunkmap_entitytracker; ObjectIterator objectiterator; @@ -1005,7 +1005,7 @@ index b5a3b1001..dcfb37004 100644 for (objectiterator = this.trackedEntities.values().iterator(); objectiterator.hasNext(); playerchunkmap_entitytracker.trackerEntry.a()) { playerchunkmap_entitytracker = (PlayerChunkMap.EntityTracker) objectiterator.next(); -@@ -1077,16 +1085,20 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -1108,16 +1116,20 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { playerchunkmap_entitytracker.e = sectionposition1; } } @@ -1027,7 +1027,7 @@ index b5a3b1001..dcfb37004 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 b257e1c4e..b7beb058d 100644 +index b257e1c4e9..b7beb058d8 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; @@ -1082,7 +1082,7 @@ index b257e1c4e..b7beb058d 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 2c671629a..eb3269e0e 100644 +index 2c671629a4..eb3269e0ea 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; @@ -1109,7 +1109,7 @@ index 2c671629a..eb3269e0e 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 0694f4563..1652a57e2 100644 +index 0694f4563e..1652a57e25 100644 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -1,5 +1,6 @@ @@ -1133,7 +1133,7 @@ index 0694f4563..1652a57e2 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 00bbd34b6..f533860bb 100644 +index 00bbd34b6a..f533860bbe 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 { @@ -1183,7 +1183,7 @@ index 00bbd34b6..f533860bb 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 820180ab3..fa6400dcc 100644 +index 820180ab3f..fa6400dccd 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; @@ -1202,7 +1202,7 @@ index 820180ab3..fa6400dcc 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 8fc88f162..0087bd9b1 100644 +index 8fc88f162c..0087bd9b1c 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -1,5 +1,7 @@ @@ -1257,7 +1257,7 @@ index 8fc88f162..0087bd9b1 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 32f8f2aed..bc1ff7d56 100644 +index 2aaf679df4..ebc252a610 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -1,6 +1,8 @@ @@ -1382,7 +1382,7 @@ index 32f8f2aed..bc1ff7d56 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 57ad50403..038928789 100644 +index 57ad50403b..038928789b 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -1935,12 +1935,31 @@ public final class CraftServer implements Server { @@ -1419,7 +1419,7 @@ index 57ad50403..038928789 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 2bd22a369..000000000 +index 2bd22a3698..0000000000 --- a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java +++ /dev/null @@ -1,162 +0,0 @@ @@ -1586,7 +1586,7 @@ index 2bd22a369..000000000 - } -} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 9eba8449e..1094190fd 100644 +index 9eba8449e4..1094190fd9 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -1753,6 +1753,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -1605,7 +1605,7 @@ index 9eba8449e..1094190fd 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 b90979c7b..8823f94f7 100644 +index b90979c7ba..8823f94f7b 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 @@ @@ -1671,7 +1671,7 @@ index b90979c7b..8823f94f7 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 3f55381c1..0d9a46680 100644 +index 3f55381c15..0d9a466809 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 @@ @@ -1756,7 +1756,7 @@ index 3f55381c1..0d9a46680 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 e52ef47b7..3d90b3426 100644 +index e52ef47b78..3d90b34268 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; @@ -1768,7 +1768,7 @@ index e52ef47b7..3d90b3426 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 afe4004ff..1c719ec0e 100644 +index afe4004ff2..1c719ec0e3 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -290,6 +290,13 @@ public final class CraftMagicNumbers implements UnsafeValues { @@ -1786,7 +1786,7 @@ index afe4004ff..1c719ec0e 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 ca7789b5e..442383969 100644 +index ca7789b5e0..4423839697 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; @@ -1847,5 +1847,5 @@ index ca7789b5e..442383969 100644 } } -- -2.25.0 +2.25.0.windows.1 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 43cb7cf64..fffdae255 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 25bc4ba2c424139f3a547e135bf830164fd857b6 Mon Sep 17 00:00:00 2001 +From e9d2579100a78a8de64e2942babd0acee0965be5 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 5f9031257..f62429277 100644 +index 2ebbcc6958..e7268074b4 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java -@@ -500,6 +500,10 @@ public class Chunk implements IChunkAccess { +@@ -506,6 +506,10 @@ public class Chunk implements IChunkAccess { } // CraftBukkit start diff --git a/Spigot-Server-Patches/0025-Entity-Origin-API.patch b/Spigot-Server-Patches/0025-Entity-Origin-API.patch index 1f8a3474c..3a5e2c3e8 100644 --- a/Spigot-Server-Patches/0025-Entity-Origin-API.patch +++ b/Spigot-Server-Patches/0025-Entity-Origin-API.patch @@ -1,11 +1,11 @@ -From f394d66b388a13b0538381f70c637c2154cf5bdb Mon Sep 17 00:00:00 2001 +From 41d5a5951d57736867404618442e8cb8a3b69520 Mon Sep 17 00:00:00 2001 From: Byteflux Date: Tue, 1 Mar 2016 23:45:08 -0600 Subject: [PATCH] Entity Origin API diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 706bab8a1..ecf9f9f76 100644 +index 706bab8a1d..ecf9f9f764 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -167,6 +167,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke @@ -51,7 +51,7 @@ index 706bab8a1..ecf9f9f76 100644 NBTTagList nbttaglist = new NBTTagList(); double[] adouble1 = adouble; diff --git a/src/main/java/net/minecraft/server/EntityFallingBlock.java b/src/main/java/net/minecraft/server/EntityFallingBlock.java -index cb21ce0b1..40fd012ae 100644 +index cb21ce0b1a..40fd012ae2 100644 --- a/src/main/java/net/minecraft/server/EntityFallingBlock.java +++ b/src/main/java/net/minecraft/server/EntityFallingBlock.java @@ -253,6 +253,14 @@ public class EntityFallingBlock extends Entity { @@ -70,7 +70,7 @@ index cb21ce0b1..40fd012ae 100644 public void a(boolean flag) { diff --git a/src/main/java/net/minecraft/server/EntityTNTPrimed.java b/src/main/java/net/minecraft/server/EntityTNTPrimed.java -index 33c51dced..346315acb 100644 +index 33c51dced7..346315acb7 100644 --- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java +++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java @@ -103,6 +103,14 @@ public class EntityTNTPrimed extends Entity { @@ -89,7 +89,7 @@ index 33c51dced..346315acb 100644 @Nullable diff --git a/src/main/java/net/minecraft/server/NBTTagList.java b/src/main/java/net/minecraft/server/NBTTagList.java -index 5406f4c40..d778eac45 100644 +index 5406f4c40f..d778eac45d 100644 --- a/src/main/java/net/minecraft/server/NBTTagList.java +++ b/src/main/java/net/minecraft/server/NBTTagList.java @@ -188,6 +188,7 @@ public class NBTTagList extends NBTList { @@ -101,10 +101,10 @@ index 5406f4c40..d778eac45 100644 if (i >= 0 && i < this.list.size()) { NBTBase nbtbase = (NBTBase) this.list.get(i); diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index bc1ff7d56..948438829 100644 +index ebc252a610..6f07065eb4 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java -@@ -1174,6 +1174,11 @@ public class WorldServer extends World { +@@ -1176,6 +1176,11 @@ public class WorldServer extends World { this.navigators.add(((EntityInsentient) entity).getNavigation()); } entity.valid = true; // CraftBukkit @@ -117,7 +117,7 @@ index bc1ff7d56..948438829 100644 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -index c82c21326..a29693674 100644 +index c82c213260..a296936748 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -1007,4 +1007,12 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { diff --git a/Spigot-Server-Patches/0030-Configurable-end-credits.patch b/Spigot-Server-Patches/0030-Configurable-end-credits.patch index fb9bb1642..144b69ca1 100644 --- a/Spigot-Server-Patches/0030-Configurable-end-credits.patch +++ b/Spigot-Server-Patches/0030-Configurable-end-credits.patch @@ -1,11 +1,11 @@ -From 8effbabd66a3a27d839b6ef5ea2a3d3d971354d4 Mon Sep 17 00:00:00 2001 +From c084ec91efac4a1c1d5721f399bd0647a1151d9c Mon Sep 17 00:00:00 2001 From: DoctorDark Date: Wed, 16 Mar 2016 02:21:39 -0500 Subject: [PATCH] Configurable end credits diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index f7a0a33e4..50dec5cb5 100644 +index f7a0a33e49..50dec5cb5e 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -144,4 +144,10 @@ public class PaperWorldConfig { @@ -20,7 +20,7 @@ index f7a0a33e4..50dec5cb5 100644 + } } diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index ce4821092..bc0a1585d 100644 +index 57ce9bde64..23c1706874 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -60,7 +60,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { @@ -32,7 +32,7 @@ index ce4821092..bc0a1585d 100644 private final RecipeBookServer recipeBook; private Vec3D co; private int cp; -@@ -691,6 +691,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { +@@ -695,6 +695,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { this.getWorldServer().removePlayer(this); if (!this.viewingCredits) { this.viewingCredits = true; diff --git a/Spigot-Server-Patches/0037-Send-absolute-position-the-first-time-an-entity-is-s.patch b/Spigot-Server-Patches/0037-Send-absolute-position-the-first-time-an-entity-is-s.patch index 814fa8d5b..d47f45b97 100644 --- a/Spigot-Server-Patches/0037-Send-absolute-position-the-first-time-an-entity-is-s.patch +++ b/Spigot-Server-Patches/0037-Send-absolute-position-the-first-time-an-entity-is-s.patch @@ -1,11 +1,11 @@ -From b4faae88abba8ea23a3d5a3b1f30d1be8e1983f1 Mon Sep 17 00:00:00 2001 +From ceaede64459309b8a6cf12881d861e8ee5a90dff Mon Sep 17 00:00:00 2001 From: Jedediah Smith Date: Wed, 2 Mar 2016 23:13:07 -0600 Subject: [PATCH] Send absolute position the first time an entity is seen diff --git a/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/EntityTrackerEntry.java -index a75e0ec54..a13fd9b34 100644 +index a75e0ec54e..a13fd9b340 100644 --- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java +++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java @@ -2,6 +2,7 @@ package net.minecraft.server; @@ -77,10 +77,10 @@ index a75e0ec54..a13fd9b34 100644 this.c(); diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index dcfb37004..89433004d 100644 +index 1f289047fa..b2260498cb 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java -@@ -1186,10 +1186,14 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -1217,10 +1217,14 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { private final Entity tracker; private final int trackingDistance; private SectionPosition e; @@ -97,7 +97,7 @@ index dcfb37004..89433004d 100644 this.tracker = entity; this.trackingDistance = i; this.e = SectionPosition.a(entity); -@@ -1271,7 +1275,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -1302,7 +1306,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { entityplayer.removeQueue.remove(Integer.valueOf(this.tracker.getId())); // CraftBukkit end diff --git a/Spigot-Server-Patches/0039-Configurable-container-update-tick-rate.patch b/Spigot-Server-Patches/0039-Configurable-container-update-tick-rate.patch index 18747264a..49f10f816 100644 --- a/Spigot-Server-Patches/0039-Configurable-container-update-tick-rate.patch +++ b/Spigot-Server-Patches/0039-Configurable-container-update-tick-rate.patch @@ -1,11 +1,11 @@ -From 276892365068cb1f6cd5535e5975d48caadf6407 Mon Sep 17 00:00:00 2001 +From de587b9b8c013c069adefd8afd0dbbae0bb9f640 Mon Sep 17 00:00:00 2001 From: Sudzzy Date: Wed, 2 Mar 2016 23:34:44 -0600 Subject: [PATCH] Configurable container update tick rate diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 428deed56..a4da22ea6 100644 +index 428deed56d..a4da22ea65 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -176,4 +176,9 @@ public class PaperWorldConfig { @@ -19,7 +19,7 @@ index 428deed56..a4da22ea6 100644 + } } diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index bc0a1585d..f03395e2d 100644 +index 23c1706874..f0f456983f 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -72,6 +72,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { @@ -30,7 +30,7 @@ index bc0a1585d..f03395e2d 100644 // CraftBukkit start public String displayName; -@@ -351,7 +352,12 @@ public class EntityPlayer extends EntityHuman implements ICrafting { +@@ -355,7 +356,12 @@ public class EntityPlayer extends EntityHuman implements ICrafting { --this.noDamageTicks; } diff --git a/Spigot-Server-Patches/0051-Add-configurable-portal-search-radius.patch b/Spigot-Server-Patches/0051-Add-configurable-portal-search-radius.patch index 5a27502e3..976709aab 100644 --- a/Spigot-Server-Patches/0051-Add-configurable-portal-search-radius.patch +++ b/Spigot-Server-Patches/0051-Add-configurable-portal-search-radius.patch @@ -1,11 +1,11 @@ -From 7fd41e3eaf2305ff8ba5253e7ed1d7e5fd53c42e Mon Sep 17 00:00:00 2001 +From 2c35f4f4a2d099ec32ad3a51236f0692b002eb7c Mon Sep 17 00:00:00 2001 From: Joseph Hirschfeld Date: Thu, 3 Mar 2016 02:46:17 -0600 Subject: [PATCH] Add configurable portal search radius diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 62e793b71..cd47a4ca0 100644 +index 62e793b71b..cd47a4ca06 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -191,4 +191,11 @@ public class PaperWorldConfig { @@ -21,7 +21,7 @@ index 62e793b71..cd47a4ca0 100644 + } } diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 1ce080287..be39f38d5 100644 +index 1ce0802879..be39f38d56 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -2574,7 +2574,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke @@ -34,10 +34,10 @@ index 1ce080287..be39f38d5 100644 return null; } diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index f03395e2d..4289aadc6 100644 +index f0f456983f..b5101af011 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java -@@ -751,7 +751,9 @@ public class EntityPlayer extends EntityHuman implements ICrafting { +@@ -755,7 +755,9 @@ public class EntityPlayer extends EntityHuman implements ICrafting { // CraftBukkit start Location enter = this.getBukkitEntity().getLocation(); Location exit = (worldserver1 == null) ? null : new Location(worldserver1.getWorld(), d0, d1, d2, f1, f); @@ -49,7 +49,7 @@ index f03395e2d..4289aadc6 100644 if (event.isCancelled() || event.getTo() == null) { return null; diff --git a/src/main/java/net/minecraft/server/PortalTravelAgent.java b/src/main/java/net/minecraft/server/PortalTravelAgent.java -index 19c54f1dd..f84dd6d9b 100644 +index 19c54f1dde..f84dd6d9be 100644 --- a/src/main/java/net/minecraft/server/PortalTravelAgent.java +++ b/src/main/java/net/minecraft/server/PortalTravelAgent.java @@ -45,7 +45,7 @@ public class PortalTravelAgent { diff --git a/Spigot-Server-Patches/0054-Add-exception-reporting-event.patch b/Spigot-Server-Patches/0054-Add-exception-reporting-event.patch index c575db948..b00d8df33 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 c96259dffb4ead729ef3e2e4055b543ce972333c Mon Sep 17 00:00:00 2001 +From b257a14b9a64d819e39d4128d92c262b38087324 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 000000000..f699ce18c +index 0000000000..f699ce18ca --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/ServerSchedulerReportingWrapper.java @@ -0,0 +1,38 @@ @@ -49,7 +49,7 @@ index 000000000..f699ce18c + } +} diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index f62429277..be32b31e7 100644 +index e7268074b4..6ed23ea6c8 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 f62429277..be32b31e7 100644 import com.google.common.collect.Maps; import com.google.common.collect.Sets; import it.unimi.dsi.fastutil.longs.LongOpenHashSet; -@@ -505,10 +506,15 @@ public class Chunk implements IChunkAccess { +@@ -511,10 +512,15 @@ public class Chunk implements IChunkAccess { this.tileEntities.remove(blockposition); // Paper end } else { @@ -80,7 +80,7 @@ index f62429277..be32b31e7 100644 } } diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java -index 99afce39a..a3ef6dba7 100644 +index 1ba34cfaa9..3ef7e4561f 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 99afce39a..a3ef6dba7 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 c9c2b0025..1422503e1 100644 +index c9c2b00251..1422503e11 100644 --- a/src/main/java/net/minecraft/server/NameReferencingFileConverter.java +++ b/src/main/java/net/minecraft/server/NameReferencingFileConverter.java @@ -1,5 +1,6 @@ @@ -121,10 +121,10 @@ index c9c2b0025..1422503e1 100644 } // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index 89433004d..1627aeeef 100644 +index b2260498cb..c575ff57dd 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java -@@ -698,6 +698,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -727,6 +727,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { this.world.checkSession(); } catch (ExceptionWorldConflict exceptionworldconflict) { PlayerChunkMap.LOGGER.error("Couldn't save chunk; already in use by another instance of Minecraft?", exceptionworldconflict); @@ -132,7 +132,7 @@ index 89433004d..1627aeeef 100644 return false; } -@@ -726,6 +727,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -755,6 +756,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { return true; } catch (Exception exception) { PlayerChunkMap.LOGGER.error("Failed to save chunk {},{}", chunkcoordintpair.x, chunkcoordintpair.z, exception); @@ -141,7 +141,7 @@ index 89433004d..1627aeeef 100644 } } diff --git a/src/main/java/net/minecraft/server/RegionFile.java b/src/main/java/net/minecraft/server/RegionFile.java -index 187c4e0f5..c2312a227 100644 +index 187c4e0f58..c2312a227c 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 187c4e0f5..c2312a227 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 8ba344df6..02157d051 100644 +index 8ba344df64..02157d051f 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 8ba344df6..02157d051 100644 } diff --git a/src/main/java/net/minecraft/server/VillageSiege.java b/src/main/java/net/minecraft/server/VillageSiege.java -index d5e9bae70..1bcf01c09 100644 +index d5e9bae709..1bcf01c09a 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 d5e9bae70..1bcf01c09 100644 } diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index cb369665c..026007891 100644 +index cb369665c4..0260078911 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 cb369665c..026007891 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 19e68a783..a2a25cf6a 100644 +index 19e68a7831..a2a25cf6a4 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 19e68a783..a2a25cf6a 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 8823f94f7..552daf437 100644 +index 8823f94f7b..552daf4376 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; 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 7187abfa5..093cc9382 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 91f5356e6a891791dc57ff093432a4eed0d57d02 Mon Sep 17 00:00:00 2001 +From 36a26b5d1886726fd705a5d5fff6c85f3e568c2a 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 a3b5793e4..71089442c 100644 +index a3b5793e48..71089442c1 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 a3b5793e4..71089442c 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 be32b31e7..fd9ba8232 100644 +index 6ed23ea6c8..7033c6e839 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java -@@ -203,12 +203,24 @@ public class Chunk implements IChunkAccess { +@@ -208,12 +208,24 @@ public class Chunk implements IChunkAccess { return this.sections; } @@ -64,7 +64,7 @@ index be32b31e7..fd9ba8232 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 652067757..0d5deee36 100644 +index 652067757a..0d5deee365 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 652067757..0d5deee36 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 37914c2f5..18ee29e50 100644 +index 37914c2f53..18ee29e507 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -183,11 +183,11 @@ public abstract class World implements GeneratorAccess, AutoCloseable { diff --git a/Spigot-Server-Patches/0075-Entity-AddTo-RemoveFrom-World-Events.patch b/Spigot-Server-Patches/0075-Entity-AddTo-RemoveFrom-World-Events.patch index 5ec3b1f9c..770f44031 100644 --- a/Spigot-Server-Patches/0075-Entity-AddTo-RemoveFrom-World-Events.patch +++ b/Spigot-Server-Patches/0075-Entity-AddTo-RemoveFrom-World-Events.patch @@ -1,14 +1,14 @@ -From 050929739349814b3532f81e389a5ee3efcb2714 Mon Sep 17 00:00:00 2001 +From b510c1a11e27b982e5a084ed3303c975eb3c36b9 Mon Sep 17 00:00:00 2001 From: Aikar Date: Mon, 28 Mar 2016 20:32:58 -0400 Subject: [PATCH] Entity AddTo/RemoveFrom World Events diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 9161d6fd6..2a80fe846 100644 +index 4e29746c14..dac6e10d25 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java -@@ -1142,7 +1142,7 @@ public class WorldServer extends World { +@@ -1144,7 +1144,7 @@ public class WorldServer extends World { if (entity instanceof EntityInsentient) { this.navigators.remove(((EntityInsentient) entity).getNavigation()); } @@ -17,7 +17,7 @@ index 9161d6fd6..2a80fe846 100644 entity.valid = false; // CraftBukkit } -@@ -1180,6 +1180,7 @@ public class WorldServer extends World { +@@ -1182,6 +1182,7 @@ public class WorldServer extends World { entity.origin = entity.getBukkitEntity().getLocation(); } // Paper end diff --git a/Spigot-Server-Patches/0076-Configurable-Chunk-Inhabited-Time.patch b/Spigot-Server-Patches/0076-Configurable-Chunk-Inhabited-Time.patch index 59258b0f9..f29ce4563 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 25fbadf155b0e1ccde33fc04eac74940af7bc4af Mon Sep 17 00:00:00 2001 +From d6acffa96589e496354732eab4ffabeb36dec11d 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 6ef0e1399..5872e6b17 100644 +index 6ef0e1399e..5872e6b171 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 6ef0e1399..5872e6b17 100644 + } } diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index fd9ba8232..034e8684d 100644 +index 7033c6e839..c6a79644ef 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java -@@ -832,7 +832,7 @@ public class Chunk implements IChunkAccess { +@@ -840,7 +840,7 @@ public class Chunk implements IChunkAccess { @Override public long getInhabitedTime() { diff --git a/Spigot-Server-Patches/0087-Remove-unused-World-Tile-Entity-List.patch b/Spigot-Server-Patches/0087-Remove-unused-World-Tile-Entity-List.patch index 307cc62d7..a90a99736 100644 --- a/Spigot-Server-Patches/0087-Remove-unused-World-Tile-Entity-List.patch +++ b/Spigot-Server-Patches/0087-Remove-unused-World-Tile-Entity-List.patch @@ -1,4 +1,4 @@ -From 6bbea6f4606dafaf738658a00512fdbddd28c9e1 Mon Sep 17 00:00:00 2001 +From a5671d9f986739e5b97273f3f6941e89b30ba5b6 Mon Sep 17 00:00:00 2001 From: Aikar Date: Wed, 13 Apr 2016 00:25:28 -0400 Subject: [PATCH] Remove unused World Tile Entity List @@ -6,7 +6,7 @@ Subject: [PATCH] Remove unused World Tile Entity List Massive hit to performance and it is completely unnecessary. diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index e7d441b22..50c138d06 100644 +index e7d441b22b..50c138d06d 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -40,7 +40,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable { @@ -67,10 +67,10 @@ index e7d441b22..50c138d06 100644 } diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 2a80fe846..9121aa2e4 100644 +index dac6e10d25..7b3e3487fa 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java -@@ -1627,7 +1627,7 @@ public class WorldServer extends World { +@@ -1629,7 +1629,7 @@ public class WorldServer extends World { } bufferedwriter.write(String.format("entities: %d\n", this.entitiesById.size())); @@ -79,7 +79,7 @@ index 2a80fe846..9121aa2e4 100644 bufferedwriter.write(String.format("block_ticks: %d\n", this.getBlockTickList().a())); bufferedwriter.write(String.format("fluid_ticks: %d\n", this.getFluidTickList().a())); bufferedwriter.write("distance_manager: " + playerchunkmap.e().c() + "\n"); -@@ -1790,7 +1790,7 @@ public class WorldServer extends World { +@@ -1792,7 +1792,7 @@ public class WorldServer extends World { private void a(Writer writer) throws IOException { CSVWriter csvwriter = CSVWriter.a().a("x").a("y").a("z").a("type").a(writer); diff --git a/Spigot-Server-Patches/0093-Implement-PlayerLocaleChangeEvent.patch b/Spigot-Server-Patches/0093-Implement-PlayerLocaleChangeEvent.patch index 025b14e7a..a8583bba0 100644 --- a/Spigot-Server-Patches/0093-Implement-PlayerLocaleChangeEvent.patch +++ b/Spigot-Server-Patches/0093-Implement-PlayerLocaleChangeEvent.patch @@ -1,11 +1,11 @@ -From da29415c772bbff8d14c2af933489884c855fb4c Mon Sep 17 00:00:00 2001 +From f5359af1e1a41db39a22219987cd988c7e4c227f Mon Sep 17 00:00:00 2001 From: Isaac Moore Date: Tue, 19 Apr 2016 14:09:31 -0500 Subject: [PATCH] Implement PlayerLocaleChangeEvent diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index 4289aadc6..1f5145d49 100644 +index b5101af011..d4bba876d0 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -37,7 +37,7 @@ import org.bukkit.inventory.MainHand; @@ -17,7 +17,7 @@ index 4289aadc6..1f5145d49 100644 public PlayerConnection playerConnection; public final MinecraftServer server; public final PlayerInteractManager playerInteractManager; -@@ -1461,13 +1461,20 @@ public class EntityPlayer extends EntityHuman implements ICrafting { +@@ -1465,13 +1465,20 @@ public class EntityPlayer extends EntityHuman implements ICrafting { PlayerChangedMainHandEvent event = new PlayerChangedMainHandEvent(getBukkitEntity(), getMainHand() == EnumMainHand.LEFT ? MainHand.LEFT : MainHand.RIGHT); this.server.server.getPluginManager().callEvent(event); } @@ -40,7 +40,7 @@ index 4289aadc6..1f5145d49 100644 this.ci = packetplayinsettings.e(); this.getDataWatcher().set(EntityPlayer.bq, (byte) packetplayinsettings.f()); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 5647eb135..447ecf636 100644 +index 5647eb135e..447ecf636d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -1768,8 +1768,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player { diff --git a/Spigot-Server-Patches/0097-Improve-Maps-in-item-frames-performance-and-bug-fixe.patch b/Spigot-Server-Patches/0097-Improve-Maps-in-item-frames-performance-and-bug-fixe.patch index 9298751e4..f8a1796d8 100644 --- a/Spigot-Server-Patches/0097-Improve-Maps-in-item-frames-performance-and-bug-fixe.patch +++ b/Spigot-Server-Patches/0097-Improve-Maps-in-item-frames-performance-and-bug-fixe.patch @@ -1,4 +1,4 @@ -From 4ee6bc1ec61b188bafb6d3ceef0d69b229465218 Mon Sep 17 00:00:00 2001 +From cfca191373edfe3183204448a202e179a526e830 Mon Sep 17 00:00:00 2001 From: Aikar Date: Fri, 29 Apr 2016 20:02:00 -0400 Subject: [PATCH] Improve Maps (in item frames) performance and bug fixes @@ -13,7 +13,7 @@ custom renderers are in use, defaulting to the much simpler Vanilla system. Additionally, numerous issues to player position tracking on maps has been fixed. diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java -index 747f5eeb6..2a54723a6 100644 +index 26adb55409..b407d80ae6 100644 --- a/src/main/java/net/minecraft/server/EntityHuman.java +++ b/src/main/java/net/minecraft/server/EntityHuman.java @@ -615,6 +615,12 @@ public abstract class EntityHuman extends EntityLiving { @@ -30,7 +30,7 @@ index 747f5eeb6..2a54723a6 100644 return entityitem; } diff --git a/src/main/java/net/minecraft/server/WorldMap.java b/src/main/java/net/minecraft/server/WorldMap.java -index a56ac3da8..2f1be1995 100644 +index a56ac3da80..2f1be1995d 100644 --- a/src/main/java/net/minecraft/server/WorldMap.java +++ b/src/main/java/net/minecraft/server/WorldMap.java @@ -31,6 +31,7 @@ public class WorldMap extends PersistentBase { @@ -102,10 +102,10 @@ index a56ac3da8..2f1be1995 100644 for ( org.bukkit.map.MapCursor cursor : render.cursors) { diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 9121aa2e4..9c20b5f6f 100644 +index 7b3e3487fa..23f3d7eb51 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java -@@ -1104,6 +1104,7 @@ public class WorldServer extends World { +@@ -1105,6 +1105,7 @@ public class WorldServer extends World { { if ( iter.next().trackee == entity ) { @@ -114,7 +114,7 @@ index 9121aa2e4..9c20b5f6f 100644 } } diff --git a/src/main/java/org/bukkit/craftbukkit/map/RenderData.java b/src/main/java/org/bukkit/craftbukkit/map/RenderData.java -index 256a13178..5768cd512 100644 +index 256a131781..5768cd512e 100644 --- a/src/main/java/org/bukkit/craftbukkit/map/RenderData.java +++ b/src/main/java/org/bukkit/craftbukkit/map/RenderData.java @@ -5,7 +5,7 @@ import org.bukkit.map.MapCursor; diff --git a/Spigot-Server-Patches/0107-Fix-Double-World-Add-issues.patch b/Spigot-Server-Patches/0107-Fix-Double-World-Add-issues.patch index a2788213f..dcccb29f2 100644 --- a/Spigot-Server-Patches/0107-Fix-Double-World-Add-issues.patch +++ b/Spigot-Server-Patches/0107-Fix-Double-World-Add-issues.patch @@ -1,4 +1,4 @@ -From 39993e55a99aafb6e160327db8d81fc95c84bc0c Mon Sep 17 00:00:00 2001 +From 188c4e80539d150665d81235bc988b53d4fc932c Mon Sep 17 00:00:00 2001 From: Aikar Date: Tue, 21 Jun 2016 22:54:34 -0400 Subject: [PATCH] Fix Double World Add issues @@ -8,10 +8,10 @@ Vanilla will double add Spider Jockeys to the world, so ignore already added. Also add debug if something else tries to, and abort before world gets bad state diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 9c20b5f6f..48737366f 100644 +index 23f3d7eb51..e69f82dcd1 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java -@@ -993,6 +993,7 @@ public class WorldServer extends World { +@@ -994,6 +994,7 @@ public class WorldServer extends World { // CraftBukkit start private boolean addEntity0(Entity entity, CreatureSpawnEvent.SpawnReason spawnReason) { org.spigotmc.AsyncCatcher.catchOp("entity add"); // Spigot diff --git a/Spigot-Server-Patches/0111-Re-track-players-that-dismount-from-other-players.patch b/Spigot-Server-Patches/0111-Re-track-players-that-dismount-from-other-players.patch index 6c3fc4769..000499fda 100644 --- a/Spigot-Server-Patches/0111-Re-track-players-that-dismount-from-other-players.patch +++ b/Spigot-Server-Patches/0111-Re-track-players-that-dismount-from-other-players.patch @@ -1,14 +1,14 @@ -From 20405ad1a330c2f8ae512f7a5847e77c60507495 Mon Sep 17 00:00:00 2001 +From 0c006970ef9bbf08b0d317a44df34104f25612e8 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Sun, 31 Jul 2016 16:33:03 -0500 Subject: [PATCH] Re-track players that dismount from other players diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index 1f5145d49..b2c070397 100644 +index d4bba876d0..ae1f0d5783 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java -@@ -993,6 +993,14 @@ public class EntityPlayer extends EntityHuman implements ICrafting { +@@ -997,6 +997,14 @@ public class EntityPlayer extends EntityHuman implements ICrafting { if (entity1 != entity && this.playerConnection != null) { this.playerConnection.a(this.locX(), this.locY(), this.locZ(), this.yaw, this.pitch); } @@ -23,7 +23,7 @@ index 1f5145d49..b2c070397 100644 } -@@ -1009,7 +1017,6 @@ public class EntityPlayer extends EntityHuman implements ICrafting { +@@ -1013,7 +1021,6 @@ public class EntityPlayer extends EntityHuman implements ICrafting { if (!this.isSpectator()) { super.b(blockposition); } diff --git a/Spigot-Server-Patches/0118-Auto-fix-bad-Y-levels-on-player-login.patch b/Spigot-Server-Patches/0118-Auto-fix-bad-Y-levels-on-player-login.patch index 82e9eb85a..ce7d9fc54 100644 --- a/Spigot-Server-Patches/0118-Auto-fix-bad-Y-levels-on-player-login.patch +++ b/Spigot-Server-Patches/0118-Auto-fix-bad-Y-levels-on-player-login.patch @@ -1,4 +1,4 @@ -From bde47603ed2163a6a9335a3bd9a087972d9aeec7 Mon Sep 17 00:00:00 2001 +From 7f770d5475c7bf8ae56d1eb2f24e4cdc88a27a46 Mon Sep 17 00:00:00 2001 From: Aikar Date: Wed, 21 Sep 2016 23:48:39 -0400 Subject: [PATCH] Auto fix bad Y levels on player login @@ -6,10 +6,10 @@ Subject: [PATCH] Auto fix bad Y levels on player login Bring down to a saner Y level if super high, as this can cause the server to crash diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index b2c070397..cb4d49b1e 100644 +index ae1f0d5783..a5701623bf 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java -@@ -193,6 +193,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { +@@ -197,6 +197,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { @Override public void a(NBTTagCompound nbttagcompound) { super.a(nbttagcompound); 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 780e99e36..743c14527 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 e6ba1a2e2785f34574ea5ee7c0f93dbde806c2aa Mon Sep 17 00:00:00 2001 +From 7db41031dd776df0570cfc2c86a08345d3d5bc2f 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 8cf3076f4..721eceeff 100644 +index 8cf3076f4e..721eceeffc 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 8cf3076f4..721eceeff 100644 + } } diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 034e8684d..1efddb533 100644 +index c6a79644ef..8fdae388e3 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java -@@ -526,6 +526,12 @@ public class Chunk implements IChunkAccess { +@@ -532,6 +532,12 @@ public class Chunk implements IChunkAccess { "Chunk coordinates: " + (this.loc.x * 16) + "," + (this.loc.z * 16)); e.printStackTrace(); ServerInternalException.reportInternalException(e); diff --git a/Spigot-Server-Patches/0122-Cache-user-authenticator-threads.patch b/Spigot-Server-Patches/0122-Cache-user-authenticator-threads.patch index b4f33770a..0087b8a54 100644 --- a/Spigot-Server-Patches/0122-Cache-user-authenticator-threads.patch +++ b/Spigot-Server-Patches/0122-Cache-user-authenticator-threads.patch @@ -1,11 +1,11 @@ -From a289a83b759623cd1ca4d8cd8aba88fbbb176047 Mon Sep 17 00:00:00 2001 +From b1dc43a6bec6886fc0525ee34cd394fbd1a38d74 Mon Sep 17 00:00:00 2001 From: vemacs Date: Wed, 23 Nov 2016 08:31:45 -0500 Subject: [PATCH] Cache user authenticator threads diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index cb4d49b1e..8aef7e480 100644 +index a5701623bf..d3bdec7995 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -4,7 +4,9 @@ import com.google.common.collect.Lists; @@ -27,7 +27,7 @@ index cb4d49b1e..8aef7e480 100644 private final AdvancementDataPlayer advancementDataPlayer; private final ServerStatisticManager serverStatisticManager; private float lastHealthScored = Float.MIN_VALUE; -@@ -367,13 +369,20 @@ public class EntityPlayer extends EntityHuman implements ICrafting { +@@ -371,13 +373,20 @@ public class EntityPlayer extends EntityHuman implements ICrafting { while (!this.removeQueue.isEmpty()) { int i = Math.min(this.removeQueue.size(), Integer.MAX_VALUE); int[] aint = new int[i]; @@ -50,7 +50,7 @@ index cb4d49b1e..8aef7e480 100644 this.playerConnection.sendPacket(new PacketPlayOutEntityDestroy(aint)); } -@@ -1328,7 +1337,14 @@ public class EntityPlayer extends EntityHuman implements ICrafting { +@@ -1332,7 +1341,14 @@ public class EntityPlayer extends EntityHuman implements ICrafting { this.lastHealthSent = -1.0F; this.lastFoodSent = -1; // this.recipeBook.a((RecipeBook) entityplayer.recipeBook); // CraftBukkit diff --git a/Spigot-Server-Patches/0134-Properly-fix-item-duplication-bug.patch b/Spigot-Server-Patches/0134-Properly-fix-item-duplication-bug.patch index b818dc057..e71f88e44 100644 --- a/Spigot-Server-Patches/0134-Properly-fix-item-duplication-bug.patch +++ b/Spigot-Server-Patches/0134-Properly-fix-item-duplication-bug.patch @@ -1,4 +1,4 @@ -From 6060dd5bf706c1c2a6bf4672884a80c859ae23bf Mon Sep 17 00:00:00 2001 +From e0662983efb699fc39eef3764e2dbb9ba07f1811 Mon Sep 17 00:00:00 2001 From: Alfie Cleveland Date: Tue, 27 Dec 2016 01:57:57 +0000 Subject: [PATCH] Properly fix item duplication bug @@ -6,10 +6,10 @@ Subject: [PATCH] Properly fix item duplication bug Credit to prplz for figuring out the real issue diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index 8aef7e480..68b19a3fc 100644 +index d3bdec7995..1296eb04f0 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java -@@ -1796,7 +1796,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { +@@ -1800,7 +1800,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { @Override protected boolean isFrozen() { @@ -19,7 +19,7 @@ index 8aef7e480..68b19a3fc 100644 @Override diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java -index 16b70221e..cc6a2aaeb 100644 +index 16b70221ea..cc6a2aaeb3 100644 --- a/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/src/main/java/net/minecraft/server/PlayerConnection.java @@ -2525,7 +2525,7 @@ public class PlayerConnection implements PacketListenerPlayIn { 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 1319fbf11..96fe1de9c 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 b25e2d534653a255280c644681141cf999a1dc7b Mon Sep 17 00:00:00 2001 +From f0e1f1fa1e613324eec3095d858a8cf79f02b85c 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 628b73a12..2f10dab36 100644 +index 9fa88d79d8..ee2174a9ca 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 628b73a12..2f10dab36 100644 import org.bukkit.Location; import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.CraftWorld; -@@ -24,6 +25,24 @@ public final class MCUtil { +@@ -94,6 +95,24 @@ public final class MCUtil { private MCUtil() {} @@ -42,7 +42,7 @@ index 628b73a12..2f10dab36 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 447ecf636..3a2a88618 100644 +index 447ecf636d..3a2a886180 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -217,6 +217,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player { diff --git a/Spigot-Server-Patches/0144-Make-targetSize-more-aggressive-in-the-chunk-unload-.patch b/Spigot-Server-Patches/0144-Make-targetSize-more-aggressive-in-the-chunk-unload-.patch index 5e10fd774..60e424dd6 100644 --- a/Spigot-Server-Patches/0144-Make-targetSize-more-aggressive-in-the-chunk-unload-.patch +++ b/Spigot-Server-Patches/0144-Make-targetSize-more-aggressive-in-the-chunk-unload-.patch @@ -1,14 +1,14 @@ -From d29b34d68e68ffcf2b8233a257389f7f3216392c Mon Sep 17 00:00:00 2001 +From 306788514e502ec1f8ac21c5f937bbd4b0e1a2cc Mon Sep 17 00:00:00 2001 From: Brokkonaut Date: Tue, 7 Feb 2017 16:55:35 -0600 Subject: [PATCH] Make targetSize more aggressive in the chunk unload queue diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index 1627aeeef..4fefdb9ce 100644 +index c575ff57dd..86e1b403b2 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java -@@ -110,7 +110,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -139,7 +139,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { this.u = new AtomicInteger(); this.playerMap = new PlayerMap(); this.trackedEntities = new Int2ObjectOpenHashMap(); @@ -17,7 +17,7 @@ index 1627aeeef..4fefdb9ce 100644 this.definedStructureManager = definedstructuremanager; this.w = worldserver.getWorldProvider().getDimensionManager().a(file); this.world = worldserver; -@@ -360,7 +360,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -389,7 +389,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { // Spigot start org.spigotmc.SlackActivityAccountant activityAccountant = this.world.getMinecraftServer().slackActivityAccountant; activityAccountant.startActivity(0.5); @@ -26,7 +26,7 @@ index 1627aeeef..4fefdb9ce 100644 // Spigot end while (longiterator.hasNext()) { // Spigot long j = longiterator.nextLong(); -@@ -382,7 +382,8 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -411,7 +411,8 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { Runnable runnable; diff --git a/Spigot-Server-Patches/0156-Basic-PlayerProfile-API.patch b/Spigot-Server-Patches/0156-Basic-PlayerProfile-API.patch index cc35f44bc..175705f4f 100644 --- a/Spigot-Server-Patches/0156-Basic-PlayerProfile-API.patch +++ b/Spigot-Server-Patches/0156-Basic-PlayerProfile-API.patch @@ -1,4 +1,4 @@ -From 7c1bfbef421a19f61008320ef8e3d26ba6ae8098 Mon Sep 17 00:00:00 2001 +From 60ac711495320c6a94f4032fb25a0cd98facd648 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 000000000..b151a13c1 +index 0000000000..b151a13c1b --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java @@ -0,0 +1,280 @@ @@ -293,7 +293,7 @@ index 000000000..b151a13c1 +} 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 000000000..25836b975 +index 0000000000..25836b975b --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/profile/PaperAuthenticationService.java @@ -0,0 +1,30 @@ @@ -329,7 +329,7 @@ index 000000000..25836b975 +} 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 000000000..3bcdb8f93 +index 0000000000..3bcdb8f93f --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/profile/PaperGameProfileRepository.java @@ -0,0 +1,17 @@ @@ -352,7 +352,7 @@ index 000000000..3bcdb8f93 +} 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 000000000..4b2a67423 +index 0000000000..4b2a67423f --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/profile/PaperMinecraftSessionService.java @@ -0,0 +1,29 @@ @@ -387,7 +387,7 @@ index 000000000..4b2a67423 +} 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 000000000..3aceb0ea8 +index 0000000000..3aceb0ea8a --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/profile/PaperUserAuthentication.java @@ -0,0 +1,11 @@ @@ -403,7 +403,7 @@ index 000000000..3aceb0ea8 + } +} diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java -index 2f10dab36..670f8313a 100644 +index ee2174a9ca..2a22bc6f3e 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 2f10dab36..670f8313a 100644 import org.apache.commons.lang.exception.ExceptionUtils; import org.bukkit.Location; import org.bukkit.block.BlockFace; -@@ -158,6 +161,10 @@ public final class MCUtil { +@@ -228,6 +231,10 @@ public final class MCUtil { return run.get(); } @@ -429,7 +429,7 @@ index 2f10dab36..670f8313a 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 7016dac2d..c15ca642d 100644 +index 7016dac2d7..c15ca642d0 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: Sun, 14 Jan 2018 17:36:02 -0500 Subject: [PATCH] PlayerNaturallySpawnCreaturesEvent @@ -9,10 +9,10 @@ from triggering monster spawns on a server. Also a highly more effecient way to blanket block spawns in a world diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index 4fefdb9ce..426beb181 100644 +index 86e1b403b2..bf80af2354 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java -@@ -852,12 +852,24 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -881,12 +881,24 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { chunkRange = (chunkRange > world.spigotConfig.viewDistance) ? (byte) world.spigotConfig.viewDistance : chunkRange; chunkRange = (chunkRange > 8) ? 8 : chunkRange; diff --git a/Spigot-Server-Patches/0219-Expand-World.spawnParticle-API-and-add-Builder.patch b/Spigot-Server-Patches/0219-Expand-World.spawnParticle-API-and-add-Builder.patch index 520c79c6d..9abde5fcc 100644 --- a/Spigot-Server-Patches/0219-Expand-World.spawnParticle-API-and-add-Builder.patch +++ b/Spigot-Server-Patches/0219-Expand-World.spawnParticle-API-and-add-Builder.patch @@ -1,4 +1,4 @@ -From 50345a69210dc593487981be003c2d2e516aa4bf Mon Sep 17 00:00:00 2001 +From 2a1b3e555dfff49e833776ac75b648013a211515 Mon Sep 17 00:00:00 2001 From: Aikar Date: Tue, 15 Aug 2017 22:29:12 -0400 Subject: [PATCH] Expand World.spawnParticle API and add Builder @@ -10,7 +10,7 @@ Adds an option to control the force mode of the particle. This adds a new Builder API which is much friendlier to use. diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index fe1a87ba5..9ee58acf7 100644 +index 69d2e2c3b5..62a16173b9 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -56,7 +56,7 @@ public class WorldServer extends World { @@ -22,7 +22,7 @@ index fe1a87ba5..9ee58acf7 100644 boolean tickingEntities; private final MinecraftServer server; private final WorldNBTStorage dataManager; -@@ -1400,12 +1400,17 @@ public class WorldServer extends World { +@@ -1402,12 +1402,17 @@ public class WorldServer extends World { } public int sendParticles(EntityPlayer sender, T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6, boolean force) { @@ -43,7 +43,7 @@ index fe1a87ba5..9ee58acf7 100644 if (this.a(entityplayer, force, d0, d1, d2, packetplayoutworldparticles)) { // CraftBukkit diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 63b1cb2a4..59036635d 100644 +index 63b1cb2a4c..59036635d7 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -2250,11 +2250,17 @@ public class CraftWorld implements World { diff --git a/Spigot-Server-Patches/0242-InventoryCloseEvent-Reason-API.patch b/Spigot-Server-Patches/0242-InventoryCloseEvent-Reason-API.patch index 771652506..c810599a3 100644 --- a/Spigot-Server-Patches/0242-InventoryCloseEvent-Reason-API.patch +++ b/Spigot-Server-Patches/0242-InventoryCloseEvent-Reason-API.patch @@ -1,4 +1,4 @@ -From 741de755a8d799b1867c66b78d561cbc3ac661de Mon Sep 17 00:00:00 2001 +From 4b7038782910fbfc830ff3d0b058230fb2a3908a Mon Sep 17 00:00:00 2001 From: Aikar Date: Tue, 3 Jul 2018 21:56:23 -0400 Subject: [PATCH] InventoryCloseEvent Reason API @@ -7,7 +7,7 @@ Allows you to determine why an inventory was closed, enabling plugin developers to "confirm" things based on if it was player triggered close or not. diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java -index 4280dacdc..1f3513874 100644 +index 4721c288ba..36748ccb73 100644 --- a/src/main/java/net/minecraft/server/EntityHuman.java +++ b/src/main/java/net/minecraft/server/EntityHuman.java @@ -164,7 +164,7 @@ public abstract class EntityHuman extends EntityLiving { @@ -34,10 +34,10 @@ index 4280dacdc..1f3513874 100644 this.activeContainer = this.defaultContainer; } diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index 68b19a3fc..5e2e0674a 100644 +index 1296eb04f0..a9a16eace9 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java -@@ -362,7 +362,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { +@@ -366,7 +366,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } // Paper end if (!this.world.isClientSide && !this.activeContainer.canUse(this)) { @@ -46,7 +46,7 @@ index 68b19a3fc..5e2e0674a 100644 this.activeContainer = this.defaultContainer; } -@@ -536,7 +536,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { +@@ -540,7 +540,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { // SPIGOT-943 - only call if they have an inventory open if (this.activeContainer != this.defaultContainer) { @@ -55,7 +55,7 @@ index 68b19a3fc..5e2e0674a 100644 } String deathMessage = event.getDeathMessage(); -@@ -1056,7 +1056,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { +@@ -1060,7 +1060,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { return OptionalInt.empty(); } else { if (this.activeContainer != this.defaultContainer) { @@ -64,7 +64,7 @@ index 68b19a3fc..5e2e0674a 100644 } this.nextContainerCounter(); -@@ -1116,7 +1116,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { +@@ -1120,7 +1120,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } // CraftBukkit end if (this.activeContainer != this.defaultContainer) { @@ -73,7 +73,7 @@ index 68b19a3fc..5e2e0674a 100644 } // this.nextContainerCounter(); // CraftBukkit - moved up -@@ -1180,7 +1180,12 @@ public class EntityPlayer extends EntityHuman implements ICrafting { +@@ -1184,7 +1184,12 @@ public class EntityPlayer extends EntityHuman implements ICrafting { @Override public void closeInventory() { @@ -88,7 +88,7 @@ index 68b19a3fc..5e2e0674a 100644 this.m(); } diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java -index 8757b6751..4f04410f9 100644 +index 8757b6751e..4f04410f9b 100644 --- a/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/src/main/java/net/minecraft/server/PlayerConnection.java @@ -2039,7 +2039,7 @@ public class PlayerConnection implements PacketListenerPlayIn { @@ -101,7 +101,7 @@ index 8757b6751..4f04410f9 100644 this.player.m(); } diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java -index 002f7e844..fd0f5c6f2 100644 +index 002f7e844a..fd0f5c6f29 100644 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -403,7 +403,7 @@ public abstract class PlayerList { @@ -114,10 +114,10 @@ index 002f7e844..fd0f5c6f2 100644 PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(cserver.getPlayer(entityplayer), "\u00A7e" + entityplayer.getName() + " left the game"); cserver.getPluginManager().callEvent(playerQuitEvent); diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 9ee58acf7..ae7df6141 100644 +index 62a16173b9..f0c912be43 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java -@@ -1046,7 +1046,7 @@ public class WorldServer extends World { +@@ -1047,7 +1047,7 @@ public class WorldServer extends World { { if ( h instanceof org.bukkit.craftbukkit.entity.CraftHumanEntity ) { @@ -126,7 +126,7 @@ index 9ee58acf7..ae7df6141 100644 } } } -@@ -1069,7 +1069,7 @@ public class WorldServer extends World { +@@ -1070,7 +1070,7 @@ public class WorldServer extends World { { if ( h instanceof org.bukkit.craftbukkit.entity.CraftHumanEntity ) { @@ -136,7 +136,7 @@ index 9ee58acf7..ae7df6141 100644 } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java -index cd8ad2704..e169679c8 100644 +index cd8ad27047..e169679c88 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -619,8 +619,13 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { @@ -155,7 +155,7 @@ index cd8ad2704..e169679c8 100644 @Override public boolean isBlocking() { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index f4affa693..c1f392716 100644 +index f4affa693a..c1f3927164 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -786,7 +786,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -168,7 +168,7 @@ index f4affa693..c1f392716 100644 // Check if the fromWorld and toWorld are the same. diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index caf277439..f931fa48b 100644 +index caf277439a..f931fa48b4 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -1293,8 +1293,19 @@ public class CraftEventFactory { diff --git a/Spigot-Server-Patches/0247-Re-add-vanilla-entity-warnings-for-duplicates.patch b/Spigot-Server-Patches/0247-Re-add-vanilla-entity-warnings-for-duplicates.patch index d1bbfda2e..8322ba287 100644 --- a/Spigot-Server-Patches/0247-Re-add-vanilla-entity-warnings-for-duplicates.patch +++ b/Spigot-Server-Patches/0247-Re-add-vanilla-entity-warnings-for-duplicates.patch @@ -1,4 +1,4 @@ -From d2d62998ed68f66af8cfa85e33aea7a3d94c1bee Mon Sep 17 00:00:00 2001 +From c028e6bde7f7c652ca0827017bfdea624603fbe5 Mon Sep 17 00:00:00 2001 From: Aikar Date: Thu, 19 Jul 2018 01:08:05 -0400 Subject: [PATCH] Re-add vanilla entity warnings for duplicates @@ -8,10 +8,10 @@ These are a critical sign that somethin went wrong, and you've lost some data... We should kind of know about these things you know. diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index ae7df6141..389036405 100644 +index f0c912be43..d46a664bdb 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java -@@ -1031,7 +1031,8 @@ public class WorldServer extends World { +@@ -1032,7 +1032,8 @@ public class WorldServer extends World { if (entity1 == null) { return false; } else { diff --git a/Spigot-Server-Patches/0251-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch b/Spigot-Server-Patches/0251-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch index d708b52a0..7722b35f0 100644 --- a/Spigot-Server-Patches/0251-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch +++ b/Spigot-Server-Patches/0251-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch @@ -1,4 +1,4 @@ -From 5dd454f6d8e206f785b33b548a9571230b95b1e0 Mon Sep 17 00:00:00 2001 +From 2178fef21e20a74545ee6cb6ab61548a87cd76f3 Mon Sep 17 00:00:00 2001 From: Aikar Date: Sat, 21 Jul 2018 08:25:40 -0400 Subject: [PATCH] Add Debug Entities option to debug dupe uuid issues @@ -6,7 +6,7 @@ Subject: [PATCH] Add Debug Entities option to debug dupe uuid issues Add -Ddebug.entities=true to your JVM flags to gain more information diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 591e2ad56..e5987be45 100644 +index 591e2ad56c..e5987be450 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -76,6 +76,8 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke @@ -19,10 +19,10 @@ index 591e2ad56..e5987be45 100644 if (bukkitEntity == null) { bukkitEntity = CraftEntity.getEntity(world.getServer(), this); diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index 426beb181..7edca1744 100644 +index bf80af2354..e93741a8e8 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java -@@ -1031,6 +1031,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -1062,6 +1062,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { } else { PlayerChunkMap.EntityTracker playerchunkmap_entitytracker = new PlayerChunkMap.EntityTracker(entity, i, j, entitytypes.isDeltaTracking()); @@ -30,7 +30,7 @@ index 426beb181..7edca1744 100644 this.trackedEntities.put(entity.getId(), playerchunkmap_entitytracker); playerchunkmap_entitytracker.track(this.world.getPlayers()); if (entity instanceof EntityPlayer) { -@@ -1073,7 +1074,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -1104,7 +1105,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { if (playerchunkmap_entitytracker1 != null) { playerchunkmap_entitytracker1.a(); } @@ -40,7 +40,7 @@ index 426beb181..7edca1744 100644 protected void g() { diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index 9987adb6f..9d9e8fed2 100644 +index 9987adb6f4..9d9e8fed27 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -67,6 +67,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable { @@ -52,7 +52,7 @@ index 9987adb6f..9d9e8fed2 100644 public boolean captureBlockStates = false; public boolean captureTreeGeneration = false; diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 389036405..224f6d151 100644 +index d46a664bdb..3d5a50ddcc 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -76,6 +76,9 @@ public class WorldServer extends World { @@ -65,7 +65,7 @@ index 389036405..224f6d151 100644 // Add env and gen to constructor public WorldServer(MinecraftServer minecraftserver, Executor executor, WorldNBTStorage worldnbtstorage, WorldData worlddata, DimensionManager dimensionmanager, GameProfilerFiller gameprofilerfiller, WorldLoadListener worldloadlistener, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen) { -@@ -993,8 +996,28 @@ public class WorldServer extends World { +@@ -994,8 +997,28 @@ public class WorldServer extends World { // CraftBukkit start private boolean addEntity0(Entity entity, CreatureSpawnEvent.SpawnReason spawnReason) { org.spigotmc.AsyncCatcher.catchOp("entity add"); // Spigot @@ -95,7 +95,7 @@ index 389036405..224f6d151 100644 // WorldServer.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getName(entity.getEntityType())); // CraftBukkit return false; } else if (this.isUUIDTaken(entity)) { -@@ -1166,7 +1189,24 @@ public class WorldServer extends World { +@@ -1168,7 +1191,24 @@ public class WorldServer extends World { } } diff --git a/Spigot-Server-Patches/0254-Speedup-BlockPos-by-fixing-inlining.patch b/Spigot-Server-Patches/0254-Speedup-BlockPos-by-fixing-inlining.patch index 34f456fac..6152d8308 100644 --- a/Spigot-Server-Patches/0254-Speedup-BlockPos-by-fixing-inlining.patch +++ b/Spigot-Server-Patches/0254-Speedup-BlockPos-by-fixing-inlining.patch @@ -1,4 +1,4 @@ -From 94b5f2ac086c6844aeea8e603c73ad062e6ba24e Mon Sep 17 00:00:00 2001 +From 2f7135a6499499a1f67c56a25881f026a74ee1b2 Mon Sep 17 00:00:00 2001 From: Techcable Date: Wed, 30 Nov 2016 20:56:58 -0600 Subject: [PATCH] Speedup BlockPos by fixing inlining @@ -21,7 +21,7 @@ This is based upon conclusions drawn from inspecting the assenmbly generated byt They had 'callq' (invoke) instead of 'mov' (get from memory) instructions. diff --git a/src/main/java/net/minecraft/server/BaseBlockPosition.java b/src/main/java/net/minecraft/server/BaseBlockPosition.java -index 71089442c..c439a8d01 100644 +index 71089442c1..c439a8d019 100644 --- a/src/main/java/net/minecraft/server/BaseBlockPosition.java +++ b/src/main/java/net/minecraft/server/BaseBlockPosition.java @@ -7,25 +7,22 @@ import javax.annotation.concurrent.Immutable; @@ -110,7 +110,7 @@ index 71089442c..c439a8d01 100644 return (int) (f + f1 + f2); } diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java -index 1cdf0346f..5a505b753 100644 +index 5dbd3e60fe..e9ea232a78 100644 --- a/src/main/java/net/minecraft/server/BlockPosition.java +++ b/src/main/java/net/minecraft/server/BlockPosition.java @@ -342,11 +342,13 @@ public class BlockPosition extends BaseBlockPosition implements MinecraftSeriali @@ -176,7 +176,7 @@ index 1cdf0346f..5a505b753 100644 return this; } -@@ -439,23 +450,23 @@ public class BlockPosition extends BaseBlockPosition implements MinecraftSeriali +@@ -439,26 +450,26 @@ public class BlockPosition extends BaseBlockPosition implements MinecraftSeriali } public BlockPosition.MutableBlockPosition c(EnumDirection enumdirection, int i) { @@ -189,16 +189,19 @@ index 1cdf0346f..5a505b753 100644 + return this.d(this.x + i, this.y + j, this.z + k); } + public final void setX(final int x) { this.o(x); } // Paper - OBFHELPER public void o(int i) { - this.b = i; + this.x = i; // Paper change to x } + public final void setY(final int y) { this.p(y); } // Paper - OBFHELPER public void p(int i) { - this.c = i; + this.y = i; // Paper change to y } + public final void setZ(final int z) { this.q(z); } // Paper - OBFHELPER public void q(int i) { - this.d = i; + this.z = i; // Paper change to z diff --git a/Spigot-Server-Patches/0258-Mark-chunk-dirty-anytime-entities-change-to-guarante.patch b/Spigot-Server-Patches/0258-Mark-chunk-dirty-anytime-entities-change-to-guarante.patch index 34c232ee9..3d2c54141 100644 --- a/Spigot-Server-Patches/0258-Mark-chunk-dirty-anytime-entities-change-to-guarante.patch +++ b/Spigot-Server-Patches/0258-Mark-chunk-dirty-anytime-entities-change-to-guarante.patch @@ -1,4 +1,4 @@ -From f50d2da0dac7ab2bfb2cb1d67f325a6f03b4aead Mon Sep 17 00:00:00 2001 +From f2538725efa773c32f5c14be02a9c19ef3f931f3 Mon Sep 17 00:00:00 2001 From: Aikar Date: Mon, 23 Jul 2018 22:18:31 -0400 Subject: [PATCH] Mark chunk dirty anytime entities change to guarantee it @@ -6,18 +6,18 @@ 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 1efddb533..6774c6480 100644 +index 8fdae388e3..28e5105ffe 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java -@@ -410,6 +410,7 @@ public class Chunk implements IChunkAccess { - entity.chunkY = k; +@@ -416,6 +416,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); + this.markDirty(); // Paper } @Override -@@ -436,6 +437,7 @@ public class Chunk implements IChunkAccess { +@@ -442,6 +443,7 @@ public class Chunk implements IChunkAccess { return; } entityCounts.decrement(entity.getMinecraftKeyString()); diff --git a/Spigot-Server-Patches/0259-Add-some-Debug-to-Chunk-Entity-slices.patch b/Spigot-Server-Patches/0259-Add-some-Debug-to-Chunk-Entity-slices.patch index b10df0a1d..076355aa0 100644 --- a/Spigot-Server-Patches/0259-Add-some-Debug-to-Chunk-Entity-slices.patch +++ b/Spigot-Server-Patches/0259-Add-some-Debug-to-Chunk-Entity-slices.patch @@ -1,4 +1,4 @@ -From fc2b2e371a21fe3a22451d658507557f4d2a5885 Mon Sep 17 00:00:00 2001 +From 0acebe52e93af5833c06aa7223868da0e572226e 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 6774c6480..b156f5428 100644 +index 28e5105ffe..2004f7fbe1 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java -@@ -402,6 +402,25 @@ public class Chunk implements IChunkAccess { +@@ -407,6 +407,25 @@ public class Chunk implements IChunkAccess { if (k >= this.entitySlices.length) { k = this.entitySlices.length - 1; } @@ -38,15 +38,15 @@ index 6774c6480..b156f5428 100644 if (!entity.inChunk || entity.getCurrentChunk() != this) entityCounts.increment(entity.getMinecraftKeyString()); // Paper entity.inChunk = true; -@@ -410,6 +429,7 @@ public class Chunk implements IChunkAccess { - entity.chunkY = k; +@@ -416,6 +435,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); + entity.entitySlice = this.entitySlices[k]; // Paper this.markDirty(); // Paper } -@@ -433,6 +453,9 @@ public class Chunk implements IChunkAccess { +@@ -439,6 +459,9 @@ public class Chunk implements IChunkAccess { } // Paper start if (entity.currentChunk != null && entity.currentChunk.get() == this) entity.setCurrentChunk(null); @@ -57,7 +57,7 @@ index 6774c6480..b156f5428 100644 return; } diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 8e23f336a..e761f7148 100644 +index 8e23f336a8..e761f71487 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 diff --git a/Spigot-Server-Patches/0264-Ignore-Dead-Entities-in-entityList-iteration.patch b/Spigot-Server-Patches/0264-Ignore-Dead-Entities-in-entityList-iteration.patch index b29a05a09..cdc2cd2a2 100644 --- a/Spigot-Server-Patches/0264-Ignore-Dead-Entities-in-entityList-iteration.patch +++ b/Spigot-Server-Patches/0264-Ignore-Dead-Entities-in-entityList-iteration.patch @@ -1,4 +1,4 @@ -From 9dbb6eb1aa5d92972f3e2c0c0513c6d0e004c4db Mon Sep 17 00:00:00 2001 +From b6ec7c795015192dd516d7c7cd8a741fbd66b9d7 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 @@ -11,7 +11,7 @@ This will ensure that dead entities are skipped from iteration since they shouldn't of been in the list in the first place. diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java -index eecf27370..d704fc79c 100644 +index eecf27370b..d704fc79c0 100644 --- a/src/main/java/com/destroystokyo/paper/PaperCommand.java +++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java @@ -179,6 +179,7 @@ public class PaperCommand extends Command { @@ -23,10 +23,10 @@ index eecf27370..d704fc79c 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 b156f5428..c7c600b80 100644 +index 2004f7fbe1..7ecff4443a 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java -@@ -671,6 +671,7 @@ public class Chunk implements IChunkAccess { +@@ -679,6 +679,7 @@ public class Chunk implements IChunkAccess { while (iterator.hasNext()) { Entity entity1 = (Entity) iterator.next(); @@ -34,7 +34,7 @@ index b156f5428..c7c600b80 100644 if (entity1.getBoundingBox().c(axisalignedbb) && entity1 != entity) { if (predicate == null || predicate.test(entity1)) { -@@ -708,6 +709,7 @@ public class Chunk implements IChunkAccess { +@@ -716,6 +717,7 @@ public class Chunk implements IChunkAccess { while (iterator.hasNext()) { T entity = (T) iterator.next(); // CraftBukkit - decompile error @@ -42,7 +42,7 @@ index b156f5428..c7c600b80 100644 if ((entitytypes == null || entity.getEntityType() == entitytypes) && entity.getBoundingBox().c(axisalignedbb) && predicate.test(entity)) { list.add(entity); -@@ -729,6 +731,7 @@ public class Chunk implements IChunkAccess { +@@ -737,6 +739,7 @@ public class Chunk implements IChunkAccess { while (iterator.hasNext()) { T t0 = (T) iterator.next(); // CraftBukkit - decompile error @@ -51,7 +51,7 @@ index b156f5428..c7c600b80 100644 if (oclass.isInstance(t0) && t0.getBoundingBox().c(axisalignedbb) && (predicate == null || predicate.test(t0))) { // Spigot - instance check list.add(t0); diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index e761f7148..ca794328a 100644 +index e761f71487..ca794328a7 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -196,6 +196,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke @@ -63,7 +63,7 @@ index e761f7148..ca794328a 100644 public float getBukkitYaw() { return this.yaw; diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 224f6d151..ba0389f2f 100644 +index 3d5a50ddcc..12cdb0cc9a 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -904,7 +904,7 @@ public class WorldServer extends World { @@ -75,7 +75,7 @@ index 224f6d151..ba0389f2f 100644 if (entity instanceof EntityInsentient) { EntityInsentient entityinsentient = (EntityInsentient) entity; -@@ -1223,6 +1223,7 @@ public class WorldServer extends World { +@@ -1225,6 +1225,7 @@ public class WorldServer extends World { entity.origin = entity.getBukkitEntity().getLocation(); } // Paper end @@ -83,7 +83,7 @@ index 224f6d151..ba0389f2f 100644 new com.destroystokyo.paper.event.entity.EntityAddToWorldEvent(entity.getBukkitEntity()).callEvent(); // Paper - fire while valid } -@@ -1235,6 +1236,7 @@ public class WorldServer extends World { +@@ -1237,6 +1238,7 @@ public class WorldServer extends World { this.removeEntityFromChunk(entity); this.entitiesById.remove(entity.getId()); this.unregisterEntity(entity); @@ -92,7 +92,7 @@ index 224f6d151..ba0389f2f 100644 } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index a257dce8f..0fb47579f 100644 +index a257dce8f0..0fb47579f6 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -1010,6 +1010,7 @@ public class CraftWorld implements World { diff --git a/Spigot-Server-Patches/0280-Send-nearby-packets-from-world-player-list-not-serve.patch b/Spigot-Server-Patches/0280-Send-nearby-packets-from-world-player-list-not-serve.patch index ce0aadba9..42d8df364 100644 --- a/Spigot-Server-Patches/0280-Send-nearby-packets-from-world-player-list-not-serve.patch +++ b/Spigot-Server-Patches/0280-Send-nearby-packets-from-world-player-list-not-serve.patch @@ -1,11 +1,11 @@ -From cdec3794b84a3c3c819fecd813fc2dbabc1bd4c9 Mon Sep 17 00:00:00 2001 +From 5b1eeb8047141b4b62bdac06095b41e77a9a0f36 Mon Sep 17 00:00:00 2001 From: Mystiflow Date: Fri, 6 Jul 2018 13:21:30 +0100 Subject: [PATCH] Send nearby packets from world player list not server list diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java -index fd0f5c6f2..e46436623 100644 +index fd0f5c6f29..e46436623c 100644 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -923,8 +923,25 @@ public abstract class PlayerList { @@ -46,10 +46,10 @@ index fd0f5c6f2..e46436623 100644 double d5 = d1 - entityplayer.locY(); double d6 = d2 - entityplayer.locZ(); diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index ba0389f2f..1e8079f91 100644 +index 12cdb0cc9a..f12cadc735 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java -@@ -1269,7 +1269,7 @@ public class WorldServer extends World { +@@ -1271,7 +1271,7 @@ public class WorldServer extends World { } // CraftBukkit end this.globalEntityList.add(entitylightning); @@ -58,7 +58,7 @@ index ba0389f2f..1e8079f91 100644 } @Override -@@ -1401,7 +1401,7 @@ public class WorldServer extends World { +@@ -1403,7 +1403,7 @@ public class WorldServer extends World { BlockActionData blockactiondata = (BlockActionData) this.I.removeFirst(); if (this.a(blockactiondata)) { @@ -68,7 +68,7 @@ index ba0389f2f..1e8079f91 100644 } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 0fb47579f..bc151d8d2 100644 +index 0fb47579f6..bc151d8d25 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -2085,7 +2085,7 @@ public class CraftWorld implements World { diff --git a/Spigot-Server-Patches/0293-Improve-death-events.patch b/Spigot-Server-Patches/0293-Improve-death-events.patch index 19a3a4d44..4f7966afb 100644 --- a/Spigot-Server-Patches/0293-Improve-death-events.patch +++ b/Spigot-Server-Patches/0293-Improve-death-events.patch @@ -1,4 +1,4 @@ -From a37fd61973e5e77832a167141998b6d5e9ae5f72 Mon Sep 17 00:00:00 2001 +From 001436f06bc138cabc999f2070aaf5be26f0074b Mon Sep 17 00:00:00 2001 From: Phoenix616 Date: Tue, 21 Aug 2018 01:39:35 +0100 Subject: [PATCH] Improve death events @@ -15,7 +15,7 @@ items and experience which is otherwise only properly possible by using internal code. diff --git a/src/main/java/net/minecraft/server/CombatTracker.java b/src/main/java/net/minecraft/server/CombatTracker.java -index 6daa400d2..38fe29f8a 100644 +index 6daa400d27..38fe29f8a2 100644 --- a/src/main/java/net/minecraft/server/CombatTracker.java +++ b/src/main/java/net/minecraft/server/CombatTracker.java @@ -175,6 +175,7 @@ public class CombatTracker { @@ -27,7 +27,7 @@ index 6daa400d2..38fe29f8a 100644 int i = this.f ? 300 : 100; diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 845993bb4..16c55a9fa 100644 +index 845993bb4e..16c55a9fa0 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -1503,6 +1503,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke @@ -47,7 +47,7 @@ index 845993bb4..16c55a9fa 100644 protected void k(double d0, double d1, double d2) { diff --git a/src/main/java/net/minecraft/server/EntityArmorStand.java b/src/main/java/net/minecraft/server/EntityArmorStand.java -index 42b9a339e..8ad131e4f 100644 +index 42b9a339e9..8ad131e4fc 100644 --- a/src/main/java/net/minecraft/server/EntityArmorStand.java +++ b/src/main/java/net/minecraft/server/EntityArmorStand.java @@ -701,7 +701,8 @@ public class EntityArmorStand extends EntityLiving { @@ -61,7 +61,7 @@ index 42b9a339e..8ad131e4f 100644 } diff --git a/src/main/java/net/minecraft/server/EntityFox.java b/src/main/java/net/minecraft/server/EntityFox.java -index 2be6c7bde..82a32d5db 100644 +index 2be6c7bde9..82a32d5dbf 100644 --- a/src/main/java/net/minecraft/server/EntityFox.java +++ b/src/main/java/net/minecraft/server/EntityFox.java @@ -571,15 +571,25 @@ public class EntityFox extends EntityAnimal { @@ -94,7 +94,7 @@ index 2be6c7bde..82a32d5db 100644 public static boolean a(EntityFox entityfox, EntityLiving entityliving) { diff --git a/src/main/java/net/minecraft/server/EntityHorseChestedAbstract.java b/src/main/java/net/minecraft/server/EntityHorseChestedAbstract.java -index 80717ad9a..53aac5bcc 100644 +index 80717ad9ac..53aac5bccd 100644 --- a/src/main/java/net/minecraft/server/EntityHorseChestedAbstract.java +++ b/src/main/java/net/minecraft/server/EntityHorseChestedAbstract.java @@ -55,11 +55,19 @@ public abstract class EntityHorseChestedAbstract extends EntityHorseAbstract { @@ -119,7 +119,7 @@ index 80717ad9a..53aac5bcc 100644 public void b(NBTTagCompound nbttagcompound) { super.b(nbttagcompound); diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java -index fa097e055..eed3e7c58 100644 +index fa097e0551..eed3e7c58e 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -89,7 +89,7 @@ public abstract class EntityLiving extends Entity { @@ -279,7 +279,7 @@ index fa097e055..eed3e7c58 100644 return this.isBaby() ? (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.5F : (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F; } diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index 5e2e0674a..e6252e5f1 100644 +index a9a16eace9..52bbe4fc02 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -75,6 +75,10 @@ public class EntityPlayer extends EntityHuman implements ICrafting { @@ -293,7 +293,7 @@ index 5e2e0674a..e6252e5f1 100644 // CraftBukkit start public String displayName; -@@ -533,6 +537,15 @@ public class EntityPlayer extends EntityHuman implements ICrafting { +@@ -537,6 +541,15 @@ public class EntityPlayer extends EntityHuman implements ICrafting { String deathmessage = defaultMessage.getString(); org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, loot, deathmessage, keepInventory); @@ -309,7 +309,7 @@ index 5e2e0674a..e6252e5f1 100644 // SPIGOT-943 - only call if they have an inventory open if (this.activeContainer != this.defaultContainer) { -@@ -671,8 +684,17 @@ public class EntityPlayer extends EntityHuman implements ICrafting { +@@ -675,8 +688,17 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } } } @@ -330,7 +330,7 @@ index 5e2e0674a..e6252e5f1 100644 } } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftSound.java b/src/main/java/org/bukkit/craftbukkit/CraftSound.java -index 90fdf89c8..b761a41dc 100644 +index 90fdf89c81..b761a41dcd 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftSound.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftSound.java @@ -821,6 +821,22 @@ public enum CraftSound { @@ -357,7 +357,7 @@ index 90fdf89c8..b761a41dc 100644 this.minecraftKey = minecraftKey; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 352ef3669..a2bda708c 100644 +index 352ef3669d..a2bda708cd 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -1730,7 +1730,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -378,7 +378,7 @@ index 352ef3669..a2bda708c 100644 public void injectScaledMaxHealth(Collection collection, boolean force) { diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index f006b441a..39ce40bd5 100644 +index f006b441ad..39ce40bd58 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -749,9 +749,16 @@ public class CraftEventFactory { diff --git a/Spigot-Server-Patches/0305-Catch-JsonParseException-in-Entity-and-TE-names.patch b/Spigot-Server-Patches/0305-Catch-JsonParseException-in-Entity-and-TE-names.patch index cf91ae54c..a2b17f988 100644 --- a/Spigot-Server-Patches/0305-Catch-JsonParseException-in-Entity-and-TE-names.patch +++ b/Spigot-Server-Patches/0305-Catch-JsonParseException-in-Entity-and-TE-names.patch @@ -1,4 +1,4 @@ -From a802670c7c392d9a70dc8ac6b4d8523f0b02142d Mon Sep 17 00:00:00 2001 +From 53100d2c99d2a53b62adb36f41a95f7ff63cbb42 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 786712297..ef2a496ed 100644 +index 7867122974..ef2a496eda 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 786712297..ef2a496ed 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 16c55a9fa..4619f2c92 100644 +index 16c55a9fa0..4619f2c928 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 16c55a9fa..4619f2c92 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 670f8313a..d49e210a3 100644 +index 2a22bc6f3e..3a482466ec 100644 --- a/src/main/java/net/minecraft/server/MCUtil.java +++ b/src/main/java/net/minecraft/server/MCUtil.java -@@ -339,4 +339,19 @@ public final class MCUtil { +@@ -409,4 +409,19 @@ public final class MCUtil { return null; } } @@ -63,7 +63,7 @@ index 670f8313a..d49e210a3 100644 + } } diff --git a/src/main/java/net/minecraft/server/TileEntityBanner.java b/src/main/java/net/minecraft/server/TileEntityBanner.java -index 93911a825..d35604edb 100644 +index 93911a8251..d35604edb2 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 93911a825..d35604edb 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 473ec2cbd..ab6b86e4e 100644 +index 473ec2cbde..ab6b86e4e9 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 diff --git a/Spigot-Server-Patches/0315-Limit-lightning-strike-effect-distance.patch b/Spigot-Server-Patches/0315-Limit-lightning-strike-effect-distance.patch index 4ba180ef8..ff2e1e88c 100644 --- a/Spigot-Server-Patches/0315-Limit-lightning-strike-effect-distance.patch +++ b/Spigot-Server-Patches/0315-Limit-lightning-strike-effect-distance.patch @@ -1,11 +1,11 @@ -From 0b660f804b58ed6c574577d1fee517a40024cd4d Mon Sep 17 00:00:00 2001 +From f4e1ede0e866a8f95fcf9a7adf08311a6509edb2 Mon Sep 17 00:00:00 2001 From: Trigary Date: Fri, 14 Sep 2018 17:42:08 +0200 Subject: [PATCH] Limit lightning strike effect distance diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 487b0d5cd..b8789c8ec 100644 +index 487b0d5cd6..b8789c8ecc 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -242,6 +242,28 @@ public class PaperWorldConfig { @@ -38,7 +38,7 @@ index 487b0d5cd..b8789c8ec 100644 private void fixedInhabitedTime() { if (PaperConfig.version < 16) { diff --git a/src/main/java/net/minecraft/server/EntityLightning.java b/src/main/java/net/minecraft/server/EntityLightning.java -index 7c518983a..bdb534deb 100644 +index 7c518983a9..bdb534deb4 100644 --- a/src/main/java/net/minecraft/server/EntityLightning.java +++ b/src/main/java/net/minecraft/server/EntityLightning.java @@ -64,6 +64,17 @@ public class EntityLightning extends Entity { @@ -69,10 +69,10 @@ index 7c518983a..bdb534deb 100644 --this.lifeTicks; diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 1e8079f91..b4443f3a6 100644 +index f12cadc735..78a9b31891 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java -@@ -1269,7 +1269,7 @@ public class WorldServer extends World { +@@ -1271,7 +1271,7 @@ public class WorldServer extends World { } // CraftBukkit end this.globalEntityList.add(entitylightning); diff --git a/Spigot-Server-Patches/0317-Call-player-spectator-target-events.patch b/Spigot-Server-Patches/0317-Call-player-spectator-target-events.patch index ef5af83a8..3301668d8 100644 --- a/Spigot-Server-Patches/0317-Call-player-spectator-target-events.patch +++ b/Spigot-Server-Patches/0317-Call-player-spectator-target-events.patch @@ -1,11 +1,11 @@ -From baccdcbf7b3f1fc9ce3500295d5d40e6b85cc651 Mon Sep 17 00:00:00 2001 +From 6372e87abbe429925f311fbb2ce2d9acdf5a5eae Mon Sep 17 00:00:00 2001 From: Caleb Bassham Date: Fri, 28 Sep 2018 02:32:19 -0500 Subject: [PATCH] Call player spectator target events diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index e6252e5f1..8858bea04 100644 +index 52bbe4fc02..10ca229cb4 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -60,7 +60,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { @@ -17,7 +17,7 @@ index e6252e5f1..8858bea04 100644 public boolean worldChangeInvuln; private boolean cm; private void setHasSeenCredits(boolean has) { this.cm = has; } // Paper - OBFHELPER private final RecipeBookServer recipeBook; -@@ -1585,15 +1585,35 @@ public class EntityPlayer extends EntityHuman implements ICrafting { +@@ -1589,15 +1589,35 @@ public class EntityPlayer extends EntityHuman implements ICrafting { return (Entity) (this.spectatedEntity == null ? this : this.spectatedEntity); } @@ -58,7 +58,7 @@ index e6252e5f1..8858bea04 100644 } @Override -@@ -1601,7 +1621,6 @@ public class EntityPlayer extends EntityHuman implements ICrafting { +@@ -1605,7 +1625,6 @@ public class EntityPlayer extends EntityHuman implements ICrafting { if (this.portalCooldown > 0 && !this.worldChangeInvuln) { --this.portalCooldown; } diff --git a/Spigot-Server-Patches/0322-Reset-players-airTicks-on-respawn.patch b/Spigot-Server-Patches/0322-Reset-players-airTicks-on-respawn.patch index ff882fd25..f2363a35e 100644 --- a/Spigot-Server-Patches/0322-Reset-players-airTicks-on-respawn.patch +++ b/Spigot-Server-Patches/0322-Reset-players-airTicks-on-respawn.patch @@ -1,11 +1,11 @@ -From a1271937315bc0dc157ead606a5fd85836ba797f Mon Sep 17 00:00:00 2001 +From 655b742944b6011c3aa6bb1f915c073d75d46e8b Mon Sep 17 00:00:00 2001 From: GreenMeanie Date: Sat, 20 Oct 2018 22:34:02 -0400 Subject: [PATCH] Reset players airTicks on respawn diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 4619f2c92..03469c965 100644 +index 4619f2c928..03469c9657 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -2326,6 +2326,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke @@ -17,10 +17,10 @@ index 4619f2c92..03469c965 100644 return 300; } diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index 8858bea04..f2f34593b 100644 +index 10ca229cb4..f33580f8c5 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java -@@ -1861,6 +1861,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { +@@ -1865,6 +1865,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } this.setHealth(this.getMaxHealth()); diff --git a/Spigot-Server-Patches/0332-force-entity-dismount-during-teleportation.patch b/Spigot-Server-Patches/0332-force-entity-dismount-during-teleportation.patch index 9420fa473..14ab3b138 100644 --- a/Spigot-Server-Patches/0332-force-entity-dismount-during-teleportation.patch +++ b/Spigot-Server-Patches/0332-force-entity-dismount-during-teleportation.patch @@ -1,4 +1,4 @@ -From 9a59cfe70b2c3dceb979d50b8f89a269da141629 Mon Sep 17 00:00:00 2001 +From 21cc9d9b68ee8a9fda20da52a53f25e8108a4a40 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Thu, 15 Nov 2018 13:38:37 +0000 Subject: [PATCH] force entity dismount during teleportation @@ -20,7 +20,7 @@ this is going to be the best soultion all around. Improvements/suggestions welcome! diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 03469c965..db404e4cd 100644 +index 03469c9657..db404e4cd5 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -2027,12 +2027,15 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke @@ -72,7 +72,7 @@ index 03469c965..db404e4cd 100644 if (event.isCancelled()) { return false; diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java -index d6df01868..2edb99b63 100644 +index 308ac18f7e..584166f225 100644 --- a/src/main/java/net/minecraft/server/EntityHuman.java +++ b/src/main/java/net/minecraft/server/EntityHuman.java @@ -968,9 +968,11 @@ public abstract class EntityHuman extends EntityLiving { @@ -91,7 +91,7 @@ index d6df01868..2edb99b63 100644 } diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java -index eed3e7c58..4e64a80a8 100644 +index eed3e7c58e..4e64a80a8a 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -2735,11 +2735,13 @@ public abstract class EntityLiving extends Entity { @@ -112,10 +112,10 @@ index eed3e7c58..4e64a80a8 100644 this.a(entity); } diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index f2f34593b..83b7ac459 100644 +index f33580f8c5..68e12cf987 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java -@@ -1015,11 +1015,13 @@ public class EntityPlayer extends EntityHuman implements ICrafting { +@@ -1019,11 +1019,13 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } } diff --git a/Spigot-Server-Patches/0343-Workaround-for-vehicle-tracking-issue-on-disconnect.patch b/Spigot-Server-Patches/0343-Workaround-for-vehicle-tracking-issue-on-disconnect.patch index 9e21e7016..bd17a0bcc 100644 --- a/Spigot-Server-Patches/0343-Workaround-for-vehicle-tracking-issue-on-disconnect.patch +++ b/Spigot-Server-Patches/0343-Workaround-for-vehicle-tracking-issue-on-disconnect.patch @@ -1,14 +1,14 @@ -From ddc742b1592154f7339cf8c9c2370b0bb66c8d93 Mon Sep 17 00:00:00 2001 +From 2e30cfa761e3ef1b77286c72cdfc389d699dd8df Mon Sep 17 00:00:00 2001 From: connorhartley Date: Mon, 7 Jan 2019 14:43:48 -0600 Subject: [PATCH] Workaround for vehicle tracking issue on disconnect diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index f51893892..959e2c1c1 100644 +index d3bfb72e39..4d614b9ef1 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java -@@ -1290,6 +1290,13 @@ public class EntityPlayer extends EntityHuman implements ICrafting { +@@ -1294,6 +1294,13 @@ public class EntityPlayer extends EntityHuman implements ICrafting { public void n() { this.cq = true; this.ejectPassengers(); diff --git a/Spigot-Server-Patches/0358-Entity-getEntitySpawnReason.patch b/Spigot-Server-Patches/0358-Entity-getEntitySpawnReason.patch index 4669a5b3d..a2e92bf14 100644 --- a/Spigot-Server-Patches/0358-Entity-getEntitySpawnReason.patch +++ b/Spigot-Server-Patches/0358-Entity-getEntitySpawnReason.patch @@ -1,4 +1,4 @@ -From 0d84c8471a87f0c6581a3d2adcec70194f4bdef2 Mon Sep 17 00:00:00 2001 +From a96ad5506ec97cf42f230431261432fb88cdf57e Mon Sep 17 00:00:00 2001 From: Aikar Date: Sun, 24 Mar 2019 00:24:52 -0400 Subject: [PATCH] Entity#getEntitySpawnReason @@ -10,7 +10,7 @@ persistenting Living Entity, SPAWNER for spawners, or DEFAULT since data was not stored. diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index f8132a1fa..716d30b8d 100644 +index f8132a1fa4..716d30b8de 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -72,6 +72,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke @@ -59,7 +59,7 @@ index f8132a1fa..716d30b8d 100644 } catch (Throwable throwable) { diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java -index 9d715d891..49437f212 100644 +index 9d715d891d..49437f2124 100644 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -251,7 +251,7 @@ public abstract class PlayerList { @@ -72,10 +72,10 @@ index 9d715d891..49437f212 100644 }); diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index b4443f3a6..f8d7bba34 100644 +index 78a9b31891..7492284703 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java -@@ -996,6 +996,7 @@ public class WorldServer extends World { +@@ -997,6 +997,7 @@ public class WorldServer extends World { // CraftBukkit start private boolean addEntity0(Entity entity, CreatureSpawnEvent.SpawnReason spawnReason) { org.spigotmc.AsyncCatcher.catchOp("entity add"); // Spigot @@ -84,7 +84,7 @@ index b4443f3a6..f8d7bba34 100644 if (entity.valid) { MinecraftServer.LOGGER.error("Attempted Double World add on " + entity, new Throwable()); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -index 915ccb180..dfa15372b 100644 +index 915ccb1807..dfa15372b8 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -1051,5 +1051,10 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { diff --git a/Spigot-Server-Patches/0365-PlayerDeathEvent-getItemsToKeep.patch b/Spigot-Server-Patches/0365-PlayerDeathEvent-getItemsToKeep.patch index 06f16d0c5..a8370b837 100644 --- a/Spigot-Server-Patches/0365-PlayerDeathEvent-getItemsToKeep.patch +++ b/Spigot-Server-Patches/0365-PlayerDeathEvent-getItemsToKeep.patch @@ -1,4 +1,4 @@ -From c0b7aacc207555016590a0786d1f4449b78f77b2 Mon Sep 17 00:00:00 2001 +From 4539d1b910705487353d67cd2d680ee5657f706d Mon Sep 17 00:00:00 2001 From: Aikar Date: Wed, 27 Mar 2019 23:01:33 -0400 Subject: [PATCH] PlayerDeathEvent#getItemsToKeep @@ -8,10 +8,10 @@ Exposes a mutable array on items a player should keep on death Example Usage: https://gist.github.com/aikar/5bb202de6057a051a950ce1f29feb0b4 diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index 959e2c1c1..6483c4a0b 100644 +index 4d614b9ef1..77ad4774ec 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java -@@ -510,6 +510,46 @@ public class EntityPlayer extends EntityHuman implements ICrafting { +@@ -514,6 +514,46 @@ public class EntityPlayer extends EntityHuman implements ICrafting { }); } @@ -58,7 +58,7 @@ index 959e2c1c1..6483c4a0b 100644 @Override public void die(DamageSource damagesource) { boolean flag = this.world.getGameRules().getBoolean(GameRules.SHOW_DEATH_MESSAGES); -@@ -596,7 +636,12 @@ public class EntityPlayer extends EntityHuman implements ICrafting { +@@ -600,7 +640,12 @@ public class EntityPlayer extends EntityHuman implements ICrafting { this.dropExperience(); // we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory. if (!event.getKeepInventory()) { diff --git a/Spigot-Server-Patches/0373-Fix-issues-with-entity-loss-due-to-unloaded-chunks.patch b/Spigot-Server-Patches/0373-Fix-issues-with-entity-loss-due-to-unloaded-chunks.patch index 16be5eea4..9febc5ca0 100644 --- a/Spigot-Server-Patches/0373-Fix-issues-with-entity-loss-due-to-unloaded-chunks.patch +++ b/Spigot-Server-Patches/0373-Fix-issues-with-entity-loss-due-to-unloaded-chunks.patch @@ -1,4 +1,4 @@ -From 922ad8a3b70e9fc1a8d8c58d6081a050eef9e1d1 Mon Sep 17 00:00:00 2001 +From dedc72add5794be5eb8848f7fe4c6c525c55f6e6 Mon Sep 17 00:00:00 2001 From: Aikar Date: Fri, 28 Sep 2018 21:49:53 -0400 Subject: [PATCH] Fix issues with entity loss due to unloaded chunks @@ -19,7 +19,7 @@ This change ensures the chunks are always loaded when entities are added to the world, or a valid entity moves between chunks. diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index f8d7bba34..3c94aa48c 100644 +index 7492284703..4a648f88ba 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -703,7 +703,7 @@ public class WorldServer extends World { @@ -31,7 +31,7 @@ index f8d7bba34..3c94aa48c 100644 entity.inChunk = false; } else { this.getChunkAt(i, k).a(entity); -@@ -1028,7 +1028,7 @@ public class WorldServer extends World { +@@ -1029,7 +1029,7 @@ public class WorldServer extends World { return false; } // CraftBukkit end diff --git a/Spigot-Server-Patches/0374-Duplicate-UUID-Resolve-Option.patch b/Spigot-Server-Patches/0374-Duplicate-UUID-Resolve-Option.patch index 7d61dfdfd..e25e1b3fd 100644 --- a/Spigot-Server-Patches/0374-Duplicate-UUID-Resolve-Option.patch +++ b/Spigot-Server-Patches/0374-Duplicate-UUID-Resolve-Option.patch @@ -1,4 +1,4 @@ -From 0080550b42ff659ffcbaea501571e8c4208e4549 Mon Sep 17 00:00:00 2001 +From a83fe1ede08bcf43c4155c8469f7b8e2b2b59245 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 4ba72275b..572679e4d 100644 +index 4ba72275b9..572679e4d1 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 4ba72275b..572679e4d 100644 + } } diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index c7c600b80..64c327669 100644 +index 7ecff4443a..d9c53cdc4b 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java -@@ -391,6 +391,7 @@ public class Chunk implements IChunkAccess { +@@ -396,6 +396,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 c7c600b80..64c327669 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 716d30b8d..7c7cd851c 100644 +index 716d30b8de..7c7cd851c0 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -2743,6 +2743,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke @@ -105,7 +105,7 @@ index 716d30b8d..7c7cd851c 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 7edca1744..314c77767 100644 +index e93741a8e8..b3fa3bd874 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java @@ -1,6 +1,7 @@ @@ -134,7 +134,7 @@ index 7edca1744..314c77767 100644 import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionException; import java.util.concurrent.Executor; -@@ -602,19 +606,55 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -631,19 +635,55 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { for (int j = 0; j < i; ++j) { List entityslice = aentityslice[j]; // Spigot @@ -201,7 +201,7 @@ index 7edca1744..314c77767 100644 if (list == null) { list = Lists.newArrayList(new Entity[]{entity}); } else { -@@ -622,6 +662,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -651,6 +691,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { } } } @@ -210,7 +210,7 @@ index 7edca1744..314c77767 100644 if (list != null) { diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 3c94aa48c..f973b0799 100644 +index 4a648f88ba..36d5466138 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; @@ -222,7 +222,7 @@ index 3c94aa48c..f973b0799 100644 import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Queues; -@@ -1055,8 +1057,23 @@ public class WorldServer extends World { +@@ -1056,8 +1058,23 @@ public class WorldServer extends World { if (entity1 == null) { return false; } else { @@ -248,7 +248,7 @@ index 3c94aa48c..f973b0799 100644 return true; } } -@@ -1195,7 +1212,7 @@ public class WorldServer extends World { +@@ -1197,7 +1214,7 @@ public class WorldServer extends World { } Entity old = this.entitiesByUUID.put(entity.getUniqueID(), entity); diff --git a/Spigot-Server-Patches/0376-Configurable-Keep-Spawn-Loaded-range-per-world.patch b/Spigot-Server-Patches/0376-Configurable-Keep-Spawn-Loaded-range-per-world.patch index 4e5c328b5..6886fa330 100644 --- a/Spigot-Server-Patches/0376-Configurable-Keep-Spawn-Loaded-range-per-world.patch +++ b/Spigot-Server-Patches/0376-Configurable-Keep-Spawn-Loaded-range-per-world.patch @@ -1,4 +1,4 @@ -From 3254c8c658ade5ab399d1d63b6d3402a48e8cc6e Mon Sep 17 00:00:00 2001 +From c5d691e244cfd8140cea50a7c15406bceceb97c7 Mon Sep 17 00:00:00 2001 From: Aikar Date: Sat, 13 Sep 2014 23:14:43 -0400 Subject: [PATCH] Configurable Keep Spawn Loaded range per world @@ -6,7 +6,7 @@ Subject: [PATCH] Configurable Keep Spawn Loaded range per world This lets you disable it for some worlds and lower it for others. diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 572679e4d..071e5e7f7 100644 +index 572679e4d1..071e5e7f72 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -481,4 +481,10 @@ public class PaperWorldConfig { @@ -21,7 +21,7 @@ index 572679e4d..071e5e7f7 100644 + } } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 3ede5ce2a..eaa26e1a5 100644 +index 3ede5ce2a6..eaa26e1a50 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -586,6 +586,14 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant 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 d704fc79c..09efbf725 100644 +index d704fc79c0..09efbf7250 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 d704fc79c..09efbf725 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 a3ef6dba7..0b43e4eb4 100644 +index 3ef7e4561f..35153af515 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 a3ef6dba7..0b43e4eb4 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 d49e210a3..25a87c2d3 100644 +index 3a482466ec..b6aeca05f7 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 d49e210a3..25a87c2d3 100644 import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executor; -@@ -354,4 +364,170 @@ public final class MCUtil { +@@ -424,4 +434,170 @@ public final class MCUtil { return null; } @@ -399,7 +399,7 @@ index d49e210a3..25a87c2d3 100644 + } } diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java -index 3c6fe0596..43d9a5634 100644 +index 3093154bb7..3a0f0314b2 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 3c6fe0596..43d9a5634 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 314c77767..c17a53915 100644 +index b3fa3bd874..803fda511f 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 314c77767..c17a53915 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 77bb6b092..7a8397815 100644 +index 77bb6b092a..7a8397815a 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> { diff --git a/Spigot-Server-Patches/0382-incremental-chunk-saving.patch b/Spigot-Server-Patches/0382-incremental-chunk-saving.patch index 16b14f31c..487c226fa 100644 --- a/Spigot-Server-Patches/0382-incremental-chunk-saving.patch +++ b/Spigot-Server-Patches/0382-incremental-chunk-saving.patch @@ -1,11 +1,11 @@ -From 522dba5da6503c5a65909606ade341f964ba4fdc Mon Sep 17 00:00:00 2001 +From 42b7bda5cbafcb1c1ac04c305d09a038e5b9f435 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Sun, 9 Jun 2019 03:53:22 +0100 Subject: [PATCH] incremental chunk saving diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 071e5e7f7..486761521 100644 +index 071e5e7f72..4867615215 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -487,4 +487,19 @@ public class PaperWorldConfig { @@ -29,7 +29,7 @@ index 071e5e7f7..486761521 100644 + } } diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 64c327669..14ec31f0a 100644 +index d9c53cdc4b..76e87c211b 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -42,7 +42,7 @@ public class Chunk implements IChunkAccess { @@ -42,10 +42,10 @@ index 64c327669..14ec31f0a 100644 private long inhabitedTime; @Nullable diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java -index 0b43e4eb4..99ce73c45 100644 +index 35153af515..191b2759a0 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java -@@ -340,6 +340,15 @@ public class ChunkProviderServer extends IChunkProvider { +@@ -436,6 +436,15 @@ public class ChunkProviderServer extends IChunkProvider { } // Paper - Timings } @@ -62,7 +62,7 @@ index 0b43e4eb4..99ce73c45 100644 public void close() throws IOException { // CraftBukkit start diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index eaa26e1a5..6fa08c60b 100644 +index eaa26e1a50..6fa08c60bd 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -168,6 +168,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant 100) { // Spigot +diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java +index 3a0f0314b2..c91312facf 100644 +--- a/src/main/java/net/minecraft/server/PlayerChunk.java ++++ b/src/main/java/net/minecraft/server/PlayerChunk.java +@@ -40,6 +40,9 @@ public class PlayerChunk { + + private final PlayerChunkMap chunkMap; // Paper + ++ long lastAutoSaveTime; // Paper - incremental autosave ++ long inactiveTimeStart; // Paper - incremental autosave ++ + public PlayerChunk(ChunkCoordIntPair chunkcoordintpair, int i, LightEngine lightengine, PlayerChunk.c playerchunk_c, PlayerChunk.d playerchunk_d) { + this.statusFutures = new AtomicReferenceArray(PlayerChunk.CHUNK_STATUSES.size()); + this.fullChunkFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE; +@@ -376,7 +379,19 @@ public class PlayerChunk { + boolean flag2 = playerchunk_state.isAtLeast(PlayerChunk.State.BORDER); + boolean flag3 = playerchunk_state1.isAtLeast(PlayerChunk.State.BORDER); + ++ boolean prevHasBeenLoaded = this.hasBeenLoaded; // Paper + this.hasBeenLoaded |= flag3; ++ // Paper start - incremental autosave ++ if (this.hasBeenLoaded & !prevHasBeenLoaded) { ++ long timeSinceAutoSave = this.inactiveTimeStart - this.lastAutoSaveTime; ++ if (timeSinceAutoSave < 0) { ++ // safest bet is to assume autosave is needed here ++ timeSinceAutoSave = this.chunkMap.world.paperConfig.autoSavePeriod; ++ } ++ this.lastAutoSaveTime = this.chunkMap.world.getTime() - timeSinceAutoSave; ++ this.chunkMap.autoSaveQueue.add(this); ++ } ++ // Paper end + if (!flag2 && flag3) { + // Paper start - cache ticking ready status + int expectCreateCount = ++this.fullChunkCreateCount; +@@ -490,8 +505,32 @@ public class PlayerChunk { + } + + public void m() { ++ boolean prev = this.hasBeenLoaded; // Paper ++ this.hasBeenLoaded = getChunkState(this.ticketLevel).isAtLeast(PlayerChunk.State.BORDER); ++ // Paper start - incremental autosave ++ if (prev != this.hasBeenLoaded) { ++ if (this.hasBeenLoaded) { ++ long timeSinceAutoSave = this.inactiveTimeStart - this.lastAutoSaveTime; ++ if (timeSinceAutoSave < 0) { ++ // safest bet is to assume autosave is needed here ++ timeSinceAutoSave = this.chunkMap.world.paperConfig.autoSavePeriod; ++ } ++ this.lastAutoSaveTime = this.chunkMap.world.getTime() - timeSinceAutoSave; ++ this.chunkMap.autoSaveQueue.add(this); ++ } else { ++ this.inactiveTimeStart = this.chunkMap.world.getTime(); ++ this.chunkMap.autoSaveQueue.remove(this); ++ } ++ } ++ // Paper end ++ } ++ ++ // Paper start - incremental autosave ++ public boolean setHasBeenLoaded() { + this.hasBeenLoaded = getChunkState(this.ticketLevel).isAtLeast(PlayerChunk.State.BORDER); ++ return this.hasBeenLoaded; + } ++ // Paper end + + public void a(ProtoChunkExtension protochunkextension) { + for (int i = 0; i < this.statusFutures.length(); ++i) { diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index c17a53915..3a02b6269 100644 +index 803fda511f..40d80f3810 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java -@@ -302,6 +302,36 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -331,6 +331,64 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { } -+ // Paper start - derived from below ++ // Paper start - incremental autosave ++ final it.unimi.dsi.fastutil.objects.ObjectRBTreeSet autoSaveQueue = new it.unimi.dsi.fastutil.objects.ObjectRBTreeSet<>((playerchunk1, playerchunk2) -> { ++ int timeCompare = Long.compare(playerchunk1.lastAutoSaveTime, playerchunk2.lastAutoSaveTime); ++ if (timeCompare != 0) { ++ return timeCompare; ++ } ++ ++ return Long.compare(MCUtil.getCoordinateKey(playerchunk1.location), MCUtil.getCoordinateKey(playerchunk2.location)); ++ }); ++ + protected void saveIncrementally() { + int savedThisTick = 0; -+ for (PlayerChunk playerchunk : visibleChunks.values()) { -+ if (playerchunk.hasBeenLoaded()) { ++ // optimized since we search far less chunks to hit ones that need to be saved ++ List reschedule = new ArrayList<>(this.world.paperConfig.maxAutoSaveChunksPerTick); ++ long currentTick = this.world.getTime(); ++ long maxSaveTime = currentTick - this.world.paperConfig.autoSavePeriod; + -+ IChunkAccess ichunkaccess = (IChunkAccess) playerchunk.getChunkSave().getNow(null); // CraftBukkit - decompile error ++ for (Iterator iterator = this.autoSaveQueue.iterator(); iterator.hasNext();) { ++ PlayerChunk playerchunk = iterator.next(); ++ if (playerchunk.lastAutoSaveTime > maxSaveTime) { ++ break; ++ } + ++ iterator.remove(); + -+ if (ichunkaccess instanceof ProtoChunkExtension || ichunkaccess instanceof Chunk) { -+ boolean shouldSave = true; ++ IChunkAccess ichunkaccess = playerchunk.getChunkSave().getNow(null); ++ if (ichunkaccess instanceof Chunk) { ++ boolean shouldSave = ((Chunk)ichunkaccess).lastSaved <= maxSaveTime; + -+ if (ichunkaccess instanceof Chunk) { -+ shouldSave = ((Chunk) ichunkaccess).lastSaved + world.paperConfig.autoSavePeriod <= world.getTime(); ++ if (shouldSave && this.saveChunk(ichunkaccess)) { ++ ++savedThisTick; ++ ++ if (!playerchunk.setHasBeenLoaded()) { ++ // do not fall through to reschedule logic ++ playerchunk.inactiveTimeStart = currentTick; ++ if (savedThisTick >= this.world.paperConfig.maxAutoSaveChunksPerTick) { ++ break; ++ } ++ continue; + } -+ -+ if (shouldSave && this.saveChunk(ichunkaccess)) { -+ ++savedThisTick; -+ playerchunk.m(); -+ } -+ } -+ -+ if (savedThisTick >= world.paperConfig.maxAutoSaveChunksPerTick) { -+ return; + } + } ++ ++ reschedule.add(playerchunk); ++ ++ if (savedThisTick >= this.world.paperConfig.maxAutoSaveChunksPerTick) { ++ break; ++ } ++ } ++ ++ for (int i = 0, len = reschedule.size(); i < len; ++i) { ++ PlayerChunk playerchunk = reschedule.get(i); ++ playerchunk.lastAutoSaveTime = this.world.getTime(); ++ this.autoSaveQueue.add(playerchunk); + } + } -+ // paper end ++ // Paper end + protected void save(boolean flag) { if (flag) { List list = (List) this.visibleChunks.values().stream().filter(PlayerChunk::hasBeenLoaded).peek(PlayerChunk::m).collect(Collectors.toList()); +@@ -441,6 +499,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { + + this.world.unloadChunk(chunk); + } ++ this.autoSaveQueue.remove(playerchunk); // Paper + + this.lightEngine.a(ichunkaccess.getPos()); + this.lightEngine.queueUpdate(); +@@ -622,6 +681,8 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { + playerchunk.a(new ProtoChunkExtension(chunk)); + } + ++ chunk.setLastSaved(this.world.getTime() - 1); // Paper - avoid autosaving newly generated/loaded chunks ++ + chunk.a(() -> { + return PlayerChunk.getChunkState(playerchunk.getTicketLevel()); + }); diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 9be58e785..7bf0b8708 100644 +index 32da4eb4e0..fae30a1c1b 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -810,11 +810,44 @@ public class WorldServer extends World { diff --git a/Spigot-Server-Patches/0384-Fix-World-isChunkGenerated-calls.patch b/Spigot-Server-Patches/0384-Fix-World-isChunkGenerated-calls.patch index 10d84763e..24c5a015a 100644 --- a/Spigot-Server-Patches/0384-Fix-World-isChunkGenerated-calls.patch +++ b/Spigot-Server-Patches/0384-Fix-World-isChunkGenerated-calls.patch @@ -1,4 +1,4 @@ -From 3edbd083e20ae90b37ce5ab04b6108c4cf7fac21 Mon Sep 17 00:00:00 2001 +From 778b5824bbdcb4d38ddddc037e4687ba6ae2aebd Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Sat, 15 Jun 2019 08:54:33 -0700 Subject: [PATCH] Fix World#isChunkGenerated calls @@ -8,19 +8,19 @@ This patch also adds a chunk status cache on region files (note that its only purpose is to cache the status on DISK) diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java -index 99ce73c45..761399e28 100644 +index 191b2759a0..9e75647953 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java @@ -28,7 +28,7 @@ public class ChunkProviderServer extends IChunkProvider { private final WorldServer world; - private final Thread serverThread; + public final Thread serverThread; // Paper - private -> public private final LightEngineThreaded lightEngine; - private final ChunkProviderServer.a serverThreadQueue; + public final ChunkProviderServer.a serverThreadQueue; // Paper private -> public public final PlayerChunkMap playerChunkMap; private final WorldPersistentData worldPersistentData; private long lastTickTime; -@@ -109,6 +109,21 @@ public class ChunkProviderServer extends IChunkProvider { +@@ -205,6 +205,21 @@ public class ChunkProviderServer extends IChunkProvider { return playerChunk.getFullChunk(); } @@ -43,7 +43,7 @@ index 99ce73c45..761399e28 100644 @Nullable diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java -index 6371f2f5b..961228e9d 100644 +index 6371f2f5b1..961228e9df 100644 --- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java +++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java @@ -391,6 +391,17 @@ public class ChunkRegionLoader { @@ -65,7 +65,7 @@ index 6371f2f5b..961228e9d 100644 if (nbttagcompound != null) { ChunkStatus chunkstatus = ChunkStatus.a(nbttagcompound.getCompound("Level").getString("Status")); diff --git a/src/main/java/net/minecraft/server/ChunkStatus.java b/src/main/java/net/minecraft/server/ChunkStatus.java -index efdf611e6..134a4f0b7 100644 +index efdf611e66..134a4f0b7d 100644 --- a/src/main/java/net/minecraft/server/ChunkStatus.java +++ b/src/main/java/net/minecraft/server/ChunkStatus.java @@ -176,6 +176,7 @@ public class ChunkStatus { @@ -95,7 +95,7 @@ index efdf611e6..134a4f0b7 100644 return (ChunkStatus) IRegistry.CHUNK_STATUS.get(MinecraftKey.a(s)); } diff --git a/src/main/java/net/minecraft/server/IChunkLoader.java b/src/main/java/net/minecraft/server/IChunkLoader.java -index f0a052eec..2f95174fc 100644 +index f0a052eec2..2f95174fcc 100644 --- a/src/main/java/net/minecraft/server/IChunkLoader.java +++ b/src/main/java/net/minecraft/server/IChunkLoader.java @@ -8,7 +8,7 @@ import javax.annotation.Nullable; @@ -108,10 +108,10 @@ index f0a052eec..2f95174fc 100644 @Nullable private PersistentStructureLegacy c; diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java -index 43d9a5634..6f2cca07e 100644 +index c91312facf..5108d3ee98 100644 --- a/src/main/java/net/minecraft/server/PlayerChunk.java +++ b/src/main/java/net/minecraft/server/PlayerChunk.java -@@ -70,6 +70,19 @@ public class PlayerChunk { +@@ -114,6 +114,19 @@ public class PlayerChunk { Either either = (Either) statusFuture.getNow(null); return either == null ? null : (Chunk) either.left().orElse(null); } @@ -132,10 +132,10 @@ index 43d9a5634..6f2cca07e 100644 public CompletableFuture> getStatusFutureUnchecked(ChunkStatus chunkstatus) { diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index 3a02b6269..6257eafe0 100644 +index 40d80f3810..6c4804232a 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java -@@ -907,11 +907,61 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -967,12 +967,62 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { } @Nullable @@ -165,8 +165,8 @@ index 3a02b6269..6257eafe0 100644 + RegionFile regionFile = this.getIOWorker().getRegionFileCache().getRegionFileIfLoaded(chunkPos); + + return regionFile == null ? null : regionFile.getStatusIfCached(chunkPos.x, chunkPos.z); -+ } -+ + } + + public ChunkStatus getChunkStatusOnDisk(ChunkCoordIntPair chunkPos) throws IOException { + RegionFile regionFile = this.getIOWorker().getRegionFileCache().getFile(chunkPos, false); + @@ -194,13 +194,14 @@ index 3a02b6269..6257eafe0 100644 + public IChunkAccess getUnloadingChunk(int chunkX, int chunkZ) { + PlayerChunk chunkHolder = this.pendingUnload.get(ChunkCoordIntPair.pair(chunkX, chunkZ)); + return chunkHolder == null ? null : chunkHolder.getAvailableChunkNow(); - } ++ } + // Paper end - ++ boolean isOutsideOfRange(ChunkCoordIntPair chunkcoordintpair) { // Spigot start + return isOutsideOfRange(chunkcoordintpair, false); diff --git a/src/main/java/net/minecraft/server/RegionFile.java b/src/main/java/net/minecraft/server/RegionFile.java -index 6b543f89d..d37abf2cf 100644 +index 6b543f89d4..d37abf2cf3 100644 --- a/src/main/java/net/minecraft/server/RegionFile.java +++ b/src/main/java/net/minecraft/server/RegionFile.java @@ -36,6 +36,30 @@ public class RegionFile implements AutoCloseable { @@ -249,7 +250,7 @@ index 6b543f89d..d37abf2cf 100644 this.c(); } finally { diff --git a/src/main/java/net/minecraft/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java -index b3d1bb5fd..e07ae9854 100644 +index b3d1bb5fd8..e07ae98540 100644 --- a/src/main/java/net/minecraft/server/RegionFileCache.java +++ b/src/main/java/net/minecraft/server/RegionFileCache.java @@ -18,7 +18,14 @@ public final class RegionFileCache implements AutoCloseable { @@ -279,7 +280,7 @@ index b3d1bb5fd..e07ae9854 100644 throwable = throwable1; throw throwable1; diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 9787d5332..f56ec3d34 100644 +index 9787d53326..f56ec3d341 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -18,6 +18,7 @@ import java.util.Objects; diff --git a/Spigot-Server-Patches/0387-Use-ChunkStatus-cache-when-saving-protochunks.patch b/Spigot-Server-Patches/0387-Use-ChunkStatus-cache-when-saving-protochunks.patch index b655384fc..9a54c0ca1 100644 --- a/Spigot-Server-Patches/0387-Use-ChunkStatus-cache-when-saving-protochunks.patch +++ b/Spigot-Server-Patches/0387-Use-ChunkStatus-cache-when-saving-protochunks.patch @@ -1,4 +1,4 @@ -From 81ca8a38e7ed63416c92b49cfcabeba9ed3edc1c Mon Sep 17 00:00:00 2001 +From e602e81e6efe942af77eebd833748d97b5ad9e9b Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Sat, 22 Jun 2019 04:20:47 -0700 Subject: [PATCH] Use ChunkStatus cache when saving protochunks @@ -7,10 +7,10 @@ The cache should contain the chunk status when saving. If not it will load it. diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index 6257eafe0..4e9edd759 100644 +index 6c4804232a..8bd212388a 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java -@@ -783,8 +783,10 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -843,8 +843,10 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { NBTTagCompound nbttagcompound; if (chunkstatus.getType() != ChunkStatus.Type.LEVELCHUNK) { diff --git a/Spigot-Server-Patches/0388-Anti-Xray.patch b/Spigot-Server-Patches/0388-Anti-Xray.patch index 31a6e7ae9..2dd2164ca 100644 --- a/Spigot-Server-Patches/0388-Anti-Xray.patch +++ b/Spigot-Server-Patches/0388-Anti-Xray.patch @@ -1,11 +1,11 @@ -From 59d051b8d575a77e737688f5abc99fdc894e92f6 Mon Sep 17 00:00:00 2001 +From 74d8489304e14d2b6ffd00976fc48142492ca132 Mon Sep 17 00:00:00 2001 From: stonar96 Date: Mon, 20 Aug 2018 03:03:58 +0200 Subject: [PATCH] Anti-Xray diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 486761521..df24e3297 100644 +index 4867615215..df24e3297b 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -1,7 +1,11 @@ @@ -66,7 +66,7 @@ index 486761521..df24e3297 100644 } diff --git a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockController.java b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockController.java new file mode 100644 -index 000000000..f7e376ce6 +index 0000000000..f7e376ce6a --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockController.java @@ -0,0 +1,46 @@ @@ -118,7 +118,7 @@ index 000000000..f7e376ce6 +} diff --git a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java new file mode 100644 -index 000000000..23626bef3 +index 0000000000..23626bef3a --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java @@ -0,0 +1,782 @@ @@ -906,7 +906,7 @@ index 000000000..23626bef3 +} diff --git a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketInfo.java b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketInfo.java new file mode 100644 -index 000000000..a68bace35 +index 0000000000..a68bace353 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketInfo.java @@ -0,0 +1,81 @@ @@ -993,7 +993,7 @@ index 000000000..a68bace35 +} diff --git a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketInfoAntiXray.java b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketInfoAntiXray.java new file mode 100644 -index 000000000..067dfb2f1 +index 0000000000..067dfb2f14 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketInfoAntiXray.java @@ -0,0 +1,31 @@ @@ -1030,7 +1030,7 @@ index 000000000..067dfb2f1 +} diff --git a/src/main/java/com/destroystokyo/paper/antixray/DataBitsReader.java b/src/main/java/com/destroystokyo/paper/antixray/DataBitsReader.java new file mode 100644 -index 000000000..cc586827a +index 0000000000..cc586827aa --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/antixray/DataBitsReader.java @@ -0,0 +1,56 @@ @@ -1092,7 +1092,7 @@ index 000000000..cc586827a +} diff --git a/src/main/java/com/destroystokyo/paper/antixray/DataBitsWriter.java b/src/main/java/com/destroystokyo/paper/antixray/DataBitsWriter.java new file mode 100644 -index 000000000..37093419c +index 0000000000..37093419cf --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/antixray/DataBitsWriter.java @@ -0,0 +1,84 @@ @@ -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 14ec31f0a..863a2222f 100644 +index 76e87c211b..3fdcc2e5d4 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java -@@ -315,7 +315,7 @@ public class Chunk implements IChunkAccess { +@@ -320,7 +320,7 @@ public class Chunk implements IChunkAccess { return null; } @@ -1194,7 +1194,7 @@ index 14ec31f0a..863a2222f 100644 } diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java -index 961228e9d..a950ad801 100644 +index 961228e9df..a950ad801d 100644 --- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java +++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java @@ -57,7 +57,7 @@ public class ChunkRegionLoader { @@ -1216,7 +1216,7 @@ index 961228e9d..a950ad801 100644 protochunk.a(biomestorage); object = protochunk; diff --git a/src/main/java/net/minecraft/server/ChunkSection.java b/src/main/java/net/minecraft/server/ChunkSection.java -index 0d5deee36..4526527ac 100644 +index 0d5deee365..4526527aca 100644 --- a/src/main/java/net/minecraft/server/ChunkSection.java +++ b/src/main/java/net/minecraft/server/ChunkSection.java @@ -6,21 +6,31 @@ public class ChunkSection { @@ -1255,7 +1255,7 @@ index 0d5deee36..4526527ac 100644 public IBlockData getType(int i, int j, int k) { diff --git a/src/main/java/net/minecraft/server/DataPaletteBlock.java b/src/main/java/net/minecraft/server/DataPaletteBlock.java -index 2c1d1b1a5..44aed6727 100644 +index 2c1d1b1a55..44aed67274 100644 --- a/src/main/java/net/minecraft/server/DataPaletteBlock.java +++ b/src/main/java/net/minecraft/server/DataPaletteBlock.java @@ -3,6 +3,7 @@ package net.minecraft.server; @@ -1377,7 +1377,7 @@ index 2c1d1b1a5..44aed6727 100644 if (this.h == this.b) { diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java -index e156804f7..96a785af2 100644 +index e156804f7a..96a785af27 100644 --- a/src/main/java/net/minecraft/server/NetworkManager.java +++ b/src/main/java/net/minecraft/server/NetworkManager.java @@ -42,7 +42,7 @@ public class NetworkManager extends SimpleChannelInboundHandler> { @@ -1440,7 +1440,7 @@ index e156804f7..96a785af2 100644 public void a() { this.o(); diff --git a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java -index 47710067a..ef7ade797 100644 +index 47710067a6..ef7ade797b 100644 --- a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java +++ b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java @@ -1,5 +1,6 @@ @@ -1533,10 +1533,10 @@ index 47710067a..ef7ade797 100644 } diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java -index 6f2cca07e..7a1578afa 100644 +index 5108d3ee98..b556a8fefa 100644 --- a/src/main/java/net/minecraft/server/PlayerChunk.java +++ b/src/main/java/net/minecraft/server/PlayerChunk.java -@@ -176,6 +176,11 @@ public class PlayerChunk { +@@ -220,6 +220,11 @@ public class PlayerChunk { World world = chunk.getWorld(); if (this.dirtyCount == 64) { @@ -1548,7 +1548,7 @@ index 6f2cca07e..7a1578afa 100644 this.s = -1; } -@@ -208,7 +213,7 @@ public class PlayerChunk { +@@ -252,7 +257,7 @@ public class PlayerChunk { this.a(world, blockposition); } } else if (this.dirtyCount == 64) { @@ -1558,10 +1558,10 @@ index 6f2cca07e..7a1578afa 100644 this.a(new PacketPlayOutMultiBlockChange(this.dirtyCount, this.dirtyBlocks, chunk), false); diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index 4e9edd759..6728e84b2 100644 +index 8bd212388a..be3dcf375b 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java -@@ -545,7 +545,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -603,7 +603,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { PlayerChunkMap.LOGGER.error("Couldn't load chunk {}", chunkcoordintpair, exception); } @@ -1570,7 +1570,7 @@ index 4e9edd759..6728e84b2 100644 }, this.executor); } -@@ -1260,7 +1260,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -1322,7 +1322,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { private void a(EntityPlayer entityplayer, Packet[] apacket, Chunk chunk) { if (apacket[0] == null) { @@ -1580,7 +1580,7 @@ index 4e9edd759..6728e84b2 100644 } diff --git a/src/main/java/net/minecraft/server/PlayerInteractManager.java b/src/main/java/net/minecraft/server/PlayerInteractManager.java -index e2e5c17c2..ce4340a47 100644 +index e2e5c17c24..ce4340a476 100644 --- a/src/main/java/net/minecraft/server/PlayerInteractManager.java +++ b/src/main/java/net/minecraft/server/PlayerInteractManager.java @@ -264,6 +264,8 @@ public class PlayerInteractManager { @@ -1593,7 +1593,7 @@ index e2e5c17c2..ce4340a47 100644 public void a(BlockPosition blockposition, PacketPlayInBlockDig.EnumPlayerDigType packetplayinblockdig_enumplayerdigtype, String s) { diff --git a/src/main/java/net/minecraft/server/ProtoChunk.java b/src/main/java/net/minecraft/server/ProtoChunk.java -index 39339fa27..f376e2106 100644 +index 39339fa275..f376e21068 100644 --- a/src/main/java/net/minecraft/server/ProtoChunk.java +++ b/src/main/java/net/minecraft/server/ProtoChunk.java @@ -45,16 +45,28 @@ public class ProtoChunk implements IChunkAccess { @@ -1636,7 +1636,7 @@ index 39339fa27..f376e2106 100644 return this.j[i]; diff --git a/src/main/java/net/minecraft/server/TicketType.java b/src/main/java/net/minecraft/server/TicketType.java -index a905a29e7..335b64435 100644 +index a905a29e75..335b644351 100644 --- a/src/main/java/net/minecraft/server/TicketType.java +++ b/src/main/java/net/minecraft/server/TicketType.java @@ -21,6 +21,7 @@ public class TicketType { @@ -1648,7 +1648,7 @@ index a905a29e7..335b64435 100644 public static TicketType a(String s, Comparator comparator) { return new TicketType<>(s, comparator, 0L); diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index d981dfd43..a1b777ac0 100644 +index d981dfd434..a1b777ac03 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -2,6 +2,8 @@ package net.minecraft.server; @@ -1685,7 +1685,7 @@ index d981dfd43..a1b777ac0 100644 if (iblockdata1 == null) { // CraftBukkit start - remove blockstate if failed diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java b/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java -index 7772d5900..4570ed999 100644 +index 7772d59005..4570ed9991 100644 --- a/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java +++ b/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java @@ -21,9 +21,11 @@ public final class CraftChunkData implements ChunkGenerator.ChunkData { diff --git a/Spigot-Server-Patches/0391-Mark-entities-as-being-ticked-when-notifying-navigat.patch b/Spigot-Server-Patches/0391-Mark-entities-as-being-ticked-when-notifying-navigat.patch index a3f3b3bb5..ab0ba895d 100644 --- a/Spigot-Server-Patches/0391-Mark-entities-as-being-ticked-when-notifying-navigat.patch +++ b/Spigot-Server-Patches/0391-Mark-entities-as-being-ticked-when-notifying-navigat.patch @@ -1,14 +1,14 @@ -From e618559325fb1981a036d690cbb52dbe40349ee7 Mon Sep 17 00:00:00 2001 +From 90d7d42ae7fae9a7933c728771736312bd08504c Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Sun, 28 Jul 2019 00:51:11 +0100 Subject: [PATCH] Mark entities as being ticked when notifying navigation diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 53172dac2..691ef0048 100644 +index e9d3424103..0f652e58e1 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java -@@ -1390,6 +1390,7 @@ public class WorldServer extends World { +@@ -1392,6 +1392,7 @@ public class WorldServer extends World { VoxelShape voxelshape1 = iblockdata1.getCollisionShape(this, blockposition); if (VoxelShapes.c(voxelshape, voxelshape1, OperatorBoolean.NOT_SAME)) { @@ -16,7 +16,7 @@ index 53172dac2..691ef0048 100644 Iterator iterator = this.navigators.iterator(); while (iterator.hasNext()) { -@@ -1400,6 +1401,7 @@ public class WorldServer extends World { +@@ -1402,6 +1403,7 @@ public class WorldServer extends World { } } diff --git a/Spigot-Server-Patches/0393-Avoid-hopper-searches-if-there-are-no-items.patch b/Spigot-Server-Patches/0393-Avoid-hopper-searches-if-there-are-no-items.patch index 95d45c3a4..9304763c8 100644 --- a/Spigot-Server-Patches/0393-Avoid-hopper-searches-if-there-are-no-items.patch +++ b/Spigot-Server-Patches/0393-Avoid-hopper-searches-if-there-are-no-items.patch @@ -1,4 +1,4 @@ -From 5977ff695cb879dc9a1d3d4c6a7a1a7e15a6800d Mon Sep 17 00:00:00 2001 +From 9bc42552b2b41e2263f1f39db6b9d0d3f819b91b 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 863a2222f..f2a04cb6a 100644 +index 3fdcc2e5d4..59d8a8719e 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,9 +28,9 @@ index 863a2222f..f2a04cb6a 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) { -@@ -430,6 +434,13 @@ public class Chunk implements IChunkAccess { - entity.chunkY = k; +@@ -436,6 +440,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); + // Paper start + if (entity instanceof EntityItem) { @@ -42,7 +42,7 @@ index 863a2222f..f2a04cb6a 100644 entity.entitySlice = this.entitySlices[k]; // Paper this.markDirty(); // Paper } -@@ -460,6 +471,11 @@ public class Chunk implements IChunkAccess { +@@ -466,6 +477,11 @@ public class Chunk implements IChunkAccess { if (!this.entitySlices[i].remove(entity)) { return; } @@ -54,7 +54,7 @@ index 863a2222f..f2a04cb6a 100644 entityCounts.decrement(entity.getMinecraftKeyString()); this.markDirty(); // Paper // Paper end -@@ -727,9 +743,29 @@ public class Chunk implements IChunkAccess { +@@ -735,9 +751,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 863a2222f..f2a04cb6a 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 498f38109..a2d1ef360 100644 +index 498f381099..a2d1ef3602 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 { diff --git a/Spigot-Server-Patches/0395-Asynchronous-chunk-IO-and-loading.patch b/Spigot-Server-Patches/0395-Asynchronous-chunk-IO-and-loading.patch index 986f5a1e2..f25e0fb05 100644 --- a/Spigot-Server-Patches/0395-Asynchronous-chunk-IO-and-loading.patch +++ b/Spigot-Server-Patches/0395-Asynchronous-chunk-IO-and-loading.patch @@ -1,4 +1,4 @@ -From cba242fa2b307d951063e3d724d73dd4cb1bfecd Mon Sep 17 00:00:00 2001 +From b2c12a10d2992373cd9bb7830bdb876772582175 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 @@ -121,7 +121,7 @@ tasks required to be executed by the chunk load task (i.e lighting and some poi tasks). diff --git a/src/main/java/co/aikar/timings/WorldTimingsHandler.java b/src/main/java/co/aikar/timings/WorldTimingsHandler.java -index 3a79cde59..8de6c4816 100644 +index 3a79cde595..8de6c4816c 100644 --- a/src/main/java/co/aikar/timings/WorldTimingsHandler.java +++ b/src/main/java/co/aikar/timings/WorldTimingsHandler.java @@ -63,6 +63,17 @@ public class WorldTimingsHandler { @@ -161,7 +161,7 @@ index 3a79cde59..8de6c4816 100644 public static Timing getTickList(WorldServer worldserver, String timingsType) { diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java -index 546a1cfe0..1d7d1ffbf 100644 +index 546a1cfe0a..1d7d1ffbf7 100644 --- a/src/main/java/com/destroystokyo/paper/PaperConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java @@ -1,5 +1,6 @@ @@ -237,7 +237,7 @@ index 546a1cfe0..1d7d1ffbf 100644 + } } diff --git a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java -index 23626bef3..1edcecd2e 100644 +index 23626bef3a..1edcecd2ee 100644 --- a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java +++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java @@ -9,6 +9,7 @@ import java.util.concurrent.Executors; @@ -318,7 +318,7 @@ index 23626bef3..1edcecd2e 100644 diff --git a/src/main/java/com/destroystokyo/paper/io/IOUtil.java b/src/main/java/com/destroystokyo/paper/io/IOUtil.java new file mode 100644 -index 000000000..5af0ac3d9 +index 0000000000..5af0ac3d9e --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/io/IOUtil.java @@ -0,0 +1,62 @@ @@ -386,7 +386,7 @@ index 000000000..5af0ac3d9 +} diff --git a/src/main/java/com/destroystokyo/paper/io/PaperFileIOThread.java b/src/main/java/com/destroystokyo/paper/io/PaperFileIOThread.java new file mode 100644 -index 000000000..4f10a8311 +index 0000000000..4f10a8311e --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/io/PaperFileIOThread.java @@ -0,0 +1,661 @@ @@ -1053,7 +1053,7 @@ index 000000000..4f10a8311 +} diff --git a/src/main/java/com/destroystokyo/paper/io/PrioritizedTaskQueue.java b/src/main/java/com/destroystokyo/paper/io/PrioritizedTaskQueue.java new file mode 100644 -index 000000000..78bd238f4 +index 0000000000..78bd238f4c --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/io/PrioritizedTaskQueue.java @@ -0,0 +1,276 @@ @@ -1335,7 +1335,7 @@ index 000000000..78bd238f4 +} diff --git a/src/main/java/com/destroystokyo/paper/io/QueueExecutorThread.java b/src/main/java/com/destroystokyo/paper/io/QueueExecutorThread.java new file mode 100644 -index 000000000..ee906b594 +index 0000000000..ee906b594b --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/io/QueueExecutorThread.java @@ -0,0 +1,241 @@ @@ -1582,7 +1582,7 @@ index 000000000..ee906b594 +} diff --git a/src/main/java/com/destroystokyo/paper/io/chunk/ChunkLoadTask.java b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkLoadTask.java new file mode 100644 -index 000000000..305da4786 +index 0000000000..305da47868 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkLoadTask.java @@ -0,0 +1,149 @@ @@ -1737,7 +1737,7 @@ index 000000000..305da4786 +} diff --git a/src/main/java/com/destroystokyo/paper/io/chunk/ChunkSaveTask.java b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkSaveTask.java new file mode 100644 -index 000000000..60312b85f +index 0000000000..60312b85f9 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkSaveTask.java @@ -0,0 +1,112 @@ @@ -1855,7 +1855,7 @@ index 000000000..60312b85f +} diff --git a/src/main/java/com/destroystokyo/paper/io/chunk/ChunkTask.java b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkTask.java new file mode 100644 -index 000000000..1dfa8abfd +index 0000000000..1dfa8abfd8 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkTask.java @@ -0,0 +1,40 @@ @@ -1901,7 +1901,7 @@ index 000000000..1dfa8abfd +} diff --git a/src/main/java/com/destroystokyo/paper/io/chunk/ChunkTaskManager.java b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkTaskManager.java new file mode 100644 -index 000000000..715a2dd8d +index 0000000000..715a2dd8d2 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkTaskManager.java @@ -0,0 +1,455 @@ @@ -2361,10 +2361,10 @@ index 000000000..715a2dd8d + +} diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java -index 761399e28..58299562e 100644 +index 9e75647953..e10035d461 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java -@@ -124,11 +124,137 @@ public class ChunkProviderServer extends IChunkProvider { +@@ -220,11 +220,137 @@ public class ChunkProviderServer extends IChunkProvider { return playerChunk.getAvailableChunkNow(); } @@ -2502,7 +2502,7 @@ index 761399e28..58299562e 100644 if (Thread.currentThread() != this.serverThread) { return (IChunkAccess) CompletableFuture.supplyAsync(() -> { return this.getChunkAt(i, j, chunkstatus, flag); -@@ -154,8 +280,13 @@ public class ChunkProviderServer extends IChunkProvider { +@@ -250,8 +376,13 @@ public class ChunkProviderServer extends IChunkProvider { CompletableFuture> completablefuture = this.getChunkFutureMainThread(i, j, chunkstatus, flag); if (!completablefuture.isDone()) { // Paper @@ -2516,7 +2516,7 @@ index 761399e28..58299562e 100644 this.world.timings.chunkAwait.stopTiming(); // Paper } // Paper ichunkaccess = (IChunkAccess) ((Either) completablefuture.join()).map((ichunkaccess1) -> { -@@ -651,11 +782,12 @@ public class ChunkProviderServer extends IChunkProvider { +@@ -747,11 +878,12 @@ public class ChunkProviderServer extends IChunkProvider { protected boolean executeNext() { // CraftBukkit start - process pending Chunk loadCallback() and unloadCallback() after each run task try { @@ -2531,7 +2531,7 @@ index 761399e28..58299562e 100644 } finally { playerChunkMap.callbackExecutor.run(); diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java -index a950ad801..26f1a4b09 100644 +index a950ad801d..26f1a4b095 100644 --- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java +++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java @@ -6,6 +6,7 @@ import it.unimi.dsi.fastutil.longs.LongOpenHashSet; @@ -2800,7 +2800,7 @@ index a950ad801..26f1a4b09 100644 nbttagcompound1.set("PostProcessing", a(ichunkaccess.l())); diff --git a/src/main/java/net/minecraft/server/ChunkStatus.java b/src/main/java/net/minecraft/server/ChunkStatus.java -index 134a4f0b7..88f167461 100644 +index 134a4f0b7d..88f1674616 100644 --- a/src/main/java/net/minecraft/server/ChunkStatus.java +++ b/src/main/java/net/minecraft/server/ChunkStatus.java @@ -153,6 +153,7 @@ public class ChunkStatus { @@ -2812,7 +2812,7 @@ index 134a4f0b7..88f167461 100644 return ChunkStatus.r.getInt(chunkstatus.c()); } diff --git a/src/main/java/net/minecraft/server/IAsyncTaskHandler.java b/src/main/java/net/minecraft/server/IAsyncTaskHandler.java -index 7e5ece9d5..cfe43e882 100644 +index 7e5ece9d50..cfe43e882e 100644 --- a/src/main/java/net/minecraft/server/IAsyncTaskHandler.java +++ b/src/main/java/net/minecraft/server/IAsyncTaskHandler.java @@ -91,7 +91,7 @@ public abstract class IAsyncTaskHandler implements Mailbox> getStatusFutureUnchecked(ChunkStatus chunkstatus) { -@@ -310,7 +322,7 @@ public class PlayerChunk { +@@ -354,7 +366,7 @@ public class PlayerChunk { ChunkStatus chunkstatus = getChunkStatus(this.oldTicketLevel); ChunkStatus chunkstatus1 = getChunkStatus(this.ticketLevel); boolean flag = this.oldTicketLevel <= PlayerChunkMap.GOLDEN_TICKET; @@ -3041,7 +3041,7 @@ index 7a1578afa..d26365eb1 100644 PlayerChunk.State playerchunk_state = getChunkState(this.oldTicketLevel); PlayerChunk.State playerchunk_state1 = getChunkState(this.ticketLevel); // CraftBukkit start -@@ -340,6 +352,12 @@ public class PlayerChunk { +@@ -384,6 +396,12 @@ public class PlayerChunk { } }); @@ -3055,7 +3055,7 @@ index 7a1578afa..d26365eb1 100644 completablefuture = (CompletableFuture) this.statusFutures.get(i); if (completablefuture != null) { diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index 6728e84b2..8ce6cf8ec 100644 +index be3dcf375b..9fa6d2b526 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java @@ -63,7 +63,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { @@ -3076,7 +3076,7 @@ index 6728e84b2..8ce6cf8ec 100644 private final File w; private final PlayerMap playerMap; public final Int2ObjectMap trackedEntities; -@@ -134,7 +134,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -163,7 +163,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { this.lightEngine = new LightEngineThreaded(ilightaccess, this, this.world.getWorldProvider().f(), threadedmailbox1, this.p.a(threadedmailbox1, false)); this.chunkDistanceManager = new PlayerChunkMap.a(executor, iasynctaskhandler); this.l = supplier; @@ -3085,7 +3085,7 @@ index 6728e84b2..8ce6cf8ec 100644 this.setViewDistance(i); } -@@ -181,7 +181,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -210,7 +210,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { } @Nullable @@ -3094,7 +3094,7 @@ index 6728e84b2..8ce6cf8ec 100644 return (PlayerChunk) this.visibleChunks.get(i); } -@@ -295,6 +295,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -324,6 +324,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { public void close() throws IOException { try { this.p.close(); @@ -3102,25 +3102,7 @@ index 6728e84b2..8ce6cf8ec 100644 this.m.close(); } finally { super.close(); -@@ -318,7 +319,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { - shouldSave = ((Chunk) ichunkaccess).lastSaved + world.paperConfig.autoSavePeriod <= world.getTime(); - } - -- if (shouldSave && this.saveChunk(ichunkaccess)) { -+ if (shouldSave && this.saveChunk(ichunkaccess, true)) { // Paper - async chunk io - ++savedThisTick; - playerchunk.m(); - } -@@ -350,7 +351,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { - return (IChunkAccess) completablefuture.join(); - }).filter((ichunkaccess) -> { - return ichunkaccess instanceof ProtoChunkExtension || ichunkaccess instanceof Chunk; -- }).filter(this::saveChunk).forEach((ichunkaccess) -> { -+ }).filter((chunk) -> this.saveChunk(chunk, true)).forEach((ichunkaccess) -> { // Paper - async io for chunk save - mutableboolean.setTrue(); - }); - } while (mutableboolean.isTrue()); -@@ -358,18 +359,20 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -415,7 +416,8 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { this.b(() -> { return true; }); @@ -3130,12 +3112,7 @@ index 6728e84b2..8ce6cf8ec 100644 PlayerChunkMap.LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", this.w.getName()); } else { this.visibleChunks.values().stream().filter(PlayerChunk::hasBeenLoaded).forEach((playerchunk) -> { - IChunkAccess ichunkaccess = (IChunkAccess) playerchunk.getChunkSave().getNow(null); // CraftBukkit - decompile error - - if (ichunkaccess instanceof ProtoChunkExtension || ichunkaccess instanceof Chunk) { -- this.saveChunk(ichunkaccess); -+ this.saveChunk(ichunkaccess, true); // Paper - playerchunk.m(); +@@ -427,6 +429,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { } }); @@ -3143,7 +3120,7 @@ index 6728e84b2..8ce6cf8ec 100644 } } -@@ -379,11 +382,15 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -436,11 +439,15 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { protected void unloadChunks(BooleanSupplier booleansupplier) { GameProfilerFiller gameprofilerfiller = this.world.getMethodProfiler(); @@ -3159,7 +3136,7 @@ index 6728e84b2..8ce6cf8ec 100644 } gameprofilerfiller.exit(); -@@ -423,6 +430,60 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -480,6 +487,60 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { } @@ -3220,7 +3197,7 @@ index 6728e84b2..8ce6cf8ec 100644 private void a(long i, PlayerChunk playerchunk) { CompletableFuture completablefuture = playerchunk.getChunkSave(); Consumer consumer = (ichunkaccess) -> { // CraftBukkit - decompile error -@@ -436,13 +497,20 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -493,7 +554,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { ((Chunk) ichunkaccess).setLoaded(false); } @@ -3229,20 +3206,21 @@ index 6728e84b2..8ce6cf8ec 100644 if (this.loadedChunks.remove(i) && ichunkaccess instanceof Chunk) { Chunk chunk = (Chunk) ichunkaccess; - this.world.unloadChunk(chunk); +@@ -501,6 +562,13 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { } + this.autoSaveQueue.remove(playerchunk); // Paper + try { + this.asyncSave(ichunkaccess); // Paper - async chunk saving + } catch (Throwable ex) { + LOGGER.fatal("Failed to prepare async save, attempting synchronous save", ex); -+ this.saveChunk(ichunkaccess, true); ++ this.saveChunk(ichunkaccess); + } + this.lightEngine.a(ichunkaccess.getPos()); this.lightEngine.queueUpdate(); this.worldLoadListener.a(ichunkaccess.getPos(), (ChunkStatus) null); -@@ -512,27 +580,32 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -570,27 +638,32 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { } } @@ -3290,7 +3268,7 @@ index 6728e84b2..8ce6cf8ec 100644 } catch (ReportedException reportedexception) { Throwable throwable = reportedexception.getCause(); -@@ -546,7 +619,27 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -604,7 +677,27 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { } return Either.left(new ProtoChunk(chunkcoordintpair, ChunkConverter.a, this.world)); // Paper - Anti-Xray @@ -3319,7 +3297,7 @@ index 6728e84b2..8ce6cf8ec 100644 } private CompletableFuture> b(PlayerChunk playerchunk, ChunkStatus chunkstatus) { -@@ -761,18 +854,43 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -821,18 +914,43 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { return this.u.get(); } @@ -3350,7 +3328,7 @@ index 6728e84b2..8ce6cf8ec 100644 public boolean saveChunk(IChunkAccess ichunkaccess) { - this.m.a(ichunkaccess.getPos()); + // Paper start - async param -+ return this.saveChunk(ichunkaccess, false); ++ return this.saveChunk(ichunkaccess, true); + } + public boolean saveChunk(IChunkAccess ichunkaccess, boolean async) { + try (co.aikar.timings.Timing ignored = this.world.timings.chunkSave.startTiming()) { @@ -3371,7 +3349,7 @@ index 6728e84b2..8ce6cf8ec 100644 ichunkaccess.setLastSaved(this.world.getTime()); ichunkaccess.setNeedsSaving(false); -@@ -783,28 +901,35 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -843,28 +961,35 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { NBTTagCompound nbttagcompound; if (chunkstatus.getType() != ChunkStatus.Type.LEVELCHUNK) { @@ -3409,7 +3387,7 @@ index 6728e84b2..8ce6cf8ec 100644 } protected void setViewDistance(int i) { -@@ -908,6 +1033,42 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -968,6 +1093,42 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { } } @@ -3452,7 +3430,7 @@ index 6728e84b2..8ce6cf8ec 100644 @Nullable public NBTTagCompound readChunkData(ChunkCoordIntPair chunkcoordintpair) throws IOException { // Paper - private -> public NBTTagCompound nbttagcompound = this.read(chunkcoordintpair); -@@ -930,33 +1091,55 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -990,33 +1151,55 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { // Paper start - chunk status cache "api" public ChunkStatus getChunkStatusOnDiskIfCached(ChunkCoordIntPair chunkPos) { @@ -3519,7 +3497,7 @@ index 6728e84b2..8ce6cf8ec 100644 } public IChunkAccess getUnloadingChunk(int chunkX, int chunkZ) { -@@ -965,6 +1148,39 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -1025,6 +1208,39 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { } // Paper end @@ -3559,7 +3537,7 @@ index 6728e84b2..8ce6cf8ec 100644 boolean isOutsideOfRange(ChunkCoordIntPair chunkcoordintpair) { // Spigot start return isOutsideOfRange(chunkcoordintpair, false); -@@ -1309,6 +1525,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -1371,6 +1587,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { } @@ -3568,7 +3546,7 @@ index 6728e84b2..8ce6cf8ec 100644 return this.m; } diff --git a/src/main/java/net/minecraft/server/RegionFile.java b/src/main/java/net/minecraft/server/RegionFile.java -index d37abf2cf..df728e2c0 100644 +index d37abf2cf3..df728e2c0a 100644 --- a/src/main/java/net/minecraft/server/RegionFile.java +++ b/src/main/java/net/minecraft/server/RegionFile.java @@ -36,6 +36,8 @@ public class RegionFile implements AutoCloseable { @@ -3613,7 +3591,7 @@ index d37abf2cf..df728e2c0 100644 } diff --git a/src/main/java/net/minecraft/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java -index e07ae9854..0f201000f 100644 +index e07ae98540..0f201000f6 100644 --- a/src/main/java/net/minecraft/server/RegionFileCache.java +++ b/src/main/java/net/minecraft/server/RegionFileCache.java @@ -9,7 +9,7 @@ import java.io.File; @@ -3718,7 +3696,7 @@ index e07ae9854..0f201000f 100644 return regionfile != null ? regionfile.chunkExists(pos) : false; diff --git a/src/main/java/net/minecraft/server/RegionFileSection.java b/src/main/java/net/minecraft/server/RegionFileSection.java -index db9f0196b..a6d8ef5eb 100644 +index db9f0196bd..a6d8ef5eb4 100644 --- a/src/main/java/net/minecraft/server/RegionFileSection.java +++ b/src/main/java/net/minecraft/server/RegionFileSection.java @@ -20,28 +20,29 @@ import javax.annotation.Nullable; @@ -3854,7 +3832,7 @@ index db9f0196b..a6d8ef5eb 100644 + // Paper end } diff --git a/src/main/java/net/minecraft/server/TicketType.java b/src/main/java/net/minecraft/server/TicketType.java -index 335b64435..481d95480 100644 +index 335b644351..481d954808 100644 --- a/src/main/java/net/minecraft/server/TicketType.java +++ b/src/main/java/net/minecraft/server/TicketType.java @@ -22,6 +22,7 @@ public class TicketType { @@ -3866,7 +3844,7 @@ index 335b64435..481d95480 100644 public static TicketType a(String s, Comparator comparator) { return new TicketType<>(s, comparator, 0L); diff --git a/src/main/java/net/minecraft/server/VillagePlace.java b/src/main/java/net/minecraft/server/VillagePlace.java -index c999f8c9b..b59ef1a63 100644 +index c999f8c9bf..b59ef1a633 100644 --- a/src/main/java/net/minecraft/server/VillagePlace.java +++ b/src/main/java/net/minecraft/server/VillagePlace.java @@ -24,8 +24,16 @@ public class VillagePlace extends RegionFileSection { @@ -3955,7 +3933,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 691ef0048..541c1535e 100644 +index 0f652e58e1..5eb52817f1 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 { @@ -4048,7 +4026,7 @@ index 691ef0048..541c1535e 100644 // CraftBukkit start diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index f56ec3d34..1a6a88b17 100644 +index f56ec3d341..1a6a88b178 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -555,22 +555,23 @@ public class CraftWorld implements World { @@ -4110,7 +4088,7 @@ index f56ec3d34..1a6a88b17 100644 @Override public int getViewDistance() { diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java -index 07936eeba..5bdcdcf9e 100644 +index 07936eeba2..5bdcdcf9e8 100644 --- a/src/main/java/org/spigotmc/WatchdogThread.java +++ b/src/main/java/org/spigotmc/WatchdogThread.java @@ -6,6 +6,7 @@ import java.lang.management.ThreadInfo; diff --git a/Spigot-Server-Patches/0397-Reduce-sync-loads.patch b/Spigot-Server-Patches/0397-Reduce-sync-loads.patch index 322190243..321fb0a23 100644 --- a/Spigot-Server-Patches/0397-Reduce-sync-loads.patch +++ b/Spigot-Server-Patches/0397-Reduce-sync-loads.patch @@ -1,4 +1,4 @@ -From 75474a2f173a6ecb18037b0a2b74c8f3691545ed Mon Sep 17 00:00:00 2001 +From 087ba4eb1b20e81032cb81fd141eedbeae580ded Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Fri, 19 Jul 2019 03:29:14 -0700 Subject: [PATCH] Reduce sync loads @@ -11,7 +11,7 @@ it must be enabled by setting the startup flag -Dpaper.debug-sync-loads=true To get a debug log for sync loads, the command is /paper syncloadinfo diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java -index 09efbf725..132397b3f 100644 +index 09efbf7250..132397b3f3 100644 --- a/src/main/java/com/destroystokyo/paper/PaperCommand.java +++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java @@ -1,9 +1,13 @@ @@ -91,7 +91,7 @@ index 09efbf725..132397b3f 100644 if (args.length < 2 || args[1].equals("*")) { diff --git a/src/main/java/com/destroystokyo/paper/io/SyncLoadFinder.java b/src/main/java/com/destroystokyo/paper/io/SyncLoadFinder.java new file mode 100644 -index 000000000..59aec1032 +index 0000000000..59aec10329 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/io/SyncLoadFinder.java @@ -0,0 +1,172 @@ @@ -268,10 +268,10 @@ index 000000000..59aec1032 + } +} diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java -index 58299562e..3eb867684 100644 +index e10035d461..92b22b9996 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java -@@ -284,6 +284,7 @@ public class ChunkProviderServer extends IChunkProvider { +@@ -380,6 +380,7 @@ public class ChunkProviderServer extends IChunkProvider { this.world.asyncChunkTaskManager.raisePriority(x, z, com.destroystokyo.paper.io.PrioritizedTaskQueue.HIGHEST_PRIORITY); com.destroystokyo.paper.io.chunk.ChunkTaskManager.pushChunkWait(this.world, x, z); // Paper end @@ -280,7 +280,7 @@ index 58299562e..3eb867684 100644 this.serverThreadQueue.awaitTasks(completablefuture::isDone); com.destroystokyo.paper.io.chunk.ChunkTaskManager.popChunkWait(); // Paper - async chunk debug diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index 0944ce045..9df079d8a 100644 +index 0944ce0458..9df079d8af 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -1198,7 +1198,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable { @@ -311,7 +311,7 @@ index 0944ce045..9df079d8a 100644 if (chunk != null) { chunk.a(oclass, axisalignedbb, list, predicate); diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 541c1535e..4c74a85e0 100644 +index 5eb52817f1..6d362316f7 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -154,6 +154,12 @@ public class WorldServer extends World { diff --git a/Spigot-Server-Patches/0401-implement-optional-per-player-mob-spawns.patch b/Spigot-Server-Patches/0401-implement-optional-per-player-mob-spawns.patch index 07bbf111a..1bf15a1a1 100644 --- a/Spigot-Server-Patches/0401-implement-optional-per-player-mob-spawns.patch +++ b/Spigot-Server-Patches/0401-implement-optional-per-player-mob-spawns.patch @@ -1,11 +1,11 @@ -From a98286788491d9065c6dabcc7773377b467014f4 Mon Sep 17 00:00:00 2001 +From 9106fe90feeffa795cf88d9c30295b11eaf7e889 Mon Sep 17 00:00:00 2001 From: kickash32 Date: Mon, 19 Aug 2019 01:27:58 +0500 Subject: [PATCH] implement optional per player mob spawns diff --git a/src/main/java/co/aikar/timings/WorldTimingsHandler.java b/src/main/java/co/aikar/timings/WorldTimingsHandler.java -index 8de6c4816..e25544f11 100644 +index 8de6c4816c..e25544f116 100644 --- a/src/main/java/co/aikar/timings/WorldTimingsHandler.java +++ b/src/main/java/co/aikar/timings/WorldTimingsHandler.java @@ -62,6 +62,7 @@ public class WorldTimingsHandler { @@ -25,7 +25,7 @@ index 8de6c4816..e25544f11 100644 poiUnload = Timings.ofSafe(name + "Chunk unload - POI"); chunkUnload = Timings.ofSafe(name + "Chunk unload - Chunk"); diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 9d9260ad0..fd3dbea62 100644 +index 9d9260ad07..fd3dbea628 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -613,4 +613,9 @@ public class PaperWorldConfig { @@ -40,7 +40,7 @@ index 9d9260ad0..fd3dbea62 100644 } diff --git a/src/main/java/com/destroystokyo/paper/util/PlayerMobDistanceMap.java b/src/main/java/com/destroystokyo/paper/util/PlayerMobDistanceMap.java new file mode 100644 -index 000000000..9ebd7ecb7 +index 0000000000..9ebd7ecb7a --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/util/PlayerMobDistanceMap.java @@ -0,0 +1,253 @@ @@ -299,7 +299,7 @@ index 000000000..9ebd7ecb7 +} diff --git a/src/main/java/com/destroystokyo/paper/util/PooledHashSets.java b/src/main/java/com/destroystokyo/paper/util/PooledHashSets.java new file mode 100644 -index 000000000..4f13d3ff8 +index 0000000000..4f13d3ff83 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/util/PooledHashSets.java @@ -0,0 +1,241 @@ @@ -545,10 +545,10 @@ index 000000000..4f13d3ff8 + } +} diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java -index 3eb867684..d1e541ad6 100644 +index 92b22b9996..72919e4c64 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java -@@ -560,7 +560,22 @@ public class ChunkProviderServer extends IChunkProvider { +@@ -656,7 +656,22 @@ public class ChunkProviderServer extends IChunkProvider { this.world.timings.countNaturalMobs.startTiming(); // Paper - timings int l = this.chunkMapDistance.b(); EnumCreatureType[] aenumcreaturetype = EnumCreatureType.values(); @@ -572,7 +572,7 @@ index 3eb867684..d1e541ad6 100644 this.world.timings.countNaturalMobs.stopTiming(); // Paper - timings this.world.getMethodProfiler().exit(); -@@ -625,8 +640,23 @@ public class ChunkProviderServer extends IChunkProvider { +@@ -721,8 +736,23 @@ public class ChunkProviderServer extends IChunkProvider { if (enumcreaturetype != EnumCreatureType.MISC && (!enumcreaturetype.c() || this.allowAnimals) && (enumcreaturetype.c() || this.allowMonsters) && (!enumcreaturetype.d() || flag2)) { int k1 = limit * l / ChunkProviderServer.b; // CraftBukkit - use per-world limits @@ -599,7 +599,7 @@ index 3eb867684..d1e541ad6 100644 } } diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index 6483c4a0b..83405b641 100644 +index 77ad4774ec..22606d894e 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -80,6 +80,11 @@ public class EntityPlayer extends EntityHuman implements ICrafting { @@ -614,7 +614,7 @@ index 6483c4a0b..83405b641 100644 // CraftBukkit start public String displayName; -@@ -110,6 +115,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { +@@ -114,6 +119,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { this.displayName = this.getName(); this.canPickUpLoot = true; this.maxHealthCache = this.getMaxHealth(); @@ -622,7 +622,7 @@ index 6483c4a0b..83405b641 100644 } // Yes, this doesn't match Vanilla, but it's the best we can do for now. -@@ -1765,6 +1771,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { +@@ -1769,6 +1775,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } @@ -631,7 +631,7 @@ index 6483c4a0b..83405b641 100644 return this.cs; } diff --git a/src/main/java/net/minecraft/server/EntityTypes.java b/src/main/java/net/minecraft/server/EntityTypes.java -index 79f854966..4100e367a 100644 +index 79f8549660..4100e367a4 100644 --- a/src/main/java/net/minecraft/server/EntityTypes.java +++ b/src/main/java/net/minecraft/server/EntityTypes.java @@ -254,6 +254,7 @@ public class EntityTypes { @@ -643,7 +643,7 @@ index 79f854966..4100e367a 100644 return this.bb; } diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index 8ce6cf8ec..1df6a1f19 100644 +index 9fa6d2b526..36657465f2 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java @@ -78,7 +78,8 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { @@ -656,7 +656,7 @@ index 8ce6cf8ec..1df6a1f19 100644 // CraftBukkit start - recursion-safe executor for Chunk loadCallback() and unloadCallback() public final CallbackExecutor callbackExecutor = new CallbackExecutor(); -@@ -136,6 +137,24 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { +@@ -165,6 +166,24 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { this.l = supplier; this.m = new VillagePlace(new File(this.w, "poi"), datafixer, this.world); // Paper this.setViewDistance(i); @@ -682,7 +682,7 @@ index 8ce6cf8ec..1df6a1f19 100644 private static double a(ChunkCoordIntPair chunkcoordintpair, Entity entity) { diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java -index fdac5bb3a..58bbf2f9d 100644 +index fdac5bb3a2..58bbf2f9d2 100644 --- a/src/main/java/net/minecraft/server/SpawnerCreature.java +++ b/src/main/java/net/minecraft/server/SpawnerCreature.java @@ -3,6 +3,7 @@ package net.minecraft.server; @@ -755,7 +755,7 @@ index fdac5bb3a..58bbf2f9d 100644 @Nullable diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index b3d23de1b..909af91ca 100644 +index 9055df2ca1..5ec0acc302 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -1024,7 +1024,20 @@ public class WorldServer extends World { diff --git a/Spigot-Server-Patches/0411-Fix-stuck-in-sneak-when-changing-worlds-MC-10657.patch b/Spigot-Server-Patches/0411-Fix-stuck-in-sneak-when-changing-worlds-MC-10657.patch index 9826ace5e..e7f2b1900 100644 --- a/Spigot-Server-Patches/0411-Fix-stuck-in-sneak-when-changing-worlds-MC-10657.patch +++ b/Spigot-Server-Patches/0411-Fix-stuck-in-sneak-when-changing-worlds-MC-10657.patch @@ -1,14 +1,14 @@ -From 7b5a4dafc73b631ad1d1aadee0c0cd601f82071c Mon Sep 17 00:00:00 2001 +From 262186e4bfad4cce5fc6ae9ec41be8f1e9d88e5a Mon Sep 17 00:00:00 2001 From: William Blake Galbreath Date: Wed, 9 Oct 2019 21:51:43 -0500 Subject: [PATCH] Fix stuck in sneak when changing worlds (MC-10657) diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index 83405b641..41a3ad104 100644 +index 22606d894e..0b35a4b143 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java -@@ -976,6 +976,8 @@ public class EntityPlayer extends EntityHuman implements ICrafting { +@@ -980,6 +980,8 @@ public class EntityPlayer extends EntityHuman implements ICrafting { this.lastHealthSent = -1.0F; this.lastFoodSent = -1; @@ -18,7 +18,7 @@ index 83405b641..41a3ad104 100644 PlayerChangedWorldEvent changeEvent = new PlayerChangedWorldEvent(this.getBukkitEntity(), worldserver.getWorld()); this.world.getServer().getPluginManager().callEvent(changeEvent); diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java -index f702619aa..7b79ee4fe 100644 +index f702619aa2..7b79ee4fe5 100644 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -729,6 +729,8 @@ public abstract class PlayerList { diff --git a/Spigot-Server-Patches/0417-Fix-spawn-radius-being-treated-as-0.patch b/Spigot-Server-Patches/0417-Fix-spawn-radius-being-treated-as-0.patch index 60a0d2e9f..25200a923 100644 --- a/Spigot-Server-Patches/0417-Fix-spawn-radius-being-treated-as-0.patch +++ b/Spigot-Server-Patches/0417-Fix-spawn-radius-being-treated-as-0.patch @@ -1,14 +1,14 @@ -From b213d93c2fec628178a313d8ea64ce8ca7f02927 Mon Sep 17 00:00:00 2001 +From 4eb744dc8be173a1d78c9729dfea41151b4cda46 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Sun, 15 Dec 2019 19:41:28 +0000 Subject: [PATCH] Fix spawn radius being treated as 0 diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index 41a3ad104..27d529efe 100644 +index 0b35a4b143..4ca28c8b64 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java -@@ -123,7 +123,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { +@@ -127,7 +127,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { public final BlockPosition getSpawnPoint(WorldServer worldserver) { BlockPosition blockposition = worldserver.getSpawn(); diff --git a/Spigot-Server-Patches/0420-PlayerDeathEvent-shouldDropExperience.patch b/Spigot-Server-Patches/0420-PlayerDeathEvent-shouldDropExperience.patch index fa29224d7..f7bfc6257 100644 --- a/Spigot-Server-Patches/0420-PlayerDeathEvent-shouldDropExperience.patch +++ b/Spigot-Server-Patches/0420-PlayerDeathEvent-shouldDropExperience.patch @@ -1,14 +1,14 @@ -From 95db5e56cb5f4c3dcd1277a07333b20669e12755 Mon Sep 17 00:00:00 2001 +From 9e075ab344d25cb7cec6f3afc5a76cc2970280d1 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Tue, 24 Dec 2019 00:35:42 +0000 Subject: [PATCH] PlayerDeathEvent#shouldDropExperience diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index 27d529efe..d09afc889 100644 +index 4ca28c8b64..15230a834c 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java -@@ -639,7 +639,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { +@@ -643,7 +643,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { this.releaseShoulderEntities(); // SPIGOT-5478 must be called manually now diff --git a/Spigot-Server-Patches/0435-Optimise-getChunkAt-calls-for-loaded-chunks.patch b/Spigot-Server-Patches/0435-Optimise-getChunkAt-calls-for-loaded-chunks.patch new file mode 100644 index 000000000..fdbc3afd2 --- /dev/null +++ b/Spigot-Server-Patches/0435-Optimise-getChunkAt-calls-for-loaded-chunks.patch @@ -0,0 +1,88 @@ +From 17c2e5b74e4cb8b5317863e8e7b17a96b93efef3 Mon Sep 17 00:00:00 2001 +From: Spottedleaf +Date: Sat, 25 Jan 2020 17:04:35 -0800 +Subject: [PATCH] Optimise getChunkAt calls for loaded chunks + +bypass the need to get a player chunk, then get the either, +then unwrap it... + +diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java +index 72919e4c64..42c559ad4f 100644 +--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java ++++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java +@@ -356,6 +356,12 @@ public class ChunkProviderServer extends IChunkProvider { + return this.getChunkAt(i, j, chunkstatus, flag); + }, this.serverThreadQueue).join(); + } else { ++ // Paper start - optimise for loaded chunks ++ Chunk ifLoaded = this.getChunkAtIfLoadedMainThread(i, j); ++ if (ifLoaded != null) { ++ return ifLoaded; ++ } ++ // Paper end + GameProfilerFiller gameprofilerfiller = this.world.getMethodProfiler(); + + gameprofilerfiller.c("getChunk"); +@@ -406,39 +412,7 @@ public class ChunkProviderServer extends IChunkProvider { + if (Thread.currentThread() != this.serverThread) { + return null; + } else { +- this.world.getMethodProfiler().c("getChunkNow"); +- long k = ChunkCoordIntPair.pair(i, j); +- +- for (int l = 0; l < 4; ++l) { +- if (k == this.cachePos[l] && this.cacheStatus[l] == ChunkStatus.FULL) { +- IChunkAccess ichunkaccess = this.cacheChunk[l]; +- +- return ichunkaccess instanceof Chunk ? (Chunk) ichunkaccess : null; +- } +- } +- +- PlayerChunk playerchunk = this.getChunk(k); +- +- if (playerchunk == null) { +- return null; +- } else { +- Either either = (Either) playerchunk.b(ChunkStatus.FULL).getNow(null); // Craftbukkit - decompile error +- +- if (either == null) { +- return null; +- } else { +- IChunkAccess ichunkaccess1 = (IChunkAccess) either.left().orElse(null); // Craftbukkit - decompile error +- +- if (ichunkaccess1 != null) { +- this.a(k, ichunkaccess1, ChunkStatus.FULL); +- if (ichunkaccess1 instanceof Chunk) { +- return (Chunk) ichunkaccess1; +- } +- } +- +- return null; +- } +- } ++ return this.getChunkAtIfLoadedMainThread(i, j); // Paper - optimise for loaded chunks + } + } + +diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java +index 8a2bb79ad9..abd8b751ba 100644 +--- a/src/main/java/net/minecraft/server/World.java ++++ b/src/main/java/net/minecraft/server/World.java +@@ -271,6 +271,14 @@ public abstract class World implements GeneratorAccess, AutoCloseable { + + @Override + public Chunk getChunkAt(int i, int j) { ++ // Paper start - optimise this for loaded chunks ++ if (Thread.currentThread() == this.serverThread) { ++ Chunk ifLoaded = ((WorldServer) this).getChunkProvider().getChunkAtIfLoadedMainThread(i, j); ++ if (ifLoaded != null) { ++ return ifLoaded; ++ } ++ } ++ // Paper end + return (Chunk) this.getChunkAt(i, j, ChunkStatus.FULL); + } + +-- +2.25.0.windows.1 + diff --git a/scripts/importmcdev.sh b/scripts/importmcdev.sh index 227a01eab..6fd55da94 100755 --- a/scripts/importmcdev.sh +++ b/scripts/importmcdev.sh @@ -106,6 +106,7 @@ done # dont forget \ at end of each line but last importLibrary com.mojang authlib com/mojang/authlib yggdrasil/YggdrasilGameProfileRepository.java +importLibrary com.mojang datafixerupper com/mojang/datafixers/util Either.java ######################################################## ########################################################