Java 类net.minecraftforge.fml.common.network.FMLNetworkEvent 实例源码

项目:Factorization    文件:FlatNet.java   
@SubscribeEvent
public void packetToServer(FMLNetworkEvent.ServerCustomPacketEvent event) {
    ByteBuf buf = event.packet.payload();
    byte kind = buf.readByte();
    NetHandlerPlayServer handler = (NetHandlerPlayServer) event.handler;
    EntityPlayerMP player = handler.playerEntity;
    if (kind == INTERACT_HIT || kind == INTERACT_USE) {
        Coord at = readCoord(buf, player);
        EnumFacing side = readSide(buf);
        if (!at.blockExists()) return;
        double reachSq = 6 * 6; // FIXME: There's no way to get this properly on the server?
        if (at.distanceSq(player) > reachSq) {
            log("Ignoring distant interaction packet for " + at + " from " + player);
            return;
        }
        FlatFace face = Flat.get(at, side);
        if (kind == INTERACT_HIT) {
            face.onHit(at, side, player);
        } else {
            face.onActivate(at, side, player);
        }
    } else {
        log("Invalid packet ID " + kind + " from " + player);
    }
}
项目:CreeperHostGui    文件:CreeperHostServer.java   
@SubscribeEvent
public void clientConnectedtoServer(FMLNetworkEvent.ServerConnectionFromClientEvent event)
{
    if (!CreeperHost.instance.active)
        return;
    MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
    if (server == null || server.isSinglePlayer() || discoverMode != Discoverability.PUBLIC)
        return;

    INetHandlerPlayServer handler = event.getHandler();
    if (handler instanceof NetHandlerPlayServer)
    {
        EntityPlayerMP entity = ((NetHandlerPlayServer)handler).playerEntity;
        playersJoined.add(entity.getUniqueID());
    }
}
项目:CustomWorldGen    文件:NetworkDispatcher.java   
private void completeClientSideConnection(ConnectionType type)
{
    this.connectionType = type;
    FMLLog.info("[%s] Client side %s connection established", Thread.currentThread().getName(), this.connectionType.name().toLowerCase(Locale.ENGLISH));
    this.state = ConnectionState.CONNECTED;
    MinecraftForge.EVENT_BUS.post(new FMLNetworkEvent.ClientConnectedToServerEvent(manager, this.connectionType.name()));
}
项目:DiscordCE    文件:MinecraftEventHandler.java   
@SubscribeEvent
public void onPlayerJoinServer(FMLNetworkEvent.ClientConnectedToServerEvent e)
{
    if (e.isLocal())
    {
        singlePlayerGames++;
        ConcurrentUtil.executor.execute(() ->
                DiscordCE.client.getAccountManager().setGame("Minecraft [SP]"));
    }
    else
    {
        multiplayerGames++;
        ConcurrentUtil.executor.execute(() ->
                DiscordCE.client.getAccountManager().setGame("Minecraft [MP]"));
    }
}
项目:justenoughdimensions    文件:JEDEventHandler.java   
@SubscribeEvent
public void onConnectionCreated(FMLNetworkEvent.ServerConnectionFromClientEvent event)
{
    JustEnoughDimensions.logInfo("FMLNetworkEvent.ServerConnectionFromClientEvent: Syncing dimension data to client");
    DimensionSyncPacket packet = new DimensionSyncPacket();
    packet.addDimensionData(DimensionConfig.instance().getRegisteredDimensions());

    FMLEmbeddedChannel channel = JustEnoughDimensions.channels.get(Side.SERVER);
    channel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.DISPATCHER);
    channel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(event.getManager().channel().attr(NetworkDispatcher.FML_DISPATCHER).get());
    channel.writeOutbound(packet);
}
项目:Tabula    文件:EventHandler.java   
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onClientConnect(FMLNetworkEvent.ClientConnectedToServerEvent event)
{
    ProjectHelper.projectParts.clear();
    ProjectHelper.projectTextureParts.clear();

    for(ProjectInfo proj : ProjectHelper.projects.values())
    {
        proj.destroy();
    }

    for(Integer id : ProjectHelper.projectTextureIDs.values())
    {
        TextureUtil.deleteTexture(id);
    }

    ProjectHelper.projects.clear();
    ProjectHelper.projectTextures.clear();
    ProjectHelper.projectTextureIDs.clear();
}
项目:Hats    文件:EventHandlerClient.java   
@SubscribeEvent
public void onClientDisconnect(FMLNetworkEvent.ClientDisconnectionFromServerEvent event)
{
    Hats.eventHandlerClient.hats.clear();
    Hats.eventHandlerClient.mobHats.clear();
    Hats.eventHandlerClient.playerWornHats.clear();
    Hats.eventHandlerClient.requestedHats.clear();
    if(Hats.eventHandlerClient.guiHatUnlocked != null)
    {
        Hats.eventHandlerClient.guiHatUnlocked.hatList.clear();
    }
    if(Hats.eventHandlerClient.guiNewTradeReq != null)
    {
        Hats.eventHandlerClient.guiNewTradeReq.hatList.clear();
    }
    Hats.eventHandlerClient.worldInstance = null;
}
项目:CustomWorldGen    文件:FMLClientHandler.java   
@Override
public void fireNetRegistrationEvent(EventBus bus, NetworkManager manager, Set<String> channelSet, String channel, Side side)
{
    if (side == Side.CLIENT)
    {
        bus.post(new FMLNetworkEvent.CustomPacketRegistrationEvent<NetHandlerPlayClient>(manager, channelSet, channel, side, NetHandlerPlayClient.class));
    }
    else
    {
        bus.post(new FMLNetworkEvent.CustomPacketRegistrationEvent<NetHandlerPlayServer>(manager, channelSet, channel, side, NetHandlerPlayServer.class));
    }
}
项目:CustomWorldGen    文件:NetworkDispatcher.java   
private synchronized void completeServerSideConnection(ConnectionType type)
{
    this.connectionType = type;
    FMLLog.info("[%s] Server side %s connection established", Thread.currentThread().getName(), this.connectionType.name().toLowerCase(Locale.ENGLISH));
    this.state = ConnectionState.CONNECTED;
    MinecraftForge.EVENT_BUS.post(new FMLNetworkEvent.ServerConnectionFromClientEvent(manager));
    if (DEBUG_HANDSHAKE)
        manager.closeChannel(new TextComponentString("Handshake Complete review log file for details."));
    scm.initializeConnectionToPlayer(manager, player, serverHandler);
}
项目:CustomWorldGen    文件:NetworkDispatcher.java   
@Override
public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception
{
    if (side == Side.CLIENT)
    {
        MinecraftForge.EVENT_BUS.post(new FMLNetworkEvent.ClientDisconnectionFromServerEvent(manager));
    }
    else
    {
        MinecraftForge.EVENT_BUS.post(new FMLNetworkEvent.ServerDisconnectionFromClientEvent(manager));
    }
    cleanAttributes(ctx);
    ctx.disconnect(promise);
}
项目:CustomWorldGen    文件:NetworkDispatcher.java   
@Override
public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception
{
    if (side == Side.CLIENT)
    {
        MinecraftForge.EVENT_BUS.post(new FMLNetworkEvent.ClientDisconnectionFromServerEvent(manager));
    }
    else
    {
        MinecraftForge.EVENT_BUS.post(new FMLNetworkEvent.ServerDisconnectionFromClientEvent(manager));
    }
    cleanAttributes(ctx);
    ctx.close(promise);
}
项目:ModularMachinery    文件:PlayerStructureSelectionHelper.java   
@SubscribeEvent
public void onDisconnect(FMLNetworkEvent.ServerDisconnectionFromClientEvent event) {
    INetHandlerPlayServer handlerServer = event.getHandler();
    if(handlerServer instanceof NetHandlerPlayServer) {
        purgeSelection(((NetHandlerPlayServer) handlerServer).player);
    }
}
项目:Mob-Dismemberment    文件:EventHandlerClient.java   
@SubscribeEvent
public void onClientConnection(FMLNetworkEvent.ClientConnectedToServerEvent event)
{
    exploTime.clear();
    dismemberTimeout.clear();
    explosionSources.clear();
}
项目:AquaRegia    文件:NetworkEventHandler.java   
/**
 * Prints server connection info when the client connects to a server.
 * <p>
 * Test for this thread:
 * http://www.minecraftforge.net/forum/index.php/topic,34546.0.html
 *
 * @param event The event
 */
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void clientConnectedToServer(FMLNetworkEvent.ClientConnectedToServerEvent event) {
    final IThreadListener mainThread = Minecraft.getMinecraft();
    mainThread.addScheduledTask(() -> {
        final ServerData serverData = Minecraft.getMinecraft().getCurrentServerData();
        Logger.info("Server Connected! Local? %s - Address: %s", event.isLocal(), serverData != null ? serverData.serverIP : "<No ServerData>");
    });
}
项目:3DManeuverGear    文件:DartHandler.java   
@SubscribeEvent
@SuppressWarnings("unused")
public void onClientDisconnectFromServer(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) {
    EntityPlayer player = ManeuverGear.proxy.getClientPlayer();
    if(player == null) {
        return;
    }
    unEquipGear(player);
}
项目:MC-Prefab    文件:ClientEventHandler.java   
/**
 * This is used to clear out the server configuration on the client side.
 * @param event The event object.
 */
@SubscribeEvent
public static void OnClientDisconnectEvent(FMLNetworkEvent.ClientDisconnectionFromServerEvent event)
{
    // When the player logs out, make sure to re-set the server configuration. 
    // This is so a new configuration can be successfully loaded when they switch servers or worlds (on single player.
    ((ClientProxy)Prefab.proxy).serverConfiguration = null;
    ClientEventHandler.playerConfig.clearNonPersistedObjects();
}
项目:JustEnoughButtons    文件:EventHandlers.java   
@SubscribeEvent
public void onJoinServer(FMLNetworkEvent.ClientConnectedToServerEvent e) {
    for (String ip : ConfigHandler.spongeServers) {
        if (Minecraft.getMinecraft().getCurrentServerData().serverIP.contains(ip)) {
            JEIButtons.isSpongePresent = true;
            JEIButtons.logInfo("Sponge support is enabled for this server!");
            break;
        }
    }
}
项目:Factorization    文件:PacketJunction.java   
public static void setup(FMLNetworkEvent event, Side side) {
    PacketJunction handler = new PacketJunction(side);
    Channel channel = event.manager.channel();
    ChannelPipeline pipeline = channel.pipeline();
    if (pipeline.get("fzds:packetJunction") == null) {
        pipeline.addAfter("fml:packet_handler", "fzds:packetJunction", handler);
    }
}
项目:Factorization    文件:BlockUndo.java   
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void addBlockUndo(FMLNetworkEvent.ClientCustomPacketEvent event) {
    PlacedBlock at = PlacedBlock.read(event.packet.payload());
    EntityPlayer player = Minecraft.getMinecraft().thePlayer;
    markPlacement(player, at);
}
项目:Blocksteps    文件:EventHandlerClient.java   
@SubscribeEvent
public void onClientConnect(FMLNetworkEvent.ClientConnectedToServerEvent event)
{
    Blocksteps.eventHandler.targetAngleX = Blocksteps.eventHandler.prevAngleX = Blocksteps.eventHandler.angleX = Blocksteps.config.camStartVertical;
    Blocksteps.eventHandler.targetAngleY = Blocksteps.eventHandler.prevAngleY = Blocksteps.eventHandler.angleY = Blocksteps.eventHandler.oriAngleY = Blocksteps.config.camStartHorizontal;
    Blocksteps.eventHandler.targetScale = Blocksteps.config.camStartScale;
    Blocksteps.eventHandler.prevScale = Blocksteps.eventHandler.scale = 0;
    saveTimeout = Blocksteps.config.saveInterval;

    String connectionName = event.getManager().getRemoteAddress().toString();
    if(connectionName.contains("/") && !connectionName.startsWith("/192.168.")) //probably a public server
    {
        saveLocation = new File(new File(ResourceHelper.getModsFolder(), "/blocksteps/"), connectionName.substring(0, connectionName.indexOf("/")) + "_" + connectionName.substring(connectionName.indexOf(":") + 1, connectionName.length()) + ".bsv");
        if(saveLocation.exists())
        {
            try
            {
                byte[] data = new byte[(int)saveLocation.length()];
                FileInputStream stream = new FileInputStream(saveLocation);
                stream.read(data);
                stream.close();
                MapSaveFile save = (new Gson()).fromJson(IOUtil.decompress(data), MapSaveFile.class);
                save.load();
            }
            catch(Exception e)
            {
                Blocksteps.LOGGER.warn("Error loading save file: " + saveLocation);
            };
        }
    }
    else if(connectionName.startsWith("local") || connectionName.startsWith("/192.168."))
    {
        attemptLocalLoad = true;
    }
}
项目:Blocksteps    文件:EventHandlerClient.java   
@SubscribeEvent
public void onClientDisconnect(FMLNetworkEvent.ClientDisconnectionFromServerEvent event)
{
    if(renderGlobalProxy != null && renderGlobalProxy.theWorld != null)
    {
        if(saveLocation != null)
        {
            saveLocation.getParentFile().mkdirs();
            try
            {
                FileOutputStream stream = new FileOutputStream(saveLocation);
                stream.write(IOUtil.compress((new Gson()).toJson(MapSaveFile.create())));
                stream.close();
            }
            catch(Exception e)
            {
                Blocksteps.LOGGER.warn("Error saving file: " + saveLocation);
            }

            saveLocation = null;
        }
        setNewWorld(null);
        steps.clear();
        blocksToRenderByStep.clear();
        ChunkStore.clear();
        synchronized(Blocksteps.eventHandler.threadCheckBlocks.checks)
        {
            Blocksteps.eventHandler.threadCheckBlocks.checks.clear();
        }
    }
}
项目:sprinkles_for_vanilla    文件:NetworkHandler.java   
@SubscribeEvent
public void onClientConnectToServer(FMLNetworkEvent.ClientConnectedToServerEvent event)
{
    if (SprinklesForVanilla.isOnServer)
    {
        //SprinklesForVanilla.network.sendToServer(new ConfigPacket("",""));
        LogHelper.info("Client has Joined Server with sprinkles_for_vanilla");
    }
}
项目:MineMenu    文件:NetworkEventHandler.java   
@SubscribeEvent
public static void onClientConnect(FMLNetworkEvent.ClientConnectedToServerEvent event) {
    if (!event.isLocal()) {
        // Disable server specific options, which will be re-enabled if the server replies
        LogHandler.info("CLIENT: Connected to server. Disabling server-side click actions until server replies");
        ActionSessionData.activateClientValues();
    } else {
        ActionSessionData.activateAll();
    }
}
项目:Battlegear2    文件:BattlegearPacketHandeler.java   
@SubscribeEvent
public void onServerPacket(final FMLNetworkEvent.ServerCustomPacketEvent event) {
    final AbstractMBPacket packet = map.get(event.getPacket().channel());
    if (packet != null) {
        Battlegear.proxy.getThreadListener().addScheduledTask(new Runnable() {
            @Override
            public void run() {
                packet.process(event.getPacket().payload(), ((NetHandlerPlayServer) event.getHandler()).player);
            }
        });
    }
}
项目:Battlegear2    文件:BattlegearPacketHandeler.java   
@SubscribeEvent
public void onClientPacket(final FMLNetworkEvent.ClientCustomPacketEvent event) {
    final AbstractMBPacket packet = map.get(event.getPacket().channel());
    if (packet != null) {
        Battlegear.proxy.getThreadListener().addScheduledTask(new Runnable() {
            @Override
            public void run() {
                packet.process(event.getPacket().payload(), Battlegear.proxy.getClientPlayer());
            }
        });
    }
}
项目:Hats    文件:EventHandlerClient.java   
@SubscribeEvent
public void onClientConnect(FMLNetworkEvent.ClientConnectedToServerEvent event)
{
    Hats.eventHandlerClient.isActive = true;

    SessionState.serverHasMod = 0;
    SessionState.currentKing = "";
    SessionState.showJoinMessage = 0;
    SessionState.hasVisited = 1;

    HatHandler.repopulateHatsList();
}
项目:iChunUtil    文件:EventHandlerClient.java   
@SubscribeEvent
public void onClientConnection(FMLNetworkEvent.ClientConnectedToServerEvent event)
{
    connectingToServer = true;

    if(iChunUtil.userIsPatron)
    {
        patronUpdateServerAsPatron = true;
    }

    for(ConfigBase conf : ConfigHandler.configs)
    {
        conf.storeSession();
    }
}
项目:iChunUtil    文件:EventHandlerClient.java   
@SubscribeEvent
public void onClientDisconnect(FMLNetworkEvent.ClientDisconnectionFromServerEvent event)
{
    IThreadListener thread = Minecraft.getMinecraft();
    if(thread.isCallingFromMinecraftThread())
    {
        onClientDisconnect();
    }
    else
    {
        thread.addScheduledTask(this::onClientDisconnect);
    }
}
项目:GeneralLaymansAestheticSpyingScreen    文件:EventHandlerClient.java   
@SubscribeEvent
public void onClientDisconnect(FMLNetworkEvent.ClientDisconnectionFromServerEvent event)
{
    Minecraft.getMinecraft().addScheduledTask(this::disconnectFromServer);
}
项目:CreeperHostGui    文件:EventHandler.java   
@SubscribeEvent
public void serverLoginEvent(FMLNetworkEvent.ClientConnectedToServerEvent event)
{
    hasJoinedWorld = false;
}
项目:CreeperHostGui    文件:EventHandler.java   
@SubscribeEvent
public void clientDisconnect(FMLNetworkEvent.ClientDisconnectionFromServerEvent evt)
{
    CreeperHost.instance.curServerId = -1;
}
项目:ForgeHax    文件:ChatLogger.java   
@SubscribeEvent
public void onConnect(FMLNetworkEvent.ClientConnectedToServerEvent event) {
    getOrSetPublicLog(); // set public log file
}
项目:ForgeHax    文件:ChatLogger.java   
@SubscribeEvent
public void onDisconnect(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) {
    publicLog = null;
}
项目:Twitchy    文件:TCEvents.java   
@SubscribeEvent
public static void onLogin(FMLNetworkEvent.ClientConnectedToServerEvent event)
{
    executorService.scheduleAtFixedRate(new TCCheck(CHANNEL), 5, DELAY, TimeUnit.SECONDS);
    System.out.println("The thread is now running");
}
项目:Twitchy    文件:TCEvents.java   
@SubscribeEvent
public static void onLogout(FMLNetworkEvent.ClientDisconnectionFromServerEvent event)
{
    executorService.shutdown();
}
项目:Solar    文件:ClientProxy.java   
@SubscribeEvent
public static void disconnect(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) {
    SolarApi.getRelativityPowerMap().clear();
    SolarApi.getRelativityMap().clear();
    SolarApi.setQuantumData(null);
}
项目:Lithium-Forge    文件:NetworkEventHandler.java   
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void clientConnectedToServer(FMLNetworkEvent.ClientConnectedToServerEvent event) {
    Minecraft.getMinecraft().addScheduledTask(() -> MinecraftForge.EVENT_BUS.register(EntityEventHandler.INSTANCE));
}
项目:Clef    文件:EventHandlerClient.java   
@SubscribeEvent
public void onClientDisconnect(FMLNetworkEvent.ClientDisconnectionFromServerEvent event)
{
    Minecraft.getMinecraft().addScheduledTask(this::disconnectFromServer);
}
项目:BackTools    文件:EventHandlerClient.java   
@SubscribeEvent
public void onClientConnect(FMLNetworkEvent.ClientConnectedToServerEvent event)
{
    onClientConnection();
}
项目:BackTools    文件:EventHandlerClient.java   
@SubscribeEvent
public void onClientDisconnect(FMLNetworkEvent.ClientDisconnectionFromServerEvent event)
{
    onClientConnection();
}