Java Code Examples for net.minecraft.network.NetworkManager

The following are top voted examples for showing how to use net.minecraft.network.NetworkManager. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: CustomWorldGen   File: ServerPinger.java   View source code 6 votes vote down vote up
public void clearPendingNetworks()
{
    synchronized (this.pingDestinations)
    {
        Iterator<NetworkManager> iterator = this.pingDestinations.iterator();

        while (iterator.hasNext())
        {
            NetworkManager networkmanager = (NetworkManager)iterator.next();

            if (networkmanager.isChannelOpen())
            {
                iterator.remove();
                networkmanager.closeChannel(new TextComponentString("Cancelled"));
            }
        }
    }
}
 
Example 2
Project: DecompiledMinecraft   File: OldServerPinger.java   View source code 6 votes vote down vote up
public void pingPendingNetworks()
{
    synchronized (this.pingDestinations)
    {
        Iterator<NetworkManager> iterator = this.pingDestinations.iterator();

        while (iterator.hasNext())
        {
            NetworkManager networkmanager = (NetworkManager)iterator.next();

            if (networkmanager.isChannelOpen())
            {
                networkmanager.processReceivedPackets();
            }
            else
            {
                iterator.remove();
                networkmanager.checkDisconnected();
            }
        }
    }
}
 
Example 3
Project: DecompiledMinecraft   File: OldServerPinger.java   View source code 6 votes vote down vote up
public void clearPendingNetworks()
{
    synchronized (this.pingDestinations)
    {
        Iterator<NetworkManager> iterator = this.pingDestinations.iterator();

        while (iterator.hasNext())
        {
            NetworkManager networkmanager = (NetworkManager)iterator.next();

            if (networkmanager.isChannelOpen())
            {
                iterator.remove();
                networkmanager.closeChannel(new ChatComponentText("Cancelled"));
            }
        }
    }
}
 
Example 4
Project: Backmemed   File: ServerPinger.java   View source code 6 votes vote down vote up
public void pingPendingNetworks()
{
    synchronized (this.pingDestinations)
    {
        Iterator<NetworkManager> iterator = this.pingDestinations.iterator();

        while (iterator.hasNext())
        {
            NetworkManager networkmanager = (NetworkManager)iterator.next();

            if (networkmanager.isChannelOpen())
            {
                networkmanager.processReceivedPackets();
            }
            else
            {
                iterator.remove();
                networkmanager.checkDisconnected();
            }
        }
    }
}
 
Example 5
Project: BaseClient   File: RealmsServerStatusPinger.java   View source code 6 votes vote down vote up
public void removeAll()
{
    synchronized (this.connections)
    {
        Iterator<NetworkManager> iterator = this.connections.iterator();

        while (iterator.hasNext())
        {
            NetworkManager networkmanager = (NetworkManager)iterator.next();

            if (networkmanager.isChannelOpen())
            {
                iterator.remove();
                networkmanager.closeChannel(new ChatComponentText("Cancelled"));
            }
        }
    }
}
 
Example 6
Project: BaseClient   File: OldServerPinger.java   View source code 6 votes vote down vote up
public void clearPendingNetworks()
{
    synchronized (this.pingDestinations)
    {
        Iterator<NetworkManager> iterator = this.pingDestinations.iterator();

        while (iterator.hasNext())
        {
            NetworkManager networkmanager = (NetworkManager)iterator.next();

            if (networkmanager.isChannelOpen())
            {
                iterator.remove();
                networkmanager.closeChannel(new ChatComponentText("Cancelled"));
            }
        }
    }
}
 
Example 7
Project: BaseClient   File: RealmsServerStatusPinger.java   View source code 6 votes vote down vote up
public void tick()
{
    synchronized (this.connections)
    {
        Iterator<NetworkManager> iterator = this.connections.iterator();

        while (iterator.hasNext())
        {
            NetworkManager networkmanager = (NetworkManager)iterator.next();

            if (networkmanager.isChannelOpen())
            {
                networkmanager.processReceivedPackets();
            }
            else
            {
                iterator.remove();
                networkmanager.checkDisconnected();
            }
        }
    }
}
 
Example 8
Project: Backmemed   File: ServerPinger.java   View source code 6 votes vote down vote up
public void clearPendingNetworks()
{
    synchronized (this.pingDestinations)
    {
        Iterator<NetworkManager> iterator = this.pingDestinations.iterator();

        while (iterator.hasNext())
        {
            NetworkManager networkmanager = (NetworkManager)iterator.next();

            if (networkmanager.isChannelOpen())
            {
                iterator.remove();
                networkmanager.closeChannel(new TextComponentString("Cancelled"));
            }
        }
    }
}
 
Example 9
Project: BaseClient   File: OldServerPinger.java   View source code 6 votes vote down vote up
public void pingPendingNetworks()
{
    synchronized (this.pingDestinations)
    {
        Iterator<NetworkManager> iterator = this.pingDestinations.iterator();

        while (iterator.hasNext())
        {
            NetworkManager networkmanager = (NetworkManager)iterator.next();

            if (networkmanager.isChannelOpen())
            {
                networkmanager.processReceivedPackets();
            }
            else
            {
                iterator.remove();
                networkmanager.checkDisconnected();
            }
        }
    }
}
 
Example 10
Project: BaseClient   File: OldServerPinger.java   View source code 6 votes vote down vote up
public void clearPendingNetworks()
{
    synchronized (this.pingDestinations)
    {
        Iterator<NetworkManager> iterator = this.pingDestinations.iterator();

        while (iterator.hasNext())
        {
            NetworkManager networkmanager = (NetworkManager)iterator.next();

            if (networkmanager.isChannelOpen())
            {
                iterator.remove();
                networkmanager.closeChannel(new ChatComponentText("Cancelled"));
            }
        }
    }
}
 
Example 11
Project: pnc-repressurized   File: EntityDrone.java   View source code 5 votes vote down vote up
private void initializeFakePlayer() {
    fakePlayer = new DroneFakePlayer(
            (WorldServer) world,
            new GameProfile(UUID.fromString(getOwnerUUID()), playerName),
            this);
    fakePlayer.connection = new NetHandlerPlayServer(FMLCommonHandler.instance().getMinecraftServerInstance(), new NetworkManager(EnumPacketDirection.SERVERBOUND), fakePlayer);
    fakePlayer.inventory = new InventoryFakePlayer(fakePlayer);
}
 
Example 12
Project: GeneralLaymansAestheticSpyingScreen   File: TileEntityGlassBase.java   View source code 5 votes vote down vote up
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt)
{
    onChunkUnload();
    readFromNBT(pkt.getNbtCompound());
    onLoad();
}
 
Example 13
Project: GeneralLaymansAestheticSpyingScreen   File: TileEntityGlassTerminal.java   View source code 5 votes vote down vote up
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt)
{
    onChunkUnload();
    readFromNBT(pkt.getNbtCompound());
    onLoad();
}
 
Example 14
Project: Backmemed   File: NetHandlerPlayClient.java   View source code 5 votes vote down vote up
public NetHandlerPlayClient(Minecraft mcIn, GuiScreen p_i46300_2_, NetworkManager networkManagerIn, GameProfile profileIn)
{
    this.gameController = mcIn;
    this.guiScreenServer = p_i46300_2_;
    this.netManager = networkManagerIn;
    this.profile = profileIn;
}
 
Example 15
Project: CreeperHostGui   File: GuiProgressDisconnected.java   View source code 5 votes vote down vote up
public GuiProgressDisconnected(GuiScreen screen, String reasonLocalizationKey, ITextComponent chatComp, NetworkManager lastNetworkManager)
{
    this.parentScreen = screen;
    this.ourReason = I18n.format(reasonLocalizationKey);
    this.ourMessage = chatComp;
    this.lastNetworkManager = lastNetworkManager;
    this.lastConnectAttempt = System.currentTimeMillis();
    if (lastNetworkManager != null)
    {
        InetSocketAddress address = (InetSocketAddress) lastNetworkManager.getRemoteAddress();
        ip = address.getHostName() + ":" + address.getPort();
    }
}
 
Example 16
Project: DecompiledMinecraft   File: MessageDeserializer.java   View source code 5 votes vote down vote up
protected void decode(ChannelHandlerContext p_decode_1_, ByteBuf p_decode_2_, List<Object> p_decode_3_) throws IOException, InstantiationException, IllegalAccessException, Exception
{
    if (p_decode_2_.readableBytes() != 0)
    {
        PacketBuffer packetbuffer = new PacketBuffer(p_decode_2_);
        int i = packetbuffer.readVarIntFromBuffer();
        Packet packet = ((EnumConnectionState)p_decode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get()).getPacket(this.direction, i);

        if (packet == null)
        {
            throw new IOException("Bad packet id " + i);
        }
        else
        {
            packet.readPacketData(packetbuffer);

            if (packetbuffer.readableBytes() > 0)
            {
                throw new IOException("Packet " + ((EnumConnectionState)p_decode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get()).getId() + "/" + i + " (" + packet.getClass().getSimpleName() + ") was larger than I expected, found " + packetbuffer.readableBytes() + " bytes extra whilst reading packet " + i);
            }
            else
            {
                p_decode_3_.add(packet);

                if (logger.isDebugEnabled())
                {
                    logger.debug(RECEIVED_PACKET_MARKER, " IN: [{}:{}] {}", new Object[] {p_decode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get(), Integer.valueOf(i), packet.getClass().getName()});
                }
            }
        }
    }
}
 
Example 17
Project: DecompiledMinecraft   File: MessageDeserializer.java   View source code 5 votes vote down vote up
protected void decode(ChannelHandlerContext p_decode_1_, ByteBuf p_decode_2_, List<Object> p_decode_3_) throws IOException, InstantiationException, IllegalAccessException, Exception
{
    if (p_decode_2_.readableBytes() != 0)
    {
        PacketBuffer packetbuffer = new PacketBuffer(p_decode_2_);
        int i = packetbuffer.readVarIntFromBuffer();
        Packet packet = ((EnumConnectionState)p_decode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get()).getPacket(this.direction, i);

        if (packet == null)
        {
            throw new IOException("Bad packet id " + i);
        }
        else
        {
            packet.readPacketData(packetbuffer);

            if (packetbuffer.readableBytes() > 0)
            {
                throw new IOException("Packet " + ((EnumConnectionState)p_decode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get()).getId() + "/" + i + " (" + packet.getClass().getSimpleName() + ") was larger than I expected, found " + packetbuffer.readableBytes() + " bytes extra whilst reading packet " + i);
            }
            else
            {
                p_decode_3_.add(packet);

                if (logger.isDebugEnabled())
                {
                    logger.debug(RECEIVED_PACKET_MARKER, " IN: [{}:{}] {}", new Object[] {p_decode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get(), Integer.valueOf(i), packet.getClass().getName()});
                }
            }
        }
    }
}
 
Example 18
Project: PacketControl   File: PacketControlService.java   View source code 5 votes vote down vote up
@Override
public void sendPacket(Packet packet, PlayerConnection connection) {
    if(connection instanceof NetworkManager) {
        ((NetworkManager)connection).sendPacket((net.minecraft.network.Packet)packet);
    } else if(connection instanceof NetHandlerPlayServer) {
        ((NetHandlerPlayServer)connection).sendPacket((net.minecraft.network.Packet)packet);
    } else {
        sendPacket(packet, connection.getPlayer());
    }
}
 
Example 19
Project: PurificatiMagicae   File: TileCodeStorage.java   View source code 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt)
{
    super.onDataPacket(net, pkt);
    setOpened(pkt.getNbtCompound().getBoolean("opened"));
}
 
Example 20
Project: BaseClient   File: NetHandlerPlayClient.java   View source code 5 votes vote down vote up
public NetHandlerPlayClient(Minecraft mcIn, GuiScreen p_i46300_2_, NetworkManager p_i46300_3_, GameProfile p_i46300_4_)
{
    this.gameController = mcIn;
    this.guiScreenServer = p_i46300_2_;
    this.netManager = p_i46300_3_;
    this.profile = p_i46300_4_;
}
 
Example 21
Project: BaseClient   File: MessageSerializer.java   View source code 5 votes vote down vote up
protected void encode(ChannelHandlerContext p_encode_1_, Packet p_encode_2_, ByteBuf p_encode_3_) throws IOException, Exception
{
    Integer integer = ((EnumConnectionState)p_encode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get()).getPacketId(this.direction, p_encode_2_);

    if (logger.isDebugEnabled())
    {
        logger.debug(RECEIVED_PACKET_MARKER, "OUT: [{}:{}] {}", new Object[] {p_encode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get(), integer, p_encode_2_.getClass().getName()});
    }

    if (integer == null)
    {
        throw new IOException("Can\'t serialize unregistered packet");
    }
    else
    {
        PacketBuffer packetbuffer = new PacketBuffer(p_encode_3_);
        packetbuffer.writeVarIntToBuffer(integer.intValue());

        try
        {
            p_encode_2_.writePacketData(packetbuffer);
        }
        catch (Throwable throwable)
        {
            logger.error((Object)throwable);
        }
    }
}
 
Example 22
Project: BaseClient   File: MessageDeserializer.java   View source code 5 votes vote down vote up
protected void decode(ChannelHandlerContext p_decode_1_, ByteBuf p_decode_2_, List<Object> p_decode_3_) throws IOException, InstantiationException, IllegalAccessException, Exception
{
    if (p_decode_2_.readableBytes() != 0)
    {
        PacketBuffer packetbuffer = new PacketBuffer(p_decode_2_);
        int i = packetbuffer.readVarIntFromBuffer();
        Packet packet = ((EnumConnectionState)p_decode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get()).getPacket(this.direction, i);

        if (packet == null)
        {
            throw new IOException("Bad packet id " + i);
        }
        else
        {
            packet.readPacketData(packetbuffer);

            if (packetbuffer.readableBytes() > 0)
            {
                throw new IOException("Packet " + ((EnumConnectionState)p_decode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get()).getId() + "/" + i + " (" + packet.getClass().getSimpleName() + ") was larger than I expected, found " + packetbuffer.readableBytes() + " bytes extra whilst reading packet " + i);
            }
            else
            {
                p_decode_3_.add(packet);

                if (logger.isDebugEnabled())
                {
                    logger.debug(RECEIVED_PACKET_MARKER, " IN: [{}:{}] {}", new Object[] {p_decode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get(), Integer.valueOf(i), packet.getClass().getName()});
                }
            }
        }
    }
}
 
Example 23
Project: BaseClient   File: NetHandlerPlayClient.java   View source code 5 votes vote down vote up
public NetHandlerPlayClient(Minecraft mcIn, GuiScreen p_i46300_2_, NetworkManager p_i46300_3_,
		GameProfile p_i46300_4_) {
	this.gameController = mcIn;
	this.guiScreenServer = p_i46300_2_;
	this.netManager = p_i46300_3_;
	this.profile = p_i46300_4_;
}
 
Example 24
Project: Zombe-Modpack   File: NetHandlerPlayClient.java   View source code 5 votes vote down vote up
public NetHandlerPlayClient(Minecraft mcIn, GuiScreen p_i46300_2_, NetworkManager networkManagerIn, GameProfile profileIn)
{
    this.gameController = mcIn;
    this.guiScreenServer = p_i46300_2_;
    this.netManager = networkManagerIn;
    this.profile = profileIn;
}
 
Example 25
Project: BaseClient   File: MessageSerializer.java   View source code 5 votes vote down vote up
protected void encode(ChannelHandlerContext p_encode_1_, Packet p_encode_2_, ByteBuf p_encode_3_) throws IOException, Exception
{
    Integer integer = ((EnumConnectionState)p_encode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get()).getPacketId(this.direction, p_encode_2_);

    if (logger.isDebugEnabled())
    {
        logger.debug(RECEIVED_PACKET_MARKER, "OUT: [{}:{}] {}", new Object[] {p_encode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get(), integer, p_encode_2_.getClass().getName()});
    }

    if (integer == null)
    {
        throw new IOException("Can\'t serialize unregistered packet");
    }
    else
    {
        PacketBuffer packetbuffer = new PacketBuffer(p_encode_3_);
        packetbuffer.writeVarIntToBuffer(integer.intValue());

        try
        {
            p_encode_2_.writePacketData(packetbuffer);
        }
        catch (Throwable throwable)
        {
            logger.error((Object)throwable);
        }
    }
}
 
Example 26
Project: Backmemed   File: NetHandlerStatusServer.java   View source code 4 votes vote down vote up
public NetHandlerStatusServer(MinecraftServer serverIn, NetworkManager netManager)
{
    this.server = serverIn;
    this.networkManager = netManager;
}
 
Example 27
Project: pnc-repressurized   File: TileEntityDroneInterface.java   View source code 4 votes vote down vote up
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
    handleUpdateTag(pkt.getNbtCompound());
}
 
Example 28
Project: SimpleTubes   File: TileTube.java   View source code 4 votes vote down vote up
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
	super.onDataPacket(net, pkt);
	handleUpdateTag(pkt.getNbtCompound());
}
 
Example 29
Project: pnc-repressurized   File: TileEntityBase.java   View source code 4 votes vote down vote up
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
    super.onDataPacket(net, pkt);
    PacketDescription packet = new PacketDescription(pkt.getNbtCompound());
    packet.handleClientSide(packet, PneumaticCraftRepressurized.proxy.getPlayer());
}
 
Example 30
Project: CustomWorldGen   File: FMLServerHandler.java   View source code 4 votes vote down vote up
@Override
public NetworkManager getClientToServerNetworkManager()
{
    throw new RuntimeException("Missing");
}
 
Example 31
Project: HeroUtils   File: TileEntityCookieJar.java   View source code 4 votes vote down vote up
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
	NBTTagCompound tagCom = pkt.getNbtCompound();
	readUpdateTag(tagCom);
}
 
Example 32
Project: Soot   File: TileEntityEmberBurst.java   View source code 4 votes vote down vote up
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
    readFromNBT(pkt.getNbtCompound());
}
 
Example 33
Project: Soot   File: TileEntityEmberFunnel.java   View source code 4 votes vote down vote up
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
    readFromNBT(pkt.getNbtCompound());
}
 
Example 34
Project: ExSartagine   File: TileEntityCooker.java   View source code 4 votes vote down vote up
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
	this.readFromNBT(pkt.getNbtCompound());
}
 
Example 35
Project: CustomWorldGen   File: FMLNetworkEvent.java   View source code 4 votes vote down vote up
public ClientDisconnectionFromServerEvent(NetworkManager manager)
{
    super((INetHandlerPlayClient) manager.getNetHandler(), INetHandlerPlayClient.class, manager);
}
 
Example 36
Project: ExSartagine   File: TileEntityRangeExtension.java   View source code 4 votes vote down vote up
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
	this.readFromNBT(pkt.getNbtCompound());
}
 
Example 37
Project: MobBlocker   File: TileEntityChunkProtector.java   View source code 4 votes vote down vote up
/**
 * Handles data packets
 */
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) {
	this.readFromNBT(packet.getNbtCompound());
}
 
Example 38
Project: Bewitchment   File: TileMod.java   View source code 4 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) {
	super.onDataPacket(net, packet);
	readDataNBT(packet.getNbtCompound());
}
 
Example 39
Project: Bewitchment   File: TileFluidInventory.java   View source code 4 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
	readFromNBT(pkt.getNbtCompound());
}
 
Example 40
Project: Bewitchment   File: TileItemInventory.java   View source code 4 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) {
	super.onDataPacket(net, packet);
	readDataNBT(packet.getNbtCompound());
}