mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-09-11 23:09:43 +00:00
46 lines
1.3 KiB
Java
46 lines
1.3 KiB
Java
![]() |
/**
|
||
|
* This file is part of ComputerCraft - http://www.computercraft.info
|
||
|
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||
|
* Send enquiries to dratcliffe@gmail.com
|
||
|
*/
|
||
|
|
||
|
package dan200.computercraft.shared.network;
|
||
|
|
||
|
import dan200.computercraft.ComputerCraft;
|
||
|
import net.minecraft.network.NetHandlerPlayServer;
|
||
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||
|
import net.minecraftforge.fml.common.network.FMLNetworkEvent;
|
||
|
|
||
|
public class PacketHandler
|
||
|
{
|
||
|
@SubscribeEvent
|
||
|
public void onClientPacket( FMLNetworkEvent.ClientCustomPacketEvent event )
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
ComputerCraftPacket packet = new ComputerCraftPacket();
|
||
|
packet.fromBytes( event.packet.payload() );
|
||
|
ComputerCraft.handlePacket( packet, null );
|
||
|
}
|
||
|
catch( Exception e )
|
||
|
{
|
||
|
e.printStackTrace();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@SubscribeEvent
|
||
|
public void onServerPacket( FMLNetworkEvent.ServerCustomPacketEvent event )
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
ComputerCraftPacket packet = new ComputerCraftPacket();
|
||
|
packet.fromBytes( event.packet.payload() );
|
||
|
ComputerCraft.handlePacket( packet, ((NetHandlerPlayServer)event.handler).playerEntity );
|
||
|
}
|
||
|
catch( Exception e )
|
||
|
{
|
||
|
e.printStackTrace();
|
||
|
}
|
||
|
}
|
||
|
}
|