2013-02-18 03:46:16 +01:00
|
|
|
package StevenDimDoors.mod_pocketDim;
|
|
|
|
|
2013-09-02 04:01:17 +02:00
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
|
import java.io.DataOutputStream;
|
|
|
|
import java.io.IOException;
|
|
|
|
|
2013-02-18 03:46:16 +01:00
|
|
|
import net.minecraft.network.INetworkManager;
|
|
|
|
import net.minecraft.network.NetLoginHandler;
|
|
|
|
import net.minecraft.network.packet.NetHandler;
|
|
|
|
import net.minecraft.network.packet.Packet1Login;
|
2013-09-02 04:01:17 +02:00
|
|
|
import net.minecraft.network.packet.Packet250CustomPayload;
|
2013-02-18 03:46:16 +01:00
|
|
|
import net.minecraft.server.MinecraftServer;
|
2013-09-02 04:01:17 +02:00
|
|
|
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
2013-02-18 03:46:16 +01:00
|
|
|
import cpw.mods.fml.common.network.IConnectionHandler;
|
|
|
|
import cpw.mods.fml.common.network.Player;
|
|
|
|
|
2013-08-31 18:58:35 +02:00
|
|
|
public class ConnectionHandler implements IConnectionHandler
|
2013-02-18 03:46:16 +01:00
|
|
|
{
|
|
|
|
@Override
|
2013-09-02 04:01:17 +02:00
|
|
|
public String connectionReceived(NetLoginHandler netHandler, INetworkManager manager)
|
2013-02-18 03:46:16 +01:00
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-08-31 18:58:35 +02:00
|
|
|
public void connectionOpened(NetHandler netClientHandler, String server, int port, INetworkManager manager) { }
|
|
|
|
|
2013-02-18 03:46:16 +01:00
|
|
|
@Override
|
2013-08-29 08:14:24 +02:00
|
|
|
public void connectionOpened(NetHandler netClientHandler,MinecraftServer server, INetworkManager manager) { }
|
2013-02-18 03:46:16 +01:00
|
|
|
|
|
|
|
@Override
|
2013-08-31 18:58:35 +02:00
|
|
|
public void connectionClosed(INetworkManager manager) { }
|
2013-02-18 03:46:16 +01:00
|
|
|
|
|
|
|
@Override
|
2013-08-29 08:14:24 +02:00
|
|
|
public void clientLoggedIn(NetHandler clientHandler, INetworkManager manager, Packet1Login login) { }
|
2013-02-18 03:46:16 +01:00
|
|
|
|
|
|
|
@Override
|
2013-09-02 04:01:17 +02:00
|
|
|
public void playerLoggedIn(Player player, NetHandler netHandler, INetworkManager manager)
|
|
|
|
{
|
|
|
|
//Send information about all the registered dimensions and links to the client
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Packet250CustomPayload packet = new Packet250CustomPayload();
|
|
|
|
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
|
|
|
DataOutputStream writer = new DataOutputStream(buffer);
|
|
|
|
writer.writeByte(PacketConstants.CLIENT_JOIN_PACKET_ID);
|
2013-09-03 21:33:09 +02:00
|
|
|
PocketManager.writePacket(writer);
|
2013-09-02 04:01:17 +02:00
|
|
|
writer.close();
|
|
|
|
packet.channel = PacketConstants.CHANNEL_NAME;
|
|
|
|
packet.data = buffer.toByteArray();
|
|
|
|
packet.length = packet.data.length;
|
|
|
|
manager.addToSendQueue(packet);
|
|
|
|
}
|
|
|
|
catch (IOException e)
|
|
|
|
{
|
|
|
|
//This shouldn't happen...
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
2013-02-18 03:46:16 +01:00
|
|
|
}
|