From 1765917a6f25b4a954231aff8f4f9f0b630594d4 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Thu, 28 Sep 2023 16:29:34 -0700 Subject: [PATCH] Fix creating the reverse map for loot table keys (#9766) --- ...-the-reverse-map-for-loot-table-keys.patch | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 patches/server/1035-Fix-creating-the-reverse-map-for-loot-table-keys.patch diff --git a/patches/server/1035-Fix-creating-the-reverse-map-for-loot-table-keys.patch b/patches/server/1035-Fix-creating-the-reverse-map-for-loot-table-keys.patch new file mode 100644 index 0000000000..d429b016f2 --- /dev/null +++ b/patches/server/1035-Fix-creating-the-reverse-map-for-loot-table-keys.patch @@ -0,0 +1,36 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic +Date: Tue, 26 Sep 2023 18:32:49 -0700 +Subject: [PATCH] Fix creating the reverse map for loot table keys + + +diff --git a/src/main/java/net/minecraft/world/level/storage/loot/LootDataManager.java b/src/main/java/net/minecraft/world/level/storage/loot/LootDataManager.java +index dd375fffa727db76fa989248b9b836960974c372..3563fdb8f8d3dbaabc611ab5cdba1d771406b336 100644 +--- a/src/main/java/net/minecraft/world/level/storage/loot/LootDataManager.java ++++ b/src/main/java/net/minecraft/world/level/storage/loot/LootDataManager.java +@@ -30,7 +30,7 @@ public class LootDataManager implements PreparableReloadListener, LootDataResolv + public static final LootDataId EMPTY_LOOT_TABLE_KEY = new LootDataId<>(LootDataType.TABLE, BuiltInLootTables.EMPTY); + private Map, ?> elements = Map.of(); + private Multimap, ResourceLocation> typeKeys = ImmutableMultimap.of(); +- public Map lootTableToKey = ImmutableMap.of(); // CraftBukkit ++ public Map lootTableToKey = ImmutableMap.of(); // CraftBukkit // Paper - only store loot tables because those don't override equals and hashCode + + public LootDataManager() {} + +@@ -101,8 +101,14 @@ public class LootDataManager implements PreparableReloadListener, LootDataResolv + this.elements = map1; + this.typeKeys = com_google_common_collect_immutablemultimap_builder.build(); + // CraftBukkit start - build a reversed registry map +- ImmutableMap.Builder lootTableToKeyBuilder = ImmutableMap.builder(); +- this.elements.forEach((key, lootTable) -> lootTableToKeyBuilder.put((Object) lootTable, key.location())); ++ // Paper start - only create a map for loot tables ++ ImmutableMap.Builder lootTableToKeyBuilder = ImmutableMap.builder(); ++ this.elements.forEach((lootDataId, value) -> { ++ if (lootDataId.type() == LootDataType.TABLE && value instanceof LootTable lootTable) { ++ lootTableToKeyBuilder.put(lootTable, lootDataId.location()); ++ } ++ }); ++ // Paper end + this.lootTableToKey = lootTableToKeyBuilder.build(); + // CraftBukkit end + }