From 37ae9e2c62f5d1420fe2d1de12d4b07b39be3dc3 Mon Sep 17 00:00:00 2001 From: Samsuik Date: Fri, 6 Dec 2024 12:46:42 +0000 Subject: [PATCH] Fix lava flow speed api --- build-data/dev-imports.txt | 3 +- .../server/0081-Add-lava-flow-speed-api.patch | 54 ++++++++++++++++--- 2 files changed, 50 insertions(+), 7 deletions(-) diff --git a/build-data/dev-imports.txt b/build-data/dev-imports.txt index 1378a91..84b074d 100644 --- a/build-data/dev-imports.txt +++ b/build-data/dev-imports.txt @@ -22,4 +22,5 @@ minecraft net.minecraft.world.item.Item minecraft net.minecraft.world.item.SwordItem minecraft net.minecraft.world.item.DiggerItem minecraft net.minecraft.world.food.Foods -minecraft net.minecraft.world.item.Items \ No newline at end of file +minecraft net.minecraft.world.item.Items +minecraft net.minecraft.world.level.material.Fluid diff --git a/patches/server/0081-Add-lava-flow-speed-api.patch b/patches/server/0081-Add-lava-flow-speed-api.patch index db1f2c2..788fbb9 100644 --- a/patches/server/0081-Add-lava-flow-speed-api.patch +++ b/patches/server/0081-Add-lava-flow-speed-api.patch @@ -4,19 +4,61 @@ Date: Thu, 5 Dec 2024 22:21:39 +0000 Subject: [PATCH] Add lava flow speed api +diff --git a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java +index 6cc129afdb19e121e1abe8dc07f5cc2216c7b084..b4a775c486d6de994591dd6b34055e3a80d9a4d3 100644 +--- a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java ++++ b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java +@@ -158,7 +158,7 @@ public class LiquidBlock extends Block implements BucketPickup { + return world.paperConfig().environment.waterOverLavaFlowSpeed; + } + } +- return this.fluid.getTickDelay(world); ++ return this.fluid.getTickDelay(world, blockposition); // Sakura - lava flow speed api + } + private static boolean isLava(Level world, BlockPos blockPos) { + final FluidState fluidState = world.getFluidIfLoaded(blockPos); +diff --git a/src/main/java/net/minecraft/world/level/material/Fluid.java b/src/main/java/net/minecraft/world/level/material/Fluid.java +index 69586077f0d9b0eed1a7de7ef1d743048de0c9d5..86afcda1f14aec7ee9c459e935782037cb0c6634 100644 +--- a/src/main/java/net/minecraft/world/level/material/Fluid.java ++++ b/src/main/java/net/minecraft/world/level/material/Fluid.java +@@ -69,6 +69,12 @@ public abstract class Fluid { + + protected abstract Vec3 getFlow(BlockGetter world, BlockPos pos, FluidState state); + ++ // Sakura start - lava flow speed api ++ public int getTickDelay(final Level world, final BlockPos pos) { ++ return this.getTickDelay(world); ++ } ++ // Sakura end - lava flow speed api ++ + public abstract int getTickDelay(LevelReader world); + + protected boolean isRandomlyTicking() { diff --git a/src/main/java/net/minecraft/world/level/material/LavaFluid.java b/src/main/java/net/minecraft/world/level/material/LavaFluid.java -index 5fb8ad171e132174af12d63e45dd623ecac7480a..e4d5d80a16dbf568ccd932aae0c30ee913873abb 100644 +index 5fb8ad171e132174af12d63e45dd623ecac7480a..62d1487ee5820a38f033d60f197b476079ea3e51 100644 --- a/src/main/java/net/minecraft/world/level/material/LavaFluid.java +++ b/src/main/java/net/minecraft/world/level/material/LavaFluid.java -@@ -189,7 +189,10 @@ public abstract class LavaFluid extends FlowingFluid { +@@ -182,6 +182,14 @@ public abstract class LavaFluid extends FlowingFluid { + // Sakura end - physics version api + } + ++ // Sakura start - lava flow speed api ++ @Override ++ public final int getTickDelay(Level world, BlockPos pos) { ++ final int flowSpeed = world.localConfig().config(pos).lavaFlowSpeed; ++ return flowSpeed >= 0 ? flowSpeed : this.getTickDelay(world); ++ } ++ // Sakura end - lava flow speed api ++ + @Override + public int getTickDelay(LevelReader world) { + return world.dimensionType().ultraWarm() && !(world instanceof Level level && level.sakuraConfig().environment.disableFastNetherLava) ? 10 : 30; // Sakura - add option for fast nether lava +@@ -189,7 +197,7 @@ public abstract class LavaFluid extends FlowingFluid { @Override public int getSpreadDelay(Level world, BlockPos pos, FluidState oldState, FluidState newState) { - int i = this.getTickDelay(world); -+ // Sakura start - lava flow speed api -+ final int flowSpeed = world.localConfig().config(pos).lavaFlowSpeed; -+ int i = flowSpeed >= 0 ? flowSpeed : this.getTickDelay(world); -+ // Sakura end - lava flow speed api ++ int i = this.getTickDelay(world, pos); // Sakura - lava flow speed api if (!oldState.isEmpty() && !newState.isEmpty() && !(Boolean) oldState.getValue(LavaFluid.FALLING) && !(Boolean) newState.getValue(LavaFluid.FALLING) && newState.getHeight(world, pos) > oldState.getHeight(world, pos) && world.getRandom().nextInt(4) != 0) { i *= 4;