3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 04:20:04 +01:00
Paper/patches/server/0873-Block-Ticking-API.patch

49 Zeilen
2.1 KiB
Diff

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 0d30b388d8d93a6dbbf8dfb30d26eb44c73e1e4e..962c950ca9c7e047a3aec215d4faa73676049d36 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
index a585deb47ceb721489e0da4a09a94922fef86a3f..27344a44b776311801b03034730fd6710190e11a 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
@@ -675,4 +675,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
}