mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-29 22:13:42 +01:00
Fix CanPlaceOn/CanDestroy API issues
This commit is contained in:
parent
c515eb9a08
commit
a16970ac1b
@ -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<net.minecraft.commands.arguments.blocks.BlockStateParser.BlockResult, net.minecraft.commands.arguments.blocks.BlockStateParser.TagResult> 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<net.minecraft.world.level.block.Block> 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) {
|
||||
|
Loading…
Reference in New Issue
Block a user