aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0017-Configurable-speed-for-water-flowing-over-lava.patch
blob: 943d8e222d26bbcb549fba7ac9602c69db4f2242 (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
From ad6832d5982a4f8af5dfcac70d5a17c97c73a780 Mon Sep 17 00:00:00 2001
From: Byteflux <byte@byteflux.net>
Date: Tue, 1 Mar 2016 14:27:13 -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 f19ae97..8fc2f6c 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -146,4 +146,10 @@ public class PaperWorldConfig {
         if (fallingBlockHeightNerf != 0) log("Falling Block Height Limit set to Y: " + fallingBlockHeightNerf);
         if (entityTNTHeightNerf != 0) log("TNT Entity Height Limit set to Y: " + entityTNTHeightNerf);
     }
+
+    public int waterOverLavaFlowSpeed;
+    private void waterOverLawFlowSpeed() {
+        waterOverLavaFlowSpeed = getInt("water-over-lava-flow-speed", 5);
+        log("Water over lava flow speed: " + waterOverLavaFlowSpeed);
+    }
 }
diff --git a/src/main/java/net/minecraft/server/BlockFlowing.java b/src/main/java/net/minecraft/server/BlockFlowing.java
index ab1efab..be8020a 100644
--- a/src/main/java/net/minecraft/server/BlockFlowing.java
+++ b/src/main/java/net/minecraft/server/BlockFlowing.java
@@ -35,7 +35,7 @@ public class BlockFlowing extends BlockFluids {
             b0 = 2;
         }
 
-        int j = this.a(world);
+        int j = this.getFlowSpeed(world, blockposition); // Paper
         int k;
 
         if (i > 0) {
@@ -263,8 +263,22 @@ public class BlockFlowing extends BlockFluids {
 
     public void onPlace(World world, BlockPosition blockposition, IBlockData iblockdata) {
         if (!this.e(world, blockposition, iblockdata)) {
-            world.a(blockposition, (Block) this, this.a(world));
+            world.a(blockposition, (Block) this, this.getFlowSpeed(world, blockposition)); // Paper
         }
 
     }
+
+    /**
+     * Paper - Get flow speed. Throttle if its water and flowing adjacent to lava
+     */
+    public int getFlowSpeed(World world, BlockPosition blockposition) {
+        if (this.material == Material.WATER && (
+                world.getType(blockposition.north(1)).getBlock().material == Material.LAVA ||
+                        world.getType(blockposition.south(1)).getBlock().material == Material.LAVA ||
+                        world.getType(blockposition.west(1)).getBlock().material == Material.LAVA ||
+                        world.getType(blockposition.east(1)).getBlock().material == Material.LAVA)) {
+            return world.paperConfig.waterOverLavaFlowSpeed;
+        }
+        return super.a(world);
+    }
 }
-- 
2.8.2