From a16970ac1beeafc78f017f72334191986981aae2 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Tue, 7 Jun 2022 18:13:05 -0700 Subject: [PATCH] Fix CanPlaceOn/CanDestroy API issues --- ...I-for-CanPlaceOn-and-CanDestroy-NBT-v.patch | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/patches/server/0259-Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch b/patches/server/0259-Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch index 3f7c07092..4ae690f9d 100644 --- a/patches/server/0259-Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch +++ b/patches/server/0259-Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Implement an API for CanPlaceOn and CanDestroy NBT values diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java -index 01ceb8de8411193fa407bf19bbd25a4bf44765d3..c4a87a98af866b9831ff5da2c574b0370d639d52 100644 +index 01ceb8de8411193fa407bf19bbd25a4bf44765d3..4304ee35a9bd912c2ae4058febf22f0eea25adbd 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java @@ -83,6 +83,12 @@ import org.bukkit.persistence.PersistentDataContainer; @@ -253,7 +253,7 @@ index 01ceb8de8411193fa407bf19bbd25a4bf44765d3..c4a87a98af866b9831ff5da2c574b037 // Paper end CraftMetaCompass.LODESTONE_DIMENSION.NBT, CraftMetaCompass.LODESTONE_POS.NBT, -@@ -1487,4 +1630,148 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { +@@ -1487,4 +1630,146 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { } // Paper end @@ -349,20 +349,18 @@ index 01ceb8de8411193fa407bf19bbd25a4bf44765d3..c4a87a98af866b9831ff5da2c574b037 + + private @Nullable Namespaced deserializeNamespaced(String raw) { + boolean isTag = raw.length() > 0 && raw.codePointAt(0) == '#'; -+ net.minecraft.commands.arguments.blocks.BlockStateParser blockParser = new net.minecraft.commands.arguments.blocks.BlockStateParser(new com.mojang.brigadier.StringReader(raw), true); ++ com.mojang.datafixers.util.Either result; + try { -+ blockParser = blockParser.parse(false); ++ result = net.minecraft.commands.arguments.blocks.BlockStateParser.parseForTesting(net.minecraft.core.Registry.BLOCK, raw, false); + } catch (com.mojang.brigadier.exceptions.CommandSyntaxException e) { + return null; + } + + net.minecraft.resources.ResourceLocation key = null; -+ if (isTag) { -+ if (blockParser.getTag() != null) { -+ key = blockParser.getTag().location(); -+ } -+ } else { -+ key = blockParser.id; ++ if (isTag && result.right().isPresent() && result.right().get().tag() instanceof net.minecraft.core.HolderSet.Named namedSet) { ++ key = namedSet.key().location(); ++ } else if (result.left().isPresent()) { ++ key = net.minecraft.core.Registry.BLOCK.getKey(result.left().get().blockState().getBlock()); + } + + if (key == null) {