aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0359-Expand-FallingBlock-API.patch
blob: 0f65eb8961866f41058522239715b973cc915ba6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
Date: Sun, 5 Dec 2021 14:58:55 -0500
Subject: [PATCH] Expand FallingBlock API

- add auto expire setting
- add setter for block data
- add accessors for block state

Co-authored-by: Lukas Planz <lukas.planz@web.de>

diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index 7ff0ac9c78c3793791afbfa344a9ced3821d9638..fa81e440ad20ab8740cb073f515d1671dc6ea9a0 100644
--- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java
@@ -2270,8 +2270,10 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
      * @return The spawned {@link FallingBlock} instance
      * @throws IllegalArgumentException if {@link Location} or {@link
      *     MaterialData} are null or {@link Material} of the {@link MaterialData} is not a block
+     * @deprecated Use {@link #spawn(Location, Class, Consumer)} (or a variation thereof) in combination with {@link FallingBlock#setBlockData(BlockData)}
      */
     @NotNull
+    @Deprecated // Paper
     public FallingBlock spawnFallingBlock(@NotNull Location location, @NotNull MaterialData data) throws IllegalArgumentException;
 
     /**
@@ -2284,8 +2286,10 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
      * @return The spawned {@link FallingBlock} instance
      * @throws IllegalArgumentException if {@link Location} or {@link
      *     BlockData} are null
+     * @deprecated Use {@link #spawn(Location, Class, Consumer)} (or a variation thereof) in combination with {@link FallingBlock#setBlockData(BlockData)}
      */
     @NotNull
+    @org.jetbrains.annotations.ApiStatus.Obsolete // Paper
     public FallingBlock spawnFallingBlock(@NotNull Location location, @NotNull BlockData data) throws IllegalArgumentException;
 
     /**
@@ -2302,7 +2306,7 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
      * @return The spawned {@link FallingBlock} instance
      * @throws IllegalArgumentException if {@link Location} or {@link
      *     Material} are null or {@link Material} is not a block
-     * @deprecated Magic value
+     * @deprecated Magic value. Use {@link #spawn(Location, Class, Consumer)} (or a variation thereof) in combination with {@link FallingBlock#setBlockData(BlockData)}
      */
     @Deprecated
     @NotNull
diff --git a/src/main/java/org/bukkit/entity/FallingBlock.java b/src/main/java/org/bukkit/entity/FallingBlock.java
index ae1ce2ee2deb82f3f4144ec54b3ba119b437c5e9..7904c716a3b0869ebf2f9b416536c59121a539a8 100644
--- a/src/main/java/org/bukkit/entity/FallingBlock.java
+++ b/src/main/java/org/bukkit/entity/FallingBlock.java
@@ -26,6 +26,33 @@ public interface FallingBlock extends Entity {
      */
     @NotNull
     BlockData getBlockData();
+    // Paper start
+    /**
+     * Sets the data for the falling block.
+     * <br>
+     * Any potential additional data currently stored in the falling blocks {@link #getBlockState()} will be
+     * purged by calling this setter.
+     *
+     * @param blockData the data to use as the block
+     */
+    void setBlockData(@NotNull BlockData blockData);
+
+    /**
+     * Get the data of the falling block represented as a {@link org.bukkit.block.BlockState BlockState}
+     * which includes potential NBT data that gets applied when the block gets placed on landing.
+     *
+     * @return the BlockState representing this block
+     */
+    @NotNull
+    org.bukkit.block.BlockState getBlockState();
+
+    /**
+     * Sets the {@link BlockData} and possibly present tile entity data for the falling block.
+     *
+     * @param blockState the BlockState to use
+     */
+    void setBlockState(@NotNull org.bukkit.block.BlockState blockState);
+    // Paper end
 
     /**
      * Get if the falling block will break into an item if it cannot be placed.
@@ -137,4 +164,23 @@ public interface FallingBlock extends Entity {
     default org.bukkit.Location getSourceLoc() {
         return this.getOrigin();
     }
+    // Paper start - Auto expire setting
+    /**
+     * Sets if this falling block should expire after:
+     * - 30 seconds
+     * - 5 seconds and is outside of the world
+     *
+     * @return if this behavior occurs
+     */
+    boolean doesAutoExpire();
+
+    /**
+     * Sets if this falling block should expire after:
+     * - 30 seconds
+     * - 5 seconds and is outside of the world
+     *
+     * @param autoExpires if this behavior should occur
+     */
+    void shouldAutoExpire(boolean autoExpires);
+    // Paper end - Auto expire setting
 }