From 11bdf4fca701dbf472c775a44e2b8601536d2dd7 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Wed, 24 Nov 2021 11:33:17 -0800
Subject: [PATCH] moaaaaar patches

---
 ...Leash-variable-to-EntityUnleashEvent.patch |  0
 ...ainThreadExecutor-to-BukkitScheduler.patch |  0
 .../api/Add-missing-effects.patch             |  0
 ...w-adding-items-to-BlockDropItemEvent.patch |  0
 .../{unapplied => }/api/EntityMoveEvent.patch |  0
 .../api/Expose-Tracked-Players.patch          |  0
 .../api/add-DragonEggFormEvent.patch          |  0
 ...-entity-allow-attribute-registration.patch |  0
 ...Leash-variable-to-EntityUnleashEvent.patch |  0
 ...ainThreadExecutor-to-BukkitScheduler.patch |  0
 ...pport-for-hex-color-codes-in-console.patch |  2 +-
 ...w-adding-items-to-BlockDropItemEvent.patch |  0
 .../server/EntityMoveEvent.patch              |  0
 .../server/Expose-Tracked-Players.patch       |  0
 .../Inline-shift-direction-fields.patch       |  0
 ...ipes-should-return-an-immutable-list.patch |  2 +-
 .../Remove-streams-from-SensorNearest.patch   | 29 ++++---------------
 ...-shield-blocking-on-dimension-change.patch |  0
 ...ce-map-update-when-spawning-disabled.patch |  0
 .../server/add-DragonEggFormEvent.patch       |  3 +-
 ...disable-pathfinding-updates-on-block.patch |  9 +++---
 ...fix-dead-slime-setSize-invincibility.patch |  0
 ...-entity-allow-attribute-registration.patch |  0
 23 files changed, 13 insertions(+), 32 deletions(-)
 rename patches/{unapplied => }/api/Add-dropLeash-variable-to-EntityUnleashEvent.patch (100%)
 rename patches/{unapplied => }/api/Add-getMainThreadExecutor-to-BukkitScheduler.patch (100%)
 rename patches/{unapplied => }/api/Add-missing-effects.patch (100%)
 rename patches/{unapplied => }/api/Allow-adding-items-to-BlockDropItemEvent.patch (100%)
 rename patches/{unapplied => }/api/EntityMoveEvent.patch (100%)
 rename patches/{unapplied => }/api/Expose-Tracked-Players.patch (100%)
 rename patches/{unapplied => }/api/add-DragonEggFormEvent.patch (100%)
 rename patches/{unapplied => }/api/living-entity-allow-attribute-registration.patch (100%)
 rename patches/{unapplied => }/server/Add-dropLeash-variable-to-EntityUnleashEvent.patch (100%)
 rename patches/{unapplied => }/server/Add-getMainThreadExecutor-to-BukkitScheduler.patch (100%)
 rename patches/{unapplied => }/server/Add-support-for-hex-color-codes-in-console.patch (99%)
 rename patches/{unapplied => }/server/Allow-adding-items-to-BlockDropItemEvent.patch (100%)
 rename patches/{unapplied => }/server/EntityMoveEvent.patch (100%)
 rename patches/{unapplied => }/server/Expose-Tracked-Players.patch (100%)
 rename patches/{unapplied => }/server/Inline-shift-direction-fields.patch (100%)
 rename patches/{unapplied => }/server/Merchant-getRecipes-should-return-an-immutable-list.patch (76%)
 rename patches/{unapplied => }/server/Remove-streams-from-SensorNearest.patch (72%)
 rename patches/{unapplied => }/server/Reset-shield-blocking-on-dimension-change.patch (100%)
 rename patches/{unapplied => }/server/Skip-distance-map-update-when-spawning-disabled.patch (100%)
 rename patches/{unapplied => }/server/add-DragonEggFormEvent.patch (91%)
 rename patches/{unapplied => }/server/added-option-to-disable-pathfinding-updates-on-block.patch (93%)
 rename patches/{unapplied => }/server/fix-dead-slime-setSize-invincibility.patch (100%)
 rename patches/{unapplied => }/server/living-entity-allow-attribute-registration.patch (100%)

diff --git a/patches/unapplied/api/Add-dropLeash-variable-to-EntityUnleashEvent.patch b/patches/api/Add-dropLeash-variable-to-EntityUnleashEvent.patch
similarity index 100%
rename from patches/unapplied/api/Add-dropLeash-variable-to-EntityUnleashEvent.patch
rename to patches/api/Add-dropLeash-variable-to-EntityUnleashEvent.patch
diff --git a/patches/unapplied/api/Add-getMainThreadExecutor-to-BukkitScheduler.patch b/patches/api/Add-getMainThreadExecutor-to-BukkitScheduler.patch
similarity index 100%
rename from patches/unapplied/api/Add-getMainThreadExecutor-to-BukkitScheduler.patch
rename to patches/api/Add-getMainThreadExecutor-to-BukkitScheduler.patch
diff --git a/patches/unapplied/api/Add-missing-effects.patch b/patches/api/Add-missing-effects.patch
similarity index 100%
rename from patches/unapplied/api/Add-missing-effects.patch
rename to patches/api/Add-missing-effects.patch
diff --git a/patches/unapplied/api/Allow-adding-items-to-BlockDropItemEvent.patch b/patches/api/Allow-adding-items-to-BlockDropItemEvent.patch
similarity index 100%
rename from patches/unapplied/api/Allow-adding-items-to-BlockDropItemEvent.patch
rename to patches/api/Allow-adding-items-to-BlockDropItemEvent.patch
diff --git a/patches/unapplied/api/EntityMoveEvent.patch b/patches/api/EntityMoveEvent.patch
similarity index 100%
rename from patches/unapplied/api/EntityMoveEvent.patch
rename to patches/api/EntityMoveEvent.patch
diff --git a/patches/unapplied/api/Expose-Tracked-Players.patch b/patches/api/Expose-Tracked-Players.patch
similarity index 100%
rename from patches/unapplied/api/Expose-Tracked-Players.patch
rename to patches/api/Expose-Tracked-Players.patch
diff --git a/patches/unapplied/api/add-DragonEggFormEvent.patch b/patches/api/add-DragonEggFormEvent.patch
similarity index 100%
rename from patches/unapplied/api/add-DragonEggFormEvent.patch
rename to patches/api/add-DragonEggFormEvent.patch
diff --git a/patches/unapplied/api/living-entity-allow-attribute-registration.patch b/patches/api/living-entity-allow-attribute-registration.patch
similarity index 100%
rename from patches/unapplied/api/living-entity-allow-attribute-registration.patch
rename to patches/api/living-entity-allow-attribute-registration.patch
diff --git a/patches/unapplied/server/Add-dropLeash-variable-to-EntityUnleashEvent.patch b/patches/server/Add-dropLeash-variable-to-EntityUnleashEvent.patch
similarity index 100%
rename from patches/unapplied/server/Add-dropLeash-variable-to-EntityUnleashEvent.patch
rename to patches/server/Add-dropLeash-variable-to-EntityUnleashEvent.patch
diff --git a/patches/unapplied/server/Add-getMainThreadExecutor-to-BukkitScheduler.patch b/patches/server/Add-getMainThreadExecutor-to-BukkitScheduler.patch
similarity index 100%
rename from patches/unapplied/server/Add-getMainThreadExecutor-to-BukkitScheduler.patch
rename to patches/server/Add-getMainThreadExecutor-to-BukkitScheduler.patch
diff --git a/patches/unapplied/server/Add-support-for-hex-color-codes-in-console.patch b/patches/server/Add-support-for-hex-color-codes-in-console.patch
similarity index 99%
rename from patches/unapplied/server/Add-support-for-hex-color-codes-in-console.patch
rename to patches/server/Add-support-for-hex-color-codes-in-console.patch
index 1eeab1c72f..cb425ecbe0 100644
--- a/patches/unapplied/server/Add-support-for-hex-color-codes-in-console.patch
+++ b/patches/server/Add-support-for-hex-color-codes-in-console.patch
@@ -16,7 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +    annotationProcessor("org.apache.logging.log4j:log4j-core:2.14.1") // Paper - Needed to generate meta for out hex color converter plugin
      // Paper end
      implementation("org.apache.logging.log4j:log4j-iostreams:2.14.1") // Paper
-     implementation("org.apache.logging.log4j:log4j-api:2.14.1") // Paper
+     implementation("org.ow2.asm:asm:9.2")
 diff --git a/src/main/java/io/papermc/paper/console/HexFormattingConverter.java b/src/main/java/io/papermc/paper/console/HexFormattingConverter.java
 new file mode 100644
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
diff --git a/patches/unapplied/server/Allow-adding-items-to-BlockDropItemEvent.patch b/patches/server/Allow-adding-items-to-BlockDropItemEvent.patch
similarity index 100%
rename from patches/unapplied/server/Allow-adding-items-to-BlockDropItemEvent.patch
rename to patches/server/Allow-adding-items-to-BlockDropItemEvent.patch
diff --git a/patches/unapplied/server/EntityMoveEvent.patch b/patches/server/EntityMoveEvent.patch
similarity index 100%
rename from patches/unapplied/server/EntityMoveEvent.patch
rename to patches/server/EntityMoveEvent.patch
diff --git a/patches/unapplied/server/Expose-Tracked-Players.patch b/patches/server/Expose-Tracked-Players.patch
similarity index 100%
rename from patches/unapplied/server/Expose-Tracked-Players.patch
rename to patches/server/Expose-Tracked-Players.patch
diff --git a/patches/unapplied/server/Inline-shift-direction-fields.patch b/patches/server/Inline-shift-direction-fields.patch
similarity index 100%
rename from patches/unapplied/server/Inline-shift-direction-fields.patch
rename to patches/server/Inline-shift-direction-fields.patch
diff --git a/patches/unapplied/server/Merchant-getRecipes-should-return-an-immutable-list.patch b/patches/server/Merchant-getRecipes-should-return-an-immutable-list.patch
similarity index 76%
rename from patches/unapplied/server/Merchant-getRecipes-should-return-an-immutable-list.patch
rename to patches/server/Merchant-getRecipes-should-return-an-immutable-list.patch
index d31191d03a..bdb44d9c15 100644
--- a/patches/unapplied/server/Merchant-getRecipes-should-return-an-immutable-list.patch
+++ b/patches/server/Merchant-getRecipes-should-return-an-immutable-list.patch
@@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
      @Override
      public List<MerchantRecipe> getRecipes() {
 -        return Collections.unmodifiableList(Lists.transform(this.merchant.getOffers(), new Function<net.minecraft.world.item.trading.MerchantOffer, MerchantRecipe>() {
-+        return com.google.common.collect.ImmutableList.copyOf(Lists.transform(this.merchant.getOffers(), new Function<net.minecraft.world.item.trading.MerchantOffer, MerchantRecipe>() { // Paper - javadoc says 'an immutable list of trades' - not 'an unmodifiable view of a list of trades'. fixes issue with setRecipes(getRecipes())
++        return List.copyOf(Lists.transform(this.merchant.getOffers(), new Function<net.minecraft.world.item.trading.MerchantOffer, MerchantRecipe>() { // Paper - javadoc says 'an immutable list of trades' - not 'an unmodifiable view of a list of trades'. fixes issue with setRecipes(getRecipes())
              @Override
              public MerchantRecipe apply(net.minecraft.world.item.trading.MerchantOffer recipe) {
                  return recipe.asBukkit();
diff --git a/patches/unapplied/server/Remove-streams-from-SensorNearest.patch b/patches/server/Remove-streams-from-SensorNearest.patch
similarity index 72%
rename from patches/unapplied/server/Remove-streams-from-SensorNearest.patch
rename to patches/server/Remove-streams-from-SensorNearest.patch
index cda6bfea63..63f161e6a9 100644
--- a/patches/unapplied/server/Remove-streams-from-SensorNearest.patch
+++ b/patches/server/Remove-streams-from-SensorNearest.patch
@@ -44,25 +44,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +        // Paper end
      }
  }
-diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestLivingEntitySensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestLivingEntitySensor.java
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
---- a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestLivingEntitySensor.java
-+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestLivingEntitySensor.java
-@@ -0,0 +0,0 @@ public class NearestLivingEntitySensor extends Sensor<LivingEntity> {
-         list.sort(Comparator.comparingDouble(entity::distanceToSqr));
-         Brain<?> brain = entity.getBrain();
-         brain.setMemory(MemoryModuleType.NEAREST_LIVING_ENTITIES, list);
--        brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, list.stream().filter((livingEntity2) -> {
--            return isEntityTargetable(entity, livingEntity2);
--        }).collect(Collectors.toList()));
-+        // Paper start - remove streams in favour of lists
-+        List<LivingEntity> visibleMobs = new java.util.ArrayList<>(list);
-+        visibleMobs.removeIf(otherEntityLiving -> !Sensor.isEntityTargetable(entity, otherEntityLiving));
-+        brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, visibleMobs);
-+        // Paper end
-     }
- 
-     @Override
 diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java
@@ -71,12 +52,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
  
      @Override
      protected void doTick(ServerLevel world, LivingEntity entity) {
--        List<Player> list = world.players().stream().filter(EntitySelector.NO_SPECTATORS).filter((serverPlayer) -> {
--            return entity.closerThan(serverPlayer, 16.0D);
+-        List<Player> list = world.players().stream().filter(EntitySelector.NO_SPECTATORS).filter((player) -> {
+-            return entity.closerThan(player, 16.0D);
 -        }).sorted(Comparator.comparingDouble(entity::distanceToSqr)).collect(Collectors.toList());
-+        // Paper start - remove streams in favour of lists
-+        List<Player> players = new java.util.ArrayList<>(world.players());
-+        players.removeIf(player -> !EntitySelector.NO_SPECTATORS.test(player) || !entity.closerThan(player, 16.0D)); // Paper - removeIf only re-allocates once compared to iterator
++        List<Player> players= new java.util.ArrayList<>(world.players());
++        players.removeIf(player -> !EntitySelector.NO_SPECTATORS.test(player) || !entity.closerThan(player, 16.0D));
++        players.sort(Comparator.comparingDouble(entity::distanceTo));
          Brain<?> brain = entity.getBrain();
 -        brain.setMemory(MemoryModuleType.NEAREST_PLAYERS, list);
 -        List<Player> list2 = list.stream().filter((player) -> {
diff --git a/patches/unapplied/server/Reset-shield-blocking-on-dimension-change.patch b/patches/server/Reset-shield-blocking-on-dimension-change.patch
similarity index 100%
rename from patches/unapplied/server/Reset-shield-blocking-on-dimension-change.patch
rename to patches/server/Reset-shield-blocking-on-dimension-change.patch
diff --git a/patches/unapplied/server/Skip-distance-map-update-when-spawning-disabled.patch b/patches/server/Skip-distance-map-update-when-spawning-disabled.patch
similarity index 100%
rename from patches/unapplied/server/Skip-distance-map-update-when-spawning-disabled.patch
rename to patches/server/Skip-distance-map-update-when-spawning-disabled.patch
diff --git a/patches/unapplied/server/add-DragonEggFormEvent.patch b/patches/server/add-DragonEggFormEvent.patch
similarity index 91%
rename from patches/unapplied/server/add-DragonEggFormEvent.patch
rename to patches/server/add-DragonEggFormEvent.patch
index 6e1a0ebc83..5f5c2ba6df 100644
--- a/patches/unapplied/server/add-DragonEggFormEvent.patch
+++ b/patches/server/add-DragonEggFormEvent.patch
@@ -14,10 +14,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
              this.spawnNewGateway();
 +            // Paper start - DragonEggFormEvent
 +            BlockPos eggPosition = this.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, EndPodiumFeature.END_PODIUM_LOCATION);
-+            org.bukkit.craftbukkit.block.CraftBlock eggBlock = org.bukkit.craftbukkit.block.CraftBlock.at(this.level, eggPosition);
 +            org.bukkit.craftbukkit.block.CraftBlockState eggState = org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(this.level, eggPosition);
 +            eggState.setData(Blocks.DRAGON_EGG.defaultBlockState());
-+            io.papermc.paper.event.block.DragonEggFormEvent eggEvent = new io.papermc.paper.event.block.DragonEggFormEvent(eggBlock, eggState,
++            io.papermc.paper.event.block.DragonEggFormEvent eggEvent = new io.papermc.paper.event.block.DragonEggFormEvent(org.bukkit.craftbukkit.block.CraftBlock.at(this.level, eggPosition), eggState,
 +                    new org.bukkit.craftbukkit.boss.CraftDragonBattle(this));
 +            // Paper end - DragonEggFormEvent
              if (this.level.paperConfig.enderDragonsDeathAlwaysPlacesDragonEgg || !this.previouslyKilled) { // Paper - always place dragon egg
diff --git a/patches/unapplied/server/added-option-to-disable-pathfinding-updates-on-block.patch b/patches/server/added-option-to-disable-pathfinding-updates-on-block.patch
similarity index 93%
rename from patches/unapplied/server/added-option-to-disable-pathfinding-updates-on-block.patch
rename to patches/server/added-option-to-disable-pathfinding-updates-on-block.patch
index 9d5406da93..715ee8984c 100644
--- a/patches/unapplied/server/added-option-to-disable-pathfinding-updates-on-block.patch
+++ b/patches/server/added-option-to-disable-pathfinding-updates-on-block.patch
@@ -9,16 +9,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
 +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
 @@ -0,0 +0,0 @@ public class PaperWorldConfig {
-     private void enderDragonsDeathAlwaysPlacesDragonEgg() {
          enderDragonsDeathAlwaysPlacesDragonEgg = getBoolean("ender-dragons-death-always-places-dragon-egg", enderDragonsDeathAlwaysPlacesDragonEgg);
      }
-+
+ 
 +    public boolean updatePathfindingOnBlockUpdate = true;
 +    private void setUpdatePathfindingOnBlockUpdate() {
 +        updatePathfindingOnBlockUpdate = getBoolean("update-pathfinding-on-block-update", this.updatePathfindingOnBlockUpdate);
 +    }
- }
- 
++
+     public boolean phantomIgnoreCreative = true;
+     public boolean phantomOnlyAttackInsomniacs = true;
+     private void phantomSettings() {
 diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
diff --git a/patches/unapplied/server/fix-dead-slime-setSize-invincibility.patch b/patches/server/fix-dead-slime-setSize-invincibility.patch
similarity index 100%
rename from patches/unapplied/server/fix-dead-slime-setSize-invincibility.patch
rename to patches/server/fix-dead-slime-setSize-invincibility.patch
diff --git a/patches/unapplied/server/living-entity-allow-attribute-registration.patch b/patches/server/living-entity-allow-attribute-registration.patch
similarity index 100%
rename from patches/unapplied/server/living-entity-allow-attribute-registration.patch
rename to patches/server/living-entity-allow-attribute-registration.patch