aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0336-Configurable-speed-for-water-flowing-over-lava.patch
blob: f23154cad4255e655b72f7a90ebf394ea18bbfba (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
From 4fef830e9621867bc3af8bac7fa822e12adfed59 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/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 8f49262226..869bf8a9f9 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -481,6 +481,12 @@ public class PaperWorldConfig {
         }
     }
 
+    public int waterOverLavaFlowSpeed;
+    private void waterOverLavaFlowSpeed() {
+        waterOverLavaFlowSpeed = getInt("water-over-lava-flow-speed", 5);
+        log("Water over lava flow speed: " + waterOverLavaFlowSpeed);
+    }
+
     public enum DuplicateUUIDMode {
         SAFE_REGEN, DELETE, NOTHING, WARN
     }
diff --git a/src/main/java/net/minecraft/server/BlockFluids.java b/src/main/java/net/minecraft/server/BlockFluids.java
index e672385829..b53a88c33f 100644
--- a/src/main/java/net/minecraft/server/BlockFluids.java
+++ b/src/main/java/net/minecraft/server/BlockFluids.java
@@ -77,11 +77,27 @@ public class BlockFluids extends Block implements IFluidSource {
 
     public void onPlace(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData iblockdata1) {
         if (this.a(world, blockposition, iblockdata)) {
-            world.getFluidTickList().a(blockposition, iblockdata.s().c(), this.a((IWorldReader) world));
+            world.getFluidTickList().a(blockposition, iblockdata.s().c(), this.getFlowSpeed(world, blockposition)); // Paper
         }
 
     }
 
+    // Paper start - Get flow speed. Throttle if its water and flowing adjacent to lava
+    public int getFlowSpeed(World world, BlockPosition blockposition) {
+        if (this.material == Material.WATER) {
+            if (
+                world.getMaterialIfLoaded(blockposition.north(1)) == Material.LAVA ||
+                world.getMaterialIfLoaded(blockposition.south(1)) == Material.LAVA ||
+                world.getMaterialIfLoaded(blockposition.west(1)) == Material.LAVA ||
+                world.getMaterialIfLoaded(blockposition.east(1)) == Material.LAVA
+            ) {
+                return world.paperConfig.waterOverLavaFlowSpeed;
+            }
+        }
+        return this.a(world);
+    }
+    // Paper end
+
     public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) {
         if (iblockdata.s().d() || iblockdata1.s().d()) {
             generatoraccess.getFluidTickList().a(blockposition, iblockdata.s().c(), this.a((IWorldReader) generatoraccess));
@@ -92,7 +108,7 @@ public class BlockFluids extends Block implements IFluidSource {
 
     public void doPhysics(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1) {
         if (this.a(world, blockposition, iblockdata)) {
-            world.getFluidTickList().a(blockposition, iblockdata.s().c(), this.a((IWorldReader) world));
+            world.getFluidTickList().a(blockposition, iblockdata.s().c(), this.getFlowSpeed(world, blockposition)); // Paper
         }
 
     }
-- 
2.21.0