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 a10ca7df7863d76e2b32bf414437cbfc6d35c9b7..b6c4f3d34603929a56073444be5f25fda15ff0c7 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -755,5 +755,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 }