2021-06-11 14:02:28 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: JRoy <joshroy126@gmail.com>
|
|
|
|
Date: Wed, 1 Jul 2020 18:01:49 -0400
|
|
|
|
Subject: [PATCH] Remove streams from classes related villager gossip
|
|
|
|
|
|
|
|
|
|
|
|
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
|
2023-09-22 19:31:02 +02:00
|
|
|
index 15f9d40f9a2a9cb265ae130c39057a3568f6ee67..a18c157d6d16f03f622dd2fca58f40a8f199417f 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java
|
2022-12-07 21:16:54 +01:00
|
|
|
@@ -61,8 +61,22 @@ public class GossipContainer {
|
2021-06-11 14:02:28 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start - Remove streams from reputation
|
|
|
|
+ private List<GossipContainer.GossipEntry> decompress() {
|
2022-06-08 07:46:52 +02:00
|
|
|
+ List<GossipContainer.GossipEntry> list = new it.unimi.dsi.fastutil.objects.ObjectArrayList<>();
|
2022-12-07 21:16:54 +01:00
|
|
|
+ for (Map.Entry<UUID, GossipContainer.EntityGossips> entry : this.gossips.entrySet()) {
|
2021-06-11 14:02:28 +02:00
|
|
|
+ for (GossipContainer.GossipEntry cur : entry.getValue().decompress(entry.getKey())) {
|
2022-12-07 21:16:54 +01:00
|
|
|
+ if (cur.weightedValue() != 0) {
|
2021-06-11 14:02:28 +02:00
|
|
|
+ list.add(cur);
|
2022-12-07 21:16:54 +01:00
|
|
|
+ }
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
2022-06-08 07:46:52 +02:00
|
|
|
private Collection<GossipContainer.GossipEntry> selectGossipsForTransfer(RandomSource random, int count) {
|
2022-12-07 21:16:54 +01:00
|
|
|
- List<GossipContainer.GossipEntry> list = this.unpack().toList();
|
2022-06-08 07:46:52 +02:00
|
|
|
+ List<GossipContainer.GossipEntry> list = this.decompress(); // Paper - Remove streams from reputation
|
2021-06-11 14:02:28 +02:00
|
|
|
if (list.isEmpty()) {
|
|
|
|
return Collections.emptyList();
|
2021-06-14 11:46:59 +02:00
|
|
|
} else {
|
2022-12-07 21:16:54 +01:00
|
|
|
@@ -156,7 +170,7 @@ public class GossipContainer {
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
2022-12-07 21:16:54 +01:00
|
|
|
public <T> T store(DynamicOps<T> ops) {
|
|
|
|
- return GossipContainer.GossipEntry.LIST_CODEC.encodeStart(ops, this.unpack().toList()).resultOrPartial((error) -> {
|
|
|
|
+ return GossipContainer.GossipEntry.LIST_CODEC.encodeStart(ops, this.decompress()).resultOrPartial((error) -> {
|
|
|
|
LOGGER.warn("Failed to serialize gossips: {}", (Object)error);
|
|
|
|
}).orElseGet(ops::emptyList);
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
2022-12-07 21:16:54 +01:00
|
|
|
@@ -184,11 +198,23 @@ public class GossipContainer {
|
2021-06-14 11:46:59 +02:00
|
|
|
final Object2IntMap<GossipType> entries = new Object2IntOpenHashMap<>();
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
public int weightedValue(Predicate<GossipType> gossipTypeFilter) {
|
|
|
|
- return this.entries.object2IntEntrySet().stream().filter((entry) -> {
|
|
|
|
- return gossipTypeFilter.test(entry.getKey());
|
|
|
|
- }).mapToInt((entry) -> {
|
2021-06-14 11:46:59 +02:00
|
|
|
- return entry.getIntValue() * (entry.getKey()).weight;
|
2021-06-11 14:02:28 +02:00
|
|
|
- }).sum();
|
|
|
|
+ // Paper start - Remove streams from reputation
|
|
|
|
+ int weight = 0;
|
2021-06-14 11:46:59 +02:00
|
|
|
+ for (Object2IntMap.Entry<GossipType> entry : entries.object2IntEntrySet()) {
|
2021-06-11 14:02:28 +02:00
|
|
|
+ if (gossipTypeFilter.test(entry.getKey())) {
|
2021-06-16 19:48:25 +02:00
|
|
|
+ weight += entry.getIntValue() * entry.getKey().weight;
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return weight;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public List<GossipContainer.GossipEntry> decompress(UUID uuid) {
|
2022-06-08 07:46:52 +02:00
|
|
|
+ List<GossipContainer.GossipEntry> list = new it.unimi.dsi.fastutil.objects.ObjectArrayList<>();
|
2021-06-14 11:46:59 +02:00
|
|
|
+ for (Object2IntMap.Entry<GossipType> entry : entries.object2IntEntrySet()) {
|
2021-06-11 14:02:28 +02:00
|
|
|
+ list.add(new GossipContainer.GossipEntry(uuid, entry.getKey(), entry.getIntValue()));
|
|
|
|
+ }
|
|
|
|
+ return list;
|
2022-11-12 21:57:41 +01:00
|
|
|
+ // Paper end
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Stream<GossipContainer.GossipEntry> unpack(UUID target) {
|