aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0236-Configurable-speed-for-water-flowing-over-lava.patch
blob: 1ae56559676ec5545883744767e0d233960bd73e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Byteflux <byte@byteflux.net>
Date: Wed, 8 Aug 2018 16:33:21 -0600
Subject: [PATCH] Configurable speed for water flowing over lava


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 82afefbbc3b9d3571792d66e6d4f9d687971aa66..9b3dcf1a4d4cece92a629506d341f6bfe79d13d0 100644
--- a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java
@@ -140,11 +140,31 @@ public class LiquidBlock extends Block implements BucketPickup {
     @Override
     public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
         if (this.shouldSpreadLiquid(world, pos, state)) {
-            world.scheduleTick(pos, state.getFluidState().getType(), this.fluid.getTickDelay(world));
+            world.scheduleTick(pos, state.getFluidState().getType(), this.getFlowSpeed(world, pos)); // Paper - Configurable speed for water flowing over lava
         }
 
     }
 
+    // Paper start - Configurable speed for water flowing over lava
+    public int getFlowSpeed(Level world, BlockPos blockposition) {
+        if (net.minecraft.core.registries.BuiltInRegistries.FLUID.wrapAsHolder(this.fluid).is(FluidTags.WATER)) {
+            if (
+                isLava(world, blockposition.north(1)) ||
+                isLava(world, blockposition.south(1)) ||
+                isLava(world, blockposition.west(1)) ||
+                isLava(world, blockposition.east(1))
+            ) {
+                return world.paperConfig().environment.waterOverLavaFlowSpeed;
+            }
+        }
+        return this.fluid.getTickDelay(world);
+    }
+    private static boolean isLava(Level world, BlockPos blockPos) {
+        final FluidState fluidState = world.getFluidIfLoaded(blockPos);
+        return fluidState != null && fluidState.is(FluidTags.LAVA);
+    }
+    // Paper end - Configurable speed for water flowing over lava
+
     @Override
     public BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
         if (state.getFluidState().isSource() || neighborState.getFluidState().isSource()) {
@@ -157,7 +177,7 @@ public class LiquidBlock extends Block implements BucketPickup {
     @Override
     public void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) {
         if (this.shouldSpreadLiquid(world, pos, state)) {
-            world.scheduleTick(pos, state.getFluidState().getType(), this.fluid.getTickDelay(world));
+            world.scheduleTick(pos, state.getFluidState().getType(), this.getFlowSpeed(world, pos)); // Paper - Configurable speed for water flowing over lava
         }
 
     }