From f8169475344b06c7148fd44916d6af0c7ea391e1 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 --- ...n-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/patches/server/Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch b/patches/server/Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch index 6f99e03d08..ed80b67ecf 100644 --- a/patches/server/Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch +++ b/patches/server/Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch @@ -349,20 +349,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + 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) {