Fix up event naming, move them to sensible packages and document everything a bit.

This commit is contained in:
cpw committed 2019-01-14 22:43:17 -05:00
1 parent 220bf8730a
commit 56a3926b86
95 files changed
+333 -251

No files matched your search

@@ -354,7 +354,7 @@ public class ForgeConfig
}
@Subscribe
public void postInit(FMLPostResourceLoadEvent evt)
public void postInit(InterModProcessEvent evt)
{
ForgeChunkManager.loadConfiguration();
}
@@ -22,12 +22,12 @@ package net.minecraftforge.common;
import net.minecraftforge.fml.FMLWorldPersistenceHook;
import net.minecraftforge.fml.VersionChecker;
import net.minecraftforge.fml.WorldPersistenceHooks;
import net.minecraftforge.fml.common.event.FMLLoadCompleteEvent;
import net.minecraftforge.fml.common.event.FMLModIdMappingEvent;
import net.minecraftforge.fml.common.event.FMLPostResourceLoadEvent;
import net.minecraftforge.fml.common.event.FMLPreRegistrationEvent;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.event.FMLServerStoppingEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent;
import net.minecraftforge.fml.event.lifecycle.FMLModIdMappingEvent;
import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import net.minecraftforge.fml.event.server.FMLServerStoppingEvent;
import net.minecraftforge.fml.javafmlmod.FMLModLoadingContext;
import net.minecraftforge.server.command.ForgeCommand;
import net.minecraftforge.versions.forge.ForgeVersion;
@@ -107,7 +107,7 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook
}
public void preInit(FMLPreRegistrationEvent evt)
public void preInit(FMLCommonSetupEvent evt)
{
CapabilityItemHandler.register();
CapabilityFluidHandler.register();
@@ -136,7 +136,7 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook
}
*/
public void postInit(FMLPostResourceLoadEvent evt)
public void postInit(InterModProcessEvent evt)
{
registerAllBiomesAndGenerateEvents();
//ForgeChunkManager.loadConfiguration();
@@ -19,7 +19,7 @@
package net.minecraftforge.fml;
import net.minecraftforge.fml.common.event.ModLifecycleEvent;
import net.minecraftforge.fml.event.lifecycle.ModLifecycleEvent;
import net.minecraftforge.fml.javafmlmod.FMLModContainer;
import net.minecraftforge.forgespi.language.ILifecycleEvent;
@@ -30,10 +30,10 @@ import java.util.function.Supplier;
public enum LifecycleEventProvider
{
CONSTRUCT(()->new LifecycleEvent(ModLoadingStage.CONSTRUCT)),
PREINIT(()->new LifecycleEvent(ModLoadingStage.PREINIT)),
SIDEDINIT(()->new LifecycleEvent(ModLoadingStage.SIDEDINIT)),
INIT(()->new LifecycleEvent(ModLoadingStage.INIT)),
POSTINIT(()->new LifecycleEvent(ModLoadingStage.POSTINIT)),
SETUP(()->new LifecycleEvent(ModLoadingStage.COMMON_SETUP)),
SIDED_SETUP(()->new LifecycleEvent(ModLoadingStage.SIDED_SETUP)),
ENQUEUE_IMC(()->new LifecycleEvent(ModLoadingStage.ENQUEUE_IMC)),
PROCESS_IMC(()->new LifecycleEvent(ModLoadingStage.PROCESS_IMC)),
COMPLETE(()->new LifecycleEvent(ModLoadingStage.COMPLETE));
public void dispatch(Consumer<List<ModLoadingException>> errorHandler) {
@@ -45,6 +45,42 @@ import java.util.stream.Stream;
import static net.minecraftforge.fml.Logging.CORE;
import static net.minecraftforge.fml.Logging.LOADING;
/**
* Loads mods.
*
* Dispatch cycle is seen in {@link #loadMods()} and {@link #finishMods()}
*
* Overall sequence for loadMods is:
* <dl>
* <dt>CONSTRUCT</dt>
* <dd>Constructs the mod instance. Mods can typically setup basic environment such as Event listeners
* and Configuration specifications here.</dd>
* <dt>Automated dispatches</dt>
* <dd>Dispatches automated elements : {@link net.minecraftforge.fml.common.Mod.EventBusSubscriber},
* {@link net.minecraftforge.event.RegistryEvent}, {@link net.minecraftforge.common.capabilities.CapabilityInject}
* and others</dd>
* <dt>CONFIG_LOAD</dt>
* <dd>Dispatches ConfigLoadEvent to mods</dd>
* <dt>COMMON_SETUP</dt>
* <dd>Dispatches {@link net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent} to mods</dd>
* <dt>SIDED_SETUP</dt>
* <dd>Dispatches {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent} or
* {@link net.minecraftforge.fml.event.lifecycle.FMLDedicatedServerSetupEvent} to mods</dd>
* </dl>
*
* Overall sequence for finishMods is:
* <dl>
* <dt>ENQUEUE_IMC</dt>
* <dd>Dispatches {@link net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent} to mods,
* for enqueuing {@link InterModComms} messages for other mods to receive subsequently</dd>
* <dt>PROCESS_IMC</dt>
* <dd>Dispatches {@link net.minecraftforge.fml.event.lifecycle.InterModProcessEvent} to mods,
* for processing {@link InterModComms} messages received from other mods prior to this event</dd>
* <dt>COMPLETE</dt>
* <dd>Dispatches {@link net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent} to mods,
* and completes the mod loading sequence.</dd>
* </dl>
*/
public class ModLoader
{
private static final Logger LOGGER = LogManager.getLogger();
@@ -91,9 +127,9 @@ public class ModLoader
ObjectHolderRegistry.findObjectHolders();
CapabilityManager.INSTANCE.injectCapabilities(modList.getAllScanData());
GameData.fireRegistryEvents();
dispatchAndHandleError(LifecycleEventProvider.PREINIT);
dispatchAndHandleError(LifecycleEventProvider.SETUP);
DistExecutor.runWhenOn(Dist.CLIENT, ModLoader::fireClientEvents);
dispatchAndHandleError(LifecycleEventProvider.SIDEDINIT);
dispatchAndHandleError(LifecycleEventProvider.SIDED_SETUP);
}
private void dispatchAndHandleError(LifecycleEventProvider event) {
@@ -130,8 +166,8 @@ public class ModLoader
public void finishMods()
{
dispatchAndHandleError(LifecycleEventProvider.INIT);
dispatchAndHandleError(LifecycleEventProvider.POSTINIT);
dispatchAndHandleError(LifecycleEventProvider.ENQUEUE_IMC);
dispatchAndHandleError(LifecycleEventProvider.PROCESS_IMC);
dispatchAndHandleError(LifecycleEventProvider.COMPLETE);
GameData.freezeData();
}
@@ -19,11 +19,7 @@
package net.minecraftforge.fml;
import net.minecraftforge.fml.common.event.FMLPostRegistrationEvent;
import net.minecraftforge.fml.common.event.FMLLoadCompleteEvent;
import net.minecraftforge.fml.common.event.FMLPostResourceLoadEvent;
import net.minecraftforge.fml.common.event.FMLPreRegistrationEvent;
import net.minecraftforge.fml.common.event.ModLifecycleEvent;
import net.minecraftforge.fml.event.lifecycle.*;
import java.util.function.Function;
import java.util.function.Supplier;
@@ -33,11 +29,11 @@ public enum ModLoadingStage
ERROR(null),
VALIDATE(null),
CONSTRUCT(null),
PREINIT(()-> FMLPreRegistrationEvent::new),
SIDEDINIT(SidedProvider.SIDEDINIT::get),
INIT(()-> FMLPostRegistrationEvent::new),
POSTINIT(()-> FMLPostResourceLoadEvent::new),
COMPLETE(()->FMLLoadCompleteEvent::new),
COMMON_SETUP(()-> FMLCommonSetupEvent::new),
SIDED_SETUP(SidedProvider.SIDED_SETUP_EVENT::get),
ENQUEUE_IMC(()-> InterModEnqueueEvent::new),
PROCESS_IMC(()-> InterModProcessEvent::new),
COMPLETE(()-> FMLLoadCompleteEvent::new),
DONE(null);
private final Supplier<Function<ModContainer, ModLifecycleEvent>> modLifecycleEventFunction;
@@ -24,8 +24,8 @@ import net.minecraft.server.dedicated.DedicatedServer;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.fml.client.ClientHooks;
import net.minecraftforge.fml.common.event.FMLClientInitEvent;
import net.minecraftforge.fml.common.event.FMLServerInitEvent;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLDedicatedServerSetupEvent;
import net.minecraftforge.fml.loading.FMLEnvironment;
import java.util.function.Function;
@@ -38,9 +38,9 @@ public enum SidedProvider
c->c.get().getDataFixer(),
s->s.get().getDataFixer(),
()-> { throw new UnsupportedOperationException(); }),
SIDEDINIT(
(Function<Supplier<Minecraft>, Function<ModContainer, Event>>)c-> mc->new FMLClientInitEvent(c, mc),
s-> mc->new FMLServerInitEvent(s, mc),
SIDED_SETUP_EVENT(
(Function<Supplier<Minecraft>, Function<ModContainer, Event>>)c-> mc->new FMLClientSetupEvent(c, mc),
s-> mc->new FMLDedicatedServerSetupEvent(s, mc),
()-> { throw new UnsupportedOperationException(); }),
STRIPCHARS(
(Function<Supplier<Minecraft>, Function<String, String>>)c-> ClientHooks::stripSpecialChars,
@@ -25,16 +25,16 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.common.event.FMLFingerprintViolationEvent;
import net.minecraftforge.fml.common.event.FMLPostResourceLoadEvent;
import net.minecraftforge.fml.common.event.FMLPreRegistrationEvent;
import net.minecraftforge.fml.common.event.FMLServerAboutToStartEvent;
import net.minecraftforge.fml.common.event.FMLServerStartedEvent;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.event.FMLServerStoppedEvent;
import net.minecraftforge.fml.common.event.FMLServerStoppingEvent;
import net.minecraftforge.fml.common.event.ModLifecycleEvent;
import net.minecraftforge.fml.common.event.FMLPostRegistrationEvent;
import net.minecraftforge.fml.event.lifecycle.FMLFingerprintViolationEvent;
import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.server.FMLServerAboutToStartEvent;
import net.minecraftforge.fml.event.server.FMLServerStartedEvent;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import net.minecraftforge.fml.event.server.FMLServerStoppedEvent;
import net.minecraftforge.fml.event.server.FMLServerStoppingEvent;
import net.minecraftforge.fml.event.lifecycle.ModLifecycleEvent;
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
/**
@@ -67,11 +67,11 @@ public @interface Mod
*
* These suggestions are mostly just suggestions on what to do in each event.
* <ul>
* <li> {@link FMLPreRegistrationEvent} : Run before anything else. Read your config, create blocks,
* <li> {@link FMLCommonSetupEvent} : Run before anything else. Read your config, create blocks,
* items, etc, and register them with the {@link GameRegistry}.</li>
* <li> {@link FMLPostRegistrationEvent} : Do your mod setup. Build whatever data structures you care about. Register recipes,
* <li> {@link InterModEnqueueEvent} : Do your mod setup. Build whatever data structures you care about. Register recipes,
* send {@link FMLInterModComms} messages to other mods.</li>
* <li> {@link FMLPostResourceLoadEvent} : Handle interaction with other mods, complete your setup based on this.</li>
* <li> {@link InterModProcessEvent} : Handle interaction with other mods, complete your setup based on this.</li>
* </ul>
* <p>These are the server lifecycle events. They are fired whenever a server is running, or about to run. Each time a server
* starts they will be fired in this sequence.
@@ -86,9 +86,9 @@ public @interface Mod
* The second set of events are more specialized, for receiving notification of specific
* information.
* <ul>
* <li> {@link FMLFingerprintViolationEvent} : Sent just before {@link FMLPreRegistrationEvent}
* <li> {@link FMLFingerprintViolationEvent} : Sent just before {@link FMLCommonSetupEvent}
* if something is wrong with your mod signature</li>
* <li> {@link IMCEvent} : Sent just after {@link FMLPostRegistrationEvent} if you have IMC messages waiting
* <li> {@link IMCEvent} : Sent just after {@link InterModEnqueueEvent} if you have IMC messages waiting
* from other mods</li>
* </ul>
*
@@ -1,44 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2018.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.fml.common.event;
import net.minecraftforge.fml.ModContainer;
/**
* Called after {@link FMLPreRegistrationEvent} and before {@link FMLPostResourceLoadEvent} during mod
* startup.
*
* This is the second of three commonly called events during mod initialization.
*
* Recommended activities: Register your recipes and Ore Dictionary entries in the
* {@link net.minecraftforge.fml.common.registry.GameRegistry} and {@link net.minecraftforge.oredict.OreDictionary}
* Dispatch requests through {@link FMLInterModComms} to other mods, to tell them what you wish them to do.
*
* @see net.minecraftforge.fml.common.Mod.EventHandler for how to subscribe to this event
* @author cpw
*/
public class FMLPostRegistrationEvent extends ModLifecycleEvent
{
public FMLPostRegistrationEvent(final ModContainer container)
{
super(container);
}
}
@@ -1,45 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2018.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.fml.common.event;
import net.minecraftforge.fml.ModContainer;
/**
* Called before {@link FMLPostRegistrationEvent} during mod startup.
*
* This is the first of three commonly called events during mod initialization.
*
* Recommended activities:
* Setup your logging {@link #getModLog()}
* Load any configuration data you might have {@link #getSuggestedConfigurationFile()}
* Search for a version.properties file and load it {@link #getVersionProperties()}
* Configure your {@link ModMetadata} programmatically {@link #getModMetadata()}
* Discover parts of your mod by using annotation search {@link #getAsmData()}
*
* @see net.minecraftforge.fml.common.Mod.EventHandler for how to subscribe to this event
* @author cpw
*/
public class FMLPreRegistrationEvent extends ModLifecycleEvent
{
public FMLPreRegistrationEvent(final ModContainer container)
{
super(container);
}
}
@@ -17,18 +17,32 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.fml.common.event;
package net.minecraftforge.fml.event.lifecycle;
import net.minecraft.client.Minecraft;
import net.minecraftforge.fml.ModContainer;
import java.util.function.Supplier;
public class FMLClientInitEvent extends ModLifecycleEvent
/**
* This is the second of four commonly called events during mod lifecycle startup.
*
* Called before {@link InterModEnqueueEvent}
* Called after {@link FMLCommonSetupEvent}
*
* Called on {@link net.minecraftforge.api.distmarker.Dist#CLIENT} - the game client.
*
* Alternative to {@link FMLDedicatedServerSetupEvent}.
*
* Do client only setup with this event, such as KeyBindings.
*
* This is a parallel dispatch event.
*/
public class FMLClientSetupEvent extends ModLifecycleEvent
{
private final Supplier<Minecraft> minecraftSupplier;
public FMLClientInitEvent(Supplier<Minecraft> mc, ModContainer container)
public FMLClientSetupEvent(Supplier<Minecraft> mc, ModContainer container)
{
super(container);
this.minecraftSupplier = mc;
@@ -0,0 +1,49 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2018.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.fml.event.lifecycle;
import net.minecraftforge.fml.ModContainer;
import java.util.function.Consumer;
/**
* This is the first of four commonly called events during mod initialization.
*
* Called before {@link FMLClientSetupEvent} or {@link FMLDedicatedServerSetupEvent} during mod startup.
*
* Called after {@link net.minecraftforge.event.RegistryEvent.Register} events have been fired.
*
* Either register your listener using {@link net.minecraftforge.fml.AutomaticEventSubscriber} and
* {@link net.minecraftforge.eventbus.api.SubscribeEvent} or
* {@link net.minecraftforge.eventbus.api.IEventBus#addListener(Consumer)} in your constructor.
*
* Most non-specific mod setup will be performed here. Note that this is a parallel dispatched event - you cannot
* interact with game state in this event.
*
* @see net.minecraftforge.fml.DeferredWorkQueue to enqueue work to run on the main game thread after this event has
* completed dispatch
*/
public class FMLCommonSetupEvent extends ModLifecycleEvent
{
public FMLCommonSetupEvent(final ModContainer container)
{
super(container);
}
}
@@ -17,18 +17,32 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.fml.common.event;
package net.minecraftforge.fml.event.lifecycle;
import net.minecraft.server.dedicated.DedicatedServer;
import net.minecraftforge.fml.ModContainer;
import java.util.function.Supplier;
public class FMLServerInitEvent extends ModLifecycleEvent
/**
* This is the second of four commonly called events during mod lifecycle startup.
*
* Called before {@link InterModEnqueueEvent}
* Called after {@link FMLCommonSetupEvent}
*
* Called on {@link net.minecraftforge.api.distmarker.Dist#DEDICATED_SERVER} - the dedicated game server.
*
* Alternative to {@link FMLClientSetupEvent}.
*
* Do dedicated server specific activities with this event.
*
* This is a parallel dispatch event.
*/
public class FMLDedicatedServerSetupEvent extends ModLifecycleEvent
{
private final Supplier<DedicatedServer> serverSupplier;
public FMLServerInitEvent(Supplier<DedicatedServer> server, ModContainer container)
public FMLDedicatedServerSetupEvent(Supplier<DedicatedServer> server, ModContainer container)
{
super(container);
this.serverSupplier = server;
@@ -17,7 +17,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.fml.common.event;
package net.minecraftforge.fml.event.lifecycle;
import java.io.File;
import java.util.Set;
@@ -17,7 +17,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.fml.common.event;
package net.minecraftforge.fml.event.lifecycle;
import net.minecraftforge.fml.ModContainer;
@@ -17,7 +17,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.fml.common.event;
package net.minecraftforge.fml.event.lifecycle;
import java.util.Comparator;
import java.util.List;
@@ -17,21 +17,25 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.fml.common.event;
package net.minecraftforge.fml.event.lifecycle;
import net.minecraftforge.fml.ModContainer;
/**
* Called after {@link FMLPostRegistrationEvent} has been dispatched on every mod. This is the third and last
* commonly called event during mod initialization.
* This is the third of four commonly called events during mod lifecycle startup.
*
* Recommended activities: interact with other mods to establish cross-mod behaviours.
* Called before {@link InterModProcessEvent}
* Called after {@link FMLClientSetupEvent} or {@link FMLDedicatedServerSetupEvent}
*
* @author cpw
*
* Enqueue {@link net.minecraftforge.fml.InterModComms} messages to other mods with this event.
*
* This is a parallel dispatch event.
*/
public class FMLPostResourceLoadEvent extends ModLifecycleEvent
public class InterModEnqueueEvent extends ModLifecycleEvent
{
public FMLPostResourceLoadEvent(final ModContainer container)
public InterModEnqueueEvent(final ModContainer container)
{
super(container);
}
@@ -0,0 +1,45 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2018.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.fml.event.lifecycle;
import net.minecraftforge.fml.ModContainer;
import java.util.function.Predicate;
/**
* This is the fourth of four commonly called events during mod lifecycle startup.
*
* Called after {@link InterModEnqueueEvent}
*
* Retrieve {@link net.minecraftforge.fml.InterModComms} {@link net.minecraftforge.fml.InterModComms.IMCMessage} suppliers
* and process them as you wish with this event.
*
* This is a parallel dispatch event.
*
* @see #getIMCStream()
* @see #getIMCStream(Predicate)
*/
public class InterModProcessEvent extends ModLifecycleEvent
{
public InterModProcessEvent(final ModContainer container)
{
super(container);
}
}
@@ -17,11 +17,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.fml.common.event;
package net.minecraftforge.fml.event.lifecycle;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.fml.InterModComms;
import net.minecraftforge.fml.ModContainer;
import java.util.function.Predicate;
import java.util.stream.Stream;
/**
* Parent type to all ModLifecycle events. This is based on Forge EventBus. They fire through the
* ModContainer's eventbus instance.
@@ -40,4 +44,12 @@ public class ModLifecycleEvent extends Event
String cn = getClass().getName();
return cn.substring(cn.lastIndexOf('.')+4,cn.length()-5);
}
public Stream<InterModComms.IMCMessage> getIMCStream() {
return InterModComms.getMessages(this.container.getModId());
}
public Stream<InterModComms.IMCMessage> getIMCStream(Predicate<String> methodFilter) {
return InterModComms.getMessages(this.container.getModId(), methodFilter);
}
}
@@ -17,12 +17,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.fml.common.event;
package net.minecraftforge.fml.event.server;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
/**
* Called before the server begins loading anything. Called after {@link FMLPostResourceLoadEvent} on the dedicated
* Called before the server begins loading anything. Called after {@link InterModProcessEvent} on the dedicated
* server, and after the player has hit "Play Selected World" in the client. Called before {@link FMLServerStartingEvent}.
*
* You can obtain a reference to the server with this event.
@@ -17,7 +17,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.fml.common.event;
package net.minecraftforge.fml.event.server;
import net.minecraft.server.MinecraftServer;
@@ -17,7 +17,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.fml.common.event;
package net.minecraftforge.fml.event.server;
import com.mojang.brigadier.CommandDispatcher;
import net.minecraft.command.CommandSource;
@@ -17,7 +17,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.fml.common.event;
package net.minecraftforge.fml.event.server;
import net.minecraft.server.MinecraftServer;
@@ -17,7 +17,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.fml.common.event;
package net.minecraftforge.fml.event.server;
import net.minecraft.server.MinecraftServer;
@@ -17,7 +17,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.fml.common.event;
package net.minecraftforge.fml.event.server;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.eventbus.api.Event;
@@ -29,7 +29,7 @@ import net.minecraftforge.fml.ModContainer;
import net.minecraftforge.fml.ModLoadingException;
import net.minecraftforge.fml.ModLoadingStage;
import net.minecraftforge.fml.ModThreadContext;
import net.minecraftforge.fml.common.event.ModLifecycleEvent;
import net.minecraftforge.fml.event.lifecycle.ModLifecycleEvent;
import net.minecraftforge.forgespi.language.IModInfo;
import net.minecraftforge.forgespi.language.ModFileScanData;
@@ -54,10 +54,10 @@ public class FMLModContainer extends ModContainer
LOGGER.debug("Creating FMLModContainer instance for {} with classLoader {} & {}", className, modClassLoader, getClass().getClassLoader());
this.scanResults = modFileScanResults;
triggerMap.put(ModLoadingStage.CONSTRUCT, dummy().andThen(this::beforeEvent).andThen(this::constructMod).andThen(this::afterEvent));
triggerMap.put(ModLoadingStage.PREINIT, dummy().andThen(this::beforeEvent).andThen(this::preinitMod).andThen(this::fireEvent).andThen(this::afterEvent));
triggerMap.put(ModLoadingStage.SIDEDINIT, dummy().andThen(this::beforeEvent).andThen(this::fireEvent).andThen(this::afterEvent));
triggerMap.put(ModLoadingStage.INIT, dummy().andThen(this::beforeEvent).andThen(this::initMod).andThen(this::fireEvent).andThen(this::afterEvent));
triggerMap.put(ModLoadingStage.POSTINIT, dummy().andThen(this::beforeEvent).andThen(this::fireEvent).andThen(this::afterEvent));
triggerMap.put(ModLoadingStage.COMMON_SETUP, dummy().andThen(this::beforeEvent).andThen(this::preinitMod).andThen(this::fireEvent).andThen(this::afterEvent));
triggerMap.put(ModLoadingStage.SIDED_SETUP, dummy().andThen(this::beforeEvent).andThen(this::fireEvent).andThen(this::afterEvent));
triggerMap.put(ModLoadingStage.ENQUEUE_IMC, dummy().andThen(this::beforeEvent).andThen(this::initMod).andThen(this::fireEvent).andThen(this::afterEvent));
triggerMap.put(ModLoadingStage.PROCESS_IMC, dummy().andThen(this::beforeEvent).andThen(this::fireEvent).andThen(this::afterEvent));
triggerMap.put(ModLoadingStage.COMPLETE, dummy().andThen(this::beforeEvent).andThen(this::completeLoading).andThen(this::fireEvent).andThen(this::afterEvent));
this.eventBus = IEventBus.create(this::onEventFailed);
@@ -29,11 +29,11 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.LogicalSidedProvider;
import net.minecraftforge.fml.common.event.FMLServerAboutToStartEvent;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.event.FMLServerStartedEvent;
import net.minecraftforge.fml.common.event.FMLServerStoppedEvent;
import net.minecraftforge.fml.common.event.FMLServerStoppingEvent;
import net.minecraftforge.fml.event.server.FMLServerAboutToStartEvent;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import net.minecraftforge.fml.event.server.FMLServerStartedEvent;
import net.minecraftforge.fml.event.server.FMLServerStoppedEvent;
import net.minecraftforge.fml.event.server.FMLServerStoppingEvent;
import net.minecraftforge.fml.network.NetworkHooks;
import net.minecraftforge.fml.packs.ResourcePackLoader;
import org.apache.logging.log4j.LogManager;