OMG! Documentation? WUT? I haz lost my mind.
Also, Functional interface for IMC. Senders can send a classname implementing Guava's function, and receivers will be able to get that function, and do, well, whatever, really. Probably best for those callback type scenarios, connecting up APIs and stuffs.
This commit is contained in:
parent
b4dc15a9cb
commit
c713309769
17 changed files with 333 additions and 21 deletions
|
@ -18,6 +18,9 @@ import net.minecraftforge.fml.common.discovery.ASMDataTable;
|
|||
|
||||
import com.google.common.collect.ListMultimap;
|
||||
|
||||
/**
|
||||
* An internal FML event used to signal the construction of mods. Should not be used by mods.
|
||||
*/
|
||||
public class FMLConstructionEvent extends FMLStateEvent
|
||||
{
|
||||
private ModClassLoader modClassLoader;
|
||||
|
|
|
@ -14,6 +14,10 @@ package net.minecraftforge.fml.common.event;
|
|||
|
||||
import net.minecraftforge.fml.common.ModContainer;
|
||||
|
||||
/**
|
||||
* Parent type to all FML events. This is based on Guava EventBus. Event Subscription isn't using the Guava annotation
|
||||
* however, it's using a custom annotation specific to FML {@link net.minecraftforge.fml.common.Mod.EventHandler}
|
||||
*/
|
||||
public class FMLEvent
|
||||
{
|
||||
public final String getEventType()
|
||||
|
|
|
@ -16,8 +16,13 @@ import java.io.File;
|
|||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
|
||||
/**
|
||||
* A special event used when the {@link Mod#certificateFingerprint()} doesn't match the certificate loaded from the JAR
|
||||
* file. You could use this to log a warning that the code that is running might not be yours, for example.
|
||||
*/
|
||||
public class FMLFingerprintViolationEvent extends FMLEvent {
|
||||
|
||||
public final boolean isDirectory;
|
||||
|
|
|
@ -14,6 +14,19 @@ package net.minecraftforge.fml.common.event;
|
|||
|
||||
import net.minecraftforge.fml.common.LoaderState.ModState;
|
||||
|
||||
/**
|
||||
* Called after {@link FMLPreInitializationEvent} and before {@link FMLPostInitializationEvent} 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 FMLInitializationEvent extends FMLStateEvent
|
||||
{
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
package net.minecraftforge.fml.common.event;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Optional;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
@ -23,6 +25,7 @@ import net.minecraftforge.fml.common.Mod.Instance;
|
|||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
/**
|
||||
* Simple intermod communications to receive simple messages directed at you
|
||||
|
@ -37,10 +40,10 @@ public class FMLInterModComms {
|
|||
|
||||
/**
|
||||
* Subscribe to this event to receive your messages (they are sent between
|
||||
* {@link Init} and {@link PostInit})
|
||||
* {@link FMLInitializationEvent} and {@link FMLPostInitializationEvent})
|
||||
*
|
||||
* @see net.minecraftforge.fml.common.Mod.EventHandler for how to subscribe to this event
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public static class IMCEvent extends FMLEvent {
|
||||
private ModContainer activeContainer;
|
||||
|
@ -72,6 +75,7 @@ public class FMLInterModComms {
|
|||
*
|
||||
*/
|
||||
public static final class IMCMessage {
|
||||
private final boolean isFunction;
|
||||
/**
|
||||
* This is the modid of the mod that sent you the message
|
||||
*/
|
||||
|
@ -83,12 +87,19 @@ public class FMLInterModComms {
|
|||
/**
|
||||
* This field, and {@link #key} are both at the mod's discretion
|
||||
*/
|
||||
private Object value;
|
||||
private final Object value;
|
||||
|
||||
private IMCMessage(String key, Object value)
|
||||
{
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
this.isFunction = false;
|
||||
}
|
||||
|
||||
private IMCMessage(String key, String value, boolean isFunction) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
this.isFunction = isFunction;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -97,6 +108,10 @@ public class FMLInterModComms {
|
|||
return sender;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sending modId of this message.
|
||||
* @return The modId of the mod that originated the message
|
||||
*/
|
||||
public String getSender()
|
||||
{
|
||||
return this.sender;
|
||||
|
@ -107,70 +122,200 @@ public class FMLInterModComms {
|
|||
this.sender = activeModContainer.getModId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the string value from this message.
|
||||
* @throws ClassCastException if this message doesn't contain a String value
|
||||
* @return The string value
|
||||
*/
|
||||
public String getStringValue()
|
||||
{
|
||||
return (String) value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link NBTTagCompound} value from this message
|
||||
* @throws ClassCastException if this message doesn't contain an NBT value
|
||||
* @return The NBT value
|
||||
*/
|
||||
public NBTTagCompound getNBTValue()
|
||||
{
|
||||
return (NBTTagCompound) value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link ItemStack} value from this message
|
||||
* @throws ClassCastException if this message doesn't contain an Itemstack value
|
||||
* @return The Itemstack value
|
||||
*/
|
||||
public ItemStack getItemStackValue()
|
||||
{
|
||||
return (ItemStack) value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link Function} value from this message. This will attempt to classload the function
|
||||
* supplied by the caller. The parameter classes are strictly to give a concrete generic function return value.
|
||||
* @param functionFrom The type of the argument to the function
|
||||
* @param functionTo The type of the result of the function
|
||||
* @param <T> The argument type
|
||||
* @param <V> The result type
|
||||
* @return The function value or Optional.absent if it wasn't readable or isn't a function call
|
||||
*/
|
||||
public <T,V> Optional<Function<T,V>> getFunctionValue(Class<T> functionFrom, Class<V> functionTo) {
|
||||
if (!isFunction) {
|
||||
return Optional.absent();
|
||||
}
|
||||
try {
|
||||
Function<T,V> f = Class.forName((String) value).asSubclass(Function.class).newInstance();
|
||||
return Optional.of(f);
|
||||
} catch (Exception e) {
|
||||
FMLLog.getLogger().log(Level.INFO, "An error occurred instantiating the IMC function. key: {} value: {}, caller: {}", key,value,sender);
|
||||
return Optional.absent();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual message class type
|
||||
* @return The type of the message
|
||||
*/
|
||||
public Class<?> getMessageType()
|
||||
{
|
||||
return value.getClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this a string type message
|
||||
* @return if this is a string type message
|
||||
*/
|
||||
public boolean isStringMessage()
|
||||
{
|
||||
return String.class.isAssignableFrom(getMessageType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this an {@link ItemStack} type message
|
||||
* @return if this is an itemstack type message
|
||||
*/
|
||||
public boolean isItemStackMessage()
|
||||
{
|
||||
return ItemStack.class.isAssignableFrom(getMessageType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this an {@link NBTTagCompound} type message
|
||||
* @return if this is an NBT type message
|
||||
*/
|
||||
public boolean isNBTMessage()
|
||||
{
|
||||
return NBTTagCompound.class.isAssignableFrom(getMessageType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this a {@link Function} type message
|
||||
* @return if this is a function type message
|
||||
*/
|
||||
public boolean isFunctionMessage() { return Function.class.isAssignableFrom(getMessageType()); }
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a startup time message
|
||||
* @param modId The modid to send it to
|
||||
* @param key The mod specific key
|
||||
* @param value An NBT type value
|
||||
* @return if the message was enqueued successfully and will be processed during startup
|
||||
*/
|
||||
public static boolean sendMessage(String modId, String key, NBTTagCompound value)
|
||||
{
|
||||
return enqueueStartupMessage(modId, new IMCMessage(key, value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a startup time message
|
||||
* @param modId The modid to send it to
|
||||
* @param key The mod specific key
|
||||
* @param value An Itemstack value
|
||||
* @return if the message was enqueued successfully and will be processed during startup
|
||||
*/
|
||||
public static boolean sendMessage(String modId, String key, ItemStack value)
|
||||
{
|
||||
return enqueueStartupMessage(modId, new IMCMessage(key, value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a startup time message
|
||||
* @param modId The modid to send it to
|
||||
* @param key The mod specific key
|
||||
* @param value A String value
|
||||
* @return if the message was enqueued successfully and will be processed during startup
|
||||
*/
|
||||
public static boolean sendMessage(String modId, String key, String value)
|
||||
{
|
||||
return enqueueStartupMessage(modId, new IMCMessage(key, value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a startup time function message
|
||||
* @param modId The modid to send it to
|
||||
* @param key The mod specific key
|
||||
* @param functionClassName The class name of a function that will be instantiated when the
|
||||
* message is read. It must implement {@link Function}
|
||||
* @return if the message was enqueued successfully and will be processed during startup
|
||||
*/
|
||||
public static boolean sendFunctionMessage(String modId, String key, String functionClassName)
|
||||
{
|
||||
return enqueueStartupMessage(modId, new IMCMessage(key, functionClassName, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a post-startup message
|
||||
* @param sourceMod The mod sending the message
|
||||
* @param modId The modid to send it to
|
||||
* @param key The mod specific key
|
||||
* @param value An NBT type value
|
||||
*/
|
||||
public static void sendRuntimeMessage(Object sourceMod, String modId, String key, NBTTagCompound value)
|
||||
{
|
||||
enqueueMessage(sourceMod, modId, new IMCMessage(key, value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a post-startup message
|
||||
* @param sourceMod The mod sending the message
|
||||
* @param modId The modid to send it to
|
||||
* @param key The mod specific key
|
||||
* @param value An Itemstack value
|
||||
*/
|
||||
public static void sendRuntimeMessage(Object sourceMod, String modId, String key, ItemStack value)
|
||||
{
|
||||
enqueueMessage(sourceMod, modId, new IMCMessage(key, value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a post-startup message
|
||||
* @param sourceMod The mod sending the message
|
||||
* @param modId The modid to send it to
|
||||
* @param key The mod specific key
|
||||
* @param value A string value
|
||||
*/
|
||||
public static void sendRuntimeMessage(Object sourceMod, String modId, String key, String value)
|
||||
{
|
||||
enqueueMessage(sourceMod, modId, new IMCMessage(key, value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a post-startup function message.
|
||||
*
|
||||
* @param sourceMod The mod originating this message
|
||||
* @param modId The modid to send it to
|
||||
* @param key The mod specific key
|
||||
* @param functionClassName The name of a class to be loaded when the caller processes this message.
|
||||
* The named class must extend {@link Function}
|
||||
*/
|
||||
public static void sendRuntimeFunctionMessage(Object sourceMod, String modId, String key, String functionClassName)
|
||||
{
|
||||
enqueueMessage(sourceMod, modId, new IMCMessage(key, functionClassName, true));
|
||||
}
|
||||
|
||||
private static boolean enqueueStartupMessage(String modTarget, IMCMessage message)
|
||||
{
|
||||
if (Loader.instance().activeModContainer() == null)
|
||||
|
|
|
@ -14,6 +14,12 @@ package net.minecraftforge.fml.common.event;
|
|||
|
||||
import net.minecraftforge.fml.common.LoaderState.ModState;
|
||||
|
||||
/**
|
||||
* This is a mostly internal event fired to mod containers that indicates that loading is complete. Mods should not
|
||||
* in general override or otherwise attempt to implement this event.
|
||||
*
|
||||
* @author cpw
|
||||
*/
|
||||
public class FMLLoadCompleteEvent extends FMLStateEvent
|
||||
{
|
||||
|
||||
|
|
|
@ -12,6 +12,11 @@
|
|||
|
||||
package net.minecraftforge.fml.common.event;
|
||||
|
||||
/**
|
||||
* Internal only event, used to begin the lifecycle of loading mods.
|
||||
*
|
||||
* @author cpw
|
||||
*/
|
||||
public class FMLLoadEvent
|
||||
{
|
||||
|
||||
|
|
|
@ -17,7 +17,9 @@ import com.google.common.collect.ListMultimap;
|
|||
* These can be remapped to other existing objects, or simply discarded.
|
||||
* Use get() and getAll() to process this event.
|
||||
*
|
||||
* @author cpw, Player
|
||||
* @see net.minecraftforge.fml.common.Mod.EventHandler for how to subscribe to this event
|
||||
* @author cpw
|
||||
* @author Player
|
||||
*
|
||||
*/
|
||||
public class FMLMissingMappingsEvent extends FMLEvent {
|
||||
|
@ -31,7 +33,7 @@ public class FMLMissingMappingsEvent extends FMLEvent {
|
|||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public static enum Action {
|
||||
public enum Action {
|
||||
/**
|
||||
* Take the default action
|
||||
*/
|
||||
|
@ -70,16 +72,6 @@ public class FMLMissingMappingsEvent extends FMLEvent {
|
|||
this.name = name;
|
||||
this.id = id;
|
||||
}
|
||||
/**
|
||||
* @deprecated use ignore(), warn(), fail() or remap() instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void setAction(Action target)
|
||||
{
|
||||
if (target == Action.DEFAULT || target == Action.REMAP || target == Action.BLOCKONLY) throw new IllegalArgumentException();
|
||||
|
||||
this.action = target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ignore the missing item.
|
||||
|
|
|
@ -9,8 +9,21 @@ import java.util.Map.Entry;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* Called whenever the ID mapping might have changed. If you register for this event, you
|
||||
* will be called back whenever the client or server loads an ID set. This includes both
|
||||
* when the ID maps are loaded from disk, as well as when the ID maps revert to the initial
|
||||
* state.
|
||||
*
|
||||
* Note: you cannot change the IDs that have been allocated, but you might want to use
|
||||
* this event to update caches or other in-mod artifacts that might be impacted by an ID
|
||||
* change.
|
||||
*
|
||||
* @see net.minecraftforge.fml.common.Mod.EventHandler for how to subscribe to this event
|
||||
* @author cpw
|
||||
*/
|
||||
public class FMLModIdMappingEvent extends FMLEvent {
|
||||
public static enum RemapTarget { BLOCK, ITEM }
|
||||
public enum RemapTarget { BLOCK, ITEM }
|
||||
public class ModRemapping
|
||||
{
|
||||
public final int oldId;
|
||||
|
|
|
@ -12,11 +12,29 @@
|
|||
|
||||
package net.minecraftforge.fml.common.event;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.LoaderState.ModState;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
/**
|
||||
* Called after {@link FMLInitializationEvent} has been dispatched on every mod. This is the third and last
|
||||
* commonly called event during mod initialization.
|
||||
*
|
||||
* Recommended activities: interact with other mods to establish cross-mod behaviours.
|
||||
*
|
||||
* @see net.minecraftforge.fml.common.Mod.EventHandler for how to subscribe to this event
|
||||
* @author cpw
|
||||
*/
|
||||
public class FMLPostInitializationEvent extends FMLStateEvent
|
||||
{
|
||||
public FMLPostInitializationEvent(Object... data)
|
||||
|
@ -30,21 +48,38 @@ public class FMLPostInitializationEvent extends FMLStateEvent
|
|||
return ModState.POSTINITIALIZED;
|
||||
}
|
||||
|
||||
public Object buildSoftDependProxy(String modId, String className)
|
||||
/**
|
||||
* Build an object depending on if a specific target mod is loaded or not.
|
||||
*
|
||||
* Usually would be used to access an object from the other mod.
|
||||
*
|
||||
* @param modId The modId I conditionally want to build an object for
|
||||
* @param className The name of the class I wish to instantiate
|
||||
* @return An optional containing the object if possible, or null if not
|
||||
*/
|
||||
public Optional<Object> buildSoftDependProxy(String modId, String className, Object... arguments)
|
||||
{
|
||||
if (Loader.isModLoaded(modId))
|
||||
{
|
||||
Class<?>[] args = Lists.transform(Lists.newArrayList(arguments),new Function<Object, Class<?>>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public Class<?> apply(@Nullable Object input) {
|
||||
return input.getClass();
|
||||
}
|
||||
}).toArray(new Class[0]);
|
||||
try
|
||||
{
|
||||
Class<?> clz = Class.forName(className,true,Loader.instance().getModClassLoader());
|
||||
return clz.newInstance();
|
||||
Constructor<?> ct = clz.getConstructor(args);
|
||||
return Optional.fromNullable(ct.newInstance(arguments));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Throwables.propagateIfPossible(e);
|
||||
return null;
|
||||
FMLLog.getLogger().log(Level.INFO, "An error occurred trying to build a soft depend proxy",e);
|
||||
return Optional.absent();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return Optional.absent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,22 @@ import net.minecraftforge.fml.common.discovery.ASMDataTable;
|
|||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Called before {@link FMLInitializationEvent} 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()}
|
||||
* Register your blocks and items with the {@link net.minecraftforge.fml.common.registry.GameRegistry}
|
||||
* 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 FMLPreInitializationEvent extends FMLStateEvent
|
||||
{
|
||||
private ModMetadata modMetadata;
|
||||
|
@ -57,31 +73,58 @@ public class FMLPreInitializationEvent extends FMLStateEvent
|
|||
this.suggestedConfigFile = new File(configurationDir, activeContainer.getModId()+".cfg");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link File} the mod was loaded from
|
||||
* @return The file the mod was loaded from
|
||||
*/
|
||||
public File getSourceFile()
|
||||
{
|
||||
return sourceFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link ModMetadata} for this mod
|
||||
* @return the mod metadata for the mod
|
||||
*/
|
||||
public ModMetadata getModMetadata()
|
||||
{
|
||||
return modMetadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the main configuration directory for this minecraft instance
|
||||
* @return the main configuration directory
|
||||
*/
|
||||
public File getModConfigurationDirectory()
|
||||
{
|
||||
return configurationDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a suggested configuration file for this mod. It will be of the form <modid>.cfg
|
||||
* @return A suggested configuration file name for this mod
|
||||
*/
|
||||
public File getSuggestedConfigurationFile()
|
||||
{
|
||||
return suggestedConfigFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link ASMDataTable} for this instance of Minecraft. This is a special structure containing
|
||||
* parsing information from FML. It can be searched for annotations parsed out by FML.
|
||||
* @return
|
||||
*/
|
||||
public ASMDataTable getAsmData()
|
||||
{
|
||||
return asmData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a version.properties file as a {@link Properties} object from the mod file.
|
||||
* This can be used to load build-type information
|
||||
* such as a unique version number from a properties file shipped as part of the distributable.
|
||||
* @return A properties object if one exists, else null
|
||||
*/
|
||||
public Properties getVersionProperties()
|
||||
{
|
||||
if (this.modContainer instanceof FMLModContainer)
|
||||
|
|
|
@ -15,6 +15,14 @@ package net.minecraftforge.fml.common.event;
|
|||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraftforge.fml.common.LoaderState.ModState;
|
||||
|
||||
/**
|
||||
* Called before the server begins loading anything. Called after {@link FMLPostInitializationEvent} 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.
|
||||
* @see net.minecraftforge.fml.common.Mod.EventHandler for how to subscribe to this event
|
||||
* @author cpw
|
||||
*/
|
||||
public class FMLServerAboutToStartEvent extends FMLStateEvent {
|
||||
|
||||
private MinecraftServer server;
|
||||
|
|
|
@ -14,6 +14,12 @@ package net.minecraftforge.fml.common.event;
|
|||
|
||||
import net.minecraftforge.fml.common.LoaderState.ModState;
|
||||
|
||||
/**
|
||||
* Called after {@link FMLServerStartingEvent} when the server is available and ready to play.
|
||||
*
|
||||
* @see net.minecraftforge.fml.common.Mod.EventHandler for how to subscribe to this event
|
||||
* @author cpw
|
||||
*/
|
||||
public class FMLServerStartedEvent extends FMLStateEvent
|
||||
{
|
||||
|
||||
|
|
|
@ -17,6 +17,14 @@ import net.minecraft.command.ICommand;
|
|||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraftforge.fml.common.LoaderState.ModState;
|
||||
|
||||
/**
|
||||
* Called after {@link FMLServerAboutToStartEvent} and before {@link FMLServerStartedEvent}.
|
||||
* This event allows for customizations of the server, such as loading custom commands, perhaps customizing recipes or
|
||||
* other activities.
|
||||
*
|
||||
* @see net.minecraftforge.fml.common.Mod.EventHandler for how to subscribe to this event
|
||||
* @author cpw
|
||||
*/
|
||||
public class FMLServerStartingEvent extends FMLStateEvent
|
||||
{
|
||||
|
||||
|
|
|
@ -14,6 +14,14 @@ package net.minecraftforge.fml.common.event;
|
|||
|
||||
import net.minecraftforge.fml.common.LoaderState.ModState;
|
||||
|
||||
/**
|
||||
* Called after {@link FMLServerStoppingEvent} when the server has completely shut down.
|
||||
* Called immediately before shutting down, on the dedicated server, and before returning
|
||||
* to the main menu on the client.
|
||||
*
|
||||
* @see net.minecraftforge.fml.common.Mod.EventHandler for how to subscribe to this event
|
||||
* @author cpw
|
||||
*/
|
||||
public class FMLServerStoppedEvent extends FMLStateEvent {
|
||||
|
||||
public FMLServerStoppedEvent(Object... data)
|
||||
|
|
|
@ -14,6 +14,12 @@ package net.minecraftforge.fml.common.event;
|
|||
|
||||
import net.minecraftforge.fml.common.LoaderState.ModState;
|
||||
|
||||
/**
|
||||
* Called when the server begins an orderly shutdown, before {@link FMLServerStoppedEvent}.
|
||||
*
|
||||
* @see net.minecraftforge.fml.common.Mod.EventHandler for how to subscribe to this event
|
||||
* @author cpw
|
||||
*/
|
||||
public class FMLServerStoppingEvent extends FMLStateEvent
|
||||
{
|
||||
|
||||
|
|
|
@ -16,6 +16,9 @@ import net.minecraftforge.fml.common.FMLCommonHandler;
|
|||
import net.minecraftforge.fml.common.LoaderState.ModState;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
/**
|
||||
* The parent of all mod-state changing events
|
||||
*/
|
||||
public abstract class FMLStateEvent extends FMLEvent
|
||||
{
|
||||
public FMLStateEvent(Object... data)
|
||||
|
@ -23,8 +26,17 @@ public abstract class FMLStateEvent extends FMLEvent
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* The current state of the mod
|
||||
* @return The current state of the mod
|
||||
*/
|
||||
public abstract ModState getModState();
|
||||
|
||||
/**
|
||||
* The side we're loading on. {@link Side#CLIENT} means we're loading in the client, {@link Side#SERVER} means
|
||||
* we're loading in the dedicated server.
|
||||
* @return Return which side we're loading on.
|
||||
*/
|
||||
public Side getSide()
|
||||
{
|
||||
return FMLCommonHandler.instance().getSide();
|
||||
|
|
Loading…
Reference in a new issue