aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0366-Block-Ticking-API.patch
blob: 02fed74c9e1c0bba511d6c7fbeb095acba2a19ef (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
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
Date: Sun, 26 Dec 2021 13:23:52 -0500
Subject: [PATCH] Block Ticking API


diff --git a/src/main/java/org/bukkit/block/Block.java b/src/main/java/org/bukkit/block/Block.java
index cf9600c743e977312c0a15c455d602391797ef34..8a842840e1a2652a6356d4a56e4749a5ba36e902 100644
--- a/src/main/java/org/bukkit/block/Block.java
+++ b/src/main/java/org/bukkit/block/Block.java
@@ -589,6 +589,41 @@ public interface Block extends Metadatable, Translatable, net.kyori.adventure.tr
      * @return true if the block was destroyed
      */
     boolean breakNaturally(@NotNull ItemStack tool, boolean triggerEffect, boolean dropExperience);
+
+    /**
+     * Causes the block to be ticked, this is different from {@link Block#randomTick()},
+     * in that it is usually scheduled to occur, for example
+     * redstone components being activated, sand falling, etc.
+     * <p>
+     * This method may directly fire events relating to block ticking.
+     *
+     * @see #fluidTick()
+     */
+    void tick();
+
+    /**
+     * Causes the fluid to be ticked, this is different from {@link Block#randomTick()},
+     * in that it is usually scheduled to occur, for example
+     * causing waterlogged blocks to spread.
+     * <p>
+     * This method may directly fire events relating to fluid ticking.
+     *
+     * @see #tick()
+     */
+    void fluidTick();
+
+    /**
+     * Causes the block to be ticked randomly.
+     * This has a chance to execute naturally if {@link BlockData#isRandomlyTicked()} is true.
+     * <p>
+     * For certain blocks, this behavior may be the same as {@link Block#tick()}.
+     * <p>
+     * This method may directly fire events relating to block random ticking.
+     *
+     * @see #tick()
+     * @see #fluidTick()
+     */
+    void randomTick();
     // Paper end
 
     /**
diff --git a/src/main/java/org/bukkit/block/data/BlockData.java b/src/main/java/org/bukkit/block/data/BlockData.java
index 8a26e7215672f5fd4555fd455c9b1571488f0259..64188a78211195fe792eac427e483e1984f52318 100644
--- a/src/main/java/org/bukkit/block/data/BlockData.java
+++ b/src/main/java/org/bukkit/block/data/BlockData.java
@@ -291,4 +291,14 @@ public interface BlockData extends Cloneable {
      */
     float getDestroySpeed(@NotNull ItemStack itemStack, boolean considerEnchants);
     // Paper end - destroy speed API
+
+    // Paper start - Tick API
+    /**
+     * Gets if this block is ticked randomly in the world.
+     * The blocks current state may change this value.
+     *
+     * @return is ticked randomly
+     */
+    boolean isRandomlyTicked();
+    // Paper end - Tick API
 }