Skip to content

Add config to only lobotomize villagers that have been traded with#1466

Merged
granny merged 6 commits into
PurpurMC:ver/1.20.4from
2stinkysocks:ver/1.20.4
Jan 26, 2024
Merged

Add config to only lobotomize villagers that have been traded with#1466
granny merged 6 commits into
PurpurMC:ver/1.20.4from
2stinkysocks:ver/1.20.4

Conversation

@2stinkysocks

Copy link
Copy Markdown
Contributor

Added a config (defaults to old behavior) that makes villagers only get lobotomized if they've been traded with at least once (their trades are locked).

@granny granny left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge this patch into the lobotomize patch, feel free to add yourself as a co-author.

Comment on lines +23 to +28
- 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));

Copy link
Copy Markdown
Member

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.

this.isLobotomized = (shouldCheckForTradeLocked && this.getVillagerXp() != 0) && ...

Copy link
Copy Markdown
Contributor Author

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:

C = only lobotomize traded with
X = has no xp
E = existing lobotomize condition

F = is lobotomized


(C -> !X) ^ E

(!C v !X) ^ E

!(C ^ X) ^ E


C  X  E    F
0  0  0    0    !(0 ^ 0) ^ 0  0
0  0  1    1    !(0 ^ 0) ^ 1  1
0  1  0    0    !(0 ^ 1) ^ 0  0
0  1  1    1    !(0 ^ 1) ^ 1  1
1  0  0    0    !(1 ^ 0) ^ 0  0
1  0  1    1    !(1 ^ 0) ^ 1  1
1  1  0    0    !(1 ^ 1) ^ 0  0
1  1  1    0    !(1 ^ 1) ^ 1  0

@2stinkysocks 2stinkysocks requested a review from granny January 25, 2024 21:22

@granny granny left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! All that's left is creating a PR to PurpurDocs documenting the new option :) Once that's done both PRs will be merged later today (PST)

@granny granny added the needs-docs A pull request to PurpurDocs is required before merge label Jan 25, 2024
@2stinkysocks

Copy link
Copy Markdown
Contributor Author

PurpurMC/PurpurDocs#88

@granny granny removed the needs-docs A pull request to PurpurDocs is required before merge label Jan 25, 2024
@granny granny merged commit eab2140 into PurpurMC:ver/1.20.4 Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants