mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-30 12:29:18 +00:00
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/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java b/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java
|
|
index 097007c1c25ba55d9916fc820dd1d1149d81f6f4..67c0a46b098d631b862df80511990c396934200b 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java
|
|
@@ -120,6 +120,16 @@ public class GossipContainer {
|
|
|
|
public int getReputation(UUID target, Predicate<GossipType> gossipTypeFilter) {
|
|
GossipContainer.EntityGossips entityGossips = this.gossips.get(target);
|
|
+ // Leaves start - sharedVillagerDiscounts
|
|
+ if (top.leavesmc.leaves.LeavesConfig.sharedVillagerDiscounts && gossipTypeFilter.test(GossipType.MAJOR_POSITIVE)) {
|
|
+ int otherRep = 0;
|
|
+ if (entityGossips != null) {
|
|
+ otherRep = entityGossips.weightedValue(v -> gossipTypeFilter.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(gossipTypeFilter) : 0;
|
|
}
|
|
|