From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Fri, 7 Aug 2020 12:53:36 -0500
Subject: [PATCH] Add no-tick block list


diff --git a/src/main/java/net/minecraft/server/BlockBase.java b/src/main/java/net/minecraft/server/BlockBase.java
index 829d4a7508e1656dbdc912096b7eafcf30cbb5b2..6aea156d7c7a9ca8a357aad6a6781d7209c9b8ae 100644
--- a/src/main/java/net/minecraft/server/BlockBase.java
+++ b/src/main/java/net/minecraft/server/BlockBase.java
@@ -617,10 +617,12 @@ public abstract class BlockBase {
         }
 
         public void a(WorldServer worldserver, BlockPosition blockposition, Random random) {
+            if (worldserver.purpurConfig.noTickBlocks.contains(getBlock())) return; // Purpur
             this.getBlock().tickAlways(this.p(), worldserver, blockposition, random);
         }
 
         public void b(WorldServer worldserver, BlockPosition blockposition, Random random) {
+            if (worldserver.purpurConfig.noTickBlocks.contains(getBlock())) return; // Purpur
             this.getBlock().tick(this.p(), worldserver, blockposition, random);
         }
 
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 428f43a37d5aa6e0bf363baeef02b0fa01951590..59301aad8c257758cb0fe9709901847925d60be4 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -418,14 +418,14 @@ public class WorldServer extends World implements GeneratorAccessSeed {
         // CraftBukkit end
         if (com.destroystokyo.paper.PaperConfig.useOptimizedTickList) {
             this.nextTickListBlock = new com.destroystokyo.paper.server.ticklist.PaperTickList<>(this, (block) -> {
-                return block == null || block.getBlockData().isAir();
+                return block == null || block.getBlockData().isAir() || purpurConfig.noTickBlocks.contains(block); // Purpur
             }, IRegistry.BLOCK::getKey, this::b, "Blocks"); // Paper - Timings
             this.nextTickListFluid = new com.destroystokyo.paper.server.ticklist.PaperTickList<>(this, (fluidtype) -> {
                 return fluidtype == null || fluidtype == FluidTypes.EMPTY;
             }, IRegistry.FLUID::getKey, this::a, "Fluids"); // Paper - Timings
         } else {
             this.nextTickListBlock = new TickListServer<>(this, (block) -> {
-                return block == null || block.getBlockData().isAir();
+                return block == null || block.getBlockData().isAir() || purpurConfig.noTickBlocks.contains(block); // Purpur
             }, IRegistry.BLOCK::getKey, this::b, "Blocks"); // Paper - Timings
             this.nextTickListFluid = new TickListServer<>(this, (fluidtype) -> {
                 return fluidtype == null || fluidtype == FluidTypes.EMPTY;
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 227bdc2d24d4d6dbacbf5b93497d1a4b61290af0..5b344d7eb8e4c031deb660955f2d1914f3ce4800 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -11,8 +11,10 @@ import org.bukkit.configuration.ConfigurationSection;
 
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.logging.Level;
 
 import static net.pl3x.purpur.PurpurConfig.log;
@@ -201,6 +203,16 @@ public class PurpurWorldConfig {
         playerInvulnerableWhileAcceptingResourcePack = getBoolean("gameplay-mechanics.player.invulnerable-while-accepting-resource-pack", playerInvulnerableWhileAcceptingResourcePack);
     }
 
+    public Set<Block> noTickBlocks = new HashSet<>();
+    private void noTickBlocks() {
+        getList("blocks.no-tick", new ArrayList<>()).forEach(key -> {
+            Block block = IRegistry.BLOCK.get(new MinecraftKey(key.toString()));
+            if (!block.getBlockData().isAir()) {
+                noTickBlocks.add(block);
+            }
+        });
+    }
+
     public boolean teleportIfOutsideBorder = false;
     private void teleportIfOutsideBorder() {
         teleportIfOutsideBorder = getBoolean("gameplay-mechanics.player.teleport-if-outside-border", teleportIfOutsideBorder);
