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 b74a4ce1b629d440681a1f5c026997ccaf1d0373..4eb97c8265ed8346b208d06a37f8068004593944 100644 --- a/net/minecraft/world/entity/ai/gossip/GossipContainer.java +++ b/net/minecraft/world/entity/ai/gossip/GossipContainer.java @@ -115,6 +115,16 @@ public class GossipContainer { public int getReputation(UUID identifier, Predicate 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; }