    001/*
    002 * Forge Mod Loader
    003 * Copyright (c) 2012-2013 cpw.
    004 * All rights reserved. This program and the accompanying materials
    005 * are made available under the terms of the GNU Lesser Public License v2.1
    006 * which accompanies this distribution, and is available at
    007 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    008 *
    009 * Contributors:
    010 *     cpw - implementation
    011 */
    012
    013package cpw.mods.fml.common.modloader;
    014
    015import net.minecraft.entity.player.EntityPlayerMP;
    016import net.minecraft.network.INetworkManager;
    017import net.minecraft.network.packet.Packet250CustomPayload;
    018import cpw.mods.fml.common.network.IPacketHandler;
    019import cpw.mods.fml.common.network.Player;
    020
    021public class ModLoaderPacketHandler implements IPacketHandler
    022{
    023    private BaseModProxy mod;
    024
    025    public ModLoaderPacketHandler(BaseModProxy mod)
    026    {
    027        this.mod = mod;
    028    }
    029
    030    @Override
    031    public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player)
    032    {
    033        if (player instanceof EntityPlayerMP)
    034        {
    035            mod.serverCustomPayload(((EntityPlayerMP)player).playerNetServerHandler, packet);
    036        }
    037        else
    038        {
    039            ModLoaderHelper.sidedHelper.sendClientPacket(mod, packet);
    040        }
    041    }
    042
    043}