summaryrefslogtreecommitdiffstats
path: root/nms-patches/BlockShulkerBox.patch
blob: e292c35ef65d1e17b3988cf00b2fc9f7e3c9f079 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
--- a/net/minecraft/server/BlockShulkerBox.java
+++ b/net/minecraft/server/BlockShulkerBox.java
@@ -3,7 +3,7 @@
 public class BlockShulkerBox extends BlockTileEntity {
 
     public static final BlockStateEnum<EnumDirection> a = BlockStateDirection.of("facing");
-    private final EnumColor b;
+    public final EnumColor b; // PAIL: public, rename
 
     public BlockShulkerBox(EnumColor enumcolor) {
         super(Material.STONE, MaterialMapColor.b);
@@ -89,7 +89,32 @@
         tileentityshulkerbox.d(entityhuman);
     }
 
-    public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {}
+    // CraftBukkit start - override to prevent duplication when dropping
+    public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {
+        TileEntity tileentity = world.getTileEntity(blockposition);
+
+        if (tileentity instanceof TileEntityShulkerBox) {
+            TileEntityShulkerBox tileentityshulkerbox = (TileEntityShulkerBox) tileentity;
+
+            if (!tileentityshulkerbox.r() && tileentityshulkerbox.F()) {
+                ItemStack itemstack = new ItemStack(Item.getItemOf(this));
+                NBTTagCompound nbttagcompound = new NBTTagCompound();
+                NBTTagCompound nbttagcompound1 = new NBTTagCompound();
+
+                nbttagcompound.set("BlockEntityTag", ((TileEntityShulkerBox) tileentity).f(nbttagcompound1));
+                itemstack.setTag(nbttagcompound);
+                if (tileentityshulkerbox.hasCustomName()) {
+                    itemstack.g(tileentityshulkerbox.getName());
+                    tileentityshulkerbox.a("");
+                }
+
+                a(world, blockposition, itemstack);
+            }
+
+            world.updateAdjacentComparators(blockposition, iblockdata.getBlock());
+        }
+    }
+    // CraftBukkit end
 
     public void postPlace(World world, BlockPosition blockposition, IBlockData iblockdata, EntityLiving entityliving, ItemStack itemstack) {
         if (itemstack.hasName()) {
@@ -105,7 +130,7 @@
     public void remove(World world, BlockPosition blockposition, IBlockData iblockdata) {
         TileEntity tileentity = world.getTileEntity(blockposition);
 
-        if (tileentity instanceof TileEntityShulkerBox) {
+        if (false && tileentity instanceof TileEntityShulkerBox) { // CraftBukkit - moved up
             TileEntityShulkerBox tileentityshulkerbox = (TileEntityShulkerBox) tileentity;
 
             if (!tileentityshulkerbox.r() && tileentityshulkerbox.F()) {
@@ -123,8 +148,8 @@
                 a(world, blockposition, itemstack);
             }
 
-            world.updateAdjacentComparators(blockposition, iblockdata.getBlock());
         }
+        world.updateAdjacentComparators(blockposition, iblockdata.getBlock()); // CraftBukkit - moved down
 
         super.remove(world, blockposition, iblockdata);
     }