mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-19 14:59:32 +00:00
--------- Co-authored-by: violetc <58360096+s-yh-china@users.noreply.github.com> Co-authored-by: Fortern <blueten.ki@gmail.com> Co-authored-by: MC_XiaoHei <xor7xiaohei@gmail.com> Co-authored-by: Helvetica Volubi <88063803+Suisuroru@users.noreply.github.com> Co-authored-by: MC_XiaoHei <xiaohei.xor7@outlook.com>
28 lines
1.6 KiB
Diff
28 lines
1.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: violetc <58360096+s-yh-china@users.noreply.github.com>
|
|
Date: Thu, 25 May 2023 17:15:22 +0800
|
|
Subject: [PATCH] Shared villager discounts
|
|
|
|
|
|
diff --git a/net/minecraft/world/entity/ai/gossip/GossipContainer.java b/net/minecraft/world/entity/ai/gossip/GossipContainer.java
|
|
index 425ca1931fb0a5c33ba7aaf4f639409c9fea836f..c17ba3f76069f23b38de2aabf29b784049059144 100644
|
|
--- a/net/minecraft/world/entity/ai/gossip/GossipContainer.java
|
|
+++ b/net/minecraft/world/entity/ai/gossip/GossipContainer.java
|
|
@@ -121,6 +121,16 @@ public class GossipContainer {
|
|
|
|
public int getReputation(UUID identifier, Predicate<GossipType> gossip) {
|
|
GossipContainer.EntityGossips entityGossips = this.gossips.get(identifier);
|
|
+ // Leaves start - sharedVillagerDiscounts
|
|
+ if (org.leavesmc.leaves.LeavesConfig.modify.sharedVillagerDiscounts && gossip.test(GossipType.MAJOR_POSITIVE)) {
|
|
+ int otherRep = 0;
|
|
+ if (entityGossips != null) {
|
|
+ otherRep = entityGossips.weightedValue(v -> gossip.test(v) && !v.equals(GossipType.MAJOR_POSITIVE));
|
|
+ }
|
|
+ int majorPositiveRep = this.gossips.values().stream().mapToInt(a -> a.weightedValue(v -> v.equals(GossipType.MAJOR_POSITIVE))).sum();
|
|
+ return otherRep + Math.min(majorPositiveRep, GossipType.MAJOR_POSITIVE.max * GossipType.MAJOR_POSITIVE.weight);
|
|
+ }
|
|
+ // Leaves end - sharedVillagerDiscounts
|
|
return entityGossips != null ? entityGossips.weightedValue(gossip) : 0;
|
|
}
|
|
|