/*
 *  Copyright (c) 2014, Lukas Tenbrink.
 *  * http://ivorius.net
 */

package ivorius.ivtoolkit.network;

import net.minecraft.client.Minecraft;
import net.minecraft.world.WorldServer;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;

public class SchedulingMessageHandler<REQ extends IMessage, REPLY extends IMessage> implements IMessageHandler<REQ, REPLY>
{
    @Override
    public REPLY onMessage(REQ message, MessageContext ctx)
    {
        if (ctx.side.isClient())
            Minecraft.getMinecraft().addScheduledTask(() -> processClient(message, ctx));
        else if (ctx.side.isServer())
        {
            WorldServer world = getServerWorld(message, ctx);
            world.addScheduledTask(() -> processServer(message, ctx, world));
        }

        return null;
    }

    public WorldServer getServerWorld(REQ message, MessageContext ctx)
    {
        return (WorldServer) ctx.getServerHandler().playerEntity.worldObj;
    }

    public void processClient(REQ message, MessageContext ctx)
    {

    }

    public void processServer(REQ message, MessageContext ctx, WorldServer world)
    {

    }
}
@@ -391,16 +391,114 @@
 Context;
+%0Aimport net.minecraftforge.fml.relauncher.Side;%0Aimport net.minecraftforge.fml.relauncher.SideOnly;
 %0A%0Apublic
@@ -745,63 +745,17 @@
     
-Minecraft.getMinecraft().addScheduledTask(() -%3E process
+onMessage
 Clie
@@ -770,17 +770,16 @@
 ge, ctx)
-)
 ;%0A      
@@ -814,30 +814,160 @@
 ())%0A        
-%7B
+    onMessageServer(message, ctx);%0A%0A        return null;%0A    %7D%0A%0A    private void onMessageServer(REQ message, MessageContext ctx)
 %0A    
+%7B%0A
         Worl
@@ -1008,28 +1008,24 @@
 sage, ctx);%0A
-    
         worl
@@ -1094,34 +1094,194 @@
     
+%7D%0A%0A
     
-%7D%0A
+@SideOnly(Side.CLIENT)%0A    private void onMessageClient(REQ message, MessageContext ctx)
 %0A    
+%7B%0A
     
-return null
+    Minecraft.getMinecraft().addScheduledTask(() -%3E processClient(message, ctx))
 ;%0A  
@@ -1436,32 +1436,59 @@
 orldObj;%0A    %7D%0A%0A
+    @SideOnly(Side.CLIENT)%0A
     public void 

Make SchedulingMessageHandler.processClient sideonly.