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

52 lines
2.0 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
index 13485933b8b897b5a9b35f337b43eab5c968f13a..390a2a2611df35a9ea6f1eb996b47e2aa4597ff0 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,21 @@ 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.
+ */
+ void tick();
+
+ /**
+ * 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()}.
+ */
+ 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
2023-04-04 11:47:16 +02:00
index 0d5ef61e100d972a5cf308b23d5e8f2fdbad5718..e65b7d1cf7b0655a3f31949f94f2f4a12e662c94 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
@@ -235,4 +235,14 @@ public interface BlockData extends Cloneable {
* @param mirror the mirror
2022-08-03 23:14:04 +02:00
*/
void mirror(@NotNull Mirror mirror);
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
}