From a4a2f67946eabc72af5713d5799af93ebc310eee Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Mon, 27 May 2019 10:00:56 +1000
Subject: [PATCH] SPIGOT-4987: Shulkerbox does not save empty slots

---
 nms-patches/BehaviorUtil.patch | 35 ++++++++++++++++++++++++++++++++++
 nms-patches/LootTable.patch    | 14 --------------
 2 files changed, 35 insertions(+), 14 deletions(-)
 create mode 100644 nms-patches/BehaviorUtil.patch
 delete mode 100644 nms-patches/LootTable.patch

diff --git a/nms-patches/BehaviorUtil.patch b/nms-patches/BehaviorUtil.patch
new file mode 100644
index 0000000000..81f3a7e955
--- /dev/null
+++ b/nms-patches/BehaviorUtil.patch
@@ -0,0 +1,35 @@
+--- a/net/minecraft/server/BehaviorUtil.java
++++ b/net/minecraft/server/BehaviorUtil.java
+@@ -31,7 +31,7 @@
+     }
+ 
+     public static void c(EntityLiving entityliving, EntityLiving entityliving1) {
+-        entityliving.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorPositionEntity(entityliving1)));
++        entityliving.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorPositionEntity(entityliving1))); // CraftBukkit - decompile error
+     }
+ 
+     public static void d(EntityLiving entityliving, EntityLiving entityliving1) {
+@@ -46,11 +46,12 @@
+         BehaviorPositionEntity behaviorpositionentity = new BehaviorPositionEntity(entityliving1);
+         MemoryTarget memorytarget = new MemoryTarget(behaviorpositionentity, f, i);
+ 
+-        entityliving.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (Object) behaviorpositionentity);
+-        entityliving.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, (Object) memorytarget);
++        entityliving.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, behaviorpositionentity); // CraftBukkit - decompile error
++        entityliving.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, memorytarget); // CraftBukkit - decompile error
+     }
+ 
+     public static void a(EntityLiving entityliving, ItemStack itemstack, EntityLiving entityliving1) {
++        if (itemstack.isEmpty()) return; // CraftBukkit - SPIGOT-4940: no empty loot
+         double d0 = entityliving.locY - 0.30000001192092896D + (double) entityliving.getHeadHeight();
+         EntityItem entityitem = new EntityItem(entityliving.world, entityliving.locX, d0, entityliving.locZ, itemstack);
+         BlockPosition blockposition = new BlockPosition(entityliving1);
+@@ -66,7 +67,7 @@
+ 
+     public static SectionPosition a(WorldServer worldserver, SectionPosition sectionposition, int i) {
+         int j = worldserver.b(sectionposition);
+-        Stream stream = SectionPosition.a(sectionposition, i).filter((sectionposition1) -> {
++        Stream<SectionPosition> stream = SectionPosition.a(sectionposition, i).filter((sectionposition1) -> { // CraftBukkit - decompile error
+             return worldserver.b(sectionposition1) < j;
+         });
+ 
diff --git a/nms-patches/LootTable.patch b/nms-patches/LootTable.patch
deleted file mode 100644
index 06298ad61b..0000000000
--- a/nms-patches/LootTable.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- a/net/minecraft/server/LootTable.java
-+++ b/net/minecraft/server/LootTable.java
-@@ -40,6 +40,11 @@
- 
-     public static Consumer<ItemStack> a(Consumer<ItemStack> consumer) {
-         return (itemstack) -> {
-+            // CraftBukkit start - SPIGOT-4940: no empty loot
-+            if (itemstack.isEmpty()) {
-+                return;
-+            }
-+            // CraftBukkit end
-             if (itemstack.getCount() < itemstack.getMaxStackSize()) {
-                 consumer.accept(itemstack);
-             } else {