PaperMC/nms-patches/LootTableRegistry.patch
2020-06-25 10:00:00 +10:00

31 lines
1.6 KiB
Diff

--- a/net/minecraft/server/LootTableRegistry.java
+++ b/net/minecraft/server/LootTableRegistry.java
@@ -15,6 +15,7 @@
private static final Logger LOGGER = LogManager.getLogger();
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) {
@@ -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);
@@ -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) {