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-random-tick block list


diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index a667c540b85a4afbb1beece7decb5d0e3e8c9572..e4651dc35114ee9fd296f7efb6a2d6b808c27d45 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -483,7 +483,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
         this.players = Lists.newArrayList();
         this.entityTickList = new EntityTickList();
         Predicate<Block> predicate = (block) -> { // CraftBukkit - decompile eror
-            return block == null || block.defaultBlockState().isAir();
+            return block == null || block.defaultBlockState().isAir() || purpurConfig.noRandomTickBlocks.contains(block); // Purpur
         };
         DefaultedRegistry registryblocks = Registry.BLOCK;
 
diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
index 7538262e14c86e4da9cd4cb887b76f649bfef2e6..f34973be478de4f088a0593b45bd89e558a13609 100644
--- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
+++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
@@ -915,10 +915,12 @@ public abstract class BlockBehaviour {
         }
 
         public void tick(ServerLevel world, BlockPos pos, Random random) {
+            if (world.purpurConfig.noRandomTickBlocks.contains(getBlock())) return; // Purpur
             this.getBlock().tick(this.asState(), world, pos, random);
         }
 
         public void randomTick(ServerLevel world, BlockPos pos, Random random) {
+            if (world.purpurConfig.noRandomTickBlocks.contains(getBlock())) return; // Purpur
             this.getBlock().randomTick(this.asState(), world, pos, random);
         }
 
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 3519a3cabf49c1af9cd80a1907d876a67dc0e15f..aeca90b8df437130a2f6461398164e132e3ec634 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -288,6 +288,28 @@ public class PurpurWorldConfig {
         voidDamageDealt = getDouble("gameplay-mechanics.void-damage-dealt", voidDamageDealt);
     }
 
+    public Set<Block> noRandomTickBlocks = new HashSet<>();
+    private void noRandomTickBlocks() {
+        if (PurpurConfig.version < 11) {
+            List<String> oldList = PurpurConfig.config.getStringList("world-settings." + worldName + ".blocks.no-tick");
+            if (!oldList.isEmpty()) {
+                PurpurConfig.config.set("world-settings." + worldName + ".blocks.no-random-tick", oldList);
+                PurpurConfig.config.set("world-settings." + worldName + ".blocks.no-tick", null);
+            }
+            oldList = PurpurConfig.config.getStringList("world-settings.default.blocks.no-tick");
+            if (!oldList.isEmpty()) {
+                PurpurConfig.config.set("world-settings.default.blocks.no-random-tick", oldList);
+                PurpurConfig.config.set("world-settings.default.blocks.no-tick", null);
+            }
+        }
+        getList("blocks.no-random-tick", new ArrayList<>()).forEach(key -> {
+            Block block = Registry.BLOCK.get(new ResourceLocation(key.toString()));
+            if (!block.defaultBlockState().isAir()) {
+                noRandomTickBlocks.add(block);
+            }
+        });
+    }
+
     public boolean anvilAllowColors = false;
     private void anvilSettings() {
         anvilAllowColors = getBoolean("blocks.anvil.allow-colors", anvilAllowColors);
