9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2026-01-04 15:41:31 +00:00
Files
LeavesMC/patches/server/0060-Shared-villager-discounts.patch
violetc f40d340092 1.20.6 (#216)
---------

Co-authored-by: MC_XiaoHei <xiaohei.xor7studio@foxmail.com>
Co-authored-by: Bluemangoo <chenfy2006@qq.com>
2024-05-20 23:03:56 +08:00

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 c7f012674361a323c1efeca4660cd3f46d308ee1..cea09319941f39dbb958ea7ee78c52c7f34fad9e 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
@@ -115,6 +115,16 @@ public class GossipContainer {
public int getReputation(UUID target, Predicate<GossipType> gossipTypeFilter) {
GossipContainer.EntityGossips entityGossips = this.gossips.get(target);
+ // Leaves start - sharedVillagerDiscounts
+ if (org.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;
}