diff --git a/patches/api/Block-Ticking-API.patch b/patches/api/Block-Ticking-API.patch new file mode 100644 index 0000000000..dd89238668 --- /dev/null +++ b/patches/api/Block-Ticking-API.patch @@ -0,0 +1,51 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> +Date: Sun, 26 Dec 2021 13:23:52 -0500 +Subject: [PATCH] Block Ticking API + + +diff --git a/src/main/java/org/bukkit/block/Block.java b/src/main/java/org/bukkit/block/Block.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/block/Block.java ++++ b/src/main/java/org/bukkit/block/Block.java +@@ -0,0 +0,0 @@ public interface Block extends Metadatable, net.kyori.adventure.translation.Tran + * @return true if the block was destroyed + */ + boolean breakNaturally(@NotNull ItemStack tool, boolean triggerEffect); ++ ++ /** ++ * Causes the block to be ticked, this is different from {@link Block#randomTick()}, ++ * in that it is usually scheduled to occur, for example ++ * redstone components being activated, sand falling, etc. ++ */ ++ void tick(); ++ ++ /** ++ * Causes the block to be ticked randomly. ++ * This has a chance to execute naturally if {@link BlockData#isRandomlyTicked()} is true. ++ *
++ * For certain blocks, this behavior may be the same as {@link Block#tick()}. ++ */ ++ void randomTick(); + // Paper end + + /** +diff --git a/src/main/java/org/bukkit/block/data/BlockData.java b/src/main/java/org/bukkit/block/data/BlockData.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/block/data/BlockData.java ++++ b/src/main/java/org/bukkit/block/data/BlockData.java +@@ -0,0 +0,0 @@ public interface BlockData extends Cloneable { + * @return true if the face is sturdy and can support a block, false otherwise + */ + boolean isFaceSturdy(@NotNull BlockFace face, @NotNull BlockSupport support); ++ ++ // Paper start - Tick API ++ /** ++ * Gets if this block is ticked randomly in the world. ++ * The blocks current state may change this value. ++ * ++ * @return is ticked randomly ++ */ ++ boolean isRandomlyTicked(); ++ // Paper end + } diff --git a/patches/server/Block-Ticking-API.patch b/patches/server/Block-Ticking-API.patch new file mode 100644 index 0000000000..247f7b6aa1 --- /dev/null +++ b/patches/server/Block-Ticking-API.patch @@ -0,0 +1,47 @@ +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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java ++++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java ++++ b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java +@@ -0,0 +0,0 @@ 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 + }