From 7d3b4f409ccf5867e296dc56e98973a5cc84a1cf Mon Sep 17 00:00:00 2001
From: BillyGalbreath <BillyGalbreath@users.noreply.github.com>
Date: Thu, 23 Aug 2018 12:02:57 -0500
Subject: [PATCH] Fix MC-124320 (#1369)

---
 Spigot-Server-Patches/Fix-MC-124320.patch | 51 +++++++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 Spigot-Server-Patches/Fix-MC-124320.patch

diff --git a/Spigot-Server-Patches/Fix-MC-124320.patch b/Spigot-Server-Patches/Fix-MC-124320.patch
new file mode 100644
index 0000000000..686063ae2b
--- /dev/null
+++ b/Spigot-Server-Patches/Fix-MC-124320.patch
@@ -0,0 +1,51 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: BillyGalbreath <Blake.Galbreath@GMail.com>
+Date: Thu, 23 Aug 2018 09:25:30 -0500
+Subject: [PATCH] Fix MC-124320
+
+
+diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java
+index fd1aec43b..1dc2b11e3 100644
+--- a/src/main/java/net/minecraft/server/Block.java
++++ b/src/main/java/net/minecraft/server/Block.java
+@@ -0,0 +0,0 @@ public class Block implements IMaterial {
+         return tag.isTagged(this);
+     }
+ 
++    public static IBlockData getValidBlockForPosition(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) { return Block.b(iblockdata, generatoraccess, blockposition); } // Paper - OBFHELPER
+     public static IBlockData b(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) {
+         IBlockData iblockdata1 = iblockdata;
+         BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition();
+diff --git a/src/main/java/net/minecraft/server/EntityEnderman.java b/src/main/java/net/minecraft/server/EntityEnderman.java
+index 2db0eb494..9e708f1fa 100644
+--- a/src/main/java/net/minecraft/server/EntityEnderman.java
++++ b/src/main/java/net/minecraft/server/EntityEnderman.java
+@@ -0,0 +0,0 @@ public class EntityEnderman extends EntityMonster {
+             if (block.a(TagsBlock.G) && flag) {
+                 // CraftBukkit start - Pickup event
+                 if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
+-                    this.enderman.setCarried(iblockdata);
++                    //this.enderman.setCarried(iblockdata); // Paper - moved down
+                     world.setAir(blockposition);
++                    this.enderman.setCarried(Block.getValidBlockForPosition(iblockdata, this.enderman.world, blockposition)); // Paper - Fix MC-124320
+                 }
+                 // CraftBukkit end
+             }
+@@ -0,0 +0,0 @@ public class EntityEnderman extends EntityMonster {
+ 
+     static class PathfinderGoalEndermanPlaceBlock extends PathfinderGoal {
+ 
++        private EntityEnderman getEnderman() { return this.a; } // Paper - OBFHELPER
+         private final EntityEnderman a;
+ 
+         public PathfinderGoalEndermanPlaceBlock(EntityEnderman entityenderman) {
+@@ -0,0 +0,0 @@ public class EntityEnderman extends EntityMonster {
+             BlockPosition blockposition = new BlockPosition(i, j, k);
+             IBlockData iblockdata = world.getType(blockposition);
+             IBlockData iblockdata1 = world.getType(blockposition.down());
+-            IBlockData iblockdata2 = this.a.getCarried();
++            IBlockData iblockdata2 = Block.getValidBlockForPosition(getEnderman().getCarried(), getEnderman().world, blockposition); // Paper - Fix MC-124320
+ 
+             if (iblockdata2 != null && this.a(world, blockposition, iblockdata2, iblockdata, iblockdata1)) {
+                 // CraftBukkit start - Place event
+--
\ No newline at end of file