SPIGOT-7632: Control middle clicking chest does not copy contents

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2024-04-25 08:41:39 +10:00
parent 660079166f
commit 715508e0dd
2 changed files with 8 additions and 3 deletions

View file

@ -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) {

View file

@ -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