Java 类cpw.mods.fml.common.network.NetworkRegistry 实例源码

项目:PopularMMOS-EpicProportions-Mod    文件:epicproportionsmod_halloween.java   
@Mod.EventHandler
public void init(FMLInitializationEvent event)
{
    proxy.init(event);
    // register CommonProxy as our GuiHandler
    NetworkRegistry.INSTANCE.registerGuiHandler(MODID, new CommonProxy());

    ItemLoader.LoadItems();
    BlockLoader.loadBlocks();
    Recipes.registerRecpies();
    EntityLoader.LoadEntitys();
    OreDict.addores();
    //Achievements.loadAchievements();
    //Stats.RegisterStats();

    GameRegistry.registerWorldGenerator(new ModWorldGen(), 0);

}
项目:PAYDAY    文件:PAYDAY.java   
@EventHandler
public void init(FMLInitializationEvent evt) {
    INSTANCE.registerMessage(LobbyPlayerOpenedGuiPacketHandler.class, LobbyPlayerOpenedGuiPacket.class, 0,
            Side.SERVER);

    INSTANCE.registerMessage(LobbyBeginGamePacketHandler.class, LobbyBeginGamePacket.class, 1, Side.SERVER);
    INSTANCE.registerMessage(PacketSyncPlayerPropertiesClientHandler.class, PacketSyncPlayerPropertiesClient.class,
            2, Side.CLIENT);
    INSTANCE.registerMessage(PacketSyncPlayerPropertiesServerHandler.class, PacketSyncPlayerPropertiesServer.class,
            3, Side.SERVER);

    INSTANCE.registerMessage(PacketSyncTileEntityServerHandler.class, PacketSyncTileEntityServer.class, 4,
            Side.SERVER);
    INSTANCE.registerMessage(PacketSyncTileEntityClientHandler.class, PacketSyncTileEntityClient.class, 5,
            Side.CLIENT);

    NetworkRegistry.INSTANCE.registerGuiHandler(PAYDAY.instance, new MGuiHandler());
    GameRegistry.registerBlock(lobbyBlock, "Lobby");
    GameRegistry.registerTileEntity(LobbyTileEntity.class, "lobby_tile_entity");

    FMLCommonHandler.instance().bus().register(eventHandler);
    MinecraftForge.EVENT_BUS.register(eventHandler);
}
项目:connor41-etfuturum2    文件:EtFuturum.java   
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
    ConfigurationHandler.INSTANCE.init(new File(event.getModConfigurationDirectory().getAbsolutePath() + File.separator + Reference.MOD_ID + ".cfg"));

    GameRegistry.registerWorldGenerator(new EtFuturumWorldGenerator(), 0);
    GameRegistry.registerWorldGenerator(new EtFuturumNetherGenerator(), 1);

    ModBlocks.init();
    ModItems.init();
    ModEnchantments.init();

    OceanMonument.makeMap();

    NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);
    networkWrapper = NetworkRegistry.INSTANCE.newSimpleChannel(Reference.MOD_ID);
    networkWrapper.registerMessage(ArmourStandInteractHandler.class, ArmourStandInteractMessage.class, 0, Side.SERVER);
    networkWrapper.registerMessage(BlackHeartParticlesHandler.class, BlackHeartParticlesMessage.class, 1, Side.CLIENT);
    networkWrapper.registerMessage(SetPlayerModelHandler.class, SetPlayerModelMessage.class, 2, Side.CLIENT);
}
项目:connor41-etfuturum2    文件:EtFuturum.java   
@EventHandler
public void init(FMLInitializationEvent event) {
    NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);

    ModRecipes.init();

    proxy.registerEvents();
    proxy.registerEntities();
    proxy.registerRenderers();

    if (ModEntityList.hasEntitiesWithEggs()) {
        ModEntityList.entity_egg = new ItemEntityEgg();
        GameRegistry.registerItem(ModEntityList.entity_egg, "entity_egg");
        OreDictionary.registerOre("mobEgg", ModEntityList.entity_egg);
    }

    isTinkersConstructLoaded = Loader.isModLoaded("TConstruct");
}
项目:ExtraUtilities    文件:ExtraUtils.java   
public void init(final FMLInitializationEvent event) {
    NetworkRegistry.INSTANCE.registerGuiHandler((Object)ExtraUtilsMod.instance, (IGuiHandler)new GuiHandler());
    if (Loader.isModLoaded("ForgeMultipart")) {
        this.FMPRegisterPassThroughInterfaces();
    }
    ExtraUtilsMod.proxy.registerEventHandler();
    ExtraUtilsMod.proxy.registerRenderInformation();
    if (Loader.isModLoaded("ThermalExpansion")) {
        TE4IMC.addIntegration();
    }
    if (Loader.isModLoaded("MineFactoryReloaded")) {
        MFRIntegration.registerMFRIntegration();
    }
    for (final ILoading loader : this.loaders) {
        loader.init();
    }
    EE3Integration.finalRegister();
}
项目:4Space-5    文件:GalacticraftPacketHandler.java   
@Override
protected void channelRead0(ChannelHandlerContext ctx, IPacket msg) throws Exception
{
    INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
    EntityPlayer player = GalacticraftCore.proxy.getPlayerFromNetHandler(netHandler);

    switch (FMLCommonHandler.instance().getEffectiveSide())
    {
    case CLIENT:
        msg.handleClientSide(player);
        break;
    case SERVER:
        msg.handleServerSide(player);
        break;
    default:
        break;
    }
}
项目:MidgarCrusade    文件:Packets.java   
public static void initialize()
{
    network = NetworkRegistry.INSTANCE.newSimpleChannel("MagicCrusade");

    network.registerMessage(PacketLogIn.Handler.class, PacketLogIn.class, 0, Side.CLIENT);
    network.registerMessage(PacketDisplayGui.Handler.class, PacketDisplayGui.class, 1, Side.CLIENT);
    network.registerMessage(PacketParticleEffectToClient.Handler.class, PacketParticleEffectToClient.class, 2, Side.CLIENT);
    network.registerMessage(PacketParticleEffectToServer.Handler.class, PacketParticleEffectToServer.class, 3, Side.SERVER);
    network.registerMessage(PacketSpellToServer.Handler.class, PacketSpellToServer.class, 4, Side.SERVER);
    network.registerMessage(PacketSetClasse.Handler.class, PacketSetClasse.class, 5, Side.SERVER);
    network.registerMessage(PacketExpToClient.Handler.class, PacketExpToClient.class, 6, Side.CLIENT);
    network.registerMessage(PacketTeamToClient.Handler.class, PacketTeamToClient.class, 7, Side.CLIENT);
    network.registerMessage(PacketTeamToServer.Handler.class, PacketTeamToServer.class, 8, Side.SERVER);
    network.registerMessage(PacketLevel.Handler.class, PacketLevel.class, 9, Side.CLIENT);
    network.registerMessage(PacketGameStart.Handler.class, PacketGameStart.class, 10, Side.CLIENT);
    network.registerMessage(PacketGameStop.Handler.class, PacketGameStop.class, 11, Side.CLIENT);
    network.registerMessage(PacketTogglePvp.Handler.class, PacketTogglePvp.class, 12, Side.CLIENT);
    network.registerMessage(PacketBorders.Handler.class, PacketBorders.class, 13, Side.CLIENT);
    network.registerMessage(PacketSetRace.Handler.class, PacketSetRace.class, 14, Side.SERVER);
}
项目:TRHS_Club_Mod_2016    文件:FMLNetworkHandler.java   
public static String checkModList(Map<String,String> listData, Side side)
{
    List<ModContainer> rejects = Lists.newArrayList();
    for (Entry<ModContainer, NetworkModHolder> networkMod : NetworkRegistry.INSTANCE.registry().entrySet())
    {
        boolean result = networkMod.getValue().check(listData, side);
        if (!result)
        {
            rejects.add(networkMod.getKey());
        }
    }
    if (rejects.isEmpty())
    {
        return null;
    }
    else
    {
        FMLLog.info("Rejecting connection %s: %s", side, rejects);
        return String.format("Mod rejections %s",rejects);
    }
}
项目:VivecraftForgeExtensions    文件:VivecraftForgePacketHandler.java   
@Override
protected void channelRead0(ChannelHandlerContext ctx, IPacket msg) throws Exception {
    INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
    EntityPlayer player = VivecraftForge.proxy.getPlayerFromNetHandler(netHandler);

    switch (FMLCommonHandler.instance().getEffectiveSide()) {
        case CLIENT:
            msg.handleClient(player);
            break;
        case SERVER:
            msg.handleServer(player);
            break;
        default:
            VivecraftForgeLog.severe("Impossible scenario encountered! Effective side is neither server nor client!");
            break;
    }
}
项目:Avaritiaddons    文件:CommonProxy.java   
public void preInit()
{
    GameRegistry.registerBlock(BlockCompressedChest.instance, ItemBlockAvaritiaddonsChest.class, "CompressedChest");
    GameRegistry.registerBlock(BlockInfinityChest.instance, ItemBlockAvaritiaddonsChest.class, "InfinityChest");
    GameRegistry.registerBlock(BlockExtremeAutoCrafter.instance, "ExtremeAutoCrafter");
    GameRegistry.registerTileEntity(TileEntityCompressedChest.class, "Avaritiaddons:CompressedChest");
    GameRegistry.registerTileEntity(TileEntityInfinityChest.class, "Avaritiaddons:InfinityChest");
    GameRegistry.registerTileEntity(TileEntityExtremeAutoCrafter.class, "Avaritiaddons:ExtremeAutoCrafter");
    NetworkRegistry.INSTANCE.registerGuiHandler(Avaritiaddons.instance, GuiHandler.instance);
    networkWrapper.registerMessage(InfinityChestSlotSync.Handler.class, InfinityChestSlotSync.class, 0, Side.SERVER);
    networkWrapper.registerMessage(InfinityChestSlotSync.Handler.class, InfinityChestSlotSync.class, 1, Side.CLIENT);
    networkWrapper.registerMessage(InfinityChestClick.Handler.class, InfinityChestClick.class, 2, Side.SERVER);
    networkWrapper.registerMessage(InfinityChestClick.Handler.class, InfinityChestClick.class, 3, Side.CLIENT);
    networkWrapper.registerMessage(InfinityChestConfirmation.Handler.class, InfinityChestConfirmation.class, 4, Side.SERVER);
    networkWrapper.registerMessage(InfinityChestConfirmation.Handler.class, InfinityChestConfirmation.class, 5, Side.CLIENT);
    networkWrapper.registerMessage(InfinityChestSyncAllSlots.Handler.class, InfinityChestSyncAllSlots.class, 6, Side.SERVER);
    networkWrapper.registerMessage(InfinityChestSyncAllSlots.Handler.class, InfinityChestSyncAllSlots.class, 7, Side.CLIENT);
}
项目:PrimitiveCraft    文件:PrimitiveCraft.java   
@Mod.EventHandler
public void init(FMLInitializationEvent event)
{
    //Load Mod Items
    ModItems.init();
    //Load Mod Blocks
    ModBlocks.init();
    //Load Mod Recipes
    ModRecipes.init();
    //Register Renders on client side
    proxy.initRenders();
    //Register GuiHandler
    NetworkRegistry.INSTANCE.registerGuiHandler(INSTANCE, new GuiHandler());
    //Register Mod Compat
    CompatHandler.init(event);
    //Register Leave drops
    MinecraftForge.EVENT_BUS.register(EventDrops.instancemain);
    //Register Mod World Gen
    ModWorldGen.init();
}
项目:DartCraft2    文件:DartCraft2.java   
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
    try {
        ConfigRegistry.registerConfig(new Config());
    } catch (ConfigException e) {
        e.printStackTrace();
    }
    NETWORK = NetworkRegistry.INSTANCE.newSimpleChannel("dartcraft2");
    proxy.registerPackets();
    GameRegistry.registerWorldGenerator(new WorldGenPowerOre(), 1);
    ModFluids.init();
    ModBlocks.init();
    ModItems.init();
    try {
        prepareAPI();
    } catch (FailedAPIRequest failedAPIRequest) {
        failedAPIRequest.printStackTrace();
        LOGGER.warn("Did another mod mess with the API?");
    }
}
项目:Coding    文件:Core.java   
private void setupNetwork() {
    NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());

    modChannel = NetworkRegistry.INSTANCE.newSimpleChannel(REFERENCE.MODID);

    int id = 0;
    modChannel.registerMessage(DragonPlayerUpdateLevel.Handler.class, DragonPlayerUpdateLevel.class, id++, Side.CLIENT);
    modChannel.registerMessage(DragonPlayerUpdateIsDragon.Handler.class, DragonPlayerUpdateIsDragon.class, id++, Side.CLIENT);
    modChannel.registerMessage(DragonPlayerUpdateDragonName.Handler.class, DragonPlayerUpdateDragonName.class, id++, Side.CLIENT);
    modChannel.registerMessage(StaffUpdateSetTargetOnFire.Handler.class, StaffUpdateSetTargetOnFire.class, id++, Side.SERVER);
    modChannel.registerMessage(StaffUpdateDamageTarget.Handler.class, StaffUpdateDamageTarget.class, id++, Side.SERVER);
    modChannel.registerMessage(StaffUpdateWitherTarget.Handler.class, StaffUpdateWitherTarget.class, id++, Side.SERVER);
    modChannel.registerMessage(StaffUpdatePoisonTarget.Handler.class, StaffUpdatePoisonTarget.class, id++, Side.SERVER);
    modChannel.registerMessage(DragonAbilityLavaToObsidian.Handler.class, DragonAbilityLavaToObsidian.class, id++, Side.CLIENT);
    modChannel.registerMessage(StaffUpdateTeleportThroughWall.Handler.class, StaffUpdateTeleportThroughWall.class, id++, Side.SERVER);
    modChannel.registerMessage(StaffUpdateTeleportThroughWallInDark.Handler.class, StaffUpdateTeleportThroughWallInDark.class, id++, Side.SERVER);
    modChannel.registerMessage(StaffUpdateDropEntity.Handler.class, StaffUpdateDropEntity.class, id++, Side.SERVER);
    modChannel.registerMessage(StaffUpdateMountEntity.Handler.class, StaffUpdateMountEntity.class, id++, Side.SERVER);
    modChannel.registerMessage(StaffUpdateDestroyBlock.Handler.class, StaffUpdateDestroyBlock.class, id++, Side.SERVER);
}
项目:KinetiCraft2-1.7.10-wip    文件:CommonProxy.java   
public void preInit() {
    /* Network stuff */
    CommonPacketHandler.init();

    /* Items */
    KinetiCraft2Items.init();

    /* Blocks */
    KinetiCraft2Blocks.init();

    /* Tile Entities */
    KinectiCraft2TileEntities.init();

    /* GUI */
    NetworkRegistry.INSTANCE.registerGuiHandler(KinetiCraft2.instance, new KC2GuiHandler());
}
项目:KinetiCraft2-1.7.10-wip    文件:KC2TileEntityBase.java   
private void sendUpdatePacket() {
    if(this.worldObj.isRemote) { return; }
    if(this.worldObj.playerEntities.size() <= 0) {
        //LogHelper.info("Returning. No players here!");
        return;
    }

    CommonPacketHandler.INSTANCE.sendToAllAround(getUpdatePacket(), new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 50));

    for(EntityPlayer player : (List<EntityPlayer>)this.worldObj.playerEntities) {
        // Send update if player is within a certain range
        if (player.getDistanceSq((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D) <= 128D) {
            //LogHelper.info("UPDATE SENT.");
            CommonPacketHandler.INSTANCE.sendTo(getUpdatePacket(), (EntityPlayerMP)player);
        }
    }
    /*
    if(this.worldObj.isRemote) { return; }
    if(this.updatePlayers.size() <= 0) { return; }

    for(EntityPlayer player : updatePlayers) {
        CommonPacketHandler.INSTANCE.sendTo(getUpdatePacket(), (EntityPlayerMP)player);
    }
    */
}
项目:CCFactoryManager    文件:CCFactoryManager.java   
@EventHandler
public void init(FMLInitializationEvent event) {
    PacketHandler.init();
    Recipes.init();

    proxy.registerTileEntities();
    proxy.registerRenderers();

    NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());

    FMLCommonHandler.instance().bus().register(new TickHandler());

    LuaType.registerTypeConverter(new ConverterFluidTankInfo());
    LuaType.registerTypeConverter(new ConverterForgeDirection());
    LuaType.registerTypeConverter(new ConverterAdvancedItemStack());

    LuaType.registerClassToNameMapping(FluidTankInfo.class, "fluid_tank");
    LuaType.registerClassToNameMapping(ForgeDirection.class, "direction");
    LuaType.registerClassToNameMapping(AdvancedItemStack.class, "item_with_nbt");

}
项目:CauldronGit    文件:FMLNetworkHandler.java   
public static String checkModList(Map<String,String> listData, Side side)
{
    List<ModContainer> rejects = Lists.newArrayList();
    for (Entry<ModContainer, NetworkModHolder> networkMod : NetworkRegistry.INSTANCE.registry().entrySet())
    {
        boolean result = networkMod.getValue().check(listData, side);
        if (!result)
        {
            rejects.add(networkMod.getKey());
        }
    }
    if (rejects.isEmpty())
    {
        return null;
    }
    else
    {
        FMLLog.info("Rejecting connection %s: %s", side, rejects);
        return String.format("Mod rejections %s",rejects);
    }
}
项目:M4thThings    文件:TileQuantumTank.java   
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
{
    if (isValveDirection(from))
    {
        FluidStack toReturn = tank.drain(maxDrain,doDrain);

        if (doDrain && Configurations.ENABLE_TANK_PARTICLES && toReturn.amount > 0)
        {
            ModPackets.INSTANCE.sendToAllAround(new PacketFilling(xCoord,yCoord,zCoord, MiscHelper.getDirectionInteger(from),0, FluidRegistry.getFluidName(toReturn),toReturn.amount,tankSize), new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId,xCoord,yCoord,zCoord,32));
        }

        if (doDrain)
        {
            prepareSync();
        }

        return toReturn;
    }

    return null;
}
项目:roadstuff    文件:RoadStuff.java   
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
    logger = event.getModLog();

    config = new Configuration(event.getSuggestedConfigurationFile());
    RoadStuffConfig.syncConfig();

    RoadStuffBlocks.initBlocks();
    RoadStuffItems.initItems();
    GameRegistry.registerWorldGenerator(oreGen, 0);

    RoadStuffAchievements.initAchievements();

    network = NetworkRegistry.INSTANCE.newSimpleChannel(MODID);
    network.registerMessage(PacketSignType.Handler.class, PacketSignType.class, 0, Side.SERVER);

    if(Loader.isModLoaded("chisel"))
    {
        Chisel.sendIMC();
    }
}
项目:Gadomancy    文件:TileEssentiaCompressor.java   
private boolean doDrain(Aspect a, List<WorldCoordinates> coordinates) {
    for (WorldCoordinates coordinate : coordinates) {
        TileEntity sourceTile = worldObj.getTileEntity(coordinate.x, coordinate.y, coordinate.z);
        if ((sourceTile == null) || (!(sourceTile instanceof IAspectSource))) {
            continue;
        }
        if(sourceTile instanceof TileEssentiaCompressor) continue;
        IAspectSource as = (IAspectSource)sourceTile;
        AspectList contains = as.getAspects();
        if(contains == null || contains.visSize() > al.visSize()) continue;
        if(!canAccept(a)) continue;
        if (as.takeFromContainer(a, 1)) {
            PacketHandler.INSTANCE.sendToAllAround(new PacketFXEssentiaSource(xCoord, yCoord + 1, zCoord,
                    (byte)(xCoord - coordinate.x), (byte)(yCoord - coordinate.y + 1), (byte)(zCoord - coordinate.z),
                    a.getColor()), new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord + 1, zCoord, 32.0D));
            return true;
        }
    }
    return false;
}
项目:HardcoreWither    文件:HardcoreWither.java   
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event)
{
   logger.info(TextHelper.localize("info." + ModInformation.ID + ".console.load.preInit"));

   ConfigManager.getInstance().init(event.getModConfigurationDirectory());

   powerUpManager.init();
   ItemRegistry.registerItems();
   BlockRegistry.registerBlocks();
   PotionRegistry.registerPotions();
   EntityRegistry.register();

   FMLCommonHandler.instance().bus().register(eventHandler);
   NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
}
项目:Thallus    文件:Thallus.java   
@Mod.EventHandler
public void init(FMLInitializationEvent event)
{
    // Register the GUI Handler
    NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());

    // Register the Achievement Handler
    FMLCommonHandler.instance().bus().register(new AchievementHandler());

    // Initialize mod tile entities
    TileEntities.init();

    // Initialize event handlers
    proxy.registerEventHandlers();

    // Initialize mod recipes
    Recipes.init();

    // Register the Waila data provider
    // FMLInterModComms.sendMessage("Waila", "register", "com.kithio.thallus.waila.WailaDataProvider.callbackRegister");
}
项目:amunra    文件:ARPacketHandler.java   
@Override
protected void channelRead0(ChannelHandlerContext ctx, IPacket msg) throws Exception
{
    INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
    //this should work
    // EntityPlayer player = getPlayerFromNetHandler(netHandler);
    EntityPlayer player = GalacticraftCore.proxy.getPlayerFromNetHandler(netHandler);

    switch (FMLCommonHandler.instance().getEffectiveSide())
    {
    case CLIENT:
        msg.handleClientSide(player);
        break;
    case SERVER:
        msg.handleServerSide(player);
        break;
    default:
        break;
    }
}
项目:vsminecraft    文件:MekanismGenerators.java   
@EventHandler
public void init(FMLInitializationEvent event)
{
    //Add this module to the core list
    Mekanism.modulesLoaded.add(this);

    packetHandler.initialize();

    //Set up the GUI handler
    NetworkRegistry.INSTANCE.registerGuiHandler(this, new GeneratorsGuiHandler());
    FMLCommonHandler.instance().bus().register(this);

    //Load the proxy
    proxy.loadConfiguration();
    proxy.registerRegularTileEntities();
    proxy.registerSpecialTileEntities();
    proxy.registerRenderInformation();

    addRecipes();

    //Finalization
    Mekanism.logger.info("Loaded MekanismGenerators module.");
}
项目:minecraft-quiverbow    文件:PacketHandler.java   
public static void initPackets()
{
    net = NetworkRegistry.INSTANCE.newSimpleChannel("quiverchevsky".toUpperCase());

    registerMessage(ParticlePacket.class, ParticleMessage.class);
    registerMessage(PositionPacket.class, PositionMessage.class);
    registerMessage(KickbackPacket.class, KickbackMessage.class);
    registerMessage(TurretInventoryPacket.class, TurretInventoryMessage.class);
    registerMessage(TurretStatePacket.class, TurretStateMessage.class);
}
项目:Technical    文件:Technical.java   
@Mod.EventHandler
public void init(FMLInitializationEvent event) {
    proxy.registerNetworkStuff();
    NetworkRegistry.INSTANCE.registerGuiHandler(this, new TechnicalGuiHandler());
    TechnicalItem.removeVanillaRecipes();
    Recipes.init();
    FMLCommonHandler.instance().bus().register(new EventListener());
    radioactivityPotion = (new PotionTechnical(radioactivityPotionId, true, 0)).setIconIndex(0, 0).setPotionName("potion.radioactivityPotion");
    TechnicalAchievement.init();
    AchievementPage.registerAchievementPage(technicalAchievementPage);
}
项目:OpenSensors    文件:OpenSensors.java   
@EventHandler
public void init(FMLInitializationEvent event) {
    long time = System.nanoTime();
    ContentRegistry.init();
    FMLCommonHandler.instance().bus().register(this);
    NetworkRegistry.INSTANCE.registerGuiHandler(OpenSensors.instance, new GUIHandler());
    logger.info("Finished init in %d ms", (System.nanoTime() - time) / 1000000);
}
项目:EnhancedLootBags    文件:EnhancedLootBags.java   
@EventHandler
public void init( FMLInitializationEvent event )
{
    FMLCommonHandler.instance().bus().register( AdminLogonErrors );
    FMLCommonHandler.instance().bus().register( LootGroupHandler );
    MinecraftForge.EVENT_BUS.register( LootGroupHandler );
    NetworkRegistry.INSTANCE.registerGuiHandler( this, new GuiHandler() );
}
项目:4Space-5    文件:GalacticraftChannelHandler.java   
/**
 * Send this message to everyone within a certain range of a point.
 * <p/>
 * Adapted from CPW's code in
 * cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
 *
 * @param message The message to send
 * @param point   The
 *                {@link cpw.mods.fml.common.network.NetworkRegistry.TargetPoint}
 *                around which to send
 */
public void sendToAllAround(IPacket message, NetworkRegistry.TargetPoint point)
{
    try {
     this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT);
     this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(point);
     this.channels.get(Side.SERVER).writeOutbound(message);
    } catch (Exception e)
    {
        GCLog.severe("Forge error when sending network packet to nearby players - this is not a Galacticraft bug, does another mod make fake players?");
        e.printStackTrace();
    }
}
项目:4Space-5    文件:GalacticraftCore.java   
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
    isPlanetsLoaded = Loader.isModLoaded(Constants.MOD_ID_PLANETS);
    GCCoreUtil.nextID = 0;

    MinecraftForge.EVENT_BUS.register(new EventHandlerGC());
    handler = new GCPlayerHandler();
    MinecraftForge.EVENT_BUS.register(handler);
    FMLCommonHandler.instance().bus().register(handler);
    GalacticraftCore.proxy.preInit(event);

    ConnectionPacket.bus = NetworkRegistry.INSTANCE.newEventDrivenChannel(ConnectionPacket.CHANNEL);
    ConnectionPacket.bus.register(new ConnectionPacket());

    ConfigManagerCore.initialize(new File(event.getModConfigurationDirectory(), GalacticraftCore.CONFIG_FILE));
    EnergyConfigHandler.setDefaultValues(new File(event.getModConfigurationDirectory(), GalacticraftCore.POWER_CONFIG_FILE));
    ChunkLoadingCallback.loadConfig(new File(event.getModConfigurationDirectory(), GalacticraftCore.CHUNKLOADER_CONFIG_FILE));

    this.registerOilandFuel();

    if (Loader.isModLoaded("PlayerAPI"))
    {
        ServerPlayerAPI.register(Constants.MOD_ID_CORE, GCPlayerBaseMP.class);
    }

    GCBlocks.initBlocks();
    GCItems.initItems();

    //Allow canisters to be filled from other mods' tanks containing fuel / oil fluids
    FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(GalacticraftCore.fluidFuel, 1000), new ItemStack(GCItems.fuelCanister, 1, 1), new ItemStack(GCItems.oilCanister, 1, ItemCanisterGeneric.EMPTY)));
    FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(GalacticraftCore.fluidOil, 1000), new ItemStack(GCItems.oilCanister, 1, 1), new ItemStack(GCItems.oilCanister, 1, ItemCanisterGeneric.EMPTY)));
}
项目:LotrAddonsRings    文件:ProxyCommon.java   
@Mod.EventHandler
public void onInit(FMLInitializationEvent e){
    /*
    REGISTERS ALL COMMON THINGS SO FOR BOTH SERVER AND CLIENT...
     */
    LOTRAddonsItems.registerRings();
    LOTRAddonsBlocks.registerBlocks();
    LOTRAddonsEntities.registerEntities();
    NetworkRegistry.INSTANCE.registerGuiHandler(LOTRAddons.lotrAddons, new GuiHandler());


}
项目:TRHS_Club_Mod_2016    文件:NetworkDispatcher.java   
public NetworkDispatcher(NetworkManager manager)
{
    super(Packet.class, false);
    this.manager = manager;
    this.scm = null;
    this.side = Side.CLIENT;
    this.handshakeChannel = new EmbeddedChannel(new HandshakeInjector(this), new ChannelRegistrationHandler(), new FMLHandshakeCodec(), new HandshakeMessageHandler<FMLHandshakeClientState>(FMLHandshakeClientState.class));
    this.handshakeChannel.attr(FML_DISPATCHER).set(this);
    this.handshakeChannel.attr(NetworkRegistry.CHANNEL_SOURCE).set(Side.SERVER);
    this.handshakeChannel.attr(NetworkRegistry.FML_CHANNEL).set("FML|HS");
    this.handshakeChannel.attr(IS_LOCAL).set(manager.func_150731_c());
}
项目:TRHS_Club_Mod_2016    文件:NetworkDispatcher.java   
public NetworkDispatcher(NetworkManager manager, ServerConfigurationManager scm)
{
    super(Packet.class, false);
    this.manager = manager;
    this.scm = scm;
    this.side = Side.SERVER;
    this.handshakeChannel = new EmbeddedChannel(new HandshakeInjector(this), new ChannelRegistrationHandler(), new FMLHandshakeCodec(), new HandshakeMessageHandler<FMLHandshakeServerState>(FMLHandshakeServerState.class));
    this.handshakeChannel.attr(FML_DISPATCHER).set(this);
    this.handshakeChannel.attr(NetworkRegistry.CHANNEL_SOURCE).set(Side.CLIENT);
    this.handshakeChannel.attr(NetworkRegistry.FML_CHANNEL).set("FML|HS");
    this.handshakeChannel.attr(IS_LOCAL).set(manager.func_150731_c());
}
项目:TRHS_Club_Mod_2016    文件:NetworkDispatcher.java   
private void cleanAttributes(ChannelHandlerContext ctx)
{
    ctx.channel().attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).remove();
    ctx.channel().attr(NetworkRegistry.NET_HANDLER).remove();
    ctx.channel().attr(NetworkDispatcher.FML_DISPATCHER).remove();
    this.handshakeChannel.attr(FML_DISPATCHER).remove();
    this.manager.channel().attr(FML_DISPATCHER).remove();
}
项目:TRHS_Club_Mod_2016    文件:SimpleChannelHandlerWrapper.java   
@Override
protected void channelRead0(ChannelHandlerContext ctx, REQ msg) throws Exception
{
    INetHandler iNetHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
    MessageContext context = new MessageContext(iNetHandler, side);
    REPLY result = messageHandler.onMessage(msg, context);
    if (result != null)
    {
        ctx.channel().attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.REPLY);
        ctx.writeAndFlush(result).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
    }
}
项目:TRHS_Club_Mod_2016    文件:FMLProxyPacket.java   
@Override
public void func_148833_a(INetHandler inethandler)
{
    this.netHandler = inethandler;
    EmbeddedChannel internalChannel = NetworkRegistry.INSTANCE.getChannel(this.channel, this.target);
    if (internalChannel != null)
    {
        internalChannel.attr(NetworkRegistry.NET_HANDLER).set(this.netHandler);
        try
        {
            if (internalChannel.writeInbound(this))
            {
                badPackets.add(this.channel);
                if (badPackets.size() % packetCountWarning == 0)
                {
                    FMLLog.severe("Detected ongoing potential memory leak. %d packets have leaked. Top offenders", badPackets.size());
                    int i = 0;
                    for (Entry<String> s  : Multisets.copyHighestCountFirst(badPackets).entrySet())
                    {
                        if (i++ > 10) break;
                        FMLLog.severe("\t %s : %d", s.getElement(), s.getCount());
                    }
                }
            }
            internalChannel.inboundMessages().clear();
        }
        catch (FMLNetworkException ne)
        {
            FMLLog.log(Level.ERROR, ne, "There was a network exception handling a packet on channel %s", channel);
            dispatcher.rejectHandshake(ne.getMessage());
        }
        catch (Throwable t)
        {
            FMLLog.log(Level.ERROR, t, "There was a critical exception handling a packet on channel %s", channel);
            dispatcher.rejectHandshake("A fatal error has occured, this connection is terminated");
        }
    }
}
项目:TRHS_Club_Mod_2016    文件:FMLNetworkHandler.java   
public static void registerChannel(FMLContainer container, Side side)
{
    channelPair = NetworkRegistry.INSTANCE.newChannel(container, "FML", new FMLRuntimeCodec(), new HandshakeCompletionHandler());
    EmbeddedChannel embeddedChannel = channelPair.get(Side.SERVER);
    embeddedChannel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.NOWHERE);

    if (side == Side.CLIENT)
    {
        addClientHandlers();
    }
}
项目:TRHS_Club_Mod_2016    文件:ForgeNetworkHandler.java   
public static void registerChannel(ForgeModContainer forgeModContainer, Side side)
{
    channelPair = NetworkRegistry.INSTANCE.newChannel(forgeModContainer, "FORGE", new ForgeRuntimeCodec());
    if (side == Side.CLIENT)
    {
        addClientHandlers();
    }

    FMLEmbeddedChannel serverChannel = channelPair.get(Side.SERVER);
    serverChannel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.NOWHERE);
    String handlerName = serverChannel.findChannelHandlerNameForType(ForgeRuntimeCodec.class);
    serverChannel.pipeline().addAfter(handlerName, "ServerToClientConnection", new ServerToClientConnectionEstablishedHandler());
}
项目:Age-of-Kingdom    文件:AgeOfKingdom.java   
@EventHandler
public void init(FMLInitializationEvent event) {
    NetworkRegistry.INSTANCE.registerGuiHandler(INSTANCE, serverProxy);
    GameRegistry.registerWorldGenerator(blockGenerator, 0);

    serverProxy.init(event);
    blockManager.init(event);
    itemManager.init(event);
    eventManager.init(event);
    entityManager.init(event);
    questManager.init(event);
    PlayerAokIEEP.init();
}
项目:OpenTeleporter    文件:CommonProxy.java   
public void init(FMLInitializationEvent e) {
    wrapper = NetworkRegistry.INSTANCE.newSimpleChannel("OpenTeleporter");
    GameRegistry.registerBlock(new BlockTeleporter(), "Teleporter");
    GameRegistry.registerTileEntity(TileEntityTeleporter.class, "TileEntityTeleporter");

    wrapper.registerMessage(PacketPlayerPosition.Handler.class, PacketPlayerPosition.class, 0, Side.CLIENT);
    wrapper.registerMessage(PacketTeleporter.Handler.class, PacketTeleporter.class, 1, Side.CLIENT);
}