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 87dfc2fd1e2ff9e9449f1ce00dfb63e3e88839cd..350cbf64c17938021002d5fd67176c44b398231e 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -760,5 +760,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 3399e8cdf2230bd71444abb43829c54d7277ce36..6f7ee97e381e80d6e8cf6b9c3f40b5e25f6bf64b 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java +++ b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java @@ -617,4 +617,10 @@ public class CraftBlockData implements BlockData { return this.state.isFaceSturdy(EmptyBlockGetter.INSTANCE, BlockPos.ZERO, CraftBlock.blockFaceToNotch(face), CraftBlockSupport.toNMS(support)); } + // Paper start - Block tick API + @Override + public boolean isRandomlyTicked() { + return this.state.isRandomlyTicking(); + } + // Paper end }