Paper/patches/api/0378-Block-Ticking-API.patch
Jake Potrebic 5730a94208
Updated Upstream (Bukkit/CraftBukkit) (#8991)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
2b4582fb SPIGOT-5916: getLastColors does not work with the rgb colors

CraftBukkit Changes:
f7707086d SPIGOT-7299: Fix indirect/anvil damage events and minor improvements
2023-03-18 10:05:04 -07:00

52 lines
2.1 KiB
Diff

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
--- 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
* @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.
+ */
+ 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
index e7ea3f9a60968f257c631bbefcc31653e6ae3728..dcfd515af841cbb957a9a651b6350c88840c041e 100644
--- a/src/main/java/org/bukkit/block/data/BlockData.java
+++ b/src/main/java/org/bukkit/block/data/BlockData.java
@@ -199,4 +199,14 @@ public interface BlockData extends Cloneable {
* @return true if the face is sturdy and can support a block, false otherwise
*/
boolean isFaceSturdy(@NotNull BlockFace face, @NotNull BlockSupport support);
+
+ // 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
}