summaryrefslogtreecommitdiffhomepage
path: root/patches/unapplied/server/0873-Block-Ticking-API.patch
blob: 4137528899b8de75e79cc4673f8aa8711ee42a62 (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
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
Date: Sun, 26 Dec 2021 13:23:46 -0500
Subject: [PATCH] Block Ticking API


diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
index e4e4a282a10bde462af1e60aa6be992c636b9726..3a201bb68ef34d53aee75ca248248c11c4a77c2c 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
@@ -758,5 +758,21 @@ public class CraftBlock implements Block {
     public boolean isValidTool(ItemStack itemStack) {
         return getDrops(itemStack).size() != 0;
     }
+
+    @Override
+    public void tick() {
+        net.minecraft.world.level.block.state.BlockState blockData = this.getNMS();
+        net.minecraft.server.level.ServerLevel level = this.world.getMinecraftWorld();
+
+        blockData.getBlock().tick(blockData, level, this.position, level.random);
+    }
+
+    @Override
+    public void randomTick() {
+        net.minecraft.world.level.block.state.BlockState blockData = this.getNMS();
+        net.minecraft.server.level.ServerLevel level = this.world.getMinecraftWorld();
+
+        blockData.getBlock().randomTick(blockData, level, this.position, level.random);
+    }
     // Paper end
 }
diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
index 9d09b3064fc0474170e6d584dd3ccb9899cfbd42..c061f76ff6ccf64d9eb53045e9bfabe2021e91ec 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
@@ -676,4 +676,11 @@ public class CraftBlockData implements BlockData {
     public void mirror(Mirror mirror) {
         this.state = this.state.mirror(net.minecraft.world.level.block.Mirror.valueOf(mirror.name()));
     }
+
+    // Paper start - Block tick API
+    @Override
+    public boolean isRandomlyTicked() {
+        return this.state.isRandomlyTicking();
+    }
+    // Paper end
 }