Expose the DataPackRegistries instance to the AddReloadListenerEvent (#6933)

This commit is contained in:
Jared 2020-07-08 23:24:01 +02:00 committed by GitHub
parent 60ee0bcdb3
commit e4ffbeb329
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 5 deletions

View file

@ -4,7 +4,7 @@
this.field_240952_b_.func_219534_a(this.field_240957_g_); this.field_240952_b_.func_219534_a(this.field_240957_g_);
this.field_240952_b_.func_219534_a(this.field_240959_i_); this.field_240952_b_.func_219534_a(this.field_240959_i_);
this.field_240952_b_.func_219534_a(this.field_240958_h_); this.field_240952_b_.func_219534_a(this.field_240958_h_);
+ net.minecraftforge.event.ForgeEventFactory.onResourceReload().forEach(field_240952_b_::func_219534_a); + net.minecraftforge.event.ForgeEventFactory.onResourceReload(this).forEach(field_240952_b_::func_219534_a);
} }
public FunctionReloader func_240960_a_() { public FunctionReloader func_240960_a_() {

View file

@ -17,7 +17,13 @@ import java.util.List;
*/ */
public class AddReloadListenerEvent extends Event public class AddReloadListenerEvent extends Event
{ {
private final List<IFutureReloadListener> listeners = new ArrayList<>(); private final List<IFutureReloadListener> listeners = new ArrayList<>();
private final DataPackRegistries dataPackRegistries;
public AddReloadListenerEvent(DataPackRegistries dataPackRegistries)
{
this.dataPackRegistries = dataPackRegistries;
}
/** /**
* @param listener the listener to add to the ResourceManager on reload * @param listener the listener to add to the ResourceManager on reload
@ -31,4 +37,9 @@ public class AddReloadListenerEvent extends Event
{ {
return ImmutableList.copyOf(listeners); return ImmutableList.copyOf(listeners);
} }
public DataPackRegistries getDataPackRegistries()
{
return dataPackRegistries;
}
} }

View file

@ -52,6 +52,7 @@ import net.minecraft.item.ItemUseContext;
import net.minecraft.loot.LootTable; import net.minecraft.loot.LootTable;
import net.minecraft.loot.LootTableManager; import net.minecraft.loot.LootTableManager;
import net.minecraft.resources.IFutureReloadListener; import net.minecraft.resources.IFutureReloadListener;
import net.minecraft.resources.DataPackRegistries;
import net.minecraft.world.spawner.AbstractSpawner; import net.minecraft.world.spawner.AbstractSpawner;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType; import net.minecraft.util.ActionResultType;
@ -724,9 +725,9 @@ public class ForgeEventFactory
return event.getNewTime(); return event.getNewTime();
} }
public static List<IFutureReloadListener> onResourceReload() public static List<IFutureReloadListener> onResourceReload(DataPackRegistries dataPackRegistries)
{ {
AddReloadListenerEvent event = new AddReloadListenerEvent(); AddReloadListenerEvent event = new AddReloadListenerEvent(dataPackRegistries);
MinecraftForge.EVENT_BUS.post(event); MinecraftForge.EVENT_BUS.post(event);
return event.getListeners(); return event.getListeners();
} }