From 04875eb8c55911b2e64aeb40268176bb5b2b77ec Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Wed, 24 Nov 2021 10:27:25 -0800
Subject: [PATCH] moar patches

---
 ...xact-interaction-point-in-PlayerInte.patch |  0
 .../api/Add-BlockPreDispenseEvent.patch       |  0
 .../api/Add-StructureLocateEvent.patch        |  0
 .../api/Add-sendOpLevel-API.patch             |  0
 ...onent-with-empty-text-instead-of-thr.patch |  0
 .../server/Add-StructureLocateEvent.patch     | 22 ++++++-------------
 .../server/Add-sendOpLevel-API.patch          |  0
 ...n-for-requiring-a-player-participant.patch | 22 +++----------------
 .../Configurable-max-leash-distance.patch     |  0
 ...pty-commands-shall-not-be-dispatched.patch |  0
 .../server/Fix-villager-boat-exploit.patch    |  3 +--
 ...PI-to-expose-exact-interaction-point.patch |  0
 .../Implement-BlockPreDispenseEvent.patch     |  0
 .../Make-schedule-command-per-world.patch     |  0
 ...ileHitEvent-call-when-fireballs-dead.patch |  0
 .../server/Remove-stale-POIs.patch            |  2 +-
 ...onent-with-empty-text-instead-of-thr.patch |  0
 17 files changed, 12 insertions(+), 37 deletions(-)
 rename patches/{unapplied => }/api/Add-API-to-get-exact-interaction-point-in-PlayerInte.patch (100%)
 rename patches/{unapplied => }/api/Add-BlockPreDispenseEvent.patch (100%)
 rename patches/{unapplied => }/api/Add-StructureLocateEvent.patch (100%)
 rename patches/{unapplied => }/api/Add-sendOpLevel-API.patch (100%)
 rename patches/{unapplied => }/api/Return-chat-component-with-empty-text-instead-of-thr.patch (100%)
 rename patches/{unapplied => }/server/Add-StructureLocateEvent.patch (63%)
 rename patches/{unapplied => }/server/Add-sendOpLevel-API.patch (100%)
 rename patches/{unapplied => }/server/Collision-option-for-requiring-a-player-participant.patch (81%)
 rename patches/{unapplied => }/server/Configurable-max-leash-distance.patch (100%)
 rename patches/{unapplied => }/server/Empty-commands-shall-not-be-dispatched.patch (100%)
 rename patches/{unapplied => }/server/Fix-villager-boat-exploit.patch (88%)
 rename patches/{unapplied => }/server/Implement-API-to-expose-exact-interaction-point.patch (100%)
 rename patches/{unapplied => }/server/Implement-BlockPreDispenseEvent.patch (100%)
 rename patches/{unapplied => }/server/Make-schedule-command-per-world.patch (100%)
 rename patches/{unapplied => }/server/Remove-ProjectileHitEvent-call-when-fireballs-dead.patch (100%)
 rename patches/{unapplied => }/server/Remove-stale-POIs.patch (88%)
 rename patches/{unapplied => }/server/Return-chat-component-with-empty-text-instead-of-thr.patch (100%)

diff --git a/patches/unapplied/api/Add-API-to-get-exact-interaction-point-in-PlayerInte.patch b/patches/api/Add-API-to-get-exact-interaction-point-in-PlayerInte.patch
similarity index 100%
rename from patches/unapplied/api/Add-API-to-get-exact-interaction-point-in-PlayerInte.patch
rename to patches/api/Add-API-to-get-exact-interaction-point-in-PlayerInte.patch
diff --git a/patches/unapplied/api/Add-BlockPreDispenseEvent.patch b/patches/api/Add-BlockPreDispenseEvent.patch
similarity index 100%
rename from patches/unapplied/api/Add-BlockPreDispenseEvent.patch
rename to patches/api/Add-BlockPreDispenseEvent.patch
diff --git a/patches/unapplied/api/Add-StructureLocateEvent.patch b/patches/api/Add-StructureLocateEvent.patch
similarity index 100%
rename from patches/unapplied/api/Add-StructureLocateEvent.patch
rename to patches/api/Add-StructureLocateEvent.patch
diff --git a/patches/unapplied/api/Add-sendOpLevel-API.patch b/patches/api/Add-sendOpLevel-API.patch
similarity index 100%
rename from patches/unapplied/api/Add-sendOpLevel-API.patch
rename to patches/api/Add-sendOpLevel-API.patch
diff --git a/patches/unapplied/api/Return-chat-component-with-empty-text-instead-of-thr.patch b/patches/api/Return-chat-component-with-empty-text-instead-of-thr.patch
similarity index 100%
rename from patches/unapplied/api/Return-chat-component-with-empty-text-instead-of-thr.patch
rename to patches/api/Return-chat-component-with-empty-text-instead-of-thr.patch
diff --git a/patches/unapplied/server/Add-StructureLocateEvent.patch b/patches/server/Add-StructureLocateEvent.patch
similarity index 63%
rename from patches/unapplied/server/Add-StructureLocateEvent.patch
rename to patches/server/Add-StructureLocateEvent.patch
index 981101a98c..9f34d62710 100644
--- a/patches/unapplied/server/Add-StructureLocateEvent.patch
+++ b/patches/server/Add-StructureLocateEvent.patch
@@ -8,22 +8,14 @@ diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java b
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
 +++ b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
-@@ -0,0 +0,0 @@ package net.minecraft.world.level.chunk;
- 
- import com.google.common.collect.Lists;
- import com.mojang.serialization.Codec;
-+import io.papermc.paper.event.world.StructureLocateEvent; // Paper - Add import due to naming conflict.
- import java.util.BitSet;
- import java.util.Iterator;
- import java.util.List;
-@@ -0,0 +0,0 @@ public abstract class ChunkGenerator {
+@@ -0,0 +0,0 @@ public abstract class ChunkGenerator implements BiomeManager.NoiseBiomeSource {
  
      @Nullable
-     public BlockPos findNearestMapFeature(ServerLevel world, StructureFeature<?> feature, BlockPos center, int radius, boolean skipExistingChunks) {
+     public BlockPos findNearestMapFeature(ServerLevel world, StructureFeature<?> structureFeature, BlockPos center, int radius, boolean skipExistingChunks) {
 +        // Paper start
 +        org.bukkit.World world1 = world.getWorld();
 +        org.bukkit.Location originLocation = new org.bukkit.Location(world1, center.getX(), center.getY(), center.getZ());
-+        StructureLocateEvent event = new StructureLocateEvent(world1, originLocation, org.bukkit.StructureType.getStructureTypes().get(feature.getFeatureName()), radius, skipExistingChunks);
++        io.papermc.paper.event.world.StructureLocateEvent event = new io.papermc.paper.event.world.StructureLocateEvent(world1, originLocation, org.bukkit.StructureType.getStructureTypes().get(structureFeature.getFeatureName()), radius, skipExistingChunks);
 +        if(!event.callEvent()) return null;
 +        // If event call set a final location, skip structure finding and just return set result.
 +        if(event.getResult() != null) return new BlockPos(event.getResult().getBlockX(), event.getResult().getBlockY(), event.getResult().getBlockZ());
@@ -32,8 +24,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +        // Get radius and whether to find unexplored structures (re)defined by event call.
 +        radius = event.getRadius();
 +        skipExistingChunks = event.shouldFindUnexplored();
-+        feature = StructureFeature.STRUCTURES_REGISTRY.get(event.getType().getName());
++        structureFeature = StructureFeature.STRUCTURES_REGISTRY.get(event.getType().getName());
 +        // Paper end
-         if (!this.biomeSource.canGenerateStructure(feature)) {
-             return null;
-         } else if (feature == StructureFeature.STRONGHOLD) {
+         if (structureFeature == StructureFeature.STRONGHOLD) {
+             this.generateStrongholds();
+             BlockPos blockposition1 = null;
diff --git a/patches/unapplied/server/Add-sendOpLevel-API.patch b/patches/server/Add-sendOpLevel-API.patch
similarity index 100%
rename from patches/unapplied/server/Add-sendOpLevel-API.patch
rename to patches/server/Add-sendOpLevel-API.patch
diff --git a/patches/unapplied/server/Collision-option-for-requiring-a-player-participant.patch b/patches/server/Collision-option-for-requiring-a-player-participant.patch
similarity index 81%
rename from patches/unapplied/server/Collision-option-for-requiring-a-player-participant.patch
rename to patches/server/Collision-option-for-requiring-a-player-participant.patch
index df0094b0a3..a450d53a4f 100644
--- a/patches/unapplied/server/Collision-option-for-requiring-a-player-participant.patch
+++ b/patches/server/Collision-option-for-requiring-a-player-participant.patch
@@ -31,7 +31,7 @@ diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/jav
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- 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, n
+@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
      public void push(Entity entity) {
          if (!this.isPassengerOfSameVehicle(entity)) {
              if (!entity.noPhysics && !this.noPhysics) {
@@ -43,19 +43,11 @@ diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.j
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
 +++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
-@@ -0,0 +0,0 @@ import net.minecraft.network.protocol.game.ClientboundAddEntityPacket;
- import net.minecraft.network.syncher.EntityDataAccessor;
- import net.minecraft.network.syncher.EntityDataSerializers;
- import net.minecraft.network.syncher.SynchedEntityData;
-+import net.minecraft.server.level.ServerPlayer;
- import net.minecraft.tags.BlockTags;
- import net.minecraft.tags.Tag;
- import net.minecraft.util.Mth;
 @@ -0,0 +0,0 @@ public abstract class AbstractMinecart extends Entity {
      public void push(Entity entity) {
          if (!this.level.isClientSide) {
              if (!entity.noPhysics && !this.noPhysics) {
-+                if (!this.level.paperConfig.allowVehicleCollisions && this.level.paperConfig.onlyPlayersCollide && !(entity instanceof ServerPlayer)) return; // Paper
++                if (!this.level.paperConfig.allowVehicleCollisions && this.level.paperConfig.onlyPlayersCollide && !(entity instanceof Player)) return; // Paper
                  if (!this.hasPassenger(entity)) {
                      // CraftBukkit start
                      VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), entity.getBukkitEntity());
@@ -63,19 +55,11 @@ diff --git a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java b/src/ma
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
 +++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
-@@ -0,0 +0,0 @@ import net.minecraft.network.protocol.game.ServerboundPaddleBoatPacket;
- import net.minecraft.network.syncher.EntityDataAccessor;
- import net.minecraft.network.syncher.EntityDataSerializers;
- import net.minecraft.network.syncher.SynchedEntityData;
-+import net.minecraft.server.level.ServerPlayer;
- import net.minecraft.sounds.SoundEvent;
- import net.minecraft.sounds.SoundEvents;
- import net.minecraft.tags.FluidTags;
 @@ -0,0 +0,0 @@ public class Boat extends Entity {
  
      @Override
      public void push(Entity entity) {
-+        if (!this.level.paperConfig.allowVehicleCollisions && this.level.paperConfig.onlyPlayersCollide && !(entity instanceof ServerPlayer)) return; // Paper
++        if (!this.level.paperConfig.allowVehicleCollisions && this.level.paperConfig.onlyPlayersCollide && !(entity instanceof Player)) return; // Paper
          if (entity instanceof Boat) {
              if (entity.getBoundingBox().minY < this.getBoundingBox().maxY) {
                  // CraftBukkit start
diff --git a/patches/unapplied/server/Configurable-max-leash-distance.patch b/patches/server/Configurable-max-leash-distance.patch
similarity index 100%
rename from patches/unapplied/server/Configurable-max-leash-distance.patch
rename to patches/server/Configurable-max-leash-distance.patch
diff --git a/patches/unapplied/server/Empty-commands-shall-not-be-dispatched.patch b/patches/server/Empty-commands-shall-not-be-dispatched.patch
similarity index 100%
rename from patches/unapplied/server/Empty-commands-shall-not-be-dispatched.patch
rename to patches/server/Empty-commands-shall-not-be-dispatched.patch
diff --git a/patches/unapplied/server/Fix-villager-boat-exploit.patch b/patches/server/Fix-villager-boat-exploit.patch
similarity index 88%
rename from patches/unapplied/server/Fix-villager-boat-exploit.patch
rename to patches/server/Fix-villager-boat-exploit.patch
index 2ab1f737b3..aa9e24ec0e 100644
--- a/patches/unapplied/server/Fix-villager-boat-exploit.patch
+++ b/patches/server/Fix-villager-boat-exploit.patch
@@ -13,8 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
                  entityplayer.stopRiding();
                  entity.getPassengersAndSelf().forEach((entity1) -> {
 +                    // Paper start
-+                    if (entity1 instanceof net.minecraft.world.entity.npc.AbstractVillager) {
-+                        final net.minecraft.world.entity.npc.AbstractVillager villager = (net.minecraft.world.entity.npc.AbstractVillager) entity1;
++                    if (entity1 instanceof net.minecraft.world.entity.npc.AbstractVillager villager) {
 +                        final net.minecraft.world.entity.player.Player human = villager.getTradingPlayer();
 +                        if (human != null) {
 +                            villager.setTradingPlayer(null);
diff --git a/patches/unapplied/server/Implement-API-to-expose-exact-interaction-point.patch b/patches/server/Implement-API-to-expose-exact-interaction-point.patch
similarity index 100%
rename from patches/unapplied/server/Implement-API-to-expose-exact-interaction-point.patch
rename to patches/server/Implement-API-to-expose-exact-interaction-point.patch
diff --git a/patches/unapplied/server/Implement-BlockPreDispenseEvent.patch b/patches/server/Implement-BlockPreDispenseEvent.patch
similarity index 100%
rename from patches/unapplied/server/Implement-BlockPreDispenseEvent.patch
rename to patches/server/Implement-BlockPreDispenseEvent.patch
diff --git a/patches/unapplied/server/Make-schedule-command-per-world.patch b/patches/server/Make-schedule-command-per-world.patch
similarity index 100%
rename from patches/unapplied/server/Make-schedule-command-per-world.patch
rename to patches/server/Make-schedule-command-per-world.patch
diff --git a/patches/unapplied/server/Remove-ProjectileHitEvent-call-when-fireballs-dead.patch b/patches/server/Remove-ProjectileHitEvent-call-when-fireballs-dead.patch
similarity index 100%
rename from patches/unapplied/server/Remove-ProjectileHitEvent-call-when-fireballs-dead.patch
rename to patches/server/Remove-ProjectileHitEvent-call-when-fireballs-dead.patch
diff --git a/patches/unapplied/server/Remove-stale-POIs.patch b/patches/server/Remove-stale-POIs.patch
similarity index 88%
rename from patches/unapplied/server/Remove-stale-POIs.patch
rename to patches/server/Remove-stale-POIs.patch
index 72ef5f2f16..f2e0e9949a 100644
--- a/patches/unapplied/server/Remove-stale-POIs.patch
+++ b/patches/server/Remove-stale-POIs.patch
@@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
              optional1.ifPresent((villageplacetype) -> {
                  this.getServer().execute(() -> {
 +                    // Paper start
-+                    if (!optional.isPresent() && this.getPoiManager().exists(blockposition1, com.google.common.base.Predicates.alwaysTrue())) {
++                    if (optional.isEmpty() && this.getPoiManager().exists(blockposition1, poiType -> true)) {
 +                        this.getPoiManager().remove(blockposition1);
 +                    }
 +                    // Paper end
diff --git a/patches/unapplied/server/Return-chat-component-with-empty-text-instead-of-thr.patch b/patches/server/Return-chat-component-with-empty-text-instead-of-thr.patch
similarity index 100%
rename from patches/unapplied/server/Return-chat-component-with-empty-text-instead-of-thr.patch
rename to patches/server/Return-chat-component-with-empty-text-instead-of-thr.patch