Paper/nms-patches/LootTableRegistry.patch

32 lines
2.3 KiB
Diff
Raw Normal View History

--- a/net/minecraft/server/LootTableRegistry.java
+++ b/net/minecraft/server/LootTableRegistry.java
@@ -17,6 +17,7 @@
private static final Logger LOGGER = LogManager.getLogger();
private static final Gson b = (new GsonBuilder()).registerTypeAdapter(LootValueBounds.class, new LootValueBounds.a()).registerTypeAdapter(LootValueBinomial.class, new LootValueBinomial.a()).registerTypeAdapter(LootValueConstant.class, new LootValueConstant.a()).registerTypeAdapter(LootIntegerLimit.class, new LootIntegerLimit.a()).registerTypeAdapter(LootSelector.class, new LootSelector.b()).registerTypeAdapter(LootTable.class, new LootTable.b()).registerTypeHierarchyAdapter(LootEntryAbstract.class, new LootEntries.a()).registerTypeHierarchyAdapter(LootItemFunction.class, new LootItemFunctions.a()).registerTypeHierarchyAdapter(LootItemCondition.class, new LootItemConditions.a()).registerTypeHierarchyAdapter(LootTableInfo.EntityTarget.class, new LootTableInfo.EntityTarget.a()).create();
private Map<MinecraftKey, LootTable> c = ImmutableMap.of();
+ public Map<LootTable, MinecraftKey> lootTableToKey = ImmutableMap.of(); // CraftBukkit
private final LootPredicateManager d;
public LootTableRegistry(LootPredicateManager lootpredicatemanager) {
@@ -52,7 +53,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);
@@ -64,6 +65,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) {