From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <blake.galbreath@gmail.com>
Date: Sat, 23 Nov 2019 17:55:42 -0600
Subject: [PATCH] Implement infinite lava


diff --git a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
index 32d15354ceb46fb06b1c36049d3a8bfba718acaf..239d0f363fc36618838a92a57bf89070a6bace73 100644
--- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
+++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
@@ -227,7 +227,7 @@ public abstract class FlowingFluid extends Fluid {
             }
         }
 
-        if (this.canConvertToSource() && j >= 2) {
+        if (this.canConvertToSource(world) && j >= getRequiredSources(world)) {
             BlockState iblockdata2 = world.getBlockState(pos.below());
             FluidState fluid1 = iblockdata2.getFluidState();
 
@@ -323,6 +323,16 @@ public abstract class FlowingFluid extends Fluid {
         return (FluidState) this.getSource().defaultFluidState().setValue(FlowingFluid.FALLING, falling);
     }
 
+    // Purpur start
+    protected boolean canConvertToSource(LevelReader world) {
+        return canConvertToSource();
+    }
+
+    protected int getRequiredSources(LevelReader world) {
+        return 2;
+    }
+    // Purpur end
+
     protected abstract boolean canConvertToSource();
 
     protected void spreadTo(LevelAccessor world, BlockPos pos, BlockState state, Direction direction, FluidState fluidState) {
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 695783e64564b1d2a178d57a89737d2a97ab9014..cd1a33a1f10d04a91358f51d736bda34110324c4 100644
--- a/src/main/java/net/minecraft/world/level/material/LavaFluid.java
+++ b/src/main/java/net/minecraft/world/level/material/LavaFluid.java
@@ -199,6 +199,18 @@ public abstract class LavaFluid extends FlowingFluid {
         world.levelEvent(1501, pos, 0);
     }
 
+    // Purpur start
+    @Override
+    protected boolean canConvertToSource(LevelReader world) {
+        return world.getWorldBorder().world.purpurConfig.lavaInfinite;
+    }
+
+    @Override
+    protected int getRequiredSources(LevelReader world) {
+        return world.getWorldBorder().world.purpurConfig.lavaInfiniteRequiredSources;
+    }
+    // Purpur end
+
     @Override
     protected boolean canConvertToSource() {
         return false;
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 91ba2eed526a17c657df5e0636c79019d91f1432..74f2f991612f409d97ea855dc1039f0eef73088d 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -216,6 +216,13 @@ public class PurpurWorldConfig {
         farmlandGetsMoistFromBelow = getBoolean("blocks.farmland.gets-moist-from-below", farmlandGetsMoistFromBelow);
     }
 
+    public boolean lavaInfinite = false;
+    public int lavaInfiniteRequiredSources = 2;
+    private void lavaSettings() {
+        lavaInfinite = getBoolean("blocks.lava.infinite-source", lavaInfinite);
+        lavaInfiniteRequiredSources = getInt("blocks.lava.infinite-required-sources", lavaInfiniteRequiredSources);
+    }
+
     public boolean signAllowColors = false;
     public boolean signRightClickEdit = false;
     private void signSettings() {
