Paper/nms-patches/BlockShulkerBox.patch

56 lines
2.5 KiB
Diff
Raw Normal View History

2016-11-17 02:41:03 +01:00
--- a/net/minecraft/server/BlockShulkerBox.java
+++ b/net/minecraft/server/BlockShulkerBox.java
2017-05-14 04:00:00 +02:00
@@ -92,7 +92,32 @@
2016-11-17 02:41:03 +01:00
}
- 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());
2017-05-14 04:00:00 +02:00
+ tileentityshulkerbox.setCustomName("");
2016-11-17 02:41:03 +01:00
+ }
+
+ 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()) {
2017-05-14 04:00:00 +02:00
@@ -108,7 +133,7 @@
2016-11-17 02:41:03 +01:00
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()) {
2017-05-14 04:00:00 +02:00
@@ -126,8 +151,8 @@
a(world, blockposition, itemstack);
}
- world.updateAdjacentComparators(blockposition, iblockdata.getBlock());
}
+ world.updateAdjacentComparators(blockposition, iblockdata.getBlock()); // CraftBukkit - moved down
super.remove(world, blockposition, iblockdata);
}