Merge branch 'master' into minecraft1.3

Bring some of the ticking fixes in

Conflicts:
	client/cpw/mods/fml/client/FMLClientHandler.java
	patches/minecraft_server/net/minecraft/server/MinecraftServer.java.patch
This commit is contained in:
Christian committed 2012-07-05 15:30:21 -04:00
commit 5eafb71083
11 files changed
+183 -87

No files matched your search

@@ -88,13 +88,13 @@ import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.ModMetadata;
import cpw.mods.fml.common.ProxyInjector;
import cpw.mods.fml.common.ReflectionHelper;
import cpw.mods.fml.common.Side;
import cpw.mods.fml.common.TickType;
import cpw.mods.fml.common.modloader.ModLoaderHelper;
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
import cpw.mods.fml.common.modloader.ModProperty;
import cpw.mods.fml.common.registry.FMLRegistry;
import cpw.mods.fml.common.ReflectionHelper;
/**
@@ -160,6 +160,8 @@ public class FMLClientHandler implements IFMLSidedHandler
private OptifineModContainer optifineContainer;
private boolean guiLoaded;
public void onPreLoad(Minecraft minecraft)
{
client = minecraft;
@@ -190,9 +192,22 @@ public class FMLClientHandler implements IFMLSidedHandler
}
FMLCommonHandler.instance().getFMLLogger().info(String.format("Forge Mod Loader has detected optifine %s, enabling compatibility features",optifineContainer.getVersion()));
}
try
{
Loader.instance().loadMods();
}
catch (LoaderException le)
{
haltGame("There was a severe problem during mod loading that has caused the game to fail", le);
return;
}
}
@Override
public void haltGame(String message, Throwable t)
{
client.func_28003_b(new UnexpectedThrowable(message, t));
}
/**
* Called a bit later on during initialization to finish loading mods
* Also initializes key bindings
@@ -200,7 +215,15 @@ public class FMLClientHandler implements IFMLSidedHandler
*/
public void onLoadComplete()
{
try
{
Loader.instance().initializeMods();
}
catch (LoaderException le)
{
haltGame("There was a severe problem during mod loading that has caused the game to fail", le);
return;
}
for (ModContainer mod : Loader.getModList()) {
mod.gatherRenderers(RenderManager.field_1233_a.getRendererList());
for (Render r : RenderManager.field_1233_a.getRendererList().values()) {
@@ -280,6 +303,12 @@ public class FMLClientHandler implements IFMLSidedHandler
public void onRenderTickEnd(float partialTickTime)
{
if (!guiLoaded)
{
FMLCommonHandler.instance().rescheduleTicks();
FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.GUILOAD), partialTickTime, client.field_6313_p);
guiLoaded = true;
}
FMLCommonHandler.instance().tickEnd(EnumSet.of(TickType.RENDER,TickType.GUI), partialTickTime, client.field_6313_p);
}
/**
@@ -918,6 +947,15 @@ public class FMLClientHandler implements IFMLSidedHandler
Profiler.func_40662_b();
}
/**
*
*/
public void preGameLoad(String user, String sessionToken)
{
// Currently this does nothing, but it's possible I could relaunch Minecraft in a new classloader if I wished
Minecraft.fmlReentry(user, sessionToken);
}
public void onTexturePackChange(RenderEngine engine, TexturePackBase texturepack, List<TextureFX> effects)
{
FMLClientHandler.instance().pruneOldTextureFX(texturepack, effects);
+9 -2
View File
@@ -46,8 +46,15 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
// World and render ticks
if (tickEnd && ( tick==TickType.RENDER || tick==TickType.GAME ) && hasWorld) {
return onTickInGame((Float) data[0], mc);
} else if (tickEnd && (tick==TickType.WORLDGUI || tick==TickType.GUI) && data[1]!=null) {
return onTickInGUI((Float) data[0], mc, (GuiScreen)data[1]);
}
return true;
}
public final boolean doTickInGUI(TickType tick, boolean tickEnd, Object minecraftInstance, Object... data)
{
Minecraft mc = (Minecraft) minecraftInstance;
if (tickEnd && ( tick==TickType.RENDER || tick==TickType.GAME ) || tick == TickType.GUILOAD) {
return onTickInGUI((Float) data[0], mc, mc.field_6313_p);
}
return true;
}
@@ -481,7 +481,10 @@ public class FMLCommonHandler
public void raiseException(Throwable exception, String message, boolean stopGame)
{
FMLCommonHandler.instance().getFMLLogger().throwing("FMLHandler", "raiseException", exception);
throw new RuntimeException(exception);
if (stopGame)
{
getSidedDelegate().haltGame(message,exception);
}
}
@@ -27,4 +27,5 @@ public interface IFMLSidedHandler
List<String> getAdditionalBrandingInformation();
Side getSide();
ProxyInjector findSidedProxyOn(BaseMod mod);
void haltGame(String message, Throwable exception);
}
+9 -1
View File
@@ -234,7 +234,15 @@ public class Loader
if (mod.wantsPreInit())
{
log.finer(String.format("Pre-initializing %s", mod.getSource()));
mod.preInit();
try
{
mod.preInit();
}
catch (Throwable t)
{
log.log(Level.SEVERE, String.format("The mod from file %s has failed to load. This is likely a mod installation error.", mod.getSource().getName()), t);
throw new LoaderException(t);
}
namedMods.put(mod.getName(), mod);
}
mod.nextState();
@@ -26,9 +26,9 @@ import cpw.mods.fml.common.IWorldGenerator;
import cpw.mods.fml.common.TickType;
/**
*
*
* Marker interface for BaseMod
*
*
* @author cpw
*
*/
@@ -36,12 +36,12 @@ public interface BaseMod extends IWorldGenerator, IPickupNotifier, IDispenseHand
{
/**
*
*
*/
void modsLoaded();
/**
*
*
*/
void load();
@@ -54,6 +54,7 @@ public interface BaseMod extends IWorldGenerator, IPickupNotifier, IDispenseHand
*/
boolean doTickInGame(TickType tick, boolean b, Object minecraftInstance, Object... data);
boolean doTickInGUI(TickType tick, boolean b, Object minecraftInstance, Object... data);
/**
* @return
*/
@@ -77,7 +78,7 @@ public interface BaseMod extends IWorldGenerator, IPickupNotifier, IDispenseHand
void onRenderHarvest(Map renderers);
/**
*
*
*/
void onRegisterAnimations();
@@ -30,25 +30,28 @@ public class BaseModTicker implements ITickHandler
private BaseMod mod;
private EnumSet<TickType> ticks;
private boolean clockTickTrigger;
BaseModTicker(BaseMod mod)
private boolean sendGuiTicks;
BaseModTicker(BaseMod mod, boolean guiTicker)
{
this.mod = mod;
this.ticks = EnumSet.of(TickType.WORLDLOAD);
this.sendGuiTicks = guiTicker;
}
BaseModTicker(EnumSet<TickType> ticks)
BaseModTicker(EnumSet<TickType> ticks, boolean guiTicker)
{
this.ticks = ticks;
this.sendGuiTicks = guiTicker;
}
@Override
public void tickStart(EnumSet<TickType> types, Object... tickData)
{
tickBaseMod(types, false, tickData);
}
@Override
public void tickEnd(EnumSet<TickType> types, Object... tickData)
{
@@ -57,25 +60,23 @@ public class BaseModTicker implements ITickHandler
private void tickBaseMod(EnumSet<TickType> types, boolean end, Object... tickData)
{
if (FMLCommonHandler.instance().getSide().isClient() && ( ticks.contains(TickType.GAME) || ticks.contains(TickType.WORLDGUI)))
if (FMLCommonHandler.instance().getSide().isClient() && ( ticks.contains(TickType.GAME) || ticks.contains(TickType.WORLDLOAD)) || ticks.contains(TickType.RENDER))
{
EnumSet cTypes=EnumSet.copyOf(types);
if (end && ( types.contains(TickType.GAME) || types.contains(TickType.WORLDLOAD) || types.contains(TickType.WORLDGUI)))
if ( ( end && types.contains(TickType.GAME)) || types.contains(TickType.WORLDLOAD))
{
clockTickTrigger = true;
cTypes.remove(TickType.GAME);
cTypes.remove(TickType.WORLDLOAD);
cTypes.remove(TickType.WORLDGUI);
}
if (end && clockTickTrigger && types.contains(TickType.RENDER))
{
clockTickTrigger = false;
cTypes.remove(TickType.RENDER);
if (ticks.contains(TickType.GAME)) cTypes.add(TickType.GAME);
if (ticks.contains(TickType.WORLDGUI)) cTypes.add(TickType.WORLDGUI);
cTypes.add(TickType.GAME);
}
sendTick(cTypes, end, tickData);
}
else
@@ -83,7 +84,7 @@ public class BaseModTicker implements ITickHandler
sendTick(types, end, tickData);
}
}
private void sendTick(EnumSet<TickType> types, boolean end, Object... tickData)
{
for (TickType type : types)
@@ -92,7 +93,16 @@ public class BaseModTicker implements ITickHandler
{
continue;
}
boolean keepTicking=mod.doTickInGame(type, end, FMLCommonHandler.instance().getMinecraftInstance(), tickData);
boolean keepTicking=true;
if (sendGuiTicks)
{
keepTicking = mod.doTickInGUI(type, end, FMLCommonHandler.instance().getMinecraftInstance(), tickData);
}
else
{
keepTicking = mod.doTickInGame(type, end, FMLCommonHandler.instance().getMinecraftInstance(), tickData);
}
if (!keepTicking) {
ticks.remove(type);
ticks.removeAll(type.partnerTicks());
@@ -119,5 +129,4 @@ public class BaseModTicker implements ITickHandler
{
this.mod = mod;
}
}
@@ -32,7 +32,7 @@ public class ModLoaderHelper
public static void updateStandardTicks(BaseMod mod, boolean enable, boolean useClock)
{
ModLoaderModContainer mlmc = findOrBuildModContainer(mod);
BaseModTicker ticker = mlmc.getTickHandler();
BaseModTicker ticker = mlmc.getGameTickHandler();
EnumSet<TickType> ticks = ticker.ticks();
// If we're enabled we get render ticks
if (enable && !useClock) {
@@ -43,26 +43,33 @@ public class ModLoaderHelper
// If we're enabled but we want clock ticks, or we're server side we get game ticks
if (enable && (useClock || FMLCommonHandler.instance().getSide().isServer())) {
ticks.add(TickType.GAME);
ticks.add(TickType.WORLDLOAD);
} else {
ticks.remove(TickType.GAME);
ticks.remove(TickType.WORLDLOAD);
}
}
public static void updateGUITicks(BaseMod mod, boolean enable, boolean useClock)
{
ModLoaderModContainer mlmc = findOrBuildModContainer(mod);
EnumSet<TickType> ticks = mlmc.getTickHandler().ticks();
EnumSet<TickType> ticks = mlmc.getGUITickHandler().ticks();
// If we're enabled and we don't want clock ticks we get render ticks
if (enable && !useClock) {
ticks.add(TickType.GUI);
ticks.add(TickType.RENDER);
ticks.add(TickType.GUILOAD);
} else {
ticks.remove(TickType.GUI);
ticks.remove(TickType.RENDER);
}
// If we're enabled but we want clock ticks, or we're server side we get world ticks
if (enable && (useClock || FMLCommonHandler.instance().getSide().isServer())) {
ticks.add(TickType.WORLDGUI);
if (enable && useClock) {
ticks.add(TickType.GAME);
ticks.add(TickType.GUILOAD);
ticks.add(TickType.WORLDLOAD);
} else {
ticks.remove(TickType.WORLDGUI);
ticks.remove(TickType.GAME);
ticks.remove(TickType.GUILOAD);
ticks.remove(TickType.WORLDLOAD);
}
}
@@ -64,7 +64,8 @@ public class ModLoaderModContainer implements ModContainer
private SourceType sourceType;
private ModMetadata metadata;
private ProxyInjector sidedProxy;
private BaseModTicker tickHandler;
private BaseModTicker gameTickHandler;
private BaseModTicker guiTickHandler;
public ModLoaderModContainer(Class <? extends BaseMod > modClazz, File modSource)
{
@@ -81,7 +82,8 @@ public class ModLoaderModContainer implements ModContainer
ModLoaderModContainer(BaseMod instance) {
FMLCommonHandler.instance().addAuxilliaryModContainer(this);
this.mod=instance;
this.tickHandler = new BaseModTicker(instance);
this.gameTickHandler = new BaseModTicker(instance, false);
this.guiTickHandler = new BaseModTicker(instance, true);
}
@Override
@@ -102,11 +104,14 @@ public class ModLoaderModContainer implements ModContainer
try
{
EnumSet<TickType> ticks = EnumSet.noneOf(TickType.class);
this.tickHandler = new BaseModTicker(ticks);
this.gameTickHandler = new BaseModTicker(ticks, false);
this.guiTickHandler = new BaseModTicker(ticks.clone(), true);
configureMod();
mod = modClazz.newInstance();
this.tickHandler.setMod(mod);
FMLCommonHandler.instance().registerTickHandler(this.tickHandler);
this.gameTickHandler.setMod(mod);
this.guiTickHandler.setMod(mod);
FMLCommonHandler.instance().registerTickHandler(this.gameTickHandler);
FMLCommonHandler.instance().registerTickHandler(this.guiTickHandler);
FMLCommonHandler.instance().registerWorldGenerator(this.mod);
}
catch (Exception e)
@@ -707,8 +712,15 @@ public class ModLoaderModContainer implements ModContainer
/**
* @return
*/
public BaseModTicker getTickHandler()
public BaseModTicker getGameTickHandler()
{
return this.tickHandler;
return this.gameTickHandler;
}
/**
* @return
*/
public BaseModTicker getGUITickHandler()
{
return this.guiTickHandler;
}
}
@@ -62,22 +62,22 @@ import cpw.mods.fml.common.registry.FMLRegistry;
/**
* Handles primary communication from hooked code into the system
*
*
* The FML entry point is {@link #onPreLoad(MinecraftServer)} called from
* {@link MinecraftServer}
*
*
* Obfuscated code should focus on this class and other members of the "server"
* (or "client") code
*
*
* The actual mod loading is handled at arms length by {@link Loader}
*
*
* It is expected that a similar class will exist for each target environment:
* Bukkit and Client side.
*
*
* It should not be directly modified.
*
*
* @author cpw
*
*
*/
public class FMLServerHandler implements IFMLSidedHandler
{
@@ -99,7 +99,7 @@ public class FMLServerHandler implements IFMLSidedHandler
/**
* Called to start the whole game off from
* {@link MinecraftServer#startServer}
*
*
* @param minecraftServer
*/
public void onPreLoad(MinecraftServer minecraftServer)
@@ -147,11 +147,17 @@ public class FMLServerHandler implements IFMLSidedHandler
Loader.instance().initializeMods();
}
@Override
public void haltGame(String message, Throwable exception)
{
throw new RuntimeException(message, exception);
}
public void onPreServerTick()
{
FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.GAME));
}
public void onPostServerTick()
{
FMLCommonHandler.instance().tickEnd(EnumSet.of(TickType.GAME));
@@ -178,7 +184,7 @@ public class FMLServerHandler implements IFMLSidedHandler
}
/**
* Get the server instance
*
*
* @return
*/
public MinecraftServer getServer()
@@ -196,10 +202,10 @@ public class FMLServerHandler implements IFMLSidedHandler
/**
* Called from ChunkProviderServer when a chunk needs to be populated
*
*
* To avoid polluting the worldgen seed, we generate a new random from the
* world seed and generate a seed from that
*
*
* @param chunkProvider
* @param chunkX
* @param chunkZ
@@ -213,7 +219,7 @@ public class FMLServerHandler implements IFMLSidedHandler
/**
* Called from the furnace to lookup fuel values
*
*
* @param itemId
* @param itemDamage
* @return
@@ -251,7 +257,7 @@ public class FMLServerHandler implements IFMLSidedHandler
/**
* Called to notify that an item was picked up from the world
*
*
* @param entityItem
* @param entityPlayer
*/
@@ -268,7 +274,7 @@ public class FMLServerHandler implements IFMLSidedHandler
/**
* Raise an exception
*
*
* @param exception
* @param message
* @param stopGame
@@ -282,7 +288,7 @@ public class FMLServerHandler implements IFMLSidedHandler
/**
* Attempt to dispense the item as an entity other than just as a the item
* itself
*
*
* @param world
* @param x
* @param y
@@ -315,7 +321,7 @@ public class FMLServerHandler implements IFMLSidedHandler
/**
* Build a list of default overworld biomes
*
*
* @return
*/
public BiomeGenBase[] getDefaultOverworldBiomes()
@@ -343,7 +349,7 @@ public class FMLServerHandler implements IFMLSidedHandler
/**
* Called when an item is crafted
*
*
* @param player
* @param craftedItem
* @param craftingGrid
@@ -361,7 +367,7 @@ public class FMLServerHandler implements IFMLSidedHandler
/**
* Called when an item is smelted
*
*
* @param player
* @param smeltedItem
*/
@@ -378,7 +384,7 @@ public class FMLServerHandler implements IFMLSidedHandler
/**
* Called when a chat packet is received
*
*
* @param chat
* @param player
* @return true if you want the packet to stop processing and not echo to
@@ -399,7 +405,7 @@ public class FMLServerHandler implements IFMLSidedHandler
/**
* Called when a packet 250 packet is received from the player
*
*
* @param packet
* @param player
*/
@@ -421,7 +427,7 @@ public class FMLServerHandler implements IFMLSidedHandler
/**
* Handle register requests for packet 250 channels
*
*
* @param packet
*/
private void handleClientRegistration(Packet250CustomPayload packet, EntityPlayer player)
@@ -458,7 +464,7 @@ public class FMLServerHandler implements IFMLSidedHandler
/**
* Handle a login
*
*
* @param loginPacket
* @param networkManager
*/
@@ -592,7 +598,7 @@ public class FMLServerHandler implements IFMLSidedHandler
objectName+=".name";
return objectName;
}
/* (non-Javadoc)
* @see cpw.mods.fml.common.IFMLSidedHandler#readMetadataFrom(java.io.InputStream, cpw.mods.fml.common.ModContainer)
*/
+26 -22
View File
@@ -29,7 +29,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
{
// CALLBACK MECHANISMS
public void keyBindingEvent(Object keybinding){}
/**
* @param minecraftInstance
* @return
@@ -43,6 +43,10 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
return true;
}
}
public final boolean doTickInGUI(TickType tick, boolean tickEnd, Object minecraftInstance, Object... data)
{
return false;
}
@Override
public final void onCrafting(Object... craftingParameters)
@@ -72,7 +76,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
public final void onServerLogin(Object handler) {
// NOOP
}
public final void onServerLogout() {
// NOOP
}
@@ -135,7 +139,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
// BASEMOD API
/**
* Override if you wish to provide a fuel item for the furnace and return the fuel value of the item
*
*
* @param id
* @param metadata
* @return
@@ -152,7 +156,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
/**
* Override if you wish to perform some action other than just dispensing the item from the dispenser
*
*
* @param world
* @param x
* @param y
@@ -169,7 +173,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
/**
* Override if you wish to generate Nether (Hell biome) blocks
*
*
* @param world
* @param random
* @param chunkX
@@ -181,7 +185,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
/**
* Override if you wish to generate Overworld (not hell or the end) blocks
*
*
* @param world
* @param random
* @param chunkX
@@ -193,7 +197,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
/**
* Return the name of your mod. Defaults to the class name
*
*
* @return
*/
public String getName()
@@ -203,7 +207,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
/**
* Get your mod priorities
*
*
* @return
*/
public String getPriorities()
@@ -213,7 +217,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
/**
* Return the version of your mod
*
*
* @return
*/
public abstract String getVersion();
@@ -237,7 +241,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
/**
* Handle item pickup
*
*
* @param player
* @param item
*/
@@ -247,7 +251,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
/**
* Ticked every game tick if you have subscribed to tick events through {@link ModLoader#setInGameHook(BaseMod, boolean, boolean)}
*
*
* @param minecraftServer the server
* @return true to continue receiving ticks
*/
@@ -264,23 +268,23 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
/**
* Only implemented on the client side
* {@link #onChatMessageReceived(EntityPlayer, Packet3Chat)}
*
*
* @param text
*/
public void receiveChatPacket(String text)
{
}
/**
* Only called on the client side
* {@link #onPacket250Received(EntityPlayer, Packet250CustomPayload)}
*
*
* @param packet
*/
public void receiveCustomPacket(Packet250CustomPayload packet)
{
}
public void registerAnimation(Object game)
@@ -301,7 +305,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
/**
* Called when someone crafts an item from a crafting table
*
*
* @param player
* @param item
* @param matrix
@@ -341,7 +345,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
/**
* Called when a chat message is received. Return true to stop further processing
*
*
* @param source
* @param chat
* @return true if you want to consume the message so it is not available for further processing
@@ -362,7 +366,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
/**
* Called when a new client logs in.
*
*
* @param player
*/
public void onClientLogin(EntityPlayer player)
@@ -371,7 +375,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
/**
* Called when a client logs out of the server.
*
*
* @param player
*/
public void onClientLogout(EntityPlayer player)
@@ -380,9 +384,9 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
}
/**
*
*
* Called when a client changes dimensions on the server.
*
*
* @param player
*/
public void onClientDimensionChanged(EntityPlayer player)
@@ -399,7 +403,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
}
/**
*
*
*/
public void onRegisterAnimations()
{