3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 12:30:06 +01:00
Paper/patches/api/0373-Block-Ticking-API.patch
Jake Potrebic 6813244fb0
Fix/improve destroy speed API (#9645)
further improvements could be a method that takes in an entity
to account for effects
2023-08-25 10:57:11 -07:00

52 Zeilen
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 49fd2f54d2051553bd2df1c53f6b229ffa64892e..0b2a927b3500be5e6583a6d1ae90fe68473ff786 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 1f475424cc04d90f437cf0e38e07f5ae4020fb54..31111cea5ffd018c3c011c1f3b8befbbd33db5e5 100644
--- a/src/main/java/org/bukkit/block/data/BlockData.java
+++ b/src/main/java/org/bukkit/block/data/BlockData.java
@@ -272,4 +272,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
}