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
|
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
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||||
+++ b/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;
|
@@ -83,6 +83,12 @@ import org.bukkit.persistence.PersistentDataContainer;
|
||||||
|
@ -253,7 +253,7 @@ index 01ceb8de8411193fa407bf19bbd25a4bf44765d3..c4a87a98af866b9831ff5da2c574b037
|
||||||
// Paper end
|
// Paper end
|
||||||
CraftMetaCompass.LODESTONE_DIMENSION.NBT,
|
CraftMetaCompass.LODESTONE_DIMENSION.NBT,
|
||||||
CraftMetaCompass.LODESTONE_POS.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
|
// Paper end
|
||||||
|
|
||||||
|
@ -349,20 +349,18 @@ index 01ceb8de8411193fa407bf19bbd25a4bf44765d3..c4a87a98af866b9831ff5da2c574b037
|
||||||
+
|
+
|
||||||
+ private @Nullable Namespaced deserializeNamespaced(String raw) {
|
+ private @Nullable Namespaced deserializeNamespaced(String raw) {
|
||||||
+ boolean isTag = raw.length() > 0 && raw.codePointAt(0) == '#';
|
+ 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 {
|
+ 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) {
|
+ } catch (com.mojang.brigadier.exceptions.CommandSyntaxException e) {
|
||||||
+ return null;
|
+ return null;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ net.minecraft.resources.ResourceLocation key = null;
|
+ net.minecraft.resources.ResourceLocation key = null;
|
||||||
+ if (isTag) {
|
+ if (isTag && result.right().isPresent() && result.right().get().tag() instanceof net.minecraft.core.HolderSet.Named<net.minecraft.world.level.block.Block> namedSet) {
|
||||||
+ if (blockParser.getTag() != null) {
|
+ key = namedSet.key().location();
|
||||||
+ key = blockParser.getTag().location();
|
+ } else if (result.left().isPresent()) {
|
||||||
+ }
|
+ key = net.minecraft.core.Registry.BLOCK.getKey(result.left().get().blockState().getBlock());
|
||||||
+ } else {
|
|
||||||
+ key = blockParser.id;
|
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ if (key == null) {
|
+ if (key == null) {
|
||||||
|
|
Loading…
Reference in New Issue