mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-29 05:55:44 +01:00
Fix creating the reverse map for loot table keys (#9766)
This commit is contained in:
parent
fe54a13b13
commit
1765917a6f
@ -0,0 +1,36 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||||
|
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
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user