From 715508e0ddbd8338f5a13423323e59ac1581076b Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Thu, 25 Apr 2024 08:41:39 +1000 Subject: [PATCH] SPIGOT-7632: Control middle clicking chest does not copy contents By: md_5 --- .../org/bukkit/craftbukkit/block/CraftBlockStates.java | 4 ++-- .../bukkit/craftbukkit/inventory/CraftMetaBlockState.java | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java index a1451a80c9..08787a5711 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java @@ -400,8 +400,8 @@ public final class CraftBlockStates { } @Deprecated - public static BlockState getBlockState(Material material, @Nullable NBTTagCompound blockEntityTag) { - return getBlockState(MinecraftServer.getDefaultRegistryAccess(), BlockPosition.ZERO, material, blockEntityTag); + public static BlockState getBlockState(BlockPosition blockPosition, Material material, @Nullable NBTTagCompound blockEntityTag) { + return getBlockState(MinecraftServer.getDefaultRegistryAccess(), blockPosition, material, blockEntityTag); } public static BlockState getBlockState(IWorldReader world, BlockPosition blockPosition, Material material, @Nullable NBTTagCompound blockEntityTag) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java index db61860f43..8420cf298e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java @@ -8,6 +8,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Set; +import net.minecraft.core.BlockPosition; import net.minecraft.core.component.DataComponentMap; import net.minecraft.core.component.DataComponentPatch; import net.minecraft.core.component.DataComponentType; @@ -17,6 +18,7 @@ import net.minecraft.core.component.TypedDataComponent; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.item.component.CustomData; +import net.minecraft.world.level.block.entity.TileEntity; import org.bukkit.Material; import org.bukkit.block.BlockState; import org.bukkit.configuration.serialization.DelegateDeserialization; @@ -321,6 +323,7 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta } private static CraftBlockEntityState getBlockState(Material material, NBTTagCompound blockEntityTag) { + BlockPosition pos = BlockPosition.ZERO; Material stateMaterial = (material != Material.SHIELD) ? material : shieldToBannerHack(); // Only actually used for jigsaws if (blockEntityTag != null) { if (material == Material.SHIELD) { @@ -330,10 +333,12 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta } else if (SHULKER_BOX_MATERIALS.contains(material)) { blockEntityTag.putString("id", "minecraft:shulker_box"); } + + pos = TileEntity.getPosFromTag(blockEntityTag); } // This is expected to always return a CraftBlockEntityState for the passed material: - return (CraftBlockEntityState) CraftBlockStates.getBlockState(stateMaterial, blockEntityTag); + return (CraftBlockEntityState) CraftBlockStates.getBlockState(pos, stateMaterial, blockEntityTag); } @Override