From e7fcac70359aa2f83ec407fe7c0ff669c0bdd304 Mon Sep 17 00:00:00 2001 From: William Blake Galbreath Date: Sun, 5 Jan 2025 14:19:12 -0800 Subject: [PATCH] Cat spawning options --- .../server/0032-Cat-spawning-options.patch | 71 ------------------- .../world/entity/npc/CatSpawner.java.patch | 39 ++++++++++ .../purpurmc/purpur/PurpurWorldConfig.java | 6 ++ 3 files changed, 45 insertions(+), 71 deletions(-) delete mode 100644 patches/server/0032-Cat-spawning-options.patch create mode 100644 purpur-server/minecraft-patches/sources/net/minecraft/world/entity/npc/CatSpawner.java.patch diff --git a/patches/server/0032-Cat-spawning-options.patch b/patches/server/0032-Cat-spawning-options.patch deleted file mode 100644 index 146c2710c..000000000 --- a/patches/server/0032-Cat-spawning-options.patch +++ /dev/null @@ -1,71 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: William Blake Galbreath -Date: Thu, 26 Dec 2019 18:52:55 -0600 -Subject: [PATCH] Cat spawning options - - -diff --git a/net/minecraft/world/entity/npc/CatSpawner.java b/net/minecraft/world/entity/npc/CatSpawner.java -index b0236c7bf9441aa84d3795ffed05dd6099f29636..e9cbbcdcefe9acc24cf7972ae356fd590e128f56 100644 ---- a/net/minecraft/world/entity/npc/CatSpawner.java -+++ b/net/minecraft/world/entity/npc/CatSpawner.java -@@ -27,7 +27,7 @@ public class CatSpawner implements CustomSpawner { - if (this.nextTick > 0) { - return 0; - } else { -- this.nextTick = 1200; -+ this.nextTick = world.purpurConfig.catSpawnDelay; // Purpur - Cat spawning options - Player player = world.getRandomPlayer(); - if (player == null) { - return 0; -@@ -61,8 +61,12 @@ public class CatSpawner implements CustomSpawner { - - private int spawnInVillage(ServerLevel world, BlockPos pos) { - int i = 48; -- if (world.getPoiManager().getCountInRange(entry -> entry.is(PoiTypes.HOME), pos, 48, PoiManager.Occupancy.IS_OCCUPIED) > 4L) { -- List list = world.getEntitiesOfClass(Cat.class, new AABB(pos).inflate(48.0, 8.0, 48.0)); -+ // Purpur start - Cat spawning options -+ int range = world.purpurConfig.catSpawnVillageScanRange; -+ if (range <= 0) return 0; -+ if (world.getPoiManager().getCountInRange(entry -> entry.is(PoiTypes.HOME), pos, range, PoiManager.Occupancy.IS_OCCUPIED) > 4L) { -+ List list = world.getEntitiesOfClass(Cat.class, new AABB(pos).inflate(range, 8.0, range)); -+ // Purpur end - Cat spawning options - if (list.size() < 5) { - return this.spawnCat(pos, world); - } -@@ -73,7 +77,11 @@ public class CatSpawner implements CustomSpawner { - - private int spawnInHut(ServerLevel world, BlockPos pos) { - int i = 16; -- List list = world.getEntitiesOfClass(Cat.class, new AABB(pos).inflate(16.0, 8.0, 16.0)); -+ // Purpur start - Cat spawning options -+ int range = world.purpurConfig.catSpawnSwampHutScanRange; -+ if (range <= 0) return 0; -+ List list = world.getEntitiesOfClass(Cat.class, new AABB(pos).inflate(range, 8.0, range)); -+ // Purpur end - Cat spawning options - return list.size() < 1 ? this.spawnCat(pos, world) : 0; - } - -diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -index 149360f01139fa4b14e27e5b34fe3fe7682c7ffc..b3284dfbcdc240919776f47a780a824c406c2781 100644 ---- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -@@ -312,6 +312,9 @@ public class PurpurWorldConfig { - public boolean catControllable = true; - public double catMaxHealth = 10.0D; - public double catScale = 1.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); -@@ -323,6 +326,9 @@ public class PurpurWorldConfig { - } - catMaxHealth = getDouble("mobs.cat.attributes.max_health", catMaxHealth); - catScale = Mth.clamp(getDouble("mobs.cat.attributes.scale", catScale), 0.0625D, 16.0D); -+ 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; diff --git a/purpur-server/minecraft-patches/sources/net/minecraft/world/entity/npc/CatSpawner.java.patch b/purpur-server/minecraft-patches/sources/net/minecraft/world/entity/npc/CatSpawner.java.patch new file mode 100644 index 000000000..d5c870866 --- /dev/null +++ b/purpur-server/minecraft-patches/sources/net/minecraft/world/entity/npc/CatSpawner.java.patch @@ -0,0 +1,39 @@ +--- a/net/minecraft/world/entity/npc/CatSpawner.java ++++ b/net/minecraft/world/entity/npc/CatSpawner.java +@@ -27,7 +_,7 @@ + if (this.nextTick > 0) { + return 0; + } else { +- this.nextTick = 1200; ++ this.nextTick = level.purpurConfig.catSpawnDelay; // Purpur - Cat spawning options + Player randomPlayer = level.getRandomPlayer(); + if (randomPlayer == null) { + return 0; +@@ -61,8 +_,12 @@ + + private int spawnInVillage(ServerLevel serverLevel, BlockPos pos) { + int i = 48; +- if (serverLevel.getPoiManager().getCountInRange(holder -> holder.is(PoiTypes.HOME), pos, 48, PoiManager.Occupancy.IS_OCCUPIED) > 4L) { +- List entitiesOfClass = serverLevel.getEntitiesOfClass(Cat.class, new AABB(pos).inflate(48.0, 8.0, 48.0)); ++ // Purpur start - Cat spawning options ++ int range = serverLevel.purpurConfig.catSpawnVillageScanRange; ++ if (range <= 0) return 0; ++ if (serverLevel.getPoiManager().getCountInRange(holder -> holder.is(PoiTypes.HOME), pos, range, PoiManager.Occupancy.IS_OCCUPIED) > 4L) { ++ List entitiesOfClass = serverLevel.getEntitiesOfClass(Cat.class, new AABB(pos).inflate(range, 8.0, range)); ++ // Purpur end - Cat spawning options + if (entitiesOfClass.size() < 5) { + return this.spawnCat(pos, serverLevel); + } +@@ -73,7 +_,11 @@ + + private int spawnInHut(ServerLevel serverLevel, BlockPos pos) { + int i = 16; +- List entitiesOfClass = serverLevel.getEntitiesOfClass(Cat.class, new AABB(pos).inflate(16.0, 8.0, 16.0)); ++ // Purpur start - Cat spawning options ++ int range = serverLevel.purpurConfig.catSpawnSwampHutScanRange; ++ if (range <= 0) return 0; ++ List entitiesOfClass = serverLevel.getEntitiesOfClass(Cat.class, new AABB(pos).inflate(range, 8.0, range)); ++ // Purpur end - Cat spawning options + return entitiesOfClass.size() < 1 ? this.spawnCat(pos, serverLevel) : 0; + } + diff --git a/purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java index 6ebcd5f75..e23fcb01b 100644 --- a/purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java +++ b/purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java @@ -298,6 +298,9 @@ public class PurpurWorldConfig { public boolean catControllable = true; public double catMaxHealth = 10.0D; public double catScale = 1.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); @@ -309,6 +312,9 @@ public class PurpurWorldConfig { } catMaxHealth = getDouble("mobs.cat.attributes.max_health", catMaxHealth); catScale = Mth.clamp(getDouble("mobs.cat.attributes.scale", catScale), 0.0625D, 16.0D); + 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;