Skip to content
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

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

Merged
merged 6 commits into from
Jan 26, 2024
Merged

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

merged 6 commits into from
Jan 26, 2024

Conversation

2stinkysocks
Copy link
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).

Copy link
Member

@granny granny left a comment

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
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
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
Copy link
Member

@granny granny left a comment

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
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
1 check passed
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