Paper/nms-patches/LootTableRegistry.patch

32 lines
1.6 KiB
Diff
Raw Normal View History

--- a/net/minecraft/server/LootTableRegistry.java
+++ b/net/minecraft/server/LootTableRegistry.java
2020-06-25 02:00:00 +02:00
@@ -15,6 +15,7 @@
private static final Logger LOGGER = LogManager.getLogger();
2020-06-25 02:00:00 +02:00
private static final Gson b = LootSerialization.c().create();
private Map<MinecraftKey, LootTable> c = ImmutableMap.of();
+ public Map<LootTable, MinecraftKey> lootTableToKey = ImmutableMap.of(); // CraftBukkit
private final LootPredicateManager d;
public LootTableRegistry(LootPredicateManager lootpredicatemanager) {
2020-06-25 02:00:00 +02:00
@@ -50,7 +51,7 @@
LootPredicateManager lootpredicatemanager = this.d;
this.d.getClass();
- Function function = lootpredicatemanager::a;
+ Function<MinecraftKey, LootItemCondition> function = lootpredicatemanager::a; // CraftBukkit - decompile error
immutablemap.getClass();
LootCollector lootcollector = new LootCollector(lootcontextparameterset, function, immutablemap::get);
2020-06-25 02:00:00 +02:00
@@ -62,6 +63,11 @@
LootTableRegistry.LOGGER.warn("Found validation problem in " + s + ": " + s1);
});
this.c = immutablemap;
+ // CraftBukkit start - build a reversed registry map
+ ImmutableMap.Builder<LootTable, MinecraftKey> lootTableToKeyBuilder = ImmutableMap.builder();
+ this.c.forEach((lootTable, key) -> lootTableToKeyBuilder.put(key, lootTable)); // PAIL rename keyToLootTable
+ this.lootTableToKey = lootTableToKeyBuilder.build();
+ // CraftBukkit end
}
public static void a(LootCollector lootcollector, MinecraftKey minecraftkey, LootTable loottable) {