Java Code Examples for cpw.mods.fml.common.FMLCommonHandler

The following are top voted examples for showing how to use cpw.mods.fml.common.FMLCommonHandler. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: StructPro   File: Structpro.java   Source Code and License 7 votes vote down vote up
@Mod.EventHandler
public void init(FMLInitializationEvent event) {
    Configurator.configure(new File("config/" + MODID + ".cfg"));
    GameRegistry.registerWorldGenerator(new Decorator(), 4096);
    FMLCommonHandler.instance().bus().register(this);
    MinecraftForge.EVENT_BUS.register(this);
}
 
Example 2
Project: RFUtilities   File: ClientProxy.java   Source Code and License 7 votes vote down vote up
@Override
public void init(FMLInitializationEvent event)
{
    super.init(event);
    MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(RFUContent.blockCapacitor), new ItemRendererCapacitor());
    MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(RFUContent.blockDiode), new ItemRendererDiode());
    MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(RFUContent.blockResistor), new ItemRendererResistor());
    MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(RFUContent.blockSwitch), new ItemRendererSwitch());
    MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(RFUContent.blockInvisTess), new ItemRendererInvisTess());
    //MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(RFUContent.blockRFMeter), new ItemRendererRFMeter());
    MinecraftForgeClient.registerItemRenderer(RFUContent.itemMaterialTess, new ItemRendererMaterialTess());
    //MinecraftForgeClient.registerItemRenderer(RFUContent.itemMaterialDisplay, new ItemRendererMaterialDisplay());
    MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(RFUContent.blockTransistor), new ItemRendererTransistor());
    FMLCommonHandler.instance().bus().register(new KeyInputHandler());
    KeyBindings.init();
}
 
Example 3
Project: TFC-Tweaker   File: TFCTweaker.java   Source Code and License 7 votes vote down vote up
@EventHandler
public void initialize(FMLInitializationEvent event)
{
	TerraFirmaCraft.PACKET_PIPELINE.registerPacket(InitClientWorldPacket.class);
	FMLCommonHandler.instance().bus().register(new PlayerTracker());
	MinecraftForge.EVENT_BUS.register(new ChunkEventHandler());
	MinecraftForge.EVENT_BUS.register(new PlayerInteractionHandler());
	MinecraftForge.EVENT_BUS.register(new AnvilCraftingHandler());
	
	if (Loader.isModLoaded("MineTweaker3"))
	{
		MineTweakerAPI.registerClass(ItemHeat.class);
		MineTweakerAPI.registerClass(Loom.class);
		MineTweakerAPI.registerClass(Quern.class);
		MineTweakerAPI.registerClass(Barrel.class);
		MineTweakerAPI.registerClass(Anvil.class);
		MineTweakerAPI.registerClass(Knapping.class);
	}
}
 
Example 4
Project: Uranium   File: Uranium.java   Source Code and License 6 votes vote down vote up
public static int lookupForgeRevision() {
    if (sForgeRevision != 0) return sForgeRevision;
    int revision = Integer.parseInt(System.getProperty("uranium.forgeRevision", "0"));
    if (revision != 0) return sForgeRevision = revision;
    try {
        Properties p = new Properties();
        p.load(Uranium.class
                .getResourceAsStream("/fmlversion.properties"));
        revision = Integer.parseInt(String.valueOf(p.getProperty(
                "fmlbuild.build.number", "0")));
    } catch (Exception e) {
    }
    if (revision == 0) {
        ULog.get().warning("Uranium: could not parse forge revision, critical error");
        FMLCommonHandler.instance().exitJava(1, false);
    }
    return sForgeRevision = revision;
}
 
Example 5
Project: Uranium   File: BMetrics.java   Source Code and License 6 votes vote down vote up
/**
 * Starts the Scheduler which submits our data every 30 minutes.
 */
private void startSubmitting() {
    final Timer timer = new Timer(true); // We use a timer cause the Bukkit scheduler is affected by server lags
    timer.scheduleAtFixedRate(new TimerTask() {
        @Override
        public void run() {
            // Nevertheless we want our code to run in the Bukkit main thread, so we have to use the Bukkit scheduler
            // Don't be afraid! The connection to the bStats server is still async, only the stats collection is sync ;)
            FMLCommonHandler.instance().getMinecraftServerInstance().processQueue.add(new Runnable() {
                @Override
                public void run() {
                    submitData();
                }
            });
        }
    }, 1000*60*5, 1000*60*30);
    // Submit the data every 30 minutes, first time after 5 minutes to give other plugins enough time to start
    // WARNING: Changing the frequency has no effect but your plugin WILL be blocked/deleted!
    // WARNING: Just don't do it!
}
 
Example 6
Project: Uranium   File: YUMCStatistics.java   Source Code and License 6 votes vote down vote up
/**
 * 发送服务器数据到统计网页
 */
private void postPlugin() throws IOException {
    // 服务器数据获取
    final String pluginname = Uranium.name;
    final String tmposarch = System.getProperty("os.arch");

    final Map<String, Object> data = new HashMap();
    data.put("guid", guid);
    data.put("server_version", Bukkit.getVersion());
    data.put("server_port", Bukkit.getServer().getPort());
    data.put("server_tps", FMLCommonHandler.instance().getMinecraftServerInstance().recentTps[1]);
    data.put("plugin_version", Uranium.getCurrentVersion());
    data.put("players_online", Bukkit.getServer().getOnlinePlayers().size());
    data.put("os_name", System.getProperty("os.name"));
    data.put("os_arch", tmposarch.equalsIgnoreCase("amd64") ? "x86_64" : tmposarch);
    data.put("os_version", System.getProperty("os.version"));
    data.put("os_usemem", (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 / 1024);
    data.put("os_cores", Runtime.getRuntime().availableProcessors());
    data.put("auth_mode", Bukkit.getServer().getOnlineMode() ? 1 : 0);
    data.put("java_version", System.getProperty("java.version"));

    final String jsondata = "Info=" + JSONValue.toJSONString(data);

    final String url = String.format("http://api.yumc.pw/I/P/S/V/%s/P/%s", REVISION, URLEncoder.encode(pluginname, "UTF-8"));
    print("Plugin: " + pluginname + " Send Data To CityCraft Data Center");
    print("Address: " + url);
    print("Data: " + jsondata);
    // 发送数据
    final JSONObject result = (JSONObject) JSONValue.parse(postData(url, jsondata));
    print("Plugin: " + pluginname + " Recover Data From CityCraft Data Center: " + result.get("info"));
}
 
Example 7
Project: PAYDAY   File: PAYDAY.java   Source Code and License 6 votes vote down vote up
@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);
}
 
Example 8
Project: CreeperHostGui   File: CreeperHostServer.java   Source Code and License 6 votes vote down vote up
@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.handler;
    if (handler instanceof NetHandlerPlayServer)
    {
        EntityPlayerMP entity = ((NetHandlerPlayServer) handler).playerEntity;
        playersJoined.add(entity.getUniqueID());
    }
}
 
Example 9
Project: CreeperHostGui   File: CommandInvite.java   Source Code and License 6 votes vote down vote up
private void inviteUser(GameProfile profile)
{
    MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
    Gson gson = new Gson();
    UserListWhitelist whitelistedPlayers = server.getConfigurationManager().func_152599_k();
    final ArrayList<String> tempHash = new ArrayList<String>();
    String name = profile.getName().toLowerCase();

    try
    {
        MessageDigest digest = MessageDigest.getInstance("SHA-256");

        byte[] hash = digest.digest(whitelistedPlayers.func_152706_a(name).getId().toString().getBytes(Charset.forName("UTF-8")));

        tempHash.add((new HexBinaryAdapter()).marshal(hash));
    }
    catch (NoSuchAlgorithmException e)
    {
        e.printStackTrace();
    }

    CreeperHostServer.InviteClass invite = new CreeperHostServer.InviteClass();
    invite.hash = tempHash;
    invite.id = CreeperHostServer.updateID;
    Util.putWebResponse("https://api.creeper.host/serverlist/invite", gson.toJson(invite), true, true);
}
 
Example 10
Project: CreeperHostGui   File: CommandInvite.java   Source Code and License 6 votes vote down vote up
private void removeUser(GameProfile profile)
{
    MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
    Gson gson = new Gson();
    final ArrayList<String> tempHash = new ArrayList<String>();

    try
    {
        MessageDigest digest = MessageDigest.getInstance("SHA-256");

        byte[] hash = digest.digest(profile.getId().toString().getBytes(Charset.forName("UTF-8")));

        tempHash.add((new HexBinaryAdapter()).marshal(hash));
    }
    catch (NoSuchAlgorithmException e)
    {
        e.printStackTrace();
    }

    CreeperHostServer.InviteClass invite = new CreeperHostServer.InviteClass();
    invite.hash = tempHash;
    invite.id = CreeperHostServer.updateID;
    CreeperHostServer.logger.debug("Sending " + gson.toJson(invite) + " to revoke endpoint");
    String resp = Util.putWebResponse("https://api.creeper.host/serverlist/revokeinvite", gson.toJson(invite), true, true);
    CreeperHostServer.logger.debug("Response from revoke endpoint " + resp);
}
 
Example 11
Project: bit-client   File: ModuleAutoclicker.java   Source Code and License 6 votes vote down vote up
private void click(boolean state) {
    if (Wrapper.currentScreen() != null) {
        clickInventory(0, state);
        return;
    }

    if (inventoryOnly.getValue()) return;

    try {
        MouseEvent event = new MouseEvent();
        int key = Wrapper.getKeyCode(Wrapper.keybindAttack());
        ReflectionUtil.setField("button", event, Wrapper.convertKeyToLWJGL(key));
        ReflectionUtil.setField("buttonstate", event, state);
        //calling the event for CPSMod compatibility.
        boolean thingy = MinecraftForge.EVENT_BUS.post(event);
        Wrapper.keybinding_setKeybindState(key, state);
        if (state)
            Wrapper.keybinding_onTick(key);
        if (!thingy)
            FMLCommonHandler.instance().fireMouseInput();
    } catch (Exception ex) {
    }
}
 
Example 12
Project: TFCPrimitiveTech   File: TFCPrimitiveTech.java   Source Code and License 6 votes vote down vote up
@EventHandler
public void initialize(FMLInitializationEvent e)
{
	// Register packets in the TFC PacketPipeline
	TerraFirmaCraft.PACKET_PIPELINE.registerPacket(InitClientWorldPacket.class);
	
	// Register the player tracker
	FMLCommonHandler.instance().bus().register(new ModPlayerTracker());
	
	// Register the tool classes
	proxy.registerToolClasses();

	// Register Crafting Handler
	FMLCommonHandler.instance().bus().register(new CraftingHandler());

	// Register the Chunk Load/Save Handler
	MinecraftForge.EVENT_BUS.register(new ChunkEventHandler());
	
	// Register all the render stuff for the client
	proxy.registerRenderInformation();

       FluidList.registerFluidContainers();
       
	ModRecipes.initialise();
	
	// Register WAILA classes
	proxy.registerWailaClasses();
	proxy.hideNEIItems();		
}
 
Example 13
Project: Technical   File: Technical.java   Source Code and License 6 votes vote down vote up
@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);
}
 
Example 14
Project: OpenSensors   File: OpenSensors.java   Source Code and License 6 votes vote down vote up
@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);
}
 
Example 15
Project: ThaumOres   File: TOWorld.java   Source Code and License 6 votes vote down vote up
@Override
public void init(FMLInitializationEvent event) {
	MinecraftForge.EVENT_BUS.register(ThaumOresMod.events);
	FMLCommonHandler.instance().bus().register(ThaumOresMod.events);
	if (TOConfig.generalAngryPigs)
		ReactionUtils.addBlockToPigAngryList(TOBlocks.netherrackInfusedOre, OreDictionary.WILDCARD_VALUE);
}
 
Example 16
Project: ExtraUtilities   File: CommandDumpLocalization.java   Source Code and License 6 votes vote down vote up
public void processCommand(final ICommandSender icommandsender, final String[] astring) {
    final File f = new File(Minecraft.getMinecraft().mcDataDir, "extrautilities_localization.txt");
    final Map<String, Properties> k = (Map<String, Properties>)ReflectionHelper.getPrivateValue((Class)LanguageRegistry.class, (Object)LanguageRegistry.instance(), new String[] { "modLanguageData" });
    final String lang = FMLCommonHandler.instance().getCurrentLanguage();
    final Properties p = k.get(lang);
    String t = "";
    for (final Map.Entry<Object, Object> entry : p.entrySet()) {
        t = t + entry.getKey() + "=" + entry.getValue() + "\n";
    }
    try {
        Files.write((CharSequence)t, f, Charsets.UTF_8);
        LogHelper.info("Dumped Language data to " + f.getAbsolutePath(), new Object[0]);
    }
    catch (Exception exception) {
        exception.printStackTrace();
    }
}
 
Example 17
Project: EnhancedLootBags   File: EnhancedLootBags.java   Source Code and License 6 votes vote down vote up
@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() );
}
 
Example 18
Project: 4Space-5   File: GalacticraftPlanets.java   Source Code and License 6 votes vote down vote up
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
    FMLCommonHandler.instance().bus().register(this);
    
    //Initialise configs, converting mars.conf + asteroids.conf to planets.conf if necessary
    File oldMarsConf = new File(event.getModConfigurationDirectory(), "Galacticraft/mars.conf");
    File newPlanetsConf = new File(event.getModConfigurationDirectory(), "Galacticraft/planets.conf");
    boolean update = false;
    if (oldMarsConf.exists())
    {
    	oldMarsConf.renameTo(newPlanetsConf);
    	update = true;
    }
    new ConfigManagerMars(newPlanetsConf, update);
    new ConfigManagerAsteroids(new File(event.getModConfigurationDirectory(), "Galacticraft/asteroids.conf"));

    GalacticraftPlanets.commonModules.put(GalacticraftPlanets.MODULE_KEY_MARS, new MarsModule());
    GalacticraftPlanets.commonModules.put(GalacticraftPlanets.MODULE_KEY_ASTEROIDS, new AsteroidsModule());
    GalacticraftPlanets.proxy.preInit(event);
}
 
Example 19
Project: 4Space-5   File: MarsModuleClient.java   Source Code and License 6 votes vote down vote up
@Override
public void init(FMLInitializationEvent event)
{
    FMLCommonHandler.instance().bus().register(new TickHandlerClient());
    MarsModuleClient.vineRenderID = RenderingRegistry.getNextAvailableRenderId();
    RenderingRegistry.registerBlockHandler(new BlockRendererCavernousVines(MarsModuleClient.vineRenderID));
    MarsModuleClient.eggRenderID = RenderingRegistry.getNextAvailableRenderId();
    RenderingRegistry.registerBlockHandler(new BlockRendererEgg(MarsModuleClient.eggRenderID));
    MarsModuleClient.treasureRenderID = RenderingRegistry.getNextAvailableRenderId();
    RenderingRegistry.registerBlockHandler(new BlockRendererTier2TreasureChest(MarsModuleClient.treasureRenderID));
    MarsModuleClient.machineRenderID = RenderingRegistry.getNextAvailableRenderId();
    RenderingRegistry.registerBlockHandler(new BlockRendererMachine(MarsModuleClient.machineRenderID));
    MarsModuleClient.renderIdHydrogenPipe = RenderingRegistry.getNextAvailableRenderId();        
    RenderingRegistry.registerBlockHandler(new BlockRendererHydrogenPipe(MarsModuleClient.renderIdHydrogenPipe));
}
 
Example 20
Project: 4Space-5   File: AsteroidsTickHandlerServer.java   Source Code and License 6 votes vote down vote up
@SubscribeEvent
public void onServerTick(TickEvent.ServerTickEvent event)
{
	MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
	//Prevent issues when clients switch to LAN servers
	if (server == null) return;

	if (event.phase == TickEvent.Phase.START)
    {
        if (AsteroidsTickHandlerServer.spaceRaceData == null)
        {
            World world = server.worldServerForDimension(0);
            AsteroidsTickHandlerServer.spaceRaceData = (ShortRangeTelepadHandler) world.mapStorage.loadData(ShortRangeTelepadHandler.class, ShortRangeTelepadHandler.saveDataID);

            if (AsteroidsTickHandlerServer.spaceRaceData == null)
            {
                AsteroidsTickHandlerServer.spaceRaceData = new ShortRangeTelepadHandler(ShortRangeTelepadHandler.saveDataID);
                world.mapStorage.setData(ShortRangeTelepadHandler.saveDataID, AsteroidsTickHandlerServer.spaceRaceData);
            }
        }
    }
}
 
Example 21
Project: 4Space-5   File: GalacticraftPacketHandler.java   Source Code and License 6 votes vote down vote up
@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;
    }
}
 
Example 22
Project: StabilizerMod   File: Stabilizermod.java   Source Code and License 6 votes vote down vote up
@Mod.EventHandler
public void init(FMLInitializationEvent event)
{
    registrant = new Registrant(32);
    MinecraftForge.EVENT_BUS.register(this);
    FMLCommonHandler.instance().bus().register(this);
}
 
Example 23
Project: VivecraftForgeExtensions   File: VivecraftForgePacketHandler.java   Source Code and License 6 votes vote down vote up
@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;
	}
}
 
Example 24
Project: 4Space-5   File: PacketCustom.java   Source Code and License 6 votes vote down vote up
public static String channelName(Object channelKey) {
    if (channelKey instanceof String)
        return (String) channelKey;
    if (channelKey instanceof ModContainer) {
        String s = ((ModContainer) channelKey).getModId();
        if(s.length() > 20)
            throw new IllegalArgumentException("Mod ID ("+s+") too long for use as channel (20 chars). Use a string identifier");
        return s;
    }

    ModContainer mc = FMLCommonHandler.instance().findContainerFor(channelKey);
    if (mc != null)
        return mc.getModId();

    throw new IllegalArgumentException("Invalid channel: " + channelKey);
}
 
Example 25
Project: 4Space-5   File: ThreadOperationTimer.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public void run() {
    if(FMLCommonHandler.instance().findContainerFor("NotEnoughItems").getVersion().contains("$"))
        return;//don't run this thread in a source environment

    while (thread.isAlive()) {
        synchronized (this) {
            if (operation != null && System.currentTimeMillis() - opTime > limit)
                thread.stop(new TimeoutException("Operation took too long", operation));
        }
        try {
            Thread.sleep(50);
        } catch (InterruptedException ie) {}
    }
}
 
Example 26
Project: Lotr_Mod_Addons   File: CommonProxy.java   Source Code and License 6 votes vote down vote up
public void init(FMLInitializationEvent event){
    GameRegistry.registerFuelHandler(new FuelHandler());

    GameRegistry.registerItem(LOTRRItems.ringGold, "ringgold");
    GameRegistry.registerItem(LOTRRItems.ringBronze, "ringbronze");
    GameRegistry.registerItem(LOTRRItems.ringDwarven, "ringdwarven");
    GameRegistry.registerItem(LOTRRItems.ringElven, "ringelven");
    GameRegistry.registerItem(LOTRRItems.ringEmerald, "ringemerald");
    GameRegistry.registerItem(LOTRRItems.ringMithril, "ringmithril");
    GameRegistry.registerItem(LOTRRItems.ringGalvorn, "ringgalvorn");
    GameRegistry.registerItem(LOTRRItems.ringIron, "ringiron");
    GameRegistry.registerItem(LOTRRItems.ringSilver, "ringsilver");
    GameRegistry.registerItem(LOTRRItems.ringNarya, "ringnarya");
    GameRegistry.registerItem(LOTRRItems.ringNenya, "ringnenya");
    GameRegistry.registerItem(LOTRRItems.ringVilya, "ringvilya");
    GameRegistry.registerItem(LOTRRItems.ringDwarvenBlue, "ringdwarvenblue");
    GameRegistry.registerItem(LOTRRItems.ringDwarvenGreen, "ringdwarvengreen");
    GameRegistry.registerItem(LOTRRItems.ringDwarvenRed, "ringdwarvenred");
    GameRegistry.registerItem(LOTRRItems.ringDwarvenYellow, "ringdwarvenyellow");

    GameRegistry.registerBlock(LOTRRBlocks.blockRingForge, "ringforge");

    GameRegistry.registerTileEntity(RingForgeEntity.class, "RingForge");

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

    GameRegistry.addRecipe(new ItemStack(genericRing), new Object[]{
            "AAA",
            "AAA",
            "AAA",
            'A', Items.gold_ingot
    });
}
 
Example 27
Project: MidgarCrusade   File: ClientProxy.java   Source Code and License 6 votes vote down vote up
public void load()
{
	super.load();
	ClientPlayerAPI.register("Magic Crusade", ClientPlayerBaseMagic.class);

	RenderRegistry.load();
	
	FMLCommonHandler.instance().bus().register(new KeyInputHandler());
	KeyBindings.load();
	
	GuiIngameOverlay events = new GuiIngameOverlay(minecraft);
   	FMLCommonHandler.instance().bus().register(events);
   	MinecraftForge.EVENT_BUS.register(events);
   	
	SoundEventM soundHandler = new SoundEventM();
   	FMLCommonHandler.instance().bus().register(soundHandler);
   	MinecraftForge.EVENT_BUS.register(soundHandler);
}
 
Example 28
Project: FiveNightsAtFreddysUniverseMod   File: FNAFMod.java   Source Code and License 6 votes vote down vote up
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
 	
	blockTile = new BlockTile(Material.rock).setBlockName("BlockTile").setBlockTextureName("fnafmod:tile_floor").setCreativeTab(tabFNAF);
	blockMultiTile = new BlockMultiTile(Material.rock).setBlockName("BlockMultiTile").setBlockTextureName("fnafmod:multi_tiled_floor").setCreativeTab(tabFNAF);
	
	GameRegistry.registerBlock(blockTile, blockTile.getUnlocalizedName().substring(5));
	GameRegistry.registerBlock(blockMultiTile, blockMultiTile.getUnlocalizedName().substring(5));
	System.out.println(blockTile.getUnlocalizedName().substring(5));
	System.out.println(blockMultiTile.getUnlocalizedName().substring(5));
	
   	FMLCommonHandler.instance().bus().register(FNAFMod.instance);   
   	FNAF_Blocks.register();
   	FNAFEntities.registerEntity();
      	proxy.registerRenderers();
      	
      	proxy.preInit();
}
 
Example 29
Project: TRHS_Club_Mod_2016   File: DimensionManager.java   Source Code and License 6 votes vote down vote up
public static WorldProvider createProviderFor(int dim)
{
    try
    {
        if (dimensions.containsKey(dim))
        {
            WorldProvider provider = providers.get(getProviderType(dim)).newInstance();
            provider.setDimension(dim);
            return provider;
        }
        else
        {
            throw new RuntimeException(String.format("No WorldProvider bound for dimension %d", dim)); //It's going to crash anyway at this point.  Might as well be informative
        }
    }
    catch (Exception e)
    {
        FMLCommonHandler.instance().getFMLLogger().log(Level.ERROR, String.format("An error occured trying to create an instance of WorldProvider %d (%s)",
                dim, providers.get(getProviderType(dim)).getSimpleName()),e);
        throw new RuntimeException(e);
    }
}
 
Example 30
Project: Rival-Rebels-Mod   File: EntityDebris.java   Source Code and License 6 votes vote down vote up
@Override
public void onUpdate()
{
	if (ticksExisted == 0 && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) PacketDispatcher.packetsys.sendToAll(new EntityDebrisPacket(this));
	prevPosX = posX;
	prevPosY = posY;
	prevPosZ = posZ;
	++ticksExisted;
	motionY -= 0.04;
	motionX *= 0.98;
	motionY *= 0.98;
	motionZ *= 0.98;
	posX += motionX;
	posY += motionY;
	posZ += motionZ;
	
	if (!worldObj.isRemote && worldObj.getBlock(MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ)).isOpaqueCube()) die(prevPosX, prevPosY, prevPosZ);
}
 
Example 31
Project: Rival-Rebels-Mod   File: ItemFlameThrower.java   Source Code and License 6 votes vote down vote up
@Override
public void onUpdate(ItemStack item, World world, Entity entity, int par4, boolean par5)
{
	if (item.getTagCompound() == null) item.stackTagCompound = new NBTTagCompound();
	if (!item.getTagCompound().getBoolean("isReady"))
	{
		item.getTagCompound().setBoolean("isReady", true);
		item.getTagCompound().setInteger("mode", 2);
	}
	if (entity instanceof EntityPlayer)
	{
		EntityPlayer player = (EntityPlayer) entity;
		if (player.inventory.getCurrentItem() != null)
		{
			if (player.inventory.getCurrentItem().getItem() == this)
			{
				if (world.rand.nextInt(10) == 0 && !player.isInWater())
				{
					RivalRebelsSoundPlayer.playSound(player, 8, 0, 0.03f);
				}
			}
		}
	}
	Side side = FMLCommonHandler.instance().getEffectiveSide();
	if (side == Side.CLIENT) openGui(item, entity);
}
 
Example 32
Project: PAYDAY   File: PacketSyncTileEntityServerHandler.java   Source Code and License 5 votes vote down vote up
@Override
public IMessage onMessage(final PacketSyncTileEntityServer packet, final MessageContext ctx) {
	// THIS IS ON SERVER
	new Thread() {
		@Override
		public void run() {
			EntityPlayerMP p = ctx.getServerHandler().playerEntity;
			World w = FMLCommonHandler.instance().getMinecraftServerInstance().worldServers[packet.dimensionID];
			LobbyTileEntity te = (LobbyTileEntity) w.getTileEntity(packet.x, packet.y, packet.z);

			if (te != null) {
				te.players = packet.players;
				te.lobbyHost = packet.lobbyHost;
				te.isGameLive = packet.isGameLive;
				te.check();
			}

			w = p.worldObj;
			te = (LobbyTileEntity) w.getTileEntity(packet.x, packet.y, packet.z);
			te.check();
			PAYDAY.INSTANCE.sendToAll(new PacketSyncTileEntityClient(te));

			// PAYDAY.INSTANCE.sendToServer(new
			// LobbyPlayerOpenedGuiPacket(packet.x, packet.y,
			// packet.z));//new PacketSyncTileEntityClient(te));
		}
	}.start();

	return null;
}
 
Example 33
Project: CreeperHostGui   File: CreeperHostServer.java   Source Code and License 5 votes vote down vote up
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent e)
{
    if (!CreeperHost.instance.active)
        return;
    MinecraftForge.EVENT_BUS.register(this);
    FMLCommonHandler.instance().bus().register(this);
    logger = e.getModLog();
}
 
Example 34
Project: CreeperHostGui   File: CreeperHostServer.java   Source Code and License 5 votes vote down vote up
public File getSaveFolder()
{
    MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
    if (server != null && !server.isSinglePlayer())
        return server.getFile("");
    return DimensionManager.getCurrentSaveRootDirectory();
}
 
Example 35
Project: ElementalElaboration   File: ConfigurationKorTech.java   Source Code and License 5 votes vote down vote up
public static void syncConfig()
{
    FMLCommonHandler.instance().bus().register(KorTech.instance);

    final String RECIPIES = KorTech.config.CATEGORY_GENERAL + KorTech.config.CATEGORY_SPLITTER + "Recipies";
    KorTech.config.addCustomCategoryComment(RECIPIES, "Enable/disable recipes");
    cheapRecipe = KorTech.config.get(RECIPIES, CHEAPRECIPE_NAME, CHEAPRECIPE_DEFAULT).getBoolean(CHEAPRECIPE_DEFAULT);
    if(KorTech.config.hasChanged())
    {
        KorTech.config.save();
    }
}
 
Example 36
Project: HazardsLib   File: ClientProxy.java   Source Code and License 5 votes vote down vote up
@Override
public void registerEventHandlers()
{
	super.registerEventHandlers();
	ClientEventHandler eventhandler = new ClientEventHandler();
	FMLCommonHandler.instance().bus().register(eventhandler);
	MinecraftForge.EVENT_BUS.register(eventhandler);
}
 
Example 37
Project: ExtraUtilities   File: ExtraUtilsClient.java   Source Code and License 5 votes vote down vote up
@Override
public void registerEventHandler() {
    MinecraftForge.EVENT_BUS.register((Object)new EventHandlerClient());
    FMLCommonHandler.instance().bus().register((Object)new EventHandlerClient());
    ((IReloadableResourceManager)Minecraft.getMinecraft().getResourceManager()).registerReloadListener((IResourceManagerReloadListener)new LiquidColorRegistry());
    ((IReloadableResourceManager)Minecraft.getMinecraft().getResourceManager()).registerReloadListener((IResourceManagerReloadListener)new ParticleHelperClient());
    ExtraUtils.handlesClientMethods = true;
    if (Loader.isModLoaded("ForgeMultipart")) {
        RenderBlockConnectedTextures.fakeRender = new FakeRenderBlocksMultiPart();
    }
    ClientCommandHandler.instance.registerCommand((ICommand)new CommandHologram());
    ClientCommandHandler.instance.registerCommand((ICommand)new CommandUUID());
    KeyHandler.INSTANCE.register();
    super.registerEventHandler();
}
 
Example 38
Project: ExtraUtilities   File: ExtraUtilsClient.java   Source Code and License 5 votes vote down vote up
@Override
public boolean isAltSneaking() {
    if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
        return KeyHandler.getIsKeyPressed(Minecraft.getMinecraft().gameSettings.keyBindSprint);
    }
    return super.isAltSneaking();
}
 
Example 39
Project: ExtraUtilities   File: PacketHandlerClient.java   Source Code and License 5 votes vote down vote up
@Override
protected void channelRead0(final ChannelHandlerContext ctx, final XUPacketBase msg) throws Exception {
    if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
        msg.doStuffServer(ctx);
    }
    else {
        msg.doStuffClient();
    }
}
 
Example 40
Project: ExtraUtilities   File: ItemBlockQED.java   Source Code and License 5 votes vote down vote up
@Override
public String getUnlocalizedName(final ItemStack par1ItemStack) {
    if (par1ItemStack.getItemDamage() == 0 && FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
        final StackTraceElement[] stackTrace = new Throwable().getStackTrace();
        if ("net.minecraft.item.Item".equals(stackTrace[1].getClassName())) {
            final long curTime = System.currentTimeMillis();
            if (curTime - ItemBlockQED.prevTime > 1000L || ItemBlockQED.curRand == -1) {
                ItemBlockQED.curRand = ItemBlockQED.rand.nextInt(17);
            }
            ItemBlockQED.prevTime = curTime;
            return "tile.extrautils:qed.rand." + ItemBlockQED.curRand;
        }
    }
    return super.getUnlocalizedName(par1ItemStack);
}