From 5b8bdf1dbc247cf57253c9d4f6cb8d200d1b5e01 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 27 Jun 2020 20:32:49 -0400
Subject: [PATCH] Fix Piglin issue

---
 Spigot-Server-Patches/FIX-DIS-SHIT.patch | 64 ------------------------
 Spigot-Server-Patches/MC-Dev-fixes.patch | 43 ++++++++++++++++
 2 files changed, 43 insertions(+), 64 deletions(-)
 delete mode 100644 Spigot-Server-Patches/FIX-DIS-SHIT.patch

diff --git a/Spigot-Server-Patches/FIX-DIS-SHIT.patch b/Spigot-Server-Patches/FIX-DIS-SHIT.patch
deleted file mode 100644
index 9216d714b7..0000000000
--- a/Spigot-Server-Patches/FIX-DIS-SHIT.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: MiniDigger | Martin <admin@minidigger.dev>
-Date: Fri, 26 Jun 2020 16:51:44 +0200
-Subject: [PATCH] FIX DIS SHIT
-
-
-diff --git a/src/main/java/net/minecraft/server/SensorHoglinSpecific.java b/src/main/java/net/minecraft/server/SensorHoglinSpecific.java
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
---- a/src/main/java/net/minecraft/server/SensorHoglinSpecific.java
-+++ b/src/main/java/net/minecraft/server/SensorHoglinSpecific.java
-@@ -0,0 +0,0 @@ public class SensorHoglinSpecific extends Sensor<EntityHoglin> {
-     protected void a(WorldServer worldserver, EntityHoglin entityhoglin) {
-         BehaviorController<?> behaviorcontroller = entityhoglin.getBehaviorController();
- 
--        behaviorcontroller.setMemory(MemoryModuleType.NEAREST_REPELLENT, this.b(worldserver, entityhoglin));
-+        // behaviorcontroller.setMemory(MemoryModuleType.NEAREST_REPELLENT, this.bb(worldserver, entityhoglin)); // Paper - fix dis shit (for now) + rename
-         Optional<EntityPiglin> optional = Optional.empty();
-         int i = 0;
-         List<EntityHoglin> list = Lists.newArrayList();
-@@ -0,0 +0,0 @@ public class SensorHoglinSpecific extends Sensor<EntityHoglin> {
-         }
- 
-         behaviorcontroller.setMemory(MemoryModuleType.NEAREST_VISIBLE_ADULT_PIGLIN, optional);
--        behaviorcontroller.setMemory(MemoryModuleType.NEAREST_VISIBLE_ADULT_HOGLINS, (Object) list);
--        behaviorcontroller.setMemory(MemoryModuleType.VISIBLE_ADULT_PIGLIN_COUNT, (Object) i);
--        behaviorcontroller.setMemory(MemoryModuleType.VISIBLE_ADULT_HOGLIN_COUNT, (Object) list.size());
-+        behaviorcontroller.setMemory(MemoryModuleType.NEAREST_VISIBLE_ADULT_HOGLINS, list); // Paper - decomp fix
-+        behaviorcontroller.setMemory(MemoryModuleType.VISIBLE_ADULT_PIGLIN_COUNT, i); // Paper - decomp fix
-+        behaviorcontroller.setMemory(MemoryModuleType.VISIBLE_ADULT_HOGLIN_COUNT, list.size()); // Paper - decomp fix
-     }
- 
--    private Optional<BlockPosition> b(WorldServer worldserver, EntityHoglin entityhoglin) {
-+    private Optional<BlockPosition> bb(WorldServer worldserver, EntityHoglin entityhoglin) { // Paper - rename
-         return BlockPosition.a(entityhoglin.getChunkCoordinates(), 8, 4, (blockposition) -> {
-             return worldserver.getType(blockposition).a((Tag) TagsBlock.HOGLIN_REPELLENTS);
-         });
-diff --git a/src/main/java/net/minecraft/server/SensorPiglinSpecific.java b/src/main/java/net/minecraft/server/SensorPiglinSpecific.java
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
---- a/src/main/java/net/minecraft/server/SensorPiglinSpecific.java
-+++ b/src/main/java/net/minecraft/server/SensorPiglinSpecific.java
-@@ -0,0 +0,0 @@ public class SensorPiglinSpecific extends Sensor<EntityLiving> {
-     protected void a(WorldServer worldserver, EntityLiving entityliving) {
-         BehaviorController<?> behaviorcontroller = entityliving.getBehaviorController();
- 
--        behaviorcontroller.setMemory(MemoryModuleType.NEAREST_REPELLENT, c(worldserver, entityliving));
-+//        behaviorcontroller.setMemory(MemoryModuleType.NEAREST_REPELLENT, c(worldserver, entityliving)); // Paper - fix dis shit (for now)
-         Optional<EntityInsentient> optional = Optional.empty();
-         Optional<EntityHoglin> optional1 = Optional.empty();
-         Optional<EntityHoglin> optional2 = Optional.empty();
-@@ -0,0 +0,0 @@ public class SensorPiglinSpecific extends Sensor<EntityLiving> {
-         behaviorcontroller.setMemory(MemoryModuleType.NEAREST_VISIBLE_ZOMBIFIED, optional4);
-         behaviorcontroller.setMemory(MemoryModuleType.NEAREST_TARGETABLE_PLAYER_NOT_WEARING_GOLD, optional5);
-         behaviorcontroller.setMemory(MemoryModuleType.NEAREST_PLAYER_HOLDING_WANTED_ITEM, optional6);
--        behaviorcontroller.setMemory(MemoryModuleType.NEAREST_ADULT_PIGLINS, (Object) list1);
--        behaviorcontroller.setMemory(MemoryModuleType.NEAREST_VISIBLE_ADULT_PIGLINS, (Object) list);
--        behaviorcontroller.setMemory(MemoryModuleType.VISIBLE_ADULT_PIGLIN_COUNT, (Object) list.size());
--        behaviorcontroller.setMemory(MemoryModuleType.VISIBLE_ADULT_HOGLIN_COUNT, (Object) i);
-+        behaviorcontroller.setMemory(MemoryModuleType.NEAREST_ADULT_PIGLINS, list1); // Paper - decomp fix
-+        behaviorcontroller.setMemory(MemoryModuleType.NEAREST_VISIBLE_ADULT_PIGLINS, list); // Paper - decomp fix
-+        behaviorcontroller.setMemory(MemoryModuleType.VISIBLE_ADULT_PIGLIN_COUNT, list.size()); // Paper - decomp fix
-+        behaviorcontroller.setMemory(MemoryModuleType.VISIBLE_ADULT_HOGLIN_COUNT, i); // Paper - decomp fix
-     }
- 
-     private static Optional<BlockPosition> c(WorldServer worldserver, EntityLiving entityliving) {
diff --git a/Spigot-Server-Patches/MC-Dev-fixes.patch b/Spigot-Server-Patches/MC-Dev-fixes.patch
index 9e0d8921a5..1835b78734 100644
--- a/Spigot-Server-Patches/MC-Dev-fixes.patch
+++ b/Spigot-Server-Patches/MC-Dev-fixes.patch
@@ -232,6 +232,49 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
          }
  
          return biomebase;
+diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java
+index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
+--- a/src/main/java/net/minecraft/server/BlockPosition.java
++++ b/src/main/java/net/minecraft/server/BlockPosition.java
+@@ -0,0 +0,0 @@ public class BlockPosition extends BaseBlockPosition {
+         };
+     }
+ 
+-    public static Iterable<BlockPosition> a(BlockPosition blockposition, int i, int j, int k) {
+-        int l = i + j + k;
++    public static Iterable<BlockPosition> a(BlockPosition blockposition, int p_i, int p_j, int p_k) { // Paper - decompile issues - variable name conflicts to inner class field refs
++        int l_decompiled = p_i + p_j + p_k; // Paper - decompile issues
+         int i1 = blockposition.getX();
+         int j1 = blockposition.getY();
+         int k1 = blockposition.getZ();
+@@ -0,0 +0,0 @@ public class BlockPosition extends BaseBlockPosition {
+                                 ++this.l;
+                                 if (this.l > this.j) {
+                                     ++this.i;
+-                                    if (this.i > l) {
++                                    if (this.i > l_decompiled) { // Paper - use proper l above (first line of this method)
+                                         return (BlockPosition) this.endOfData();
+                                     }
+ 
+-                                    this.j = Math.min(i, this.i);
++                                    this.j = Math.min(p_i, this.i); // Paper - decompile issues
+                                     this.l = -this.j;
+                                 }
+ 
+-                                this.k = Math.min(j, this.i - Math.abs(this.l));
++                                this.k = Math.min(p_j, this.i - Math.abs(this.l)); // Paper - decompile issues
+                                 this.m = -this.k;
+                             }
+ 
+@@ -0,0 +0,0 @@ public class BlockPosition extends BaseBlockPosition {
+                             int i2 = this.m;
+                             int j2 = this.i - Math.abs(l1) - Math.abs(i2);
+ 
+-                            if (j2 <= k) {
++                            if (j2 <= p_k) { // Paper - decompile issues
+                                 this.n = j2 != 0;
+                                 blockposition_mutableblockposition = this.h.d(i1 + l1, j1 + i2, k1 + j2);
+                             }
 diff --git a/src/main/java/net/minecraft/server/BlockStateEnum.java b/src/main/java/net/minecraft/server/BlockStateEnum.java
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/server/BlockStateEnum.java