-
-
Notifications
You must be signed in to change notification settings - Fork 478
Add config to only lobotomize villagers that have been traded with #1466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c1bdde9
Add config to only lobotomize if villagers have been traded with
2stinkysocks 6cfef5f
Merge branch 'ver/1.20.4' into ver/1.20.4
2stinkysocks 3501d4e
Merge branch 'PurpurMC:ver/1.20.4' into ver/1.20.4
2stinkysocks 9172258
Merge branch 'PurpurMC:ver/1.20.4' into ver/1.20.4
2stinkysocks eec1e99
Modify patch 0242 to add a config for lobotomozing only trade locked …
2stinkysocks 57f0077
Merge branch 'ver/1.20.4' into 2stinkysocks/ver/1.20.4
granny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
patches/server/0307-Add-config-to-only-lobotomize-if-villagers-have-been.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: 2stinkysocks <zmehall@gmail.com> | ||
| Date: Wed, 27 Dec 2023 16:04:52 -0700 | ||
| Subject: [PATCH] Add config to only lobotomize if villagers have been traded | ||
| with | ||
|
|
||
|
|
||
| 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 68404053233985cb830e95e287c81875a3b86957..15862eb0e3c56d3dac5d7772242a75fbfc8c877a 100644 | ||
| --- a/src/main/java/net/minecraft/world/entity/npc/Villager.java | ||
| +++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java | ||
| @@ -204,13 +204,18 @@ public class Villager extends AbstractVillager implements ReputationEventHandler | ||
|
|
||
| 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)); | ||
| + boolean canLobotomize = true; | ||
| + if(shouldCheckForTradeLocked) { | ||
| + canLobotomize = this.getVillagerXp() != 0; | ||
| + } | ||
| + this.isLobotomized = canLobotomize && !canTravelFrom(BlockPos.containing(this.position().x, this.getBoundingBox().minY + 0.0625D, this.position().z)); | ||
|
|
||
| if (this.isLobotomized) { | ||
| this.notLobotomizedCount = 0; | ||
| diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java | ||
| index bbf371428e343cfad0ae118c387fd2342541fe53..6f921269ab3563618cc4ce780b6e047a16b85a0a 100644 | ||
| --- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java | ||
| +++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java | ||
| @@ -2900,6 +2900,7 @@ public class PurpurWorldConfig { | ||
| public int villagerMinimumDemand = 0; | ||
| public boolean villagerLobotomizeEnabled = false; | ||
| public int villagerLobotomizeCheckInterval = 100; | ||
| + public boolean villagerLobotomizeWaitUntilTradeLocked = false; | ||
| public boolean villagerDisplayTradeItem = true; | ||
| public int villagerSpawnIronGolemRadius = 0; | ||
| public int villagerSpawnIronGolemLimit = 0; | ||
| @@ -2935,6 +2936,7 @@ public class PurpurWorldConfig { | ||
| } | ||
| 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); | ||
| villagerDisplayTradeItem = getBoolean("mobs.villager.display-trade-item", villagerDisplayTradeItem); | ||
| villagerSpawnIronGolemRadius = getInt("mobs.villager.spawn-iron-golem.radius", villagerSpawnIronGolemRadius); | ||
| villagerSpawnIronGolemLimit = getInt("mobs.villager.spawn-iron-golem.limit", villagerSpawnIronGolemLimit); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inline the canLobotomize check into the
this.isLobotomized = ...line.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
condensed the logic, yours was a bit off when I double checked it. here's a truth table I used to check my work: