|
| 1 | +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| 2 | +From: 2stinkysocks <zmehall@gmail.com> |
| 3 | +Date: Wed, 27 Dec 2023 16:04:52 -0700 |
| 4 | +Subject: [PATCH] Add config to only lobotomize if villagers have been traded |
| 5 | + with |
| 6 | + |
| 7 | + |
| 8 | +diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java |
| 9 | +index 68404053233985cb830e95e287c81875a3b86957..15862eb0e3c56d3dac5d7772242a75fbfc8c877a 100644 |
| 10 | +--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java |
| 11 | ++++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java |
| 12 | +@@ -204,13 +204,18 @@ public class Villager extends AbstractVillager implements ReputationEventHandler |
| 13 | + |
| 14 | + private boolean checkLobotomized() { |
| 15 | + int interval = this.level().purpurConfig.villagerLobotomizeCheckInterval; |
| 16 | ++ boolean shouldCheckForTradeLocked = this.level().purpurConfig.villagerLobotomizeWaitUntilTradeLocked; |
| 17 | + if (this.notLobotomizedCount > 3) { |
| 18 | + // check half as often if not lobotomized for the last 3+ consecutive checks |
| 19 | + interval *= 2; |
| 20 | + } |
| 21 | + if (this.level().getGameTime() % interval == 0) { |
| 22 | + // offset Y for short blocks like dirt_path/farmland |
| 23 | +- this.isLobotomized = !canTravelFrom(BlockPos.containing(this.position().x, this.getBoundingBox().minY + 0.0625D, this.position().z)); |
| 24 | ++ boolean canLobotomize = true; |
| 25 | ++ if(shouldCheckForTradeLocked) { |
| 26 | ++ canLobotomize = this.getVillagerXp() != 0; |
| 27 | ++ } |
| 28 | ++ this.isLobotomized = canLobotomize && !canTravelFrom(BlockPos.containing(this.position().x, this.getBoundingBox().minY + 0.0625D, this.position().z)); |
| 29 | + |
| 30 | + if (this.isLobotomized) { |
| 31 | + this.notLobotomizedCount = 0; |
| 32 | +diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java |
| 33 | +index bbf371428e343cfad0ae118c387fd2342541fe53..6f921269ab3563618cc4ce780b6e047a16b85a0a 100644 |
| 34 | +--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java |
| 35 | ++++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java |
| 36 | +@@ -2900,6 +2900,7 @@ public class PurpurWorldConfig { |
| 37 | + public int villagerMinimumDemand = 0; |
| 38 | + public boolean villagerLobotomizeEnabled = false; |
| 39 | + public int villagerLobotomizeCheckInterval = 100; |
| 40 | ++ public boolean villagerLobotomizeWaitUntilTradeLocked = false; |
| 41 | + public boolean villagerDisplayTradeItem = true; |
| 42 | + public int villagerSpawnIronGolemRadius = 0; |
| 43 | + public int villagerSpawnIronGolemLimit = 0; |
| 44 | +@@ -2935,6 +2936,7 @@ public class PurpurWorldConfig { |
| 45 | + } |
| 46 | + villagerLobotomizeEnabled = getBoolean("mobs.villager.lobotomize.enabled", villagerLobotomizeEnabled); |
| 47 | + villagerLobotomizeCheckInterval = getInt("mobs.villager.lobotomize.check-interval", villagerLobotomizeCheckInterval); |
| 48 | ++ villagerLobotomizeWaitUntilTradeLocked = getBoolean("mobs.villager.lobotomize.wait-until-trade-locked", villagerLobotomizeWaitUntilTradeLocked); |
| 49 | + villagerDisplayTradeItem = getBoolean("mobs.villager.display-trade-item", villagerDisplayTradeItem); |
| 50 | + villagerSpawnIronGolemRadius = getInt("mobs.villager.spawn-iron-golem.radius", villagerSpawnIronGolemRadius); |
| 51 | + villagerSpawnIronGolemLimit = getInt("mobs.villager.spawn-iron-golem.limit", villagerSpawnIronGolemLimit); |
0 commit comments