Expose the DataPackRegistries instance to the AddReloadListenerEvent (#6933)
This commit is contained in:
parent
60ee0bcdb3
commit
e4ffbeb329
3 changed files with 17 additions and 5 deletions
|
@ -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_() {
|
||||||
|
|
|
@ -18,6 +18,12 @@ 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue