aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJake Potrebic <[email protected]>2024-04-19 13:03:32 -0700
committerGitHub <[email protected]>2024-04-19 13:03:32 -0700
commit3b078f822a46039edbf8f9bdf078b28e35b57ca2 (patch)
treea34a40186be4131afbb9df64d7e6dd3353be43f8
parent9e886c431029a71a97e850bec8c63b0699fd09f2 (diff)
downloadPaper-3b078f822a46039edbf8f9bdf078b28e35b57ca2.tar.gz
Paper-3b078f822a46039edbf8f9bdf078b28e35b57ca2.zip
Add API for ticking fluids (#10435)
* Add API for ticking fluids * update javadocs
-rw-r--r--patches/api/0368-Block-Ticking-API.patch24
-rw-r--r--patches/server/0773-Block-Ticking-API.patch33
-rw-r--r--patches/server/0899-Only-capture-actual-tree-growth.patch4
-rw-r--r--patches/server/0974-Properly-handle-experience-dropping-on-block-break.patch4
4 files changed, 50 insertions, 15 deletions
diff --git a/patches/api/0368-Block-Ticking-API.patch b/patches/api/0368-Block-Ticking-API.patch
index aba95a2d13..02fed74c9e 100644
--- a/patches/api/0368-Block-Ticking-API.patch
+++ b/patches/api/0368-Block-Ticking-API.patch
@@ -5,10 +5,10 @@ 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 cf9600c743e977312c0a15c455d602391797ef34..38cf77e32b76bc7d9db7523f7f21427ebb72f913 100644
+index cf9600c743e977312c0a15c455d602391797ef34..8a842840e1a2652a6356d4a56e4749a5ba36e902 100644
--- a/src/main/java/org/bukkit/block/Block.java
+++ b/src/main/java/org/bukkit/block/Block.java
-@@ -589,6 +589,21 @@ public interface Block extends Metadatable, Translatable, net.kyori.adventure.tr
+@@ -589,6 +589,41 @@ public interface Block extends Metadatable, Translatable, net.kyori.adventure.tr
* @return true if the block was destroyed
*/
boolean breakNaturally(@NotNull ItemStack tool, boolean triggerEffect, boolean dropExperience);
@@ -17,14 +17,34 @@ index cf9600c743e977312c0a15c455d602391797ef34..38cf77e32b76bc7d9db7523f7f21427e
+ * 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.
++ * <p>
++ * This method may directly fire events relating to block ticking.
++ *
++ * @see #fluidTick()
+ */
+ void tick();
+
+ /**
++ * Causes the fluid to be ticked, this is different from {@link Block#randomTick()},
++ * in that it is usually scheduled to occur, for example
++ * causing waterlogged blocks to spread.
++ * <p>
++ * This method may directly fire events relating to fluid ticking.
++ *
++ * @see #tick()
++ */
++ void fluidTick();
++
++ /**
+ * Causes the block to be ticked randomly.
+ * This has a chance to execute naturally if {@link BlockData#isRandomlyTicked()} is true.
+ * <p>
+ * For certain blocks, this behavior may be the same as {@link Block#tick()}.
++ * <p>
++ * This method may directly fire events relating to block random ticking.
++ *
++ * @see #tick()
++ * @see #fluidTick()
+ */
+ void randomTick();
// Paper end
diff --git a/patches/server/0773-Block-Ticking-API.patch b/patches/server/0773-Block-Ticking-API.patch
index 9afbc4d4b1..d26cc16750 100644
--- a/patches/server/0773-Block-Ticking-API.patch
+++ b/patches/server/0773-Block-Ticking-API.patch
@@ -5,28 +5,43 @@ 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 6d10396347b69d9243ab902ecc68ede93fa17b7d..0a96b00a98227714ef99005e0a223765feae8fe9 100644
+index 6d10396347b69d9243ab902ecc68ede93fa17b7d..af219df5267589300f0ad1d30fa5c81a1f50234f 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
-@@ -709,5 +709,21 @@ public class CraftBlock implements Block {
+@@ -78,6 +78,12 @@ public class CraftBlock implements Block {
+ return this.world.getBlockState(this.position);
+ }
+
++ // Paper start
++ public net.minecraft.world.level.material.FluidState getNMSFluid() {
++ return this.world.getFluidState(this.position);
++ }
++ // Paper end
++
+ public BlockPos getPosition() {
+ return this.position;
+ }
+@@ -709,5 +715,23 @@ 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();
++ final ServerLevel level = this.world.getMinecraftWorld();
++ this.getNMS().tick(level, this.position, level.random);
++ }
++
+
-+ blockData.getBlock().tick(blockData, level, this.position, level.random);
++ @Override
++ public void fluidTick() {
++ this.getNMSFluid().tick(this.world.getMinecraftWorld(), this.position);
+ }
+
+ @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);
++ final ServerLevel level = this.world.getMinecraftWorld();
++ this.getNMS().randomTick(level, this.position, level.random);
+ }
// Paper end
}
diff --git a/patches/server/0899-Only-capture-actual-tree-growth.patch b/patches/server/0899-Only-capture-actual-tree-growth.patch
index 845e3ce577..683dad5511 100644
--- a/patches/server/0899-Only-capture-actual-tree-growth.patch
+++ b/patches/server/0899-Only-capture-actual-tree-growth.patch
@@ -60,10 +60,10 @@ index 83e6e3286d04c39d6d7ba496251aec962621f72e..3ff0d08e4964aae82d8e51d3b8bf9aa0
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
-index 0a96b00a98227714ef99005e0a223765feae8fe9..e5506a7d074a9f89d41f4d5d7549a458779bef20 100644
+index af219df5267589300f0ad1d30fa5c81a1f50234f..461a66c323a74db5a70981fafc5fa20f54f0f40d 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
-@@ -566,6 +566,7 @@ public class CraftBlock implements Block {
+@@ -572,6 +572,7 @@ public class CraftBlock implements Block {
if (!event.isCancelled()) {
for (BlockState blockstate : blocks) {
blockstate.update(true);
diff --git a/patches/server/0974-Properly-handle-experience-dropping-on-block-break.patch b/patches/server/0974-Properly-handle-experience-dropping-on-block-break.patch
index 3cc682a856..57e56e24ab 100644
--- a/patches/server/0974-Properly-handle-experience-dropping-on-block-break.patch
+++ b/patches/server/0974-Properly-handle-experience-dropping-on-block-break.patch
@@ -80,10 +80,10 @@ index e57e3a26b0fb856e1ab693df5783fe8b9bee9719..64300077fce6eb28b6bddd42b3467eaa
public List<ItemStack> getDrops(LootParams.Builder builder) {
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
-index e5506a7d074a9f89d41f4d5d7549a458779bef20..4b42ef2a876ea210d948238e63fd7a2b7035bb5b 100644
+index 461a66c323a74db5a70981fafc5fa20f54f0f40d..ac11f18690434922179b61ffcc3036dea025b0cb 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
-@@ -503,7 +503,7 @@ public class CraftBlock implements Block {
+@@ -509,7 +509,7 @@ public class CraftBlock implements Block {
// Modelled off EntityHuman#hasBlock
if (block != Blocks.AIR && (item == null || !iblockdata.requiresCorrectToolForDrops() || nmsItem.isCorrectToolForDrops(iblockdata))) {