reset meta block state on BlockStateMeta#setBlockState

This commit is contained in:
Jake Potrebic 2024-05-25 22:36:55 -07:00
parent 41bee55b53
commit 4e10fadfdc
No known key found for this signature in database
GPG key ID: ECE0B3C133C016C5

View file

@ -150,7 +150,7 @@ index 1ac3bec02fce28d5ce698305a7482a9eccbb1867..b494568f833dc21d4e2447ac3e5c5002
for (Pattern p : this.patterns) { for (Pattern p : this.patterns) {
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java
index 12911233c01d0ac1af9adbd157d56d28361fc76f..e5c2ab243fd56ef32321cbf127ef7b9d21fad56c 100644 index 12911233c01d0ac1af9adbd157d56d28361fc76f..322d5f19d0c156bf6e46202d2e185d8aec455492 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java
@@ -142,9 +142,17 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta @@ -142,9 +142,17 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
@ -411,7 +411,7 @@ index 12911233c01d0ac1af9adbd157d56d28361fc76f..e5c2ab243fd56ef32321cbf127ef7b9d
} }
private static CraftBlockEntityState<?> getBlockState(Material material, CompoundTag blockEntityTag) { private static CraftBlockEntityState<?> getBlockState(Material material, CompoundTag blockEntityTag) {
@@ -331,7 +407,19 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta @@ -331,7 +407,22 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
Class<?> blockStateType = CraftBlockStates.getBlockStateType(stateMaterial); Class<?> blockStateType = CraftBlockStates.getBlockStateType(stateMaterial);
Preconditions.checkArgument(blockStateType == blockState.getClass() && blockState instanceof CraftBlockEntityState, "Invalid blockState for " + this.material); Preconditions.checkArgument(blockStateType == blockState.getClass() && blockState instanceof CraftBlockEntityState, "Invalid blockState for " + this.material);
@ -427,6 +427,9 @@ index 12911233c01d0ac1af9adbd157d56d28361fc76f..e5c2ab243fd56ef32321cbf127ef7b9d
+ patchedMap.setAll(map); + patchedMap.setAll(map);
+ final DataComponentPatch patch = patchedMap.asPatch(); + final DataComponentPatch patch = patchedMap.asPatch();
+ this.updateFromPatch(patch, null); + this.updateFromPatch(patch, null);
+ // we have to reset the fields because this should be like a "new" block entity is being used
+ this.blockEntityTag = CustomData.EMPTY;
+ this.components = DataComponentMap.EMPTY;
+ this.updateBlockState(patch); + this.updateBlockState(patch);
+ // Paper end + // Paper end
} }