From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Mon, 19 Oct 2020 15:14:01 -0500
Subject: [PATCH] Infinite fuel furnace


diff --git a/src/main/java/net/minecraft/world/level/block/entity/TileEntityFurnace.java b/src/main/java/net/minecraft/world/level/block/entity/TileEntityFurnace.java
index 1997139fb87dc1947acfdf02e1f116577c3fa943..cd7bcedf8474dcb565b5b1157e167706c031a7f1 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/TileEntityFurnace.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/TileEntityFurnace.java
@@ -12,6 +12,7 @@ import java.util.Map;
 import javax.annotation.Nullable;
 import net.minecraft.SharedConstants;
 import net.minecraft.SystemUtils;
+import net.minecraft.core.BlockPosition;
 import net.minecraft.core.EnumDirection;
 import net.minecraft.core.NonNullList;
 import net.minecraft.nbt.NBTTagCompound;
@@ -38,6 +39,7 @@ import net.minecraft.world.level.World;
 import net.minecraft.world.level.block.BlockFurnace;
 import net.minecraft.world.level.block.Blocks;
 import net.minecraft.world.level.block.state.IBlockData;
+import net.minecraft.world.level.material.Fluid;
 import net.minecraft.world.phys.Vec3D;
 
 // CraftBukkit start
@@ -308,6 +310,22 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements I
         if (!this.world.isClientSide) {
             ItemStack itemstack = (ItemStack) this.items.get(1);
 
+            // Purpur start
+            boolean infiniteFuel = false;
+            if (world.purpurConfig.furnaceInfiniteFuel && !isBurning() && itemstack.isEmpty() && !items.get(0).isEmpty() && world.getTime() % 20 == 0) {
+                BlockPosition pos = getPosition().down();
+                IBlockData iblockdata = world.getTypeIfLoaded(pos);
+                if (iblockdata != null && iblockdata.equals(Blocks.LAVA)) {
+                    Fluid fluid = iblockdata.getFluid();
+                    if (fluid != null && fluid.isSource()) {
+                        world.setTypeAndData(pos, Blocks.AIR.getBlockData(), 3);
+                        itemstack = Items.LAVA_BUCKET.createItemStack();
+                        infiniteFuel = true;
+                    }
+                }
+            }
+            // Purpur end
+
             if (!this.isBurning() && (itemstack.isEmpty() || ((ItemStack) this.items.get(0)).isEmpty())) {
                 if (!this.isBurning() && this.cookTime > 0) {
                     this.cookTime = MathHelper.clamp(this.cookTime - 2, 0, this.cookTimeTotal);
@@ -361,6 +379,8 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements I
                 flag1 = true;
                 this.world.setTypeAndData(this.position, (IBlockData) this.world.getType(this.position).set(BlockFurnace.LIT, this.isBurning()), 3);
             }
+
+            if (infiniteFuel) this.items.set(1, ItemStack.NULL_ITEM); // Purpur
         }
 
         if (flag1) {
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 21bc5f3b398b824a66e089e408e6759d33c30511..938876a4edb3b37e6b7dcc3b2c1b55cd35df1c8e 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -363,6 +363,11 @@ public class PurpurWorldConfig {
         farmlandGetsMoistFromBelow = getBoolean("blocks.farmland.gets-moist-from-below", farmlandGetsMoistFromBelow);
     }
 
+    public boolean furnaceInfiniteFuel = false;
+    private void furnaceSettings() {
+        furnaceInfiniteFuel = getBoolean("blocks.furnace.infinite-fuel", furnaceInfiniteFuel);
+    }
+
     public boolean lavaInfinite = false;
     public int lavaInfiniteRequiredSources = 2;
     public int lavaSpeedNether = 10;
