PaperMC/patches/server/0860-Block-Ticking-API.patch

49 lines
2.1 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: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 c04397cc60154ef55027c90be990b9dfb818fd2f..5401ab9f8f6ce12e1c5368dbc3acc78a250b3822 100644
2022-08-03 23:14:04 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
@@ -756,5 +756,21 @@ public class CraftBlock implements Block {
2022-08-03 23:14:04 +02:00
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
2023-06-08 10:47:19 +02:00
index 58d10e8909fea652810e30bbd4b24aaa5e038277..85c2e7f8399788caa4c7dfed4f8b1104a546fc21 100644
2022-08-03 23:14:04 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
2023-06-08 10:47:19 +02:00
@@ -680,4 +680,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()));
2022-08-03 23:14:04 +02:00
}
+
2022-08-03 23:14:04 +02:00
+ // Paper start - Block tick API
+ @Override
+ public boolean isRandomlyTicked() {
+ return this.state.isRandomlyTicking();
+ }
+ // Paper end
}