mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-21 18:37:42 +01:00
Add config to only lobotomize villagers that have been traded with (#1466)
This commit is contained in:
@@ -5,7 +5,7 @@ Subject: [PATCH] Lobotomize stuck villagers
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
||||
index cb6ca99d429b395c0c79b57b1709eb1b8899da82..27e8f8bbaa25227c19399fab2bce8953d098e612 100644
|
||||
index af3af49f2965dbc3da7749bd9c6ae5e2d6b94cbe..fed066980b17d7c7fa773a00b314535c92fc53fd 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
||||
@@ -141,6 +141,8 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
@@ -17,19 +17,20 @@ index cb6ca99d429b395c0c79b57b1709eb1b8899da82..27e8f8bbaa25227c19399fab2bce8953
|
||||
|
||||
public long nextGolemPanic = -1; // Pufferfish
|
||||
|
||||
@@ -200,6 +202,47 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
@@ -200,6 +202,48 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
return this.level().purpurConfig.villagerAlwaysDropExp;
|
||||
}
|
||||
|
||||
+ private boolean checkLobotomized() {
|
||||
+ int interval = this.level().purpurConfig.villagerLobotomizeCheckInterval;
|
||||
+ boolean shouldCheckForTradeLocked = this.level().purpurConfig.villagerLobotomizeWaitUntilTradeLocked;
|
||||
+ if (this.notLobotomizedCount > 3) {
|
||||
+ // check half as often if not lobotomized for the last 3+ consecutive checks
|
||||
+ interval *= 2;
|
||||
+ }
|
||||
+ if (this.level().getGameTime() % interval == 0) {
|
||||
+ // offset Y for short blocks like dirt_path/farmland
|
||||
+ this.isLobotomized = !canTravelFrom(BlockPos.containing(this.position().x, this.getBoundingBox().minY + 0.0625D, this.position().z));
|
||||
+ this.isLobotomized = !(shouldCheckForTradeLocked && this.getVillagerXp() == 0) && !canTravelFrom(BlockPos.containing(this.position().x, this.getBoundingBox().minY + 0.0625D, this.position().z));
|
||||
+
|
||||
+ if (this.isLobotomized) {
|
||||
+ this.notLobotomizedCount = 0;
|
||||
@@ -65,7 +66,7 @@ index cb6ca99d429b395c0c79b57b1709eb1b8899da82..27e8f8bbaa25227c19399fab2bce8953
|
||||
@Override
|
||||
public Brain<Villager> getBrain() {
|
||||
return (Brain<Villager>) super.getBrain(); // CraftBukkit - decompile error
|
||||
@@ -297,13 +340,19 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
@@ -297,13 +341,19 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
// Paper start
|
||||
this.customServerAiStep(false);
|
||||
}
|
||||
@@ -104,19 +105,20 @@ index 6c15d40979fd3e3d246a447c432b321fbf29ada3..6ace76a829c88e2e747dbbcce0a6582c
|
||||
+ // Purpur end
|
||||
}
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
index e320196cc5f7302377916d5402579632374de09c..39f373cfbe0228d2040a9e7616a0491b11ee67a1 100644
|
||||
index e320196cc5f7302377916d5402579632374de09c..26351f5ba9fd4f2e231481cfdd52341e0f4d96a4 100644
|
||||
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
@@ -2795,6 +2795,8 @@ public class PurpurWorldConfig {
|
||||
@@ -2795,6 +2795,9 @@ public class PurpurWorldConfig {
|
||||
public boolean villagerAllowTrading = true;
|
||||
public boolean villagerAlwaysDropExp = false;
|
||||
public int villagerMinimumDemand = 0;
|
||||
+ public boolean villagerLobotomizeEnabled = false;
|
||||
+ public int villagerLobotomizeCheckInterval = 100;
|
||||
+ public boolean villagerLobotomizeWaitUntilTradeLocked = false;
|
||||
private void villagerSettings() {
|
||||
villagerRidable = getBoolean("mobs.villager.ridable", villagerRidable);
|
||||
villagerRidableInWater = getBoolean("mobs.villager.ridable-in-water", villagerRidableInWater);
|
||||
@@ -2816,6 +2818,17 @@ public class PurpurWorldConfig {
|
||||
@@ -2816,6 +2819,18 @@ public class PurpurWorldConfig {
|
||||
villagerAllowTrading = getBoolean("mobs.villager.allow-trading", villagerAllowTrading);
|
||||
villagerAlwaysDropExp = getBoolean("mobs.villager.always-drop-exp", villagerAlwaysDropExp);
|
||||
villagerMinimumDemand = getInt("mobs.villager.minimum-demand", villagerMinimumDemand);
|
||||
@@ -131,6 +133,7 @@ index e320196cc5f7302377916d5402579632374de09c..39f373cfbe0228d2040a9e7616a0491b
|
||||
+ }
|
||||
+ villagerLobotomizeEnabled = getBoolean("mobs.villager.lobotomize.enabled", villagerLobotomizeEnabled);
|
||||
+ villagerLobotomizeCheckInterval = getInt("mobs.villager.lobotomize.check-interval", villagerLobotomizeCheckInterval);
|
||||
+ villagerLobotomizeWaitUntilTradeLocked = getBoolean("mobs.villager.lobotomize.wait-until-trade-locked", villagerLobotomizeWaitUntilTradeLocked);
|
||||
}
|
||||
|
||||
public boolean vindicatorRidable = false;
|
||||
|
||||
Reference in New Issue
Block a user