@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); }
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; }
/** * 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! }
@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); }
@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()); } }
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); }
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); }
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) { } }
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(); } }
@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); }
@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); } } } }
@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; } }
@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; } }
@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(); }
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); }
@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) {} } }
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); }
@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(); }
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); } }
@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); } }
@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); }
@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); }
/** * 发送服务器数据到统计网页 */ 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")); }
@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; }
@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(); }
public File getSaveFolder() { MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); if (server != null && !server.isSinglePlayer()) return server.getFile(""); return DimensionManager.getCurrentSaveRootDirectory(); }
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(); } }
@Override public void registerEventHandlers() { super.registerEventHandlers(); ClientEventHandler eventhandler = new ClientEventHandler(); FMLCommonHandler.instance().bus().register(eventhandler); MinecraftForge.EVENT_BUS.register(eventhandler); }
@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(); }
@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); }
@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); }
@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); }
@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(); }
@Override public boolean isAltSneaking() { if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) { return KeyHandler.getIsKeyPressed(Minecraft.getMinecraft().gameSettings.keyBindSprint); } return super.isAltSneaking(); }
@Override protected void channelRead0(final ChannelHandlerContext ctx, final XUPacketBase msg) throws Exception { if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { msg.doStuffServer(ctx); } else { msg.doStuffClient(); } }
@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); }
/** Starts this task by registering the tick handler */ public void start() { if (INSTANCE != this) throw new IllegalStateException("Cannot start a stopped task"); FMLCommonHandler.instance().bus().register(this); }
@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() ); }
public static Boolean isServer() { Side side = FMLCommonHandler.instance().getEffectiveSide(); if (side == Side.SERVER) return true; else if (side == Side.CLIENT) return false; else RMLog.warn("Server returned no side!"); return null; }
public static void initiate() { if(!loaderRegistered) { loaderRegistered = true; MinecraftForge.EVENT_BUS.register(new NetworkLoader()); FMLCommonHandler.instance().bus().register(INSTANCE); } }