Paper/patches/api/0357-Block-Ticking-API.patch

72 lines
2.7 KiB
Diff
Raw Normal View History

2022-08-03 23:14:04 +02:00
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
2024-06-13 17:45:43 +02:00
index 87327df6a37668eaf87394b6b049e6d4badec6df..a13c8ddd4a1222e7a16debb61769af3758502d7c 100644
2022-08-03 23:14:04 +02:00
--- 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
2022-08-03 23:14:04 +02:00
* @return true if the block was destroyed
*/
boolean breakNaturally(@NotNull ItemStack tool, boolean triggerEffect, boolean dropExperience);
2022-08-03 23:14:04 +02:00
+
+ /**
+ * 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()
2022-08-03 23:14:04 +02:00
+ */
+ 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();
+
+ /**
2022-08-03 23:14:04 +02:00
+ * 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()
2022-08-03 23:14:04 +02:00
+ */
+ 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 a2dc7376b2a3d386b671c894f73389139e0d97bf..26b70af4a1f3db5b17957bfa644e758603f8863c 100644
2022-08-03 23:14:04 +02:00
--- a/src/main/java/org/bukkit/block/data/BlockData.java
+++ b/src/main/java/org/bukkit/block/data/BlockData.java
@@ -297,4 +297,14 @@ public interface BlockData extends Cloneable {
@Deprecated(forRemoval = true, since = "1.21")
float getDestroySpeed(@NotNull ItemStack itemStack, boolean considerEnchants);
// Paper end - destroy speed API
2022-08-03 23:14:04 +02:00
+
+ // 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
2022-08-03 23:14:04 +02:00
}