From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <blake.galbreath@gmail.com>
Date: Thu, 26 Dec 2019 18:52:55 -0600
Subject: [PATCH] Cat spawning options


diff --git a/src/main/java/net/minecraft/world/entity/npc/CatSpawner.java b/src/main/java/net/minecraft/world/entity/npc/CatSpawner.java
index 4cab98b5e441a174482893d3d289bbafa1f7a5fc..fa3cdff99a16b67ed86c8f7940ffa139930c3448 100644
--- a/src/main/java/net/minecraft/world/entity/npc/CatSpawner.java
+++ b/src/main/java/net/minecraft/world/entity/npc/CatSpawner.java
@@ -30,7 +30,7 @@ public class CatSpawner implements CustomSpawner {
             if (this.nextTick > 0) {
                 return 0;
             } else {
-                this.nextTick = 1200;
+                this.nextTick = world.purpurConfig.catSpawnDelay; // Purpur
                 Player player = world.getRandomPlayer();
                 if (player == null) {
                     return 0;
@@ -63,9 +63,13 @@ public class CatSpawner implements CustomSpawner {
     }
 
     private int spawnInVillage(ServerLevel world, BlockPos pos) {
-        int i = 48;
-        if (world.getPoiManager().getCountInRange(PoiType.HOME.getPredicate(), pos, 48, PoiManager.Occupancy.IS_OCCUPIED) > 4L) {
-            List<Cat> list = world.getEntitiesOfClass(Cat.class, (new AABB(pos)).inflate(48.0D, 8.0D, 48.0D));
+        // Purpur start
+        int range = world.purpurConfig.catSpawnVillageScanRange;
+        if (range <= 0) return 0;
+
+        if (world.getPoiManager().getCountInRange(PoiType.HOME.getPredicate(), pos, range, PoiManager.Occupancy.IS_OCCUPIED) > 4L) {
+            List<Cat> list = world.getEntitiesOfClass(Cat.class, (new AABB(pos)).inflate(range, 8.0D, range));
+            // Purpur end
             if (list.size() < 5) {
                 return this.spawnCat(pos, world);
             }
@@ -75,8 +79,11 @@ public class CatSpawner implements CustomSpawner {
     }
 
     private int spawnInHut(ServerLevel world, BlockPos pos) {
-        int i = 16;
-        List<Cat> list = world.getEntitiesOfClass(Cat.class, (new AABB(pos)).inflate(16.0D, 8.0D, 16.0D));
+        // Purpur start
+        int range = world.purpurConfig.catSpawnSwampHutScanRange;
+        if (range <= 0) return 0;
+        List<Cat> list = world.getEntitiesOfClass(Cat.class, (new AABB(pos)).inflate(range, 8.0D, range));
+        // Purpur end
         return list.size() < 1 ? this.spawnCat(pos, world) : 0;
     }
 
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 0ab41948063fff3de291f538334dd6e28027df74..f02872f45a6cdc55637a7aa55ca6886d08dc3576 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -214,6 +214,9 @@ public class PurpurWorldConfig {
     public boolean catRidable = false;
     public boolean catRidableInWater = false;
     public double catMaxHealth = 10.0D;
+    public int catSpawnDelay = 1200;
+    public int catSpawnSwampHutScanRange = 16;
+    public int catSpawnVillageScanRange = 48;
     private void catSettings() {
         catRidable = getBoolean("mobs.cat.ridable", catRidable);
         catRidableInWater = getBoolean("mobs.cat.ridable-in-water", catRidableInWater);
@@ -223,6 +226,9 @@ public class PurpurWorldConfig {
             set("mobs.cat.attributes.max_health", oldValue);
         }
         catMaxHealth = getDouble("mobs.cat.attributes.max_health", catMaxHealth);
+        catSpawnDelay = getInt("mobs.cat.spawn-delay", catSpawnDelay);
+        catSpawnSwampHutScanRange = getInt("mobs.cat.scan-range-for-other-cats.swamp-hut", catSpawnSwampHutScanRange);
+        catSpawnVillageScanRange = getInt("mobs.cat.scan-range-for-other-cats.village", catSpawnVillageScanRange);
     }
 
     public boolean caveSpiderRidable = false;
