2012-03-30 14:11:13 +00:00
|
|
|
/*
|
2013-03-08 00:25:48 +00:00
|
|
|
* Forge Mod Loader
|
|
|
|
* Copyright (c) 2012-2013 cpw.
|
|
|
|
* All rights reserved. This program and the accompanying materials
|
|
|
|
* are made available under the terms of the GNU Lesser Public License v2.1
|
|
|
|
* which accompanies this distribution, and is available at
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
2013-03-30 16:12:54 +00:00
|
|
|
*
|
2013-03-08 00:25:48 +00:00
|
|
|
* Contributors:
|
|
|
|
* cpw - implementation
|
2012-03-30 14:11:13 +00:00
|
|
|
*/
|
2013-03-08 00:25:48 +00:00
|
|
|
|
2012-04-02 22:09:06 +00:00
|
|
|
package cpw.mods.fml.common;
|
|
|
|
|
2012-05-07 05:39:55 +00:00
|
|
|
import java.util.List;
|
2012-10-03 01:54:47 +00:00
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Set;
|
2012-12-09 04:21:03 +00:00
|
|
|
import net.minecraft.crash.CrashReport;
|
|
|
|
import net.minecraft.crash.CrashReportCategory;
|
2013-12-17 16:24:57 +00:00
|
|
|
import net.minecraft.entity.item.EntityItem;
|
2012-12-09 04:21:03 +00:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2013-12-17 16:24:57 +00:00
|
|
|
import net.minecraft.inventory.IInventory;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2012-12-09 04:21:03 +00:00
|
|
|
import net.minecraft.nbt.NBTBase;
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2013-12-31 14:45:26 +00:00
|
|
|
import net.minecraft.network.INetHandler;
|
2013-12-06 16:17:40 +00:00
|
|
|
import net.minecraft.network.NetworkManager;
|
2013-02-02 15:54:48 +00:00
|
|
|
import net.minecraft.server.MinecraftServer;
|
2012-12-09 04:21:03 +00:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraft.world.storage.SaveHandler;
|
|
|
|
import net.minecraft.world.storage.WorldInfo;
|
2013-12-17 04:18:00 +00:00
|
|
|
import org.apache.logging.log4j.Level;
|
|
|
|
import org.apache.logging.log4j.Logger;
|
2013-03-30 16:12:54 +00:00
|
|
|
import com.google.common.base.Joiner;
|
2012-07-24 01:20:37 +00:00
|
|
|
import com.google.common.base.Strings;
|
|
|
|
import com.google.common.collect.ImmutableList;
|
|
|
|
import com.google.common.collect.ImmutableList.Builder;
|
|
|
|
import com.google.common.collect.Lists;
|
2012-10-03 01:54:47 +00:00
|
|
|
import com.google.common.collect.MapMaker;
|
|
|
|
import com.google.common.collect.Maps;
|
|
|
|
import com.google.common.collect.Sets;
|
2014-02-08 17:18:34 +00:00
|
|
|
import cpw.mods.fml.common.event.FMLMissingMappingsEvent;
|
2013-12-17 04:18:00 +00:00
|
|
|
import cpw.mods.fml.common.eventhandler.EventBus;
|
|
|
|
import cpw.mods.fml.common.gameevent.InputEvent;
|
|
|
|
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
|
|
|
import cpw.mods.fml.common.gameevent.TickEvent;
|
|
|
|
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
2012-12-16 04:21:26 +00:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
2012-08-17 13:16:08 +00:00
|
|
|
import cpw.mods.fml.server.FMLServerHandler;
|
2012-07-22 14:26:38 +00:00
|
|
|
|
2012-05-07 05:39:55 +00:00
|
|
|
|
2012-04-05 20:22:47 +00:00
|
|
|
/**
|
|
|
|
* The main class for non-obfuscated hook handling code
|
2012-06-26 20:24:50 +00:00
|
|
|
*
|
|
|
|
* Anything that doesn't require obfuscated or client/server specific code should
|
2012-04-05 20:22:47 +00:00
|
|
|
* go in this handler
|
2012-06-26 20:24:50 +00:00
|
|
|
*
|
2012-04-05 20:22:47 +00:00
|
|
|
* It also contains a reference to the sided handler instance that is valid
|
|
|
|
* allowing for common code to access specific properties from the obfuscated world
|
|
|
|
* without a direct dependency
|
2012-06-26 20:24:50 +00:00
|
|
|
*
|
2012-04-05 20:22:47 +00:00
|
|
|
* @author cpw
|
|
|
|
*
|
|
|
|
*/
|
2012-04-05 15:34:57 +00:00
|
|
|
public class FMLCommonHandler
|
2012-04-05 14:07:52 +00:00
|
|
|
{
|
2012-04-05 20:22:47 +00:00
|
|
|
/**
|
|
|
|
* The singleton
|
|
|
|
*/
|
2012-04-05 15:34:57 +00:00
|
|
|
private static final FMLCommonHandler INSTANCE = new FMLCommonHandler();
|
2012-04-05 20:22:47 +00:00
|
|
|
/**
|
2012-06-26 20:24:50 +00:00
|
|
|
* The delegate for side specific data and functions
|
2012-04-05 20:22:47 +00:00
|
|
|
*/
|
2012-04-05 15:34:57 +00:00
|
|
|
private IFMLSidedHandler sidedDelegate;
|
2012-06-26 20:24:50 +00:00
|
|
|
|
2012-08-21 22:48:12 +00:00
|
|
|
private Class<?> forge;
|
|
|
|
private boolean noForge;
|
|
|
|
private List<String> brandings;
|
2013-12-06 13:07:09 +00:00
|
|
|
private List<String> brandingsNoMC;
|
2012-08-21 22:48:12 +00:00
|
|
|
private List<ICrashCallable> crashCallables = Lists.newArrayList(Loader.instance().getCallableCrashInformation());
|
2012-10-03 01:54:47 +00:00
|
|
|
private Set<SaveHandler> handlerSet = Sets.newSetFromMap(new MapMaker().weakKeys().<SaveHandler,Boolean>makeMap());
|
2013-12-17 04:18:00 +00:00
|
|
|
private EventBus eventBus = new EventBus();
|
|
|
|
/**
|
|
|
|
* The FML event bus. Subscribe here for FML related events
|
|
|
|
*
|
|
|
|
* @return the event bus
|
|
|
|
*/
|
|
|
|
public EventBus bus()
|
|
|
|
{
|
|
|
|
return eventBus;
|
|
|
|
}
|
2012-06-29 03:37:30 +00:00
|
|
|
|
2012-06-07 23:25:49 +00:00
|
|
|
public void beginLoading(IFMLSidedHandler handler)
|
2012-04-05 16:36:54 +00:00
|
|
|
{
|
|
|
|
sidedDelegate = handler;
|
2013-01-30 23:57:21 +00:00
|
|
|
FMLLog.log("MinecraftForge", Level.INFO, "Attempting early MinecraftForge initialization");
|
2012-06-07 23:25:49 +00:00
|
|
|
callForgeMethod("initialize");
|
2012-08-21 22:48:12 +00:00
|
|
|
callForgeMethod("registerCrashCallable");
|
2013-01-30 23:57:21 +00:00
|
|
|
FMLLog.log("MinecraftForge", Level.INFO, "Completed early MinecraftForge initialization");
|
2012-04-05 15:34:57 +00:00
|
|
|
}
|
2012-04-05 16:36:54 +00:00
|
|
|
|
2012-04-05 14:07:52 +00:00
|
|
|
/**
|
|
|
|
* @return the instance
|
|
|
|
*/
|
2012-04-05 15:34:57 +00:00
|
|
|
public static FMLCommonHandler instance()
|
2012-04-05 14:07:52 +00:00
|
|
|
{
|
|
|
|
return INSTANCE;
|
2012-03-30 14:11:13 +00:00
|
|
|
}
|
2012-06-26 20:24:50 +00:00
|
|
|
/**
|
|
|
|
* Find the container that associates with the supplied mod object
|
|
|
|
* @param mod
|
|
|
|
*/
|
|
|
|
public ModContainer findContainerFor(Object mod)
|
|
|
|
{
|
2014-01-01 00:55:41 +00:00
|
|
|
if (mod instanceof String)
|
|
|
|
{
|
|
|
|
return Loader.instance().getIndexedModList().get(mod);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return Loader.instance().getReversedModObjectList().get(mod);
|
|
|
|
}
|
2012-06-26 20:24:50 +00:00
|
|
|
}
|
2012-04-05 20:22:47 +00:00
|
|
|
/**
|
|
|
|
* Get the forge mod loader logging instance (goes to the forgemodloader log file)
|
2012-10-25 20:18:42 +00:00
|
|
|
* @return The log instance for the FML log file
|
2012-04-05 20:22:47 +00:00
|
|
|
*/
|
2012-04-05 16:36:54 +00:00
|
|
|
public Logger getFMLLogger()
|
|
|
|
{
|
2012-07-30 02:54:59 +00:00
|
|
|
return FMLLog.getLogger();
|
2012-04-05 15:34:57 +00:00
|
|
|
}
|
2012-04-05 16:36:54 +00:00
|
|
|
|
2012-06-02 19:13:55 +00:00
|
|
|
public Side getSide()
|
2012-05-07 04:54:18 +00:00
|
|
|
{
|
2012-06-02 19:13:55 +00:00
|
|
|
return sidedDelegate.getSide();
|
2012-05-07 04:54:18 +00:00
|
|
|
}
|
2012-06-26 20:24:50 +00:00
|
|
|
|
2012-08-21 23:15:07 +00:00
|
|
|
/**
|
|
|
|
* Return the effective side for the context in the game. This is dependent
|
2012-08-22 13:43:32 +00:00
|
|
|
* on thread analysis to try and determine whether the code is running in the
|
2012-08-21 23:15:07 +00:00
|
|
|
* server or not. Use at your own risk
|
|
|
|
*/
|
|
|
|
public Side getEffectiveSide()
|
|
|
|
{
|
|
|
|
Thread thr = Thread.currentThread();
|
2013-12-03 04:46:42 +00:00
|
|
|
if ((thr.getName().equals("Server thread")))
|
2012-10-20 16:31:35 +00:00
|
|
|
{
|
|
|
|
return Side.SERVER;
|
|
|
|
}
|
2012-08-22 13:43:32 +00:00
|
|
|
|
2012-08-21 23:15:07 +00:00
|
|
|
return Side.CLIENT;
|
|
|
|
}
|
2012-05-10 22:54:25 +00:00
|
|
|
/**
|
|
|
|
* Raise an exception
|
|
|
|
*/
|
|
|
|
public void raiseException(Throwable exception, String message, boolean stopGame)
|
2012-05-07 05:39:55 +00:00
|
|
|
{
|
2013-12-16 16:47:48 +00:00
|
|
|
FMLLog.log(Level.ERROR, exception, "Something raised an exception. The message was '%s'. 'stopGame' is %b", message, stopGame);
|
2012-07-04 02:39:35 +00:00
|
|
|
if (stopGame)
|
|
|
|
{
|
|
|
|
getSidedDelegate().haltGame(message,exception);
|
|
|
|
}
|
2012-05-07 05:39:55 +00:00
|
|
|
}
|
2012-05-10 22:54:25 +00:00
|
|
|
|
2012-06-26 20:24:50 +00:00
|
|
|
|
2012-06-07 23:25:49 +00:00
|
|
|
private Class<?> findMinecraftForge()
|
|
|
|
{
|
|
|
|
if (forge==null && !noForge)
|
|
|
|
{
|
|
|
|
try {
|
2012-08-06 21:27:21 +00:00
|
|
|
forge = Class.forName("net.minecraftforge.common.MinecraftForge");
|
2012-06-07 23:25:49 +00:00
|
|
|
} catch (Exception ex) {
|
2012-08-06 21:27:21 +00:00
|
|
|
noForge = true;
|
2012-06-07 23:25:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return forge;
|
|
|
|
}
|
2012-06-26 20:24:50 +00:00
|
|
|
|
2012-06-07 23:25:49 +00:00
|
|
|
private Object callForgeMethod(String method)
|
|
|
|
{
|
|
|
|
if (noForge)
|
|
|
|
return null;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
return findMinecraftForge().getMethod(method).invoke(null);
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
// No Forge installation
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
2012-09-16 01:04:56 +00:00
|
|
|
|
2012-07-24 01:20:37 +00:00
|
|
|
public void computeBranding()
|
2012-05-11 05:45:36 +00:00
|
|
|
{
|
2012-07-24 01:20:37 +00:00
|
|
|
if (brandings == null)
|
2012-06-07 23:25:49 +00:00
|
|
|
{
|
2013-11-10 16:49:06 +00:00
|
|
|
Builder<String> brd = ImmutableList.<String>builder();
|
2012-07-31 02:31:07 +00:00
|
|
|
brd.add(Loader.instance().getMCVersionString());
|
2012-10-25 13:02:49 +00:00
|
|
|
brd.add(Loader.instance().getMCPVersionString());
|
2012-09-07 23:08:28 +00:00
|
|
|
brd.add("FML v"+Loader.instance().getFMLVersionString());
|
2012-08-16 17:01:48 +00:00
|
|
|
String forgeBranding = (String) callForgeMethod("getBrandingVersion");
|
2012-08-16 16:22:56 +00:00
|
|
|
if (!Strings.isNullOrEmpty(forgeBranding))
|
|
|
|
{
|
|
|
|
brd.add(forgeBranding);
|
|
|
|
}
|
2012-10-29 21:41:08 +00:00
|
|
|
if (sidedDelegate!=null)
|
|
|
|
{
|
|
|
|
brd.addAll(sidedDelegate.getAdditionalBrandingInformation());
|
|
|
|
}
|
2013-03-30 16:12:54 +00:00
|
|
|
if (Loader.instance().getFMLBrandingProperties().containsKey("fmlbranding"))
|
|
|
|
{
|
|
|
|
brd.add(Loader.instance().getFMLBrandingProperties().get("fmlbranding"));
|
2012-07-24 01:20:37 +00:00
|
|
|
}
|
|
|
|
int tModCount = Loader.instance().getModList().size();
|
|
|
|
int aModCount = Loader.instance().getActiveModList().size();
|
|
|
|
brd.add(String.format("%d mod%s loaded, %d mod%s active", tModCount, tModCount!=1 ? "s" :"", aModCount, aModCount!=1 ? "s" :"" ));
|
|
|
|
brandings = brd.build();
|
2013-12-06 13:07:09 +00:00
|
|
|
brandingsNoMC = brandings.subList(1, brandings.size());
|
2012-05-11 05:45:36 +00:00
|
|
|
}
|
2012-07-24 01:20:37 +00:00
|
|
|
}
|
2013-12-06 13:07:09 +00:00
|
|
|
public List<String> getBrandings(boolean includeMC)
|
2012-07-24 01:20:37 +00:00
|
|
|
{
|
|
|
|
if (brandings == null)
|
|
|
|
{
|
|
|
|
computeBranding();
|
2012-05-11 05:45:36 +00:00
|
|
|
}
|
2013-12-06 13:07:09 +00:00
|
|
|
return includeMC ? ImmutableList.copyOf(brandings) : ImmutableList.copyOf(brandingsNoMC);
|
2012-05-11 05:45:36 +00:00
|
|
|
}
|
|
|
|
|
2012-06-01 02:09:45 +00:00
|
|
|
public IFMLSidedHandler getSidedDelegate()
|
|
|
|
{
|
|
|
|
return sidedDelegate;
|
|
|
|
}
|
|
|
|
|
2012-07-06 14:29:17 +00:00
|
|
|
public void onPostServerTick()
|
|
|
|
{
|
2013-12-17 04:18:00 +00:00
|
|
|
bus().post(new TickEvent.ServerTickEvent(Phase.END));
|
2012-07-06 14:29:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Every tick just after world and other ticks occur
|
|
|
|
*/
|
2013-12-17 04:18:00 +00:00
|
|
|
public void onPostWorldTick(World world)
|
2012-07-06 14:29:17 +00:00
|
|
|
{
|
2013-12-17 04:18:00 +00:00
|
|
|
bus().post(new TickEvent.WorldTickEvent(Side.SERVER, Phase.END, world));
|
2012-07-06 14:29:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void onPreServerTick()
|
|
|
|
{
|
2013-12-17 04:18:00 +00:00
|
|
|
bus().post(new TickEvent.ServerTickEvent(Phase.START));
|
2012-07-06 14:29:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Every tick just before world and other ticks occur
|
|
|
|
*/
|
2013-12-17 04:18:00 +00:00
|
|
|
public void onPreWorldTick(World world)
|
2012-07-06 14:29:17 +00:00
|
|
|
{
|
2013-12-17 04:18:00 +00:00
|
|
|
bus().post(new TickEvent.WorldTickEvent(Side.SERVER, Phase.START, world));
|
2012-07-06 02:31:46 +00:00
|
|
|
}
|
2012-08-06 13:52:42 +00:00
|
|
|
|
2013-01-22 14:11:44 +00:00
|
|
|
public boolean handleServerAboutToStart(MinecraftServer server)
|
2012-08-02 04:38:30 +00:00
|
|
|
{
|
2013-01-22 14:11:44 +00:00
|
|
|
return Loader.instance().serverAboutToStart(server);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean handleServerStarting(MinecraftServer server)
|
|
|
|
{
|
2014-02-09 03:37:40 +00:00
|
|
|
sidedDelegate.serverLoadedSuccessfully();
|
2013-01-22 14:11:44 +00:00
|
|
|
return Loader.instance().serverStarting(server);
|
2012-08-02 04:38:30 +00:00
|
|
|
}
|
2012-08-06 13:52:42 +00:00
|
|
|
|
2012-08-02 04:38:30 +00:00
|
|
|
public void handleServerStarted()
|
|
|
|
{
|
|
|
|
Loader.instance().serverStarted();
|
|
|
|
}
|
2012-08-06 13:52:42 +00:00
|
|
|
|
2012-08-02 04:38:30 +00:00
|
|
|
public void handleServerStopping()
|
|
|
|
{
|
|
|
|
Loader.instance().serverStopping();
|
|
|
|
}
|
2012-08-02 19:20:30 +00:00
|
|
|
|
|
|
|
public MinecraftServer getMinecraftServerInstance()
|
|
|
|
{
|
2012-08-11 15:01:18 +00:00
|
|
|
return sidedDelegate.getServer();
|
2012-08-02 19:20:30 +00:00
|
|
|
}
|
2012-08-08 04:31:24 +00:00
|
|
|
|
|
|
|
public void showGuiScreen(Object clientGuiElement)
|
|
|
|
{
|
|
|
|
sidedDelegate.showGuiScreen(clientGuiElement);
|
|
|
|
}
|
2012-08-09 05:58:14 +00:00
|
|
|
|
2013-12-03 04:46:42 +00:00
|
|
|
public void onServerStart(MinecraftServer dedicatedServer)
|
2012-08-09 13:21:16 +00:00
|
|
|
{
|
2012-08-17 13:16:08 +00:00
|
|
|
FMLServerHandler.instance();
|
2012-08-09 13:21:16 +00:00
|
|
|
sidedDelegate.beginServerLoading(dedicatedServer);
|
|
|
|
}
|
2012-08-10 20:37:06 +00:00
|
|
|
|
2012-08-09 13:21:16 +00:00
|
|
|
public void onServerStarted()
|
|
|
|
{
|
|
|
|
sidedDelegate.finishServerLoading();
|
|
|
|
}
|
2012-08-10 20:37:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
public void onPreClientTick()
|
|
|
|
{
|
2013-12-17 04:18:00 +00:00
|
|
|
bus().post(new TickEvent.ClientTickEvent(Phase.START));
|
2012-08-10 20:37:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void onPostClientTick()
|
|
|
|
{
|
2013-12-17 04:18:00 +00:00
|
|
|
bus().post(new TickEvent.ClientTickEvent(Phase.END));
|
2012-08-10 20:37:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void onRenderTickStart(float timer)
|
|
|
|
{
|
2013-12-17 04:18:00 +00:00
|
|
|
bus().post(new TickEvent.RenderTickEvent(Phase.START, timer));
|
2012-08-10 20:37:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void onRenderTickEnd(float timer)
|
|
|
|
{
|
2013-12-17 04:18:00 +00:00
|
|
|
bus().post(new TickEvent.RenderTickEvent(Phase.END, timer));
|
2012-08-10 20:37:06 +00:00
|
|
|
}
|
2012-08-10 21:11:01 +00:00
|
|
|
|
|
|
|
public void onPlayerPreTick(EntityPlayer player)
|
|
|
|
{
|
2013-12-17 04:18:00 +00:00
|
|
|
bus().post(new TickEvent.PlayerTickEvent(Phase.START, player));
|
2012-08-10 21:11:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void onPlayerPostTick(EntityPlayer player)
|
|
|
|
{
|
2013-12-18 13:34:20 +00:00
|
|
|
bus().post(new TickEvent.PlayerTickEvent(Phase.END, player));
|
2012-08-10 21:11:01 +00:00
|
|
|
}
|
2012-08-21 22:48:12 +00:00
|
|
|
|
|
|
|
public void registerCrashCallable(ICrashCallable callable)
|
|
|
|
{
|
|
|
|
crashCallables.add(callable);
|
|
|
|
}
|
2012-08-22 13:43:32 +00:00
|
|
|
|
2012-11-02 03:53:13 +00:00
|
|
|
public void enhanceCrashReport(CrashReport crashReport, CrashReportCategory category)
|
2012-08-21 22:48:12 +00:00
|
|
|
{
|
|
|
|
for (ICrashCallable call: crashCallables)
|
|
|
|
{
|
2012-11-02 03:53:13 +00:00
|
|
|
category.func_71500_a(call.getLabel(), call);
|
2012-08-21 22:48:12 +00:00
|
|
|
}
|
|
|
|
}
|
2012-09-06 14:03:30 +00:00
|
|
|
|
2012-10-03 01:54:47 +00:00
|
|
|
public void handleWorldDataSave(SaveHandler handler, WorldInfo worldInfo, NBTTagCompound tagCompound)
|
|
|
|
{
|
|
|
|
for (ModContainer mc : Loader.instance().getModList())
|
|
|
|
{
|
|
|
|
if (mc instanceof InjectedModContainer)
|
|
|
|
{
|
|
|
|
WorldAccessContainer wac = ((InjectedModContainer)mc).getWrappedWorldAccessContainer();
|
|
|
|
if (wac != null)
|
|
|
|
{
|
|
|
|
NBTTagCompound dataForWriting = wac.getDataForWriting(handler, worldInfo);
|
2013-12-03 04:46:42 +00:00
|
|
|
tagCompound.func_74782_a(mc.getModId(), dataForWriting);
|
2012-10-03 01:54:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void handleWorldDataLoad(SaveHandler handler, WorldInfo worldInfo, NBTTagCompound tagCompound)
|
|
|
|
{
|
|
|
|
if (getEffectiveSide()!=Side.SERVER)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (handlerSet.contains(handler))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
handlerSet.add(handler);
|
|
|
|
Map<String,NBTBase> additionalProperties = Maps.newHashMap();
|
2014-01-19 03:25:35 +00:00
|
|
|
worldInfo.setAdditionalProperties(additionalProperties);
|
2012-10-03 01:54:47 +00:00
|
|
|
for (ModContainer mc : Loader.instance().getModList())
|
|
|
|
{
|
|
|
|
if (mc instanceof InjectedModContainer)
|
|
|
|
{
|
|
|
|
WorldAccessContainer wac = ((InjectedModContainer)mc).getWrappedWorldAccessContainer();
|
|
|
|
if (wac != null)
|
|
|
|
{
|
2014-02-09 03:37:40 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
wac.readData(handler, worldInfo, additionalProperties, tagCompound.func_74775_l(mc.getModId()));
|
|
|
|
}
|
|
|
|
catch (RuntimeException ex)
|
|
|
|
{
|
|
|
|
sidedDelegate.failedServerLoading(ex, wac);
|
|
|
|
throw ex;
|
|
|
|
}
|
2012-10-03 01:54:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-12-07 06:52:16 +00:00
|
|
|
|
|
|
|
public boolean shouldServerBeKilledQuietly()
|
|
|
|
{
|
2013-01-27 20:54:36 +00:00
|
|
|
if (sidedDelegate == null)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2012-12-07 06:52:16 +00:00
|
|
|
return sidedDelegate.shouldServerShouldBeKilledQuietly();
|
|
|
|
}
|
|
|
|
|
2012-12-31 04:52:38 +00:00
|
|
|
public void handleServerStopped()
|
|
|
|
{
|
2013-09-20 21:02:56 +00:00
|
|
|
sidedDelegate.serverStopped();
|
2013-06-11 18:41:19 +00:00
|
|
|
MinecraftServer server = getMinecraftServerInstance();
|
2012-12-31 04:52:38 +00:00
|
|
|
Loader.instance().serverStopped();
|
2013-06-11 18:41:19 +00:00
|
|
|
// FORCE the internal server to stop: hello optifine workaround!
|
2013-09-20 21:02:56 +00:00
|
|
|
if (server!=null) ObfuscationReflectionHelper.setPrivateValue(MinecraftServer.class, server, false, "field_71316"+"_v", "u", "serverStopped");
|
2012-12-31 04:52:38 +00:00
|
|
|
}
|
2013-03-30 16:12:54 +00:00
|
|
|
|
|
|
|
public String getModName()
|
|
|
|
{
|
|
|
|
List<String> modNames = Lists.newArrayListWithExpectedSize(3);
|
|
|
|
modNames.add("fml");
|
|
|
|
if (!noForge)
|
|
|
|
{
|
|
|
|
modNames.add("forge");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Loader.instance().getFMLBrandingProperties().containsKey("snooperbranding"))
|
|
|
|
{
|
|
|
|
modNames.add(Loader.instance().getFMLBrandingProperties().get("snooperbranding"));
|
|
|
|
}
|
|
|
|
return Joiner.on(',').join(modNames);
|
|
|
|
}
|
2013-07-02 05:39:40 +00:00
|
|
|
|
|
|
|
public void addModToResourcePack(ModContainer container)
|
|
|
|
{
|
|
|
|
sidedDelegate.addModAsResource(container);
|
|
|
|
}
|
2013-07-10 04:42:40 +00:00
|
|
|
|
|
|
|
public void updateResourcePackList()
|
|
|
|
{
|
|
|
|
sidedDelegate.updateResourcePackList();
|
|
|
|
}
|
2013-09-14 00:04:25 +00:00
|
|
|
|
|
|
|
public String getCurrentLanguage()
|
|
|
|
{
|
2013-09-20 21:02:56 +00:00
|
|
|
|
2013-09-14 00:04:25 +00:00
|
|
|
return sidedDelegate.getCurrentLanguage();
|
|
|
|
}
|
2013-12-03 04:46:42 +00:00
|
|
|
|
|
|
|
public void bootstrap()
|
|
|
|
{
|
|
|
|
}
|
2013-12-06 16:17:40 +00:00
|
|
|
|
|
|
|
public NetworkManager getClientToServerNetworkManager()
|
|
|
|
{
|
|
|
|
return sidedDelegate.getClientToServerNetworkManager();
|
|
|
|
}
|
2013-12-17 04:18:00 +00:00
|
|
|
|
|
|
|
public void fireMouseInput()
|
|
|
|
{
|
|
|
|
bus().post(new InputEvent.MouseInputEvent());
|
|
|
|
}
|
|
|
|
|
|
|
|
public void fireKeyInput()
|
|
|
|
{
|
|
|
|
bus().post(new InputEvent.KeyInputEvent());
|
|
|
|
}
|
|
|
|
|
|
|
|
public void firePlayerChangedDimensionEvent(EntityPlayer player, int fromDim, int toDim)
|
|
|
|
{
|
|
|
|
bus().post(new PlayerEvent.PlayerChangedDimensionEvent(player, fromDim, toDim));
|
|
|
|
}
|
|
|
|
|
|
|
|
public void firePlayerLoggedIn(EntityPlayer player)
|
|
|
|
{
|
|
|
|
bus().post(new PlayerEvent.PlayerLoggedInEvent(player));
|
|
|
|
}
|
|
|
|
|
|
|
|
public void firePlayerLoggedOut(EntityPlayer player)
|
|
|
|
{
|
|
|
|
bus().post(new PlayerEvent.PlayerLoggedOutEvent(player));
|
|
|
|
}
|
|
|
|
|
|
|
|
public void firePlayerRespawnEvent(EntityPlayer player)
|
|
|
|
{
|
|
|
|
bus().post(new PlayerEvent.PlayerRespawnEvent(player));
|
|
|
|
}
|
2013-12-17 16:24:57 +00:00
|
|
|
|
|
|
|
public void firePlayerItemPickupEvent(EntityPlayer player, EntityItem item)
|
|
|
|
{
|
|
|
|
bus().post(new PlayerEvent.ItemPickupEvent(player, item));
|
|
|
|
}
|
|
|
|
|
|
|
|
public void firePlayerCraftingEvent(EntityPlayer player, ItemStack crafted, IInventory craftMatrix)
|
|
|
|
{
|
|
|
|
bus().post(new PlayerEvent.ItemCraftedEvent(player, crafted, craftMatrix));
|
|
|
|
}
|
|
|
|
|
|
|
|
public void firePlayerSmeltedEvent(EntityPlayer player, ItemStack smelted)
|
|
|
|
{
|
|
|
|
bus().post(new PlayerEvent.ItemSmeltedEvent(player, smelted));
|
|
|
|
}
|
2013-12-31 14:45:26 +00:00
|
|
|
|
|
|
|
public INetHandler getClientPlayHandler()
|
|
|
|
{
|
|
|
|
return sidedDelegate.getClientPlayHandler();
|
|
|
|
}
|
2014-01-16 19:58:28 +00:00
|
|
|
|
|
|
|
public void waitForPlayClient()
|
|
|
|
{
|
|
|
|
sidedDelegate.waitForPlayClient();
|
|
|
|
}
|
2014-01-17 00:45:42 +00:00
|
|
|
|
|
|
|
public void fireNetRegistrationEvent(NetworkManager manager, Set<String> channelSet, String channel, Side side)
|
|
|
|
{
|
|
|
|
sidedDelegate.fireNetRegistrationEvent(bus(), manager, channelSet, channel, side);
|
|
|
|
}
|
2014-02-08 17:18:34 +00:00
|
|
|
|
|
|
|
public FMLMissingMappingsEvent.Action getDefaultMissingAction()
|
|
|
|
{
|
|
|
|
return sidedDelegate.getDefaultMissingAction();
|
|
|
|
}
|
2014-03-11 07:50:55 +00:00
|
|
|
|
|
|
|
public boolean shouldAllowPlayerLogins()
|
|
|
|
{
|
|
|
|
return sidedDelegate.shouldAllowPlayerLogins();
|
|
|
|
}
|
2012-03-30 14:11:13 +00:00
|
|
|
}
|