From 2f393a5bddd78a161ad709da6a2f27874dd64d17 Mon Sep 17 00:00:00 2001 From: Jake Potrebic <jake.m.potrebic@gmail.com> Date: Wed, 16 Mar 2022 18:28:06 -0700 Subject: [PATCH] Added method to check snapshot state of TileStates (#7325) --- ...-get-a-BlockState-without-a-snapshot.patch | 23 +++++++++++++++++++ ...-get-a-BlockState-without-a-snapshot.patch | 12 ++++++++++ 2 files changed, 35 insertions(+) diff --git a/patches/api/API-to-get-a-BlockState-without-a-snapshot.patch b/patches/api/API-to-get-a-BlockState-without-a-snapshot.patch index edbbe3a954..1df53fbe18 100644 --- a/patches/api/API-to-get-a-BlockState-without-a-snapshot.patch +++ b/patches/api/API-to-get-a-BlockState-without-a-snapshot.patch @@ -29,3 +29,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 /** * Returns the biome that this block resides in * +diff --git a/src/main/java/org/bukkit/block/TileState.java b/src/main/java/org/bukkit/block/TileState.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/block/TileState.java ++++ b/src/main/java/org/bukkit/block/TileState.java +@@ -0,0 +0,0 @@ public interface TileState extends BlockState, PersistentDataHolder { + @NotNull + @Override + PersistentDataContainer getPersistentDataContainer(); ++ ++ // Paper start ++ /** ++ * Checks if this TileState is a snapshot or a live ++ * representation of the underlying tile entity. ++ * <p> ++ * NOTE: You may still have to call {@link BlockState#update()} on ++ * live representations to update any visuals on the block. ++ * ++ * @return true if this is a snapshot ++ * @see Block#getState(boolean) ++ */ ++ boolean isSnapshot(); ++ // Paper end + } diff --git a/patches/server/API-to-get-a-BlockState-without-a-snapshot.patch b/patches/server/API-to-get-a-BlockState-without-a-snapshot.patch index f69c6885b4..39dd7a02c9 100644 --- a/patches/server/API-to-get-a-BlockState-without-a-snapshot.patch +++ b/patches/server/API-to-get-a-BlockState-without-a-snapshot.patch @@ -101,6 +101,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } public void refreshSnapshot() { +@@ -0,0 +0,0 @@ public class CraftBlockEntityState<T extends BlockEntity> extends CraftBlockStat + public PersistentDataContainer getPersistentDataContainer() { + return this.getSnapshot().persistentDataContainer; + } ++ ++ // Paper start ++ @Override ++ public boolean isSnapshot() { ++ return !this.snapshotDisabled; ++ } ++ // Paper end + } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java