2021-06-11 14:02:28 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Josh Roy <10731363+JRoy@users.noreply.github.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
|
|
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 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
|
|
|
|
@@ -0,0 +0,0 @@ public class GossipContainer {
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // 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 {
|
2021-06-11 14:02:28 +02:00
|
|
|
@@ -0,0 +0,0 @@ public class GossipContainer {
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
2021-06-14 11:46:59 +02:00
|
|
|
@@ -0,0 +0,0 @@ public class GossipContainer {
|
|
|
|
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) {
|