From 55f4d6c7cb7ed2722db2c708f08e8cf7b55ee06f Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Sat, 16 Oct 2021 18:48:21 +1100 Subject: [PATCH] SPIGOT-6760: Chest#getInventory only returns one half of a double chest when one or both halves are blocked By: md_5 --- .../minecraft/world/level/block/BlockChest.patch | 16 ++++++++++++++++ .../org/bukkit/craftbukkit/block/CraftChest.java | 3 +-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockChest.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockChest.patch index f85841805f..7b906c105d 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockChest.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockChest.patch @@ -74,3 +74,19 @@ if (flag) { bipredicate = (generatoraccess, blockposition1) -> { +@@ -292,7 +307,14 @@ + @Nullable + @Override + public ITileInventory getInventory(IBlockData iblockdata, World world, BlockPosition blockposition) { +- return (ITileInventory) ((Optional) this.a(iblockdata, world, blockposition, false).apply(BlockChest.MENU_PROVIDER_COMBINER)).orElse((Object) null); ++ // CraftBukkit start ++ return getInventory(iblockdata, world, blockposition, false); ++ } ++ ++ @Nullable ++ public ITileInventory getInventory(IBlockData iblockdata, World world, BlockPosition blockposition, boolean ignoreObstructions) { ++ return (ITileInventory) ((Optional) this.a(iblockdata, world, blockposition, ignoreObstructions).apply(BlockChest.MENU_PROVIDER_COMBINER)).orElse((Object) null); ++ // CraftBukkit end + } + + public static DoubleBlockFinder.Combiner a(final LidBlockEntity lidblockentity) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java index 3a20de0aa6..b23029b48e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java @@ -1,6 +1,5 @@ package org.bukkit.craftbukkit.block; -import com.google.common.base.Preconditions; import net.minecraft.sounds.SoundEffects; import net.minecraft.world.ITileInventory; import net.minecraft.world.level.block.BlockChest; @@ -46,7 +45,7 @@ public class CraftChest extends CraftLootable implements Chest CraftWorld world = (CraftWorld) this.getWorld(); BlockChest blockChest = (BlockChest) (this.getType() == Material.CHEST ? Blocks.CHEST : Blocks.TRAPPED_CHEST); - ITileInventory nms = blockChest.getInventory(data, world.getHandle(), this.getPosition()); + ITileInventory nms = blockChest.getInventory(data, world.getHandle(), this.getPosition(), true); if (nms instanceof BlockChest.DoubleInventory) { inventory = new CraftInventoryDoubleChest((BlockChest.DoubleInventory) nms);