mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-19 11:59:25 +00:00
Moved some events to the Mod's event bus. You'll need to update which bus
you're listening to for these. (The Mod event bus is the only one actively dispatching events during model loading). ModelRegistryEvent, ModelBakeEvent, TextureStitchEvent.Pre, TextureStitchEvent.Post, ColourHandlerEvent.Block, ColourHandlerEvent.Item Signed-off-by: cpw <[email protected]>
This commit is contained in:
5 files changed
+28
-9
No files matched your search
@@ -19,6 +19,7 @@
|
||||
|
||||
package net.minecraftforge.fml;
|
||||
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
import net.minecraftforge.forgespi.language.IModInfo;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -158,4 +159,10 @@ public abstract class ModContainer
|
||||
* @return the mod object instance
|
||||
*/
|
||||
public abstract Object getMod();
|
||||
|
||||
/**
|
||||
* Accept an arbitrary event for processing by the mod. Probably posted to an event bus in the lower level container.
|
||||
* @param e Event to accept
|
||||
*/
|
||||
protected void acceptEvent(Event e) {}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.config.ConfigTracker;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
import net.minecraftforge.fml.event.lifecycle.GatherDataEvent;
|
||||
@@ -118,16 +119,16 @@ public class ModLoader
|
||||
return INSTANCE == null ? INSTANCE = new ModLoader() : INSTANCE;
|
||||
}
|
||||
|
||||
private static Runnable fireClientEvents()
|
||||
private Runnable fireClientEvents()
|
||||
{
|
||||
return ()->MinecraftForge.EVENT_BUS.post(new ModelRegistryEvent());
|
||||
return ()->postEvent(new ModelRegistryEvent());
|
||||
}
|
||||
|
||||
public void loadMods() {
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, ()->()-> ConfigTracker.INSTANCE.loadConfigs(ModConfig.Type.CLIENT, FMLPaths.CONFIGDIR.get()));
|
||||
ConfigTracker.INSTANCE.loadConfigs(ModConfig.Type.COMMON, FMLPaths.CONFIGDIR.get());
|
||||
dispatchAndHandleError(LifecycleEventProvider.SETUP);
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, ModLoader::fireClientEvents);
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, this::fireClientEvents);
|
||||
dispatchAndHandleError(LifecycleEventProvider.SIDED_SETUP);
|
||||
}
|
||||
|
||||
@@ -200,6 +201,10 @@ public class ModLoader
|
||||
}
|
||||
}
|
||||
|
||||
public void postEvent(Event e) {
|
||||
ModList.get().forEachModContainer((id, mc) -> mc.acceptEvent(e));
|
||||
}
|
||||
|
||||
public void finishMods()
|
||||
{
|
||||
dispatchAndHandleError(LifecycleEventProvider.ENQUEUE_IMC);
|
||||
|
||||
@@ -157,4 +157,9 @@ public class FMLModContainer extends ModContainer
|
||||
{
|
||||
return this.eventBus;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void acceptEvent(final Event e) {
|
||||
this.eventBus.post(e);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user