当前位置: 首页>>代码示例>>Java>>正文


Java FMLNetworkEvent类代码示例

本文整理汇总了Java中net.minecraftforge.fml.common.network.FMLNetworkEvent的典型用法代码示例。如果您正苦于以下问题:Java FMLNetworkEvent类的具体用法?Java FMLNetworkEvent怎么用?Java FMLNetworkEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FMLNetworkEvent类属于net.minecraftforge.fml.common.network包,在下文中一共展示了FMLNetworkEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: packetToServer

import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:purpleposeidon,项目名称:Factorization,代码行数:26,代码来源:FlatNet.java

示例2: clientConnectedtoServer

import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@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());
    }
}
 
开发者ID:CreeperHost,项目名称:CreeperHostGui,代码行数:17,代码来源:CreeperHostServer.java

示例3: completeClientSideConnection

import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
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()));
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:8,代码来源:NetworkDispatcher.java

示例4: onPlayerJoinServer

import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@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]"));
    }
}
 
开发者ID:duke605,项目名称:DiscordCE,代码行数:17,代码来源:MinecraftEventHandler.java

示例5: onConnectionCreated

import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@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);
}
 
开发者ID:maruohon,项目名称:justenoughdimensions,代码行数:13,代码来源:JEDEventHandler.java

示例6: onClientConnect

import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@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();
}
 
开发者ID:iChun,项目名称:Tabula,代码行数:22,代码来源:EventHandler.java

示例7: onClientDisconnect

import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@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;
}
 
开发者ID:iChun,项目名称:Hats,代码行数:18,代码来源:EventHandlerClient.java

示例8: fireNetRegistrationEvent

import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@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));
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:13,代码来源:FMLClientHandler.java

示例9: completeServerSideConnection

import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
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);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:11,代码来源:NetworkDispatcher.java

示例10: disconnect

import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@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);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:15,代码来源:NetworkDispatcher.java

示例11: close

import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@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);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:15,代码来源:NetworkDispatcher.java

示例12: onDisconnect

import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@SubscribeEvent
public void onDisconnect(FMLNetworkEvent.ServerDisconnectionFromClientEvent event) {
    INetHandlerPlayServer handlerServer = event.getHandler();
    if(handlerServer instanceof NetHandlerPlayServer) {
        purgeSelection(((NetHandlerPlayServer) handlerServer).player);
    }
}
 
开发者ID:HellFirePvP,项目名称:ModularMachinery,代码行数:8,代码来源:PlayerStructureSelectionHelper.java

示例13: onClientConnection

import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@SubscribeEvent
public void onClientConnection(FMLNetworkEvent.ClientConnectedToServerEvent event)
{
    exploTime.clear();
    dismemberTimeout.clear();
    explosionSources.clear();
}
 
开发者ID:iChun,项目名称:Mob-Dismemberment,代码行数:8,代码来源:EventHandlerClient.java

示例14: clientConnectedToServer

import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
/**
 * 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>");
    });
}
 
开发者ID:droidicus,项目名称:AquaRegia,代码行数:18,代码来源:NetworkEventHandler.java

示例15: onClientDisconnectFromServer

import net.minecraftforge.fml.common.network.FMLNetworkEvent; //导入依赖的package包/类
@SubscribeEvent
@SuppressWarnings("unused")
public void onClientDisconnectFromServer(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) {
    EntityPlayer player = ManeuverGear.proxy.getClientPlayer();
    if(player == null) {
        return;
    }
    unEquipGear(player);
}
 
开发者ID:InfinityRaider,项目名称:3DManeuverGear,代码行数:10,代码来源:DartHandler.java


注:本文中的net.minecraftforge.fml.common.network.FMLNetworkEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。