From 60caeea54e820c787853385632ad1e51c3f55db5 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Wed, 24 Nov 2021 14:26:32 -0800
Subject: [PATCH] Updated Upstream (Bukkit/CraftBukkit/Spigot)

Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
d25437bc Update to Minecraft 1.18-pre8

CraftBukkit Changes:
5a39a236 Update to Minecraft 1.18-pre8

Spigot Changes:
7840c2af Update to Minecraft 1.18-pre8
---
 build.gradle.kts                              |  2 +-
 gradle.properties                             |  4 +--
 patches/api/Convert-project-to-Gradle.patch   |  2 +-
 ...dd-configurable-portal-search-radius.patch |  6 ++--
 .../Allow-Saving-of-Oversized-Chunks.patch    |  4 +--
 .../Asynchronous-chunk-IO-and-loading.patch   | 10 +++---
 ...opper-searches-if-there-are-no-items.patch | 31 ++++++++---------
 .../Bound-Treasure-Maps-to-World-Border.patch |  2 +-
 .../Custom-replacement-for-eaten-items.patch  | 34 +++++++++----------
 .../Don-t-allow-null-UUID-s-for-chat.patch    |  4 +--
 ...ItemConsumeEvent-cancelling-properly.patch | 10 +++---
 .../Fix-World-isChunkGenerated-calls.patch    |  4 +--
 ...ston-physics-inconsistency-MC-188840.patch |  2 +-
 .../server/Improved-Watchdog-Support.patch    |  2 +-
 patches/server/MC-Dev-fixes.patch             | 27 +++++++++------
 patches/server/MC-Utils.patch                 | 11 +++---
 .../server/Mob-Spawner-API-Enhancements.patch | 28 +++++++--------
 ...ptimise-BlockState-s-hashCode-equals.patch |  9 +++--
 ...ptimize-Collision-to-not-load-chunks.patch | 14 --------
 patches/server/Optimize-MappedRegistry.patch  | 10 +++---
 ...ze-NibbleArray-to-use-pooled-buffers.patch |  2 +-
 ...der-Remove-Streams-Optimized-collect.patch |  4 +--
 ...CreateEvent-needs-to-know-its-entity.patch |  2 +-
 ...revent-consuming-the-wrong-itemstack.patch | 16 ++++-----
 ...and-End-Portal-Frames-from-being-des.patch |  4 +--
 patches/server/Remap-fixes.patch              |  4 +--
 patches/server/Setup-Gradle-project.patch     |  3 +-
 patches/server/Timings-v2.patch               |  2 +-
 ...-more-information-to-Entity.toString.patch |  8 ++---
 todo.txt                                      | 17 ++++++++++
 work/BuildData                                |  2 +-
 work/Bukkit                                   |  2 +-
 work/CraftBukkit                              |  2 +-
 work/Spigot                                   |  2 +-
 34 files changed, 147 insertions(+), 139 deletions(-)

diff --git a/build.gradle.kts b/build.gradle.kts
index ab9ef4e8cf..4f69aafe47 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -46,7 +46,7 @@ repositories {
 }
 
 dependencies {
-    paramMappings("net.fabricmc:yarn:1.18-pre5+build.4:mergedv2")
+    paramMappings("net.fabricmc:yarn:1.18-pre8+build.4:mergedv2")
     remapper("net.fabricmc:tiny-remapper:0.7.0:fat")
     decompiler("net.minecraftforge:forgeflower:1.5.498.22")
     paperclip("io.papermc:paperclip:2.0.1")
diff --git a/gradle.properties b/gradle.properties
index 25a452897d..07543018ce 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,7 +1,7 @@
 group=io.papermc.paper
-version=1.18-pre5-R0.1-SNAPSHOT
+version=1.18-pre8-R0.1-SNAPSHOT
 
-mcVersion=1.18-pre5
+mcVersion=1.18-pre8
 
 org.gradle.caching=true
 org.gradle.parallel=true
diff --git a/patches/api/Convert-project-to-Gradle.patch b/patches/api/Convert-project-to-Gradle.patch
index 7e4e1cc23f..6a4b0fc8d9 100644
--- a/patches/api/Convert-project-to-Gradle.patch
+++ b/patches/api/Convert-project-to-Gradle.patch
@@ -112,7 +112,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 -
 -    <groupId>org.spigotmc</groupId>
 -    <artifactId>spigot-api</artifactId>
--    <version>1.18-pre5-R0.1-SNAPSHOT</version>
+-    <version>1.18-pre8-R0.1-SNAPSHOT</version>
 -    <packaging>jar</packaging>
 -
 -    <name>Spigot-API</name>
diff --git a/patches/server/Add-configurable-portal-search-radius.patch b/patches/server/Add-configurable-portal-search-radius.patch
index 3a824b89b7..c15aff4382 100644
--- a/patches/server/Add-configurable-portal-search-radius.patch
+++ b/patches/server/Add-configurable-portal-search-radius.patch
@@ -47,10 +47,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +++ b/src/main/java/net/minecraft/world/level/portal/PortalForcer.java
 @@ -0,0 +0,0 @@ public class PortalForcer {
  
-     public Optional<BlockUtil.FoundRectangle> findPortalAround(BlockPos blockposition, boolean destIsNether, WorldBorder worldborder) {
+     public Optional<BlockUtil.FoundRectangle> findPortalAround(BlockPos pos, boolean destIsNether, WorldBorder worldBorder) {
          // CraftBukkit start
--        return this.findPortalAround(blockposition, worldborder, destIsNether ? 16 : 128); // Search Radius
-+        return this.findPortalAround(blockposition, worldborder, destIsNether ? level.paperConfig.portalCreateRadius : level.paperConfig.portalSearchRadius); // Search Radius // Paper - search Radius
+-        return this.findPortalAround(pos, worldBorder, destIsNether ? 16 : 128); // Search Radius
++        return this.findPortalAround(pos, worldBorder, destIsNether ? level.paperConfig.portalCreateRadius : level.paperConfig.portalSearchRadius); // Search Radius // Paper - search Radius
      }
  
      public Optional<BlockUtil.FoundRectangle> findPortalAround(BlockPos blockposition, WorldBorder worldborder, int i) {
diff --git a/patches/server/Allow-Saving-of-Oversized-Chunks.patch b/patches/server/Allow-Saving-of-Oversized-Chunks.patch
index 8c3a6f20e9..ef204e5888 100644
--- a/patches/server/Allow-Saving-of-Oversized-Chunks.patch
+++ b/patches/server/Allow-Saving-of-Oversized-Chunks.patch
@@ -55,8 +55,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
      public final java.util.concurrent.locks.ReentrantLock fileLock = new java.util.concurrent.locks.ReentrantLock(true); // Paper
 +    public final Path regionFile; // Paper
  
-     public RegionFile(Path path, Path path1, boolean dsync) throws IOException {
-         this(path, path1, RegionFileVersion.VERSION_DEFLATE, dsync);
+     public RegionFile(Path file, Path directory, boolean dsync) throws IOException {
+         this(file, directory, RegionFileVersion.VERSION_DEFLATE, dsync);
 @@ -0,0 +0,0 @@ public class RegionFile implements AutoCloseable {
  
      public RegionFile(Path file, Path directory, RegionFileVersion outputChunkStreamVersion, boolean dsync) throws IOException {
diff --git a/patches/server/Asynchronous-chunk-IO-and-loading.patch b/patches/server/Asynchronous-chunk-IO-and-loading.patch
index 1f6aae1cfb..ad6327676d 100644
--- a/patches/server/Asynchronous-chunk-IO-and-loading.patch
+++ b/patches/server/Asynchronous-chunk-IO-and-loading.patch
@@ -2336,8 +2336,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +            //this.flushWorker(); // Paper - nuke IOWorker
 +            this.level.asyncChunkTaskManager.flush(); // Paper - flush to preserve behavior compat with pre-async behaviour
          } else {
-             this.visibleChunkMap.values().stream().filter(ChunkHolder::wasAccessibleSinceLastSave).forEach((playerchunk) -> {
-                 ChunkAccess ichunkaccess = (ChunkAccess) playerchunk.getChunkToSave().getNow(null); // CraftBukkit - decompile error
+             this.visibleChunkMap.values().forEach(this::saveChunkIfNeeded);
+         }
 @@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
      protected void tick(BooleanSupplier shouldKeepTicking) {
          ProfilerFiller gameprofilerfiller = this.level.getProfiler();
@@ -2462,7 +2462,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
  
      private void markPositionReplaceable(ChunkPos pos) {
 @@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
-         return this.tickingGenerated.get();
+         }
      }
  
 +    // Paper start - async chunk save for unload
@@ -3287,8 +3287,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
      protected final RegionBitmap usedSectors;
 +    public final java.util.concurrent.locks.ReentrantLock fileLock = new java.util.concurrent.locks.ReentrantLock(true); // Paper
  
-     public RegionFile(Path path, Path path1, boolean dsync) throws IOException {
-         this(path, path1, RegionFileVersion.VERSION_DEFLATE, dsync);
+     public RegionFile(Path file, Path directory, boolean dsync) throws IOException {
+         this(file, directory, RegionFileVersion.VERSION_DEFLATE, dsync);
 @@ -0,0 +0,0 @@ public class RegionFile implements AutoCloseable {
          return (byteCount + 4096 - 1) / 4096;
      }
diff --git a/patches/server/Avoid-hopper-searches-if-there-are-no-items.patch b/patches/server/Avoid-hopper-searches-if-there-are-no-items.patch
index 70f08e5db0..90d7860300 100644
--- a/patches/server/Avoid-hopper-searches-if-there-are-no-items.patch
+++ b/patches/server/Avoid-hopper-searches-if-there-are-no-items.patch
@@ -44,32 +44,32 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 @@ -0,0 +0,0 @@ public class EntitySection<T extends EntityAccess> {
      }
  
-     public void add(T entityAccess) {
+     public void add(T entity) {
 +        // Paper start
-+        if (entityAccess instanceof net.minecraft.world.entity.item.ItemEntity) {
++        if (entity instanceof net.minecraft.world.entity.item.ItemEntity) {
 +            this.itemCount++;
-+        } else if (entityAccess instanceof net.minecraft.world.Container) {
++        } else if (entity instanceof net.minecraft.world.Container) {
 +            this.inventoryEntityCount++;
 +        }
 +        // Paper end
-         this.storage.add(entityAccess);
+         this.storage.add(entity);
      }
  
-     public boolean remove(T entityAccess) {
+     public boolean remove(T entity) {
 +        // Paper start
-+        if (entityAccess instanceof net.minecraft.world.entity.item.ItemEntity) {
++        if (entity instanceof net.minecraft.world.entity.item.ItemEntity) {
 +            this.itemCount--;
-+        } else if (entityAccess instanceof net.minecraft.world.Container) {
++        } else if (entity instanceof net.minecraft.world.Container) {
 +            this.inventoryEntityCount--;
 +        }
 +        // Paper end
-         return this.storage.remove(entityAccess);
+         return this.storage.remove(entity);
      }
  
 @@ -0,0 +0,0 @@ public class EntitySection<T extends EntityAccess> {
              for(T entityAccess : collection) {
                  U entityAccess2 = (U)((EntityAccess)type.tryCast(entityAccess));
-                 if (entityAccess2 != null && entityAccess.getBoundingBox().intersects(aABB)) {
+                 if (entityAccess2 != null && entityAccess.getBoundingBox().intersects(box)) {
 -                    action.accept((T)entityAccess2);
 +                    action.accept(entityAccess2); // Paper - decompile fixes
                  }
@@ -84,20 +84,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
  
      public void getEntities(AABB box, Consumer<T> action) {
 +        // Paper start
-+        this.getEntities(box, action, false);
 +    }
 +    public void getEntities(AABB box, Consumer<T> action, boolean isContainerSearch) {
 +        // Paper end
-         this.forEachAccessibleNonEmptySection(box, (entitySection) -> {
-+            if (isContainerSearch && entitySection.inventoryEntityCount <= 0) return; // Paper
-             entitySection.getEntities(box, action);
+         this.forEachAccessibleNonEmptySection(box, (section) -> {
++            if (isContainerSearch && section.inventoryEntityCount <= 0) return; // Paper
+             section.getEntities(box, action);
          });
      }
  
      public <U extends T> void getEntities(EntityTypeTest<T, U> filter, AABB box, Consumer<U> action) {
-         this.forEachAccessibleNonEmptySection(box, (entitySection) -> {
-+            if (filter.getBaseClass() == net.minecraft.world.entity.item.ItemEntity.class && entitySection.itemCount <= 0) return; // Paper
-             entitySection.getEntities(filter, box, action);
+         this.forEachAccessibleNonEmptySection(box, (section) -> {
++            if (filter.getBaseClass() == net.minecraft.world.entity.item.ItemEntity.class && section.itemCount <= 0) return; // Paper
+             section.getEntities(filter, box, action);
          });
      }
 diff --git a/src/main/java/net/minecraft/world/level/entity/LevelEntityGetter.java b/src/main/java/net/minecraft/world/level/entity/LevelEntityGetter.java
diff --git a/patches/server/Bound-Treasure-Maps-to-World-Border.patch b/patches/server/Bound-Treasure-Maps-to-World-Border.patch
index a95a7bdcce..430e40b282 100644
--- a/patches/server/Bound-Treasure-Maps-to-World-Border.patch
+++ b/patches/server/Bound-Treasure-Maps-to-World-Border.patch
@@ -41,7 +41,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
                          int o = j + i * m;
                          int p = k + i * n;
                          ChunkPos chunkPos = this.getPotentialFeatureChunk(config, worldSeed, o, p);
-+                        if (!levelReader.getWorldBorder().isChunkInBounds(chunkPos.x, chunkPos.z)) { continue; } // Paper
++                        if (!world.getWorldBorder().isChunkInBounds(chunkPos.x, chunkPos.z)) { continue; } // Paper
                          StructureCheckResult structureCheckResult = structureAccessor.checkStructurePresence(chunkPos, this, skipExistingChunks);
                          if (structureCheckResult != StructureCheckResult.START_NOT_PRESENT) {
                              if (!skipExistingChunks && structureCheckResult == StructureCheckResult.START_PRESENT) {
diff --git a/patches/server/Custom-replacement-for-eaten-items.patch b/patches/server/Custom-replacement-for-eaten-items.patch
index 8d3c4668b9..1b223f204b 100644
--- a/patches/server/Custom-replacement-for-eaten-items.patch
+++ b/patches/server/Custom-replacement-for-eaten-items.patch
@@ -9,21 +9,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
 +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
 @@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity {
-                 this.triggerItemUseEffects(this.useItem, 16);
-                 // CraftBukkit start - fire PlayerItemConsumeEvent
-                 ItemStack itemstack;
+                     this.triggerItemUseEffects(this.useItem, 16);
+                     // CraftBukkit start - fire PlayerItemConsumeEvent
+                     ItemStack itemstack;
 +                PlayerItemConsumeEvent event = null; // Paper
-                 if (this instanceof ServerPlayer) {
-                     org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.useItem);
--                    PlayerItemConsumeEvent event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem);
+                     if (this instanceof ServerPlayer) {
+                         org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.useItem);
+-                        PlayerItemConsumeEvent event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem);
 +                    event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem); // Paper
-                     level.getCraftServer().getPluginManager().callEvent(event);
+                         level.getCraftServer().getPluginManager().callEvent(event);
  
-                     if (event.isCancelled()) {
+                         if (event.isCancelled()) {
 @@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity {
-                 } else {
-                     itemstack = this.useItem.finishUsingItem(this.level, this);
-                 }
+                     } else {
+                         itemstack = this.useItem.finishUsingItem(this.level, this);
+                     }
 +
 +                // Paper start - save the default replacement item and change it if necessary
 +                final ItemStack defaultReplacement = itemstack;
@@ -31,18 +31,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +                    itemstack = CraftItemStack.asNMSCopy(event.getReplacement());
 +                }
 +                // Paper end
-                 // CraftBukkit end
+                     // CraftBukkit end
  
-                 if (itemstack != this.useItem) {
+                     if (itemstack != this.useItem) {
 @@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity {
-                 }
+                     }
  
-                 this.stopUsingItem();
+                     this.stopUsingItem();
 +                // Paper start - if the replacement is anything but the default, update the client inventory
 +                if (this instanceof ServerPlayer && !com.google.common.base.Objects.equal(defaultReplacement, itemstack)) {
 +                    ((ServerPlayer) this).getBukkitEntity().updateInventory();
 +                }
 +                // Paper end
-             }
+                 }
  
-         }
+             }
diff --git a/patches/server/Don-t-allow-null-UUID-s-for-chat.patch b/patches/server/Don-t-allow-null-UUID-s-for-chat.patch
index 227b8a9644..9ccd1b869b 100644
--- a/patches/server/Don-t-allow-null-UUID-s-for-chat.patch
+++ b/patches/server/Don-t-allow-null-UUID-s-for-chat.patch
@@ -9,9 +9,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 --- a/src/main/java/net/minecraft/network/protocol/game/ClientboundChatPacket.java
 +++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundChatPacket.java
 @@ -0,0 +0,0 @@ public class ClientboundChatPacket implements Packet<ClientGamePacketListener> {
-     public ClientboundChatPacket(Component message, ChatType location, UUID sender) {
+     public ClientboundChatPacket(Component message, ChatType type, UUID sender) {
          this.message = message;
-         this.type = location;
+         this.type = type;
 -        this.sender = sender;
 +        this.sender = sender != null ? sender : net.minecraft.Util.NIL_UUID;
      }
diff --git a/patches/server/Fix-PlayerItemConsumeEvent-cancelling-properly.patch b/patches/server/Fix-PlayerItemConsumeEvent-cancelling-properly.patch
index e7beb44886..097707a6fa 100644
--- a/patches/server/Fix-PlayerItemConsumeEvent-cancelling-properly.patch
+++ b/patches/server/Fix-PlayerItemConsumeEvent-cancelling-properly.patch
@@ -13,10 +13,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
 +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
 @@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity {
-                     level.getCraftServer().getPluginManager().callEvent(event);
+                         level.getCraftServer().getPluginManager().callEvent(event);
  
-                     if (event.isCancelled()) {
+                         if (event.isCancelled()) {
 +                        this.stopUsingItem(); // Paper - event is using an item, clear active item to reset its use
-                         // Update client
-                         ((ServerPlayer) this).getBukkitEntity().updateInventory();
-                         ((ServerPlayer) this).getBukkitEntity().updateScaledHealth();
+                             // Update client
+                             ((ServerPlayer) this).getBukkitEntity().updateInventory();
+                             ((ServerPlayer) this).getBukkitEntity().updateScaledHealth();
diff --git a/patches/server/Fix-World-isChunkGenerated-calls.patch b/patches/server/Fix-World-isChunkGenerated-calls.patch
index 18388b3cfb..8f684191e3 100644
--- a/patches/server/Fix-World-isChunkGenerated-calls.patch
+++ b/patches/server/Fix-World-isChunkGenerated-calls.patch
@@ -164,8 +164,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +    }
 +    // Paper end
 +
-     public RegionFile(Path path, Path path1, boolean dsync) throws IOException {
-         this(path, path1, RegionFileVersion.VERSION_DEFLATE, dsync);
+     public RegionFile(Path file, Path directory, boolean dsync) throws IOException {
+         this(file, directory, RegionFileVersion.VERSION_DEFLATE, dsync);
      }
 @@ -0,0 +0,0 @@ public class RegionFile implements AutoCloseable {
          return this.getOffset(pos) != 0;
diff --git a/patches/server/Fix-piston-physics-inconsistency-MC-188840.patch b/patches/server/Fix-piston-physics-inconsistency-MC-188840.patch
index 1e8e19e9b0..7a5cb43489 100644
--- a/patches/server/Fix-piston-physics-inconsistency-MC-188840.patch
+++ b/patches/server/Fix-piston-physics-inconsistency-MC-188840.patch
@@ -87,7 +87,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 --- a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
 +++ b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
 @@ -0,0 +0,0 @@ public class PistonMovingBlockEntity extends BlockEntity {
-                 if (blockEntity.movedState != null && world.getBlockState(pos).is(Blocks.MOVING_PISTON)) {
+                 if (world.getBlockState(pos).is(Blocks.MOVING_PISTON)) {
                      BlockState blockState = Block.updateFromNeighbourShapes(blockEntity.movedState, world, pos);
                      if (blockState.isAir()) {
 -                        world.setBlock(pos, blockEntity.movedState, 84);
diff --git a/patches/server/Improved-Watchdog-Support.patch b/patches/server/Improved-Watchdog-Support.patch
index ac44397338..31b9501a75 100644
--- a/patches/server/Improved-Watchdog-Support.patch
+++ b/patches/server/Improved-Watchdog-Support.patch
@@ -296,8 +296,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
          } catch (Exception var3) {
 +            if (var3.getCause() instanceof ThreadDeath) throw var3; // Paper
              LOGGER.fatal("Error executing task on {}", this.name(), var3);
+             throw var3;
          }
- 
 diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/world/level/Level.java
diff --git a/patches/server/MC-Dev-fixes.patch b/patches/server/MC-Dev-fixes.patch
index 85cb4c6414..37c212c36f 100644
--- a/patches/server/MC-Dev-fixes.patch
+++ b/patches/server/MC-Dev-fixes.patch
@@ -39,6 +39,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
                      }
                  }
              };
+diff --git a/src/main/java/net/minecraft/core/MappedRegistry.java b/src/main/java/net/minecraft/core/MappedRegistry.java
+index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
+--- a/src/main/java/net/minecraft/core/MappedRegistry.java
++++ b/src/main/java/net/minecraft/core/MappedRegistry.java
+@@ -0,0 +0,0 @@ public class MappedRegistry<T> extends WritableRegistry<T> {
+     }
+ 
+     static record RegistryEntry<T>(ResourceKey<T> key, int id, T value) {
+-        RegistryEntry(ResourceKey<T> key, int rawId, T entry) {
+-            this.key = key;
+-            this.id = rawId;
+-            this.value = entry;
+-        }
+     }
+ }
 diff --git a/src/main/java/net/minecraft/nbt/ListTag.java b/src/main/java/net/minecraft/nbt/ListTag.java
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/nbt/ListTag.java
@@ -126,15 +141,7 @@ diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundLoginP
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLoginPacket.java
 +++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLoginPacket.java
-@@ -0,0 +0,0 @@ import net.minecraft.world.level.GameType;
- import net.minecraft.world.level.Level;
- import net.minecraft.world.level.dimension.DimensionType;
- 
--public record ClientboundLoginPacket(int playerId, boolean hardcore, GameType gameType, GameType previousGameType, Set<ResourceKey<Level>> levels, RegistryAccess.RegistryHolder registryHolder, DimensionType dimensionType, ResourceKey<Level> dimension, long seed, int maxPlayers, int chunkRadius, int simulationDistance, boolean reducedDebugInfo, boolean showDeathScreen, boolean isDebug, boolean isFlat) implements Packet {
-+public record ClientboundLoginPacket(int playerId, boolean hardcore, GameType gameType, GameType previousGameType, Set<ResourceKey<Level>> levels, RegistryAccess.RegistryHolder registryHolder, DimensionType dimensionType, ResourceKey<Level> dimension, long seed, int maxPlayers, int chunkRadius, int simulationDistance, boolean reducedDebugInfo, boolean showDeathScreen, boolean isDebug, boolean isFlat) implements Packet<ClientGamePacketListener> { // Paper - fix missing generic
-     public ClientboundLoginPacket(FriendlyByteBuf buf) {
-         this(buf.readInt(), buf.readBoolean(), GameType.byId(buf.readByte()), GameType.byNullableId(buf.readByte()), buf.readCollection(Sets::newHashSetWithExpectedSize, (b) -> {
-             return ResourceKey.create(Registry.DIMENSION_REGISTRY, b.readResourceLocation());
+@@ -0,0 +0,0 @@ public record ClientboundLoginPacket(int playerId, boolean hardcore, GameType ga
          }), buf.readWithCodec(RegistryAccess.RegistryHolder.NETWORK_CODEC), buf.readWithCodec(DimensionType.CODEC).get(), ResourceKey.create(Registry.DIMENSION_REGISTRY, buf.readResourceLocation()), buf.readLong(), buf.readVarInt(), buf.readVarInt(), buf.readVarInt(), buf.readBoolean(), buf.readBoolean(), buf.readBoolean(), buf.readBoolean());
      }
  
@@ -223,8 +230,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 -            return (entry1.getValue()); // CraftBukkit
 +            return entry1.getValue(); // CraftBukkit // Paper - decompile fix - *shrugs internally* // todo: is this needed anymore?
          }));
+         this.byName = Maps.newHashMap(builder.build()); // CraftBukkit
          RecipeManager.LOGGER.info("Loaded {} recipes", map1.size());
-     }
 diff --git a/src/main/java/net/minecraft/world/level/biome/Biome.java b/src/main/java/net/minecraft/world/level/biome/Biome.java
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/world/level/biome/Biome.java
diff --git a/patches/server/MC-Utils.patch b/patches/server/MC-Utils.patch
index 1d8ec3303a..c78054cc3c 100644
--- a/patches/server/MC-Utils.patch
+++ b/patches/server/MC-Utils.patch
@@ -5450,18 +5450,15 @@ diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/sr
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
 +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
-@@ -0,0 +0,0 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureMana
- import net.minecraft.world.level.storage.DimensionDataStorage;
- import net.minecraft.world.level.storage.LevelData;
+@@ -0,0 +0,0 @@ import net.minecraft.world.level.storage.LevelData;
  import net.minecraft.world.level.storage.LevelStorageSource;
+ import org.apache.logging.log4j.LogManager;
+ import org.apache.logging.log4j.Logger;
 +import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; // Paper
 +import java.util.function.Function; // Paper
  
  public class ServerChunkCache extends ChunkSource {
-+    public static final org.apache.logging.log4j.Logger LOGGER = org.apache.logging.log4j.LogManager.getLogger(); // Paper
  
-     public static final List<ChunkStatus> CHUNK_STATUSES = ChunkStatus.getStatusList();
-     private final DistanceManager distanceManager;
 @@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource {
      @Nullable
      @VisibleForDebug
@@ -6480,8 +6477,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 -    protected final ChunkPos chunkPos;
 +    protected final ChunkPos chunkPos; public final long coordinateKey; public final int locX; public final int locZ; // Paper - cache coordinate key
      private long inhabitedTime;
+     /** @deprecated */
      @Nullable
-     @Deprecated
 @@ -0,0 +0,0 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom
      protected final LevelChunkSection[] sections;
  
diff --git a/patches/server/Mob-Spawner-API-Enhancements.patch b/patches/server/Mob-Spawner-API-Enhancements.patch
index 7fdc3a3819..d6d2c8adc8 100644
--- a/patches/server/Mob-Spawner-API-Enhancements.patch
+++ b/patches/server/Mob-Spawner-API-Enhancements.patch
@@ -43,27 +43,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 @@ -0,0 +0,0 @@ public abstract class BaseSpawner {
      }
  
-     public CompoundTag save(CompoundTag nbttagcompound) {
--        nbttagcompound.putShort("Delay", (short) this.spawnDelay);
--        nbttagcompound.putShort("MinSpawnDelay", (short) this.minSpawnDelay);
--        nbttagcompound.putShort("MaxSpawnDelay", (short) this.maxSpawnDelay);
+     public CompoundTag save(CompoundTag nbt) {
+-        nbt.putShort("Delay", (short) this.spawnDelay);
+-        nbt.putShort("MinSpawnDelay", (short) this.minSpawnDelay);
+-        nbt.putShort("MaxSpawnDelay", (short) this.maxSpawnDelay);
 +        // Paper start
 +        if (spawnDelay > Short.MAX_VALUE) {
-+            nbttagcompound.putInt("Paper.Delay", this.spawnDelay);
++            nbt.putInt("Paper.Delay", this.spawnDelay);
 +        }
-+        nbttagcompound.putShort("Delay", (short) Math.min(Short.MAX_VALUE, this.spawnDelay));
++        nbt.putShort("Delay", (short) Math.min(Short.MAX_VALUE, this.spawnDelay));
 +
 +        if (minSpawnDelay > Short.MAX_VALUE || maxSpawnDelay > Short.MAX_VALUE) {
-+            nbttagcompound.putInt("Paper.MinSpawnDelay", this.minSpawnDelay);
-+            nbttagcompound.putInt("Paper.MaxSpawnDelay", this.maxSpawnDelay);
++            nbt.putInt("Paper.MinSpawnDelay", this.minSpawnDelay);
++            nbt.putInt("Paper.MaxSpawnDelay", this.maxSpawnDelay);
 +        }
 +
-+        nbttagcompound.putShort("MinSpawnDelay", (short) Math.min(Short.MAX_VALUE, this.minSpawnDelay));
-+        nbttagcompound.putShort("MaxSpawnDelay", (short) Math.min(Short.MAX_VALUE, this.maxSpawnDelay));
-+        // Paper end
-         nbttagcompound.putShort("SpawnCount", (short) this.spawnCount);
-         nbttagcompound.putShort("MaxNearbyEntities", (short) this.maxNearbyEntities);
-         nbttagcompound.putShort("RequiredPlayerRange", (short) this.requiredPlayerRange);
++        nbt.putShort("MinSpawnDelay", (short) Math.min(Short.MAX_VALUE, this.minSpawnDelay));
++        nbt.putShort("MaxSpawnDelay", (short) Math.min(Short.MAX_VALUE, this.maxSpawnDelay));
++        // Paper nbt
+         nbt.putShort("SpawnCount", (short) this.spawnCount);
+         nbt.putShort("MaxNearbyEntities", (short) this.maxNearbyEntities);
+         nbt.putShort("RequiredPlayerRange", (short) this.requiredPlayerRange);
 diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java b/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java
diff --git a/patches/server/Optimise-BlockState-s-hashCode-equals.patch b/patches/server/Optimise-BlockState-s-hashCode-equals.patch
index 663ab12b16..74b05a023e 100644
--- a/patches/server/Optimise-BlockState-s-hashCode-equals.patch
+++ b/patches/server/Optimise-BlockState-s-hashCode-equals.patch
@@ -55,19 +55,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 --- a/src/main/java/net/minecraft/world/level/block/state/properties/Property.java
 +++ b/src/main/java/net/minecraft/world/level/block/state/properties/Property.java
 @@ -0,0 +0,0 @@ public abstract class Property<T extends Comparable<T>> {
-     }
  
+     @Override
      public boolean equals(Object object) {
 -        if (this == object) {
 -            return true;
 -        } else if (!(object instanceof Property)) {
 -            return false;
 -        } else {
--            Property<?> iblockstate = (Property) object;
--
--            return this.clazz.equals(iblockstate.clazz) && this.name.equals(iblockstate.name);
+-            Property<?> property = (Property)object;
+-            return this.clazz.equals(property.clazz) && this.name.equals(property.name);
 -        }
 +        return this == object; // Paper
      }
  
-     public final int hashCode() {
+     @Override
diff --git a/patches/server/Optimize-Collision-to-not-load-chunks.patch b/patches/server/Optimize-Collision-to-not-load-chunks.patch
index 111db03e5c..088c218b37 100644
--- a/patches/server/Optimize-Collision-to-not-load-chunks.patch
+++ b/patches/server/Optimize-Collision-to-not-load-chunks.patch
@@ -109,17 +109,3 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
  
          if (!this.getEntityCollisions(entity, box).isEmpty()) {
              return false;
-diff --git a/src/main/java/net/minecraft/world/phys/shapes/Shapes.java b/src/main/java/net/minecraft/world/phys/shapes/Shapes.java
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
---- a/src/main/java/net/minecraft/world/phys/shapes/Shapes.java
-+++ b/src/main/java/net/minecraft/world/phys/shapes/Shapes.java
-@@ -0,0 +0,0 @@ public final class Shapes {
- 
-                             if (s < 3) {
-                                 mutableBlockPos.set(axisCycle, q, r, p);
--                                BlockState blockState = world.getBlockState(mutableBlockPos);
-+                                BlockState blockState = world.getTypeIfLoaded(mutableBlockPos); // Paper
-+                                if (blockState == null) return 0.0D; // Paper
-                                 if ((s != 1 || blockState.hasLargeCollisionShape()) && (s != 2 || blockState.is(Blocks.MOVING_PISTON))) {
-                                     initial = blockState.getCollisionShape(world, mutableBlockPos, context).collide(axis3, box.move((double)(-mutableBlockPos.getX()), (double)(-mutableBlockPos.getY()), (double)(-mutableBlockPos.getZ())), initial);
-                                     if (Math.abs(initial) < 1.0E-7D) {
diff --git a/patches/server/Optimize-MappedRegistry.patch b/patches/server/Optimize-MappedRegistry.patch
index 58e056332a..cc2d65e038 100644
--- a/patches/server/Optimize-MappedRegistry.patch
+++ b/patches/server/Optimize-MappedRegistry.patch
@@ -11,16 +11,18 @@ diff --git a/src/main/java/net/minecraft/core/MappedRegistry.java b/src/main/jav
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/core/MappedRegistry.java
 +++ b/src/main/java/net/minecraft/core/MappedRegistry.java
-@@ -0,0 +0,0 @@ public class MappedRegistry<T> extends WritableRegistry<T> {
+@@ -0,0 +0,0 @@ import org.apache.logging.log4j.Logger;
  
+ public class MappedRegistry<T> extends WritableRegistry<T> {
      protected static final Logger LOGGER = LogManager.getLogger();
-     private final ObjectList<T> byId = new ObjectArrayList(256);
--    private final Object2IntMap<T> toId = (Object2IntMap) Util.make(new Object2IntOpenCustomHashMap(Util.identityStrategy()), (object2intopencustomhashmap) -> {
--        object2intopencustomhashmap.defaultReturnValue(-1);
+-    private final ObjectList<T> byId = new ObjectArrayList<>(256);
+-    private final Object2IntMap<T> toId = Util.make(new Object2IntOpenCustomHashMap<>(Util.identityStrategy()), (object2IntOpenCustomHashMap) -> {
+-        object2IntOpenCustomHashMap.defaultReturnValue(-1);
 -    });
 -    private final BiMap<ResourceLocation, T> storage = HashBiMap.create();
 -    private final BiMap<ResourceKey<T>, T> keyStorage = HashBiMap.create();
 -    private final Map<T, Lifecycle> lifecycles = Maps.newIdentityHashMap();
++    private final ObjectList<T> byId = new ObjectArrayList(256);
 +    private final it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap<T> toId = new it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap<T>(2048);// Paper - use bigger expected size to reduce collisions and direct intent for FastUtil to be identity map
 +    private final BiMap<ResourceLocation, T> storage = HashBiMap.create(2048); // Paper - use bigger expected size to reduce collisions
 +    private final BiMap<ResourceKey<T>, T> keyStorage = HashBiMap.create(2048); // Paper - use bigger expected size to reduce collisions
diff --git a/patches/server/Optimize-NibbleArray-to-use-pooled-buffers.patch b/patches/server/Optimize-NibbleArray-to-use-pooled-buffers.patch
index 55bfd61ae8..2be574fc3e 100644
--- a/patches/server/Optimize-NibbleArray-to-use-pooled-buffers.patch
+++ b/patches/server/Optimize-NibbleArray-to-use-pooled-buffers.patch
@@ -45,7 +45,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +    }
 +    // Paper end
 +
-     public ClientboundLevelChunkWithLightPacket(LevelChunk chunk, LevelLightEngine lightProvider, @Nullable BitSet bitSet, @Nullable BitSet bitSet2, boolean bl) {
+     public ClientboundLevelChunkWithLightPacket(LevelChunk chunk, LevelLightEngine lightProvider, @Nullable BitSet skyBits, @Nullable BitSet blockBits, boolean nonEdge) {
          ChunkPos chunkPos = chunk.getPos();
          this.x = chunkPos.x;
 diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundLightUpdatePacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundLightUpdatePacket.java
diff --git a/patches/server/Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch b/patches/server/Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch
index 9740b36521..7c2c7137b7 100644
--- a/patches/server/Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch
+++ b/patches/server/Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch
@@ -24,8 +24,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
          this.openSet.clear();
          this.nodeEvaluator.prepare(world, mob);
          Node node = this.nodeEvaluator.getStart();
--        Map<Target, BlockPos> map = positions.stream().collect(Collectors.toMap((blockPos) -> {
--            return this.nodeEvaluator.getGoal((double)blockPos.getX(), (double)blockPos.getY(), (double)blockPos.getZ());
+-        Map<Target, BlockPos> map = positions.stream().collect(Collectors.toMap((pos) -> {
+-            return this.nodeEvaluator.getGoal((double)pos.getX(), (double)pos.getY(), (double)pos.getZ());
 -        }, Function.identity()));
 +        // Paper start - remove streams - and optimize collection
 +        List<Map.Entry<Target, BlockPos>> map = Lists.newArrayList();
diff --git a/patches/server/PortalCreateEvent-needs-to-know-its-entity.patch b/patches/server/PortalCreateEvent-needs-to-know-its-entity.patch
index 12e5856fcc..cf874ce9c9 100644
--- a/patches/server/PortalCreateEvent-needs-to-know-its-entity.patch
+++ b/patches/server/PortalCreateEvent-needs-to-know-its-entity.patch
@@ -100,9 +100,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +        this.onPlace(iblockdata, world, blockposition, iblockdata1, flag);
 +    }
 +    // Paper end
+     /** @deprecated */
      @Deprecated
      public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
-         org.spigotmc.AsyncCatcher.catchOp("block onPlace"); // Spigot
 diff --git a/src/main/java/net/minecraft/world/level/portal/PortalShape.java b/src/main/java/net/minecraft/world/level/portal/PortalShape.java
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/world/level/portal/PortalShape.java
diff --git a/patches/server/Prevent-consuming-the-wrong-itemstack.patch b/patches/server/Prevent-consuming-the-wrong-itemstack.patch
index 981783a2f9..bdef90371d 100644
--- a/patches/server/Prevent-consuming-the-wrong-itemstack.patch
+++ b/patches/server/Prevent-consuming-the-wrong-itemstack.patch
@@ -25,17 +25,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
              this.useItemRemaining = itemstack.getUseDuration();
              if (!this.level.isClientSide) {
 @@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity {
-             this.releaseUsingItem();
-         } else {
-             if (!this.useItem.isEmpty() && this.isUsingItem()) {
+                 this.releaseUsingItem();
+             } else {
+                 if (!this.useItem.isEmpty() && this.isUsingItem()) {
 +                this.startUsingItem(this.getUsedItemHand(), true); // Paper
-                 this.triggerItemUseEffects(this.useItem, 16);
-                 // CraftBukkit start - fire PlayerItemConsumeEvent
-                 ItemStack itemstack;
+                     this.triggerItemUseEffects(this.useItem, 16);
+                     // CraftBukkit start - fire PlayerItemConsumeEvent
+                     ItemStack itemstack;
 @@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity {
-                 }
+                     }
  
-                 this.stopUsingItem();
+                     this.stopUsingItem();
 -                // Paper start - if the replacement is anything but the default, update the client inventory
 -                if (this instanceof ServerPlayer && !com.google.common.base.Objects.equal(defaultReplacement, itemstack)) {
 +                // Paper start
diff --git a/patches/server/Protect-Bedrock-and-End-Portal-Frames-from-being-des.patch b/patches/server/Protect-Bedrock-and-End-Portal-Frames-from-being-des.patch
index 7b8a957a30..21e1ed04bf 100644
--- a/patches/server/Protect-Bedrock-and-End-Portal-Frames-from-being-des.patch
+++ b/patches/server/Protect-Bedrock-and-End-Portal-Frames-from-being-des.patch
@@ -139,14 +139,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 --- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
 +++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
 @@ -0,0 +0,0 @@ public abstract class BlockBehaviour {
- 
+     /** @deprecated */
      @Deprecated
      public boolean canBeReplaced(BlockState state, BlockPlaceContext context) {
 -        return this.material.isReplaceable() && (context.getItemInHand().isEmpty() || !context.getItemInHand().is(this.asItem()));
 +        return this.material.isReplaceable() && (context.getItemInHand().isEmpty() || !context.getItemInHand().is(this.asItem())) && (state.isDestroyable() || (context.getPlayer() != null && context.getPlayer().getAbilities().instabuild)); // Paper
      }
  
-     @Deprecated
+     /** @deprecated */
 @@ -0,0 +0,0 @@ public abstract class BlockBehaviour {
          public Block getBlock() {
              return (Block) this.owner;
diff --git a/patches/server/Remap-fixes.patch b/patches/server/Remap-fixes.patch
index 648545218f..532e2daf43 100644
--- a/patches/server/Remap-fixes.patch
+++ b/patches/server/Remap-fixes.patch
@@ -82,14 +82,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 --- a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
 +++ b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
 @@ -0,0 +0,0 @@ public class RecipeManager extends SimpleJsonResourceReloadListener {
-         Map<RecipeType<?>, Object2ObjectLinkedOpenHashMap<ResourceLocation, Recipe<?>>> map = Maps.newHashMap(); // CraftBukkit
+         Builder<ResourceLocation, Recipe<?>> builder = ImmutableMap.builder();
  
          recipes.forEach((irecipe) -> {
 -            Map<ResourceLocation, Recipe<?>> map1 = (Map) map.computeIfAbsent(irecipe.getType(), (recipes) -> {
 +            Map<ResourceLocation, Recipe<?>> map1 = (Map) map.computeIfAbsent(irecipe.getType(), (recipes_) -> { // Paper - remap fix
                  return new Object2ObjectLinkedOpenHashMap<>(); // CraftBukkit
              });
-             Recipe<?> irecipe1 = (Recipe) map1.put(irecipe.getId(), irecipe);
+             ResourceLocation minecraftkey = irecipe.getId();
 diff --git a/src/test/java/org/bukkit/DyeColorsTest.java b/src/test/java/org/bukkit/DyeColorsTest.java
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/test/java/org/bukkit/DyeColorsTest.java
diff --git a/patches/server/Setup-Gradle-project.patch b/patches/server/Setup-Gradle-project.patch
index bdb1fffc8d..da94fac057 100644
--- a/patches/server/Setup-Gradle-project.patch
+++ b/patches/server/Setup-Gradle-project.patch
@@ -194,7 +194,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 -    <groupId>org.spigotmc</groupId>
 -    <artifactId>spigot</artifactId>
 -    <packaging>jar</packaging>
--    <version>1.18-pre5-R0.1-SNAPSHOT</version>
+-    <version>1.18-pre8-R0.1-SNAPSHOT</version>
 -    <name>Spigot</name>
 -    <url>https://www.spigotmc.org/</url>
 -
@@ -552,6 +552,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 -                            <algorithms>
 -                                <algorithm>SHA-256</algorithm>
 -                            </algorithms>
+-                            <quiet>true</quiet>
 -                            <scopes>
 -                                <scope>compile</scope>
 -                                <scope>runtime</scope>
diff --git a/patches/server/Timings-v2.patch b/patches/server/Timings-v2.patch
index 8a587ed5a9..99597f9da2 100644
--- a/patches/server/Timings-v2.patch
+++ b/patches/server/Timings-v2.patch
@@ -1315,7 +1315,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
  
 @@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel {
  
-         if (!flag1) {
+         if (!savingDisabled) {
              org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); // CraftBukkit
 +            try (co.aikar.timings.Timing ignored = timings.worldSave.startTiming()) { // Paper
              if (progressListener != null) {
diff --git a/patches/server/add-more-information-to-Entity.toString.patch b/patches/server/add-more-information-to-Entity.toString.patch
index c3e2a472a2..ab3f84fd40 100644
--- a/patches/server/add-more-information-to-Entity.toString.patch
+++ b/patches/server/add-more-information-to-Entity.toString.patch
@@ -10,11 +10,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 --- a/src/main/java/net/minecraft/world/entity/Entity.java
 +++ b/src/main/java/net/minecraft/world/entity/Entity.java
 @@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
-     }
- 
      public String toString() {
--        return String.format(Locale.ROOT, "%s['%s'/%d, l='%s', x=%.2f, y=%.2f, z=%.2f]", this.getClass().getSimpleName(), this.getName().getString(), this.id, this.level == null ? "~NULL~" : this.level.toString(), this.getX(), this.getY(), this.getZ());
-+        return String.format(Locale.ROOT, "%s['%s'/%d, uuid='%s', l='%s', x=%.2f, y=%.2f, z=%.2f, cpos=%s, tl=%d, v=%b, rR=%s]", new Object[] { this.getClass().getSimpleName(), this.getName().getString(), Integer.valueOf(this.id), this.uuid.toString(), this.level == null ? "~NULL~" : this.level.toString(), Double.valueOf(this.getX()), Double.valueOf(this.getY()), Double.valueOf(this.getZ()), this.chunkPosition(), this.tickCount, this.valid, this.removalReason}); // Paper - add more information
+         String s = this.level == null ? "~NULL~" : this.level.toString();
+ 
+-        return this.removalReason != null ? String.format(Locale.ROOT, "%s['%s'/%d, l='%s', x=%.2f, y=%.2f, z=%.2f, removed=%s]", this.getClass().getSimpleName(), this.getName().getString(), this.id, s, this.getX(), this.getY(), this.getZ(), this.removalReason) : String.format(Locale.ROOT, "%s['%s'/%d, l='%s', x=%.2f, y=%.2f, z=%.2f]", this.getClass().getSimpleName(), this.getName().getString(), this.id, s, this.getX(), this.getY(), this.getZ());
++        return this.removalReason != null ? String.format(Locale.ROOT, "%s['%s'/%d, uuid='%s', l='%s', x=%.2f, y=%.2f, z=%.2f, cpos=%s, tl=%d, v=%b, removed=%s]", this.getClass().getSimpleName(), this.getName().getString(), this.id, this.uuid, s, this.getX(), this.getY(), this.getZ(), this.chunkPosition(), this.tickCount, this.valid, this.removalReason) : String.format(Locale.ROOT, "%s['%s'/%d, uuid='%s', l='%s', x=%.2f, y=%.2f, z=%.2f, cpos=%s, tl=%d, v=%b]", this.getClass().getSimpleName(), this.getName().getString(), this.id, this.uuid, s, this.getX(), this.getY(), this.getZ(), this.chunkPosition(), this.tickCount, this.valid);
      }
  
      public boolean isInvulnerableTo(DamageSource damageSource) {
diff --git a/todo.txt b/todo.txt
index fd43ae8e68..63c052e7a1 100644
--- a/todo.txt
+++ b/todo.txt
@@ -6,3 +6,20 @@ Improve Server Thread Pool and Thread Priorities: mojang added a max thread coun
 Use Vanilla Minecart Speeds: is this needed?
 Handle Oversized Tile Entities: make sure impl is correct
 0467-Optimize-WorldBorder-collision-checks-and-air check first hunk that has been removed
+
+Not sure where this needs to go, if anywhere
+diff --git a/src/main/java/net/minecraft/world/phys/shapes/Shapes.java b/src/main/java/net/minecraft/world/phys/shapes/Shapes.java
+index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
+--- a/src/main/java/net/minecraft/world/phys/shapes/Shapes.java
++++ b/src/main/java/net/minecraft/world/phys/shapes/Shapes.java
+@@ -0,0 +0,0 @@ public final class Shapes {
+
+                             if (s < 3) {
+                                 mutableBlockPos.set(axisCycle, q, r, p);
+-                                BlockState blockState = world.getBlockState(mutableBlockPos);
++                                BlockState blockState = world.getTypeIfLoaded(mutableBlockPos); // Paper
++                                if (blockState == null) return 0.0D; // Paper
+                                 if ((s != 1 || blockState.hasLargeCollisionShape()) && (s != 2 || blockState.is(Blocks.MOVING_PISTON))) {
+                                     initial = blockState.getCollisionShape(world, mutableBlockPos, context).collide(axis3, box.move((double)(-mutableBlockPos.getX()), (double)(-mutableBlockPos.getY()), (double)(-mutableBlockPos.getZ())), initial);
+                                     if (Math.abs(initial) < 1.0E-7D) {
+
diff --git a/work/BuildData b/work/BuildData
index 8581e449a3..09c3da501e 160000
--- a/work/BuildData
+++ b/work/BuildData
@@ -1 +1 @@
-Subproject commit 8581e449a3490934f8bfa8b36d45842393dc8a20
+Subproject commit 09c3da501e40b5090cbd93cc91c8e5c49ce053b7
diff --git a/work/Bukkit b/work/Bukkit
index ea30a299e9..d25437bce3 160000
--- a/work/Bukkit
+++ b/work/Bukkit
@@ -1 +1 @@
-Subproject commit ea30a299e948f5545b0ad042bd8e11716aeaa7f2
+Subproject commit d25437bce34e0cb0b7c895867183dc949ea41667
diff --git a/work/CraftBukkit b/work/CraftBukkit
index a58fde42cc..5a39a236c1 160000
--- a/work/CraftBukkit
+++ b/work/CraftBukkit
@@ -1 +1 @@
-Subproject commit a58fde42cc9cd946db4c502a91dfe5cdf314fade
+Subproject commit 5a39a236c11b6a5a19f8d26b4c5af1f59f16d447
diff --git a/work/Spigot b/work/Spigot
index c07753b057..7840c2af5f 160000
--- a/work/Spigot
+++ b/work/Spigot
@@ -1 +1 @@
-Subproject commit c07753b057d92ef6c0f9ad8e8446f51bcc37604d
+Subproject commit 7840c2af5f487981d5a2eab4f9e832fdd7cfb298