Skip to content

Commit

Permalink
Fix duplicate registration error for empty loot table
Browse files Browse the repository at this point in the history
  • Loading branch information
XFactHD committed Jun 20, 2024
1 parent fd4e42a commit 204949d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main/java/net/neoforged/neoforge/event/EventHooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -680,12 +680,13 @@ public static boolean onProjectileImpact(Projectile projectile, HitResult ray) {
return NeoForge.EVENT_BUS.post(new ProjectileImpactEvent(projectile, ray)).isCanceled();
}

@Nullable
public static LootTable loadLootTable(ResourceLocation name, LootTable table) {
if (table == LootTable.EMPTY) // Empty table has a null name, and shouldn't be modified anyway.
return table;
return null;
LootTableLoadEvent event = new LootTableLoadEvent(name, table);
if (NeoForge.EVENT_BUS.post(event).isCanceled())
return LootTable.EMPTY;
if (NeoForge.EVENT_BUS.post(event).isCanceled() || event.getTable() == LootTable.EMPTY)
return null;
return event.getTable();
}

Expand Down

0 comments on commit 204949d

Please sign in to comment.