Skip to content

Commit

Permalink
fixed #576
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke100000 committed Sep 10, 2023
1 parent beffeea commit c0d57bf
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 28 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* Married adventurers no longer despawn
* Added a procreation cooldown (3 in-game days by default)
* Added attack-text cooldown
* Fixed trait influenced gender preferences
* Added gender override config flag for players

# 7.5.7

Expand Down
1 change: 1 addition & 0 deletions common/src/main/java/net/mca/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public static Config getInstance() {
public boolean enableVillagerMailingPlayers = true;
public boolean allowBodyCustomizationInDestiny = true;
public boolean allowTraitCustomizationInDestiny = true;
public boolean enableGenderCheckForPlayers = true;

public float zombieBiteInfectionChance = 0.05f;
public float infectionChanceDecreasePerLevel = 0.25f;
Expand Down
23 changes: 17 additions & 6 deletions common/src/main/java/net/mca/entity/VillagerLike.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;

public interface VillagerLike<E extends Entity & VillagerLike<E>> extends CTrackedEntity<E>, VillagerDataContainer, Infectable, Messenger {
Expand Down Expand Up @@ -139,16 +140,26 @@ default boolean hasCustomSkin() {
}
}

default boolean canBeAttractedTo(VillagerLike<?> other) {
if (getTraits().eitherHaveTrait(Traits.Trait.HOMOSEXUAL, other)) {
return getTraits().hasSameTrait(Traits.Trait.HOMOSEXUAL, other) && getGenetics().getGender() == other.getGenetics().getGender();
/**
* @param villager the villager to check
* @return the set of "valid" genders
*/
default Set<Gender> getAttractedGenderSet(VillagerLike<?> villager) {
if (villager.getTraits().hasTrait(Traits.Trait.BISEXUAL)) {
return Set.of(Gender.MALE, Gender.FEMALE, Gender.NEUTRAL);
} else if (villager.getTraits().hasTrait(Traits.Trait.HOMOSEXUAL)) {
return Set.of(villager.getGenetics().getGender(), Gender.NEUTRAL);
} else {
return Set.of(villager.getGenetics().getGender().opposite(), Gender.NEUTRAL);
}
return getTraits().hasSameTrait(Traits.Trait.BISEXUAL, other)
|| getGenetics().getGender().isMutuallyAttracted(other.getGenetics().getGender());
}

default boolean canBeAttractedTo(VillagerLike<?> other) {
return getAttractedGenderSet(this).contains(other.getGenetics().getGender()) && getAttractedGenderSet(other).contains(getGenetics().getGender());
}

default boolean canBeAttractedTo(PlayerSaveData other) {
return canBeAttractedTo(toVillager(other));
return !Config.getInstance().enableGenderCheckForPlayers || canBeAttractedTo(toVillager(other));
}

default Hand getDominantHand() {
Expand Down
22 changes: 0 additions & 22 deletions common/src/main/java/net/mca/entity/ai/relationship/Gender.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,6 @@ public String getDataName() {
return dataName;
}

public boolean isNonBinary() {
return this == NEUTRAL || this == UNASSIGNED;
}

public Stream<Gender> getTransients() {
return isNonBinary() ? Stream.of(MALE, FEMALE) : Stream.of(this);
}

public Gender binary() {
return this == FEMALE ? FEMALE : MALE;
}
Expand All @@ -68,20 +60,6 @@ public Gender opposite() {
return this == FEMALE ? MALE : FEMALE;
}

/**
* Checks whether this gender is attracted to another.
*/
public boolean isAttractedTo(Gender other) {
return other == UNASSIGNED || this == NEUTRAL || other != this;
}

/**
* Checks whether both genders are mutually attracted to each other.
*/
public boolean isMutuallyAttracted(Gender other) {
return isAttractedTo(other) && other.isAttractedTo(this);
}

public static Gender byId(int id) {
if (id < 0 || id >= VALUES.length) {
return UNASSIGNED;
Expand Down

0 comments on commit c0d57bf

Please sign in to comment.