Applied-Energistics-2-tiler.../core/sync/AppEngClientPacketHandler.java
2013-12-27 16:59:59 -06:00

46 lines
1.2 KiB
Java

package appeng.core.sync;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet250CustomPayload;
import cpw.mods.fml.common.network.IPacketHandler;
import cpw.mods.fml.common.network.Player;
public class AppEngClientPacketHandler extends AppEngPacketHandlerBase implements IPacketHandler
{
@Override
public void onPacketData(INetworkManager network, Packet250CustomPayload packet, Player player)
{
DataInputStream stream = new DataInputStream( new ByteArrayInputStream( packet.data ) );
// Determine packet type and coordinates of affected tile entity
int packetType = -1;
try
{
packetType = stream.readInt();
AppEngPacket pack = PacketTypes.getPacket( packetType ).parsePacket( stream );
pack.clientPacketData( network, pack, player );
} catch (IOException e)
{
e.printStackTrace();
} catch (InstantiationException e)
{
e.printStackTrace();
} catch (IllegalAccessException e)
{
e.printStackTrace();
} catch (IllegalArgumentException e)
{
e.printStackTrace();
} catch (InvocationTargetException e)
{
e.printStackTrace();
}
}
}