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

项目:CustomWorldGen    文件: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);
    }
}
项目:CustomWorldGen    文件:NetworkDispatcher.java   
public void serverToClientHandshake(EntityPlayerMP player)
{
    this.player = player;
    Boolean fml = this.manager.channel().attr(NetworkRegistry.FML_MARKER).get();
    if (fml != null && fml)
    {
        //FML on client, send server hello
        //TODO: Make this cleaner as it uses netty magic 0.o
        insertIntoChannel();
    }
    else
    {
        serverInitiateHandshake();
        FMLLog.info("Connection received without FML marker, assuming vanilla.");
        this.completeServerSideConnection(ConnectionType.VANILLA);
    }
}
项目:CustomWorldGen    文件:EntitySpawnHandler.java   
@Override
protected void channelRead0(ChannelHandlerContext ctx, final EntityMessage msg) throws Exception
{
    IThreadListener thread = FMLCommonHandler.instance().getWorldThread(ctx.channel().attr(NetworkRegistry.NET_HANDLER).get());
    if (thread.isCallingFromMinecraftThread())
    {
        process(msg);
    }
    else
    {
        thread.addScheduledTask(new Runnable()
        {
            public void run()
            {
                EntitySpawnHandler.this.process(msg);
            }
        });
    }
}
项目:ExSartagine    文件:ExSartagine.java   
@EventHandler
public void preInit(FMLPreInitializationEvent event){
    ModMetadata modMeta = event.getModMetadata();
    modMeta.authorList = Arrays.asList(new String[] { "Subaraki" });
    modMeta.autogenerated = false;
    modMeta.credits = "";
    modMeta.description = "Thermo Efficient Pots and Pans";
    modMeta.url = "https://github.com/ArtixAllMighty/ExSartagine/wiki";

    instance = this;

    ExSartagineBlock.load();
    ExSartagineItems.load();

    proxy.registerTileEntityAndRenderer();
    proxy.registerRenders();

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

    new Recipes();

}
项目:harshencastle    文件:HarshenNetwork.java   
public static void preInit()
{
    INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(HarshenCastle.MODID);
    registerMessage(MessagePacketPlayerHasAccess.class, Side.CLIENT);
    registerMessage(MessagePacketTileEntityBloodPlacerUpdated.class, Side.CLIENT);
    registerMessage(MessagePacketOpenInv.class, Side.SERVER);
    registerMessage(MessageSendPlayerInvToClient.class, Side.CLIENT);
    registerMessage(MessagePacketPlayerTeleportEffects.class, Side.CLIENT);
    registerMessage(MessagePacketRingUpdate.class, Side.SERVER);
    registerMessage(MessagePacketSetItemInSlot.class, Side.CLIENT);
    registerMessage(MessagePacketUpdateXrayBlock.class, Side.SERVER);
    registerMessage(MessagePacketSummonFirework.class, Side.SERVER);
    registerMessage(MessagePacketRequestInv.class, Side.SERVER);
    registerMessage(MessagePacketSpawnItemParticles.class, Side.CLIENT);
    registerMessage(MessagePacketSpawnBloodParticle.class, Side.CLIENT);
    registerMessage(MessagePacketKillAllWithTag.class, Side.CLIENT);
    registerMessage(MessagePacketHitWithRange.class, Side.SERVER);
    registerMessage(MessagePacketReviveInventory.class, Side.CLIENT);
    registerMessage(MessagePacketUpdateComplexEntity.class, Side.CLIENT);
    registerMessage(MessagePacketUpdateCauldron.class, Side.CLIENT);
    registerMessage(MessagePacketForceCauldronUpdate.class, Side.CLIENT);
    registerMessage(MessagePacketForceCauldronUpdate.class, Side.SERVER);
}
项目:Infernum    文件:SpellSoulDrain.java   
@Override
public void onCastTick(World world, EntityPlayer player, ItemStack stack) {
    if (!world.isRemote) {
        BlockPos centerPos = player.getPosition();
        AxisAlignedBB area = new AxisAlignedBB(centerPos).expandXyz(3F);
        for (Entity entity : world.getEntitiesWithinAABBExcludingEntity(player, area)) {
            if (entity instanceof EntityLivingBase) {
                WorldServer worldServer = (WorldServer) world;
                if (player.getItemInUseCount() % 10 == 0 && consumePower(player)) {
                    MessageSoulDrainFX message = new MessageSoulDrainFX(entity.posX,
                            entity.posY + (entity.height / 2.0F), entity.posZ, player.posX,
                            player.posY + (player.height / 2.0F), player.posZ);
                    PacketHandler.INSTANCE.sendToAllAround(message, new NetworkRegistry.TargetPoint(
                            player.dimension, player.posX, player.posY, player.posZ, 128));
                    entity.attackEntityFrom(DamageSource.magic, 1);
                    world.spawnEntity(new EntityXPOrb(world, entity.posX, entity.posY + 0.5, entity.posZ, 1));
                }
            }
        }
    }
}
项目:CustomWorldGen    文件:FMLProxyPacket.java   
/**
 * Passes this Packet on to the NetHandler for processing.
 */
@Override
public void processPacket(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 occurred, this connection is terminated");
        }
    }
}
项目:Randores2    文件:Randores.java   
@Mod.EventHandler
public void onInit(FMLInitializationEvent ev) {
    info("Randores is Initializing...",
            "Sending handler message to WAILA.");
    FMLInterModComms.sendMessage("waila", "register", "com.gmail.socraticphoenix.randores.waila.RandoresWailaHandler.callbackRegister");
    if (Loader.isModLoaded("waila")) {
        info("WAILA was found and should have receieved the handler message.");
    } else {
        info("WAILA wasn't found. The handler message will be ignored.");
    }

    info("Registering up GUI handler and world generators...");
    NetworkRegistry.INSTANCE.registerGuiHandler(this, new RandoresGuiHandler());
    GameRegistry.registerWorldGenerator(new RandoresWorldGenerator(), 10);
    GameRegistry.registerWorldGenerator(new RandoresAltarGenerator(), -100);
    info("Registered GUI hander and world generators.", "Calling proxy Initialization...");
    Randores.PROXY.initSided(ev);
    info("Finished Initialization.");
}
项目:interactionwheel    文件:CommonProxy.java   
public void init(FMLInitializationEvent e) {
        MinecraftForge.EVENT_BUS.register(new ForgeEventHandlers());
        NetworkRegistry.INSTANCE.registerGuiHandler(InteractionWheel.instance, new GuiProxy());

        InteractionWheel.registry.register(new RotateBlockAction());
        InteractionWheel.registry.register(new SearchWheelAction());
        InteractionWheel.registry.register(new DumpWheelAction());
        InteractionWheel.registry.register(new Dump1WheelAction());
        InteractionWheel.registry.register(new DumpSimilarWheelAction());
        InteractionWheel.registry.register(new DumpSimilarInventoryAction());
        InteractionWheel.registry.register(new DumpOresAction());
        InteractionWheel.registry.register(new DumpBlocksAction());
        InteractionWheel.registry.register(new ExtractWheelAction());
        InteractionWheel.registry.register(new PickToolWheelAction());
//        for (int i = 0 ; i < 30 ; i++) {
//            InteractionWheel.registry.register(new DummyWheelAction("std.dummy" + i));
//        }
    }
项目:Never-Enough-Currency    文件:Currency.java   
@EventHandler
public void init(FMLInitializationEvent event) {
    proxy.init(event);

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

    AccountCapability.register();
    CartCapability.register();

    PacketDispatcher.registerPackets();

    FMLInterModComms.sendMessage("waila", "register", "com.zundrel.currency.common.compat.waila.CurrencyWailaProvider.callbackRegister");

    GameRegistry.registerTileEntity(TileEntityShopController.class, ModInfo.MODID + ":" + "shop_controller");
    GameRegistry.registerTileEntity(TileEntityDisplay.class, ModInfo.MODID + ":" + "display");
    GameRegistry.registerTileEntity(TileEntityStockCrate.class, ModInfo.MODID + ":" + "stock_crate");
}
项目:CustomWorldGen    文件:OpenGuiHandler.java   
@Override
protected void channelRead0(ChannelHandlerContext ctx, final OpenGui msg) throws Exception
{
    IThreadListener thread = FMLCommonHandler.instance().getWorldThread(ctx.channel().attr(NetworkRegistry.NET_HANDLER).get());
    if (thread.isCallingFromMinecraftThread())
    {
        process(msg);
    }
    else
    {
        thread.addScheduledTask(new Runnable()
        {
            public void run()
            {
                OpenGuiHandler.this.process(msg);
            }
        });
    }
}
项目:PurificatiMagicae    文件:NetworkManager.java   
public static void setup()
{
    NetworkRegistry.INSTANCE.registerGuiHandler(PurMag.INSTANCE, new GuiHandler());

    INSTANCE.registerMessage(CPacketSyncEntryStore.Handler.class, CPacketSyncEntryStore.class, id++, Side.CLIENT);
    INSTANCE.registerMessage(CPacketDisplayMessage.Handler.class, CPacketDisplayMessage.class, id++, Side.CLIENT);
    INSTANCE.registerMessage(CPacketSyncSif.Handler.class, CPacketSyncSif.class, id++, Side.CLIENT);
    INSTANCE.registerMessage(CPacketDesyncSif.Handler.class, CPacketDesyncSif.class, id++, Side.CLIENT);
    INSTANCE.registerMessage(SPacketUseSipAmulet.Handler.class, SPacketUseSipAmulet.class, id++, Side.SERVER);
    INSTANCE.registerMessage(CPacketSpawnSipParticle.Handler.class, CPacketSpawnSipParticle.class, id++, Side.CLIENT);
    INSTANCE.registerMessage(SPacketDoneTranslation.Handler.class, SPacketDoneTranslation.class, id++, Side.SERVER);
    INSTANCE.registerMessage(CPacketSpawnParticle.Handler.class, CPacketSpawnParticle.class, id++, Side.CLIENT);
    INSTANCE.registerMessage(CPacketSyncAura.Handler.class, CPacketSyncAura.class, id++, Side.CLIENT);
    INSTANCE.registerMessage(SPacketLock.Handler.class, SPacketLock.class, id++, Side.SERVER);
    INSTANCE.registerMessage(SPacketUnlock.Handler.class, SPacketUnlock.class, id++, Side.SERVER);
    INSTANCE.registerMessage(CPacketUnlockResponse.Handler.class, CPacketUnlockResponse.class, id++, Side.CLIENT);
    INSTANCE.registerMessage(SPacketCheckMicroscopeResearch.Handler.class, SPacketCheckMicroscopeResearch.class, id++, Side.SERVER);
    INSTANCE.registerMessage(CPacketCheckMicroscopeResearchResponse.Handler.class, CPacketCheckMicroscopeResearchResponse.class, id++, Side.CLIENT);
    INSTANCE.registerMessage(CPacketSpawnMultiblockParticles.Handler.class, CPacketSpawnMultiblockParticles.class, id++, Side.CLIENT);
}
项目:FirstAid    文件:FirstAid.java   
@Mod.EventHandler
public void init(FMLInitializationEvent event) {
    CapabilityExtendedHealthSystem.register();

    int i = 0;
    NETWORKING = NetworkRegistry.INSTANCE.newSimpleChannel(MODID);
    NETWORKING.registerMessage(MessageReceiveDamage.Handler.class, MessageReceiveDamage.class, ++i, Side.CLIENT);
    NETWORKING.registerMessage(MessageApplyHealingItem.Handler.class, MessageApplyHealingItem.class, ++i , Side.SERVER);
    NETWORKING.registerMessage(MessageReceiveConfiguration.Handler.class, MessageReceiveConfiguration.class, ++i, Side.CLIENT);
    NETWORKING.registerMessage(MessageApplyAbsorption.Handler.class, MessageApplyAbsorption.class, ++i, Side.CLIENT);
    NETWORKING.registerMessage(MessageAddHealth.Handler.class, MessageAddHealth.class, ++i, Side.CLIENT);
    NETWORKING.registerMessage(MessagePlayHurtSound.Handler.class, MessagePlayHurtSound.class, ++i, Side.CLIENT);
    NETWORKING.registerMessage(MessageClientUpdate.Handler.class, MessageClientUpdate.class, ++i, Side.SERVER);
    NETWORKING.registerMessage(MessageResync.Handler.class, MessageResync.class, ++i, Side.CLIENT);
    MessageReceiveConfiguration.validate();

    if (Loader.isModLoaded("morpheus")) {
        enableMorpheusCompat = true;
        logger.info("Morpheus present - enabling compatibility module");
        MorpheusHelper.register();
    }

    RegistryManager.registerDefaults();
    checkEarlyExit();
}
项目:GlobalXP    文件:XPBlock.java   
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
    if(worldIn.isRemote || !stack.hasTagCompound())
        return;

    TileEntity te = worldIn.getTileEntity(pos);

    if(te instanceof TileEntityXPBlock)
    {
        NBTTagCompound tag = stack.getTagCompound().getCompoundTag("BlockEntityTag");

        tag.setInteger("x", pos.getX());
        tag.setInteger("y", pos.getY());
        tag.setInteger("z", pos.getZ());
        ((TileEntityXPBlock)te).readFromNBT(tag);
        ((TileEntityXPBlock)te).markDirty();
        GlobalXP.network.sendToAllAround(new SPacketUpdateXPBlock((TileEntityXPBlock)te), new NetworkRegistry.TargetPoint(worldIn.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), 64));
    }
}
项目:DebugServerInfo    文件:DebugServerInfo.java   
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
    logger = event.getModLog();

    config = new Configuration(event.getSuggestedConfigurationFile());
    doConfig();

    int id = 1; // Don't use 0, more easy debug.
    snw = NetworkRegistry.INSTANCE.newSimpleChannel(MOD_ID);

    snw.registerMessage(Request.Handler.class, Request.class, id++, Side.SERVER);
    snw.registerMessage(Data.Handler.class, Data.class, id++, Side.CLIENT);

    proxy.preInit();
}
项目:Loot-Slash-Conquer    文件:ModPackets.java   
public static void registerPackets()
{
    LootSlashConquer.network = NetworkRegistry.INSTANCE.newSimpleChannel(Reference.MODID);
    LootSlashConquer.network.registerMessage(PacketClassGui.Handler.class, PacketClassGui.class, 0, Side.CLIENT);
    LootSlashConquer.network.registerMessage(PacketClassSelection.Handler.class, PacketClassSelection.class, 1, Side.SERVER);
    LootSlashConquer.network.registerMessage(PacketUpdatePlayerInformation.Handler.class, PacketUpdatePlayerInformation.class, 2, Side.CLIENT);
    LootSlashConquer.network.registerMessage(PacketUpdateCoreStats.Handler.class, PacketUpdateCoreStats.class, 3, Side.CLIENT);
    LootSlashConquer.network.registerMessage(PacketUpdateIncreaseStat.Handler.class, PacketUpdateIncreaseStat.class, 4, Side.SERVER);
    LootSlashConquer.network.registerMessage(PacketUpdateStats.Handler.class, PacketUpdateStats.class, 5, Side.CLIENT);
    LootSlashConquer.network.registerMessage(PacketUpdateChunkLevel.Handler.class, PacketUpdateChunkLevel.class, 6, Side.CLIENT);
}
项目:pnc-repressurized    文件:PacketHackingEntityStart.java   
@Override
public void handleServerSide(PacketHackingEntityStart message, EntityPlayer player) {
    Entity entity = player.world.getEntityByID(message.entityId);
    if (entity != null) {
        CommonHUDHandler.getHandlerForPlayer(player).setHackedEntity(entity);
        NetworkHandler.sendToAllAround(message, new NetworkRegistry.TargetPoint(entity.world.provider.getDimension(), entity.posX, entity.posY, entity.posZ, 64));
    }
}
项目:pnc-repressurized    文件:EventHandlerPneumaticCraft.java   
/**
 * Used by PneumaticHelmet
 *
 * @param event
 */
@SubscribeEvent
public void onMobTargetSet(LivingSetAttackTargetEvent event) {
    if (event.getEntity() instanceof EntityCreature) {
        if (!event.getEntity().world.isRemote) {
            NetworkHandler.sendToAllAround(
                    new PacketSetMobTarget((EntityCreature) event.getEntity(), event.getTarget()),
                    new NetworkRegistry.TargetPoint(event.getEntity().world.provider.getDimension(),
                            event.getEntity().posX, event.getEntity().posY, event.getEntity().posZ, TileEntityConstants.PACKET_UPDATE_DISTANCE));
        } else {
            warnPlayerIfNecessary(event);
        }
    }
}
项目:Whoosh    文件:Whoosh.java   
@EventHandler
public void preInit(FMLPreInitializationEvent event) {

    CONFIG.setConfiguration(new Configuration(new File(CoreProps.configDir, MOD_ID + "/common.cfg"), true));
    CONFIG_CLIENT.setConfiguration(new Configuration(new File(CoreProps.configDir, MOD_ID + "/client.cfg"), true));

    WProps.preInit();
    WItems.preInit();

    PacketHandler.INSTANCE.registerPacket(PacketWhoosh.class);
    NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());

    proxy.preInit(event);
}
项目:MiningWells    文件:ModPackets.java   
public static final void commonPreinit() {
    network = NetworkRegistry.INSTANCE.newSimpleChannel(ModInfo.MODID);

    network.registerMessage(PacketWellToServer.Handler.class, PacketWellToServer.class, 0, Side.SERVER);
    network.registerMessage(PacketWellToClient.Handler.class, PacketWellToClient.class, 1, Side.CLIENT);

    LogUtils.info("Registered mining well info packets");
}
项目:CustomWorldGen    文件: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();
}
项目:Industrial-Foregoing    文件:CommonProxy.java   
public void preInit(FMLPreInitializationEvent event) {
    IFRegistries.poke();

    CraftingHelper.register(new ResourceLocation(Reference.MOD_ID, "configuration_value"), new ConfigurationConditionFactory());
    random = new Random();

    FluidsRegistry.registerFluids();
    BlockRegistry.poke();

    MinecraftForge.EVENT_BUS.register(new BlockRegistry());
    MinecraftForge.EVENT_BUS.register(new ItemRegistry());
    MinecraftForge.EVENT_BUS.register(new StrawRegistry());
    MinecraftForge.EVENT_BUS.register(new MeatFeederTickHandler());
    MinecraftForge.EVENT_BUS.register(new MobDeathHandler());
    MinecraftForge.EVENT_BUS.register(new WorldTickHandler());
    MinecraftForge.EVENT_BUS.register(new PlantRecollectableRegistryHandler());
    MinecraftForge.EVENT_BUS.register(new FakePlayerRideEntityHandler());
    MinecraftForge.EVENT_BUS.register(new PlantInteractorHarvestDropsHandler());

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

    CustomConfiguration.config = new Configuration(event.getSuggestedConfigurationFile());
    CustomConfiguration.config.load();
    CustomConfiguration.sync();
    CustomConfiguration.configValues = new HashMap<>();
    CustomConfiguration.configValues.put("useTEFrames", CustomConfiguration.config.getBoolean("useTEFrames", Configuration.CATEGORY_GENERAL, true, "Use Thermal Expansion Machine Frames instead of Tesla Core Lib"));

    if (Loader.isModLoaded("crafttweaker")) CraftTweakerHelper.register();

    EntityRegistry.registerModEntity(new ResourceLocation(Reference.MOD_ID, "pink_slime"), EntityPinkSlime.class, "pink_slime", 135135, IndustrialForegoing.instance, 32, 1, false, 10485860, 16777215);
    PINK_SLIME_LOOT = LootTableList.register(new ResourceLocation(Reference.MOD_ID, "entities/pink_slime"));
}
项目:Scripty    文件:ScriptyMod.java   
@EventHandler
public void init(FMLInitializationEvent event) {
    // init
    MinecraftForge.EVENT_BUS.register(this);
    scriptyBlock = new ScriptyBlock();
    if (event.getSide() == Side.CLIENT) {
        RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
        renderItem.getItemModelMesher().register(Item.getItemFromBlock(scriptyBlock), 0, new ModelResourceLocation("scripty:" + scriptyBlock.getName(), "inventory"));
    }
    NetworkRegistry.INSTANCE.registerGuiHandler(this, gui);
}
项目:HardcoreRevival    文件:RescueHandler.java   
public static void finishRescue(EntityPlayer player) {
    IHardcoreRevival revival = player.getCapability(CapabilityHardcoreRevival.REVIVAL_CAPABILITY, null);
    if (revival != null) {
        EntityPlayer target = revival.getRescueTarget();
        if (target != null) {
            MinecraftServer server = target.getServer();
            if (server != null) {
                BlockPos prevSpawnPos = target.getBedLocation(target.dimension);
                boolean prevSpawnForced = target.isSpawnForced(target.dimension);
                target.setSpawnPoint(target.getPosition(), true);
                if (ModConfig.glowOnDeath) {
                    target.setGlowing(false);
                }
                EntityPlayerMP newPlayer = server.getPlayerList().recreatePlayerEntity((EntityPlayerMP) target, target.dimension, false);
                ((EntityPlayerMP) target).connection.player = newPlayer;
                newPlayer.setHealth(1f);
                newPlayer.getFoodStats().setFoodLevel(5);
                newPlayer.addPotionEffect(new PotionEffect(MobEffects.HUNGER, 20 * 30));
                newPlayer.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, 20 * 60));
                newPlayer.inventory.copyInventory(target.inventory);
                newPlayer.experienceLevel = target.experienceLevel;
                newPlayer.experienceTotal = target.experienceTotal;
                newPlayer.experience = target.experience;

                newPlayer.extinguish();
                newPlayer.setFlag(0, false); // burning flag

                newPlayer.setScore(target.getScore());
                newPlayer.setSpawnPoint(prevSpawnPos, prevSpawnForced);
                NetworkHandler.instance.sendToAllAround(new MessageRevivalSuccess(newPlayer.getEntityId()), new NetworkRegistry.TargetPoint(newPlayer.dimension, newPlayer.posX, newPlayer.posY, newPlayer.posZ, 32));
            }
        }
    }
}
项目:ToolBelt    文件:ToolBelt.java   
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
    logger = event.getModLog();

    channel = NetworkRegistry.INSTANCE.newSimpleChannel(CHANNEL);

    int messageNumber = 0;
    channel.registerMessage(SwapItems.Handler.class, SwapItems.class, messageNumber++, Side.SERVER);
    channel.registerMessage(BeltContentsChange.Handler.class, BeltContentsChange.class, messageNumber++, Side.CLIENT);
    logger.debug("Final message number: " + messageNumber);

    File configurationFile = event.getSuggestedConfigurationFile();
    Config.loadConfig(configurationFile);
}
项目:ToolBelt    文件:ToolBelt.java   
@EventHandler
public void init(FMLInitializationEvent event)
{
    proxy.init();

    NetworkRegistry.INSTANCE.registerGuiHandler(this, guiHandler = new GuiHandler());
}
项目:ArcaneMagic    文件:ArcaneMagic.java   
@Mod.EventHandler
public void init(FMLInitializationEvent event)
{
    MinecraftForge.EVENT_BUS.post(
            new Register<Anima>(new ResourceLocation(ArcaneMagic.MODID, "essence_registry"), Anima.REGISTRY));
    NetworkRegistry.INSTANCE.registerGuiHandler(ArcaneMagic.instance, new GuiProxy());
    proxy.init(event);
}
项目:CustomWorldGen    文件: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());
}
项目:Elicitation    文件:Elicitation.java   
@EventHandler
  public void preInit(FMLPreInitializationEvent event)
  {

NetworkRegistry.INSTANCE.registerGuiHandler(Elicitation.instance, new GuiHandler());
Items.setup();
  }
项目:UniversalRemote    文件:OpenGuiFilterServer.java   
private void HandleDataMismatch(OpenGuiWrapper msg, RemoteGuiPlayerData data, EntityPlayerMP player, ChannelHandlerContext ctx)
 {
// sometimes multiblocks trigger UI from another position!
// time to re-issue with the correct information

// however we could be on the networking thread!

    IThreadListener scheduler = FMLCommonHandler.instance().getWorldThread(ctx.channel().attr(NetworkRegistry.NET_HANDLER).get());

     if (!scheduler.isCallingFromMinecraftThread())
     {
        Util.logger.warn("HandleDataMismatch scheduling PrepareReissueRequest!");
         scheduler.addScheduledTask(new Runnable()
         {
             @Override
    public void run()
             {
                PrepareReissueRequest(msg, data, player);
             }
         });

     } else {

        PrepareReissueRequest(msg, data, player);

     }
 }
项目:CustomWorldGen    文件: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);
    }
}
项目:Machines-and-Stuff    文件:BlockCrank.java   
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if(worldIn.isRemote) {
        return true;
    }
    TileEntityCrank tile = (TileEntityCrank) worldIn.getTileEntity(pos);
    if(tile.generationTimerDefault <= 100) {
        tile.generationTimerDefault += 5;
        tile.generationTimer += 5;
        PacketHandler.INSTANCE.sendToAllAround(new MessageCrank(tile), new NetworkRegistry.TargetPoint(worldIn.provider.getDimension(), (double) pos.getX(), (double) pos.getY(), (double) pos.getZ(), 128d));
    }
    return true;
}
项目:Machines-and-Stuff    文件:BlockBaseGenerator.java   
public static void setState(boolean active, World worldIn, BlockPos pos) {
    IBlockState iblockstate = worldIn.getBlockState(pos);
    TileEntity tileentity = worldIn.getTileEntity(pos);
    worldIn.setBlockState(pos, iblockstate.getBlock().getDefaultState().withProperty(FACING, iblockstate.getValue(FACING)).withProperty(isActive, active), 3);

    if(tileentity != null) {
        tileentity.validate();
        worldIn.setTileEntity(pos, tileentity);
        PacketHandler.INSTANCE.sendToAllAround(new MessageGenerator(tileentity), new NetworkRegistry.TargetPoint(worldIn.provider.getDimension(), tileentity.getPos().getX(), tileentity.getPos().getY(), tileentity.getPos().getZ(), 128d));
    }
}
项目:Machines-and-Stuff    文件:BlockMachine.java   
public void setState(boolean active, World worldIn, BlockPos pos) {
    IBlockState iblockstate = worldIn.getBlockState(pos);
    TileEntity tileentity = worldIn.getTileEntity(pos);
    worldIn.setBlockState(pos, getDefaultState().withProperty(FACING, iblockstate.getValue(FACING)).withProperty(isActive, active), 3);
    worldIn.setBlockState(pos, getDefaultState().withProperty(FACING, iblockstate.getValue(FACING)).withProperty(isActive, active), 3);

    if(tileentity != null) {
        tileentity.validate();
        worldIn.setTileEntity(pos, tileentity);
        PacketHandler.INSTANCE.sendToAllAround(new MessageMachineBase((TileEntityMachineBase) tileentity), new NetworkRegistry.TargetPoint(worldIn.provider.getDimension(), (double) tileentity.getPos().getX(), (double) tileentity.getPos().getY(), (double) tileentity.getPos().getZ(), 128d));
    }
}
项目:Machines-and-Stuff    文件:TileEntityCrank.java   
@Override
public void update() {
    boolean sendUpdate = false;
    if(generationTimer < 0) {
        generationTimerDefault = -1;
        generationTimer = -1;
        if(!world.isRemote)
            sendUpdate = true;
    }
    if(container.getStoredPower() > 0)
        if(pushEnergy()) {
            sendUpdate = true;
        }
    if(generationTimerDefault > 0 && this.container.getStoredPower() < this.container.getCapacity()) {
        generationTimer--;
        this.container.givePower(5, false);
        if(!world.isRemote)
            sendUpdate = true;
    }

    if(!world.isRemote) {
        if(sendUpdate) {
            this.markDirty();
            PacketHandler.INSTANCE.sendToAllAround(new MessageCrank(this), new NetworkRegistry.TargetPoint(this.world.provider.getDimension(), (double) this.getPos().getX(), (double) this.getPos().getY(), (double) this.getPos().getZ(), 128d));
            this.world.notifyNeighborsOfStateChange(getPos(), getBlockType(), true);
        }
    }

}
项目:VanillaExtras    文件:PacketHandler.java   
public static void registerMessages(String channelName) {
    NETWORKINSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(channelName);

    NETWORKINSTANCE.registerMessage(PacketGetWorker.Handler.class, PacketGetWorker.class, nextID(), Side.SERVER);

    NETWORKINSTANCE.registerMessage(PacketReturnWorker.Handler.class, PacketReturnWorker.class, nextID(),
            Side.CLIENT);
}
项目:Lithium-Forge    文件:LithiumMod.java   
@SideOnly(Side.CLIENT)
@EventHandler
public void init(FMLInitializationEvent event) {
    overlayRenderer = new LithiumOverlay();
    MinecraftForge.EVENT_BUS.register(NetworkEventHandler.INSTANCE);
    MinecraftForge.EVENT_BUS.register(overlayRenderer);
    network = NetworkRegistry.INSTANCE.newSimpleChannel(LithiumMod.CHANNELNAME);
    Handle.setPacketHandler(new PacketHandlerImpl());
    getSimpleNetworkWrapper().registerMessage(Handle.class, LithiumMessage.class, 0, Side.CLIENT);

}
项目:Proyecto-DASI    文件:MalmoMod.java   
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
    if (!SchemaHelper.testSchemaVersionNumbers(Loader.instance().activeModContainer().getVersion()))
        throw new RuntimeException("This mod has been incorrectly built; check schema version numbers.");

    if (event.getModMetadata().version.equals("${version}"))
    {
        // The mcmod.info version number is populated by gradle; if we've been built without gradle,
        // via eclipse say, then we can just use the internal version number instead, which comes to us from the version.properties file.
        // (There's no real benefit to doing this; it just looks nicer in the Mod GUI if the version number is filled in.)
        event.getModMetadata().version = Loader.instance().activeModContainer().getVersion();
    }
    // Load the correct configs (client or server)
    File configDir = event.getModConfigurationDirectory();
    File sessionConfigFile = new File(configDir, MODID + event.getSide().toString() + ".cfg");
    File permanentConfigFile = new File(configDir, MODID + event.getSide().toString() + "Permanent.cfg");
    this.sessionConfig = new Configuration(sessionConfigFile);
    this.sessionConfig.load();
    this.permanentConfig = new Configuration(permanentConfigFile);
    this.permanentConfig.load();

    AddressHelper.update(this.sessionConfig);
    ScreenHelper.update(this.permanentConfig);

    network = NetworkRegistry.INSTANCE.newSimpleChannel("Malmo");
    network.registerMessage(ObservationFromFullStatsImplementation.FullStatsRequestMessageHandler.class, ObservationFromFullStatsImplementation.FullStatsRequestMessage.class, 1, Side.SERVER);
    network.registerMessage(ObservationFromGridImplementation.GridRequestMessageHandler.class, ObservationFromGridImplementation.GridRequestMessage.class, 2, Side.SERVER);
    network.registerMessage(MalmoMessageHandler.class, MalmoMessage.class, 3, Side.CLIENT); // Malmo messages from server to client
    network.registerMessage(SimpleCraftCommandsImplementation.CraftMessageHandler.class, SimpleCraftCommandsImplementation.CraftMessage.class, 4, Side.SERVER);
    network.registerMessage(AbsoluteMovementCommandsImplementation.TeleportMessageHandler.class, AbsoluteMovementCommandsImplementation.TeleportMessage.class, 5, Side.SERVER);
    network.registerMessage(MalmoMessageHandler.class, MalmoMessage.class, 6, Side.SERVER); // Malmo messages from client to server
    network.registerMessage(InventoryCommandsImplementation.InventoryMessageHandler.class, InventoryCommandsImplementation.InventoryMessage.class, 7, Side.SERVER);
    network.registerMessage(DiscreteMovementCommandsImplementation.UseActionMessageHandler.class, DiscreteMovementCommandsImplementation.UseActionMessage.class, 8, Side.SERVER);
    network.registerMessage(DiscreteMovementCommandsImplementation.AttackActionMessageHandler.class, DiscreteMovementCommandsImplementation.AttackActionMessage.class, 9, Side.SERVER);
}
项目:Proyecto-DASI    文件:MalmoMod.java   
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
    if (!SchemaHelper.testSchemaVersionNumbers(Loader.instance().activeModContainer().getVersion()))
        throw new RuntimeException("This mod has been incorrectly built; check schema version numbers.");

    if (event.getModMetadata().version.equals("${version}"))
    {
        // The mcmod.info version number is populated by gradle; if we've been built without gradle,
        // via eclipse say, then we can just use the internal version number instead, which comes to us from the version.properties file.
        // (There's no real benefit to doing this; it just looks nicer in the Mod GUI if the version number is filled in.)
        event.getModMetadata().version = Loader.instance().activeModContainer().getVersion();
    }
    // Load the correct configs (client or server)
    File configDir = event.getModConfigurationDirectory();
    File sessionConfigFile = new File(configDir, MODID + event.getSide().toString() + ".cfg");
    File permanentConfigFile = new File(configDir, MODID + event.getSide().toString() + "Permanent.cfg");
    this.sessionConfig = new Configuration(sessionConfigFile);
    this.sessionConfig.load();
    this.permanentConfig = new Configuration(permanentConfigFile);
    this.permanentConfig.load();

    AddressHelper.update(this.sessionConfig);
    ScreenHelper.update(this.permanentConfig);

    network = NetworkRegistry.INSTANCE.newSimpleChannel("Malmo");
    network.registerMessage(ObservationFromFullStatsImplementation.FullStatsRequestMessageHandler.class, ObservationFromFullStatsImplementation.FullStatsRequestMessage.class, 1, Side.SERVER);
    network.registerMessage(ObservationFromGridImplementation.GridRequestMessageHandler.class, ObservationFromGridImplementation.GridRequestMessage.class, 2, Side.SERVER);
    network.registerMessage(MalmoMessageHandler.class, MalmoMessage.class, 3, Side.CLIENT); // Malmo messages from server to client
    network.registerMessage(SimpleCraftCommandsImplementation.CraftMessageHandler.class, SimpleCraftCommandsImplementation.CraftMessage.class, 4, Side.SERVER);
    network.registerMessage(AbsoluteMovementCommandsImplementation.TeleportMessageHandler.class, AbsoluteMovementCommandsImplementation.TeleportMessage.class, 5, Side.SERVER);
    network.registerMessage(MalmoMessageHandler.class, MalmoMessage.class, 6, Side.SERVER); // Malmo messages from client to server
    network.registerMessage(InventoryCommandsImplementation.InventoryMessageHandler.class, InventoryCommandsImplementation.InventoryMessage.class, 7, Side.SERVER);
    network.registerMessage(DiscreteMovementCommandsImplementation.UseActionMessageHandler.class, DiscreteMovementCommandsImplementation.UseActionMessage.class, 8, Side.SERVER);
    network.registerMessage(DiscreteMovementCommandsImplementation.AttackActionMessageHandler.class, DiscreteMovementCommandsImplementation.AttackActionMessage.class, 9, Side.SERVER);
}
项目:Pangu    文件:PanguCore.java   
/**
 *  ==============================
 *        FML Initialization
 *  ==============================
 */

@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
    // Init the network
    network = NetworkRegistry.INSTANCE.newSimpleChannel(MODID);

    proxy.preInit(event);
}