-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix creating the reverse map for loot table keys (#9766)
- Loading branch information
1 parent
fe54a13
commit 1765917
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
patches/server/1035-Fix-creating-the-reverse-map-for-loot-table-keys.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Jake Potrebic <[email protected]> | ||
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<LootTable> EMPTY_LOOT_TABLE_KEY = new LootDataId<>(LootDataType.TABLE, BuiltInLootTables.EMPTY); | ||
private Map<LootDataId<?>, ?> elements = Map.of(); | ||
private Multimap<LootDataType<?>, ResourceLocation> typeKeys = ImmutableMultimap.of(); | ||
- public Map<?, ResourceLocation> lootTableToKey = ImmutableMap.of(); // CraftBukkit | ||
+ public Map<LootTable, ResourceLocation> 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<Object, ResourceLocation> 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<LootTable, ResourceLocation> 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 | ||
} |